feat: search and install Schematics

Aperta
#10,000 8 commenti 35 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
25/100
Tipo di issue
Funzionalità
Chiarezza
Da chiarire
Stato di attività
Ferma
Stack tecnologico
angular, typescript
Ambito
cli, tooling

Direzione di ricerca

Inizia da packages/@angular/cli/tasks/schematic-search.ts e dal commit del prototipo collegato, quindi confronta il suo comportamento con gli esempi di ng search dell'RFC. Esamina come dovrebbero funzionare il registro NPM e l'identificazione dei pacchetti Schematics, inclusa la nota secondo cui l'installazione è stata implementata tramite ng add. I criteri di completamento per la ricerca, la selezione interattiva, l'individuazione dei pacchetti e l'installazione locale devono ancora essere concordati.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

area: @angular/cli feature feature: under consideration

RFC: Search and install Angular CLI Schematics

tl;dr

The goal of this proposal is to add a new ng command allowing to search and install Angular CLI Schematics right from the command line, using the NPM registry. Read below for more technical details.

Longer version

The Angular CLI has introduced support for Schematics allowing developers to easily extend or even completely change the default behavior of the Angular CLI commands. With Schematics, we can (for instance)...

More generally, you can use Schematics to "[...] transforms to your project, such as create a new component or updating your code to fix breaking changes in a dependency. Or maybe you want to add a new configuration option or framework to an existing project". Read more on the angular.io.

The Angular community has already started creating custom Schematics, here are some of them:

We expect the number of the Angular CLI Schematics to grow; hence, the goal of this thread is to discuss the ability to add a new ng command allowing to (right from the command line):

Note: the commands used below ng search ** are just for illustration purposes!
  1. Searching for available Schematics
> ng search foo_
● foo_abc     (description)      (popularity index)
○ foo_def     (description)      (popularity index)   
○ foo_ghi     (description)      (popularity index)
○ foo_ijk     (description)      (popularity index)
  1. Interactively search for Schematics
> ng search
? Find and install Angular CLI Schematics: foo_
● foo_abc     (description)      (popularity index)
○ foo_def     (description)      (popularity index)   
○ foo_ghi     (description)      (popularity index)
○ foo_ijk     (description)      (popularity index)
  1. Interactively installing Schematics
> ng search 
? Find and install Angular CLI Schematics: bar_ [ENTER]
● bar_def     (description)      (popularity index)   
○ bar_ijk     (description)      (popularity index)

Installing packages for tooling via npm...
  1. Install Schematics
    NOTE: This was implemented via the ng add command.
> ng schematics install foo_abc foo_ghi
Installing...

In order for this search to be done, we will leverage the NPM infrastructure and use the public registry as the database and we need to be able to identify what NPM packages are actually Angular CLI Schematics. Here are different proposals:

  1. Use the current schematics property in the package.json, eg. see example:
{
  ...
  "schematics": "./src/collection.json"
}
  1. Use an NPM named scope, eg. @ngxschematics (ngx being the community reserved prefix we agreed on (cc @IgorMinar) — @schematics is already reserved for the official Schematics made by the Angular team). The community NPM scope (@ngxschematics) would obviously be owned (and maintained) by the Angular core team. So (community) Schematics authors will have to send PRs to that repository to make their Schematics available (listed) in the Angular CLI search command (discussed here). This approach is similar to the DefinitelyTyped project (@types/**).

  2. Have some sort of a "Market Place for Schematics" (out of the scope of this proposal). This could be merged with the previous solution.

  3. Community Schematics authors would have to tag their schematics with an explicit set of tags, eg. (angular, schematics). Community Schematics that aren't tagged using these keywords won't be listed by the Angular CLI search command (discussed here).

Other topics to cover (later) are:

  1. list, update or remove local Schematics.
  2. Replace an active Schematic, eg. defaults, with a new one.

The search process would be done by using 3rd party search APIs that interface with the NPM registry (offering probably better performances?), here are some of them:

  1. npms.io
  2. npmsearch.com
  3. github.com/algolia/npm-search
  4. npm search

Similar projects (inspiration):


Please use Github's emoji to express your interest in this draft.

cc @hansl @Brocco @filipesilva

[UPDATE] working prototype (https://github.com/manekinekko/angular-cli/blob/search-install-schematics/packages/%40angular/cli/tasks/schematic-search.ts)

[UPDATE] upgrade ptotype to v6.0.0-rc.6 (https://github.com/manekinekko/angular-cli/commit/37063374c731386b460fff925183a9d461d0a364)

angular-schematics

Lingua principale
TypeScript
Stelle
27k
Fork
11.8k
Merge medio
16h 35m
PR unite (30g)
176

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di angular/angular-cli

Tutte le issue di angular/angular-cli

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.