Attempting to develop a schematic that utilizes the angular ng-new as the initial call and another schematic to add a prettier file to the new project. Upon executing the command, an error is encountered:
Data path "" must have required property 'version'.
This necessitates adding --version="x" to the command. Is there a way to incorporate this external schematic without explicitly specifying the version so it automatically defaults to the latest version like ng new?
Here's the schematic code snippet:
import {
chain,
externalSchematic,
Rule,
schematic,
SchematicContext,
Tree,
} from "@angular-devkit/schematics";
import { Schema as NgNewOptions } from "@schematics/angular/ng-new/schema";
export function newProject(options: NgNewOptions): Rule {
return async (_tree: Tree, _context: SchematicContext) => {
const rule = externalSchematic("@schematics/angular", "ng-new", options);
const rule2 = schematic("add-prettier-configuration", options);
return chain([rule, rule2]);
};
}
And here is my collection setup:
{
"$schema": "../node_modules/@angular-devkit/schematics/collection-schema.json",
"extends": ["@schematics/angular"],
"schematics": {
"hello-world": {
"description": "A blank schematic.",
"factory": "./hello-world/index#helloWorld"
},
"goodbye-world": {
"description": "A blank schematic.",
"factory": "./goodbye-world/index#goodbyeWorld"
},
"add-prettier-configuration": {
"description": "Add a prettier configuration file.",
"factory": "./add-prettier-configuration/index#addPrettierConfiguration",
"schema": "./add-prettier-configuration/schema.json"
},
"new-project": {
"description": "A blank schematic.",
"factory": "./new-project/index#newProject",
"schema": "./new-project/schema.json"
}
}
}
When attempting to execute the new-project schematic, it prompts for the project name but encounters an error before starting the "new" schematic with the following message:
schematics ./hello-world:new-project
Debug mode enabled by default for local collections.
? What name would you like to use for the new workspace and initial project? iuhiuh+
An error occurred:
Error: Schematic input does not validate against the Schema: {"name":"iuhiuh+"}
Errors:
Data path "" must have required property 'version'.
...