Repository: ember-cli/ember-cli
Pull request #7667 (2018-03-07 18:09:06)

MU addons must generate a MU dummy app
/cc @rwjblue @mixonic 

mixonic: In https://github.com/ember-cli/ember-cli/blob/master/blueprints/module-unification-addon/files/tests/test-helper.js#L1 the import must be from `../src/main`

Patch:
diff --git a/blueprints/addon/index.js b/blueprints/addon/index.js
index e21e16c6a..e218c914e 100644
--- a/blueprints/addon/index.js
+++ b/blueprints/addon/index.js
@@ -23,6 +23,7 @@ const replacers = {
 const description = 'The default blueprint for ember-cli addons.';
 module.exports = {
   description,
+  appBlueprintName: 'app',
 
   filesToRemove: [
     'tests/dummy/app/styles/.gitkeep',
@@ -138,7 +139,7 @@ module.exports = {
   },
 
   files() {
-    let appFiles = this.lookupBlueprint('app').files();
+    let appFiles = this.lookupBlueprint(this.appBlueprintName).files();
     let addonFilesPath = this.filesPath(this.options);
     let addonFiles = walkSync(addonFilesPath);
 
@@ -184,7 +185,7 @@ module.exports = {
 
   srcPath(file) {
     let path = `${this.path}/files/${file}`;
-    let superPath = `${this.lookupBlueprint('app').path}/files/${file}`;
+    let superPath = `${this.lookupBlueprint(this.appBlueprintName).path}/files/${file}`;
     return fs.existsSync(path) ? path : superPath;
   },
 };
diff --git a/blueprints/module-unification-addon/index.js b/blueprints/module-unification-addon/index.js
index c0d812c13..e867e7278 100644
--- a/blueprints/module-unification-addon/index.js
+++ b/blueprints/module-unification-addon/index.js
@@ -3,4 +3,9 @@ const addonBlueprint = require('../addon');
 
 module.exports = Object.assign({}, addonBlueprint, {
   description: 'Generates an Ember addon with a module unification layout.',
+  appBlueprintName: 'module-unification-app',
+  fileMap: Object.assign({}, addonBlueprint.fileMap, {
+    '^src.*': 'tests/dummy/:path',
+    '^addon-src/.gitkeep': 'src/.gitkeep',
+  }),
 });
diff --git a/blueprints/module-unification-app/files/src/main.js b/blueprints/module-unification-app/files/src/main.js
index 2a188be3b..84b092ff1 100644
--- a/blueprints/module-unification-app/files/src/main.js
+++ b/blueprints/module-unification-app/files/src/main.js
@@ -11,4 +11,9 @@ const App = Application.extend({
 
 loadInitializers(App, config.modulePrefix + "/src/init");
 
+/*
+ * This line is added to support initializers in the `app/` directory
+ */
+loadInitializers(App, config.modulePrefix);
+
 export default App;


Test patch:
diff --git a/blueprints/module-unification-addon/files/src/.gitkeep b/blueprints/module-unification-addon/files/addon-src/.gitkeep
similarity index 100%
rename from blueprints/module-unification-addon/files/src/.gitkeep
rename to blueprints/module-unification-addon/files/addon-src/.gitkeep
diff --git a/blueprints/module-unification-addon/files/tests/test-helper.js b/blueprints/module-unification-addon/files/tests/test-helper.js
index 0382a848d..007bd6e50 100644
--- a/blueprints/module-unification-addon/files/tests/test-helper.js
+++ b/blueprints/module-unification-addon/files/tests/test-helper.js
@@ -1,4 +1,4 @@
-import Application from '../app';
+import Application from '../src/main';
 import config from '../config/environment';
 import { setApplication } from '@ember/test-helpers';
 import { start } from 'ember-qunit';
diff --git a/tests/fixtures/module-unification-addon/package.json b/tests/fixtures/module-unification-addon/package.json
index 97ce97c12..c5269de14 100644
--- a/tests/fixtures/module-unification-addon/package.json
+++ b/tests/fixtures/module-unification-addon/package.json
@@ -25,7 +25,7 @@
   "devDependencies": {
     "broccoli-asset-rev": "^2.4.5",
     "ember-ajax": "^3.0.0",
-    "ember-cli": "~3.1.0-beta.1",
+    "ember-cli": "github:ember-cli/ember-cli",
     "ember-cli-dependency-checker": "^2.0.0",
     "ember-cli-eslint": "^4.2.1",
     "ember-cli-htmlbars": "^2.0.1",
@@ -40,13 +40,12 @@
     "ember-load-initializers": "^1.0.0",
     "ember-maybe-import-regenerator": "^0.1.6",
     "ember-resolver": "^4.0.0",
-    "ember-source": "~3.1.0-beta.1",
+    "ember-source": "http://builds.emberjs.com/canary.tgz",
     "ember-source-channel-url": "^1.0.1",
     "ember-try": "^0.2.23",
     "eslint-plugin-ember": "^5.0.0",
     "eslint-plugin-node": "^5.2.1",
-    "loader.js": "^4.2.3",
-    "qunit-dom": "^0.5.0"
+    "loader.js": "^4.2.3"
   },
   "engines": {
     "node": "^4.5 || 6.* || >= 7.*"
diff --git a/tests/fixtures/module-unification-addon/testem.js b/tests/fixtures/module-unification-addon/testem.js
index d1755a4ea..09a686f94 100644
--- a/tests/fixtures/module-unification-addon/testem.js
+++ b/tests/fixtures/module-unification-addon/testem.js
@@ -8,17 +8,11 @@ module.exports = {
     'Chrome'
   ],
   browser_args: {
-    Chrome: {
-      mode: 'ci',
-      args: [
-        // --no-sandbox is needed when running Chrome inside a container
-        process.env.TRAVIS ? '--no-sandbox' : null,
-
-        '--disable-gpu',
-        '--headless',
-        '--remote-debugging-port=0',
-        '--window-size=1440,900'
-      ].filter(Boolean)
-    }
+    Chrome: [
+      '--disable-gpu',
+      '--headless',
+      '--remote-debugging-port=9222',
+      '--window-size=1440,900'
+    ]
   }
 };
diff --git a/tests/fixtures/module-unification-addon/tests/dummy/app/app.js b/tests/fixtures/module-unification-addon/tests/dummy/app/app.js
deleted file mode 100644
index b3b2bd677..000000000
--- a/tests/fixtures/module-unification-addon/tests/dummy/app/app.js
+++ /dev/null
@@ -1,14 +0,0 @@
-import Application from '@ember/application';
-import Resolver from './resolver';
-import loadInitializers from 'ember-load-initializers';
-import config from './config/environment';
-
-const App = Application.extend({
-  modulePrefix: config.modulePrefix,
-  podModulePrefix: config.podModulePrefix,
-  Resolver
-});
-
-loadInitializers(App, config.modulePrefix);
-
-export default App;
diff --git a/tests/fixtures/module-unification-addon/tests/dummy/app/controllers/.gitkeep b/tests/fixtures/module-unification-addon/tests/dummy/app/controllers/.gitkeep
deleted file mode 100644
index e69de29bb..000000000
diff --git a/tests/fixtures/module-unification-addon/tests/dummy/app/helpers/.gitkeep b/tests/fixtures/module-unification-addon/tests/dummy/app/helpers/.gitkeep
deleted file mode 100644
index e69de29bb..000000000
diff --git a/tests/fixtures/module-unification-addon/tests/dummy/app/models/.gitkeep b/tests/fixtures/module-unification-addon/tests/dummy/app/models/.gitkeep
deleted file mode 100644
index e69de29bb..000000000
diff --git a/tests/fixtures/module-unification-addon/tests/dummy/app/resolver.js b/tests/fixtures/module-unification-addon/tests/dummy/app/resolver.js
deleted file mode 100644
index 2fb563d6c..000000000
--- a/tests/fixtures/module-unification-addon/tests/dummy/app/resolver.js
+++ /dev/null
@@ -1,3 +0,0 @@
-import Resolver from 'ember-resolver';
-
-export default Resolver;
diff --git a/tests/fixtures/module-unification-addon/tests/dummy/app/routes/.gitkeep b/tests/fixtures/module-unification-addon/tests/dummy/app/routes/.gitkeep
deleted file mode 100644
index e69de29bb..000000000
diff --git a/tests/fixtures/module-unification-addon/tests/dummy/app/templates/components/.gitkeep b/tests/fixtures/module-unification-addon/tests/dummy/app/templates/components/.gitkeep
deleted file mode 100644
index e69de29bb..000000000
diff --git a/tests/fixtures/module-unification-addon/tests/dummy/config/environment.js b/tests/fixtures/module-unification-addon/tests/dummy/config/environment.js
index 182d3fcbf..8ce806a92 100644
--- a/tests/fixtures/module-unification-addon/tests/dummy/config/environment.js
+++ b/tests/fixtures/module-unification-addon/tests/dummy/config/environment.js
@@ -2,6 +2,11 @@
 
 module.exports = function(environment) {
   let ENV = {
+    'ember-resolver': {
+      features: {
+        EMBER_RESOLVER_MODULE_UNIFICATION: true
+      }
+    },
     modulePrefix: 'dummy',
     environment,
     rootURL: '/',
@@ -10,6 +15,7 @@ module.exports = function(environment) {
       FEATURES: {
         // Here you can enable experimental features on an ember canary build
         // e.g. 'with-controller': true
+        'ember-module-unification': true
       },
       EXTEND_PROTOTYPES: {
         // Prevent Ember Data from overriding Date.parse.
@@ -40,11 +46,10 @@ module.exports = function(environment) {
     ENV.APP.LOG_VIEW_LOOKUPS = false;
 
     ENV.APP.rootElement = '#ember-testing';
-    ENV.APP.autoboot = false;
   }
 
   if (environment === 'production') {
-    // here you can enable a production-specific feature
+
   }
 
   return ENV;
diff --git a/tests/fixtures/module-unification-addon/tests/dummy/config/targets.js b/tests/fixtures/module-unification-addon/tests/dummy/config/targets.js
index 8ffae3636..082e68b51 100644
--- a/tests/fixtures/module-unification-addon/tests/dummy/config/targets.js
+++ b/tests/fixtures/module-unification-addon/tests/dummy/config/targets.js
@@ -1,18 +1,8 @@
-'use strict';
-
-const browsers = [
-  'last 1 Chrome versions',
-  'last 1 Firefox versions',
-  'last 1 Safari versions'
-];
-
-const isCI = !!process.env.CI;
-const isProduction = process.env.EMBER_ENV === 'production';
-
-if (isCI || isProduction) {
-  browsers.push('ie 11');
-}
-
 module.exports = {
-  browsers
+  browsers: [
+    'ie 9',
+    'last 1 Chrome versions',
+    'last 1 Firefox versions',
+    'last 1 Safari versions'
+  ]
 };
diff --git a/tests/fixtures/module-unification-addon/tests/dummy/src/main.js b/tests/fixtures/module-unification-addon/tests/dummy/src/main.js
new file mode 100644
index 000000000..84b092ff1
--- /dev/null
+++ b/tests/fixtures/module-unification-addon/tests/dummy/src/main.js
@@ -0,0 +1,19 @@
+import Application from "@ember/application";
+import Resolver from "./resolver";
+import loadInitializers from "ember-load-initializers";
+import config from "../config/environment";
+
+const App = Application.extend({
+  modulePrefix: config.modulePrefix,
+  podModulePrefix: config.podModulePrefix,
+  Resolver
+});
+
+loadInitializers(App, config.modulePrefix + "/src/init");
+
+/*
+ * This line is added to support initializers in the `app/` directory
+ */
+loadInitializers(App, config.modulePrefix);
+
+export default App;
diff --git a/tests/fixtures/module-unification-addon/tests/dummy/src/resolver.js b/tests/fixtures/module-unification-addon/tests/dummy/src/resolver.js
new file mode 100644
index 000000000..f0b8a1cce
--- /dev/null
+++ b/tests/fixtures/module-unification-addon/tests/dummy/src/resolver.js
@@ -0,0 +1,13 @@
+import Resolver from 'ember-resolver/resolvers/fallback';
+import buildResolverConfig from 'ember-resolver/ember-config';
+import config from '../config/environment';
+
+let moduleConfig = buildResolverConfig(config.modulePrefix);
+/*
+ * If your application has custom types and collections, modify moduleConfig here
+ * to add support for them.
+ */
+
+export default Resolver.extend({
+  config: moduleConfig
+});
diff --git a/tests/fixtures/module-unification-addon/tests/dummy/app/router.js b/tests/fixtures/module-unification-addon/tests/dummy/src/router.js
similarity index 51%
rename from tests/fixtures/module-unification-addon/tests/dummy/app/router.js
rename to tests/fixtures/module-unification-addon/tests/dummy/src/router.js
index d0bb00952..7f2298b0d 100644
--- a/tests/fixtures/module-unification-addon/tests/dummy/app/router.js
+++ b/tests/fixtures/module-unification-addon/tests/dummy/src/router.js
@@ -1,12 +1,11 @@
-import EmberRouter from '@ember/routing/router';
-import config from './config/environment';
+import EmberRouter from "@ember/routing/router";
+import config from "../config/environment";
 
 const Router = EmberRouter.extend({
   location: config.locationType,
   rootURL: config.rootURL
 });
 
-Router.map(function() {
-});
+Router.map(function() {});
 
 export default Router;
diff --git a/tests/fixtures/module-unification-addon/tests/dummy/app/components/.gitkeep b/tests/fixtures/module-unification-addon/tests/dummy/src/ui/components/.gitkeep
similarity index 100%
rename from tests/fixtures/module-unification-addon/tests/dummy/app/components/.gitkeep
rename to tests/fixtures/module-unification-addon/tests/dummy/src/ui/components/.gitkeep
diff --git a/tests/fixtures/module-unification-addon/tests/dummy/app/index.html b/tests/fixtures/module-unification-addon/tests/dummy/src/ui/index.html
similarity index 73%
rename from tests/fixtures/module-unification-addon/tests/dummy/app/index.html
rename to tests/fixtures/module-unification-addon/tests/dummy/src/ui/index.html
index 61400b20f..e4e6c5d6e 100644
--- a/tests/fixtures/module-unification-addon/tests/dummy/app/index.html
+++ b/tests/fixtures/module-unification-addon/tests/dummy/src/ui/index.html
@@ -3,14 +3,14 @@
   <head>
     <meta charset="utf-8">
     <meta http-equiv="X-UA-Compatible" content="IE=edge">
-    <title>Dummy</title>
+    <title>dummy</title>
     <meta name="description" content="">
     <meta name="viewport" content="width=device-width, initial-scale=1">
 
     {{content-for "head"}}
 
-    <link integrity="" rel="stylesheet" href="{{rootURL}}assets/vendor.css">
-    <link integrity="" rel="stylesheet" href="{{rootURL}}assets/dummy.css">
+    <link rel="stylesheet" href="{{rootURL}}assets/vendor.css">
+    <link rel="stylesheet" href="{{rootURL}}assets/dummy.css">
 
     {{content-for "head-footer"}}
   </head>
diff --git a/tests/fixtures/module-unification-addon/tests/dummy/app/templates/application.hbs b/tests/fixtures/module-unification-addon/tests/dummy/src/ui/routes/application/template.hbs
similarity index 100%
rename from tests/fixtures/module-unification-addon/tests/dummy/app/templates/application.hbs
rename to tests/fixtures/module-unification-addon/tests/dummy/src/ui/routes/application/template.hbs
diff --git a/tests/fixtures/module-unification-addon/tests/dummy/app/styles/app.css b/tests/fixtures/module-unification-addon/tests/dummy/src/ui/styles/app.css
similarity index 100%
rename from tests/fixtures/module-unification-addon/tests/dummy/app/styles/app.css
rename to tests/fixtures/module-unification-addon/tests/dummy/src/ui/styles/app.css
diff --git a/tests/fixtures/module-unification-addon/tests/test-helper.js b/tests/fixtures/module-unification-addon/tests/test-helper.js
index 0382a848d..007bd6e50 100644
--- a/tests/fixtures/module-unification-addon/tests/test-helper.js
+++ b/tests/fixtures/module-unification-addon/tests/test-helper.js
@@ -1,4 +1,4 @@
-import Application from '../app';
+import Application from '../src/main';
 import config from '../config/environment';
 import { setApplication } from '@ember/test-helpers';
 import { start } from 'ember-qunit';