GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — externalSchematic executes schematics from migration.json instead of collection.json · Issue #21131 · angular/angular-cli

externalSchematic executes schematics from migration.json instead of collection.json #21131

New issue
Copy link
New issue
Copy link
Open
Open
externalSchematic executes schematics from migration.json instead of collection.json#21131
Copy link
Labels
area: @angular-devkit/schematicsfreq1: lowOnly reported by a handful of users who observe it rarelyOnly reported by a handful of users who observe it rarelyseverity3: brokentype: bug/fix
Milestone
Backlog

Description

@mmuenker
mmuenker
opened on Jun 14, 2021
Issue body actions

🐞 Bug report

Command

  • new
  • build
  • serve
  • test
  • e2e
  • generate
  • add
  • 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.

Activity

  1. alan-agius4
    added
    freq1: lowOnly reported by a handful of users who observe it rarelyOnly reported by a handful of users who observe it rarely
    type: bug/fix
    area: @angular-devkit/schematics
    on Jun 15, 2021
  2. ngbot
    added this to the needsTriage milestone on Jun 15, 2021
  3. alan-agius4
    added
    severity3: broken
    on Jun 15, 2021
  4. ngbot
    modified the milestones: needsTriage, Backlog on Jun 15, 2021
  5. mmuenker commented on Jun 16, 2021

    @mmuenker
    mmuenker
    on Jun 16, 2021
    Author
    More actions

    For now, I have created a hacky workaround:

    In a migration function for the package ngx-my-lib

    return chain([
      (_, context) => {
        // TODO: workaround until issue is resolved: https://github.com/angular/angular-cli/issues/21131
        context.engine['_collectionCache'].delete('ngx-my-lib');
      },
      externalSchematic('ngx-my-lib', 'demo', {}),
    ]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: @angular-devkit/schematicsfreq1: lowOnly reported by a handful of users who observe it rarelyOnly reported by a handful of users who observe it rarelyseverity3: brokentype: bug/fix

    Type

    No type

    Projects

    No projects

      Milestone

      • BacklogNo due date

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.