diff --git a/.github/actions/install-build/action.yml b/.github/actions/install-build/action.yml index f4c161d69f0..bec7a8b95d5 100644 --- a/.github/actions/install-build/action.yml +++ b/.github/actions/install-build/action.yml @@ -5,6 +5,10 @@ inputs: required: false description: The directory to target. default: ./ + composer_no_dev: + required: false + description: COMPOSER_NO_DEV option. + default: 1 runs: using: "composite" @@ -17,7 +21,7 @@ runs: - name: Install dependencies shell: bash working-directory: ${{ inputs.working_directory }} - run: COMPOSER_NO_DEV=1 pnpm install + run: COMPOSER_NO_DEV=${{ inputs.composer_no_dev }} pnpm install - name: Run build shell: bash diff --git a/.github/workflows/pr-code-coverage.yml b/.github/workflows/pr-code-coverage.yml index 6d0d3bddc01..3203475b2b2 100644 --- a/.github/workflows/pr-code-coverage.yml +++ b/.github/workflows/pr-code-coverage.yml @@ -46,7 +46,9 @@ jobs: - name: Install and Build uses: ./.github/actions/install-build - + with: + composer_no_dev: 0 + - name: Build Admin feature config run: | pnpm build:feature-config --filter=woocommerce diff --git a/.github/workflows/pr-code-sniff.yml b/.github/workflows/pr-code-sniff.yml index 0d3dc8ab3d4..972f2325f81 100644 --- a/.github/workflows/pr-code-sniff.yml +++ b/.github/workflows/pr-code-sniff.yml @@ -35,6 +35,8 @@ jobs: - name: Install and Build uses: ./.github/actions/install-build + with: + composer_no_dev: 0 - name: Run code sniffer uses: thenabeel/action-phpcs@v8 diff --git a/.github/workflows/pr-unit-tests.yml b/.github/workflows/pr-unit-tests.yml index 0bf28dc6d32..f74f2c8bca9 100644 --- a/.github/workflows/pr-unit-tests.yml +++ b/.github/workflows/pr-unit-tests.yml @@ -57,6 +57,8 @@ jobs: - name: Install and Build uses: ./.github/actions/install-build + with: + composer_no_dev: 0 - name: Build Admin feature config run: | diff --git a/plugins/woocommerce-admin/bin/install-if-deps-outdated.js b/plugins/woocommerce-admin/bin/install-if-deps-outdated.js deleted file mode 100755 index 268b12a4edb..00000000000 --- a/plugins/woocommerce-admin/bin/install-if-deps-outdated.js +++ /dev/null @@ -1,37 +0,0 @@ -#!/usr/bin/env node - -/** - * Performs an `pnpm install`. Since that's a costly operation, - * it will only perform it if needed, that is, if the packages - * installed at `node_modules` aren't in sync over what - * `package-lock.json` has. For that, modification times of both - * files will be compared. If the package-lock is newer, it means that - * the packages at node_modules may be outdated. That will happen, - * for example, when switching branches. - */ - -const fs = require( 'fs' ); -const spawnSync = require( 'child_process' ).spawnSync; - -const needsInstall = () => { - try { - const shrinkwrapTime = fs.statSync( 'pnpm-lock.yaml' ).mtime; - const nodeModulesTime = fs.statSync( 'node_modules' ).mtime; - return shrinkwrapTime - nodeModulesTime > 1000; // In Windows, directory mtime has less precision than file mtime - } catch ( e ) { - return true; - } -}; - -if ( needsInstall() ) { - const installResult = spawnSync( 'pnpm', [ 'install' ], { - shell: true, - stdio: 'inherit', - } ).status; - - if ( installResult ) { - process.exit( installResult ); - } - - fs.utimesSync( 'node_modules', new Date(), new Date() ); -} diff --git a/plugins/woocommerce-admin/bin/install-if-no-packages.js b/plugins/woocommerce-admin/bin/install-if-no-packages.js deleted file mode 100644 index 24036e5808f..00000000000 --- a/plugins/woocommerce-admin/bin/install-if-no-packages.js +++ /dev/null @@ -1,13 +0,0 @@ -const spawnSync = require( 'child_process' ).spawnSync; -const fs = require( 'fs' ); - -if ( ! fs.existsSync( 'node_modules' ) ) { - console.log( 'No "node_modules" present, installing dependencies...' ); - const installResult = spawnSync( 'pnpm', [ 'install' ], { - shell: true, - stdio: 'inherit', - } ).status; - if ( installResult ) { - process.exit( installResult ); - } -} diff --git a/plugins/woocommerce-admin/package.json b/plugins/woocommerce-admin/package.json index 5d959e3d349..2eff81b52de 100644 --- a/plugins/woocommerce-admin/package.json +++ b/plugins/woocommerce-admin/package.json @@ -10,18 +10,16 @@ }, "scripts": { "analyze": "cross-env NODE_ENV=production ANALYZE=true webpack", - "build": "node ./node_modules/require-turbo && pnpm run install-if-deps-outdated && pnpm run clean && WC_ADMIN_PHASE=core pnpm run build:packages && WC_ADMIN_PHASE=core pnpm run build:feature-config && cross-env NODE_ENV=production WC_ADMIN_PHASE=core webpack", + "build": "node ./node_modules/require-turbo && pnpm run clean && WC_ADMIN_PHASE=core pnpm run build:feature-config && cross-env NODE_ENV=production WC_ADMIN_PHASE=core webpack", "build:feature-config": "php ../woocommerce/bin/generate-feature-config.php", "build:packages": "cross-env NODE_ENV=production pnpm -w exec turbo run build --filter='./packages/js/*'", - "clean": "rimraf ../woocommerce/assets/client/admin/* && pnpm run:packages -- clean --parallel", + "clean": "rimraf ../woocommerce/assets/client/admin/*", "client:watch": "cross-env WC_ADMIN_PHASE=development pnpm run build:feature-config && cross-env WC_ADMIN_PHASE=development webpack --watch", "create-hook-reference": "node ./bin/hook-reference/index.js", "create-wc-extension": "node ./bin/starter-pack/starter-pack.js", - "dev": "pnpm run -s install-if-deps-outdated && cross-env WC_ADMIN_PHASE=development pnpm run build:feature-config && cross-env WC_ADMIN_PHASE=development pnpm run build:packages && cross-env WC_ADMIN_PHASE=development webpack", + "dev": "cross-env WC_ADMIN_PHASE=development pnpm run build:feature-config && cross-env WC_ADMIN_PHASE=development pnpm -w exec turbo run build --filter='./packages/js/*' && cross-env WC_ADMIN_PHASE=development webpack", "example": "webpack --config docs/examples/extensions/examples.config.js --watch", "preinstall": "npx only-allow pnpm", - "install-if-deps-outdated": "node bin/install-if-deps-outdated.js", - "install-if-no-packages": "node bin/install-if-no-packages.js", "lint": "node ./node_modules/require-turbo && pnpm run lint:js && pnpm run lint:css", "lint:fix": "pnpm lint:js-fix && pnpm lint:css-fix", "lint:css": "stylelint '**/*.scss'", @@ -33,21 +31,13 @@ "prepack": "pnpm install && pnpm run lint && pnpm run test && cross-env WC_ADMIN_PHASE=core pnpm run build", "packages:fix:textdomain": "node ./bin/package-update-textdomain.js", "packages:watch": "cross-env WC_ADMIN_PHASE=development pnpm run:packages -- start --parallel", - "pre-release": "./bin/pre-release.sh", - "publish-packages:check": "pnpm run build:packages && pnpm publish --dry-run --filter ../../packages/js/ --publish-branch main --report-summary && cat ../../pnpm-publish-summary.json && rimraf ../../pnpm-publish-summary.json", - "publish-packages:dev": "pnpm run build:packages && pnpm publish --filter ../../packages/js/ --publish-branch main --tag next", - "publish-packages:prod": "pnpm run build:packages && pnpm publish --filter ../../packages/js/ --publish-branch main", - "reformat-files": "wp-scripts format-js -- --ignore-path .eslintignore", "run:packages": "pnpm run --filter ../../packages/js/", - "start": "pnpm run install-if-deps-outdated && cross-env WC_ADMIN_PHASE=development pnpm run build:packages && cross-env WC_ADMIN_PHASE=development pnpm run build:feature-config && concurrently \"cross-env WC_ADMIN_PHASE=development webpack --watch\" \"cross-env WC_ADMIN_PHASE=development pnpm run:packages -- start --parallel\"", - "start:package": "pnpm run:packages -- start --parallel", - "pretest": "pnpm run -s install-if-no-packages", + "start": "cross-env WC_ADMIN_PHASE=development pnpm -w exec turbo run build --filter='./packages/js/*' && cross-env WC_ADMIN_PHASE=development pnpm run build:feature-config && concurrently \"cross-env WC_ADMIN_PHASE=development webpack --watch\" \"cross-env WC_ADMIN_PHASE=development pnpm packages:watch\"", "test": "node ./node_modules/require-turbo && pnpm run test:client", "test-staged": "pnpm run test:client -- --bail --findRelatedTests", "test:client": "jest --config client/jest.config.js", "test:debug": "node --inspect-brk ./node_modules/.bin/jest --config client/jest.config.js --watch --runInBand --no-cache", "test:help": "wp-scripts test-unit-js --help", - "test:packages": "pnpm -w exec turbo run test --filter='./packages/js/*'", "test:update-snapshots": "pnpm run test:client -- --updateSnapshot && pnpm run --filter @woocommerce/components test:update-snapshots", "test:watch": "pnpm run test:client -- --watch", "ts:check": "tsc --build ./tsconfig.json --pretty", diff --git a/plugins/woocommerce/changelog/update-33948_client_admin_scripts b/plugins/woocommerce/changelog/update-33948_client_admin_scripts new file mode 100644 index 00000000000..660fa09494d --- /dev/null +++ b/plugins/woocommerce/changelog/update-33948_client_admin_scripts @@ -0,0 +1,4 @@ +Significance: patch +Type: dev + +Update package.json scripts within woocommerce/client/admin plugin. #33982 diff --git a/turbo.json b/turbo.json index a74255c79a6..54facc6e93a 100644 --- a/turbo.json +++ b/turbo.json @@ -10,7 +10,7 @@ }, "build": { - "dependsOn": [ "^build" ], + "dependsOn": [ "^build", "$WC_ADMIN_PHASE" ], "inputs": [ "src/*.js", "src/**/*.js", @@ -47,7 +47,23 @@ "includes/**/*.php" ] }, - + "woocommerce/client/admin#build": { + "dependsOn": [ "^build", "$WC_ADMIN_PHASE" ], + "outputs": [], + "inputs": [ + "client/*.js", + "client/**/*.js", + "client/*.jsx", + "client/**/*.jsx", + "client/*.ts", + "client/**/*.ts", + "client/*.tsx", + "client/**/*.tsx", + "client/*.scss", + "client/**/*.scss" + ] + }, + "test": { "dependsOn": [ "build" ], "inputs": [