Skip to content

Commit

Permalink
Upgrade to pnpm 7 (woocommerce#34661)
Browse files Browse the repository at this point in the history
* Remove -- -- from scripts that fixed issue in pnpm 6, fix a couple TS issues in sep packages
* Minor fixes to analyzer scripts and doco based on pnpm 7
* Add dompurify types to data package to avoid TS errors
* Remove pnpx in favor of pnpm exec
* Modify the code analyzer to respect pnpm version if present.
* Update instructions for running recursive lint, add comments to explain
  • Loading branch information
samueljseay authored Sep 15, 2022
1 parent cd31ec0 commit 04b74c1
Show file tree
Hide file tree
Showing 60 changed files with 4,909 additions and 5,159 deletions.
6 changes: 4 additions & 2 deletions .github/actions/setup-woocommerce-monorepo/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ runs:
- name: Setup PNPM
uses: pnpm/action-setup@10693b3829bf86eb2572aef5f3571dcf5ca9287d
with:
version: 6
version: 7

- name: Setup Node
uses: actions/setup-node@2fddd8803e2f5c9604345a0b591c3020ee971a93
Expand All @@ -51,7 +51,9 @@ runs:

- name: Install Node and PHP Dependencies
shell: bash
run: pnpm install ${{ steps.parse-input.outputs.INSTALL_FILTERS }}
run: |
pnpm -w install turbo
pnpm install ${{ steps.parse-input.outputs.INSTALL_FILTERS }}
- name: Cache Build Output
uses: actions/cache@fd5de65bc895cf536527842281bea11763fefd77
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ jobs:
composer --version
- name: Build Admin feature config
run: pnpm build:feature-config --filter=woocommerce
working-directory: plugins/woocommerce
run: pnpm run build:feature-config

- name: Add PHP8 Compatibility.
run: |
Expand All @@ -72,4 +73,5 @@ jobs:
run: ./tests/bin/install.sh woo_test root root 127.0.0.1 ${{ matrix.wp }}

- name: Run tests
run: pnpm run test --filter="woocommerce" --color
working-directory: plugins/woocommerce
run: pnpm run test --color
6 changes: 3 additions & 3 deletions .github/workflows/pr-build-and-e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ jobs:

- name: Download and install Chromium browser.
working-directory: plugins/woocommerce
run: pnpx playwright install chromium
run: pnpm exec playwright install chromium

- name: Run Playwright E2E tests.
timeout-minutes: 60
id: run_playwright_e2e_tests
env:
USE_WP_ENV: 1
working-directory: plugins/woocommerce
run: pnpx playwright test --config=tests/e2e-pw/playwright.config.js
run: pnpm exec playwright test --config=tests/e2e-pw/playwright.config.js

- name: Generate Playwright E2E Test report.
id: generate_e2e_report
Expand All @@ -42,7 +42,7 @@ jobs:
steps.run_playwright_e2e_tests.conclusion != 'skipped'
)
working-directory: plugins/woocommerce
run: pnpx allure generate --clean e2e/allure-results --output e2e/allure-report
run: pnpm exec allure generate --clean e2e/allure-results --output e2e/allure-report

- name: Archive Playwright E2E test report
if: |
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/pr-code-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@ jobs:
composer --version
- name: Build Admin feature config
run: |
pnpm build:feature-config --filter=woocommerce
working-directory: plugins/woocommerce
run:
pnpm run build:feature-config

- name: Init DB and WP
working-directory: plugins/woocommerce
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/pr-highlight-changes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ jobs:
uses: actions/checkout@v3
- name: Install prerequisites
run: |
npm install -g pnpm@^6.24.2
npm install -g pnpm
npm -g i @wordpress/env@5.1.0
pnpm install --filter code-analyzer --filter cli-core
- name: Run analyzer
id: run
working-directory: tools/code-analyzer
run: |
version=$(pnpm run analyzer --filter code-analyzer -- major-minor "${{ github.head_ref || github.ref_name }}" "plugins/woocommerce/woocommerce.php" | tail -n 1)
pnpm run analyzer --filter code-analyzer -- "$GITHUB_HEAD_REF" $version -o "github"
version=$(pnpm run analyzer major-minor "${{ github.head_ref || github.ref_name }}" "plugins/woocommerce/woocommerce.php" | tail -n 1)
pnpm run analyzer "$GITHUB_HEAD_REF" $version -o "github"
- name: Print results
id: results
run: echo "::set-output name=results::${{ steps.run.outputs.templates }}${{ steps.run.outputs.wphooks }}${{ steps.run.outputs.schema }}${{ steps.run.outputs.database }}"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr-lint-monorepo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ jobs:
run: php tools/monorepo/check-changelogger-use.php --debug "$BASE" "$HEAD"

- name: Run changelog validation
run: pnpm changelog --filter=* -- validate
run: pnpm run -r changelog validate
8 changes: 3 additions & 5 deletions .github/workflows/pr-lint-test-js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,10 @@ jobs:
- uses: actions/checkout@v3

- name: Setup WooCommerce Monorepo
uses: ./.github/actions/setup-woocommerce-monorepo
with:
install-filters: 'woocommerce/client/admin...'
uses: ./.github/actions/setup-woocommerce-monorepo

- name: Lint
run: pnpm run lint --filter='woocommerce/client/admin...' --filter='!@woocommerce/e2e*' --filter='!@woocommerce/api' --color
run: pnpm run -r --filter='woocommerce/client/admin...' --filter='!@woocommerce/e2e*' --filter='!@woocommerce/api' --color lint

- name: Test
run: pnpm run test --filter='woocommerce/client/admin...' --filter='!@woocommerce/e2e*' --filter='!@woocommerce/api' --color
run: pnpm run test --filter='woocommerce/client/admin...' --filter='!@woocommerce/e2e*' --filter='!@woocommerce/api' --color
1 change: 1 addition & 0 deletions .github/workflows/pr-unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,5 @@ jobs:
run: ./tests/bin/install.sh woo_test root root 127.0.0.1 ${{ matrix.wp }}

- name: Run tests
working-directory: plugins/woocommerce
run: pnpm run test --filter=woocommerce --color
2 changes: 1 addition & 1 deletion .github/workflows/smoke-test-daily.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ jobs:
UPDATE_WC: 1
DEFAULT_TIMEOUT_OVERRIDE: 120000
run: |
pnpx wc-e2e test:e2e tests/e2e/specs/smoke-tests/update-woocommerce.js
pnpm exec wc-e2e test:e2e tests/e2e/specs/smoke-tests/update-woocommerce.js
continue-on-error: true

