Angular-cli: [TRACKING] Custom Templates for Generators

Created on 6 Jun 2017  路  8Comments  路  Source: angular/angular-cli

Implement usage of Schematics (see this PR) in the CLI and allow custom templates.

This requires some design to have a default collection and use a custom collection + schematics.

This issue can be considered completed when:

  • [x] Use Schematics in the CLI

    • [x] Generate

    • [x] New

  • [x] Move all blueprints in the CLI to Schematics

    • [x] app

    • [x] class

    • [x] component

    • [x] directive angular/devkit#33

    • [x] enum

    • [x] guard angular/devkit#30

    • [x] interface

    • [x] module

    • [x] pipe angular/devkit#20

    • [x] service angular/devkit#26

  • [x] Fix the app schematic to use component to create the default component, and module to create the initial module.
  • [x] Publish a default Angular Collection that contains most blueprints we have and maybe some others
  • [x] Add options to select a collection and schematic by name.
  • [x] Add configuration flag in angular-cli.json to use a collection by default, so that ng g my-awesome-schematics will use the default collection which includes my-awesome-schematics.
  • [x] Ensure help works
  • [x] Remove blueprints code from ember
feature

Most helpful comment

Could you please provide a documentation? I updated to 1.4.0-rc0 and cant create a component anymore: ng g c not working. ng g component working. ng g component shared/mycomponent (to create component inside module) not working.

Also i dont know what schematics are and the github project doesn't contain any readme.

All 8 comments

I'm very interested in this feature. I've spent some time prototyping the ability to hack custom blueprints into the current CLI for an Enterprise client. I've got it working, but I've run into a number of issues that make things a bit more hacky than I'd like. I'm doing the initial design for this client from now until July 5th, but then I'll need to implement the new system with custom schematics and custom app schematics starting the first week of September.

Is there a design document for this work that I can review and/or provide feedback on?

I've looked at the devkit repo a good bit and saw the example schematic, but I haven't yet figured out how to start testing it w/ the CLI.

Publish a default Angular Collection that contains most blueprints we have and maybe some others

How will custom collections/schematics be added to an Angular CLI project? This sounds like they would be published as npm packages?

The first post says that the following is done:

Add configuration flag in angular-cli.json to use a collection by default, so that ng g my-awesome-schematics will use the default collection which includes my-awesome-schematics.

Which flag in the schema.json is this? I wasn't able to find one that seemed to fit this description.

Move all blueprints in the CLI to Schematics
I may be able to help with this if the tooling is ready and I can get some guidance.

I spoke to @Brocco and got my questions answered.

  • No design doc available.
  • For the initial design, you will be able to add a single collection of schematics which will override/extend the original defaults. These can be added via NPM Modules or via pointing to a path on the File system. This is implemented by Engines in DevKit. It's possible additional Engines could be added in the future.
  • The angular-cli.json flag for schematics is implemented on a private branch and will be pushed to this repo soon.

Awesome progress on this!

Being very eager to try this out, I got the new master branch now that the branch is merged and all the critical stuff seems to be there. I created a custom collection (I just took @schematics/angular and changed a few things) and ran ng new -c ./my-own-collection testproject. Which ofc did not work (I see that there are still a few checkmarks not finished ;-) ).

Now, I may be way too early trying this out, but I also did not see any plans for further documentation on this Tracking Issue for the collections. So as a bit of - maybe way to early - feedback, I guess a little bit more documentation how such a collection needs to be set up (or where) in order for something like ng new -c my-own-collection testproject to work, would not hurt. My instinct of just taking your @schematics/angular-collection, modifying it and pointing to the modified version seems to have been the wrong instinct :-D

Oh and awesome work on this! Thanks a lot!

Could you please provide a documentation? I updated to 1.4.0-rc0 and cant create a component anymore: ng g c not working. ng g component working. ng g component shared/mycomponent (to create component inside module) not working.

Also i dont know what schematics are and the github project doesn't contain any readme.

Any further updates on this?

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

_This action has been performed automatically by a bot._

Was this page helpful?
0 / 5 - 0 ratings