250 Commits

Author SHA1 Message Date
Charles Lyding
d223d1eda3 refactor(@schematics/angular): increase new application anyComponentStyle budget thresholds
The 2kB/4kB warning/error thresholds for any component style within an application
has now been increased to 4kB/8kB for warnings/errors respectively. This allows for
more complex styles within a component while also reducing the likelihood of the budget
rule being disabled or removed. The new limits still provide diagnostics for extreme
size cases such as accidentally importing all Bootstrap or Material styles into an
individual component. Such instances are a primary use case for the budget.
2024-08-21 20:47:31 +02:00
Atchyut Pulavarthi
e3b8b780be fix(@schematics/angular): update schematics to use RouterModule when --routing flag is present
update schematics to use RouterModule instead of RouterTestingModule when generating a new project with the --routing flag

Fixes #27691
2024-06-17 12:39:18 +02:00
Ash Ramirez
434a3740f0 refactor(@angular/cli): update aio links -> adev links
Updates for all angular.io links to the new angular.dev domain. Additionally, adjustment to new resources where the equivalent does not exist on the new site (e.g. Tour of Heroes tutorial)
2024-06-06 11:12:06 +02:00
David LJ
0fa7e91231 docs: update tsconfig template link aio->adev 2024-06-05 09:31:34 -07:00
Alan Agius
8ea94eb73c fix(@schematics/angular): set builders assets option correctly for new applications
This commit ensures that the `assets` option value accurately reflects the source location.

Closes: #27709
2024-05-28 11:03:46 +02:00
Alan Agius
9e13a8b0c8 fix(@angular/build): format sizes using decimal byte units consistently
Ensure that file sizes are consistently formatted using decimal byte units, adhering to the International System of Units (SI) convention. This aligns with clarity and standardization across the project.

- Kilobyte (kB): 10^3 bytes (1000 bytes)
- Megabyte (MB): 10^6 bytes (1,000,000 bytes)
- Gigabyte (GB): 10^9 bytes (1,000,000,000 bytes)

Closes: #27580
2024-05-06 16:03:25 +02:00
Charles Lyding
b0ec254c62 refactor(@schematics/angular): remove unneeded extract-i18n buildTarget option for new applications
The `buildTarget` option for the `extract-18n` builder will automatically
default to use the `build` target of the containing project. This removes
the need for projects to manually configure the target. New projects will
now be generated without this option in the `angular.json` file.
2024-04-29 12:10:39 -04:00
cexbrayat
1573293848 fix(@schematics/angular): add spaces around eventCoalescing option
The usual coding style in the generated application is to have spaces in objects (see `server.ts.template` for example).
2024-03-29 19:27:41 -07:00
Pawel Kozlowski
508d97da76 feat(@schematics/angular): use ngZoneEventCoalescing option by default (module bootstrap)
This commit enables ngZoneEventCoalescing by default for NgModule-based applications.
2024-03-29 07:13:56 -07:00
Pawel Kozlowski
7258837138 feat(@schematics/angular): use eventCoalescing option by default (standalone bootstrap)
This commit enables eventCoalescing by default for standalone applications.
2024-03-29 07:13:56 -07:00
Alan Agius
6530aa11be feat(@schematics/angular): replace assets with public directory
The `assets` directory is confusing for the users and commonly users place "assets" which are not meant to be copied but instead processed by the build system. This causes some files both bundled and copied.

With this change we rename the `assets` directory to `public` and also move the `favicon.ico` inside this newly created directory.
2024-03-25 17:10:29 +01:00
Charles Lyding
feef54ac11 fix(@schematics/angular): improve Sass format clarity for application style option
The labels of the Sass preprocessor stylesheet option values have been updated for
the `application` schematic's `style` option. The labels now provide greater
clarity regarding the preprocessor tool used for both the SCSS (more common) and
indented Sass syntaxes.

