ember-cli 4.8.0 → 4.9.0

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 (39) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/LICENSE +1 -1
  3. package/bin/ember +3 -0
  4. package/blueprints/addon/additional-package.json +19 -0
  5. package/blueprints/addon/files/npmignore +0 -1
  6. package/blueprints/addon/index.js +18 -18
  7. package/blueprints/app/files/.ember-cli +3 -3
  8. package/blueprints/app/files/.eslintrc.js +12 -3
  9. package/blueprints/app/files/app/{app.js → app.ts} +0 -0
  10. package/blueprints/app/files/app/{router.js → router.ts} +3 -1
  11. package/blueprints/app/files/config/environment.js +1 -0
  12. package/blueprints/app/files/package.json +22 -19
  13. package/blueprints/app/files/tests/helpers/{index.js → index.ts} +4 -3
  14. package/blueprints/app/files/tests/{test-helper.js → test-helper.ts} +0 -0
  15. package/blueprints/app/index.js +10 -0
  16. package/docs/build/data.json +44 -44
  17. package/lib/commands/addon.js +1 -0
  18. package/lib/commands/destroy.js +1 -1
  19. package/lib/commands/generate.js +2 -10
  20. package/lib/commands/init.js +1 -0
  21. package/lib/commands/new.js +32 -4
  22. package/lib/models/asset-size-printer.js +1 -1
  23. package/lib/models/blueprint.js +24 -1
  24. package/lib/models/builder.js +13 -6
  25. package/lib/models/project.js +2 -1
  26. package/lib/models/server-watcher.js +2 -2
  27. package/lib/models/watcher.js +23 -6
  28. package/lib/tasks/build-watch.js +9 -7
  29. package/lib/tasks/generate-from-blueprint.js +1 -1
  30. package/lib/tasks/install-blueprint.js +1 -1
  31. package/lib/tasks/interactive-new.js +153 -0
  32. package/lib/tasks/npm-task.js +1 -1
  33. package/lib/tasks/serve.js +10 -8
  34. package/lib/utilities/find-build-file.js +17 -9
  35. package/lib/utilities/lint-fix.js +11 -10
  36. package/package.json +12 -10
  37. package/blueprints/addon/additional-dev-dependencies.json +0 -8
  38. package/blueprints/addon/files/addon-config/environment.js +0 -5
  39. package/blueprints/app/files/vendor/.gitkeep +0 -0
