@magic-xpa/cli 4.801.0-dev481.245 → 4.801.0-dev481.253
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.js +1 -1
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/src/collection.json +2 -1
- package/src/public_api.js +3 -3
- package/src/public_api.js.map +1 -1
- package/src/schematics/magic-utils/env.js +5 -5
- package/src/schematics/magic-utils/env.js.map +1 -1
- package/src/schematics/magic-utils/env.ts +5 -5
- package/src/schematics/magic-utils/metadata.class.js +3 -3
- package/src/schematics/magic-utils/metadata.class.js.map +1 -1
- package/src/schematics/magic-utils/process-json.js +4 -4
- package/src/schematics/magic-utils/process-json.js.map +1 -1
- package/src/schematics/magic-utils/rules/build-control.rule.js +4 -4
- package/src/schematics/magic-utils/rules/build-control.rule.js.map +1 -1
- package/src/schematics/magic-utils/rules/build-view.rule.js +4 -4
- package/src/schematics/magic-utils/rules/build-view.rule.js.map +1 -1
- package/src/schematics/magic-utils/rules/component-list.rule.js +29 -50
- package/src/schematics/magic-utils/rules/component-list.rule.js.map +1 -1
- package/src/schematics/magic-utils/rules/component-list.rule.ts +2 -28
- package/src/schematics/magic-utils/rules/generate.rule.js +3 -3
- package/src/schematics/magic-utils/rules/generate.rule.js.map +1 -1
- package/src/schematics/magic-utils/rules/init-add-modules.rule.js +40 -24
- package/src/schematics/magic-utils/rules/init-add-modules.rule.js.map +1 -1
- package/src/schematics/magic-utils/rules/init-add-modules.rule.ts +21 -1
- package/src/schematics/magic-utils/rules/init-gen-components.rule.js +9 -9
- package/src/schematics/magic-utils/rules/init-gen-components.rule.js.map +1 -1
- package/src/schematics/magic-utils/rules/init-magic-metadata.rule.js +2 -2
- package/src/schematics/magic-utils/rules/init-magic-metadata.rule.js.map +1 -1
- package/src/schematics/magic-utils/rules/load-views-gen.rule.js +5 -5
- package/src/schematics/magic-utils/rules/load-views-gen.rule.js.map +1 -1
- package/src/schematics/magic-utils/utils.js +10 -10
- package/src/schematics/magic-utils/utils.js.map +1 -1
- package/src/schematics/mg-Install-prerequisites/index.js +3 -3
- package/src/schematics/mg-Install-prerequisites/index.js.map +1 -1
- package/src/schematics/mg-Install-prerequisites/schema.json +1 -1
- package/src/schematics/mg-add/files/src/app/magic/lazy-loader.service.ts +10 -0
- package/src/schematics/mg-add/index.js +52 -16
- package/src/schematics/mg-add/index.js.map +1 -1
- package/src/schematics/mg-add/index.ts +42 -3
- package/src/schematics/mg-add/schema.json +1 -1
- package/src/schematics/mg-add/utils/add-declaration-to-root-module.js +2 -2
- package/src/schematics/mg-add/utils/add-declaration-to-root-module.js.map +1 -1
- package/src/schematics/mg-add-tasks/schema.json +1 -1
- package/src/schematics/mg-delete-files/index.js +3 -3
- package/src/schematics/mg-delete-files/index.js.map +1 -1
- package/src/schematics/mg-delete-files/schema.json +1 -1
- package/src/schematics/mg-gen-module/index.js +4 -4
- package/src/schematics/mg-gen-module/index.js.map +1 -1
- package/src/schematics/mg-gen-module/schema.json +1 -1
- package/src/schematics/mg-generate/index.js +3 -3
- package/src/schematics/mg-generate/index.js.map +1 -1
- package/src/schematics/mg-generate/schema.json +1 -1
- package/src/schematics/mg-install/index.js +2 -2
- package/src/schematics/mg-install/index.js.map +1 -1
- package/src/schematics/mg-install/schema.json +1 -1
- package/src/schematics/mg-routes/index.js +6 -6
- package/src/schematics/mg-routes/index.js.map +1 -1
- package/src/schematics/mg-routes/schema.json +1 -1
- package/src/schematics/mg-single-control/index.js +4 -4
- package/src/schematics/mg-single-control/index.js.map +1 -1
- package/src/schematics/mg-single-control/schema.json +1 -1
- package/src/schematics/utils/ast.js +6 -6
- package/src/schematics/utils/ast.js.map +1 -1
- package/src/schematics/utils/devkit-utils/ast-utils_old.js +2 -2
- package/src/schematics/utils/devkit-utils/ast-utils_old.js.map +1 -1
- package/src/schematics/utils/devkit-utils/component.js +16 -16
- package/src/schematics/utils/devkit-utils/component.js.map +1 -1
- package/src/schematics/utils/devkit-utils/find-module.js +11 -11
- package/src/schematics/utils/devkit-utils/find-module.js.map +1 -1
- package/src/schematics/utils/devkit-utils/ng-ast-utils.js +6 -6
- package/src/schematics/utils/devkit-utils/ng-ast-utils.js.map +1 -1
- package/src/schematics/utils/devkit-utils/parse-name.js +3 -3
- package/src/schematics/utils/devkit-utils/parse-name.js.map +1 -1
- package/src/schematics/utils/devkit-utils/route-utils.js +16 -16
- package/src/schematics/utils/devkit-utils/route-utils.js.map +1 -1
- package/src/schematics/utils/html.js +1 -1
- package/src/schematics/utils/html.js.map +1 -1
- package/src/schematics/utils/testing.js +1 -1
- package/src/schematics/utils/testing.js.map +1 -1
- package/src/types/enums/Enums.js +5 -1
- package/src/types/enums/Enums.js.map +1 -1
- package/src/types/index.js +7 -7
- package/src/types/index.js.map +1 -1
|
@@ -18,15 +18,14 @@ let toAddImports = true;
|
|
|
18
18
|
let orgPreventLog = env_1.env.prevent_log;
|
|
19
19
|
function componentlistGen(options, module_name, loadOnDemand) {
|
|
20
20
|
return (host, context) => {
|
|
21
|
-
Util_1.LogLn(`[>] Step 4: components-list.`);
|
|
22
|
-
return schematics_1.chain([
|
|
21
|
+
(0, Util_1.LogLn)(`[>] Step 4: components-list.`);
|
|
22
|
+
return (0, schematics_1.chain)([
|
|
23
23
|
addNewCmpsToCmpListOrGenAll(options, module_name),
|
|
24
24
|
addCmpsImportsToCmpList(options, module_name),
|
|
25
25
|
createLazyModuleMap(options, module_name),
|
|
26
26
|
addLazyLoadComponentList(options, module_name, loadOnDemand),
|
|
27
27
|
addLazyModuleToMagicGen(options),
|
|
28
|
-
addImportForLazyModule(options)
|
|
29
|
-
modifyAngularJson(options, module_name, loadOnDemand)
|
|
28
|
+
addImportForLazyModule(options)
|
|
30
29
|
])(host, context);
|
|
31
30
|
};
|
|
32
31
|
}
|
|
@@ -41,7 +40,7 @@ function createLazyModuleMap(options, module_name) {
|
|
|
41
40
|
const LazyMOduleArrayEnd = '};';
|
|
42
41
|
// create lazy load component array if it does not exist
|
|
43
42
|
if (source.indexOf(LazyModuleArrayStart) < 0) {
|
|
44
|
-
Util_1.LogLn(`[>] Creating LazyLoadModulesMap `);
|
|
43
|
+
(0, Util_1.LogLn)(`[>] Creating LazyLoadModulesMap `);
|
|
45
44
|
// add the code of creating map in file
|
|
46
45
|
host.overwrite(cmpListPath, source + "\r\n" + LazyModuleArrayStart + LazyMOduleArrayEnd);
|
|
47
46
|
}
|
|
@@ -55,13 +54,13 @@ function addLazyLoadComponentList(options, module_name, loadOnDemand) {
|
|
|
55
54
|
const cmpListPath = env_1.env.metadata.paths.componentListPath("");
|
|
56
55
|
const source = host.read(cmpListPath);
|
|
57
56
|
if (source) {
|
|
58
|
-
let cmpListSource = ast_1.getSourceFile(host, cmpListPath);
|
|
57
|
+
let cmpListSource = (0, ast_1.getSourceFile)(host, cmpListPath);
|
|
59
58
|
let cmpListTs = getLazyLoadCompoenentsInfo(cmpListSource, env_1.GEN_LAZY_LOAD_MODULES_ARRAY);
|
|
60
59
|
let sourceStep1 = host.read(cmpListPath).toString("utf-8");
|
|
61
60
|
env_1.env.app.views.forEach(view => {
|
|
62
|
-
if (util_1.isNullOrUndefined(cmpListTs.components) || !(cmpListTs.components.includes(view.props.component_uniquename))) {
|
|
61
|
+
if ((0, util_1.isNullOrUndefined)(cmpListTs.components) || !(cmpListTs.components.includes(view.props.component_uniquename))) {
|
|
63
62
|
lazyLoadedComponents.push(view); // if component does not exist add it to list
|
|
64
|
-
Util_1.LogLn(`[>] Add ${view.props.component_uniquename} component to LazyLoadModulesMap`);
|
|
63
|
+
(0, Util_1.LogLn)(`[>] Add ${view.props.component_uniquename} component to LazyLoadModulesMap`);
|
|
65
64
|
}
|
|
66
65
|
});
|
|
67
66
|
// add components to map
|
|
@@ -79,8 +78,8 @@ function addImportForLazyModule(options) {
|
|
|
79
78
|
return (tree, context) => {
|
|
80
79
|
let genLibPath = env_1.env.metadata.paths.rootMagicGenFolder + '/magic/magic.gen.lib.module.ts';
|
|
81
80
|
const recorder = tree.beginUpdate(genLibPath);
|
|
82
|
-
let genLibSource = ast_1.getSourceFile(tree, genLibPath);
|
|
83
|
-
const importChange = route_utils_1.insertImport(genLibSource, genLibPath, env_1.GEN_LAZY_LOAD_MODULES_ARRAY, './component-list.g');
|
|
81
|
+
let genLibSource = (0, ast_1.getSourceFile)(tree, genLibPath);
|
|
82
|
+
const importChange = (0, route_utils_1.insertImport)(genLibSource, genLibPath, env_1.GEN_LAZY_LOAD_MODULES_ARRAY, './component-list.g');
|
|
84
83
|
if (importChange.toAdd) {
|
|
85
84
|
recorder.insertLeft(importChange.pos, importChange.toAdd);
|
|
86
85
|
}
|
|
@@ -92,7 +91,7 @@ function addLazyModuleToMagicGen(options) {
|
|
|
92
91
|
return (tree, context) => {
|
|
93
92
|
let origModuleFileName = env_1.env.metadata.paths.rootMagicGenFolder + '/magic/magic.gen.lib.module.ts';
|
|
94
93
|
if (!tree.exists(origModuleFileName)) {
|
|
95
|
-
Util_1.LogLn(` [>Error] File cannot be overwrite, The file is not exist !!! : ${origModuleFileName}`);
|
|
94
|
+
(0, Util_1.LogLn)(` [>Error] File cannot be overwrite, The file is not exist !!! : ${origModuleFileName}`);
|
|
96
95
|
}
|
|
97
96
|
const text = tree.read(origModuleFileName);
|
|
98
97
|
if (text === null) {
|
|
@@ -101,9 +100,9 @@ function addLazyModuleToMagicGen(options) {
|
|
|
101
100
|
let sourceText = text.toString('utf-8');
|
|
102
101
|
const lazyModuleStatement = '\r\n componentList.lazyLoadModulesMap = ' + env_1.GEN_LAZY_LOAD_MODULES_ARRAY + ';';
|
|
103
102
|
if (sourceText !== "" && sourceText.indexOf(lazyModuleStatement) == -1) {
|
|
104
|
-
let genLibSource = ast_1.getSourceFile(tree, origModuleFileName);
|
|
103
|
+
let genLibSource = (0, ast_1.getSourceFile)(tree, origModuleFileName);
|
|
105
104
|
let newLazyModuleText = sourceText.replace(lazyModuleStatement, '').trim();
|
|
106
|
-
const constNode = ast_utils_1.findNodes(genLibSource, ts.SyntaxKind.Constructor)[0];
|
|
105
|
+
const constNode = (0, ast_utils_1.findNodes)(genLibSource, ts.SyntaxKind.Constructor)[0];
|
|
107
106
|
let lastStatementEnd = constNode.body.statements.end;
|
|
108
107
|
const prefix = sourceText.substring(0, lastStatementEnd);
|
|
109
108
|
const suffix = sourceText.substring(lastStatementEnd);
|
|
@@ -112,25 +111,6 @@ function addLazyModuleToMagicGen(options) {
|
|
|
112
111
|
return tree;
|
|
113
112
|
};
|
|
114
113
|
}
|
|
115
|
-
// Update the angular json filr
|
|
116
|
-
function modifyAngularJson(options, module_name, loadOnDemand) {
|
|
117
|
-
return (host, context) => {
|
|
118
|
-
if (loadOnDemand) {
|
|
119
|
-
// get the module path to we added in angular json
|
|
120
|
-
let currentModulePath = env_1.env.metadata.paths.magicGenLibModulePath(module_name);
|
|
121
|
-
// create the lazyModules array if it does not exits
|
|
122
|
-
if (util_1.isNullOrUndefined(env_1.env.project.architect.build.options.lazyModules))
|
|
123
|
-
env_1.env.project.architect.build.options.lazyModules = new Array();
|
|
124
|
-
// add the modulepath to lazyModules if it is not already present
|
|
125
|
-
if (!env_1.env.project.architect.build.options.lazyModules.includes(currentModulePath)) {
|
|
126
|
-
env_1.env.project.architect.build.options.lazyModules.push(currentModulePath);
|
|
127
|
-
}
|
|
128
|
-
// get angular json path
|
|
129
|
-
let angularJsonPath = env_1.env.metadata.paths.angularJsonPath;
|
|
130
|
-
host.overwrite(angularJsonPath, JSON.stringify(env_1.env.workspace, null, 2));
|
|
131
|
-
}
|
|
132
|
-
};
|
|
133
|
-
}
|
|
134
114
|
/*
|
|
135
115
|
* Add new component to component-list.g file (Array and Hash).
|
|
136
116
|
* If the file not exist new file will create by componentListGenIfNotExist function.
|
|
@@ -144,7 +124,7 @@ function addNewCmpsToCmpListOrGenAll(options, module_name) {
|
|
|
144
124
|
if (source) {
|
|
145
125
|
let cmpToGenNum = 0;
|
|
146
126
|
let sourceStep1 = source.toString("utf-8");
|
|
147
|
-
let cmpListSource = ast_1.getSourceFile(host, cmpListPath);
|
|
127
|
+
let cmpListSource = (0, ast_1.getSourceFile)(host, cmpListPath);
|
|
148
128
|
let cmpListTs = getComponentsArrayInfo(cmpListSource, env_1.GEN_COMPONENTS_ARRAY);
|
|
149
129
|
existCmpListSet = new Set(cmpListTs.components);
|
|
150
130
|
newCmpListSet = new Set();
|
|
@@ -159,7 +139,7 @@ function addNewCmpsToCmpListOrGenAll(options, module_name) {
|
|
|
159
139
|
let sourceStep2 = addComponentsToArray(sourceStep1, cmpListTs, newCmpListArray);
|
|
160
140
|
let cmpListHashTs = getComponentsHashInfo(cmpListSource, env_1.GEN_COMPONENTS_HASH);
|
|
161
141
|
let sourceStep3 = addComponentsToHash(sourceStep2, cmpListHashTs, newCmpListArray);
|
|
162
|
-
Util_1.LogLn(` Total old components: ${existCmpListSet.size}, added components: ${newCmpListSet.size}. `);
|
|
142
|
+
(0, Util_1.LogLn)(` Total old components: ${existCmpListSet.size}, added components: ${newCmpListSet.size}. `);
|
|
163
143
|
host.overwrite(cmpListPath, sourceStep3);
|
|
164
144
|
}
|
|
165
145
|
}
|
|
@@ -190,8 +170,8 @@ function componentListGenIfNotExist(options) {
|
|
|
190
170
|
type: types_1.GeneratedFileTypes.TS,
|
|
191
171
|
data: data
|
|
192
172
|
};
|
|
193
|
-
return schematics_1.chain([
|
|
194
|
-
generate_rule_1.generate(componentFile, options)
|
|
173
|
+
return (0, schematics_1.chain)([
|
|
174
|
+
(0, generate_rule_1.generate)(componentFile, options)
|
|
195
175
|
])(host, context);
|
|
196
176
|
};
|
|
197
177
|
}
|
|
@@ -202,14 +182,14 @@ function addCmpsImportsToCmpList(options, module_name) {
|
|
|
202
182
|
return (host, context) => {
|
|
203
183
|
if (toAddImports) {
|
|
204
184
|
const cmpsToGen = env_1.env.app.views;
|
|
205
|
-
let cmpListSource = ast_1.getSourceFile(host, env_1.env.metadata.paths.componentListPath(module_name));
|
|
185
|
+
let cmpListSource = (0, ast_1.getSourceFile)(host, env_1.env.metadata.paths.componentListPath(module_name));
|
|
206
186
|
const recorder = host.beginUpdate(env_1.env.metadata.paths.componentListPath(module_name));
|
|
207
187
|
cmpsToGen.forEach(cmp => {
|
|
208
188
|
let name = cmp.props.id;
|
|
209
189
|
let uniqueName = cmp.props.component_uniquename;
|
|
210
190
|
let cmpPath = cmp.props.component_path;
|
|
211
191
|
if (newCmpListSet.has(uniqueName)) {
|
|
212
|
-
const importsChange = route_utils_1.insertImport2(cmpListSource, env_1.env.metadata.paths.componentListPath(module_name), name, uniqueName, `./${cmpPath}${name}.component`);
|
|
192
|
+
const importsChange = (0, route_utils_1.insertImport2)(cmpListSource, env_1.env.metadata.paths.componentListPath(module_name), name, uniqueName, `./${cmpPath}${name}.component`);
|
|
213
193
|
if (importsChange.toAdd) {
|
|
214
194
|
recorder.insertLeft(importsChange.pos, importsChange.toAdd);
|
|
215
195
|
}
|
|
@@ -222,17 +202,17 @@ function addCmpsImportsToCmpList(options, module_name) {
|
|
|
222
202
|
}
|
|
223
203
|
function getComponentsHashInfo(source, variable) {
|
|
224
204
|
const rootNode = source;
|
|
225
|
-
const cmpListVars = ast_utils_1.findNodes(rootNode, ts.SyntaxKind.VariableDeclaration);
|
|
205
|
+
const cmpListVars = (0, ast_utils_1.findNodes)(rootNode, ts.SyntaxKind.VariableDeclaration);
|
|
226
206
|
let endPos = -1;
|
|
227
207
|
let isEmpty = true;
|
|
228
208
|
let magicGenCmpsInfo = cmpListVars.filter((node) => node.name.escapedText === variable);
|
|
229
209
|
if (magicGenCmpsInfo && magicGenCmpsInfo.length > 0) {
|
|
230
|
-
const firstPunctuation = ast_utils_1.findNodes(magicGenCmpsInfo[0], ts.SyntaxKind.FirstPunctuation);
|
|
210
|
+
const firstPunctuation = (0, ast_utils_1.findNodes)(magicGenCmpsInfo[0], ts.SyntaxKind.FirstPunctuation);
|
|
231
211
|
if (!(firstPunctuation && firstPunctuation.length > 0)) {
|
|
232
212
|
throw new Error('magicGenCmpsHash variable has no open bracket ( { )');
|
|
233
213
|
}
|
|
234
214
|
endPos = firstPunctuation[0].end;
|
|
235
|
-
const propertyAssignment = ast_utils_1.findNodes(firstPunctuation[0].parent, ts.SyntaxKind.PropertyAssignment);
|
|
215
|
+
const propertyAssignment = (0, ast_utils_1.findNodes)(firstPunctuation[0].parent, ts.SyntaxKind.PropertyAssignment);
|
|
236
216
|
if (propertyAssignment && propertyAssignment.length > 0) {
|
|
237
217
|
isEmpty = false;
|
|
238
218
|
}
|
|
@@ -245,18 +225,18 @@ function getComponentsHashInfo(source, variable) {
|
|
|
245
225
|
}
|
|
246
226
|
function getComponentsArrayInfo(source, variable) {
|
|
247
227
|
const rootNode = source;
|
|
248
|
-
const cmpListVars = ast_utils_1.findNodes(rootNode, ts.SyntaxKind.VariableDeclaration);
|
|
228
|
+
const cmpListVars = (0, ast_utils_1.findNodes)(rootNode, ts.SyntaxKind.VariableDeclaration);
|
|
249
229
|
let endPos = -1;
|
|
250
230
|
let cmpListArray;
|
|
251
231
|
let isEmpty = true;
|
|
252
232
|
let magicGenCmpsInfo = cmpListVars.filter((node) => node.name.escapedText === variable);
|
|
253
233
|
if (magicGenCmpsInfo && magicGenCmpsInfo.length > 0) {
|
|
254
|
-
const openBracketToken = ast_utils_1.findNodes(magicGenCmpsInfo[0], ts.SyntaxKind.OpenBracketToken);
|
|
234
|
+
const openBracketToken = (0, ast_utils_1.findNodes)(magicGenCmpsInfo[0], ts.SyntaxKind.OpenBracketToken);
|
|
255
235
|
if (!(openBracketToken && openBracketToken.length > 0)) {
|
|
256
236
|
throw new Error('magicGenComponents variable has no open bracket ([)');
|
|
257
237
|
}
|
|
258
238
|
endPos = openBracketToken[0].end;
|
|
259
|
-
const identifiers = ast_utils_1.findNodes(openBracketToken[0].parent, ts.SyntaxKind.Identifier);
|
|
239
|
+
const identifiers = (0, ast_utils_1.findNodes)(openBracketToken[0].parent, ts.SyntaxKind.Identifier);
|
|
260
240
|
// Array with items
|
|
261
241
|
if (identifiers && identifiers.length > 0) {
|
|
262
242
|
isEmpty = false;
|
|
@@ -275,19 +255,19 @@ function getComponentsArrayInfo(source, variable) {
|
|
|
275
255
|
};
|
|
276
256
|
}
|
|
277
257
|
function getLazyLoadCompoenentsInfo(source, variable) {
|
|
278
|
-
const cmpListVars = ast_utils_1.findNodes(source, ts.SyntaxKind.VariableDeclaration);
|
|
258
|
+
const cmpListVars = (0, ast_utils_1.findNodes)(source, ts.SyntaxKind.VariableDeclaration);
|
|
279
259
|
let endPos = -1;
|
|
280
260
|
let cmpListArray;
|
|
281
261
|
let isEmpty = true;
|
|
282
262
|
let magicGenCmpsInfo = cmpListVars.filter((node) => node.name.escapedText === variable);
|
|
283
263
|
if (magicGenCmpsInfo && magicGenCmpsInfo.length > 0) {
|
|
284
|
-
const openBracketToken = ast_utils_1.findNodes(magicGenCmpsInfo[0], ts.SyntaxKind.FirstPunctuation);
|
|
264
|
+
const openBracketToken = (0, ast_utils_1.findNodes)(magicGenCmpsInfo[0], ts.SyntaxKind.FirstPunctuation);
|
|
285
265
|
if (!(openBracketToken && openBracketToken.length > 0)) {
|
|
286
266
|
throw new Error('FirstPunctuation variable has no open bracket ([)');
|
|
287
267
|
}
|
|
288
268
|
endPos = openBracketToken[0].end;
|
|
289
|
-
const identifiers = ast_utils_1.findNodes(openBracketToken[0].parent, ts.SyntaxKind.PropertyAssignment);
|
|
290
|
-
const identifiers1 = ast_utils_1.findNodes(openBracketToken[0].parent, ts.SyntaxKind.Identifier);
|
|
269
|
+
const identifiers = (0, ast_utils_1.findNodes)(openBracketToken[0].parent, ts.SyntaxKind.PropertyAssignment);
|
|
270
|
+
const identifiers1 = (0, ast_utils_1.findNodes)(openBracketToken[0].parent, ts.SyntaxKind.Identifier);
|
|
291
271
|
// Array with items
|
|
292
272
|
if (identifiers && identifiers.length > 0) {
|
|
293
273
|
isEmpty = false;
|
|
@@ -331,8 +311,7 @@ function addComponentsToLazyLoad(source, info, cmpsToAdd, module_name) {
|
|
|
331
311
|
let currentModulePath = env_1.env.metadata.paths.magicGenLibModulePath(module_name);
|
|
332
312
|
const cmpHashStr = EJS.render(`
|
|
333
313
|
<%{components.forEach(view =>{-%>
|
|
334
|
-
<%=view.props.component_uniquename %> : { moduleName : 'Magic<%=moduleName%>Module',
|
|
335
|
-
modulePath : '<%=modulePath%>'},
|
|
314
|
+
<%=view.props.component_uniquename %> : { moduleName : 'Magic<%=moduleName%>Module'},
|
|
336
315
|
<%})}-%>`, { components: cmpsToAdd, moduleName: module_name, modulePath: currentModulePath });
|
|
337
316
|
let toAdd = `${cmpHashStr.replace(/\n/g, '').replace(/,/g, ",\n")}`;
|
|
338
317
|
// update source
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component-list.rule.js","sourceRoot":"","sources":["component-list.rule.ts"],"names":[],"mappings":";;;AAAA,iCAAiC;AACjC,2BAA2B;AAC3B,2DAAoG;AACpG,gCAAmG;AAEnG,0CAAoF;AACpF,mDAAyC;AACzC,yCAA8C;AAC9C,sEAAiF;AAEjF,kEAA6D;AAC7D,kCAA8B;AAC9B,+BAAuC;AAGvC,IAAI,eAA4B,CAAC;AACjC,IAAI,aAAa,GAAG,IAAI,GAAG,EAAE,CAAC;AAC9B,IAAI,YAAY,GAAY,IAAI,CAAC;AACjC,IAAI,aAAa,GAAG,SAAG,CAAC,WAAW,CAAC;AAGpC,SAAgB,gBAAgB,CAAC,OAA0B,EAAE,WAAmB,EAAE,YAAqB;IACrG,OAAO,CAAC,IAAU,EAAE,OAAyB,EAAE,EAAE;QAC/C,YAAK,CAAC,8BAA8B,CAAC,CAAC;QACtC,OAAO,kBAAK,CAAC;YACX,2BAA2B,CAAC,OAAO,EAAE,WAAW,CAAC;YACjD,uBAAuB,CAAC,OAAO,EAAE,WAAW,CAAC;YAC7C,mBAAmB,CAAC,OAAO,EAAE,WAAW,CAAC;YACzC,wBAAwB,CAAC,OAAO,EAAE,WAAW,EAAE,YAAY,CAAC;YAC5D,uBAAuB,CAAC,OAAO,CAAC;YAChC,sBAAsB,CAAC,OAAO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chematicContext, SchematicsException, Tree} from \"@angular-devkit/schematics\";\r\nimport {env, GEN_COMPONENTS_ARRAY, GEN_COMPONENTS_HASH, GEN_LAZY_LOAD_MODULES_ARRAY} from \"../env\";\r\nimport {MagicOptionScheme} from \"./magic-option.scheme\";\r\nimport {GeneratedFileTypes, TemplateConfig, View, WindowType} from \"../../../types\";\r\nimport {generate} from \"./generate.rule\";\r\nimport {getSourceFile} from \"../../utils/ast\";\r\nimport {insertImport, insertImport2} from \"../../utils/devkit-utils/route-utils\";\r\nimport {InsertChange} from \"../../utils/devkit-utils/change\";\r\nimport {findNodes} from \"../../utils/devkit-utils/ast-utils\";\r\nimport {LogLn} from \"../Util\";\r\nimport {isNullOrUndefined} from \"util\";\r\n\r\n\r\nlet existCmpListSet: Set<string>;\r\nlet newCmpListSet = new Set();\r\nlet toAddImports: boolean = true;\r\nlet orgPreventLog = env.prevent_log;\r\n\r\n\r\nexport function componentlistGen(options: MagicOptionScheme, module_name: string, loadOnDemand: boolean): Rule {\r\n return (host: Tree, context: SchematicContext) => {\r\n LogLn(`[>] Step 4: components-list.`);\r\n return chain([\r\n addNewCmpsToCmpListOrGenAll(options, module_name),\r\n addCmpsImportsToCmpList(options, module_name),\r\n createLazyModuleMap(options, module_name),\r\n addLazyLoadComponentList(options, module_name, loadOnDemand),\r\n addLazyModuleToMagicGen(options),\r\n addImportForLazyModule(options),\r\n modifyAngularJson(options, module_name, loadOnDemand)\r\n ])(host, context);\r\n }\r\n}\r\n\r\n// create the lazy load map if it does not exist\r\nfunction createLazyModuleMap(options: MagicOptionScheme, module_name: string) {\r\n return (host: Tree, context: SchematicContext) => {\r\n const cmpListPath = env.metadata.paths.componentListPath(\"\");\r\n env.prevent_log = false;\r\n const source = host.read(cmpListPath).toString(\"utf-8\")\r\n\r\n const LazyModuleArrayStart = 'export const ' + GEN_LAZY_LOAD_MODULES_ARRAY + ' = {';\r\n const LazyMOduleArrayEnd = '};';\r\n // create lazy load component array if it does not exist\r\n if (source.indexOf(LazyModuleArrayStart) < 0) {\r\n LogLn(`[>] Creating LazyLoadModulesMap `);\r\n // add the code of creating map in file\r\n host.overwrite(cmpListPath, source + \"\\r\\n\" + LazyModuleArrayStart + LazyMOduleArrayEnd);\r\n }\r\n\r\n }\r\n}\r\n\r\n// add the lazy load components\r\nfunction addLazyLoadComponentList(options: MagicOptionScheme, module_name: string, loadOnDemand: boolean): Rule {\r\n return (host: Tree, context: SchematicContext) => {\r\n if (loadOnDemand) {\r\n let lazyLoadedComponents: Array<View> = new Array<View>();\r\n const cmpListPath = env.metadata.paths.componentListPath(\"\");\r\n\r\n const source = host.read(cmpListPath);\r\n if (source) {\r\n let cmpListSource = getSourceFile(host, cmpListPath);\r\n\r\n let cmpListTs = getLazyLoadCompoenentsInfo(cmpListSource, GEN_LAZY_LOAD_MODULES_ARRAY);\r\n let sourceStep1 = host.read(cmpListPath).toString(\"utf-8\");\r\n\r\n env.app.views.forEach(view => {\r\n if( isNullOrUndefined(cmpListTs.components) || !(cmpListTs.components.includes(view.props.component_uniquename))) {\r\n lazyLoadedComponents.push(view); // if component does not exist add it to list\r\n LogLn(`[>] Add ${view.props.component_uniquename} component to LazyLoadModulesMap`, );\r\n }\r\n });\r\n\r\n // add components to map\r\n if (lazyLoadedComponents.length > 0) {\r\n let sourceStep2 = addComponentsToLazyLoad(sourceStep1, cmpListTs, lazyLoadedComponents, module_name);\r\n host.overwrite(cmpListPath, sourceStep2);\r\n }\r\n }\r\n env.prevent_log = orgPreventLog;\r\n }\r\n return host;\r\n }\r\n}\r\n\r\nfunction addImportForLazyModule(options) {\r\n return (tree: Tree, context: SchematicContext) => {\r\n\r\n let genLibPath= env.metadata.paths.rootMagicGenFolder + '/magic/magic.gen.lib.module.ts';\r\n const recorder = tree.beginUpdate(genLibPath);\r\n let genLibSource = getSourceFile(tree, genLibPath);\r\n\r\n const importChange = insertImport(genLibSource, genLibPath, GEN_LAZY_LOAD_MODULES_ARRAY, './component-list.g') as InsertChange;\r\n if (importChange.toAdd) {\r\n recorder.insertLeft(importChange.pos, importChange.toAdd);\r\n }\r\n tree.commitUpdate(recorder);\r\n }\r\n}\r\n\r\n// add the lazy load module to magic.gen.lib\r\nfunction addLazyModuleToMagicGen(options) {\r\n return (tree: Tree, context: SchematicContext) => {\r\n\r\n let origModuleFileName= env.metadata.paths.rootMagicGenFolder + '/magic/magic.gen.lib.module.ts';\r\n if(!tree.exists(origModuleFileName)){\r\n LogLn(` [>Error] File cannot be overwrite, The file is not exist !!! : ${origModuleFileName}`);\r\n }\r\n const text = tree.read(origModuleFileName);\r\n\r\n if (text === null) {\r\n throw new SchematicsException(`File ${origModuleFileName} does not exist.`);\r\n }\r\n let sourceText = text.toString('utf-8');\r\n const lazyModuleStatement = '\\r\\n componentList.lazyLoadModulesMap = '+ GEN_LAZY_LOAD_MODULES_ARRAY+';';\r\n if (sourceText !== \"\" && sourceText.indexOf(lazyModuleStatement)== -1) {\r\n let genLibSource = getSourceFile(tree, origModuleFileName);\r\n let newLazyModuleText: string = sourceText.replace(lazyModuleStatement, '').trim();\r\n const constNode: ts.FunctionLikeDeclarationBase = findNodes(genLibSource, ts.SyntaxKind.Constructor)[0] as ts.FunctionLikeDeclarationBase;\r\n\r\n let lastStatementEnd = (<ts.Block>constNode.body).statements.end;\r\n\r\n const prefix = sourceText.substring(0, lastStatementEnd);\r\n const suffix = sourceText.substring(lastStatementEnd );\r\n tree.overwrite(origModuleFileName, `${prefix} ${lazyModuleStatement} ${suffix}` );\r\n\r\n }\r\n return tree;\r\n }\r\n}\r\n\r\n// Update the angular json filr\r\nfunction modifyAngularJson(options: MagicOptionScheme, module_name: string, loadOnDemand: boolean): Rule {\r\n return (host: Tree, context: SchematicContext) => {\r\n if (loadOnDemand) {\r\n\r\n // get the module path to we added in angular json\r\n let currentModulePath = env.metadata.paths.magicGenLibModulePath(module_name);\r\n\r\n // create the lazyModules array if it does not exits\r\n if (isNullOrUndefined(env.project.architect.build.options.lazyModules))\r\n env.project.architect.build.options.lazyModules = new Array();\r\n\r\n // add the modulepath to lazyModules if it is not already present\r\n if (!env.project.architect.build.options.lazyModules.includes(currentModulePath)) {\r\n env.project.architect.build.options.lazyModules.push(currentModulePath);\r\n }\r\n\r\n // get angular json path\r\n let angularJsonPath = env.metadata.paths.angularJsonPath;\r\n host.overwrite(angularJsonPath, JSON.stringify(env.workspace, null, 2));\r\n }\r\n }\r\n}\r\n\r\n/*\r\n* Add new component to component-list.g file (Array and Hash).\r\n* If the file not exist new file will create by componentListGenIfNotExist function.\r\n* */\r\nfunction addNewCmpsToCmpListOrGenAll(options: MagicOptionScheme, module_name: string): Rule {\r\n return (host: Tree, context: SchematicContext) => {\r\n const metadata = env.metadata;\r\n const cmpsToGen = env.app.views;\r\n const cmpListPath = env.metadata.paths.componentListPath(module_name);\r\n const source = host.read(cmpListPath);\r\n if (source) {\r\n let cmpToGenNum = 0;\r\n let sourceStep1 = source.toString(\"utf-8\");\r\n let cmpListSource = getSourceFile(host, cmpListPath);\r\n\r\n let cmpListTs = getComponentsArrayInfo(cmpListSource, GEN_COMPONENTS_ARRAY);\r\n existCmpListSet = new Set(cmpListTs.components);\r\n newCmpListSet = new Set<string>();\r\n\r\n // merge between components in the file and new component to gen\r\n cmpsToGen.forEach(newCmpGen => {\r\n if (!existCmpListSet.has(newCmpGen.props.component_uniquename)) {\r\n newCmpListSet.add(newCmpGen.props.component_uniquename);\r\n }\r\n });\r\n const newCmpListArray: string[] = <string[]>Array.from(newCmpListSet);\r\n if (newCmpListArray && newCmpListArray.length > 0) {\r\n let sourceStep2 = addComponentsToArray(sourceStep1, cmpListTs, newCmpListArray);\r\n\r\n let cmpListHashTs = getComponentsHashInfo(cmpListSource, GEN_COMPONENTS_HASH);\r\n let sourceStep3 = addComponentsToHash(sourceStep2, cmpListHashTs, newCmpListArray);\r\n\r\n LogLn(` Total old components: ${existCmpListSet.size}, added components: ${newCmpListSet.size}. `);\r\n\r\n host.overwrite(cmpListPath, sourceStep3);\r\n }\r\n } else {\r\n // If component-list.g.ts doesn't exist.\r\n toAddImports = false; // We generate the entire file with imports.\r\n return componentListGenIfNotExist(options)(host, context);\r\n }\r\n\r\n return host;\r\n }\r\n}\r\n\r\n/*\r\n* Create new component-list.g file.\r\n* */\r\nfunction componentListGenIfNotExist(options: MagicOptionScheme): Rule {\r\n return (host: Tree, context: SchematicContext) => {\r\n\r\n console.log(\"creating component-list\");\r\n const metadata = env.metadata;\r\n const cmpList = new Set<string>();\r\n const data: any = {\r\n app: env.app,\r\n cmpList: env.app.views\r\n };\r\n\r\n const componentFile: TemplateConfig = {\r\n template: `./templates/angular/src/app/component-list.g.ts`,\r\n name: 'component-list.g.ts',\r\n destination: metadata.paths.magicGenFolderPath,\r\n type: GeneratedFileTypes.TS,\r\n data: data\r\n };\r\n\r\n return chain([\r\n generate(componentFile, options)\r\n ])(host, context);\r\n }\r\n}\r\n\r\n/*\r\n* Add new imports to component-list.g file.\r\n* */\r\nfunction addCmpsImportsToCmpList(options: MagicOptionScheme, module_name: string): Rule {\r\n return (host: Tree, context: SchematicContext) => {\r\n if (toAddImports) {\r\n const cmpsToGen = env.app.views;\r\n let cmpListSource = getSourceFile(host, env.metadata.paths.componentListPath(module_name));\r\n\r\n const recorder = host.beginUpdate(env.metadata.paths.componentListPath(module_name));\r\n\r\n cmpsToGen.forEach(cmp => {\r\n let name = cmp.props.id;\r\n let uniqueName = cmp.props.component_uniquename;\r\n let cmpPath = cmp.props.component_path;\r\n\r\n if (newCmpListSet.has(uniqueName)) {\r\n const importsChange =\r\n insertImport2(\r\n cmpListSource,\r\n env.metadata.paths.componentListPath(module_name),\r\n name,\r\n uniqueName,\r\n `./${cmpPath}${name}.component`\r\n ) as InsertChange;\r\n\r\n if (importsChange.toAdd) {\r\n recorder.insertLeft(importsChange.pos, importsChange.toAdd);\r\n }\r\n }\r\n });\r\n\r\n host.commitUpdate(recorder);\r\n }\r\n return host;\r\n }\r\n}\r\n\r\n\r\n// //-------------------------------------------------------------------------------------------------\r\n// //\r\n// //-------------------------------------------------------------------------------------------------\r\n// function checkIfTheComponentNeedToBeRemoveFromGeneralMagicModule\r\n// (options: MagicOptionScheme, modulePath:string, moduleName:string, srcModuleName:string) : Rule {\r\n// return (tree: Tree , context : SchematicContext)=>{\r\n// const project = env.project;\r\n//\r\n// if (env.metadata.paths.generateCompForModuleName != \"\") {\r\n// LogLn(` [>] checking component name [${moduleName}]\r\n// from ${srcModuleName}]\r\n// To App Module : [${modulePath}]`);\r\n// const moduleSourceFile = getSourceFile(tree, modulePath);\r\n// if (isImported(moduleSourceFile, moduleName, srcModuleName)) {\r\n//\r\n// }\r\n// }\r\n//\r\n// return tree;\r\n// }\r\n// }\r\n\r\n/**************************\r\n * Helper Functions\r\n ***************************/\r\n\r\ninterface IComponentListParser {\r\n components: string[];\r\n endPos: number;\r\n isEmpty: boolean;\r\n}\r\n\r\nfunction getComponentsHashInfo(source: ts.SourceFile, variable: string): IComponentListParser {\r\n\r\n const rootNode = source;\r\n const cmpListVars: ts.Node[] = findNodes(rootNode, ts.SyntaxKind.VariableDeclaration);\r\n let endPos = -1;\r\n let isEmpty = true;\r\n\r\n let magicGenCmpsInfo = cmpListVars.filter(\r\n (node: any) => node.name.escapedText === variable);\r\n\r\n if (magicGenCmpsInfo && magicGenCmpsInfo.length > 0) {\r\n const firstPunctuation: ts.Node[] = findNodes(magicGenCmpsInfo[0], ts.SyntaxKind.FirstPunctuation);\r\n if (!(firstPunctuation && firstPunctuation.length > 0)) {\r\n throw new Error('magicGenCmpsHash variable has no open bracket ( { )');\r\n }\r\n endPos = firstPunctuation[0].end;\r\n const propertyAssignment = findNodes(firstPunctuation[0].parent, ts.SyntaxKind.PropertyAssignment);\r\n if (propertyAssignment && propertyAssignment.length > 0) {\r\n isEmpty = false;\r\n }\r\n }\r\n return {\r\n components: null,\r\n endPos,\r\n isEmpty\r\n };\r\n}\r\n\r\nfunction getComponentsArrayInfo(source: ts.SourceFile, variable: string): IComponentListParser {\r\n\r\n const rootNode = source;\r\n const cmpListVars: ts.Node[] = findNodes(rootNode, ts.SyntaxKind.VariableDeclaration);\r\n let endPos = -1;\r\n let cmpListArray;\r\n let isEmpty = true;\r\n let magicGenCmpsInfo = cmpListVars.filter(\r\n (node: any) => node.name.escapedText === variable);\r\n\r\n if (magicGenCmpsInfo && magicGenCmpsInfo.length > 0) {\r\n const openBracketToken: ts.Node[] = findNodes(magicGenCmpsInfo[0], ts.SyntaxKind.OpenBracketToken);\r\n if (!(openBracketToken && openBracketToken.length > 0)) {\r\n throw new Error('magicGenComponents variable has no open bracket ([)');\r\n }\r\n endPos = openBracketToken[0].end;\r\n const identifiers = findNodes(openBracketToken[0].parent, ts.SyntaxKind.Identifier);\r\n\r\n\r\n // Array with items\r\n if (identifiers && identifiers.length > 0) {\r\n isEmpty = false;\r\n //endPos = identifiers[identifiers.length - 1].end;\r\n cmpListArray = identifiers.map((i: any) => i.escapedText) as string[];\r\n }\r\n // Array with no items\r\n // else{\r\n // endPos = openBracketToken[0].end;\r\n // }\r\n }\r\n return {\r\n components: cmpListArray,\r\n endPos,\r\n isEmpty\r\n };\r\n}\r\n\r\n\r\nfunction getLazyLoadCompoenentsInfo(source: ts.SourceFile, variable: string): IComponentListParser {\r\n\r\n const cmpListVars: ts.Node[] = findNodes(source, ts.SyntaxKind.VariableDeclaration);\r\n let endPos = -1;\r\n let cmpListArray;\r\n let isEmpty = true;\r\n let magicGenCmpsInfo = cmpListVars.filter(\r\n (node: any) => node.name.escapedText === variable);\r\n\r\n if (magicGenCmpsInfo && magicGenCmpsInfo.length > 0) {\r\n const openBracketToken: ts.Node[] = findNodes(magicGenCmpsInfo[0], ts.SyntaxKind.FirstPunctuation);\r\n if (!(openBracketToken && openBracketToken.length > 0)) {\r\n throw new Error('FirstPunctuation variable has no open bracket ([)');\r\n }\r\n endPos = openBracketToken[0].end;\r\n const identifiers = findNodes(openBracketToken[0].parent, ts.SyntaxKind.PropertyAssignment);\r\n const identifiers1 = findNodes(openBracketToken[0].parent, ts.SyntaxKind.Identifier);\r\n\r\n // Array with items\r\n if (identifiers && identifiers.length > 0) {\r\n isEmpty = false;\r\n cmpListArray = identifiers.map((i: any) => i.name.escapedText ).filter(id => id !== \"moduleName\" && id !== \"modulePath\");\r\n }\r\n }\r\n return {\r\n components: cmpListArray,\r\n endPos,\r\n isEmpty\r\n };\r\n}\r\n\r\nfunction addComponentsToArray(source: string, info: IComponentListParser, cmpsToAdd: string[]): string {\r\n const prefix = source.substring(0, info.endPos);\r\n const suffix = source.substring(info.endPos);\r\n let toAdd = `${cmpsToAdd}`;\r\n toAdd = `${toAdd.replace(/,/g, \",\\n\")}`;\r\n\r\n return info.isEmpty ?\r\n `${prefix} ${toAdd} ${suffix}` :\r\n `${prefix} ${toAdd} , ${suffix}`;\r\n}\r\n\r\nfunction addComponentsToHash(source: string, info: IComponentListParser, cmpsToAdd: string[]): string {\r\n const prefix = source.substring(0, info.endPos);\r\n const suffix = source.substring(info.endPos);\r\n const cmpHashStr = EJS.render(`\r\n <% components.forEach(componentUniqueName => { %>\r\n <%= componentUniqueName %>:<%- componentUniqueName %>,\r\n <%})%>`, {components: cmpsToAdd});\r\n let toAdd = `${cmpHashStr.replace(/\\n/g, '').replace(/,/g, \",\\n\")}`;\r\n // update source\r\n return `${prefix} ${toAdd} ${suffix}`;\r\n /*return info.isEmpty ?\r\n `${prefix} ${delLastComma(cmpHashStr)} ${suffix}` :\r\n `${prefix} ${delLastComma(cmpHashStr)}, ${suffix}` ;*/\r\n}\r\n\r\n// add the lazy loaded components to map\r\nfunction addComponentsToLazyLoad(source: string, info: IComponentListParser, cmpsToAdd: View[], module_name: string): string {\r\n const prefix = source.substring(0, info.endPos);\r\n const suffix = source.substring(info.endPos);\r\n\r\n // get the module path\r\n let currentModulePath = env.metadata.paths.magicGenLibModulePath(module_name);\r\n\r\n const cmpHashStr = EJS.render(`\r\n<%{components.forEach(view =>{-%>\r\n<%=view.props.component_uniquename %> : { moduleName : 'Magic<%=moduleName%>Module',\r\n modulePath : '<%=modulePath%>'},\r\n<%})}-%>`, {components: cmpsToAdd, moduleName: module_name, modulePath: currentModulePath});\r\n\r\n let toAdd = `${cmpHashStr.replace(/\\n/g, '').replace(/,/g, \",\\n\")}`;\r\n // update source\r\n return `${prefix} ${toAdd} ${suffix}`;\r\n}\r\n\r\nfunction delLastComma(source: string) {\r\n let index = source.lastIndexOf(',');\r\n return source.substring(0, index);\r\n}\r\n\r\n\r\n\r\n"]}
|
|
1
|
+
{"version":3,"file":"component-list.rule.js","sourceRoot":"","sources":["component-list.rule.ts"],"names":[],"mappings":";;;AAAA,iCAAiC;AACjC,2BAA2B;AAC3B,2DAAoG;AACpG,gCAAmG;AAEnG,0CAAoF;AACpF,mDAAyC;AACzC,yCAA8C;AAC9C,sEAAiF;AAEjF,kEAA6D;AAC7D,kCAA8B;AAC9B,+BAAuC;AAGvC,IAAI,eAA4B,CAAC;AACjC,IAAI,aAAa,GAAG,IAAI,GAAG,EAAE,CAAC;AAC9B,IAAI,YAAY,GAAY,IAAI,CAAC;AACjC,IAAI,aAAa,GAAG,SAAG,CAAC,WAAW,CAAC;AAGpC,SAAgB,gBAAgB,CAAC,OAA0B,EAAE,WAAmB,EAAE,YAAqB;IACrG,OAAO,CAAC,IAAU,EAAE,OAAyB,EAAE,EAAE;QAC/C,IAAA,YAAK,EAAC,8BAA8B,CAAC,CAAC;QACtC,OAAO,IAAA,kBAAK,EAAC;YACX,2BAA2B,CAAC,OAAO,EAAE,WAAW,CAAC;YACjD,uBAAuB,CAAC,OAAO,EAAE,WAAW,CAAC;YAC7C,mBAAmB,CAAC,OAAO,EAAE,WAAW,CAAC;YACzC,wBAAwB,CAAC,OAAO,EAAE,WAAW,EAAE,YAAY,CAAC;YAC5D,uBAAuB,CAAC,OAAO,CAAC;YAChC,sBAAsB,CAAC,OAAO,CAAC;SAChC,CAAC,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACpB,CAAC,CAAA;AACH,CAAC;AAZD,4CAYC;AAED,gDAAgD;AAChD,SAAS,mBA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Ac;IAClC,IAAI,KAAK,GAAG,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IACpC,OAAO,MAAM,CAAC,SAAS,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;AACpC,CAAC","sourcesContent":["import * as ts from 'typescript';\r\nimport * as EJS from \"ejs\";\r\nimport {chain, Rule, SchematicContext, SchematicsException, Tree} from \"@angular-devkit/schematics\";\r\nimport {env, GEN_COMPONENTS_ARRAY, GEN_COMPONENTS_HASH, GEN_LAZY_LOAD_MODULES_ARRAY} from \"../env\";\r\nimport {MagicOptionScheme} from \"./magic-option.scheme\";\r\nimport {GeneratedFileTypes, TemplateConfig, View, WindowType} from \"../../../types\";\r\nimport {generate} from \"./generate.rule\";\r\nimport {getSourceFile} from \"../../utils/ast\";\r\nimport {insertImport, insertImport2} from \"../../utils/devkit-utils/route-utils\";\r\nimport {InsertChange} from \"../../utils/devkit-utils/change\";\r\nimport {findNodes} from \"../../utils/devkit-utils/ast-utils\";\r\nimport {LogLn} from \"../Util\";\r\nimport {isNullOrUndefined} from \"util\";\r\n\r\n\r\nlet existCmpListSet: Set<string>;\r\nlet newCmpListSet = new Set();\r\nlet toAddImports: boolean = true;\r\nlet orgPreventLog = env.prevent_log;\r\n\r\n\r\nexport function componentlistGen(options: MagicOptionScheme, module_name: string, loadOnDemand: boolean): Rule {\r\n return (host: Tree, context: SchematicContext) => {\r\n LogLn(`[>] Step 4: components-list.`);\r\n return chain([\r\n addNewCmpsToCmpListOrGenAll(options, module_name),\r\n addCmpsImportsToCmpList(options, module_name),\r\n createLazyModuleMap(options, module_name),\r\n addLazyLoadComponentList(options, module_name, loadOnDemand),\r\n addLazyModuleToMagicGen(options),\r\n addImportForLazyModule(options)\r\n ])(host, context);\r\n }\r\n}\r\n\r\n// create the lazy load map if it does not exist\r\nfunction createLazyModuleMap(options: MagicOptionScheme, module_name: string) {\r\n return (host: Tree, context: SchematicContext) => {\r\n const cmpListPath = env.metadata.paths.componentListPath(\"\");\r\n env.prevent_log = false;\r\n const source = host.read(cmpListPath).toString(\"utf-8\")\r\n\r\n const LazyModuleArrayStart = 'export const ' + GEN_LAZY_LOAD_MODULES_ARRAY + ' = {';\r\n const LazyMOduleArrayEnd = '};';\r\n // create lazy load component array if it does not exist\r\n if (source.indexOf(LazyModuleArrayStart) < 0) {\r\n LogLn(`[>] Creating LazyLoadModulesMap `);\r\n // add the code of creating map in file\r\n host.overwrite(cmpListPath, source + \"\\r\\n\" + LazyModuleArrayStart + LazyMOduleArrayEnd);\r\n }\r\n\r\n }\r\n}\r\n\r\n// add the lazy load components\r\nfunction addLazyLoadComponentList(options: MagicOptionScheme, module_name: string, loadOnDemand: boolean): Rule {\r\n return (host: Tree, context: SchematicContext) => {\r\n if (loadOnDemand) {\r\n let lazyLoadedComponents: Array<View> = new Array<View>();\r\n const cmpListPath = env.metadata.paths.componentListPath(\"\");\r\n\r\n const source = host.read(cmpListPath);\r\n if (source) {\r\n let cmpListSource = getSourceFile(host, cmpListPath);\r\n\r\n let cmpListTs = getLazyLoadCompoenentsInfo(cmpListSource, GEN_LAZY_LOAD_MODULES_ARRAY);\r\n let sourceStep1 = host.read(cmpListPath).toString(\"utf-8\");\r\n\r\n env.app.views.forEach(view => {\r\n if( isNullOrUndefined(cmpListTs.components) || !(cmpListTs.components.includes(view.props.component_uniquename))) {\r\n lazyLoadedComponents.push(view); // if component does not exist add it to list\r\n LogLn(`[>] Add ${view.props.component_uniquename} component to LazyLoadModulesMap`, );\r\n }\r\n });\r\n\r\n // add components to map\r\n if (lazyLoadedComponents.length > 0) {\r\n let sourceStep2 = addComponentsToLazyLoad(sourceStep1, cmpListTs, lazyLoadedComponents, module_name);\r\n host.overwrite(cmpListPath, sourceStep2);\r\n }\r\n }\r\n env.prevent_log = orgPreventLog;\r\n }\r\n return host;\r\n }\r\n}\r\n\r\nfunction addImportForLazyModule(options) {\r\n return (tree: Tree, context: SchematicContext) => {\r\n\r\n let genLibPath= env.metadata.paths.rootMagicGenFolder + '/magic/magic.gen.lib.module.ts';\r\n const recorder = tree.beginUpdate(genLibPath);\r\n let genLibSource = getSourceFile(tree, genLibPath);\r\n\r\n const importChange = insertImport(genLibSource, genLibPath, GEN_LAZY_LOAD_MODULES_ARRAY, './component-list.g') as InsertChange;\r\n if (importChange.toAdd) {\r\n recorder.insertLeft(importChange.pos, importChange.toAdd);\r\n }\r\n tree.commitUpdate(recorder);\r\n }\r\n}\r\n\r\n// add the lazy load module to magic.gen.lib\r\nfunction addLazyModuleToMagicGen(options) {\r\n return (tree: Tree, context: SchematicContext) => {\r\n\r\n let origModuleFileName= env.metadata.paths.rootMagicGenFolder + '/magic/magic.gen.lib.module.ts';\r\n if(!tree.exists(origModuleFileName)){\r\n LogLn(` [>Error] File cannot be overwrite, The file is not exist !!! : ${origModuleFileName}`);\r\n }\r\n const text = tree.read(origModuleFileName);\r\n\r\n if (text === null) {\r\n throw new SchematicsException(`File ${origModuleFileName} does not exist.`);\r\n }\r\n let sourceText = text.toString('utf-8');\r\n const lazyModuleStatement = '\\r\\n componentList.lazyLoadModulesMap = '+ GEN_LAZY_LOAD_MODULES_ARRAY+';';\r\n if (sourceText !== \"\" && sourceText.indexOf(lazyModuleStatement)== -1) {\r\n let genLibSource = getSourceFile(tree, origModuleFileName);\r\n let newLazyModuleText: string = sourceText.replace(lazyModuleStatement, '').trim();\r\n const constNode: ts.FunctionLikeDeclarationBase = findNodes(genLibSource, ts.SyntaxKind.Constructor)[0] as ts.FunctionLikeDeclarationBase;\r\n\r\n let lastStatementEnd = (<ts.Block>constNode.body).statements.end;\r\n\r\n const prefix = sourceText.substring(0, lastStatementEnd);\r\n const suffix = sourceText.substring(lastStatementEnd );\r\n tree.overwrite(origModuleFileName, `${prefix} ${lazyModuleStatement} ${suffix}` );\r\n\r\n }\r\n return tree;\r\n }\r\n}\r\n\r\n/*\r\n* Add new component to component-list.g file (Array and Hash).\r\n* If the file not exist new file will create by componentListGenIfNotExist function.\r\n* */\r\nfunction addNewCmpsToCmpListOrGenAll(options: MagicOptionScheme, module_name: string): Rule {\r\n return (host: Tree, context: SchematicContext) => {\r\n const metadata = env.metadata;\r\n const cmpsToGen = env.app.views;\r\n const cmpListPath = env.metadata.paths.componentListPath(module_name);\r\n const source = host.read(cmpListPath);\r\n if (source) {\r\n let cmpToGenNum = 0;\r\n let sourceStep1 = source.toString(\"utf-8\");\r\n let cmpListSource = getSourceFile(host, cmpListPath);\r\n\r\n let cmpListTs = getComponentsArrayInfo(cmpListSource, GEN_COMPONENTS_ARRAY);\r\n existCmpListSet = new Set(cmpListTs.components);\r\n newCmpListSet = new Set<string>();\r\n\r\n // merge between components in the file and new component to gen\r\n cmpsToGen.forEach(newCmpGen => {\r\n if (!existCmpListSet.has(newCmpGen.props.component_uniquename)) {\r\n newCmpListSet.add(newCmpGen.props.component_uniquename);\r\n }\r\n });\r\n const newCmpListArray: string[] = <string[]>Array.from(newCmpListSet);\r\n if (newCmpListArray && newCmpListArray.length > 0) {\r\n let sourceStep2 = addComponentsToArray(sourceStep1, cmpListTs, newCmpListArray);\r\n\r\n let cmpListHashTs = getComponentsHashInfo(cmpListSource, GEN_COMPONENTS_HASH);\r\n let sourceStep3 = addComponentsToHash(sourceStep2, cmpListHashTs, newCmpListArray);\r\n\r\n LogLn(` Total old components: ${existCmpListSet.size}, added components: ${newCmpListSet.size}. `);\r\n\r\n host.overwrite(cmpListPath, sourceStep3);\r\n }\r\n } else {\r\n // If component-list.g.ts doesn't exist.\r\n toAddImports = false; // We generate the entire file with imports.\r\n return componentListGenIfNotExist(options)(host, context);\r\n }\r\n\r\n return host;\r\n }\r\n}\r\n\r\n/*\r\n* Create new component-list.g file.\r\n* */\r\nfunction componentListGenIfNotExist(options: MagicOptionScheme): Rule {\r\n return (host: Tree, context: SchematicContext) => {\r\n\r\n console.log(\"creating component-list\");\r\n const metadata = env.metadata;\r\n const cmpList = new Set<string>();\r\n const data: any = {\r\n app: env.app,\r\n cmpList: env.app.views\r\n };\r\n\r\n const componentFile: TemplateConfig = {\r\n template: `./templates/angular/src/app/component-list.g.ts`,\r\n name: 'component-list.g.ts',\r\n destination: metadata.paths.magicGenFolderPath,\r\n type: GeneratedFileTypes.TS,\r\n data: data\r\n };\r\n\r\n return chain([\r\n generate(componentFile, options)\r\n ])(host, context);\r\n }\r\n}\r\n\r\n/*\r\n* Add new imports to component-list.g file.\r\n* */\r\nfunction addCmpsImportsToCmpList(options: MagicOptionScheme, module_name: string): Rule {\r\n return (host: Tree, context: SchematicContext) => {\r\n if (toAddImports) {\r\n const cmpsToGen = env.app.views;\r\n let cmpListSource = getSourceFile(host, env.metadata.paths.componentListPath(module_name));\r\n\r\n const recorder = host.beginUpdate(env.metadata.paths.componentListPath(module_name));\r\n\r\n cmpsToGen.forEach(cmp => {\r\n let name = cmp.props.id;\r\n let uniqueName = cmp.props.component_uniquename;\r\n let cmpPath = cmp.props.component_path;\r\n\r\n if (newCmpListSet.has(uniqueName)) {\r\n const importsChange =\r\n insertImport2(\r\n cmpListSource,\r\n env.metadata.paths.componentListPath(module_name),\r\n name,\r\n uniqueName,\r\n `./${cmpPath}${name}.component`\r\n ) as InsertChange;\r\n\r\n if (importsChange.toAdd) {\r\n recorder.insertLeft(importsChange.pos, importsChange.toAdd);\r\n }\r\n }\r\n });\r\n\r\n host.commitUpdate(recorder);\r\n }\r\n return host;\r\n }\r\n}\r\n\r\n\r\n// //-------------------------------------------------------------------------------------------------\r\n// //\r\n// //-------------------------------------------------------------------------------------------------\r\n// function checkIfTheComponentNeedToBeRemoveFromGeneralMagicModule\r\n// (options: MagicOptionScheme, modulePath:string, moduleName:string, srcModuleName:string) : Rule {\r\n// return (tree: Tree , context : SchematicContext)=>{\r\n// const project = env.project;\r\n//\r\n// if (env.metadata.paths.generateCompForModuleName != \"\") {\r\n// LogLn(` [>] checking component name [${moduleName}]\r\n// from ${srcModuleName}]\r\n// To App Module : [${modulePath}]`);\r\n// const moduleSourceFile = getSourceFile(tree, modulePath);\r\n// if (isImported(moduleSourceFile, moduleName, srcModuleName)) {\r\n//\r\n// }\r\n// }\r\n//\r\n// return tree;\r\n// }\r\n// }\r\n\r\n/**************************\r\n * Helper Functions\r\n ***************************/\r\n\r\ninterface IComponentListParser {\r\n components: string[];\r\n endPos: number;\r\n isEmpty: boolean;\r\n}\r\n\r\nfunction getComponentsHashInfo(source: ts.SourceFile, variable: string): IComponentListParser {\r\n\r\n const rootNode = source;\r\n const cmpListVars: ts.Node[] = findNodes(rootNode, ts.SyntaxKind.VariableDeclaration);\r\n let endPos = -1;\r\n let isEmpty = true;\r\n\r\n let magicGenCmpsInfo = cmpListVars.filter(\r\n (node: any) => node.name.escapedText === variable);\r\n\r\n if (magicGenCmpsInfo && magicGenCmpsInfo.length > 0) {\r\n const firstPunctuation: ts.Node[] = findNodes(magicGenCmpsInfo[0], ts.SyntaxKind.FirstPunctuation);\r\n if (!(firstPunctuation && firstPunctuation.length > 0)) {\r\n throw new Error('magicGenCmpsHash variable has no open bracket ( { )');\r\n }\r\n endPos = firstPunctuation[0].end;\r\n const propertyAssignment = findNodes(firstPunctuation[0].parent, ts.SyntaxKind.PropertyAssignment);\r\n if (propertyAssignment && propertyAssignment.length > 0) {\r\n isEmpty = false;\r\n }\r\n }\r\n return {\r\n components: null,\r\n endPos,\r\n isEmpty\r\n };\r\n}\r\n\r\nfunction getComponentsArrayInfo(source: ts.SourceFile, variable: string): IComponentListParser {\r\n\r\n const rootNode = source;\r\n const cmpListVars: ts.Node[] = findNodes(rootNode, ts.SyntaxKind.VariableDeclaration);\r\n let endPos = -1;\r\n let cmpListArray;\r\n let isEmpty = true;\r\n let magicGenCmpsInfo = cmpListVars.filter(\r\n (node: any) => node.name.escapedText === variable);\r\n\r\n if (magicGenCmpsInfo && magicGenCmpsInfo.length > 0) {\r\n const openBracketToken: ts.Node[] = findNodes(magicGenCmpsInfo[0], ts.SyntaxKind.OpenBracketToken);\r\n if (!(openBracketToken && openBracketToken.length > 0)) {\r\n throw new Error('magicGenComponents variable has no open bracket ([)');\r\n }\r\n endPos = openBracketToken[0].end;\r\n const identifiers = findNodes(openBracketToken[0].parent, ts.SyntaxKind.Identifier);\r\n\r\n\r\n // Array with items\r\n if (identifiers && identifiers.length > 0) {\r\n isEmpty = false;\r\n //endPos = identifiers[identifiers.length - 1].end;\r\n cmpListArray = identifiers.map((i: any) => i.escapedText) as string[];\r\n }\r\n // Array with no items\r\n // else{\r\n // endPos = openBracketToken[0].end;\r\n // }\r\n }\r\n return {\r\n components: cmpListArray,\r\n endPos,\r\n isEmpty\r\n };\r\n}\r\n\r\n\r\nfunction getLazyLoadCompoenentsInfo(source: ts.SourceFile, variable: string): IComponentListParser {\r\n\r\n const cmpListVars: ts.Node[] = findNodes(source, ts.SyntaxKind.VariableDeclaration);\r\n let endPos = -1;\r\n let cmpListArray;\r\n let isEmpty = true;\r\n let magicGenCmpsInfo = cmpListVars.filter(\r\n (node: any) => node.name.escapedText === variable);\r\n\r\n if (magicGenCmpsInfo && magicGenCmpsInfo.length > 0) {\r\n const openBracketToken: ts.Node[] = findNodes(magicGenCmpsInfo[0], ts.SyntaxKind.FirstPunctuation);\r\n if (!(openBracketToken && openBracketToken.length > 0)) {\r\n throw new Error('FirstPunctuation variable has no open bracket ([)');\r\n }\r\n endPos = openBracketToken[0].end;\r\n const identifiers = findNodes(openBracketToken[0].parent, ts.SyntaxKind.PropertyAssignment);\r\n const identifiers1 = findNodes(openBracketToken[0].parent, ts.SyntaxKind.Identifier);\r\n\r\n // Array with items\r\n if (identifiers && identifiers.length > 0) {\r\n isEmpty = false;\r\n cmpListArray = identifiers.map((i: any) => i.name.escapedText ).filter(id => id !== \"moduleName\" && id !== \"modulePath\");\r\n }\r\n }\r\n return {\r\n components: cmpListArray,\r\n endPos,\r\n isEmpty\r\n };\r\n}\r\n\r\nfunction addComponentsToArray(source: string, info: IComponentListParser, cmpsToAdd: string[]): string {\r\n const prefix = source.substring(0, info.endPos);\r\n const suffix = source.substring(info.endPos);\r\n let toAdd = `${cmpsToAdd}`;\r\n toAdd = `${toAdd.replace(/,/g, \",\\n\")}`;\r\n\r\n return info.isEmpty ?\r\n `${prefix} ${toAdd} ${suffix}` :\r\n `${prefix} ${toAdd} , ${suffix}`;\r\n}\r\n\r\nfunction addComponentsToHash(source: string, info: IComponentListParser, cmpsToAdd: string[]): string {\r\n const prefix = source.substring(0, info.endPos);\r\n const suffix = source.substring(info.endPos);\r\n const cmpHashStr = EJS.render(`\r\n <% components.forEach(componentUniqueName => { %>\r\n <%= componentUniqueName %>:<%- componentUniqueName %>,\r\n <%})%>`, {components: cmpsToAdd});\r\n let toAdd = `${cmpHashStr.replace(/\\n/g, '').replace(/,/g, \",\\n\")}`;\r\n // update source\r\n return `${prefix} ${toAdd} ${suffix}`;\r\n /*return info.isEmpty ?\r\n `${prefix} ${delLastComma(cmpHashStr)} ${suffix}` :\r\n `${prefix} ${delLastComma(cmpHashStr)}, ${suffix}` ;*/\r\n}\r\n\r\n// add the lazy loaded components to map\r\nfunction addComponentsToLazyLoad(source: string, info: IComponentListParser, cmpsToAdd: View[], module_name: string): string {\r\n const prefix = source.substring(0, info.endPos);\r\n const suffix = source.substring(info.endPos);\r\n\r\n // get the module path\r\n let currentModulePath = env.metadata.paths.magicGenLibModulePath(module_name);\r\n\r\n const cmpHashStr = EJS.render(`\r\n<%{components.forEach(view =>{-%>\r\n<%=view.props.component_uniquename %> : { moduleName : 'Magic<%=moduleName%>Module'},\r\n<%})}-%>`, {components: cmpsToAdd, moduleName: module_name, modulePath: currentModulePath});\r\n\r\n let toAdd = `${cmpHashStr.replace(/\\n/g, '').replace(/,/g, \",\\n\")}`;\r\n // update source\r\n return `${prefix} ${toAdd} ${suffix}`;\r\n}\r\n\r\nfunction delLastComma(source: string) {\r\n let index = source.lastIndexOf(',');\r\n return source.substring(0, index);\r\n}\r\n\r\n\r\n\r\n"]}
|
|
@@ -28,8 +28,7 @@ export function componentlistGen(options: MagicOptionScheme, module_name: string
|
|
|
28
28
|
createLazyModuleMap(options, module_name),
|
|
29
29
|
addLazyLoadComponentList(options, module_name, loadOnDemand),
|
|
30
30
|
addLazyModuleToMagicGen(options),
|
|
31
|
-
addImportForLazyModule(options)
|
|
32
|
-
modifyAngularJson(options, module_name, loadOnDemand)
|
|
31
|
+
addImportForLazyModule(options)
|
|
33
32
|
])(host, context);
|
|
34
33
|
}
|
|
35
34
|
}
|
|
@@ -132,30 +131,6 @@ function addLazyModuleToMagicGen(options) {
|
|
|
132
131
|
}
|
|
133
132
|
}
|
|
134
133
|
|
|
135
|
-
// Update the angular json filr
|
|
136
|
-
function modifyAngularJson(options: MagicOptionScheme, module_name: string, loadOnDemand: boolean): Rule {
|
|
137
|
-
return (host: Tree, context: SchematicContext) => {
|
|
138
|
-
if (loadOnDemand) {
|
|
139
|
-
|
|
140
|
-
// get the module path to we added in angular json
|
|
141
|
-
let currentModulePath = env.metadata.paths.magicGenLibModulePath(module_name);
|
|
142
|
-
|
|
143
|
-
// create the lazyModules array if it does not exits
|
|
144
|
-
if (isNullOrUndefined(env.project.architect.build.options.lazyModules))
|
|
145
|
-
env.project.architect.build.options.lazyModules = new Array();
|
|
146
|
-
|
|
147
|
-
// add the modulepath to lazyModules if it is not already present
|
|
148
|
-
if (!env.project.architect.build.options.lazyModules.includes(currentModulePath)) {
|
|
149
|
-
env.project.architect.build.options.lazyModules.push(currentModulePath);
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
// get angular json path
|
|
153
|
-
let angularJsonPath = env.metadata.paths.angularJsonPath;
|
|
154
|
-
host.overwrite(angularJsonPath, JSON.stringify(env.workspace, null, 2));
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
|
|
159
134
|
/*
|
|
160
135
|
* Add new component to component-list.g file (Array and Hash).
|
|
161
136
|
* If the file not exist new file will create by componentListGenIfNotExist function.
|
|
@@ -434,8 +409,7 @@ function addComponentsToLazyLoad(source: string, info: IComponentListParser, cmp
|
|
|
434
409
|
|
|
435
410
|
const cmpHashStr = EJS.render(`
|
|
436
411
|
<%{components.forEach(view =>{-%>
|
|
437
|
-
<%=view.props.component_uniquename %> : { moduleName : 'Magic<%=moduleName%>Module',
|
|
438
|
-
modulePath : '<%=modulePath%>'},
|
|
412
|
+
<%=view.props.component_uniquename %> : { moduleName : 'Magic<%=moduleName%>Module'},
|
|
439
413
|
<%})}-%>`, {components: cmpsToAdd, moduleName: module_name, modulePath: currentModulePath});
|
|
440
414
|
|
|
441
415
|
let toAdd = `${cmpHashStr.replace(/\n/g, '').replace(/,/g, ",\n")}`;
|
|
@@ -28,7 +28,7 @@ function generate(file, options) {
|
|
|
28
28
|
return (host, context) => {
|
|
29
29
|
EJS.renderFile(`${env_1.MAGIC_CLI_FOLDER}/${file.template}`, file.data, { "rmWhitespace": true }, (err, output) => {
|
|
30
30
|
if (err) {
|
|
31
|
-
Util_1.logErr(err);
|
|
31
|
+
(0, Util_1.logErr)(err);
|
|
32
32
|
return;
|
|
33
33
|
}
|
|
34
34
|
try {
|
|
@@ -44,8 +44,8 @@ function generate(file, options) {
|
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
catch (err) {
|
|
47
|
-
Util_1.logErr(output);
|
|
48
|
-
Util_1.logErr(err);
|
|
47
|
+
(0, Util_1.logErr)(output);
|
|
48
|
+
(0, Util_1.logErr)(err);
|
|
49
49
|
}
|
|
50
50
|
});
|
|
51
51
|
return host;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.rule.js","sourceRoot":"","sources":["generate.rule.ts"],"names":[],"mappings":";;;AAAA,2BAAmC;AACnC,0CAA0C;AAC1C,0CAA2C;AAI3C,kCAAiC;AACjC,gCAA0C;AAC1C,0CAAoE;AAIpE,SAAgB,cAAc,CAAC,MAAe,EAAC,IAAwB;IACrE,MAAM,MAAM,GAAI,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE;QACjD,uBAAuB,EAAE,CAAC;QAC1B,kBAAkB,EAAO,CAAC;QAC1B,iBAAiB,EA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gBAE9C,IAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAC;oBACnB,IAAI,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC,IAAI,EAAE,EAAE,MAAM,CAAC,CAAA;iBAC3D;qBAAK;oBACJ,IAAI,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC,IAAI,EAAE,EAAE,MAAM,CAAC,CAAC;iBACzD;aACF;YACD,OAAO,GAAG,EAAE;gBACV,IAAA,aAAM,EAAC,MAAM,CAAC,CAAC;gBACf,IAAA,aAAM,EAAC,GAAG,CAAC,CAAC;aACb;QACH,CAAC,CAAC,CAAC;QACL,OAAO,IAAI,CAAC;IACd,CAAC,CAAA;AACH,CAAC;AA7BD,4BA6BC","sourcesContent":["import * as EJS from \"ejs\";\n//import * as prettier from \"prettier\";\nimport * as jsbeautify from \"js-beautify\";\n\nimport { Rule, SchematicContext, Tree } from \"@angular-devkit/schematics\";\n\nimport { logErr } from \"../Util\";\nimport { MAGIC_CLI_FOLDER } from \"../env\";\nimport { GeneratedFileTypes, TemplateConfig } from \"../../../types\";\nimport { MagicOptionScheme } from \"./magic-option.scheme\";\nimport { prettierConfig } from \"../config\";\n\nexport function createGenFuncs(output : string,type: GeneratedFileTypes ) {\n const htmlFn = jsbeautify.html.bind(this, output, {\n \"max_preserve_newlines\": 0,\n \"wrap_line_length\" : 0,\n \"wrap_attributes\" : \"force-expand-multiline\",\n \"brace_style\" : 'collapse,preserve-inline'\n });\n\n const fnMap = {\n [GeneratedFileTypes.HTML]: htmlFn,\n //[GeneratedFileTypes.TS] : prettier.format.bind(this, output, prettierConfig),\n [GeneratedFileTypes.TS] : jsbeautify.js.bind(this, output, {\"brace_style\" : 'collapse,preserve-inline'}),\n [GeneratedFileTypes.HELPER] : jsbeautify.js.bind(this, output, {}),\n [GeneratedFileTypes.CSS] : jsbeautify.css.bind(this, output, { })\n };\n\n return fnMap[type]();\n}\n\nexport function generate(file: TemplateConfig,options:MagicOptionScheme) :Rule{\n return (host:Tree, context: SchematicContext) => {\n EJS.renderFile(\n `${MAGIC_CLI_FOLDER}/${file.template}`,\n file.data,\n {\"rmWhitespace\" : true},\n (err, output) => {\n if (err) { logErr(err); return }\n\n try {\n //if(file.type != GeneratedFileTypes.TS) {\n output = createGenFuncs(output, file.type);\n //}\n\n let path = `${file.destination}/${file.name}`;\n\n if(host.exists(path)){\n host.overwrite(`${file.destination}/${file.name}`, output)\n } else{\n host.create(`${file.destination}/${file.name}`, output);\n }\n }\n catch (err) {\n logErr(output);\n logErr(err);\n }\n });\n return host;\n }\n}\n"]}
|
|
@@ -27,7 +27,7 @@ function initGenModules(options) {
|
|
|
27
27
|
env_1.env.modulesGen.push(moduleInfo);
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
|
-
Util_1.LogLn(` Number of modules to be check for generate: ${web_modules.length}`);
|
|
30
|
+
(0, Util_1.LogLn)(` Number of modules to be check for generate: ${web_modules.length}`);
|
|
31
31
|
return tree;
|
|
32
32
|
};
|
|
33
33
|
}
|
|
@@ -38,7 +38,7 @@ exports.initGenModules = initGenModules;
|
|
|
38
38
|
function overwriteWebModuleFileName(options, moduleNameFileName, content) {
|
|
39
39
|
return (tree, _context) => {
|
|
40
40
|
if (!tree.exists(moduleNameFileName)) {
|
|
41
|
-
Util_1.LogLn(` [>Error] File cannot be overwrite, The file is not exist !!! : ${moduleNameFileName}`);
|
|
41
|
+
(0, Util_1.LogLn)(` [>Error] File cannot be overwrite, The file is not exist !!! : ${moduleNameFileName}`);
|
|
42
42
|
}
|
|
43
43
|
tree.overwrite(moduleNameFileName, content);
|
|
44
44
|
return tree;
|
|
@@ -64,7 +64,7 @@ function updateWebModuleFileWithNewClassName(options, webModuleName) {
|
|
|
64
64
|
let newsourceText = sourceText.replace(`MagicGenLibModule`, newClassModuleName);
|
|
65
65
|
rules.push(overwriteWebModuleFileName(options, origModuleFileName, newsourceText));
|
|
66
66
|
}
|
|
67
|
-
return schematics_1.chain(rules)(tree, context);
|
|
67
|
+
return (0, schematics_1.chain)(rules)(tree, context);
|
|
68
68
|
};
|
|
69
69
|
}
|
|
70
70
|
exports.updateWebModuleFileWithNewClassName = updateWebModuleFileWithNewClassName;
|
|
@@ -74,16 +74,31 @@ exports.updateWebModuleFileWithNewClassName = updateWebModuleFileWithNewClassNam
|
|
|
74
74
|
function copyDefaultMagicFilesToWebModule(options, webModuleName) {
|
|
75
75
|
return (tree, context) => {
|
|
76
76
|
const webModulePath = getDestinationModulePathByWebModuleName(webModuleName);
|
|
77
|
-
return schematics_1.chain([
|
|
78
|
-
schematics_1.branchAndMerge(schematics_1.chain([
|
|
79
|
-
schematics_1.mergeWith(schematics_1.apply(schematics_1.url(`./../mg-add/files/src/app/magic/`), [
|
|
80
|
-
schematics_1.move(webModulePath)
|
|
77
|
+
return (0, schematics_1.chain)([
|
|
78
|
+
(0, schematics_1.branchAndMerge)((0, schematics_1.chain)([
|
|
79
|
+
(0, schematics_1.mergeWith)((0, schematics_1.apply)((0, schematics_1.url)(`./../mg-add/files/src/app/magic/`), [
|
|
80
|
+
(0, schematics_1.move)(webModulePath)
|
|
81
81
|
]), schematics_1.MergeStrategy.AllowCreationConflict)
|
|
82
82
|
]))
|
|
83
83
|
])(tree, context);
|
|
84
84
|
};
|
|
85
85
|
}
|
|
86
86
|
//-------------------------------------------------------------------------------------------------
|
|
87
|
+
// delete LazyLoadService for non root modules
|
|
88
|
+
//-------------------------------------------------------------------------------------------------
|
|
89
|
+
function deleteLazyLoadService(webModuleName) {
|
|
90
|
+
return (tree) => {
|
|
91
|
+
const lazyLoaderServicePath = getDestinationModulePathByWebModuleName(webModuleName) + '/lazy-loader.service.ts';
|
|
92
|
+
if (webModuleName != '') {
|
|
93
|
+
if (!tree.exists(lazyLoaderServicePath)) {
|
|
94
|
+
(0, Util_1.LogLn)(` [>Error] File cannot be overwrite, The file is not exist !!! :lazyLoaderServicePath`);
|
|
95
|
+
}
|
|
96
|
+
tree.delete(lazyLoaderServicePath);
|
|
97
|
+
return tree;
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
//-------------------------------------------------------------------------------------------------
|
|
87
102
|
// get destination path according to the send webModuleName
|
|
88
103
|
//-------------------------------------------------------------------------------------------------
|
|
89
104
|
function getDestinationModulePathByWebModuleName(webModuleName) {
|
|
@@ -111,10 +126,10 @@ function getWebModuleClass(webModuleName) {
|
|
|
111
126
|
function addMagicModuleToAppModule(options, modulePath, moduleName, srcModuleName) {
|
|
112
127
|
return (tree, context) => {
|
|
113
128
|
const project = env_1.env.project;
|
|
114
|
-
Util_1.LogLn(` [>] add New Web Module :[${moduleName}] `);
|
|
115
|
-
Util_1.LogLn(` [>] from :[${srcModuleName}]`);
|
|
116
|
-
Util_1.LogLn(` [>] To App Module :[${modulePath}]`);
|
|
117
|
-
ast_1.addModuleImportToModule(tree, modulePath, // for now we will update env.metadata.paths.magicGenLibModule
|
|
129
|
+
(0, Util_1.LogLn)(` [>] add New Web Module :[${moduleName}] `);
|
|
130
|
+
(0, Util_1.LogLn)(` [>] from :[${srcModuleName}]`);
|
|
131
|
+
(0, Util_1.LogLn)(` [>] To App Module :[${modulePath}]`);
|
|
132
|
+
(0, ast_1.addModuleImportToModule)(tree, modulePath, // for now we will update env.metadata.paths.magicGenLibModule
|
|
118
133
|
moduleName, // 'MagicXXXModule',
|
|
119
134
|
srcModuleName);
|
|
120
135
|
return tree;
|
|
@@ -131,13 +146,14 @@ function checkAndCreateModule(options, webModuleName, loadOnDemand) {
|
|
|
131
146
|
if (!tree.exists(webModuleFullFileName)) {
|
|
132
147
|
rules.push(copyDefaultMagicFilesToWebModule(options, webModuleName));
|
|
133
148
|
rules.push(updateWebModuleFileWithNewClassName(tree, webModuleName));
|
|
149
|
+
rules.push(deleteLazyLoadService(webModuleName));
|
|
134
150
|
// for NON load on demand we need to update magic root module
|
|
135
151
|
if (!loadOnDemand) {
|
|
136
152
|
const newDestModulePath = `./${webModuleName}/magic.gen.lib.module`;
|
|
137
153
|
const webModuleClass = getWebModuleClass(webModuleName);
|
|
138
154
|
rules.push(addMagicModuleToAppModule(options, env_1.env.metadata.paths.magicGenLibModule, webModuleClass, newDestModulePath));
|
|
139
155
|
}
|
|
140
|
-
return schematics_1.chain(rules)(tree, context);
|
|
156
|
+
return (0, schematics_1.chain)(rules)(tree, context);
|
|
141
157
|
}
|
|
142
158
|
;
|
|
143
159
|
};
|
|
@@ -149,10 +165,10 @@ exports.checkAndCreateModule = checkAndCreateModule;
|
|
|
149
165
|
function generateWebModule(options, webModuleName, loadOnDemand) {
|
|
150
166
|
return (tree, context) => {
|
|
151
167
|
let rules = [];
|
|
152
|
-
Util_1.LogLn(` [>]Handling Web Module named: [${webModuleName}] isLoadOnDemand: [${loadOnDemand}]`);
|
|
168
|
+
(0, Util_1.LogLn)(` [>]Handling Web Module named: [${webModuleName}] isLoadOnDemand: [${loadOnDemand}]`);
|
|
153
169
|
rules.push(checkAndCreateModule(options, webModuleName, loadOnDemand));
|
|
154
170
|
rules.push(checkAndCreateRouteForModule(options, webModuleName, loadOnDemand));
|
|
155
|
-
return schematics_1.chain(rules)(tree, context);
|
|
171
|
+
return (0, schematics_1.chain)(rules)(tree, context);
|
|
156
172
|
};
|
|
157
173
|
}
|
|
158
174
|
exports.generateWebModule = generateWebModule;
|
|
@@ -167,7 +183,7 @@ function generateWebModules(options) {
|
|
|
167
183
|
rules.push(generateWebModule(options, webModuleInfo.moduleName, webModuleInfo.loadOnDemand));
|
|
168
184
|
}
|
|
169
185
|
}
|
|
170
|
-
return schematics_1.chain(rules)(tree, context);
|
|
186
|
+
return (0, schematics_1.chain)(rules)(tree, context);
|
|
171
187
|
};
|
|
172
188
|
}
|
|
173
189
|
exports.generateWebModules = generateWebModules;
|
|
@@ -188,7 +204,7 @@ function checkAndCreateRouteForModule(options, webModuleName, loadOnDemand) {
|
|
|
188
204
|
rules.push(addRouteFileToModuleFile(options, webModuleName));
|
|
189
205
|
}
|
|
190
206
|
}
|
|
191
|
-
return schematics_1.chain(rules)(tree, context);
|
|
207
|
+
return (0, schematics_1.chain)(rules)(tree, context);
|
|
192
208
|
};
|
|
193
209
|
}
|
|
194
210
|
exports.checkAndCreateRouteForModule = checkAndCreateRouteForModule;
|
|
@@ -215,7 +231,7 @@ function createRoute(options, webModuleName) {
|
|
|
215
231
|
// --------------------------------------------------------
|
|
216
232
|
// update the new MagicRoutingModule in file magic.gen.lib.module.ts of the module
|
|
217
233
|
rules.push(addRouteFileToModuleFile(options, webModuleName));
|
|
218
|
-
return schematics_1.chain(rules)(tree, context);
|
|
234
|
+
return (0, schematics_1.chain)(rules)(tree, context);
|
|
219
235
|
};
|
|
220
236
|
}
|
|
221
237
|
exports.createRoute = createRoute;
|
|
@@ -229,7 +245,7 @@ function addRouteFileToModuleFile(options, webModuleName) {
|
|
|
229
245
|
const moduleName = `MagicRoutingModule`; //for now it will be the same for all modules ... getWebModuleClass(webModuleName);
|
|
230
246
|
const srcModuleName = `./app.routes`;
|
|
231
247
|
rules.push(addMagicModuleToAppModule(options, modulePath, moduleName, srcModuleName));
|
|
232
|
-
return schematics_1.chain(rules)(tree, context);
|
|
248
|
+
return (0, schematics_1.chain)(rules)(tree, context);
|
|
233
249
|
};
|
|
234
250
|
}
|
|
235
251
|
exports.addRouteFileToModuleFile = addRouteFileToModuleFile;
|
|
@@ -241,15 +257,15 @@ function copyDefaultRouteMagicFilesToWebModule(options, webModuleName) {
|
|
|
241
257
|
const routeFileForWebModulePath = env_1.env.metadata.paths.getRoutePathForWebModule(webModuleName);
|
|
242
258
|
if (tree.exists(routeFileForWebModulePath)) {
|
|
243
259
|
let rules = [];
|
|
244
|
-
return schematics_1.chain(rules)(tree, context);
|
|
260
|
+
return (0, schematics_1.chain)(rules)(tree, context);
|
|
245
261
|
}
|
|
246
262
|
else {
|
|
247
263
|
const webModulePath = getDestinationModulePathByWebModuleName(webModuleName);
|
|
248
|
-
Util_1.LogLn(`[ >] copy default Route file to webModule [${webModuleName}]`);
|
|
249
|
-
return schematics_1.chain([
|
|
250
|
-
schematics_1.branchAndMerge(schematics_1.chain([
|
|
251
|
-
schematics_1.mergeWith(schematics_1.apply(schematics_1.url(`./../mg-add/webModule/`), [
|
|
252
|
-
schematics_1.move(webModulePath)
|
|
264
|
+
(0, Util_1.LogLn)(`[ >] copy default Route file to webModule [${webModuleName}]`);
|
|
265
|
+
return (0, schematics_1.chain)([
|
|
266
|
+
(0, schematics_1.branchAndMerge)((0, schematics_1.chain)([
|
|
267
|
+
(0, schematics_1.mergeWith)((0, schematics_1.apply)((0, schematics_1.url)(`./../mg-add/webModule/`), [
|
|
268
|
+
(0, schematics_1.move)(webModulePath)
|
|
253
269
|
]), schematics_1.MergeStrategy.AllowCreationConflict)
|
|
254
270
|
]))
|
|
255
271
|
])(tree, context);
|