Visitar URL original
Schematics update operation does not work. Change is not reflected. · Issue #17578 · angular/angular-cli · GitHub
The Wayback Machine - https://web.archive.org/web/20260424194721/https://github.com/angular/angular-cli/issues/17578
Skip to content

Schematics update operation does not work. Change is not reflected. #17578

@raul1991

Description

@raul1991

🐞 Bug report

Command (mark with an x)

  • new
  • build
  • serve
  • test
  • e2e
  • generate
  • add
  • update
  • lint
  • xi18n
  • run
  • config
  • help
  • version
  • doc

Is this a regression?

Not sure about this as I am using it for the first time.

Description

I am using angular schematics to add a declaration to my module file. Even though the output says the UPDATE /path/to/file.ts I still can't see the update.

🔬 Minimal Reproduction

const declarationChanges = addDeclarationToModule(sourceFile, newLocal, `List${strings.classify(_options.name)}Component`, `./components/general-configuration/${dasherize(_options.name)}/list/list-${dasherize(_options.name)}.component`);
    const declarationRecorder = tree.beginUpdate(newLocal);
    for (const change of declarationChanges) {
        if (change instanceof InsertChange) { // This if statement is evaluating to false, may be that is why
            _context.logger.info(change.toAdd);
            declarationRecorder.insertLeft(change.pos, change.toAdd);
        }
    }
    tree.commitUpdate(declarationRecorder);
    return chain([
      mergeWith(createTemplate(tree, _options, templates.services, '/services')),
      mergeWith(createTemplate(tree, _options, templates.models, '/models')),
      mergeWith(createTemplate(tree, _options, templates.components.create, `/components/general-configuration/${dasherize(_options.name)}/create`)),
      mergeWith(createTemplate(tree, _options, templates.components.list, `/components/general-configuration/${dasherize(_options.name)}/list`)),
      mergeWith(createTemplate(tree, _options, templates.constants, '/constants')),
    ]);

🔥 Exception or Error


I get no error but the update is not reflected either.
CREATE src/coba/services/fossil-fuels.service.ts (1252 bytes)
CREATE src/coba/models/fossil-fuels.create-fossil-fuels.model.ts (807 bytes)
CREATE src/coba/components/general-configuration/fossil-fuels/create/fossil-fuels.create-fossil-fuels.component.scss (0 bytes)
CREATE src/coba/components/general-configuration/fossil-fuels/create/fossil-fuels.create-fossil-fuels.component.ts (8259 bytes)
CREATE src/coba/components/general-configuration/fossil-fuels/list/fossil-fuels.list-fossil-fuels.component.scss (0 bytes)
CREATE src/coba/components/general-configuration/fossil-fuels/list/fossil-fuels.list-fossil-fuels.component.ts (6995 bytes)
CREATE src/coba/constants/serverurl.constants.ts (70129 bytes)
**UPDATE src/coba/coba.module.ts (1959 bytes)**   <- This is not reflected in the actual file. All of the above operations are.

🌍 Your Environment



Angular CLI: 8.2.0
Node: 12.13.1
OS: linux x64
Angular: 8.2.0
... animations, cli, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router

Package                            Version
------------------------------------------------------------
@angular-devkit/architect          0.802.0
@angular-devkit/build-angular      0.800.6
@angular-devkit/build-ng-packagr   0.800.6
@angular-devkit/build-optimizer    0.800.6
@angular-devkit/build-webpack      0.800.6
@angular-devkit/core               8.2.0
@angular-devkit/schematics         8.2.0 (cli-only)
@ngtools/webpack                   8.0.6
@schematics/angular                8.2.0
@schematics/update                 0.802.0
ng-packagr                         5.7.1
rxjs                               6.4.0
typescript                         3.4.5
webpack                            4.30.0



Anything else relevant?

I created a schematics project and everything new changes is going to the file properly but the UPDATE operation is not. I am running the following command

ng g ../coba-schematics/src/collection.json:entities FossilFuels --create-page-title "Fossils" --force

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions