Skip to content

Support having a default project in v6 #10352

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

Closed
filipesilva opened this issue Apr 16, 2018 · 4 comments · Fixed by angular/devkit#813
Closed

Support having a default project in v6 #10352

filipesilva opened this issue Apr 16, 2018 · 4 comments · Fixed by angular/devkit#813
Assignees
Labels
P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
Milestone

Comments

@filipesilva
Copy link
Contributor

Angular CLI 6 supports having multiple projects, and comes with two projects by default (the Angular app and the E2E suite).

The user expectectation for some commands, like ng build or ng lint, is that all projects are built/linted. But other commands, like ng serve or ng generate, are expected to target a single project.

Currently we don't support project targets depending on each other either. If you have a library and a project, running ng build would built both in no specific order. If your app depends on your library, this can lead to app compilation failing or using an old library build. For this reason ng build should be a single project command.

We should have a default project to make sure single-project commands are run over the default one.

@filipesilva filipesilva added this to the v6.0.0 milestone Apr 16, 2018
@CanKattwinkel
Copy link

Hello @filipesilva, struggling with ng generate comands I came across this issue and would like to add my thoughts since it's all about the same thing.

Is it possible to standardize and simplify the general process of selecting the application as part of this change?

Given an example portal project that consists of a portal app and a navbar app (provided for other applications as iframe, therefore a independent application) both sharing a core lib app-hub-core.

I would prefer not to have to wrap the ng generate commands with my own npm scripts just because they are too complex. But currently selecting the app/lib to generate components into is not intuitive enough. The structure of the portal I'm building is available as example project here.

To generate a component in the shared app-hub-core I'd have to use:

// --skip-import  because he can't find the right module
ng --project=app-hub-core g c test --dry-run --skip-import

CREATE projects/app-hub-core/src/app/test/test.component.scss (0 bytes)
CREATE projects/app-hub-core/src/app/test/test.component.html (23 bytes)
CREATE projects/app-hub-core/src/app/test/test.component.spec.ts (614 bytes)
CREATE projects/app-hub-core/src/app/test/test.component.ts (262 bytes)

So far so good.

But lets try to create a component in one of the apps.

ng --project=navbar g c test --dry-run --skip-import

CREATE src/app/test/test.component.scss (0 bytes)
CREATE src/app/test/test.component.html (23 bytes)
CREATE src/app/test/test.component.spec.ts (614 bytes)
CREATE src/app/test/test.component.ts (262 bytes)

There is not even a src folder in my project. Lets try to use the --app parameter instead of project:

ng --app=navbar g c test --dry-run --skip-import

CREATE src/app/test/test.component.scss (0 bytes)
CREATE src/app/test/test.component.html (23 bytes)
CREATE src/app/test/test.component.spec.ts (614 bytes)
CREATE src/app/test/test.component.ts (262 bytes)

Same result, not happy with hat.


How I imagine an ideal solution (for multiple apps and multiple libraries)

  • Loose the distinction between app/project since all are mapped as project
  • Short commands without difficult prefix structure since they get used a lot
  • Unified with Ng serve (ng serve portal is working already but this syntax would be harder to use for generate).

So how about bringing the project name forward? Yarn is doing something similar with providing the npm scripts directly without additional run like npm does (e.g. yarn serve vs npm run serve).

So ideally I'd would want to write something like this:

ng portal g c test
ng portal serve`

Folder Structure: (click to expand)
src-portal/
├── app
│   ├── portal-app.component.html
│   ├── portal-app.component.scss
│   ├── portal-app.component.spec.ts
│   ├── portal-app.component.ts
│   └── portal-app.module.ts
├── assets
├── browserslist
├── environments
│   ├── environment.prod.ts
│   └── environment.ts
├── favicon.ico
├── index.html
├── karma.conf.js
├── main.ts
├── polyfills.ts
├── styles.scss
├── test.ts
├── tsconfig.app.json
├── tsconfig.spec.json
└── tslint.json
src-navbar/
├── app
│   ├── navbar-app.component.html
│   ├── navbar-app.component.scss
│   ├── navbar-app.component.spec.ts
│   ├── navbar-app.component.ts
│   └── navbar-app.module.ts
├── assets
├── browserslist
├── environments
│   ├── environment.prod.ts
│   └── environment.ts
├── favicon.ico
├── index.html
├── karma.conf.js
├── main.ts
├── polyfills.ts
├── styles.scss
├── test.ts
├── tsconfig.app.json
├── tsconfig.spec.json
└── tslint.json
projects/
└── app-hub-core
    ├── karma.conf.js
    ├── ng-package.json
    ├── ng-package.prod.json
    ├── package.json
    ├── src
    │   ├── lib
    │   │   ├── app-hub-core.component.spec.ts
    │   │   ├── app-hub-core.component.ts
    │   │   ├── app-hub-core.module.ts
    │   │   ├── app-hub-core.service.spec.ts
    │   │   └── app-hub-core.service.ts
    │   ├── public_api.ts
    │   └── test.ts
    ├── tsconfig.lint.json
    ├── tsconfig.spec.json
    └── tslint.json

Ng Version (click to expand)


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

Angular CLI: 6.0.0-rc.5
Node: 9.4.0
OS: linux x64
Angular: 6.0.0-rc.5
... animations, cli, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

Package                            Version
------------------------------------------------------------
@angular-devkit/architect          0.5.7
@angular-devkit/build-angular      0.5.7
@angular-devkit/build-ng-packagr   0.5.7
@angular-devkit/build-optimizer    0.5.7
@angular-devkit/core               0.5.7
@angular-devkit/schematics         0.5.7
@ngtools/json-schema               1.1.0
@ngtools/webpack                   6.0.0-rc.5
@schematics/angular                0.5.7
@schematics/update                 0.5.7
rxjs                               6.0.0-uncanny-rc.7
typescript                         2.7.2
webpack                            4.5.0


@filipesilva
Copy link
Contributor Author

@Brocco could you comment on @CanKattwinkel's post? The default project I am proposing in this issue is useful for generators with no targeted project but I don't think it would help for targeting specific projects.

@hansl hansl added the P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent label Apr 23, 2018
@filipesilva filipesilva self-assigned this Apr 23, 2018
filipesilva added a commit to angular/devkit that referenced this issue Apr 24, 2018
filipesilva added a commit to filipesilva/angular-cli that referenced this issue Apr 25, 2018
filipesilva added a commit to filipesilva/angular-cli that referenced this issue Apr 25, 2018
filipesilva added a commit to filipesilva/angular-cli that referenced this issue Apr 26, 2018
filipesilva added a commit to filipesilva/angular-cli that referenced this issue Apr 26, 2018
filipesilva added a commit to filipesilva/angular-cli that referenced this issue Apr 26, 2018
filipesilva added a commit to filipesilva/angular-cli that referenced this issue Apr 26, 2018
@hansl hansl closed this as completed in 06bba06 Apr 26, 2018
@cyrilletuzi
Copy link
Contributor

Still not fixed for ng g service-worker and ng add @angular/pwa. See #10469

@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants