Skip to content

fix(@schematics/angular): accept the project as a positional argument in refactor-jasmine-vitest - #34605

Closed
MeAkib wants to merge 1 commit into
angular:mainfrom
MeAkib:fix/refactor-jasmine-vitest-positional-project
Closed

MeAkib wants to merge 1 commit into
angular:mainfrom
MeAkib:fix/refactor-jasmine-vitest-positional-project

Conversation

@MeAkib

@MeAkib MeAkib commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Follow-up to #34387, where @alan-agius4 noted that the schematic should accept the positional argument.

The karma-to-vitest migration suggests running ng g @schematics/angular:refactor-jasmine-vitest <project_name>, but the schematic only accepts the project through the --project option, so the suggested command fails with Unknown argument.

Read the project from the first positional argument. When it is not provided, the schematic still uses the only project of the workspace.

Note: an option can only have one $default, so the project is no longer inferred from the current directory ($source: projectName). In a multi-project workspace, running the schematic without a project name now reports the available projects instead. If keeping that inference is preferred, it could be done with a hidden workingDirectory option as suggested by the bot. Happy to add it.

… in refactor-jasmine-vitest

The karma-to-vitest migration suggests running
`ng g @schematics/angular:refactor-jasmine-vitest <project_name>`, but the
schematic only accepts the project through the `--project` option, so the
suggested command fails with `Unknown argument`.

Read the project from the first positional argument. When it is not provided,
the schematic still uses the only project of the workspace.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the schema for the jasmine-vitest refactoring schematic to accept the project name as a positional argument from the command line arguments. The reviewer pointed out that this change introduces a usability regression because the CLI will no longer automatically resolve the project from the current working directory in multi-project workspaces. To resolve this, the reviewer suggested adding a hidden workingDirectory option and provided a code implementation to handle the fallback logic in the schematic.

@alan-agius4

Copy link
Copy Markdown
Collaborator

Thanks for this, but thinking about this a bit more, this will break the projectName smart default and breaks consistency with other schematics.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants