Monorepo Utils: Move postinstall build to local package.json (#37688)

* add warning if package hasn't been built yet

* move postinstall script

* remove extra build in highlight flow
This commit is contained in:
Paul Sealock 2023-04-14 10:11:13 +12:00 committed by GitHub
parent d62b2995b5
commit 0fda297965
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 23 additions and 2 deletions

View File

@ -22,7 +22,7 @@ jobs:
run: |
npm install -g pnpm@7
npm -g i @wordpress/env@5.1.0
pnpm install --filter monorepo-utils --filter code-analyzer --filter cli-core
pnpm install --filter code-analyzer --filter cli-core
- name: Run analyzer
id: run
working-directory: tools/code-analyzer

View File

@ -25,7 +25,7 @@
"test": "pnpm exec turbo run turbo:test",
"clean": "pnpm store prune && git clean -fx **/node_modules && pnpm i",
"preinstall": "npx only-allow pnpm",
"postinstall": "pnpm git:update-hooks && pnpm run --filter='./tools/monorepo-utils' build",
"postinstall": "pnpm git:update-hooks",
"git:update-hooks": "rm -r .git/hooks && mkdir -p .git/hooks && husky install",
"create-extension": "node ./tools/create-extension/index.js",
"cherry-pick": "node ./tools/cherry-pick/bin/run",

View File

@ -1,5 +1,25 @@
#!/usr/bin/env node
const { existsSync } = require( 'fs' );
const chalk = require( 'chalk' );
const path = require( 'path' );
const nodeModulesDirectory = path.join( __dirname, '../', 'node_modules' );
if ( ! existsSync( nodeModulesDirectory ) ) {
console.log(
chalk.red(
'The @woocommerce/monorepo-utils must be built before running the CLI.'
)
);
console.log(
chalk.yellow(
'run `pnpm run build` from the root of the monorepo-utils package. or `pnpm install --filter monorepo-utils` from project root.'
)
);
process.exit( 1 );
}
const { program } = require( '../dist/index' );
program.parse( process.argv );

View File

@ -27,6 +27,7 @@
"build": "tsc",
"start": "tsc --watch",
"lint": "eslint . --ext .ts",
"postinstall": "pnpm run build",
"test": "jest"
},
"engines": {