@magic-xpa/cli 4.1000.0-dev4100.387 → 4.1000.0-dev4100.389
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/schematics/magic-utils/metadata.class.d.ts +4 -0
- package/src/schematics/magic-utils/metadata.class.js +10 -0
- package/src/schematics/magic-utils/metadata.class.js.map +1 -1
- package/src/schematics/magic-utils/metadata.class.ts +14 -0
- package/src/schematics/magic-utils/rules/init-add-modules.rule.js +11 -6
- 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 +11 -6
- package/src/schematics/magic-utils/rules/init-gen-components.rule.js +10 -5
- 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 +13 -8
- package/src/schematics/magic-utils/rules/init-magic-metadata.rule.js +1 -0
- package/src/schematics/magic-utils/rules/init-magic-metadata.rule.js.map +1 -1
- package/src/schematics/magic-utils/rules/init-magic-metadata.rule.ts +1 -0
- package/src/schematics/magic-utils/rules/magic-option.scheme.d.ts +1 -0
- package/src/schematics/magic-utils/rules/magic-option.scheme.js.map +1 -1
- package/src/schematics/magic-utils/rules/magic-option.scheme.ts +15 -14
- package/src/schematics/mg-generate-component/index.js +17 -3
- package/src/schematics/mg-generate-component/index.js.map +1 -1
- package/src/schematics/mg-generate-component/index.ts +19 -3
- package/src/schematics/mg-generate-component/schema.json +4 -0
- package/src/types/interfaces/env.interface.d.ts +1 -0
- package/src/types/interfaces/env.interface.js.map +1 -1
- package/src/types/interfaces/env.interface.ts +1 -0
package/package.json
CHANGED
|
@@ -27,6 +27,7 @@ export declare class MagicPaths {
|
|
|
27
27
|
get metadataFolderPath(): string;
|
|
28
28
|
get manifestPath(): string;
|
|
29
29
|
get configPath(): string;
|
|
30
|
+
get programListPath(): string;
|
|
30
31
|
get routesPath(): string;
|
|
31
32
|
constructor(project: Project);
|
|
32
33
|
}
|
|
@@ -36,12 +37,15 @@ export declare class MagicMetadata {
|
|
|
36
37
|
options: MagicOptionScheme;
|
|
37
38
|
private _config;
|
|
38
39
|
private _routesTable;
|
|
40
|
+
private _programListContents;
|
|
39
41
|
paths: MagicPaths;
|
|
40
42
|
get theme(): string;
|
|
41
43
|
get allow_testing(): boolean;
|
|
42
44
|
get config(): AppConfig;
|
|
45
|
+
get programListContents(): any;
|
|
43
46
|
get routesTable(): RouteTable[];
|
|
44
47
|
constructor(host: Tree, context: SchematicContext, options: MagicOptionScheme);
|
|
45
48
|
loadConfig(): AppConfig;
|
|
49
|
+
loadProgramList(): any;
|
|
46
50
|
loadRoutes(): RouteTable[];
|
|
47
51
|
}
|
|
@@ -67,6 +67,7 @@ class MagicPaths {
|
|
|
67
67
|
get metadataFolderPath() { return `./${this.project.root}/${env_1.METADATA_DIR}`; }
|
|
68
68
|
get manifestPath() { return `./${this.project.root}/${env_1.METADATA_DIR}/manifest.json`; }
|
|
69
69
|
get configPath() { return `./${this.project.root}/${env_1.METADATA_DIR}/config.json`; }
|
|
70
|
+
get programListPath() { return `./${this.project.root}/${env_1.METADATA_DIR}/ProgramsList.json`; }
|
|
70
71
|
get routesPath() { return `./${this.project.root}/${env_1.METADATA_DIR}/routes.json`; }
|
|
71
72
|
constructor(project) {
|
|
72
73
|
this.project = project;
|
|
@@ -91,6 +92,11 @@ class MagicMetadata {
|
|
|
91
92
|
return this._config;
|
|
92
93
|
return this.loadConfig();
|
|
93
94
|
}
|
|
95
|
+
get programListContents() {
|
|
96
|
+
if (this._programListContents)
|
|
97
|
+
return this._programListContents;
|
|
98
|
+
return this.loadProgramList();
|
|
99
|
+
}
|
|
94
100
|
get routesTable() {
|
|
95
101
|
if (this._routesTable)
|
|
96
102
|
return this._routesTable;
|
|
@@ -106,6 +112,10 @@ class MagicMetadata {
|
|
|
106
112
|
this._config = (0, utils_1.readJson)(this.host, this.paths.configPath);
|
|
107
113
|
return this._config;
|
|
108
114
|
}
|
|
115
|
+
loadProgramList() {
|
|
116
|
+
this._programListContents = (0, utils_1.readJson)(this.host, this.paths.programListPath);
|
|
117
|
+
return this._programListContents;
|
|
118
|
+
}
|
|
109
119
|
loadRoutes() {
|
|
110
120
|
this._routesTable = (0, utils_1.readJson)(this.host, this.paths.routesPath);
|
|
111
121
|
return this._routesTable;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metadata.class.js","sourceRoot":"","sources":["metadata.class.ts"],"names":[],"mappings":";;;AAIA,+BAAsD;AAEtD,mCAA+C;AAG/C,MAAa,UAAU;IAErB,iCAAiC;IACjC,8EAA8E;IAC/E,iBAAiB,CAAC,WAAkB;QACjC,IAAI,WAAW,KAAK,EAAE,EAAE;YACtB,OAAO,GAAG,IAAI,CAAC,kBAAkB,IAAI,gBAAU,IAAI,WAAW,EAAE,CAAC;SAClE;QAED,OAAO,GAAG,IAAI,CAAC,kBAAkB,IAAI,gBAAU,EAAE,CAAC;IAGpD,CAAC;IAED,uDAAuD;IACvD,kHAAkH;IAClH,uBAAuB,CAAC,WAAkB,EAAE,aAAoB;QAC5D,OAAO,GAAG,IAAI,CAAC,iBAAiB,CAAC,WAAW,CAAC,IAAI,aAAa,EAAE,CAAC;IACrE,CAAC;IAED,uBAAuB,CAAC,WAAkB;QACxC,OAAO,GAAG,IAAI,CAAC,kBAAkB,IAAI,WAAW,OAAO,CAAC;IAC1D,CAAC;IAED,mCAAmC,CAAC,WAAkB,EAAE,WAAkB;QACxE,IAAI,gCAAgC,GAAG,GAAG,WAAW,EAAE,CAAC;QACxD,IAAI,WAAW,KAAK,EAAE;YACpB,gCAAgC,GAAG,GAAG,WAAW,IAAI,WAAW,EAAE,CAAC;QAErE,OAAO,gCAAgC,CAAC;IAC1C,CAAC;IAED,wBAAwB,CAAC,WAAkB;QAEzC,IAAI,WAAW,IAAI,EAAE;YACnB,OAAO,IAAI,CAAC,aAAa,CAAC;QAE5B,OAAO,GAAG,IAAI,CAAC,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I,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;QAC1D,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IACD,UAAU;QACR,IAAI,CAAC,YAAY,GAAG,IAAA,gBAAQ,EAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;QAC/D,OAAO,IAAI,CAAC,YAAY,CAAC;IAC3B,CAAC;CACF;AAzCD,sCAyCC","sourcesContent":["import { SchematicContext, Tree } from \"@angular-devkit/schematics\";\nimport { AppConfig, ComponentId, Route, RouteTable } from \"../../types/interfaces/app\";\nimport { MagicOptionScheme } from \"./rules/magic-option.scheme\";\nimport { Project } from \"../utils/devkit-utils/config\";\nimport { env, GEN_FOLDER, METADATA_DIR } from \"./env\";\nimport { Manifest } from \"./manifest\";\nimport { getProject, readJson } from \"./utils\";\n\n\nexport class MagicPaths {\n\n // return the current module path\n // for example : for module \"WebModule1\" it returns 'src/app/magic/WebModule1'\n currentModulePath(module_name:string) {\n if (module_name !== \"\") {\n return `${this.rootMagicGenFolder}/${GEN_FOLDER}/${module_name}`;\n }\n\n return `${this.rootMagicGenFolder}/${GEN_FOLDER}`;\n\n\n }\n\n // return the destanation path for create the component\n // for example : for module \"WebModule1\" component \"WebModule1/folder1/bb/cc/it returns 'src/app/magic/WebModule1'\n getDestPathForComponent(module_name:string, componentPath:string) {\n return `${this.currentModulePath(module_name)}/${componentPath}`;\n }\n\n getJsonPathForComponent(cmpJsonPath:string) {\n return `${this.metadataFolderPath}/${cmpJsonPath}.json`;\n }\n\n getRelativePathForComponentInModule(module_name:string, cmpJsonPath:string) {\n let relativePathForComponentInModule = `${cmpJsonPath}`;\n if (module_name !== \"\")\n relativePathForComponentInModule = `${module_name}/${cmpJsonPath}`;\n\n return relativePathForComponentInModule;\n }\n\n getRoutePathForWebModule(module_name:string) {\n\n if (module_name == \"\")\n return this.appRoutesPath;\n\n return `${this.rootMagicGenFolder}/${GEN_FOLDER}/${module_name}/app.routes.ts`;\n }\n get rootMagicGenFolder(){ return `./${this.project.root}/src/app`; }\n get appComponentPath(){ return `./${this.project.root}/src/app/app.component.html`}\n get appRoutesPath(){ return `./${this.project.root}/src/app/app.routes.ts`}\n get appModulePath(){ return `./${this.project.root}/src/app/app.module.ts`}\n get executionPath(){ return `./${this.project.root}/src/assets/execution.properties`}\n get magicStylePath(){ return `./${this.project.root}/src/magic-styles.css`}\n get angularJsonPath(){ return `./angular.json`}\n get tsConfigAppJsonPath(){ return `./${this.project.root}/tsconfig.app.json`}\n\n // get the relative path of module to be used in LazyLoadMap\n magicGenLibModulePath (moduleName){\n\n let rootPath = this.project.root == '' ? this.project.root: this.project.root + '/';\n let modulepath = rootPath+`src/app/${GEN_FOLDER}`;\n if (moduleName !== \"\") {\n return `${modulepath}/${moduleName}/magic.gen.lib.module`;\n }\n return `${modulepath}/magic.gen.lib.module`;\n }\n\n // Files under gen folder\n get magicGenFolderPath (){ return `./${this.project.root}/src/app/${GEN_FOLDER}`}\n\n componentListPathForCurrentModuleName (module_name:string):string{\n return `./${this.project.root}/src/app/${GEN_FOLDER}/${module_name}/component-list.g.ts`\n }\n componentListPath (module_name:string):string{\n\n if (module_name !== \"\"){\n return this.componentListPathForCurrentModuleName(module_name);\n }\n return this.rootMagicComponentListPath;\n }\n\n get rootMagicComponentListPath (){\n\n return `./${this.project.root}/src/app/${GEN_FOLDER}/component-list.g.ts`\n }\n\n get magicGenLibModule (){ return `./${this.project.root}/src/app/${GEN_FOLDER}/magic.gen.lib.module.ts`}\n\n get favIconPath(){ return `./${this.project.root}/src/favicon.ico`; }\n\n get metadataFolderPath(){ return `./${this.project.root}/${METADATA_DIR}`; }\n get manifestPath (){ return `./${this.project.root}/${METADATA_DIR}/manifest.json`; }\n get configPath (){ return `./${this.project.root}/${METADATA_DIR}/config.json`; }\n get routesPath (){ return `./${this.project.root}/${METADATA_DIR}/routes.json`; }\n\n constructor(protected project:Project){\n }\n}\n\n\nexport class MagicMetadata {\n\n private _config: AppConfig;\n private _routesTable: RouteTable[];\n\n paths: MagicPaths;\n\n get theme() {\n if (!this.options.theme) {\n this.options.theme = env.metadata.config ?env.metadata.config.theme : 'basicHTML';\n }\n return this.options.theme;\n }\n\n get allow_testing() {\n if (!this.options.allowTesting) {\n this.options.allowTesting = env.metadata.config ?env.metadata.config.allow_testing: false;\n }\n return this.options.allowTesting;\n }\n get config() {\n if (this._config) return this._config;\n return this.loadConfig();\n }\n get routesTable(){\n if (this._routesTable) return this._routesTable;\n return this.loadRoutes();\n }\n\n constructor(public host: Tree, public context: SchematicContext, public options: MagicOptionScheme) {\n this.paths = new MagicPaths(getProject(host, options.project));\n }\n\n loadConfig() {\n this._config = readJson(this.host, this.paths.configPath);\n return this._config;\n }\n loadRoutes() {\n this._routesTable = readJson(this.host, this.paths.routesPath);\n return this._routesTable;\n }\n}\n\n\n"]}
|
|
1
|
+
{"version":3,"file":"metadata.class.js","sourceRoot":"","sources":["metadata.class.ts"],"names":[],"mappings":";;;AAIA,+BAAsD;AAEtD,mCAA+C;AAG/C,MAAa,UAAU;IAErB,iCAAiC;IACjC,8EAA8E;IAC/E,iBAAiB,CAAC,WAAkB;QACjC,IAAI,WAAW,KAAK,EAAE,EAAE;YACtB,OAAO,GAAG,IAAI,CAAC,kBAAkB,IAAI,gBAAU,IAAI,WAAW,EAAE,CAAC;SAClE;QAED,OAAO,GAAG,IAAI,CAAC,kBAAkB,IAAI,gBAAU,EAAE,CAAC;IAGpD,CAAC;IAED,uDAAuD;IACvD,kHAAkH;IAClH,uBAAuB,CAAC,WAAkB,EAAE,aAAoB;QAC5D,OAAO,GAAG,IAAI,CAAC,iBAAiB,CAAC,WAAW,CAAC,IAAI,aAAa,EAAE,CAAC;IACrE,CAAC;IAED,uBAAuB,CAAC,WAAkB;QACxC,OAAO,GAAG,IAAI,CAAC,kBAAkB,IAAI,WAAW,OAAO,CAAC;IAC1D,CAAC;IAED,mCAAmC,CAAC,WAAkB,EAAE,WAAkB;QACxE,IAAI,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D,OAAO,IAAI,CAAC,eAAe,EAAE,CAAC;IAClC,CAAC;IAED,IAAI,WAAW;QACb,IAAI,IAAI,CAAC,YAAY;YAAE,OAAO,IAAI,CAAC,YAAY,CAAC;QAChD,OAAO,IAAI,CAAC,UAAU,EAAE,CAAC;IAC3B,CAAC;IAED,YAAmB,IAAU,EAAS,OAAyB,EAAS,OAA0B;QAA/E,SAAI,GAAJ,IAAI,CAAM;QAAS,YAAO,GAAP,OAAO,CAAkB;QAAS,YAAO,GAAP,OAAO,CAAmB;QAChG,IAAI,CAAC,KAAK,GAAG,IAAI,UAAU,CAAC,IAAA,kBAAU,EAAC,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;IACjE,CAAC;IAED,UAAU;QACR,IAAI,CAAC,OAAO,GAAG,IAAA,gBAAQ,EAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;QAC1D,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED,eAAe;QACX,IAAI,CAAC,oBAAoB,GAAG,IAAA,gBAAQ,EAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;QAC5E,OAAO,IAAI,CAAC,oBAAoB,CAAC;IACrC,CAAC;IAED,UAAU;QACR,IAAI,CAAC,YAAY,GAAG,IAAA,gBAAQ,EAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;QAC/D,OAAO,IAAI,CAAC,YAAY,CAAC;IAC3B,CAAC;CACF;AAtDD,sCAsDC","sourcesContent":["import { SchematicContext, Tree } from \"@angular-devkit/schematics\";\nimport { AppConfig, ComponentId, Route, RouteTable } from \"../../types/interfaces/app\";\nimport { MagicOptionScheme } from \"./rules/magic-option.scheme\";\nimport { Project } from \"../utils/devkit-utils/config\";\nimport { env, GEN_FOLDER, METADATA_DIR } from \"./env\";\nimport { Manifest } from \"./manifest\";\nimport { getProject, readJson } from \"./utils\";\n\n\nexport class MagicPaths {\n\n // return the current module path\n // for example : for module \"WebModule1\" it returns 'src/app/magic/WebModule1'\n currentModulePath(module_name:string) {\n if (module_name !== \"\") {\n return `${this.rootMagicGenFolder}/${GEN_FOLDER}/${module_name}`;\n }\n\n return `${this.rootMagicGenFolder}/${GEN_FOLDER}`;\n\n\n }\n\n // return the destanation path for create the component\n // for example : for module \"WebModule1\" component \"WebModule1/folder1/bb/cc/it returns 'src/app/magic/WebModule1'\n getDestPathForComponent(module_name:string, componentPath:string) {\n return `${this.currentModulePath(module_name)}/${componentPath}`;\n }\n\n getJsonPathForComponent(cmpJsonPath:string) {\n return `${this.metadataFolderPath}/${cmpJsonPath}.json`;\n }\n\n getRelativePathForComponentInModule(module_name:string, cmpJsonPath:string) {\n let relativePathForComponentInModule = `${cmpJsonPath}`;\n if (module_name !== \"\")\n relativePathForComponentInModule = `${module_name}/${cmpJsonPath}`;\n\n return relativePathForComponentInModule;\n }\n\n getRoutePathForWebModule(module_name:string) {\n\n if (module_name == \"\")\n return this.appRoutesPath;\n\n return `${this.rootMagicGenFolder}/${GEN_FOLDER}/${module_name}/app.routes.ts`;\n }\n get rootMagicGenFolder(){ return `./${this.project.root}/src/app`; }\n get appComponentPath(){ return `./${this.project.root}/src/app/app.component.html`}\n get appRoutesPath(){ return `./${this.project.root}/src/app/app.routes.ts`}\n get appModulePath(){ return `./${this.project.root}/src/app/app.module.ts`}\n get executionPath(){ return `./${this.project.root}/src/assets/execution.properties`}\n get magicStylePath(){ return `./${this.project.root}/src/magic-styles.css`}\n get angularJsonPath(){ return `./angular.json`}\n get tsConfigAppJsonPath(){ return `./${this.project.root}/tsconfig.app.json`}\n\n // get the relative path of module to be used in LazyLoadMap\n magicGenLibModulePath (moduleName){\n\n let rootPath = this.project.root == '' ? this.project.root: this.project.root + '/';\n let modulepath = rootPath+`src/app/${GEN_FOLDER}`;\n if (moduleName !== \"\") {\n return `${modulepath}/${moduleName}/magic.gen.lib.module`;\n }\n return `${modulepath}/magic.gen.lib.module`;\n }\n\n // Files under gen folder\n get magicGenFolderPath (){ return `./${this.project.root}/src/app/${GEN_FOLDER}`}\n\n componentListPathForCurrentModuleName (module_name:string):string{\n return `./${this.project.root}/src/app/${GEN_FOLDER}/${module_name}/component-list.g.ts`\n }\n componentListPath (module_name:string):string{\n\n if (module_name !== \"\"){\n return this.componentListPathForCurrentModuleName(module_name);\n }\n return this.rootMagicComponentListPath;\n }\n\n get rootMagicComponentListPath (){\n\n return `./${this.project.root}/src/app/${GEN_FOLDER}/component-list.g.ts`\n }\n\n get magicGenLibModule (){ return `./${this.project.root}/src/app/${GEN_FOLDER}/magic.gen.lib.module.ts`}\n\n get favIconPath(){ return `./${this.project.root}/src/favicon.ico`; }\n\n get metadataFolderPath(){ return `./${this.project.root}/${METADATA_DIR}`; }\n get manifestPath (){ return `./${this.project.root}/${METADATA_DIR}/manifest.json`; }\n get configPath (){ return `./${this.project.root}/${METADATA_DIR}/config.json`; }\n get programListPath (){return `./${this.project.root}/${METADATA_DIR}/ProgramsList.json`; }\n get routesPath (){ return `./${this.project.root}/${METADATA_DIR}/routes.json`; }\n\n constructor(protected project:Project){\n }\n}\n\n\nexport class MagicMetadata {\n\n private _config: AppConfig;\n private _routesTable: RouteTable[];\n private _programListContents: any;\n\n paths: MagicPaths;\n\n get theme() {\n if (!this.options.theme) {\n this.options.theme = env.metadata.config ?env.metadata.config.theme : 'basicHTML';\n }\n return this.options.theme;\n }\n\n get allow_testing() {\n if (!this.options.allowTesting) {\n this.options.allowTesting = env.metadata.config ?env.metadata.config.allow_testing: false;\n }\n return this.options.allowTesting;\n }\n get config() {\n if (this._config) return this._config;\n return this.loadConfig();\n }\n\n get programListContents(){\n if(this._programListContents) return this._programListContents;\n return this.loadProgramList();\n }\n\n get routesTable(){\n if (this._routesTable) return this._routesTable;\n return this.loadRoutes();\n }\n\n constructor(public host: Tree, public context: SchematicContext, public options: MagicOptionScheme) {\n this.paths = new MagicPaths(getProject(host, options.project));\n }\n\n loadConfig() {\n this._config = readJson(this.host, this.paths.configPath);\n return this._config;\n }\n\n loadProgramList(){\n this._programListContents = readJson(this.host, this.paths.programListPath);\n return this._programListContents;\n }\n\n loadRoutes() {\n this._routesTable = readJson(this.host, this.paths.routesPath);\n return this._routesTable;\n }\n}\n\n\n"]}
|
|
@@ -92,6 +92,7 @@ export class MagicPaths {
|
|
|
92
92
|
get metadataFolderPath(){ return `./${this.project.root}/${METADATA_DIR}`; }
|
|
93
93
|
get manifestPath (){ return `./${this.project.root}/${METADATA_DIR}/manifest.json`; }
|
|
94
94
|
get configPath (){ return `./${this.project.root}/${METADATA_DIR}/config.json`; }
|
|
95
|
+
get programListPath (){return `./${this.project.root}/${METADATA_DIR}/ProgramsList.json`; }
|
|
95
96
|
get routesPath (){ return `./${this.project.root}/${METADATA_DIR}/routes.json`; }
|
|
96
97
|
|
|
97
98
|
constructor(protected project:Project){
|
|
@@ -103,6 +104,7 @@ export class MagicMetadata {
|
|
|
103
104
|
|
|
104
105
|
private _config: AppConfig;
|
|
105
106
|
private _routesTable: RouteTable[];
|
|
107
|
+
private _programListContents: any;
|
|
106
108
|
|
|
107
109
|
paths: MagicPaths;
|
|
108
110
|
|
|
@@ -123,6 +125,12 @@ export class MagicMetadata {
|
|
|
123
125
|
if (this._config) return this._config;
|
|
124
126
|
return this.loadConfig();
|
|
125
127
|
}
|
|
128
|
+
|
|
129
|
+
get programListContents(){
|
|
130
|
+
if(this._programListContents) return this._programListContents;
|
|
131
|
+
return this.loadProgramList();
|
|
132
|
+
}
|
|
133
|
+
|
|
126
134
|
get routesTable(){
|
|
127
135
|
if (this._routesTable) return this._routesTable;
|
|
128
136
|
return this.loadRoutes();
|
|
@@ -136,6 +144,12 @@ export class MagicMetadata {
|
|
|
136
144
|
this._config = readJson(this.host, this.paths.configPath);
|
|
137
145
|
return this._config;
|
|
138
146
|
}
|
|
147
|
+
|
|
148
|
+
loadProgramList(){
|
|
149
|
+
this._programListContents = readJson(this.host, this.paths.programListPath);
|
|
150
|
+
return this._programListContents;
|
|
151
|
+
}
|
|
152
|
+
|
|
139
153
|
loadRoutes() {
|
|
140
154
|
this._routesTable = readJson(this.host, this.paths.routesPath);
|
|
141
155
|
return this._routesTable;
|
|
@@ -12,14 +12,18 @@ const env_interface_1 = require("../../../types/interfaces/env.interface");
|
|
|
12
12
|
function initGenModules(options, generateViaCLI = false) {
|
|
13
13
|
return (tree, context) => {
|
|
14
14
|
let metadata = env_1.env.metadata;
|
|
15
|
+
let programList = env_1.env.programList;
|
|
15
16
|
env_1.env.modulesGen = [];
|
|
16
17
|
let web_modules = metadata.config.web_modules;
|
|
17
18
|
if (generateViaCLI) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
let programListString = JSON.stringify(programList.programListContents);
|
|
20
|
+
// Validate whether the component is valid
|
|
21
|
+
if (programListString.includes(options.component)) {
|
|
22
|
+
let moduleInfo = new env_interface_1.ModuleInfo(options.module, options.loadOnDemand);
|
|
23
|
+
env_1.env.modulesGen.push(moduleInfo);
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
(0, Util_1.LogLn)(`Invalid component ${options.component} to generate.`);
|
|
23
27
|
}
|
|
24
28
|
}
|
|
25
29
|
else {
|
|
@@ -37,7 +41,8 @@ function initGenModules(options, generateViaCLI = false) {
|
|
|
37
41
|
}
|
|
38
42
|
}
|
|
39
43
|
}
|
|
40
|
-
|
|
44
|
+
if (!generateViaCLI)
|
|
45
|
+
(0, Util_1.LogLn)(` Number of modules to be check for generate: ${web_modules.length}`);
|
|
41
46
|
return tree;
|
|
42
47
|
};
|
|
43
48
|
}
|
|
@@ -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,2EAA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BAC3C,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"]}
|
|
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,EAAE,iBAAyB,KAAK;IACvF,OAAO,CAAC,IAAU,EAAE,OAAyB,EAAE,EAAE;QAC/C,IAAI,QAAQ,GAAG,SAAG,CAAC,QAAQ,CAAC;QAC5B,IAAI,WAAW,GAAG,SAAG,CAAC,WAAW,CAAC;QAClC,SAAG,CAAC,UAAU,GAAG,EAAE,CAAC;QACpB,IAAI,WAAW,GAAoB,QAAQ,CAAC,MAAM,CAAC,WAAW,CAAC;QAE/D,IAAG,cAAc,EAAC;YA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} 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 let programList = env.programList;\n env.modulesGen = [];\n let web_modules:webModuleItem [] = metadata.config.web_modules;\n\n if(generateViaCLI){\n let programListString = JSON.stringify(programList.programListContents);\n\n // Validate whether the component is valid\n if(programListString.includes(options.component)){\n let moduleInfo: ModuleInfo = new ModuleInfo(options.module, options.loadOnDemand);\n env.modulesGen.push(moduleInfo)\n }else{\n LogLn(`Invalid component ${options.component} to generate.`);\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 if(!generateViaCLI)\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"]}
|
|
@@ -23,15 +23,19 @@ import * as ts from "typescript";
|
|
|
23
23
|
export function initGenModules(options: MagicOptionScheme, generateViaCLI:boolean = false): Rule {
|
|
24
24
|
return (tree: Tree, context: SchematicContext) => {
|
|
25
25
|
let metadata = env.metadata;
|
|
26
|
+
let programList = env.programList;
|
|
26
27
|
env.modulesGen = [];
|
|
27
28
|
let web_modules:webModuleItem [] = metadata.config.web_modules;
|
|
28
29
|
|
|
29
30
|
if(generateViaCLI){
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
let programListString = JSON.stringify(programList.programListContents);
|
|
32
|
+
|
|
33
|
+
// Validate whether the component is valid
|
|
34
|
+
if(programListString.includes(options.component)){
|
|
35
|
+
let moduleInfo: ModuleInfo = new ModuleInfo(options.module, options.loadOnDemand);
|
|
36
|
+
env.modulesGen.push(moduleInfo)
|
|
37
|
+
}else{
|
|
38
|
+
LogLn(`Invalid component ${options.component} to generate.`);
|
|
35
39
|
}
|
|
36
40
|
}else{
|
|
37
41
|
// Generate only one module from --module=xxxx
|
|
@@ -48,7 +52,8 @@ export function initGenModules(options: MagicOptionScheme, generateViaCLI:boolea
|
|
|
48
52
|
}
|
|
49
53
|
}
|
|
50
54
|
}
|
|
51
|
-
|
|
55
|
+
if(!generateViaCLI)
|
|
56
|
+
LogLn(` Number of modules to be check for generate: ${web_modules.length}`);
|
|
52
57
|
return tree;
|
|
53
58
|
};
|
|
54
59
|
}
|
|
@@ -8,7 +8,6 @@ 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
|
-
const Util_1 = require("../Util");
|
|
12
11
|
function initAndGenComponentsForModule(options, shouldBuildAndUpdateModule, generateViaCLI = false) {
|
|
13
12
|
return (tree, context) => {
|
|
14
13
|
let metadata = env_1.env.metadata;
|
|
@@ -20,12 +19,18 @@ function initAndGenComponentsForModule(options, shouldBuildAndUpdateModule, gene
|
|
|
20
19
|
rules.push((0, init_add_modules_rule_1.initGenModules)(options, generateViaCLI));
|
|
21
20
|
rules.push((0, init_add_modules_rule_1.generateWebModules)(options, generateViaCLI));
|
|
22
21
|
}
|
|
23
|
-
|
|
24
|
-
if (
|
|
25
|
-
|
|
22
|
+
// TO DO: Following code can be simplified.
|
|
23
|
+
if (generateViaCLI) {
|
|
24
|
+
const componentsArray = [options.component];
|
|
25
|
+
rules.push(initGenComponentsFromList(options, options.module, options.component, componentsArray));
|
|
26
|
+
rules.push((0, load_views_gen_rule_1.loadViewsToGen)(options));
|
|
27
|
+
if (shouldBuildAndUpdateModule) {
|
|
28
|
+
rules.push((0, build_view_rule_1.buildViews)(options, options.module));
|
|
29
|
+
rules.push((0, component_list_rule_1.componentlistGen)(options, options.module, options.loadOnDemand));
|
|
30
|
+
}
|
|
26
31
|
}
|
|
27
32
|
else {
|
|
28
|
-
for (let moduleJsonPath of
|
|
33
|
+
for (let moduleJsonPath of metadata.config.web_modules) {
|
|
29
34
|
rules.push((0, utils_1.displayMessge)(options, ` ****** Start Web Module name : [${moduleJsonPath.module_name}] *******`));
|
|
30
35
|
rules.push(initGenComponentsFromList(options, moduleJsonPath.module_name, options.component, moduleJsonPath.form_files));
|
|
31
36
|
rules.push((0, load_views_gen_rule_1.loadViewsToGen)(options));
|
|
@@ -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,mEAA6E;AAC7E,oCAAyC;
|
|
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,mEAA6E;AAC7E,oCAAyC;AAGzC,SAAgB,6BAA6B,CAAC,OAA0B,EAAE,0BAAmC,EAAE,iBAA0B,KAAK;IAC5I,OAAO,CAAC,IAAU,EAAE,OAAyB,EAAE,EAAE;QAC/C,IAAI,QAAQ,GAAG,SAAG,CAAC,QAAQ,CAAC;QAC5B,SAAG,CAAC,aAAa,GAAG,EAAE,CAAC;QACvB,IAAI,KAAK,GAAU,EAAE,CAAC;QAEtB,KAAK,CAAC,IAAI,CAAC,IAAA,qBAAa,EAAC,OAAO,EAAE,wFAAwF,CAAC,CAAC,CAAA;QAC5H,gFAAgF;QAChF,IAAI,0BAA0B,EAAE;YAC9B,KAAK,CAAC,IAAI,CAAC,IAAA,sCAAc,EAAE,OAAO,EAAE,cAAc,CAAC,CAAC,CAAC;YACrD,KAAK,CAAC,IAAI,CAAC,IAAA,0CAAkB,EAAC,OAAO,EAAE,cAAc,CAAC,CAAC,CAAC;SACzD;QAED,2CAA2C;QAC3C,IAAG,cAAc,EAAC;YAChB,MAAM,eAAe,GA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AO,EAAE,wFAAwF,CAAC,CAAC,CAAA;QAC9H,OAAO,IAAA,kBAAK,EAAC,KAAK,CAAC,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACrC,CAAC,CAAC;AACJ,CAAC;AAxCD,sEAwCC;AAGD,SAAgB,yBAAyB,CAAC,OAA0B,EAAE,WAAkB,EAAE,SAAiB,EAAE,UAAoB;IAC/H,OAAO,CAAC,IAAU,EAAE,OAAyB,EAAE,EAAE;QAC/C,IAAI,QAAQ,GAAG,SAAG,CAAC,QAAQ,CAAC;QAC5B,SAAG,CAAC,aAAa,GAAG,EAAE,CAAC;QAEvB,oDAAoD;QACpD,IAAI,SAAS,EAAE;YACb,SAAG,CAAC,aAAa,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;SAClC;aAAM;YAEL,uEAAuE;YACvE,KAAK,IAAI,WAAW,IAAI,UAAU,EAAE;gBAElC,IAAI,gBAAgB,GAAG,SAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,mCAAmC,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;gBAExG,SAAG,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 // TO DO: Following code can be simplified.\r\n if(generateViaCLI){\r\n const componentsArray = [options.component];\r\n rules.push(initGenComponentsFromList(options, options.module, options.component, componentsArray));\r\n rules.push(loadViewsToGen(options));\r\n\r\n if (shouldBuildAndUpdateModule) {\r\n rules.push(buildViews(options, options.module));\r\n rules.push(componentlistGen(options, options.module, options.loadOnDemand));\r\n }\r\n }else{\r\n for (let moduleJsonPath of metadata.config.web_modules) {\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"]}
|
|
@@ -21,13 +21,18 @@ export function initAndGenComponentsForModule(options: MagicOptionScheme, should
|
|
|
21
21
|
rules.push(generateWebModules(options, generateViaCLI));
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
24
|
+
// TO DO: Following code can be simplified.
|
|
25
|
+
if(generateViaCLI){
|
|
26
|
+
const componentsArray = [options.component];
|
|
27
|
+
rules.push(initGenComponentsFromList(options, options.module, options.component, componentsArray));
|
|
28
|
+
rules.push(loadViewsToGen(options));
|
|
29
|
+
|
|
30
|
+
if (shouldBuildAndUpdateModule) {
|
|
31
|
+
rules.push(buildViews(options, options.module));
|
|
32
|
+
rules.push(componentlistGen(options, options.module, options.loadOnDemand));
|
|
33
|
+
}
|
|
34
|
+
}else{
|
|
35
|
+
for (let moduleJsonPath of metadata.config.web_modules) {
|
|
31
36
|
rules.push(displayMessge(options, ` ****** Start Web Module name : [${moduleJsonPath.module_name}] *******`))
|
|
32
37
|
|
|
33
38
|
rules.push(initGenComponentsFromList(options, moduleJsonPath.module_name, options.component, moduleJsonPath.form_files));
|
|
@@ -40,7 +45,7 @@ export function initAndGenComponentsForModule(options: MagicOptionScheme, should
|
|
|
40
45
|
}
|
|
41
46
|
}
|
|
42
47
|
|
|
43
|
-
|
|
48
|
+
rules.push(displayMessge(options, " ********************************* E N D GENERATE *********************************"))
|
|
44
49
|
return chain(rules)(tree, context);
|
|
45
50
|
};
|
|
46
51
|
}
|
|
@@ -10,6 +10,7 @@ function initMagicMetadata(options) {
|
|
|
10
10
|
env_1.env.workspace = (0, config_1.getWorkspace)(host);
|
|
11
11
|
env_1.env.project = (0, config_1.getProjectFromWorkspace)(env_1.env.workspace, options.project);
|
|
12
12
|
env_1.env.metadata = new metadata_class_1.MagicMetadata(host, context, options);
|
|
13
|
+
env_1.env.programList = new metadata_class_1.MagicMetadata(host, context, options);
|
|
13
14
|
}
|
|
14
15
|
return host;
|
|
15
16
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init-magic-metadata.rule.js","sourceRoot":"","sources":["init-magic-metadata.rule.ts"],"names":[],"mappings":";;;AACA,sDAAkD;AAClD,gCAA6B;AAC7B,4DAAwF;AAIxF,SAAgB,iBAAiB,CAAC,OAAyB;IACzD,OAAO,CAAC,IAAU,EAAE,OAAyB,EAAC,EAAE;QAC9C,IAAI,CAAC,SAAG,CAAC,QAAQ,EAAG;YAClB,SAAG,CAAC,SAAS,GAAG,IAAA,qBAAY,EAAC,IAAI,CAAC,CAAC;YACnC,SAAG,CAAC,OAAO,GAAK,IAAA,gCAAuB,EAAC,SAAG,CAAC,SAAS,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;YACxE,SAAG,CAAC,QAAQ,GAAI,IAAI,8BAAa,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"init-magic-metadata.rule.js","sourceRoot":"","sources":["init-magic-metadata.rule.ts"],"names":[],"mappings":";;;AACA,sDAAkD;AAClD,gCAA6B;AAC7B,4DAAwF;AAIxF,SAAgB,iBAAiB,CAAC,OAAyB;IACzD,OAAO,CAAC,IAAU,EAAE,OAAyB,EAAC,EAAE;QAC9C,IAAI,CAAC,SAAG,CAAC,QAAQ,EAAG;YAClB,SAAG,CAAC,SAAS,GAAG,IAAA,qBAAY,EAAC,IAAI,CAAC,CAAC;YACnC,SAAG,CAAC,OAAO,GAAK,IAAA,gCAAuB,EAAC,SAAG,CAAC,SAAS,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;YACxE,SAAG,CAAC,QAAQ,GAAI,IAAI,8BAAa,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;YAC1D,SAAG,CAAC,WAAW,GAAG,IAAI,8BAAa,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;SAC7D;QACD,OAAO,IAAI,CAAC;IACd,CAAC,CAAA;AACH,CAAC;AAVD,8CAUC","sourcesContent":["import { Rule, SchematicContext, Tree } from \"@angular-devkit/schematics\";\nimport { MagicMetadata } from \"../metadata.class\";\nimport { env } from \"../env\";\nimport { getProjectFromWorkspace, getWorkspace } from \"../../utils/devkit-utils/config\";\nimport { MagicOptionScheme } from \"./magic-option.scheme\";\n\n\nexport function initMagicMetadata(options:MagicOptionScheme) : Rule {\n return (host: Tree, context: SchematicContext)=>{\n if( !env.metadata ) {\n env.workspace = getWorkspace(host);\n env.project = getProjectFromWorkspace(env.workspace, options.project);\n env.metadata = new MagicMetadata(host, context, options);\n env.programList = new MagicMetadata(host, context, options);\n }\n return host;\n }\n}\n\n"]}
|
|
@@ -11,6 +11,7 @@ export function initMagicMetadata(options:MagicOptionScheme) : Rule {
|
|
|
11
11
|
env.workspace = getWorkspace(host);
|
|
12
12
|
env.project = getProjectFromWorkspace(env.workspace, options.project);
|
|
13
13
|
env.metadata = new MagicMetadata(host, context, options);
|
|
14
|
+
env.programList = new MagicMetadata(host, context, options);
|
|
14
15
|
}
|
|
15
16
|
return host;
|
|
16
17
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"magic-option.scheme.js","sourceRoot":"","sources":["magic-option.scheme.ts"],"names":[],"mappings":"","sourcesContent":["export interface dependency{\n name : string;\n version : string;\n}\nexport interface MagicOptionScheme {\n // Magic properties\n path?
|
|
1
|
+
{"version":3,"file":"magic-option.scheme.js","sourceRoot":"","sources":["magic-option.scheme.ts"],"names":[],"mappings":"","sourcesContent":["export interface dependency{\n name : string;\n version : string;\n}\nexport interface MagicOptionScheme {\n // Magic properties\n path? : string;\n allowTesting? : boolean;\n theme? : string;\n component? : string;\n module? : string;\n loadOnDemand? : boolean;\n containerType? : string;\n skipHelp? : boolean;\n // Angular Properties\n project? : string;\n dependencies? : dependency[];\n devDependencies? : dependency[];\n skipInstall? : boolean;\n skipPackageJson? : boolean;\n cliVersion? : string;\n angularVersion? : string;\n}\n"]}
|
|
@@ -4,19 +4,20 @@ export interface dependency{
|
|
|
4
4
|
}
|
|
5
5
|
export interface MagicOptionScheme {
|
|
6
6
|
// Magic properties
|
|
7
|
-
path?
|
|
8
|
-
allowTesting?
|
|
9
|
-
theme?
|
|
10
|
-
component?
|
|
11
|
-
module?
|
|
12
|
-
loadOnDemand?
|
|
13
|
-
|
|
7
|
+
path? : string;
|
|
8
|
+
allowTesting? : boolean;
|
|
9
|
+
theme? : string;
|
|
10
|
+
component? : string;
|
|
11
|
+
module? : string;
|
|
12
|
+
loadOnDemand? : boolean;
|
|
13
|
+
containerType? : string;
|
|
14
|
+
skipHelp? : boolean;
|
|
14
15
|
// Angular Properties
|
|
15
|
-
project?
|
|
16
|
-
dependencies?
|
|
17
|
-
devDependencies
|
|
18
|
-
skipInstall?
|
|
19
|
-
skipPackageJson
|
|
20
|
-
cliVersion?
|
|
21
|
-
angularVersion?
|
|
16
|
+
project? : string;
|
|
17
|
+
dependencies? : dependency[];
|
|
18
|
+
devDependencies? : dependency[];
|
|
19
|
+
skipInstall? : boolean;
|
|
20
|
+
skipPackageJson? : boolean;
|
|
21
|
+
cliVersion? : string;
|
|
22
|
+
angularVersion? : string;
|
|
22
23
|
}
|
|
@@ -6,17 +6,31 @@ const init_magic_metadata_rule_1 = require("../magic-utils/rules/init-magic-meta
|
|
|
6
6
|
const Util_1 = require("../magic-utils/Util");
|
|
7
7
|
const init_gen_components_rule_1 = require("../magic-utils/rules/init-gen-components.rule");
|
|
8
8
|
function mgGenerateComponent(options) {
|
|
9
|
-
let module;
|
|
10
9
|
if (options.component == '') {
|
|
11
10
|
(0, Util_1.LogLn)('Component name should not be empty.');
|
|
12
11
|
return (0, schematics_1.chain)([]);
|
|
13
12
|
}
|
|
14
|
-
module = options
|
|
15
|
-
options.
|
|
13
|
+
options.module = getModuleName(options);
|
|
14
|
+
options.loadOnDemand = getLoadOnDemandFlagForModule(options);
|
|
16
15
|
return (0, schematics_1.chain)([
|
|
17
16
|
(0, init_magic_metadata_rule_1.initMagicMetadata)(options),
|
|
18
17
|
(0, init_gen_components_rule_1.initAndGenComponentsForModule)(options, true, true)
|
|
19
18
|
]);
|
|
20
19
|
}
|
|
21
20
|
exports.mgGenerateComponent = mgGenerateComponent;
|
|
21
|
+
// To get the module name from the FormId
|
|
22
|
+
// In the case of containerType="Directory", consider root module.
|
|
23
|
+
// In all other cases gets the first string value till separator(/) from the formId.
|
|
24
|
+
function getModuleName(options) {
|
|
25
|
+
let moduleName = "";
|
|
26
|
+
if (options.containerType && options.containerType !== "Directory")
|
|
27
|
+
moduleName = options.component.split('/')[0];
|
|
28
|
+
return moduleName;
|
|
29
|
+
}
|
|
30
|
+
// To get loadOnDemand flag for the module
|
|
31
|
+
// In the case of containerType == "LoadOnDemandModule", consider it as true
|
|
32
|
+
// In all other cases, consider it as false
|
|
33
|
+
function getLoadOnDemandFlagForModule(options) {
|
|
34
|
+
return options.containerType === "LoadOnDemandModule";
|
|
35
|
+
}
|
|
22
36
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +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;
|
|
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;IAE3D,IAAG,OAAO,CAAC,SAAS,IAAI,EAAE,EAAC;QACzB,IAAA,YAAK,EAAC,qCAAqC,CAAC,CAAC;QAC7C,OAAO,IAAA,kBAAK,EAAC,EAAE,CAAC,CAAC;KAClB;IAED,OAAO,CAAC,MAAM,GAAG,aAAa,CAAC,OAAO,CAAC,CAAC;IACxC,OAAO,CAAC,YAAY,GAAG,4BAA4B,CAAC,OAAO,CAAC,CAAC;IAE7D,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;AAdD,kDAcC;AAED,yCAAyC;AACzC,kEAAkE;AAClE,oFAAoF;AACpF,SAAS,aAAa,CAAC,OAA0B;IAC/C,IAAI,UAAU,GAAU,EAAE,CAAC;IAC3B,IAAG,OAAO,CAAC,aAAa,IAAI,OAAO,CAAC,aAAa,KAAK,WAAW;QAC/D,UAAU,GAAG,OAAO,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IAC/C,OAAO,UAAU,CAAC;AACpB,CAAC;AAED,0CAA0C;AAC1C,4EAA4E;AAC5E,2CAA2C;AAC3C,SAAS,4BAA4B,CAAC,OAA0B;IAC7D,OAAO,OAAO,CAAC,aAAa,KAAK,oBAAoB,CAAC;AACzD,CAAC","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\r\n if(options.component == ''){\r\n LogLn('Component name should not be empty.');\r\n return chain([]);\r\n }\r\n\r\n options.module = getModuleName(options);\r\n options.loadOnDemand = getLoadOnDemandFlagForModule(options);\r\n\r\n return chain([\r\n initMagicMetadata (options),\r\n initAndGenComponentsForModule(options, true,true)\r\n ]);\r\n}\r\n\r\n// To get the module name from the FormId\r\n// In the case of containerType=\"Directory\", consider root module.\r\n// In all other cases gets the first string value till separator(/) from the formId.\r\nfunction getModuleName(options: MagicOptionScheme){\r\n let moduleName:string = \"\";\r\n if(options.containerType && options.containerType !== \"Directory\")\r\n moduleName = options.component.split('/')[0];\r\n return moduleName;\r\n}\r\n\r\n// To get loadOnDemand flag for the module\r\n// In the case of containerType == \"LoadOnDemandModule\", consider it as true\r\n// In all other cases, consider it as false\r\nfunction getLoadOnDemandFlagForModule(options: MagicOptionScheme){\r\n return options.containerType === \"LoadOnDemandModule\";\r\n}\r\n"]}
|
|
@@ -5,18 +5,34 @@ import {LogLn} from "../magic-utils/Util";
|
|
|
5
5
|
import {initAndGenComponentsForModule} from "../magic-utils/rules/init-gen-components.rule";
|
|
6
6
|
|
|
7
7
|
export function mgGenerateComponent(options:MagicOptionScheme): Rule {
|
|
8
|
-
let module:string[];
|
|
9
8
|
|
|
10
9
|
if(options.component == ''){
|
|
11
10
|
LogLn('Component name should not be empty.');
|
|
12
11
|
return chain([]);
|
|
13
12
|
}
|
|
14
13
|
|
|
15
|
-
module = options
|
|
16
|
-
options.
|
|
14
|
+
options.module = getModuleName(options);
|
|
15
|
+
options.loadOnDemand = getLoadOnDemandFlagForModule(options);
|
|
17
16
|
|
|
18
17
|
return chain([
|
|
19
18
|
initMagicMetadata (options),
|
|
20
19
|
initAndGenComponentsForModule(options, true,true)
|
|
21
20
|
]);
|
|
22
21
|
}
|
|
22
|
+
|
|
23
|
+
// To get the module name from the FormId
|
|
24
|
+
// In the case of containerType="Directory", consider root module.
|
|
25
|
+
// In all other cases gets the first string value till separator(/) from the formId.
|
|
26
|
+
function getModuleName(options: MagicOptionScheme){
|
|
27
|
+
let moduleName:string = "";
|
|
28
|
+
if(options.containerType && options.containerType !== "Directory")
|
|
29
|
+
moduleName = options.component.split('/')[0];
|
|
30
|
+
return moduleName;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// To get loadOnDemand flag for the module
|
|
34
|
+
// In the case of containerType == "LoadOnDemandModule", consider it as true
|
|
35
|
+
// In all other cases, consider it as false
|
|
36
|
+
function getLoadOnDemandFlagForModule(options: MagicOptionScheme){
|
|
37
|
+
return options.containerType === "LoadOnDemandModule";
|
|
38
|
+
}
|
|
@@ -23,6 +23,10 @@
|
|
|
23
23
|
"type": "boolean",
|
|
24
24
|
"description": "is allow testing ",
|
|
25
25
|
"aliases" : ["a"]
|
|
26
|
+
},
|
|
27
|
+
"containerType": {
|
|
28
|
+
"type": "string",
|
|
29
|
+
"description": "The value of container type (EagerModule, Directory, LoadOnDemandModule, '')"
|
|
26
30
|
}
|
|
27
31
|
},
|
|
28
32
|
"required": []
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"env.interface.js","sourceRoot":"","sources":["env.interface.ts"],"names":[],"mappings":";;;AAMA,MAAa,UAAU;IAIrB,YAAY,UAAiB,EAAE,YAAoB;QACjD,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;IACnC,CAAC;CACF;AARD,gCAQC","sourcesContent":["import { MagicMetadata, MagicPaths } from \"../../schematics/magic-utils/metadata.class\";\r\nimport { AppJson } from \"../index\";\r\nimport { Project, Workspace } from \"../../schematics/utils/devkit-utils/config\";\r\n\r\n\r\n\r\nexport class ModuleInfo {\r\n moduleName: string;\r\n loadOnDemand: boolean;\r\n\r\n constructor(moduleName:string, loadOnDemand:boolean){\r\n this.moduleName = moduleName;\r\n this.loadOnDemand = loadOnDemand;\r\n }\r\n}\r\n\r\n\r\nexport interface IEnv{\r\n workspace : Workspace,\r\n project : Project,\r\n metadata : MagicMetadata;\r\n componentsGen: string[];\r\n modulesGen : ModuleInfo[];\r\n app : AppJson;\r\n paths? : MagicPaths;\r\n prevent_log : boolean;\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"env.interface.js","sourceRoot":"","sources":["env.interface.ts"],"names":[],"mappings":";;;AAMA,MAAa,UAAU;IAIrB,YAAY,UAAiB,EAAE,YAAoB;QACjD,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;IACnC,CAAC;CACF;AARD,gCAQC","sourcesContent":["import { MagicMetadata, MagicPaths } from \"../../schematics/magic-utils/metadata.class\";\r\nimport { AppJson } from \"../index\";\r\nimport { Project, Workspace } from \"../../schematics/utils/devkit-utils/config\";\r\n\r\n\r\n\r\nexport class ModuleInfo {\r\n moduleName: string;\r\n loadOnDemand: boolean;\r\n\r\n constructor(moduleName:string, loadOnDemand:boolean){\r\n this.moduleName = moduleName;\r\n this.loadOnDemand = loadOnDemand;\r\n }\r\n}\r\n\r\n\r\nexport interface IEnv{\r\n workspace : Workspace,\r\n project : Project,\r\n metadata : MagicMetadata;\r\n programList : MagicMetadata;\r\n componentsGen: string[];\r\n modulesGen : ModuleInfo[];\r\n app : AppJson;\r\n paths? : MagicPaths;\r\n prevent_log : boolean;\r\n}\r\n"]}
|