@@ -35,13 +35,15 @@ class BuildWatchTask extends Task {
35
35
 
36
36
  let watcher =
37
37
  options._watcher ||
38
- new Watcher({
39
- ui,
40
- builder,
41
- analytics: this.analytics,
42
- options,
43
- ignored: [path.resolve(this.project.root, options.outputPath)],
44
- });
38
+ (
39
+ await Watcher.build({
40
+ ui,
41
+ builder,
42
+ analytics: this.analytics,
43
+ options,
44
+ ignored: [path.resolve(this.project.root, options.outputPath)],
45
+ })
46
+ ).watcher;
45
47
 
46
48
  await watcher;
47
49
  // Run until failure or signal to exit
@@ -17,7 +17,7 @@ class GenerateTask extends Task {
17
17
 
18
18
  if (options.lintFix) {
19
19
  try {
20
- await lintFix.run(this.ui);
20
+ await lintFix.run(this.project);
21
21
  } catch (error) {
22
22
  logger.error('Lint fix failed: %o', error);
23
23
  }
@@ -51,7 +51,7 @@ class InstallBlueprintTask extends Task {
51
51
 
52
52
  if (options.lintFix) {
53
53
  try {
54
- await lintFix.run(this.ui);
54
+ await lintFix.run(this.project);
55
55
  } catch (error) {
56
56
  logger.error('Lint fix failed: %o', error);
57
57
  }
@@ -0,0 +1,153 @@
1
+ 'use strict';
2
+
3
+ const inquirer = require('inquirer');
4
+ const { isLangCode } = require('is-language-code');
5
+ const osLocale = require('os-locale');
6
+
7
+ const Task = require('../models/task');
8
+ const isValidProjectName = require('../utilities/valid-project-name');
9
+
10
+ const DEFAULT_LOCALE = 'en-US';
11
+
12
+ class InteractiveNewTask extends Task {
13
+ async run(newCommandOptions, _testAnswers) {
14
+ let prompt = inquirer.createPromptModule();
15
+ let questions = await this.getQuestions(newCommandOptions);
16
+ let answers = await prompt(questions, _testAnswers);
17
+
18
+ answers.lang = answers.langSelection || answers.langDifferent;
19
+
20
+ delete answers.langSelection;
21
+ delete answers.langDifferent;
22
+
23
+ return answers;
24
+ }
25
+
26
+ async getQuestions(newCommandOptions = {}) {
27
+ return [
28
+ {
29
+ name: 'blueprint',
30
+ type: 'list',
31
+ message: 'Is this an app or an addon?',
32
+ choices: [
33
+ {
34
+ name: 'App',
35
+ value: 'app',
36
+ },
37
+ {
38
+ name: 'Addon',
39
+ value: 'addon',
40
+ },
41
+ ],
42
+ },
43
+ {
44
+ name: 'name',
45
+ type: 'input',
46
+ message: ({ blueprint }) => `Please provide the name of your ${blueprint}:`,
47
+ when: !newCommandOptions.name,
48
+ validate: (name) => {
49
+ if (name) {
50
+ if (isValidProjectName(name)) {
51
+ return true;
52
+ }
53
+
54
+ return `We currently do not support \`${name}\` as a name.`;
55
+ }
56
+
57
+ return 'Please provide a name.';
58
+ },
59
+ },
60
+ {
61
+ name: 'langSelection',
62
+ type: 'list',
63
+ message: ({ blueprint }) => `Please provide the spoken/content language of your ${blueprint}:`,
64
+ when: !newCommandOptions.lang,
65
+ choices: await this.getLangChoices(),
66
+ },
67
+ {
68
+ name: 'langDifferent',
69
+ type: 'input',
70
+ message: 'Please provide the different language:',
71
+ when: ({ langSelection } = {}) => !newCommandOptions.lang && !langSelection,
72
+ validate: (lang) => {
73
+ if (isLangCode(lang).res) {
74
+ return true;
75
+ }
76
+
77
+ return 'Please provide a valid locale code.';
78
+ },
79
+ },
80
+ {
81
+ name: 'packageManager',
82
+ type: 'list',
83
+ message: 'Pick the package manager to use when installing dependencies:',
84
+ when: !newCommandOptions.yarn,
85
+ choices: [
86
+ {
87
+ name: 'NPM',
88
+ value: 'npm',
89
+ },
90
+ {
91
+ name: 'Yarn',
92
+ value: 'yarn',
93
+ },
94
+ {
95
+ name: 'Ignore/Skip',
96
+ value: null,
97
+ },
98
+ ],
99
+ },
100
+ {
101
+ name: 'ciProvider',
102
+ type: 'list',
103
+ message: 'Which CI provider do you want to use?',
104
+ when: !newCommandOptions.ciProvider,
105
+ choices: [
106
+ {
107
+ name: 'GitHub Actions',
108
+ value: 'github',
109
+ },
110
+ {
111
+ name: 'Travis CI',
112
+ value: 'travis',
113
+ },
114
+ {
115
+ name: 'Ignore/Skip',
116
+ value: null,
117
+ },
118
+ ],
119
+ },
120
+ ];
121
+ }
122
+
123
+ async getLangChoices() {
124
+ let userLocale = await this.getUserLocale();
125
+ let langChoices = [
126
+ {
127
+ name: DEFAULT_LOCALE,
128
+ value: DEFAULT_LOCALE,
129
+ },
130
+ ];
131
+
132
+ if (userLocale !== DEFAULT_LOCALE) {
133
+ langChoices.push({
134
+ name: userLocale,
135
+ value: userLocale,
136
+ });
137
+ }
138
+
139
+ langChoices.push({
140
+ name: 'I want to manually provide a different language',
141
+ value: null,
142
+ });
143
+
144
+ return langChoices;
145
+ }
146
+
147
+ getUserLocale() {
148
+ return osLocale();
149
+ }
150
+ }
151
+
152
+ module.exports = InteractiveNewTask;
153
+ module.exports.DEFAULT_LOCALE = DEFAULT_LOCALE;
@@ -26,7 +26,7 @@ class NpmTask extends Task {
26
26
  // The command to run: can be 'install' or 'uninstall'
27
27
  this.command = '';
28
28
 
29
- this.versionConstraints = '3 || 4 || 5 || 6';
29
+ this.versionConstraints = '3 || 4 || 5 || 6 || 7 || 8';
30
30
  }
31
31
 
32
32
  get packageManagerOutputName() {
@@ -55,14 +55,16 @@ class ServeTask extends Task {
55
55
 
56
56
  let watcher =
57
57
  options._watcher ||
58
- new Watcher({
59
- ui: this.ui,
60
- builder,
61
- analytics: this.analytics,
62
- options,
63
- serving: true,
64
- ignored: [path.resolve(this.project.root, options.outputPath)],
65
- });
58
+ (
59
+ await Watcher.build({
60
+ ui: this.ui,
61
+ builder,
62
+ analytics: this.analytics,
63
+ options,
64
+ serving: true,
65
+ ignored: [path.resolve(this.project.root, options.outputPath)],
66
+ })
67
+ ).watcher;
66
68
 
67
69
  let serverRoot = './server';
68
70
  let serverWatcher = null;
@@ -1,24 +1,32 @@
1
1
  'use strict';
2
2
  const findUp = require('find-up');
3
3
  const path = require('path');
4
+ const url = require('url');
4
5
 
5
- module.exports = function (file, dir) {
6
- let buildFilePath = findUp.sync(file, { cwd: dir });
6
+ module.exports = async function (dir) {
7
+ let buildFilePath = null;
7
8
 
8
- // Note: In the future this should throw
9
- if (!buildFilePath) {
9
+ for (let ext of ['js', 'mjs', 'cjs']) {
10
+ let candidate = findUp.sync(`ember-cli-build.${ext}`, { cwd: dir });
11
+ if (candidate) {
12
+ buildFilePath = candidate;
13
+ break;
14
+ }
15
+ }
16
+
17
+ if (buildFilePath === null) {
10
18
  return null;
11
19
  }
12
20
 
13
21
  process.chdir(path.dirname(buildFilePath));
14
22
 
15
- let buildFile = null;
23
+ let buildFileUrl = url.pathToFileURL(buildFilePath);
16
24
  try {
17
- buildFile = require(buildFilePath);
25
+ // eslint-disable-next-line node/no-unsupported-features/es-syntax
26
+ let fn = (await import(buildFileUrl)).default;
27
+ return fn;
18
28
  } catch (err) {
19
- err.message = `Could not require '${file}': ${err.message}`;
29
+ err.message = `Could not \`import('${buildFileUrl}')\`: ${err.message}`;
20
30
  throw err;
21
31
  }
22
-
23
- return buildFile;
24
32
  };
@@ -1,26 +1,27 @@
1
1
  'use strict';
2
2
 
3
- const fs = require('fs-extra');
4
3
  const execa = require('../utilities/execa');
4
+ const isYarnProject = require('../utilities/is-yarn-project');
5
+ const prependEmoji = require('../utilities/prepend-emoji');
5
6
 
6
- async function run(ui) {
7
+ async function run(project) {
7
8
  let lintFixScriptName = 'lint:fix';
8
- let cwd = process.cwd();
9
- let packageJson = fs.readJsonSync('package.json');
10
-
11
- let hasLintFixScript = !!packageJson.scripts[lintFixScriptName];
9
+ let hasLintFixScript = Boolean(project.pkg.scripts[lintFixScriptName]);
12
10
 
13
11
  if (!hasLintFixScript) {
14
- ui.writeWarnLine(
15
- 'Lint fix skipped: "lint:fix" not found in package.json scripts. New files might not pass linting.'
12
+ project.ui.writeWarnLine(
13
+ `Lint fix skipped: "${lintFixScriptName}" script not found in "package.json". New files might not pass linting.`
16
14
  );
17
15
 
18
16
  return;
19
17
  }
20
18
 
21
- let usingYarn = fs.existsSync('yarn.lock');
19
+ project.ui.writeLine('');
20
+ project.ui.writeLine(prependEmoji('✨', `Running "${lintFixScriptName}" script...`));
21
+
22
+ let cwd = process.cwd();
22
23
 
23
- if (usingYarn) {
24
+ if (isYarnProject(project.root)) {
24
25
  await execa('yarn', [lintFixScriptName], { cwd });
25
26
  } else {
26
27
  await execa('npm', ['run', lintFixScriptName], { cwd });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ember-cli",
3
- "version": "4.8.0",
3
+ "version": "4.9.0",
4
4
  "description": "Command line tool for developing ambitious ember.js apps",
5
5
  "keywords": [
6
6
  "app",
@@ -37,7 +37,7 @@
37
37
  "test:slow": "node --unhandled-rejections=strict tests/runner slow"
38
38
  },
39
39
  "dependencies": {
40
- "@babel/core": "^7.18.13",
40
+ "@babel/core": "^7.19.3",
41
41
  "@babel/plugin-transform-modules-amd": "^7.18.6",
42
42
  "amd-name-resolver": "^1.3.1",
43
43
  "babel-plugin-module-resolver": "^4.1.0",
@@ -61,7 +61,7 @@
61
61
  "calculate-cache-key-for-tree": "^2.0.0",
62
62
  "capture-exit": "^2.0.0",
63
63
  "chalk": "^4.1.2",
64
- "ci-info": "^3.3.2",
64
+ "ci-info": "^3.4.0",
65
65
  "clean-base-url": "^1.0.0",
66
66
  "compression": "^1.7.4",
67
67
  "configstore": "^5.0.1",
@@ -79,7 +79,7 @@
79
79
  "execa": "^5.1.1",
80
80
  "exit": "^0.1.2",
81
81
  "express": "^4.18.1",
82
- "filesize": "^9.0.11",
82
+ "filesize": "^10.0.5",
83
83
  "find-up": "^5.0.0",
84
84
  "find-yarn-workspace-root": "^2.0.0",
85
85
  "fixturify-project": "^2.1.1",
@@ -87,13 +87,14 @@
87
87
  "fs-tree-diff": "^2.0.1",
88
88
  "get-caller-file": "^2.0.5",
89
89
  "git-repo-info": "^2.1.1",
90
- "glob": "^7.2.0",
90
+ "glob": "^8.0.3",
91
91
  "heimdalljs": "^0.2.6",
92
92
  "heimdalljs-fs-monitor": "^1.1.1",
93
93
  "heimdalljs-graph": "^1.0.0",
94
94
  "heimdalljs-logger": "^0.1.10",
95
95
  "http-proxy": "^1.18.1",
96
96
  "inflection": "^1.13.1",
97
+ "inquirer": "^8.2.1",
97
98
  "is-git-url": "^1.0.0",
98
99
  "is-language-code": "^3.1.0",
99
100
  "isbinaryfile": "^5.0.0",
@@ -105,9 +106,10 @@
105
106
  "minimatch": "^5.1.0",
106
107
  "morgan": "^1.10.0",
107
108
  "nopt": "^3.0.6",
108
- "npm-package-arg": "^9.1.0",
109
+ "npm-package-arg": "^9.1.2",
110
+ "os-locale": "^5.0.0",
109
111
  "p-defer": "^3.0.0",
110
- "portfinder": "^1.0.29",
112
+ "portfinder": "^1.0.32",
111
113
  "promise-map-series": "^0.3.0",
112
114
  "promise.hash.helper": "^1.0.8",
113
115
  "quick-temp": "^0.1.8",
@@ -121,7 +123,7 @@
121
123
  "sort-package-json": "^1.57.0",
122
124
  "symlink-or-copy": "^1.3.1",
123
125
  "temp": "0.9.4",
124
- "testem": "^3.8.0",
126
+ "testem": "^3.9.0",
125
127
  "tiny-lr": "^2.0.0",
126
128
  "tree-sync": "^2.1.0",
127
129
  "uuid": "^8.3.2",
@@ -141,7 +143,7 @@
141
143
  "chai-jest-snapshot": "^2.0.0",
142
144
  "ember-cli-blueprint-test-helpers": "^0.19.2",
143
145
  "ember-cli-internal-test-helpers": "^0.9.1",
144
- "eslint": "^8.23.0",
146
+ "eslint": "^8.24.0",
145
147
  "eslint-config-prettier": "^8.5.0",
146
148
  "eslint-plugin-chai-expect": "^3.0.0",
147
149
  "eslint-plugin-mocha": "^10.1.0",
@@ -154,7 +156,7 @@
154
156
  "nock": "^13.2.9",
155
157
  "nyc": "^15.1.0",
156
158
  "prettier": "2.7.1",
157
- "release-it": "^15.4.1",
159
+ "release-it": "^15.4.2",
158
160
  "rimraf": "^3.0.2",
159
161
  "strip-ansi": "^6.0.0",
160
162
  "supertest": "^6.2.4",
@@ -1,8 +0,0 @@
1
- {
2
- "devDependencies": {
3
- "@embroider/test-setup": "^1.8.3",
4
- "ember-disable-prototype-extensions": "^1.1.3",
5
- "ember-try": "^2.0.0",
6
- "ember-source-channel-url": "^3.0.0"
7
- }
8
- }
@@ -1,5 +0,0 @@
1
- 'use strict';
2
-
3
- module.exports = function (/* environment, appConfig */) {
4
- return {};
5
- };
File without changes