- name: Install k6
Expand Down
3 changes: 2 additions & 1 deletion .npmrc
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
; adding this as npm 7 automatically installs peer dependencies but pnpm does not
auto-install-peers=true
auto-install-peers=true
strict-peer-dependencies=false
10 changes: 6 additions & 4 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,16 @@ If you would like to read more about the syntax, please check out [the Turborepo
Here are some examples of the ways you can use Turborepo / pnpm commands:

```bash
# Lint and build all plugins, packages, and tools
pnpm run lint && pnpm run build
# Lint and build all plugins, packages, and tools. Note the use of `-r` for lint,
# turbo does not run the lint at this time.
pnpm run -r lint && pnpm run build

# Build WooCommerce Core and all of its dependencies
pnpm run build --filter='woocommerce'

# Lint the @woocommerce/components package
pnpm run lint --filter='@woocommerce/components'
# Lint the @woocommerce/components package - note the different argument order, turbo scripts
# are not running lints at this point in time.
pnpm run -r --filter='@woocommerce/components' lint

# Test all of the @woocommerce scoped packages
pnpm run test --filter='@woocommerce/*'
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
"url": "https://github.com/woocommerce/woocommerce/issues"
},
"scripts": {
"build": "pnpm exec turbo run turbo:build -- -- ",
"test": "pnpm exec turbo run turbo:test -- --",
"build": "pnpm exec turbo run turbo:build",
"test": "pnpm exec turbo run turbo:test",
"build-storybook": "build-storybook -c ./tools/storybook/.storybook",
"preinstall": "npx only-allow pnpm",
"postinstall": "pnpm git:update-hooks",
Expand Down
4 changes: 4 additions & 0 deletions packages/js/admin-e2e-tests/changelog/upgrade-pnpm-7
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: dev

Adjust build/test scripts to remove -- -- that was required for pnpm 6.
2 changes: 1 addition & 1 deletion packages/js/admin-e2e-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"turbo:build": "tsc --build",
"prepare": "composer install",
"changelog": "composer exec -- changelogger",
"build": "pnpm -w exec turbo run turbo:build --filter=$npm_package_name -- --",
"build": "pnpm -w exec turbo run turbo:build --filter=$npm_package_name",
"lint": "eslint src",
"start": "tsc --build --watch",
"clean": "pnpm exec rimraf tsconfig.tsbuildinfo build build-*",
Expand Down
4 changes: 4 additions & 0 deletions packages/js/api/changelog/upgrade-pnpm-7
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: dev

Adjust build/test scripts to remove -- -- that was required for pnpm 6.
4 changes: 2 additions & 2 deletions packages/js/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@
"scripts": {
"turbo:build": "pnpm run clean && npm run compile",
"turbo:test": "jest",
"test": "pnpm -w exec turbo run turbo:test --filter=$npm_package_name -- --",
"test": "pnpm -w exec turbo run turbo:test --filter=$npm_package_name",
"prepare": "composer install",
"changelog": "composer exec -- changelogger",
"clean": "rm -rf ./dist ./tsconfig.tsbuildinfo",
"compile": "tsc -b",
"prepack": "pnpm run build",
"build": "pnpm -w exec turbo run turbo:build --filter=$npm_package_name -- --",
"build": "pnpm -w exec turbo run turbo:build --filter=$npm_package_name",
"lint": "eslint src",
"lint:fix": "eslint src --fix"
},
Expand Down
4 changes: 4 additions & 0 deletions packages/js/components/changelog/upgrade-pnpm-7
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: dev

Adjust build/test scripts to remove -- -- that was required for pnpm 6.
4 changes: 2 additions & 2 deletions packages/js/components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@
"turbo:test": "jest --config ./jest.config.json",
"prepare": "composer install",
"changelog": "composer exec -- changelogger",
"build": "pnpm -w exec turbo run turbo:build --filter=$npm_package_name -- --",
"test": "pnpm -w exec turbo run turbo:test --filter=$npm_package_name -- --",
"build": "pnpm -w exec turbo run turbo:build --filter=$npm_package_name",
"test": "pnpm -w exec turbo run turbo:test --filter=$npm_package_name",
"lint": "eslint src --ext=js,ts,tsx",
"build:js": "tsc --build ./tsconfig.json ./tsconfig-cjs.json",
"build:css": "webpack",
Expand Down
4 changes: 4 additions & 0 deletions packages/js/csv-export/changelog/upgrade-pnpm-7
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: dev

Adjust build/test scripts to remove -- -- that was required for pnpm 6.
4 changes: 2 additions & 2 deletions packages/js/csv-export/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
"prepare": "composer install",
"changelog": "composer exec -- changelogger",
"clean": "pnpm exec rimraf tsconfig.tsbuildinfo build build-*",
"build": "pnpm -w exec turbo run turbo:build --filter=$npm_package_name -- --",
"test": "pnpm -w exec turbo run turbo:test --filter=$npm_package_name -- --",
"build": "pnpm -w exec turbo run turbo:build --filter=$npm_package_name",
"test": "pnpm -w exec turbo run turbo:test --filter=$npm_package_name",
"lint": "eslint src",
"start": "tsc --build --watch",
"prepack": "pnpm run clean && pnpm run build",
Expand Down
4 changes: 4 additions & 0 deletions packages/js/currency/changelog/upgrade-pnpm-7
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: dev

Adjust build/test scripts to remove -- -- that was required for pnpm 6.
4 changes: 2 additions & 2 deletions packages/js/currency/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
"prepare": "composer install",
"changelog": "composer exec -- changelogger",
"clean": "pnpm exec rimraf tsconfig.tsbuildinfo build build-*",
"build": "pnpm -w exec turbo run turbo:build --filter=$npm_package_name -- --",
"test": "pnpm -w exec turbo run turbo:test --filter=$npm_package_name -- --",
"build": "pnpm -w exec turbo run turbo:build --filter=$npm_package_name",
"test": "pnpm -w exec turbo run turbo:test --filter=$npm_package_name",
"lint": "eslint src",
"start": "tsc --build --watch",
"prepack": "pnpm run clean && pnpm run build",
Expand Down
4 changes: 4 additions & 0 deletions packages/js/customer-effort-score/changelog/upgrade-pnpm-7
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: dev

Adjust build/test scripts to remove -- -- that was required for pnpm 6.
4 changes: 2 additions & 2 deletions packages/js/customer-effort-score/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@
"prepare": "composer install",
"changelog": "composer exec -- changelogger",
"clean": "pnpm exec rimraf tsconfig.tsbuildinfo build build-*",
"build": "pnpm -w exec turbo run turbo:build --filter=$npm_package_name -- --",
"test": "pnpm -w exec turbo run turbo:test --filter=$npm_package_name -- --",
"build": "pnpm -w exec turbo run turbo:build --filter=$npm_package_name",
"test": "pnpm -w exec turbo run turbo:test --filter=$npm_package_name",
"lint": "eslint src",
"build:js": "tsc --build ./tsconfig.json ./tsconfig-cjs.json",
"build:css": "webpack",
Expand Down
4 changes: 4 additions & 0 deletions packages/js/data/changelog/upgrade-pnpm-7
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: dev

Adjust build/test scripts to remove -- -- that was required for pnpm 6.
5 changes: 3 additions & 2 deletions packages/js/data/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"@babel/runtime": "^7.17.2",
"@testing-library/react": "^12.1.3",
"@testing-library/react-hooks": "^7.0.2",
"@types/dompurify": "^2.3.3",
"@types/jest": "^27.4.1",
"@types/lodash": "^4.14.182",
"@types/md5": "^2.3.2",
Expand Down Expand Up @@ -78,8 +79,8 @@
"prepare": "composer install",
"changelog": "composer exec -- changelogger",
"clean": "pnpm exec rimraf tsconfig.tsbuildinfo build build-*",
"build": "pnpm -w exec turbo run turbo:build --filter=$npm_package_name -- --",
"test": "pnpm -w exec turbo run turbo:test --filter=$npm_package_name -- --",
"build": "pnpm -w exec turbo run turbo:build --filter=$npm_package_name",
"test": "pnpm -w exec turbo run turbo:test --filter=$npm_package_name",
"lint": "eslint src",
"start": "tsc --build --watch",
"prepack": "pnpm run clean && pnpm run build",
Expand Down
4 changes: 4 additions & 0 deletions packages/js/date/changelog/upgrade-pnpm-7
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: dev

Adjust build/test scripts to remove -- -- that was required for pnpm 6.
4 changes: 2 additions & 2 deletions packages/js/date/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@
"prepare": "composer install",
"changelog": "composer exec -- changelogger",
"clean": "pnpm exec rimraf tsconfig.tsbuildinfo build build-*",
"build": "pnpm -w exec turbo run turbo:build --filter=$npm_package_name -- --",
"test": "pnpm -w exec turbo run turbo:test --filter=$npm_package_name -- --",
"build": "pnpm -w exec turbo run turbo:build --filter=$npm_package_name",
"test": "pnpm -w exec turbo run turbo:test --filter=$npm_package_name",
"lint": "eslint src",
"start": "tsc --build --watch",
"prepack": "pnpm run clean && pnpm run build",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: dev

Remove direct dependency on eslint so that linting works properly with pnpm7
2 changes: 1 addition & 1 deletion packages/js/e2e-core-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"scripts": {
"turbo:build": "./bin/build.sh && pnpm run clean && pnpm run compile",
"prepare": "pnpm run build",
"build": "pnpm -w exec turbo run turbo:build --filter=$npm_package_name -- --",
"build": "pnpm -w exec turbo run turbo:build --filter=$npm_package_name",
"clean": "rm -rf ./build ./build-module",
"compile": "e2e-builds",
"lint": "eslint src --ext=js,ts,tsx",
Expand Down
3 changes: 1 addition & 2 deletions packages/js/e2e-environment/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@
"@wordpress/babel-plugin-import-jsx-pragma": "1.1.3",
"@wordpress/babel-preset-default": "3.0.2",
"@wordpress/browserslist-config": "^4.1.0",
"eslint": "^8.1.0",
"ndb": "^1.1.5",
"semver": "^7.3.2"
},
Expand All @@ -63,7 +62,7 @@
},
"scripts": {
"turbo:build": "pnpm run clean && pnpm run compile",
"build": "pnpm -w exec turbo run turbo:build --filter=$npm_package_name -- --",
"build": "pnpm -w exec turbo run turbo:build --filter=$npm_package_name",
"clean": "rm -rf ./build ./build-module",
"compile": "e2e-builds",
"prepare": "pnpm run build",
Expand Down
3 changes: 2 additions & 1 deletion packages/js/e2e-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"@babel/polyfill": "7.12.1",
"@babel/preset-env": "7.12.7",
"@typescript-eslint/eslint-plugin": "^5.3.0",
"@woocommerce/eslint-plugin": "workspace:*",
"@typescript-eslint/parser": "^5.3.0",
"@woocommerce/internal-e2e-builds": "workspace:*",
"@wordpress/babel-plugin-import-jsx-pragma": "1.1.3",
Expand All @@ -42,7 +43,7 @@
},
"scripts": {
"turbo:build": "pnpm run clean && pnpm run compile",
"build": "pnpm -w exec turbo run turbo:build --filter=$npm_package_name -- --",
"build": "pnpm -w exec turbo run turbo:build --filter=$npm_package_name",
"clean": "rm -rf ./build ./build-module",
"compile": "e2e-builds",
"prepare": "pnpm run build",
Expand Down
4 changes: 4 additions & 0 deletions packages/js/experimental/changelog/upgrade-pnpm-7
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: dev

Adjust build/test scripts to remove -- -- that was required for pnpm 6.
4 changes: 2 additions & 2 deletions packages/js/experimental/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@
"prepare": "composer install",
"changelog": "composer exec -- changelogger",
"clean": "pnpm exec rimraf tsconfig.tsbuildinfo build build-*",
"build": "pnpm -w exec turbo run turbo:build --filter=$npm_package_name -- --",
"test": "pnpm -w exec turbo run turbo:test --filter=$npm_package_name -- --",
"build": "pnpm -w exec turbo run turbo:build --filter=$npm_package_name",
"test": "pnpm -w exec turbo run turbo:test --filter=$npm_package_name",
"lint": "eslint src",
"build:js": "tsc --build ./tsconfig.json ./tsconfig-cjs.json",
"build:css": "webpack",
Expand Down
4 changes: 4 additions & 0 deletions packages/js/explat/changelog/upgrade-pnpm-7
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: dev

Adjust build/test scripts to remove -- -- that was required for pnpm 6.
4 changes: 2 additions & 2 deletions packages/js/explat/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@
"prepare": "composer install",
"changelog": "composer exec -- changelogger",
"clean": "pnpm exec rimraf tsconfig.tsbuildinfo build build-*",
"build": "pnpm -w exec turbo run turbo:build --filter=$npm_package_name -- --",
"test": "pnpm -w exec turbo run turbo:test --filter=$npm_package_name -- --",
"build": "pnpm -w exec turbo run turbo:build --filter=$npm_package_name",
"test": "pnpm -w exec turbo run turbo:test --filter=$npm_package_name",
"lint": "eslint src",
"start": "tsc --build --watch",
"prepack": "pnpm run clean && pnpm run build",
Expand Down
2 changes: 1 addition & 1 deletion packages/js/internal-js-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"module": "build-module/util/index.js",
"scripts": {
"turbo:build": "tsc --build ./tsconfig.json ./tsconfig-cjs.json",
"build": "pnpm -w exec turbo run turbo:build --filter=$npm_package_name -- --",
"build": "pnpm -w exec turbo run turbo:build --filter=$npm_package_name",
"lint": "eslint src",
"ts:check": "tsc --noEmit --project ./tsconfig.json",
"clean": "pnpm exec rimraf *.tsbuildinfo build build-*",
Expand Down
Loading

0 comments on commit 04b74c1

Please sign in to comment.