Repository: ember-cli/ember-cli
Pull request #9492 (2021-03-19 18:38:43)

Ensure --embroider is saved as blueprint options


Patch:
diff --git a/blueprints/addon/files/README.md b/blueprints/addon/files/README.md
index e6972a912..c229f9afd 100644
--- a/blueprints/addon/files/README.md
+++ b/blueprints/addon/files/README.md
@@ -7,8 +7,8 @@
 Compatibility
 ------------------------------------------------------------------------------
 
-* Ember.js v3.20 or above
-* Ember CLI v3.20 or above
+* Ember.js v3.16 or above
+* Ember CLI v2.13 or above
 * Node.js v10 or above
 
 
diff --git a/blueprints/app/index.js b/blueprints/app/index.js
index c54ba7988..73d3c8db7 100644
--- a/blueprints/app/index.js
+++ b/blueprints/app/index.js
@@ -21,8 +21,9 @@ module.exports = {
     let rawName = entity.name;
     let name = stringUtil.dasherize(rawName);
     let namespace = stringUtil.classify(rawName);
+    let embroider = isExperimentEnabled('EMBROIDER') || options.embroider;
 
-    let hasOptions = !options.welcome || options.yarn;
+    let hasOptions = !options.welcome || options.yarn || embroider;
     let blueprintOptions = '';
     if (hasOptions) {
       let indent = `\n            `;
@@ -30,7 +31,9 @@ module.exports = {
 
       blueprintOptions =
         indent +
-        [!options.welcome && '"--no-welcome"', options.yarn && '"--yarn"'].filter(Boolean).join(',\n            ') +
+        [!options.welcome && '"--no-welcome"', options.yarn && '"--yarn"', embroider && '"--embroider"']
+          .filter(Boolean)
+          .join(',\n            ') +
         outdent;
     }
 
@@ -43,7 +46,7 @@ module.exports = {
       welcome: options.welcome,
       blueprint: 'app',
       blueprintOptions,
-      embroider: isExperimentEnabled('EMBROIDER') || options.embroider,
+      embroider,
       lang: options.lang,
     };
   },
diff --git a/lib/utilities/ember-app-utils.js b/lib/utilities/ember-app-utils.js
index f3f31508e..cf6e73202 100644
--- a/lib/utilities/ember-app-utils.js
+++ b/lib/utilities/ember-app-utils.js
@@ -129,13 +129,7 @@ function contentFor(config, match, type, options) {
       break;
     case 'test-body-footer':
       content.push(
-        `<script>
-document.addEventListener('DOMContentLoaded', function() {
-  if (!EmberENV.TESTS_FILE_LOADED) {
-    throw new Error('The tests file was not loaded. Make sure your tests index.html includes "assets/tests.js".');
-  }
-});
-</script>`
+        `<script>document.addEventListener('DOMContentLoaded', function() { Ember.assert('The tests file was not loaded. Make sure your tests index.html includes "assets/tests.js".', EmberENV.TESTS_FILE_LOADED);});</script>`
       );
 
       break;


Test patch:
diff --git a/tests/acceptance/new-test.js b/tests/acceptance/new-test.js
index 45f977ea8..a3137036a 100644
--- a/tests/acceptance/new-test.js
+++ b/tests/acceptance/new-test.js
@@ -470,12 +470,11 @@ describe('Acceptance: ember new', function () {
         expect(file(filePath)).to.equal(file(path.join(__dirname, '../fixtures', fixturePath, filePath)));
       });
 
-      checkFileWithEmberCLIVersionReplacement(fixturePath, 'config/ember-cli-update.json');
-
       if (isExperimentEnabled('EMBROIDER')) {
         fixturePath = `${namespace}/embroider`;
       }
 
+      checkFileWithEmberCLIVersionReplacement(fixturePath, 'config/ember-cli-update.json');
       checkFileWithEmberCLIVersionReplacement(fixturePath, 'package.json');
       checkEmberCLIBuild(fixturePath, 'ember-cli-build.js');
 
@@ -522,12 +521,11 @@ describe('Acceptance: ember new', function () {
         expect(file(filePath)).to.equal(file(path.join(__dirname, '../fixtures', fixturePath, filePath)));
       });
 
-      checkFileWithEmberCLIVersionReplacement(fixturePath, 'config/ember-cli-update.json');
-
       if (isExperimentEnabled('EMBROIDER')) {
         fixturePath = 'app/embroider-no-welcome';
       }
 
+      checkFileWithEmberCLIVersionReplacement(fixturePath, 'config/ember-cli-update.json');
       checkFileWithEmberCLIVersionReplacement(fixturePath, 'package.json');
       // option independent, but piggy-backing on an existing generate for speed
       checkEslintConfig(namespace);
@@ -542,12 +540,11 @@ describe('Acceptance: ember new', function () {
         expect(file(filePath)).to.equal(file(path.join(__dirname, '../fixtures', fixturePath, filePath)));
       });
 
-      checkFileWithEmberCLIVersionReplacement(fixturePath, 'config/ember-cli-update.json');
-
       if (isExperimentEnabled('EMBROIDER')) {
-        fixturePath = 'app/embroider';
+        fixturePath = 'app/embroider-yarn';
       }
 
+      checkFileWithEmberCLIVersionReplacement(fixturePath, 'config/ember-cli-update.json');
       checkFileWithEmberCLIVersionReplacement(fixturePath, 'package.json');
     });
 
