95 Commits

Author SHA1 Message Date
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
695a01ba02 feat(@schematics/angular): configure new libraries to be published in Ivy partial mode
With this change we configure new libraries to be published using Ivy partial compilation instead of the deprecated View Engine rendering engine, we also remove several view engine specific `angularCompilerOptions`.

New libraries can be published using this format, as they are not depend upon by View Engine libraries or application.
2021-04-09 18:40:39 -04: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
Alan Agius
226a8d274d feat(@schematics/angular): remove tslint and codelyzer from new projects
Both of these projects and the tslint builder are deprecated.

Closes #20105 and closes #18465
2021-03-16 15:49:46 +01:00
Alan Agius
ba6f546a02 fix(@schematics/angular): add additionalProperties to all schemas 2021-03-10 08:17:50 -06:00
Alan Agius
1de6d71edd feat(@schematics/angular): production builds by default
With this change we do several changes to the `angular.json` configuration for `build` , `server` and `app-shell` targets so that these are `production` by default.

- build, server and app-shell targets are configured to run production by default.
- We add a new configuration named `development` to run the mentioned builder targets in development. Ex: `ng build --configuration development`.
- When adding `universal` or `app-shell`, we generate the full set of configurations as per the `buiid` target. Previously, we only generated the `production` configuration.
- We added a helper script in `package.json` to run build in watch mode. `npm run watch` which is a shortcut for `ng build --watch --configuration development`
2021-03-10 08:16:38 -06:00
Alan Agius
bb38f85202 feat(@schematics/angular): use new zone.js entry-points 2021-02-17 12:44:43 -06: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
cexbrayat
5a0940e62d fix(@schematics/angular): document jasmine options
Currently it can be hard to find how to configure Jasmine in the Karma config.
For example, a developer might want to reproduce a randomly failing test with a specific seed.

This commit adds some information that may be helpful to beginners.
2020-11-20 11:37:19 +00:00
cexbrayat
53193eaf77 fix(@schematics/angular): remove duplicated Karma traces
Currently, Karma is reporting a failed test and the total twice in a bare CLI project:

```
12 11 2020 13:59:46.666:INFO [launcher]: Starting browser Chrome
✔ Browser application bundle generation complete.
12 11 2020 13:59:50.457:INFO [Chrome 86.0.4240.198 (Mac OS 10.15.7)]: Connected on socket F0ehOBWL6BYFqXfbAAAA with id 69358036
Chrome 86.0.4240.198 (Mac OS 10.15.7) AppComponent should render title FAILED
	Error: Expected 'ponyracer app is running!' to contain 'other'.
	    at <Jasmine>
	    at UserContext.<anonymous> (src/app/app.component.spec.ts:29:65)
	    at ZoneDelegate.invoke (node_modules/zone.js/dist/zone-evergreen.js:364:1)
	    at ProxyZoneSpec.push.QpwO.ProxyZoneSpec.onInvoke (node_modules/zone.js/dist/zone-testing.js:292:1)
Chrome 86.0.4240.198 (Mac OS 10.15.7): Executed 2 of 3 (1 FAILED) (0 secs / 0.231 secs)
Chrome 86.0.4240.198 (Mac OS 10.15.7) AppComponent should render title FAILED
	Error: Expected 'ponyracer app is running!' to contain 'other'.
	    at <Jasmine>
	    at UserContext.<anonymous> (src/app/app.component.spec.ts:29:65)
	    at ZoneDelegate.invoke (node_modules/zone.js/dist/zone-evergreen.js:364:1)
Chrome 86.0.4240.198 (Mac OS 10.15.7): Executed 3 of 3 (1 FAILED) (0.309 secs / 0.242 secs)
TOTAL: 1 FAILED, 2 SUCCESS
TOTAL: 1 FAILED, 2 SUCCESS
```

This is a bit annoying when you have several tests failing, and tend to confuse beginners.

This commit configures the Karma HTML reporter to suppress the duplicates (both error and success), which results in only one reporter showing the failed test and total:

```
12 11 2020 14:01:43.002:INFO [launcher]: Starting browser Chrome
✔ Browser application bundle generation complete.
12 11 2020 14:01:58.728:INFO [Chrome 86.0.4240.198 (Mac OS 10.15.7)]: Connected on socket Pc0xPggxJPdC8E_LAAAA with id 54797430
Chrome 86.0.4240.198 (Mac OS 10.15.7) AppComponent should render title FAILED
	Error: Expected 'ponyracer app is running!' to contain 'other'.
	    at <Jasmine>
	    at UserContext.<anonymous> (src/app/app.component.spec.ts:29:65)
	    at ZoneDelegate.invoke (node_modules/zone.js/dist/zone-evergreen.js:364:1)
	    at ProxyZoneSpec.push.QpwO.ProxyZoneSpec.onInvoke (node_modules/zone.js/dist/zone-testing.js:292:1)
Chrome 86.0.4240.198 (Mac OS 10.15.7): Executed 3 of 3 (1 FAILED) (0.331 secs / 0.252 secs)
TOTAL: 1 FAILED, 2 SUCCESS
```
2020-11-13 15:53:01 -05:00
cexbrayat
8e8a51c3fa fix(@schematics/angular): remove trailing comma in karma conf
We usually don't have trailing commas in the generated code of the CLI (and this one makes the linter/formatter angry).
2020-11-12 13:16:40 -05:00
Alan Agius
0bc15970ad refactor(@schematics/angular): use jsonc-parser instead of devkit parser 2020-11-05 08:31:02 +01: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
9768230b4d docs: update further help section in readme 2020-10-21 14:15:24 +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
cexbrayat
8303681123 style(@schematics/angular): fix formatting of coverage reporters 2020-09-14 12:34:33 -04:00
Alan Agius
0d7bbd82f6 refactor(@schematics/angular): remove lcov from coverage reporters
In many users will not use lcov reports, also  this reporter generates an HTML report, which we are already generating using the html reporter.\
2020-09-11 15:17:23 -04:00
Keen Yee Liau
8995e49f0b feat(@angular-devkit/build-angular): Switch to karma-coverage
This commit switches coverage tooling from karma-coverage-istanbul-reporter
to karma-coverage since it's better supported.

Closes #17757
2020-09-06 12:22:25 +02:00
Alan Agius
da9825ceb2 refactor(@schematics/angular): use ng-packagr builder from build-angular 2020-08-14 15:38:12 +02:00
Alan Agius
8b96e52d83 fix(@schematics/angular): remove solution style tsconfig from new projects
Following the issues highlighted in https://docs.google.com/document/d/1eB6cGCG_2ircfS5GzpDC9dBgikeYYcMxghVH5sDESHw/edit?usp=sharing and discussions held with the TypeScript team. The best course of action is to rollback this feature.

In future, it is not excluded that solution style tsconfigs are re-introduced..

Closes #18040 and closes #18170
2020-08-12 19:26:12 +01:00
Alan Agius
76f525cec2 fix(@schematics/angular): add links to generated tsconfig files
We now add a link to generated tsconfig.json to make is easier for users to find relevant information.
2020-06-15 08:48:14 +02:00
Alan Agius
17dbaeb1fa feat(@schematics/angular): emit declaration maps for local library builds
With this change we enable emitting declaration maps when building libraries to be consumed locally as this improved DX as this will allow editors to go to the original typescript file when using `Go to Definition`.

For production builds, declaration maps are disabled because they are not useful since the source files are not included in the distributable package.

Closes #17888
2020-06-12 19:39:58 +02:00
Alan Agius
ade3f491fe fix(@schematics/angular): remove node typings from tsconfig.spec.json 2020-05-27 14:17:05 +02:00
Alan Agius
bede23226a feat(@schematics/angular): add solutions style tsconfig structure
In version 3.9, TypeScript introduced the concept of "Solutions Style" tsconfig to improve developer experience.

More info: https://devblogs.microsoft.com/typescript/announcing-typescript-3-9-rc/#solution-style-tsconfig

Closes #17493 and closes #8138
2020-05-20 12:12:33 -07:00
Alan Agius
a042290726 fix(@schematics/angular): update to tslib 2.0.0
TypeScript 3.9 requires tslib 2.0.0, with this change we;
- Update tslib existing and new workspaces to use tslib 2.0.0
- Update new and existing libraries to use tslib 2.0.0 as a direct depedency.

Tslib version is bound to the TypeScript version used to compile the library. Thus, we shouldn't list `tslib` as a `peerDependencies`. This is because, a user can install libraries which have been compiled with older versions of TypeScript and thus require multiple `tslib` versions to be installed.

Closes: #17753

Reference: TOOL-1374
2020-05-20 11:25:31 +01:00
Cyrille Tuzi
ee589d9116 fix(@schematics/angular): add compliance with no-any lint rule 2020-01-29 10:19:36 -08:00
Daniele Morosinotto
3aacf41057 fix(@schematics/angular): regression tsconfig.json #16708 (#16709)
* fix(@schematics/angular): regression tsconfig.json

fix(@schematics/angular): regression tsconfig.json  …
Unverified
0e318ae
Regression in tsconfig.json set `"outDir": "./dist/out-tsc"` for problems in VSCode TS(2307) when building library referred in tsconfig "paths" 
 
Closes: #16708

* fix(@schematics/angular): regression tsconfig.json

Improve paths in root tsconfig.json for better DX experience when using auto imports in IDE's.

Closes #16709

* fix(@schematics/angular): regression tsconfig.json

Improve paths in root tsconfig.json for better DX experience when using auto imports in IDE's.
Fix code lint.

Closes #16709

* fix(@schematics/angular): regression tsconfig.json

Improve paths in root tsconfig.json for better DX experience when using auto imports in IDE's.
Fix test code to conform new behaviour.

Closes #16709
2020-01-23 17:58:38 -08:00
Alan Agius
be1bcbaead fix(@schematics/angular): improve paths and exclude options
Currently the library schematic doesn't support adding a secondary entry-point and having deep imports is not recommanded.

