78 Commits

Author SHA1 Message Date
Cédric Exbrayat
84e3f7727d fix(@schematics/angular): remove empty lines
The recet removal of enableProdMode in 283b564d1de985f0af8c2fcb6192801a90baacda introduced unnecessary empty lines in main.ts
2022-09-29 18:58:01 +02:00
Alan Agius
b6897dbb0a feat(@schematics/angular): remove karma.conf.js from newly generated projects
`@angular-devkit/build-angular` now has a built in Karma config. Users can still create their own Karma configuration if they want to override the default configuration.
2022-09-28 17:37:53 +02:00
Alan Agius
283b564d1d feat(@schematics/angular): remove environment files in new applications
This commit removes the usage of environment files and `fileReplacements` in new application projects. Previously, the environment files was used to distinguish between a prod build to invoke `enableProdMode`. The `enableProdMode` however needed only for the case of JIT mode in production mode, which is a rare case as JIT mode is recommanded to be used in production.

In the CLI, calling `enableProdMode` is not needed as `ngDevMode` it's set using the minifier.
2022-09-27 19:48:34 +02:00
Alan Agius
56a1e8f9f5 feat(@schematics/angular): remove test.ts file from new projects
The test.ts is now included in `@angular-devkit/build-angular` and unless this needs to be customized is no longer needed to be provided.

Default config:
```js
// This file is required by karma.conf.js and loads recursively all the .spec and framework files
import { getTestBed } from '@angular/core/testing';
import {
  BrowserDynamicTestingModule,
  platformBrowserDynamicTesting
} from '@angular/platform-browser-dynamic/testing';

// First, initialize the Angular testing environment.
getTestBed().initTestEnvironment(BrowserDynamicTestingModule, platformBrowserDynamicTesting(), {
  errorOnUnknownElements: true,
  errorOnUnknownProperties: true
});
```
2022-09-27 18:59:08 +02:00
Alan Agius
597bfea1b2 feat(@schematics/angular): drop polyfills.ts file from new templates
With this change we drop the `polyfills.ts` from new application projects and add the polyfills directly in the `angular.json`. This is possible as now the `polyfills` option accept an array of module specifiers.

This change also fixes another open issue (#14432) which was caused by the missing polyfills file in the library test setup.

Closes #14432
2022-09-26 18:27:35 +02:00
Alan Agius
dbcea96274 refactor(@angular-devkit/build-angular): simplify how specs are found and loaded
Prior to this change specs where found and loaded using Webpack's `require.context` API. The `require.context` is found in the users project `test.ts`. This resulted in a complex and hacky setup especially to filter tests when the `include` builder option is provided, were we had to amend the `test.ts` in memory.

With this change we find all the specs files and add them as part of the main entrypoint.

Closes #23751 and closes #22531
2022-09-23 18:52:26 -04:00
Cédric Exbrayat
1c21e470c7 feat(@schematics/angular): enable error on unknown properties and elements in tests
These new options have been introduced in Angular v14.
The commit enables the option in a new project, as we did when we introduced the `destroyAfterOption`,
with the same long term goal to have these options enabled by default.
2022-09-16 11:37:56 -07:00
Alan Agius
9beb878e2e feat(@schematics/angular): remove Browserslist configuration files from projects
The Browserslist configuration file is redundant as we set the defaults directly in @angular-devkit/build-angular. 8da926966e/packages/angular_devkit/build_angular/src/utils/supported-browsers.ts (L12-L19)

With this commit, we remove the `.browserlistrc` configuration file from the schematics application template and through a migration in existing projects when the Browserslist query result matches the default.

Users needing a finer grain support should still create a `.browserlistrc` in the root directory of the project.
2022-09-14 10:43:41 -07:00
alkavats1
d52697047a refactor: refactored the code and removed the code smells
refactored the code and removed the code smells
2022-05-06 11:11:13 -07:00
Alan Agius
37a7239458 fix(@schematics/angular): address eslint linting failures in test.ts
Closes #22171
2021-11-18 20:26:39 +01: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
585adacd06 fix(@schematics/angular): don't add destroyAfterEach in newly generated spec files
This is now enabled by default.

See https://github.com/angular/angular/pull/43353 for more context.
2021-10-06 14:33:42 -05:00
Doug Parker
ba9c60360f refactor(@schematics/angular): drop IE-only polyfills and drop versions from comment.
This removes polyfills only required on Internet Explorer since it is no longer supported (`web-animations-js`). Also updates the doc comment to leave specific versions unspecified, since they are already out of date and updating them now would just cause them to go out of date again in the future. Instead, users can visit the browser support guide to understand find the most up to date browser versions supported.
2021-10-01 14:07:58 -05: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
Alan Agius
9fbd16655e feat(@schematics/angular): remove IE 11 specific polyfills 2021-07-30 12:56:30 +01:00
Alan Agius
20fd33f6d4 feat(@schematics/angular): destroy test module after every test
In version 12.1, the framework added the `destroyAfterEach` an opt-in feature that improves tests performance and also addresses two long-standing issues.

The idea, is to have this enabled by default in the future.  Related PR: https://github.com/angular/angular/pull/42566

Closes #21280
2021-07-07 10:31:20 -04: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
cexbrayat
663c4bc9c1 fix(@schematics/angular): remove references to the prod flag
As the `--prod` is now deprecated, and `ng build` uses by default the `production` configuration,
then we should remove the references to `ng build --prod` in the generated project.
2021-03-11 11:36:25 +01:00
Alan Agius
bb38f85202 feat(@schematics/angular): use new zone.js entry-points 2021-02-17 12:44:43 -06:00
Oleksii Potiekhin
f73a878c67 fix(@schematics/angular): adjust block comment
https://github.com/Microsoft/tslint-microsoft-contrib

ERROR: 21:1 no-single-line-block-comment Replace block comment with a single-line comment
2020-12-15 12:24:53 +00: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
5617131e7f fix(@schematics/angular) remove reference to IE10 in comment
IE 10 is no longer supported therefore we removed it from the classlist polyfill comment.
2020-10-02 15:43:26 -04:00
Charles Lyding
e64ea69cf4 fix(@schematics/angular): remove IE9/10 from browserslist for new projects
BREAKING CHANGE:
Deprecated support for IE 9-10 has been removed in Angular 11.
Only IE 9-10 support has been removed. IE 11 is officially supported in Angular 11.
Additional information can be found here: https://v10.angular.io/guide/deprecations#ie-9-10-and-mobile
2020-09-25 22:46:04 +02: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
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
Simon Kurtz
68c7a96f10 refactor(@schematics/angular): pluralize Safari entry in .browserslistrc 2020-07-03 22:29:14 +02:00
Alan Agius
bb2c109e7e fix(@schematics/angular): split browserslist IE entries and provide better comments
Closes #18032
2020-06-30 15:37:05 +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
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
a723af4271 feat(@schematics/angular): evergreen new applications
By default, we now generate new applications which support only evergreen browsers, as a result differential loading is now opt-in.

A new flag `--legacy-browsers`, was added to generate applications which support non evergreen browsers such as Internet Explorer 11.

**Note**: After an application is generated opting in and out of differential loading is still possible through the supported browsers configuration in the browserslist configuration file  defaulted to `.browserslistrc`.
2020-05-04 10:53:48 -07:00
Alan Agius
10e7eb2c24 test: change browserslist file name to .browserslistrc 2020-04-06 09:58:42 -07:00
Alan Agius
b7a612f14a feat(@schematics/angular): change browserslist file name to .browserslistrc
Closes: #15961
2020-04-06 09:58:42 -07:00
Alan Agius
2335c1f3bf fix(@schematics/angular) remove file extension from zone flags comment 2020-02-12 12:01:08 -08:00
Cyrille Tuzi
ee589d9116 fix(@schematics/angular): add compliance with no-any lint rule 2020-01-29 10:19:36 -08:00
Alan
ba8a6ea599 feat(@schematics/angular): remove enableIvy option
With this change we remove the enableIvy option as now we only support generating Ivy application. Users who want to create a VE applications should follow the opt-out guide
2019-08-16 09:31:02 -07:00
Stefanie Fluin
40601c46e7 feat(@schematics/angular): cli app redesign (#14403)
* feat(@angular/cli): cli app redesign

* add template comment code and fix rocket ship smoke image placement

* correct tests verbiage

* fix tests copy of PR 14484

* move styles to template and remove unused icons font ref

* move font references to template

* remove external font references

* remove body styles and simplify css

* add comment block and remove old comments

* fix end of placeholder comment
2019-08-12 13:54:09 -07:00
Alan Agius
0551360035 fix(@schematics/angular): exclusively list the files in tsconfigs (#15030)
* test: update tests to work with new stricter tsconfig file inclusions

* fix(@schematics/angular): exclusively list the files in tsconfigs

With the omission of `includes` or `files` in tsconfig files tsc will pick up all the files under the rootDir and make them as part of the compilation. In certain cases, redundant files will be picked up which will cause a slower compilations.

Related to: TOOL-949
2019-07-16 11:04:29 -07:00
Cédric Exbrayat
9d4d5742bb feat(@schematics/angular): enable ivy in tests (#15044)
If a project is generated with `enableIvy`, this commit adds the necessary configuration to `tsconfig.spec.json` to then run the tests with Ivy. Note that the CLI already does the correct work (runs `ngcc` and then runs the tests).
2019-07-15 09:50:16 -07:00
Alan Agius
04b854956c fix(@schematics/angular): remove old GoogleBot browserslist setting
GoogleBot is now evergreen, we don't need to specialcase it: https://webmasters.googleblog.com/2019/05/the-new-evergreen-googlebot.html?m=1

Fixes #14364
2019-05-09 10:08:52 -07:00
Minko Gechev
4d7581d60b feat(@schematics/angular): enable support for Chrome 41
We want apps to be SEO friendly by default.
2019-04-19 10:49:03 -07:00
cexbrayat
0ce98ceeb3 docs(@schematics/angular): mention npx browserslist in browserslist
Running `npx browserslist` allows to see what browsers are actually selected with the configuration,
which is very handy and not very known.
2019-04-17 15:47:39 -07:00
Alan Agius
413a35bd56 feat(@schematics/angular): add more information and browsers in browserlist 2019-04-15 11:30:34 -07:00
JiaLiPassion
888bb27815 refactor: rename Zone 'BLACK_LISTED_EVENTS' to 'UNPATCHED_EVENTS' 2019-04-01 00:48:24 -07:00
Alan
a7d095d916 feat(@schematics/angular): change layout for root applications
This change aligns the file layout of applications generated with `ng new` and `ng generate`

Ref: TOOL-686
2019-03-06 11:28:26 -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