externalSchematic executes schematics from migration.json instead of collection.json
- Lenguaje dominante
- TypeScript
- Estrellas
- 27k
- Forks
- 11.8k
- Merge medio
- 14 h 23 min
- PR fusionados (30 d)
- 162
Descripción
# 🐞 Bug report
### Command
- [ ] new
- [ ] build
- [ ] serve
- [ ] test
- [ ] e2e
- [ ] generate
- [ ] add
- [x] update
- [ ] lint
- [ ] extract-i18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc
### Is this a regression?
No
### Description
The function `externalSchematic` from `@angular-devkit/schematics` does not call the schematic from the `collection.json` but instead from the `migration.json` If the collection (package) name is the same as the current package that is migrated.
## 🔬 Minimal Reproduction
1. The package `ngx-my-lib` has the schematic `config` defined in the `collection.json`
2. Create a migration schematic for the package `ngx-my-lib`.
3. Call the externalSchematic function with `externalSchematic('ngx-my-lib', 'config')` in the migration schematic.
4. Execute the migration schematic
## 🔥 Exception or Error
Schematic "config" not found in collection "ngx-my-lib"
## 🌍 Your Environment
Angular CLI: 12.0.3
Node: 14.16.1
Package Manager: yarn 1.22.10
OS: linux x64
Angular: undefined
...
Package Version
------------------------------------------------------
@angular-devkit/architect 0.1200.3
@angular-devkit/core 12.0.3
@angular-devkit/schematics 12.0.3
@angular/cli 12.0.3
@schematics/angular 12.0.3
typescript 4.2.4
**Anything else relevant?**
I could track down this error to the `createCollection` method in the class `SchematicEngine`. Invoking the `externalSchematic` the `Collection` instance for the `migration.json` is cached with the key `ngx-my-lib`. So the external schematic execution does not load the collection for the `collection.json`, but for the `migration.json`.
Guía de contribución
Línea de trabajo
Comienza con SchematicEngine.createCollection y la llamada a externalSchematic descrita en el informe; luego sigue cómo se cargan y se almacenan en caché collection.json y migration.json con el mismo nombre de paquete. Reproduce el escenario de ngx-my-lib y verifica que externalSchematic resuelva el schematic desde collection.json en lugar de migration.json.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- angular, typescript
- Área
- tooling
- Tipo de issue
- Error
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 35/100