@magic-xpa/cli 4.1100.0-dev4110.19 → 4.1100.0-dev4110.190
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/magic.gen.lib.module.ts +19 -19
- package/src/schematics/mg-add/files/src/magic-styles.css +1 -1
- 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/themes/basicHTML/edit.ejs +2 -1
|
@@ -1,152 +1,152 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.mgAdd = void 0;
|
|
4
|
-
const schematics_1 = require("@angular-devkit/schematics");
|
|
5
|
-
const tasks_1 = require("@angular-devkit/schematics/tasks");
|
|
6
|
-
const package_1 = require("./../utils/package");
|
|
7
|
-
const env_1 = require("../magic-utils/env");
|
|
8
|
-
const utils_1 = require("../magic-utils/utils");
|
|
9
|
-
const init_magic_metadata_rule_1 = require("../magic-utils/rules/init-magic-metadata.rule");
|
|
10
|
-
const ast_1 = require("../utils/ast");
|
|
11
|
-
const Util_1 = require("../magic-utils/Util");
|
|
12
|
-
const generate_rule_1 = require("../magic-utils/rules/generate.rule");
|
|
13
|
-
const generated_file_types_enum_1 = require("../../types/enums/generated-file-types.enum");
|
|
14
|
-
const ast_utils_1 = require("../utils/devkit-utils/ast-utils");
|
|
15
|
-
const ts = require("typescript");
|
|
16
|
-
const change_1 = require("../utils/devkit-utils/change");
|
|
17
|
-
function mgAdd(options) {
|
|
18
|
-
return (0, schematics_1.chain)([
|
|
19
|
-
(0, init_magic_metadata_rule_1.initMagicMetadata)(options),
|
|
20
|
-
(0, utils_1.copyMagicFiles)(options),
|
|
21
|
-
// handel app.modules.ts
|
|
22
|
-
addMagicModuleToAppModule(options),
|
|
23
|
-
// handel Angular.json
|
|
24
|
-
updateAngularJsonWithMagicStyle(options),
|
|
25
|
-
updateTsConfigAppJson(options),
|
|
26
|
-
addLazyLoadProvider(),
|
|
27
|
-
// handel app.component.html
|
|
28
|
-
//updateAppComponentHtmlFiles (options),
|
|
29
|
-
//handel package.Json
|
|
30
|
-
//addMagicDependenciesToPackageJson (options),
|
|
31
|
-
]);
|
|
32
|
-
}
|
|
33
|
-
exports.mgAdd = mgAdd;
|
|
34
|
-
function updateAppComponentHtmlFiles(options) {
|
|
35
|
-
return (0, generate_rule_1.generate)({
|
|
36
|
-
template: "./templates/angular/src/app/app.component.html.ejs",
|
|
37
|
-
name: "app.component.html",
|
|
38
|
-
destination: env_1.env.metadata.paths.rootMagicGenFolder,
|
|
39
|
-
type: generated_file_types_enum_1.GeneratedFileTypes.HTML,
|
|
40
|
-
data: {
|
|
41
|
-
skipHelp: options.skipHelp
|
|
42
|
-
}
|
|
43
|
-
}, options);
|
|
44
|
-
}
|
|
45
|
-
function updateAngularJsonWithMagicStyle(options) {
|
|
46
|
-
return (host, context) => {
|
|
47
|
-
const project = env_1.env.project;
|
|
48
|
-
let isDirty = false;
|
|
49
|
-
let fullPathmagicStylePath = env_1.env.metadata.paths.magicStylePath;
|
|
50
|
-
if (!project.architect.test.options.styles.includes(fullPathmagicStylePath)) {
|
|
51
|
-
context.logger.info(` [>]add file ${fullPathmagicStylePath} to test`);
|
|
52
|
-
project.architect.test.options.styles.push(fullPathmagicStylePath);
|
|
53
|
-
isDirty = true;
|
|
54
|
-
}
|
|
55
|
-
if (!project.architect.build.options.styles.includes(fullPathmagicStylePath)) {
|
|
56
|
-
context.logger.info(` [>]add file ${fullPathmagicStylePath} to build`);
|
|
57
|
-
project.architect.build.options.styles.push(fullPathmagicStylePath);
|
|
58
|
-
isDirty = true;
|
|
59
|
-
}
|
|
60
|
-
if (isDirty) {
|
|
61
|
-
let fullPath = env_1.env.metadata.paths.angularJsonPath;
|
|
62
|
-
host.overwrite(fullPath, JSON.stringify(env_1.env.workspace, null, 2));
|
|
63
|
-
}
|
|
64
|
-
return host;
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
// Angular 10 , does not include .ts file for compilation
|
|
68
|
-
// So to avoid compilation error , add *.module.ts in includes section
|
|
69
|
-
function updateTsConfigAppJson(option) {
|
|
70
|
-
return (host, context) => {
|
|
71
|
-
const tsConfigPath = env_1.env.metadata.paths.tsConfigAppJsonPath;
|
|
72
|
-
const tsConfig = host.read(tsConfigPath).toString("utf-8");
|
|
73
|
-
// extract the comment
|
|
74
|
-
let comment = tsConfig.substring(tsConfig.indexOf('/*'), tsConfig.indexOf('*/') + 2);
|
|
75
|
-
// replace the comment as parsing json with comment throws exception
|
|
76
|
-
var config = JSON.parse(tsConfig.replace(comment, ''));
|
|
77
|
-
//Add module files for compilation
|
|
78
|
-
if (!config['include'].includes('src/**/*module.ts'))
|
|
79
|
-
config['include'].push('src/**/*module.ts');
|
|
80
|
-
// append the comment again and write the file
|
|
81
|
-
host.overwrite(tsConfigPath, comment + "\n" + JSON.stringify(config, null, 2));
|
|
82
|
-
return host;
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
function addMagicDependenciesToPackageJson(option) {
|
|
86
|
-
return (host, context) => {
|
|
87
|
-
if (!option.skipPackageJson) {
|
|
88
|
-
for (let dep of env_1.dependencies) {
|
|
89
|
-
(0, Util_1.LogLn)(`[>] Add dependencies ${dep.name}`);
|
|
90
|
-
(0, package_1.addPackageToPackageJson)(host, 'dependencies', dep.name, dep.version);
|
|
91
|
-
}
|
|
92
|
-
/*
|
|
93
|
-
// done in pre-install step
|
|
94
|
-
for (let dep of devDependencies){
|
|
95
|
-
LogLn(`[>] Add devDependencies ${dep.name}`);
|
|
96
|
-
addPackageToPackageJson(host, 'devDependencies', dep.name, dep.version);
|
|
97
|
-
}
|
|
98
|
-
*/
|
|
99
|
-
}
|
|
100
|
-
if (!option.skipInstall) {
|
|
101
|
-
(0, Util_1.LogLn)(`[>] Install dependencies.`);
|
|
102
|
-
context.addTask(new tasks_1.NodePackageInstallTask());
|
|
103
|
-
}
|
|
104
|
-
else {
|
|
105
|
-
(0, Util_1.LogLn)(`skipIstalls ${env_1.dependencies.length} dependencies`);
|
|
106
|
-
(0, Util_1.LogLn)(`skipIstalls ${env_1.devDependencies.length} devDependencies`);
|
|
107
|
-
}
|
|
108
|
-
return host;
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
|
-
function addMagicModuleToAppModule(options) {
|
|
112
|
-
return (host, context) => {
|
|
113
|
-
const workspace = env_1.env.workspace;
|
|
114
|
-
const project = env_1.env.project;
|
|
115
|
-
(0, ast_1.addModuleImportToRootModule)(host, 'BrowserAnimationsModule', '@angular/platform-browser/animations', project);
|
|
116
|
-
(0, ast_1.addModuleImportToRootModule)(host, 'ReactiveFormsModule', '@angular/forms', project);
|
|
117
|
-
(0, ast_1.addModuleImportToRootModule)(host, 'MagicModule', "@magic-xpa/angular", project);
|
|
118
|
-
(0, ast_1.addModuleImportToRootModule)(host, 'MagicAngularMaterialModule', "@magic-xpa/angular-material-core", project);
|
|
119
|
-
(0, ast_1.addModuleImportToRootModule)(host, 'MagicGenLibModule', "./magic/magic.gen.lib.module", project);
|
|
120
|
-
(0, ast_1.addModuleImportToRootModule)(host, 'MagicRoutingModule', "./app.routes", project);
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
|
-
function addLazyLoadProvider() {
|
|
124
|
-
return (host) => {
|
|
125
|
-
const appmodule = env_1.env.metadata.paths.rootMagicGenFolder + '/app.module.ts';
|
|
126
|
-
const lazyLoaderService = 'LazyLoaderService';
|
|
127
|
-
const lazyLoaderServicePath = './magic/lazy-loader.service';
|
|
128
|
-
let text = host.read(appmodule);
|
|
129
|
-
let sourceText = text.toString('utf-8');
|
|
130
|
-
let source = ts.createSourceFile(appmodule, sourceText, ts.ScriptTarget.Latest, true);
|
|
131
|
-
let providerChanges = (0, ast_utils_1.addProviderToModule)(source, appmodule, '{ provide: MagicLazyLoaderService, useClass: LazyLoaderService }', lazyLoaderServicePath);
|
|
132
|
-
const providerRecorder = host.beginUpdate(appmodule);
|
|
133
|
-
for (const change of providerChanges) {
|
|
134
|
-
if (change instanceof change_1.InsertChange) {
|
|
135
|
-
if (!change.toAdd.includes('import')) // skip import change
|
|
136
|
-
providerRecorder.insertLeft(change.pos, change.toAdd);
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
host.commitUpdate(providerRecorder);
|
|
140
|
-
const lazyLoaderServiceImport = (0, ast_utils_1.insertImport)(source, appmodule, lazyLoaderService, lazyLoaderServicePath, false);
|
|
141
|
-
const lazyLoaderServiceChangesRecorder = host.beginUpdate(appmodule);
|
|
142
|
-
if (lazyLoaderServiceImport instanceof change_1.InsertChange)
|
|
143
|
-
lazyLoaderServiceChangesRecorder.insertLeft(lazyLoaderServiceImport.pos, lazyLoaderServiceImport.toAdd);
|
|
144
|
-
host.commitUpdate(lazyLoaderServiceChangesRecorder);
|
|
145
|
-
// add import for MagicLazyLoaderService
|
|
146
|
-
const magicLazyLoaderServiceImportChanges = (0, ast_utils_1.insertImport)(source, appmodule, 'MagicLazyLoaderService', '@magic-xpa/angular', false);
|
|
147
|
-
const magicImportChangesRecorder = host.beginUpdate(appmodule);
|
|
148
|
-
magicImportChangesRecorder.insertLeft(magicLazyLoaderServiceImportChanges.pos, magicLazyLoaderServiceImportChanges.toAdd);
|
|
149
|
-
host.commitUpdate(magicImportChangesRecorder);
|
|
150
|
-
};
|
|
151
|
-
}
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mgAdd = void 0;
|
|
4
|
+
const schematics_1 = require("@angular-devkit/schematics");
|
|
5
|
+
const tasks_1 = require("@angular-devkit/schematics/tasks");
|
|
6
|
+
const package_1 = require("./../utils/package");
|
|
7
|
+
const env_1 = require("../magic-utils/env");
|
|
8
|
+
const utils_1 = require("../magic-utils/utils");
|
|
9
|
+
const init_magic_metadata_rule_1 = require("../magic-utils/rules/init-magic-metadata.rule");
|
|
10
|
+
const ast_1 = require("../utils/ast");
|
|
11
|
+
const Util_1 = require("../magic-utils/Util");
|
|
12
|
+
const generate_rule_1 = require("../magic-utils/rules/generate.rule");
|
|
13
|
+
const generated_file_types_enum_1 = require("../../types/enums/generated-file-types.enum");
|
|
14
|
+
const ast_utils_1 = require("../utils/devkit-utils/ast-utils");
|
|
15
|
+
const ts = require("typescript");
|
|
16
|
+
const change_1 = require("../utils/devkit-utils/change");
|
|
17
|
+
function mgAdd(options) {
|
|
18
|
+
return (0, schematics_1.chain)([
|
|
19
|
+
(0, init_magic_metadata_rule_1.initMagicMetadata)(options),
|
|
20
|
+
(0, utils_1.copyMagicFiles)(options),
|
|
21
|
+
// handel app.modules.ts
|
|
22
|
+
addMagicModuleToAppModule(options),
|
|
23
|
+
// handel Angular.json
|
|
24
|
+
updateAngularJsonWithMagicStyle(options),
|
|
25
|
+
updateTsConfigAppJson(options),
|
|
26
|
+
addLazyLoadProvider(),
|
|
27
|
+
// handel app.component.html
|
|
28
|
+
//updateAppComponentHtmlFiles (options),
|
|
29
|
+
//handel package.Json
|
|
30
|
+
//addMagicDependenciesToPackageJson (options),
|
|
31
|
+
]);
|
|
32
|
+
}
|
|
33
|
+
exports.mgAdd = mgAdd;
|
|
34
|
+
function updateAppComponentHtmlFiles(options) {
|
|
35
|
+
return (0, generate_rule_1.generate)({
|
|
36
|
+
template: "./templates/angular/src/app/app.component.html.ejs",
|
|
37
|
+
name: "app.component.html",
|
|
38
|
+
destination: env_1.env.metadata.paths.rootMagicGenFolder,
|
|
39
|
+
type: generated_file_types_enum_1.GeneratedFileTypes.HTML,
|
|
40
|
+
data: {
|
|
41
|
+
skipHelp: options.skipHelp
|
|
42
|
+
}
|
|
43
|
+
}, options);
|
|
44
|
+
}
|
|
45
|
+
function updateAngularJsonWithMagicStyle(options) {
|
|
46
|
+
return (host, context) => {
|
|
47
|
+
const project = env_1.env.project;
|
|
48
|
+
let isDirty = false;
|
|
49
|
+
let fullPathmagicStylePath = env_1.env.metadata.paths.magicStylePath;
|
|
50
|
+
if (!project.architect.test.options.styles.includes(fullPathmagicStylePath)) {
|
|
51
|
+
context.logger.info(` [>]add file ${fullPathmagicStylePath} to test`);
|
|
52
|
+
project.architect.test.options.styles.push(fullPathmagicStylePath);
|
|
53
|
+
isDirty = true;
|
|
54
|
+
}
|
|
55
|
+
if (!project.architect.build.options.styles.includes(fullPathmagicStylePath)) {
|
|
56
|
+
context.logger.info(` [>]add file ${fullPathmagicStylePath} to build`);
|
|
57
|
+
project.architect.build.options.styles.push(fullPathmagicStylePath);
|
|
58
|
+
isDirty = true;
|
|
59
|
+
}
|
|
60
|
+
if (isDirty) {
|
|
61
|
+
let fullPath = env_1.env.metadata.paths.angularJsonPath;
|
|
62
|
+
host.overwrite(fullPath, JSON.stringify(env_1.env.workspace, null, 2));
|
|
63
|
+
}
|
|
64
|
+
return host;
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
// Angular 10 , does not include .ts file for compilation
|
|
68
|
+
// So to avoid compilation error , add *.module.ts in includes section
|
|
69
|
+
function updateTsConfigAppJson(option) {
|
|
70
|
+
return (host, context) => {
|
|
71
|
+
const tsConfigPath = env_1.env.metadata.paths.tsConfigAppJsonPath;
|
|
72
|
+
const tsConfig = host.read(tsConfigPath).toString("utf-8");
|
|
73
|
+
// extract the comment
|
|
74
|
+
let comment = tsConfig.substring(tsConfig.indexOf('/*'), tsConfig.indexOf('*/') + 2);
|
|
75
|
+
// replace the comment as parsing json with comment throws exception
|
|
76
|
+
var config = JSON.parse(tsConfig.replace(comment, ''));
|
|
77
|
+
//Add module files for compilation
|
|
78
|
+
if (!config['include'].includes('src/**/*module.ts'))
|
|
79
|
+
config['include'].push('src/**/*module.ts');
|
|
80
|
+
// append the comment again and write the file
|
|
81
|
+
host.overwrite(tsConfigPath, comment + "\n" + JSON.stringify(config, null, 2));
|
|
82
|
+
return host;
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
function addMagicDependenciesToPackageJson(option) {
|
|
86
|
+
return (host, context) => {
|
|
87
|
+
if (!option.skipPackageJson) {
|
|
88
|
+
for (let dep of env_1.dependencies) {
|
|
89
|
+
(0, Util_1.LogLn)(`[>] Add dependencies ${dep.name}`);
|
|
90
|
+
(0, package_1.addPackageToPackageJson)(host, 'dependencies', dep.name, dep.version);
|
|
91
|
+
}
|
|
92
|
+
/*
|
|
93
|
+
// done in pre-install step
|
|
94
|
+
for (let dep of devDependencies){
|
|
95
|
+
LogLn(`[>] Add devDependencies ${dep.name}`);
|
|
96
|
+
addPackageToPackageJson(host, 'devDependencies', dep.name, dep.version);
|
|
97
|
+
}
|
|
98
|
+
*/
|
|
99
|
+
}
|
|
100
|
+
if (!option.skipInstall) {
|
|
101
|
+
(0, Util_1.LogLn)(`[>] Install dependencies.`);
|
|
102
|
+
context.addTask(new tasks_1.NodePackageInstallTask());
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
(0, Util_1.LogLn)(`skipIstalls ${env_1.dependencies.length} dependencies`);
|
|
106
|
+
(0, Util_1.LogLn)(`skipIstalls ${env_1.devDependencies.length} devDependencies`);
|
|
107
|
+
}
|
|
108
|
+
return host;
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
function addMagicModuleToAppModule(options) {
|
|
112
|
+
return (host, context) => {
|
|
113
|
+
const workspace = env_1.env.workspace;
|
|
114
|
+
const project = env_1.env.project;
|
|
115
|
+
(0, ast_1.addModuleImportToRootModule)(host, 'BrowserAnimationsModule', '@angular/platform-browser/animations', project);
|
|
116
|
+
(0, ast_1.addModuleImportToRootModule)(host, 'ReactiveFormsModule', '@angular/forms', project);
|
|
117
|
+
(0, ast_1.addModuleImportToRootModule)(host, 'MagicModule', "@magic-xpa/angular", project);
|
|
118
|
+
(0, ast_1.addModuleImportToRootModule)(host, 'MagicAngularMaterialModule', "@magic-xpa/angular-material-core", project);
|
|
119
|
+
(0, ast_1.addModuleImportToRootModule)(host, 'MagicGenLibModule', "./magic/magic.gen.lib.module", project);
|
|
120
|
+
(0, ast_1.addModuleImportToRootModule)(host, 'MagicRoutingModule', "./app.routes", project);
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
function addLazyLoadProvider() {
|
|
124
|
+
return (host) => {
|
|
125
|
+
const appmodule = env_1.env.metadata.paths.rootMagicGenFolder + '/app.module.ts';
|
|
126
|
+
const lazyLoaderService = 'LazyLoaderService';
|
|
127
|
+
const lazyLoaderServicePath = './magic/lazy-loader.service';
|
|
128
|
+
let text = host.read(appmodule);
|
|
129
|
+
let sourceText = text.toString('utf-8');
|
|
130
|
+
let source = ts.createSourceFile(appmodule, sourceText, ts.ScriptTarget.Latest, true);
|
|
131
|
+
let providerChanges = (0, ast_utils_1.addProviderToModule)(source, appmodule, '{ provide: MagicLazyLoaderService, useClass: LazyLoaderService }', lazyLoaderServicePath);
|
|
132
|
+
const providerRecorder = host.beginUpdate(appmodule);
|
|
133
|
+
for (const change of providerChanges) {
|
|
134
|
+
if (change instanceof change_1.InsertChange) {
|
|
135
|
+
if (!change.toAdd.includes('import')) // skip import change
|
|
136
|
+
providerRecorder.insertLeft(change.pos, change.toAdd);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
host.commitUpdate(providerRecorder);
|
|
140
|
+
const lazyLoaderServiceImport = (0, ast_utils_1.insertImport)(source, appmodule, lazyLoaderService, lazyLoaderServicePath, false);
|
|
141
|
+
const lazyLoaderServiceChangesRecorder = host.beginUpdate(appmodule);
|
|
142
|
+
if (lazyLoaderServiceImport instanceof change_1.InsertChange)
|
|
143
|
+
lazyLoaderServiceChangesRecorder.insertLeft(lazyLoaderServiceImport.pos, lazyLoaderServiceImport.toAdd);
|
|
144
|
+
host.commitUpdate(lazyLoaderServiceChangesRecorder);
|
|
145
|
+
// add import for MagicLazyLoaderService
|
|
146
|
+
const magicLazyLoaderServiceImportChanges = (0, ast_utils_1.insertImport)(source, appmodule, 'MagicLazyLoaderService', '@magic-xpa/angular', false);
|
|
147
|
+
const magicImportChangesRecorder = host.beginUpdate(appmodule);
|
|
148
|
+
magicImportChangesRecorder.insertLeft(magicLazyLoaderServiceImportChanges.pos, magicLazyLoaderServiceImportChanges.toAdd);
|
|
149
|
+
host.commitUpdate(magicImportChangesRecorder);
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
152
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;AAAA,2DAKoC;AACpC,4DAAwE;AAExE,gDAA2D;AAC3D,4CAAuE;AACvE,gDAAwE;AACxE,4FAAiF;AACjF,sCAA2D;AAC3D,8CAA4C;AAC5C,sEAA8D;AAC9D,2FAAiF;AAEjF,+DAAkF;AAClF,iCAAiC;AACjC,yDAA0D;AAC1D,SAAgB,KAAK,CAAC,OAAyB;IAC7C,OAAO,IAAA,kBAAK,EAAC;QACX,IAAA,4CAAiB,EAAkB,OAAO,CAAC;QAC3C,IAAA,sBAAc,EAAqB,OAAO,CAAC;QAE3C,wBAAwB;QACxB,yBAAyB,CAAU,OAAO,CAAC;QAE3C,sBAAsB;QACtB,+BAA+B,CAAI,OAAO,CAAC;QAE3C,qBAAqB,CAAG,OAAO,CAAC;QAEhC,mBAAmB,EAAE;QACrB,4BAA4B;QAC5B,8CAA8C;QAE9C,qBAAqB;QACrB,8CAA8C;KAC/C,CAAC,CAAC;AACL,CAAC;AApBD,sBAoBC;AAED,SAAS,2BAA2B,CAAC,OAAyB;IAC5D,OAAO,IAAA,wBAAQ,EAAC;QACd,QAAQ,EAAM,oDAAoD;QAClE,IAAI,EAAU,oBAAoB;QAClC,WAAW,EAAG,SAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,kBAAkB;QACnD,IAAI,EAAS,8CAAkB,CAAC,IAAI;QACpC,IAAI,EAAU;YACZ,QAAQ,EAAG,OAAO,CA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G,IAAI,CAAC,YAAY,CAAC,gCAAgC,CAAC,CAAC;QAEpD,wCAAwC;QACxC,MAAM,mCAAmC,GAA+B,IAAA,wBAAY,EAAC,MAAM,EAAE,SAAS,EAAE,wBAAwB,EAAE,oBAAoB,EAAE,KAAK,CAAC,CAAC;QAC/J,MAAM,0BAA0B,GAAG,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;QAC/D,0BAA0B,CAAC,UAAU,CAAC,mCAAmC,CAAC,GAAG,EAAE,mCAAmC,CAAC,KAAK,CAAC,CAAA;QACzH,IAAI,CAAC,YAAY,CAAC,0BAA0B,CAAC,CAAC;IAChD,CAAC,CAAA;AACH,CAAC","sourcesContent":["import {\r\n Rule,\r\n chain,\r\n Tree,\r\n SchematicContext\r\n} from \"@angular-devkit/schematics\";\r\nimport {NodePackageInstallTask} from \"@angular-devkit/schematics/tasks\";\r\n\r\nimport {addPackageToPackageJson} from './../utils/package';\r\nimport { dependencies, devDependencies, env} from \"../magic-utils/env\";\r\nimport { addImportTSModule, copyMagicFiles} from \"../magic-utils/utils\";\r\nimport { initMagicMetadata} from \"../magic-utils/rules/init-magic-metadata.rule\";\r\nimport { addModuleImportToRootModule } from \"../utils/ast\";\r\nimport { LogLn } from \"../magic-utils/Util\";\r\nimport { generate } from \"../magic-utils/rules/generate.rule\";\r\nimport { GeneratedFileTypes } from \"../../types/enums/generated-file-types.enum\";\r\nimport { MagicOptionScheme } from \"../magic-utils/rules/magic-option.scheme\";\r\nimport {addProviderToModule, insertImport} from \"../utils/devkit-utils/ast-utils\";\r\nimport * as ts from 'typescript';\r\nimport {InsertChange} from \"../utils/devkit-utils/change\";\r\nexport function mgAdd(options:MagicOptionScheme): Rule {\r\n return chain([\r\n initMagicMetadata (options),\r\n copyMagicFiles (options),\r\n\r\n // handel app.modules.ts\r\n addMagicModuleToAppModule (options),\r\n\r\n // handel Angular.json\r\n updateAngularJsonWithMagicStyle (options),\r\n\r\n updateTsConfigAppJson (options),\r\n\r\n addLazyLoadProvider(),\r\n // handel app.component.html\r\n //updateAppComponentHtmlFiles (options),\r\n\r\n //handel package.Json\r\n //addMagicDependenciesToPackageJson (options),\r\n ]);\r\n}\r\n\r\nfunction updateAppComponentHtmlFiles(options:MagicOptionScheme): Rule {\r\n return generate({\r\n template : \"./templates/angular/src/app/app.component.html.ejs\",\r\n name : \"app.component.html\",\r\n destination : env.metadata.paths.rootMagicGenFolder,\r\n type :GeneratedFileTypes.HTML,\r\n data : {\r\n skipHelp : options.skipHelp\r\n }\r\n },options)\r\n}\r\nfunction updateAngularJsonWithMagicStyle(options:MagicOptionScheme): Rule {\r\n return (host: Tree, context: SchematicContext) => {\r\n const project = env.project;\r\n let isDirty = false;\r\n\r\n let fullPathmagicStylePath = env.metadata.paths.magicStylePath;\r\n if (!project.architect.test.options.styles.includes(fullPathmagicStylePath)) {\r\n context.logger.info(` [>]add file ${fullPathmagicStylePath} to test`);\r\n project.architect.test.options.styles.push(fullPathmagicStylePath);\r\n isDirty = true;\r\n }\r\n\r\n if (!project.architect.build.options.styles.includes(fullPathmagicStylePath)) {\r\n context.logger.info(` [>]add file ${fullPathmagicStylePath} to build`);\r\n project.architect.build.options.styles.push(fullPathmagicStylePath);\r\n isDirty = true;\r\n }\r\n\r\n if(isDirty){\r\n let fullPath = env.metadata.paths.angularJsonPath;\r\n host.overwrite(fullPath, JSON.stringify(env.workspace, null, 2));\r\n }\r\n\r\n return host;\r\n };\r\n}\r\n\r\n// Angular 10 , does not include .ts file for compilation\r\n// So to avoid compilation error , add *.module.ts in includes section\r\nfunction updateTsConfigAppJson (option: MagicOptionScheme): Rule{\r\n return (host: Tree, context: SchematicContext) => {\r\n\r\n const tsConfigPath = env.metadata.paths.tsConfigAppJsonPath;\r\n const tsConfig = host.read(tsConfigPath)!.toString(\"utf-8\");\r\n\r\n // extract the comment\r\n let comment = tsConfig.substring(tsConfig.indexOf('/*'), tsConfig.indexOf('*/') + 2);\r\n\r\n // replace the comment as parsing json with comment throws exception\r\n var config = JSON.parse(tsConfig.replace(comment, ''));\r\n\r\n //Add module files for compilation\r\n if(!config['include'].includes('src/**/*module.ts'))\r\n config['include'].push('src/**/*module.ts');\r\n\r\n // append the comment again and write the file\r\n host.overwrite(tsConfigPath, comment + \"\\n\" + JSON.stringify(config, null , 2));\r\n return host;\r\n }\r\n}\r\n\r\nfunction addMagicDependenciesToPackageJson(option:MagicOptionScheme): Rule {\r\n\treturn (host: Tree, context: SchematicContext) => {\r\n\t if(!option.skipPackageJson){\r\n for (let dep of dependencies){\r\n LogLn(`[>] Add dependencies ${dep.name}`);\r\n addPackageToPackageJson(host, 'dependencies', dep.name, dep.version);\r\n }\r\n /*\r\n // done in pre-install step\r\n for (let dep of devDependencies){\r\n LogLn(`[>] Add devDependencies ${dep.name}`);\r\n addPackageToPackageJson(host, 'devDependencies', dep.name, dep.version);\r\n }\r\n */\r\n }\r\n\r\n\t\tif(!option.skipInstall){\r\n LogLn(`[>] Install dependencies.`);\r\n context.addTask(new NodePackageInstallTask());\r\n }else{\r\n LogLn(`skipIstalls ${dependencies.length} dependencies`);\r\n LogLn(`skipIstalls ${devDependencies.length} devDependencies`);\r\n }\r\n\r\n\t\treturn host;\r\n\t};\r\n}\r\nfunction addMagicModuleToAppModule(options: MagicOptionScheme) : Rule {\r\n return (host: Tree , context : SchematicContext)=>{\r\n const workspace = env.workspace;\r\n const project = env.project;\r\n\r\n addModuleImportToRootModule(\r\n host,\r\n 'BrowserAnimationsModule',\r\n '@angular/platform-browser/animations',\r\n project);\r\n\r\n addModuleImportToRootModule(\r\n host,\r\n 'ReactiveFormsModule',\r\n '@angular/forms',\r\n project);\r\n\r\n\r\n addModuleImportToRootModule(\r\n host,\r\n 'MagicModule',\r\n \"@magic-xpa/angular\",\r\n project);\r\n\r\n addModuleImportToRootModule(\r\n host,\r\n 'MagicAngularMaterialModule',\r\n \"@magic-xpa/angular-material-core\",\r\n project);\r\n\r\n addModuleImportToRootModule(\r\n host,\r\n 'MagicGenLibModule',\r\n \"./magic/magic.gen.lib.module\",\r\n project);\r\n\r\n addModuleImportToRootModule(\r\n host,\r\n 'MagicRoutingModule',\r\n \"./app.routes\",\r\n project);\r\n\r\n\r\n }\r\n}\r\n\r\nfunction addLazyLoadProvider(): Rule {\r\n return (host: Tree) => {\r\n const appmodule = env.metadata.paths.rootMagicGenFolder + '/app.module.ts';\r\n\r\n const lazyLoaderService = 'LazyLoaderService';\r\n const lazyLoaderServicePath = './magic/lazy-loader.service';\r\n\r\n let text = host.read(appmodule);\r\n let sourceText = text.toString('utf-8');\r\n let source = ts.createSourceFile(appmodule, sourceText, ts.ScriptTarget.Latest, true);\r\n let providerChanges = addProviderToModule(source, appmodule, '{ provide: MagicLazyLoaderService, useClass: LazyLoaderService }', lazyLoaderServicePath)\r\n\r\n const providerRecorder = host.beginUpdate(appmodule);\r\n for (const change of providerChanges) {\r\n if (change instanceof InsertChange) {\r\n if (!change.toAdd.includes('import')) // skip import change\r\n providerRecorder.insertLeft(change.pos, change.toAdd);\r\n }\r\n }\r\n host.commitUpdate(providerRecorder);\r\n\r\n const lazyLoaderServiceImport = insertImport(source, appmodule, lazyLoaderService, lazyLoaderServicePath, false);\r\n const lazyLoaderServiceChangesRecorder = host.beginUpdate(appmodule);\r\n if (lazyLoaderServiceImport instanceof InsertChange)\r\n lazyLoaderServiceChangesRecorder.insertLeft(lazyLoaderServiceImport.pos, lazyLoaderServiceImport.toAdd);\r\n host.commitUpdate(lazyLoaderServiceChangesRecorder);\r\n\r\n // add import for MagicLazyLoaderService\r\n const magicLazyLoaderServiceImportChanges: InsertChange = <InsertChange>insertImport(source, appmodule, 'MagicLazyLoaderService', '@magic-xpa/angular', false);\r\n const magicImportChangesRecorder = host.beginUpdate(appmodule);\r\n magicImportChangesRecorder.insertLeft(magicLazyLoaderServiceImportChanges.pos, magicLazyLoaderServiceImportChanges.toAdd)\r\n host.commitUpdate(magicImportChangesRecorder);\r\n }\r\n}\r\n\r\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","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AW,CAAC,SAAS,CAAC,CAAC;QAC/D,0BAA0B,CAAC,UAAU,CAAC,mCAAmC,CAAC,GAAG,EAAE,mCAAmC,CAAC,KAAK,CAAC,CAAA;QACzH,IAAI,CAAC,YAAY,CAAC,0BAA0B,CAAC,CAAC;IAChD,CAAC,CAAA;AACH,CAAC","sourcesContent":["import {\r\n Rule,\r\n chain,\r\n Tree,\r\n SchematicContext\r\n} from \"@angular-devkit/schematics\";\r\nimport {NodePackageInstallTask} from \"@angular-devkit/schematics/tasks\";\r\n\r\nimport {addPackageToPackageJson} from './../utils/package';\r\nimport { dependencies, devDependencies, env} from \"../magic-utils/env\";\r\nimport { addImportTSModule, copyMagicFiles} from \"../magic-utils/utils\";\r\nimport { initMagicMetadata} from \"../magic-utils/rules/init-magic-metadata.rule\";\r\nimport { addModuleImportToRootModule } from \"../utils/ast\";\r\nimport { LogLn } from \"../magic-utils/Util\";\r\nimport { generate } from \"../magic-utils/rules/generate.rule\";\r\nimport { GeneratedFileTypes } from \"../../types/enums/generated-file-types.enum\";\r\nimport { MagicOptionScheme } from \"../magic-utils/rules/magic-option.scheme\";\r\nimport {addProviderToModule, insertImport} from \"../utils/devkit-utils/ast-utils\";\r\nimport * as ts from 'typescript';\r\nimport {InsertChange} from \"../utils/devkit-utils/change\";\r\nexport function mgAdd(options:MagicOptionScheme): Rule {\r\n return chain([\r\n initMagicMetadata (options),\r\n copyMagicFiles (options),\r\n\r\n // handel app.modules.ts\r\n addMagicModuleToAppModule (options),\r\n\r\n // handel Angular.json\r\n updateAngularJsonWithMagicStyle (options),\r\n\r\n updateTsConfigAppJson (options),\r\n\r\n addLazyLoadProvider(),\r\n // handel app.component.html\r\n //updateAppComponentHtmlFiles (options),\r\n\r\n //handel package.Json\r\n //addMagicDependenciesToPackageJson (options),\r\n ]);\r\n}\r\n\r\nfunction updateAppComponentHtmlFiles(options:MagicOptionScheme): Rule {\r\n return generate({\r\n template : \"./templates/angular/src/app/app.component.html.ejs\",\r\n name : \"app.component.html\",\r\n destination : env.metadata.paths.rootMagicGenFolder,\r\n type :GeneratedFileTypes.HTML,\r\n data : {\r\n skipHelp : options.skipHelp\r\n }\r\n },options)\r\n}\r\nfunction updateAngularJsonWithMagicStyle(options:MagicOptionScheme): Rule {\r\n return (host: Tree, context: SchematicContext) => {\r\n const project = env.project;\r\n let isDirty = false;\r\n\r\n let fullPathmagicStylePath = env.metadata.paths.magicStylePath;\r\n if (!project.architect.test.options.styles.includes(fullPathmagicStylePath)) {\r\n context.logger.info(` [>]add file ${fullPathmagicStylePath} to test`);\r\n project.architect.test.options.styles.push(fullPathmagicStylePath);\r\n isDirty = true;\r\n }\r\n\r\n if (!project.architect.build.options.styles.includes(fullPathmagicStylePath)) {\r\n context.logger.info(` [>]add file ${fullPathmagicStylePath} to build`);\r\n project.architect.build.options.styles.push(fullPathmagicStylePath);\r\n isDirty = true;\r\n }\r\n\r\n if(isDirty){\r\n let fullPath = env.metadata.paths.angularJsonPath;\r\n host.overwrite(fullPath, JSON.stringify(env.workspace, null, 2));\r\n }\r\n\r\n return host;\r\n };\r\n}\r\n\r\n// Angular 10 , does not include .ts file for compilation\r\n// So to avoid compilation error , add *.module.ts in includes section\r\nfunction updateTsConfigAppJson (option: MagicOptionScheme): Rule{\r\n return (host: Tree, context: SchematicContext) => {\r\n\r\n const tsConfigPath = env.metadata.paths.tsConfigAppJsonPath;\r\n const tsConfig = host.read(tsConfigPath)!.toString(\"utf-8\");\r\n\r\n // extract the comment\r\n let comment = tsConfig.substring(tsConfig.indexOf('/*'), tsConfig.indexOf('*/') + 2);\r\n\r\n // replace the comment as parsing json with comment throws exception\r\n var config = JSON.parse(tsConfig.replace(comment, ''));\r\n\r\n //Add module files for compilation\r\n if(!config['include'].includes('src/**/*module.ts'))\r\n config['include'].push('src/**/*module.ts');\r\n\r\n // append the comment again and write the file\r\n host.overwrite(tsConfigPath, comment + \"\\n\" + JSON.stringify(config, null , 2));\r\n return host;\r\n }\r\n}\r\n\r\nfunction addMagicDependenciesToPackageJson(option:MagicOptionScheme): Rule {\r\n\treturn (host: Tree, context: SchematicContext) => {\r\n\t if(!option.skipPackageJson){\r\n for (let dep of dependencies){\r\n LogLn(`[>] Add dependencies ${dep.name}`);\r\n addPackageToPackageJson(host, 'dependencies', dep.name, dep.version);\r\n }\r\n /*\r\n // done in pre-install step\r\n for (let dep of devDependencies){\r\n LogLn(`[>] Add devDependencies ${dep.name}`);\r\n addPackageToPackageJson(host, 'devDependencies', dep.name, dep.version);\r\n }\r\n */\r\n }\r\n\r\n\t\tif(!option.skipInstall){\r\n LogLn(`[>] Install dependencies.`);\r\n context.addTask(new NodePackageInstallTask());\r\n }else{\r\n LogLn(`skipIstalls ${dependencies.length} dependencies`);\r\n LogLn(`skipIstalls ${devDependencies.length} devDependencies`);\r\n }\r\n\r\n\t\treturn host;\r\n\t};\r\n}\r\nfunction addMagicModuleToAppModule(options: MagicOptionScheme) : Rule {\r\n return (host: Tree , context : SchematicContext)=>{\r\n const workspace = env.workspace;\r\n const project = env.project;\r\n\r\n addModuleImportToRootModule(\r\n host,\r\n 'BrowserAnimationsModule',\r\n '@angular/platform-browser/animations',\r\n project);\r\n\r\n addModuleImportToRootModule(\r\n host,\r\n 'ReactiveFormsModule',\r\n '@angular/forms',\r\n project);\r\n\r\n\r\n addModuleImportToRootModule(\r\n host,\r\n 'MagicModule',\r\n \"@magic-xpa/angular\",\r\n project);\r\n\r\n addModuleImportToRootModule(\r\n host,\r\n 'MagicAngularMaterialModule',\r\n \"@magic-xpa/angular-material-core\",\r\n project);\r\n\r\n addModuleImportToRootModule(\r\n host,\r\n 'MagicGenLibModule',\r\n \"./magic/magic.gen.lib.module\",\r\n project);\r\n\r\n addModuleImportToRootModule(\r\n host,\r\n 'MagicRoutingModule',\r\n \"./app.routes\",\r\n project);\r\n\r\n\r\n }\r\n}\r\n\r\nfunction addLazyLoadProvider(): Rule {\r\n return (host: Tree) => {\r\n const appmodule = env.metadata.paths.rootMagicGenFolder + '/app.module.ts';\r\n\r\n const lazyLoaderService = 'LazyLoaderService';\r\n const lazyLoaderServicePath = './magic/lazy-loader.service';\r\n\r\n let text = host.read(appmodule);\r\n let sourceText = text.toString('utf-8');\r\n let source = ts.createSourceFile(appmodule, sourceText, ts.ScriptTarget.Latest, true);\r\n let providerChanges = addProviderToModule(source, appmodule, '{ provide: MagicLazyLoaderService, useClass: LazyLoaderService }', lazyLoaderServicePath)\r\n\r\n const providerRecorder = host.beginUpdate(appmodule);\r\n for (const change of providerChanges) {\r\n if (change instanceof InsertChange) {\r\n if (!change.toAdd.includes('import')) // skip import change\r\n providerRecorder.insertLeft(change.pos, change.toAdd);\r\n }\r\n }\r\n host.commitUpdate(providerRecorder);\r\n\r\n const lazyLoaderServiceImport = insertImport(source, appmodule, lazyLoaderService, lazyLoaderServicePath, false);\r\n const lazyLoaderServiceChangesRecorder = host.beginUpdate(appmodule);\r\n if (lazyLoaderServiceImport instanceof InsertChange)\r\n lazyLoaderServiceChangesRecorder.insertLeft(lazyLoaderServiceImport.pos, lazyLoaderServiceImport.toAdd);\r\n host.commitUpdate(lazyLoaderServiceChangesRecorder);\r\n\r\n // add import for MagicLazyLoaderService\r\n const magicLazyLoaderServiceImportChanges: InsertChange = <InsertChange>insertImport(source, appmodule, 'MagicLazyLoaderService', '@magic-xpa/angular', false);\r\n const magicImportChangesRecorder = host.beginUpdate(appmodule);\r\n magicImportChangesRecorder.insertLeft(magicLazyLoaderServiceImportChanges.pos, magicLazyLoaderServiceImportChanges.toAdd)\r\n host.commitUpdate(magicImportChangesRecorder);\r\n }\r\n}\r\n\r\n"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Tree } from '@angular-devkit/schematics';
|
|
2
|
-
export declare function addDeclarationToRootModule(host: Tree, moduleName: string, importSrc: string): void;
|
|
1
|
+
import { Tree } from '@angular-devkit/schematics';
|
|
2
|
+
export declare function addDeclarationToRootModule(host: Tree, moduleName: string, importSrc: string): void;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.addDeclarationToRootModule = void 0;
|
|
4
|
-
const ast_1 = require("../../utils/ast");
|
|
5
|
-
const ast_utils_1 = require("../../utils/devkit-utils/ast-utils");
|
|
6
|
-
const core_1 = require("@angular-devkit/core");
|
|
7
|
-
function addDeclarationToRootModule(host, moduleName, importSrc) {
|
|
8
|
-
let path = `src/app/app.module.ts`, source = (0, ast_1.getSourceFile)(host, path);
|
|
9
|
-
(0, ast_utils_1.addDeclarationToModule)(source, (0, core_1.normalize)(path), moduleName, importSrc);
|
|
10
|
-
}
|
|
11
|
-
exports.addDeclarationToRootModule = addDeclarationToRootModule;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.addDeclarationToRootModule = void 0;
|
|
4
|
+
const ast_1 = require("../../utils/ast");
|
|
5
|
+
const ast_utils_1 = require("../../utils/devkit-utils/ast-utils");
|
|
6
|
+
const core_1 = require("@angular-devkit/core");
|
|
7
|
+
function addDeclarationToRootModule(host, moduleName, importSrc) {
|
|
8
|
+
let path = `src/app/app.module.ts`, source = (0, ast_1.getSourceFile)(host, path);
|
|
9
|
+
(0, ast_utils_1.addDeclarationToModule)(source, (0, core_1.normalize)(path), moduleName, importSrc);
|
|
10
|
+
}
|
|
11
|
+
exports.addDeclarationToRootModule = addDeclarationToRootModule;
|
|
12
12
|
//# sourceMappingURL=add-declaration-to-root-module.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { Rule } from "@angular-devkit/schematics";
|
|
2
|
-
import { MagicOptionScheme } from "../magic-utils/rules/magic-option.scheme";
|
|
3
|
-
export declare function mgAddTasks(options: MagicOptionScheme): Rule;
|
|
1
|
+
import { Rule } from "@angular-devkit/schematics";
|
|
2
|
+
import { MagicOptionScheme } from "../magic-utils/rules/magic-option.scheme";
|
|
3
|
+
export declare function mgAddTasks(options: MagicOptionScheme): Rule;
|
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.mgAddTasks = void 0;
|
|
4
|
-
const tasks_1 = require("@angular-devkit/schematics/tasks");
|
|
5
|
-
const env_1 = require("../magic-utils/env");
|
|
6
|
-
function mgAddTasks(options) {
|
|
7
|
-
return (host, context) => {
|
|
8
|
-
console.log(" [V - add install dependencies !] options.cliVersion=" + options.cliVersion);
|
|
9
|
-
env_1.devDependencies.push(new env_1.Idependencies("@magic-xpa/cli", options.cliVersion));
|
|
10
|
-
// install the devDependencies
|
|
11
|
-
const devInstallTask = context.addTask(new tasks_1.RunSchematicTask('mg-install', {
|
|
12
|
-
skipInstall: false,
|
|
13
|
-
skipPackageJson: false,
|
|
14
|
-
dependencies: [],
|
|
15
|
-
devDependencies: env_1.devDependencies
|
|
16
|
-
}));
|
|
17
|
-
console.log(" [V - add install dependencies !] options.angularVersion=" + options.angularVersion);
|
|
18
|
-
env_1.dependencies.push(new env_1.Idependencies("@magic-xpa/angular", options.angularVersion));
|
|
19
|
-
// install the dependencies
|
|
20
|
-
const packagesInstallTask = context.addTask(new tasks_1.RunSchematicTask('mg-install', {
|
|
21
|
-
skipInstall: options.skipInstall,
|
|
22
|
-
skipPackageJson: options.skipPackageJson,
|
|
23
|
-
dependencies: env_1.dependencies,
|
|
24
|
-
devDependencies: []
|
|
25
|
-
}), [devInstallTask]);
|
|
26
|
-
const deleteFilesTask = context.addTask(new tasks_1.RunSchematicTask('delete-files', options), [devInstallTask, packagesInstallTask]);
|
|
27
|
-
const ngAddTask = context.addTask(new tasks_1.RunSchematicTask('mg-add', options), [devInstallTask, packagesInstallTask, deleteFilesTask]);
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
exports.mgAddTasks = mgAddTasks;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mgAddTasks = void 0;
|
|
4
|
+
const tasks_1 = require("@angular-devkit/schematics/tasks");
|
|
5
|
+
const env_1 = require("../magic-utils/env");
|
|
6
|
+
function mgAddTasks(options) {
|
|
7
|
+
return (host, context) => {
|
|
8
|
+
console.log(" [V - add install dependencies !] options.cliVersion=" + options.cliVersion);
|
|
9
|
+
env_1.devDependencies.push(new env_1.Idependencies("@magic-xpa/cli", options.cliVersion));
|
|
10
|
+
// install the devDependencies
|
|
11
|
+
const devInstallTask = context.addTask(new tasks_1.RunSchematicTask('mg-install', {
|
|
12
|
+
skipInstall: false,
|
|
13
|
+
skipPackageJson: false,
|
|
14
|
+
dependencies: [],
|
|
15
|
+
devDependencies: env_1.devDependencies
|
|
16
|
+
}));
|
|
17
|
+
console.log(" [V - add install dependencies !] options.angularVersion=" + options.angularVersion);
|
|
18
|
+
env_1.dependencies.push(new env_1.Idependencies("@magic-xpa/angular", options.angularVersion));
|
|
19
|
+
// install the dependencies
|
|
20
|
+
const packagesInstallTask = context.addTask(new tasks_1.RunSchematicTask('mg-install', {
|
|
21
|
+
skipInstall: options.skipInstall,
|
|
22
|
+
skipPackageJson: options.skipPackageJson,
|
|
23
|
+
dependencies: env_1.dependencies,
|
|
24
|
+
devDependencies: []
|
|
25
|
+
}), [devInstallTask]);
|
|
26
|
+
const deleteFilesTask = context.addTask(new tasks_1.RunSchematicTask('delete-files', options), [devInstallTask, packagesInstallTask]);
|
|
27
|
+
const ngAddTask = context.addTask(new tasks_1.RunSchematicTask('mg-add', options), [devInstallTask, packagesInstallTask, deleteFilesTask]);
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
exports.mgAddTasks = mgAddTasks;
|
|
31
31
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { Rule } from "@angular-devkit/schematics";
|
|
2
|
-
import { MagicOptionScheme } from "../magic-utils/rules/magic-option.scheme";
|
|
3
|
-
export declare function mgDeleteFiles(options: MagicOptionScheme): Rule;
|
|
1
|
+
import { Rule } from "@angular-devkit/schematics";
|
|
2
|
+
import { MagicOptionScheme } from "../magic-utils/rules/magic-option.scheme";
|
|
3
|
+
export declare function mgDeleteFiles(options: MagicOptionScheme): Rule;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.mgDeleteFiles = void 0;
|
|
4
|
-
const schematics_1 = require("@angular-devkit/schematics");
|
|
5
|
-
const init_magic_metadata_rule_1 = require("../magic-utils/rules/init-magic-metadata.rule");
|
|
6
|
-
const utils_1 = require("../magic-utils/utils");
|
|
7
|
-
function mgDeleteFiles(options) {
|
|
8
|
-
return (0, schematics_1.chain)([
|
|
9
|
-
(0, init_magic_metadata_rule_1.initMagicMetadata)(options),
|
|
10
|
-
(0, utils_1.deleteMagicFiles)(options),
|
|
11
|
-
]);
|
|
12
|
-
}
|
|
13
|
-
exports.mgDeleteFiles = mgDeleteFiles;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mgDeleteFiles = void 0;
|
|
4
|
+
const schematics_1 = require("@angular-devkit/schematics");
|
|
5
|
+
const init_magic_metadata_rule_1 = require("../magic-utils/rules/init-magic-metadata.rule");
|
|
6
|
+
const utils_1 = require("../magic-utils/utils");
|
|
7
|
+
function mgDeleteFiles(options) {
|
|
8
|
+
return (0, schematics_1.chain)([
|
|
9
|
+
(0, init_magic_metadata_rule_1.initMagicMetadata)(options),
|
|
10
|
+
(0, utils_1.deleteMagicFiles)(options),
|
|
11
|
+
]);
|
|
12
|
+
}
|
|
13
|
+
exports.mgDeleteFiles = mgDeleteFiles;
|
|
14
14
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { Rule } from "@angular-devkit/schematics";
|
|
2
|
-
import { MagicOptionScheme } from "../magic-utils/rules/magic-option.scheme";
|
|
3
|
-
export declare function mgGenModule(options: MagicOptionScheme): Rule;
|
|
1
|
+
import { Rule } from "@angular-devkit/schematics";
|
|
2
|
+
import { MagicOptionScheme } from "../magic-utils/rules/magic-option.scheme";
|
|
3
|
+
export declare function mgGenModule(options: MagicOptionScheme): Rule;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.mgGenModule = void 0;
|
|
4
|
-
const schematics_1 = require("@angular-devkit/schematics");
|
|
5
|
-
const init_magic_metadata_rule_1 = require("../magic-utils/rules/init-magic-metadata.rule");
|
|
6
|
-
const init_add_modules_rule_1 = require("../magic-utils/rules/init-add-modules.rule");
|
|
7
|
-
function mgGenModule(options) {
|
|
8
|
-
return (0, schematics_1.chain)([
|
|
9
|
-
(0, init_magic_metadata_rule_1.initMagicMetadata)(options),
|
|
10
|
-
// ** generate the modules in the project **
|
|
11
|
-
(0, init_add_modules_rule_1.initGenModules)(options),
|
|
12
|
-
(0, init_add_modules_rule_1.generateWebModules)(options)
|
|
13
|
-
]);
|
|
14
|
-
}
|
|
15
|
-
exports.mgGenModule = mgGenModule;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mgGenModule = void 0;
|
|
4
|
+
const schematics_1 = require("@angular-devkit/schematics");
|
|
5
|
+
const init_magic_metadata_rule_1 = require("../magic-utils/rules/init-magic-metadata.rule");
|
|
6
|
+
const init_add_modules_rule_1 = require("../magic-utils/rules/init-add-modules.rule");
|
|
7
|
+
function mgGenModule(options) {
|
|
8
|
+
return (0, schematics_1.chain)([
|
|
9
|
+
(0, init_magic_metadata_rule_1.initMagicMetadata)(options),
|
|
10
|
+
// ** generate the modules in the project **
|
|
11
|
+
(0, init_add_modules_rule_1.initGenModules)(options),
|
|
12
|
+
(0, init_add_modules_rule_1.generateWebModules)(options)
|
|
13
|
+
]);
|
|
14
|
+
}
|
|
15
|
+
exports.mgGenModule = mgGenModule;
|
|
16
16
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { Rule } from "@angular-devkit/schematics";
|
|
2
|
-
import { MagicOptionScheme } from "../magic-utils/rules/magic-option.scheme";
|
|
3
|
-
export declare function mgGenerate(options: MagicOptionScheme): Rule;
|
|
1
|
+
import { Rule } from "@angular-devkit/schematics";
|
|
2
|
+
import { MagicOptionScheme } from "../magic-utils/rules/magic-option.scheme";
|
|
3
|
+
export declare function mgGenerate(options: MagicOptionScheme): Rule;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.mgGenerate = void 0;
|
|
4
|
-
const schematics_1 = require("@angular-devkit/schematics");
|
|
5
|
-
const init_magic_metadata_rule_1 = require("../magic-utils/rules/init-magic-metadata.rule");
|
|
6
|
-
const init_gen_components_rule_1 = require("../magic-utils/rules/init-gen-components.rule");
|
|
7
|
-
function mgGenerate(options) {
|
|
8
|
-
return (0, schematics_1.chain)([
|
|
9
|
-
(0, init_magic_metadata_rule_1.initMagicMetadata)(options),
|
|
10
|
-
(0, init_gen_components_rule_1.initAndGenComponentsForModule)(options, true)
|
|
11
|
-
]);
|
|
12
|
-
}
|
|
13
|
-
exports.mgGenerate = mgGenerate;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mgGenerate = void 0;
|
|
4
|
+
const schematics_1 = require("@angular-devkit/schematics");
|
|
5
|
+
const init_magic_metadata_rule_1 = require("../magic-utils/rules/init-magic-metadata.rule");
|
|
6
|
+
const init_gen_components_rule_1 = require("../magic-utils/rules/init-gen-components.rule");
|
|
7
|
+
function mgGenerate(options) {
|
|
8
|
+
return (0, schematics_1.chain)([
|
|
9
|
+
(0, init_magic_metadata_rule_1.initMagicMetadata)(options),
|
|
10
|
+
(0, init_gen_components_rule_1.initAndGenComponentsForModule)(options, true)
|
|
11
|
+
]);
|
|
12
|
+
}
|
|
13
|
+
exports.mgGenerate = mgGenerate;
|
|
14
14
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { Rule } from "@angular-devkit/schematics";
|
|
2
|
-
import { MagicOptionScheme } from "../magic-utils/rules/magic-option.scheme";
|
|
3
|
-
export declare function mgGenerateComponent(options: MagicOptionScheme): Rule;
|
|
1
|
+
import { Rule } from "@angular-devkit/schematics";
|
|
2
|
+
import { MagicOptionScheme } from "../magic-utils/rules/magic-option.scheme";
|
|
3
|
+
export declare function mgGenerateComponent(options: MagicOptionScheme): Rule;
|