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

Build: Fix CRA repro generator and e2e test in PnP mode #17375

Merged
merged 32 commits into from
Feb 18, 2022
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
d3305f8
fix e2e tests and update the CI version of node
ndelangen Feb 1, 2022
bacafa2
improve
ndelangen Feb 1, 2022
b35acc8
cleanup
ndelangen Feb 1, 2022
dd736ce
add missing per deps
ndelangen Feb 1, 2022
78a0b46
Merge branch 'next' into fix/e2e-cra
ndelangen Feb 1, 2022
930eb3a
might as well try this
ndelangen Feb 1, 2022
6c24eba
set version of @mdx-js/react to 1.x.x
ndelangen Feb 1, 2022
16bb465
sigh
ndelangen Feb 1, 2022
1dfd34c
I hope this is the last one
ndelangen Feb 1, 2022
f04451b
fix?
ndelangen Feb 1, 2022
45b8257
try and zip the & see if adding 'assert' polyfill helps
ndelangen Feb 2, 2022
0bae768
what do I say at this point?
ndelangen Feb 2, 2022
1e19a05
Merge branch 'next' into fix/e2e-cra
ndelangen Feb 2, 2022
873bf53
well, that's one way to do it I guess, sorry
ndelangen Feb 2, 2022
5eda531
Merge branch 'next' into fix/e2e-cra
ndelangen Feb 2, 2022
e233456
Merge branch 'next' into fix/e2e-cra
ndelangen Feb 11, 2022
d737c52
change back to use pnp
ndelangen Feb 11, 2022
a76c99a
fix a new error
ndelangen Feb 11, 2022
b775930
remove peerDependencies that are already specified in peerDependencie…
ndelangen Feb 11, 2022
c13a0fa
add regenerator-runtime to where it is needed
ndelangen Feb 11, 2022
3bf5571
add excemption to lint warnings
ndelangen Feb 11, 2022
bfc1a40
fix linting
ndelangen Feb 11, 2022
4cfc80c
Add some dependencies in CRA template generator
gaetanmaisse Feb 13, 2022
f517d56
Add tmp workaround to fix CRA repro in PnP mode
gaetanmaisse Feb 17, 2022
27c5007
Merge branch 'next' into fix/e2e-cra
gaetanmaisse Feb 17, 2022
cf55644
Rely on `peerDependenciesMeta` only for some packages
gaetanmaisse Feb 17, 2022
4c46e48
Force use of NPM during bootstrap of CRA repros
gaetanmaisse Jan 19, 2022
eb2f559
Add missing peer dep in addon-essentials
gaetanmaisse Feb 17, 2022
2851adb
Ignore eslint warning
gaetanmaisse Feb 17, 2022
e1a3dae
Use fixed versions for Vue packages in repro generator
gaetanmaisse Feb 17, 2022
dd4ae47
Remove wrongly committed packageExtensions
gaetanmaisse Feb 17, 2022
4abf608
Update yarn.lock
gaetanmaisse Feb 17, 2022
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
38 changes: 22 additions & 16 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: 2.1

