67 Commits

Author SHA1 Message Date
Charles Lyding
9afe185fc6 build: enable noImplicitOverride TypeScript option
The `noImplicitOverride` TypeScript option improves code quality by ensuring that properties from base classes are not accidentally overriden.
Reference: https://www.typescriptlang.org/tsconfig#noImplicitOverride
2021-07-02 06:40:36 -04:00
Alan Agius
586226a305 fix(@angular/cli): infer schematic defaults correctly when using --project
Previously, the `--project` flag was ignored when gathering and merging the schematics defaults from the angular workspace configuration file.

Closes #20666
2021-05-05 11:49:22 -04:00
Alan Agius
f6135a20d1 fix(@angular/cli): don't display options multiple times in schematics help output
Previously, we disabled options in the help output multiple times.

Previous output
```
Generates and/or modifies files based on a schematic.
usage: ng generate c <name> [options]

arguments:
  schematic
    The schematic or collection:schematic to generate.
  name
    The name of the component.

options:
  --change-detection (-c)
    The change detection strategy to use in the new component.
  --defaults
    When true, disables interactive input prompts for options with a default.
  --display-block (-b)
    Specifies if the style will contain `:host { display: block; }`.
  --dry-run (-d)
    When true, runs through and reports activity without writing out results.
  --entry-component
    When true, the new component is the entry component of the declaring NgModule.
  --export
    When true, the declaring NgModule exports this component.
  --flat
    When true, creates the new files at the top level of the current project.
  --force (-f)
    When true, forces overwriting of existing files.
  --help
    Shows a help message for this command in the console.
  --inline-style (-s)
    When true, includes styles inline in the component.ts file. Only CSS styles can be included inline. By default, an external styles file is created and referenced in the component.ts file.
  --inline-template (-t)
    When true, includes template inline in the component.ts file. By default, an external template file is created and referenced in the component.ts file.
  --interactive
    When false, disables interactive input prompts.
  --lint-fix
    When true, applies lint fixes after generating the component.
  --module (-m)
    The declaring NgModule.
  --prefix (-p)
    The prefix to apply to the generated component selector.
  --project
    The name of the project.
  --selector
    The HTML selector to use for this component.
  --skip-import
    When true, does not import this component into the owning NgModule.
  --skip-selector
    Specifies if the component should have a selector or not.
  --skip-tests
    When true, does not create "spec.ts" test files for the new component.
  --style
    The file extension or preprocessor to use for style files.
  --type
    Adds a developer-defined type to the filename, in the format "name.type.ts".
  --view-encapsulation (-v)
    The view encapsulation strategy to use in the new component.

Help for schematic c
Creates a new generic component definition in the given or default project.
arguments:
  name
    The name of the component.

options:
  --change-detection (-c)
    The change detection strategy to use in the new component.
  --display-block (-b)
    Specifies if the style will contain `:host { display: block; }`.
  --entry-component
    When true, the new component is the entry component of the declaring NgModule.
  --export
    When true, the declaring NgModule exports this component.
  --flat
    When true, creates the new files at the top level of the current project.
  --inline-style (-s)
    When true, includes styles inline in the component.ts file. Only CSS styles can be included inline. By default, an external styles file is created and referenced in the component.ts file.
  --inline-template (-t)
    When true, includes template inline in the component.ts file. By default, an external template file is created and referenced in the component.ts file.
  --lint-fix
    When true, applies lint fixes after generating the component.
  --module (-m)
    The declaring NgModule.
  --prefix (-p)
    The prefix to apply to the generated component selector.
  --project
    The name of the project.
  --selector
    The HTML selector to use for this component.
  --skip-import
    When true, does not import this component into the owning NgModule.
  --skip-selector
    Specifies if the component should have a selector or not.
  --skip-tests
    When true, does not create "spec.ts" test files for the new component.
  --style
    The file extension or preprocessor to use for style files.
  --type
    Adds a developer-defined type to the filename, in the format "name.type.ts".
  --view-encapsulation (-v)
    The view encapsulation strategy to use in the new component.

To see help for a schematic run:
  ng generate <schematic> --help
```

