Repository: ember-cli/ember-cli (js)

Issue:
Ember cli can not find default blueprint for scoped addons
Starting from version 4.3, ember cli can not find default blueprint for addon if addon is a scoped package (i.e. `@scope/addon-name`). If I install such addon, ember cli behaves like it does not have default blueprint. If I run `ember g @scope/addon-name`, it gives `Unknown blueprint: @scope/addon-name`. Unfortunately I can not provide a specific addon example to reproduce this issue, because it is published to private registry. 

The cause of problem is [line 1511 of lib/models/blueprint.js](https://github.com/ember-cli/ember-cli/blob/master/lib/models/blueprint.js#L1511), which checks if blueprint name is a path ([related PR](https://github.com/ember-cli/ember-cli/pull/9387)). Scoped packages contain `/`, which is a `path.sep`.


Pull request:
[BUGFIX] Fix looking up the default blueprint for scoped addons
Fixes #10090 by checking if addon name starts with '@'

Patch:
diff --git a/lib/models/blueprint.js b/lib/models/blueprint.js
index 356a6a112..0ef25fc02 100644
--- a/lib/models/blueprint.js
+++ b/lib/models/blueprint.js
@@ -1508,23 +1508,6 @@ let Blueprint = CoreObject.extend({
 Blueprint.lookup = function (name, options) {
   options = options || {};
 
-  if (name.includes(path.sep)) {
-    let blueprintPath = path.resolve(name);
-    let isNameAPath = Boolean(blueprintPath);
-
-    if (isNameAPath) {
-      if (Blueprint._existsSync(blueprintPath)) {
-        return Blueprint.load(blueprintPath, options.blueprintOptions);
-      }
-
-      if (!options.ignoreMissing) {
-        throw new SilentError(`Unknown blueprint: ${name}`);
-      }
-
-      return;
-    }
-  }
-
   let lookupPaths = generateLookupPaths(options.paths);
 
   let lookupPath;
@@ -1536,6 +1519,15 @@ Blueprint.lookup = function (name, options) {
     }
   }
 
+  // Check if `name` itself is a path to a blueprint:
+  if (name.includes(path.sep)) {
+    let blueprintPath = path.resolve(name);
+
+    if (Blueprint._existsSync(blueprintPath)) {
+      return Blueprint.load(blueprintPath, options.blueprintOptions);
+    }
+  }
+
   if (!options.ignoreMissing) {
     throw new SilentError(`Unknown blueprint: ${name}`);
   }


Test patch:
diff --git a/tests/acceptance/addon-generate-test.js b/tests/acceptance/addon-generate-test.js
index 45414e511..46d1c1d58 100644
--- a/tests/acceptance/addon-generate-test.js
+++ b/tests/acceptance/addon-generate-test.js
@@ -143,4 +143,17 @@ describe('Acceptance: ember generate in-addon', function () {
     await generateInAddon(['server']);
     expect(file('server/index.js')).to.exist;
   });
+
+  it('successfully generates the default blueprint for scoped addons', async function () {
+    await initAddon('@foo/bar');
+    await ember(['g', 'blueprint', '@foo/bar']);
+    await fs.outputFile('blueprints/@foo/bar/files/__name__.js', '');
+    await ember(['g', '@foo/bar', 'baz']);
+
+    expect(file('baz.js')).to.exist;
+  });
+
+  it(`throws the unknown blueprint error when \`name\` matches a folder's name, but doesn't include the \`${path.sep}\` char`, async function () {
+    await expect(generateInAddon(['tests'])).to.be.rejectedWith('Unknown blueprint: tests');
+  });
 });
diff --git a/tests/acceptance/generate-test.js b/tests/acceptance/generate-test.js
index 03a715cf4..993244c46 100755
--- a/tests/acceptance/generate-test.js
+++ b/tests/acceptance/generate-test.js
@@ -234,4 +234,17 @@ describe('Acceptance: ember generate', function () {
 
     td.verify(lintFixStub(), { ignoreExtraArgs: true, times: 1 });
   });
+
+  it('successfully generates a blueprint with a scoped name', async function () {
+    await initApp();
+    await ember(['g', 'blueprint', '@foo/bar']);
+    await outputFile('blueprints/@foo/bar/files/__name__.js', '');
+    await ember(['g', '@foo/bar', 'baz']);
+
+    expect(file('baz.js')).to.exist;
+  });
+
+  it(`throws the unknown blueprint error when \`name\` matches a folder's name, but doesn't include the \`${path.sep}\` char`, async function () {
+    await expect(generate(['tests'])).to.be.rejectedWith('Unknown blueprint: tests');
+  });
 });