Repository: rtCamp/snapwp
Pull request #153: update(ci): use snapwp cli to scaffold next application
Author: login: L0RD-ZER0
Created: 2025-04-10T11:00:02Z | Merged: 2025-04-18T09:40:35Z

## What
Updates CI to use SnapWP CLI for scaffolding next application instead of using the examples dir directly.


## How
Use `npx snapwp` after installing the local cli package to scaffold the next application in the ci.


## Additional Info
- After the application is scaffolded, the dependencies are updated to use the local repository packages.


## Checklist
<!--
We encourage you to complete this checklist to the best of your abilities.
If you can't do everything, that's okay too.
Contributing Guidelines: https://github.com/rtCamp/snapwp/blob/develop/.github/CONTRIBUTING.md
-->

-   [x] I have read the [Contribution Guidelines](https://github.com/rtCamp/snapwp/blob/develop/.github/CONTRIBUTING.md).
-   [x] My code is tested to the best of my abilities.
-   [x] My code passes all lints (ESLint, tsc, prettier etc.).
-   [ ] My code has detailed inline documentation.
-   [ ] I have added unit tests to verify the code works as intended.
-   [ ] I have updated the project documentation as needed.
-   [ ] I have added a changeset for this PR using `npm run changeset`.



Diff:
diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml
index 813cc41d..2789e0a2 100644
--- a/.github/workflows/pull_request.yml
+++ b/.github/workflows/pull_request.yml
@@ -195,14 +195,6 @@ jobs:
                   coverageLocations: |
                       ./coverage/lcov.info:lcov
 
-            # - name: Upload coverage to Codecov
-            #   uses: codecov/codecov-action@v5
-            #   with:
-            #       token: ${{ secrets.CODECOV_TOKEN }}
-            #       files: ./coverage/*.json
-            #       flags: unittests
-            #       name: codecov-umbrella
-
     # Reenable when we have playwright tests
     # playwright:
     #     name: E2E Tests (Node v${{ matrix.node-version }})
diff --git a/.github/workflows/pull_request_examples.yml b/.github/workflows/pull_request_examples.yml
index bcaaed56..9d8b3281 100644
--- a/.github/workflows/pull_request_examples.yml
+++ b/.github/workflows/pull_request_examples.yml
@@ -8,6 +8,7 @@ on:
         paths:
             - .github/workflows/pull_request_examples.yml
             - examples/**
+            - packages/**
     push:
         branches:
             - main
@@ -15,13 +16,14 @@ on:
         paths:
             - .github/workflows/pull_request_examples.yml
             - examples/**
+            - packages/**
     # TODO: Remove and replace with real matrix.
     workflow_dispatch:
         inputs:
             NODE_VERSIONS:
                 description: 'Node versions to test against. Need a JSON array of versions.'
                 required: true
-                default: '[20]'
+                default: '[20, 22]'
                 type: string
 
 permissions:
@@ -29,14 +31,15 @@ permissions:
     pull-requests: read
 
 env:
-    #  NODE_VERSIONS: '[18, 20, 22]'
-    NODE_VERSIONS: '[20]'
+    NODE_VERSIONS: '[20, 22]'
     PATHS: |
         nextjs/starter:
           - .github/workflows/pull_request_examples.yml
           - examples/nextjs/starter/**
+          - packages/**
     GRAPHQL_SCHEMA_FILE: '${{ github.workspace }}/schema.graphql'
     SNAPWP_HELPER_REF: 'develop' # TODO: Get from PR description.
+    TEST_APP_DIR: '${{ runner.temp }}/snapwp-test-app' # Use runner.temp to create app outside the main workspace
 
 jobs:
     path-filter:
@@ -50,7 +53,7 @@ jobs:
               with:
                   filters: ${{ env.PATHS }}
         outputs:
-            #TODO: the example shouldn't be hardcoded
+            # TODO: the example shouldn't be hardcoded
             changes: ${{ github.event_name == 'workflow_dispatch' && '["nextjs/starter"]' || steps.filter.outputs.changes }}
 
     generate_schema:
@@ -92,26 +95,47 @@ jobs:
               run: |
                   cp /tmp/schema/schema.graphql ${{ github.workspace }}/schema.graphql
 
-            - name: Build Local packages
+            - name: Build local packages
               run: |
                   cd '${{ github.workspace }}'
                   npm ci --workspaces --include-workspace-root
+                  npm run --if-present local-registry:start
                   npm run --if-present build
+                  npm link snapwp
 
-            - name: Install dependencies
-              working-directory: ${{ github.workspace }}/examples/${{ matrix.example }}
-              run: npm install
+                  # Ensure Verdaccio has the right permissions for CI
+                  touch .verdaccio/conf/htpasswd
+                  sudo chmod 666 .verdaccio/conf/htpasswd  # Required so verdaccio container can add our user
+                  mkdir -p .verdaccio/storage/
+                  sudo chmod 777 .verdaccio/storage/
+                  sudo chmod 777 .verdaccio/
 
-            - name: Copy .env.example to .env
-              working-directory: ${{ github.workspace }}/examples/${{ matrix.example }}
+                  npm run --if-present publish:local
+
+                  # Create test app directory outside of workspace
+                  mkdir -p ${{ env.TEST_APP_DIR }}
+
+            - name: Scaffold ${{ matrix.example }} App
+              working-directory: ${{ env.TEST_APP_DIR }}
               run: |
-                  cp .env.example .env
+                  cp '${{ github.workspace }}/examples/${{ matrix.example }}/.env.example' .env
                   sed -i 's|NEXT_PUBLIC_WP_HOME_URL=.*|NEXT_PUBLIC_WP_HOME_URL=http://localhost|' .env
+                  npm i '${{ github.workspace }}/packages/cli' --no-save
+                  npx snapwp <<< '.'
+                  npm i
 
             - name: Run ESLint
-              working-directory: ${{ github.workspace }}/examples/${{ matrix.example }}
+              working-directory: ${{ env.TEST_APP_DIR }}
               run: npm run --if-present lint
 
+            - name: Clean up
+              if: always()
+              continue-on-error: true
+              run: |
+                  cd '${{ github.workspace }}'
+                  npm run --if-present local-registry:stop
+                  rm -rf ${{ env.TEST_APP_DIR }}
+
     typecheck:
         name: TS Typecheck
         runs-on: ubuntu-latest
@@ -143,32 +167,51 @@ jobs:
               run: |
                   cp /tmp/schema/schema.graphql ${{ github.workspace }}/schema.graphql
 
-            # TODO: figure out overriding installed dependency for local one for testing
-            - name: Build Local packages
+            - name: Build local packages
               run: |
                   cd '${{ github.workspace }}'
                   npm ci --workspaces --include-workspace-root
+                  npm run --if-present local-registry:start
                   npm run --if-present build
+                  npm link snapwp
+
+                  # Ensure Verdaccio has the right permissions for CI
+                  touch .verdaccio/conf/htpasswd
+                  sudo chmod 666 .verdaccio/conf/htpasswd  # Required so verdaccio container can add our user
+                  mkdir -p .verdaccio/storage/
+                  sudo chmod 777 .verdaccio/storage/
+                  sudo chmod 777 .verdaccio/
 
-            - name: Install dependencies
-              working-directory: ${{ github.workspace }}/examples/${{ matrix.example }}
-              run: npm install
+                  npm run --if-present publish:local
 
-            - name: Copy .env.example to .env
-              working-directory: ${{ github.workspace }}/examples/${{ matrix.example }}
+                  # Create test app directory outside of workspace
+                  mkdir -p ${{ env.TEST_APP_DIR }}
+
+            - name: Scaffold ${{ matrix.example }} App
+              working-directory: ${{ env.TEST_APP_DIR }}
               run: |
-                  cp .env.example .env
+                  cp '${{ github.workspace }}/examples/${{ matrix.example }}/.env.example' .env
                   sed -i 's|NEXT_PUBLIC_WP_HOME_URL=.*|NEXT_PUBLIC_WP_HOME_URL=http://localhost|' .env
+                  snapwp --proxy <<< '.'
+                  npm i
 
             - name: Run Codegen
-              working-directory: ${{ github.workspace }}/examples/${{ matrix.example }}
+              working-directory: ${{ env.TEST_APP_DIR }}
               run: npm run codegen
 
             - name: Run TypeScript type check
               # TODO: Why are we catching the error?
-              working-directory: ${{ github.workspace }}/examples/${{ matrix.example }}
+              working-directory: ${{ env.TEST_APP_DIR }}
               run: npm run --if-present typecheck
 
+            - name: Clean up
+              if: always()
+              continue-on-error: true
+              run: |
+                  cd '${{ github.workspace }}'
+                  npm run --if-present local-registry:stop
+                  rm -rf ${{ env.TEST_APP_DIR }}
+
     test-build:
         name: Test Build (Node v${{ matrix.node-version }} | ${{ matrix.example }})
         runs-on: ubuntu-latest
@@ -242,27 +285,46 @@ jobs:
                   sleep 3
                   curl -IL http://localhost  # Verify that the server is running; will fail and exit workflow if not
 
-            # TODO: figure out overriding installed dependency for local one for testing
-            - name: Build Local packages
+            - name: Build local packages
               run: |
                   cd '${{ github.workspace }}'
                   npm ci --workspaces --include-workspace-root
+                  npm run --if-present local-registry:start
                   npm run --if-present build
+                  npm link snapwp
+
+                  # Ensure Verdaccio has the right permissions for CI
+                  touch .verdaccio/conf/htpasswd
+                  sudo chmod 666 .verdaccio/conf/htpasswd  # Required so verdaccio container can add our user
+                  mkdir -p .verdaccio/storage/
+                  sudo chmod 777 .verdaccio/storage/
+                  sudo chmod 777 .verdaccio/
+
+                  npm run --if-present publish:local
 
-            - name: Install dependencies
-              working-directory: ${{ github.workspace }}/examples/${{ matrix.example }}
-              run: npm install
+                  # Create test app directory outside of workspace
+                  mkdir -p ${{ env.TEST_APP_DIR }}
 
-            - name: Copy .env.example to .env
-              working-directory: ${{ github.workspace }}/examples/${{ matrix.example }}
+            - name: Scaffold ${{ matrix.example }} App
+              working-directory: ${{ env.TEST_APP_DIR }}
               run: |
-                  cp .env.example .env
+                  cp '${{ github.workspace }}/examples/${{ matrix.example }}/.env.example' .env
                   sed -i 's|NEXT_PUBLIC_WP_HOME_URL=.*|NEXT_PUBLIC_WP_HOME_URL=http://localhost|' .env
+                  snapwp --proxy <<< '.'
+                  npm i
 
             - name: Build assets
-              working-directory: ${{ github.workspace }}/examples/${{ matrix.example }}
+              working-directory: ${{ env.TEST_APP_DIR }}
               run: npm run --if-present build
 
+            - name: Clean up
+              if: always()
+              continue-on-error: true
+              run: |
+                  cd '${{ github.workspace }}'
+                  npm run --if-present local-registry:stop
+                  rm -rf ${{ env.TEST_APP_DIR }}
+
     unit:
         name: Unit Tests (Node v${{ matrix.node-version }} | ${{ matrix.example }})
         runs-on: ubuntu-latest
@@ -295,27 +357,46 @@ jobs:
               run: |
                   cp /tmp/schema/schema.graphql ${{ github.workspace }}/schema.graphql
 
-              # TODO: figure out overriding installed dependency for local one for testing
-            - name: Build Local packages
+            - name: Build local packages
               run: |
                   cd '${{ github.workspace }}'
                   npm ci --workspaces --include-workspace-root
+                  npm run --if-present local-registry:start
                   npm run --if-present build
+                  npm link snapwp
 
-            - name: Install dependencies
-              working-directory: ${{ github.workspace }}/examples/${{ matrix.example }}
-              run: npm install
+                  # Ensure Verdaccio has the right permissions for CI
+                  touch .verdaccio/conf/htpasswd
+                  sudo chmod 666 .verdaccio/conf/htpasswd  # Required so verdaccio container can add our user
+                  mkdir -p .verdaccio/storage/
+                  sudo chmod 777 .verdaccio/storage/
+                  sudo chmod 777 .verdaccio/
 
-            - name: Copy .env.example to .env
-              working-directory: ${{ github.workspace }}/examples/${{ matrix.example }}
+                  npm run --if-present publish:local
+
+                  # Create test app directory outside of workspace
+                  mkdir -p ${{ env.TEST_APP_DIR }}
+
+            - name: Scaffold ${{ matrix.example }} App
+              working-directory: ${{ env.TEST_APP_DIR }}
               run: |
-                  cp .env.example .env
+                  cp '${{ github.workspace }}/examples/${{ matrix.example }}/.env.example' .env
                   sed -i 's|NEXT_PUBLIC_WP_HOME_URL=.*|NEXT_PUBLIC_WP_HOME_URL=http://localhost|' .env
+                  snapwp --proxy <<< '.'
+                  npm i
 
             - name: Run unit tests
-              working-directory: ${{ github.workspace }}/examples/${{ matrix.example }}
+              working-directory: ${{ env.TEST_APP_DIR }}
               run: npm run --if-present test
 
+            - name: Clean up
+              if: always()
+              continue-on-error: true
+              run: |
+                  cd '${{ github.workspace }}'
+                  npm run --if-present local-registry:stop
+                  rm -rf ${{ env.TEST_APP_DIR }}
+
     security:
         name: Dependencies Audit
         runs-on: ubuntu-latest
@@ -347,27 +428,46 @@ jobs:
               run: |
                   cp /tmp/schema/schema.graphql ${{ github.workspace }}/schema.graphql
 
-            # TODO: figure out overriding installed dependency for local one for testing
-            - name: Build Local packages
+            - name: Build local packages
               run: |
                   cd '${{ github.workspace }}'
                   npm ci --workspaces --include-workspace-root
+                  npm run --if-present local-registry:start
                   npm run --if-present build
+                  npm link snapwp
+
+                  # Ensure Verdaccio has the right permissions for CI
+                  touch .verdaccio/conf/htpasswd
+                  sudo chmod 666 .verdaccio/conf/htpasswd  # Required so verdaccio container can add our user
+                  mkdir -p .verdaccio/storage/
+                  sudo chmod 777 .verdaccio/storage/
+                  sudo chmod 777 .verdaccio/
 
-            - name: Install dependencies
-              working-directory: ${{ github.workspace }}/examples/${{ matrix.example }}
-              run: npm install
+                  npm run --if-present publish:local
 
-            - name: Copy .env.example to .env
-              working-directory: ${{ github.workspace }}/examples/${{ matrix.example }}
+                  # Create test app directory outside of workspace
+                  mkdir -p ${{ env.TEST_APP_DIR }}
+
+            - name: Scaffold ${{ matrix.example }} App
+              working-directory: ${{ env.TEST_APP_DIR }}
               run: |
-                  cp .env.example .env
+                  cp '${{ github.workspace }}/examples/${{ matrix.example }}/.env.example' .env
                   sed -i 's|NEXT_PUBLIC_WP_HOME_URL=.*|NEXT_PUBLIC_WP_HOME_URL=http://localhost|' .env
+                  snapwp --proxy <<< '.'
+                  npm i
 
             - name: Run npm audit
-              working-directory: ${{ github.workspace }}/examples/${{ matrix.example }}
+              working-directory: ${{ env.TEST_APP_DIR }}
               run: npm audit --audit-level=high
 
+            - name: Clean up
+              if: always()
+              continue-on-error: true
+              run: |
+                  cd '${{ github.workspace }}'
+                  npm run --if-present local-registry:stop
+                  rm -rf ${{ env.TEST_APP_DIR }}
+
     prettier:
         name: Check Formatting
         runs-on: ubuntu-latest
@@ -399,23 +499,42 @@ jobs:
               run: |
                   cp /tmp/schema/schema.graphql ${{ github.workspace }}/schema.graphql
 
-            # TODO: figure out overriding installed dependency for local one for testing
-            - name: Build Local packages
+            - name: Build local packages
               run: |
                   cd '${{ github.workspace }}'
                   npm ci --workspaces --include-workspace-root
+                  npm run --if-present local-registry:start
                   npm run --if-present build
+                  npm link snapwp
+
+                  # Ensure Verdaccio has the right permissions for CI
+                  touch .verdaccio/conf/htpasswd
+                  sudo chmod 666 .verdaccio/conf/htpasswd  # Required so verdaccio container can add our user
+                  mkdir -p .verdaccio/storage/
+                  sudo chmod 777 .verdaccio/storage/
+                  sudo chmod 777 .verdaccio/
+
+                  npm run --if-present publish:local
 
-            - name: Install dependencies
-              working-directory: ${{ github.workspace }}/examples/${{ matrix.example }}
-              run: npm install
+                  # Create test app directory outside of workspace
+                  mkdir -p ${{ env.TEST_APP_DIR }}
 
-            - name: Copy .env.example to .env
-              working-directory: ${{ github.workspace }}/examples/${{ matrix.example }}
+            - name: Scaffold ${{ matrix.example }} App
+              working-directory: ${{ env.TEST_APP_DIR }}
               run: |
-                  cp .env.example .env
+                  cp '${{ github.workspace }}/examples/${{ matrix.example }}/.env.example' .env
                   sed -i 's|NEXT_PUBLIC_WP_HOME_URL=.*|NEXT_PUBLIC_WP_HOME_URL=http://localhost|' .env
+                  snapwp --proxy <<< '.'
+                  npm i
 
             - name: Run Prettier
-              working-directory: ${{ github.workspace }}/examples/${{ matrix.example }}
+              working-directory: ${{ env.TEST_APP_DIR }}
               run: npm run --if-present format-check
+
+            - name: Clean up
+              if: always()
+              continue-on-error: true
+              run: |
+                  cd '${{ github.workspace }}'
+                  npm run --if-present local-registry:stop
+                  rm -rf ${{ env.TEST_APP_DIR }}
diff --git a/bin/publish-local.sh b/bin/publish-local.sh
index df5573bb..f29b8518 100644
--- a/bin/publish-local.sh
+++ b/bin/publish-local.sh
@@ -47,7 +47,7 @@ echo "Deleting previous published packages"
 rm -r ./.verdaccio/storage/*
 
 echo "Publishing workspaces to private registry"
-npm publish --workspaces --registry $registry_url 
+npm publish --workspaces --registry $registry_url --access public  # access public is needed for initial publish (ci)
 
 echo "Logging out"
 npm logout --registry $registry_url


Reviews:
user: login: copilot-pull-request-reviewer[bot]
body: 

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.




state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-04-10T11:20:21Z
user: login: mrrobot47
state: APPROVED
author_association: MEMBER
submitted_at: 2025-04-10T11:59:36Z
user: login: justlevine
state: COMMENTED
author_association: COLLABORATOR
submitted_at: 2025-04-11T02:45:47Z
user: login: ayushnirwal
state: COMMENTED
author_association: COLLABORATOR
submitted_at: 2025-04-11T05:55:00Z
user: login: L0RD-ZER0
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-04-14T13:01:37Z
user: login: L0RD-ZER0
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-04-14T13:05:04Z
user: login: justlevine
state: COMMENTED
author_association: COLLABORATOR
submitted_at: 2025-04-14T13:34:27Z
user: login: justlevine
state: COMMENTED
author_association: COLLABORATOR
submitted_at: 2025-04-14T14:04:41Z
user: login: ayushnirwal
state: COMMENTED
author_association: COLLABORATOR
submitted_at: 2025-04-15T10:58:25Z
user: login: justlevine
state: COMMENTED
author_association: COLLABORATOR
submitted_at: 2025-04-15T17:39:17Z
user: login: mrrobot47
state: APPROVED
author_association: MEMBER
submitted_at: 2025-04-16T14:50:07Z
user: login: justlevine
body: PR is working (I did a bit of cleanup), but as a result, eslint is failing due to a conflict between our dependencies and next/core-web-vitals.

We need to fix that before we can merge this PR.

(I tried and failed a few approaches and then ran out of time).

state: CHANGES_REQUESTED
author_association: COLLABORATOR
submitted_at: 2025-04-16T23:25:27Z
user: login: justlevine
state: COMMENTED
author_association: COLLABORATOR
submitted_at: 2025-04-18T09:34:15Z
user: login: copilot-pull-request-reviewer[bot]
body: ## Pull Request Overview

This PR updates the CI configuration to use the local SnapWP CLI for scaffolding the next application instead of directly using the examples directory. Key changes include:
- Adding the "packages/**" path to trigger workflows.
- Updating Node versions from [20] to [20, 22] in workflow configuration.
- Modifying workflow steps to scaffold the test app using SnapWP CLI with environment changes to create the app outside of the main workspace.

### Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

| File                                   | Description                                                  |
| -------------------------------------- | ------------------------------------------------------------ |
| .github/workflows/pull_request_examples.yml | Updates to workflow steps for building local packages, scaffolding the test app, and adjusting environment variables for SnapWP CLI usage. |
| .github/workflows/pull_request.yml     | Cleanup of commented-out Codecov upload steps and minor adjustments. |




state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-04-18T09:34:52Z
user: login: justlevine
state: COMMENTED
author_association: COLLABORATOR
submitted_at: 2025-04-18T09:39:42Z
user: login: justlevine
state: APPROVED
author_association: COLLABORATOR
submitted_at: 2025-04-18T09:40:13Z

Review comments:
diff_hunk: @@ -97,19 +99,24 @@ jobs:
                   cd '${{ github.workspace }}'
                   npm ci --workspaces --include-workspace-root
                   npm run --if-present build
+                  mkdir -p snapwp-test-app
 
-            - name: Install dependencies
-              working-directory: ${{ github.workspace }}/examples/${{ matrix.example }}
-              run: npm install
-
-            - name: Copy .env.example to .env
-              working-directory: ${{ github.workspace }}/examples/${{ matrix.example }}
+            - name: Scaffold Snapwp App
+              working-directory: ${{ github.workspace }}/snapwp-test-app
               run: |
-                  cp .env.example .env
+                  cp '${{ github.workspace }}/examples/${{ matrix.example }}/.env.example' .env
                   sed -i 's|NEXT_PUBLIC_WP_HOME_URL=.*|NEXT_PUBLIC_WP_HOME_URL=http://localhost|' .env
+                  npm i '${{ github.workspace }}/packages/cli' --no-save
+                  npx snapwp <<< '.'
+                  npm i
+                  for i in '${{ github.workspace }}/packages/'*; do
path: .github/workflows/pull_request_examples.yml
user: login: Copilot
body: The use of single quotes around the workspace path may prevent shell glob expansion. Consider using double quotes or removing quotes around ${{ github.workspace }} to ensure the glob pattern is expanded correctly.
created_at: 2025-04-10T11:20:20Z
author_association: CONTRIBUTOR
diff_hunk: @@ -97,19 +99,24 @@ jobs:
                   cd '${{ github.workspace }}'
                   npm ci --workspaces --include-workspace-root
                   npm run --if-present build
+                  mkdir -p snapwp-test-app
 
-            - name: Install dependencies
-              working-directory: ${{ github.workspace }}/examples/${{ matrix.example }}
-              run: npm install
-
-            - name: Copy .env.example to .env
-              working-directory: ${{ github.workspace }}/examples/${{ matrix.example }}
+            - name: Scaffold Snapwp App
+              working-directory: ${{ github.workspace }}/snapwp-test-app
               run: |
-                  cp .env.example .env
+                  cp '${{ github.workspace }}/examples/${{ matrix.example }}/.env.example' .env
                   sed -i 's|NEXT_PUBLIC_WP_HOME_URL=.*|NEXT_PUBLIC_WP_HOME_URL=http://localhost|' .env
+                  npm i '${{ github.workspace }}/packages/cli' --no-save
+                  npx snapwp <<< '.'
+                  npm i
+                  for i in '${{ github.workspace }}/packages/'*; do
+                      if [ -d "$i" ]; then
+                          npm i "$i"  # Swap snapwp dependencies for local packages
+                      fi
+                  done
path: .github/workflows/pull_request_examples.yml
user: login: justlevine
body: @ayushnirwal / @SH4LIN if there's an _easy_ cleaner way to install local copies of the packages before I merge this spaghetti, please LMK.

Ref: https://rtcamp.slack.com/archives/CK2CEH4F6/p1744296854287099?thread_ts=1744273250.043439&cid=CK2CEH4F6
created_at: 2025-04-11T02:45:45Z
author_association: COLLABORATOR
diff_hunk: @@ -97,19 +99,24 @@ jobs:
                   cd '${{ github.workspace }}'
                   npm ci --workspaces --include-workspace-root
                   npm run --if-present build
+                  mkdir -p snapwp-test-app
 
-            - name: Install dependencies
-              working-directory: ${{ github.workspace }}/examples/${{ matrix.example }}
-              run: npm install
-
-            - name: Copy .env.example to .env
-              working-directory: ${{ github.workspace }}/examples/${{ matrix.example }}
+            - name: Scaffold Snapwp App
+              working-directory: ${{ github.workspace }}/snapwp-test-app
path: .github/workflows/pull_request_examples.yml
user: login: ayushnirwal
body: @L0RD-ZER0 This is what I do to scaffold a project to test the command and packages pre publish

```
npm i
npm run build
npm link snapwp
npm run publish:local
snapwp --proxy
```

If a package is linked snapwp is just an command. no need for npx
npm run publish:local publishes to a local registry (verdaccio)
snapwp --proxy There is a (undocumented) flag which tells snapwp to use packages from the local registry.
created_at: 2025-04-11T05:55:00Z
author_association: COLLABORATOR
diff_hunk: @@ -97,19 +99,24 @@ jobs:
                   cd '${{ github.workspace }}'
                   npm ci --workspaces --include-workspace-root
                   npm run --if-present build
+                  mkdir -p snapwp-test-app
 
-            - name: Install dependencies
-              working-directory: ${{ github.workspace }}/examples/${{ matrix.example }}
-              run: npm install
-
-            - name: Copy .env.example to .env
-              working-directory: ${{ github.workspace }}/examples/${{ matrix.example }}
+            - name: Scaffold Snapwp App
+              working-directory: ${{ github.workspace }}/snapwp-test-app
path: .github/workflows/pull_request_examples.yml
user: login: L0RD-ZER0
body: The current CI implementation works by utilizing the template from the local repository and installing the packages in the local repository itself to test them for the applied changes. The resulting workspace created for the CI process closely mirrors the state achieved when using a custom registry with the `--proxy flag`, but without the additional setup required for the custom registry. 

Please review this and confirm if setting up a custom registry is necessary, as there is almost no difference between the two approaches.
created_at: 2025-04-14T13:01:37Z
author_association: CONTRIBUTOR
diff_hunk: @@ -97,19 +99,24 @@ jobs:
                   cd '${{ github.workspace }}'
                   npm ci --workspaces --include-workspace-root
                   npm run --if-present build
+                  mkdir -p snapwp-test-app
 
-            - name: Install dependencies
-              working-directory: ${{ github.workspace }}/examples/${{ matrix.example }}
-              run: npm install
-
-            - name: Copy .env.example to .env
-              working-directory: ${{ github.workspace }}/examples/${{ matrix.example }}
+            - name: Scaffold Snapwp App
+              working-directory: ${{ github.workspace }}/snapwp-test-app
               run: |
-                  cp .env.example .env
+                  cp '${{ github.workspace }}/examples/${{ matrix.example }}/.env.example' .env
                   sed -i 's|NEXT_PUBLIC_WP_HOME_URL=.*|NEXT_PUBLIC_WP_HOME_URL=http://localhost|' .env
+                  npm i '${{ github.workspace }}/packages/cli' --no-save
+                  npx snapwp <<< '.'
+                  npm i
+                  for i in '${{ github.workspace }}/packages/'*; do
path: .github/workflows/pull_request_examples.yml
user: login: L0RD-ZER0
body: This is inserted by the yaml templating engine used by GitHub actions. It does not need shell expansion. Use of single quotes is intentional to eliminate the factor of glob expansions in the path in the first place.
created_at: 2025-04-14T13:05:04Z
author_association: CONTRIBUTOR
diff_hunk: @@ -97,19 +99,24 @@ jobs:
                   cd '${{ github.workspace }}'
                   npm ci --workspaces --include-workspace-root
                   npm run --if-present build
+                  mkdir -p snapwp-test-app
 
-            - name: Install dependencies
-              working-directory: ${{ github.workspace }}/examples/${{ matrix.example }}
-              run: npm install
-
-            - name: Copy .env.example to .env
-              working-directory: ${{ github.workspace }}/examples/${{ matrix.example }}
+            - name: Scaffold Snapwp App
+              working-directory: ${{ github.workspace }}/snapwp-test-app
path: .github/workflows/pull_request_examples.yml
user: login: justlevine
body: As noted in [Slack](https://rtcamp.slack.com/archives/CK2CEH4F6/p1744273250043439) the goal of this PR (and https://github.com/rtCamp/headless/issues/399) is two-fold:

1. to prevent issues like https://github.com/rtCamp/headless/issues/453 
2. to ensure our CI is testing as much of our IRL workflow as possible.

Both of these are accomplished by updating the CI to follow the local scaffolding steps that @ayushnirwal outlined below.

With that said:

> The resulting workspace created for the CI process closely mirrors the state achieved when using a custom registry with the --proxy flag, but without the additional setup required for the custom registry.

If your argument here is that we can replace the _entire_ use of Verdaccio with a bash script that's just a for-each loop (and @ayushnirwal agrees), then personally I can get behind that because it's one more piece of tech debt that we don't need to test.

If however the CI _only_ "closely mirrors" the local situation, but we still need Verdaccio's `publish:local` and `--proxy` flag IRL, then there would need to be a very strong case made as to why we don't want to be testing our real-world workflow.  

> as there is almost no difference between the two approaches.

If this refers to the effort, then go ahead and change over as described. Otherwise, review any perceived "downsides"/concerns with @mrrobot47 and share back so @ayushnirwal and myself can make an informed decision.
created_at: 2025-04-14T13:34:27Z
author_association: COLLABORATOR
diff_hunk: @@ -97,19 +99,24 @@ jobs:
                   cd '${{ github.workspace }}'
                   npm ci --workspaces --include-workspace-root
                   npm run --if-present build
+                  mkdir -p snapwp-test-app
 
-            - name: Install dependencies
-              working-directory: ${{ github.workspace }}/examples/${{ matrix.example }}
-              run: npm install
-
-            - name: Copy .env.example to .env
-              working-directory: ${{ github.workspace }}/examples/${{ matrix.example }}
+            - name: Scaffold Snapwp App
+              working-directory: ${{ github.workspace }}/snapwp-test-app
               run: |
-                  cp .env.example .env
+                  cp '${{ github.workspace }}/examples/${{ matrix.example }}/.env.example' .env
                   sed -i 's|NEXT_PUBLIC_WP_HOME_URL=.*|NEXT_PUBLIC_WP_HOME_URL=http://localhost|' .env
+                  npm i '${{ github.workspace }}/packages/cli' --no-save
+                  npx snapwp <<< '.'
+                  npm i
+                  for i in '${{ github.workspace }}/packages/'*; do
+                      if [ -d "$i" ]; then
+                          npm i "$i"  # Swap snapwp dependencies for local packages
+                      fi
+                  done
path: .github/workflows/pull_request_examples.yml
user: login: justlevine
body: https://github.com/rtCamp/snapwp/pull/153#discussion_r2038844575
created_at: 2025-04-14T14:04:41Z
author_association: COLLABORATOR
diff_hunk: @@ -97,19 +99,24 @@ jobs:
                   cd '${{ github.workspace }}'
                   npm ci --workspaces --include-workspace-root
                   npm run --if-present build
+                  mkdir -p snapwp-test-app
 
-            - name: Install dependencies
-              working-directory: ${{ github.workspace }}/examples/${{ matrix.example }}
-              run: npm install
-
-            - name: Copy .env.example to .env
-              working-directory: ${{ github.workspace }}/examples/${{ matrix.example }}
+            - name: Scaffold Snapwp App
+              working-directory: ${{ github.workspace }}/snapwp-test-app
path: .github/workflows/pull_request_examples.yml
user: login: ayushnirwal
body: @L0RD-ZER0 
The downsides I see are - 
- Missing support for other package managers (yarn).
- Missing support for protected access to test packages ( we may plan to keep some libs closed source )
- Long shot, but we may have to test against caching through npm registry. This has caused some errors in scaffolding before because directories are laid out differently.

created_at: 2025-04-15T10:58:25Z
author_association: COLLABORATOR
diff_hunk: @@ -97,19 +99,24 @@ jobs:
                   cd '${{ github.workspace }}'
                   npm ci --workspaces --include-workspace-root
                   npm run --if-present build
+                  mkdir -p snapwp-test-app
 
-            - name: Install dependencies
-              working-directory: ${{ github.workspace }}/examples/${{ matrix.example }}
-              run: npm install
-
-            - name: Copy .env.example to .env
-              working-directory: ${{ github.workspace }}/examples/${{ matrix.example }}
+            - name: Scaffold Snapwp App
+              working-directory: ${{ github.workspace }}/snapwp-test-app
path: .github/workflows/pull_request_examples.yml
user: login: justlevine
body: Per today's sync we're keeping verdaccio and are updating the CI accordingly. 
created_at: 2025-04-15T17:39:17Z
author_association: COLLABORATOR
diff_hunk: @@ -8,35 +8,38 @@ on:
         paths:
             - .github/workflows/pull_request_examples.yml
             - examples/**
+            - packages/**
     push:
         branches:
             - main
             - develop
         paths:
             - .github/workflows/pull_request_examples.yml
             - examples/**
+            - packages/**
     # TODO: Remove and replace with real matrix.
     workflow_dispatch:
         inputs:
             NODE_VERSIONS:
                 description: 'Node versions to test against. Need a JSON array of versions.'
                 required: true
-                default: '[20]'
+                default: '[20, 22]'
                 type: string
 
 permissions:
     contents: read
     pull-requests: read
 
 env:
-    #  NODE_VERSIONS: '[18, 20, 22]'
-    NODE_VERSIONS: '[20]'
+    NODE_VERSIONS: '[20, 22]'
     PATHS: |
         nextjs/starter:
           - .github/workflows/pull_request_examples.yml
           - examples/nextjs/starter/**
+          - packages/**
     GRAPHQL_SCHEMA_FILE: '${{ github.workspace }}/schema.graphql'
     SNAPWP_HELPER_REF: 'develop' # TODO: Get from PR description.
+    TEST_APP_DIR: '${{ runner.temp }}/snapwp-test-app' # Use runner.temp to create app outside the main workspace
path: .github/workflows/pull_request_examples.yml
user: login: justlevine
body: I did not know this was possible. I love it!

@mrrobot47 any concerns we need to be worried about doing it like this?
created_at: 2025-04-18T09:34:14Z
author_association: COLLABORATOR
diff_hunk: @@ -8,35 +8,38 @@ on:
         paths:
             - .github/workflows/pull_request_examples.yml
             - examples/**
+            - packages/**
     push:
         branches:
             - main
             - develop
         paths:
             - .github/workflows/pull_request_examples.yml
             - examples/**
+            - packages/**
     # TODO: Remove and replace with real matrix.
     workflow_dispatch:
         inputs:
             NODE_VERSIONS:
                 description: 'Node versions to test against. Need a JSON array of versions.'
                 required: true
-                default: '[20]'
+                default: '[20, 22]'
                 type: string
 
 permissions:
     contents: read
     pull-requests: read
 
 env:
-    #  NODE_VERSIONS: '[18, 20, 22]'
-    NODE_VERSIONS: '[20]'
+    NODE_VERSIONS: '[20, 22]'
     PATHS: |
         nextjs/starter:
           - .github/workflows/pull_request_examples.yml
           - examples/nextjs/starter/**
+          - packages/**
     GRAPHQL_SCHEMA_FILE: '${{ github.workspace }}/schema.graphql'
     SNAPWP_HELPER_REF: 'develop' # TODO: Get from PR description.
+    TEST_APP_DIR: '${{ runner.temp }}/snapwp-test-app' # Use runner.temp to create app outside the main workspace
path: .github/workflows/pull_request_examples.yml
user: login: justlevine
body: Confirmed via slack : https://rtcamp.slack.com/archives/CK2CEH4F6/p1744969143237679?thread_ts=1744273250.043439&cid=CK2CEH4F6
created_at: 2025-04-18T09:39:42Z
author_association: COLLABORATOR

PR comments:
user: login: changeset-bot[bot]
created_at: 2025-04-10T11:00:06Z
body: ###  ⚠️  No Changeset found

Latest commit: 06eda35615913e43af0ddab789bc76d0b8076cb7

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. **If these changes should result in a version bump, you need to add a changeset.**

<details><summary>This PR includes no changesets</summary>

  When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

</details>

[Click here to learn what changesets are, and how to add one](https://github.com/changesets/changesets/blob/main/docs/adding-a-changeset.md).

[Click here if you're a maintainer who wants to add a changeset to this PR](https://github.com/rtCamp/snapwp/new/ci/use-snapwp-cli?filename=.changeset/gorgeous-horses-heal.md&value=---%0A%0A---%0A%0Aupdate(ci)%3A%20use%20snapwp%20cli%20to%20scaffold%20next%20application%0A)


author_association: NONE
user: login: coveralls
created_at: 2025-04-16T13:26:23Z
body: ## Pull Request Test Coverage Report for [Build 14532356075](https://coveralls.io/builds/73286917)


### Details

* **0** of **0**   changed or added relevant lines in **0** files are covered.
* No unchanged relevant lines lost coverage.
* Overall coverage remained the same at **53.748%**

---



|  Totals | [![Coverage Status](https://coveralls.io/builds/73286917/badge)](https://coveralls.io/builds/73286917) |
| :-- | --: |
| Change from base [Build 14524679315](https://coveralls.io/builds/73281408): |  0.0% |
| Covered Lines: | 400 |
| Relevant Lines: | 661 |

---
##### 💛  - [Coveralls](https://coveralls.io)

author_association: NONE