@magic-xpa/cli 4.1300.0-dev4130.253 → 4.1300.0-dev4130.258
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/mg-add/files/src/app/app.routes.ts +2 -1
- package/src/schematics/mg-add/files/src/app/custom.routes.ts +23 -0
- package/src/schematics/mg-add/webModule/app.routes.ts +2 -1
- package/src/schematics/mg-add/webModule/custom.routes.ts +23 -0
- package/src/schematics/mg-routes/index.js +13 -4
- package/src/schematics/mg-routes/index.js.map +1 -1
- package/src/schematics/mg-routes/index.ts +16 -5
- package/templates/angular/src/app.routes.ts +2 -0
- package/templates/angular/src/custom.routes.ts +23 -0
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import {Routes, RouterModule} from '@angular/router';
|
|
2
|
+
import {customRoutes} from './custom.routes';
|
|
2
3
|
import { NgModule } from "@angular/core";
|
|
3
4
|
import { CommonModule } from "@angular/common";
|
|
4
5
|
|
|
5
6
|
export const routes: Routes= [
|
|
6
|
-
|
|
7
|
+
...customRoutes,
|
|
7
8
|
];
|
|
8
9
|
|
|
9
10
|
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Routes } from '@angular/router';
|
|
2
|
+
import { RouterContainerMagicComponent } from "@magic-xpa/angular";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Custom Routes
|
|
6
|
+
* =============
|
|
7
|
+
* Add your custom/manual routes in this file.
|
|
8
|
+
*
|
|
9
|
+
* IMPORTANT: This file is NOT affected by CLI route regeneration.
|
|
10
|
+
* The generated app.routes.ts automatically imports these routes.
|
|
11
|
+
*
|
|
12
|
+
* Custom routes are placed BEFORE generated routes in the final
|
|
13
|
+
* routes array, so they take PRIORITY when paths conflict.
|
|
14
|
+
*
|
|
15
|
+
* Example:
|
|
16
|
+
* {
|
|
17
|
+
* path: 'callPublic/:name',
|
|
18
|
+
* component: RouterContainerMagicComponent,
|
|
19
|
+
* },
|
|
20
|
+
*/
|
|
21
|
+
export const customRoutes: Routes = [
|
|
22
|
+
|
|
23
|
+
];
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import {Routes, RouterModule} from '@angular/router';
|
|
2
|
+
import {customRoutes} from './custom.routes';
|
|
2
3
|
import { NgModule } from "@angular/core";
|
|
3
4
|
import { CommonModule } from "@angular/common";
|
|
4
5
|
|
|
5
6
|
export const routes: Routes = [
|
|
6
|
-
|
|
7
|
+
...customRoutes,
|
|
7
8
|
];
|
|
8
9
|
|
|
9
10
|
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Routes } from '@angular/router';
|
|
2
|
+
import { RouterContainerMagicComponent } from "@magic-xpa/angular";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Custom Routes
|
|
6
|
+
* =============
|
|
7
|
+
* Add your custom/manual routes in this file.
|
|
8
|
+
*
|
|
9
|
+
* IMPORTANT: This file is NOT affected by CLI route regeneration.
|
|
10
|
+
* The generated app.routes.ts automatically imports these routes.
|
|
11
|
+
*
|
|
12
|
+
* Custom routes are placed BEFORE generated routes in the final
|
|
13
|
+
* routes array, so they take PRIORITY when paths conflict.
|
|
14
|
+
*
|
|
15
|
+
* Example:
|
|
16
|
+
* {
|
|
17
|
+
* path: 'callPublic/:name',
|
|
18
|
+
* component: RouterContainerMagicComponent,
|
|
19
|
+
* },
|
|
20
|
+
*/
|
|
21
|
+
export const customRoutes: Routes = [
|
|
22
|
+
|
|
23
|
+
];
|
|
@@ -48,16 +48,25 @@ function genRouteFile(options, routeItem) {
|
|
|
48
48
|
context.logger.info(`RouteTable is not defined !`);
|
|
49
49
|
else
|
|
50
50
|
context.logger.info(`generating ${data.routesArray.length} root routes`);
|
|
51
|
-
const
|
|
51
|
+
const routeFile = {
|
|
52
52
|
type: types_1.GeneratedFileTypes.TS,
|
|
53
53
|
template: template, // `./templates/angular/src/app.routes.ts`,
|
|
54
54
|
destination: destinationPath, // metadata.paths.rootMagicGenFolder,
|
|
55
55
|
name: 'app.routes.ts',
|
|
56
56
|
data: data
|
|
57
57
|
};
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
58
|
+
const customRouteFile = {
|
|
59
|
+
type: types_1.GeneratedFileTypes.TS,
|
|
60
|
+
template: `./templates/angular/src/custom.routes.ts`,
|
|
61
|
+
destination: destinationPath,
|
|
62
|
+
name: 'custom.routes.ts',
|
|
63
|
+
data: {}
|
|
64
|
+
};
|
|
65
|
+
let rules = [
|
|
66
|
+
(0, generate_rule_1.generate)(routeFile, options),
|
|
67
|
+
!host.exists(`${destinationPath}/custom.routes.ts`) ? (0, generate_rule_1.generate)(customRouteFile, options) : (0, schematics_1.noop)()
|
|
68
|
+
];
|
|
69
|
+
return (0, schematics_1.chain)(rules)(host, context);
|
|
61
70
|
};
|
|
62
71
|
}
|
|
63
72
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;AASA,4CAKC;AAKD,sCAeC;AAMD,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;AASA,4CAKC;AAKD,sCAeC;AAMD,oCA8CC;AAtFD,2DAAqG;AACrG,4FAAkF;AAClF,uCAAiE;AACjE,sEAA8D;AAC9D,4CAAyC;AAGzC,8CAA4C;AAE5C,SAAgB,gBAAgB,CAAC,OAA0B;IACzD,OAAO,IAAA,kBAAK,EAAC;QACX,IAAA,4CAAiB,EAAE,OAAO,CAAC;QAC3B,aAAa,CAAM,OAAO,CAAC;KAC5B,CAAC,CAAC;AACL,CAAC;AAED,mGAAmG;AACnG,8CAA8C;AAC9C,mGAAmG;AACnG,SAAgB,aAAa,CAAC,OAA0B;IACtD,OAAO,CAAC,IAAU,EAAE,OAAyB,EAAE,EAAE;QAE/C,MAAM,QAAQ,GAAI,SAAG,CAAC,QAAQ,CAAC;QAC/B,I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AO,CAAC,MAAM,CAAC,IAAI,CAAC,cAAc,IAAI,CAAC,WAAW,CAAC,MAAM,cAAc,CAAC,CAAC;QAE3E,MAAM,SAAS,GAAmB;YAChC,IAAI,EAAU,0BAAkB,CAAC,EAAE;YACnC,QAAQ,EAAM,QAAQ,EAAoC,2CAA2C;YACrG,WAAW,EAAG,eAAe,EAA6B,qCAAqC;YAC/F,IAAI,EAAU,eAAe;YAC7B,IAAI,EAAU,IAAI;SACnB,CAAC;QAEF,MAAM,eAAe,GAAmB;YACtC,IAAI,EAAU,0BAAkB,CAAC,EAAE;YACnC,QAAQ,EAAM,0CAA0C;YACxD,WAAW,EAAG,eAAe;YAC7B,IAAI,EAAU,kBAAkB;YAChC,IAAI,EAAU,EAAE;SACjB,CAAC;QAEF,IAAI,KAAK,GAAW;YAClB,IAAA,wBAAQ,EAAC,SAAS,EAAE,OAAO,CAAC;YAC5B,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,eAAe,mBAAmB,CAAC,CAAC,CAAC,CAAC,IAAA,wBAAQ,EAAC,eAAe,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,IAAA,iBAAI,GAAE;SAClG,CAAC;QAEF,OAAO,IAAA,kBAAK,EAAC,KAAK,CAAC,CAAC,IAAI,EAAC,OAAO,CAAC,CAAC;IACpC,CAAC,CAAA;AACH,CAAC","sourcesContent":["import { chain, forEach, Rule, SchematicContext, Tree, url, noop } from \"@angular-devkit/schematics\";\r\nimport { initMagicMetadata } from \"../magic-utils/rules/init-magic-metadata.rule\";\r\nimport { GeneratedFileTypes, TemplateConfig } from \"../../types\";\r\nimport { generate } from \"../magic-utils/rules/generate.rule\";\r\nimport { env } from \"../magic-utils/env\";\r\nimport { MagicOptionScheme } from \"../magic-utils/rules/magic-option.scheme\";\r\nimport { RouteTable } from \"../../types/interfaces/app\";\r\nimport { LogLn } from \"../magic-utils/Util\";\r\n\r\nexport function mgGenerateRoutes(options: MagicOptionScheme): Rule {\r\n return chain([\r\n initMagicMetadata (options),\r\n genRoutesFile (options)\r\n ]);\r\n}\r\n\r\n//-------------------------------------------------------------------------------------------------\r\n// generate all the modules in env.modulesGen\r\n//-------------------------------------------------------------------------------------------------\r\nexport function genRoutesFile(options: MagicOptionScheme): Rule {\r\n return (tree: Tree, context: SchematicContext) => {\r\n\r\n const metadata = env.metadata;\r\n let routeTable: RouteTable[] = metadata.routesTable;\r\n let rules:Rule[] = [];\r\n\r\n context.logger.info(`routes length: ${routeTable.length}`);\r\n\r\n for (let routeItem of routeTable){\r\n rules.push(genRouteFile(options, routeItem));\r\n }\r\n\r\n return chain(rules)(tree,context);\r\n };\r\n}\r\n\r\n\r\n\r\n\r\n\r\nexport function genRouteFile(options: MagicOptionScheme, routeItem : RouteTable ) : Rule {\r\n return (host: Tree, context: SchematicContext) => {\r\n const metadata = env.metadata;\r\n let createRootRoute:boolean = routeItem.module_name =='' ? true: false;\r\n LogLn(`genRouteFile : [${routeItem.module_name}] createRootRoute = ${createRootRoute}`)\r\n\r\n const data: any = {\r\n routesArray: routeItem.routesArray,\r\n createRootRoute:createRootRoute\r\n };\r\n\r\n let template : string = `./templates/angular/src/app.routes.ts`;\r\n let destinationPath:string = metadata.paths.rootMagicGenFolder;\r\n if (routeItem.module_name != '')\r\n {\r\n destinationPath = metadata.paths.magicGenFolderPath + `/${routeItem.module_name}`;\r\n }\r\n\r\n if (data.routesArray == undefined)\r\n context.logger.info(`RouteTable is not defined !`);\r\n else\r\n context.logger.info(`generating ${data.routesArray.length} root routes`);\r\n\r\n const routeFile: TemplateConfig = {\r\n type : GeneratedFileTypes.TS,\r\n template : template, // `./templates/angular/src/app.routes.ts`,\r\n destination : destinationPath, // metadata.paths.rootMagicGenFolder,\r\n name : 'app.routes.ts',\r\n data : data\r\n };\r\n\r\n const customRouteFile: TemplateConfig = {\r\n type : GeneratedFileTypes.TS,\r\n template : `./templates/angular/src/custom.routes.ts`,\r\n destination : destinationPath,\r\n name : 'custom.routes.ts',\r\n data : {}\r\n };\r\n\r\n let rules: Rule[] = [\r\n generate(routeFile, options),\r\n !host.exists(`${destinationPath}/custom.routes.ts`) ? generate(customRouteFile, options) : noop()\r\n ];\r\n\r\n return chain(rules)(host,context);\r\n }\r\n}\r\n\r\n\r\n\r\n\r\n\r\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { chain, forEach, Rule, SchematicContext, Tree, url } from "@angular-devkit/schematics";
|
|
1
|
+
import { chain, forEach, Rule, SchematicContext, Tree, url, noop } from "@angular-devkit/schematics";
|
|
2
2
|
import { initMagicMetadata } from "../magic-utils/rules/init-magic-metadata.rule";
|
|
3
3
|
import { GeneratedFileTypes, TemplateConfig } from "../../types";
|
|
4
4
|
import { generate } from "../magic-utils/rules/generate.rule";
|
|
@@ -61,7 +61,7 @@ export function genRouteFile(options: MagicOptionScheme, routeItem : RouteTable
|
|
|
61
61
|
else
|
|
62
62
|
context.logger.info(`generating ${data.routesArray.length} root routes`);
|
|
63
63
|
|
|
64
|
-
const
|
|
64
|
+
const routeFile: TemplateConfig = {
|
|
65
65
|
type : GeneratedFileTypes.TS,
|
|
66
66
|
template : template, // `./templates/angular/src/app.routes.ts`,
|
|
67
67
|
destination : destinationPath, // metadata.paths.rootMagicGenFolder,
|
|
@@ -69,9 +69,20 @@ export function genRouteFile(options: MagicOptionScheme, routeItem : RouteTable
|
|
|
69
69
|
data : data
|
|
70
70
|
};
|
|
71
71
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
72
|
+
const customRouteFile: TemplateConfig = {
|
|
73
|
+
type : GeneratedFileTypes.TS,
|
|
74
|
+
template : `./templates/angular/src/custom.routes.ts`,
|
|
75
|
+
destination : destinationPath,
|
|
76
|
+
name : 'custom.routes.ts',
|
|
77
|
+
data : {}
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
let rules: Rule[] = [
|
|
81
|
+
generate(routeFile, options),
|
|
82
|
+
!host.exists(`${destinationPath}/custom.routes.ts`) ? generate(customRouteFile, options) : noop()
|
|
83
|
+
];
|
|
84
|
+
|
|
85
|
+
return chain(rules)(host,context);
|
|
75
86
|
}
|
|
76
87
|
}
|
|
77
88
|
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import {Routes, RouterModule} from '@angular/router';
|
|
2
2
|
import {RouterContainerMagicComponent} from "@magic-xpa/angular";
|
|
3
|
+
import {customRoutes} from './custom.routes';
|
|
3
4
|
|
|
4
5
|
import { CommonModule } from "@angular/common";
|
|
5
6
|
import { NgModule } from '@angular/core';
|
|
6
7
|
|
|
7
8
|
export const routes: Routes = [
|
|
9
|
+
...customRoutes,
|
|
8
10
|
<%- startRanderForRootModule (createRootRoute); -%>
|
|
9
11
|
<%- renderRoutes (routesArray, createRootRoute); -%>
|
|
10
12
|
<%- endRanderForRootModule (createRootRoute); -%>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Routes } from '@angular/router';
|
|
2
|
+
import { RouterContainerMagicComponent } from "@magic-xpa/angular";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Custom Routes
|
|
6
|
+
* =============
|
|
7
|
+
* Add your custom/manual routes in this file.
|
|
8
|
+
*
|
|
9
|
+
* IMPORTANT: This file is NOT affected by CLI route regeneration.
|
|
10
|
+
* The generated app.routes.ts automatically imports these routes.
|
|
11
|
+
*
|
|
12
|
+
* Custom routes are placed BEFORE generated routes in the final
|
|
13
|
+
* routes array, so they take PRIORITY when paths conflict.
|
|
14
|
+
*
|
|
15
|
+
* Example:
|
|
16
|
+
* {
|
|
17
|
+
* path: 'callPublic/:name',
|
|
18
|
+
* component: RouterContainerMagicComponent,
|
|
19
|
+
* },
|
|
20
|
+
*/
|
|
21
|
+
export const customRoutes: Routes = [
|
|
22
|
+
|
|
23
|
+
];
|