ember-cli 6.9.0-alpha.1 → 6.9.0-beta.1

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 (36) hide show
  1. package/CHANGELOG.md +100 -167
  2. package/RELEASE.md +20 -13
  3. package/blueprints/http-mock/index.js +6 -1
  4. package/blueprints/http-proxy/index.js +6 -1
  5. package/blueprints/server/index.js +8 -1
  6. package/docs/build/data.json +75 -50
  7. package/lib/commands/addon.js +1 -1
  8. package/lib/commands/asset-sizes.js +8 -0
  9. package/lib/commands/build.js +39 -4
  10. package/lib/commands/destroy.js +15 -1
  11. package/lib/commands/generate.js +15 -1
  12. package/lib/commands/init.js +1 -7
  13. package/lib/commands/new.js +3 -3
  14. package/lib/commands/serve.js +18 -1
  15. package/lib/commands/test.js +25 -2
  16. package/lib/models/command.js +7 -0
  17. package/lib/models/project.js +17 -1
  18. package/lib/tasks/install-blueprint.js +5 -0
  19. package/package.json +8 -8
  20. package/packages/addon-blueprint/index.js +1 -1
  21. package/packages/addon-blueprint/package.json +5 -4
  22. package/packages/app-blueprint/files/.ember-cli +2 -2
  23. package/packages/app-blueprint/files/package.json +13 -13
  24. package/packages/app-blueprint/package.json +5 -4
  25. package/packages/blueprint-blueprint/files/blueprints/__name__/files/.gitkeep +0 -0
  26. package/packages/blueprint-blueprint/files/blueprints/__name__/index.js +0 -16
  27. package/packages/blueprint-blueprint/index.js +0 -5
  28. package/packages/blueprint-blueprint/package.json +0 -12
  29. package/packages/blueprint-model/package.json +0 -18
  30. package/packages/blueprint-model/utilities/directory-for-package-name.js +0 -31
  31. package/packages/blueprint-model/utilities/edit-file-diff.js +0 -64
  32. package/packages/blueprint-model/utilities/experiments.js +0 -63
  33. package/packages/blueprint-model/utilities/file-info.js +0 -170
  34. package/packages/blueprint-model/utilities/open-editor.js +0 -44
  35. package/packages/blueprint-model/utilities/prepend-emoji.js +0 -12
  36. package/packages/blueprint-model/utilities/process-template.js +0 -10
