igniteui-cli 13.2.1 → 13.2.2-beta.1

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.
Files changed (60) hide show
  1. package/lib/templates/AngularTemplate.js +29 -8
  2. package/lib/templates/IgniteUIForReactTemplate.d.ts +1 -0
  3. package/lib/templates/IgniteUIForReactTemplate.js +36 -11
  4. package/lib/templates/IgniteUIForWebComponentsTemplate.js +35 -5
  5. package/migrations/update-5_0_0/index.js +3 -2
  6. package/package.json +3 -3
  7. package/templates/react/ReactTypeScriptFileUpdate.d.ts +10 -49
  8. package/templates/react/ReactTypeScriptFileUpdate.js +60 -336
  9. package/templates/react/types/ReactRouteEntry.d.ts +6 -0
  10. package/templates/react/types/ReactRouteEntry.js +2 -0
  11. package/templates/react/types/ReactRouteLike.d.ts +25 -0
  12. package/templates/react/types/ReactRouteLike.js +2 -0
  13. package/templates/react/types/ReactRouteTarget.d.ts +7 -0
  14. package/templates/react/types/ReactRouteTarget.js +11 -0
  15. package/templates/react/types/index.d.ts +3 -0
  16. package/templates/react/types/index.js +19 -0
  17. package/templates/webcomponents/WebComponentsTypeScriptFileUpdate.d.ts +11 -0
  18. package/templates/webcomponents/WebComponentsTypeScriptFileUpdate.js +82 -0
  19. package/templates/webcomponents/igc-ts/accordion/default/index.js +0 -3
  20. package/templates/webcomponents/igc-ts/avatar/default/index.js +0 -3
  21. package/templates/webcomponents/igc-ts/badge/default/index.js +0 -3
  22. package/templates/webcomponents/igc-ts/button/default/index.js +0 -3
  23. package/templates/webcomponents/igc-ts/button-group/default/index.js +0 -3
  24. package/templates/webcomponents/igc-ts/calendar/default/index.js +0 -3
  25. package/templates/webcomponents/igc-ts/card/default/index.js +0 -3
  26. package/templates/webcomponents/igc-ts/checkbox/default/index.js +0 -3
  27. package/templates/webcomponents/igc-ts/chip/default/index.js +0 -3
  28. package/templates/webcomponents/igc-ts/circular-progress/default/index.js +0 -3
  29. package/templates/webcomponents/igc-ts/custom-templates/subscription-form/index.js +0 -3
  30. package/templates/webcomponents/igc-ts/date-time-input/default/index.js +0 -3
  31. package/templates/webcomponents/igc-ts/dock-manager/default/index.js +0 -3
  32. package/templates/webcomponents/igc-ts/dropdown/default/index.js +0 -3
  33. package/templates/webcomponents/igc-ts/expansion-panel/default/index.js +0 -3
  34. package/templates/webcomponents/igc-ts/financial-chart/default/index.js +0 -3
  35. package/templates/webcomponents/igc-ts/form/default/index.js +0 -3
  36. package/templates/webcomponents/igc-ts/grid/default/index.js +0 -3
  37. package/templates/webcomponents/igc-ts/grid/grid-editing/index.js +0 -3
  38. package/templates/webcomponents/igc-ts/grid/grid-summaries/index.js +0 -3
  39. package/templates/webcomponents/igc-ts/icon/default/index.js +0 -3
  40. package/templates/webcomponents/igc-ts/icon-button/default/index.js +0 -3
  41. package/templates/webcomponents/igc-ts/input/default/index.js +0 -3
  42. package/templates/webcomponents/igc-ts/linear-gauge/default/index.js +0 -3
  43. package/templates/webcomponents/igc-ts/linear-progress/default/index.js +0 -3
  44. package/templates/webcomponents/igc-ts/list/default/index.js +0 -3
  45. package/templates/webcomponents/igc-ts/navbar/default/index.js +0 -3
  46. package/templates/webcomponents/igc-ts/pie-chart/default/index.js +0 -3
  47. package/templates/webcomponents/igc-ts/projects/_base/files/package.json +1 -1
  48. package/templates/webcomponents/igc-ts/projects/_base_with_home/files/package.json +7 -7
  49. package/templates/webcomponents/igc-ts/radial-gauge/default/index.js +0 -3
  50. package/templates/webcomponents/igc-ts/radio-group/default/index.js +0 -3
  51. package/templates/webcomponents/igc-ts/rating/default/index.js +0 -3
  52. package/templates/webcomponents/igc-ts/ripple/default/index.js +0 -3
  53. package/templates/webcomponents/igc-ts/slider/default/index.js +0 -3
  54. package/templates/webcomponents/igc-ts/switch/default/index.js +0 -3
  55. package/templates/webcomponents/igc-ts/tabs/default/index.js +0 -3
  56. package/templates/webcomponents/igc-ts/text-area/default/index.js +0 -3
  57. package/templates/webcomponents/igc-ts/text-area/index.js +0 -3
  58. package/templates/webcomponents/igc-ts/tree/default/index.js +0 -3
  59. package/templates/webcomponents/TypeScriptFileUpdate.d.ts +0 -52
  60. package/templates/webcomponents/TypeScriptFileUpdate.js +0 -341
@@ -40,21 +40,42 @@ class AngularTemplate {
40
40
  // tslint:disable-next-line:variable-name
41
41
  const TsUpdate =
42
42
  // tslint:disable-next-line:no-submodule-imports
43
- require("@igniteui/cli-core/typescript").TypeScriptFileUpdate;
43
+ require("@igniteui/angular-templates").AngularTypeScriptFileUpdate;
44
+ const componentPath = path.join(projectPath, `src/app/components/${this.folderName(name)}/${this.fileName(name)}.component.ts`);
45
+ const className = `${cli_core_1.Util.className(cli_core_1.Util.nameFromPath(name))}Component`;
44
46
  if (!(options && options.skipRoute)) {
45
47
  //1) import the component class name,
46
48
  //2) and populate the Routes array with the path and component
47
49
  //for example: { path: "combo", component: ComboComponent }
48
- const routingModule = new TsUpdate(path.join(projectPath, "src/app/app-routing.module.ts"));
49
- routingModule.addRoute(path.join(projectPath, `src/app/components/${this.folderName(name)}/${this.fileName(name)}.component.ts`), this.folderName(name), //path
50
- cli_core_1.Util.nameFromPath(name) //text
51
- );
50
+ const routingModulePath = path.join(projectPath, "src/app/app-routing.module.ts");
51
+ const routingModule = new TsUpdate(routingModulePath, false, { singleQuotes: false });
52
+ routingModule.addRoute({
53
+ path: this.folderName(name),
54
+ identifierName: className,
55
+ modulePath: cli_core_1.Util.relativePath(routingModulePath, componentPath, true, true),
56
+ data: { text: cli_core_1.Util.nameFromPath(name) }
57
+ });
58
+ const content = routingModule.finalize();
59
+ if (content) {
60
+ // add to a finalize override in the NG File Update instead?
61
+ cli_core_1.TypeScriptUtils.saveFile(routingModulePath, content);
62
+ }
52
63
  }
53
64
  //3) add an import of the component class from its file location.
54
65
  //4) populate the declarations portion of the @NgModule with the component class name.
55
- const mainModule = new TsUpdate(path.join(projectPath, `src/app/${modulePath}`));
56
- mainModule.addDeclaration(path.join(projectPath, `src/app/components/${this.folderName(name)}/${this.fileName(name)}.component.ts`), modulePath !== "app.module.ts");
57
- mainModule.finalize();
66
+ const mainModulePath = path.join(projectPath, `src/app/${modulePath}`);
67
+ const relativePath = cli_core_1.Util.relativePath(mainModulePath, componentPath, true, true);
68
+ const mainModule = new TsUpdate(mainModulePath, false, { singleQuotes: false });
69
+ mainModule.addNgModuleMeta({
70
+ declare: [className],
71
+ from: relativePath,
72
+ export: modulePath !== "app.module.ts" ? [className] : []
73
+ });
74
+ const content = mainModule.finalize();
75
+ if (content) {
76
+ // add to a finalize override in the NG File Update instead?
77
+ cli_core_1.TypeScriptUtils.saveFile(mainModulePath, content);
78
+ }
58
79
  this.ensureSourceFiles(projectPath);
59
80
  }
60
81
  getExtraConfiguration() {
@@ -28,6 +28,7 @@ export declare class IgniteUIForReactTemplate implements Template {
28
28
  getExtraConfiguration(): ControlExtraConfiguration[];
29
29
  setExtraConfiguration(extraConfigKeys: {}): void;
30
30
  protected folderName(pathName: string): string;
31
+ protected fileName(pathName: string): string;
31
32
  protected registerJSONRoute(projectPath: string, name: string, routingModulePath: string): void;
32
33
  protected getViewLink(name: string): string;
33
34
  protected getToolbarLink(name: string): string;
@@ -5,6 +5,7 @@ const cli_core_1 = require("@igniteui/cli-core");
5
5
  const fs = require("fs-extra");
6
6
  const path = require("path");
7
7
  const ReactTypeScriptFileUpdate_1 = require("../../templates/react/ReactTypeScriptFileUpdate");
8
+ const typescript_1 = require("typescript");
8
9
  class IgniteUIForReactTemplate {
9
10
  /**
10
11
  * Base ReactTemplate constructor
@@ -53,20 +54,40 @@ class IgniteUIForReactTemplate {
53
54
  const routeModulePath = options.parentRoutingModulePath;
54
55
  if (!(options && options.skipRoute)
55
56
  && cli_core_1.App.container.get(cli_core_1.FS_TOKEN).fileExists(routeModulePath)) {
56
- let nameFromPath = cli_core_1.Util.nameFromPath(name);
57
- let lowerDashed = cli_core_1.Util.lowerDashed(nameFromPath);
58
- let filePath = path.posix.join(projectPath, options.modulePath, `${lowerDashed}.tsx`);
59
- const routingModule = new ReactTypeScriptFileUpdate_1.ReactTypeScriptFileUpdate(path.join(projectPath, routeModulePath));
57
+ const routingModule = new ReactTypeScriptFileUpdate_1.ReactTypeScriptFileUpdate(path.join(projectPath, routeModulePath), { convertTabsToSpaces: false, indentSize: 2, singleQuotes: true }, { jsx: typescript_1.JsxEmit.Preserve });
58
+ const modulePath = `./${cli_core_1.Util.lowerDashed(name)}/${cli_core_1.Util.lowerDashed(name)}-routes`;
59
+ const child = {
60
+ identifierName: cli_core_1.ROUTES_VARIABLE_NAME,
61
+ aliasName: options.routerChildren,
62
+ modulePath
63
+ };
60
64
  if (defaultPath) {
61
- routingModule.addRoute(lowerDashed, options.className, nameFromPath, filePath, options.routerChildren, undefined, defaultPath);
65
+ routingModule.addRoute({
66
+ index: true,
67
+ redirectTo: options.path,
68
+ });
62
69
  }
63
- routingModule.addRoute(lowerDashed, options.className, nameFromPath, filePath, options.routerChildren, undefined);
70
+ const children = routeModulePath.includes(cli_core_1.REACT_APP_ROUTING_NAME)
71
+ ? child
72
+ : undefined;
64
73
  if (options.hasChildren) {
65
- nameFromPath = cli_core_1.Util.nameFromPath(`${options.modulePath}-routes.tsx`);
66
- lowerDashed = cli_core_1.Util.lowerDashed(nameFromPath);
67
- filePath = path.posix.join(projectPath, options.modulePath, nameFromPath);
68
- routingModule.addRoute(lowerDashed, options.className, nameFromPath, filePath, options.routerChildren, options.importAlias);
74
+ routingModule.addRoute({
75
+ path: this.fileName(name),
76
+ element: cli_core_1.Util.className(name),
77
+ text: cli_core_1.Util.nameFromPath(name),
78
+ children
79
+ });
69
80
  }
81
+ else {
82
+ routingModule.addRoute({
83
+ path: this.fileName(name),
84
+ element: cli_core_1.Util.className(name),
85
+ text: cli_core_1.Util.nameFromPath(name)
86
+ }, false, // multiline
87
+ false // prepend
88
+ );
89
+ }
90
+ routingModule.finalize();
70
91
  }
71
92
  }
72
93
  getExtraConfiguration() {
@@ -90,11 +111,15 @@ class IgniteUIForReactTemplate {
90
111
  cli_core_1.Util.error(`Path ${"src/views/" + folderName} is not valid!`, "red");
91
112
  process.exit(1);
92
113
  }
93
- //clean up potential leading spaces in folder names (`path/ name`):
114
+ //clean up potential leading spaces in folder names (`path/ name`):
94
115
  folderName = folderName.replace(/\/\s+/g, "/");
95
116
  }
96
117
  return cli_core_1.Util.lowerDashed(folderName);
97
118
  }
119
+ fileName(pathName) {
120
+ const name = cli_core_1.Util.nameFromPath(pathName);
121
+ return cli_core_1.Util.lowerDashed(name);
122
+ }
98
123
  registerJSONRoute(projectPath, name, routingModulePath) {
99
124
  const configFile = fs.readFileSync(path.join(projectPath, routingModulePath), "utf8");
100
125
  const viewsArr = JSON.parse(configFile);
@@ -3,7 +3,7 @@ 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 TypeScriptFileUpdate_1 = require("../../templates/webcomponents/TypeScriptFileUpdate");
6
+ const WebComponentsTypeScriptFileUpdate_1 = require("../../templates/webcomponents/WebComponentsTypeScriptFileUpdate");
7
7
  class IgniteUIForWebComponentsTemplate {
8
8
  get templatePaths() {
9
9
  return [path.join(this.rootPath, "files")];
@@ -31,16 +31,46 @@ class IgniteUIForWebComponentsTemplate {
31
31
  return;
32
32
  }
33
33
  const routeModulePath = options.parentRoutingModulePath;
34
- const routingModule = new TypeScriptFileUpdate_1.TypeScriptFileUpdate(path.join(projectPath, routeModulePath));
34
+ const routingModule = new WebComponentsTypeScriptFileUpdate_1.WebComponentsTypeScriptFileUpdate(path.join(projectPath, routeModulePath), { convertTabsToSpaces: false, indentSize: 2, singleQuotes: true });
35
35
  if (!(options && options.skipRoute) && cli_core_1.App.container.get(cli_core_1.FS_TOKEN)
36
36
  .fileExists(routeModulePath)) {
37
+ const modulePath = `./${cli_core_1.Util.lowerDashed(fullName)}/${cli_core_1.Util.lowerDashed(fullName)}-routing`;
38
+ const child = {
39
+ identifierName: cli_core_1.ROUTES_VARIABLE_NAME,
40
+ aliasName: options.routerChildren,
41
+ modulePath
42
+ };
43
+ const children = options.hasChildren ? child : undefined;
37
44
  if (defaultPath) {
38
- routingModule.addRoute("", options.selector, cli_core_1.Util.nameFromPath(fullName), options.routerChildren, undefined);
45
+ routingModule.addRoute({
46
+ path: "",
47
+ redirectTo: options.selector,
48
+ name: cli_core_1.Util.nameFromPath(fullName),
49
+ children
50
+ }, false, // multiline
51
+ true // prepend
52
+ );
39
53
  }
40
- routingModule.addRoute(this.fileName(fullName), options.selector, cli_core_1.Util.nameFromPath(fullName), options.routerChildren, undefined);
41
54
  if (options.hasChildren) {
42
- routingModule.addRoute(this.fileName(`${options.modulePath}-routing.ts`), options.selector, cli_core_1.Util.nameFromPath(`${options.modulePath}-routing.ts`), options.routerChildren, options.importAlias);
55
+ routingModule.addRoute({
56
+ path: this.fileName(fullName),
57
+ identifierName: options.selector,
58
+ name: cli_core_1.Util.nameFromPath(fullName),
59
+ children
60
+ }, false, // multiline
61
+ true // prepend
62
+ );
43
63
  }
64
+ else {
65
+ routingModule.addRoute({
66
+ path: this.fileName(fullName),
67
+ identifierName: options.selector,
68
+ name: cli_core_1.Util.nameFromPath(fullName)
69
+ }, false, // multiline
70
+ true // prepend
71
+ );
72
+ }
73
+ routingModule.finalize();
44
74
  }
45
75
  }
46
76
  getExtraConfiguration() {
@@ -13,6 +13,7 @@ exports.setVirtual = exports.NgTreeFileSystem = void 0;
13
13
  // tslint:disable:no-implicit-dependencies
14
14
  const core_1 = require("@angular-devkit/core");
15
15
  const cli_core_1 = require("@igniteui/cli-core");
16
+ const angular_templates_1 = require("@igniteui/angular-templates");
16
17
  //#region Temp duplicate of schematics pack fs
17
18
  class NgTreeFileSystem {
18
19
  constructor(tree) {
@@ -51,9 +52,9 @@ function default_1() {
51
52
  context.logger.info(`Applying migration for Ignite UI CLI 5.0.0`);
52
53
  if (tree.exists(moduleFile)) {
53
54
  setVirtual(tree);
54
- const mainModule = new cli_core_1.TypeScriptFileUpdate(moduleFile);
55
+ const mainModule = new angular_templates_1.AngularTypeScriptFileUpdate(moduleFile, false, { indentSize: 2 });
55
56
  mainModule.addNgModuleMeta({ import: "HammerModule", from: "@angular/platform-browser" });
56
- mainModule.finalize();
57
+ cli_core_1.TypeScriptUtils.saveFile(moduleFile, mainModule.finalize());
57
58
  }
58
59
  });
59
60
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "igniteui-cli",
3
- "version": "13.2.1",
3
+ "version": "13.2.2-beta.1",
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.2.1321",
76
- "@igniteui/cli-core": "~13.2.1",
75
+ "@igniteui/angular-templates": "~17.2.1322-beta.1",
76
+ "@igniteui/cli-core": "~13.2.2-beta.1",
77
77
  "chalk": "^2.3.2",
78
78
  "fs-extra": "^3.0.1",
79
79
  "glob": "^7.1.2",
@@ -1,50 +1,11 @@
1
- import * as ts from "typescript";
2
- /**
3
- * Apply various updates to typescript files using AST
4
- */
5
- export declare class ReactTypeScriptFileUpdate {
6
- private targetPath;
7
- protected formatOptions: {
8
- spaces: boolean;
9
- indentSize: number;
10
- singleQuotes: boolean;
11
- };
12
- private fileSystem;
13
- private targetSource;
14
- private importsMeta;
15
- private requestedImports;
16
- private createdStringLiterals;
17
- /** Create updates for a file. Use `add<X>` methods to add transformations and `finalize` to apply and save them. */
18
- constructor(targetPath: string);
19
- /** Applies accumulated transforms, saves and formats the file */
20
- finalize(): void;
21
- addRoute(path: string, component: string, name: string, filePath: string, routerChildren: string, importAlias: string, defaultRoute?: boolean): void;
22
- /** Initializes existing imports info, [re]sets import and `NgModule` edits */
23
- protected initState(): void;
24
- protected loadImportsMeta(): {
25
- lastIndex: number;
26
- modulePaths: any[];
27
- };
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
- /** Add `import` statements not previously found in the file */
31
- protected addNewFileImports(): void;
32
- protected createIdentifierImport(importPath: string, as: string, component: string, namedImport: boolean): ts.ImportDeclaration;
33
- /** Transformation to apply edits to existing named import declarations */
34
- protected importsTransformer: ts.TransformerFactory<ts.Node>;
35
- /** Format a TS source file, very TBD */
36
- protected formatFile(filePath: string): void;
37
- /** Try and parse formatting from project `.editorconfig` / `tslint.json` */
38
- protected readFormatConfigs(): void;
39
- /**
40
- * Apply formatting changes (position based) in reverse
41
- * from https://github.com/Microsoft/TypeScript/issues/1651#issuecomment-69877863
42
- */
43
- private applyChanges;
44
- /** Return source file formatting options */
45
- private getFormattingOptions;
46
- /** Get language service host, sloppily */
47
- private getLanguageHost;
48
- private createVisitor;
49
- private createRouteEntry;
1
+ import * as ts from 'typescript';
2
+ import { FormatSettings, PropertyAssignment, TypeScriptFileUpdate } from '@igniteui/cli-core';
3
+ import { ReactRouteLike } from './types';
4
+ export declare class ReactTypeScriptFileUpdate extends TypeScriptFileUpdate {
5
+ constructor(filePath: string, formatSettings?: FormatSettings, compilerOptions?: ts.CompilerOptions);
6
+ addRoute(route: ReactRouteLike, multiline?: boolean, prepend?: boolean, anchorElement?: PropertyAssignment): ts.SourceFile;
7
+ protected addRouteEntry(route: ReactRouteLike, visitCondition: (node: ts.Node) => boolean, multiline: boolean, prepend: boolean, anchorElement: PropertyAssignment): ts.SourceFile;
8
+ protected addRedirectRouteEntry(route: ReactRouteLike, visitCondition: (node: ts.Node) => boolean, multiline?: boolean, prepend?: boolean, anchorElement?: PropertyAssignment): ts.SourceFile;
9
+ protected addChildRouteEntry(route: ReactRouteLike, asIdentifier?: boolean, multiline?: boolean, prepend?: boolean): ts.SourceFile;
10
+ private requestImportForRouteLoader;
50
11
  }