Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUGFIX] Fix looking up the default blueprint for scoped addons #10091

Merged
merged 1 commit into from Feb 1, 2023

Conversation

GendelfLugansk
Copy link
Contributor

Fixes #10090 by checking if addon name starts with '@'

@bertdeblock
Copy link
Contributor

Thanks for reporting the issue and making this PR.
I had a look at the PR that introduced this regression and I think we can actually avoid the sep + @ check if we write the lookup by path after the original lookup code:

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;
  for (let i = 0; (lookupPath = lookupPaths[i]); i++) {
    let blueprintPath = path.resolve(lookupPath, name);

    if (Blueprint._existsSync(blueprintPath)) {
      return Blueprint.load(blueprintPath, options.blueprintOptions);
    }
  }

+ // Check if `name` itself is a path to a blueprint.
+ let blueprintPath = path.resolve(name);
+ if (Blueprint._existsSync(blueprintPath)) {
+   return Blueprint.load(blueprintPath, options.blueprintOptions);
+ }

  if (!options.ignoreMissing) {
    throw new SilentError(`Unknown blueprint: ${name}`);
  }
};

@bertdeblock bertdeblock added the bug label Dec 5, 2022
@bertdeblock bertdeblock changed the title Detect scoped packages [BUGFIX] Fix looking up the default blueprint for scoped addons Dec 5, 2022
@bertdeblock
Copy link
Contributor

I also noticed that the tests added in #9387 actually pass with and without the added code for supporting paths, so I'm going to try and fix that first to make sure we don't introduce any additional regressions.

@GendelfLugansk
Copy link
Contributor Author

In this case, can we just add empty line to lookupPaths array? Inside generateLookupPaths, for example. But I am not sure this approach would not break support for specifying a path for the generate command.

@bertdeblock
Copy link
Contributor

Made #10092 to fix the tests.

@kategengler
Copy link
Member

Should we add a test for this case?

@bertdeblock
Copy link
Contributor

#10092 was merged. Added a test for this fix as well.

@bertdeblock bertdeblock merged commit 77b573d into ember-cli:master Feb 1, 2023
@bertdeblock
Copy link
Contributor

@GendelfLugansk Thanks for opening the issue and this PR!

@GendelfLugansk GendelfLugansk deleted the patch-1 branch February 1, 2023 11:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ember cli can not find default blueprint for scoped addons
3 participants