67 Commits

Author SHA1 Message Date
Charles Lyding
bb43e0a7c4 test(@schematics/angular): update several tests to use async expectations
Using Jasmine's `expectAsync` allows for reduced test code when testing that
a function returning a promise rejects with a specific error.
2022-06-14 11:28:21 +02:00
Alan Agius
e751464ea3 fix(@angular/cli): populate path with working directory in nested schematics
With this change we change the how we handle `"format": "path"` schematic property option. We replace the formatter in favour of a `SmartDefaultProvider`, which ensures that nested schematics can access the `workingDirectory`.
2022-05-24 10:19:30 -07:00
Elton Coelho
d899091d5d fix(@schematics/angular): alphabetically order imports during component generation
change the order of imports during component generation using changeDetectionStrategy set to OnPush

closes angular#23156
2022-05-18 12:58:10 -04:00
Cédric Exbrayat
b16e6f13a7 fix(@schematics/angular): remove extra space in standalone imports 2022-05-06 11:05:29 -07:00
Pawel Kozlowski
df9fc8f5ab refactor(@schematics/angular): include CommonModule for standalone components
This commit adds the CommonModule imports to the standalone components
generated by the Angular's ng add component schematic.
2022-05-03 12:18:54 -07:00
Kristiyan Kostadinov
7b78b7840e feat(@schematics/angular): add --standalone to ng generate
Adds the `--standalone` flag when generating components, directives or pipes through `ng generate`.
2022-04-27 15:33:48 -04:00
Charles Lyding
a0e3de2b5f refactor(@schematics/angular): use Tree's newly introduced readText and readJSON functionality
Code related to decoding buffers into strings and parsing content into JSON can now be removed by using the
support provided directly from the Tree instance for the executing schematic.
2022-04-26 19:24:55 -04:00
Charles Lyding
291bbffcc9 refactor(@schematics/angular): use string helper re-export from @angular-devkit/schematics
By using the `strings` re-export from `@angular-devkit/schematics` instead of from `@angular-devkit/core`,
the number of imports from `@angular-devkit/core` has been reduced and lowers the direct dependency count
for many of the individual schematics.
2022-04-22 11:31:53 -04:00
gauravsoni119
a5e99762ef fix(@schematics/angular): fix extra comma added when use --change-detection=onPush and --style=none to generate a component 2022-03-30 16:59:17 +02:00
Adrien Crivelli
09a71bab60 fix(@schematics/angular): Consolidated setup with a single beforeEach()
Since f463c8403547 we use native `async`/`await` and thus we do not need
to split setup in two `beforeEach()`
2022-03-21 12:27:09 -07:00
Alan Agius
21809e14cd feat(@schematics/angular): loosen project name validation
With this change we update the validation of the libraries and application projects names to fully allow characters that make a valid NPM package name. http://json.schemastore.org/package has been used as reference.

We also remove validators that are no longer needed.

Closes #11051
2021-11-16 10:51:10 +00:00
Alan Agius
5986befcdc feat(@schematics/angular): remove deprecated options
With this change we removed several deprecated `@schematics/angular` deprecated options.

BREAKING CHANGE:

We removed several deprecated `@schematics/angular` deprecated options.
- `lintFix` have been removed from all schematics. `ng lint --fix` should be used instead.
- `legacyBrowsers` have been removed from the `application` schematics since IE 11 is no longer supported.
- `configuration` has been removed from the `web-worker` as it was unused.
- `target` has been removed from the `service-worker` as it was unused.
2021-07-30 14:26:53 +01:00
David Scourfield
8ad1539c5e feat(@schematics/angular): add 'none' value for the 'style' option of the component schematic
Allow setting `--style=none` for the component schematic to prevent generation of any style file.  Previously this was possible only with `--inlineStyle=true`, which had the side-effect of adding an inline style block to the component decorator.  Useful for components or projects which have entirely externalised stylesheets and never want to use component-specific styles.
2021-06-21 11:10:23 +01:00
hien-pham
9cd8be69d6 test(@schematics/angular): add missing unit test for skipTests flag of component, class, directive, and pipe 2021-06-18 11:18:46 +01:00
Alan Agius
7cd801eb06 fix(@schematics/angular): show better error when non existing project is passed to the component schematic
Closes: #21003
2021-06-02 09:15:17 +02:00
Charles Lyding
c1512e4274 build: update files to be eslint compliant
All TypeScript files have been updated to pass the new eslint-based linting checks. eslint compatible disabling comments have also been added in place of the previous tslint comments.
2021-05-03 07:31:02 -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
Joey Perrott
003854257c build: migrate all file header to use Google LLC rather than Google Inc 2021-04-27 08:35:22 +02:00
Alan Agius
0272fc55b6 refactor(@schematics/angular): remove stylus from style options
BREAKING CHANGE:

