@magic-xpa/cli 4.1100.0-dev4110.24 → 4.1100.0-dev4110.241
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/index.d.ts +1 -1
- package/index.js +4 -4
- package/package.json +2 -2
- package/src/public_api.d.ts +3 -3
- package/src/public_api.js +6 -6
- package/src/schematics/magic-utils/Util.d.ts +6 -6
- package/src/schematics/magic-utils/Util.js +26 -26
- package/src/schematics/magic-utils/config.d.ts +12 -12
- package/src/schematics/magic-utils/config.js +56 -56
- package/src/schematics/magic-utils/env.d.ts +23 -23
- package/src/schematics/magic-utils/env.js +39 -39
- package/src/schematics/magic-utils/env.js.map +1 -1
- package/src/schematics/magic-utils/env.ts +5 -5
- package/src/schematics/magic-utils/manifest.d.ts +11 -11
- package/src/schematics/magic-utils/manifest.js +40 -40
- package/src/schematics/magic-utils/manifest.js.map +1 -1
- package/src/schematics/magic-utils/metadata.class.d.ts +51 -51
- package/src/schematics/magic-utils/metadata.class.js +124 -124
- package/src/schematics/magic-utils/metadata.class.js.map +1 -1
- package/src/schematics/magic-utils/process-json.d.ts +2 -2
- package/src/schematics/magic-utils/process-json.js +158 -158
- package/src/schematics/magic-utils/process-json.js.map +1 -1
- package/src/schematics/magic-utils/rules/build-control.rule.d.ts +5 -5
- package/src/schematics/magic-utils/rules/build-control.rule.js +74 -74
- package/src/schematics/magic-utils/rules/build-control.rule.js.map +1 -1
- package/src/schematics/magic-utils/rules/build-view.rule.d.ts +3 -3
- package/src/schematics/magic-utils/rules/build-view.rule.js +83 -80
- package/src/schematics/magic-utils/rules/build-view.rule.js.map +1 -1
- package/src/schematics/magic-utils/rules/build-view.rule.ts +4 -0
- package/src/schematics/magic-utils/rules/component-list.rule.d.ts +3 -3
- package/src/schematics/magic-utils/rules/component-list.rule.js +317 -317
- package/src/schematics/magic-utils/rules/component-list.rule.js.map +1 -1
- package/src/schematics/magic-utils/rules/generate.rule.d.ts +5 -5
- package/src/schematics/magic-utils/rules/generate.rule.js +54 -54
- package/src/schematics/magic-utils/rules/generate.rule.js.map +1 -1
- package/src/schematics/magic-utils/rules/init-add-modules.rule.d.ts +12 -12
- package/src/schematics/magic-utils/rules/init-add-modules.rule.js +296 -296
- package/src/schematics/magic-utils/rules/init-add-modules.rule.js.map +1 -1
- package/src/schematics/magic-utils/rules/init-gen-components.rule.d.ts +4 -4
- package/src/schematics/magic-utils/rules/init-gen-components.rule.js +66 -66
- package/src/schematics/magic-utils/rules/init-gen-components.rule.js.map +1 -1
- package/src/schematics/magic-utils/rules/init-magic-metadata.rule.d.ts +3 -3
- package/src/schematics/magic-utils/rules/init-magic-metadata.rule.js +18 -18
- package/src/schematics/magic-utils/rules/init-magic-metadata.rule.js.map +1 -1
- package/src/schematics/magic-utils/rules/load-views-gen.rule.d.ts +3 -3
- package/src/schematics/magic-utils/rules/load-views-gen.rule.js +29 -29
- package/src/schematics/magic-utils/rules/magic-option.scheme.d.ts +22 -21
- package/src/schematics/magic-utils/rules/magic-option.scheme.js +2 -2
- package/src/schematics/magic-utils/rules/magic-option.scheme.js.map +1 -1
- package/src/schematics/magic-utils/rules/magic-option.scheme.ts +1 -0
- package/src/schematics/magic-utils/utils.d.ts +12 -12
- package/src/schematics/magic-utils/utils.js +117 -117
- package/src/schematics/magic-utils/utils.js.map +1 -1
- package/src/schematics/mg-Install-prerequisites/index.d.ts +3 -3
- package/src/schematics/mg-Install-prerequisites/index.js +25 -25
- package/src/schematics/mg-Install-prerequisites/index.js.map +1 -1
- package/src/schematics/mg-add/files/src/app/magic/lazy-loader.service.ts +1 -1
- package/src/schematics/mg-add/files/src/app/magic/magic.gen.lib.module.ts +19 -19
- package/src/schematics/mg-add/files/src/magic-styles.css +2 -2
- package/src/schematics/mg-add/index.d.ts +3 -3
- package/src/schematics/mg-add/index.js +151 -151
- package/src/schematics/mg-add/index.js.map +1 -1
- package/src/schematics/mg-add/utils/add-declaration-to-root-module.d.ts +2 -2
- package/src/schematics/mg-add/utils/add-declaration-to-root-module.js +11 -11
- package/src/schematics/mg-add-tasks/index.d.ts +3 -3
- package/src/schematics/mg-add-tasks/index.js +30 -30
- package/src/schematics/mg-delete-files/index.d.ts +3 -3
- package/src/schematics/mg-delete-files/index.js +13 -13
- package/src/schematics/mg-gen-module/index.d.ts +3 -3
- package/src/schematics/mg-gen-module/index.js +15 -15
- package/src/schematics/mg-generate/index.d.ts +3 -3
- package/src/schematics/mg-generate/index.js +13 -13
- package/src/schematics/mg-generate-component/index.d.ts +3 -3
- package/src/schematics/mg-generate-component/index.js +35 -35
- package/src/schematics/mg-generate-component/index.js.map +1 -1
- package/src/schematics/mg-generate-component/schema.json +6 -0
- package/src/schematics/mg-install/index.d.ts +3 -3
- package/src/schematics/mg-install/index.js +30 -30
- package/src/schematics/mg-install/index.js.map +1 -1
- package/src/schematics/mg-routes/index.d.ts +6 -6
- package/src/schematics/mg-routes/index.js +63 -63
- package/src/schematics/mg-routes/index.js.map +1 -1
- package/src/schematics/mg-single-control/index.d.ts +3 -3
- package/src/schematics/mg-single-control/index.js +29 -29
- package/src/schematics/utils/ast.d.ts +21 -21
- package/src/schematics/utils/ast.js +91 -91
- package/src/schematics/utils/ast.js.map +1 -1
- package/src/schematics/utils/ast.ts +1 -1
- package/src/schematics/utils/devkit-utils/ast-utils.d.ts +87 -87
- package/src/schematics/utils/devkit-utils/ast-utils.js +490 -490
- package/src/schematics/utils/devkit-utils/ast-utils.js.map +1 -1
- package/src/schematics/utils/devkit-utils/ast-utils_old.d.ts +68 -68
- package/src/schematics/utils/devkit-utils/ast-utils_old.js +420 -420
- package/src/schematics/utils/devkit-utils/ast-utils_old.js.map +1 -1
- package/src/schematics/utils/devkit-utils/change.d.ts +66 -66
- package/src/schematics/utils/devkit-utils/change.js +94 -94
- package/src/schematics/utils/devkit-utils/change.js.map +1 -1
- package/src/schematics/utils/devkit-utils/component.d.ts +2 -2
- package/src/schematics/utils/devkit-utils/component.js +97 -97
- package/src/schematics/utils/devkit-utils/component.js.map +1 -1
- package/src/schematics/utils/devkit-utils/config.d.ts +78 -78
- package/src/schematics/utils/devkit-utils/config.js +52 -52
- package/src/schematics/utils/devkit-utils/config.js.map +1 -1
- package/src/schematics/utils/devkit-utils/find-module.d.ts +28 -28
- package/src/schematics/utils/devkit-utils/find-module.js +93 -93
- package/src/schematics/utils/devkit-utils/find-module.js.map +1 -1
- package/src/schematics/utils/devkit-utils/ng-ast-utils.d.ts +5 -5
- package/src/schematics/utils/devkit-utils/ng-ast-utils.js +74 -74
- package/src/schematics/utils/devkit-utils/ng-ast-utils.js.map +1 -1
- package/src/schematics/utils/devkit-utils/parse-name.d.ts +13 -13
- package/src/schematics/utils/devkit-utils/parse-name.js +20 -20
- package/src/schematics/utils/devkit-utils/route-utils.d.ts +20 -20
- package/src/schematics/utils/devkit-utils/route-utils.js +134 -134
- package/src/schematics/utils/devkit-utils/route-utils.js.map +1 -1
- package/src/schematics/utils/devkit-utils/validation.d.ts +1 -1
- package/src/schematics/utils/devkit-utils/validation.js +18 -18
- package/src/schematics/utils/devkit-utils/validation.js.map +1 -1
- package/src/schematics/utils/html.d.ts +18 -18
- package/src/schematics/utils/html.js +60 -60
- package/src/schematics/utils/html.js.map +1 -1
- package/src/schematics/utils/lib-versions.d.ts +3 -3
- package/src/schematics/utils/lib-versions.js +6 -6
- package/src/schematics/utils/package.d.ts +5 -5
- package/src/schematics/utils/package.js +21 -21
- package/src/schematics/utils/package.js.map +1 -1
- package/src/schematics/utils/testing.d.ts +5 -5
- package/src/schematics/utils/testing.js +27 -27
- package/src/schematics/utils/testing.js.map +1 -1
- package/src/schematics/utils/testing.ts +2 -2
- package/src/types/enums/Enums.d.ts +1646 -1646
- package/src/types/enums/Enums.js +1862 -1862
- package/src/types/enums/Enums.js.map +1 -1
- package/src/types/enums/generated-file-types.enum.d.ts +6 -6
- package/src/types/enums/generated-file-types.enum.js +10 -10
- package/src/types/enums/generated-file-types.enum.js.map +1 -1
- package/src/types/enums/horizontal-alignments.enum.d.ts +5 -5
- package/src/types/enums/horizontal-alignments.enum.js +9 -9
- package/src/types/enums/horizontal-alignments.enum.js.map +1 -1
- package/src/types/enums/themes.enum.d.ts +6 -6
- package/src/types/enums/themes.enum.js +10 -10
- package/src/types/enums/themes.enum.js.map +1 -1
- package/src/types/index.d.ts +7 -7
- package/src/types/index.js +10 -10
- package/src/types/interfaces/app.d.ts +53 -53
- package/src/types/interfaces/app.js +9 -9
- package/src/types/interfaces/control.d.ts +82 -82
- package/src/types/interfaces/control.js +2 -2
- package/src/types/interfaces/env.interface.d.ts +19 -19
- package/src/types/interfaces/env.interface.js +10 -10
- package/src/types/interfaces/template.config.d.ts +8 -8
- package/src/types/interfaces/template.config.js +2 -2
- package/templates/component/view.component.ts +2 -1
- package/templates/themes/basicHTML/checkbox.ejs +1 -1
- package/templates/themes/basicHTML/edit.ejs +2 -1
- package/templates/themes/basicHTML/label.ejs +1 -1
- package/templates/themes/material/checkbox.ejs +1 -1
- package/templates/themes/material/listbox.ejs +0 -1
- package/templates/themes/table/HTMLTable/columnHeader.ejs +3 -1
- package/templates/themes/table/grid/column.ejs +3 -1
|
@@ -1,98 +1,98 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.buildComponent = void 0;
|
|
4
|
-
const core_1 = require("@angular-devkit/core");
|
|
5
|
-
const schematics_1 = require("@angular-devkit/schematics");
|
|
6
|
-
const ts = require("typescript");
|
|
7
|
-
const ast_utils_1 = require("./ast-utils");
|
|
8
|
-
const change_1 = require("./change");
|
|
9
|
-
const find_module_1 = require("./find-module");
|
|
10
|
-
const config_1 = require("./config");
|
|
11
|
-
const parse_name_1 = require("./parse-name");
|
|
12
|
-
const validation_1 = require("./validation");
|
|
13
|
-
function addDeclarationToNgModule(options) {
|
|
14
|
-
return (host) => {
|
|
15
|
-
if (options.skipImport || !options.module) {
|
|
16
|
-
return host;
|
|
17
|
-
}
|
|
18
|
-
const modulePath = options.module;
|
|
19
|
-
const text = host.read(modulePath);
|
|
20
|
-
if (text === null) {
|
|
21
|
-
throw new schematics_1.SchematicsException(`File ${modulePath} does not exist.`);
|
|
22
|
-
}
|
|
23
|
-
const sourceText = text.toString('utf-8');
|
|
24
|
-
const source = ts.createSourceFile(modulePath, sourceText, ts.ScriptTarget.Latest, true);
|
|
25
|
-
const componentPath = `/${options.path}/`
|
|
26
|
-
+ (options.flat ? '' : core_1.strings.dasherize(options.name) + '/')
|
|
27
|
-
+ core_1.strings.dasherize(options.name)
|
|
28
|
-
+ '.component';
|
|
29
|
-
const relativePath = (0, find_module_1.buildRelativePath)(modulePath, componentPath);
|
|
30
|
-
const classifiedName = core_1.strings.classify(`${options.name}Component`);
|
|
31
|
-
const declarationChanges = (0, ast_utils_1.addDeclarationToModule)(source, modulePath, classifiedName, relativePath);
|
|
32
|
-
const declarationRecorder = host.beginUpdate(modulePath);
|
|
33
|
-
for (const change of declarationChanges) {
|
|
34
|
-
if (change instanceof change_1.InsertChange) {
|
|
35
|
-
declarationRecorder.insertLeft(change.pos, change.toAdd);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
host.commitUpdate(declarationRecorder);
|
|
39
|
-
if (options.export) {
|
|
40
|
-
// Need to refresh the AST because we overwrote the file in the host.
|
|
41
|
-
const text = host.read(modulePath);
|
|
42
|
-
if (text === null) {
|
|
43
|
-
throw new schematics_1.SchematicsException(`File ${modulePath} does not exist.`);
|
|
44
|
-
}
|
|
45
|
-
const sourceText = text.toString('utf-8');
|
|
46
|
-
const source = ts.createSourceFile(modulePath, sourceText, ts.ScriptTarget.Latest, true);
|
|
47
|
-
const exportRecorder = host.beginUpdate(modulePath);
|
|
48
|
-
const exportChanges = (0, ast_utils_1.addExportToModule)(source, modulePath, core_1.strings.classify(`${options.name}Component`), relativePath);
|
|
49
|
-
for (const change of exportChanges) {
|
|
50
|
-
if (change instanceof change_1.InsertChange) {
|
|
51
|
-
exportRecorder.insertLeft(change.pos, change.toAdd);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
host.commitUpdate(exportRecorder);
|
|
55
|
-
}
|
|
56
|
-
return host;
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
function buildSelector(options) {
|
|
60
|
-
let selector = core_1.strings.dasherize(options.name);
|
|
61
|
-
if (options.prefix) {
|
|
62
|
-
selector = `${options.prefix}-${selector}`;
|
|
63
|
-
}
|
|
64
|
-
return selector;
|
|
65
|
-
}
|
|
66
|
-
function buildComponent(options) {
|
|
67
|
-
return (host, context) => {
|
|
68
|
-
const workspace = (0, config_1.getWorkspace)(host);
|
|
69
|
-
if (!options.project) {
|
|
70
|
-
options.project = Object.keys(workspace.projects)[0];
|
|
71
|
-
}
|
|
72
|
-
const project = workspace.projects[options.project];
|
|
73
|
-
if (options.path === undefined) {
|
|
74
|
-
options.path = `/${project.root}/src/app`;
|
|
75
|
-
}
|
|
76
|
-
options.selector = options.selector || buildSelector(options);
|
|
77
|
-
options.module = (0, find_module_1.findModuleFromOptions)(host, options);
|
|
78
|
-
const parsedPath = (0, parse_name_1.parseName)(options.path, options.name);
|
|
79
|
-
options.name = parsedPath.name;
|
|
80
|
-
options.path = parsedPath.path;
|
|
81
|
-
(0, validation_1.validateName)(options.name);
|
|
82
|
-
const templateSource = (0, schematics_1.apply)((0, schematics_1.url)('./files'), [
|
|
83
|
-
options.spec ? (0, schematics_1.noop)() : (0, schematics_1.filter)(path => !path.endsWith('.spec.ts')),
|
|
84
|
-
options.inlineStyle ? (0, schematics_1.filter)(path => !path.endsWith('.__styleext__')) : (0, schematics_1.noop)(),
|
|
85
|
-
options.inlineTemplate ? (0, schematics_1.filter)(path => !path.endsWith('.html')) : (0, schematics_1.noop)(),
|
|
86
|
-
(0, schematics_1.template)(Object.assign(Object.assign(Object.assign({}, core_1.strings), { 'if-flat': (s) => options.flat ? '' : s }), options)),
|
|
87
|
-
(0, schematics_1.move)(null, parsedPath.path),
|
|
88
|
-
]);
|
|
89
|
-
return (0, schematics_1.chain)([
|
|
90
|
-
(0, schematics_1.branchAndMerge)((0, schematics_1.chain)([
|
|
91
|
-
addDeclarationToNgModule(options),
|
|
92
|
-
(0, schematics_1.mergeWith)(templateSource),
|
|
93
|
-
])),
|
|
94
|
-
])(host, context);
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
exports.buildComponent = buildComponent;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildComponent = void 0;
|
|
4
|
+
const core_1 = require("@angular-devkit/core");
|
|
5
|
+
const schematics_1 = require("@angular-devkit/schematics");
|
|
6
|
+
const ts = require("typescript");
|
|
7
|
+
const ast_utils_1 = require("./ast-utils");
|
|
8
|
+
const change_1 = require("./change");
|
|
9
|
+
const find_module_1 = require("./find-module");
|
|
10
|
+
const config_1 = require("./config");
|
|
11
|
+
const parse_name_1 = require("./parse-name");
|
|
12
|
+
const validation_1 = require("./validation");
|
|
13
|
+
function addDeclarationToNgModule(options) {
|
|
14
|
+
return (host) => {
|
|
15
|
+
if (options.skipImport || !options.module) {
|
|
16
|
+
return host;
|
|
17
|
+
}
|
|
18
|
+
const modulePath = options.module;
|
|
19
|
+
const text = host.read(modulePath);
|
|
20
|
+
if (text === null) {
|
|
21
|
+
throw new schematics_1.SchematicsException(`File ${modulePath} does not exist.`);
|
|
22
|
+
}
|
|
23
|
+
const sourceText = text.toString('utf-8');
|
|
24
|
+
const source = ts.createSourceFile(modulePath, sourceText, ts.ScriptTarget.Latest, true);
|
|
25
|
+
const componentPath = `/${options.path}/`
|
|
26
|
+
+ (options.flat ? '' : core_1.strings.dasherize(options.name) + '/')
|
|
27
|
+
+ core_1.strings.dasherize(options.name)
|
|
28
|
+
+ '.component';
|
|
29
|
+
const relativePath = (0, find_module_1.buildRelativePath)(modulePath, componentPath);
|
|
30
|
+
const classifiedName = core_1.strings.classify(`${options.name}Component`);
|
|
31
|
+
const declarationChanges = (0, ast_utils_1.addDeclarationToModule)(source, modulePath, classifiedName, relativePath);
|
|
32
|
+
const declarationRecorder = host.beginUpdate(modulePath);
|
|
33
|
+
for (const change of declarationChanges) {
|
|
34
|
+
if (change instanceof change_1.InsertChange) {
|
|
35
|
+
declarationRecorder.insertLeft(change.pos, change.toAdd);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
host.commitUpdate(declarationRecorder);
|
|
39
|
+
if (options.export) {
|
|
40
|
+
// Need to refresh the AST because we overwrote the file in the host.
|
|
41
|
+
const text = host.read(modulePath);
|
|
42
|
+
if (text === null) {
|
|
43
|
+
throw new schematics_1.SchematicsException(`File ${modulePath} does not exist.`);
|
|
44
|
+
}
|
|
45
|
+
const sourceText = text.toString('utf-8');
|
|
46
|
+
const source = ts.createSourceFile(modulePath, sourceText, ts.ScriptTarget.Latest, true);
|
|
47
|
+
const exportRecorder = host.beginUpdate(modulePath);
|
|
48
|
+
const exportChanges = (0, ast_utils_1.addExportToModule)(source, modulePath, core_1.strings.classify(`${options.name}Component`), relativePath);
|
|
49
|
+
for (const change of exportChanges) {
|
|
50
|
+
if (change instanceof change_1.InsertChange) {
|
|
51
|
+
exportRecorder.insertLeft(change.pos, change.toAdd);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
host.commitUpdate(exportRecorder);
|
|
55
|
+
}
|
|
56
|
+
return host;
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
function buildSelector(options) {
|
|
60
|
+
let selector = core_1.strings.dasherize(options.name);
|
|
61
|
+
if (options.prefix) {
|
|
62
|
+
selector = `${options.prefix}-${selector}`;
|
|
63
|
+
}
|
|
64
|
+
return selector;
|
|
65
|
+
}
|
|
66
|
+
function buildComponent(options) {
|
|
67
|
+
return (host, context) => {
|
|
68
|
+
const workspace = (0, config_1.getWorkspace)(host);
|
|
69
|
+
if (!options.project) {
|
|
70
|
+
options.project = Object.keys(workspace.projects)[0];
|
|
71
|
+
}
|
|
72
|
+
const project = workspace.projects[options.project];
|
|
73
|
+
if (options.path === undefined) {
|
|
74
|
+
options.path = `/${project.root}/src/app`;
|
|
75
|
+
}
|
|
76
|
+
options.selector = options.selector || buildSelector(options);
|
|
77
|
+
options.module = (0, find_module_1.findModuleFromOptions)(host, options);
|
|
78
|
+
const parsedPath = (0, parse_name_1.parseName)(options.path, options.name);
|
|
79
|
+
options.name = parsedPath.name;
|
|
80
|
+
options.path = parsedPath.path;
|
|
81
|
+
(0, validation_1.validateName)(options.name);
|
|
82
|
+
const templateSource = (0, schematics_1.apply)((0, schematics_1.url)('./files'), [
|
|
83
|
+
options.spec ? (0, schematics_1.noop)() : (0, schematics_1.filter)(path => !path.endsWith('.spec.ts')),
|
|
84
|
+
options.inlineStyle ? (0, schematics_1.filter)(path => !path.endsWith('.__styleext__')) : (0, schematics_1.noop)(),
|
|
85
|
+
options.inlineTemplate ? (0, schematics_1.filter)(path => !path.endsWith('.html')) : (0, schematics_1.noop)(),
|
|
86
|
+
(0, schematics_1.template)(Object.assign(Object.assign(Object.assign({}, core_1.strings), { 'if-flat': (s) => options.flat ? '' : s }), options)),
|
|
87
|
+
(0, schematics_1.move)(null, parsedPath.path),
|
|
88
|
+
]);
|
|
89
|
+
return (0, schematics_1.chain)([
|
|
90
|
+
(0, schematics_1.branchAndMerge)((0, schematics_1.chain)([
|
|
91
|
+
addDeclarationToNgModule(options),
|
|
92
|
+
(0, schematics_1.mergeWith)(templateSource),
|
|
93
|
+
])),
|
|
94
|
+
])(host, context);
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
exports.buildComponent = buildComponent;
|
|
98
98
|
//# sourceMappingURL=component.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component.js","sourceRoot":"","sources":["component.ts"],"names":[],"mappings":";;;AAAA,+CAAwD;AACxD,2DAcoC;AACpC,iCAAiC;AACjC,2CAAsE;AACtE,qCAAsC;AACtC,+CAAuE;AACvE,qCAAsC;AACtC,6CAAuC;AACvC,6CAA0C;AAE1C,SAAS,wBAAwB,CAAC,O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BACjC,IAAA,sBAAS,EAAC,cAAc,CAAC;aAC1B,CAAC,CAAC;SACJ,CAAC,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACpB,CAAC,CAAC;AACJ,CAAC;AAxCD,wCAwCC","sourcesContent":["import {normalize, strings} from '@angular-devkit/core';\nimport {\n apply,\n branchAndMerge,\n chain,\n filter,\n mergeWith,\n move,\n noop,\n Rule,\n SchematicContext,\n SchematicsException,\n template,\n Tree,\n url,\n} from '@angular-devkit/schematics';\nimport * as ts from 'typescript';\nimport {addDeclarationToModule, addExportToModule} from './ast-utils';\nimport {InsertChange} from './change';\nimport {buildRelativePath, findModuleFromOptions} from './find-module';\nimport {getWorkspace} from './config';\nimport {parseName} from './parse-name';\nimport {validateName} from './validation';\n\nfunction addDeclarationToNgModule(options: any): Rule {\n return (host: Tree) => {\n if (options.skipImport || !options.module) {\n return host;\n }\n\n const modulePath = options.module;\n const text = host.read(modulePath);\n if (text === null) {\n throw new SchematicsException(`File ${modulePath} does not exist.`);\n }\n const sourceText = text.toString('utf-8');\n const source = ts.createSourceFile(modulePath, sourceText, ts.ScriptTarget.Latest, true);\n\n const componentPath = `/${options.path}/`\n + (options.flat ? '' : strings.dasherize(options.name) + '/')\n + strings.dasherize(options.name)\n + '.component';\n const relativePath = buildRelativePath(modulePath, componentPath);\n const classifiedName = strings.classify(`${options.name}Component`);\n const declarationChanges = addDeclarationToModule(source,\n modulePath,\n classifiedName,\n relativePath);\n\n const declarationRecorder = host.beginUpdate(modulePath);\n for (const change of declarationChanges) {\n if (change instanceof InsertChange) {\n declarationRecorder.insertLeft(change.pos, change.toAdd);\n }\n }\n host.commitUpdate(declarationRecorder);\n\n if (options.export) {\n // Need to refresh the AST because we overwrote the file in the host.\n const text = host.read(modulePath);\n if (text === null) {\n throw new SchematicsException(`File ${modulePath} does not exist.`);\n }\n const sourceText = text.toString('utf-8');\n const source = ts.createSourceFile(modulePath, sourceText, ts.ScriptTarget.Latest, true);\n\n const exportRecorder = host.beginUpdate(modulePath);\n const exportChanges = addExportToModule(source, modulePath,\n strings.classify(`${options.name}Component`),\n relativePath);\n\n for (const change of exportChanges) {\n if (change instanceof InsertChange) {\n exportRecorder.insertLeft(change.pos, change.toAdd);\n }\n }\n host.commitUpdate(exportRecorder);\n }\n\n\n return host;\n };\n}\n\n\nfunction buildSelector(options: any) {\n let selector = strings.dasherize(options.name);\n if (options.prefix) {\n selector = `${options.prefix}-${selector}`;\n }\n\n return selector;\n}\n\n\nexport function buildComponent(options: any): Rule {\n return (host: Tree, context: SchematicContext) => {\n const workspace = getWorkspace(host);\n if (!options.project) {\n options.project = Object.keys(workspace.projects)[0];\n }\n const project = workspace.projects[options.project];\n\n if (options.path === undefined) {\n options.path = `/${project.root}/src/app`;\n }\n\n options.selector = options.selector || buildSelector(options);\n options.module = findModuleFromOptions(host, options);\n\n const parsedPath = parseName(options.path, options.name);\n options.name = parsedPath.name;\n options.path = parsedPath.path;\n\n validateName(options.name);\n\n const templateSource = apply(url('./files'), [\n options.spec ? noop() : filter(path => !path.endsWith('.spec.ts')),\n options.inlineStyle ? filter(path => !path.endsWith('.__styleext__')) : noop(),\n options.inlineTemplate ? filter(path => !path.endsWith('.html')) : noop(),\n template({\n ...strings,\n 'if-flat': (s: string) => options.flat ? '' : s,\n ...options,\n }),\n move(null, parsedPath.path),\n ]);\n\n return chain([\n branchAndMerge(chain([\n addDeclarationToNgModule(options),\n mergeWith(templateSource),\n ])),\n ])(host, context);\n };\n}\n"]}
|
|
@@ -1,78 +1,78 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright Google Inc. 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.io/license
|
|
7
|
-
*/
|
|
8
|
-
import { Tree } from '@angular-devkit/schematics';
|
|
9
|
-
export declare const ANGULAR_CLI_WORKSPACE_PATH = "/angular.json";
|
|
10
|
-
/** An Angular CLI Workspacer config (angular.json) */
|
|
11
|
-
export interface Workspace {
|
|
12
|
-
/** Link to schema. */
|
|
13
|
-
$schema?: string;
|
|
14
|
-
/** Workspace Schema version. */
|
|
15
|
-
version: number;
|
|
16
|
-
/** New project root. */
|
|
17
|
-
newProjectRoot?: string;
|
|
18
|
-
/** Tool options. */
|
|
19
|
-
cli?: {
|
|
20
|
-
/** Link to schema. */
|
|
21
|
-
$schema?: string;
|
|
22
|
-
[k: string]: any;
|
|
23
|
-
};
|
|
24
|
-
/** Tool options. */
|
|
25
|
-
schematics?: {
|
|
26
|
-
/** Link to schema. */
|
|
27
|
-
$schema?: string;
|
|
28
|
-
[k: string]: any;
|
|
29
|
-
};
|
|
30
|
-
/** Tool options. */
|
|
31
|
-
architect?: {
|
|
32
|
-
/** Link to schema. */
|
|
33
|
-
$schema?: string;
|
|
34
|
-
[k: string]: any;
|
|
35
|
-
};
|
|
36
|
-
/** A map of project names to project options. */
|
|
37
|
-
projects: {
|
|
38
|
-
[k: string]: Project;
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* A project in an Angular CLI workspace (e.g. an app or a library). A single workspace
|
|
43
|
-
* can house multiple projects.
|
|
44
|
-
*/
|
|
45
|
-
export interface Project {
|
|
46
|
-
name: string;
|
|
47
|
-
/** Project type. */
|
|
48
|
-
projectType: 'application' | 'library';
|
|
49
|
-
/** Root of the project sourcefiles. */
|
|
50
|
-
root: string;
|
|
51
|
-
/** Tool options. */
|
|
52
|
-
cli?: {
|
|
53
|
-
/** Link to schema. */
|
|
54
|
-
$schema?: string;
|
|
55
|
-
[k: string]: any;
|
|
56
|
-
};
|
|
57
|
-
/** Tool options. */
|
|
58
|
-
schematics?: {
|
|
59
|
-
/** Link to schema. */
|
|
60
|
-
$schema?: string;
|
|
61
|
-
[k: string]: any;
|
|
62
|
-
};
|
|
63
|
-
/** Tool options. */
|
|
64
|
-
architect?: ProjectBuildOptions;
|
|
65
|
-
}
|
|
66
|
-
/** Architect options for an Angular CLI workspace. */
|
|
67
|
-
export interface ProjectBuildOptions {
|
|
68
|
-
/** Link to schema. */
|
|
69
|
-
$schema?: string;
|
|
70
|
-
[k: string]: any;
|
|
71
|
-
}
|
|
72
|
-
/** Gets the Angular CLI workspace config (angular.json) */
|
|
73
|
-
export declare function getWorkspace(host: Tree): Workspace;
|
|
74
|
-
/**
|
|
75
|
-
* Gets a project from the Angular CLI workspace. If no project name is given, the first project
|
|
76
|
-
* will be retrieved.
|
|
77
|
-
*/
|
|
78
|
-
export declare function getProjectFromWorkspace(config: Workspace, projectName?: string): Project;
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright Google Inc. 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.io/license
|
|
7
|
+
*/
|
|
8
|
+
import { Tree } from '@angular-devkit/schematics';
|
|
9
|
+
export declare const ANGULAR_CLI_WORKSPACE_PATH = "/angular.json";
|
|
10
|
+
/** An Angular CLI Workspacer config (angular.json) */
|
|
11
|
+
export interface Workspace {
|
|
12
|
+
/** Link to schema. */
|
|
13
|
+
$schema?: string;
|
|
14
|
+
/** Workspace Schema version. */
|
|
15
|
+
version: number;
|
|
16
|
+
/** New project root. */
|
|
17
|
+
newProjectRoot?: string;
|
|
18
|
+
/** Tool options. */
|
|
19
|
+
cli?: {
|
|
20
|
+
/** Link to schema. */
|
|
21
|
+
$schema?: string;
|
|
22
|
+
[k: string]: any;
|
|
23
|
+
};
|
|
24
|
+
/** Tool options. */
|
|
25
|
+
schematics?: {
|
|
26
|
+
/** Link to schema. */
|
|
27
|
+
$schema?: string;
|
|
28
|
+
[k: string]: any;
|
|
29
|
+
};
|
|
30
|
+
/** Tool options. */
|
|
31
|
+
architect?: {
|
|
32
|
+
/** Link to schema. */
|
|
33
|
+
$schema?: string;
|
|
34
|
+
[k: string]: any;
|
|
35
|
+
};
|
|
36
|
+
/** A map of project names to project options. */
|
|
37
|
+
projects: {
|
|
38
|
+
[k: string]: Project;
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* A project in an Angular CLI workspace (e.g. an app or a library). A single workspace
|
|
43
|
+
* can house multiple projects.
|
|
44
|
+
*/
|
|
45
|
+
export interface Project {
|
|
46
|
+
name: string;
|
|
47
|
+
/** Project type. */
|
|
48
|
+
projectType: 'application' | 'library';
|
|
49
|
+
/** Root of the project sourcefiles. */
|
|
50
|
+
root: string;
|
|
51
|
+
/** Tool options. */
|
|
52
|
+
cli?: {
|
|
53
|
+
/** Link to schema. */
|
|
54
|
+
$schema?: string;
|
|
55
|
+
[k: string]: any;
|
|
56
|
+
};
|
|
57
|
+
/** Tool options. */
|
|
58
|
+
schematics?: {
|
|
59
|
+
/** Link to schema. */
|
|
60
|
+
$schema?: string;
|
|
61
|
+
[k: string]: any;
|
|
62
|
+
};
|
|
63
|
+
/** Tool options. */
|
|
64
|
+
architect?: ProjectBuildOptions;
|
|
65
|
+
}
|
|
66
|
+
/** Architect options for an Angular CLI workspace. */
|
|
67
|
+
export interface ProjectBuildOptions {
|
|
68
|
+
/** Link to schema. */
|
|
69
|
+
$schema?: string;
|
|
70
|
+
[k: string]: any;
|
|
71
|
+
}
|
|
72
|
+
/** Gets the Angular CLI workspace config (angular.json) */
|
|
73
|
+
export declare function getWorkspace(host: Tree): Workspace;
|
|
74
|
+
/**
|
|
75
|
+
* Gets a project from the Angular CLI workspace. If no project name is given, the first project
|
|
76
|
+
* will be retrieved.
|
|
77
|
+
*/
|
|
78
|
+
export declare function getProjectFromWorkspace(config: Workspace, projectName?: string): Project;
|
|
@@ -1,53 +1,53 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getProjectFromWorkspace = exports.getWorkspace = exports.ANGULAR_CLI_WORKSPACE_PATH = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* @license
|
|
6
|
-
* Copyright Google Inc. All Rights Reserved.
|
|
7
|
-
*
|
|
8
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
9
|
-
* found in the LICENSE file at https://angular.io/license
|
|
10
|
-
*/
|
|
11
|
-
const schematics_1 = require("@angular-devkit/schematics");
|
|
12
|
-
exports.ANGULAR_CLI_WORKSPACE_PATH = '/angular.json';
|
|
13
|
-
/** Gets the Angular CLI workspace config (angular.json) */
|
|
14
|
-
function getWorkspace(host) {
|
|
15
|
-
const configBuffer = host.read(exports.ANGULAR_CLI_WORKSPACE_PATH);
|
|
16
|
-
if (configBuffer === null) {
|
|
17
|
-
throw new schematics_1.SchematicsException('Could not find angular.json');
|
|
18
|
-
}
|
|
19
|
-
return JSON.parse(configBuffer.toString());
|
|
20
|
-
}
|
|
21
|
-
exports.getWorkspace = getWorkspace;
|
|
22
|
-
/**
|
|
23
|
-
* Gets a project from the Angular CLI workspace. If no project name is given, the first project
|
|
24
|
-
* will be retrieved.
|
|
25
|
-
*/
|
|
26
|
-
function getProjectFromWorkspace(config, projectName) {
|
|
27
|
-
if (config.projects) {
|
|
28
|
-
if (projectName) {
|
|
29
|
-
const project = config.projects[projectName];
|
|
30
|
-
if (!project) {
|
|
31
|
-
throw new schematics_1.SchematicsException(`No project named "${projectName}" exists.`);
|
|
32
|
-
}
|
|
33
|
-
Object.defineProperty(project, 'name', { enumerable: false, value: projectName });
|
|
34
|
-
return project;
|
|
35
|
-
}
|
|
36
|
-
// If there is exactly one non-e2e project, use that. Otherwise, require that a specific
|
|
37
|
-
// project be specified.
|
|
38
|
-
const allProjectNames = Object.keys(config.projects).filter(p => !p.includes('e2e'));
|
|
39
|
-
if (allProjectNames.length === 1) {
|
|
40
|
-
const project = config.projects[allProjectNames[0]];
|
|
41
|
-
// Set a non-enumerable project name to the project. We need the name for schematics
|
|
42
|
-
// later on, but don't want to write it back out to the config file.
|
|
43
|
-
Object.defineProperty(project, 'name', { enumerable: false, value: projectName });
|
|
44
|
-
return project;
|
|
45
|
-
}
|
|
46
|
-
else {
|
|
47
|
-
throw new schematics_1.SchematicsException('Multiple projects are defined; please specify a project name');
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
throw new schematics_1.SchematicsException('No projects are defined');
|
|
51
|
-
}
|
|
52
|
-
exports.getProjectFromWorkspace = getProjectFromWorkspace;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getProjectFromWorkspace = exports.getWorkspace = exports.ANGULAR_CLI_WORKSPACE_PATH = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* @license
|
|
6
|
+
* Copyright Google Inc. All Rights Reserved.
|
|
7
|
+
*
|
|
8
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
9
|
+
* found in the LICENSE file at https://angular.io/license
|
|
10
|
+
*/
|
|
11
|
+
const schematics_1 = require("@angular-devkit/schematics");
|
|
12
|
+
exports.ANGULAR_CLI_WORKSPACE_PATH = '/angular.json';
|
|
13
|
+
/** Gets the Angular CLI workspace config (angular.json) */
|
|
14
|
+
function getWorkspace(host) {
|
|
15
|
+
const configBuffer = host.read(exports.ANGULAR_CLI_WORKSPACE_PATH);
|
|
16
|
+
if (configBuffer === null) {
|
|
17
|
+
throw new schematics_1.SchematicsException('Could not find angular.json');
|
|
18
|
+
}
|
|
19
|
+
return JSON.parse(configBuffer.toString());
|
|
20
|
+
}
|
|
21
|
+
exports.getWorkspace = getWorkspace;
|
|
22
|
+
/**
|
|
23
|
+
* Gets a project from the Angular CLI workspace. If no project name is given, the first project
|
|
24
|
+
* will be retrieved.
|
|
25
|
+
*/
|
|
26
|
+
function getProjectFromWorkspace(config, projectName) {
|
|
27
|
+
if (config.projects) {
|
|
28
|
+
if (projectName) {
|
|
29
|
+
const project = config.projects[projectName];
|
|
30
|
+
if (!project) {
|
|
31
|
+
throw new schematics_1.SchematicsException(`No project named "${projectName}" exists.`);
|
|
32
|
+
}
|
|
33
|
+
Object.defineProperty(project, 'name', { enumerable: false, value: projectName });
|
|
34
|
+
return project;
|
|
35
|
+
}
|
|
36
|
+
// If there is exactly one non-e2e project, use that. Otherwise, require that a specific
|
|
37
|
+
// project be specified.
|
|
38
|
+
const allProjectNames = Object.keys(config.projects).filter(p => !p.includes('e2e'));
|
|
39
|
+
if (allProjectNames.length === 1) {
|
|
40
|
+
const project = config.projects[allProjectNames[0]];
|
|
41
|
+
// Set a non-enumerable project name to the project. We need the name for schematics
|
|
42
|
+
// later on, but don't want to write it back out to the config file.
|
|
43
|
+
Object.defineProperty(project, 'name', { enumerable: false, value: projectName });
|
|
44
|
+
return project;
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
throw new schematics_1.SchematicsException('Multiple projects are defined; please specify a project name');
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
throw new schematics_1.SchematicsException('No projects are defined');
|
|
51
|
+
}
|
|
52
|
+
exports.getProjectFromWorkspace = getProjectFromWorkspace;
|
|
53
53
|
//# sourceMappingURL=config.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["config.ts"],"names":[],"mappings":";;;AAAA;;;;;;GAMG;AACH,2DAAqE;AAExD,QAAA,0BAA0B,GAAG,eAAe,CAAC;AAqE1D,2DAA2D;AAC3D,SAAgB,YAAY,CAAC,IAAU;IACrC,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,kCAA0B,CAAC,CAAC;IAC3D,IAAI,YAAY,KAAK,IAAI,EAAE;
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["config.ts"],"names":[],"mappings":";;;AAAA;;;;;;GAMG;AACH,2DAAqE;AAExD,QAAA,0BAA0B,GAAG,eAAe,CAAC;AAqE1D,2DAA2D;AAC3D,SAAgB,YAAY,CAAC,IAAU;IACrC,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,kCAA0B,CAAC,CAAC;IAC3D,IAAI,YAAY,KAAK,IAAI,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CAAC;QAChG,CAAC;IACH,CAAC;IAED,MAAM,IAAI,gCAAmB,CAAC,yBAAyB,CAAC,CAAC;AAC3D,CAAC;AA3BD,0DA2BC","sourcesContent":["/**\n * @license\n * Copyright Google Inc. All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\nimport {SchematicsException, Tree} from '@angular-devkit/schematics';\n\nexport const ANGULAR_CLI_WORKSPACE_PATH = '/angular.json';\n\n\n/** An Angular CLI Workspacer config (angular.json) */\nexport interface Workspace {\n /** Link to schema. */\n $schema?: string;\n /** Workspace Schema version. */\n version: number;\n /** New project root. */\n newProjectRoot?: string;\n /** Tool options. */\n cli?: {\n /** Link to schema. */\n $schema?: string;\n [k: string]: any;\n };\n /** Tool options. */\n schematics?: {\n /** Link to schema. */\n $schema?: string;\n [k: string]: any;\n };\n /** Tool options. */\n architect?: {\n /** Link to schema. */\n $schema?: string;\n [k: string]: any;\n };\n /** A map of project names to project options. */\n projects: {\n [k: string]: Project;\n };\n}\n\n/**\n * A project in an Angular CLI workspace (e.g. an app or a library). A single workspace\n * can house multiple projects.\n */\nexport interface Project {\n name: string;\n\n /** Project type. */\n projectType: 'application' | 'library';\n /** Root of the project sourcefiles. */\n root: string;\n /** Tool options. */\n cli?: {\n /** Link to schema. */\n $schema?: string;\n [k: string]: any;\n };\n /** Tool options. */\n schematics?: {\n /** Link to schema. */\n $schema?: string;\n [k: string]: any;\n };\n /** Tool options. */\n architect?: ProjectBuildOptions;\n}\n\n/** Architect options for an Angular CLI workspace. */\nexport interface ProjectBuildOptions {\n /** Link to schema. */\n $schema?: string;\n [k: string]: any;\n}\n\n/** Gets the Angular CLI workspace config (angular.json) */\nexport function getWorkspace(host: Tree): Workspace {\n const configBuffer = host.read(ANGULAR_CLI_WORKSPACE_PATH);\n if (configBuffer === null) {\n throw new SchematicsException('Could not find angular.json');\n }\n\n return JSON.parse(configBuffer.toString());\n}\n\n/**\n * Gets a project from the Angular CLI workspace. If no project name is given, the first project\n * will be retrieved.\n */\nexport function getProjectFromWorkspace(config: Workspace, projectName?: string): Project {\n if (config.projects) {\n if (projectName) {\n const project = config.projects[projectName];\n if (!project) {\n throw new SchematicsException(`No project named \"${projectName}\" exists.`);\n }\n\n Object.defineProperty(project, 'name', {enumerable: false, value: projectName});\n return project;\n }\n\n // If there is exactly one non-e2e project, use that. Otherwise, require that a specific\n // project be specified.\n const allProjectNames = Object.keys(config.projects).filter(p => !p.includes('e2e'));\n if (allProjectNames.length === 1) {\n const project = config.projects[allProjectNames[0]];\n // Set a non-enumerable project name to the project. We need the name for schematics\n // later on, but don't want to write it back out to the config file.\n Object.defineProperty(project, 'name', {enumerable: false, value: projectName});\n return project;\n } else {\n throw new SchematicsException('Multiple projects are defined; please specify a project name');\n }\n }\n\n throw new SchematicsException('No projects are defined');\n}\n"]}
|
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright Google Inc. 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.io/license
|
|
7
|
-
*/
|
|
8
|
-
import { Path } from '@angular-devkit/core';
|
|
9
|
-
import { Tree } from '@angular-devkit/schematics';
|
|
10
|
-
export interface ModuleOptions {
|
|
11
|
-
module?: string;
|
|
12
|
-
name: string;
|
|
13
|
-
flat?: boolean;
|
|
14
|
-
path?: string;
|
|
15
|
-
skipImport?: boolean;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Find the module referred by a set of options passed to the schematics.
|
|
19
|
-
*/
|
|
20
|
-
export declare function findModuleFromOptions(host: Tree, options: ModuleOptions): Path | undefined;
|
|
21
|
-
/**
|
|
22
|
-
* Function to find the "closest" module to a generated file's path.
|
|
23
|
-
*/
|
|
24
|
-
export declare function findModule(host: Tree, generateDir: string): Path;
|
|
25
|
-
/**
|
|
26
|
-
* Build a relative path from one file path to another file path.
|
|
27
|
-
*/
|
|
28
|
-
export declare function buildRelativePath(from: string, to: string): string;
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright Google Inc. 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.io/license
|
|
7
|
+
*/
|
|
8
|
+
import { Path } from '@angular-devkit/core';
|
|
9
|
+
import { Tree } from '@angular-devkit/schematics';
|
|
10
|
+
export interface ModuleOptions {
|
|
11
|
+
module?: string;
|
|
12
|
+
name: string;
|
|
13
|
+
flat?: boolean;
|
|
14
|
+
path?: string;
|
|
15
|
+
skipImport?: boolean;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Find the module referred by a set of options passed to the schematics.
|
|
19
|
+
*/
|
|
20
|
+
export declare function findModuleFromOptions(host: Tree, options: ModuleOptions): Path | undefined;
|
|
21
|
+
/**
|
|
22
|
+
* Function to find the "closest" module to a generated file's path.
|
|
23
|
+
*/
|
|
24
|
+
export declare function findModule(host: Tree, generateDir: string): Path;
|
|
25
|
+
/**
|
|
26
|
+
* Build a relative path from one file path to another file path.
|
|
27
|
+
*/
|
|
28
|
+
export declare function buildRelativePath(from: string, to: string): string;
|