From b1f674106abdbeba59efd8926175c20e69fb4175 Mon Sep 17 00:00:00 2001 From: Ankur Datta <64993082+ankur-arch@users.noreply.github.com> Date: Wed, 27 Nov 2024 09:15:39 +0600 Subject: [PATCH 1/7] fix(custom): keep existing optimizeDeps values closes #22 and #DA-1782 --- src/module.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/module.ts b/src/module.ts index 90779dc..4336daf 100644 --- a/src/module.ts +++ b/src/module.ts @@ -88,10 +88,12 @@ export default defineNuxtModule({ addServerImportsDir(resolver(runtimeDir, "utils")); addServerImportsDir(resolver(runtimeDir, "server/utils")); - nuxt.options.vite.optimizeDeps ||= {}; - nuxt.options.vite.optimizeDeps = { - include: ["@prisma/nuxt > @prisma/client"], - }; + nuxt.options.vite.optimizeDeps = defu( + nuxt.options.vite.optimizeDeps || {}, + { + include: ["@prisma/nuxt > @prisma/client"], + }, + ); }; const force_skip_prisma_setup = From 1a8144b3be707ae542c64506ff11d5041911528e Mon Sep 17 00:00:00 2001 From: Ankur Datta <64993082+ankur-arch@users.noreply.github.com> Date: Wed, 27 Nov 2024 09:30:26 +0600 Subject: [PATCH 2/7] chore(custom): add workflow to publish to npm on pr to main closes #DA-1783 Issue: #DA-1783 --- .github/workflows/preview-publish.yml | 75 +++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 .github/workflows/preview-publish.yml diff --git a/.github/workflows/preview-publish.yml b/.github/workflows/preview-publish.yml new file mode 100644 index 0000000..5dfa1d9 --- /dev/null +++ b/.github/workflows/preview-publish.yml @@ -0,0 +1,75 @@ +name: Preview Release on PR +on: + pull_request: + branches: + - main +permissions: + contents: write # Required for publishing releases +jobs: + preview-release: + name: Preview Dev Release + runs-on: ubuntu-latest + permissions: + contents: write # For publishing to GitHub releases + id-token: write # For npm provenance + steps: + # Step 1: Checkout the repository + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + # Step 2: Setup Node.js environment + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: "lts/*" + cache: "npm" + + # Step 3: Configure npm for authentication + - name: Configure npm for Authentication + run: | + echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_NUXT_TOKEN }}" >> ~/.npmrc + echo "@prisma:registry=https://registry.npmjs.org/" >> ~/.npmrc + + # Step 4: Install dependencies + - name: Install Dependencies + run: npm clean-install + + # Step 5: Prepare project + - name: Prepare Project + run: npx nuxi prepare + + # Step 6: Build project + - name: Build Project + run: npm run dev:build + + # Step 7: Lint the code + - name: Lint Code + run: npm run lint + + # Step 8: Prepack the project + - name: Prepack + run: npm run prepack + + # Step 9: Audit dependencies + - name: Audit Dependencies + run: npm audit signatures + + # Step 10: Generate and log preview release version + - name: Generate and Log Preview Release Version + id: preview_version + run: | + VERSION="0.0.0-pr-${{ github.event.pull_request.number }}-$(git rev-parse --short HEAD)" + echo "Preview release version: $VERSION" + echo "version=$VERSION" >> $GITHUB_ENV + + # Step 11: Create a preview release + - name: Publish Preview Release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + NPM_TOKEN: ${{ secrets.NPM_NUXT_TOKEN }} + run: | + echo "Publishing preview release ${{ env.version }}" + # Use semantic-release or another tool to publish the preview version + npx semantic-release --no-ci --branches main --tag-format "v${{ env.version }}" From d02c52e3a92d4562c96f5a8d9de308487f56b6b2 Mon Sep 17 00:00:00 2001 From: Ankur Datta <64993082+ankur-arch@users.noreply.github.com> Date: Wed, 27 Nov 2024 09:32:12 +0600 Subject: [PATCH 3/7] chore(custom): remove prompt for prisma studio --- src/module.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/module.ts b/src/module.ts index 4336daf..579945a 100644 --- a/src/module.ts +++ b/src/module.ts @@ -216,7 +216,7 @@ export default defineNuxtModule({ const promptResults = await executeRequiredPrompts({ promptForMigrate: false && !skip_all_prompts, - promptForPrismaStudio: true && !skip_all_prompts, + promptForPrismaStudio: false && !skip_all_prompts, }); if (promptResults?.promptForInstallingStudio) { From f90829f1b84f3db945039c288f34ac67d01e74b4 Mon Sep 17 00:00:00 2001 From: Ankur Datta <64993082+ankur-arch@users.noreply.github.com> Date: Wed, 27 Nov 2024 09:55:08 +0600 Subject: [PATCH 4/7] fix(custom): fix preview workflow error --- .github/workflows/preview-publish.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/preview-publish.yml b/.github/workflows/preview-publish.yml index 5dfa1d9..444a504 100644 --- a/.github/workflows/preview-publish.yml +++ b/.github/workflows/preview-publish.yml @@ -71,5 +71,4 @@ jobs: NPM_TOKEN: ${{ secrets.NPM_NUXT_TOKEN }} run: | echo "Publishing preview release ${{ env.version }}" - # Use semantic-release or another tool to publish the preview version - npx semantic-release --no-ci --branches main --tag-format "v${{ env.version }}" + npx semantic-release --no-ci --branches main --tag-format "v${{version}}-pr-${{ github.event.pull_request.number }}-$(git rev-parse --short HEAD)" From 1d9514e53102b118ed1ad8f970daa9b51153f38f Mon Sep 17 00:00:00 2001 From: Ankur Datta <64993082+ankur-arch@users.noreply.github.com> Date: Wed, 27 Nov 2024 10:29:59 +0600 Subject: [PATCH 5/7] fix(custom): add VERSION env variable --- .github/workflows/preview-publish.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/preview-publish.yml b/.github/workflows/preview-publish.yml index 444a504..6d61b7a 100644 --- a/.github/workflows/preview-publish.yml +++ b/.github/workflows/preview-publish.yml @@ -62,13 +62,14 @@ jobs: run: | VERSION="0.0.0-pr-${{ github.event.pull_request.number }}-$(git rev-parse --short HEAD)" echo "Preview release version: $VERSION" - echo "version=$VERSION" >> $GITHUB_ENV + echo "VERSION=$VERSION" >> $GITHUB_ENV # Step 11: Create a preview release - name: Publish Preview Release env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} NPM_TOKEN: ${{ secrets.NPM_NUXT_TOKEN }} + VERSION: ${{ env.VERSION }} run: | - echo "Publishing preview release ${{ env.version }}" - npx semantic-release --no-ci --branches main --tag-format "v${{version}}-pr-${{ github.event.pull_request.number }}-$(git rev-parse --short HEAD)" + echo "Publishing preview release $VERSION" + npx semantic-release --no-ci --branches main --tag-format "v${VERSION}" From 9000ca50c76275c28b60246a2ee13bbd793e0313 Mon Sep 17 00:00:00 2001 From: Ankur Datta <64993082+ankur-arch@users.noreply.github.com> Date: Wed, 27 Nov 2024 10:41:01 +0600 Subject: [PATCH 6/7] fix: use npm publish instead of semantic release for experimental version --- .github/workflows/preview-publish.yml | 28 ++++++++++----------------- 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/.github/workflows/preview-publish.yml b/.github/workflows/preview-publish.yml index 6d61b7a..6d54f77 100644 --- a/.github/workflows/preview-publish.yml +++ b/.github/workflows/preview-publish.yml @@ -1,4 +1,4 @@ -name: Preview Release on PR +name: Publish Experimental Release on: pull_request: branches: @@ -6,8 +6,8 @@ on: permissions: contents: write # Required for publishing releases jobs: - preview-release: - name: Preview Dev Release + experimental-release: + name: Experimental Dev Release runs-on: ubuntu-latest permissions: contents: write # For publishing to GitHub releases @@ -56,20 +56,12 @@ jobs: - name: Audit Dependencies run: npm audit signatures - # Step 10: Generate and log preview release version - - name: Generate and Log Preview Release Version - id: preview_version - run: | - VERSION="0.0.0-pr-${{ github.event.pull_request.number }}-$(git rev-parse --short HEAD)" - echo "Preview release version: $VERSION" - echo "VERSION=$VERSION" >> $GITHUB_ENV + # Step 10: Set experimental version + - name: Set Experimental Version + run: npm version --no-git-tag-version 0.0.0-experimental-${GITHUB_SHA::7} - # Step 11: Create a preview release - - name: Publish Preview Release + # Step 11: Publish Experimental Release + - name: Publish Experimental Release env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - NPM_TOKEN: ${{ secrets.NPM_NUXT_TOKEN }} - VERSION: ${{ env.VERSION }} - run: | - echo "Publishing preview release $VERSION" - npx semantic-release --no-ci --branches main --tag-format "v${VERSION}" + NODE_AUTH_TOKEN: ${{ secrets.NPM_NUXT_TOKEN }} + run: npm publish --access public --tag experimental From 01e8a0701788f5b3d6335e5d817be3b05bbcdf7c Mon Sep 17 00:00:00 2001 From: Ankur Datta <64993082+ankur-arch@users.noreply.github.com> Date: Wed, 27 Nov 2024 11:23:56 +0600 Subject: [PATCH 7/7] fix: remove unnecessary prompt to start studio --- src/module.ts | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/module.ts b/src/module.ts index 579945a..1f7f600 100644 --- a/src/module.ts +++ b/src/module.ts @@ -214,14 +214,7 @@ export default defineNuxtModule({ return; } - const promptResults = await executeRequiredPrompts({ - promptForMigrate: false && !skip_all_prompts, - promptForPrismaStudio: false && !skip_all_prompts, - }); - - if (promptResults?.promptForInstallingStudio) { - await installAndStartPrismaStudio(); - } + await installAndStartPrismaStudio(); }; if (!prismaSchemaExists) {