`styl` (Stylus) is no longer a supported value as `style` in `application`, `component`, `ng-new` schematics. Stylus is not actively maintained and only 0.3% of the Angular CLI users use it.
2021-04-21 12:39:18 -07:00
Keen Yee Liau
5a57fea36b docs(@schematics/angular): add README and update description in schema
Create README for the package, and add missing description in some schema.
2021-04-19 20:34:35 +02:00
Alan Agius
076ab0f11f refactor: add correct schema keys
With this change
- We replace `id` with `$id`,  this no longer valid in draft-07.
- Replace all `$schemas` to `http://json-schema.org/draft-07/schema`, this is needed to "pin" the schema to `draft-07`.

More information about `draft-07` can be found https://json-schema.org/draft-07/json-schema-release-notes.html
2021-04-13 10:51:12 -04:00
Alan Agius
8582ddc35e feat(@schematics/angular): remove entryComponent from component schematic
BREAKING CHANGE:

`entryComponent` option has been removed from the `component` schematic as this was intended to be used with the the now no longer supported ViewEngine rendering engine.
2021-03-31 10:04:05 -06:00
George Kalpakas
fb14945c02 fix(@schematics/angular): correctly handle adding multi-line strings to @NgModule metadata
Previously, `addSymbolToNgModuleMetadata()` assumed that the added
symbol would not span multiple lines. In most cases, the added symbol is
a single word, so this assumption was correct. In some cases, however,
we might want to add a mutli-line string, such as a static method of an
`@NgModule`:

```ts
  imports: [
    SomeModule.staticMethod({
      prop1: 'val1',
      prop2: 'val2'
    })
  ]
```

This commit allows `addSymbolToNgModuleMetadata()` to correctly handle
multi-line strings by ensuring that added metadata symbols are always
put on a new line (even if the array is empty) and each line in the
string is indented as necessary.
2021-03-30 14:33:19 -06:00
Mouad Ennaciri
ee4918db40 fix(@schematics/angular): remove Native value from viewEncapsulation option 2021-03-16 08:57:42 +01:00
Alan Agius
ba6f546a02 fix(@schematics/angular): add additionalProperties to all schemas 2021-03-10 08:17:50 -06:00
Alan Agius
385aeda2e7 refactor(@schematics/angular): use includes instead of RegExp 2021-01-14 10:44:27 -05:00
Alan Agius
c99cef7ed6 docs: remove when true, when false from argument descriptions
It's confusing and redundant to use `When true` and `when false` in descriptions for a CLI arguments because specifying false/true is redundant in a command line argument flag and in most cases users will not do it.

Example:
`--foo=true` is the same as `--foo`
`--foo=false` is the same as `--no-foo`
2020-12-08 14:39:23 -05:00
Alan Agius
affaabe6d3 fix(@schematics/angular): remove lint fix default value
Since will remove lintFix usage warnings when the option is set by a default of another schematic.

Example when executing
```
ng generate module customers --route customers --module app.module
```

The lintFix default of the module schematic will be passed down to the component schematic which would cause a warning to be shown.

