angular / angular-cli

CLI tool for Angular
https://cli.angular.io
MIT License
26.76k stars 11.97k forks source link

Schematics that worked in 7.x no longer work with 8.x #15156

Closed mcgear closed 5 years ago

mcgear commented 5 years ago

🐞 Bug report

Command (mark with an x)

- [ ] new
- [ ] build
- [ ] serve
- [ ] test
- [ ] e2e
- [x ] generate
- [ ] add
- [ ] update
- [ ] lint
- [ ] xi18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc

Is this a regression?

Yes, the previous version in which this bug was not present was: 7.3.9 ### Description We have a series of Schematics that are managed at the following github repo: https://github.com/lowcodeunit-devkit/ng-lcu In the 'master' branch are all the old schematics that we had working in older version of angular. As we work on our upgrade to 8, everything was going smooth until the ng-lcu schematics. We upgraded the project, and when running schematics locally with 'schematics .:lcu-core-app' or something everything succeeds as would be expected. The issue arises after releasing schematics to an npm package and trying to reference them from there. It is at this point we run into issues after adding the schematic and attempting to use ng g to execute. More explained in repro steps. We have seen this issue against 8.1.2 and attempted upgrad to the 8.2.0-next.1 and saw the same issue. ## πŸ”¬ Minimal Reproduction We believe that the issue is in the ng g command as the ng add command does actually succeed. To simplify the reproduction of this issue (and in our own attempt to resolve) we have taken the integration branch of our repo (https://github.com/lowcodeunit-devkit/ng-lcu) and turned it into a reproduction of this issue. This provides both the code we are seeing and a build usable from npm. To reproduce this issue in a new project, try the following: 1. mkdir tester 2. cd tester 3. ng new tester --directory=./ --defaults 4. ng add @lowcodeunit-devkit/ng-lcu 5. ng-add worked - verify version 0.37.226-integration of @lowcodeunit-devkit/ng-lcu is installed in package.json and verify the existence of an ng-add.json at the root of the angular workspace 6. ng g @lowcodeunit-devkit/ng-lcu:hello It is at this point the simple hello schematic fails to run:

import { Rule, SchematicContext, Tree } from '@angular-devkit/schematics';
// You don't have to export the function as default. You can also have more than one rule factory
// per file.
export function hello(_options: any): Rule {
  return (tree: Tree, _context: SchematicContext) => {
    tree.create('hello.json', JSON.stringify({ workspace: 'hey' }));
    return tree;
  };
}

The way that ng add works and ng g fails to do anything is what leads me to believe the issue is in ng generate.

πŸ”₯ Exception or Error

We receive no errors.

🌍 Your Environment




@angular-devkit/architect         0.801.2
@angular-devkit/build-angular     0.801.2
@angular-devkit/build-optimizer   0.801.2
@angular-devkit/build-webpack     0.801.2
@angular-devkit/core              8.1.2
@angular-devkit/schematics        8.1.2
@ngtools/webpack                  8.1.2
@schematics/angular               8.1.2
@schematics/update                0.801.2
rxjs                              6.4.0
typescript                        3.4.5
webpack                           4.35.2

Anything else relevant?

Windows system on VS Code.

mcgear commented 5 years ago

Hey, just a little update. We had to cut a release of the CLI back to when it was more or less working. So to get the full reproduction, you will need to manually install @lowcodeunit-devkit/ng-lcu0.37.226-integration after the add step.

mcgear commented 5 years ago

Wanted to post that we have reverted our integration branch back to our actual code base in prep to test when this is released.

xchanin commented 5 years ago

I've verified that this fix works for us, thanks. Do you know when it will be released?

angular-automatic-lock-bot[bot] commented 5 years ago

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.