@schematics/angular 20.0.0-next.4 → 20.0.0-next.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/application/files/common-files/tsconfig.app.json.template +5 -4
- package/application/files/common-files/tsconfig.spec.json.template +2 -2
- package/application/files/module-files/src/app/{app.module.ts.template → app-module.ts.template} +1 -1
- package/application/files/module-files/src/app/app.ts.template +1 -1
- package/application/files/module-files/src/main.ts.template +1 -1
- package/application/files/standalone-files/src/app/app.ts.template +1 -1
- package/application/index.js +18 -1
- package/class/index.js +0 -1
- package/component/index.js +10 -1
- package/component/schema.d.ts +0 -1
- package/component/schema.json +2 -2
- package/directive/index.js +10 -3
- package/enum/index.d.ts +2 -2
- package/enum/index.js +0 -1
- package/guard/implements-files/{__name@dasherize__.guard.spec.ts.template → __name@dasherize____typeSeparator__guard.spec.ts.template} +1 -1
- package/guard/schema.d.ts +13 -0
- package/guard/schema.js +10 -1
- package/guard/schema.json +6 -0
- package/guard/type-files/{__name@dasherize__.guard.spec.ts.template → __name@dasherize____typeSeparator__guard.spec.ts.template} +1 -1
- package/interceptor/class-files/{__name@dasherize@if-flat__/__name@dasherize__.interceptor.spec.ts.template → __name@dasherize____typeSeparator__interceptor.spec.ts.template} +1 -1
- package/interceptor/functional-files/{__name@dasherize@if-flat__/__name@dasherize__.interceptor.spec.ts.template → __name@dasherize____typeSeparator__interceptor.spec.ts.template} +1 -1
- package/interceptor/index.d.ts +2 -2
- package/interceptor/index.js +2 -9
- package/interceptor/schema.d.ts +13 -0
- package/interceptor/schema.js +10 -0
- package/interceptor/schema.json +6 -0
- package/interface/index.js +0 -1
- package/library/files/src/__entryFile__.ts.template +1 -1
- package/library/index.js +4 -3
- package/migrations/migration-collection.json +5 -0
- package/migrations/previous-style-guide/migration.d.ts +9 -0
- package/migrations/previous-style-guide/migration.js +42 -0
- package/migrations/use-application-builder/migration.js +8 -0
- package/module/files/__name@dasherize@if-flat__/{__name@dasherize__.module.ts.template → __name@dasherize____typeSeparator__module.ts.template} +1 -1
- package/module/index.js +17 -6
- package/module/schema.d.ts +13 -0
- package/module/schema.js +10 -1
- package/module/schema.json +6 -0
- package/package.json +3 -3
- package/pipe/files/{__name@dasherize@if-flat__/__name@dasherize__.pipe.spec.ts.template → __name@dasherize____typeSeparator__pipe.spec.ts.template} +1 -1
- package/pipe/index.js +12 -11
- package/pipe/schema.d.ts +13 -0
- package/pipe/schema.js +10 -0
- package/pipe/schema.json +6 -0
- package/resolver/class-files/{__name@dasherize__.resolver.spec.ts.template → __name@dasherize____typeSeparator__resolver.spec.ts.template} +1 -1
- package/resolver/functional-files/{__name@dasherize__.resolver.spec.ts.template → __name@dasherize____typeSeparator__resolver.spec.ts.template} +1 -1
- package/resolver/index.d.ts +3 -3
- package/resolver/index.js +2 -3
- package/resolver/schema.d.ts +13 -0
- package/resolver/schema.js +10 -0
- package/resolver/schema.json +6 -0
- package/server/files/application-builder/ngmodule-src/app/app.module.server.ts.template +4 -4
- package/server/files/application-builder/standalone-src/main.server.ts.template +2 -2
- package/server/files/server-builder/ngmodule-src/app/app.module.server.ts.template +4 -4
- package/server/files/server-builder/standalone-src/main.server.ts.template +2 -2
- package/server/index.js +13 -4
- package/service/index.js +1 -8
- package/ssr/index.js +5 -0
- package/utility/add-declaration-to-ng-module.d.ts +1 -0
- package/utility/add-declaration-to-ng-module.js +3 -3
- package/utility/ast-utils.d.ts +1 -1
- package/utility/ast-utils.js +1 -4
- package/utility/generate-from-files.js +2 -0
- package/utility/latest-versions.js +3 -3
- package/utility/standalone/app_component.d.ts +29 -0
- package/utility/standalone/app_component.js +109 -0
- package/workspace/files/tsconfig.json.template +3 -3
- /package/application/files/common-files/src/app/{app.ng.html.template → app.html.template} +0 -0
- /package/class/files/{__name@dasherize____type__.spec.ts.template → __name@dasherize__.__type__.spec.ts.template} +0 -0
- /package/class/files/{__name@dasherize____type__.ts.template → __name@dasherize__.__type__.ts.template} +0 -0
- /package/enum/files/{__name@dasherize____type__.ts.template → __name@dasherize__.__type__.ts.template} +0 -0
- /package/guard/implements-files/{__name@dasherize__.guard.ts.template → __name@dasherize____typeSeparator__guard.ts.template} +0 -0
- /package/guard/type-files/{__name@dasherize__.guard.ts.template → __name@dasherize____typeSeparator__guard.ts.template} +0 -0
- /package/interceptor/class-files/{__name@dasherize@if-flat__/__name@dasherize__.interceptor.ts.template → __name@dasherize____typeSeparator__interceptor.ts.template} +0 -0
- /package/interceptor/functional-files/{__name@dasherize@if-flat__/__name@dasherize__.interceptor.ts.template → __name@dasherize____typeSeparator__interceptor.ts.template} +0 -0
- /package/interface/files/{__name@dasherize____type__.ts.template → __name@dasherize__.__type__.ts.template} +0 -0
- /package/module/files/__name@dasherize@if-flat__/{__name@dasherize__-routing.module.ts.template → __name@dasherize__-routing__typeSeparator__module.ts.template} +0 -0
- /package/pipe/files/{__name@dasherize@if-flat__/__name@dasherize__.pipe.ts.template → __name@dasherize____typeSeparator__pipe.ts.template} +0 -0
- /package/resolver/class-files/{__name@dasherize__.resolver.ts.template → __name@dasherize____typeSeparator__resolver.ts.template} +0 -0
- /package/resolver/functional-files/{__name@dasherize__.resolver.ts.template → __name@dasherize____typeSeparator__resolver.ts.template} +0 -0
- /package/service/files/{__name@dasherize@if-flat__/__name@dasherize__.__type@dasherize__.spec.ts.template → __name@dasherize__.__type@dasherize__.spec.ts.template} +0 -0
- /package/service/files/{__name@dasherize@if-flat__/__name@dasherize__.__type@dasherize__.ts.template → __name@dasherize__.__type@dasherize__.ts.template} +0 -0
package/module/schema.json
CHANGED
|
@@ -62,6 +62,12 @@
|
|
|
62
62
|
"type": "string",
|
|
63
63
|
"description": "The declaring NgModule.",
|
|
64
64
|
"alias": "m"
|
|
65
|
+
},
|
|
66
|
+
"typeSeparator": {
|
|
67
|
+
"type": "string",
|
|
68
|
+
"default": "-",
|
|
69
|
+
"enum": ["-", "."],
|
|
70
|
+
"description": "The separator character to use before the type within the generated file's name. For example, if you set the option to `.`, the file will be named `example.module.ts`."
|
|
65
71
|
}
|
|
66
72
|
},
|
|
67
73
|
"required": ["name", "project"]
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@schematics/angular",
|
|
3
|
-
"version": "20.0.0-next.
|
|
3
|
+
"version": "20.0.0-next.6",
|
|
4
4
|
"description": "Schematics specific to Angular",
|
|
5
5
|
"homepage": "https://github.com/angular/angular-cli",
|
|
6
6
|
"keywords": [
|
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
},
|
|
23
23
|
"schematics": "./collection.json",
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@angular-devkit/core": "20.0.0-next.
|
|
26
|
-
"@angular-devkit/schematics": "20.0.0-next.
|
|
25
|
+
"@angular-devkit/core": "20.0.0-next.6",
|
|
26
|
+
"@angular-devkit/schematics": "20.0.0-next.6",
|
|
27
27
|
"jsonc-parser": "3.3.1"
|
|
28
28
|
},
|
|
29
29
|
"repository": {
|
package/pipe/index.js
CHANGED
|
@@ -11,32 +11,33 @@ exports.default = default_1;
|
|
|
11
11
|
const schematics_1 = require("@angular-devkit/schematics");
|
|
12
12
|
const add_declaration_to_ng_module_1 = require("../utility/add-declaration-to-ng-module");
|
|
13
13
|
const find_module_1 = require("../utility/find-module");
|
|
14
|
+
const generate_from_files_1 = require("../utility/generate-from-files");
|
|
14
15
|
const parse_name_1 = require("../utility/parse-name");
|
|
15
16
|
const validation_1 = require("../utility/validation");
|
|
16
17
|
const workspace_1 = require("../utility/workspace");
|
|
17
18
|
function default_1(options) {
|
|
18
19
|
return async (host) => {
|
|
19
20
|
options.path ??= await (0, workspace_1.createDefaultPath)(host, options.project);
|
|
20
|
-
|
|
21
|
+
try {
|
|
22
|
+
options.module = (0, find_module_1.findModuleFromOptions)(host, options);
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
options.module = (0, find_module_1.findModuleFromOptions)(host, {
|
|
26
|
+
...options,
|
|
27
|
+
moduleExt: '-module.ts',
|
|
28
|
+
routingModuleExt: '-routing-module.ts',
|
|
29
|
+
});
|
|
30
|
+
}
|
|
21
31
|
const parsedPath = (0, parse_name_1.parseName)(options.path, options.name);
|
|
22
32
|
options.name = parsedPath.name;
|
|
23
33
|
options.path = parsedPath.path;
|
|
24
34
|
(0, validation_1.validateClassName)(schematics_1.strings.classify(options.name));
|
|
25
|
-
const templateSource = (0, schematics_1.apply)((0, schematics_1.url)('./files'), [
|
|
26
|
-
options.skipTests ? (0, schematics_1.filter)((path) => !path.endsWith('.spec.ts.template')) : (0, schematics_1.noop)(),
|
|
27
|
-
(0, schematics_1.applyTemplates)({
|
|
28
|
-
...schematics_1.strings,
|
|
29
|
-
'if-flat': (s) => (options.flat ? '' : s),
|
|
30
|
-
...options,
|
|
31
|
-
}),
|
|
32
|
-
(0, schematics_1.move)(parsedPath.path),
|
|
33
|
-
]);
|
|
34
35
|
return (0, schematics_1.chain)([
|
|
35
36
|
(0, add_declaration_to_ng_module_1.addDeclarationToNgModule)({
|
|
36
37
|
type: 'pipe',
|
|
37
38
|
...options,
|
|
38
39
|
}),
|
|
39
|
-
(0,
|
|
40
|
+
(0, generate_from_files_1.generateFromFiles)(options),
|
|
40
41
|
]);
|
|
41
42
|
};
|
|
42
43
|
}
|
package/pipe/schema.d.ts
CHANGED
|
@@ -49,4 +49,17 @@ export type Schema = {
|
|
|
49
49
|
* standalone components, directives, or pipes.
|
|
50
50
|
*/
|
|
51
51
|
standalone?: boolean;
|
|
52
|
+
/**
|
|
53
|
+
* The separator character to use before the type within the generated file's name. For
|
|
54
|
+
* example, if you set the option to `.`, the file will be named `example.pipe.ts`.
|
|
55
|
+
*/
|
|
56
|
+
typeSeparator?: TypeSeparator;
|
|
52
57
|
};
|
|
58
|
+
/**
|
|
59
|
+
* The separator character to use before the type within the generated file's name. For
|
|
60
|
+
* example, if you set the option to `.`, the file will be named `example.pipe.ts`.
|
|
61
|
+
*/
|
|
62
|
+
export declare enum TypeSeparator {
|
|
63
|
+
Empty = "-",
|
|
64
|
+
TypeSeparator = "."
|
|
65
|
+
}
|
package/pipe/schema.js
CHANGED
|
@@ -2,3 +2,13 @@
|
|
|
2
2
|
// THIS FILE IS AUTOMATICALLY GENERATED. TO UPDATE THIS FILE YOU NEED TO CHANGE THE
|
|
3
3
|
// CORRESPONDING JSON SCHEMA FILE, THEN RUN devkit-admin build (or bazel build ...).
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.TypeSeparator = void 0;
|
|
6
|
+
/**
|
|
7
|
+
* The separator character to use before the type within the generated file's name. For
|
|
8
|
+
* example, if you set the option to `.`, the file will be named `example.pipe.ts`.
|
|
9
|
+
*/
|
|
10
|
+
var TypeSeparator;
|
|
11
|
+
(function (TypeSeparator) {
|
|
12
|
+
TypeSeparator["Empty"] = "-";
|
|
13
|
+
TypeSeparator["TypeSeparator"] = ".";
|
|
14
|
+
})(TypeSeparator || (exports.TypeSeparator = TypeSeparator = {}));
|
package/pipe/schema.json
CHANGED
|
@@ -61,6 +61,12 @@
|
|
|
61
61
|
"type": "boolean",
|
|
62
62
|
"default": false,
|
|
63
63
|
"description": "Automatically export the pipe from the specified NgModule, making it accessible to other modules in the application."
|
|
64
|
+
},
|
|
65
|
+
"typeSeparator": {
|
|
66
|
+
"type": "string",
|
|
67
|
+
"default": "-",
|
|
68
|
+
"enum": ["-", "."],
|
|
69
|
+
"description": "The separator character to use before the type within the generated file's name. For example, if you set the option to `.`, the file will be named `example.pipe.ts`."
|
|
64
70
|
}
|
|
65
71
|
},
|
|
66
72
|
"required": ["name", "project"]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { TestBed } from '@angular/core/testing';
|
|
2
2
|
|
|
3
|
-
import { <%= classify(name) %>Resolver } from './<%= dasherize(name)
|
|
3
|
+
import { <%= classify(name) %>Resolver } from './<%= dasherize(name) %><%= typeSeparator %>resolver';
|
|
4
4
|
|
|
5
5
|
describe('<%= classify(name) %>Resolver', () => {
|
|
6
6
|
let resolver: <%= classify(name) %>Resolver;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { TestBed } from '@angular/core/testing';
|
|
2
2
|
import { ResolveFn } from '@angular/router';
|
|
3
3
|
|
|
4
|
-
import { <%= camelize(name) %>Resolver } from './<%= dasherize(name)
|
|
4
|
+
import { <%= camelize(name) %>Resolver } from './<%= dasherize(name) %><%= typeSeparator %>resolver';
|
|
5
5
|
|
|
6
6
|
describe('<%= camelize(name) %>Resolver', () => {
|
|
7
7
|
const executeResolver: ResolveFn<boolean> = (...resolverParameters) =>
|
package/resolver/index.d.ts
CHANGED
|
@@ -5,6 +5,6 @@
|
|
|
5
5
|
* Use of this source code is governed by an MIT-style license that can be
|
|
6
6
|
* found in the LICENSE file at https://angular.dev/license
|
|
7
7
|
*/
|
|
8
|
-
import { Rule } from '@angular-devkit/schematics';
|
|
9
|
-
import { Schema } from './schema';
|
|
10
|
-
export default function (options:
|
|
8
|
+
import type { Rule } from '@angular-devkit/schematics';
|
|
9
|
+
import type { Schema as ResolverOptions } from './schema';
|
|
10
|
+
export default function (options: ResolverOptions): Rule;
|
package/resolver/index.js
CHANGED
|
@@ -10,7 +10,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
10
10
|
exports.default = default_1;
|
|
11
11
|
const generate_from_files_1 = require("../utility/generate-from-files");
|
|
12
12
|
function default_1(options) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
: (0, generate_from_files_1.generateFromFiles)({ ...options, templateFilesDirectory: './class-files' });
|
|
13
|
+
const templateFilesDirectory = options.functional ? './functional-files' : './class-files';
|
|
14
|
+
return (0, generate_from_files_1.generateFromFiles)({ ...options, templateFilesDirectory });
|
|
16
15
|
}
|
package/resolver/schema.d.ts
CHANGED
|
@@ -34,4 +34,17 @@ export type Schema = {
|
|
|
34
34
|
* Skip the generation of a unit test file `spec.ts` for the new resolver.
|
|
35
35
|
*/
|
|
36
36
|
skipTests?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* The separator character to use before the type within the generated file's name. For
|
|
39
|
+
* example, if you set the option to `.`, the file will be named `example.resolver.ts`.
|
|
40
|
+
*/
|
|
41
|
+
typeSeparator?: TypeSeparator;
|
|
37
42
|
};
|
|
43
|
+
/**
|
|
44
|
+
* The separator character to use before the type within the generated file's name. For
|
|
45
|
+
* example, if you set the option to `.`, the file will be named `example.resolver.ts`.
|
|
46
|
+
*/
|
|
47
|
+
export declare enum TypeSeparator {
|
|
48
|
+
Empty = "-",
|
|
49
|
+
TypeSeparator = "."
|
|
50
|
+
}
|
package/resolver/schema.js
CHANGED
|
@@ -2,3 +2,13 @@
|
|
|
2
2
|
// THIS FILE IS AUTOMATICALLY GENERATED. TO UPDATE THIS FILE YOU NEED TO CHANGE THE
|
|
3
3
|
// CORRESPONDING JSON SCHEMA FILE, THEN RUN devkit-admin build (or bazel build ...).
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.TypeSeparator = void 0;
|
|
6
|
+
/**
|
|
7
|
+
* The separator character to use before the type within the generated file's name. For
|
|
8
|
+
* example, if you set the option to `.`, the file will be named `example.resolver.ts`.
|
|
9
|
+
*/
|
|
10
|
+
var TypeSeparator;
|
|
11
|
+
(function (TypeSeparator) {
|
|
12
|
+
TypeSeparator["Empty"] = "-";
|
|
13
|
+
TypeSeparator["TypeSeparator"] = ".";
|
|
14
|
+
})(TypeSeparator || (exports.TypeSeparator = TypeSeparator = {}));
|
package/resolver/schema.json
CHANGED
|
@@ -45,6 +45,12 @@
|
|
|
45
45
|
"$default": {
|
|
46
46
|
"$source": "projectName"
|
|
47
47
|
}
|
|
48
|
+
},
|
|
49
|
+
"typeSeparator": {
|
|
50
|
+
"type": "string",
|
|
51
|
+
"default": "-",
|
|
52
|
+
"enum": ["-", "."],
|
|
53
|
+
"description": "The separator character to use before the type within the generated file's name. For example, if you set the option to `.`, the file will be named `example.resolver.ts`."
|
|
48
54
|
}
|
|
49
55
|
},
|
|
50
56
|
"required": ["name", "project"]
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { NgModule } from '@angular/core';
|
|
2
2
|
import { provideServerRendering, withRoutes } from '@angular/ssr';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { <%= appComponentName %> } from '<%= appComponentPath %>';
|
|
4
|
+
import { <%= appModuleName %> } from '<%= appModulePath %>';
|
|
5
5
|
import { serverRoutes } from './app.routes.server';
|
|
6
6
|
|
|
7
7
|
@NgModule({
|
|
8
|
-
imports: [
|
|
8
|
+
imports: [<%= appModuleName %>],
|
|
9
9
|
providers: [provideServerRendering(withRoutes(serverRoutes))],
|
|
10
|
-
bootstrap: [
|
|
10
|
+
bootstrap: [<%= appComponentName %>],
|
|
11
11
|
})
|
|
12
12
|
export class AppServerModule {}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { bootstrapApplication } from '@angular/platform-browser';
|
|
2
|
-
import {
|
|
2
|
+
import { <%= appComponentName %> } from '<%= appComponentPath %>';
|
|
3
3
|
import { config } from './app/app.config.server';
|
|
4
4
|
|
|
5
|
-
const bootstrap = () => bootstrapApplication(
|
|
5
|
+
const bootstrap = () => bootstrapApplication(<%= appComponentName %>, config);
|
|
6
6
|
|
|
7
7
|
export default bootstrap;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { NgModule } from '@angular/core';
|
|
2
2
|
import { ServerModule } from '@angular/platform-server';
|
|
3
3
|
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { <%= appModuleName %> } from '<%= appModulePath %>';
|
|
5
|
+
import { <%= appComponentName %> } from '<%= appComponentPath %>';
|
|
6
6
|
|
|
7
7
|
@NgModule({
|
|
8
8
|
imports: [
|
|
9
|
-
|
|
9
|
+
<%= appModuleName %>,
|
|
10
10
|
ServerModule,
|
|
11
11
|
],
|
|
12
|
-
bootstrap: [
|
|
12
|
+
bootstrap: [<%= appComponentName %>],
|
|
13
13
|
})
|
|
14
14
|
export class AppServerModule {}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { bootstrapApplication } from '@angular/platform-browser';
|
|
2
|
-
import {
|
|
2
|
+
import { <%= appComponentName %> } from '<%= appComponentPath %>';
|
|
3
3
|
import { config } from './app/app.config.server';
|
|
4
4
|
|
|
5
|
-
const bootstrap = () => bootstrapApplication(
|
|
5
|
+
const bootstrap = () => bootstrapApplication(<%= appComponentName %>, config);
|
|
6
6
|
|
|
7
7
|
export default bootstrap;
|
package/server/index.js
CHANGED
|
@@ -18,6 +18,7 @@ const latest_versions_1 = require("../utility/latest-versions");
|
|
|
18
18
|
const ng_ast_utils_1 = require("../utility/ng-ast-utils");
|
|
19
19
|
const paths_1 = require("../utility/paths");
|
|
20
20
|
const project_targets_1 = require("../utility/project-targets");
|
|
21
|
+
const app_component_1 = require("../utility/standalone/app_component");
|
|
21
22
|
const util_1 = require("../utility/standalone/util");
|
|
22
23
|
const workspace_1 = require("../utility/workspace");
|
|
23
24
|
const workspace_models_1 = require("../utility/workspace-models");
|
|
@@ -94,10 +95,6 @@ function updateConfigFileApplicationBuilder(options) {
|
|
|
94
95
|
function updateTsConfigFile(tsConfigPath) {
|
|
95
96
|
return (host) => {
|
|
96
97
|
const json = new json_file_1.JSONFile(host, tsConfigPath);
|
|
97
|
-
const filesPath = ['files'];
|
|
98
|
-
const files = new Set(json.get(filesPath) ?? []);
|
|
99
|
-
files.add('src/' + serverMainEntryName);
|
|
100
|
-
json.modify(filesPath, [...files]);
|
|
101
98
|
const typePath = ['compilerOptions', 'types'];
|
|
102
99
|
const types = new Set(json.get(typePath) ?? []);
|
|
103
100
|
types.add('node');
|
|
@@ -150,10 +147,22 @@ function default_1(options) {
|
|
|
150
147
|
const sourceRoot = clientProject.sourceRoot ?? (0, core_1.join)((0, core_1.normalize)(clientProject.root), 'src');
|
|
151
148
|
let filesUrl = `./files/${usingApplicationBuilder ? 'application-builder/' : 'server-builder/'}`;
|
|
152
149
|
filesUrl += isStandalone ? 'standalone-src' : 'ngmodule-src';
|
|
150
|
+
const { componentName, componentImportPathInSameFile, moduleName, moduleImportPathInSameFile } = (0, app_component_1.resolveBootstrappedComponentData)(host, browserEntryPoint) || {
|
|
151
|
+
componentName: 'App',
|
|
152
|
+
componentImportPathInSameFile: './app/app',
|
|
153
|
+
moduleName: 'AppModule',
|
|
154
|
+
moduleImportPathInSameFile: './app/app.module',
|
|
155
|
+
};
|
|
153
156
|
const templateSource = (0, schematics_1.apply)((0, schematics_1.url)(filesUrl), [
|
|
154
157
|
(0, schematics_1.applyTemplates)({
|
|
155
158
|
...schematics_1.strings,
|
|
156
159
|
...options,
|
|
160
|
+
appComponentName: componentName,
|
|
161
|
+
appComponentPath: componentImportPathInSameFile,
|
|
162
|
+
appModuleName: moduleName,
|
|
163
|
+
appModulePath: moduleImportPathInSameFile === null
|
|
164
|
+
? null
|
|
165
|
+
: `./${node_path_1.posix.basename(moduleImportPathInSameFile)}`,
|
|
157
166
|
}),
|
|
158
167
|
(0, schematics_1.move)(sourceRoot),
|
|
159
168
|
]);
|
package/service/index.js
CHANGED
|
@@ -10,12 +10,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
10
10
|
exports.default = default_1;
|
|
11
11
|
const generate_from_files_1 = require("../utility/generate-from-files");
|
|
12
12
|
function default_1(options) {
|
|
13
|
-
|
|
14
|
-
const flat = options.flat;
|
|
15
|
-
options.flat = true;
|
|
16
|
-
// Schematic templates require a defined type value
|
|
17
|
-
options.type ??= '';
|
|
18
|
-
return (0, generate_from_files_1.generateFromFiles)(options, {
|
|
19
|
-
'if-flat': (s) => (flat ? '' : s),
|
|
20
|
-
});
|
|
13
|
+
return (0, generate_from_files_1.generateFromFiles)(options);
|
|
21
14
|
}
|
package/ssr/index.js
CHANGED
|
@@ -107,6 +107,11 @@ function updateApplicationBuilderTsConfigRule(options) {
|
|
|
107
107
|
return;
|
|
108
108
|
}
|
|
109
109
|
const json = new json_file_1.JSONFile(host, tsConfigPath);
|
|
110
|
+
// Skip adding the files entry if the server entry would already be included
|
|
111
|
+
const include = json.get(['include']);
|
|
112
|
+
if (Array.isArray(include) && include.includes('src/**/*.ts')) {
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
110
115
|
const filesPath = ['files'];
|
|
111
116
|
const files = new Set(json.get(filesPath) ?? []);
|
|
112
117
|
files.add('src/server.ts');
|
|
@@ -52,15 +52,15 @@ function addDeclarationToNgModule(options) {
|
|
|
52
52
|
if (options.skipImport || options.standalone || !modulePath) {
|
|
53
53
|
return host;
|
|
54
54
|
}
|
|
55
|
+
const typeSeparator = options.typeSeparator ?? '.';
|
|
55
56
|
const sourceText = host.readText(modulePath);
|
|
56
57
|
const source = ts.createSourceFile(modulePath, sourceText, ts.ScriptTarget.Latest, true);
|
|
57
58
|
const filePath = `/${options.path}/` +
|
|
58
59
|
(options.flat ? '' : schematics_1.strings.dasherize(options.name) + '/') +
|
|
59
60
|
schematics_1.strings.dasherize(options.name) +
|
|
60
|
-
(options.type ?
|
|
61
|
-
schematics_1.strings.dasherize(options.type);
|
|
61
|
+
(options.type ? typeSeparator + schematics_1.strings.dasherize(options.type) : '');
|
|
62
62
|
const importPath = (0, find_module_1.buildRelativePath)(modulePath, filePath);
|
|
63
|
-
const classifiedName = schematics_1.strings.classify(options.name) + schematics_1.strings.classify(options.type);
|
|
63
|
+
const classifiedName = schematics_1.strings.classify(options.name) + (options.type ? schematics_1.strings.classify(options.type) : '');
|
|
64
64
|
const changes = (0, ast_utils_1.addDeclarationToModule)(source, modulePath, classifiedName, importPath);
|
|
65
65
|
if (options.export) {
|
|
66
66
|
changes.push(...(0, ast_utils_1.addSymbolToNgModuleMetadata)(source, modulePath, 'exports', classifiedName));
|
package/utility/ast-utils.d.ts
CHANGED
|
@@ -60,7 +60,7 @@ export declare function findNode(node: ts.Node, kind: ts.SyntaxKind, text: strin
|
|
|
60
60
|
*/
|
|
61
61
|
export declare function insertAfterLastOccurrence(nodes: ts.Node[] | ts.NodeArray<ts.Node>, toInsert: string, file: string, fallbackPos: number, syntaxKind?: ts.SyntaxKind): Change;
|
|
62
62
|
export declare function getDecoratorMetadata(source: ts.SourceFile, identifier: string, module: string): ts.Node[];
|
|
63
|
-
export declare function getMetadataField(node: ts.ObjectLiteralExpression, metadataField: string): ts.
|
|
63
|
+
export declare function getMetadataField(node: ts.ObjectLiteralExpression, metadataField: string): ts.PropertyAssignment[];
|
|
64
64
|
export declare function addSymbolToNgModuleMetadata(source: ts.SourceFile, ngModulePath: string, metadataField: string, symbolName: string, importPath?: string | null): Change[];
|
|
65
65
|
/**
|
|
66
66
|
* Custom function to insert a declaration (component, pipe, directive)
|
package/utility/ast-utils.js
CHANGED
|
@@ -442,11 +442,8 @@ function getRouterModuleDeclaration(source) {
|
|
|
442
442
|
return undefined;
|
|
443
443
|
}
|
|
444
444
|
const matchingProperties = getMetadataField(node, 'imports');
|
|
445
|
-
if (!matchingProperties) {
|
|
446
|
-
return;
|
|
447
|
-
}
|
|
448
445
|
const assignment = matchingProperties[0];
|
|
449
|
-
if (assignment.initializer.kind !== ts.SyntaxKind.ArrayLiteralExpression) {
|
|
446
|
+
if (!assignment || assignment.initializer.kind !== ts.SyntaxKind.ArrayLiteralExpression) {
|
|
450
447
|
return;
|
|
451
448
|
}
|
|
452
449
|
const arrLiteral = assignment.initializer;
|
|
@@ -17,6 +17,8 @@ function generateFromFiles(options, extraTemplateValues = {}) {
|
|
|
17
17
|
options.path ??= await (0, workspace_1.createDefaultPath)(host, options.project);
|
|
18
18
|
options.prefix ??= '';
|
|
19
19
|
options.flat ??= true;
|
|
20
|
+
// Schematic templates require a defined type value
|
|
21
|
+
options.type ??= '';
|
|
20
22
|
const parsedPath = (0, parse_name_1.parseName)(options.path, options.name);
|
|
21
23
|
options.name = parsedPath.name;
|
|
22
24
|
options.path = parsedPath.path;
|
|
@@ -16,7 +16,7 @@ exports.latestVersions = {
|
|
|
16
16
|
// As Angular CLI works with same minor versions of Angular Framework, a tilde match for the current
|
|
17
17
|
Angular: '^20.0.0-next.0',
|
|
18
18
|
NgPackagr: '^20.0.0-next.0',
|
|
19
|
-
DevkitBuildAngular: '^20.0.0-next.
|
|
20
|
-
AngularBuild: '^20.0.0-next.
|
|
21
|
-
AngularSSR: '^20.0.0-next.
|
|
19
|
+
DevkitBuildAngular: '^20.0.0-next.6',
|
|
20
|
+
AngularBuild: '^20.0.0-next.6',
|
|
21
|
+
AngularSSR: '^20.0.0-next.6',
|
|
22
22
|
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright Google LLC All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
+
* found in the LICENSE file at https://angular.dev/license
|
|
7
|
+
*/
|
|
8
|
+
import { Tree } from '@angular-devkit/schematics';
|
|
9
|
+
/** Data resolved for a bootstrapped component. */
|
|
10
|
+
interface BootstrappedComponentData {
|
|
11
|
+
/** Original name of the component class. */
|
|
12
|
+
componentName: string;
|
|
13
|
+
/** Path under which the component was imported in the main entrypoint. */
|
|
14
|
+
componentImportPathInSameFile: string;
|
|
15
|
+
/** Original name of the NgModule being bootstrapped, null if the app isn't module-based. */
|
|
16
|
+
moduleName: string | null;
|
|
17
|
+
/**
|
|
18
|
+
* Path under which the module was imported in the main entrypoint,
|
|
19
|
+
* null if the app isn't module-based.
|
|
20
|
+
*/
|
|
21
|
+
moduleImportPathInSameFile: string | null;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Finds the original name and path relative to the `main.ts` of the bootrstrapped app component.
|
|
25
|
+
* @param tree File tree in which to look for the component.
|
|
26
|
+
* @param mainFilePath Path of the `main` file.
|
|
27
|
+
*/
|
|
28
|
+
export declare function resolveBootstrappedComponentData(tree: Tree, mainFilePath: string): BootstrappedComponentData | null;
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @license
|
|
4
|
+
* Copyright Google LLC All Rights Reserved.
|
|
5
|
+
*
|
|
6
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
7
|
+
* found in the LICENSE file at https://angular.dev/license
|
|
8
|
+
*/
|
|
9
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
10
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.resolveBootstrappedComponentData = resolveBootstrappedComponentData;
|
|
14
|
+
const schematics_1 = require("@angular-devkit/schematics");
|
|
15
|
+
const typescript_1 = __importDefault(require("../../third_party/github.com/Microsoft/TypeScript/lib/typescript"));
|
|
16
|
+
const ast_utils_1 = require("../ast-utils");
|
|
17
|
+
const ng_ast_utils_1 = require("../ng-ast-utils");
|
|
18
|
+
const util_1 = require("./util");
|
|
19
|
+
/**
|
|
20
|
+
* Finds the original name and path relative to the `main.ts` of the bootrstrapped app component.
|
|
21
|
+
* @param tree File tree in which to look for the component.
|
|
22
|
+
* @param mainFilePath Path of the `main` file.
|
|
23
|
+
*/
|
|
24
|
+
function resolveBootstrappedComponentData(tree, mainFilePath) {
|
|
25
|
+
// First try to resolve for a standalone app.
|
|
26
|
+
try {
|
|
27
|
+
const call = (0, util_1.findBootstrapApplicationCall)(tree, mainFilePath);
|
|
28
|
+
if (call.arguments.length > 0 && typescript_1.default.isIdentifier(call.arguments[0])) {
|
|
29
|
+
const resolved = resolveIdentifier(call.arguments[0]);
|
|
30
|
+
if (resolved) {
|
|
31
|
+
return {
|
|
32
|
+
componentName: resolved.name,
|
|
33
|
+
componentImportPathInSameFile: resolved.path,
|
|
34
|
+
moduleName: null,
|
|
35
|
+
moduleImportPathInSameFile: null,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
catch (e) {
|
|
41
|
+
// `findBootstrapApplicationCall` will throw if it can't find the `bootrstrapApplication` call.
|
|
42
|
+
// Catch so we can continue to the fallback logic.
|
|
43
|
+
if (!(e instanceof schematics_1.SchematicsException)) {
|
|
44
|
+
throw e;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
// Otherwise fall back to resolving an NgModule-based app.
|
|
48
|
+
return resolveNgModuleBasedData(tree, mainFilePath);
|
|
49
|
+
}
|
|
50
|
+
/** Resolves the bootstrap data for a NgModule-based app. */
|
|
51
|
+
function resolveNgModuleBasedData(tree, mainFilePath) {
|
|
52
|
+
const appModulePath = (0, ng_ast_utils_1.getAppModulePath)(tree, mainFilePath);
|
|
53
|
+
const appModuleFile = (0, util_1.getSourceFile)(tree, appModulePath);
|
|
54
|
+
const metadataNodes = (0, ast_utils_1.getDecoratorMetadata)(appModuleFile, 'NgModule', '@angular/core');
|
|
55
|
+
for (const node of metadataNodes) {
|
|
56
|
+
if (!typescript_1.default.isObjectLiteralExpression(node)) {
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
const bootstrapProp = (0, ast_utils_1.getMetadataField)(node, 'bootstrap').find((prop) => {
|
|
60
|
+
return (typescript_1.default.isArrayLiteralExpression(prop.initializer) &&
|
|
61
|
+
prop.initializer.elements.length > 0 &&
|
|
62
|
+
typescript_1.default.isIdentifier(prop.initializer.elements[0]));
|
|
63
|
+
});
|
|
64
|
+
const componentIdentifier = (bootstrapProp?.initializer)
|
|
65
|
+
.elements[0];
|
|
66
|
+
const componentResult = componentIdentifier ? resolveIdentifier(componentIdentifier) : null;
|
|
67
|
+
const bootstrapCall = (0, ng_ast_utils_1.findBootstrapModuleCall)(tree, mainFilePath);
|
|
68
|
+
if (componentResult &&
|
|
69
|
+
bootstrapCall &&
|
|
70
|
+
bootstrapCall.arguments.length > 0 &&
|
|
71
|
+
typescript_1.default.isIdentifier(bootstrapCall.arguments[0])) {
|
|
72
|
+
const moduleResult = resolveIdentifier(bootstrapCall.arguments[0]);
|
|
73
|
+
if (moduleResult) {
|
|
74
|
+
return {
|
|
75
|
+
componentName: componentResult.name,
|
|
76
|
+
componentImportPathInSameFile: componentResult.path,
|
|
77
|
+
moduleName: moduleResult.name,
|
|
78
|
+
moduleImportPathInSameFile: moduleResult.path,
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
/** Resolves an identifier to its original name and path that it was imported from. */
|
|
86
|
+
function resolveIdentifier(identifier) {
|
|
87
|
+
const sourceFile = identifier.getSourceFile();
|
|
88
|
+
// Try to resolve the import path by looking at the top-level named imports of the file.
|
|
89
|
+
for (const node of sourceFile.statements) {
|
|
90
|
+
if (!typescript_1.default.isImportDeclaration(node) ||
|
|
91
|
+
!typescript_1.default.isStringLiteral(node.moduleSpecifier) ||
|
|
92
|
+
!node.importClause ||
|
|
93
|
+
!node.importClause.namedBindings ||
|
|
94
|
+
!typescript_1.default.isNamedImports(node.importClause.namedBindings)) {
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
for (const element of node.importClause.namedBindings.elements) {
|
|
98
|
+
if (element.name.text === identifier.text) {
|
|
99
|
+
return {
|
|
100
|
+
// Note that we use `propertyName` if available, because it contains
|
|
101
|
+
// the real name in the case where the import is aliased.
|
|
102
|
+
name: (element.propertyName || element.name).text,
|
|
103
|
+
path: node.moduleSpecifier.text,
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
/* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */
|
|
3
3
|
{
|
|
4
4
|
"compileOnSave": false,
|
|
5
|
-
"compilerOptions": {
|
|
6
|
-
"outDir": "./dist/out-tsc",<% if (strict) { %>
|
|
5
|
+
"compilerOptions": {<% if (strict) { %>
|
|
7
6
|
"strict": true,
|
|
8
7
|
"noImplicitOverride": true,
|
|
9
8
|
"noPropertyAccessFromIndexSignature": true,
|
|
@@ -22,5 +21,6 @@
|
|
|
22
21
|
"strictInputAccessModifiers": true,
|
|
23
22
|
"typeCheckHostBindings": true,
|
|
24
23
|
"strictTemplates": true<% } %>
|
|
25
|
-
}
|
|
24
|
+
},
|
|
25
|
+
"files": []
|
|
26
26
|
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|