Repository: ember-cli/ember-cli
Pull request #7489 (2017-12-06 15:23:03)

Fix regression with scoped package name mismatches
https://github.com/ember-cli/ember-cli/commit/69750c9b8a078900e163598542c295a518d1b49f introduced a regression where, if your package name is scoped in package.json and not scoped in index.js, `isDevelopingAddon` would now evaluate to `false`, when it used to evaluate to `true`. This caused the `addon` folder to not be linted anymore.

This fixes the regression and allows the old behavior to work again, but also issues a warning, saying you should sync the names up, per the suggestion of @rwjblue 

rwwagner90: @rwjblue added a test. Please let me know if that is sufficient.
rwjblue: Also, can you confirm which version introduced the regression? I believe it was 2.18.0-beta.1, right? If that is the case, can you update the PR target to be `beta` and rebase (to drop out the additional commits other than the one you are adding here)? 
rwwagner90: This was introduced in 2.16, so I suppose we need to get it in the 2.16 LTS, beta, and master? Not sure.
rwwagner90: @rwjblue any idea why travis is failing on not having `this.ui.writeWarnLine`? https://travis-ci.org/ember-cli/ember-cli/jobs/312999293#L1318
rwwagner90: Fixed the tests 👍 

Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 0e0c7a0a0..7d808553b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,29 +1,5 @@
 # ember-cli Changelog
 
-## 2.17.1
-
-The following changes are required if you are upgrading from the previous
-version:
-
-- Users
-  + [`ember new` diff](https://github.com/ember-cli/ember-new-output/compare/v2.17.0...v2.17.1)
-  + Upgrade your project's ember-cli version - [docs](https://ember-cli.com/user-guide/#upgrading)
-- Addon Developers
-  + [`ember new` diff](https://github.com/ember-cli/ember-addon-output/compare/v2.17.0...v2.17.1)
-  + No changes required
-- Core Contributors
-  + No changes required
-
-#### Community Contributions
-
-- [#7475](https://github.com/ember-cli/ember-cli/pull/7475) don't treat strings as regex in insertIntoFile [@kellyselden](https://github.com/kellyselden)
-- [#7477](https://github.com/ember-cli/ember-cli/pull/7477) Restore `separator: '\n;'` to vendor JS concat [@lennyburdette](https://github.com/lennyburdette)
-- [#7478](https://github.com/ember-cli/ember-cli/pull/7478) Remove obsolete CONFIG_CACHING feature flag [@Turbo87](https://github.com/Turbo87)
-- [#7481](https://github.com/ember-cli/ember-cli/pull/7481) NpmInstallTask: `useYarn` from constructor args [@lennyburdette](https://github.com/lennyburdette)
-
-Thank you to all who took the time to contribute!
-
-
 ## 2.17.0
 
 The following changes are required if you are upgrading from the previous
diff --git a/lib/models/addon.js b/lib/models/addon.js
index 5bfffae04..201331d76 100644
--- a/lib/models/addon.js
+++ b/lib/models/addon.js
@@ -35,6 +35,7 @@ const calculateCacheKeyForTree = require('calculate-cache-key-for-tree');
 const addonProcessTree = require('../utilities/addon-process-tree');
 const semver = require('semver');
 const processModulesOnly = require('../broccoli/babel-process-modules-only');
+const npa = require('npm-package-arg');
 
 const BUILD_BABEL_OPTIONS_FOR_PREPROCESSORS = Symbol('BUILD_BABEL_OPTIONS_FOR_PREPROCESSORS');
 
@@ -333,7 +334,29 @@ let addonProto = {
   */
   isDevelopingAddon() {
     if (process.env.EMBER_ADDON_ENV === 'development' && (this.parent instanceof Project)) {
-      return this.parent.name() === this.name;
+      const parentName = this.parent.name();
+      // If the name in package.json and index.js match, we're definitely developing
+      if (parentName === this.name) {
+        return true;
+      }
+
+      // If package.json and index.js names do not match, we should check for scoped vs non-scoped
+      const parsed = npa(parentName);
+      let parsedName = parsed.name;
+      if (parsed.scope) {
+        parsedName = parsedName.replace(parsed.scope, '').slice(1);
+      }
+      if (parsedName === this.name) {
+        if (!this._hasWarnedForMismatchedNames) {
+          this.ui.writeWarnLine(
+            'Your names in package.json and index.js should match. ' +
+            `You currently have ${parsed.name} in package.json and ${this.name} in index.js.`);
+
+          this._hasWarnedForMismatchedNames = true;
+        }
+
+        return true;
+      }
     }
     return false;
   },
diff --git a/package.json b/package.json
index faa903383..df43a551e 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
 {
   "name": "ember-cli",
-  "version": "2.17.1",
+  "version": "2.17.0",
   "description": "Command line tool for developing ambitious ember.js apps",
   "keywords": [
     "app",


Test patch:
diff --git a/tests/unit/models/addon-test.js b/tests/unit/models/addon-test.js
index 3ae4bd829..d6e187c0e 100644
--- a/tests/unit/models/addon-test.js
+++ b/tests/unit/models/addon-test.js
@@ -364,7 +364,7 @@ describe('models/addon.js', function() {
 
         project = new Project(projectPath, packageContents, cli.ui, cli);
 
-        addon = new MyAddon(project);
+        addon = new MyAddon(project, project);
 
         originalEnvValue = process.env.EMBER_ADDON_ENV;
       });
@@ -383,6 +383,14 @@ describe('models/addon.js', function() {
         expect(addon.isDevelopingAddon(), 'addon is being developed').to.eql(true);
       });
 
+      it('returns true when the addon name is prefixed in package.json and not in index.js', function() {
+        process.env.EMBER_ADDON_ENV = 'development';
+
+        project.name = () => ('@foo/my-addon');
+        addon.name = 'my-addon';
+        expect(addon.isDevelopingAddon(), 'addon is being developed').to.eql(true);
+      });
+
       it('returns false when `EMBER_ADDON_ENV` is not set', function() {
         delete process.env.EMBER_ADDON_ENV;