From 8eb348b3a94cabcae2ab947b9ba887d3c5f549a0 Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Sat, 28 May 2022 14:18:11 +0300 Subject: [PATCH] Build packages after installing them with monorepo script --- components/ember/package.json | 3 ++- components/react/package.json | 1 + components/svelte/package.json | 1 + components/svg-framework/package.json | 1 + components/vue/package.json | 1 + components/vue2/package.json | 1 + iconify-icon/icon/package.json | 1 + iconify-icon/react/package.json | 1 + iconify-icon/solid/package.json | 3 ++- monorepo/index.js | 2 +- monorepo/src/index.ts | 17 ++++++++++++++++- package.json | 2 +- packages/api-redundancy/package.json | 1 + packages/core/package.json | 1 + packages/utils/package.json | 1 + 15 files changed, 32 insertions(+), 5 deletions(-) diff --git a/components/ember/package.json b/components/ember/package.json index ee6241b..afdc6bb 100644 --- a/components/ember/package.json +++ b/components/ember/package.json @@ -20,7 +20,8 @@ "build:lib": "tsc -b", "build:rollup": "rollup -c rollup.config.js", "build:api": "api-extractor run --local --verbose --config api-extractor.json", - "build:cleanup": "node cleanup" + "build:cleanup": "node cleanup", + "monorepo:postinstall": "npm run build" }, "devDependencies": { "@iconify/core": "^1.3.2", diff --git a/components/react/package.json b/components/react/package.json index aac8ee4..a98bd01 100644 --- a/components/react/package.json +++ b/components/react/package.json @@ -21,6 +21,7 @@ "prebuild:api": "api-extractor run --local --verbose --config api-extractor.offline.json", "build:api": "api-extractor run --local --verbose --config api-extractor.iconify.json", "build:cleanup": "node cleanup", + "monorepo:postinstall": "npm run build", "test": "jest --runInBand" }, "main": "dist/iconify.js", diff --git a/components/svelte/package.json b/components/svelte/package.json index 7b3377f..ac50df0 100644 --- a/components/svelte/package.json +++ b/components/svelte/package.json @@ -23,6 +23,7 @@ "build:tsc": "tsc -b", "build:bundles": "rollup -c rollup.config.js", "build:api": "node build --only-api", + "monorepo:postinstall": "npm run build", "test": "jest --runInBand" }, "dependencies": { diff --git a/components/svg-framework/package.json b/components/svg-framework/package.json index 65fd6bd..af5a76e 100644 --- a/components/svg-framework/package.json +++ b/components/svg-framework/package.json @@ -25,6 +25,7 @@ "build:dist": "rollup -c rollup.config.js", "build:api": "api-extractor run --local --verbose", "build:api2": "api-extractor run --local --verbose --config api-extractor.without-api.json", + "monorepo:postinstall": "npm run build", "test:jest": "jest --runInBand", "test:mjs": "cross-env NODE_OPTIONS=--experimental-vm-modules node tests/import-test.mjs", "test": "npm run test:jest && npm run test:mjs" diff --git a/components/vue/package.json b/components/vue/package.json index 242ceb7..34a17bb 100644 --- a/components/vue/package.json +++ b/components/vue/package.json @@ -18,6 +18,7 @@ "build:dist": "rollup -c rollup.config.js", "prebuild:api": "api-extractor run --local --verbose --config api-extractor.offline.json", "build:api": "api-extractor run --local --verbose --config api-extractor.iconify.json", + "monorepo:postinstall": "npm run build", "test": "vitest" }, "main": "dist/iconify.js", diff --git a/components/vue2/package.json b/components/vue2/package.json index 08a61ff..12c06da 100644 --- a/components/vue2/package.json +++ b/components/vue2/package.json @@ -18,6 +18,7 @@ "build:dist": "rollup -c rollup.config.js", "prebuild:api": "api-extractor run --local --verbose --config api-extractor.offline.json", "build:api": "api-extractor run --local --verbose --config api-extractor.iconify.json", + "monorepo:postinstall": "npm run build", "test": "jest --runInBand" }, "main": "dist/iconify.js", diff --git a/iconify-icon/icon/package.json b/iconify-icon/icon/package.json index 8707c27..eed0322 100644 --- a/iconify-icon/icon/package.json +++ b/iconify-icon/icon/package.json @@ -24,6 +24,7 @@ "build:api": "api-extractor run --local --verbose", "build:lib": "tsc -b", "build:dist": "rollup -c rollup.config.js", + "monorepo:postinstall": "npm run build", "test:jest": "jest --runInBand", "test:mjs": "cross-env NODE_OPTIONS=--experimental-vm-modules node tests/import-test.mjs", "test": "npm run test:jest && npm run test:mjs" diff --git a/iconify-icon/react/package.json b/iconify-icon/react/package.json index d032603..14fd9ac 100644 --- a/iconify-icon/react/package.json +++ b/iconify-icon/react/package.json @@ -16,6 +16,7 @@ "clean": "rimraf lib dist tsconfig.tsbuildinfo", "prebuild": "npm run clean", "build": "tsup", + "monorepo:postinstall": "npm run build", "test": "vitest --config vitest.config.mjs" }, "main": "dist/iconify.js", diff --git a/iconify-icon/solid/package.json b/iconify-icon/solid/package.json index 3100281..9e36865 100644 --- a/iconify-icon/solid/package.json +++ b/iconify-icon/solid/package.json @@ -16,7 +16,8 @@ "scripts": { "clean": "rimraf lib dist tsconfig.tsbuildinfo", "prebuild": "npm run clean", - "build": "tsc -b" + "build": "tsc -b", + "monorepo:postinstall": "npm run build" }, "main": "dist/iconify.jsx", "types": "dist/iconify.d.ts", diff --git a/monorepo/index.js b/monorepo/index.js index 3d18378..0376f08 100644 --- a/monorepo/index.js +++ b/monorepo/index.js @@ -29,7 +29,7 @@ function getNPMCommand() { return cmd; } } - throw new Error('Cannot execute NPM commands') + throw new Error('Cannot execute NPM commands'); } /** diff --git a/monorepo/src/index.ts b/monorepo/src/index.ts index 4834ea4..9ec7b1b 100644 --- a/monorepo/src/index.ts +++ b/monorepo/src/index.ts @@ -19,12 +19,27 @@ const actionFunctions: Record void> = { clean: () => { runAction('Removing node_modules', cleanWorkspace); }, - install: () => { + reinstall: () => { runAction('Installing dependencies', (workspace) => { runNPMCommand(workspace, ['install']); addLinksToWorkspace(workspace); }); }, + install: () => { + runAction( + 'Installing dependencies and building packages', + (workspace) => { + if (workspace.scripts.indexOf('monorepo:preinstall') !== -1) { + runNPMCommand(workspace, ['run', 'monorepo:preinstall']); + } + runNPMCommand(workspace, ['install']); + addLinksToWorkspace(workspace); + if (workspace.scripts.indexOf('monorepo:postinstall') !== -1) { + runNPMCommand(workspace, ['run', 'monorepo:postinstall']); + } + } + ); + }, versions: () => { runAction('Updating versions of local packages', updateVersions); }, diff --git a/package.json b/package.json index 2b4a420..3ee7c1c 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "clean": "node monorepo clean", "link": "node monorepo link", "unlink": "node monorepo unlink", - "reinstall": "node monorepo clean install", + "reinstall": "node monorepo clean reinstall", "build": "node monorepo run build --if-present --public", "test": "node monorepo run build --if-present --public", "versions": "node monorepo versions" diff --git a/packages/api-redundancy/package.json b/packages/api-redundancy/package.json index e0ee533..a7d7ba8 100644 --- a/packages/api-redundancy/package.json +++ b/packages/api-redundancy/package.json @@ -18,6 +18,7 @@ "lint": "eslint src/*.ts", "prebuild": "npm run lint", "build": "tsup src/index.ts --dts --format esm,cjs", + "monorepo:postinstall": "npm run build", "test:jest": "jest --runInBand", "test:jasmine": "cross-env NODE_OPTIONS=--experimental-vm-modules npx jasmine", "test": "npm run test:jest && npm run test:jasmine" diff --git a/packages/core/package.json b/packages/core/package.json index 2f2147f..9a52d21 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -17,6 +17,7 @@ "lint": "eslint --fix src/**/*.ts", "prebuild": "npm run lint && npm run clean", "build": "unbuild", + "monorepo:postinstall": "npm run build", "test:jest-cjs": "jest --clearCache --config=jest.config.cjs && jest --runInBand --config=jest.config.cjs", "test:jest-esm": "cross-env NODE_OPTIONS=--experimental-vm-modules jest --clearCache --config=jest.config.mjs && cross-env NODE_OPTIONS=--experimental-vm-modules npx jest --runInBand --config=jest.config.mjs", "test": "npm run test:jest-cjs && npm run test:jest-esm", diff --git a/packages/utils/package.json b/packages/utils/package.json index 220b35f..a334032 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -17,6 +17,7 @@ "lint": "eslint --fix src/**/*.ts", "prebuild": "npm run lint && npm run clean", "build": "unbuild", + "monorepo:postinstall": "npm run build", "test:jest-cjs": "jest --clearCache --config=jest.config.cjs && jest --runInBand --config=jest.config.cjs", "test:jest-esm": "cross-env NODE_OPTIONS=--experimental-vm-modules jest --clearCache --config=jest.config.mjs && cross-env NODE_OPTIONS=--experimental-vm-modules npx jest --runInBand --config=jest.config.mjs", "test": "npm run test:jest-cjs && npm run test:jest-esm",