-
Notifications
You must be signed in to change notification settings - Fork 8
Exercise 5: move
Kevin Schuchard edited this page May 2, 2019
·
8 revisions
Checkout the move branch:
npm run clean
git checkout -f moveIn the src/schematic-starter/schema.json file:
- Add a prompt for
name
"properties": {
"name": {
"type": "string",
"description": "Name of the componet",
"default": "ng-conf",
"x-prompt": "Enter the name of the component"
}
}In the src/collection.json file:
- Add the
schemaproperty to eachschematicsentry under thefactoryproperty.
"factory": "./schematic-starter/index#schematicStarter",
"schema": "./schematic-starter/schema.json"In src/schematic-starter/index.ts file:
- Create an interface called
AddFilesInterfacewith aname: stringentry. - Replace the
anytype for the_optionsfunction argument in theschematicStartermethod.
In src/schematic-starter/index.ts file:
- Use the
template()function and provide thestringsand_optionsmembers
const rules: Rule[] = [template({ ...strings, ..._options })];- Add a second Rule that tells the schematic where to place the file
const rules: Rule[] = [template({ ...strings, ..._options }), move('src/app/components')];In the src/schematic-starter/files directory:
- Remove the index.html file
- Add the following files
__name@dasherize__.component.ts
__name@dasherize__.component.css
__name@dasherize__.component.html
npm testYou should have 3 files added to the sandbox with the filename you provided to the CLI prompt in sandbox/src/app/components.