@progress/kendo-angular-schematics 11.0.0-develop.79

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 (141) hide show
  1. package/LICENSE.md +11 -0
  2. package/NOTICE.txt +654 -0
  3. package/collection.json +53 -0
  4. package/package.json +33 -0
  5. package/src/charts/categorical/files/data.d.ts +5 -0
  6. package/src/charts/categorical/files/data.js +29 -0
  7. package/src/charts/categorical/files/data.js.map +1 -0
  8. package/src/charts/categorical/files/data.ts +25 -0
  9. package/src/charts/categorical/files/html/__name@dasherize__/__name@dasherize__.component.html +46 -0
  10. package/src/charts/categorical/files/html/__name@dasherize__/__name@dasherize__.component.ts +25 -0
  11. package/src/charts/categorical/files/inline/__name@dasherize__/__name@dasherize__.component.ts +69 -0
  12. package/src/charts/categorical/index.d.ts +7 -0
  13. package/src/charts/categorical/index.js +124 -0
  14. package/src/charts/categorical/index.js.map +1 -0
  15. package/src/charts/categorical/schema.d.ts +92 -0
  16. package/src/charts/categorical/schema.js +54 -0
  17. package/src/charts/categorical/schema.js.map +1 -0
  18. package/src/charts/categorical/schema.json +253 -0
  19. package/src/charts/circular/files/data.d.ts +5 -0
  20. package/src/charts/circular/files/data.js +15 -0
  21. package/src/charts/circular/files/data.js.map +1 -0
  22. package/src/charts/circular/files/data.ts +11 -0
  23. package/src/charts/circular/files/html/__name@dasherize__/__name@dasherize__.component.html +27 -0
  24. package/src/charts/circular/files/html/__name@dasherize__/__name@dasherize__.component.ts +23 -0
  25. package/src/charts/circular/files/inline/__name@dasherize__/__name@dasherize__.component.ts +52 -0
  26. package/src/charts/circular/index.d.ts +7 -0
  27. package/src/charts/circular/index.js +50 -0
  28. package/src/charts/circular/index.js.map +1 -0
  29. package/src/charts/circular/schema.d.ts +31 -0
  30. package/src/charts/circular/schema.js +7 -0
  31. package/src/charts/circular/schema.js.map +1 -0
  32. package/src/charts/circular/schema.json +175 -0
  33. package/src/charts/scatter/files/data.d.ts +5 -0
  34. package/src/charts/scatter/files/data.js +25 -0
  35. package/src/charts/scatter/files/data.js.map +1 -0
  36. package/src/charts/scatter/files/data.ts +21 -0
  37. package/src/charts/scatter/files/html/__name@dasherize__/__name@dasherize__.component.html +35 -0
  38. package/src/charts/scatter/files/html/__name@dasherize__/__name@dasherize__.component.ts +21 -0
  39. package/src/charts/scatter/files/inline/__name@dasherize__/__name@dasherize__.component.ts +58 -0
  40. package/src/charts/scatter/index.d.ts +7 -0
  41. package/src/charts/scatter/index.js +50 -0
  42. package/src/charts/scatter/index.js.map +1 -0
  43. package/src/charts/scatter/schema.d.ts +32 -0
  44. package/src/charts/scatter/schema.js +7 -0
  45. package/src/charts/scatter/schema.js.map +1 -0
  46. package/src/charts/scatter/schema.json +209 -0
  47. package/src/charts/stock/files/data.d.ts +5 -0
  48. package/src/charts/stock/files/data.js +418 -0
  49. package/src/charts/stock/files/data.js.map +1 -0
  50. package/src/charts/stock/files/data.ts +414 -0
  51. package/src/charts/stock/files/html/__name@dasherize__/__name@dasherize__.component.html +57 -0
  52. package/src/charts/stock/files/html/__name@dasherize__/__name@dasherize__.component.ts +23 -0
  53. package/src/charts/stock/files/inline/__name@dasherize__/__name@dasherize__.component.ts +83 -0
  54. package/src/charts/stock/index.d.ts +7 -0
  55. package/src/charts/stock/index.js +50 -0
  56. package/src/charts/stock/index.js.map +1 -0
  57. package/src/charts/stock/schema.d.ts +36 -0
  58. package/src/charts/stock/schema.js +7 -0
  59. package/src/charts/stock/schema.js.map +1 -0
  60. package/src/charts/stock/schema.json +285 -0
  61. package/src/component/files/__full-path__/__name@folder-name__/__name@dasherize__.component.__styleext__ +0 -0
  62. package/src/component/files/__full-path__/__name@folder-name__/__name@dasherize__.component.html +1 -0
  63. package/src/component/files/__full-path__/__name@folder-name__/__name@dasherize__.component.ts +23 -0
  64. package/src/component/index.d.ts +6 -0
  65. package/src/component/index.js +18 -0
  66. package/src/component/index.js.map +1 -0
  67. package/src/component/schema.d.ts +66 -0
  68. package/src/component/schema.js +7 -0
  69. package/src/component/schema.js.map +1 -0
  70. package/src/component/schema.json +96 -0
  71. package/src/grid/files/data.d.ts +5 -0
  72. package/src/grid/files/data.js +1241 -0
  73. package/src/grid/files/data.js.map +1 -0
  74. package/src/grid/files/data.ts +1237 -0
  75. package/src/grid/files/html/__name@dasherize__/__name@dasherize__.component.html +48 -0
  76. package/src/grid/files/html/__name@dasherize__/__name@dasherize__.component.ts +29 -0
  77. package/src/grid/files/inline/__name@dasherize__/__name@dasherize__.component.ts +79 -0
  78. package/src/grid/index.d.ts +7 -0
  79. package/src/grid/index.js +84 -0
  80. package/src/grid/index.js.map +1 -0
  81. package/src/grid/schema.d.ts +44 -0
  82. package/src/grid/schema.js +28 -0
  83. package/src/grid/schema.js.map +1 -0
  84. package/src/grid/schema.json +168 -0
  85. package/src/ngAdd/index.d.ts +7 -0
  86. package/src/ngAdd/index.js +143 -0
  87. package/src/ngAdd/index.js.map +1 -0
  88. package/src/ngAdd/schema.d.ts +61 -0
  89. package/src/ngAdd/schema.js +7 -0
  90. package/src/ngAdd/schema.js.map +1 -0
  91. package/src/ngAdd/schema.json +70 -0
  92. package/src/ngAdd/theming.d.ts +8 -0
  93. package/src/ngAdd/theming.js +79 -0
  94. package/src/ngAdd/theming.js.map +1 -0
  95. package/src/rules/index.d.ts +11 -0
  96. package/src/rules/index.js +80 -0
  97. package/src/rules/index.js.map +1 -0
  98. package/src/scheduler/files/events-utc.d.ts +5 -0
  99. package/src/scheduler/files/events-utc.js +846 -0
  100. package/src/scheduler/files/events-utc.js.map +1 -0
  101. package/src/scheduler/files/events-utc.ts +842 -0
  102. package/src/scheduler/files/html/__name@dasherize__/__name@dasherize__.component.html +29 -0
  103. package/src/scheduler/files/html/__name@dasherize__/__name@dasherize__.component.ts +17 -0
  104. package/src/scheduler/files/inline/__name@dasherize__/__name@dasherize__.component.ts +48 -0
  105. package/src/scheduler/index.d.ts +7 -0
  106. package/src/scheduler/index.js +47 -0
  107. package/src/scheduler/index.js.map +1 -0
  108. package/src/scheduler/schema.d.ts +16 -0
  109. package/src/scheduler/schema.js +7 -0
  110. package/src/scheduler/schema.js.map +1 -0
  111. package/src/scheduler/schema.json +78 -0
  112. package/src/utils/ast-utils.d.ts +34 -0
  113. package/src/utils/ast-utils.js +206 -0
  114. package/src/utils/ast-utils.js.map +1 -0
  115. package/src/utils/bootstrap-module.d.ts +9 -0
  116. package/src/utils/bootstrap-module.js +54 -0
  117. package/src/utils/bootstrap-module.js.map +1 -0
  118. package/src/utils/find-module.d.ts +25 -0
  119. package/src/utils/find-module.js +91 -0
  120. package/src/utils/find-module.js.map +1 -0
  121. package/src/utils/index.d.ts +16 -0
  122. package/src/utils/index.js +74 -0
  123. package/src/utils/index.js.map +1 -0
  124. package/src/utils/test/create-app-module.d.ts +6 -0
  125. package/src/utils/test/create-app-module.js +24 -0
  126. package/src/utils/test/create-app-module.js.map +1 -0
  127. package/src/utils/test/create-cli-config.d.ts +6 -0
  128. package/src/utils/test/create-cli-config.js +121 -0
  129. package/src/utils/test/create-cli-config.js.map +1 -0
  130. package/src/utils/test/create-main-bootstrap.d.ts +6 -0
  131. package/src/utils/test/create-main-bootstrap.js +26 -0
  132. package/src/utils/test/create-main-bootstrap.js.map +1 -0
  133. package/src/utils/test/create-package-json.d.ts +6 -0
  134. package/src/utils/test/create-package-json.js +20 -0
  135. package/src/utils/test/create-package-json.js.map +1 -0
  136. package/src/utils/test/index.d.ts +8 -0
  137. package/src/utils/test/index.js +12 -0
  138. package/src/utils/test/index.js.map +1 -0
  139. package/src/utils/workspace.d.ts +16 -0
  140. package/src/utils/workspace.js +58 -0
  141. package/src/utils/workspace.js.map +1 -0
