ng-alain 12.4.0 → 13.0.0-beta.2
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/src/app/layout/basic/widgets/clear-storage.component.ts +1 -1
- package/application/files/src/app/layout/basic/widgets/fullscreen.component.ts +1 -1
- package/application/files/src/app/layout/basic/widgets/i18n.component.ts +3 -0
- package/application/index.js +43 -43
- package/application/index.js.map +1 -1
- package/application/index.ts +8 -8
- package/application/schema.json +1 -1
- package/collection.json +2 -3
- package/curd/index.js +2 -2
- package/curd/index.js.map +1 -1
- package/curd/schema.json +34 -27
- package/docs/generate.en-US.md +7 -7
- package/docs/generate.zh-CN.md +7 -7
- package/docs/plugin.en-US.md +0 -13
- package/docs/plugin.zh-CN.md +0 -13
- package/edit/index.js +1 -1
- package/edit/index.js.map +1 -1
- package/edit/schema.json +2 -7
- package/empty/index.js +1 -1
- package/empty/index.js.map +1 -1
- package/empty/schema.json +2 -7
- package/list/index.js +1 -1
- package/list/index.js.map +1 -1
- package/list/schema.json +2 -7
- package/migration.json +5 -10
- package/module/index.js +18 -18
- package/module/index.js.map +1 -1
- package/module/schema.json +1 -1
- package/ng-add/index.js +24 -26
- package/ng-add/index.js.map +1 -1
- package/ng-add/index.spec.ts +13 -3
- package/ng-add/index.ts +19 -21
- package/ng-add/schema.json +1 -1
- package/ng-update/data/attribute-selectors.js +1 -1
- package/ng-update/data/attribute-selectors.ts +1 -1
- package/ng-update/data/class-names.js +1 -1
- package/ng-update/data/class-names.ts +1 -1
- package/ng-update/data/constructor-checks.js +1 -1
- package/ng-update/data/constructor-checks.ts +1 -1
- package/ng-update/data/css-selectors.js +1 -1
- package/ng-update/data/css-selectors.ts +1 -1
- package/ng-update/data/element-selectors.js +1 -1
- package/ng-update/data/element-selectors.ts +1 -1
- package/ng-update/data/input-names.js +1 -1
- package/ng-update/data/input-names.ts +1 -1
- package/ng-update/data/method-call-checks.js +1 -1
- package/ng-update/data/method-call-checks.ts +1 -1
- package/ng-update/data/output-names.js +1 -1
- package/ng-update/data/output-names.ts +1 -1
- package/ng-update/data/property-names.js +1 -1
- package/ng-update/data/property-names.ts +1 -1
- package/ng-update/index.js +8 -13
- package/ng-update/index.js.map +1 -1
- package/ng-update/index.ts +5 -10
- package/ng-update/upgrade-data.js +3 -1
- package/ng-update/upgrade-data.js.map +1 -1
- package/ng-update/upgrade-data.ts +3 -2
- package/ng-update/upgrade-rules/checks/_src-to-nz-image-rule.js +1 -1
- package/ng-update/upgrade-rules/checks/_src-to-nz-image-rule.js.map +1 -1
- package/ng-update/upgrade-rules/v12/index.js +32 -32
- package/ng-update/upgrade-rules/v12/index.js.map +1 -1
- package/ng-update/upgrade-rules/v12/index.ts +1 -5
- package/ng-update/upgrade-rules/v12/schema.json +1 -1
- package/ng-update/upgrade-rules/v13/index.js +56 -0
- package/ng-update/upgrade-rules/v13/index.js.map +1 -0
- package/ng-update/upgrade-rules/v13/index.spec.ts +32 -0
- package/ng-update/upgrade-rules/v13/index.ts +51 -0
- package/package.json +2 -2
- package/plugin/files/rtl/layout/basic/widgets/rtl.component.ts +1 -1
- package/plugin/index.js +10 -14
- package/plugin/index.js.map +1 -1
- package/plugin/index.ts +0 -4
- package/plugin/plugin.code-style.js +2 -2
- package/plugin/plugin.code-style.js.map +1 -1
- package/plugin/plugin.default-language.js +3 -3
- package/plugin/plugin.default-language.js.map +1 -1
- package/plugin/plugin.default-language.ts +1 -1
- package/plugin/plugin.docker.js +6 -6
- package/plugin/plugin.docker.js.map +1 -1
- package/plugin/plugin.icon.js +7 -7
- package/plugin/plugin.icon.js.map +1 -1
- package/plugin/plugin.icon.ts +2 -2
- package/plugin/plugin.rtl.js +11 -11
- package/plugin/plugin.rtl.js.map +1 -1
- package/plugin/plugin.sts.js +1 -1
- package/plugin/plugin.sts.js.map +1 -1
- package/plugin/schema.json +1 -1
- package/schema.json +10 -0
- package/sta/index.js +13 -13
- package/sta/index.js.map +1 -1
- package/sta/schema.json +1 -1
- package/tpl/index.js +2 -2
- package/tpl/index.js.map +1 -1
- package/tpl/index.ts +1 -1
- package/tpl/schema.json +3 -8
- package/utils/alain.js +17 -18
- package/utils/alain.js.map +1 -1
- package/utils/alain.ts +1 -2
- package/utils/file.js +2 -2
- package/utils/file.js.map +1 -1
- package/utils/html.js +1 -1
- package/utils/html.js.map +1 -1
- package/utils/json.js +1 -1
- package/utils/json.js.map +1 -1
- package/utils/lib-versions.js +2 -2
- package/utils/lib-versions.ts +2 -2
- package/utils/log.js +3 -3
- package/utils/log.js.map +1 -1
- package/utils/log.ts +3 -3
- package/utils/node.js +8 -0
- package/utils/node.js.map +1 -0
- package/utils/node.ts +3 -0
- package/utils/package.js +4 -4
- package/utils/package.js.map +1 -1
- package/utils/package.ts +2 -2
- package/utils/testing.js +3 -3
- package/utils/testing.js.map +1 -1
- package/utils/versions.js +21 -20
- package/utils/versions.js.map +1 -1
- package/utils/versions.ts +17 -16
- package/utils/workspace.js +5 -5
- package/utils/workspace.js.map +1 -1
- package/view/index.js +1 -1
- package/view/index.js.map +1 -1
- package/view/schema.json +2 -7
- package/ng-update/upgrade-rules/v11/files-tpl/main.js +0 -31
- package/ng-update/upgrade-rules/v11/files-tpl/main.js.map +0 -1
- package/ng-update/upgrade-rules/v11/files-tpl/main.ts +0 -28
- package/ng-update/upgrade-rules/v11/hmr.js +0 -103
- package/ng-update/upgrade-rules/v11/hmr.js.map +0 -1
- package/ng-update/upgrade-rules/v11/hmr.ts +0 -109
- package/ng-update/upgrade-rules/v11/index.js +0 -72
- package/ng-update/upgrade-rules/v11/index.js.map +0 -1
- package/ng-update/upgrade-rules/v11/index.spec.ts +0 -51
- package/ng-update/upgrade-rules/v11/index.ts +0 -80
- package/ng-update/upgrade-rules/v11/layout.js +0 -39
- package/ng-update/upgrade-rules/v11/layout.js.map +0 -1
- package/ng-update/upgrade-rules/v11/layout.ts +0 -47
- package/ng-update/upgrade-rules/v117/index.js +0 -82
- package/ng-update/upgrade-rules/v117/index.js.map +0 -1
- package/ng-update/upgrade-rules/v117/index.spec.ts +0 -58
- package/ng-update/upgrade-rules/v117/index.ts +0 -71
- package/plugin/files/ie/tsconfig-es5.app.js +0 -9
- package/plugin/files/ie/tsconfig-es5.app.js.map +0 -1
- package/plugin/files/ie/tsconfig-es5.spec.js +0 -9
- package/plugin/files/ie/tsconfig-es5.spec.js.map +0 -1
- package/plugin/plugin.ie.js +0 -128
- package/plugin/plugin.ie.js.map +0 -1
- package/plugin/plugin.ie.spec.ts +0 -35
- package/plugin/plugin.ie.ts +0 -144
package/edit/schema.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"$schema": "http://json-schema.org/schema",
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema",
|
|
3
3
|
"$id": "SchematicsNgAlainEditComponent",
|
|
4
4
|
"title": "Ng Alain Edit Component Options Schema",
|
|
5
5
|
"type": "object",
|
|
@@ -44,6 +44,7 @@
|
|
|
44
44
|
"description": "Include template inline in the component.ts file. By default, an external template file is created and referenced in the component.ts file.",
|
|
45
45
|
"type": "boolean",
|
|
46
46
|
"default": false,
|
|
47
|
+
"alias": "t",
|
|
47
48
|
"x-user-analytics": 10
|
|
48
49
|
},
|
|
49
50
|
"viewEncapsulation": {
|
|
@@ -119,12 +120,6 @@
|
|
|
119
120
|
"description": "The declaring NgModule exports this component.",
|
|
120
121
|
"x-user-analytics": 19
|
|
121
122
|
},
|
|
122
|
-
"lintFix": {
|
|
123
|
-
"type": "boolean",
|
|
124
|
-
"description": "Apply lint fixes after generating the component.",
|
|
125
|
-
"x-user-analytics": 15,
|
|
126
|
-
"x-deprecated": "Use \"ng lint --fix\" directly instead."
|
|
127
|
-
},
|
|
128
123
|
"withoutPrefix": {
|
|
129
124
|
"type": "boolean",
|
|
130
125
|
"description": "指定选择器名不加前缀 (Without prefix to selectors)",
|
package/empty/index.js
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const schematics_1 = require("@angular-devkit/schematics");
|
|
4
4
|
const utils_1 = require("../utils");
|
|
5
5
|
function default_1(options) {
|
|
6
|
-
return schematics_1.chain([utils_1.buildAlain(Object.assign({ schematicName: 'empty' }, options))]);
|
|
6
|
+
return (0, schematics_1.chain)([(0, utils_1.buildAlain)(Object.assign({ schematicName: 'empty' }, options))]);
|
|
7
7
|
}
|
|
8
8
|
exports.default = default_1;
|
|
9
9
|
//# sourceMappingURL=index.js.map
|
package/empty/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../schematics/empty/index.ts"],"names":[],"mappings":";;AAAA,2DAAyD;AAEzD,oCAAsC;AAGtC,mBAAyB,OAAe;IACtC,OAAO,kBAAK,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../schematics/empty/index.ts"],"names":[],"mappings":";;AAAA,2DAAyD;AAEzD,oCAAsC;AAGtC,mBAAyB,OAAe;IACtC,OAAO,IAAA,kBAAK,EAAC,CAAC,IAAA,kBAAU,kBAAG,aAAa,EAAE,OAAO,IAAK,OAAO,EAAG,CAAC,CAAC,CAAC;AACrE,CAAC;AAFD,4BAEC"}
|
package/empty/schema.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"$schema": "http://json-schema.org/schema",
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema",
|
|
3
3
|
"$id": "SchematicsNgAlainEmptyComponent",
|
|
4
4
|
"title": "Ng Alain Empty Component Options Schema",
|
|
5
5
|
"type": "object",
|
|
@@ -44,6 +44,7 @@
|
|
|
44
44
|
"description": "Include template inline in the component.ts file. By default, an external template file is created and referenced in the component.ts file.",
|
|
45
45
|
"type": "boolean",
|
|
46
46
|
"default": false,
|
|
47
|
+
"alias": "t",
|
|
47
48
|
"x-user-analytics": 10
|
|
48
49
|
},
|
|
49
50
|
"viewEncapsulation": {
|
|
@@ -119,12 +120,6 @@
|
|
|
119
120
|
"description": "The declaring NgModule exports this component.",
|
|
120
121
|
"x-user-analytics": 19
|
|
121
122
|
},
|
|
122
|
-
"lintFix": {
|
|
123
|
-
"type": "boolean",
|
|
124
|
-
"description": "Apply lint fixes after generating the component.",
|
|
125
|
-
"x-user-analytics": 15,
|
|
126
|
-
"x-deprecated": "Use \"ng lint --fix\" directly instead."
|
|
127
|
-
},
|
|
128
123
|
"withoutPrefix": {
|
|
129
124
|
"type": "boolean",
|
|
130
125
|
"description": "指定选择器名不加前缀 (Without prefix to selectors)",
|
package/list/index.js
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const schematics_1 = require("@angular-devkit/schematics");
|
|
4
4
|
const utils_1 = require("../utils");
|
|
5
5
|
function default_1(options) {
|
|
6
|
-
return schematics_1.chain([utils_1.buildAlain(Object.assign({ schematicName: 'list' }, options))]);
|
|
6
|
+
return (0, schematics_1.chain)([(0, utils_1.buildAlain)(Object.assign({ schematicName: 'list' }, options))]);
|
|
7
7
|
}
|
|
8
8
|
exports.default = default_1;
|
|
9
9
|
//# sourceMappingURL=index.js.map
|
package/list/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../schematics/list/index.ts"],"names":[],"mappings":";;AAAA,2DAAyD;AAEzD,oCAAsC;AAGtC,mBAAyB,OAAe;IACtC,OAAO,kBAAK,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../schematics/list/index.ts"],"names":[],"mappings":";;AAAA,2DAAyD;AAEzD,oCAAsC;AAGtC,mBAAyB,OAAe;IACtC,OAAO,IAAA,kBAAK,EAAC,CAAC,IAAA,kBAAU,kBAAG,aAAa,EAAE,MAAM,IAAK,OAAO,EAAG,CAAC,CAAC,CAAC;AACpE,CAAC;AAFD,4BAEC"}
|
package/list/schema.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"$schema": "http://json-schema.org/schema",
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema",
|
|
3
3
|
"$id": "SchematicsNgAlainListComponent",
|
|
4
4
|
"title": "Ng Alain List Component Options Schema",
|
|
5
5
|
"type": "object",
|
|
@@ -44,6 +44,7 @@
|
|
|
44
44
|
"description": "Include template inline in the component.ts file. By default, an external template file is created and referenced in the component.ts file.",
|
|
45
45
|
"type": "boolean",
|
|
46
46
|
"default": false,
|
|
47
|
+
"alias": "t",
|
|
47
48
|
"x-user-analytics": 10
|
|
48
49
|
},
|
|
49
50
|
"viewEncapsulation": {
|
|
@@ -119,12 +120,6 @@
|
|
|
119
120
|
"description": "The declaring NgModule exports this component.",
|
|
120
121
|
"x-user-analytics": 19
|
|
121
122
|
},
|
|
122
|
-
"lintFix": {
|
|
123
|
-
"type": "boolean",
|
|
124
|
-
"description": "Apply lint fixes after generating the component.",
|
|
125
|
-
"x-user-analytics": 15,
|
|
126
|
-
"x-deprecated": "Use \"ng lint --fix\" directly instead."
|
|
127
|
-
},
|
|
128
123
|
"withoutPrefix": {
|
|
129
124
|
"type": "boolean",
|
|
130
125
|
"description": "指定选择器名不加前缀 (Without prefix to selectors)",
|
package/migration.json
CHANGED
|
@@ -1,21 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "./node_modules/@angular-devkit/schematics/collection-schema.json",
|
|
3
3
|
"schematics": {
|
|
4
|
-
"migration-v11": {
|
|
5
|
-
"version": "11",
|
|
6
|
-
"description": "Updates NG-ALAIN to v11 [https://github.com/ng-alain/ng-alain/issues/1863]",
|
|
7
|
-
"factory": "./ng-update/index#updateToV11"
|
|
8
|
-
},
|
|
9
|
-
"migration-v117": {
|
|
10
|
-
"version": "11.7.0",
|
|
11
|
-
"description": "Updates NG-ALAIN to v11.7.0",
|
|
12
|
-
"factory": "./ng-update/index#updateToV117"
|
|
13
|
-
},
|
|
14
4
|
"migration-v12": {
|
|
15
5
|
"version": "12",
|
|
16
6
|
"description": "Updates NG-ALAIN to v12 [https://github.com/ng-alain/ng-alain/issues/2027]",
|
|
17
7
|
"factory": "./ng-update/index#updateToV12"
|
|
18
8
|
},
|
|
9
|
+
"migration-v13": {
|
|
10
|
+
"version": "13",
|
|
11
|
+
"description": "Updates NG-ALAIN to v13 [https://github.com/ng-alain/ng-alain/issues/2174]",
|
|
12
|
+
"factory": "./ng-update/index#updateToV13"
|
|
13
|
+
},
|
|
19
14
|
"ng-post-update": {
|
|
20
15
|
"description": "Performs cleanup after ng-update.",
|
|
21
16
|
"factory": "./ng-update/index#postUpdate",
|
package/module/index.js
CHANGED
|
@@ -22,17 +22,17 @@ function addDeclarationToNgModule(options) {
|
|
|
22
22
|
if (!options.module) {
|
|
23
23
|
return tree;
|
|
24
24
|
}
|
|
25
|
-
const modulePath = core_1.normalize(`/${options.module}`);
|
|
25
|
+
const modulePath = (0, core_1.normalize)(`/${options.module}`);
|
|
26
26
|
const text = tree.read(modulePath);
|
|
27
27
|
if (text === null) {
|
|
28
28
|
throw new schematics_1.SchematicsException(`File ${modulePath} does not exist.`);
|
|
29
29
|
}
|
|
30
30
|
const sourceText = text.toString('utf-8');
|
|
31
31
|
const source = ts.createSourceFile(modulePath, sourceText, ts.ScriptTarget.Latest, true);
|
|
32
|
-
const importModulePath = core_1.normalize(`/${options.path}/${options.flat ? '' : `${core_1.strings.dasherize(options.name)}/`}${core_1.strings.dasherize(options.name)}.module`);
|
|
33
|
-
const relativeDir = core_1.relative(core_1.dirname(modulePath), core_1.dirname(importModulePath));
|
|
34
|
-
const relativePath = `${relativeDir.startsWith('.') ? relativeDir : `./${relativeDir}`}/${core_1.basename(importModulePath)}`;
|
|
35
|
-
const changes = ast_utils_1.addImportToModule(source, modulePath, core_1.strings.classify(`${options.name}Module`), relativePath);
|
|
32
|
+
const importModulePath = (0, core_1.normalize)(`/${options.path}/${options.flat ? '' : `${core_1.strings.dasherize(options.name)}/`}${core_1.strings.dasherize(options.name)}.module`);
|
|
33
|
+
const relativeDir = (0, core_1.relative)((0, core_1.dirname)(modulePath), (0, core_1.dirname)(importModulePath));
|
|
34
|
+
const relativePath = `${relativeDir.startsWith('.') ? relativeDir : `./${relativeDir}`}/${(0, core_1.basename)(importModulePath)}`;
|
|
35
|
+
const changes = (0, ast_utils_1.addImportToModule)(source, modulePath, core_1.strings.classify(`${options.name}Module`), relativePath);
|
|
36
36
|
const recorder = tree.beginUpdate(modulePath);
|
|
37
37
|
for (const change of changes) {
|
|
38
38
|
if (change instanceof change_1.InsertChange) {
|
|
@@ -45,13 +45,13 @@ function addDeclarationToNgModule(options) {
|
|
|
45
45
|
}
|
|
46
46
|
function addRoutingModuleToTop(options) {
|
|
47
47
|
return (tree) => {
|
|
48
|
-
const modulePath = core_1.normalize(`${options.path}/routes-routing.module.ts`);
|
|
48
|
+
const modulePath = (0, core_1.normalize)(`${options.path}/routes-routing.module.ts`);
|
|
49
49
|
if (!tree.exists(modulePath)) {
|
|
50
50
|
return tree;
|
|
51
51
|
}
|
|
52
52
|
const sourceText = tree.read(modulePath).toString('utf-8');
|
|
53
53
|
const source = ts.createSourceFile(modulePath, sourceText, ts.ScriptTarget.Latest, true);
|
|
54
|
-
const routesNode = ast_utils_1.findNode(source, ts.SyntaxKind.Identifier, 'routes');
|
|
54
|
+
const routesNode = (0, ast_utils_1.findNode)(source, ts.SyntaxKind.Identifier, 'routes');
|
|
55
55
|
if (routesNode == null || routesNode.parent == null) {
|
|
56
56
|
return tree;
|
|
57
57
|
}
|
|
@@ -60,7 +60,7 @@ function addRoutingModuleToTop(options) {
|
|
|
60
60
|
parentNode.initializer.getChildCount() === 0) {
|
|
61
61
|
return tree;
|
|
62
62
|
}
|
|
63
|
-
const childrenNode = ast_utils_1.findNode(parentNode.initializer, ts.SyntaxKind.Identifier, 'children');
|
|
63
|
+
const childrenNode = (0, ast_utils_1.findNode)(parentNode.initializer, ts.SyntaxKind.Identifier, 'children');
|
|
64
64
|
if (childrenNode == null || childrenNode.parent == null) {
|
|
65
65
|
return tree;
|
|
66
66
|
}
|
|
@@ -76,23 +76,23 @@ function addRoutingModuleToTop(options) {
|
|
|
76
76
|
}
|
|
77
77
|
function default_1(schema) {
|
|
78
78
|
return (tree) => __awaiter(this, void 0, void 0, function* () {
|
|
79
|
-
const proj = yield utils_1.getProject(tree, schema.project);
|
|
80
|
-
utils_1.refreshPathRoot(proj.project, schema, proj.alainProject);
|
|
79
|
+
const proj = yield (0, utils_1.getProject)(tree, schema.project);
|
|
80
|
+
(0, utils_1.refreshPathRoot)(proj.project, schema, proj.alainProject);
|
|
81
81
|
if (schema.module) {
|
|
82
|
-
schema.module = find_module_1.findModuleFromOptions(tree, schema);
|
|
82
|
+
schema.module = (0, find_module_1.findModuleFromOptions)(tree, schema);
|
|
83
83
|
}
|
|
84
|
-
const parsedPath = parse_name_1.parseName(schema.path, schema.name);
|
|
84
|
+
const parsedPath = (0, parse_name_1.parseName)(schema.path, schema.name);
|
|
85
85
|
schema.name = parsedPath.name;
|
|
86
86
|
schema.path = parsedPath.path;
|
|
87
87
|
schema.routing = true;
|
|
88
88
|
schema.flat = false;
|
|
89
|
-
const templateSource = schematics_1.apply(schematics_1.url('./files'), [
|
|
90
|
-
schema.routing ? schematics_1.noop() : schematics_1.filter(path => !path.endsWith('-routing.module.ts')),
|
|
91
|
-
schematics_1.applyTemplates(Object.assign(Object.assign(Object.assign({}, core_1.strings), { 'if-flat': (s) => (schema.flat ? '' : s) }), schema)),
|
|
92
|
-
schematics_1.move(parsedPath.path)
|
|
89
|
+
const templateSource = (0, schematics_1.apply)((0, schematics_1.url)('./files'), [
|
|
90
|
+
schema.routing ? (0, schematics_1.noop)() : (0, schematics_1.filter)(path => !path.endsWith('-routing.module.ts')),
|
|
91
|
+
(0, schematics_1.applyTemplates)(Object.assign(Object.assign(Object.assign({}, core_1.strings), { 'if-flat': (s) => (schema.flat ? '' : s) }), schema)),
|
|
92
|
+
(0, schematics_1.move)(parsedPath.path)
|
|
93
93
|
]);
|
|
94
|
-
return schematics_1.chain([
|
|
95
|
-
schematics_1.branchAndMerge(schematics_1.chain([addDeclarationToNgModule(schema), addRoutingModuleToTop(schema), schematics_1.mergeWith(templateSource)]))
|
|
94
|
+
return (0, schematics_1.chain)([
|
|
95
|
+
(0, schematics_1.branchAndMerge)((0, schematics_1.chain)([addDeclarationToNgModule(schema), addRoutingModuleToTop(schema), (0, schematics_1.mergeWith)(templateSource)]))
|
|
96
96
|
]);
|
|
97
97
|
});
|
|
98
98
|
}
|
package/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../schematics/module/index.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,+CAAuF;AACvF,2DAaoC;AACpC,qEAAoF;AACpF,+DAAkE;AAClE,yEAAgF;AAChF,uEAAmE;AACnE,iCAAiC;AAEjC,oCAAuD;AAGvD,SAAS,wBAAwB,CAAC,OAAqB;IACrD,OAAO,CAAC,IAAU,EAAE,EAAE;QACpB,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE;YACnB,OAAO,IAAI,CAAC;SACb;QAED,MAAM,UAAU,GAAG,gBAAS,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../schematics/module/index.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,+CAAuF;AACvF,2DAaoC;AACpC,qEAAoF;AACpF,+DAAkE;AAClE,yEAAgF;AAChF,uEAAmE;AACnE,iCAAiC;AAEjC,oCAAuD;AAGvD,SAAS,wBAAwB,CAAC,OAAqB;IACrD,OAAO,CAAC,IAAU,EAAE,EAAE;QACpB,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE;YACnB,OAAO,IAAI,CAAC;SACb;QAED,MAAM,UAAU,GAAG,IAAA,gBAAS,EAAC,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;QAEnD,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QACnC,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EpB,MAAM,cAAc,GAAG,IAAA,kBAAK,EAAC,IAAA,gBAAG,EAAC,SAAS,CAAC,EAAE;YAC3C,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,IAAA,iBAAI,GAAE,CAAC,CAAC,CAAC,IAAA,mBAAM,EAAC,IAAI,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,oBAAoB,CAAC,CAAC;YAC9E,IAAA,2BAAc,gDACT,cAAO,KACV,SAAS,EAAE,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,KAC7C,MAAM,EACT;YACF,IAAA,iBAAI,EAAC,UAAU,CAAC,IAAI,CAAC;SACtB,CAAC,CAAC;QAEH,OAAO,IAAA,kBAAK,EAAC;YACX,IAAA,2BAAc,EACZ,IAAA,kBAAK,EAAC,CAAC,wBAAwB,CAAC,MAAM,CAAC,EAAE,qBAAqB,CAAC,MAAM,CAAC,EAAE,IAAA,sBAAS,EAAC,cAAc,CAAC,CAAC,CAAC,CACpG;SACF,CAAC,CAAC;IACL,CAAC,CAAA,CAAC;AACJ,CAAC;AAjCD,4BAiCC"}
|
package/module/schema.json
CHANGED
package/ng-add/index.js
CHANGED
|
@@ -3,52 +3,44 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const color_1 = require("@angular/cli/utilities/color");
|
|
4
4
|
const schematics_1 = require("@angular-devkit/schematics");
|
|
5
5
|
const tasks_1 = require("@angular-devkit/schematics/tasks");
|
|
6
|
-
const fs_1 = require("fs");
|
|
7
|
-
const path_1 = require("path");
|
|
8
6
|
const utils_1 = require("../utils");
|
|
9
|
-
const
|
|
7
|
+
const node_1 = require("../utils/node");
|
|
8
|
+
const V = 13;
|
|
10
9
|
function genRules(options) {
|
|
11
10
|
return () => {
|
|
12
11
|
const rules = [];
|
|
13
12
|
const applicationOptions = Object.assign({}, options);
|
|
14
|
-
rules.push(schematics_1.schematic('application', applicationOptions));
|
|
13
|
+
rules.push((0, schematics_1.schematic)('application', applicationOptions));
|
|
15
14
|
if (options.codeStyle) {
|
|
16
|
-
rules.push(schematics_1.schematic('plugin', { name: 'codeStyle', type: 'add' }));
|
|
15
|
+
rules.push((0, schematics_1.schematic)('plugin', { name: 'codeStyle', type: 'add' }));
|
|
17
16
|
}
|
|
18
17
|
if (options.defaultLanguage) {
|
|
19
|
-
rules.push(schematics_1.schematic('plugin', {
|
|
18
|
+
rules.push((0, schematics_1.schematic)('plugin', {
|
|
20
19
|
name: 'defaultLanguage',
|
|
21
20
|
type: 'add',
|
|
22
21
|
defaultLanguage: options.defaultLanguage
|
|
23
22
|
}));
|
|
24
23
|
}
|
|
25
24
|
if (options.npm) {
|
|
26
|
-
rules.push(schematics_1.schematic('plugin', {
|
|
25
|
+
rules.push((0, schematics_1.schematic)('plugin', {
|
|
27
26
|
name: 'networkEnv',
|
|
28
27
|
type: 'add',
|
|
29
28
|
packageManager: 'npm'
|
|
30
29
|
}));
|
|
31
30
|
}
|
|
32
31
|
if (options.yarn) {
|
|
33
|
-
rules.push(schematics_1.schematic('plugin', {
|
|
32
|
+
rules.push((0, schematics_1.schematic)('plugin', {
|
|
34
33
|
name: 'networkEnv',
|
|
35
34
|
type: 'add',
|
|
36
35
|
packageManager: 'yarn'
|
|
37
36
|
}));
|
|
38
37
|
}
|
|
39
|
-
return schematics_1.chain(rules);
|
|
38
|
+
return (0, schematics_1.chain)(rules);
|
|
40
39
|
};
|
|
41
40
|
}
|
|
42
|
-
function
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
return [];
|
|
46
|
-
return fs_1.readdirSync(nodeModulesPath) || [];
|
|
47
|
-
}
|
|
48
|
-
function isUseCNPM() {
|
|
49
|
-
const names = getFiles();
|
|
50
|
-
const res = ['_@angular', '_ng-zorro-antd'].every(prefix => names.findIndex(w => w.startsWith(prefix)) !== -1);
|
|
51
|
-
return res;
|
|
41
|
+
function isYarn(tree) {
|
|
42
|
+
var _a, _b;
|
|
43
|
+
return ((_b = (_a = (0, utils_1.readJSON)(tree, '/angular.json')) === null || _a === void 0 ? void 0 : _a.cli) === null || _b === void 0 ? void 0 : _b.packageManager) === 'yarn';
|
|
52
44
|
}
|
|
53
45
|
function finished() {
|
|
54
46
|
return (_, context) => {
|
|
@@ -62,21 +54,27 @@ NG-ALAIN documentation site: https://ng-alain.com
|
|
|
62
54
|
}
|
|
63
55
|
function default_1(options) {
|
|
64
56
|
return (tree, context) => {
|
|
65
|
-
if (
|
|
66
|
-
|
|
57
|
+
if (!isYarn(tree)) {
|
|
58
|
+
context.logger.warn(`TIPS:: Please use yarn instead of NPM to install dependencies`);
|
|
59
|
+
}
|
|
60
|
+
const nodeVersion = (0, node_1.getNodeMajorVersion)();
|
|
61
|
+
const allowNodeVersions = [12, 14, 16];
|
|
62
|
+
if (!allowNodeVersions.some(v => nodeVersion === v)) {
|
|
63
|
+
const versions = allowNodeVersions.join(', ');
|
|
64
|
+
throw new schematics_1.SchematicsException(`Sorry, currently only supports ${versions} major version number of node (Got ${process.version}), pls refer to https://gist.github.com/LayZeeDK/c822cc812f75bb07b7c55d07ba2719b3`);
|
|
67
65
|
}
|
|
68
|
-
const pkg = utils_1.readPackage(tree);
|
|
66
|
+
const pkg = (0, utils_1.readPackage)(tree);
|
|
69
67
|
if (pkg.devDependencies['ng-alain']) {
|
|
70
|
-
throw new
|
|
68
|
+
throw new schematics_1.SchematicsException(`Already an NG-ALAIN project and can't be executed again: ng add ng-alain`);
|
|
71
69
|
}
|
|
72
70
|
let ngCoreVersion = pkg.dependencies['@angular/core'];
|
|
73
71
|
if (/^[\^|\~]/g.test(ngCoreVersion)) {
|
|
74
|
-
ngCoreVersion = ngCoreVersion.
|
|
72
|
+
ngCoreVersion = ngCoreVersion.substring(1);
|
|
75
73
|
}
|
|
76
74
|
if (!ngCoreVersion.startsWith(`${V}.`)) {
|
|
77
|
-
throw new
|
|
75
|
+
throw new schematics_1.SchematicsException(`Sorry, the current version only supports angular ${V}.x, pls downgrade the global Anguar-cli version: [yarn global add @angular/cli@${V}] (or via npm: [npm install -g @angular/cli@${V}])`);
|
|
78
76
|
}
|
|
79
|
-
return schematics_1.chain([genRules(options), finished()])(tree, context);
|
|
77
|
+
return (0, schematics_1.chain)([genRules(options), finished()])(tree, context);
|
|
80
78
|
};
|
|
81
79
|
}
|
|
82
80
|
exports.default = default_1;
|
package/ng-add/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../schematics/ng-add/index.ts"],"names":[],"mappings":";;AAAA,wDAAsD;AAEtD,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../schematics/ng-add/index.ts"],"names":[],"mappings":";;AAAA,wDAAsD;AAEtD,2DAAiH;AACjH,4DAA0E;AAG1E,oCAAiD;AACjD,wCAAoD;AAGpD,MAAM,CAAC,GAAG,EAAE,CAAC;AAEb,SAAS,QAAQ,CAAC,OAAqB;IACrC,OAAO,GAAG,EAAE;QACV,MAAM,KAAK,GAAW,EAAE,CAAC;QAEzB,MAAM,kBAAkB,qBAA4B,OAAO,CAAE,CAAC;QAC9D,KAAK,CAAC,IAAI,CAAC,IAAA,sBAAS,EAAC,aAAa,EAAE,kBAAkB,CAAC,CAAC,CAAC;QAEzD,IAAI,OAAO,CAAC,SAAS,EAAE;YACrB,KAAK,CAAC,IAAI,CAAC,IAAA,sBAAS,EAAC,QAAQ,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;SACrE;QAED,IAAI,OAAO,CAAC,eAAe,EAAE;YAC3B,KAAK,CAAC,IAAI,CACR,IAAA,sBAAS,EAAC,QAAQ,EAAE;gBAClB,IAAI,EAAE,iBAAiB;gBACvB,IAAI,EAAE,KAAK;gBACX,eAAe,EAAE,OAAO,CAAC,eAAe;aACzC,CAAC,CACH,CAAC;SACH;QAED,IAA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I,CAAC,CAAC,CAAC,EAAE,CAAC,WAAW,KAAK,CAAC,CAAC,EAAE;YACnD,MAAM,QAAQ,GAAG,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAC9C,MAAM,IAAI,gCAAmB,CAC3B,kCAAkC,QAAQ,sCAAsC,OAAO,CAAC,OAAO,mFAAmF,CACnL,CAAC;SACH;QAED,MAAM,GAAG,GAAG,IAAA,mBAAW,EAAC,IAAI,CAAC,CAAC;QAE9B,IAAI,GAAG,CAAC,eAAe,CAAC,UAAU,CAAC,EAAE;YACnC,MAAM,IAAI,gCAAmB,CAAC,0EAA0E,CAAC,CAAC;SAC3G;QAED,IAAI,aAAa,GAAG,GAAG,CAAC,YAAY,CAAC,eAAe,CAAW,CAAC;QAChE,IAAI,WAAW,CAAC,IAAI,CAAC,aAAa,CAAC,EAAE;YACnC,aAAa,GAAG,aAAa,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;SAC5C;QACD,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;YACtC,MAAM,IAAI,gCAAmB,CAC3B,oDAAoD,CAAC,kFAAkF,CAAC,+CAA+C,CAAC,IAAI,CAC7L,CAAC;SACH;QAED,OAAO,IAAA,kBAAK,EAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAC/D,CAAC,CAAC;AACJ,CAAC;AAjCD,4BAiCC"}
|
package/ng-add/index.spec.ts
CHANGED
|
@@ -1,15 +1,25 @@
|
|
|
1
1
|
import { SchematicTestRunner, UnitTestTree } from '@angular-devkit/schematics/testing';
|
|
2
2
|
|
|
3
|
+
import * as nodeUtils from '../utils/node';
|
|
3
4
|
import { createAlainApp } from '../utils/testing';
|
|
4
5
|
|
|
5
6
|
describe('Schematic: ng-add', () => {
|
|
6
7
|
let runner: SchematicTestRunner;
|
|
7
8
|
let tree: UnitTestTree;
|
|
8
9
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
it('should dependencies @delon of an application', () => {
|
|
10
|
+
it('should dependencies @delon of an application', async () => {
|
|
11
|
+
({ runner, tree } = await createAlainApp());
|
|
12
12
|
const packageJson = JSON.parse(tree.readContent('package.json'));
|
|
13
13
|
expect(packageJson.dependencies['@delon/theme']).toBeDefined();
|
|
14
14
|
});
|
|
15
|
+
|
|
16
|
+
it('should throw errr when node version is not valid range', async () => {
|
|
17
|
+
spyOn(nodeUtils, 'getNodeMajorVersion').and.returnValue(10);
|
|
18
|
+
try {
|
|
19
|
+
await createAlainApp();
|
|
20
|
+
expect(true).toBe(false);
|
|
21
|
+
} catch (ex) {
|
|
22
|
+
expect(true).toBe(true);
|
|
23
|
+
}
|
|
24
|
+
});
|
|
15
25
|
});
|
package/ng-add/index.ts
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import { colors } from '@angular/cli/utilities/color';
|
|
2
2
|
|
|
3
|
-
import { chain, Rule, schematic, Tree, SchematicContext } from '@angular-devkit/schematics';
|
|
3
|
+
import { chain, Rule, schematic, Tree, SchematicContext, SchematicsException } from '@angular-devkit/schematics';
|
|
4
4
|
import { NodePackageInstallTask } from '@angular-devkit/schematics/tasks';
|
|
5
|
-
import { readdirSync, statSync } from 'fs';
|
|
6
|
-
import { join } from 'path';
|
|
7
5
|
|
|
8
6
|
import { Schema as ApplicationOptions } from '../application/schema';
|
|
9
|
-
import { readPackage } from '../utils';
|
|
7
|
+
import { readJSON, readPackage } from '../utils';
|
|
8
|
+
import { getNodeMajorVersion } from '../utils/node';
|
|
10
9
|
import { Schema as NgAddOptions } from './schema';
|
|
11
10
|
|
|
12
|
-
const V =
|
|
11
|
+
const V = 13;
|
|
13
12
|
|
|
14
13
|
function genRules(options: NgAddOptions): Rule {
|
|
15
14
|
return () => {
|
|
@@ -56,16 +55,8 @@ function genRules(options: NgAddOptions): Rule {
|
|
|
56
55
|
};
|
|
57
56
|
}
|
|
58
57
|
|
|
59
|
-
function
|
|
60
|
-
|
|
61
|
-
if (!statSync(nodeModulesPath).isDirectory()) return [];
|
|
62
|
-
return readdirSync(nodeModulesPath) || [];
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
function isUseCNPM(): boolean {
|
|
66
|
-
const names = getFiles();
|
|
67
|
-
const res = ['_@angular', '_ng-zorro-antd'].every(prefix => names.findIndex(w => w.startsWith(prefix)) !== -1);
|
|
68
|
-
return res;
|
|
58
|
+
function isYarn(tree: Tree): boolean {
|
|
59
|
+
return readJSON(tree, '/angular.json')?.cli?.packageManager === 'yarn';
|
|
69
60
|
}
|
|
70
61
|
|
|
71
62
|
function finished(): Rule {
|
|
@@ -84,24 +75,31 @@ NG-ALAIN documentation site: https://ng-alain.com
|
|
|
84
75
|
|
|
85
76
|
export default function (options: NgAddOptions): Rule {
|
|
86
77
|
return (tree: Tree, context: SchematicContext) => {
|
|
87
|
-
if (
|
|
88
|
-
|
|
89
|
-
|
|
78
|
+
if (!isYarn(tree)) {
|
|
79
|
+
context.logger.warn(`TIPS:: Please use yarn instead of NPM to install dependencies`);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const nodeVersion = getNodeMajorVersion();
|
|
83
|
+
const allowNodeVersions = [12, 14, 16];
|
|
84
|
+
if (!allowNodeVersions.some(v => nodeVersion === v)) {
|
|
85
|
+
const versions = allowNodeVersions.join(', ');
|
|
86
|
+
throw new SchematicsException(
|
|
87
|
+
`Sorry, currently only supports ${versions} major version number of node (Got ${process.version}), pls refer to https://gist.github.com/LayZeeDK/c822cc812f75bb07b7c55d07ba2719b3`
|
|
90
88
|
);
|
|
91
89
|
}
|
|
92
90
|
|
|
93
91
|
const pkg = readPackage(tree);
|
|
94
92
|
|
|
95
93
|
if (pkg.devDependencies['ng-alain']) {
|
|
96
|
-
throw new
|
|
94
|
+
throw new SchematicsException(`Already an NG-ALAIN project and can't be executed again: ng add ng-alain`);
|
|
97
95
|
}
|
|
98
96
|
|
|
99
97
|
let ngCoreVersion = pkg.dependencies['@angular/core'] as string;
|
|
100
98
|
if (/^[\^|\~]/g.test(ngCoreVersion)) {
|
|
101
|
-
ngCoreVersion = ngCoreVersion.
|
|
99
|
+
ngCoreVersion = ngCoreVersion.substring(1);
|
|
102
100
|
}
|
|
103
101
|
if (!ngCoreVersion.startsWith(`${V}.`)) {
|
|
104
|
-
throw new
|
|
102
|
+
throw new SchematicsException(
|
|
105
103
|
`Sorry, the current version only supports angular ${V}.x, pls downgrade the global Anguar-cli version: [yarn global add @angular/cli@${V}] (or via npm: [npm install -g @angular/cli@${V}])`
|
|
106
104
|
);
|
|
107
105
|
}
|
package/ng-add/schema.json
CHANGED
|
@@ -3,6 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.attributeSelectors = void 0;
|
|
4
4
|
const schematics_1 = require("@angular/cdk/schematics");
|
|
5
5
|
exports.attributeSelectors = {
|
|
6
|
-
[schematics_1.TargetVersion.
|
|
6
|
+
[schematics_1.TargetVersion.V13]: []
|
|
7
7
|
};
|
|
8
8
|
//# sourceMappingURL=attribute-selectors.js.map
|
|
@@ -3,6 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.classNames = void 0;
|
|
4
4
|
const schematics_1 = require("@angular/cdk/schematics");
|
|
5
5
|
exports.classNames = {
|
|
6
|
-
[schematics_1.TargetVersion.
|
|
6
|
+
[schematics_1.TargetVersion.V13]: []
|
|
7
7
|
};
|
|
8
8
|
//# sourceMappingURL=class-names.js.map
|
|
@@ -8,6 +8,6 @@ const schematics_1 = require("@angular/cdk/schematics");
|
|
|
8
8
|
* automatically through type checking.
|
|
9
9
|
*/
|
|
10
10
|
exports.constructorChecks = {
|
|
11
|
-
[schematics_1.TargetVersion.
|
|
11
|
+
[schematics_1.TargetVersion.V13]: []
|
|
12
12
|
};
|
|
13
13
|
//# sourceMappingURL=constructor-checks.js.map
|
|
@@ -3,6 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.cssSelectors = void 0;
|
|
4
4
|
const schematics_1 = require("@angular/cdk/schematics");
|
|
5
5
|
exports.cssSelectors = {
|
|
6
|
-
[schematics_1.TargetVersion.
|
|
6
|
+
[schematics_1.TargetVersion.V13]: []
|
|
7
7
|
};
|
|
8
8
|
//# sourceMappingURL=css-selectors.js.map
|
|
@@ -3,6 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.elementSelectors = void 0;
|
|
4
4
|
const schematics_1 = require("@angular/cdk/schematics");
|
|
5
5
|
exports.elementSelectors = {
|
|
6
|
-
[schematics_1.TargetVersion.
|
|
6
|
+
[schematics_1.TargetVersion.V13]: []
|
|
7
7
|
};
|
|
8
8
|
//# sourceMappingURL=element-selectors.js.map
|
|
@@ -3,6 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.inputNames = void 0;
|
|
4
4
|
const schematics_1 = require("@angular/cdk/schematics");
|
|
5
5
|
exports.inputNames = {
|
|
6
|
-
[schematics_1.TargetVersion.
|
|
6
|
+
[schematics_1.TargetVersion.V13]: []
|
|
7
7
|
};
|
|
8
8
|
//# sourceMappingURL=input-names.js.map
|
|
@@ -3,6 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.methodCallChecks = void 0;
|
|
4
4
|
const schematics_1 = require("@angular/cdk/schematics");
|
|
5
5
|
exports.methodCallChecks = {
|
|
6
|
-
[schematics_1.TargetVersion.
|
|
6
|
+
[schematics_1.TargetVersion.V13]: []
|
|
7
7
|
};
|
|
8
8
|
//# sourceMappingURL=method-call-checks.js.map
|
|
@@ -3,6 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.outputNames = void 0;
|
|
4
4
|
const schematics_1 = require("@angular/cdk/schematics");
|
|
5
5
|
exports.outputNames = {
|
|
6
|
-
[schematics_1.TargetVersion.
|
|
6
|
+
[schematics_1.TargetVersion.V13]: []
|
|
7
7
|
};
|
|
8
8
|
//# sourceMappingURL=output-names.js.map
|