From a78f04a6f9fa46120ee5bb75a3143300fcd9c8d7 Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Tue, 19 Sep 2023 08:36:18 +0200 Subject: [PATCH] Merge pull request #24208 from storybookjs/norbert/filter-angular-prerelease Build: Filter `angular-cli/prerelease` in sandbox generation (cherry picked from commit f49c9a24128110d9df272a153901e72564dbec75) --- .github/workflows/generate-sandboxes-main.yml | 2 +- .github/workflows/generate-sandboxes-next.yml | 2 +- code/lib/cli/src/sandbox-templates.ts | 5 ++-- scripts/sandbox/generate.ts | 28 +++++++++++++------ scripts/tasks/generate.ts | 3 +- 5 files changed, 26 insertions(+), 14 deletions(-) diff --git a/.github/workflows/generate-sandboxes-main.yml b/.github/workflows/generate-sandboxes-main.yml index 66cd1b800d37..474542495848 100644 --- a/.github/workflows/generate-sandboxes-main.yml +++ b/.github/workflows/generate-sandboxes-main.yml @@ -43,7 +43,7 @@ jobs: run: yarn wait-on http://localhost:6001 working-directory: ./code - name: Generate - run: yarn generate-sandboxes --local-registry + run: yarn generate-sandboxes --local-registry --exclude=angular-cli/prerelease working-directory: ./code - name: Publish run: yarn publish-sandboxes --remote=https://storybook-bot:${{ secrets.PAT_STORYBOOK_BOT}}@github.com/storybookjs/sandboxes.git --push --branch=main diff --git a/.github/workflows/generate-sandboxes-next.yml b/.github/workflows/generate-sandboxes-next.yml index f22e7cb4a50b..f6ab2f7c822f 100644 --- a/.github/workflows/generate-sandboxes-next.yml +++ b/.github/workflows/generate-sandboxes-next.yml @@ -43,7 +43,7 @@ jobs: run: yarn wait-on http://localhost:6001 working-directory: ./code - name: Generate - run: yarn generate-sandboxes --local-registry + run: yarn generate-sandboxes --local-registry --exclude=angular-cli/prerelease working-directory: ./code - name: Publish run: yarn publish-sandboxes --remote=https://storybook-bot:${{ secrets.PAT_STORYBOOK_BOT}}@github.com/storybookjs/sandboxes.git --push --branch=next diff --git a/code/lib/cli/src/sandbox-templates.ts b/code/lib/cli/src/sandbox-templates.ts index 7fb52574ea3a..b2c4e3b6b17c 100644 --- a/code/lib/cli/src/sandbox-templates.ts +++ b/code/lib/cli/src/sandbox-templates.ts @@ -285,7 +285,7 @@ const baseTemplates = { builder: '@storybook/builder-webpack5', }, skipTasks: ['e2e-tests-dev', 'bench'], - // TODO: Can be enabled once we re-revert this PR: https://github.com/storybookjs/storybook/pull/24033 + // TODO: Should be removed after we merge this PR: https://github.com/storybookjs/storybook/pull/24188 inDevelopment: true, }, 'angular-cli/default-ts': { @@ -575,7 +575,8 @@ export const merged: TemplateKey[] = [ ]; export const daily: TemplateKey[] = [ ...merged, - 'angular-cli/prerelease', + // TODO: Should be re-added after we merge this PR: https://github.com/storybookjs/storybook/pull/24188 + // 'angular-cli/prerelease', 'cra/default-js', 'react-vite/default-js', 'vue3-vite/default-js', diff --git a/scripts/sandbox/generate.ts b/scripts/sandbox/generate.ts index b74ae5a28d03..0e477b1a6220 100755 --- a/scripts/sandbox/generate.ts +++ b/scripts/sandbox/generate.ts @@ -202,11 +202,16 @@ const runGenerators = async ( }; export const options = createOptions({ - template: { - type: 'string', - description: 'Which template would you like to create?', + templates: { + type: 'string[]', + description: 'Which templates would you like to create?', values: Object.keys(sandboxTemplates), }, + exclude: { + type: 'string[]', + description: 'Space-delimited list of templates to exclude. Takes precedence over --templates', + promptType: false, + }, localRegistry: { type: 'boolean', description: 'Generate reproduction from local registry?', @@ -220,7 +225,8 @@ export const options = createOptions({ }); export const generate = async ({ - template, + templates, + exclude, localRegistry, debug, }: OptionValues) => { @@ -230,11 +236,11 @@ export const generate = async ({ ...configuration, })) .filter(({ dirName }) => { - if (template) { - return dirName === template; + let include = Array.isArray(templates) ? templates.includes(dirName) : true; + if (Array.isArray(exclude) && include) { + include = !exclude.includes(dirName); } - - return true; + return include; }); await runGenerators(generatorConfigs, localRegistry, debug); @@ -243,7 +249,11 @@ export const generate = async ({ if (require.main === module) { program .description('Generate sandboxes from a set of possible templates') - .option('--template