Skip to content

Commit

Permalink
fix(@angular/cli): add fallbacks for migration package resolution
Browse files Browse the repository at this point in the history
Before this commit, running `ng update @angular/cli` would fail when using the PNPM package manager. This update resolves the issue by implementing fallbacks in the migration package resolution logic, similar to the approach used in `NodeWorkflow`.
  • Loading branch information
alan-agius4 committed Jun 12, 2024
1 parent c545f77 commit 6d266c1
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/angular/cli/src/commands/update/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ const UPDATE_SCHEMATIC_COLLECTION = path.join(__dirname, 'schematic/collection.j
export default class UpdateCommandModule extends CommandModule<UpdateCommandArgs> {
override scope = CommandScope.In;
protected override shouldReportAnalytics = false;
private readonly resolvePaths = [__dirname, this.context.root];

command = 'update [packages..]';
describe = 'Updates your workspace and its dependencies. See https://update.angular.dev/.';
Expand Down Expand Up @@ -251,7 +252,7 @@ export default class UpdateCommandModule extends CommandModule<UpdateCommandArgs
packageManagerForce: this.packageManagerForce(options.verbose),
// __dirname -> favor @schematics/update from this package
// Otherwise, use packages from the active workspace (migrations)
resolvePaths: [__dirname, this.context.root],
resolvePaths: this.resolvePaths,
schemaValidation: true,
engineHostCreator: (options) => new SchematicEngineHost(options.resolvePaths),
});
Expand Down Expand Up @@ -555,7 +556,7 @@ export default class UpdateCommandModule extends CommandModule<UpdateCommandArgs
// This avoids issues with package hoisting.
try {
const packageRequire = createRequire(packagePath + '/');
migrations = packageRequire.resolve(migrations);
migrations = packageRequire.resolve(migrations, { paths: this.resolvePaths });
} catch (e) {
assertIsError(e);
if (e.code === 'MODULE_NOT_FOUND') {
Expand Down

0 comments on commit 6d266c1

Please sign in to comment.