igniteui-cli 10.1.0-alpha.0 → 10.1.0-alpha.2
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.
|
@@ -19,7 +19,7 @@ export declare class IgniteUIForWebComponentsTemplate implements Template {
|
|
|
19
19
|
generateConfig(name: string, options: {}): {
|
|
20
20
|
[key: string]: any;
|
|
21
21
|
};
|
|
22
|
-
registerInProject(projectPath: string, fullName: string, options?: AddTemplateArgs): void;
|
|
22
|
+
registerInProject(projectPath: string, fullName: string, options?: AddTemplateArgs, defaultPath?: boolean): void;
|
|
23
23
|
getExtraConfiguration(): ControlExtraConfiguration[];
|
|
24
24
|
setExtraConfiguration(extraConfigKeys: {}): void;
|
|
25
25
|
protected getBaseVariables(name: string): {
|
|
@@ -27,21 +27,20 @@ class IgniteUIForWebComponentsTemplate {
|
|
|
27
27
|
}
|
|
28
28
|
return Object.assign({}, options["extraConfig"], this.getBaseVariables(name));
|
|
29
29
|
}
|
|
30
|
-
registerInProject(projectPath, fullName, options) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
registerInProject(projectPath, fullName, options, defaultPath = false) {
|
|
31
|
+
if (!options.parentName) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
const routeModulePath = options.parentRoutingModulePath;
|
|
35
|
+
const routingModule = new TypeScriptFileUpdate_1.TypeScriptFileUpdate(path.join(projectPath, routeModulePath));
|
|
34
36
|
if (!(options && options.skipRoute) && cli_core_1.App.container.get(cli_core_1.FS_TOKEN)
|
|
35
37
|
.fileExists(routeModulePath)) {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
const moduleName = options.routingModulePath.split("/")[1];
|
|
43
|
-
if (routingModuleText.indexOf(moduleName + "-routing") < 0) {
|
|
44
|
-
routingModule.addRoute(path.join(projectPath, `src/app/${options.routingModulePath}-routing.ts`), this.fileName(`${options.routingModulePath}-routing.ts`), cli_core_1.Util.nameFromPath(`${options.routingModulePath}-routing.ts`), options, options.parentName);
|
|
38
|
+
if (defaultPath) {
|
|
39
|
+
routingModule.addRoute("", options.selector, cli_core_1.Util.nameFromPath(fullName), options.routerChildren, undefined);
|
|
40
|
+
}
|
|
41
|
+
routingModule.addRoute(this.fileName(fullName), options.selector, cli_core_1.Util.nameFromPath(fullName), options.routerChildren, undefined);
|
|
42
|
+
if (options.hasChildren) {
|
|
43
|
+
routingModule.addRoute(this.fileName(`${options.modulePath}-routing.ts`), options.selector, cli_core_1.Util.nameFromPath(`${options.modulePath}-routing.ts`), options.routerChildren, options.importAlias);
|
|
45
44
|
}
|
|
46
45
|
}
|
|
47
46
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "igniteui-cli",
|
|
3
|
-
"version": "10.1.0-alpha.
|
|
3
|
+
"version": "10.1.0-alpha.2",
|
|
4
4
|
"description": "CLI tool for creating Ignite UI projects",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"CLI",
|
|
@@ -72,8 +72,8 @@
|
|
|
72
72
|
"all": true
|
|
73
73
|
},
|
|
74
74
|
"dependencies": {
|
|
75
|
-
"@igniteui/angular-templates": "~14.1.1010-alpha.
|
|
76
|
-
"@igniteui/cli-core": "~10.1.0-alpha.
|
|
75
|
+
"@igniteui/angular-templates": "~14.1.1010-alpha.2",
|
|
76
|
+
"@igniteui/cli-core": "~10.1.0-alpha.2",
|
|
77
77
|
"chalk": "^2.3.2",
|
|
78
78
|
"fs-extra": "^3.0.1",
|
|
79
79
|
"glob": "^7.1.2",
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { AddTemplateArgs } from "@igniteui/cli-core";
|
|
2
1
|
import * as ts from "typescript";
|
|
3
2
|
/**
|
|
4
3
|
* Apply various updates to typescript files using AST
|
|
@@ -19,15 +18,15 @@ export declare class TypeScriptFileUpdate {
|
|
|
19
18
|
constructor(targetPath: string);
|
|
20
19
|
/** Applies accumulated transforms, saves and formats the file */
|
|
21
20
|
finalize(): void;
|
|
22
|
-
addRoute(
|
|
21
|
+
addRoute(path: string, component: string, name: string, routerChildren: string, importAlias: string, routesVariable?: string): void;
|
|
23
22
|
/** Initializes existing imports info, [re]sets import and `NgModule` edits */
|
|
24
23
|
protected initState(): void;
|
|
25
24
|
protected loadImportsMeta(): {
|
|
26
25
|
lastIndex: number;
|
|
27
26
|
modulePaths: any[];
|
|
28
27
|
};
|
|
29
|
-
protected addRouteModuleEntry(
|
|
30
|
-
protected requestImport(modulePath: string,
|
|
28
|
+
protected addRouteModuleEntry(path: string, component: string, name: string, routerChildren: string, importAlias: string, routesVariable?: string): void;
|
|
29
|
+
protected requestImport(modulePath: string, routerAlias: string): void;
|
|
31
30
|
/** Add `import` statements not previously found in the file */
|
|
32
31
|
protected addNewFileImports(): void;
|
|
33
32
|
protected createIdentifierImport(importPath: string, as: string): ts.ImportDeclaration;
|
|
@@ -46,8 +46,8 @@ class TypeScriptFileUpdate {
|
|
|
46
46
|
// reset state in case of further updates
|
|
47
47
|
this.initState();
|
|
48
48
|
}
|
|
49
|
-
addRoute(
|
|
50
|
-
this.addRouteModuleEntry(
|
|
49
|
+
addRoute(path, component, name, routerChildren, importAlias, routesVariable = DEFAULT_ROUTES_VARIABLE) {
|
|
50
|
+
this.addRouteModuleEntry(path, component, name, routerChildren, importAlias, routesVariable);
|
|
51
51
|
}
|
|
52
52
|
//#region File state
|
|
53
53
|
/** Initializes existing imports info, [re]sets import and `NgModule` edits */
|
|
@@ -82,28 +82,25 @@ class TypeScriptFileUpdate {
|
|
|
82
82
|
return meta;
|
|
83
83
|
}
|
|
84
84
|
//#endregion File state
|
|
85
|
-
addRouteModuleEntry(
|
|
86
|
-
const isRouting =
|
|
87
|
-
if (isRouting && this.targetSource.text.indexOf(
|
|
85
|
+
addRouteModuleEntry(path, component, name, routerChildren, importAlias, routesVariable = DEFAULT_ROUTES_VARIABLE) {
|
|
86
|
+
const isRouting = path.indexOf("routing") >= 0;
|
|
87
|
+
if (isRouting && this.targetSource.text.indexOf(path.slice(0, -3)) > 0) {
|
|
88
88
|
return;
|
|
89
89
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
const hasNestedModule = (!hasParent && hasChildren) ? true : false;
|
|
97
|
-
className = "app-" + filePath;
|
|
98
|
-
this.requestImport(relativePath, parentName);
|
|
90
|
+
const moduleName = path.substring(0, path.indexOf("-routing"));
|
|
91
|
+
if (path) {
|
|
92
|
+
const relativePath = isRouting ?
|
|
93
|
+
"./" + moduleName + "/" + path.slice(0, -3) : "./" + path + "/" + path;
|
|
94
|
+
this.requestImport(relativePath, importAlias);
|
|
95
|
+
}
|
|
99
96
|
// https://github.com/Microsoft/TypeScript/issues/14419#issuecomment-307256171
|
|
100
97
|
const transformer = (context) => (rootNode) => {
|
|
101
98
|
// the visitor that should be used when adding routes to the main route array
|
|
102
99
|
const conditionalVisitor = (node) => {
|
|
103
100
|
if (node.kind === ts.SyntaxKind.ArrayLiteralExpression) {
|
|
104
|
-
const newObject = this.createRouteEntry(
|
|
101
|
+
const newObject = this.createRouteEntry(path, component, name, routerChildren);
|
|
105
102
|
const array = node;
|
|
106
|
-
this.createdStringLiterals.push(
|
|
103
|
+
this.createdStringLiterals.push(path, name);
|
|
107
104
|
const notFoundWildCard = ".*";
|
|
108
105
|
const nodes = ts.visitNodes(array.elements, visitor);
|
|
109
106
|
const errorRouteNode = nodes.filter(element => element.getText().includes(notFoundWildCard))[0];
|
|
@@ -149,13 +146,12 @@ class TypeScriptFileUpdate {
|
|
|
149
146
|
}).transformed[0];
|
|
150
147
|
this.finalize();
|
|
151
148
|
}
|
|
152
|
-
requestImport(modulePath,
|
|
149
|
+
requestImport(modulePath, routerAlias) {
|
|
153
150
|
const existing = this.requestedImports.find(x => x.from === modulePath);
|
|
154
151
|
if (!existing) {
|
|
155
|
-
const exportedObject = parentName ? parentName : undefined;
|
|
156
152
|
// new imports, check if already exists in file
|
|
157
153
|
this.requestedImports.push({
|
|
158
|
-
as:
|
|
154
|
+
as: routerAlias,
|
|
159
155
|
from: modulePath,
|
|
160
156
|
edit: this.importsMeta.modulePaths.indexOf(modulePath) !== -1
|
|
161
157
|
});
|
|
@@ -329,12 +325,12 @@ class TypeScriptFileUpdate {
|
|
|
329
325
|
return node;
|
|
330
326
|
};
|
|
331
327
|
}
|
|
332
|
-
createRouteEntry(filePath, className, linkText,
|
|
328
|
+
createRouteEntry(filePath, className, linkText, routerAlias) {
|
|
333
329
|
const routePath = ts.factory.createPropertyAssignment("path", ts.factory.createStringLiteral(filePath));
|
|
334
330
|
const routeComponent = ts.factory.createPropertyAssignment("component", ts.factory.createStringLiteral(className));
|
|
335
331
|
const routeData = ts.factory.createPropertyAssignment("name", ts.factory.createStringLiteral(linkText));
|
|
336
|
-
|
|
337
|
-
|
|
332
|
+
if (routerAlias) {
|
|
333
|
+
const childrenData = ts.factory.createPropertyAssignment("children", ts.factory.createIdentifier(routerAlias));
|
|
338
334
|
return ts.factory.createObjectLiteralExpression([routePath, routeComponent, routeData, childrenData]);
|
|
339
335
|
}
|
|
340
336
|
else {
|