igniteui-cli 13.2.2-beta.1 → 13.2.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.
Files changed (61) hide show
  1. package/lib/templates/AngularTemplate.js +8 -29
  2. package/lib/templates/IgniteUIForReactTemplate.d.ts +0 -1
  3. package/lib/templates/IgniteUIForReactTemplate.js +11 -36
  4. package/lib/templates/IgniteUIForWebComponentsTemplate.js +5 -35
  5. package/migrations/update-5_0_0/index.js +2 -3
  6. package/package.json +3 -3
  7. package/templates/react/ReactTypeScriptFileUpdate.d.ts +49 -10
  8. package/templates/react/ReactTypeScriptFileUpdate.js +336 -60
  9. package/templates/react/igr-ts/projects/_base/files/src/setupTests.ts +6 -0
  10. package/templates/webcomponents/TypeScriptFileUpdate.d.ts +52 -0
  11. package/templates/webcomponents/TypeScriptFileUpdate.js +341 -0
  12. package/templates/webcomponents/igc-ts/accordion/default/index.js +3 -0
  13. package/templates/webcomponents/igc-ts/avatar/default/index.js +3 -0
  14. package/templates/webcomponents/igc-ts/badge/default/index.js +3 -0
  15. package/templates/webcomponents/igc-ts/button/default/index.js +3 -0
  16. package/templates/webcomponents/igc-ts/button-group/default/index.js +3 -0
  17. package/templates/webcomponents/igc-ts/calendar/default/index.js +3 -0
  18. package/templates/webcomponents/igc-ts/card/default/index.js +3 -0
  19. package/templates/webcomponents/igc-ts/checkbox/default/index.js +3 -0
  20. package/templates/webcomponents/igc-ts/chip/default/index.js +3 -0
  21. package/templates/webcomponents/igc-ts/circular-progress/default/index.js +3 -0
  22. package/templates/webcomponents/igc-ts/custom-templates/subscription-form/index.js +3 -0
  23. package/templates/webcomponents/igc-ts/date-time-input/default/index.js +3 -0
  24. package/templates/webcomponents/igc-ts/dock-manager/default/index.js +3 -0
  25. package/templates/webcomponents/igc-ts/dropdown/default/index.js +3 -0
  26. package/templates/webcomponents/igc-ts/expansion-panel/default/index.js +3 -0
  27. package/templates/webcomponents/igc-ts/financial-chart/default/index.js +3 -0
  28. package/templates/webcomponents/igc-ts/form/default/index.js +3 -0
  29. package/templates/webcomponents/igc-ts/grid/default/index.js +3 -0
  30. package/templates/webcomponents/igc-ts/grid/grid-editing/index.js +3 -0
  31. package/templates/webcomponents/igc-ts/grid/grid-summaries/index.js +3 -0
  32. package/templates/webcomponents/igc-ts/icon/default/index.js +3 -0
  33. package/templates/webcomponents/igc-ts/icon-button/default/index.js +3 -0
  34. package/templates/webcomponents/igc-ts/input/default/index.js +3 -0
  35. package/templates/webcomponents/igc-ts/linear-gauge/default/index.js +3 -0
  36. package/templates/webcomponents/igc-ts/linear-progress/default/index.js +3 -0
  37. package/templates/webcomponents/igc-ts/list/default/index.js +3 -0
  38. package/templates/webcomponents/igc-ts/navbar/default/index.js +3 -0
  39. package/templates/webcomponents/igc-ts/pie-chart/default/index.js +3 -0
  40. package/templates/webcomponents/igc-ts/projects/_base/files/package.json +7 -7
  41. package/templates/webcomponents/igc-ts/projects/_base_with_home/files/package.json +13 -13
  42. package/templates/webcomponents/igc-ts/radial-gauge/default/index.js +3 -0
  43. package/templates/webcomponents/igc-ts/radio-group/default/index.js +3 -0
  44. package/templates/webcomponents/igc-ts/rating/default/index.js +3 -0
  45. package/templates/webcomponents/igc-ts/ripple/default/index.js +3 -0
  46. package/templates/webcomponents/igc-ts/slider/default/index.js +3 -0
  47. package/templates/webcomponents/igc-ts/switch/default/index.js +3 -0
  48. package/templates/webcomponents/igc-ts/tabs/default/index.js +3 -0
  49. package/templates/webcomponents/igc-ts/text-area/default/index.js +3 -0
  50. package/templates/webcomponents/igc-ts/text-area/index.js +3 -0
  51. package/templates/webcomponents/igc-ts/tree/default/index.js +3 -0
  52. package/templates/react/types/ReactRouteEntry.d.ts +0 -6
  53. package/templates/react/types/ReactRouteEntry.js +0 -2
  54. package/templates/react/types/ReactRouteLike.d.ts +0 -25
  55. package/templates/react/types/ReactRouteLike.js +0 -2
  56. package/templates/react/types/ReactRouteTarget.d.ts +0 -7
  57. package/templates/react/types/ReactRouteTarget.js +0 -11
  58. package/templates/react/types/index.d.ts +0 -3
  59. package/templates/react/types/index.js +0 -19
  60. package/templates/webcomponents/WebComponentsTypeScriptFileUpdate.d.ts +0 -11
  61. package/templates/webcomponents/WebComponentsTypeScriptFileUpdate.js +0 -82
@@ -40,42 +40,21 @@ 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/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`;
43
+ require("@igniteui/cli-core/typescript").TypeScriptFileUpdate;
46
44
  if (!(options && options.skipRoute)) {
47
45
  //1) import the component class name,
48
46
  //2) and populate the Routes array with the path and component
49
47
  //for example: { path: "combo", component: ComboComponent }
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
- }
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
+ );
63
52
  }
64
53
  //3) add an import of the component class from its file location.
65
54
  //4) populate the declarations portion of the @NgModule with the component class name.
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
- }
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();
79
58
  this.ensureSourceFiles(projectPath);
80
59
  }
81
60
  getExtraConfiguration() {
@@ -28,7 +28,6 @@ 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;
32
31
  protected registerJSONRoute(projectPath: string, name: string, routingModulePath: string): void;
33
32
  protected getViewLink(name: string): string;
34
33
  protected getToolbarLink(name: string): string;
@@ -5,7 +5,6 @@ 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");
9
8
  class IgniteUIForReactTemplate {
10
9
  /**
11
10
  * Base ReactTemplate constructor
@@ -54,40 +53,20 @@ class IgniteUIForReactTemplate {
54
53
  const routeModulePath = options.parentRoutingModulePath;
55
54
  if (!(options && options.skipRoute)
56
55
  && cli_core_1.App.container.get(cli_core_1.FS_TOKEN).fileExists(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
- };
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));
64
60
  if (defaultPath) {
65
- routingModule.addRoute({
66
- index: true,
67
- redirectTo: options.path,
68
- });
61
+ routingModule.addRoute(lowerDashed, options.className, nameFromPath, filePath, options.routerChildren, undefined, defaultPath);
69
62
  }
70
- const children = routeModulePath.includes(cli_core_1.REACT_APP_ROUTING_NAME)
71
- ? child
72
- : undefined;
63
+ routingModule.addRoute(lowerDashed, options.className, nameFromPath, filePath, options.routerChildren, undefined);
73
64
  if (options.hasChildren) {
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
- });
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);
80
69
  }
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();
91
70
  }
92
71
  }
93
72
  getExtraConfiguration() {
@@ -111,15 +90,11 @@ class IgniteUIForReactTemplate {
111
90
  cli_core_1.Util.error(`Path ${"src/views/" + folderName} is not valid!`, "red");
112
91
  process.exit(1);
113
92
  }
114
- //clean up potential leading spaces in folder names (`path/ name`):
93
+ //clean up potential leading spaces in folder names (`path/ name`):
115
94
  folderName = folderName.replace(/\/\s+/g, "/");
116
95
  }
117
96
  return cli_core_1.Util.lowerDashed(folderName);
118
97
  }
119
- fileName(pathName) {
120
- const name = cli_core_1.Util.nameFromPath(pathName);
121
- return cli_core_1.Util.lowerDashed(name);
122
- }
123
98
  registerJSONRoute(projectPath, name, routingModulePath) {
124
99
  const configFile = fs.readFileSync(path.join(projectPath, routingModulePath), "utf8");
125
100
  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 WebComponentsTypeScriptFileUpdate_1 = require("../../templates/webcomponents/WebComponentsTypeScriptFileUpdate");
6
+ const TypeScriptFileUpdate_1 = require("../../templates/webcomponents/TypeScriptFileUpdate");
7
7
  class IgniteUIForWebComponentsTemplate {
8
8
  get templatePaths() {
9
9
  return [path.join(this.rootPath, "files")];
@@ -31,46 +31,16 @@ class IgniteUIForWebComponentsTemplate {
31
31
  return;
32
32
  }
33
33
  const routeModulePath = options.parentRoutingModulePath;
34
- const routingModule = new WebComponentsTypeScriptFileUpdate_1.WebComponentsTypeScriptFileUpdate(path.join(projectPath, routeModulePath), { convertTabsToSpaces: false, indentSize: 2, singleQuotes: true });
34
+ const routingModule = new TypeScriptFileUpdate_1.TypeScriptFileUpdate(path.join(projectPath, routeModulePath));
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;
44
37
  if (defaultPath) {
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
- );
38
+ routingModule.addRoute("", options.selector, cli_core_1.Util.nameFromPath(fullName), options.routerChildren, undefined);
53
39
  }
40
+ routingModule.addRoute(this.fileName(fullName), options.selector, cli_core_1.Util.nameFromPath(fullName), options.routerChildren, undefined);
54
41
  if (options.hasChildren) {
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
- );
42
+ routingModule.addRoute(this.fileName(`${options.modulePath}-routing.ts`), options.selector, cli_core_1.Util.nameFromPath(`${options.modulePath}-routing.ts`), options.routerChildren, options.importAlias);
63
43
  }
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();
74
44
  }
75
45
  }
76
46
  getExtraConfiguration() {
@@ -13,7 +13,6 @@ 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");
17
16
  //#region Temp duplicate of schematics pack fs
18
17
  class NgTreeFileSystem {
19
18
  constructor(tree) {
@@ -52,9 +51,9 @@ function default_1() {
52
51
  context.logger.info(`Applying migration for Ignite UI CLI 5.0.0`);
53
52
  if (tree.exists(moduleFile)) {
54
53
  setVirtual(tree);
55
- const mainModule = new angular_templates_1.AngularTypeScriptFileUpdate(moduleFile, false, { indentSize: 2 });
54
+ const mainModule = new cli_core_1.TypeScriptFileUpdate(moduleFile);
56
55
  mainModule.addNgModuleMeta({ import: "HammerModule", from: "@angular/platform-browser" });
57
- cli_core_1.TypeScriptUtils.saveFile(moduleFile, mainModule.finalize());
56
+ mainModule.finalize();
58
57
  }
59
58
  });
60
59
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "igniteui-cli",
3
- "version": "13.2.2-beta.1",
3
+ "version": "13.2.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.2.1322-beta.1",
76
- "@igniteui/cli-core": "~13.2.2-beta.1",
75
+ "@igniteui/angular-templates": "~17.2.1322",
76
+ "@igniteui/cli-core": "~13.2.2",
77
77
  "chalk": "^2.3.2",
78
78
  "fs-extra": "^3.0.1",
79
79
  "glob": "^7.1.2",
@@ -1,11 +1,50 @@
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;
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;
11
50
  }