Skip to content

Commit

Permalink
Merge pull request #19480 from storybookjs/fix-repro-generation
Browse files Browse the repository at this point in the history
  • Loading branch information
tmeasday authored Oct 14, 2022
2 parents 349b2e5 + ca066a8 commit 15e534a
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 20 deletions.
34 changes: 16 additions & 18 deletions code/lib/cli/src/repro-templates.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const craTemplates = {
'cra/default-js': {
name: 'Create React App (Javascript)',
script: 'npx create-react-app {{beforeDir}}',
script: 'npx create-react-app .',
cadence: ['ci', 'daily', 'weekly'],
expected: {
framework: '@storybook/cra',
Expand All @@ -11,7 +11,7 @@ const craTemplates = {
},
'cra/default-ts': {
name: 'Create React App (Typescript)',
script: 'npx create-react-app {{beforeDir}} --template typescript',
script: 'npx create-react-app . --template typescript',
cadence: ['ci', 'daily', 'weekly'],
// Re-enable once https://github.com/storybookjs/storybook/issues/19351 is fixed.
skipTasks: ['smoke-test'],
Expand All @@ -26,7 +26,7 @@ const craTemplates = {
const reactViteTemplates = {
'react-vite/default-js': {
name: 'React Vite (JS)',
script: 'yarn create vite {{beforeDir}} --template react',
script: 'yarn create vite . --template react',
cadence: ['ci', 'daily', 'weekly'],
expected: {
framework: '@storybook/react-vite',
Expand All @@ -36,7 +36,7 @@ const reactViteTemplates = {
},
'react-vite/default-ts': {
name: 'React Vite (TS)',
script: 'yarn create vite {{beforeDir}} --template react-ts',
script: 'yarn create vite . --template react-ts',
cadence: ['ci', 'daily', 'weekly'],
expected: {
framework: '@storybook/react-vite',
Expand All @@ -49,7 +49,7 @@ const reactViteTemplates = {
const reactWebpackTemplates = {
'react-webpack/18-ts': {
name: 'React Webpack5 (TS)',
script: 'yarn create webpack5-react {{beforeDir}}',
script: 'yarn create webpack5-react .',
cadence: ['ci', 'daily', 'weekly'],
expected: {
framework: '@storybook/react-webpack5',
Expand All @@ -59,8 +59,7 @@ const reactWebpackTemplates = {
},
'react-webpack/17-ts': {
name: 'React Webpack5 (TS)',
script:
'yarn create webpack5-react {{beforeDir}} --version-react="17" --version-react-dom="17"',
script: 'yarn create webpack5-react . --version-react="17" --version-react-dom="17"',
cadence: ['ci', 'daily', 'weekly'],
expected: {
framework: '@storybook/react-webpack5',
Expand All @@ -73,7 +72,7 @@ const reactWebpackTemplates = {
const vue3ViteTemplates = {
'vue3-vite/default-js': {
name: 'Vue3 Vite (JS)',
script: 'yarn create vite {{beforeDir}} --template vue',
script: 'yarn create vite . --template vue',
cadence: ['ci', 'daily', 'weekly'],
expected: {
framework: '@storybook/vue3-vite',
Expand All @@ -83,7 +82,7 @@ const vue3ViteTemplates = {
},
'vue3-vite/default-ts': {
name: 'Vue3 Vite (TS)',
script: 'yarn create vite {{beforeDir}} --template vue-ts',
script: 'yarn create vite . --template vue-ts',
cadence: ['ci', 'daily', 'weekly'],
expected: {
framework: '@storybook/vue3-vite',
Expand All @@ -100,7 +99,7 @@ const vue2ViteTemplates = {
// We don't really want to maintain weird custom scripts like this,
// preferring community bootstrap scripts / generators instead.
script:
'yarn create vite {{beforeDir}} --template vanilla && yarn add --dev @vitejs/plugin-vue2 vue-template-compiler vue@2 && echo "import vue2 from \'@vitejs/plugin-vue2\';\n\nexport default {\n\tplugins: [vue2()]\n};" > vite.config.js',
'yarn create vite . --template vanilla && yarn add --dev @vitejs/plugin-vue2 vue-template-compiler vue@2 && echo "import vue2 from \'@vitejs/plugin-vue2\';\n\nexport default {\n\tplugins: [vue2()]\n};" > vite.config.js',
cadence: ['ci', 'daily', 'weekly'],
// Re-enable once https://github.com/storybookjs/storybook/issues/19351 is fixed.
skipTasks: ['smoke-test'],
Expand All @@ -115,7 +114,7 @@ const vue2ViteTemplates = {
const htmlWebpackTemplates = {
'html-webpack/default': {
name: 'HTML Webpack5',
script: 'yarn create webpack5-html {{beforeDir}}',
script: 'yarn create webpack5-html .',
cadence: ['ci', 'daily', 'weekly'],
expected: {
framework: '@storybook/html-webpack5',
Expand All @@ -128,7 +127,7 @@ const htmlWebpackTemplates = {
const svelteViteTemplates = {
'svelte-vite/default-js': {
name: 'Svelte Vite (JS)',
script: 'yarn create vite {{beforeDir}} --template svelte',
script: 'yarn create vite . --template svelte',
cadence: ['ci', 'daily', 'weekly'],
expected: {
framework: '@storybook/svelte-vite',
Expand All @@ -138,7 +137,7 @@ const svelteViteTemplates = {
},
'svelte-vite/default-ts': {
name: 'Svelte Vite (TS)',
script: 'yarn create vite {{beforeDir}} --template svelte-ts',
script: 'yarn create vite . --template svelte-ts',
cadence: ['ci', 'daily', 'weekly'],
// Re-enable once https://github.com/storybookjs/storybook/issues/19351 is fixed.
skipTasks: ['smoke-test'],
Expand Down Expand Up @@ -205,7 +204,7 @@ const angularCliTemplates = {
const litViteTemplates = {
'lit-vite/default-js': {
name: 'Lit Vite (JS)',
script: 'yarn create vite {{beforeDir}} --template lit',
script: 'yarn create vite . --template lit',
cadence: ['ci', 'daily', 'weekly'] as any,
// Re-enable once https://github.com/storybookjs/storybook/issues/19351 is fixed.
skipTasks: ['smoke-test'],
Expand All @@ -217,7 +216,7 @@ const litViteTemplates = {
},
'lit-vite/default-ts': {
name: 'Lit Vite (TS)',
script: 'yarn create vite {{beforeDir}} --template lit-ts',
script: 'yarn create vite . --template lit-ts',
cadence: ['ci', 'daily', 'weekly'] as any,
// Re-enable once https://github.com/storybookjs/storybook/issues/19351 is fixed.
skipTasks: ['smoke-test'],
Expand All @@ -232,8 +231,7 @@ const litViteTemplates = {
const vueCliTemplates = {
'vue-cli/default-js': {
name: 'Vue-CLI (Default JS)',
script:
'npx -p @vue/cli vue create {{beforeDir}} --default --packageManager=yarn --force --merge',
script: 'npx -p @vue/cli vue create . --default --packageManager=yarn --force --merge',
cadence: ['ci', 'daily', 'weekly'],
skipTasks: [
// Re-enable once https://github.com/storybookjs/storybook/issues/19351 is fixed.
Expand All @@ -250,7 +248,7 @@ const vueCliTemplates = {
'vue-cli/vue2-default-js': {
name: 'Vue-CLI (Vue2 JS)',
script:
'npx -p @vue/cli vue create {{beforeDir}} --default --packageManager=yarn --force --merge --preset=Default\\ (Vue\\ 2)',
'npx -p @vue/cli vue create . --default --packageManager=yarn --force --merge --preset="Default (Vue 2)"',
cadence: ['ci', 'daily', 'weekly'],
skipTasks: [
// Re-enable once https://github.com/storybookjs/storybook/issues/19351 is fixed.
Expand Down
14 changes: 12 additions & 2 deletions scripts/next-repro-generators/generate-repros.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { runRegistry } from '../tasks/run-registry';
const OUTPUT_DIRECTORY = join(__dirname, '..', '..', 'repros');
const BEFORE_DIR_NAME = 'before-storybook';
const AFTER_DIR_NAME = 'after-storybook';
const SCRIPT_TIMEOUT = 5 * 60 * 1000;

const sbInit = async (cwd: string, flags?: string[]) => {
const sbCliBinaryPath = join(__dirname, `../../code/lib/cli/bin/index.js`);
Expand Down Expand Up @@ -136,8 +137,17 @@ const runGenerators = async (
await setupYarn({ cwd: createBaseDir });

const createBeforeDir = join(createBaseDir, BEFORE_DIR_NAME);
const scriptWithBeforeDir = script.replace('{{beforeDir}}', createBeforeDir);
await runCommand(scriptWithBeforeDir, { cwd: createBaseDir });

// Some tools refuse to run inside an existing directory and replace the contents,
// where as others are very picky about what directories can be called. So we need to
// handle different modes of operation.
if (script.includes('{{beforeDir}}')) {
const scriptWithBeforeDir = script.replace('{{beforeDir}}', BEFORE_DIR_NAME);
await runCommand(scriptWithBeforeDir, { cwd: createBaseDir, timeout: SCRIPT_TIMEOUT });
} else {
await ensureDir(createBeforeDir);
await runCommand(script, { cwd: createBeforeDir, timeout: SCRIPT_TIMEOUT });
}

await localizeYarnConfigFiles(createBaseDir, createBeforeDir);

Expand Down

0 comments on commit 15e534a

Please sign in to comment.