@c8y/devkit 1019.0.3

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 (196) hide show
  1. package/README.md +13 -0
  2. package/dist/builders.json +29 -0
  3. package/dist/index.d.ts +6 -0
  4. package/dist/index.js +11 -0
  5. package/dist/index.js.map +1 -0
  6. package/dist/options.d.ts +2 -0
  7. package/dist/options.js +6 -0
  8. package/dist/options.js.map +1 -0
  9. package/dist/src/builders/BuilderOptions.d.ts +90 -0
  10. package/dist/src/builders/BuilderOptions.js +3 -0
  11. package/dist/src/builders/BuilderOptions.js.map +1 -0
  12. package/dist/src/builders/browser/index.d.ts +2 -0
  13. package/dist/src/builders/browser/index.js +17 -0
  14. package/dist/src/builders/browser/index.js.map +1 -0
  15. package/dist/src/builders/browser/schema.json +606 -0
  16. package/dist/src/builders/compile-i18n/compile-i18n-builder.d.ts +5 -0
  17. package/dist/src/builders/compile-i18n/compile-i18n-builder.js +88 -0
  18. package/dist/src/builders/compile-i18n/compile-i18n-builder.js.map +1 -0
  19. package/dist/src/builders/compile-i18n/schema.json +24 -0
  20. package/dist/src/builders/create-schema.d.ts +1 -0
  21. package/dist/src/builders/create-schema.js +32 -0
  22. package/dist/src/builders/create-schema.js.map +1 -0
  23. package/dist/src/builders/deploy/Deploy.model.d.ts +30 -0
  24. package/dist/src/builders/deploy/Deploy.model.js +8 -0
  25. package/dist/src/builders/deploy/Deploy.model.js.map +1 -0
  26. package/dist/src/builders/deploy/app-as-zip-file.d.ts +8 -0
  27. package/dist/src/builders/deploy/app-as-zip-file.js +74 -0
  28. package/dist/src/builders/deploy/app-as-zip-file.js.map +1 -0
  29. package/dist/src/builders/deploy/build-and-zip-app.d.ts +10 -0
  30. package/dist/src/builders/deploy/build-and-zip-app.js +105 -0
  31. package/dist/src/builders/deploy/build-and-zip-app.js.map +1 -0
  32. package/dist/src/builders/deploy/deploy-builder.d.ts +5 -0
  33. package/dist/src/builders/deploy/deploy-builder.js +268 -0
  34. package/dist/src/builders/deploy/deploy-builder.js.map +1 -0
  35. package/dist/src/builders/deploy/helpers.d.ts +25 -0
  36. package/dist/src/builders/deploy/helpers.js +45 -0
  37. package/dist/src/builders/deploy/helpers.js.map +1 -0
  38. package/dist/src/builders/deploy/schema.json +42 -0
  39. package/dist/src/builders/dev-server/index.d.ts +2 -0
  40. package/dist/src/builders/dev-server/index.js +67 -0
  41. package/dist/src/builders/dev-server/index.js.map +1 -0
  42. package/dist/src/builders/dev-server/schema.json +120 -0
  43. package/dist/src/builders/extract-i18n/extract-i18n-builder.d.ts +5 -0
  44. package/dist/src/builders/extract-i18n/extract-i18n-builder.js +126 -0
  45. package/dist/src/builders/extract-i18n/extract-i18n-builder.js.map +1 -0
  46. package/dist/src/builders/extract-i18n/schema.json +30 -0
  47. package/dist/src/options.d.ts +82 -0
  48. package/dist/src/options.js +98 -0
  49. package/dist/src/options.js.map +1 -0
  50. package/dist/src/schematics/collection.json +9 -0
  51. package/dist/src/schematics/ng-add/configs/angular-json.d.ts +28 -0
  52. package/dist/src/schematics/ng-add/configs/angular-json.js +93 -0
  53. package/dist/src/schematics/ng-add/configs/angular-json.js.map +1 -0
  54. package/dist/src/schematics/ng-add/configs/app-module.d.ts +3 -0
  55. package/dist/src/schematics/ng-add/configs/app-module.js +13 -0
  56. package/dist/src/schematics/ng-add/configs/app-module.js.map +1 -0
  57. package/dist/src/schematics/ng-add/configs/app-routing.d.ts +2 -0
  58. package/dist/src/schematics/ng-add/configs/app-routing.js +16 -0
  59. package/dist/src/schematics/ng-add/configs/app-routing.js.map +1 -0
  60. package/dist/src/schematics/ng-add/configs/index-html.d.ts +2 -0
  61. package/dist/src/schematics/ng-add/configs/index-html.js +15 -0
  62. package/dist/src/schematics/ng-add/configs/index-html.js.map +1 -0
  63. package/dist/src/schematics/ng-add/configs/index.d.ts +2 -0
  64. package/dist/src/schematics/ng-add/configs/index.js +37 -0
  65. package/dist/src/schematics/ng-add/configs/index.js.map +1 -0
  66. package/dist/src/schematics/ng-add/configs/main.d.ts +2 -0
  67. package/dist/src/schematics/ng-add/configs/main.js +30 -0
  68. package/dist/src/schematics/ng-add/configs/main.js.map +1 -0
  69. package/dist/src/schematics/ng-add/configs/ng1.d.ts +3 -0
  70. package/dist/src/schematics/ng-add/configs/ng1.js +13 -0
  71. package/dist/src/schematics/ng-add/configs/ng1.js.map +1 -0
  72. package/dist/src/schematics/ng-add/configs/package-json.d.ts +17 -0
  73. package/dist/src/schematics/ng-add/configs/package-json.js +67 -0
  74. package/dist/src/schematics/ng-add/configs/package-json.js.map +1 -0
  75. package/dist/src/schematics/ng-add/configs/translation.d.ts +2 -0
  76. package/dist/src/schematics/ng-add/configs/translation.js +36 -0
  77. package/dist/src/schematics/ng-add/configs/translation.js.map +1 -0
  78. package/dist/src/schematics/ng-add/configs/tsconfig-app-json.d.ts +2 -0
  79. package/dist/src/schematics/ng-add/configs/tsconfig-app-json.js +21 -0
  80. package/dist/src/schematics/ng-add/configs/tsconfig-app-json.js.map +1 -0
  81. package/dist/src/schematics/ng-add/configs/tsconfig-json.d.ts +2 -0
  82. package/dist/src/schematics/ng-add/configs/tsconfig-json.js +19 -0
  83. package/dist/src/schematics/ng-add/configs/tsconfig-json.js.map +1 -0
  84. package/dist/src/schematics/ng-add/index.d.ts +4 -0
  85. package/dist/src/schematics/ng-add/index.js +93 -0
  86. package/dist/src/schematics/ng-add/index.js.map +1 -0
  87. package/dist/src/schematics/ng-add/model.d.ts +19 -0
  88. package/dist/src/schematics/ng-add/model.js +3 -0
  89. package/dist/src/schematics/ng-add/model.js.map +1 -0
  90. package/dist/src/schematics/ng-add/ng-add.json +18 -0
  91. package/dist/src/schematics/ng-add/utils.d.ts +13 -0
  92. package/dist/src/schematics/ng-add/utils.js +32 -0
  93. package/dist/src/schematics/ng-add/utils.js.map +1 -0
  94. package/dist/src/utils/locale-compiler.d.ts +48 -0
  95. package/dist/src/utils/locale-compiler.js +83 -0
  96. package/dist/src/utils/locale-compiler.js.map +1 -0
  97. package/dist/src/utils/locale-json-paths.d.ts +19 -0
  98. package/dist/src/utils/locale-json-paths.js +63 -0
  99. package/dist/src/utils/locale-json-paths.js.map +1 -0
  100. package/dist/src/utils/locale-utils.d.ts +24 -0
  101. package/dist/src/utils/locale-utils.js +104 -0
  102. package/dist/src/utils/locale-utils.js.map +1 -0
  103. package/dist/src/utils/package-config.d.ts +1 -0
  104. package/dist/src/utils/package-config.js +13 -0
  105. package/dist/src/utils/package-config.js.map +1 -0
  106. package/dist/src/webpack/ApplicationOptions.d.ts +344 -0
  107. package/dist/src/webpack/ApplicationOptions.js +3 -0
  108. package/dist/src/webpack/ApplicationOptions.js.map +1 -0
  109. package/dist/src/webpack/BuildDefaults.d.ts +10 -0
  110. package/dist/src/webpack/BuildDefaults.js +15 -0
  111. package/dist/src/webpack/BuildDefaults.js.map +1 -0
  112. package/dist/src/webpack/EnvironmentOptions.d.ts +132 -0
  113. package/dist/src/webpack/EnvironmentOptions.js +15 -0
  114. package/dist/src/webpack/EnvironmentOptions.js.map +1 -0
  115. package/dist/src/webpack/config/babel.d.ts +2 -0
  116. package/dist/src/webpack/config/babel.js +65 -0
  117. package/dist/src/webpack/config/babel.js.map +1 -0
  118. package/dist/src/webpack/config/base.d.ts +27 -0
  119. package/dist/src/webpack/config/base.js +125 -0
  120. package/dist/src/webpack/config/base.js.map +1 -0
  121. package/dist/src/webpack/config/development.d.ts +4 -0
  122. package/dist/src/webpack/config/development.js +37 -0
  123. package/dist/src/webpack/config/development.js.map +1 -0
  124. package/dist/src/webpack/config/extra.d.ts +3 -0
  125. package/dist/src/webpack/config/extra.js +24 -0
  126. package/dist/src/webpack/config/extra.js.map +1 -0
  127. package/dist/src/webpack/config/favicon.d.ts +2 -0
  128. package/dist/src/webpack/config/favicon.js +20 -0
  129. package/dist/src/webpack/config/favicon.js.map +1 -0
  130. package/dist/src/webpack/config/federation.d.ts +3 -0
  131. package/dist/src/webpack/config/federation.js +66 -0
  132. package/dist/src/webpack/config/federation.js.map +1 -0
  133. package/dist/src/webpack/config/legacy.d.ts +2 -0
  134. package/dist/src/webpack/config/legacy.js +72 -0
  135. package/dist/src/webpack/config/legacy.js.map +1 -0
  136. package/dist/src/webpack/config/plugin.d.ts +5 -0
  137. package/dist/src/webpack/config/plugin.js +89 -0
  138. package/dist/src/webpack/config/plugin.js.map +1 -0
  139. package/dist/src/webpack/config/production.d.ts +3 -0
  140. package/dist/src/webpack/config/production.js +30 -0
  141. package/dist/src/webpack/config/production.js.map +1 -0
  142. package/dist/src/webpack/config/styles.d.ts +3 -0
  143. package/dist/src/webpack/config/styles.js +54 -0
  144. package/dist/src/webpack/config/styles.js.map +1 -0
  145. package/dist/src/webpack/config/translation.d.ts +2 -0
  146. package/dist/src/webpack/config/translation.js +23 -0
  147. package/dist/src/webpack/config/translation.js.map +1 -0
  148. package/dist/src/webpack/loaders/loader-data.d.ts +1 -0
  149. package/dist/src/webpack/loaders/loader-data.js +53 -0
  150. package/dist/src/webpack/loaders/loader-data.js.map +1 -0
  151. package/dist/src/webpack/loaders/loader-less.d.ts +1 -0
  152. package/dist/src/webpack/loaders/loader-less.js +23 -0
  153. package/dist/src/webpack/loaders/loader-less.js.map +1 -0
  154. package/dist/src/webpack/loaders/loader-manifest.d.ts +1 -0
  155. package/dist/src/webpack/loaders/loader-manifest.js +88 -0
  156. package/dist/src/webpack/loaders/loader-manifest.js.map +1 -0
  157. package/dist/src/webpack/loaders/loader-ngtemplate.d.ts +1 -0
  158. package/dist/src/webpack/loaders/loader-ngtemplate.js +16 -0
  159. package/dist/src/webpack/loaders/loader-ngtemplate.js.map +1 -0
  160. package/dist/src/webpack/loaders/loader-pluginpath.d.ts +1 -0
  161. package/dist/src/webpack/loaders/loader-pluginpath.js +10 -0
  162. package/dist/src/webpack/loaders/loader-pluginpath.js.map +1 -0
  163. package/dist/src/webpack/loaders/loader-po.d.ts +3 -0
  164. package/dist/src/webpack/loaders/loader-po.js +9 -0
  165. package/dist/src/webpack/loaders/loader-po.js.map +1 -0
  166. package/dist/src/webpack/plugin/index-content.d.ts +2 -0
  167. package/dist/src/webpack/plugin/index-content.js +113 -0
  168. package/dist/src/webpack/plugin/index-content.js.map +1 -0
  169. package/dist/src/webpack/plugin/locales.d.ts +6 -0
  170. package/dist/src/webpack/plugin/locales.js +746 -0
  171. package/dist/src/webpack/plugin/locales.js.map +1 -0
  172. package/dist/src/webpack/plugin/plugin.d.ts +259 -0
  173. package/dist/src/webpack/plugin/plugin.js +286 -0
  174. package/dist/src/webpack/plugin/plugin.js.map +1 -0
  175. package/dist/src/webpack/plugin/translation-aggregation-plugin.d.ts +80 -0
  176. package/dist/src/webpack/plugin/translation-aggregation-plugin.js +152 -0
  177. package/dist/src/webpack/plugin/translation-aggregation-plugin.js.map +1 -0
  178. package/dist/src/webpack/plugin/translation-data-store.d.ts +27 -0
  179. package/dist/src/webpack/plugin/translation-data-store.js +37 -0
  180. package/dist/src/webpack/plugin/translation-data-store.js.map +1 -0
  181. package/dist/src/webpack/utils/federationUtils.d.ts +26 -0
  182. package/dist/src/webpack/utils/federationUtils.js +234 -0
  183. package/dist/src/webpack/utils/federationUtils.js.map +1 -0
  184. package/dist/src/webpack/utils/helpers.d.ts +45 -0
  185. package/dist/src/webpack/utils/helpers.js +137 -0
  186. package/dist/src/webpack/utils/helpers.js.map +1 -0
  187. package/dist/src/webpack/utils/index.d.ts +1 -0
  188. package/dist/src/webpack/utils/index.js +5 -0
  189. package/dist/src/webpack/utils/index.js.map +1 -0
  190. package/dist/src/webpack/utils/legacy-manifest-resolver.d.ts +4 -0
  191. package/dist/src/webpack/utils/legacy-manifest-resolver.js +27 -0
  192. package/dist/src/webpack/utils/legacy-manifest-resolver.js.map +1 -0
  193. package/dist/src/webpack/utils/proxy.d.ts +2 -0
  194. package/dist/src/webpack/utils/proxy.js +39 -0
  195. package/dist/src/webpack/utils/proxy.js.map +1 -0
  196. package/package.json +99 -0
