Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: cli repros creation not working on windows #18337

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions lib/cli/src/repro-generators/configs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ export interface Parameters {
typescript?: boolean;
/** Merge configurations to main.js before running the tests */
mainOverrides?: Partial<StorybookConfig> & Record<string, any>;
/** Environment variables to inject while running generator */
envs?: Record<string, string>;
}

const fromDeps = (...args: string[]): string =>
Expand All @@ -39,11 +41,12 @@ export const cra: Parameters = {
version: 'latest',
generator: [
// Force npm otherwise we have a mess between Yarn 1, Yarn 2 and NPM
'npm_config_user_agent=npm npx -p create-react-app@{{version}} create-react-app {{appName}}',
'npx -p create-react-app@{{version}} create-react-app {{appName}}',
'cd {{appName}}',
'echo "FAST_REFRESH=true" > .env',
'echo "SKIP_PREFLIGHT_CHECK=true" > .env',
].join(' && '),
envs: { npm_config_user_agent: 'npm' },
};

export const cra_typescript: Parameters = {
Expand All @@ -52,8 +55,9 @@ export const cra_typescript: Parameters = {
version: 'latest',
generator: [
// Force npm otherwise we have a mess between Yarn 1, Yarn 2 and NPM
'npm_config_user_agent=npm npx -p create-react-app@{{version}} create-react-app {{appName}} --template typescript',
'npx -p create-react-app@{{version}} create-react-app {{appName}} --template typescript',
].join(' && '),
envs: { npm_config_user_agent: 'npm' },
};

export const react: Parameters = {
Expand Down
6 changes: 4 additions & 2 deletions lib/cli/src/repro-generators/scripts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ export interface Parameters {
additionalDeps?: string[];
/** Add typescript dependency and creates a tsconfig.json file */
typescript?: boolean;
/** Environment variables to inject while running generator */
envs?: Record<string, string>;
}

interface Configuration {
Expand Down Expand Up @@ -123,12 +125,12 @@ const configureYarn2ForE2E = async ({ cwd }: Options) => {
);
};

const generate = async ({ cwd, name, appName, version, generator }: Options) => {
const generate = async ({ cwd, name, appName, version, generator, envs }: Options) => {
const command = generator.replace(/{{appName}}/g, appName).replace(/{{version}}/g, version);

await exec(
command,
{ cwd },
{ cwd, env: { ...process.env, ...envs } },
{
startMessage: `🏗 Bootstrapping ${name} project (this might take a few minutes)`,
errorMessage: `🚨 Bootstrapping ${name} failed`,
Expand Down