Closes #19169
2020-10-22 15:48:30 +02:00
Alan Agius
57b63b3a93 refactor(@schematics/angular): deprecate lintFix option
As part of tslint deprecation we are also deprecated the lintFIx option. Users should use `ng lint --fix` directly instead
2020-10-07 11:12:58 -04:00
Alan Agius
05588fcee1 refactor: clean up unused code and imports 2020-07-24 08:01:52 +02:00
Charles Lyding
f463c84035 fix(@schematics/angular): remove async test helper function from component schematic 2020-07-15 12:36:48 -04:00
Chau Tran
f089bb144c fix(@schematics/angular): fix extra comma if inlineStyle is on
When generating a new component, if `inlineStyle` and either
`viewEncapsulation` or `changeDetection` flag is provided, there is an
extra comma after `styles: [],,` causing the component to bugged out.
2020-03-30 10:22:37 -07:00
Sachin Grover
1c1f1cde65 fix(@schematics/angular): Allow empty string in the type option
Currently, Component and Class have the options to add custom type. In the case of class, It's already working fine with  an empty string in type but in the case  of component When setting the type to an empty string the file names generated will contain an extra period (.) which breaks the flow.

With this PR, It will generate the files without an extra period (.)

Reference #16811 and #16891
2020-02-26 12:02:20 -08:00
Alan Agius
8465538f9d test(@schematics/angular): fix component schematic tests on Windows 2020-02-18 10:52:11 -08:00
Reto Ryter
d6fa2bde93 feat(@schematics/angular): add opt in option 'displayBlock' 2020-02-05 10:30:15 -08:00
Cyrille Tuzi
76d2656fe5 fix(@schematics/angular): add compliance with call-signature lint rule 2020-01-27 11:28:59 -08:00
Alan Agius
aad8fa1fab refactor(@schematics/angular): deprecate component entryComponents
Since version 9.0.0 with Ivy, entryComponents is no longer necessary
2019-11-05 16:36:16 -08:00
Alan Agius
e92c46a3cf refactor(@schematics/angular): remove deprecated spec and styleext options
BREAKING CHANGE:

Deprecated `styleext` and `spec` options have been removed.  Use `style` and `skipTests` options instead.
2019-10-22 13:27:08 -07:00
Leon Radley
c0d42e0c0e feat(@schematics/angular): add type option to component generator (#15754)
the type option allows you to change the default .component.ts suffix to new types.
such as

Route
Dialog
UI
Container
2019-10-09 11:09:12 -07:00
Charles Lyding
5a7b823b28 test: remove use of deprecated synchronous test helper runSchematic 2019-08-08 08:27:31 -07:00
Alan Agius
15ef15e94a style: remove redundant max-line-length disables and fix other lint issues 2019-07-24 19:06:21 -07:00
Alan
2c1b78f35d style: remove redundant console.log 2019-06-25 13:30:28 -07:00
mgechev
302cace038 feat(@schematics/angular): add skipSelector property to the component generator
Fix #14749
2019-06-20 10:57:33 -07:00
SamanthaAdrichem
8352f1e10f fix(@schematics/angular): remove indentation in component html
Most editors remember the indentation, even if you remove all code. This way, there is no
indentation thus there is nothing for the editor to remember and there will be no need for
a HTML lint fix.

Fixes #14816
2019-06-18 18:26:35 -07:00
Charles Lyding
e52f62f840 refactor(@schematics/angular): update component to use new workspace rules 2019-04-16 11:23:48 -07:00
Hans Larsen
ecd25a7131 refactor(@angular/cli): remove dimension 20
We need it for errors in build.
2019-03-28 13:28:41 -07:00
Hans Larsen
2e9dc3d252 docs: add analytics dimensions for schematics flags and internal doc
The analytics.md should be kept up to date with the flags.
2019-03-20 15:08:07 -07:00
Alex Eagle
bf1c069f73 refactor(@schematics/angular): drop dependency on TypeScript package
instead, vendor in the two files we actually need.
This reduces our install footprint by 5MB
2019-03-06 11:27:48 -08:00
Alan
1fcb9a09f9 test: remove now duplicate test 2019-03-04 10:26:09 -08:00
Alan
08c4cb748f fix(@schematics/angular): reintroduce .sass as a supported file extention
Sass Indented (.sass) is fully supported by the Sass team and we should still offer and support it.

Fixes #13739
2019-03-04 10:26:09 -08:00