executors:
sb_node_12_classic:
sb_node_14_classic:
parameters:
class:
description: The Resource class
Expand All @@ -10,11 +10,11 @@ executors:
default: 'medium'
working_directory: /tmp/storybook
docker:
- image: circleci/node:12
- image: circleci/node:14
environment:
NODE_OPTIONS: --max_old_space_size=3076
resource_class: <<parameters.class>>
sb_node_12_browsers:
sb_node_14_browsers:
parameters:
class:
description: The Resource class
Expand All @@ -23,7 +23,7 @@ executors:
default: 'medium'
working_directory: /tmp/storybook
docker:
- image: circleci/node:12-browsers
- image: circleci/node:14-browsers
environment:
NODE_OPTIONS: --max_old_space_size=3076
resource_class: <<parameters.class>>
Expand Down Expand Up @@ -79,14 +79,14 @@ jobs:
build:
executor:
class: xlarge
name: sb_node_12_classic
name: sb_node_14_classic
steps:
- git-shallow-clone/checkout_advanced:
clone_options: '--depth 1 --verbose'
- restore_cache:
name: Restore Yarn cache
keys:
- build-yarn-2-cache-v1--{{ checksum "yarn.lock" }}
- build-yarn-2-cache-v2--{{ checksum "yarn.lock" }}
- run:
name: Install dependencies
command: yarn install --immutable
Expand All @@ -95,7 +95,7 @@ jobs:
command: yarn bootstrap --core
- save_cache:
name: Save Yarn cache
key: build-yarn-2-cache-v1--{{ checksum "yarn.lock" }}
key: build-yarn-2-cache-v2--{{ checksum "yarn.lock" }}
paths:
- ~/.yarn/berry/cache
- persist_to_workspace:
Expand All @@ -107,7 +107,7 @@ jobs:
- app
- lib
chromatic:
executor: sb_node_12_browsers
executor: sb_node_14_browsers
parallelism: 4
steps:
# Keep using default checkout because Chromatic needs some git history to work properly
Expand All @@ -121,7 +121,7 @@ jobs:
packtracker:
executor:
class: medium
name: sb_node_12_browsers
name: sb_node_14_browsers
steps:
- git-shallow-clone/checkout_advanced:
clone_options: '--depth 1 --verbose'
Expand All @@ -135,7 +135,7 @@ jobs:
examples:
executor:
class: medium
name: sb_node_12_browsers
name: sb_node_14_browsers
parallelism: 4
steps:
- git-shallow-clone/checkout_advanced:
Expand All @@ -153,7 +153,7 @@ jobs:
publish:
executor:
class: medium
name: sb_node_12_classic
name: sb_node_14_classic
steps:
- git-shallow-clone/checkout_advanced:
clone_options: '--depth 1 --verbose'
Expand Down Expand Up @@ -269,10 +269,16 @@ jobs:
command: yarn wait-on http://localhost:6000
- run:
name: run e2e tests
command: yarn test:e2e-framework --pnp sfcVue cra
command: yarn test:e2e-framework --pnp cra
- run:
name: run e2e tests
command: yarn test:e2e-framework --pnp sfcVue
- store_artifacts:
path: /tmp/cypress-record
destination: cypress
- store_artifacts:
path: /tmp/storybook-e2e-testing
destination: e2e
e2e-tests-examples:
executor:
class: small
Expand All @@ -298,7 +304,7 @@ jobs:
smoke-tests:
executor:
class: medium
name: sb_node_12_browsers
name: sb_node_14_browsers
environment:
# Disable ESLint when running smoke tests to improve perf + As of CRA 4.0.3, CRA kitchen sinks are throwing
# because of some ESLint warnings, related to: https://github.com/facebook/create-react-app/pull/10590
Expand Down Expand Up @@ -356,7 +362,7 @@ jobs:
lint:
executor:
class: small
name: sb_node_12_classic
name: sb_node_14_classic
steps:
- git-shallow-clone/checkout_advanced:
clone_options: '--depth 1 --verbose'
Expand All @@ -366,7 +372,7 @@ jobs:
name: Lint
command: yarn lint
unit-tests:
executor: sb_node_12_browsers
executor: sb_node_14_browsers
steps:
- git-shallow-clone/checkout_advanced:
clone_options: '--depth 1 --verbose'
Expand All @@ -382,7 +388,7 @@ jobs:
coverage:
executor:
class: small
name: sb_node_12_browsers
name: sb_node_14_browsers
steps:
- git-shallow-clone/checkout_advanced:
clone_options: '--depth 1 --verbose'
Expand Down
16 changes: 16 additions & 0 deletions app/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,29 @@
},
"peerDependencies": {
"@babel/core": "^7.11.5",
"@storybook/builder-webpack4": "6.5.0-alpha.33",
"@storybook/builder-webpack5": "6.5.0-alpha.33",
"@storybook/manager-webpack4": "6.5.0-alpha.33",
"@storybook/manager-webpack5": "6.5.0-alpha.33",
"react": "^16.8.0 || ^17.0.0",
"react-dom": "^16.8.0 || ^17.0.0"
},
"peerDependenciesMeta": {
"@babel/core": {
"optional": true
},
"@storybook/builder-webpack4": {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to add these?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because there is @storybook/core as dep and it has @storybook/builder-webpack4 as optional peer dep itself, so we need to add it to satisfy transitivity. Maël did a post about it some time ago: https://dev.to/arcanis/implicit-transitive-peer-dependencies-ed0

"optional": true
},
"@storybook/builder-webpack5": {
"optional": true
},
"@storybook/manager-webpack4": {
"optional": true
},
"@storybook/manager-webpack5": {
"optional": true
},
"typescript": {
"optional": true
}
Expand Down
2 changes: 1 addition & 1 deletion lib/cli/src/generators/baseGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export async function baseGenerator(
const addonPackages = [...addons, '@storybook/addon-actions'];

const yarn2Dependencies =
packageManager.type === 'yarn2' ? ['@storybook/addon-docs', '@mdx-js/react'] : [];
packageManager.type === 'yarn2' ? ['@storybook/addon-docs', '@mdx-js/react@1.x.x'] : [];
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shilman version lock it to v1


const files = await fse.readdir(process.cwd());
const isNewFolder = !files.some(
Expand Down
3 changes: 2 additions & 1 deletion lib/cli/src/initiate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ export async function initiate(options: CommandOptions, pkg: Package): Promise<v
} catch (ex) {
done(ex.message);
process.exit(1);
return;
}
done();

Expand All @@ -333,5 +334,5 @@ export async function initiate(options: CommandOptions, pkg: Package): Promise<v
...(isEsm ? { commonJs: true } : undefined),
});