@@ -0,0 +1,9 @@
1
+ {
2
+ "schematics": {
3
+ "ng-add": {
4
+ "description": "Adds Cumulocity IoT application to the project.",
5
+ "factory": "./ng-add/index#ngAdd",
6
+ "schema": "./ng-add/ng-add.json"
7
+ }
8
+ }
9
+ }
@@ -0,0 +1,28 @@
1
+ import { ProjectDefinition } from '@angular-devkit/core/src/workspace';
2
+ import { Tree } from '@angular-devkit/schematics';
3
+ import { CumulocityNgAddOptions } from '../model';
4
+ export declare const ANGULAR_JSON = "angular.json";
5
+ interface AngularJson {
6
+ projects: Record<string, ProjectDefinition>;
7
+ }
8
+ /** Adds custom builders and adjust project settings. */
9
+ export declare function updateAngularJson(host: Tree, options: CumulocityNgAddOptions): Tree;
10
+ /**
11
+ * Retrieves the project name from the Angular configuration. If the project name is not provided,
12
+ * it defaults to the first project listed in the Angular configuration.
13
+ *
14
+ * @param {Tree} host - The Tree representing the current state of the source files.
15
+ * @param {string} projectName - The desired project name. Optional.
16
+ * @returns {string} The resolved project name.
17
+ * @throws {SchematicsException} Throws an error if the project name cannot be determined.
18
+ */
19
+ export declare function getProjectName(host: Tree, projectName: string): string;
20
+ /**
21
+ * Retrieves and parses the `angular.json` configuration file.
22
+ *
23
+ * @param {Tree} host - The Tree representing the current state of the source files.
24
+ * @returns {AngularJson} The parsed contents of the `angular.json` file.
25
+ * @throws {SchematicsException} Throws an error if the `angular.json` file does not exist.
26
+ */
27
+ export declare function getAngularJson(host: Tree): AngularJson;
28
+ export {};
@@ -0,0 +1,93 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getAngularJson = exports.getProjectName = exports.updateAngularJson = exports.ANGULAR_JSON = void 0;
4
+ const schematics_1 = require("@angular-devkit/schematics");
5
+ exports.ANGULAR_JSON = 'angular.json';
6
+ /** Adds custom builders and adjust project settings. */
7
+ function updateAngularJson(host, options) {
8
+ if (!host.exists(exports.ANGULAR_JSON)) {
9
+ throw new schematics_1.SchematicsException(`The file ${exports.ANGULAR_JSON} doesn't exists...`);
10
+ }
11
+ const sourceText = host.read(exports.ANGULAR_JSON).toString('utf-8');
12
+ const json = JSON.parse(sourceText);
13
+ const projectName = getProjectName(host, options.project);
14
+ if (!projectName) {
15
+ throw new schematics_1.SchematicsException(`Project name is not defined...`);
16
+ }
17
+ const project = json.projects[projectName];
18
+ // Add custom builders
19
+ project.architect.build.builder = '@c8y/devkit:build';
20
+ project.architect.serve.builder = '@c8y/devkit:dev-server';
21
+ project.architect.deploy = {
22
+ builder: '@c8y/devkit:deploy',
23
+ configurations: {
24
+ production: {
25
+ browserTarget: `${projectName}:build:production`
26
+ },
27
+ development: {
28
+ browserTarget: `${projectName}:build:development`
29
+ }
30
+ },
31
+ defaultConfiguration: 'production'
32
+ };
33
+ project.architect['extract-i18n'] = {
34
+ builder: '@c8y/devkit:extract-i18n'
35
+ };
36
+ project.architect['compile-i18n'] = {
37
+ builder: '@c8y/devkit:compile-i18n'
38
+ };
39
+ // Adjust settings
40
+ project.architect.build.options.aot = false;
41
+ project.architect.build.configurations.production.buildOptimizer = false;
42
+ // Added to remove warning: CommonJS or AMD dependencies can cause optimization bailouts.
43
+ // https://angular.io/guide/build#configuring-commonjs-dependencies
44
+ project.architect.build.options.allowedCommonJsDependencies = [
45
+ 'regenerator-runtime/runtime',
46
+ '@cordobo/qrcode',
47
+ 'zone.js/dist/zone',
48
+ 'chroma-js'
49
+ ];
50
+ /**
51
+ * TODO: try to fix it, right now we can't add path to index.html, as webpack starts to break.
52
+ * It complains about multiple sources trying to write to index.html
53
+ */
54
+ delete project.architect.build.options.index;
55
+ host.overwrite('angular.json', JSON.stringify(json, null, 2));
56
+ return host;
57
+ }
58
+ exports.updateAngularJson = updateAngularJson;
59
+ /**
60
+ * Retrieves the project name from the Angular configuration. If the project name is not provided,
61
+ * it defaults to the first project listed in the Angular configuration.
62
+ *
63
+ * @param {Tree} host - The Tree representing the current state of the source files.
64
+ * @param {string} projectName - The desired project name. Optional.
65
+ * @returns {string} The resolved project name.
66
+ * @throws {SchematicsException} Throws an error if the project name cannot be determined.
67
+ */
68
+ function getProjectName(host, projectName) {
69
+ const json = getAngularJson(host);
70
+ const pN = projectName || Object.keys(json.projects)[0];
71
+ if (!pN) {
72
+ throw new schematics_1.SchematicsException(`Project name is not defined...`);
73
+ }
74
+ return pN;
75
+ }
76
+ exports.getProjectName = getProjectName;
77
+ /**
78
+ * Retrieves and parses the `angular.json` configuration file.
79
+ *
80
+ * @param {Tree} host - The Tree representing the current state of the source files.
81
+ * @returns {AngularJson} The parsed contents of the `angular.json` file.
82
+ * @throws {SchematicsException} Throws an error if the `angular.json` file does not exist.
83
+ */
84
+ function getAngularJson(host) {
85
+ if (!host.exists(exports.ANGULAR_JSON)) {
86
+ throw new schematics_1.SchematicsException(`The file ${exports.ANGULAR_JSON} doesn't exists...`);
87
+ }
88
+ const sourceText = host.read(exports.ANGULAR_JSON).toString('utf-8');
89
+ const json = JSON.parse(sourceText);
90
+ return json;
91
+ }
92
+ exports.getAngularJson = getAngularJson;
93
+ //# sourceMappingURL=angular-json.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"angular-json.js","sourceRoot":"","sources":["../../../../../src/schematics/ng-add/configs/angular-json.ts"],"names":[],"mappings":";;;AACA,2DAAuE;AAE1D,QAAA,YAAY,GAAG,cAAc,CAAC;AAM3C,wDAAwD;AACxD,SAAgB,iBAAiB,CAAC,IAAU,EAAE,OAA+B;IAC3E,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,oBAAY,CAAC,EAAE;QAC9B,MAAM,IAAI,gCAAmB,CAAC,YAAY,oBAAY,oBAAoB,CAAC,CAAC;KAC7E;IACD,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,oBAAY,CAAE,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IAC9D,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,CAAgB,CAAC;IACnD,MAAM,WAAW,GAAG,cAAc,CAAC,IAAI,EAAE,OAAO,CAAC,OAAiB,CAAC,CAAC;IAEpE,IAAI,CAAC,WAA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AI,EAAE,CAAC,CAAC,CAAC,CAAC;IAC9D,OAAO,IAAI,CAAC;AACd,CAAC;AAxDD,8CAwDC;AAED;;;;;;;;GAQG;AACH,SAAgB,cAAc,CAAC,IAAU,EAAE,WAAmB;IAC5D,MAAM,IAAI,GAAG,cAAc,CAAC,IAAI,CAAC,CAAC;IAClC,MAAM,EAAE,GAAG,WAAW,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;IAExD,IAAI,CAAC,EAAE,EAAE;QACP,MAAM,IAAI,gCAAmB,CAAC,gCAAgC,CAAC,CAAC;KACjE;IACD,OAAO,EAAE,CAAC;AACZ,CAAC;AARD,wCAQC;AAED;;;;;;GAMG;AACH,SAAgB,cAAc,CAAC,IAAU;IACvC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,oBAAY,CAAC,EAAE;QAC9B,MAAM,IAAI,gCAAmB,CAAC,YAAY,oBAAY,oBAAoB,CAAC,CAAC;KAC7E;IACD,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,oBAAY,CAAE,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IAC9D,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,CAAgB,CAAC;IACnD,OAAO,IAAI,CAAC;AACd,CAAC;AAPD,wCAOC"}
@@ -0,0 +1,3 @@
1
+ import { Tree } from '@angular-devkit/schematics';
2
+ import { ApplicationSetup } from '../model';
3
+ export declare function updateAppModule(host: Tree, projectSrcRoot: string, appModule: ApplicationSetup['appModule']): void;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.updateAppModule = void 0;
4
+ const schematics_1 = require("@angular-devkit/schematics");
5
+ function updateAppModule(host, projectSrcRoot, appModule) {
6
+ const appModulePath = `${projectSrcRoot}/app/app.module.ts`;
7
+ if (!host.exists(appModulePath)) {
8
+ throw new schematics_1.SchematicsException(`The file ${appModulePath} doesn't exists...`);
9
+ }
10
+ host.overwrite(appModulePath, appModule);
11
+ }
12
+ exports.updateAppModule = updateAppModule;
13
+ //# sourceMappingURL=app-module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app-module.js","sourceRoot":"","sources":["../../../../../src/schematics/ng-add/configs/app-module.ts"],"names":[],"mappings":";;;AAAA,2DAAuE;AAGvE,SAAgB,eAAe,CAC7B,IAAU,EACV,cAAsB,EACtB,SAAwC;IAExC,MAAM,aAAa,GAAG,GAAG,cAAc,oBAAoB,CAAC;IAE5D,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,EAAE;QAC/B,MAAM,IAAI,gCAAmB,CAAC,YAAY,aAAa,oBAAoB,CAAC,CAAC;KAC9E;IACD,IAAI,CAAC,SAAS,CAAC,aAAa,EAAE,SAAmB,CAAC,CAAC;AACrD,CAAC;AAXD,0CAWC"}
@@ -0,0 +1,2 @@
1
+ import { Tree } from '@angular-devkit/schematics';
2
+ export declare function hashRouteModule(host: Tree, projectSrcRoot: string): void;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.hashRouteModule = void 0;
4
+ const schematics_1 = require("@angular-devkit/schematics");
5
+ function hashRouteModule(host, projectSrcRoot) {
6
+ const routingModulePath = `${projectSrcRoot}/app/app-routing.module.ts`;
7
+ if (!host.exists(routingModulePath)) {
8
+ throw new schematics_1.SchematicsException(`Cannot find application routing module. To add @c8y/cli,
9
+ application routing module should be present in app/app-routing.module.ts.`);
10
+ }
11
+ const content = host.read(routingModulePath).toString();
12
+ const replacedContent = content.replace(/RouterModule\.forRoot\([^)]+\)/, 'RouterModule.forRoot(routes, { useHash: true })');
13
+ host.overwrite(routingModulePath, replacedContent);
14
+ }
15
+ exports.hashRouteModule = hashRouteModule;
16
+ //# sourceMappingURL=app-routing.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app-routing.js","sourceRoot":"","sources":["../../../../../src/schematics/ng-add/configs/app-routing.ts"],"names":[],"mappings":";;;AAAA,2DAAuE;AAEvE,SAAgB,eAAe,CAAC,IAAU,EAAE,cAAsB;IAChE,MAAM,iBAAiB,GAAG,GAAG,cAAc,4BAA4B,CAAC;IACxE,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC,EAAE;QACnC,MAAM,IAAI,gCAAmB,CAAC;+EAC6C,CAAC,CAAC;KAC9E;IACD,MAAM,OAAO,GAAI,IAAI,CAAC,IAAI,CAAC,iBAAiB,CAAS,CAAC,QAAQ,EAAE,CAAC;IACjE,MAAM,eAAe,GAAG,OAAO,CAAC,OAAO,CACrC,gCAAgC,EAChC,iDAAiD,CAClD,CAAC;IACF,IAAI,CAAC,SAAS,CAAC,iBAAiB,EAAE,eAAe,CAAC,CAAC;AACrD,CAAC;AAZD,0CAYC"}
@@ -0,0 +1,2 @@
1
+ import { Tree } from '@angular-devkit/schematics';
2
+ export declare function indexHtml(host: Tree, projectSrcRoot: string): void;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.indexHtml = void 0;
4
+ const schematics_1 = require("@angular-devkit/schematics");
5
+ const INDEX_HTML = 'index.html';
6
+ const index_content_1 = require("../../../webpack/plugin/index-content");
7
+ function indexHtml(host, projectSrcRoot) {
8
+ const indexHtmlPath = `${projectSrcRoot}/${INDEX_HTML}`;
9
+ if (!host.exists(indexHtmlPath)) {
10
+ throw new schematics_1.SchematicsException(`The file ${INDEX_HTML} doesn't exists...`);
11
+ }
12
+ host.overwrite(indexHtmlPath, index_content_1.default);
13
+ }
14
+ exports.indexHtml = indexHtml;
15
+ //# sourceMappingURL=index-html.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-html.js","sourceRoot":"","sources":["../../../../../src/schematics/ng-add/configs/index-html.ts"],"names":[],"mappings":";;;AAAA,2DAAuE;AAEvE,MAAM,UAAU,GAAG,YAAY,CAAC;AAChC,yEAAuE;AAEvE,SAAgB,SAAS,CAAC,IAAU,EAAE,cAAsB;IAC1D,MAAM,aAAa,GAAG,GAAG,cAAc,IAAI,UAAU,EAAE,CAAC;IACxD,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,EAAE;QAC/B,MAAM,IAAI,gCAAmB,CAAC,YAAY,UAAU,oBAAoB,CAAC,CAAC;KAC3E;IACD,IAAI,CAAC,SAAS,CAAC,aAAa,EAAE,uBAAkB,CAAC,CAAC;AACpD,CAAC;AAND,8BAMC"}
@@ -0,0 +1,2 @@
1
+ import { Tree } from '@angular-devkit/schematics';
2
+ export declare function addApplicationBootstrap(host: Tree, projectSrcRoot: string): void;
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.addApplicationBootstrap = void 0;
4
+ const MAIN_TS = 'main.ts';
5
+ const INDEX = `
6
+ // import './i18n';
7
+ import {
8
+ applyOptions,
9
+ loadOptions,
10
+ loginOptions,
11
+ } from '@c8y/bootstrap';
12
+
13
+ const barHolder: HTMLElement = document.querySelector('body > .init-load');
14
+ export const removeProgress = () =>
15
+ barHolder && barHolder.parentNode.removeChild(barHolder);
16
+
17
+ applicationSetup();
18
+
19
+ async function applicationSetup() {
20
+ const options = await applyOptions({
21
+ ...(await loadOptions()),
22
+ ...((await loginOptions()) as object),
23
+ });
24
+
25
+ const mod = await import('./main');
26
+ const bootstrapApp =
27
+ mod.bootstrap || (window as any).bootstrap || (() => null);
28
+
29
+ return Promise.resolve(bootstrapApp(options)).then(removeProgress);
30
+ }
31
+ `;
32
+ function addApplicationBootstrap(host, projectSrcRoot) {
33
+ const ng1Path = `${projectSrcRoot}/${MAIN_TS}`;
34
+ host.create(ng1Path, INDEX);
35
+ }
36
+ exports.addApplicationBootstrap = addApplicationBootstrap;
37
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/schematics/ng-add/configs/index.ts"],"names":[],"mappings":";;;AACA,MAAM,OAAO,GAAG,SAAS,CAAC;AAC1B,MAAM,KAAK,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;CA0Bb,CAAC;AAEF,SAAgB,uBAAuB,CAAC,IAAU,EAAE,cAAsB;IACxE,MAAM,OAAO,GAAG,GAAG,cAAc,IAAI,OAAO,EAAE,CAAC;IAC/C,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;AAC9B,CAAC;AAHD,0DAGC"}
@@ -0,0 +1,2 @@
1
+ import { Tree } from '@angular-devkit/schematics';
2
+ export declare function updateMain(host: Tree, projectSrcRoot: string): void;
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.updateMain = void 0;
4
+ const schematics_1 = require("@angular-devkit/schematics");
5
+ const MAIN_TS = 'main.ts';
6
+ const MAIN = `import './ng1';
7
+ import { enableProdMode } from '@angular/core';
8
+ import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
9
+ import { AppModule } from './app/app.module';
10
+
11
+ declare const __MODE__: string;
12
+ if (__MODE__ === 'production') {
13
+ enableProdMode();
14
+ }
15
+
16
+ export function bootstrap(options: any = {}) {
17
+ return platformBrowserDynamic()
18
+ .bootstrapModule(AppModule)
19
+ .catch(err => console.log(err));
20
+ }
21
+ `;
22
+ function updateMain(host, projectSrcRoot) {
23
+ const mainPath = `${projectSrcRoot}/${MAIN_TS}`;
24
+ if (!host.exists(mainPath)) {
25
+ throw new schematics_1.SchematicsException(`The file ${mainPath} doesn't exists...`);
26
+ }
27
+ host.overwrite(mainPath, MAIN);
28
+ }
29
+ exports.updateMain = updateMain;
30
+ //# sourceMappingURL=main.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"main.js","sourceRoot":"","sources":["../../../../../src/schematics/ng-add/configs/main.ts"],"names":[],"mappings":";;;AAAA,2DAAuE;AAEvE,MAAM,OAAO,GAAG,SAAS,CAAC;AAE1B,MAAM,IAAI,GAAG;;;;;;;;;;;;;;;CAeZ,CAAC;AAEF,SAAgB,UAAU,CAAC,IAAU,EAAE,cAAsB;IAC3D,MAAM,QAAQ,GAAG,GAAG,cAAc,IAAI,OAAO,EAAE,CAAC;IAChD,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE;QAC1B,MAAM,IAAI,gCAAmB,CAAC,YAAY,QAAQ,oBAAoB,CAAC,CAAC;KACzE;IACD,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;AACjC,CAAC;AAND,gCAMC"}
@@ -0,0 +1,3 @@
1
+ import { Tree } from '@angular-devkit/schematics';
2
+ export declare const NG1_TS = "ng1.ts";
3
+ export declare function addNg1(host: Tree, projectSrcRoot: string, ng1Modules: string): void;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.addNg1 = exports.NG1_TS = void 0;
4
+ exports.NG1_TS = 'ng1.ts';
5
+ function addNg1(host, projectSrcRoot, ng1Modules) {
6
+ if (!ng1Modules) {
7
+ return;
8
+ }
9
+ const ng1Path = `${projectSrcRoot}/${exports.NG1_TS}`;
10
+ host.create(ng1Path, ng1Modules);
11
+ }
12
+ exports.addNg1 = addNg1;
13
+ //# sourceMappingURL=ng1.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ng1.js","sourceRoot":"","sources":["../../../../../src/schematics/ng-add/configs/ng1.ts"],"names":[],"mappings":";;;AAEa,QAAA,MAAM,GAAG,QAAQ,CAAC;AAE/B,SAAgB,MAAM,CAAC,IAAU,EAAE,cAAsB,EAAE,UAAkB;IAC3E,IAAI,CAAC,UAAU,EAAE;QACf,OAAO;KACR;IACD,MAAM,OAAO,GAAG,GAAG,cAAc,IAAI,cAAM,EAAE,CAAC;IAC9C,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;AACnC,CAAC;AAND,wBAMC"}
@@ -0,0 +1,17 @@
1
+ import { Tree } from '@angular-devkit/schematics';
2
+ import { Application } from '../model';
3
+ import { NodeDependencyType } from '@schematics/angular/utility/dependencies';
4
+ export declare const PACKAGE_JSON = "package.json";
5
+ export declare const ANGULAR_JSON = "angular.json";
6
+ interface Dependency {
7
+ name: string;
8
+ version: string;
9
+ type: NodeDependencyType;
10
+ }
11
+ /** Adds a package to the package.json in the given host tree. */
12
+ export declare function addPackageToPackageJson(host: Tree, dependency: Dependency): Tree;
13
+ /** Gets the version of the specified package by looking at the package.json in the given tree. */
14
+ export declare function getPackageVersionFromPackageJson(host: Tree, name: string): string | null;
15
+ /** Add application metadata to the package.json */
16
+ export declare function addApplicationMetadataToPackageJson(host: Tree, application: Application): void;
17
+ export {};
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.addApplicationMetadataToPackageJson = exports.getPackageVersionFromPackageJson = exports.addPackageToPackageJson = exports.ANGULAR_JSON = exports.PACKAGE_JSON = void 0;
4
+ const schematics_1 = require("@angular-devkit/schematics");
5
+ const dependencies_1 = require("@schematics/angular/utility/dependencies");
6
+ const utils_1 = require("../utils");
7
+ exports.PACKAGE_JSON = 'package.json';
8
+ exports.ANGULAR_JSON = 'angular.json';
9
+ const APPLICATION_OPTIONS_DEFAULTS = {
10
+ name: 'application',
11
+ contextPath: 'application',
12
+ key: 'application-application-key'
13
+ };
14
+ /** Adds a package to the package.json in the given host tree. */
15
+ function addPackageToPackageJson(host, dependency) {
16
+ if (!host.exists(exports.PACKAGE_JSON)) {
17
+ throw new schematics_1.SchematicsException(`The file ${exports.PACKAGE_JSON} doesn't exists...`);
18
+ }
19
+ const { name, version, type } = dependency;
20
+ const sourceText = host.read(exports.PACKAGE_JSON).toString('utf-8');
21
+ const json = JSON.parse(sourceText);
22
+ switch (type) {
23
+ case dependencies_1.NodeDependencyType.Dev:
24
+ if (!json[dependencies_1.NodeDependencyType.Dev]) {
25
+ json[dependencies_1.NodeDependencyType.Dev] = {};
26
+ }
27
+ if (!json[dependencies_1.NodeDependencyType.Dev][name]) {
28
+ json[dependencies_1.NodeDependencyType.Dev][name] = version;
29
+ json[dependencies_1.NodeDependencyType.Dev] = (0, utils_1.sortObjectByKeys)(json[dependencies_1.NodeDependencyType.Dev]);
30
+ }
31
+ break;
32
+ default:
33
+ if (!json[dependencies_1.NodeDependencyType.Default]) {
34
+ json[dependencies_1.NodeDependencyType.Default] = {};
35
+ }
36
+ if (!json[dependencies_1.NodeDependencyType.Default][name]) {
37
+ json[dependencies_1.NodeDependencyType.Default][name] = version;
38
+ json[dependencies_1.NodeDependencyType.Default] = (0, utils_1.sortObjectByKeys)(json[dependencies_1.NodeDependencyType.Default]);
39
+ }
40
+ break;
41
+ }
42
+ host.overwrite(exports.PACKAGE_JSON, JSON.stringify(json, null, 2));
43
+ return host;
44
+ }
45
+ exports.addPackageToPackageJson = addPackageToPackageJson;
46
+ /** Gets the version of the specified package by looking at the package.json in the given tree. */
47
+ function getPackageVersionFromPackageJson(host, name) {
48
+ if (!host.exists(exports.PACKAGE_JSON)) {
49
+ throw new schematics_1.SchematicsException(`The file ${exports.PACKAGE_JSON} doesn't exists...`);
50
+ }
51
+ const packageJson = JSON.parse(host.read(exports.PACKAGE_JSON).toString('utf8'));
52
+ if (packageJson.dependencies && packageJson.dependencies[name]) {
53
+ return packageJson.dependencies[name];
54
+ }
55
+ return null;
56
+ }
57
+ exports.getPackageVersionFromPackageJson = getPackageVersionFromPackageJson;
58
+ /** Add application metadata to the package.json */
59
+ function addApplicationMetadataToPackageJson(host, application) {
60
+ const packageJson = JSON.parse(host.read(exports.PACKAGE_JSON).toString('utf8'));
61
+ packageJson.c8y = {
62
+ application: { ...APPLICATION_OPTIONS_DEFAULTS, ...application }
63
+ };
64
+ host.overwrite(exports.PACKAGE_JSON, JSON.stringify(packageJson, null, 2));
65
+ }
66
+ exports.addApplicationMetadataToPackageJson = addApplicationMetadataToPackageJson;
67
+ //# sourceMappingURL=package-json.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"package-json.js","sourceRoot":"","sources":["../../../../../src/schematics/ng-add/configs/package-json.ts"],"names":[],"mappings":";;;AAAA,2DAAuE;AAEvE,2EAA8E;AAC9E,oCAA4C;AAE/B,QAAA,YAAY,GAAG,cAAc,CAAC;AAC9B,QAAA,YAAY,GAAG,cAAc,CAAC;AAE3C,MAAM,4BAA4B,GAAG;IACnC,IAAI,EAAE,aAAa;IACnB,WAAW,EAAE,aAAa;IAC1B,GAAG,EAAE,6BAA6B;CACnC,CAAC;AAmBF,iEAAiE;AACjE,SAAgB,uBAAuB,CAAC,IAAU,EAAE,UAAsB;IACxE,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,oBAAY,CAAC,EAAE;QAC9B,MAAM,IAAI,gCAAmB,CAAC,YAAY,oBAAY,oBAAoB,CAAC,CAAC;KAC7E;IACD,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,UAAU,CAAC;IAC3C,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,oBAAY,CAAE,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IAC9D,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,CAAgB,CAAC;IAEnD,QAAQ,IAAI,EAAE;QACZ,KAAK,iCAAkB,CAAC,GAAG;YACzB,IAAI,CAAC,IAAI,CAAC,iCAAkB,CAAC,GAAG,CAAC,EAAE;gBACjC,IAAI,CAAC,iCAAkB,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC;aACnC;YACD,IAAI,CAAC,IAAI,CAAC,iCAAkB,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE;gBACvC,IAAI,CAAC,iCAAkB,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC;gBAC7C,IAAI,CAAC,iCAAkB,CAAC,GAAG,CAAC,GAAG,IAAA,wBAAgB,EAA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IAAU,EAAE,WAAwB;IACtF,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,oBAAY,CAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAgB,CAAC;IACzF,WAAW,CAAC,GAAG,GAAG;QAChB,WAAW,EAAE,EAAE,GAAG,4BAA4B,EAAE,GAAG,WAAW,EAAE;KACjE,CAAC;IACF,IAAI,CAAC,SAAS,CAAC,oBAAY,EAAE,IAAI,CAAC,SAAS,CAAC,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;AACrE,CAAC;AAND,kFAMC"}
@@ -0,0 +1,2 @@
1
+ import { Tree } from '@angular-devkit/schematics';
2
+ export declare function addTranslation(host: Tree, projectSrcRoot: string): void;
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.addTranslation = void 0;
4
+ const schematics_1 = require("@angular-devkit/schematics");
5
+ const I18N_TS = 'i18n.ts';
6
+ const I18N_TRANSLATIONS = `
7
+ /**
8
+ * Internationalizing files in po format (https://en.wikipedia.org/wiki/Gettext#Translating)
9
+ * You can always add additional strings by adding your own po file. All po files are
10
+ * combined to one JSON file per language and are loaded if the specific language is needed.
11
+ */
12
+ import '@c8y/ngx-components/locales/de.po';
13
+ import '@c8y/ngx-components/locales/en.po';
14
+ import '@c8y/ngx-components/locales/es.po';
15
+ import '@c8y/ngx-components/locales/fr.po';
16
+ import '@c8y/ngx-components/locales/ja_JP.po';
17
+ import '@c8y/ngx-components/locales/ko.po';
18
+ import '@c8y/ngx-components/locales/nl.po';
19
+ import '@c8y/ngx-components/locales/pl.po';
20
+ import '@c8y/ngx-components/locales/pt_BR.po';
21
+ import '@c8y/ngx-components/locales/ru.po';
22
+ import '@c8y/ngx-components/locales/zh_CN.po';
23
+ import '@c8y/ngx-components/locales/zh_TW.po';
24
+ // import './locales/de.po'; // <- adding additional strings to the german translation.
25
+ `;
26
+ function addTranslation(host, projectSrcRoot) {
27
+ const appTranslationFilePath = `${projectSrcRoot}/${I18N_TS}`;
28
+ // TODO name of the main property from the config?
29
+ const mainFilePath = `${projectSrcRoot}/main.ts`;
30
+ if (!host.exists(mainFilePath)) {
31
+ throw new schematics_1.SchematicsException(`The file ${mainFilePath} doesn't exists...`);
32
+ }
33
+ host.create(appTranslationFilePath, I18N_TRANSLATIONS);
34
+ }
35
+ exports.addTranslation = addTranslation;
36
+ //# sourceMappingURL=translation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"translation.js","sourceRoot":"","sources":["../../../../../src/schematics/ng-add/configs/translation.ts"],"names":[],"mappings":";;;AAAA,2DAAuE;AAEvE,MAAM,OAAO,GAAG,SAAS,CAAC;AAE1B,MAAM,iBAAiB,GAAG;;;;;;;;;;;;;;;;;;;CAmBzB,CAAC;AAEF,SAAgB,cAAc,CAAC,IAAU,EAAE,cAAsB;IAC/D,MAAM,sBAAsB,GAAG,GAAG,cAAc,IAAI,OAAO,EAAE,CAAC;IAC9D,kDAAkD;IAClD,MAAM,YAAY,GAAG,GAAG,cAAc,UAAU,CAAC;IACjD,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,EAAE;QAC9B,MAAM,IAAI,gCAAmB,CAAC,YAAY,YAAY,oBAAoB,CAAC,CAAC;KAC7E;IACD,IAAI,CAAC,MAAM,CAAC,sBAAsB,EAAE,iBAAiB,CAAC,CAAC;AACzD,CAAC;AARD,wCAQC"}
@@ -0,0 +1,2 @@
1
+ import { Tree } from '@angular-devkit/schematics';
2
+ export declare function updateTsAppConfig(host: Tree): void;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.updateTsAppConfig = void 0;
4
+ const schematics_1 = require("@angular-devkit/schematics");
5
+ const typescript_1 = require("typescript");
6
+ const TSCONFIG_JSON = 'tsconfig.app.json';
7
+ function updateTsAppConfig(host) {
8
+ if (!host.exists(TSCONFIG_JSON)) {
9
+ throw new schematics_1.SchematicsException(`The file ${TSCONFIG_JSON} doesn't exists...`);
10
+ }
11
+ const sourceText = host.read(TSCONFIG_JSON).toString('utf-8');
12
+ const json = (0, typescript_1.parseConfigFileTextToJson)(TSCONFIG_JSON, sourceText);
13
+ // in monorepo we extend from the root tsconfig
14
+ // for ng-add apps, we need to extend the current one
15
+ json.config.extends = './tsconfig.json';
16
+ // In monorepo we need to include ngx-components, in ng-add cases not.
17
+ json.config.include = [json.config.include[0]];
18
+ host.overwrite(TSCONFIG_JSON, JSON.stringify(json.config, null, 2));
19
+ }
20
+ exports.updateTsAppConfig = updateTsAppConfig;
21
+ //# sourceMappingURL=tsconfig-app-json.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tsconfig-app-json.js","sourceRoot":"","sources":["../../../../../src/schematics/ng-add/configs/tsconfig-app-json.ts"],"names":[],"mappings":";;;AAAA,2DAAuE;AACvE,2CAAuD;AAEvD,MAAM,aAAa,GAAG,mBAAmB,CAAC;AAE1C,SAAgB,iBAAiB,CAAC,IAAU;IAC1C,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,EAAE;QAC/B,MAAM,IAAI,gCAAmB,CAAC,YAAY,aAAa,oBAAoB,CAAC,CAAC;KAC9E;IACD,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,aAAa,CAAE,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IAC/D,MAAM,IAAI,GAAG,IAAA,sCAAyB,EAAC,aAAa,EAAE,UAAU,CAAC,CAAC;IAElE,+CAA+C;IAC/C,qDAAqD;IACrD,IAAI,CAAC,MAAM,CAAC,OAAO,GAAG,iBAAiB,CAAC;IAExC,sEAAsE;IACtE,IAAI,CAAC,MAAM,CAAC,OAAO,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;IAE/C,IAAI,CAAC,SAAS,CAAC,aAAa,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;AACtE,CAAC;AAfD,8CAeC"}
@@ -0,0 +1,2 @@
1
+ import { Tree } from '@angular-devkit/schematics';
2
+ export declare function updateTsConfig(host: Tree): void;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.updateTsConfig = void 0;
4
+ const schematics_1 = require("@angular-devkit/schematics");
5
+ const TSCONFIG_JSON = 'tsconfig.json';
6
+ function updateTsConfig(host) {
7
+ if (!host.exists(TSCONFIG_JSON)) {
8
+ throw new schematics_1.SchematicsException(`The file ${TSCONFIG_JSON} doesn't exists...`);
9
+ }
10
+ const sourceText = host.read(TSCONFIG_JSON).toString('utf-8');
11
+ const fileContentWithoutComments = sourceText.replace(/(\/\*[^*]*\*\/)|(\/\/[^*]*)/g, '');
12
+ const json = JSON.parse(fileContentWithoutComments);
13
+ json.compilerOptions.noImplicitOverride = false;
14
+ json.compilerOptions.skipLibCheck = true;
15
+ json.compilerOptions.strict = false;
16
+ host.overwrite(TSCONFIG_JSON, JSON.stringify(json, null, 2));
17
+ }
18
+ exports.updateTsConfig = updateTsConfig;
19
+ //# sourceMappingURL=tsconfig-json.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tsconfig-json.js","sourceRoot":"","sources":["../../../../../src/schematics/ng-add/configs/tsconfig-json.ts"],"names":[],"mappings":";;;AAAA,2DAAuE;AAEvE,MAAM,aAAa,GAAG,eAAe,CAAC;AAEtC,SAAgB,cAAc,CAAC,IAAU;IACvC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,EAAE;QAC/B,MAAM,IAAI,gCAAmB,CAAC,YAAY,aAAa,oBAAoB,CAAC,CAAC;KAC9E;IACD,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,aAAa,CAAE,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IAC/D,MAAM,0BAA0B,GAAG,UAAU,CAAC,OAAO,CAAC,8BAA8B,EAAE,EAAE,CAAC,CAAC;IAC1F,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,0BAA0B,CAAC,CAAC;IAEpD,IAAI,CAAC,eAAe,CAAC,kBAAkB,GAAG,KAAK,CAAC;IAChD,IAAI,CAAC,eAAe,CAAC,YAAY,GAAG,IAAI,CAAC;IACzC,IAAI,CAAC,eAAe,CAAC,MAAM,GAAG,KAAK,CAAC;IACpC,IAAI,CAAC,SAAS,CAAC,aAAa,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;AAC/D,CAAC;AAZD,wCAYC"}
@@ -0,0 +1,4 @@
1
+ import { Rule } from '@angular-devkit/schematics';
2
+ import { CumulocityNgAddOptions } from './model';
3
+ export declare function ngAdd(options: CumulocityNgAddOptions): Rule;
4
+ export { Application, CumulocityNgAddOptions } from './model';
@@ -0,0 +1,93 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ngAdd = void 0;
4
+ const schematics_1 = require("@angular-devkit/schematics");
5
+ const tasks_1 = require("@angular-devkit/schematics/tasks");
6
+ const dependencies_1 = require("@schematics/angular/utility/dependencies");
7
+ const path_1 = require("path");
8
+ const angular_json_1 = require("./configs/angular-json");
9
+ const app_routing_1 = require("./configs/app-routing");
10
+ const index_html_1 = require("./configs/index-html");
11
+ const tsconfig_app_json_1 = require("./configs/tsconfig-app-json");
12
+ const utils_1 = require("./utils");
13
+ function ngAdd(options) {
14
+ return async (host, context) => {
15
+ const appPath = (0, path_1.dirname)(require.resolve(`${options.application}/package.json`));
16
+ context.logger.info('Adding Cumulocity IoT modules to the application...');
17
+ const templateSource = (0, schematics_1.apply)((0, schematics_1.url)(appPath), [
18
+ ignoreFiles(['package.json', '.npmignore', 'node_modules'])
19
+ ]);
20
+ const alignFileRule = (_tree, _context) => alignFiles(_tree, _context, options);
21
+ return (0, schematics_1.chain)([
22
+ (0, schematics_1.branchAndMerge)((0, schematics_1.mergeWith)(templateSource, schematics_1.MergeStrategy.Overwrite), schematics_1.MergeStrategy.Overwrite),
23
+ alignFileRule
24
+ ]);
25
+ };
26
+ }
27
+ exports.ngAdd = ngAdd;
28
+ function alignFiles(tree, context, options) {
29
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
30
+ const appPackageJson = require(`${options.application}/package.json`);
31
+ /** Get project source root */
32
+ const projectSourceRoot = (0, angular_json_1.getAngularJson)(tree)?.projects[(0, angular_json_1.getProjectName)(tree, options?.project)]?.sourceRoot;
33
+ context.logger.debug(`Project source root: ${projectSourceRoot}`);
34
+ /**
35
+ * Update app-routing.module.ts
36
+ */
37
+ context.logger.info('Updating app-routing.module.ts...');
38
+ (0, app_routing_1.hashRouteModule)(tree, projectSourceRoot);
39
+ /**
40
+ * Update angular.json
41
+ */
42
+ context.logger.info('Updating angular.json...');
43
+ (0, angular_json_1.updateAngularJson)(tree, options);
44
+ /**
45
+ * Update tsconfig.app.json
46
+ */
47
+ context.logger.info('Updating tsconfig.app.json');
48
+ (0, tsconfig_app_json_1.updateTsAppConfig)(tree);
49
+ /**
50
+ * Update index.html
51
+ */
52
+ context.logger.info('Updating index.html...');
53
+ (0, index_html_1.indexHtml)(tree, projectSourceRoot);
54
+ /**
55
+ * Remove files
56
+ */
57
+ context.logger.info('Removing files...');
58
+ (0, utils_1.deleteFile)(tree, `${projectSourceRoot}/app/app.component`);
59
+ (0, utils_1.deleteFile)(tree, `${projectSourceRoot}/favicon.ico`);
60
+ /**
61
+ * Update dependencies
62
+ */
63
+ context.logger.info('Installing dependencies...');
64
+ const dependencies = Object.entries(appPackageJson.dependencies || {}).map(([name, version]) => ({
65
+ name,
66
+ version: version,
67
+ type: dependencies_1.NodeDependencyType.Default,
68
+ overwrite: true
69
+ }));
70
+ const devDependencies = Object.entries(appPackageJson.devDependencies || {}).map(([name, version]) => ({
71
+ name,
72
+ version: version,
73
+ type: dependencies_1.NodeDependencyType.Dev,
74
+ overwrite: true
75
+ }));
76
+ [...dependencies, ...devDependencies].forEach(dependency => {
77
+ (0, dependencies_1.addPackageJsonDependency)(tree, dependency);
78
+ });
79
+ context.addTask(new tasks_1.NodePackageInstallTask());
80
+ return tree;
81
+ }
82
+ // Filter out specific files or patterns.
83
+ function ignoreFiles(patterns) {
84
+ return (0, schematics_1.filter)((path) => {
85
+ for (const pattern of patterns) {
86
+ if (path.endsWith(pattern) || path.includes(pattern)) {
87
+ return false;
88
+ }
89
+ }
90
+ return true;
91
+ });
92
+ }
93
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/schematics/ng-add/index.ts"],"names":[],"mappings":";;;AAAA,2DAWoC;AACpC,4DAA0E;AAC1E,2EAIkD;AAClD,+BAA+B;AAC/B,yDAA2F;AAC3F,uDAAwD;AACxD,qDAAiD;AACjD,mEAAgE;AAChE,mCAAqC;AAGrC,SAAgB,KAAK,CAAC,OAA+B;IACnD,OAAO,KAAK,EAAE,IAAU,EAAE,OAAyB,EAAE,EAAE;QACrD,MAAM,OAAO,GAAG,IAAA,cAAO,EAAC,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,WAAW,eAAe,CAAC,CAAC,CAAC;QAEhF,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,qDAAqD,CAAC,CAAC;QAE3E,MAAM,cAAc,GAAG,IAAA,kBAAK,EAAC,IAAA,gBAAG,EAAC,OAAO,CAAC,EAAE;YACzC,WAAW,CAAC,CAAC,cAAc,EAAE,YAAY,EAAE,cAAc,CAAC,CAAC;SAC5D,CAAC,CAAC;QACH,MAAM,aAAa,GAAS,CAAC,KAAW,EAAE,QAA0B,EAAE,EAAE,CACtE,UAAU,CAAC,KAAK,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;QAEvC,OAAO,IAAA,kBAAK,EAAC;YACX,IAAA,2BAAc,EAAC,IAAA,sB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