New output
```
Generates and/or modifies files based on a schematic.
usage: ng generate c <name> [options]

arguments:
  schematic
    The schematic or collection:schematic to generate.
  name
    The name of the component.

options:
  --change-detection (-c)
    The change detection strategy to use in the new component.
  --defaults
    Disable interactive input prompts for options with a default.
  --display-block (-b)
    Specifies if the style will contain `:host { display: block; }`.
  --dry-run (-d)
    Run through and reports activity without writing out results.
  --export
    The declaring NgModule exports this component.
  --flat
    Create the new files at the top level of the current project.
  --force (-f)
    Force overwriting of existing files.
  --help
    Shows a help message for this command in the console.
  --inline-style (-s)
    Include styles inline in the component.ts file. Only CSS styles can be included inline. By default, an external styles file is created and referenced in the component.ts file.
  --inline-template (-t)
    Include template inline in the component.ts file. By default, an external template file is created and referenced in the component.ts file.
  --interactive
    Enable interactive input prompts.
  --lint-fix
    Apply lint fixes after generating the component.
  --module (-m)
    The declaring NgModule.
  --prefix (-p)
    The prefix to apply to the generated component selector.
  --project
    The name of the project.
  --selector
    The HTML selector to use for this component.
  --skip-import
    Do not import this component into the owning NgModule.
  --skip-selector
    Specifies if the component should have a selector or not.
  --skip-tests
    Do not create "spec.ts" test files for the new component.
  --style
    The file extension or preprocessor to use for style files.
  --type
    Adds a developer-defined type to the filename, in the format "name.type.ts".
  --view-encapsulation (-v)
    The view encapsulation strategy to use in the new component.

To see help for a schematic run:
  ng generate <schematic> --help
```
2021-05-03 11:39:23 -04:00
Charles Lyding
37a06a7c37 build: format all files
All files are now formatted using the ng-dev tools via prettier.
2021-04-28 16:05:49 -07:00
Charles Lyding
203f9626df refactor(@angular/cli): correct various uncaught code style issues
This change cleans up some of the code by removing unused variables/imports, unnecessary double negation, and some long line lengths.
2021-04-28 09:58:15 +02:00
Joey Perrott
003854257c build: migrate all file header to use Google LLC rather than Google Inc 2021-04-27 08:35:22 +02:00
Charles Lyding
52aaa8c167 fix(@angular/cli): update NPM 7 guidance
Update NPM 7 behavior based on https://github.com/angular/angular-cli/issues/19957#issuecomment-775407654
2021-02-08 19:48:42 -05:00
profanis
9a6541f882 refactor(@angular/cli): fix super minor typo
while I was making myself familiar with the code-base
to solve an open issue, I saw this super minor typo
and decided to fix it
2021-01-28 19:39:34 +01:00
Charles Lyding
86d69e22fb fix(@angular/cli): redirect Angular schematic dependency requests to known versions
This change adds logic to redirect module resolution requests for Angular schematics to ensure that the correct versions of core schematic related packages are used.  This also ensures that the runtime version of the schematics package matches the version used inside the schematic and that object instances passed into the schematic are compatible.
The current set of core schematic related packages are `@angular-devkit/*` and `@schematics/angular`.  Only first-party Angular schematics are currently affected by this change.
2021-01-28 12:44:34 +01:00
Charles Lyding
1f16d113a9 fix(@angular/cli): avoid using number inquirer prompt in schematic prompts
The number prompt type currently prevents correction of an invalid user entered value after schema validation. An input type is now used instead.  Type coercion based on the schema type(s) already occurs during the filter phase for the inquirer question.
2021-01-14 15:37:41 -05:00
Charles Lyding
aad3bbf0c1 refactor(@angular/cli): use direct schematic workflow option transform option 2020-11-16 13:14:24 -05:00
Charles Lyding
5db4ec7df7 refactor(@angular/cli): remove outdated workspace targets warning
The stable workspace API will now normalize configuration file content.
2020-10-30 10:17:49 -05:00
Charles Lyding
fd63e29406 fix(@angular/cli): coerce prompt answers to requested property types
This change converts answers from prompts into the property type requested from the schema.  This allows properties that expect a number to correctly validate when an input prompt is used.
2020-10-21 16:37:11 +02:00
Alan Agius
2960bf08b2 refactor(@angular/cli): remove redundant context transform 2020-10-13 12:47:06 -04:00
Alan Agius
5318e4c511 fix(@angular/cli): don't display prompts twice
Closes #19027
2020-10-13 12:37:59 -04:00
Alan Agius
49199cee5d fix(@angular/cli): don't show deprecation messages for defaults when using --defaults
With this change we use the addUndefinedDefaults transformer post validation and don't create prompts which have a default value when options.defaults is truthy.

