@storybook/cli 6.5.0-alpha.38 โ†’ 6.5.0-alpha.41

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/dist/cjs/extract.js +7 -2
  2. package/dist/cjs/frameworks/angular/Header.stories.ts +8 -3
  3. package/dist/cjs/frameworks/angular/Page.stories.ts +12 -10
  4. package/dist/cjs/frameworks/angular/header.component.ts +30 -19
  5. package/dist/cjs/frameworks/angular/page.component.ts +13 -27
  6. package/dist/cjs/generators/REACT_SCRIPTS/index.js +9 -1
  7. package/dist/cjs/generators/baseGenerator.js +1 -1
  8. package/dist/cjs/initiate.js +2 -1
  9. package/dist/cjs/repro-generators/configs.js +9 -7
  10. package/dist/cjs/repro-generators/scripts.js +21 -12
  11. package/dist/cjs/repro.js +1 -0
  12. package/dist/cjs/versions.js +55 -55
  13. package/dist/esm/extract.js +7 -2
  14. package/dist/esm/frameworks/angular/Header.stories.ts +8 -3
  15. package/dist/esm/frameworks/angular/Page.stories.ts +12 -10
  16. package/dist/esm/frameworks/angular/header.component.ts +30 -19
  17. package/dist/esm/frameworks/angular/page.component.ts +13 -27
  18. package/dist/esm/generators/REACT_SCRIPTS/index.js +9 -1
  19. package/dist/esm/generators/baseGenerator.js +1 -1
  20. package/dist/esm/initiate.js +2 -1
  21. package/dist/esm/repro-generators/configs.js +9 -7
  22. package/dist/esm/repro-generators/scripts.js +21 -12
  23. package/dist/esm/repro.js +1 -0
  24. package/dist/esm/versions.js +55 -55
  25. package/dist/modern/extract.js +7 -2
  26. package/dist/modern/generators/REACT_SCRIPTS/index.js +9 -1
  27. package/dist/modern/generators/baseGenerator.js +1 -1
  28. package/dist/modern/initiate.js +2 -1
  29. package/dist/modern/repro-generators/configs.js +9 -7
  30. package/dist/modern/repro-generators/scripts.js +21 -12
  31. package/dist/modern/repro.js +1 -0
  32. package/dist/modern/versions.js +55 -55
  33. package/package.json +7 -7
@@ -1,4 +1,4 @@
1
- import { Component, Input, Output, EventEmitter } from '@angular/core';
1
+ import { Component } from '@angular/core';
2
2
  import { User } from './User';
3
3
 
4
4
  @Component({
@@ -6,9 +6,9 @@ import { User } from './User';
6
6
  template: `<article>
7
7
  <storybook-header
8
8
  [user]="user"
9
- (onLogout)="onLogout.emit($event)"
10
- (onLogin)="onLogin.emit($event)"
11
- (onCreateAccount)="onCreateAccount.emit($event)"
9
+ (onLogout)="doLogout()"
10
+ (onLogin)="doLogin()"
11
+ (onCreateAccount)="doCreateAccount()"
12
12
  ></storybook-header>
13
13
  <section>
14
14
  <h2>Pages in Storybook</h2>
@@ -61,31 +61,17 @@ import { User } from './User';
61
61
  styleUrls: ['./page.css'],
62
62
  })
63
63
  export default class PageComponent {
64
- @Input()
65
64
  user: User | null = null;
66
65
 
67
- @Output()
68
- onLogin = new EventEmitter<Event>();
66
+ doLogout() {
67
+ this.user = null;
68
+ }
69
69
 
70
- @Output()
71
- onLogout = new EventEmitter<Event>();
70
+ doLogin() {
71
+ this.user = { name: 'Jane Doe' };
72
+ }
72
73
 
73
- @Output()
74
- onCreateAccount = new EventEmitter<Event>();
74
+ doCreateAccount() {
75
+ this.user = { name: 'Jane Doe' };
76
+ }
75
77
  }
76
-
77
- // export const Page = ({ user, onLogin, onLogout, onCreateAccount }) => (
78
- // <article>
79
- // <Header user={user} onLogin={onLogin} onLogout={onLogout} onCreateAccount={onCreateAccount} />
80
-
81
- // );
82
- // Page.propTypes = {
83
- // user: PropTypes.shape({}),
84
- // onLogin: PropTypes.func.isRequired,
85
- // onLogout: PropTypes.func.isRequired,
86
- // onCreateAccount: PropTypes.func.isRequired,
87
- // };
88
-
89
- // Page.defaultProps = {
90
- // user: null,
91
- // };
@@ -44,7 +44,15 @@ const generator = async (packageManager, npmOptions, options) => {
44
44
  }) : options; // `@storybook/preset-create-react-app` has `@storybook/node-logger` as peerDep
45
45
 
46
46
  const extraPackages = ['@storybook/node-logger'];
47
- if (isCra5) extraPackages.push('webpack'); // preset v3 is compat with older versions of CRA, otherwise let version float
47
+
48
+ if (isCra5) {
49
+ extraPackages.push('webpack'); // Miscellaneous dependency used in `babel-preset-react-app` but not listed as dep there
50
+
51
+ extraPackages.push('babel-plugin-named-exports-order'); // Miscellaneous dependency to add to be sure Storybook + CRA is working fine with Yarn PnP mode
52
+
53
+ extraPackages.push('prop-types');
54
+ } // preset v3 is compat with older versions of CRA, otherwise let version float
55
+
48
56
 
49
57
  const extraAddons = [`@storybook/preset-create-react-app${isCra5 ? '' : '@3'}`];
50
58
  await (0, _baseGenerator.baseGenerator)(packageManager, npmOptions, updatedOptions, 'react', {
@@ -51,7 +51,7 @@ const builderDependencies = builder => {
51
51
 
52
52
  const stripVersions = addons => addons.map(addon => (0, _jsPackageManager.getPackageDetails)(addon)[0]);
53
53
 
54
- const hasInteractiveStories = framework => ['react'].includes(framework);
54
+ const hasInteractiveStories = framework => ['react', 'angular'].includes(framework);
55
55
 
56
56
  async function baseGenerator(packageManager, npmOptions, {
57
57
  language,
@@ -282,11 +282,12 @@ async function initiate(options, pkg) {
282
282
  } catch (ex) {
283
283
  done(ex.message);
284
284
  process.exit(1);
285
+ return;
285
286
  }
286
287
 
287
288
  done();
288
289
  await installStorybook(projectType, Object.assign({}, options, isEsm ? {
289
290
  commonJs: true
290
291
  } : undefined));
291
- return (0, _automigrate.automigrate)();
292
+ await (0, _automigrate.automigrate)();
292
293
  }
@@ -14,16 +14,16 @@ const cra = {
14
14
  framework: 'react',
15
15
  name: 'cra',
16
16
  version: 'latest',
17
- generator: [// Force npm otherwise we have a mess between Yarn 1 and Yarn 2
18
- 'npx create-react-app@{{version}} {{appName}} --use-npm', 'cd {{appName}}', 'echo "FAST_REFRESH=true" > .env', 'echo "SKIP_PREFLIGHT_CHECK=true" > .env'].join(' && ')
17
+ generator: [// Force npm otherwise we have a mess between Yarn 1, Yarn 2 and NPM
18
+ 'npm_config_user_agent=npm npx -p create-react-app@{{version}} create-react-app {{appName}}', 'cd {{appName}}', 'echo "FAST_REFRESH=true" > .env', 'echo "SKIP_PREFLIGHT_CHECK=true" > .env'].join(' && ')
19
19
  };
20
20
  exports.cra = cra;
21
21
  const cra_typescript = {
22
22
  framework: 'react',
23
23
  name: 'cra_typescript',
24
24
  version: 'latest',
25
- generator: [// Force npm otherwise we have a mess between Yarn 1 and Yarn 2
26
- 'npx create-react-app@{{version}} {{appName}} --template typescript --use-npm'].join(' && ')
25
+ generator: [// Force npm otherwise we have a mess between Yarn 1, Yarn 2 and NPM
26
+ 'npm_config_user_agent=npm npx -p create-react-app@{{version}} create-react-app {{appName}} --template typescript'].join(' && ')
27
27
  };
28
28
  exports.cra_typescript = cra_typescript;
29
29
  const react = {
@@ -62,7 +62,7 @@ const baseAngular = {
62
62
  framework: 'angular',
63
63
  name: 'angular',
64
64
  version: 'latest',
65
- generator: `npx --package @angular/cli@{{version}} ng new {{appName}} --routing=true --minimal=true --style=scss --skipInstall=true --strict`
65
+ generator: `npx -p @angular/cli@{{version}} ng new {{appName}} --routing=true --minimal=true --style=scss --skipInstall=true --strict`
66
66
  };
67
67
  const angular10 = Object.assign({}, baseAngular, {
68
68
  name: 'angular10',
@@ -117,7 +117,8 @@ exports.web_components_lit2 = web_components_lit2;
117
117
  const vue = {
118
118
  framework: 'vue',
119
119
  name: 'vue',
120
- version: 'latest',
120
+ // Be careful here, the latest versions of vue cli are bootstrapping a vue 3 project
121
+ version: '4',
121
122
  generator: [// Force npm otherwise we have a mess between Yarn 1 and Yarn 2
122
123
  `npx -p @vue/cli@{{version}} vue create {{appName}} --default --packageManager=npm --no-git --force`].join(' && ')
123
124
  };
@@ -151,7 +152,8 @@ const sfcVue = {
151
152
  framework: 'vue',
152
153
  name: 'sfcVue',
153
154
  version: 'latest',
154
- generator: fromDeps('vue', 'vue-loader', 'vue-template-compiler', 'webpack@webpack-4')
155
+ //
156
+ generator: fromDeps('vue@2.6', 'vue-loader@15.9', 'vue-template-compiler@2.6', 'webpack@webpack-4')
155
157
  };
156
158
  exports.sfcVue = sfcVue;
157
159
  const svelte = {
@@ -15,6 +15,8 @@ var _shelljs = _interopRequireDefault(require("shelljs"));
15
15
 
16
16
  var _chalk = _interopRequireDefault(require("chalk"));
17
17
 
18
+ var _configs = require("./configs");
19
+
18
20
  const _excluded = ["name", "version"];
19
21
 
20
22
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -38,17 +40,18 @@ const exec = async (command, options = {}, {
38
40
  silent: true
39
41
  };
40
42
 
41
- _shelljs.default.exec(command, Object.assign({}, defaultOptions, options), (code, stdout, stderr) => {
43
+ const child = _shelljs.default.exec(command, Object.assign({}, defaultOptions, options, {
44
+ async: true
45
+ }));
46
+
47
+ child.stderr.pipe(process.stderr);
48
+ child.stdout.pipe(process.stdout);
49
+ child.on('exit', code => {
42
50
  if (code === 0) {
43
51
  resolve(undefined);
44
52
  } else {
45
53
  logger.error(_chalk.default.red(`An error occurred while executing: \`${command}\``));