It's best if paths are more stricter when having a secondary entry-point instead of a wildcard.

Instead of :
```
"lib/*": [
  "dist/lib/*"
]
```

Users should configure:
```
"lib/secondary": [
  "dist/lib/secondary"
]
```

This would allow a better DX experience when using auto imports in IDE's.

Closes: #15952
2019-12-03 12:37:07 -08:00
Alan Agius
a384a983fa feat(@schematics/angular): add tslib as a peerDependencies in library package.json
This is to align with https://github.com/angular/angular/pull/32167
2019-10-22 13:26:38 -07:00
Alan Agius
745670fa6a feat(@schematics/angular): remove dependency on tsickle (#15603)
With this change we remove the requirement  to add tsickle as a dependency when having a workspace library.

Since the CTOR downlevel transformer which was previously provided via tsickle  is now in ng-packagr version 5.5.1+ We migrate existing libraries to remove the need for tsickle.
2019-09-18 14:50:29 +01:00
Alan
beb7070ac8 feat(@schematics/angular): introduce Ivy libraries for development
Since `NGCC` is non incremental and in library projects we have the original TS sources
we don't need to build a library using the `VE` and transform it using `NGCC`. Instead we can build the library using `NGTSC` (Ivy) directly
 as this enables faster incremental compilations and a better development experience.

 Libraries now have a `production` configuration, which enabled `VE` compilations. As it is not recommended to publish NGTSC (Ivy)
 built libraries to NPM repositories, since Ivy libraries are not backwards compatible with the legacy View Engine.
2019-08-16 09:31:02 -07:00
Charles Lyding
5a7b823b28 test: remove use of deprecated synchronous test helper runSchematic 2019-08-08 08:27:31 -07:00
Alan Agius
d7b9650b5f refactor(@schematics/angular): remove hardcoded default values
Defaults in code are no longer required as the root issue was solved by https://github.com/angular/angular-cli/pull/15222
2019-08-08 08:25:50 -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
Wataru.Kasahara
4cbf59beb2 fix(@schematics/angular): add text-summary to code coverage reporter 2019-07-10 04:16:27 +08:00
hawkgs
fdcd1f7546 feat(@schematics/angular): lazy routing module generator
Introduces the lazy routing module generator as part of the existing
module generator.

Feature document:
https://docs.google.com/document/d/1NAJEWTG54cu4kW7XBp0gVadmz-gqJouW2XDs4c9PPJM/edit#heading=h.xgjl2srtytjt
2019-06-26 11:15:58 -07:00
Alan
89a122cd5c fix(@schematics/angular): update ng-packagr and tsickle when migrating to version 8 2019-06-06 14:16:51 -07:00
Charles Lyding
635de55982 fix(@schematics/angular): enable tsickle for library compilation
This is required to support forward references in ES2015 target code.  tsickle provides the constructor parameter downlevel logic that removes the runtime TDZ error that would otherwise be encountered.
2019-05-23 19:12:40 +02:00
Charles Lyding
6b28d3ac51 fix(@schematics/angular): remove emitDecoratorMetadata TS option for new applications 2019-05-23 19:12:40 +02:00
hawkgs
d1332607d6 fix(@schematics/angular): project name option in the library schematic 2019-05-07 16:15:34 -06:00
Alan Agius
a464c001c3 fix(@schematics/angular): fix paths when newProjectRoot is an empty string
When `newProjectRoot` the paths are prefixed with an `/` example `/project-name/tsconfig.lib.json` which results in these being marked as absolute paths, which causes build failures.

Fixes #14108
2019-04-22 16:17:39 -07:00
Alan
f03ff807b4 refactor(@schematics/angular): create relativePathToWorkspaceRoot helper and replace usages 2019-04-19 10:55:02 -07:00
Charles Lyding
ca1ecb027d test(@schematics/angular): ensure application schematic is run async 2019-04-16 11:23:48 -07:00
Alan Agius
58fb593787 feat(@schematics/angular): update several workspace dependencies
With this change we update ng-packagr, jasmine-core and tslint.
2019-04-15 11:09:13 -07:00
Charles Lyding
cbce3d3793 refactor(@schematics/angular): update library to use new workspace rules 2019-04-15 11:02:46 -07:00
Charles Lyding
a0a583adaa fix(@schematics/angular): remove unused core-js dependency from new projects
Required polyfills are now managed directly by the build system.  If additional polyfills are required, packages can be manually added as needed.
2019-04-04 09:28:02 -07:00
Hans Larsen
2ffbdfa86a build: add a validation script for the analytics.md tables
Also added enums to update when changing dimensions.
2019-03-28 13:28:41 -07:00
Hans Larsen
55471770db refactor: use dimensions for some values instead of metrics
This is after a discussion with someone internal. Metrics are good
for sums but not for comparisons and search/filtering.
2019-03-28 13:28:41 -07:00
Alan Agius
e516a817ac feat(@schematics/angular): update to ng-packagr version 5
This changes remove the need for tsickle.
2019-03-27 12:11:38 -07:00