diff --git a/tests/fixtures/addon/defaults/README.md b/tests/fixtures/addon/defaults/README.md
index f863b52d5..246839130 100644
--- a/tests/fixtures/addon/defaults/README.md
+++ b/tests/fixtures/addon/defaults/README.md
@@ -7,8 +7,8 @@ foo
 Compatibility
 ------------------------------------------------------------------------------
 
-* Ember.js v3.20 or above
-* Ember CLI v3.20 or above
+* Ember.js v3.16 or above
+* Ember CLI v2.13 or above
 * Node.js v10 or above
 
 
diff --git a/tests/fixtures/addon/yarn/README.md b/tests/fixtures/addon/yarn/README.md
index f863b52d5..246839130 100644
--- a/tests/fixtures/addon/yarn/README.md
+++ b/tests/fixtures/addon/yarn/README.md
@@ -7,8 +7,8 @@ foo
 Compatibility
 ------------------------------------------------------------------------------
 
-* Ember.js v3.20 or above
-* Ember CLI v3.20 or above
+* Ember.js v3.16 or above
+* Ember CLI v2.13 or above
 * Node.js v10 or above
 
 
diff --git a/tests/fixtures/app/embroider-no-welcome/config/ember-cli-update.json b/tests/fixtures/app/embroider-no-welcome/config/ember-cli-update.json
new file mode 100644
index 000000000..4322ddea2
--- /dev/null
+++ b/tests/fixtures/app/embroider-no-welcome/config/ember-cli-update.json
@@ -0,0 +1,21 @@
+{
+  "schemaVersion": "1.0.0",
+  "packages": [
+    {
+      "name": "ember-cli",
+      "version": "<%= emberCLIVersion %>",
+      "blueprints": [
+        {
+          "name": "app",
+          "outputRepo": "https://github.com/ember-cli/ember-new-output",
+          "codemodsSource": "ember-app-codemods-manifest@1",
+          "isBaseBlueprint": true,
+          "options": [
+            "--no-welcome",
+            "--embroider"
+          ]
+        }
+      ]
+    }
+  ]
+}
diff --git a/tests/fixtures/app/embroider-yarn/config/ember-cli-update.json b/tests/fixtures/app/embroider-yarn/config/ember-cli-update.json
new file mode 100644
index 000000000..140099c30
--- /dev/null
+++ b/tests/fixtures/app/embroider-yarn/config/ember-cli-update.json
@@ -0,0 +1,21 @@
+{
+  "schemaVersion": "1.0.0",
+  "packages": [
+    {
+      "name": "ember-cli",
+      "version": "<%= emberCLIVersion %>",
+      "blueprints": [
+        {
+          "name": "app",
+          "outputRepo": "https://github.com/ember-cli/ember-new-output",
+          "codemodsSource": "ember-app-codemods-manifest@1",
+          "isBaseBlueprint": true,
+          "options": [
+            "--yarn",
+            "--embroider"
+          ]
+        }
+      ]
+    }
+  ]
+}
diff --git a/tests/fixtures/app/embroider-yarn/package.json b/tests/fixtures/app/embroider-yarn/package.json
new file mode 100644
index 000000000..b7a1f646f
--- /dev/null
+++ b/tests/fixtures/app/embroider-yarn/package.json
@@ -0,0 +1,73 @@
+{
+  "name": "foo",
+  "version": "0.0.0",
+  "private": true,
+  "description": "Small description for foo goes here",
+  "repository": "",
+  "license": "MIT",
+  "author": "",
+  "directories": {
+    "doc": "doc",
+    "test": "tests"
+  },
+  "scripts": {
+    "build": "ember build --environment=production",
+    "lint": "npm-run-all --aggregate-output --continue-on-error --parallel 'lint:!(fix)'",
+    "lint:fix": "npm-run-all --aggregate-output --continue-on-error --parallel lint:*:fix",
+    "lint:hbs": "ember-template-lint .",
+    "lint:hbs:fix": "ember-template-lint . --fix",
+    "lint:js": "eslint . --cache",
+    "lint:js:fix": "eslint . --fix",
+    "start": "ember serve",
+    "test": "npm-run-all lint test:*",
+    "test:ember": "ember test"
+  },
+  "devDependencies": {
+    "@ember/optional-features": "^2.0.0",
+    "@ember/test-helpers": "^2.2.0",
+    "@embroider/compat": "^0.37.0",
+    "@embroider/core": "^0.37.0",
+    "@embroider/webpack": "^0.37.0",
+    "@glimmer/component": "^1.0.3",
+    "@glimmer/tracking": "^1.0.3",
+    "babel-eslint": "^10.1.0",
+    "broccoli-asset-rev": "^3.0.0",
+    "ember-auto-import": "^1.10.1",
+    "ember-cli": "~<%= emberCLIVersion %>",
+    "ember-cli-app-version": "^4.0.0",
+    "ember-cli-babel": "^7.23.1",
+    "ember-cli-dependency-checker": "^3.2.0",
+    "ember-cli-htmlbars": "^5.3.2",
+    "ember-cli-inject-live-reload": "^2.0.2",
+    "ember-cli-sri": "^2.1.1",
+    "ember-cli-terser": "^4.0.1",
+    "ember-data": "~3.26.0-beta.0",
+    "ember-export-application-global": "^2.0.1",
+    "ember-fetch": "^8.0.4",
+    "ember-load-initializers": "^2.1.2",
+    "ember-maybe-import-regenerator": "^0.1.6",
+    "ember-page-title": "^6.2.1",
+    "ember-qunit": "^5.1.4",
+    "ember-resolver": "^8.0.2",
+    "ember-source": "~3.26.0-beta.2",
+    "ember-template-lint": "^2.18.1",
+    "ember-welcome-page": "^4.0.0",
+    "eslint": "^7.20.0",
+    "eslint-config-prettier": "^7.2.0",
+    "eslint-plugin-ember": "^10.2.0",
+    "eslint-plugin-node": "^11.1.0",
+    "eslint-plugin-prettier": "^3.3.1",
+    "eslint-plugin-qunit": "^6.0.0",
+    "loader.js": "^4.7.0",
+    "npm-run-all": "^4.1.5",
+    "prettier": "^2.2.1",
+    "qunit": "^2.14.1",
+    "qunit-dom": "^1.6.0"
+  },
+  "engines": {
+    "node": "10.* || >= 12"
+  },
+  "ember": {
+    "edition": "octane"
+  }
+}
diff --git a/tests/fixtures/app/embroider/config/ember-cli-update.json b/tests/fixtures/app/embroider/config/ember-cli-update.json
new file mode 100644
index 000000000..2cd80dfc9
--- /dev/null
+++ b/tests/fixtures/app/embroider/config/ember-cli-update.json
@@ -0,0 +1,20 @@
+{
+  "schemaVersion": "1.0.0",
+  "packages": [
+    {
+      "name": "ember-cli",
+      "version": "<%= emberCLIVersion %>",
+      "blueprints": [
+        {
+          "name": "app",
+          "outputRepo": "https://github.com/ember-cli/ember-new-output",
+          "codemodsSource": "ember-app-codemods-manifest@1",
+          "isBaseBlueprint": true,
+          "options": [
+            "--embroider"
+          ]
+        }
+      ]
+    }
+  ]
+}
diff --git a/tests/unit/utilities/ember-app-utils-test.js b/tests/unit/utilities/ember-app-utils-test.js
index 8d76738cb..faafc3c4c 100644
--- a/tests/unit/utilities/ember-app-utils-test.js
+++ b/tests/unit/utilities/ember-app-utils-test.js
@@ -211,13 +211,7 @@ describe('ember-app-utils', function () {
         let output = contentFor(config, defaultMatch, 'test-body-footer', defaultOptions);
 
         expect(output, 'includes `<script>` tag').to.equal(
-          `<script>
-document.addEventListener('DOMContentLoaded', function() {
-  if (!EmberENV.TESTS_FILE_LOADED) {
-    throw new Error('The tests file was not loaded. Make sure your tests index.html includes "assets/tests.js".');
-  }
-});
-</script>`
+          `<script>document.addEventListener('DOMContentLoaded', function() { Ember.assert('The tests file was not loaded. Make sure your tests index.html includes "assets/tests.js".', EmberENV.TESTS_FILE_LOADED);});</script>`
         );
       });
     });