Workspace Plugins
Inspecting the Existing Generator
-
Have a look to the generator in
libs/my-plugin/src/generators/data-lib
. Look at the files in this folder and focus on the filegenerator.ts
. -
Execute the generator:
npx nx g @flight-workspace/my-plugin:data-lib my-tickets --entity ticket
-
Have a look at the generated files.
Hint: You can delete your generated library with
ng g @nrwl/workspace:rm my-tickets
.
Bonus: Extend the Existing Generator *
Extend the existing generator so that it also adds a save method to the generated data service.
Bonus: Add a Parameter to the Existing Generator *
Add a boolean parameter save
to the files schema.d.ts
and schema.json
. Make the generator
to only emit a save method if this flag is set to true
.
Hint: This is what an if
looks like in an template.
<% if (save) { %>
// Your Code here ...
<% } %>
Please find the solution here.
Bonus: Inspecting the Existing Executor *
-
Have a look to the executor in
libs/my-plugin/src/executors/build
. Look at the files in this folder and focus on the fileexecutor.ts
. -
Have a look to the target
demo-executor
at the end of the fileapps/flight-app/project.json
. -
Start the executor:
ng run flight-app:demo-executor
-
Have a look at the generated file
dist/demo.txt
.