Closes: #18692
2020-10-13 12:36:48 -04:00
Alan Agius
90988aaf52 fix(@angular/cli): collect analytics option usage from workspace config and prompts
With this change we fix two analytics collection bugs:
- We now collect the usage of options defined in the workspace config (angular.json).
- We now also collect values set via schematic prompts.

Closes: #17900
2020-10-07 09:54:59 -04:00
Charles Lyding
d903d39fc8 refactor(@angular/cli): use new NodeWorkflow schematic features
This change reduces the amount of schematic runtime setup code by leveraging the new options for the root path and schema validation in the NodeWorkflow class.
2020-10-02 18:56:11 -04:00
Charles Lyding
b2b536789b refactor(@angular/cli): discover/load workspace on startup
Previously, the workspace configuration file was found and loaded by individual commands potentially multiple times.  This change moves the initial workspace location discovery and loading of the workspace to the CLI startup.  It also provides the workspace to each command so that the commands can reuse the already loaded and parsed workspace configuration.
2020-10-02 07:53:07 -04:00
Alan Agius
e96fbd3c8a refactor(@angular-devkit/build-angular): change errors and warnings messages
Sometimes the WARNING IN/ERROR IN can lead of ambiguous messages

 - Use `Warning` instead of `WARNING IN`
-  Use `Error` instead of `Error In`
2020-09-30 16:17:05 +02:00
Alan Agius
88c3acb945 fix(@angular/cli): favor dirname when resolving @schematics/angular
This ensures that the correct build-in version of `@schematics/angular` is resolved.

Closes #18840
2020-09-24 00:05:58 +03:00
Alan Agius
64cc005f0b refactor: change UPDATE action color to cyan 2020-09-14 16:36:30 -04:00
Alan Agius
951d99e979 feat(@angular/cli): show warning when using deprecated options
With this change we show a warning when a deprecated option is also defined in the workspace configuration file (angular.json).

