Skip to content

fix: keep a generator- inside a package or generator name in the namespace - #860

Merged
mshima merged 1 commit into
yeoman:mainfrom
mshima:fix-as-namespace
Oct 8, 2026
Merged

mshima merged 1 commit into
yeoman:mainfrom
mshima:fix-as-namespace

Conversation

@mshima

@mshima mshima commented Oct 8, 2026

Copy link
Copy Markdown
Member

Summary

asNamespace removed everything up to the last generator- of the path, wherever it was:

Path Before After
generator-foo-generator-bar/generators/app/index.js bar:app foo-generator-bar:app
@scope/generator-foo-generator-bar/generators/app/index.js @scope/bar:app @scope/foo-generator-bar:app
generator-foo/generators/my-generator-thing/index.js thing foo:my-generator-thing
@scope/plain/generators/app/index.js @scope/@scope:plain:app throws
  • Only the last folder starting with generator- is the package: the path up to it and its generator- prefix are removed, a generator- inside a package or generator name is kept. The existing cases (absolute paths, node_modules, Windows paths, generator-backbone/generator-backbone/all.js) are unchanged.
  • A path in a scoped package that is not a generator- one has no namespace: asNamespace (and Environment#namespace) throws instead of returning a broken one.
  • Store#lookupSync computes the namespace inside its try: such a generator is reported as not registered (and logged) and the lookup goes on with the other generators.

Behavior change

Packages with generator- inside their name (generator-foo-generator-bar) are now registered under their full name (foo-generator-bar), like namespaceFromPackageName gives it.

Test plan

  • eslint, tsc
  • esmocha: tests for generator- inside package and generator names, the throw for scoped non generator- packages, and a lookup going on after such a package

🤖 Generated with Claude Code

…space

- asNamespace removes the path up to the last folder starting with
  `generator-` and its prefix, instead of everything up to the last
  `generator-`: `generator-foo-generator-bar` is `foo-generator-bar`, and
  a generator in `my-generator-thing` is `foo:my-generator-thing`.
- asNamespace throws for a path in a scoped package that is not a
  `generator-` one, which gave `@scope/@scope:plain:app`.
- A lookup does not register such a generator and goes on with the others.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mshima
mshima merged commit 931e742 into yeoman:main Oct 8, 2026
15 of 16 checks passed
@mshima
mshima deleted the fix-as-namespace branch October 8, 2026 17:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant