angular / angular-cli

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

Allow to specify particular angular version during project creation #12609

Closed marbug closed 6 years ago

marbug commented 6 years ago

Bug Report or Feature Request (mark with an x)

- [ ] bug report -> please search issues before submitting
- [x] feature request

Command (mark with an x)

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

Versions

It's needed in each version but here are my current ones:

$ node --version
v8.11.4

$ npm --version
5.6.0

$ ng --version

     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/

Angular CLI: 6.1.5
Node: 8.11.4
OS: darwin x64
Angular: 
... 

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.7.5
@angular-devkit/core         0.7.5
@angular-devkit/schematics   0.7.5
@schematics/angular          0.7.5
@schematics/update           0.7.5
rxjs                         6.3.1
typescript                   2.9.2

MacOS High Sierra 10.13.6 but same on Windows 10 64bit

Repro steps

I found a suggestion to use --ng4 for angular4 here:

https://stackoverflow.com/questions/43344600/installing-a-specific-version-of-angular-with-angular-cli

So I tried the following:

ng new test-app --ng4
ng new test-app --ng5

but angular6 is used in any case:

$ less test-app/package.json | grep angular
    "@angular/animations": "^6.1.0",
    "@angular/common": "^6.1.0",
    "@angular/compiler": "^6.1.0",
    "@angular/core": "^6.1.0",
    "@angular/forms": "^6.1.0",
    "@angular/http": "^6.1.0",
    "@angular/platform-browser": "^6.1.0",
    "@angular/platform-browser-dynamic": "^6.1.0",
    "@angular/router": "^6.1.0",
    "@angular-devkit/build-angular": "~0.7.0",
    "@angular/cli": "~6.1.5",
    "@angular/compiler-cli": "^6.1.0",
    "@angular/language-service": "^6.1.0",

The log given by the failure

No log is present

Desired functionality

The project with the specified angular version is created.

Mention any other details that might be useful

Usecases of this are very simple:

  1. Sometimes beta version becomes a default one, but it's needed to generate a project with stable version
  2. Sometimes it's needed to create project with previous stable version
  3. etc
alexeagle commented 6 years ago

If you want version X of angular, then install version X of the CLI.

For example, CLI v6 will always create Angular v6 projects.

We feel that the latest version of Angular is always the appropriate one for creating new projects.

marbug commented 6 years ago

Sorry, @alexeagle but I even remember, when projects, generated by latest versions of Angular, failed just after first run (i.e. without any changes) and I had to recheck and downgrade that versions manually :D So it sounds much better to have an ability to switch even to particular subversion of angular (I mean the appropriate package.json version indeed) if something is wrong (very big sorry: I did not want to mention this, but I have to). I.e. something like to 5.1 or 5.2 or x.y or ... If everything is implemented as templates, then it could be simple and very useful even for angular team IMHO.

marbug commented 6 years ago

All previous projects were generated with some default package.json so it should be simple to store such package.json (may be with package-lock.json) in the separate folder and use something like --template <folder-name> to use them (i.e. from particular folder). And this should also allow other teams to create their own templates like angular6+redux, etc. What do you think?

marbug commented 6 years ago

And re-installation of angular CLI each time when I need project with other version sounds a bit time consuming. Having an option to use some particular template should save much time.

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.