@magic-xpa/cli 4.1100.0-dev4110.24 → 4.1100.0-dev4110.240
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,92 +1,92 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.findModuleFromOptions = exports.getStylesPath = exports.getIndexHtmlPath = exports.addModuleImportToModule = exports.addModuleImportToRootModule = exports.getSourceFile = 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("./devkit-utils/ast-utils");
|
|
8
|
-
const change_1 = require("./devkit-utils/change");
|
|
9
|
-
const config_1 = require("./devkit-utils/config");
|
|
10
|
-
const ng_ast_utils_1 = require("./devkit-utils/ng-ast-utils");
|
|
11
|
-
const find_module_1 = require("./devkit-utils/find-module");
|
|
12
|
-
/** Reads file given path and returns TypeScript source file. */
|
|
13
|
-
function getSourceFile(host, path) {
|
|
14
|
-
const buffer = host.read(path);
|
|
15
|
-
if (!buffer) {
|
|
16
|
-
throw new schematics_1.SchematicsException(`Could not find file for path: ${path}`);
|
|
17
|
-
}
|
|
18
|
-
const content = buffer.toString();
|
|
19
|
-
return ts.createSourceFile(path, content, ts.ScriptTarget.Latest, true);
|
|
20
|
-
}
|
|
21
|
-
exports.getSourceFile = getSourceFile;
|
|
22
|
-
/** Import and add module to root app module. */
|
|
23
|
-
function addModuleImportToRootModule(host, moduleName, src, project) {
|
|
24
|
-
const modulePath = (0, ng_ast_utils_1.getAppModulePath)(host, project.architect.build.options.
|
|
25
|
-
addModuleImportToModule(host, modulePath, moduleName, src);
|
|
26
|
-
}
|
|
27
|
-
exports.addModuleImportToRootModule = addModuleImportToRootModule;
|
|
28
|
-
/**
|
|
29
|
-
* Import and add module to specific module path.
|
|
30
|
-
* @param host the tree we are updating
|
|
31
|
-
* @param modulePath src location of the module to import
|
|
32
|
-
* @param moduleName name of module to import
|
|
33
|
-
* @param src src location to import
|
|
34
|
-
*/
|
|
35
|
-
function addModuleImportToModule(host, modulePath, moduleName, src) {
|
|
36
|
-
const moduleSource = getSourceFile(host, modulePath);
|
|
37
|
-
if (!moduleSource) {
|
|
38
|
-
throw new schematics_1.SchematicsException(`Module not found: ${modulePath}`);
|
|
39
|
-
}
|
|
40
|
-
const changes = (0, ast_utils_1.addImportToModule)(moduleSource, modulePath, moduleName, src);
|
|
41
|
-
const recorder = host.beginUpdate(modulePath);
|
|
42
|
-
changes.forEach((change) => {
|
|
43
|
-
if (change instanceof change_1.InsertChange) {
|
|
44
|
-
recorder.insertLeft(change.pos, change.toAdd);
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
host.commitUpdate(recorder);
|
|
48
|
-
}
|
|
49
|
-
exports.addModuleImportToModule = addModuleImportToModule;
|
|
50
|
-
/** Gets the app index.html file */
|
|
51
|
-
function getIndexHtmlPath(host, project) {
|
|
52
|
-
const buildTarget = project.architect.build.options;
|
|
53
|
-
if (buildTarget.index && buildTarget.index.endsWith('index.html')) {
|
|
54
|
-
return buildTarget.index;
|
|
55
|
-
}
|
|
56
|
-
throw new schematics_1.SchematicsException('No index.html file was found.');
|
|
57
|
-
}
|
|
58
|
-
exports.getIndexHtmlPath = getIndexHtmlPath;
|
|
59
|
-
/** Get the root stylesheet file. */
|
|
60
|
-
function getStylesPath(host, project) {
|
|
61
|
-
const buildTarget = project.architect['build'];
|
|
62
|
-
if (buildTarget.options && buildTarget.options.styles && buildTarget.options.styles.length) {
|
|
63
|
-
const styles = buildTarget.options.styles.map(s => s.input);
|
|
64
|
-
// First, see if any of the assets is called "styles.(le|sc|c)ss", which is the default
|
|
65
|
-
// "main" style sheet.
|
|
66
|
-
const defaultMainStylePath = styles.find(a => /styles\.(c|le|sc)ss/.test(a));
|
|
67
|
-
if (defaultMainStylePath) {
|
|
68
|
-
return (0, core_1.normalize)(defaultMainStylePath);
|
|
69
|
-
}
|
|
70
|
-
// If there was no obvious default file, use the first style asset.
|
|
71
|
-
const fallbackStylePath = styles.find(a => /\.(c|le|sc)ss/.test(a));
|
|
72
|
-
if (fallbackStylePath) {
|
|
73
|
-
return (0, core_1.normalize)(fallbackStylePath);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
throw new schematics_1.SchematicsException('No style files could be found into which a theme could be added');
|
|
77
|
-
}
|
|
78
|
-
exports.getStylesPath = getStylesPath;
|
|
79
|
-
/** Wraps the internal find module from options with undefined path handling */
|
|
80
|
-
function findModuleFromOptions(host, options) {
|
|
81
|
-
const workspace = (0, config_1.getWorkspace)(host);
|
|
82
|
-
if (!options.project) {
|
|
83
|
-
options.project = Object.keys(workspace.projects)[0];
|
|
84
|
-
}
|
|
85
|
-
const project = workspace.projects[options.project];
|
|
86
|
-
if (options.path === undefined) {
|
|
87
|
-
options.path = `/${project.root}/src/app`;
|
|
88
|
-
}
|
|
89
|
-
return (0, find_module_1.findModuleFromOptions)(host, options);
|
|
90
|
-
}
|
|
91
|
-
exports.findModuleFromOptions = findModuleFromOptions;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.findModuleFromOptions = exports.getStylesPath = exports.getIndexHtmlPath = exports.addModuleImportToModule = exports.addModuleImportToRootModule = exports.getSourceFile = 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("./devkit-utils/ast-utils");
|
|
8
|
+
const change_1 = require("./devkit-utils/change");
|
|
9
|
+
const config_1 = require("./devkit-utils/config");
|
|
10
|
+
const ng_ast_utils_1 = require("./devkit-utils/ng-ast-utils");
|
|
11
|
+
const find_module_1 = require("./devkit-utils/find-module");
|
|
12
|
+
/** Reads file given path and returns TypeScript source file. */
|
|
13
|
+
function getSourceFile(host, path) {
|
|
14
|
+
const buffer = host.read(path);
|
|
15
|
+
if (!buffer) {
|
|
16
|
+
throw new schematics_1.SchematicsException(`Could not find file for path: ${path}`);
|
|
17
|
+
}
|
|
18
|
+
const content = buffer.toString();
|
|
19
|
+
return ts.createSourceFile(path, content, ts.ScriptTarget.Latest, true);
|
|
20
|
+
}
|
|
21
|
+
exports.getSourceFile = getSourceFile;
|
|
22
|
+
/** Import and add module to root app module. */
|
|
23
|
+
function addModuleImportToRootModule(host, moduleName, src, project) {
|
|
24
|
+
const modulePath = (0, ng_ast_utils_1.getAppModulePath)(host, project.architect.build.options.browser);
|
|
25
|
+
addModuleImportToModule(host, modulePath, moduleName, src);
|
|
26
|
+
}
|
|
27
|
+
exports.addModuleImportToRootModule = addModuleImportToRootModule;
|
|
28
|
+
/**
|
|
29
|
+
* Import and add module to specific module path.
|
|
30
|
+
* @param host the tree we are updating
|
|
31
|
+
* @param modulePath src location of the module to import
|
|
32
|
+
* @param moduleName name of module to import
|
|
33
|
+
* @param src src location to import
|
|
34
|
+
*/
|
|
35
|
+
function addModuleImportToModule(host, modulePath, moduleName, src) {
|
|
36
|
+
const moduleSource = getSourceFile(host, modulePath);
|
|
37
|
+
if (!moduleSource) {
|
|
38
|
+
throw new schematics_1.SchematicsException(`Module not found: ${modulePath}`);
|
|
39
|
+
}
|
|
40
|
+
const changes = (0, ast_utils_1.addImportToModule)(moduleSource, modulePath, moduleName, src);
|
|
41
|
+
const recorder = host.beginUpdate(modulePath);
|
|
42
|
+
changes.forEach((change) => {
|
|
43
|
+
if (change instanceof change_1.InsertChange) {
|
|
44
|
+
recorder.insertLeft(change.pos, change.toAdd);
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
host.commitUpdate(recorder);
|
|
48
|
+
}
|
|
49
|
+
exports.addModuleImportToModule = addModuleImportToModule;
|
|
50
|
+
/** Gets the app index.html file */
|
|
51
|
+
function getIndexHtmlPath(host, project) {
|
|
52
|
+
const buildTarget = project.architect.build.options;
|
|
53
|
+
if (buildTarget.index && buildTarget.index.endsWith('index.html')) {
|
|
54
|
+
return buildTarget.index;
|
|
55
|
+
}
|
|
56
|
+
throw new schematics_1.SchematicsException('No index.html file was found.');
|
|
57
|
+
}
|
|
58
|
+
exports.getIndexHtmlPath = getIndexHtmlPath;
|
|
59
|
+
/** Get the root stylesheet file. */
|
|
60
|
+
function getStylesPath(host, project) {
|
|
61
|
+
const buildTarget = project.architect['build'];
|
|
62
|
+
if (buildTarget.options && buildTarget.options.styles && buildTarget.options.styles.length) {
|
|
63
|
+
const styles = buildTarget.options.styles.map(s => s.input);
|
|
64
|
+
// First, see if any of the assets is called "styles.(le|sc|c)ss", which is the default
|
|
65
|
+
// "main" style sheet.
|
|
66
|
+
const defaultMainStylePath = styles.find(a => /styles\.(c|le|sc)ss/.test(a));
|
|
67
|
+
if (defaultMainStylePath) {
|
|
68
|
+
return (0, core_1.normalize)(defaultMainStylePath);
|
|
69
|
+
}
|
|
70
|
+
// If there was no obvious default file, use the first style asset.
|
|
71
|
+
const fallbackStylePath = styles.find(a => /\.(c|le|sc)ss/.test(a));
|
|
72
|
+
if (fallbackStylePath) {
|
|
73
|
+
return (0, core_1.normalize)(fallbackStylePath);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
throw new schematics_1.SchematicsException('No style files could be found into which a theme could be added');
|
|
77
|
+
}
|
|
78
|
+
exports.getStylesPath = getStylesPath;
|
|
79
|
+
/** Wraps the internal find module from options with undefined path handling */
|
|
80
|
+
function findModuleFromOptions(host, options) {
|
|
81
|
+
const workspace = (0, config_1.getWorkspace)(host);
|
|
82
|
+
if (!options.project) {
|
|
83
|
+
options.project = Object.keys(workspace.projects)[0];
|
|
84
|
+
}
|
|
85
|
+
const project = workspace.projects[options.project];
|
|
86
|
+
if (options.path === undefined) {
|
|
87
|
+
options.path = `/${project.root}/src/app`;
|
|
88
|
+
}
|
|
89
|
+
return (0, find_module_1.findModuleFromOptions)(host, options);
|
|
90
|
+
}
|
|
91
|
+
exports.findModuleFromOptions = findModuleFromOptions;
|
|
92
92
|
//# sourceMappingURL=ast.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ast.js","sourceRoot":"","sources":["ast.ts"],"names":[],"mappings":";;;AAAA,+CAA+C;AAC/C,2DAAqE;AACrE,iCAAiC;AACjC,wDAA2D;AAC3D,kDAAmD;AACnD,kDAA4D;AAC5D,8DAAsF;AACtF,4DAAsG;AAGtG,gEAAgE;AAChE,SAAgB,aAAa,CAAC,IAAU,EAAE,IAAY;IACpD,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC/B,IAAI,CAAC,MAAM,EAAE;
|
|
1
|
+
{"version":3,"file":"ast.js","sourceRoot":"","sources":["ast.ts"],"names":[],"mappings":";;;AAAA,+CAA+C;AAC/C,2DAAqE;AACrE,iCAAiC;AACjC,wDAA2D;AAC3D,kDAAmD;AACnD,kDAA4D;AAC5D,8DAAsF;AACtF,4DAAsG;AAGtG,gEAAgE;AAChE,SAA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,iBAAiB,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;QACpE,IAAI,iBAAiB,EAAE,CAAC;YACtB,OAAO,IAAA,gBAAS,EAAC,iBAAiB,CAAC,CAAC;QACtC,CAAC;IACH,CAAC;IAED,MAAM,IAAI,gCAAmB,CAAC,iEAAiE,CAAC,CAAC;AACnG,CAAC;AArBD,sCAqBC;AAED,gFAAgF;AAChF,SAAgB,qBAAqB,CAAC,IAAU,EAAE,OAAY;IAC5D,MAAM,SAAS,GAAG,IAAA,qBAAY,EAAC,IAAI,CAAC,CAAC;IACrC,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;QACrB,OAAO,CAAC,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;IACvD,CAAC;IAED,MAAM,OAAO,GAAG,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IAEpD,IAAI,OAAO,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;QAC/B,OAAO,CAAC,IAAI,GAAG,IAAI,OAAO,CAAC,IAAI,UAAU,CAAC;IAC5C,CAAC;IAED,OAAO,IAAA,mCAAkB,EAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AAC3C,CAAC;AAbD,sDAaC","sourcesContent":["import {normalize} from '@angular-devkit/core';\nimport {SchematicsException, Tree} from '@angular-devkit/schematics';\nimport * as ts from 'typescript';\nimport {addImportToModule} from './devkit-utils/ast-utils';\nimport {InsertChange} from './devkit-utils/change';\nimport {Project, getWorkspace} from './devkit-utils/config';\nimport {findBootstrapModulePath, getAppModulePath} from './devkit-utils/ng-ast-utils';\nimport {ModuleOptions, findModuleFromOptions as internalFindModule} from './devkit-utils/find-module';\n\n\n/** Reads file given path and returns TypeScript source file. */\nexport function getSourceFile(host: Tree, path: string): ts.SourceFile {\n const buffer = host.read(path);\n if (!buffer) {\n throw new SchematicsException(`Could not find file for path: ${path}`);\n }\n const content = buffer.toString();\n return ts.createSourceFile(path, content, ts.ScriptTarget.Latest, true);\n}\n\n/** Import and add module to root app module. */\nexport function addModuleImportToRootModule(host: Tree, moduleName: string, src: string, project: Project) {\n const modulePath = getAppModulePath(host, project.architect.build.options.browser);\n addModuleImportToModule(host, modulePath, moduleName, src);\n}\n\n/**\n * Import and add module to specific module path.\n * @param host the tree we are updating\n * @param modulePath src location of the module to import\n * @param moduleName name of module to import\n * @param src src location to import\n */\nexport function addModuleImportToModule(\n host: Tree, modulePath: string, moduleName: string, src: string) {\n const moduleSource = getSourceFile(host, modulePath);\n\n if (!moduleSource) {\n throw new SchematicsException(`Module not found: ${modulePath}`);\n }\n\n const changes = addImportToModule(moduleSource, modulePath, moduleName, src);\n const recorder = host.beginUpdate(modulePath);\n\n changes.forEach((change) => {\n if (change instanceof InsertChange) {\n recorder.insertLeft(change.pos, change.toAdd);\n }\n });\n\n host.commitUpdate(recorder);\n}\n\n/** Gets the app index.html file */\nexport function getIndexHtmlPath(host: Tree, project: Project): string {\n const buildTarget = project.architect.build.options;\n\n if (buildTarget.index && buildTarget.index.endsWith('index.html')) {\n return buildTarget.index;\n }\n\n throw new SchematicsException('No index.html file was found.');\n}\n\n/** Get the root stylesheet file. */\nexport function getStylesPath(host: Tree, project: Project): string {\n const buildTarget = project.architect['build'];\n\n if (buildTarget.options && buildTarget.options.styles && buildTarget.options.styles.length) {\n const styles = buildTarget.options.styles.map(s => s.input);\n\n // First, see if any of the assets is called \"styles.(le|sc|c)ss\", which is the default\n // \"main\" style sheet.\n const defaultMainStylePath = styles.find(a => /styles\\.(c|le|sc)ss/.test(a));\n if (defaultMainStylePath) {\n return normalize(defaultMainStylePath);\n }\n\n // If there was no obvious default file, use the first style asset.\n const fallbackStylePath = styles.find(a => /\\.(c|le|sc)ss/.test(a));\n if (fallbackStylePath) {\n return normalize(fallbackStylePath);\n }\n }\n\n throw new SchematicsException('No style files could be found into which a theme could be added');\n}\n\n/** Wraps the internal find module from options with undefined path handling */\nexport function findModuleFromOptions(host: Tree, options: any) {\n const workspace = getWorkspace(host);\n if (!options.project) {\n options.project = Object.keys(workspace.projects)[0];\n }\n\n const project = workspace.projects[options.project];\n\n if (options.path === undefined) {\n options.path = `/${project.root}/src/app`;\n }\n\n return internalFindModule(host, options);\n}\n"]}
|
|
@@ -20,7 +20,7 @@ export function getSourceFile(host: Tree, path: string): ts.SourceFile {
|
|
|
20
20
|
|
|
21
21
|
/** Import and add module to root app module. */
|
|
22
22
|
export function addModuleImportToRootModule(host: Tree, moduleName: string, src: string, project: Project) {
|
|
23
|
-
const modulePath = getAppModulePath(host, project.architect.build.options.
|
|
23
|
+
const modulePath = getAppModulePath(host, project.architect.build.options.browser);
|
|
24
24
|
addModuleImportToModule(host, modulePath, moduleName, src);
|
|
25
25
|
}
|
|
26
26
|
|
|
@@ -1,87 +1,87 @@
|
|
|
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 * as ts from 'typescript';
|
|
9
|
-
import { Change } from './change';
|
|
10
|
-
/**
|
|
11
|
-
* Add Import `import { symbolName } from fileName` if the import doesn't exit
|
|
12
|
-
* already. Assumes fileToEdit can be resolved and accessed.
|
|
13
|
-
* @param fileToEdit (file we want to add import to)
|
|
14
|
-
* @param symbolName (item to import)
|
|
15
|
-
* @param fileName (path to the file)
|
|
16
|
-
* @param isDefault (if true, import follows style for importing default exports)
|
|
17
|
-
* @return Change
|
|
18
|
-
*/
|
|
19
|
-
export declare function insertImport(source: ts.SourceFile, fileToEdit: string, symbolName: string, fileName: string, isDefault?: boolean): Change;
|
|
20
|
-
/**
|
|
21
|
-
* Find all nodes from the AST in the subtree of node of SyntaxKind kind.
|
|
22
|
-
* @param node
|
|
23
|
-
* @param kind
|
|
24
|
-
* @param max The maximum number of items to return.
|
|
25
|
-
* @return all nodes of kind, or [] if none is found
|
|
26
|
-
*/
|
|
27
|
-
export declare function findNodes(node: ts.Node, kind: ts.SyntaxKind, max?: number): ts.Node[];
|
|
28
|
-
/**
|
|
29
|
-
* Get all the nodes from a source.
|
|
30
|
-
* @param sourceFile The source file object.
|
|
31
|
-
* @returns {Observable<ts.Node>} An observable of all the nodes in the source.
|
|
32
|
-
*/
|
|
33
|
-
export declare function getSourceNodes(sourceFile: ts.SourceFile): ts.Node[];
|
|
34
|
-
export declare function findNode(node: ts.Node, kind: ts.SyntaxKind, text: string): ts.Node | null;
|
|
35
|
-
/**
|
|
36
|
-
* Insert `toInsert` after the last occurence of `ts.SyntaxKind[nodes[i].kind]`
|
|
37
|
-
* or after the last of occurence of `syntaxKind` if the last occurence is a sub child
|
|
38
|
-
* of ts.SyntaxKind[nodes[i].kind] and save the changes in file.
|
|
39
|
-
*
|
|
40
|
-
* @param nodes insert after the last occurence of nodes
|
|
41
|
-
* @param toInsert string to insert
|
|
42
|
-
* @param file file to insert changes into
|
|
43
|
-
* @param fallbackPos position to insert if toInsert happens to be the first occurence
|
|
44
|
-
* @param syntaxKind the ts.SyntaxKind of the subchildren to insert after
|
|
45
|
-
* @return Change instance
|
|
46
|
-
* @throw Error if toInsert is first occurence but fall back is not set
|
|
47
|
-
*/
|
|
48
|
-
export declare function insertAfterLastOccurrence(nodes: ts.Node[], toInsert: string, file: string, fallbackPos: number, syntaxKind?: ts.SyntaxKind): Change;
|
|
49
|
-
export declare function getContentOfKeyLiteral(_source: ts.SourceFile, node: ts.Node): string | null;
|
|
50
|
-
export declare function getDecoratorMetadata(source: ts.SourceFile, identifier: string, module: string): ts.Node[];
|
|
51
|
-
/**
|
|
52
|
-
* Given a source file with @NgModule class(es), find the name of the first @NgModule class.
|
|
53
|
-
*
|
|
54
|
-
* @param source source file containing one or more @NgModule
|
|
55
|
-
* @returns the name of the first @NgModule, or `undefined` if none is found
|
|
56
|
-
*/
|
|
57
|
-
export declare function getFirstNgModuleName(source: ts.SourceFile): string | undefined;
|
|
58
|
-
export declare function addSymbolToNgModuleMetadata(source: ts.SourceFile, ngModulePath: string, metadataField: string, symbolName: string, importPath?: string | null): Change[];
|
|
59
|
-
/**
|
|
60
|
-
* Custom function to insert a declaration (component, pipe, directive)
|
|
61
|
-
* into NgModule declarations. It also imports the component.
|
|
62
|
-
*/
|
|
63
|
-
export declare function addDeclarationToModule(source: ts.SourceFile, modulePath: string, classifiedName: string, importPath: string): Change[];
|
|
64
|
-
/**
|
|
65
|
-
* Custom function to insert an NgModule into NgModule imports. It also imports the module.
|
|
66
|
-
*/
|
|
67
|
-
export declare function addImportToModule(source: ts.SourceFile, modulePath: string, classifiedName: string, importPath: string): Change[];
|
|
68
|
-
/**
|
|
69
|
-
* Custom function to insert a provider into NgModule. It also imports it.
|
|
70
|
-
*/
|
|
71
|
-
export declare function addProviderToModule(source: ts.SourceFile, modulePath: string, classifiedName: string, importPath: string): Change[];
|
|
72
|
-
/**
|
|
73
|
-
* Custom function to insert an export into NgModule. It also imports it.
|
|
74
|
-
*/
|
|
75
|
-
export declare function addExportToModule(source: ts.SourceFile, modulePath: string, classifiedName: string, importPath: string): Change[];
|
|
76
|
-
/**
|
|
77
|
-
* Custom function to insert an export into NgModule. It also imports it.
|
|
78
|
-
*/
|
|
79
|
-
export declare function addBootstrapToModule(source: ts.SourceFile, modulePath: string, classifiedName: string, importPath: string): Change[];
|
|
80
|
-
/**
|
|
81
|
-
* Custom function to insert an entryComponent into NgModule. It also imports it.
|
|
82
|
-
*/
|
|
83
|
-
export declare function addEntryComponentToModule(source: ts.SourceFile, modulePath: string, classifiedName: string, importPath: string): Change[];
|
|
84
|
-
/**
|
|
85
|
-
* Determine if an import already exists.
|
|
86
|
-
*/
|
|
87
|
-
export declare function isImported(source: ts.SourceFile, classifiedName: string, importPath: string): boolean;
|
|
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 * as ts from 'typescript';
|
|
9
|
+
import { Change } from './change';
|
|
10
|
+
/**
|
|
11
|
+
* Add Import `import { symbolName } from fileName` if the import doesn't exit
|
|
12
|
+
* already. Assumes fileToEdit can be resolved and accessed.
|
|
13
|
+
* @param fileToEdit (file we want to add import to)
|
|
14
|
+
* @param symbolName (item to import)
|
|
15
|
+
* @param fileName (path to the file)
|
|
16
|
+
* @param isDefault (if true, import follows style for importing default exports)
|
|
17
|
+
* @return Change
|
|
18
|
+
*/
|
|
19
|
+
export declare function insertImport(source: ts.SourceFile, fileToEdit: string, symbolName: string, fileName: string, isDefault?: boolean): Change;
|
|
20
|
+
/**
|
|
21
|
+
* Find all nodes from the AST in the subtree of node of SyntaxKind kind.
|
|
22
|
+
* @param node
|
|
23
|
+
* @param kind
|
|
24
|
+
* @param max The maximum number of items to return.
|
|
25
|
+
* @return all nodes of kind, or [] if none is found
|
|
26
|
+
*/
|
|
27
|
+
export declare function findNodes(node: ts.Node, kind: ts.SyntaxKind, max?: number): ts.Node[];
|
|
28
|
+
/**
|
|
29
|
+
* Get all the nodes from a source.
|
|
30
|
+
* @param sourceFile The source file object.
|
|
31
|
+
* @returns {Observable<ts.Node>} An observable of all the nodes in the source.
|
|
32
|
+
*/
|
|
33
|
+
export declare function getSourceNodes(sourceFile: ts.SourceFile): ts.Node[];
|
|
34
|
+
export declare function findNode(node: ts.Node, kind: ts.SyntaxKind, text: string): ts.Node | null;
|
|
35
|
+
/**
|
|
36
|
+
* Insert `toInsert` after the last occurence of `ts.SyntaxKind[nodes[i].kind]`
|
|
37
|
+
* or after the last of occurence of `syntaxKind` if the last occurence is a sub child
|
|
38
|
+
* of ts.SyntaxKind[nodes[i].kind] and save the changes in file.
|
|
39
|
+
*
|
|
40
|
+
* @param nodes insert after the last occurence of nodes
|
|
41
|
+
* @param toInsert string to insert
|
|
42
|
+
* @param file file to insert changes into
|
|
43
|
+
* @param fallbackPos position to insert if toInsert happens to be the first occurence
|
|
44
|
+
* @param syntaxKind the ts.SyntaxKind of the subchildren to insert after
|
|
45
|
+
* @return Change instance
|
|
46
|
+
* @throw Error if toInsert is first occurence but fall back is not set
|
|
47
|
+
*/
|
|
48
|
+
export declare function insertAfterLastOccurrence(nodes: ts.Node[], toInsert: string, file: string, fallbackPos: number, syntaxKind?: ts.SyntaxKind): Change;
|
|
49
|
+
export declare function getContentOfKeyLiteral(_source: ts.SourceFile, node: ts.Node): string | null;
|
|
50
|
+
export declare function getDecoratorMetadata(source: ts.SourceFile, identifier: string, module: string): ts.Node[];
|
|
51
|
+
/**
|
|
52
|
+
* Given a source file with @NgModule class(es), find the name of the first @NgModule class.
|
|
53
|
+
*
|
|
54
|
+
* @param source source file containing one or more @NgModule
|
|
55
|
+
* @returns the name of the first @NgModule, or `undefined` if none is found
|
|
56
|
+
*/
|
|
57
|
+
export declare function getFirstNgModuleName(source: ts.SourceFile): string | undefined;
|
|
58
|
+
export declare function addSymbolToNgModuleMetadata(source: ts.SourceFile, ngModulePath: string, metadataField: string, symbolName: string, importPath?: string | null): Change[];
|
|
59
|
+
/**
|
|
60
|
+
* Custom function to insert a declaration (component, pipe, directive)
|
|
61
|
+
* into NgModule declarations. It also imports the component.
|
|
62
|
+
*/
|
|
63
|
+
export declare function addDeclarationToModule(source: ts.SourceFile, modulePath: string, classifiedName: string, importPath: string): Change[];
|
|
64
|
+
/**
|
|
65
|
+
* Custom function to insert an NgModule into NgModule imports. It also imports the module.
|
|
66
|
+
*/
|
|
67
|
+
export declare function addImportToModule(source: ts.SourceFile, modulePath: string, classifiedName: string, importPath: string): Change[];
|
|
68
|
+
/**
|
|
69
|
+
* Custom function to insert a provider into NgModule. It also imports it.
|
|
70
|
+
*/
|
|
71
|
+
export declare function addProviderToModule(source: ts.SourceFile, modulePath: string, classifiedName: string, importPath: string): Change[];
|
|
72
|
+
/**
|
|
73
|
+
* Custom function to insert an export into NgModule. It also imports it.
|
|
74
|
+
*/
|
|
75
|
+
export declare function addExportToModule(source: ts.SourceFile, modulePath: string, classifiedName: string, importPath: string): Change[];
|
|
76
|
+
/**
|
|
77
|
+
* Custom function to insert an export into NgModule. It also imports it.
|
|
78
|
+
*/
|
|
79
|
+
export declare function addBootstrapToModule(source: ts.SourceFile, modulePath: string, classifiedName: string, importPath: string): Change[];
|
|
80
|
+
/**
|
|
81
|
+
* Custom function to insert an entryComponent into NgModule. It also imports it.
|
|
82
|
+
*/
|
|
83
|
+
export declare function addEntryComponentToModule(source: ts.SourceFile, modulePath: string, classifiedName: string, importPath: string): Change[];
|
|
84
|
+
/**
|
|
85
|
+
* Determine if an import already exists.
|
|
86
|
+
*/
|
|
87
|
+
export declare function isImported(source: ts.SourceFile, classifiedName: string, importPath: string): boolean;
|