From c6fc8e7bf4da1447e7b9b9d4f7656f1e045e79c4 Mon Sep 17 00:00:00 2001 From: Satyajit Sahoo Date: Tue, 26 Sep 2023 12:17:14 +0200 Subject: [PATCH] refactor: use 'prepare' instead of 'prepack' --- .github/workflows/build-templates.yml | 4 ++-- .github/workflows/check-project.yml | 2 +- README.md | 6 +++--- package.json | 2 +- packages/create-react-native-library/package.json | 2 +- .../templates/common/$.github/workflows/ci.yml | 2 +- .../templates/common/$package.json | 6 +++--- packages/react-native-builder-bob/package.json | 2 +- packages/react-native-builder-bob/src/index.ts | 10 +++++----- 9 files changed, 18 insertions(+), 18 deletions(-) diff --git a/.github/workflows/build-templates.yml b/.github/workflows/build-templates.yml index 92c93d6d7..20b87c575 100644 --- a/.github/workflows/build-templates.yml +++ b/.github/workflows/build-templates.yml @@ -95,7 +95,7 @@ jobs: - name: Build package run: | - yarn workspace create-react-native-library prepack + yarn workspace create-react-native-library prepare - name: Get working directory run: | @@ -195,7 +195,7 @@ jobs: - name: Build library working-directory: ${{ env.work_dir }} run: | - yarn prepack + yarn prepare - name: Build example (Web) working-directory: ${{ env.work_dir }} diff --git a/.github/workflows/check-project.yml b/.github/workflows/check-project.yml index d47ddba1b..af539d7c6 100644 --- a/.github/workflows/check-project.yml +++ b/.github/workflows/check-project.yml @@ -24,4 +24,4 @@ jobs: run: yarn typecheck - name: Build packages - run: yarn lerna run prepack + run: yarn lerna run prepare diff --git a/README.md b/README.md index 1abf65c48..87a21611e 100644 --- a/README.md +++ b/README.md @@ -78,11 +78,11 @@ yarn add --dev react-native-builder-bob See options below for more details. -1. Add `bob` to your `prepack` step: +1. Add `bob` to your `prepare` or `prepack` step: ```js "scripts": { - "prepack": "bob build" + "prepare": "bob build" } ``` @@ -226,7 +226,7 @@ This builds the project according to the configuration. This is usually run as p ```json "scripts": { - "prepack": "bob build" + "prepare": "bob build" } ``` diff --git a/package.json b/package.json index 6b8f990d7..00c89e2ad 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "scripts": { "lint": "eslint \"**/*.{js,ts,tsx}\"", "typecheck": "tsc --noEmit", - "watch": "concurrently 'yarn typecheck --watch' 'lerna run --parallel prepack -- --watch'" + "watch": "concurrently 'yarn typecheck --watch' 'lerna run --parallel prepare -- --watch'" }, "devDependencies": { "@arkweid/lefthook": "^0.7.7", diff --git a/packages/create-react-native-library/package.json b/packages/create-react-native-library/package.json index c31c99887..cc4613e9f 100644 --- a/packages/create-react-native-library/package.json +++ b/packages/create-react-native-library/package.json @@ -37,7 +37,7 @@ "registry": "https://registry.npmjs.org/" }, "scripts": { - "prepack": "babel --extensions .ts,.tsx src --out-dir lib --ignore '**/__tests__/**' --source-maps --delete-dir-on-start" + "prepare": "babel --extensions .ts,.tsx src --out-dir lib --ignore '**/__tests__/**' --source-maps --delete-dir-on-start" }, "dependencies": { "cross-spawn": "^7.0.3", diff --git a/packages/create-react-native-library/templates/common/$.github/workflows/ci.yml b/packages/create-react-native-library/templates/common/$.github/workflows/ci.yml index f8d61df5e..2b16e4e6c 100644 --- a/packages/create-react-native-library/templates/common/$.github/workflows/ci.yml +++ b/packages/create-react-native-library/templates/common/$.github/workflows/ci.yml @@ -45,7 +45,7 @@ jobs: uses: ./.github/actions/setup - name: Build package - run: yarn prepack + run: yarn prepare <% if (project.native) { -%> build-android: diff --git a/packages/create-react-native-library/templates/common/$package.json b/packages/create-react-native-library/templates/common/$package.json index e570e8a3d..cbda1fc5c 100644 --- a/packages/create-react-native-library/templates/common/$package.json +++ b/packages/create-react-native-library/templates/common/$package.json @@ -27,6 +27,7 @@ "!**/.*" ], "scripts": { + "example": "yarn workspace <%- project.slug -%>-example", "test": "jest", "typecheck": "tsc --noEmit", "lint": "eslint \"**/*.{js,ts,tsx}\"", @@ -35,9 +36,8 @@ <% } else { -%> "clean": "del-cli lib", <% } -%> - "prepack": "bob build", - "release": "release-it", - "example": "yarn workspace <%- project.slug -%>-example" + "prepare": "bob build", + "release": "release-it" }, "keywords": [ "react-native", diff --git a/packages/react-native-builder-bob/package.json b/packages/react-native-builder-bob/package.json index 21ad84131..9ab6ac59e 100644 --- a/packages/react-native-builder-bob/package.json +++ b/packages/react-native-builder-bob/package.json @@ -33,7 +33,7 @@ "registry": "https://registry.npmjs.org/" }, "scripts": { - "prepack": "babel --extensions .ts,.tsx src --out-dir lib --source-maps --delete-dir-on-start" + "prepare": "babel --extensions .ts,.tsx src --out-dir lib --source-maps --delete-dir-on-start" }, "dependencies": { "@babel/core": "^7.18.5", diff --git a/packages/react-native-builder-bob/src/index.ts b/packages/react-native-builder-bob/src/index.ts index 7c29040a0..234171071 100644 --- a/packages/react-native-builder-bob/src/index.ts +++ b/packages/react-native-builder-bob/src/index.ts @@ -208,7 +208,7 @@ yargs } } - const prepack = 'bob build'; + const prepare = 'bob build'; const files = [ source, output, @@ -236,20 +236,20 @@ yargs } } - if (pkg.scripts?.prepack && pkg.scripts.prepack !== prepack) { + if (pkg.scripts?.prepare && pkg.scripts.prepare !== prepare) { const { replace } = await prompts({ type: 'confirm', name: 'replace', - message: `Your package.json has the 'scripts.prepack' field set to '${pkg.scripts.prepack}'. Do you want to replace it with '${prepack}'?`, + message: `Your package.json has the 'scripts.prepare' field set to '${pkg.scripts.prepare}'. Do you want to replace it with '${prepare}'?`, initial: true, }); if (replace) { - pkg.scripts.prepack = prepack; + pkg.scripts.prepare = prepare; } } else { pkg.scripts = pkg.scripts || {}; - pkg.scripts.prepack = prepack; + pkg.scripts.prepare = prepare; } if (