Workspace Plugins

Inspecting the Existing Generator

  1. 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 file generator.ts.

  2. Execute the generator:

    npx nx g @flight-workspace/my-plugin:data-lib my-tickets --entity ticket
    
  3. 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 *

  1. Have a look to the executor in libs/my-plugin/src/executors/build. Look at the files in this folder and focus on the file executor.ts.

  2. Have a look to the target demo-executor at the end of the file apps/flight-app/project.json.

  3. Start the executor:

    ng run flight-app:demo-executor
    
  4. Have a look at the generated file dist/demo.txt.