@@ -72,7 +72,7 @@ module.exports = Command.extend({
72
72
  {
73
73
  name: 'strict',
74
74
  type: Boolean,
75
- default: false,
75
+ default: true,
76
76
  description: 'Use GJS/GTS templates by default for generated components, tests, and route templates',
77
77
  },
78
78
  ],
@@ -83,7 +83,7 @@ module.exports = Command.extend({
83
83
 
84
84
  async run(commandOptions, rawArgs) {
85
85
  deprecate(
86
- "Don't use `--embroider` option. Use `-b @ember/app-blueprint` instead.",
86
+ "Don't use `--embroider` option. Generating a new project will use the latest Vite-based embroider by default.",
87
87
  !commandOptions.embroider,
88
88
  DEPRECATIONS.EMBROIDER.options
89
89
  );
@@ -160,7 +160,7 @@ module.exports = Command.extend({
160
160
  initCommand.project.root = process.cwd();
161
161
 
162
162
  deprecate(
163
- "Don't use `--embroider` option. Use `-b @ember/app-blueprint` instead.",
163
+ "Don't use `--embroider` option. Generating a new project will use the latest Vite-based embroider by default.",
164
164
  !commandOptions.embroider,
165
165
  DEPRECATIONS.EMBROIDER.options
166
166
  );
@@ -10,7 +10,8 @@ const DEFAULT_PORT = 4200;
10
10
 
11
11
  module.exports = Command.extend({
12
12
  name: 'serve',
13
- description: 'Builds and serves your app, rebuilding on file changes.',
13
+ description: 'Vestigial command in Vite-based projects. Use the `start` script from package.json instead.',
14
+ skipHelp: true,
14
15
  aliases: ['server', 's'],
15
16
 
16
17
  availableOptions: [
@@ -88,7 +89,23 @@ module.exports = Command.extend({
88
89
  { name: 'path', type: 'Path', description: 'Reuse an existing build at given path.' },
89
90
  ],
90
91
 
92
+ init() {
93
+ this._super.apply(this, arguments);
94
+ if (!this.isViteProject) {
95
+ this.skipHelp = false;
96
+ this.description = 'Builds and serves your app, rebuilding on file changes.';
97
+ }
98
+ },
99
+
91
100
  async run(commandOptions) {
101
+ if (this.isViteProject) {
102
+ return Promise.reject(
103
+ new SilentError(
104
+ 'The `serve` command is not supported in Vite-based projects. Please use the `start` script from package.json.'
105
+ )
106
+ );
107
+ }
108
+
92
109
  commandOptions.liveReloadHost = commandOptions.liveReloadHost || commandOptions.host;
93
110
 
94
111
  let wrappedCommandOptions = await this._checkOrGetPort(commandOptions);
@@ -16,6 +16,11 @@ temp.track();
16
16
 
17
17
  let defaultPort = 7357;
18
18
 
19
+ const ClassicOptions = [
20
+ { name: 'server', type: Boolean, default: false, aliases: ['s'] },
21
+ { name: 'output-path', type: 'Path', aliases: ['o'] },
22
+ ];
23
+
19
24
  module.exports = Command.extend({
20
25
  name: 'test',
21
26
  description: "Runs your app's test suite.",
@@ -30,7 +35,6 @@ module.exports = Command.extend({
30
35
  description: 'Possible values are "development", "production", and "test".',
31
36
  },
32
37
  { name: 'config-file', type: String, aliases: ['c', 'cf'] },
33
- { name: 'server', type: Boolean, default: false, aliases: ['s'] },
34
38
  { name: 'host', type: String, aliases: ['H'] },
35
39
  {
36
40
  name: 'test-port',
@@ -77,12 +81,15 @@ module.exports = Command.extend({
77
81
  { name: 'test-page', type: String, description: 'Test page to invoke' },
78
82
  { name: 'path', type: 'Path', description: 'Reuse an existing build at given path.' },
79
83
  { name: 'query', type: String, description: 'A query string to append to the test page URL.' },
80
- { name: 'output-path', type: 'Path', aliases: ['o'] },
81
84
  ],
82
85
 
83
86
  init() {
84
87
  this._super.apply(this, arguments);
85
88
 
89
+ if (!this.isViteProject) {
90
+ this.availableOptions = this.availableOptions.concat(ClassicOptions);
91
+ }
92
+
86
93
  // Make sure Testem supports the Wasm MIME type:
87
94
  require('express').static.mime.define({ 'application/wasm': ['wasm'] });
88
95
 
@@ -162,6 +169,22 @@ module.exports = Command.extend({
162
169
  },
163
170
 
164
171
  async run(commandOptions) {
172
+ if (this.isViteProject) {
173
+ if (commandOptions.outputPath) {
174
+ return Promise.reject(
175
+ new SilentError('The `--output-path` option to `ember test` is not supported in Vite-based projects.')
176
+ );
177
+ }
178
+
179
+ if (commandOptions.server) {
180
+ return Promise.reject(
181
+ new SilentError(
182
+ 'The `--server` option to `ember test` is not supported in Vite-based projects. Please use the `start` script from package.json and visit `/tests` in the browser.'
183
+ )
184
+ );
185
+ }
186
+ }
187
+
165
188
  let hasBuild = !!commandOptions.path;
166
189
  let outputPath;
167
190
 
@@ -89,6 +89,13 @@ let Command = CoreObject.extend({
89
89
  */
90
90
  this.isWithinProject = this.project.isEmberCLIProject();
91
91
 
92
+ /**
93
+ * @final
94
+ * @property isViteProject
95
+ * @type Boolean
96
+ */
97
+ this.isViteProject = this.isWithinProject && this.project.isViteProject?.();
98
+
92
99
  /**
93
100
  * The name of the command.
94
101
  *
@@ -140,6 +140,10 @@ class Project {
140
140
  return false;
141
141
  };
142
142
 
143
+ NULL_PROJECT.isViteProject = function () {
144
+ return false;
145
+ };
146
+
143
147
  NULL_PROJECT.isEmberCLIAddon = function () {
144
148
  return false;
145
149
  };
@@ -168,7 +172,7 @@ class Project {
168
172
 
169
173
  /**
170
174
  Returns whether or not this is an Ember CLI project.
171
- This checks whether ember-cli is listed in devDependencies.
175
+ This checks whether ember-cli is listed in (dev)Dependencies.
172
176
 
173
177
  @private
174
178
  @method isEmberCLIProject
@@ -178,6 +182,18 @@ class Project {
178
182
  return (this.cli ? this.cli.npmPackage : 'ember-cli') in this.dependencies();
179
183
  }
180
184
 
185
+ /**
186
+ Returns whether this is a Vite-based project.
187
+ This checks whether @embroider/vite is listed in (dev)Dependencies.
188
+
189
+ @private
190
+ @method isViteProject
191
+ @return {Boolean} Whether this is a Vite project
192
+ */
193
+ isViteProject() {
194
+ return '@embroider/vite' in this.dependencies(); // This would preferably be `isClassicProject` as Vite is the default now, but it is tough to come up with a metric
195
+ }
196
+
181
197
  /**
182
198
  Returns whether or not this is an Ember CLI addon.
183
199
 
@@ -13,6 +13,7 @@ const npa = require('npm-package-arg');
13
13
  const lintFix = require('../utilities/lint-fix');
14
14
 
15
15
  const logger = require('heimdalljs-logger')('ember-cli:tasks:install-blueprint');
16
+ const { isExperimentEnabled } = require('@ember-tooling/blueprint-model/utilities/experiments');
16
17
 
17
18
  const NOT_FOUND_REGEXP = /npm ERR! 404 {2}'(\S+)' is not in the npm registry/;
18
19
 
@@ -61,6 +62,10 @@ class InstallBlueprintTask extends Task {
61
62
  name = name || 'app';
62
63
  logger.info(`Resolving blueprint "${name}" ...`);
63
64
 
65
+ if (isExperimentEnabled('VITE') && name === 'app') {
66
+ return Blueprint.load(path.dirname(require.resolve('@ember/app-blueprint')));
67
+ }
68
+
64
69
  let blueprint;
65
70
  try {
66
71
  blueprint = await this._lookupLocalBlueprint(name);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ember-cli",
3
- "version": "6.9.0-alpha.1",
3
+ "version": "6.9.0-beta.1",
4
4
  "description": "Command line tool for developing ambitious ember.js apps",
5
5
  "keywords": [
6
6
  "app",
@@ -31,11 +31,13 @@
31
31
  "minor": "prerelease",
32
32
  "patch": "prerelease"
33
33
  },
34
- "semverIncrementTag": "alpha",
35
- "publishTag": "alpha"
34
+ "semverIncrementTag": "beta",
35
+ "publishTag": "beta"
36
36
  },
37
37
  "dependencies": {
38
- "@ember/app-blueprint": "6.9.0-alpha.1",
38
+ "@ember-tooling/blueprint-blueprint": "^0.2.1",
39
+ "@ember-tooling/blueprint-model": "^0.4.1",
40
+ "@ember/app-blueprint": "~6.9.0-beta.1",
39
41
  "@pnpm/find-workspace-dir": "^1000.1.0",
40
42
  "babel-remove-types": "^1.0.1",
41
43
  "broccoli": "^3.5.2",
@@ -118,10 +120,8 @@
118
120
  "watch-detector": "^1.0.2",
119
121
  "workerpool": "^9.2.0",
120
122
  "yam": "^1.0.0",
121
- "@ember-tooling/blueprint-blueprint": "0.2.0",
122
- "@ember-tooling/blueprint-model": "0.4.0",
123
- "@ember-tooling/classic-build-addon-blueprint": "6.9.0-alpha.1",
124
- "@ember-tooling/classic-build-app-blueprint": "6.9.0-alpha.1"
123
+ "@ember-tooling/classic-build-addon-blueprint": "6.9.0-beta.1",
124
+ "@ember-tooling/classic-build-app-blueprint": "6.9.0-beta.1"
125
125
  },
126
126
  "devDependencies": {
127
127
  "broccoli-plugin": "^4.0.3",
@@ -134,7 +134,7 @@ module.exports = {
134
134
  * _ts_eslint.config.mjs is renamed to eslint.config.mjs
135
135
  */
136
136
  buildFileInfo(intoDir, templateVariables, file, commandOptions) {
137
- if (file.startsWith('_js_') || file.startsWith('_ts_')) {
137
+ if (file.includes('_js_') || file.includes('_ts_')) {
138
138
  let fileInfo = this._super.buildFileInfo.apply(this, arguments);
139
139
 
140
140
  if (file.includes('_js_')) {
@@ -1,16 +1,17 @@
1
1
  {
2
2
  "name": "@ember-tooling/classic-build-addon-blueprint",
3
- "version": "6.9.0-alpha.1",
3
+ "version": "6.9.0-beta.1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/ember-cli/ember-cli.git",
7
7
  "directory": "packages/addon-blueprint"
8
8
  },
9
+ "license": "MIT",
9
10
  "keywords": [
10
11
  "ember-blueprint"
11
12
  ],
12
13
  "dependencies": {
13
- "@ember-tooling/blueprint-model": "workspace:*",
14
+ "@ember-tooling/blueprint-model": "^0.4.1",
14
15
  "chalk": "^4.1.2",
15
16
  "ember-cli-normalize-entity-name": "^1.0.0",
16
17
  "ember-cli-string-utils": "^1.1.0",
@@ -25,7 +26,7 @@
25
26
  "minor": "prerelease",
26
27
  "patch": "prerelease"
27
28
  },
28
- "semverIncrementTag": "alpha",
29
- "publishTag": "alpha"
29
+ "semverIncrementTag": "beta",
30
+ "publishTag": "beta"
30
31
  }
31
32
  }
@@ -7,13 +7,13 @@
7
7
 
8
8
  /**
9
9
  Setting `componentAuthoringFormat` to "strict" will force the blueprint generators to generate GJS
10
- or GTS files for the component and the component rendering test. "loose" is the default.
10
+ or GTS files for the component and the component rendering test. "strict" is the default.
11
11
  */
12
12
  "componentAuthoringFormat": <%= strict ? '"strict"' : '"loose"' %>,
13
13
 
14
14
  /**
15
15
  Setting `routeAuthoringFormat` to "strict" will force the blueprint generators to generate GJS
16
- or GTS templates for routes. "loose" is the default
16
+ or GTS templates for routes. "strict" is the default
17
17
  */
18
18
  "routeAuthoringFormat": <%= strict ? '"strict"' : '"loose"' %>
19
19
  }
@@ -45,22 +45,22 @@
45
45
  "@ember/test-helpers": "^5.3.0<% if (embroider) { %>",
46
46
  "@embroider/compat": "^3.9.1",
47
47
  "@embroider/core": "^3.5.7<% } %>",
48
- "@embroider/macros": "^1.18.1<% if (embroider) { %>",
48
+ "@embroider/macros": "^1.19.1<% if (embroider) { %>",
49
49
  "@embroider/webpack": "^4.1.1<% } %>",
50
- "@eslint/js": "^9.35.0",
50
+ "@eslint/js": "^9.37.0",
51
51
  "@glimmer/component": "^2.0.0",
52
52
  "@glimmer/tracking": "^1.1.2<% if (typescript) { %>",
53
53
  "@glint/environment-ember-loose": "^1.5.2",
54
54
  "@glint/environment-ember-template-imports": "^1.5.2",
55
- "@glint/template": "^1.5.2",
55
+ "@glint/template": "^1.6.1",
56
56
  "@tsconfig/ember": "^3.0.11",
57
57
  "@types/qunit": "^2.19.13",
58
58
  "@types/rsvp": "^4.0.9<% if (emberData) {%>",
59
59
  "@warp-drive/core-types": "~5.7.0<% }} %>",
60
60
  "broccoli-asset-rev": "^3.0.0",
61
61
  "concurrently": "^9.2.1",
62
- "ember-auto-import": "^2.10.0",
63
- "ember-cli": "~6.9.0-alpha.1",
62
+ "ember-auto-import": "^2.11.1",
63
+ "ember-cli": "~6.9.0-beta.1",
64
64
  "ember-cli-app-version": "^7.0.0",
65
65
  "ember-cli-babel": "^8.2.0",
66
66
  "ember-cli-clean-css": "^3.0.0",
@@ -76,27 +76,27 @@
76
76
  "ember-page-title": "^9.0.3",
77
77
  "ember-qunit": "^9.0.4",
78
78
  "ember-resolver": "^13.1.1",
79
- "ember-source": "~6.9.0-alpha.1",
79
+ "ember-source": "~6.9.0-beta.1",
80
80
  "ember-template-imports": "^4.3.0",
81
81
  "ember-template-lint": "^6.1.0<% if (welcome) { %>",
82
82
  "ember-welcome-page": "^7.0.2<% } %>",
83
- "eslint": "^9.35.0",
83
+ "eslint": "^9.37.0",
84
84
  "eslint-config-prettier": "^9.1.2",
85
85
  "eslint-plugin-ember": "^12.7.4",
86
- "eslint-plugin-n": "^17.23.0",
86
+ "eslint-plugin-n": "^17.23.1",
87
87
  "eslint-plugin-qunit": "^8.2.5",
88
88
  "globals": "^15.15.0",
89
89
  "loader.js": "^4.7.0",
90
90
  "prettier": "^3.6.2",
91
91
  "prettier-plugin-ember-template-tag": "^2.1.0",
92
- "qunit": "^2.24.1",
92
+ "qunit": "^2.24.2",
93
93
  "qunit-dom": "^3.5.0",
94
- "stylelint": "^16.24.0",
94
+ "stylelint": "^16.25.0",
95
95
  "stylelint-config-standard": "^36.0.1",
96
96
  "tracked-built-ins": "^3.4.0<% if (typescript) { %>",
97
- "typescript": "^5.9.2",
98
- "typescript-eslint": "^8.44.0<% } %>",
99
- "webpack": "^5.101.3"
97
+ "typescript": "^5.9.3",
98
+ "typescript-eslint": "^8.46.1<% } %>",
99
+ "webpack": "^5.102.1"
100
100
  },
101
101
  "engines": {
102
102
  "node": ">= 20.11"
@@ -1,16 +1,17 @@
1
1
  {
2
2
  "name": "@ember-tooling/classic-build-app-blueprint",
3
- "version": "6.9.0-alpha.1",
3
+ "version": "6.9.0-beta.1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/ember-cli/ember-cli.git",
7
7
  "directory": "packages/app-blueprint"
8
8
  },
9
+ "license": "MIT",
9
10
  "keywords": [
10
11
  "ember-blueprint"
11
12
  ],
12
13
  "dependencies": {
13
- "@ember-tooling/blueprint-model": "workspace:*",
14
+ "@ember-tooling/blueprint-model": "^0.4.1",
14
15
  "chalk": "^4.1.2",
15
16
  "ember-cli-string-utils": "^1.1.0"
16
17
  },
@@ -19,7 +20,7 @@
19
20
  "minor": "prerelease",
20
21
  "patch": "prerelease"
21
22
  },
22
- "semverIncrementTag": "alpha",
23
- "publishTag": "alpha"
23
+ "semverIncrementTag": "beta",
24
+ "publishTag": "beta"
24
25
  }
25
26
  }
@@ -1,16 +0,0 @@
1
- 'use strict';
2
-
3
- module.exports = {
4
- description: ''
5
-
6
- // locals(options) {
7
- // // Return custom template variables here.
8
- // return {
9
- // foo: options.entity.options.foo
10
- // };
11
- // }
12
-
13
- // afterInstall(options) {
14
- // // Perform extra work here.
15
- // }
16
- };
@@ -1,5 +0,0 @@
1
- 'use strict';
2
-
3
- module.exports = {
4
- description: 'Generates a blueprint and definition.',
5
- };
@@ -1,12 +0,0 @@
1
- {
2
- "name": "@ember-tooling/blueprint-blueprint",
3
- "version": "0.2.0",
4
- "repository": {
5
- "type": "git",
6
- "url": "https://github.com/ember-cli/ember-cli.git",
7
- "directory": "packages/blueprint-blueprint"
8
- },
9
- "keywords": [
10
- "ember-blueprint"
11
- ]
12
- }
@@ -1,18 +0,0 @@
1
- {
2
- "name": "@ember-tooling/blueprint-model",
3
- "version": "0.4.0",
4
- "repository": {
5
- "type": "git",
6
- "url": "https://github.com/ember-cli/ember-cli.git",
7
- "directory": "packages/blueprint-model"
8
- },
9
- "dependencies": {
10
- "chalk": "^4.1.2",
11
- "diff": "^7.0.0",
12
- "isbinaryfile": "^5.0.4",
13
- "lodash": "^4.17.21",
14
- "promise.hash.helper": "^1.0.8",
15
- "quick-temp": "^0.1.8",
16
- "silent-error": "^1.1.1"
17
- }
18
- }
@@ -1,31 +0,0 @@
1
- 'use strict';
2
-
3
- const path = require('path');
4
-
5
- /**
6
- * Derive a directory name from a package name.
7
- * Takes scoped packages into account.
8
- *
9
- * @method directoryForPackageName
10
- * @param {String} packageName
11
- * @return {String} Derived directory name.
12
- */
13
- module.exports = function directoryForPackageName(packageName) {
14
- let isScoped = packageName[0] === '@' && packageName.includes('/');
15
-
16
- if (isScoped) {
17
- let slashIndex = packageName.indexOf('/');
18
- let scopeName = packageName.substring(1, slashIndex);
19
- let packageNameWithoutScope = packageName.substring(slashIndex + 1);
20
- let pathParts = process.cwd().split(path.sep);
21
- let parentDirectoryContainsScopeName = pathParts.includes(scopeName);
22
-
23
- if (parentDirectoryContainsScopeName) {
24
- return packageNameWithoutScope;
25
- } else {
26
- return `${scopeName}-${packageNameWithoutScope}`;
27
- }
28
- } else {
29
- return packageName;
30
- }
31
- };
@@ -1,64 +0,0 @@
1
- 'use strict';
2
-
3
- const fs = require('fs');
4
- const util = require('util');
5
- const jsdiff = require('diff');
6
- const quickTemp = require('quick-temp');
7
- const path = require('path');
8
- const SilentError = require('silent-error');
9
- const openEditor = require('./open-editor');
10
- const hash = require('promise.hash.helper');
11
-
12
- const readFile = util.promisify(fs.readFile);
13
- const writeFile = util.promisify(fs.writeFile);
14
-
15
- class EditFileDiff {
16
- constructor(options) {
17
- this.info = options.info;
18
-
19
- quickTemp.makeOrRemake(this, 'tmpDifferenceDir');
20
- }
21
-
22
- edit() {
23
- return hash({
24
- input: this.info.render(),
25
- output: readFile(this.info.outputPath),
26
- })
27
- .then(this.invokeEditor.bind(this))
28
- .then(this.applyPatch.bind(this))
29
- .finally(this.cleanUp.bind(this));
30
- }
31
-
32
- cleanUp() {
33
- quickTemp.remove(this, 'tmpDifferenceDir');
34
- }
35
-
36
- applyPatch(resultHash) {
37
- return hash({
38
- diffString: readFile(resultHash.diffPath),
39
- currentString: readFile(resultHash.outputPath),
40
- }).then((result) => {
41
- let appliedDiff = jsdiff.applyPatch(result.currentString.toString(), result.diffString.toString());
42
-
43
- if (!appliedDiff) {
44
- let message = 'Patch was not cleanly applied.';
45
- this.info.ui.writeLine(`${message} Please choose another action.`);
46
- throw new SilentError(message);
47
- }
48
-
49
- return writeFile(resultHash.outputPath, appliedDiff);
50
- });
51
- }
52
-
53
- invokeEditor(result) {
54
- let info = this.info;
55
- let diff = jsdiff.createPatch(info.outputPath, result.output.toString(), result.input);
56
- let diffPath = path.join(this.tmpDifferenceDir, 'currentDiff.diff');
57
-
58
- return writeFile(diffPath, diff)
59
- .then(() => openEditor(diffPath))
60
- .then(() => ({ outputPath: info.outputPath, diffPath }));
61
- }
62
- }
63
-
64
- module.exports = EditFileDiff;
@@ -1,63 +0,0 @@
1
- 'use strict';
2
-
3
- const chalk = require('chalk');
4
-
5
- /*
6
- If you're here to remove the VITE experiment flag in favor of it being
7
- permanently on, you can't do that until addressing
8
- https://github.com/ember-cli/ember-cli/pull/10781#pullrequestreview-3230644293
9
-
10
- A lot of test coverage would otherwise be lost, because valid tests are being
11
- run only when the VITE experiment is off.
12
- */
13
- const availableExperiments = Object.freeze(['EMBROIDER', 'CLASSIC', 'VITE']);
14
-
15
- const deprecatedExperiments = Object.freeze([]);
16
- const enabledExperiments = Object.freeze(['VITE']);
17
- const deprecatedExperimentsDeprecationsIssued = [];
18
-
19
- function isExperimentEnabled(experimentName) {
20
- if (!availableExperiments.includes(experimentName)) {
21
- return false;
22
- }
23
-
24
- if (process.env.EMBER_CLI_ENABLE_ALL_EXPERIMENTS && deprecatedExperiments.includes(experimentName)) {
25
- return false;
26
- }
27
-
28
- if (process.env.EMBER_CLI_ENABLE_ALL_EXPERIMENTS) {
29
- return true;
30
- }
31
-
32
- if (process.env.EMBER_CLI_CLASSIC && experimentName === 'EMBROIDER') {
33
- return false;
34
- }
35
-
36
- let experimentEnvironmentVariable = `EMBER_CLI_${experimentName}`;
37
- let experimentValue = process.env[experimentEnvironmentVariable];
38
-
39
- if (deprecatedExperiments.includes(experimentName)) {
40
- let deprecationPreviouslyIssued = deprecatedExperimentsDeprecationsIssued.includes(experimentName);
41
- let isSpecifiedByUser = experimentValue !== undefined;
42
-
43
- if (!deprecationPreviouslyIssued && isSpecifiedByUser) {
44
- console.warn(
45
- chalk.yellow(`The ${experimentName} experiment in ember-cli has been deprecated and will be removed.`)
46
- );
47
- deprecatedExperimentsDeprecationsIssued.push(experimentName);
48
- }
49
- }
50
-
51
- if (enabledExperiments.includes(experimentName)) {
52
- return experimentValue !== 'false';
53
- } else {
54
- return experimentValue !== undefined && experimentValue !== 'false';
55
- }
56
- }
57
-
58
- module.exports = {
59
- isExperimentEnabled,
60
-
61
- // exported for testing purposes
62
- _deprecatedExperimentsDeprecationsIssued: deprecatedExperimentsDeprecationsIssued,
63
- };