Schematics
Instalation
To work with schematics run the following installation command
npm i -g @angular-devkit/schematics-cli
To verify it is installed run
schematics --help
Use in Parro Connect
The parro connect repo has a directory called code-gen/schematics. This contains the exisiting schematics which can be used to generate code.
Create a new schematics
When you want to add a new schematic for code generation you need to create a new directory in the src folder with the name of the schematic you want to add.
Next you open de collection.json file in the src folder and add your schematic to it.
Within the created schematic folder you can add your code which is triggered when generating code.
Easiest way to start is to copy one of the existing schematics and work from there.
Build the schematic
To build the schematic run the following command:
npm run build
Test run a schematic
To see if your schematic is working you can run this command from within the code-gen/schematics dir.
schematics .:<schematics_dir_name>
i.e to run the connect-service:
schematics .:connect-service
This will output the result of what the schematic will create. This command will run in debug mode by default. This will not acutally generated any files.
To test your schematic with files run
schematics .:connect-service --debug=false
Build and install
For testing you van create and install the schematics locally. To do this run:
npm run build
npm pack
npm i -g schematics-connect-service-<version>.tgz
When all is working you can publish (when you have the publish permissions) the schematics to the artifactory. Before you van publish make sure you bumped the version, it is not allowed to publish the same version again.
To do this run:
npm run build
npm publish