-
Notifications
You must be signed in to change notification settings - Fork 669
Angular*CLI.buildArchitectCommand should not fallback to app #4192
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@SchnWalter How can I reproduce the error case where it's falling back to The "bare projects" error isn't the ideal message, but it seems to error properly when it's supposed to. If I try to manipulate See my test repo branches:
What am I missing? |
You need to use Angular CLI to generate a new workspace with a default project that is an Ionic application and some other angular specific libraries and/or applications. To do this I am using the Ionic Angular CLI schematic, which doesn't hardcode To reproduce this step you can checkout https://github.com/SchnWalter/ionic-cli-issue-4192 (or follow the "Steps for recreating the demo repository" section below. If you grep for defaultProject in
But if you do the same after you follow the steps bellow (or just clone the linked repository), you will see this:
To reproduce the issue issue you have to install the latest Ionic CLI (not the modified version)
And you will see that the ionic commands will fail:
And with the version that is included in the PR that I sent earlier, you will see that the ionic commands will work properly:
-- Steps for recreating the demo repository:cd ~/MyProjects/
# Create a new empty Angular workspace.
ng new --create-application=false --new-project-root='.' my-frontend-monorepo
cd ~/MyProjects/my-frontend-monorepo/
# Generate two minimal applications, one to be use with ionic.
# We want the ionic application to be the defaultProject, so we generate it first.
ng generate application --minimal --prefix=mic --routing --style=css my-ionic-client
git add . && git commit -m "add my-ionic-client application"
ng generate application --minimal --prefix=mwc --routing --style=css my-web-client
git add . && git commit -m "add my-web-client application"
# Now add Ionic support using the partial Angular CLI schematic
ng add @ionic/angular --project=my-ionic-client And because
|
It only works when you have multiple Ionic applications in the same repository. If you have an Angular workspace with multiple projects, but only one Ionic application, as the default project, then you get this error:
Because there is no Angular project called In multi-app Angular workspaces that contain a single Ionic application, the
|
This flag automates the setup steps for multi-app projects (see the docs: https://ionicframework.com/docs/cli/configuration#multi-app-projects). Although this feature was built largely with Angular monorepos in mind, it is flexible for all project types. See this wiki article for examples of how to use this feature in Angular: https://github.com/ionic-team/ionic-cli/wiki/Angular-Monorepo ref: #4121 ref: #4192
@SchnWalter I added a feature to Please update to Ionic CLI 6.2.0 and see the example in this new wiki article: https://github.com/ionic-team/ionic-cli/wiki/Angular-Monorepo (largely inspired by your example). You can tweak the prefix/ID from The issue I have with your PR is that it conflicts with the design decision to decouple the Ionic CLI and Angular CLI as much as possible, which makes things more flexible (for example, you can have an Ionic React and Ionic Angular app in the same multi-app project) and easier to maintain in the future (right now we're not reading/writing to I hope this is acceptable and resolves your issue. I think documentation is a big part of this, which is why I wrote up the wiki article and plan to add examples in the future as well as updated the Multi-app Project docs which are meant to be as general as possible. Thank you so much for diving into this and giving a great concrete example. Please let me know if there's something incorrect or missing. 💙 |
I see your point. Thanks for the update and the feature. I've created a followup MR to fix some parts of P.S. I'll create a followup MR to port some tests and fixes from the old MR: #4311 |
Thanks. Apologies it took so long for me to look at it. That all sounds good! I look forward to your PR. |
Added MR #4349 |
Awesome! I'm happy these commands are now up to snuff. Cheers 🍻 |
The
AngularBuildCLI.buildArchitectCommand()
andAngularServeCLI.buildArchitectCommand()
methods should not hardcodeapp
as a fallback project name when no project name is provided via arguments. The best approach would be to read thedefaultProject
key fromangular.json
or by runningng config defaultProject
With this, the Ionic CLI will be able to work, by default, in Angular workspaces where the
defaultProject
is not namedapp
; as for the ones generated using theng add @ionic/angular
schematic; see: #4191L.E. #4121 should be dealt with first.
The text was updated successfully, but these errors were encountered: