259 Commits

Author SHA1 Message Date
Alan Agius
8ba6b28b43 docs: enhance descriptions for schematics options
Refined and clarified the descriptions for various schematics options to improve their readability and accuracy. These changes aim to make the documentation more user-friendly and accessible for developers.

Closes #25571
2025-01-15 17:31:06 +01:00
Doug Parker
160dee33d7 fix(@schematics/angular): don't show server routing prompt when using browser builder
The new routing APIs don't support `browser` builder, but calling `ng add @angular/ssr` with a `browser` builder would still prompt the user to add them. If the user said "Yes", it would actually ignore that answer and not enable the new APIs.

With this change, `ng add @angular/ssr` when using `browser` builder does not show the prompt and assumes the answer is "No". It also throws an error if the user runs `ng add @angular/ssr --server-routing`.

I'm not aware of a built-in prompting mechanism in schematics beyond `x-prompt`, which can't be used here, so instead I just called Inquirer directly. Unfortunately testing the prompt is a little awkward, as Inquirier does not provide useful APIs in this space. I evaluated `@inquirer/testing`, but ultimately decided that was more intended for testing custom Inquirer prompts, not mocking usage of standard prompts. Schematics APIs do not provide a useful way to inject additional data like a mock, so instead I had to do this through a `setPrompterForTestOnly` function. I'm not a huge fan of it, but I don't see a more straightforward way of solving the problem.
2024-11-18 10:37:31 -08:00
Alan Agius
43cd4584f5 fix(@schematics/angular): enable opt-in for new @angular/ssr feature
This commit updates several schematics to make the new `@angular/ssr` feature opt-in. Users can opt in by using the `--server-routing` option or by responding with `yes` to the prompt.
2024-10-25 19:51:12 +02:00
Alan Agius
8567267603 refactor(@schematics/angular): remove redundant standalone: true from templates
This is no longer needed.
2024-10-24 16:23:02 +02:00
cexbrayat
8ce57fea5f refactor(@schematics/angular): spacing fixes after experimental zoneless introduction 2024-10-17 14:16:15 +00:00
Jan Martin
fcf7443d62 fix(@schematics/angular): explicitly set standalone:false 2024-10-16 07:56:23 -07:00
Alan Agius
3db1d81397 refactor(@schematics/angular): minor formatting fixes
Some minor formatting fixes.
2024-10-15 19:42:39 +02:00
aparziale
755f3a07f5 feat(@schematics/angular): add option to setup new workspace or application as zoneless mode 2024-10-15 09:28:18 -07:00
Alan Agius
292a4b7c2f feat(@schematics/angular): update app-shell and ssr schematics to adopt new Server Rendering API
This commit revises the app-shell and ssr schematics to incorporate the new Server Rendering API, along with the integration of server-side routes.

BREAKING CHANGE: The app-shell schematic is no longer compatible with Webpack-based builders.
2024-10-09 18:07:33 +02:00
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