return automigrate();
await automigrate();
}
19 changes: 16 additions & 3 deletions lib/cli/src/repro-generators/configs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,21 @@ export const cra: Parameters = {
name: 'cra',
version: 'latest',
generator: [
// hacky way to get CRA to get booted with yarn berry
`npm init -y`,
`yarn set version classic`,
`yarn install`,

// just some sanity checks
'yarn -v',
'pwd',

// Force npm otherwise we have a mess between Yarn 1 and Yarn 2
'npx create-react-app@{{version}} {{appName}} --use-npm',
'npx -p create-react-app@{{version}} create-react-app {{appName}}',

// cleanup after the hacky work around from above
'rm -rf node_modules yarn.lock package.json',

'cd {{appName}}',
'echo "FAST_REFRESH=true" > .env',
'echo "SKIP_PREFLIGHT_CHECK=true" > .env',
Expand All @@ -49,7 +62,7 @@ export const cra_typescript: Parameters = {
version: 'latest',
generator: [
// Force npm otherwise we have a mess between Yarn 1 and Yarn 2
'npx create-react-app@{{version}} {{appName}} --template typescript --use-npm',
'npx -p create-react-app@{{version}} create-react-app {{appName}} --template typescript --use-npm',
].join(' && '),
};

Expand Down Expand Up @@ -96,7 +109,7 @@ const baseAngular: Parameters = {
framework: 'angular',
name: 'angular',
version: 'latest',
generator: `npx --package @angular/cli@{{version}} ng new {{appName}} --routing=true --minimal=true --style=scss --skipInstall=true --strict`,
generator: `npx -p @angular/cli@{{version}} ng new {{appName}} --routing=true --minimal=true --style=scss --skipInstall=true --strict`,
};

export const angular10: Parameters = {
Expand Down
19 changes: 9 additions & 10 deletions lib/cli/src/repro-generators/scripts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,17 @@ export const exec = async (
const defaultOptions: ExecOptions = {
silent: true,
};
shell.exec(command, { ...defaultOptions, ...options }, (code, stdout, stderr) => {
const child = shell.exec(command, { ...defaultOptions, ...options, async: true });

child.stderr.pipe(process.stderr);
child.stdout.pipe(process.stdout);

child.on('exit', (code) => {
if (code === 0) {
resolve(undefined);
} else {
logger.error(chalk.red(`An error occurred while executing: \`${command}\``));
logger.error(`Command output was:${chalk.yellow(`\n${stdout}\n${stderr}`)}`);
if (errorMessage) {
logger.error(errorMessage);
}
logger.log(errorMessage);
reject(new Error(`command exited with code: ${code}: `));
}
});
Expand Down Expand Up @@ -105,6 +107,8 @@ const configureYarn2ForE2E = async ({ cwd }: Options) => {
const generate = async ({ cwd, name, appName, version, generator }: Options) => {
const command = generator.replace(/{{appName}}/g, appName).replace(/{{version}}/g, version);

console.log('generate', { command, generator });
gaetanmaisse marked this conversation as resolved.
Show resolved Hide resolved

await exec(
command,
{ cwd },
Expand Down Expand Up @@ -205,15 +209,10 @@ export const createAndInit = async (
logger.log();
logger.info(`🏃 Starting for ${name} ${version}`);
logger.log();
logger.debug(options);
logger.log();

await doTask(generate, { ...options, cwd: options.creationPath });

await doTask(installYarn2, options);

await doTask(configureYarn2ForE2E, options, e2e);

await doTask(addTypescript, options, !!options.typescript);
await doTask(addRequiredDeps, options);
await doTask(initStorybook, options);
Expand Down
1 change: 1 addition & 0 deletions lib/cli/src/repro.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ export const repro = async ({
);
} catch (error) {
logger.error('🚨 Failed to create repro');
throw new Error(error);
}
};

Expand Down
Loading