@magic-xpa/cli 4.1000.0-dev4100.36 → 4.1000.0-dev4100.360
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/package.json +1 -1
- package/src/collection.json +7 -0
- package/src/schematics/magic-utils/env.js +8 -4
- package/src/schematics/magic-utils/env.js.map +1 -1
- package/src/schematics/magic-utils/env.ts +10 -4
- package/src/schematics/magic-utils/rules/init-add-modules.rule.d.ts +2 -2
- package/src/schematics/magic-utils/rules/init-add-modules.rule.js +28 -11
- 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 +33 -21
- package/src/schematics/magic-utils/rules/init-gen-components.rule.d.ts +1 -1
- package/src/schematics/magic-utils/rules/init-gen-components.rule.js +17 -10
- package/src/schematics/magic-utils/rules/init-gen-components.rule.js.map +1 -1
- package/src/schematics/magic-utils/rules/init-gen-components.rule.ts +19 -12
- package/src/schematics/mg-generate-component/index.d.ts +3 -0
- package/src/schematics/mg-generate-component/index.js +22 -0
- package/src/schematics/mg-generate-component/index.js.map +1 -0
- package/src/schematics/mg-generate-component/index.ts +22 -0
- package/src/schematics/mg-generate-component/schema.json +29 -0
- package/templates/themes/table/HTMLTable/columnHeader.ejs +6 -1
package/package.json
CHANGED
package/src/collection.json
CHANGED
|
@@ -23,6 +23,13 @@
|
|
|
23
23
|
"aliases": ["magic-mg-generate"],
|
|
24
24
|
"hidden": true
|
|
25
25
|
},
|
|
26
|
+
"generate-component": {
|
|
27
|
+
"description": "generate component to the application through command line interface",
|
|
28
|
+
"factory": "./schematics/mg-generate-component/index#mgGenerateComponent",
|
|
29
|
+
"schema" : "./schematics/mg-generate-component/schema.json",
|
|
30
|
+
"aliases": ["magic-mg-generate-component"],
|
|
31
|
+
"hidden": true
|
|
32
|
+
},
|
|
26
33
|
"routes": {
|
|
27
34
|
"description": "generate routes to the application",
|
|
28
35
|
"factory": "./schematics/mg-routes/index#mgGenerateRoutes",
|
|
@@ -18,16 +18,20 @@ class Idependencies {
|
|
|
18
18
|
exports.Idependencies = Idependencies;
|
|
19
19
|
exports.dependencies = [
|
|
20
20
|
// material dependencies
|
|
21
|
-
{ name: "@angular/material", version: '^
|
|
22
|
-
{ name: "@angular/cdk", version: '^
|
|
23
|
-
{ name: "@angular/animations", version: '^
|
|
21
|
+
{ name: "@angular/material", version: '^14.0.0' },
|
|
22
|
+
{ name: "@angular/cdk", version: '^14.0.0' },
|
|
23
|
+
{ name: "@angular/animations", version: '^15.2.2' },
|
|
24
24
|
{ name: "font-awesome", version: '^4.7.0' },
|
|
25
25
|
{ name: "hammerjs", version: '^2.0.8' },
|
|
26
26
|
{ name: "ngx-infinite-scroll", version: '^10.0.0' },
|
|
27
27
|
{ name: "ng-dynamic-component", version: '~10.1.0' },
|
|
28
28
|
{ name: "rxjs-compat", version: "^6.6.0" },
|
|
29
29
|
{ name: "ngx-currency", version: "^2.5.2" },
|
|
30
|
-
{ name: "ngx-mask", version: "^13.1.15" }
|
|
30
|
+
{ name: "ngx-mask", version: "^13.1.15" },
|
|
31
|
+
// Time masking dependencies (hh:mm, hh:mm:ss, hh:mm:ss:mss)
|
|
32
|
+
{ name: "@maskito/angular", version: "^1.4.0" },
|
|
33
|
+
{ name: "@maskito/core", version: "^1.4.0" },
|
|
34
|
+
{ name: "@maskito/kit", version: "^1.4.0" }
|
|
31
35
|
];
|
|
32
36
|
exports.devDependencies = [
|
|
33
37
|
{ name: "@types/stacktrace-js", version: '^0.0.32' }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"env.js","sourceRoot":"","sources":["env.ts"],"names":[],"mappings":";;;AAKa,QAAA,YAAY,GAAW,gBAAgB,CAAC;AACxC,QAAA,oBAAoB,GAAG,oBAAoB,CAAC;AAC5C,QAAA,mBAAmB,GAAI,kBAAkB,CAAC;AAC1C,QAAA,UAAU,GAAa,OAAO,CAAC;AAC/B,QAAA,gBAAgB,GAAO,+BAA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,IAAI,EAAE,sBAAsB,EAAE,OAAO,EAAE,SAAS,EAAC;CACnD,CAAC;AACW,QAAA,GAAG,GAAU,EAAS,CAAC","sourcesContent":["// TODO(PK): hard-code for now, will query npm repo\n// to get this info in the future\nimport { MagicMetadata } from \"./metadata.class\";\nimport { IEnv } from \"../../types/interfaces/env.interface\";\n\nexport const METADATA_DIR = `magic-metadata`;\nexport const GEN_COMPONENTS_ARRAY = 'magicGenComponents';\nexport const GEN_COMPONENTS_HASH = 'magicGenCmpsHash';\nexport const GEN_FOLDER = 'magic';\nexport const MAGIC_CLI_FOLDER = './node_modules/@magic-xpa/cli';\nexport const GEN_LAZY_LOAD_MODULES_ARRAY = 'LazyLoadModulesMap';\nexport const manifest_path = `./${METADATA_DIR}/manifest.json`;\nexport const config_path = `./${METADATA_DIR}/config.json`;\n\nexport class Idependencies {\n constructor(setName:string, setVersion:string){\n this.name = setName;\n this.version = setVersion;\n }\n name:string;\n version:string;\n}\n\nexport var dependencies = [\n\n // material dependencies\n {name: \"@angular/material\" , version: '^14.0.0'},\n {name: \"@angular/cdk\" , version: '^14.0.0'},\n {name: \"@angular/animations\", version: '^15.2.2'},\n {name: \"font-awesome\" , version: '^4.7.0'},\n {name: \"hammerjs\" , version: '^2.0.8'},\n\n {name: \"ngx-infinite-scroll\" , version: '^10.0.0'},\n {name: \"ng-dynamic-component\", version: '~10.1.0'},\n {name: \"rxjs-compat\" , version: \"^6.6.0\"},\n {name: \"ngx-currency\" , version: \"^2.5.2\"},\n {name: \"ngx-mask\" , version: \"^13.1.15\"},\n\n // Time masking dependencies (hh:mm, hh:mm:ss, hh:mm:ss:mss)\n {name: \"@maskito/angular\" , version: \"^1.4.0\"},\n {name: \"@maskito/core\" , version: \"^1.4.0\"},\n {name: \"@maskito/kit\" , version: \"^1.4.0\"}\n\n];\n\nexport const devDependencies = [\n {name: \"@types/stacktrace-js\", version: '^0.0.32'}\n];\nexport const env : IEnv = {} as any;\n\n"]}
|
|
@@ -24,9 +24,9 @@ export class Idependencies {
|
|
|
24
24
|
export var dependencies = [
|
|
25
25
|
|
|
26
26
|
// material dependencies
|
|
27
|
-
{name: "@angular/material" , version: '^
|
|
28
|
-
{name: "@angular/cdk" , version: '^
|
|
29
|
-
{name: "@angular/animations", version: '^
|
|
27
|
+
{name: "@angular/material" , version: '^14.0.0'},
|
|
28
|
+
{name: "@angular/cdk" , version: '^14.0.0'},
|
|
29
|
+
{name: "@angular/animations", version: '^15.2.2'},
|
|
30
30
|
{name: "font-awesome" , version: '^4.7.0'},
|
|
31
31
|
{name: "hammerjs" , version: '^2.0.8'},
|
|
32
32
|
|
|
@@ -34,7 +34,13 @@ export var dependencies = [
|
|
|
34
34
|
{name: "ng-dynamic-component", version: '~10.1.0'},
|
|
35
35
|
{name: "rxjs-compat" , version: "^6.6.0"},
|
|
36
36
|
{name: "ngx-currency" , version: "^2.5.2"},
|
|
37
|
-
{name: "ngx-mask" , version: "^13.1.15"}
|
|
37
|
+
{name: "ngx-mask" , version: "^13.1.15"},
|
|
38
|
+
|
|
39
|
+
// Time masking dependencies (hh:mm, hh:mm:ss, hh:mm:ss:mss)
|
|
40
|
+
{name: "@maskito/angular" , version: "^1.4.0"},
|
|
41
|
+
{name: "@maskito/core" , version: "^1.4.0"},
|
|
42
|
+
{name: "@maskito/kit" , version: "^1.4.0"}
|
|
43
|
+
|
|
38
44
|
];
|
|
39
45
|
|
|
40
46
|
export const devDependencies = [
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { Rule } from "@angular-devkit/schematics";
|
|
2
2
|
import { MagicOptionScheme } from "./magic-option.scheme";
|
|
3
|
-
export declare function initGenModules(options: MagicOptionScheme): Rule;
|
|
3
|
+
export declare function initGenModules(options: MagicOptionScheme, generateViaCLI?: boolean): Rule;
|
|
4
4
|
export declare function overwriteWebModuleFileName(options: any, moduleNameFileName: string, content: string): Rule;
|
|
5
5
|
export declare function updateWebModuleFileWithNewClassName(options: any, webModuleName: string): Rule;
|
|
6
6
|
export declare function getDestinationModulePathByWebModuleName(webModuleName: string): string;
|
|
7
7
|
export declare function checkAndCreateModule(options: MagicOptionScheme, webModuleName: string, loadOnDemand: boolean): Rule;
|
|
8
8
|
export declare function generateWebModule(options: MagicOptionScheme, webModuleName: string, loadOnDemand: boolean): Rule;
|
|
9
|
-
export declare function generateWebModules(options: MagicOptionScheme): Rule;
|
|
9
|
+
export declare function generateWebModules(options: MagicOptionScheme, generateViaCLI?: boolean): Rule;
|
|
10
10
|
export declare function checkAndCreateRouteForModule(options: MagicOptionScheme, webModuleName: string, loadOnDemand: boolean): Rule;
|
|
11
11
|
export declare function createRoute(options: MagicOptionScheme, webModuleName: string): Rule;
|
|
12
12
|
export declare function addRouteFileToModuleFile(options: MagicOptionScheme, webModuleName: string): Rule;
|
|
@@ -9,23 +9,33 @@ const env_interface_1 = require("../../../types/interfaces/env.interface");
|
|
|
9
9
|
//-------------------------------------------------------------------------------------------------
|
|
10
10
|
// init generate module into env.modulesGen
|
|
11
11
|
//-------------------------------------------------------------------------------------------------
|
|
12
|
-
function initGenModules(options) {
|
|
12
|
+
function initGenModules(options, generateViaCLI = false) {
|
|
13
13
|
return (tree, context) => {
|
|
14
14
|
let metadata = env_1.env.metadata;
|
|
15
15
|
env_1.env.modulesGen = [];
|
|
16
16
|
let web_modules = metadata.config.web_modules;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
if (generateViaCLI) {
|
|
18
|
+
for (let moduleJsonPath of metadata.config.web_modules) {
|
|
19
|
+
if (moduleJsonPath.module_name === options.module) {
|
|
20
|
+
let moduleInfo = new env_interface_1.ModuleInfo(options.module, moduleJsonPath.load_on_demand);
|
|
21
|
+
env_1.env.modulesGen.push(moduleInfo);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
21
24
|
}
|
|
22
25
|
else {
|
|
23
|
-
// Generate
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
let moduleInfo = new env_interface_1.ModuleInfo(modulePath.module_name, modulePath.load_on_demand);
|
|
26
|
+
// Generate only one module from --module=xxxx
|
|
27
|
+
if (options.module) {
|
|
28
|
+
let moduleInfo = new env_interface_1.ModuleInfo(options.module, options.loadOnDemand);
|
|
27
29
|
env_1.env.modulesGen.push(moduleInfo);
|
|
28
30
|
}
|
|
31
|
+
else {
|
|
32
|
+
// Generate list of components from config.json, properties web_modules.module_name
|
|
33
|
+
for (let modulePath of web_modules) {
|
|
34
|
+
//LogLn(` Web Module name: [${modulePath.module_name}] IsLoadOnDemand? [${modulePath.load_on_demand}]`);
|
|
35
|
+
let moduleInfo = new env_interface_1.ModuleInfo(modulePath.module_name, modulePath.load_on_demand);
|
|
36
|
+
env_1.env.modulesGen.push(moduleInfo);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
29
39
|
}
|
|
30
40
|
(0, Util_1.LogLn)(` Number of modules to be check for generate: ${web_modules.length}`);
|
|
31
41
|
return tree;
|
|
@@ -175,12 +185,19 @@ exports.generateWebModule = generateWebModule;
|
|
|
175
185
|
//-------------------------------------------------------------------------------------------------
|
|
176
186
|
// generate all the modules in env.modulesGen
|
|
177
187
|
//-------------------------------------------------------------------------------------------------
|
|
178
|
-
function generateWebModules(options) {
|
|
188
|
+
function generateWebModules(options, generateViaCLI = false) {
|
|
179
189
|
return (tree, context) => {
|
|
180
190
|
let rules = [];
|
|
181
191
|
for (let webModuleInfo of env_1.env.modulesGen) {
|
|
182
192
|
if (webModuleInfo.moduleName !== undefined && webModuleInfo.moduleName !== "") {
|
|
183
|
-
|
|
193
|
+
if (generateViaCLI) {
|
|
194
|
+
if (webModuleInfo.moduleName === options.module) {
|
|
195
|
+
rules.push(generateWebModule(options, webModuleInfo.moduleName, webModuleInfo.loadOnDemand));
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
else {
|
|
199
|
+
rules.push(generateWebModule(options, webModuleInfo.moduleName, webModuleInfo.loadOnDemand));
|
|
200
|
+
}
|
|
184
201
|
}
|
|
185
202
|
}
|
|
186
203
|
return (0, schematics_1.chain)(rules)(tree, context);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init-add-modules.rule.js","sourceRoot":"","sources":["init-add-modules.rule.ts"],"names":[],"mappings":";;;AAAA,2DASoC;AAEpC,gCAAoE;AACpE,kCAAgC;AAEhC,yCAAuE;AACvE,2EAAqE;AAIrE,mGAAmG;AACnG,2CAA2C;AAC3C,mGAAmG;AACnG,SAAgB,cAAc,CAAC,OAA0B;IACvD,OAAO,CAAC,IAAU,EAAE,OAAyB,EAAE,EAAE;QAC/C,IAAI,QAAQ,GAAG,SAAG,CAAC,QAAQ,CAAC;QAC5B,SAAG,CAAC,UAAU,GAAG,EAAE,CAAC;QACpB,IAAI,WAAW,GAAoB,QAAQ,CAAC,MAAM,CAAC,WAAW,CAAC;QAE/D,8CAA8C;QAC9C,IAAI,OAAO,CAAC,MAAM,EAAE;YAClB,IAAI,UAAU,GAAiB,IAAI,0BAAU,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC;YACpF,SAAG,CAAC,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;SAChC;aAAM;YAEL,mFAAmF;YACnF,KAAK,IAAI,UAAU,IAAI,WAAW,EAAE;gBAClC,gHAAgH;gBAChH,IAAI,UAAU,GAAiB,IAAI,0BAAU,CAAC,UAAU,CAAC,WAAW,EAAE,UAAU,CAAC,cAAc,CAAC,CAAC;gBACjG,SAAG,CAAC,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;aACjC;SACF;QACD,IAAA,YAAK,EAAC,kDAAkD,WAAW,CAAC,MAAM,EAAE,CAAC,CAAC;QAI9E,OAAO,IAAI,CAAC;IACd,CAAC,CAAC;AACJ,CAAC;AAzBD,wCAyBC;AAED,mGAAmG;AACnG,0DAA0D;AAC1D,mGAAmG;AACnG,SAAgB,0BAA0B,CAAC,OAAY,EAAE,kBAAyB,EAAE,OAAc;IAChG,OAAO,CAAC,IAAU,EAAE,Q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,CAAC;AACJ,CAAC;AAbD,4DAaC;AACD,mGAAmG;AACnG,sDAAsD;AACtD,mGAAmG;AACnG,SAAS,qCAAqC,CAAC,OAAyB,EAAE,aAAoB;IAC5F,OAAO,CAAC,IAAU,EAAC,OAAwB,EAAE,EAAE;QAC7C,MAAM,yBAAyB,GAAG,SAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,wBAAwB,CAAC,aAAa,CAAC,CAAC;QAG7F,IAAG,IAAI,CAAC,MAAM,CAAC,yBAAyB,CAAC,EACzC;YACE,IAAI,KAAK,GAAU,EAAE,CAAC;YACtB,OAAO,IAAA,kBAAK,EAAC,KAAK,CAAC,CAAC,IAAI,EAAC,OAAO,CAAC,CAAC;SACnC;aAED;YACE,MAAM,aAAa,GAAG,uCAAuC,CAAC,aAAa,CAAC,CAAC;YAC7E,IAAA,YAAK,EAAC,8CAA8C,aAAa,GAAG,CAAC,CAAA;YACrE,OAAO,IAAA,kBAAK,EAAC;gBACX,IAAA,2BAAc,EAAC,IAAA,kBAAK,EAAC;oBACnB,IAAA,sBAAS,EACP,IAAA,kBAAK,EAAC,IAAA,gBAAG,EAAC,wBAAwB,CAAC,EAAE;wBAEnC,IAAA,iBAAI,EAAC,aAAa,CAAC;qBACpB,CAAC,EAAE,0BAAa,CAAC,qBAAqB,CAAC;iBAC3C,CAAC,CAAC;aACJ,CAAC,CAAC,IAAI,EAAC,OAAO,CAAC,CAAC;SAClB;IACH,CAAC,CAAA;AACH,CAAC","sourcesContent":["import {\n apply, branchAndMerge,\n chain,\n MergeStrategy, mergeWith,\n move,\n Rule,\n SchematicContext, SchematicsException,\n Tree,\n url\n} from \"@angular-devkit/schematics\";\nimport { MagicOptionScheme } from \"./magic-option.scheme\";\nimport {env, GEN_FOLDER, GEN_LAZY_LOAD_MODULES_ARRAY} from \"../env\";\nimport { LogLn } from \"../Util\";\nimport { Route, RouteTable, webModuleItem } from \"../../../types/interfaces/app\";\nimport {addModuleImportToModule, getSourceFile} from \"../../utils/ast\";\nimport { ModuleInfo } from \"../../../types/interfaces/env.interface\";\n\nimport {findNodes} from \"../../utils/devkit-utils/ast-utils\";\nimport * as ts from \"typescript\";\n//-------------------------------------------------------------------------------------------------\n// init generate module into env.modulesGen\n//-------------------------------------------------------------------------------------------------\nexport function initGenModules(options: MagicOptionScheme): Rule {\n return (tree: Tree, context: SchematicContext) => {\n let metadata = env.metadata;\n env.modulesGen = [];\n let web_modules:webModuleItem [] = metadata.config.web_modules;\n\n // Generate only one module from --module=xxxx\n if (options.module) {\n let moduleInfo : ModuleInfo = new ModuleInfo(options.module, options.loadOnDemand);\n env.modulesGen.push(moduleInfo)\n } else {\n\n // Generate list of components from config.json, properties web_modules.module_name\n for (let modulePath of web_modules) {\n //LogLn(` Web Module name: [${modulePath.module_name}] IsLoadOnDemand? [${modulePath.load_on_demand}]`);\n let moduleInfo : ModuleInfo = new ModuleInfo(modulePath.module_name, modulePath.load_on_demand);\n env.modulesGen.push(moduleInfo);\n }\n }\n LogLn(` Number of modules to be check for generate: ${web_modules.length}`);\n\n\n\n return tree;\n };\n}\n\n//-------------------------------------------------------------------------------------------------\n// overwrite the web module file name with the new content\n//-------------------------------------------------------------------------------------------------\nexport function overwriteWebModuleFileName(options: any, moduleNameFileName:string, content:string): Rule {\n return (tree: Tree, _context: SchematicContext) => {\n\n if(!tree.exists(moduleNameFileName)){\n LogLn(` [>Error] File cannot be overwrite, The file is not exist !!! : ${moduleNameFileName}`);\n }\n\n tree.overwrite(moduleNameFileName, content);\n return tree;\n };\n}\n\n//-------------------------------------------------------------------------------------------------\n// update the the web module file name with the new class name\n//-------------------------------------------------------------------------------------------------\nexport function updateWebModuleFileWithNewClassName(options: any, webModuleName:string): Rule {\n return (tree: Tree, context: SchematicContext) => {\n let rules:Rule[] = [];\n\n const origModuleFileName = getWebModuleFullFileName(webModuleName)\n\n // create new class name for \"web Module Name\"\n let newClassModuleName = getWebModuleClass(webModuleName );\n\n //read the exist module file name\n const text = tree.read(origModuleFileName);\n\n if (text === null) {\n throw new SchematicsException(`File ${origModuleFileName} does not exist.`);\n }\n let sourceText = text.toString('utf-8');\n\n if (sourceText !== \"\") {\n let newsourceText: string = sourceText.replace(`MagicGenLibModule`, newClassModuleName);\n rules.push(overwriteWebModuleFileName(options, origModuleFileName, newsourceText));\n\n }\n return chain(rules)(tree, context);\n };\n}\n\n//-------------------------------------------------------------------------------------------------\n// copy the two default files into the web module path\n//-------------------------------------------------------------------------------------------------\nfunction copyDefaultMagicFilesToWebModule(options:MagicOptionScheme, webModuleName:string): Rule {\n return (tree: Tree,context:SchematicContext) => {\n const webModulePath = getDestinationModulePathByWebModuleName(webModuleName);\n\n return chain([\n branchAndMerge(chain([\n mergeWith(\n apply(url(`./../mg-add/files/src/app/magic/`), [\n\n move(webModulePath)\n ]), MergeStrategy.AllowCreationConflict)\n ]))\n ])(tree,context);\n }\n}\n\n\n//-------------------------------------------------------------------------------------------------\n// delete LazyLoadService for non root modules\n//-------------------------------------------------------------------------------------------------\nfunction deleteLazyLoadService( webModuleName:string): Rule {\n return (tree: Tree) => {\n const lazyLoaderServicePath = getDestinationModulePathByWebModuleName(webModuleName) + '/lazy-loader.service.ts';\n\n if(webModuleName != '') {\n if (!tree.exists(lazyLoaderServicePath)) {\n LogLn(` [>Error] File cannot be overwrite, The file is not exist !!! :lazyLoaderServicePath`);\n }\n\n tree.delete(lazyLoaderServicePath);\n return tree;\n }\n }\n}\n\n\n//-------------------------------------------------------------------------------------------------\n// get destination path according to the send webModuleName\n//-------------------------------------------------------------------------------------------------\n export function getDestinationModulePathByWebModuleName(webModuleName:string):string {\n const newDestModulePath = `${env.metadata.paths.rootMagicGenFolder}/${GEN_FOLDER}/${webModuleName}`;\n return newDestModulePath;\n}\n\n//-------------------------------------------------------------------------------------------------\n// get web module full file name according to the send webModuleName\n//-------------------------------------------------------------------------------------------------\nfunction getWebModuleFullFileName(webModuleName:string):string {\n// calc the path of new the module\n const newDestModulePath = getDestinationModulePathByWebModuleName(webModuleName);\n return `${newDestModulePath}/magic.gen.lib.module.ts`;\n}\n\n//-------------------------------------------------------------------------------------------------\n// get web module class according to the send webModuleName\n//-------------------------------------------------------------------------------------------------\nfunction getWebModuleClass(webModuleName:string):string {\n return `Magic` + webModuleName + `Module`;\n}\n\n\n//-------------------------------------------------------------------------------------------------\n// add magic module to app module\n//-------------------------------------------------------------------------------------------------\nfunction addMagicModuleToAppModule(options: MagicOptionScheme, modulePath:string, moduleName:string, srcModuleName:string) : Rule {\n return (tree: Tree , context : SchematicContext)=>{\n const project = env.project;\n\n LogLn(` [>] add New Web Module :[${moduleName}] `);\n LogLn(` [>] from :[${srcModuleName}]`);\n LogLn(` [>] To App Module :[${modulePath}]`);\n addModuleImportToModule(\n tree,\n modulePath, // for now we will update env.metadata.paths.magicGenLibModule\n moduleName, // 'MagicXXXModule',\n srcModuleName, // `./XXX/magic.gen.lib.module`\n );\n return tree;\n }\n}\n\n//-------------------------------------------------------------------------------------------------\n// create module\n//-------------------------------------------------------------------------------------------------\nexport function checkAndCreateModule(options: MagicOptionScheme, webModuleName:string, loadOnDemand: boolean ): Rule {\n return (tree: Tree, context: SchematicContext) => {\n\n let rules: Rule[] = [];\n const webModuleFullFileName = getWebModuleFullFileName(webModuleName);\n // only if not exist create the new 2 files magic.gen.lib.module.ts & component-list.g.ts\n if (!tree.exists(webModuleFullFileName)) {\n rules.push(copyDefaultMagicFilesToWebModule(options, webModuleName));\n rules.push(updateWebModuleFileWithNewClassName(tree, webModuleName));\n rules.push(deleteLazyLoadService(webModuleName));\n // for NON load on demand we need to update magic root module\n if (!loadOnDemand) {\n const newDestModulePath = `./${webModuleName}/magic.gen.lib.module`;\n const webModuleClass = getWebModuleClass(webModuleName);\n rules.push(addMagicModuleToAppModule(options, env.metadata.paths.magicGenLibModule, webModuleClass, newDestModulePath));\n }\n return chain(rules)(tree, context);\n }\n ;\n }\n}\n\n//-------------------------------------------------------------------------------------------------\n// check if module is exist, only if not exist create the web module\n//-------------------------------------------------------------------------------------------------\nexport function generateWebModule(options: MagicOptionScheme, webModuleName:string, loadOnDemand:boolean ): Rule {\n return (tree: Tree, context: SchematicContext) => {\n\n let rules:Rule[] = [];\n\n LogLn(` [>]Handling Web Module named: [${webModuleName}] isLoadOnDemand: [${loadOnDemand}]`);\n rules.push(checkAndCreateModule(options, webModuleName, loadOnDemand));\n rules.push(checkAndCreateRouteForModule(options, webModuleName, loadOnDemand));\n\n return chain(rules)(tree,context);\n };\n}\n\n\n//-------------------------------------------------------------------------------------------------\n// generate all the modules in env.modulesGen\n//-------------------------------------------------------------------------------------------------\nexport function generateWebModules(options: MagicOptionScheme): Rule {\n return (tree: Tree, context: SchematicContext) => {\n\n let rules:Rule[] = [];\n\n for (let webModuleInfo of env.modulesGen){\n if (webModuleInfo.moduleName !== undefined && webModuleInfo.moduleName !== \"\") {\n rules.push(generateWebModule(options, webModuleInfo.moduleName, webModuleInfo.loadOnDemand));\n }\n }\n\n return chain(rules)(tree,context);\n };\n}\n\n\n\n//-------------------------------------------------------------------------------------------------\n// check if module is exist, only if not exist create the web module\n//-------------------------------------------------------------------------------------------------\nexport function checkAndCreateRouteForModule(options: MagicOptionScheme, webModuleName:string, loadOnDemand :boolean): Rule {\n return (tree: Tree, context: SchematicContext) => {\n\n let rules:Rule[] = [];\n\n if (loadOnDemand) {\n const newDestRoutePathForModule = env.metadata.paths.getRoutePathForWebModule(webModuleName);\n\n // only if file not exist then copy the default route\n if (!tree.exists(newDestRoutePathForModule)) {\n rules.push(createRoute(options, webModuleName));\n }\n else{\n // if file exist then only update the magic.gen.lib.module.ts\n rules.push(addRouteFileToModuleFile(options, webModuleName));\n }\n }\n return chain(rules)(tree,context);\n };\n}\n\n\n\n//-------------------------------------------------------------------------------------------------\n// create route for module\n//-------------------------------------------------------------------------------------------------\nexport function createRoute(options: MagicOptionScheme, webModuleName:string): Rule {\n return (tree: Tree, context: SchematicContext) => {\n\n let rules:Rule[] = [];\n\n rules.push(copyDefaultRouteMagicFilesToWebModule(options, webModuleName));\n // --------------------------------------------------------\n // // generate the route for module /////\n // let routeItem : RouteTable = new RouteTable();\n // routeItem.module_name = webModuleName;\n //\n // let route:Route = new Route();\n // route.ModuleName = webModuleName;\n // route.OutletName=\"\";\n // route.RouteName=\"\";\n // route.children=null;\n //\n // routeItem.routesArray = [route];\n // rules.push(genRouteFile(options, routeItem ));\n // --------------------------------------------------------\n // update the new MagicRoutingModule in file magic.gen.lib.module.ts of the module\n\n\n rules.push(addRouteFileToModuleFile(options, webModuleName));\n\n return chain(rules)(tree,context);\n };\n}\n\n//-------------------------------------------------------------------------------------------------\n// create route for module\n//-------------------------------------------------------------------------------------------------\nexport function addRouteFileToModuleFile(options: MagicOptionScheme, webModuleName:string): Rule {\n return (tree: Tree, context: SchematicContext) => {\n\n let rules:Rule[] = [];\n\n const modulePath = getWebModuleFullFileName(webModuleName); // get the magic.gen.lib.module.ts according to the module name\n const moduleName = `MagicRoutingModule`;//for now it will be the same for all modules ... getWebModuleClass(webModuleName);\n const srcModuleName = `./app.routes`;\n\n rules.push(addMagicModuleToAppModule(options, modulePath, moduleName, srcModuleName));\n\n return chain(rules)(tree,context);\n };\n}\n//-------------------------------------------------------------------------------------------------\n// copy the two default files into the web module path\n//-------------------------------------------------------------------------------------------------\nfunction copyDefaultRouteMagicFilesToWebModule(options:MagicOptionScheme, webModuleName:string): Rule {\n return (tree: Tree,context:SchematicContext) => {\n const routeFileForWebModulePath = env.metadata.paths.getRoutePathForWebModule(webModuleName);\n\n\n if(tree.exists(routeFileForWebModulePath))\n {\n let rules:Rule[] = [];\n return chain(rules)(tree,context);\n }\n else\n {\n const webModulePath = getDestinationModulePathByWebModuleName(webModuleName);\n LogLn(`[ >] copy default Route file to webModule [${webModuleName}]`)\n return chain([\n branchAndMerge(chain([\n mergeWith(\n apply(url(`./../mg-add/webModule/`), [\n\n move(webModulePath)\n ]), MergeStrategy.AllowCreationConflict)\n ]))\n ])(tree,context);\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"init-add-modules.r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,gBAAG,EAAC,wBAAwB,CAAC,EAAE;wBAEnC,IAAA,iBAAI,EAAC,aAAa,CAAC;qBACpB,CAAC,EAAE,0BAAa,CAAC,qBAAqB,CAAC;iBAC3C,CAAC,CAAC;aACJ,CAAC,CAAC,IAAI,EAAC,OAAO,CAAC,CAAC;SAClB;IACH,CAAC,CAAA;AACH,CAAC","sourcesContent":["import {\n apply, branchAndMerge,\n chain,\n MergeStrategy, mergeWith,\n move,\n Rule,\n SchematicContext, SchematicsException,\n Tree,\n url\n} from \"@angular-devkit/schematics\";\nimport { MagicOptionScheme } from \"./magic-option.scheme\";\nimport {env, GEN_FOLDER, GEN_LAZY_LOAD_MODULES_ARRAY} from \"../env\";\nimport { LogLn } from \"../Util\";\nimport { Route, RouteTable, webModuleItem } from \"../../../types/interfaces/app\";\nimport {addModuleImportToModule, getSourceFile} from \"../../utils/ast\";\nimport { ModuleInfo } from \"../../../types/interfaces/env.interface\";\n\nimport {findNodes} from \"../../utils/devkit-utils/ast-utils\";\nimport * as ts from \"typescript\";\n//-------------------------------------------------------------------------------------------------\n// init generate module into env.modulesGen\n//-------------------------------------------------------------------------------------------------\nexport function initGenModules(options: MagicOptionScheme, generateViaCLI:boolean = false): Rule {\n return (tree: Tree, context: SchematicContext) => {\n let metadata = env.metadata;\n env.modulesGen = [];\n let web_modules:webModuleItem [] = metadata.config.web_modules;\n\n if(generateViaCLI){\n for (let moduleJsonPath of metadata.config.web_modules) {\n if (moduleJsonPath.module_name === options.module) {\n let moduleInfo: ModuleInfo = new ModuleInfo(options.module, moduleJsonPath.load_on_demand);\n env.modulesGen.push(moduleInfo)\n }\n }\n }else{\n // Generate only one module from --module=xxxx\n if (options.module) {\n let moduleInfo : ModuleInfo = new ModuleInfo(options.module, options.loadOnDemand);\n env.modulesGen.push(moduleInfo)\n } else {\n\n // Generate list of components from config.json, properties web_modules.module_name\n for (let modulePath of web_modules) {\n //LogLn(` Web Module name: [${modulePath.module_name}] IsLoadOnDemand? [${modulePath.load_on_demand}]`);\n let moduleInfo : ModuleInfo = new ModuleInfo(modulePath.module_name, modulePath.load_on_demand);\n env.modulesGen.push(moduleInfo);\n }\n }\n }\n LogLn(` Number of modules to be check for generate: ${web_modules.length}`);\n return tree;\n };\n}\n\n//-------------------------------------------------------------------------------------------------\n// overwrite the web module file name with the new content\n//-------------------------------------------------------------------------------------------------\nexport function overwriteWebModuleFileName(options: any, moduleNameFileName:string, content:string): Rule {\n return (tree: Tree, _context: SchematicContext) => {\n\n if(!tree.exists(moduleNameFileName)){\n LogLn(` [>Error] File cannot be overwrite, The file is not exist !!! : ${moduleNameFileName}`);\n }\n\n tree.overwrite(moduleNameFileName, content);\n return tree;\n };\n}\n\n//-------------------------------------------------------------------------------------------------\n// update the the web module file name with the new class name\n//-------------------------------------------------------------------------------------------------\nexport function updateWebModuleFileWithNewClassName(options: any, webModuleName:string): Rule {\n return (tree: Tree, context: SchematicContext) => {\n let rules:Rule[] = [];\n\n const origModuleFileName = getWebModuleFullFileName(webModuleName)\n\n // create new class name for \"web Module Name\"\n let newClassModuleName = getWebModuleClass(webModuleName );\n\n //read the exist module file name\n const text = tree.read(origModuleFileName);\n\n if (text === null) {\n throw new SchematicsException(`File ${origModuleFileName} does not exist.`);\n }\n let sourceText = text.toString('utf-8');\n\n if (sourceText !== \"\") {\n let newsourceText: string = sourceText.replace(`MagicGenLibModule`, newClassModuleName);\n rules.push(overwriteWebModuleFileName(options, origModuleFileName, newsourceText));\n\n }\n return chain(rules)(tree, context);\n };\n}\n\n//-------------------------------------------------------------------------------------------------\n// copy the two default files into the web module path\n//-------------------------------------------------------------------------------------------------\nfunction copyDefaultMagicFilesToWebModule(options:MagicOptionScheme, webModuleName:string): Rule {\n return (tree: Tree,context:SchematicContext) => {\n const webModulePath = getDestinationModulePathByWebModuleName(webModuleName);\n\n return chain([\n branchAndMerge(chain([\n mergeWith(\n apply(url(`./../mg-add/files/src/app/magic/`), [\n\n move(webModulePath)\n ]), MergeStrategy.AllowCreationConflict)\n ]))\n ])(tree,context);\n }\n}\n\n\n//-------------------------------------------------------------------------------------------------\n// delete LazyLoadService for non root modules\n//-------------------------------------------------------------------------------------------------\nfunction deleteLazyLoadService( webModuleName:string): Rule {\n return (tree: Tree) => {\n const lazyLoaderServicePath = getDestinationModulePathByWebModuleName(webModuleName) + '/lazy-loader.service.ts';\n\n if(webModuleName != '') {\n if (!tree.exists(lazyLoaderServicePath)) {\n LogLn(` [>Error] File cannot be overwrite, The file is not exist !!! :lazyLoaderServicePath`);\n }\n\n tree.delete(lazyLoaderServicePath);\n return tree;\n }\n }\n}\n\n\n//-------------------------------------------------------------------------------------------------\n// get destination path according to the send webModuleName\n//-------------------------------------------------------------------------------------------------\nexport function getDestinationModulePathByWebModuleName(webModuleName:string):string {\n const newDestModulePath = `${env.metadata.paths.rootMagicGenFolder}/${GEN_FOLDER}/${webModuleName}`;\n return newDestModulePath;\n}\n\n//-------------------------------------------------------------------------------------------------\n// get web module full file name according to the send webModuleName\n//-------------------------------------------------------------------------------------------------\nfunction getWebModuleFullFileName(webModuleName:string):string {\n// calc the path of new the module\n const newDestModulePath = getDestinationModulePathByWebModuleName(webModuleName);\n return `${newDestModulePath}/magic.gen.lib.module.ts`;\n}\n\n//-------------------------------------------------------------------------------------------------\n// get web module class according to the send webModuleName\n//-------------------------------------------------------------------------------------------------\nfunction getWebModuleClass(webModuleName:string):string {\n return `Magic` + webModuleName + `Module`;\n}\n\n\n//-------------------------------------------------------------------------------------------------\n// add magic module to app module\n//-------------------------------------------------------------------------------------------------\nfunction addMagicModuleToAppModule(options: MagicOptionScheme, modulePath:string, moduleName:string, srcModuleName:string) : Rule {\n return (tree: Tree , context : SchematicContext)=>{\n const project = env.project;\n\n LogLn(` [>] add New Web Module :[${moduleName}] `);\n LogLn(` [>] from :[${srcModuleName}]`);\n LogLn(` [>] To App Module :[${modulePath}]`);\n addModuleImportToModule(\n tree,\n modulePath, // for now we will update env.metadata.paths.magicGenLibModule\n moduleName, // 'MagicXXXModule',\n srcModuleName, // `./XXX/magic.gen.lib.module`\n );\n return tree;\n }\n}\n\n//-------------------------------------------------------------------------------------------------\n// create module\n//-------------------------------------------------------------------------------------------------\nexport function checkAndCreateModule(options: MagicOptionScheme, webModuleName:string, loadOnDemand: boolean ): Rule {\n return (tree: Tree, context: SchematicContext) => {\n\n let rules: Rule[] = [];\n const webModuleFullFileName = getWebModuleFullFileName(webModuleName);\n // only if not exist create the new 2 files magic.gen.lib.module.ts & component-list.g.ts\n if (!tree.exists(webModuleFullFileName)) {\n rules.push(copyDefaultMagicFilesToWebModule(options, webModuleName));\n rules.push(updateWebModuleFileWithNewClassName(tree, webModuleName));\n rules.push(deleteLazyLoadService(webModuleName));\n // for NON load on demand we need to update magic root module\n if (!loadOnDemand) {\n const newDestModulePath = `./${webModuleName}/magic.gen.lib.module`;\n const webModuleClass = getWebModuleClass(webModuleName);\n rules.push(addMagicModuleToAppModule(options, env.metadata.paths.magicGenLibModule, webModuleClass, newDestModulePath));\n }\n return chain(rules)(tree, context);\n }\n ;\n }\n}\n\n//-------------------------------------------------------------------------------------------------\n// check if module is exist, only if not exist create the web module\n//-------------------------------------------------------------------------------------------------\nexport function generateWebModule(options: MagicOptionScheme, webModuleName:string, loadOnDemand:boolean ): Rule {\n return (tree: Tree, context: SchematicContext) => {\n\n let rules:Rule[] = [];\n\n LogLn(` [>]Handling Web Module named: [${webModuleName}] isLoadOnDemand: [${loadOnDemand}]`);\n rules.push(checkAndCreateModule(options, webModuleName, loadOnDemand));\n rules.push(checkAndCreateRouteForModule(options, webModuleName, loadOnDemand));\n\n return chain(rules)(tree,context);\n };\n}\n\n\n//-------------------------------------------------------------------------------------------------\n// generate all the modules in env.modulesGen\n//-------------------------------------------------------------------------------------------------\nexport function generateWebModules(options: MagicOptionScheme, generateViaCLI:boolean = false): Rule {\n return (tree: Tree, context: SchematicContext) => {\n\n let rules:Rule[] = [];\n\n for (let webModuleInfo of env.modulesGen){\n if (webModuleInfo.moduleName !== undefined && webModuleInfo.moduleName !== \"\") {\n if (generateViaCLI) {\n if (webModuleInfo.moduleName === options.module) {\n rules.push(generateWebModule(options, webModuleInfo.moduleName, webModuleInfo.loadOnDemand));\n }\n }else{\n rules.push(generateWebModule(options, webModuleInfo.moduleName, webModuleInfo.loadOnDemand));\n }\n }\n }\n\n return chain(rules)(tree,context);\n };\n}\n\n\n\n//-------------------------------------------------------------------------------------------------\n// check if module is exist, only if not exist create the web module\n//-------------------------------------------------------------------------------------------------\nexport function checkAndCreateRouteForModule(options: MagicOptionScheme, webModuleName:string, loadOnDemand :boolean): Rule {\n return (tree: Tree, context: SchematicContext) => {\n\n let rules:Rule[] = [];\n\n if (loadOnDemand) {\n const newDestRoutePathForModule = env.metadata.paths.getRoutePathForWebModule(webModuleName);\n\n // only if file not exist then copy the default route\n if (!tree.exists(newDestRoutePathForModule)) {\n rules.push(createRoute(options, webModuleName));\n }\n else{\n // if file exist then only update the magic.gen.lib.module.ts\n rules.push(addRouteFileToModuleFile(options, webModuleName));\n }\n }\n return chain(rules)(tree,context);\n };\n}\n\n\n\n//-------------------------------------------------------------------------------------------------\n// create route for module\n//-------------------------------------------------------------------------------------------------\nexport function createRoute(options: MagicOptionScheme, webModuleName:string): Rule {\n return (tree: Tree, context: SchematicContext) => {\n\n let rules:Rule[] = [];\n\n rules.push(copyDefaultRouteMagicFilesToWebModule(options, webModuleName));\n // --------------------------------------------------------\n // // generate the route for module /////\n // let routeItem : RouteTable = new RouteTable();\n // routeItem.module_name = webModuleName;\n //\n // let route:Route = new Route();\n // route.ModuleName = webModuleName;\n // route.OutletName=\"\";\n // route.RouteName=\"\";\n // route.children=null;\n //\n // routeItem.routesArray = [route];\n // rules.push(genRouteFile(options, routeItem ));\n // --------------------------------------------------------\n // update the new MagicRoutingModule in file magic.gen.lib.module.ts of the module\n\n\n rules.push(addRouteFileToModuleFile(options, webModuleName));\n\n return chain(rules)(tree,context);\n };\n}\n\n//-------------------------------------------------------------------------------------------------\n// create route for module\n//-------------------------------------------------------------------------------------------------\nexport function addRouteFileToModuleFile(options: MagicOptionScheme, webModuleName:string): Rule {\n return (tree: Tree, context: SchematicContext) => {\n\n let rules:Rule[] = [];\n\n const modulePath = getWebModuleFullFileName(webModuleName); // get the magic.gen.lib.module.ts according to the module name\n const moduleName = `MagicRoutingModule`;//for now it will be the same for all modules ... getWebModuleClass(webModuleName);\n const srcModuleName = `./app.routes`;\n\n rules.push(addMagicModuleToAppModule(options, modulePath, moduleName, srcModuleName));\n\n return chain(rules)(tree,context);\n };\n}\n//-------------------------------------------------------------------------------------------------\n// copy the two default files into the web module path\n//-------------------------------------------------------------------------------------------------\nfunction copyDefaultRouteMagicFilesToWebModule(options:MagicOptionScheme, webModuleName:string): Rule {\n return (tree: Tree,context:SchematicContext) => {\n const routeFileForWebModulePath = env.metadata.paths.getRoutePathForWebModule(webModuleName);\n\n\n if(tree.exists(routeFileForWebModulePath))\n {\n let rules:Rule[] = [];\n return chain(rules)(tree,context);\n }\n else\n {\n const webModulePath = getDestinationModulePathByWebModuleName(webModuleName);\n LogLn(`[ >] copy default Route file to webModule [${webModuleName}]`)\n return chain([\n branchAndMerge(chain([\n mergeWith(\n apply(url(`./../mg-add/webModule/`), [\n\n move(webModulePath)\n ]), MergeStrategy.AllowCreationConflict)\n ]))\n ])(tree,context);\n }\n }\n}\n"]}
|
|
@@ -20,29 +20,35 @@ import * as ts from "typescript";
|
|
|
20
20
|
//-------------------------------------------------------------------------------------------------
|
|
21
21
|
// init generate module into env.modulesGen
|
|
22
22
|
//-------------------------------------------------------------------------------------------------
|
|
23
|
-
export function initGenModules(options: MagicOptionScheme): Rule {
|
|
23
|
+
export function initGenModules(options: MagicOptionScheme, generateViaCLI:boolean = false): Rule {
|
|
24
24
|
return (tree: Tree, context: SchematicContext) => {
|
|
25
25
|
let metadata = env.metadata;
|
|
26
26
|
env.modulesGen = [];
|
|
27
27
|
let web_modules:webModuleItem [] = metadata.config.web_modules;
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
29
|
+
if(generateViaCLI){
|
|
30
|
+
for (let moduleJsonPath of metadata.config.web_modules) {
|
|
31
|
+
if (moduleJsonPath.module_name === options.module) {
|
|
32
|
+
let moduleInfo: ModuleInfo = new ModuleInfo(options.module, moduleJsonPath.load_on_demand);
|
|
33
|
+
env.modulesGen.push(moduleInfo)
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}else{
|
|
37
|
+
// Generate only one module from --module=xxxx
|
|
38
|
+
if (options.module) {
|
|
39
|
+
let moduleInfo : ModuleInfo = new ModuleInfo(options.module, options.loadOnDemand);
|
|
40
|
+
env.modulesGen.push(moduleInfo)
|
|
41
|
+
} else {
|
|
42
|
+
|
|
43
|
+
// Generate list of components from config.json, properties web_modules.module_name
|
|
44
|
+
for (let modulePath of web_modules) {
|
|
45
|
+
//LogLn(` Web Module name: [${modulePath.module_name}] IsLoadOnDemand? [${modulePath.load_on_demand}]`);
|
|
46
|
+
let moduleInfo : ModuleInfo = new ModuleInfo(modulePath.module_name, modulePath.load_on_demand);
|
|
47
|
+
env.modulesGen.push(moduleInfo);
|
|
48
|
+
}
|
|
40
49
|
}
|
|
41
50
|
}
|
|
42
51
|
LogLn(` Number of modules to be check for generate: ${web_modules.length}`);
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
52
|
return tree;
|
|
47
53
|
};
|
|
48
54
|
}
|
|
@@ -133,7 +139,7 @@ function deleteLazyLoadService( webModuleName:string): Rule {
|
|
|
133
139
|
//-------------------------------------------------------------------------------------------------
|
|
134
140
|
// get destination path according to the send webModuleName
|
|
135
141
|
//-------------------------------------------------------------------------------------------------
|
|
136
|
-
|
|
142
|
+
export function getDestinationModulePathByWebModuleName(webModuleName:string):string {
|
|
137
143
|
const newDestModulePath = `${env.metadata.paths.rootMagicGenFolder}/${GEN_FOLDER}/${webModuleName}`;
|
|
138
144
|
return newDestModulePath;
|
|
139
145
|
}
|
|
@@ -170,7 +176,7 @@ function addMagicModuleToAppModule(options: MagicOptionScheme, modulePath:string
|
|
|
170
176
|
modulePath, // for now we will update env.metadata.paths.magicGenLibModule
|
|
171
177
|
moduleName, // 'MagicXXXModule',
|
|
172
178
|
srcModuleName, // `./XXX/magic.gen.lib.module`
|
|
173
|
-
|
|
179
|
+
);
|
|
174
180
|
return tree;
|
|
175
181
|
}
|
|
176
182
|
}
|
|
@@ -220,14 +226,20 @@ export function generateWebModule(options: MagicOptionScheme, webModuleName:stri
|
|
|
220
226
|
//-------------------------------------------------------------------------------------------------
|
|
221
227
|
// generate all the modules in env.modulesGen
|
|
222
228
|
//-------------------------------------------------------------------------------------------------
|
|
223
|
-
export function generateWebModules(options: MagicOptionScheme): Rule {
|
|
229
|
+
export function generateWebModules(options: MagicOptionScheme, generateViaCLI:boolean = false): Rule {
|
|
224
230
|
return (tree: Tree, context: SchematicContext) => {
|
|
225
231
|
|
|
226
232
|
let rules:Rule[] = [];
|
|
227
233
|
|
|
228
234
|
for (let webModuleInfo of env.modulesGen){
|
|
229
235
|
if (webModuleInfo.moduleName !== undefined && webModuleInfo.moduleName !== "") {
|
|
230
|
-
|
|
236
|
+
if (generateViaCLI) {
|
|
237
|
+
if (webModuleInfo.moduleName === options.module) {
|
|
238
|
+
rules.push(generateWebModule(options, webModuleInfo.moduleName, webModuleInfo.loadOnDemand));
|
|
239
|
+
}
|
|
240
|
+
}else{
|
|
241
|
+
rules.push(generateWebModule(options, webModuleInfo.moduleName, webModuleInfo.loadOnDemand));
|
|
242
|
+
}
|
|
231
243
|
}
|
|
232
244
|
}
|
|
233
245
|
|
|
@@ -271,7 +283,7 @@ export function createRoute(options: MagicOptionScheme, webModuleName:string): R
|
|
|
271
283
|
|
|
272
284
|
let rules:Rule[] = [];
|
|
273
285
|
|
|
274
|
-
|
|
286
|
+
rules.push(copyDefaultRouteMagicFilesToWebModule(options, webModuleName));
|
|
275
287
|
// --------------------------------------------------------
|
|
276
288
|
// // generate the route for module /////
|
|
277
289
|
// let routeItem : RouteTable = new RouteTable();
|
|
@@ -289,7 +301,7 @@ export function createRoute(options: MagicOptionScheme, webModuleName:string): R
|
|
|
289
301
|
// update the new MagicRoutingModule in file magic.gen.lib.module.ts of the module
|
|
290
302
|
|
|
291
303
|
|
|
292
|
-
|
|
304
|
+
rules.push(addRouteFileToModuleFile(options, webModuleName));
|
|
293
305
|
|
|
294
306
|
return chain(rules)(tree,context);
|
|
295
307
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { Rule } from "@angular-devkit/schematics";
|
|
2
2
|
import { MagicOptionScheme } from "./magic-option.scheme";
|
|
3
|
-
export declare function initAndGenComponentsForModule(options: MagicOptionScheme, shouldBuildAndUpdateModule: boolean): Rule;
|
|
3
|
+
export declare function initAndGenComponentsForModule(options: MagicOptionScheme, shouldBuildAndUpdateModule: boolean, generateViaCLI?: boolean): Rule;
|
|
4
4
|
export declare function initGenComponentsFromList(options: MagicOptionScheme, module_name: string, component: string, form_files: string[]): Rule;
|
|
@@ -8,7 +8,8 @@ const build_view_rule_1 = require("./build-view.rule");
|
|
|
8
8
|
const component_list_rule_1 = require("./component-list.rule");
|
|
9
9
|
const init_add_modules_rule_1 = require("./init-add-modules.rule");
|
|
10
10
|
const utils_1 = require("../utils");
|
|
11
|
-
|
|
11
|
+
const Util_1 = require("../Util");
|
|
12
|
+
function initAndGenComponentsForModule(options, shouldBuildAndUpdateModule, generateViaCLI = false) {
|
|
12
13
|
return (tree, context) => {
|
|
13
14
|
let metadata = env_1.env.metadata;
|
|
14
15
|
env_1.env.componentsGen = [];
|
|
@@ -16,16 +17,22 @@ function initAndGenComponentsForModule(options, shouldBuildAndUpdateModule) {
|
|
|
16
17
|
rules.push((0, utils_1.displayMessge)(options, " ********************************* START GENERATE *********************************"));
|
|
17
18
|
// if we need to build and update module , first generate(if needed) the modules
|
|
18
19
|
if (shouldBuildAndUpdateModule) {
|
|
19
|
-
rules.push((0, init_add_modules_rule_1.initGenModules)(options));
|
|
20
|
-
rules.push((0, init_add_modules_rule_1.generateWebModules)(options));
|
|
20
|
+
rules.push((0, init_add_modules_rule_1.initGenModules)(options, generateViaCLI));
|
|
21
|
+
rules.push((0, init_add_modules_rule_1.generateWebModules)(options, generateViaCLI));
|
|
21
22
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
rules.push((0,
|
|
23
|
+
let generatedModules = metadata.config.web_modules.filter(moduleJsonPath => !generateViaCLI || moduleJsonPath.module_name === options.module);
|
|
24
|
+
if (generatedModules.length === 0) {
|
|
25
|
+
(0, Util_1.LogLn)(`Metadata for module '${options.module}' doesn't exist.`);
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
for (let moduleJsonPath of generatedModules) {
|
|
29
|
+
rules.push((0, utils_1.displayMessge)(options, ` ****** Start Web Module name : [${moduleJsonPath.module_name}] *******`));
|
|
30
|
+
rules.push(initGenComponentsFromList(options, moduleJsonPath.module_name, options.component, moduleJsonPath.form_files));
|
|
31
|
+
rules.push((0, load_views_gen_rule_1.loadViewsToGen)(options));
|
|
32
|
+
if (shouldBuildAndUpdateModule) {
|
|
33
|
+
rules.push((0, build_view_rule_1.buildViews)(options, moduleJsonPath.module_name));
|
|
34
|
+
rules.push((0, component_list_rule_1.componentlistGen)(options, moduleJsonPath.module_name, moduleJsonPath.load_on_demand));
|
|
35
|
+
}
|
|
29
36
|
}
|
|
30
37
|
}
|
|
31
38
|
rules.push((0, utils_1.displayMessge)(options, " ********************************* E N D GENERATE *********************************"));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init-gen-components.rule.js","sourceRoot":"","sources":["init-gen-components.rule.ts"],"names":[],"mappings":";;;AAAA,2DAAiF;AAEjF,gCAA6B;AAC7B,+DAAuD;AACvD,uDAA+C;AAC/C,+DAAyD;AACzD,mE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,CAAC,aAAa,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;aAC1C;SACF;QACD,OAAO,IAAI,CAAC;IACd,CAAC,CAAC;AACJ,CAAC;AApBD,8DAoBC","sourcesContent":["import { chain, Rule, SchematicContext, Tree } from \"@angular-devkit/schematics\";\r\nimport { MagicOptionScheme } from \"./magic-option.scheme\";\r\nimport { env } from \"../env\";\r\nimport { loadViewsToGen } from \"./load-views-gen.rule\";\r\nimport { buildViews } from \"./build-view.rule\";\r\nimport { componentlistGen } from \"./component-list.rule\";\r\nimport { generateWebModules, initGenModules } from \"./init-add-modules.rule\";\r\nimport { displayMessge } from \"../utils\";\r\nimport {LogLn} from \"../Util\";\r\n\r\nexport function initAndGenComponentsForModule(options: MagicOptionScheme, shouldBuildAndUpdateModule: boolean, generateViaCLI: boolean = false): Rule {\r\n return (tree: Tree, context: SchematicContext) => {\r\n let metadata = env.metadata;\r\n env.componentsGen = [];\r\n let rules:Rule[] = [];\r\n\r\n rules.push(displayMessge(options, \" ********************************* START GENERATE *********************************\"))\r\n // if we need to build and update module , first generate(if needed) the modules\r\n if (shouldBuildAndUpdateModule) {\r\n rules.push(initGenModules (options, generateViaCLI));\r\n rules.push(generateWebModules(options, generateViaCLI));\r\n }\r\n\r\n let generatedModules = metadata.config.web_modules.filter(\r\n moduleJsonPath => !generateViaCLI || moduleJsonPath.module_name === options.module\r\n );\r\n if (generatedModules.length === 0) {\r\n LogLn(`Metadata for module '${options.module}' doesn't exist.`);\r\n } else {\r\n for (let moduleJsonPath of generatedModules) {\r\n rules.push(displayMessge(options, ` ****** Start Web Module name : [${moduleJsonPath.module_name}] *******`))\r\n\r\n rules.push(initGenComponentsFromList(options, moduleJsonPath.module_name, options.component, moduleJsonPath.form_files));\r\n rules.push(loadViewsToGen(options));\r\n\r\n if (shouldBuildAndUpdateModule) {\r\n rules.push(buildViews(options, moduleJsonPath.module_name));\r\n rules.push(componentlistGen(options, moduleJsonPath.module_name, moduleJsonPath.load_on_demand));\r\n }\r\n }\r\n }\r\n\r\n rules.push(displayMessge(options, \" ********************************* E N D GENERATE *********************************\"))\r\n return chain(rules)(tree, context);\r\n };\r\n}\r\n\r\n\r\nexport function initGenComponentsFromList(options: MagicOptionScheme, module_name:string, component: string, form_files: string[]): Rule {\r\n return (host: Tree, context: SchematicContext) => {\r\n let metadata = env.metadata;\r\n env.componentsGen = [];\r\n\r\n // Generate only one component from --component=xxxx\r\n if (component) {\r\n env.componentsGen.push(component)\r\n } else {\r\n\r\n // Generate list of components from config.json, properties form_views.\r\n for (let cmpJsonPath of form_files) {\r\n\r\n let JsonRelativePath = env.metadata.paths.getRelativePathForComponentInModule(module_name, cmpJsonPath);\r\n\r\n env.componentsGen.push(JsonRelativePath);\r\n }\r\n }\r\n return host;\r\n };\r\n}\r\n"]}
|
|
@@ -6,9 +6,9 @@ import { buildViews } from "./build-view.rule";
|
|
|
6
6
|
import { componentlistGen } from "./component-list.rule";
|
|
7
7
|
import { generateWebModules, initGenModules } from "./init-add-modules.rule";
|
|
8
8
|
import { displayMessge } from "../utils";
|
|
9
|
+
import {LogLn} from "../Util";
|
|
9
10
|
|
|
10
|
-
|
|
11
|
-
export function initAndGenComponentsForModule(options: MagicOptionScheme, shouldBuildAndUpdateModule: boolean): Rule {
|
|
11
|
+
export function initAndGenComponentsForModule(options: MagicOptionScheme, shouldBuildAndUpdateModule: boolean, generateViaCLI: boolean = false): Rule {
|
|
12
12
|
return (tree: Tree, context: SchematicContext) => {
|
|
13
13
|
let metadata = env.metadata;
|
|
14
14
|
env.componentsGen = [];
|
|
@@ -17,22 +17,29 @@ export function initAndGenComponentsForModule(options: MagicOptionScheme, should
|
|
|
17
17
|
rules.push(displayMessge(options, " ********************************* START GENERATE *********************************"))
|
|
18
18
|
// if we need to build and update module , first generate(if needed) the modules
|
|
19
19
|
if (shouldBuildAndUpdateModule) {
|
|
20
|
-
rules.push(initGenModules (options));
|
|
21
|
-
rules.push(generateWebModules(options));
|
|
20
|
+
rules.push(initGenModules (options, generateViaCLI));
|
|
21
|
+
rules.push(generateWebModules(options, generateViaCLI));
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
let generatedModules = metadata.config.web_modules.filter(
|
|
25
|
+
moduleJsonPath => !generateViaCLI || moduleJsonPath.module_name === options.module
|
|
26
|
+
);
|
|
27
|
+
if (generatedModules.length === 0) {
|
|
28
|
+
LogLn(`Metadata for module '${options.module}' doesn't exist.`);
|
|
29
|
+
} else {
|
|
30
|
+
for (let moduleJsonPath of generatedModules) {
|
|
31
|
+
rules.push(displayMessge(options, ` ****** Start Web Module name : [${moduleJsonPath.module_name}] *******`))
|
|
27
32
|
|
|
28
|
-
|
|
29
|
-
|
|
33
|
+
rules.push(initGenComponentsFromList(options, moduleJsonPath.module_name, options.component, moduleJsonPath.form_files));
|
|
34
|
+
rules.push(loadViewsToGen(options));
|
|
30
35
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
36
|
+
if (shouldBuildAndUpdateModule) {
|
|
37
|
+
rules.push(buildViews(options, moduleJsonPath.module_name));
|
|
38
|
+
rules.push(componentlistGen(options, moduleJsonPath.module_name, moduleJsonPath.load_on_demand));
|
|
39
|
+
}
|
|
34
40
|
}
|
|
35
41
|
}
|
|
42
|
+
|
|
36
43
|
rules.push(displayMessge(options, " ********************************* E N D GENERATE *********************************"))
|
|
37
44
|
return chain(rules)(tree, context);
|
|
38
45
|
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mgGenerateComponent = 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 Util_1 = require("../magic-utils/Util");
|
|
7
|
+
const init_gen_components_rule_1 = require("../magic-utils/rules/init-gen-components.rule");
|
|
8
|
+
function mgGenerateComponent(options) {
|
|
9
|
+
let module;
|
|
10
|
+
if (options.component == '') {
|
|
11
|
+
(0, Util_1.LogLn)('Component name should not be empty.');
|
|
12
|
+
return (0, schematics_1.chain)([]);
|
|
13
|
+
}
|
|
14
|
+
module = options.component.split('/');
|
|
15
|
+
options.module = module[0];
|
|
16
|
+
return (0, schematics_1.chain)([
|
|
17
|
+
(0, init_magic_metadata_rule_1.initMagicMetadata)(options),
|
|
18
|
+
(0, init_gen_components_rule_1.initAndGenComponentsForModule)(options, true, true)
|
|
19
|
+
]);
|
|
20
|
+
}
|
|
21
|
+
exports.mgGenerateComponent = mgGenerateComponent;
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;AAAA,2DAAiF;AACjF,4FAAmF;AAEnF,8CAA0C;AAC1C,4FAA4F;AAE5F,SAAgB,mBAAmB,CAAC,OAAyB;IAC3D,IAAI,MAAe,CAAC;IAEpB,IAAG,OAAO,CAAC,SAAS,IAAI,EAAE,EAAC;QACzB,IAAA,YAAK,EAAC,qCAAqC,CAAC,CAAC;QAC7C,OAAO,IAAA,kBAAK,EAAC,EAAE,CAAC,CAAC;KAClB;IAED,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACtC,OAAO,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;IAE3B,OAAO,IAAA,kBAAK,EAAC;QACX,IAAA,4CAAiB,EAAE,OAAO,CAAC;QAC3B,IAAA,wDAA6B,EAAC,OAAO,EAAE,IAAI,EAAC,IAAI,CAAC;KAClD,CAAC,CAAC;AACL,CAAC;AAfD,kDAeC","sourcesContent":["import { chain, Rule, SchematicContext, Tree } from \"@angular-devkit/schematics\";\r\nimport { initMagicMetadata} from \"../magic-utils/rules/init-magic-metadata.rule\";\r\nimport { MagicOptionScheme } from \"../magic-utils/rules/magic-option.scheme\";\r\nimport {LogLn} from \"../magic-utils/Util\";\r\nimport {initAndGenComponentsForModule} from \"../magic-utils/rules/init-gen-components.rule\";\r\n\r\nexport function mgGenerateComponent(options:MagicOptionScheme): Rule {\r\n let module:string[];\r\n\r\n if(options.component == ''){\r\n LogLn('Component name should not be empty.');\r\n return chain([]);\r\n }\r\n\r\n module = options.component.split('/');\r\n options.module = module[0];\r\n\r\n return chain([\r\n initMagicMetadata (options),\r\n initAndGenComponentsForModule(options, true,true)\r\n ]);\r\n}\r\n"]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { chain, Rule, SchematicContext, Tree } from "@angular-devkit/schematics";
|
|
2
|
+
import { initMagicMetadata} from "../magic-utils/rules/init-magic-metadata.rule";
|
|
3
|
+
import { MagicOptionScheme } from "../magic-utils/rules/magic-option.scheme";
|
|
4
|
+
import {LogLn} from "../magic-utils/Util";
|
|
5
|
+
import {initAndGenComponentsForModule} from "../magic-utils/rules/init-gen-components.rule";
|
|
6
|
+
|
|
7
|
+
export function mgGenerateComponent(options:MagicOptionScheme): Rule {
|
|
8
|
+
let module:string[];
|
|
9
|
+
|
|
10
|
+
if(options.component == ''){
|
|
11
|
+
LogLn('Component name should not be empty.');
|
|
12
|
+
return chain([]);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
module = options.component.split('/');
|
|
16
|
+
options.module = module[0];
|
|
17
|
+
|
|
18
|
+
return chain([
|
|
19
|
+
initMagicMetadata (options),
|
|
20
|
+
initAndGenComponentsForModule(options, true,true)
|
|
21
|
+
]);
|
|
22
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/schema",
|
|
3
|
+
"$id": "SchematicsMagicGenerateComponent",
|
|
4
|
+
"title": "Magic Options Schema",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"properties": {
|
|
7
|
+
"skipPackageJson": {
|
|
8
|
+
"type": "boolean",
|
|
9
|
+
"default": false,
|
|
10
|
+
"description": "Do not generate magic component from json (e.g., --skipPackageJson)"
|
|
11
|
+
},
|
|
12
|
+
"project":{
|
|
13
|
+
"type": "string",
|
|
14
|
+
"description": "The name of the project",
|
|
15
|
+
"aliases" : ["p"]
|
|
16
|
+
},
|
|
17
|
+
"component":{
|
|
18
|
+
"type": "string",
|
|
19
|
+
"description": "The name of the component",
|
|
20
|
+
"aliases" : [ "c"]
|
|
21
|
+
},
|
|
22
|
+
"allowTesting":{
|
|
23
|
+
"type": "boolean",
|
|
24
|
+
"description": "is allow testing ",
|
|
25
|
+
"aliases" : ["a"]
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"required": []
|
|
29
|
+
}
|
|
@@ -1,6 +1,11 @@
|
|
|
1
|
+
<%- include(`../../helperProperties`, {ctrl: ctrl}) %>
|
|
1
2
|
<th <%- include('../../../attributes/common/base/visible', {ctrl : ctrl}) %>
|
|
2
3
|
>
|
|
3
4
|
<label>
|
|
4
|
-
|
|
5
|
+
<%if(ctrl.props.column_title && ctrl.props.column_title.has_exp) { %>
|
|
6
|
+
{{mg.getText(<%= ctrl.props.enum_id %>)}}
|
|
7
|
+
<% } else {%>
|
|
8
|
+
<%=ctrl.props.column_title%>
|
|
9
|
+
<%}%>
|
|
5
10
|
</label>
|
|
6
11
|
</th>
|