@@ -0,0 +1,29 @@
1
+ <kendo-scheduler [kendoSchedulerBinding]="events" [selectedDate]="selectedDate" scrollTime="08:00" style="height: 600px;">
2
+ <%
3
+ if (dayView) {
4
+ %>
5
+ <kendo-scheduler-day-view> </kendo-scheduler-day-view>
6
+ <%
7
+ }
8
+ if (weekView) {
9
+ %>
10
+ <kendo-scheduler-week-view> </kendo-scheduler-week-view>
11
+ <%
12
+ }
13
+ if (monthView) {
14
+ %>
15
+ <kendo-scheduler-month-view> </kendo-scheduler-month-view>
16
+ <%
17
+ }
18
+ if (timelineView) {
19
+ %>
20
+ <kendo-scheduler-timeline-view> </kendo-scheduler-timeline-view>
21
+ <%
22
+ }
23
+ if (agendaView) {
24
+ %>
25
+ <kendo-scheduler-agenda-view> </kendo-scheduler-agenda-view>
26
+ <%
27
+ }
28
+ %>
29
+ </kendo-scheduler>
@@ -0,0 +1,17 @@
1
+ /**-----------------------------------------------------------------------------------------
2
+ * Copyright © 2022 Progress Software Corporation. All rights reserved.
3
+ * Licensed under commercial license. See LICENSE.md in the project root for more information
4
+ *-------------------------------------------------------------------------------------------*/
5
+ import { Component } from '@angular/core';
6
+ import { sampleData, displayDate } from './events-utc';
7
+ import { SchedulerEvent } from '@progress/kendo-angular-scheduler';
8
+
9
+ @Component({
10
+ selector: '<%= dasherize(name) %>-component',
11
+ templateUrl: './<%= dasherize(name) %>.component.html',
12
+ <% if (inlineStyle) {%> styleUrls: ['./<%= dasherize(name) %>.component.css']<% } else {%>styles: [``]<% } %>
13
+ })
14
+ export class <%= classify(name) %>Component {
15
+ public selectedDate: Date = displayDate;
16
+ public events: SchedulerEvent[] = sampleData;
17
+ }
@@ -0,0 +1,48 @@
1
+ /**-----------------------------------------------------------------------------------------
2
+ * Copyright © 2022 Progress Software Corporation. All rights reserved.
3
+ * Licensed under commercial license. See LICENSE.md in the project root for more information
4
+ *-------------------------------------------------------------------------------------------*/
5
+ import { Component } from '@angular/core';
6
+ import { sampleData, displayDate } from './events-utc';
7
+ import { SchedulerEvent } from '@progress/kendo-angular-scheduler';
8
+
9
+ @Component({
10
+ selector: '<%= dasherize(name) %>-component',
11
+ template: `
12
+ <kendo-scheduler [kendoSchedulerBinding]="events" [selectedDate]="selectedDate" scrollTime="08:00" style="height: 600px;">
13
+ <%
14
+ if (dayView) {
15
+ %>
16
+ <kendo-scheduler-day-view> </kendo-scheduler-day-view>
17
+ <%
18
+ }
19
+ if (weekView) {
20
+ %>
21
+ <kendo-scheduler-week-view> </kendo-scheduler-week-view>
22
+ <%
23
+ }
24
+ if (monthView) {
25
+ %>
26
+ <kendo-scheduler-month-view> </kendo-scheduler-month-view>
27
+ <%
28
+ }
29
+ if (timelineView) {
30
+ %>
31
+ <kendo-scheduler-timeline-view> </kendo-scheduler-timeline-view>
32
+ <%
33
+ }
34
+ if (agendaView) {
35
+ %>
36
+ <kendo-scheduler-agenda-view> </kendo-scheduler-agenda-view>
37
+ <%
38
+ }
39
+ %>
40
+ </kendo-scheduler>
41
+ `,<% if (inlineStyle) {%>
42
+ styles: [``]<% } else {%>
43
+ styleUrls: ['./<%= dasherize(name) %>.component.css']<% } %>
44
+ })
45
+ export class <%= classify(name) %>Component {
46
+ public selectedDate: Date = displayDate;
47
+ public events: SchedulerEvent[] = sampleData;
48
+ }
@@ -0,0 +1,7 @@
1
+ /**-----------------------------------------------------------------------------------------
2
+ * Copyright © 2022 Progress Software Corporation. All rights reserved.
3
+ * Licensed under commercial license. See LICENSE.md in the project root for more information
4
+ *-------------------------------------------------------------------------------------------*/
5
+ import { Rule } from '@angular-devkit/schematics';
6
+ import { Schema } from './schema';
7
+ export declare function scheduler(_options: Schema): Rule;
@@ -0,0 +1,47 @@
1
+ /**-----------------------------------------------------------------------------------------
2
+ * Copyright © 2022 Progress Software Corporation. All rights reserved.
3
+ * Licensed under commercial license. See LICENSE.md in the project root for more information
4
+ *-------------------------------------------------------------------------------------------*/
5
+ "use strict";
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.scheduler = void 0;
8
+ const core_1 = require("@angular-devkit/core");
9
+ const strings_1 = require("@angular-devkit/core/src/utils/strings");
10
+ const schematics_1 = require("@angular-devkit/schematics");
11
+ const path_1 = require("path");
12
+ const events_utc_1 = require("./files/events-utc");
13
+ function scheduler(_options) {
14
+ return (_tree, _context) => {
15
+ _options.name = (0, path_1.basename)(_options.name);
16
+ let path = (0, path_1.normalize)('/' + (0, path_1.dirname)((_options.path + '/' + _options.name)));
17
+ if (process.platform == "win32") {
18
+ path = path.replace(/\\/g, '/');
19
+ }
20
+ const templateSource = (0, schematics_1.apply)((0, schematics_1.url)(_options.inlineTemplate ? './files/inline' : './files/html'), [
21
+ (0, schematics_1.template)({
22
+ ..._options,
23
+ classify: core_1.strings.classify,
24
+ dasherize: core_1.strings.dasherize,
25
+ arrayify(args) {
26
+ return args.map(s => `'${s}'`).join(", ");
27
+ }
28
+ }),
29
+ (0, schematics_1.move)(_options.path),
30
+ ]);
31
+ const angularComponentOptions = {
32
+ path: _options.path,
33
+ name: _options.name,
34
+ inlineTemplate: _options.inlineTemplate,
35
+ inlineStyle: _options.inlineStyle,
36
+ skipTests: _options.skipTests,
37
+ style: "css"
38
+ };
39
+ _tree.create(`${_options.path}/${(0, strings_1.dasherize)(_options.name)}/events-utc.ts`, events_utc_1.eventsSourceCode);
40
+ return (0, schematics_1.chain)([
41
+ (0, schematics_1.externalSchematic)('@schematics/angular', 'component', angularComponentOptions),
42
+ (0, schematics_1.mergeWith)(templateSource, schematics_1.MergeStrategy.Overwrite)
43
+ ]);
44
+ };
45
+ }
46
+ exports.scheduler = scheduler;
47
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../libs/schematics/src/scheduler/index.ts"],"names":[],"mappings":";;;AAAA,+CAA+C;AAC/C,oEAAmE;AACnE,2DAYoC;AAEpC,+BAA2D;AAE3D,mDAAsD;AAEtD,SAAgB,SAAS,CAAC,QAAgB;IACzC,OAAO,CAAC,KAAW,EAAE,QAA0B,EAAE,EAAE;QAClD,QAAQ,CAAC,IAAI,GAAG,IAAA,eAAQ,EAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QAExC,IAAI,IAAI,GAAI,IAAA,gBAAS,EAAC,GAAG,GAAG,IAAA,cAAO,EAAC,CAAC,QAAQ,CAAC,I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0BAAa,CAAC,SAAS,CAAC;SAClD,CAAC,CAAC;IACJ,CAAC,CAAC;AACH,CAAC;AAvCD,8BAuCC"}
@@ -0,0 +1,16 @@
1
+ /**-----------------------------------------------------------------------------------------
2
+ * Copyright © 2022 Progress Software Corporation. All rights reserved.
3
+ * Licensed under commercial license. See LICENSE.md in the project root for more information
4
+ *-------------------------------------------------------------------------------------------*/
5
+ export interface Schema {
6
+ path?: string;
7
+ name: string;
8
+ inlineStyle: boolean;
9
+ inlineTemplate: boolean;
10
+ skipTests: boolean;
11
+ dayView: boolean;
12
+ weekView: boolean;
13
+ monthView: boolean;
14
+ timelineView: boolean;
15
+ agendaView: boolean;
16
+ }
@@ -0,0 +1,7 @@
1
+ /**-----------------------------------------------------------------------------------------
2
+ * Copyright © 2022 Progress Software Corporation. All rights reserved.
3
+ * Licensed under commercial license. See LICENSE.md in the project root for more information
4
+ *-------------------------------------------------------------------------------------------*/
5
+ "use strict";
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ //# sourceMappingURL=schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../../../libs/schematics/src/scheduler/schema.ts"],"names":[],"mappings":""}
@@ -0,0 +1,78 @@
1
+ {
2
+ "progress:name": "Scheduler",
3
+ "progress:description": "Generate new Kendo UI for Angular Scheduler page",
4
+ "$schema": "http://json-schema.org/schema",
5
+ "$id": "Schema",
6
+ "type": "object",
7
+ "properties": {
8
+ "path": {
9
+ "type": "string",
10
+ "format": "path",
11
+ "progress:editorVisible": false
12
+ },
13
+ "name": {
14
+ "type": "string",
15
+ "$default": {
16
+ "$source": "argv",
17
+ "index": 0
18
+ },
19
+ "default": "SchedulerPage"
20
+ },
21
+
22
+ "inlineTemplate": {
23
+ "progress:category": "Code Generation",
24
+ "progress:display-name": "Inline template",
25
+ "description": "Include template inline in the component.ts file. By default, an external template file is created and referenced in the component.ts file.",
26
+ "type": "boolean",
27
+ "default": false,
28
+ "alias": "t"
29
+ },
30
+ "inlineStyle": {
31
+ "progress:category": "Code Generation",
32
+ "description": "Include styles inline in the component.ts file. Only CSS styles can be included inline. By default, an external styles file is created and referenced in the component.ts file.",
33
+ "type": "boolean",
34
+ "default": false,
35
+ "alias": "s"
36
+ },
37
+ "skipTests": {
38
+ "progress:category": "Code Generation",
39
+ "type": "boolean",
40
+ "description": "Do not create \"spec.ts\" test files for the new component.",
41
+ "default": false
42
+ },
43
+
44
+ "dayView": {
45
+ "progress:category": "Scheduler Views",
46
+ "description": "Enables Scheduler day view",
47
+ "type": "boolean",
48
+ "default": true
49
+ },
50
+ "weekView": {
51
+ "progress:category": "Scheduler Views",
52
+ "description": "Enables Scheduler week view",
53
+ "type": "boolean",
54
+ "default": true
55
+ },
56
+ "monthView": {
57
+ "progress:category": "Scheduler Views",
58
+ "description": "Enables Scheduler week view",
59
+ "type": "boolean",
60
+ "default": true
61
+ },
62
+ "timelineView": {
63
+ "progress:category": "Scheduler Views",
64
+ "description": "Enables Scheduler timeline view",
65
+ "type": "boolean",
66
+ "default": true
67
+ },
68
+ "agendaView": {
69
+ "progress:category": "Scheduler Views",
70
+ "description": "Enables Scheduler agenda view",
71
+ "type": "boolean",
72
+ "default": true
73
+ }
74
+ },
75
+ "required": [
76
+ "name"
77
+ ]
78
+ }
@@ -0,0 +1,34 @@
1
+ /**-----------------------------------------------------------------------------------------
2
+ * Copyright © 2022 Progress Software Corporation. All rights reserved.
3
+ * Licensed under commercial license. See LICENSE.md in the project root for more information
4
+ *-------------------------------------------------------------------------------------------*/
5
+ import * as ts from 'typescript';
6
+ declare type ModuleOptions = {
7
+ source: ts.SourceFile;
8
+ symbolName: string;
9
+ modulePath?: string;
10
+ };
11
+ export declare const addDeclarationToModule: (options: ModuleOptions) => {
12
+ position: any;
13
+ toAdd: string;
14
+ }[];
15
+ export declare const addImportToModule: (options: ModuleOptions) => {
16
+ position: any;
17
+ toAdd: string;
18
+ }[];
19
+ export declare const addExportToModule: (options: ModuleOptions) => {
20
+ position: any;
21
+ toAdd: string;
22
+ }[];
23
+ export declare const ngModuleMetadata: (source: ts.SourceFile) => ts.ObjectLiteralExpression;
24
+ export declare const addSymbolToMetadata: (source: ts.SourceFile, metadataField: string, symbolName: string) => {
25
+ position: any;
26
+ toAdd: string;
27
+ }[];
28
+ export declare function findNode(node: ts.Node, kind: ts.SyntaxKind, text: string): ts.Node | null;
29
+ export declare const nodesByKind: (source: ts.Node, kind: ts.SyntaxKind) => ts.Node[];
30
+ export declare const insertImport: (source: ts.SourceFile, symbolName: string, importFrom: string) => {
31
+ position: any;
32
+ toAdd: string;
33
+ }[];
34
+ export {};
@@ -0,0 +1,206 @@
1
+ /**-----------------------------------------------------------------------------------------
2
+ * Copyright © 2022 Progress Software Corporation. All rights reserved.
3
+ * Licensed under commercial license. See LICENSE.md in the project root for more information
4
+ *-------------------------------------------------------------------------------------------*/
5
+ "use strict";
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.insertImport = exports.nodesByKind = exports.findNode = exports.addSymbolToMetadata = exports.ngModuleMetadata = exports.addExportToModule = exports.addImportToModule = exports.addDeclarationToModule = void 0;
8
+ const ts = require("typescript");
9
+ const addDeclarationToModule = (options) => addToModule('declarations', options);
10
+ exports.addDeclarationToModule = addDeclarationToModule;
11
+ const addImportToModule = (options) => addToModule('imports', options);
12
+ exports.addImportToModule = addImportToModule;
13
+ const addExportToModule = (options) => addToModule('exports', options);
14
+ exports.addExportToModule = addExportToModule;
15
+ const addToModule = (metadataField, options) => {
16
+ const result = (0, exports.addSymbolToMetadata)(options.source, metadataField, options.symbolName);
17
+ if (options.modulePath) {
18
+ return result.concat((0, exports.insertImport)(options.source, options.symbolName, options.modulePath));
19
+ }
20
+ return result;
21
+ };
22
+ const ngModuleMetadata = (source) => {
23
+ const decorator = decoratorMetadata(source, 'NgModule')
24
+ .filter(node => ofKind(node.arguments[0], ts.SyntaxKind.ObjectLiteralExpression))[0];
25
+ if (!decorator) {
26
+ return null;
27
+ }
28
+ return decorator.arguments[0];
29
+ };
30
+ exports.ngModuleMetadata = ngModuleMetadata;
31
+ const addSymbolToMetadata = (source, metadataField, symbolName) => {
32
+ if (!symbolName)
33
+ return [];
34
+ const node = (0, exports.ngModuleMetadata)(source);
35
+ if (!node) {
36
+ return [];
37
+ }
38
+ const property = findProperty(node.properties, metadataField);
39
+ if (!property) {
40
+ return [
41
+ addMetaField(node, `${metadataField}: [${symbolName}]`)
42
+ ];
43
+ }
44
+ if (!ofKind(property.initializer, ts.SyntaxKind.ArrayLiteralExpression)) {
45
+ //We cannot handle it if is not a array literal
46
+ return [];
47
+ }
48
+ const elements = property.initializer.elements;
49
+ if (elements.length === 0) {
50
+ return [{
51
+ position: property.initializer.getEnd() - 1,
52
+ toAdd: symbolName
53
+ }];
54
+ }
55
+ const exists = elements.map(e => e.getText()).find(t => t === symbolName);
56
+ //already there
57
+ if (exists) {
58
+ return [];
59
+ }
60
+ return [
61
+ format(elements, symbolName)
62
+ ];
63
+ };
64
+ exports.addSymbolToMetadata = addSymbolToMetadata;
65
+ const addMetaField = (node, text) => {
66
+ if (node.properties.length === 0) {
67
+ return {
68
+ position: node.getEnd() - 1,
69
+ toAdd: text
70
+ };
71
+ }
72
+ return format(node.properties, text);
73
+ };
74
+ const format = (nodes, text) => {
75
+ let toAdd = `, ${text}`;
76
+ const lastNode = nodes[nodes.length - 1];
77
+ const matches = lastNode.getFullText().match(/^\r?\n\s*/);
78
+ if (matches && matches.length > 0) {
79
+ toAdd = `,${matches[0]}${text}`;
80
+ }
81
+ return {
82
+ position: lastNode.getEnd(),
83
+ toAdd
84
+ };
85
+ };
86
+ const formatNode = (node, text) => {
87
+ const toAdd = `${text}`;
88
+ return {
89
+ position: node.getStart(),
90
+ toAdd
91
+ };
92
+ };
93
+ const anyOf = (kind, possible) => possible.reduce((result, current) => result || current === kind, false);
94
+ const ofKind = (node, ...kinds) => node && anyOf(node.kind, kinds);
95
+ const isNgModelIdentifier = (node, name) => (ofKind(node, ts.SyntaxKind.Identifier) && node.getText() === name) ||
96
+ (ofKind(node, ts.SyntaxKind.PropertyAccessExpression) && node.name.escapedText === name);
97
+ function findNode(node, kind, text) {
98
+ if (node.kind === kind && node.getText() === text) {
99
+ return node;
100
+ }
101
+ let foundNode = null;
102
+ ts.forEachChild(node, childNode => {
103
+ foundNode = foundNode || findNode(childNode, kind, text);
104
+ });
105
+ return foundNode;
106
+ }
107
+ exports.findNode = findNode;
108
+ const nodesByKind = (source, kind) => {
109
+ const nodes = [source];
110
+ const result = [];
111
+ let node;
112
+ // eslint-disable-next-line no-cond-assign
113
+ while (node = nodes.shift()) {
114
+ if (ofKind(node, kind)) {
115
+ result.push(node);
116
+ }
117
+ if (node.getChildCount()) {
118
+ nodes.unshift(...node.getChildren());
119
+ }
120
+ }
121
+ return result;
122
+ };
123
+ exports.nodesByKind = nodesByKind;
124
+ const findProperty = (props, metadataField) => props
125
+ .filter(prop => ofKind(prop, ts.SyntaxKind.PropertyAssignment))
126
+ .filter(prop => {
127
+ const name = prop.name;
128
+ if (ofKind(name, ts.SyntaxKind.Identifier)) {
129
+ return name.text === metadataField;
130
+ }
131
+ if (ofKind(name, ts.SyntaxKind.StringLiteral)) {
132
+ return name.text === metadataField;
133
+ }
134
+ return false;
135
+ })[0];
136
+ const decoratorMetadata = (source, name) => (0, exports.nodesByKind)(source, ts.SyntaxKind.Decorator)
137
+ .map(decorator => decorator.expression)
138
+ .filter(expression => expression.kind === ts.SyntaxKind.CallExpression)
139
+ .map(expression => expression)
140
+ .filter(node => isNgModelIdentifier(node.expression, name));
141
+ const insertImport = (source, symbolName, importFrom) => {
142
+ const isSideEffectsImport = !symbolName;
143
+ const allImports = (0, exports.nodesByKind)(source, ts.SyntaxKind.ImportDeclaration);
144
+ const imports = allImports
145
+ .filter(node => node.getChildren()
146
+ .filter(child => ofKind(child, ts.SyntaxKind.StringLiteral))
147
+ .map(child => child.text)
148
+ .indexOf(importFrom) !== -1);
149
+ if (imports.length) {
150
+ return exitExisting(imports, symbolName);
151
+ }
152
+ let position = 0;
153
+ let prefix = '';
154
+ if (allImports.length) {
155
+ position = allImports[allImports.length - 1].getEnd();
156
+ prefix = '\n';
157
+ }
158
+ else {
159
+ const useStrict = useStrictNode(source);
160
+ if (useStrict.length) {
161
+ position = useStrict[0].getEnd();
162
+ prefix = '\n';
163
+ }
164
+ }
165
+ // missing module declaration
166
+ const toAdd = isSideEffectsImport ?
167
+ `${prefix}import '${importFrom}';\n` :
168
+ `${prefix}import { ${symbolName} } from '${importFrom}';\n`;
169
+ return [{
170
+ position,
171
+ toAdd
172
+ }];
173
+ };
174
+ exports.insertImport = insertImport;
175
+ const useStrictNode = (source) => (0, exports.nodesByKind)(source, ts.SyntaxKind.StringLiteral)
176
+ .filter(node => node.text === 'use strict');
177
+ const exitExisting = (imports, symbolName) => {
178
+ const importAsterisk = imports.reduce((acc, cur) => acc || (0, exports.nodesByKind)(cur, ts.SyntaxKind.AsteriskToken).length > 0, false);
179
+ // symbol is imported with * from the module
180
+ // e.g import * from '...';
181
+ if (importAsterisk) {
182
+ return [];
183
+ }
184
+ const importsText = imports.reduce((acc, cur) => [...acc, ...(0, exports.nodesByKind)(cur, ts.SyntaxKind.Identifier)], [])
185
+ .filter(node => node.text === symbolName);
186
+ // module declaration
187
+ // symbol is not imported
188
+ if (importsText.length === 0) {
189
+ const namedImport = (0, exports.nodesByKind)(imports[0], ts.SyntaxKind.NamedImports)[0];
190
+ if (!namedImport) {
191
+ // it should be import 'some-package';
192
+ return [];
193
+ }
194
+ if (!namedImport.elements.length) {
195
+ return [
196
+ formatNode(namedImport.getLastToken(), symbolName)
197
+ ];
198
+ }
199
+ return [
200
+ format(namedImport.elements, symbolName)
201
+ ];
202
+ }
203
+ // symbol already imported from the module
204
+ return [];
205
+ };
206
+ //# sourceMappingURL=ast-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ast-utils.js","sourceRoot":"","sources":["../../../../../libs/schematics/src/utils/ast-utils.ts"],"names":[],"mappings":";;;AAAA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AAC;QAE/F,IAAI,CAAC,WAAW,EAAE;YACd,sCAAsC;YACtC,OAAO,EAAE,CAAC;SACb;QAED,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,MAAM,EAAE;YAC9B,OAAO;gBACH,UAAU,CAAC,WAAW,CAAC,YAAY,EAAE,EAAE,UAAU,CAAC;aACrD,CAAC;SACL;QAED,OAAO;YACH,MAAM,CAAC,WAAW,CAAC,QAAQ,EAAE,UAAU,CAAC;SAC3C,CAAC;KACL;IAED,0CAA0C;IAC1C,OAAO,EAAE,CAAC;AACd,CAAC,CAAA"}
@@ -0,0 +1,9 @@
1
+ /**-----------------------------------------------------------------------------------------
2
+ * Copyright © 2022 Progress Software Corporation. All rights reserved.
3
+ * Licensed under commercial license. See LICENSE.md in the project root for more information
4
+ *-------------------------------------------------------------------------------------------*/
5
+ import * as ts from 'typescript';
6
+ import { Tree } from '@angular-devkit/schematics';
7
+ export declare function getAppModulePath(host: Tree, mainPath: string): string;
8
+ export declare function findBootstrapModuleCall(host: Tree, mainPath: string): ts.CallExpression | null;
9
+ export declare function findBootstrapModulePath(host: Tree, mainPath: string): string;
@@ -0,0 +1,54 @@
1
+ /**-----------------------------------------------------------------------------------------
2
+ * Copyright © 2022 Progress Software Corporation. All rights reserved.
3
+ * Licensed under commercial license. See LICENSE.md in the project root for more information
4
+ *-------------------------------------------------------------------------------------------*/
5
+ "use strict";
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.findBootstrapModulePath = exports.findBootstrapModuleCall = exports.getAppModulePath = void 0;
8
+ const ts = require("typescript");
9
+ const path_1 = require("path");
10
+ const core_1 = require("@angular-devkit/core");
11
+ const schematics_1 = require("@angular-devkit/schematics");
12
+ const _1 = require(".");
13
+ const ast_utils_1 = require("./ast-utils");
14
+ function getAppModulePath(host, mainPath) {
15
+ const moduleRelativePath = findBootstrapModulePath(host, mainPath);
16
+ const mainDir = (0, path_1.dirname)(mainPath);
17
+ const modulePath = (0, core_1.normalize)(`/${mainDir}/${moduleRelativePath}.ts`);
18
+ return modulePath;
19
+ }
20
+ exports.getAppModulePath = getAppModulePath;
21
+ function findBootstrapModuleCall(host, mainPath) {
22
+ const sourceText = (0, _1.fileContent)(host, mainPath);
23
+ const source = ts.createSourceFile(mainPath, sourceText, ts.ScriptTarget.Latest, true);
24
+ const calls = (0, ast_utils_1.nodesByKind)(source, ts.SyntaxKind.CallExpression)
25
+ .filter(call => (0, ast_utils_1.findNode)(call, ts.SyntaxKind.Identifier, 'bootstrapModule'));
26
+ return calls[calls.length - 1];
27
+ }
28
+ exports.findBootstrapModuleCall = findBootstrapModuleCall;
29
+ function findBootstrapModulePath(host, mainPath) {
30
+ const bootstrapCall = findBootstrapModuleCall(host, mainPath);
31
+ if (!bootstrapCall) {
32
+ throw new schematics_1.SchematicsException('Bootstrap call not found');
33
+ }
34
+ const bootstrapModule = bootstrapCall.arguments[0];
35
+ const mainBuffer = host.read(mainPath);
36
+ if (!mainBuffer) {
37
+ throw new schematics_1.SchematicsException(`Client app main file (${mainPath}) not found`);
38
+ }
39
+ const mainText = mainBuffer.toString('utf-8');
40
+ const source = ts.createSourceFile(mainPath, mainText, ts.ScriptTarget.Latest, true);
41
+ const allImports = (0, ast_utils_1.nodesByKind)(source, ts.SyntaxKind.ImportDeclaration);
42
+ const bootstrapModuleRelativePath = allImports
43
+ .filter(node => node.kind === ts.SyntaxKind.ImportDeclaration)
44
+ .filter(imp => {
45
+ return (0, ast_utils_1.findNode)(imp, ts.SyntaxKind.Identifier, bootstrapModule.getText());
46
+ })
47
+ .map((imp) => {
48
+ const modulePathStringLiteral = imp.moduleSpecifier;
49
+ return modulePathStringLiteral.text;
50
+ })[0];
51
+ return bootstrapModuleRelativePath;
52
+ }
53
+ exports.findBootstrapModulePath = findBootstrapModulePath;
54
+ //# sourceMappingURL=bootstrap-module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bootstrap-module.js","sourceRoot":"","sources":["../../../../../libs/schematics/src/utils/bootstrap-module.ts"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CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;IAEnD,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACvC,IAAI,CAAC,UAAU,EAAE;QACf,MAAM,IAAI,gCAAmB,CAAC,yBAAyB,QAAQ,aAAa,CAAC,CAAC;KAC/E;IACD,MAAM,QAAQ,GAAG,UAAU,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IAC9C,MAAM,MAAM,GAAG,EAAE,CAAC,gBAAgB,CAAC,QAAQ,EAAE,QAAQ,EAAE,EAAE,CAAC,YAAY,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IACrF,MAAM,UAAU,GAAG,IAAA,uBAAW,EAAC,MAAM,EAAE,EAAE,CAAC,UAAU,CAAC,iBAAiB,CAAC,CAAC;IACxE,MAAM,2BAA2B,GAAG,UAAU;SAC3C,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,EAAE,CAAC,UAAU,CAAC,iBAAiB,CAAC;SAC7D,MAAM,CAAC,GAAG,CAAC,EAAE;QACZ,OAAO,IAAA,oBAAQ,EAAC,GAAG,EAAE,EAAE,CAAC,UAAU,CAAC,UAAU,EAAE,eAAe,CAAC,OAAO,EAAE,CAAC,CAAC;IAC5E,CAAC,CAAC;SACD,GAAG,CAAC,CAAC,GAAyB,EAAE,EAAE;QACjC,MAAM,uBAAuB,GAAsB,GAAG,CAAC,eAAe,CAAC;QAEvE,OAAO,uBAAuB,CAAC,IAAI,CAAC;IACtC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAER,OAAO,2BAA2B,CAAC;AACrC,CAAC;AA5BH,0DA4BG"}
@@ -0,0 +1,25 @@
1
+ /**-----------------------------------------------------------------------------------------
2
+ * Copyright © 2022 Progress Software Corporation. All rights reserved.
3
+ * Licensed under commercial license. See LICENSE.md in the project root for more information
4
+ *-------------------------------------------------------------------------------------------*/
5
+ import { Path } from '@angular-devkit/core';
6
+ import { Tree } from '@angular-devkit/schematics';
7
+ export interface ModuleOptions {
8
+ module?: string;
9
+ name?: string;
10
+ flat?: boolean;
11
+ path?: string;
12
+ skipImport?: boolean;
13
+ }
14
+ /**
15
+ * Find the module referred by a set of options passed to the schematics.
16
+ */
17
+ export declare function findModule(host: Tree, options: ModuleOptions): Path | undefined;
18
+ /**
19
+ * Function to find the "closest" module to a generated file's path.
20
+ */
21
+ export declare function resolveModule(host: Tree, generateDir: string): Path;
22
+ /**
23
+ * Build a relative path from one file path to another file path.
24
+ */
25
+ export declare function buildRelativePath(from: string, to: string): string;