46
- logger.error(`Command output was:${_chalk.default.yellow(`\n${stdout}\n${stderr}`)}`);
47
-
48
- if (errorMessage) {
49
- logger.error(errorMessage);
50
- }
51
-
54
+ logger.log(errorMessage);
52
55
  reject(new Error(`command exited with code: ${code}: `));
53
56
  }
54
57
  });
@@ -59,10 +62,18 @@ exports.exec = exec;
59
62
 
60
63
  const installYarn2 = async ({
61
64
  cwd,
62
- pnp
65
+ pnp,
66
+ name
63
67
  }) => {
64
- const command = [`yarn set version berry`, `yarn config set enableGlobalCache true`, `yarn config set nodeLinker ${pnp ? 'pnp' : 'node-modules'}`].join(' && ');
65
- await exec(command, {
68
+ const command = [`yarn set version berry`, `yarn config set enableGlobalCache true`, `yarn config set nodeLinker ${pnp ? 'pnp' : 'node-modules'}`]; // FIXME: Some dependencies used by CRA aren't listed in its package.json
69
+ // Next line is a hack to remove as soon as CRA will have added these missing deps
70
+ // for details see https://github.com/facebook/create-react-app/pull/11751
71
+
72
+ if ([_configs.cra.name, _configs.cra_typescript.name].includes(name)) {
73
+ command.push(`yarn config set packageExtensions --json '{ "babel-preset-react-app@10.0.x": { "dependencies": { "@babel/plugin-proposal-private-property-in-object": "^7.16.0" } } }'`);
74
+ }
75
+
76
+ await exec(command.join(' && '), {
66
77
  cwd
67
78
  }, {
68
79
  startMessage: `๐Ÿงถ Installing Yarn 2`,
@@ -198,8 +209,6 @@ const createAndInit = async (cwd, _ref, {
198
209
  logger.log();
199
210
  logger.info(`๐Ÿƒ Starting for ${name} ${version}`);
200
211
  logger.log();
201
- logger.debug(options);
202
- logger.log();
203
212
  await doTask(generate, Object.assign({}, options, {
204
213
  cwd: options.creationPath
205
214
  }));
package/dist/esm/repro.js CHANGED
@@ -169,6 +169,7 @@ const repro = async ({
169
169
  }));
170
170
  } catch (error) {
171
171
  logger.error('๐Ÿšจ Failed to create repro');
172
+ throw new Error(error);
172
173
  }
173
174
  };
174
175
 
@@ -6,60 +6,60 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.default = void 0;
7
7
  // auto generated file, do not edit
8
8
  var _default = {
9
- "@storybook/addon-a11y": "6.5.0-alpha.38",
10
- "@storybook/addon-actions": "6.5.0-alpha.38",
11
- "@storybook/addon-backgrounds": "6.5.0-alpha.38",
12
- "@storybook/addon-controls": "6.5.0-alpha.38",
13
- "@storybook/addon-docs": "6.5.0-alpha.38",
14
- "@storybook/addon-essentials": "6.5.0-alpha.38",
15
- "@storybook/addon-interactions": "6.5.0-alpha.38",
16
- "@storybook/addon-jest": "6.5.0-alpha.38",
17
- "@storybook/addon-links": "6.5.0-alpha.38",
18
- "@storybook/addon-measure": "6.5.0-alpha.38",
19
- "@storybook/addon-outline": "6.5.0-alpha.38",
20
- "@storybook/addon-storyshots": "6.5.0-alpha.38",
21
- "@storybook/addon-storyshots-puppeteer": "6.5.0-alpha.38",
22
- "@storybook/addon-storysource": "6.5.0-alpha.38",
23
- "@storybook/addon-toolbars": "6.5.0-alpha.38",
24
- "@storybook/addon-viewport": "6.5.0-alpha.38",
25
- "@storybook/addons": "6.5.0-alpha.38",
26
- "@storybook/angular": "6.5.0-alpha.38",
27
- "@storybook/api": "6.5.0-alpha.38",
28
- "@storybook/builder-webpack4": "6.5.0-alpha.38",
29
- "@storybook/builder-webpack5": "6.5.0-alpha.38",
30
- "@storybook/channel-postmessage": "6.5.0-alpha.38",
31
- "@storybook/channel-websocket": "6.5.0-alpha.38",
32
- "@storybook/channels": "6.5.0-alpha.38",
33
- "@storybook/cli": "6.5.0-alpha.38",
34
- "@storybook/client-api": "6.5.0-alpha.38",
35
- "@storybook/client-logger": "6.5.0-alpha.38",
36
- "@storybook/codemod": "6.5.0-alpha.38",
37
- "@storybook/components": "6.5.0-alpha.38",
38
- "@storybook/core": "6.5.0-alpha.38",
39
- "@storybook/core-client": "6.5.0-alpha.38",
40
- "@storybook/core-common": "6.5.0-alpha.38",
41
- "@storybook/core-events": "6.5.0-alpha.38",
42
- "@storybook/core-server": "6.5.0-alpha.38",
43
- "@storybook/csf-tools": "6.5.0-alpha.38",
44
- "@storybook/ember": "6.5.0-alpha.38",
45
- "@storybook/html": "6.5.0-alpha.38",
46
- "@storybook/instrumenter": "6.5.0-alpha.38",
47
- "@storybook/manager-webpack4": "6.5.0-alpha.38",
48
- "@storybook/manager-webpack5": "6.5.0-alpha.38",
49
- "@storybook/node-logger": "6.5.0-alpha.38",
50
- "@storybook/postinstall": "6.5.0-alpha.38",
51
- "@storybook/preact": "6.5.0-alpha.38",
52
- "@storybook/preview-web": "6.5.0-alpha.38",
53
- "@storybook/react": "6.5.0-alpha.38",
54
- "@storybook/router": "6.5.0-alpha.38",
55
- "@storybook/server": "6.5.0-alpha.38",
56
- "@storybook/source-loader": "6.5.0-alpha.38",
57
- "@storybook/store": "6.5.0-alpha.38",
58
- "@storybook/svelte": "6.5.0-alpha.38",
59
- "@storybook/theming": "6.5.0-alpha.38",
60
- "@storybook/ui": "6.5.0-alpha.38",
61
- "@storybook/vue": "6.5.0-alpha.38",
62
- "@storybook/vue3": "6.5.0-alpha.38",
63
- "@storybook/web-components": "6.5.0-alpha.38"
9
+ "@storybook/addon-a11y": "6.5.0-alpha.41",
10
+ "@storybook/addon-actions": "6.5.0-alpha.41",
11
+ "@storybook/addon-backgrounds": "6.5.0-alpha.41",
12
+ "@storybook/addon-controls": "6.5.0-alpha.41",
13
+ "@storybook/addon-docs": "6.5.0-alpha.41",
14
+ "@storybook/addon-essentials": "6.5.0-alpha.41",
15
+ "@storybook/addon-interactions": "6.5.0-alpha.41",
16
+ "@storybook/addon-jest": "6.5.0-alpha.41",
17
+ "@storybook/addon-links": "6.5.0-alpha.41",
18
+ "@storybook/addon-measure": "6.5.0-alpha.41",
19
+ "@storybook/addon-outline": "6.5.0-alpha.41",
20
+ "@storybook/addon-storyshots": "6.5.0-alpha.41",
21
+ "@storybook/addon-storyshots-puppeteer": "6.5.0-alpha.41",
22
+ "@storybook/addon-storysource": "6.5.0-alpha.41",
23
+ "@storybook/addon-toolbars": "6.5.0-alpha.41",
24
+ "@storybook/addon-viewport": "6.5.0-alpha.41",
25
+ "@storybook/addons": "6.5.0-alpha.41",
26
+ "@storybook/angular": "6.5.0-alpha.41",
27
+ "@storybook/api": "6.5.0-alpha.41",
28
+ "@storybook/builder-webpack4": "6.5.0-alpha.41",
29
+ "@storybook/builder-webpack5": "6.5.0-alpha.41",
30
+ "@storybook/channel-postmessage": "6.5.0-alpha.41",
31
+ "@storybook/channel-websocket": "6.5.0-alpha.41",
32
+ "@storybook/channels": "6.5.0-alpha.41",
33
+ "@storybook/cli": "6.5.0-alpha.41",
34
+ "@storybook/client-api": "6.5.0-alpha.41",
35
+ "@storybook/client-logger": "6.5.0-alpha.41",
36
+ "@storybook/codemod": "6.5.0-alpha.41",
37
+ "@storybook/components": "6.5.0-alpha.41",
38
+ "@storybook/core": "6.5.0-alpha.41",
39
+ "@storybook/core-client": "6.5.0-alpha.41",
40
+ "@storybook/core-common": "6.5.0-alpha.41",
41
+ "@storybook/core-events": "6.5.0-alpha.41",
42
+ "@storybook/core-server": "6.5.0-alpha.41",
43
+ "@storybook/csf-tools": "6.5.0-alpha.41",
44
+ "@storybook/ember": "6.5.0-alpha.41",
45
+ "@storybook/html": "6.5.0-alpha.41",
46
+ "@storybook/instrumenter": "6.5.0-alpha.41",
47
+ "@storybook/manager-webpack4": "6.5.0-alpha.41",
48
+ "@storybook/manager-webpack5": "6.5.0-alpha.41",
49
+ "@storybook/node-logger": "6.5.0-alpha.41",
50
+ "@storybook/postinstall": "6.5.0-alpha.41",
51
+ "@storybook/preact": "6.5.0-alpha.41",
52
+ "@storybook/preview-web": "6.5.0-alpha.41",
53
+ "@storybook/react": "6.5.0-alpha.41",
54
+ "@storybook/router": "6.5.0-alpha.41",
55
+ "@storybook/server": "6.5.0-alpha.41",
56
+ "@storybook/source-loader": "6.5.0-alpha.41",
57
+ "@storybook/store": "6.5.0-alpha.41",
58
+ "@storybook/svelte": "6.5.0-alpha.41",
59
+ "@storybook/theming": "6.5.0-alpha.41",
60
+ "@storybook/ui": "6.5.0-alpha.41",
61
+ "@storybook/vue": "6.5.0-alpha.41",
62
+ "@storybook/vue3": "6.5.0-alpha.41",
63
+ "@storybook/web-components": "6.5.0-alpha.41"
64
64
  };
65
65
  exports.default = _default;
@@ -24,8 +24,13 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
24
24
  const read = async url => {
25
25
  const browser = await usePuppeteerBrowser();
26
26
  const page = await browser.newPage();
27
- await page.goto(url);
28
- await page.waitForFunction('window.__STORYBOOK_STORY_STORE__ && window.__STORYBOOK_STORY_STORE__.extract && window.__STORYBOOK_STORY_STORE__.extract()');
27
+ await page.goto(url); // we don't know whether we are running against a new or old storybook
28
+ // FIXME: add tests for both
29
+
30
+ await page.waitForFunction(`
31
+ (window.__STORYBOOK_PREVIEW__ && window.__STORYBOOK_PREVIEW__.extract && window.__STORYBOOK_PREVIEW__.extract()) ||
32
+ (window.__STORYBOOK_STORY_STORE__ && window.__STORYBOOK_STORY_STORE__.extract && window.__STORYBOOK_STORY_STORE__.extract())
33
+ `);
29
34
  const data = JSON.parse(await page.evaluate(async () => {
30
35
  // eslint-disable-next-line no-undef
31
36
  return JSON.stringify(window.__STORYBOOK_STORY_STORE__.getStoriesJsonData(), null, 2);
@@ -44,7 +44,15 @@ const generator = async (packageManager, npmOptions, options) => {
44
44
  }) : options; // `@storybook/preset-create-react-app` has `@storybook/node-logger` as peerDep
45
45
 
46
46
  const extraPackages = ['@storybook/node-logger'];
47
- if (isCra5) extraPackages.push('webpack'); // preset v3 is compat with older versions of CRA, otherwise let version float
47
+
48
+ if (isCra5) {
49
+ extraPackages.push('webpack'); // Miscellaneous dependency used in `babel-preset-react-app` but not listed as dep there
50
+
51
+ extraPackages.push('babel-plugin-named-exports-order'); // Miscellaneous dependency to add to be sure Storybook + CRA is working fine with Yarn PnP mode
52
+
53
+ extraPackages.push('prop-types');
54
+ } // preset v3 is compat with older versions of CRA, otherwise let version float
55
+
48
56
 
49
57
  const extraAddons = [`@storybook/preset-create-react-app${isCra5 ? '' : '@3'}`];
50
58
  await (0, _baseGenerator.baseGenerator)(packageManager, npmOptions, updatedOptions, 'react', {
@@ -51,7 +51,7 @@ const builderDependencies = builder => {
51
51
 
52
52
  const stripVersions = addons => addons.map(addon => (0, _jsPackageManager.getPackageDetails)(addon)[0]);
53
53
 
54
- const hasInteractiveStories = framework => ['react'].includes(framework);
54
+ const hasInteractiveStories = framework => ['react', 'angular'].includes(framework);
55
55
 
56
56
  async function baseGenerator(packageManager, npmOptions, {
57
57
  language,
@@ -282,11 +282,12 @@ async function initiate(options, pkg) {
282
282
  } catch (ex) {
283
283
  done(ex.message);
284
284
  process.exit(1);
285
+ return;
285
286
  }
286
287
 
287
288
  done();
288
289
  await installStorybook(projectType, Object.assign({}, options, isEsm ? {
289
290
  commonJs: true
290
291
  } : undefined));
291
- return (0, _automigrate.automigrate)();
292
+ await (0, _automigrate.automigrate)();
292
293
  }
@@ -14,16 +14,16 @@ const cra = {
14
14
  framework: 'react',
15
15
  name: 'cra',
16
16
  version: 'latest',
17
- generator: [// Force npm otherwise we have a mess between Yarn 1 and Yarn 2
18
- 'npx create-react-app@{{version}} {{appName}} --use-npm', 'cd {{appName}}', 'echo "FAST_REFRESH=true" > .env', 'echo "SKIP_PREFLIGHT_CHECK=true" > .env'].join(' && ')
17
+ generator: [// Force npm otherwise we have a mess between Yarn 1, Yarn 2 and NPM
18
+ 'npm_config_user_agent=npm npx -p create-react-app@{{version}} create-react-app {{appName}}', 'cd {{appName}}', 'echo "FAST_REFRESH=true" > .env', 'echo "SKIP_PREFLIGHT_CHECK=true" > .env'].join(' && ')
19
19
  };
20
20
  exports.cra = cra;
21
21
  const cra_typescript = {
22
22
  framework: 'react',
23
23
  name: 'cra_typescript',
24
24
  version: 'latest',
25
- generator: [// Force npm otherwise we have a mess between Yarn 1 and Yarn 2
26
- 'npx create-react-app@{{version}} {{appName}} --template typescript --use-npm'].join(' && ')
25
+ generator: [// Force npm otherwise we have a mess between Yarn 1, Yarn 2 and NPM
26
+ 'npm_config_user_agent=npm npx -p create-react-app@{{version}} create-react-app {{appName}} --template typescript'].join(' && ')
27
27
  };
28
28
  exports.cra_typescript = cra_typescript;
29
29
  const react = {
@@ -62,7 +62,7 @@ const baseAngular = {
62
62
  framework: 'angular',
63
63
  name: 'angular',
64
64
  version: 'latest',
65
- generator: `npx --package @angular/cli@{{version}} ng new {{appName}} --routing=true --minimal=true --style=scss --skipInstall=true --strict`
65
+ generator: `npx -p @angular/cli@{{version}} ng new {{appName}} --routing=true --minimal=true --style=scss --skipInstall=true --strict`
66
66
  };
67
67
  const angular10 = Object.assign({}, baseAngular, {
68
68
  name: 'angular10',
@@ -117,7 +117,8 @@ exports.web_components_lit2 = web_components_lit2;
117
117
  const vue = {
118
118
  framework: 'vue',
119
119
  name: 'vue',
120
- version: 'latest',
120
+ // Be careful here, the latest versions of vue cli are bootstrapping a vue 3 project
121
+ version: '4',
121
122
  generator: [// Force npm otherwise we have a mess between Yarn 1 and Yarn 2
122
123
  `npx -p @vue/cli@{{version}} vue create {{appName}} --default --packageManager=npm --no-git --force`].join(' && ')
123
124
  };
@@ -151,7 +152,8 @@ const sfcVue = {
151
152
  framework: 'vue',
152
153
  name: 'sfcVue',
153
154
  version: 'latest',
154
- generator: fromDeps('vue', 'vue-loader', 'vue-template-compiler', 'webpack@webpack-4')
155
+ //
156
+ generator: fromDeps('vue@2.6', 'vue-loader@15.9', 'vue-template-compiler@2.6', 'webpack@webpack-4')
155
157
  };
156
158
  exports.sfcVue = sfcVue;
157
159
  const svelte = {
@@ -15,6 +15,8 @@ var _shelljs = _interopRequireDefault(require("shelljs"));
15
15
 
16
16
  var _chalk = _interopRequireDefault(require("chalk"));
17
17
 
18
+ var _configs = require("./configs");
19
+
18
20
  const _excluded = ["name", "version"];
19
21
 
20
22
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -38,17 +40,18 @@ const exec = async (command, options = {}, {
38
40
  silent: true
39
41
  };
40
42
 
41
- _shelljs.default.exec(command, Object.assign({}, defaultOptions, options), (code, stdout, stderr) => {
43
+ const child = _shelljs.default.exec(command, Object.assign({}, defaultOptions, options, {
44
+ async: true
45
+ }));
46
+
47
+ child.stderr.pipe(process.stderr);
48
+ child.stdout.pipe(process.stdout);
49
+ child.on('exit', code => {
42
50
  if (code === 0) {
43
51
  resolve(undefined);
44
52
  } else {
45
53
  logger.error(_chalk.default.red(`An error occurred while executing: \`${command}\``));
46
- logger.error(`Command output was:${_chalk.default.yellow(`\n${stdout}\n${stderr}`)}`);
47
-
48
- if (errorMessage) {
49
- logger.error(errorMessage);
50
- }
51
-
54
+ logger.log(errorMessage);
52
55
  reject(new Error(`command exited with code: ${code}: `));
53
56
  }
54
57
  });
@@ -59,10 +62,18 @@ exports.exec = exec;
59
62
 
60
63
  const installYarn2 = async ({
61
64
  cwd,
62
- pnp
65
+ pnp,
66
+ name
63
67
  }) => {
64
- const command = [`yarn set version berry`, `yarn config set enableGlobalCache true`, `yarn config set nodeLinker ${pnp ? 'pnp' : 'node-modules'}`].join(' && ');
65
- await exec(command, {
68
+ const command = [`yarn set version berry`, `yarn config set enableGlobalCache true`, `yarn config set nodeLinker ${pnp ? 'pnp' : 'node-modules'}`]; // FIXME: Some dependencies used by CRA aren't listed in its package.json
69
+ // Next line is a hack to remove as soon as CRA will have added these missing deps
70
+ // for details see https://github.com/facebook/create-react-app/pull/11751
71
+
72
+ if ([_configs.cra.name, _configs.cra_typescript.name].includes(name)) {
73
+ command.push(`yarn config set packageExtensions --json '{ "babel-preset-react-app@10.0.x": { "dependencies": { "@babel/plugin-proposal-private-property-in-object": "^7.16.0" } } }'`);
74
+ }
75
+
76
+ await exec(command.join(' && '), {
66
77
  cwd
67
78
  }, {
68
79
  startMessage: `๐Ÿงถ Installing Yarn 2`,
@@ -198,8 +209,6 @@ const createAndInit = async (cwd, _ref, {
198
209
  logger.log();
199
210
  logger.info(`๐Ÿƒ Starting for ${name} ${version}`);
200
211
  logger.log();
201
- logger.debug(options);
202
- logger.log();
203
212
  await doTask(generate, Object.assign({}, options, {
204
213
  cwd: options.creationPath
205
214
  }));
@@ -169,6 +169,7 @@ const repro = async ({
169
169
  }));
170
170
  } catch (error) {
171
171
  logger.error('๐Ÿšจ Failed to create repro');
172
+ throw new Error(error);
172
173
  }
173
174
  };
174
175