angular / angular-cli

CLI tool for Angular
https://cli.angular.dev
MIT License
26.79k stars 11.98k forks source link

NodePackageLinkTask fails to execute in custom schematics #25824

Open Nosfistis opened 1 year ago

Nosfistis commented 1 year ago

Command

other

Is this a regression?

The previous version in which this bug was not present was

No response

Description

I have created a custom ngAdd schematic, where I check a boolean option (--local), and if it is set I want to perform a link to a local package instead of the npm registry.

In order to do this, instead of:

context.addTask(new NodePackageInstallTask());

for each package I want to link I do

context.addTask(new NodePackageLinkTask(packageName));

However, the command fails. It seems that the actual command being ran is npm test-package where test-package is the package I want to link.

After checking the executor, it seems that the link command of NodePackageLinkTask is disregarded entirely: https://github.com/angular/angular-cli/blob/b4a12a9264033c18cdc2de81b05a2d1f41d549e2/packages/angular_devkit/schematics/tasks/package-manager/executor.ts#L91C9-L98

Minimal Reproduction

Follow the ngAdd tutorial, and use NodePackageLinkTask instead of NodePackageInstallTask`.

Exception or Error

Unknown command: `test-package`

Your Environment

Package                            Version
------------------------------------------------------------
@angular-devkit/architect          0.1303.7
@angular-devkit/build-angular      13.3.7
@angular-devkit/core               13.3.7
@angular-devkit/schematics         13.3.7
@angular/cdk                       13.3.9
@angular/cli                       13.3.7
@angular/flex-layout               13.0.0-beta.38
@angular/material                  13.3.9
@angular/material-moment-adapter   13.3.9
@schematics/angular                13.3.7
ng-packagr                         13.3.1
rxjs                               7.5.5
typescript                         4.6.4

Anything else relevant?

This does not seem to have changed in the past angular versions.

ahmedhalac commented 4 weeks ago

Hi. Is anybody working on this? I could try to fix it.