igniteui-cli 13.1.12-beta.1 → 13.1.12-beta.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.
@@ -42,11 +42,10 @@ command = {
42
42
  case "jquery":
43
43
  cli_core_1.Util.log("Upgrading packages for jQuery projects is currently not supported!");
44
44
  return;
45
- case "react":
46
- cli_core_1.Util.log("Upgrading packages for React projects is currently not supported!");
47
- return;
48
45
  case "angular":
49
- if (projectType === "igx-ts") {
46
+ case "react":
47
+ case "webcomponents":
48
+ if (projectType === "igx-ts" || projectType === "igr-ts" || projectType === "igc-ts") {
50
49
  const projectLibrary = command.templateManager.getProjectLibrary(framework, projectType);
51
50
  let project;
52
51
  if (!config.project.projectTemplate || !projectLibrary.hasProject(config.project.projectTemplate)) {
@@ -69,7 +68,7 @@ command = {
69
68
  }
70
69
  }
71
70
  }
72
- else {
71
+ else if (framework.toLowerCase() === "angular") {
73
72
  cli_core_1.Util.log("Upgrading packages for Angular Wrappers projects is currently not supported!");
74
73
  return;
75
74
  }
@@ -58,7 +58,7 @@ class IgniteUIForReactTemplate {
58
58
  let filePath = path.posix.join(projectPath, options.modulePath, `${lowerDashed}.tsx`);
59
59
  const routingModule = new ReactTypeScriptFileUpdate_1.ReactTypeScriptFileUpdate(path.join(projectPath, routeModulePath));
60
60
  if (defaultPath) {
61
- routingModule.addRoute("", options.className, nameFromPath, filePath, options.routerChildren, undefined);
61
+ routingModule.addRoute(lowerDashed, options.className, nameFromPath, filePath, options.routerChildren, undefined, defaultPath);
62
62
  }
63
63
  routingModule.addRoute(lowerDashed, options.className, nameFromPath, filePath, options.routerChildren, undefined);
64
64
  if (options.hasChildren) {
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.IgniteUIForWebComponentsTemplate = void 0;
4
4
  const cli_core_1 = require("@igniteui/cli-core");
5
5
  const path = require("path");
6
- const package_resolve_1 = require("../../templates/webcomponents/package-resolve");
7
6
  const TypeScriptFileUpdate_1 = require("../../templates/webcomponents/TypeScriptFileUpdate");
8
7
  class IgniteUIForWebComponentsTemplate {
9
8
  constructor(rootPath) {
@@ -59,7 +58,7 @@ class IgniteUIForWebComponentsTemplate {
59
58
  config["description"] = this.description;
60
59
  config["cliVersion"] = cli_core_1.Util.version();
61
60
  config["camelCaseName"] = cli_core_1.Util.camelCase(name);
62
- config["dockManagerPackage"] = (0, package_resolve_1.resolveIgcPackage)(package_resolve_1.NPM_DOCK_MANAGER);
61
+ config["dockManagerPackage"] = (0, cli_core_1.resolvePackage)(cli_core_1.NPM_DOCK_MANAGER);
63
62
  return config;
64
63
  }
65
64
  folderName(pathName) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "igniteui-cli",
3
- "version": "13.1.12-beta.1",
3
+ "version": "13.1.12-beta.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": "~17.1.13112-beta.1",
76
- "@igniteui/cli-core": "~13.1.12-beta.1",
75
+ "@igniteui/angular-templates": "^17.1.13112-beta.2",
76
+ "@igniteui/cli-core": "^13.1.12-beta.2",
77
77
  "chalk": "^2.3.2",
78
78
  "fs-extra": "^3.0.1",
79
79
  "glob": "^7.1.2",
@@ -18,18 +18,18 @@ export declare class ReactTypeScriptFileUpdate {
18
18
  constructor(targetPath: string);
19
19
  /** Applies accumulated transforms, saves and formats the file */
20
20
  finalize(): void;
21
- addRoute(path: string, component: string, name: string, filePath: string, routerChildren: string, importAlias: string, routesVariable?: string): void;
21
+ addRoute(path: string, component: string, name: string, filePath: string, routerChildren: string, importAlias: string, defaultRoute?: boolean): void;
22
22
  /** Initializes existing imports info, [re]sets import and `NgModule` edits */
23
23
  protected initState(): void;
24
24
  protected loadImportsMeta(): {
25
25
  lastIndex: number;
26
26
  modulePaths: any[];
27
27
  };
28
- protected addRouteModuleEntry(path: string, component: string, name: string, filePath: string, routerChildren: string, importAlias: string, routesVariable?: string): void;
29
- protected requestImport(modulePath: string, routerAlias: string, componentName: string): void;
28
+ protected addRouteModuleEntry(path: string, component: string, name: string, filePath: string, routerChildren: string, importAlias: string, defaultRoute?: boolean): void;
29
+ protected requestImport(modulePath: string, routerAlias: string, componentName: string, namedImport?: boolean): void;
30
30
  /** Add `import` statements not previously found in the file */
31
31
  protected addNewFileImports(): void;
32
- protected createIdentifierImport(importPath: string, as: string, component: string): ts.ImportDeclaration;
32
+ protected createIdentifierImport(importPath: string, as: string, component: string, namedImport: boolean): ts.ImportDeclaration;
33
33
  /** Transformation to apply edits to existing named import declarations */
34
34
  protected importsTransformer: ts.TransformerFactory<ts.Node>;
35
35
  /** Format a TS source file, very TBD */
@@ -46,8 +46,8 @@ class ReactTypeScriptFileUpdate {
46
46
  // reset state in case of further updates
47
47
  this.initState();
48
48
  }
49
- addRoute(path, component, name, filePath, routerChildren, importAlias, routesVariable = DEFAULT_ROUTES_VARIABLE) {
50
- this.addRouteModuleEntry(path, component, name, filePath, routerChildren, importAlias, routesVariable);
49
+ addRoute(path, component, name, filePath, routerChildren, importAlias, defaultRoute = false) {
50
+ this.addRouteModuleEntry(path, component, name, filePath, routerChildren, importAlias, defaultRoute);
51
51
  }
52
52
  //#region File state
53
53
  /** Initializes existing imports info, [re]sets import and `NgModule` edits */
@@ -82,12 +82,15 @@ class ReactTypeScriptFileUpdate {
82
82
  return meta;
83
83
  }
84
84
  //#endregion File state
85
- addRouteModuleEntry(path, component, name, filePath, routerChildren, importAlias, routesVariable = DEFAULT_ROUTES_VARIABLE) {
86
- const isRouting = path.indexOf("routes") >= 0;
85
+ addRouteModuleEntry(path, component, name, filePath, routerChildren, importAlias, defaultRoute = false) {
86
+ const isRouting = path.indexOf(DEFAULT_ROUTES_VARIABLE) >= 0;
87
87
  if (isRouting && this.targetSource.text.indexOf(path.slice(0, -4)) > 0) {
88
88
  return;
89
89
  }
90
- if (path) {
90
+ if (defaultRoute) {
91
+ this.requestImport("react-router-dom", undefined, "redirect", true);
92
+ }
93
+ else {
91
94
  const relativePath = cli_core_1.Util.relativePath(this.targetPath, filePath, true, true);
92
95
  this.requestImport(relativePath, importAlias, component);
93
96
  }
@@ -96,7 +99,7 @@ class ReactTypeScriptFileUpdate {
96
99
  // the visitor that should be used when adding routes to the main route array
97
100
  const conditionalVisitor = (node) => {
98
101
  if (node.kind === ts.SyntaxKind.ArrayLiteralExpression) {
99
- const newObject = this.createRouteEntry(path, component, name, routerChildren);
102
+ const newObject = this.createRouteEntry(path, component, name, routerChildren, defaultRoute);
100
103
  const array = node;
101
104
  this.createdStringLiterals.push(path, name);
102
105
  const notFoundWildCard = ".*";
@@ -126,7 +129,7 @@ class ReactTypeScriptFileUpdate {
126
129
  if (!isRouting) {
127
130
  visitCondition = (node) => {
128
131
  return node.kind === ts.SyntaxKind.VariableDeclaration &&
129
- node.name.getText() === routesVariable;
132
+ node.name.getText() === DEFAULT_ROUTES_VARIABLE;
130
133
  // no type currently
131
134
  //(node as ts.VariableDeclaration).type.getText() === "Route[]";
132
135
  };
@@ -145,20 +148,19 @@ class ReactTypeScriptFileUpdate {
145
148
  }).transformed[0];
146
149
  this.finalize();
147
150
  }
148
- requestImport(modulePath, routerAlias, componentName) {
151
+ requestImport(modulePath, routerAlias, componentName, namedImport = false) {
149
152
  const existing = this.requestedImports.find(x => x.from === modulePath);
153
+ // TODO: better check for named imports. There could be several named imports from same modulePath
150
154
  if (!existing) {
151
155
  // new imports, check if already exists in file
152
156
  this.requestedImports.push({
153
157
  as: routerAlias,
154
158
  from: modulePath,
155
159
  component: componentName,
156
- edit: this.importsMeta.modulePaths.indexOf(modulePath) !== -1
160
+ edit: this.importsMeta.modulePaths.indexOf(modulePath) !== -1,
161
+ namedImport
157
162
  });
158
163
  }
159
- else {
160
- return;
161
- }
162
164
  }
163
165
  /** Add `import` statements not previously found in the file */
164
166
  addNewFileImports() {
@@ -168,13 +170,13 @@ class ReactTypeScriptFileUpdate {
168
170
  }
169
171
  const newStatements = ts.factory.createNodeArray([
170
172
  ...this.targetSource.statements.slice(0, this.importsMeta.lastIndex),
171
- ...newImports.map(x => this.createIdentifierImport(x.from, x.as, x.component)),
173
+ ...newImports.map(x => this.createIdentifierImport(x.from, x.as, x.component, x.namedImport)),
172
174
  ...this.targetSource.statements.slice(this.importsMeta.lastIndex)
173
175
  ]);
174
176
  newImports.forEach(x => this.createdStringLiterals.push(x.from));
175
177
  this.targetSource = ts.factory.updateSourceFile(this.targetSource, newStatements);
176
178
  }
177
- createIdentifierImport(importPath, as, component) {
179
+ createIdentifierImport(importPath, as, component, namedImport) {
178
180
  let exportedObject;
179
181
  let exportedObjectName;
180
182
  let importClause;
@@ -186,7 +188,14 @@ class ReactTypeScriptFileUpdate {
186
188
  ]));
187
189
  }
188
190
  else {
189
- importClause = ts.factory.createImportClause(false, ts.factory.createIdentifier(component), undefined);
191
+ if (namedImport) {
192
+ const importSpecifier = ts.factory.createImportSpecifier(false, undefined, ts.factory.createIdentifier(component));
193
+ const imports = ts.factory.createNamedImports([importSpecifier]);
194
+ importClause = ts.factory.createImportClause(false, undefined, imports);
195
+ }
196
+ else {
197
+ importClause = ts.factory.createImportClause(false, ts.factory.createIdentifier(component), undefined);
198
+ }
190
199
  }
191
200
  const importDeclaration = ts.factory.createImportDeclaration(undefined, undefined, importClause, ts.factory.createStringLiteral(importPath, true));
192
201
  return importDeclaration;
@@ -316,7 +325,14 @@ class ReactTypeScriptFileUpdate {
316
325
  return node;
317
326
  };
318
327
  }
319
- createRouteEntry(path, component, name, routerAlias) {
328
+ createRouteEntry(path, component, name, routerAlias, defaultRoute = false) {
329
+ if (defaultRoute) {
330
+ // for default route in React we should generate index: true, loader: () => redirect(path)
331
+ const index = ts.factory.createPropertyAssignment("index", ts.factory.createTrue());
332
+ const loader = ts.factory.createArrowFunction(undefined, undefined, [], undefined, undefined, ts.factory.createCallExpression(ts.factory.createIdentifier("redirect"), [], [ts.factory.createStringLiteral(path, true)]));
333
+ const redirect = ts.factory.createPropertyAssignment("loader", loader);
334
+ return ts.factory.createObjectLiteralExpression([index, redirect]);
335
+ }
320
336
  const routePath = ts.factory.createPropertyAssignment("path", ts.factory.createStringLiteral(path, true));
321
337
  const jsxElement = ts.factory.createJsxSelfClosingElement(ts.factory.createIdentifier(component), [], undefined);
322
338
  const routeComponent = ts.factory.createPropertyAssignment("element", jsxElement);
@@ -325,9 +341,7 @@ class ReactTypeScriptFileUpdate {
325
341
  const childrenData = ts.factory.createPropertyAssignment("children", ts.factory.createIdentifier(routerAlias));
326
342
  return ts.factory.createObjectLiteralExpression([routePath, routeComponent, routeData, childrenData]);
327
343
  }
328
- else {
329
- return ts.factory.createObjectLiteralExpression([routePath, routeComponent, routeData]);
330
- }
344
+ return ts.factory.createObjectLiteralExpression([routePath, routeComponent, routeData]);
331
345
  }
332
346
  }
333
347
  exports.ReactTypeScriptFileUpdate = ReactTypeScriptFileUpdate;
@@ -33,7 +33,7 @@ class BaseIgrTsProject {
33
33
  }
34
34
  upgradeIgniteUIPackages(projectPath, packagePath) {
35
35
  return __awaiter(this, void 0, void 0, function* () {
36
- throw new Error("Method not implemented.");
36
+ return (0, cli_core_1.updateWorkspace)(projectPath);
37
37
  });
38
38
  }
39
39
  getExtraConfiguration() {
@@ -5,9 +5,9 @@ name: Node.js CI
5
5
 
6
6
  on:
7
7
  push:
8
- branches: [ <%=yaml-default-branch%> ]
8
+ branches: [ $(yamlDefaultBranch) ]
9
9
  pull_request:
10
- branches: [ <%=yaml-default-branch%> ]
10
+ branches: [ $(yamlDefaultBranch) ]
11
11
 
12
12
  jobs:
13
13
  build:
@@ -31,7 +31,7 @@ class BaseIgcProject {
31
31
  }
32
32
  upgradeIgniteUIPackages(projectPath, packagePath) {
33
33
  return __awaiter(this, void 0, void 0, function* () {
34
- throw new Error("Method not implemented.");
34
+ return (0, cli_core_1.updateWorkspace)(projectPath);
35
35
  });
36
36
  }
37
37
  getExtraConfiguration() {
@@ -48,7 +48,8 @@ class BaseIgcProject {
48
48
  DefaultTheme: "",
49
49
  dot: ".",
50
50
  path: name,
51
- projectTemplate: this.id
51
+ projectTemplate: this.id,
52
+ yamlDefaultBranch: this.id === "base" ? "<%=yaml-default-branch%>" : "main"
52
53
  };
53
54
  return config;
54
55
  }
@@ -1,12 +0,0 @@
1
- export declare const NPM_DOCK_MANAGER = "igniteui-dockmanager";
2
- export declare const FEED_DOCK_MANAGER = "@infragistics/igniteui-dockmanager";
3
- export interface PackageDefinition {
4
- trial: string;
5
- licensed: string;
6
- }
7
- /** packages map of `trial: licensed` names */
8
- export declare const UPGRADEABLE_PACKAGES: {
9
- "igniteui-dockmanager": string;
10
- };
11
- export declare function resolveIgcPackage(packageName: keyof typeof UPGRADEABLE_PACKAGES): string;
12
- export declare function getUpgradeablePackages(): PackageDefinition[];
@@ -1,42 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getUpgradeablePackages = exports.resolveIgcPackage = exports.UPGRADEABLE_PACKAGES = exports.FEED_DOCK_MANAGER = exports.NPM_DOCK_MANAGER = void 0;
4
- const cli_core_1 = require("@igniteui/cli-core");
5
- exports.NPM_DOCK_MANAGER = "igniteui-dockmanager";
6
- exports.FEED_DOCK_MANAGER = "@infragistics/igniteui-dockmanager";
7
- /** packages map of `trial: licensed` names */
8
- exports.UPGRADEABLE_PACKAGES = {
9
- [exports.NPM_DOCK_MANAGER]: exports.FEED_DOCK_MANAGER
10
- };
11
- function resolveIgcPackage(packageName) {
12
- const fs = cli_core_1.App.container.get(cli_core_1.FS_TOKEN);
13
- // read project package JSON
14
- if (fs.fileExists("./package.json")) {
15
- const packageJson = JSON.parse(fs.readFile("./package.json"));
16
- const dependencies = packageJson["dependencies"];
17
- const licensed = exports.UPGRADEABLE_PACKAGES[packageName];
18
- if (dependencies[licensed]) {
19
- return licensed;
20
- }
21
- }
22
- return packageName;
23
- }
24
- exports.resolveIgcPackage = resolveIgcPackage;
25
- function getUpgradeablePackages() {
26
- const fs = cli_core_1.App.container.get(cli_core_1.FS_TOKEN);
27
- const upgradeable = [];
28
- if (fs.fileExists("./package.json")) {
29
- const packageJson = JSON.parse(fs.readFile("./package.json"));
30
- const dependencies = packageJson["dependencies"];
31
- for (const packageEntry in exports.UPGRADEABLE_PACKAGES) {
32
- if (dependencies[packageEntry]) {
33
- upgradeable.push({
34
- trial: packageEntry,
35
- licensed: exports.UPGRADEABLE_PACKAGES[packageEntry]
36
- });
37
- }
38
- }
39
- }
40
- return upgradeable;
41
- }
42
- exports.getUpgradeablePackages = getUpgradeablePackages;