0

I would like to call Angular's ng-new schematic first, and then my Rule needs to operate on the results.

so something like:

 chain([
                    externalSchematic('@schematics/angular', 'ng-new', options),
                    schematic('someRule', options)
])

but this doesn't work. My rule needs the angular.json ngNew is supposed to create and since that obviously doesn't exist when my rule starts, the the rule fails.

So is there way to wait to accomplish either or the following:

a) wait for the external schematic to complete and then run the other schematic b) make the 2nd schematic use the tree returned by the 1st schematic?

So like:

chain([
      externalSchematic('@schematics/angular', 'ng-new', options),
      mergeWith(apply(source(/* tree created by ng-new */), [
        schematic('someStuff', options)
      ])
    )])
user2297996
  • 1,382
  • 3
  • 18
  • 28

1 Answers1

0

I am not sure why the innitial approach isn't workin for you but you can get the angular-cli.json file content after running the ng-new schematic by using one of the functions provided by the @angular/schematics/utilities/config.d.ts file.

export declare function getWorkspacePath(host: Tree): string;
export declare function getWorkspace(host: Tree): WorkspaceSchema;
export declare function addProjectToWorkspace<TProjectType extends ProjectType = ProjectType.Application>(workspace: WorkspaceSchema, name: string, project: WorkspaceProject<TProjectType>): Rule;
export declare function updateWorkspace(workspace: WorkspaceSchema): Rule;
export declare const configPath = "/.angular-cli.json";
export declare function getConfig(host: Tree): CliConfig;
export declare function getAppFromConfig(config: CliConfig, appIndexOrName: string): AppConfig | null;

In this case, getWorkspace will give you the content of angular-cli.json file.

KingDarBoja
  • 1,033
  • 6
  • 12