The new list selection prompt is now as follows:
```
? Which stylesheet format would you like to use? (Use arrow keys)
❯ CSS             [ https://developer.mozilla.org/docs/Web/CSS                     ]
  Sass (SCSS)     [ https://sass-lang.com/documentation/syntax#scss                ]
  Sass (Indented) [ https://sass-lang.com/documentation/syntax#the-indented-syntax ]
  Less            [ http://lesscss.org                                             ]
```
2024-03-19 11:27:21 -04:00
Val-Git
ea8102ac7f refactor(@angular/cli): change Twitter icon in the application schematic 2024-01-10 10:48:34 -08:00
Alan Agius
4469e481fc fix(@schematics/angular): do not trigger NPM install when using ---skip-install and --ssr
The `skipInstall` option was never passed to the ssr schematic, which caused NPM install to also be invoked when running `ng new --ssr`.
2023-12-26 18:28:45 +01:00
Matthieu Riegler
3c66ba78b4 refactor(@angular-devkit/schematics): use self-closing tag for router-outlet
Let's make the component as simple a possible.
2023-11-20 08:06:08 -05:00
Matthieu Riegler
18231e0804 refactor(@angular-devkit/schematics): remove CommonModule
The template now uses the new control flow syntax
2023-11-20 08:06:08 -05:00
cexbrayat
0b987b5eeb fix(@schematics/angular): html indentation
The div was badly aligned in `app.component.html`
2023-11-08 18:57:57 +01:00
cexbrayat
47700e3c50 fix(@schematics/angular): use styleUrl
The `ng g c` schematic is already using `styleUrl`, but `app.component.ts` was still using `styleUrls`.
2023-11-08 18:57:40 +01:00
cexbrayat
da7dea654f fix(@schematics/angular): use href property binding for links 2023-11-08 15:04:33 +01:00
Alan Agius
a2fa0c995e refactor(@schematics/angular): add fallback fonts
Just in case Inter Tight is not available.
2023-11-07 19:14:34 +01:00
Alan Agius
7e72fd86fa refactor(@schematics/angular): remove unused CSS
Only h1 is used in the initial template.
2023-11-07 19:14:34 +01:00
Alan Agius
be6ef55369 refactor(@schematics/angular): use control flow to reduce code
This commit uses control flow to reduces code in the template
2023-11-07 19:14:34 +01:00
Alan Agius
f9a798be05 fix(@angular/pwa): replace Angular logos
This commit replaces the Angular old logo with the new one.
2023-11-07 19:14:34 +01:00
Alan Agius
1f02aa9f61 fix(@schematics/angular): add missing icons in ng-new template
This commit adds a number of missing icons.

Closes #26257
2023-11-07 19:14:34 +01:00
Doug Parker
42934bcffe feat(@schematics/angular): update ng new generated application 2023-11-06 15:53:53 -08:00
Sarthak Deshmukh
4b390abbe4 fix(@schematics/angular): change Twitter logo to X
Update twitter logo to x

Closes #26012
2023-10-18 16:35:26 +02:00
Alan Agius
c48982dc1d feat(@angular-devkit/build-angular): add buildTarget option to dev-server and extract-i18n builders
This is to better match the nature of the application builder where the target can be both browser and server.

DEPRECATED: The `browserTarget` in the dev-server and extract-i18n builders have been deprecated in favor of `buildTarget`.
2023-10-10 19:43:11 +02:00
Charles Lyding
0c20cc4dc5 fix(@angular-devkit/build-angular): re-add TestBed compileComponents in schematics to support defer block testing
The defer block support introduces a new asynchronous form of the set class metadata Angular function. This form
is needed to allow for providing metadata for dynamically imported deferred components. The asynchronous compileComponents
call within TestBed is now used to initialize this metadata during unit tests. Unit tests that contain defer blocks
must use this call prior to executing a test to allow templates containing defer to properly render. Existing tests that
do not use the new defer block do not require modification unless the defer block is introduced into components used in
the unit test.
2023-10-04 09:50:20 -04:00
Kristiyan Kostadinov
03a1eaf01c fix(@schematics/angular): account for new block syntax in starter template
Fixes that the starter template would've generated a compilation error in v17 after https://github.com/angular/angular/pull/51994 is released.
2023-10-04 09:49:36 -04:00
Alan Agius
741cca73c1 feat(@schematics/angular): add ng new --ssr
This commit enabled users to opt-in adding SSR and SSG to their application during the `ng new` experience. This can be done either by using the `--ssr` option or answer `Yes` when prompted.
2023-09-25 20:17:01 +02:00
Alan Agius
ac0db66975 feat(@schematics/angular): enable standalone by default in new applications
This commit update the schematics to generate a standalone application by default.
2023-09-22 16:42:35 +02:00
Enea Jahollari
e6dc2465b9 refactor(@schematics/angular): remove empty space in app.config.ts.template 2023-09-15 16:37:34 +02:00
Alan Agius
3f8aa9d8c7 feat(@schematics/angular): update ng new to use the esbuild application builder based builder
This commit updates the `ng generate application` to use the esbuild `application` builder. This also updates the schematics to support both `browser` and `application` builders.

BREAKING CHANGE: `rootModuleClassName`, `rootModuleFileName` and `main` options have been removed from the public `pwa` and `app-shell` schematics.
2023-09-13 17:40:50 +02:00
Alan Agius
1a6a139aaf feat(@schematics/angular): enable routing by default for new applications
This commits updates the `routing` option in the `ng new` and `ng generation application` schematics to `true` by default and also removed the `Would you like to add Angular routing?` prompt.

BREAKING CHANGE: Routing is enabled by default for new applications when using `ng generate application` and `ng new`. The `--no-routing` command line option can be used to disable this behaviour.
2023-09-08 16:00:01 +02:00
Alan Agius
f98c9de809 fix(@schematics/angular): add experimental message when using standalone application schematic.
This commit adds a warning when using `ng new --standalone` and `ng generate app --standalone`.
2023-04-05 12:45:46 +00:00
cexbrayat
202e9a50f6 fix(@schematics/angular): remove compileComponents from component test schematic
`compileComponents` is not necessary when using the CLI (as the templates are inlined) and just adds boilerplate code. So we can remove it from the test schematic and make it independent from `async/await` (only place we would have it in the CLI generated code, and in most Angular apps).
2023-03-24 18:30:26 +00:00
cexbrayat
ba4414b2cf fix(@schematics/angular): reformat app.config.ts
The CLI usually generates files with a new line at the end.
This line was lacking in the new `app.config.ts` file generated for standalone applications.

It was also using a trailing comma, which is not the usual convention in generated files.
2023-03-24 18:28:46 +00:00
cexbrayat
85fe820b08 fix(@schematics/angular): use same property order in standalone AppComponent
The `imports` are below the `standalone` property when generating a new component with `ng g c`.
This commit moves the `imports` of the standalone `app.component.ts` file to be in a similar place.
2023-03-24 18:21:43 +00:00
Alan Agius
8917d6d249 refactor(@schematics/angular): simplify application schematic
This commit simplifies the application schematic
2023-03-22 18:24:16 +00:00
Mike Brocchi
a832c20282 feat(@schematics/angular): Implement a standalone flag for new applications 2023-03-21 17:21:40 +00:00
Alan Agius
207358afb8 feat(@angular-devkit/schematics): add runSchematic and runExternalSchematic methods
These async methods are a replacement for the Observable based `runSchematicAsync` and `runExternalSchematicAsync` methods.

DEPRECATED:
The Observable based `SchematicTestRunner.runSchematicAsync` and `SchematicTestRunner.runExternalSchematicAsync` method have been deprecated in favor of the Promise based `SchematicTestRunner.runSchematic` and `SchematicTestRunner.runExternalSchematic`.
2022-12-08 14:49:43 -08:00
Alan Agius
639a3071c3 refactor: migrate analytics collector to use GA4
This change updates the analytics collector collector to use GA4 instead of UA. The motivation behind this change is that UA will stop collecting data in 2023.

BREAKING CHANGE:

`analyticsSharing` option in the global angular configuration has been
removed without replacement. This option was used to configure the Angular CLI to  access to your own users' CLI usage data.

If this option is used, it can be removed using `ng config --global cli.analyticsSharing undefined`.
2022-10-11 18:52:30 +02:00
Alan Agius
b06421d15e feat(@schematics/angular): mark projectRoot as non hidden option in application schematic
This option is useful to create an application outside of the `newProjectRoot`.

Related to https://github.com/angular/angular-cli/pull/23994
2022-10-07 11:09:43 -04:00
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