You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Feature request: Initialize a new CLI project without having CLI globally installed #4768
Due to major breaking changes with each CLI release to be able to initialize a new project without having CLI globally installed so this way we can run multiple projects with different CLI versions on single PC and it is what was the purpose of this PR 761e86f
Current situation
Before beta30 without having CLI globally installed it was possible to create CLI app just like that :
npm init -y
npm install @angular/cli --save
alter package.json by adding "ng":"ng" script section (761e86f)
npm run ng -- init
Now it is seams to be it is not longer possible due to this PR #4628
Proposal
How about if you run npm run ng -- new on an empty folder it will create the new CLI app?
Right now it is also not an option because just by having a folder with just node_modules folder and a simple package.json like that:
When running npm run ng -- new I am getting an error You cannot use the new command inside an Angular CLI project. which is not quite right because there is no Angular CLI app in my folder.
@filipesilva this is more related to #4762, which is also closed, but has a pending discussion that I hope you or @hansl can look at, so, it's either completely killed, or maybe opened for further consideration.
@kuncevic this isn't a functionality that we want to explicitly support, but we might end up supporting via a bugfix that I discussed with @Meligy. He'll be looking into it.
Hi everyone, Dennis from the WebStorm team.
We're using ng init to generate the project because due to some platform limitations project directory with .idea in it is already present at the time when we can finally invoke real project generator. We can generate the project in some temp directory for sure and then copy over, but this looks like a messy solution.
I'm not seeing a problem of keeping ng init in place as currently ng new just delegates the command line options to init (https://github.com/angular/angular-cli/blob/master/packages/%40angular/cli/commands/new.ts#L66)
@denofevil the problem for us is that we don't want to support the command at all. It's not as much a matter of technical feasibility but rather a question of the set of commands we want to have in the CLI.
@Meligy did you have time to look at the bug we discussed?
That is @Meligy's suggestion in #4762. Maybe you can even use it in your scenario right now with no change: ng new sample -dir=..
Currently @Meligy's full scenario (using a local CLI install) doesn't work because the CLI uses package.json/node_modules as project identity, and thus it considers to already be inside of a project.
We were looking at fixing a related bug (#1079) that would enable #4762.
@filipesilva actually that was the second thing I've tried and I'm getting
ng new sample -dir=.
Directory '.' already exists.
which seems to be handled here. This exception is causing then block in new command to be never invoked.
I'm trying with completely empty directory on the command line (and there are no package.json files in upper folders), in case of WebStorm/IntelliJ there would be .idea folder and [ProjectName].iml file
Activity
Meligy commentedon Feb 17, 2017
Related #4762
I think if we fix it, this one will be fixed as well.
kuncevic commentedon Feb 17, 2017
@Meligy, comment that saying it is not quite 'by design' #4762 (comment) :
filipesilva commentedon Feb 17, 2017
ng inithas been removed in #4628.Meligy commentedon Feb 17, 2017
@filipesilva this is more related to #4762, which is also closed, but has a pending discussion that I hope you or @hansl can look at, so, it's either completely killed, or maybe opened for further consideration.
It also makes implementing your suggestion here 3ad2856#commitcomment-20929880 a bit easier.
kuncevic commentedon Feb 17, 2017
@filipesilva I saw the PR you mentioned, that is why I raised the Feature request, why you do not want to keep for further discussion?
filipesilva commentedon Feb 17, 2017
@kuncevic this isn't a functionality that we want to explicitly support, but we might end up supporting via a bugfix that I discussed with @Meligy. He'll be looking into it.
denofevil commentedon Feb 21, 2017
Hi everyone, Dennis from the WebStorm team.
We're using
ng initto generate the project because due to some platform limitations project directory with .idea in it is already present at the time when we can finally invoke real project generator. We can generate the project in some temp directory for sure and then copy over, but this looks like a messy solution.I'm not seeing a problem of keeping
ng initin place as currentlyng newjust delegates the command line options to init (https://github.com/angular/angular-cli/blob/master/packages/%40angular/cli/commands/new.ts#L66)filipesilva commentedon Feb 21, 2017
@denofevil the problem for us is that we don't want to support the command at all. It's not as much a matter of technical feasibility but rather a question of the set of commands we want to have in the CLI.
@Meligy did you have time to look at the bug we discussed?
denofevil commentedon Feb 21, 2017
@filipesilva so how about handling non-empty directory in
ng newlike create-react-app does?filipesilva commentedon Feb 21, 2017
That is @Meligy's suggestion in #4762. Maybe you can even use it in your scenario right now with no change:
ng new sample -dir=..Currently @Meligy's full scenario (using a local CLI install) doesn't work because the CLI uses package.json/node_modules as project identity, and thus it considers to already be inside of a project.
We were looking at fixing a related bug (#1079) that would enable #4762.
denofevil commentedon Feb 21, 2017
@filipesilva actually that was the second thing I've tried and I'm getting
which seems to be handled here. This exception is causing then block in new command to be never invoked.
I'm trying with completely empty directory on the command line (and there are no package.json files in upper folders), in case of WebStorm/IntelliJ there would be .idea folder and [ProjectName].iml file
filipesilva commentedon Feb 21, 2017
Ok, that's a bit more problematic. Maybe we need a force flag or something.
denofevil commentedon Feb 21, 2017
Yes, that would work ok for us.
If you think that
--forcewould be ok I can probably come up with a PR.hansl commentedon Feb 22, 2017
Hi @denofevil @filipesilva,
Sorry about the lack of discussion on this, I've been away all weekend. I think Filipe has done a good job explaining why we removed
init.ng new --dir=. my-projectshould work, in my opinion. I'll make a PR to do it and try to merge it before RC. Cheers!hansl commentedon Feb 22, 2017
Dupe of #4762. Will use that one to track. Thanks!