38 Commits

Author SHA1 Message Date
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
Alan Agius
dfde2750b4 fix(@schematics/angular): retain existing EOL when adding imports
This commit updates the AST utility to retain the existing EOF when adding imports
2024-01-05 16:30:06 +01:00
Paweł Fraś
9be1a82018 refactor(@schematics/angular): fix typo in "expression" variable name inside "addSymbolToNgModuleMetadata" function 2023-12-27 09:00:27 -05:00
Kristiyan Kostadinov
b14b959901 feat(@schematics/angular): add bootstrap-agnostic utilities for writing ng-add schematics
Currently writing schematics that support both NgModule-based and standalone projects is tricky, because they have different layouts. These changes introduce two new APIs that work both on NgModule and standalone projects and can be used by library authors to create their `ng add` schematics. Example rule for adding a `ModuleWithProviders`-style library:

```ts
import { Rule } from '@angular-devkit/schematics';
import { addRootImport } from '@schematics/angular/utility';

export default function(): Rule {
  return addRootImport('default', ({code, external}) => {
    return code`${external('MyModule', '@my/module')}.forRoot({})`;
  });
}
```

This rulle will add `imports: [MyModule.forRoot({})]` to an NgModule app and `providers: [importProvidersFrom(MyModule.forRoot({}))]` to a standalone one. It also adds all of the necessary imports.
2023-06-06 15:36:13 +02:00
Kristiyan Kostadinov
b36effda51 refactor(@schematics/angular): add utility to find top-level identifiers
Adds a utility that will find if a source file has a top-level identifier with a certain name. This will be useful when trying to avoid conflicts in generated imports later on.
2023-06-06 15:36:13 +02:00
Kristiyan Kostadinov
90e69badcc refactor(@schematics/angular): allow for imports to be inserted under an alias
Expands the `insertImport` utility to allow for imports to be inserted wuth an alias. Also adds unit tests and reworks the internals to be a bit more precise in where they look for matching nodes since previously they could've broken in some cases.
2023-06-06 15:36:13 +02:00
Günhan Gülsoy
2230374e18 refactor: remove add implicate types for better code readability
When strictNullChecks in enabled in TS compiler, the following files
cause some failures in certain environments. Fix these failures.
Also update outdated goldens.
2022-10-10 12:22:56 +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
7db433bb06 fix(@schematics/angular): provide actionable error message when routing declaration cannot be found
Due to incorrect castings previously the code would crash when the module doesn't contain an routing module with the following error:

```
Cannot read property 'properties' of undefined
```

Closes #21397
2022-04-04 10:03:40 -04: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
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
George Kalpakas
515f042380 refactor(@schematics/angular): remove dead code paths from addSymbolToNgModuleMetadata() 2021-03-30 14:33:19 -06:00
Alan Agius
08b263ca94 refactor(@schematics/angular): remove unused TS AST utils 2021-01-07 09:38:18 +01:00
Alan Agius
65dac11c20 fix(@schematics/angular): correctly handle PropertyAssignments with StringLiteral keys
Closes #16009
2021-01-06 12:02:06 +00:00
jaroslawsawicki
b2363414e1 fix(@schematics/angular): pass down recursive flag
This change makes `findNodes` recursive
2020-10-06 11:10:14 -04:00
aly ahmed
7280c62bb9 docs(@schematics/angular): update docs on getSourceNodes to match function type 2020-06-18 19:54:58 -04:00
Charles Lyding
cfbd6e81fb refactor(@schematics/angular): use type guard based narrowing in ast-utils
By leveraging TypeScript's AST type guards, function parameter assumptions and casting can be removed.  Many of these cases caused errors when enabling TypeScript's strict option. This is preliminary work to support enabling full TypeScript strict mode within the project.
2020-06-13 20:08:59 +02:00
Artur Androsovych
545847788d fix(@schematics/angular): handle aliased or existing environment import (#16377)
Closes: #16226
2019-12-20 16:33:31 -08:00
timdeschryver
3784859d13 fix(@schematics/angular): add new route before wildcard route 2019-11-18 10:55:19 -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
ae0f790ee7 fix(@schematics/angular): change findNodes to stop recursive lookup for child nodes of kind
Curtrently, when a node of kind is found, we recursivly continue to look up it's child nodes until the end of the AST. This ends up returing other nodes which we were not looking for as typically we are looking for the first level of children of the specified kind.

By default now, we stop recursivly looking for child nodes of kind when we encounter one.

Closes #15117
2019-07-24 19:06:47 -07:00
Alan
2c71af1465 fix(@schematics/angular): ignore nested arrays in route declarations
`findNodes` will continue looking for arrays recursively unless we specify that we specify that we want only the first array.

Routes array can contain nested arrays such as when specifying guards.

Fixes #15016
2019-07-10 04:18:23 +08:00
Alan
70a4cbe306 style: enable no-debugger and no-console tslint rules 2019-06-27 09:28:35 -07: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
22d77285e1 fix(@schematics/angular): handle newline after @ of a decorator
Fixes #14490
2019-05-23 19:14:58 +02:00
hawkgs
c402903a3d refactor(@schematics/angular): optimize insertAfterLastOccurrence AST util 2019-05-17 11:26:53 -07:00
hawkgs
52e9819232 fix(@schematics/angular): allow insertion when there are no occurrences 2019-05-09 10:06:09 -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
赵正阳
822d6a0b9b fix(@schematics/angular): add providers into providers metadata but not inner Object with ut. (#13081) 2018-11-30 14:08:49 -08:00
Alan Agius
8f0d03b6c2 fix(@schematics/angular): addSymbolToNgModuleMetadata metadata without indent
At the moment, at least a single whitespace is required as otherwise the following error `Cannot read property '0' of null ` will be thrown

Fixes #12950
2018-11-14 12:42:48 -08:00
vikerman
e3f56ebc71
fix(@schematics/angular): ast utils - handle NgModule with no newlines (#12521)
Exposed in Google where the formatting is different. Check for null before using a regex match result.
2018-10-09 06:37:50 -07:00
Charles Lyding
d202480a17 build: update/cleanup tslint rules & fix errors 2018-08-23 11:35:34 -07:00
Hans Larsen
548616eda3 feat(@schematics/angular): use STDERR to report warnings 2018-08-21 09:57:34 -07:00
Hans Larsen
483cbe2665 refactor: add tslint-sonarts and a lot of tslint rules
This should clean up the code a bit.

Note: at first I added the no-useless-cast rule, but after getting frustrated
with it (as it has many false positive), I decided to remove the rule but some
useless casts were removed so I let those in the PR.
2018-07-10 15:07:36 -07:00
Hans Larsen
44086c60ff build: move devkit repo back to angular-cli 2018-06-05 18:50:06 -07:00