NativeScript / nativescript-cli

Command-line interface for building NativeScript apps
https://www.npmjs.com/package/nativescript
Apache License 2.0
1.04k stars 196 forks source link

Feature Request: Use schematics for project transformations #3860

Open sis0k0 opened 6 years ago

sis0k0 commented 6 years ago

What is Schematics?

Schematics is a workflow tool for project transformations, such as scaffolding, file updates and tasks execution (npm install, git init). It can apply rules* from predefined collections - for example generate a new Angular project using the @schematics/angular collection or set up Kendo UI using the @progress/kendo-schematics collection.

* rules - should also be called schematics, but that's confusing, so I'll stick to the name rules instead.

Who uses Schematics?

Schematics is extensively used inside the Angular CLI. It's the backbone of the commands:

How can Schematics be used in the NativeScript CLI?

1. tns generate

Create a command that behaves similarly to ng generate. The @nativescript/schematics collection can be extended with non-Angular rules (Vue.js, plain NativeScript). This will allow all NativeScript developers to use schematics in their projects.

2. tns plugin add

There is already a tns plugin add command in NativeScript CLI, which installs NativeScript plugins and performs project modifications. With schematics, the NativeScript CLI can:

3. tns create

Schematics provides a powerful template engine. The NativeScript templates can be turned into schematic rules. The benefits:

Also, the NativeScript CLI will be able to perform tasks, similarly to the Angular CLI - it could initialize a git repository for the project, install the project dependencies, etc.


Please share your feedback in the comments!

vakrilov commented 6 years ago

Few more points and additions:

4. Extensibility

If played out right, the community should be able to contribute with schematics that will add functionality to (1. tns generate) and (3. tns create).

5. tns update

Updating dependencies, migrating code, handling breaking changes between versions can also be done with schematics in a robust and transactional manner.

Some things that we should consider:

  1. How big is it? Will the additional dependencies will increase the size of the CLI considerably? (@sis0k0)
  2. If we decide that it is worth a try - which would be the best place to integrate it first? (@rosen-vladimirov)
rosen-vladimirov commented 5 years ago

Related to: https://github.com/NativeScript/nativescript-cli/issues/2606