Closes: #14966
2020-08-17 18:18:24 +02:00
Alan Agius
c824bbb4f7 refactor(@angular/cli): update CLI package to be strict compliant 2020-08-12 19:29:13 +01:00
Alan Agius
05588fcee1 refactor: clean up unused code and imports 2020-07-24 08:01:52 +02:00
Alan Agius
5bb853f1d5 build: update @types/inquirer to 7.3.0 2020-07-23 23:30:22 +02:00
Charles Lyding
f4127b5b43 fix(@angular/cli): fully use add command registry option when installing packages
Fixes: #16766
2020-02-10 16:02:05 -08:00
Charles Lyding
7cce3f0811 fix(@angular/cli): ensure built-in Angular schematics package can be found
The `@angular/cli` package contains a built-in version of the `@schematics/angular` package.  The module resolution paths for the schematics workflow should not assume package hoisting behavior when resolving.  This change corrects that oversight.
2020-01-22 09:00:04 -08:00
Alan Agius
23589ed00e fix(@angular/cli): inform user and error if schematics package is in unreachable location (#16466)
This is a workaround for the schematics runtime to support the requirement of packages containing migrations (or other schematics) to not have a direct/runtime dependency on the schematics package.

Closes: #16392
2020-01-02 11:27:04 -08:00
Alan Agius
35ca3901ac refactor: strip leading slash to prevent confusion 2019-12-02 10:10:34 -08:00
Charles Lyding
5df776780d fix(@angular-devkit/schematics): use NodeWorkflow root to resolve collections 2019-10-28 17:48:08 -07:00
Keen Yee Liau
7e1e8adf7a feat(@angular/cli): allow subclass to override default collection name
This PR provides a way for subclass that extends `SchematicCommand` to
provide a different default collection name.
This is needed in g3 where the collection name is different from
external.
2019-10-03 14:42:20 -07:00
Alan Agius
26dd51221a style: collapse if statements (#15449) 2019-08-27 10:25:14 -07:00
Charles Lyding
b630317b4b refactor(@angular/cli): convert workspace access to async
This is in preparation for conversion from the experimental workspace API to the stable workspace API.
2019-08-16 09:32:04 -07:00
Minko Gechev
d274add7b4
fix(@angular/cli): use correct schematic defaults considering workspace (#15041)
Fix #14986

This PR includes some refactoring to simplify the interaction
of the `NodeWorkflow` and the `BaseWorkflow` with the registry.

We were registering redundant `addPostTransform`s. Some of them in
the constructor of the `BaseWorkflow`, which did not allow us to
intercept `addUndefinedDefaults`.

Additionally, we were setting the `validateOptionsWithSchema` transform
multiple times unnecessarily.

An issue left to fix is support for the `--project` option in
schematic commands. Currently, `getProjectName` does not know about
this option, since `createWorkflow` does not know how to parse the
command line arguments. The parsing logic is implemented partially
by the concrete implementation of the `SchematicCommand` template
method.
2019-07-16 09:58:01 -07:00
Charles Lyding
5b5f140109 refactor(@angular/cli): use stable workspace API 2019-07-10 04:05:26 +08:00
Charles Lyding
c4313f55e4 refactor(@angular/cli): unify color handling and support 2019-06-24 17:27:59 -07:00
Alan Agius
db344641f4 fix(@angular/cli): ng generate --help shows the wrong collection
At the moment, collectionName and schematicCollections are not set in various schematics command which result in fallbacking to the hardcoded default collectionName https://github.com/angular/angular-cli/blob/master/packages/angular/cli/models/schematic-command.ts#L79

Hence, this will result in incorrect information being present when using the `--help`, `--list`.

Fixes #14519
2019-05-28 20:57:21 +02:00
Charles Lyding
57189f6eca fix(@angular/cli): standardize TTY checks 2019-05-22 10:02:58 +02:00
Charles Lyding
290898536b fix(@angular/cli): prevent nested schematic execution from generating analytics
Fixes #14190
2019-05-15 14:11:48 -07:00
Filipe Silva
b6b00ebc98 build: update typescript to version 3.4.3 2019-04-13 10:23:02 -07:00
Hans Larsen
2e58fb33ca feat(@angular/cli): add custom implementation for analytics for commands
Some commands (like schematics) need to have custom reporting for
analytics. Schematics and Architect commands need to verify if the
schematic/architect builder run is in the safelist, for example.
2019-03-20 15:08:07 -07:00
Hans Larsen
1cbd915c26 feat(@angular/cli): add support for analytics command proper
To add/remove/prompt about the analytics configuration.
2019-03-20 15:08:07 -07:00
Alan Agius
71c6cc506e refactor: add allowAdditionalArgs to be able to bypass extra params validations (#13556) 2019-02-05 21:13:45 -08:00
Alan Agius
f8e873b645 fix(@angular/cli): schematics commands should fail on unknown options
When an addition argument is parsed the schematic commands should fail with an error.

Fixes #12549
2019-01-30 11:41:42 -08:00
Michael O'Keefe
db0fc7759b feat(@angular/cli): Added support for multiselect list prompt (#13031)
* feat(@angular/cli): Added support for multiselect list prompt

* If multiselect option is true use the checkbox
   inquirer prompt type, otherwise use list.

* feat(@angular-devkit/core): Added support for multiselect list prompt

* Added multiselect to PromptDefinition interface and usages
2018-11-30 12:01:57 -08:00
clydin
43aabb4be6 fix(@schematics/update): improve npmrc discovery (#12871)
* fix(@schematics/update): improve npmrc discovery

* feat(@angular/cli): support yarnrc options during update when using yarn
2018-11-14 10:30:00 -08:00
Hans Larsen
456614828f feat(@angular/cli): allow flags to have deprecation
The feature comes from the "x-deprecated" field in schemas (any schema that is used
to parse arguments), and can be a boolean or a string.

The parser now takes a logger and will warn users when encountering a deprecated
option. These options will also appear in JSON help.
2018-11-14 10:29:07 -08:00
clydin
5e354d17f1 feat(@angular/cli): autodetect default package manager (#12753) 2018-11-06 22:00:40 -08:00
Charles Lyding
5af69ba43b refactor(@angular/cli): remove rxjs direct dependency 2018-10-31 14:53:56 -07:00