From f04dc7514750ca82cdd68dc54ceddc32b14c11d9 Mon Sep 17 00:00:00 2001 From: Yann Braga Date: Sat, 16 May 2020 16:41:42 +0200 Subject: [PATCH 1/2] chore(build-package): run processes in parallel --- scripts/build-package.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/build-package.js b/scripts/build-package.js index 7a7663c1446b..dd03bedb92fb 100644 --- a/scripts/build-package.js +++ b/scripts/build-package.js @@ -143,7 +143,7 @@ function run() { if (watchMode) { const runWatchMode = () => { - const baseWatchCommand = `lerna exec --scope "${glob}" -- cross-env-shell node ${resolve( + const baseWatchCommand = `lerna exec --scope "${glob}" --parallel -- cross-env-shell node ${resolve( __dirname )}`; const watchTsc = `${baseWatchCommand}/watch-tsc.js`; From 8b17baee5173b285fdc53967741223d5ad05d481 Mon Sep 17 00:00:00 2001 From: Yann Braga Date: Sat, 16 May 2020 17:10:43 +0200 Subject: [PATCH 2/2] chore(build-packages): use * when using --all flag - Also add a warn message when using --all with --watch mode --- scripts/build-package.js | 32 ++++++++++++-------------------- 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/scripts/build-package.js b/scripts/build-package.js index dd03bedb92fb..71e36dd6e81f 100644 --- a/scripts/build-package.js +++ b/scripts/build-package.js @@ -136,14 +136,23 @@ function run() { .map((key) => key.suffix) .filter(Boolean); - const glob = + let glob = packageNames.length > 1 ? `@storybook/{${packageNames.join(',')}}` : `@storybook/${packageNames[0]}`; + const isAllPackages = process.argv.includes('--all'); + if (isAllPackages) { + glob = '@storybook/*'; + + log.warn( + 'You are building a lot of packages on watch mode. This is an expensive action and might slow your computer down.\nIf this is an issue, run yarn build to filter packages and speed things up!' + ); + } + if (watchMode) { const runWatchMode = () => { - const baseWatchCommand = `lerna exec --scope "${glob}" --parallel -- cross-env-shell node ${resolve( + const baseWatchCommand = `lerna exec --scope '${glob}' --parallel -- cross-env-shell node ${resolve( __dirname )}`; const watchTsc = `${baseWatchCommand}/watch-tsc.js`; @@ -152,24 +161,7 @@ function run() { spawn(command); }; - if (packageNames.length < 5) { - runWatchMode(); - } else { - inquirer - .prompt([ - { - type: 'confirm', - message: - 'You selected a lot of packages on watch mode. This is a very expensive action and might slow your computer down. Do you want to continue?', - name: 'confirmation', - }, - ]) - .then(({ confirmation }) => { - if (confirmation === true) { - runWatchMode(); - } - }); - } + runWatchMode(); } else { spawn(`lerna run prepare --scope "${glob}"`); }