@ihk-gfi/lux-components-update 11.3.0

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 (158) hide show
  1. package/LICENSE +198 -0
  2. package/README.md +55 -0
  3. package/package.json +54 -0
  4. package/src/add-lux-components/files/app/app-routing.module.ts +19 -0
  5. package/src/add-lux-components/files/app/app.component.html +27 -0
  6. package/src/add-lux-components/files/app/app.component.spec.ts +19 -0
  7. package/src/add-lux-components/files/app/app.component.ts +13 -0
  8. package/src/add-lux-components/files/app/app.module.ts +56 -0
  9. package/src/add-lux-components/files/app/error/error.component.html +10 -0
  10. package/src/add-lux-components/files/app/error/error.component.scss +3 -0
  11. package/src/add-lux-components/files/app/error/error.component.spec.ts +49 -0
  12. package/src/add-lux-components/files/app/error/error.component.ts +17 -0
  13. package/src/add-lux-components/files/app/home/home.component.html +7 -0
  14. package/src/add-lux-components/files/app/home/home.component.scss +0 -0
  15. package/src/add-lux-components/files/app/home/home.component.ts +13 -0
  16. package/src/add-lux-components/files/app/profil/profil.component.html +1 -0
  17. package/src/add-lux-components/files/app/profil/profil.component.scss +0 -0
  18. package/src/add-lux-components/files/app/profil/profil.component.spec.ts +24 -0
  19. package/src/add-lux-components/files/app/profil/profil.component.ts +11 -0
  20. package/src/add-lux-components/files/environments/environment.prod.ts +4 -0
  21. package/src/add-lux-components/files/environments/environment.ts +17 -0
  22. package/src/add-lux-components/files/locale/messages.en.xlf +948 -0
  23. package/src/add-lux-components/files/locale/messages.xlf +822 -0
  24. package/src/add-lux-components/files/scripts/.browserslistrc +17 -0
  25. package/src/add-lux-components/files/src/polyfills.ts +68 -0
  26. package/src/add-lux-components/index.d.ts +10 -0
  27. package/src/add-lux-components/index.js +143 -0
  28. package/src/add-lux-components/index.js.map +1 -0
  29. package/src/add-lux-components/index.ts +183 -0
  30. package/src/add-lux-components/index_spec.d.ts +1 -0
  31. package/src/add-lux-components/index_spec.js +51 -0
  32. package/src/add-lux-components/index_spec.js.map +1 -0
  33. package/src/add-lux-components/index_spec.ts +55 -0
  34. package/src/add-lux-components/schema.json +23 -0
  35. package/src/collection.json +55 -0
  36. package/src/migrate-to-eslint/files/.eslintrc.json +68 -0
  37. package/src/migrate-to-eslint/files/.prettierrc +25 -0
  38. package/src/migrate-to-eslint/index.d.ts +6 -0
  39. package/src/migrate-to-eslint/index.js +149 -0
  40. package/src/migrate-to-eslint/index.js.map +1 -0
  41. package/src/migrate-to-eslint/index.ts +181 -0
  42. package/src/migrate-to-eslint/index_spec.d.ts +1 -0
  43. package/src/migrate-to-eslint/index_spec.js +129 -0
  44. package/src/migrate-to-eslint/index_spec.js.map +1 -0
  45. package/src/migrate-to-eslint/index_spec.ts +152 -0
  46. package/src/migrate-to-eslint/schema.json +23 -0
  47. package/src/migrate-to-webcomponent/index.d.ts +10 -0
  48. package/src/migrate-to-webcomponent/index.js +278 -0
  49. package/src/migrate-to-webcomponent/index.js.map +1 -0
  50. package/src/migrate-to-webcomponent/index.ts +331 -0
  51. package/src/migrate-to-webcomponent/index_spec.d.ts +1 -0
  52. package/src/migrate-to-webcomponent/index_spec.js +580 -0
  53. package/src/migrate-to-webcomponent/index_spec.js.map +1 -0
  54. package/src/migrate-to-webcomponent/index_spec.ts +703 -0
  55. package/src/migrate-to-webcomponent/schema.json +23 -0
  56. package/src/update/files/locale/messages.en.xlf +940 -0
  57. package/src/update/files/locale/messages.xlf +815 -0
  58. package/src/update/files/scripts/move-de-files.js +15 -0
  59. package/src/update/index.d.ts +23 -0
  60. package/src/update/index.js +635 -0
  61. package/src/update/index.js.map +1 -0
  62. package/src/update/index.ts +712 -0
  63. package/src/update/index_spec.d.ts +1 -0
  64. package/src/update/index_spec.js +990 -0
  65. package/src/update/index_spec.js.map +1 -0
  66. package/src/update/index_spec.ts +1145 -0
  67. package/src/update/schema.json +23 -0
  68. package/src/update-dependencies/index.d.ts +5 -0
  69. package/src/update-dependencies/index.js +113 -0
  70. package/src/update-dependencies/index.js.map +1 -0
  71. package/src/update-dependencies/index.ts +114 -0
  72. package/src/update-dependencies/schema.json +23 -0
  73. package/src/update110001/index.d.ts +2 -0
  74. package/src/update110001/index.js +42 -0
  75. package/src/update110001/index.js.map +1 -0
  76. package/src/update110001/index.ts +40 -0
  77. package/src/update110001/index_spec.d.ts +1 -0
  78. package/src/update110001/index_spec.js +67 -0
  79. package/src/update110001/index_spec.js.map +1 -0
  80. package/src/update110001/index_spec.ts +72 -0
  81. package/src/update110001/schema.json +23 -0
  82. package/src/update110100/index.d.ts +2 -0
  83. package/src/update110100/index.js +27 -0
  84. package/src/update110100/index.js.map +1 -0
  85. package/src/update110100/index.ts +24 -0
  86. package/src/update110100/index_spec.d.ts +1 -0
  87. package/src/update110100/index_spec.js +69 -0
  88. package/src/update110100/index_spec.js.map +1 -0
  89. package/src/update110100/index_spec.ts +73 -0
  90. package/src/update110100/schema.json +23 -0
  91. package/src/update110101/index.d.ts +2 -0
  92. package/src/update110101/index.js +24 -0
  93. package/src/update110101/index.js.map +1 -0
  94. package/src/update110101/index.ts +21 -0
  95. package/src/update110101/index_spec.d.ts +1 -0
  96. package/src/update110101/index_spec.js +65 -0
  97. package/src/update110101/index_spec.js.map +1 -0
  98. package/src/update110101/index_spec.ts +69 -0
  99. package/src/update110101/schema.json +23 -0
  100. package/src/update110200/index.d.ts +2 -0
  101. package/src/update110200/index.js +24 -0
  102. package/src/update110200/index.js.map +1 -0
  103. package/src/update110200/index.ts +21 -0
  104. package/src/update110200/index_spec.d.ts +1 -0
  105. package/src/update110200/index_spec.js +65 -0
  106. package/src/update110200/index_spec.js.map +1 -0
  107. package/src/update110200/index_spec.ts +69 -0
  108. package/src/update110200/schema.json +23 -0
  109. package/src/update110300/index.d.ts +2 -0
  110. package/src/update110300/index.js +133 -0
  111. package/src/update110300/index.js.map +1 -0
  112. package/src/update110300/index.ts +148 -0
  113. package/src/update110300/index_spec.d.ts +1 -0
  114. package/src/update110300/index_spec.js +121 -0
  115. package/src/update110300/index_spec.js.map +1 -0
  116. package/src/update110300/index_spec.ts +139 -0
  117. package/src/update110300/schema.json +23 -0
  118. package/src/utility/dependencies.d.ts +39 -0
  119. package/src/utility/dependencies.js +96 -0
  120. package/src/utility/dependencies.js.map +1 -0
  121. package/src/utility/dependencies.ts +116 -0
  122. package/src/utility/files.d.ts +60 -0
  123. package/src/utility/files.js +299 -0
  124. package/src/utility/files.js.map +1 -0
  125. package/src/utility/files.ts +355 -0
  126. package/src/utility/html.d.ts +49 -0
  127. package/src/utility/html.js +183 -0
  128. package/src/utility/html.js.map +1 -0
  129. package/src/utility/html.ts +212 -0
  130. package/src/utility/json.d.ts +34 -0
  131. package/src/utility/json.js +70 -0
  132. package/src/utility/json.js.map +1 -0
  133. package/src/utility/json.ts +70 -0
  134. package/src/utility/logging.d.ts +32 -0
  135. package/src/utility/logging.js +82 -0
  136. package/src/utility/logging.js.map +1 -0
  137. package/src/utility/logging.ts +80 -0
  138. package/src/utility/test.d.ts +10 -0
  139. package/src/utility/test.js +24 -0
  140. package/src/utility/test.js.map +1 -0
  141. package/src/utility/test.ts +24 -0
  142. package/src/utility/typescript.d.ts +22 -0
  143. package/src/utility/typescript.js +521 -0
  144. package/src/utility/typescript.js.map +1 -0
  145. package/src/utility/typescript.ts +598 -0
  146. package/src/utility/typescript_spec.d.ts +1 -0
  147. package/src/utility/typescript_spec.js +1006 -0
  148. package/src/utility/typescript_spec.js.map +1 -0
  149. package/src/utility/typescript_spec.ts +1267 -0
  150. package/src/utility/util.d.ts +33 -0
  151. package/src/utility/util.js +139 -0
  152. package/src/utility/util.js.map +1 -0
  153. package/src/utility/util.ts +140 -0
  154. package/src/utility/validation.d.ts +11 -0
  155. package/src/utility/validation.js +44 -0
  156. package/src/utility/validation.js.map +1 -0
  157. package/src/utility/validation.ts +49 -0
  158. package/tsconfig.json +37 -0
@@ -0,0 +1,635 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.updateAppModule = exports.updateAppComponent = exports.removeThemeAssets = exports.addThemeAssets = exports.clearStylesScss = exports.addNg2PdfViewer = exports.updateAngularJson = exports.deleteOldThemeDir = exports.updateBrowserList = exports.updateTsConfigJson = exports.check = exports.i18nCopyMessages = exports.i18nUpdatePolyfills = exports.i18nUpdateAppModule = exports.i18nUpdatePackageJson = exports.i18nUpdateAngularJson = exports.addI18N = exports.updateProject = exports.update = exports.updateNodeMinVersion = exports.updateMinVersion = exports.updateMajorVersion = void 0;
4
+ const schematics_1 = require("@angular-devkit/schematics");
5
+ const chalk = require("chalk");
6
+ const jsonc_parser_1 = require("jsonc-parser");
7
+ const ts = require("typescript");
8
+ const index_1 = require("../update-dependencies/index");
9
+ const files_1 = require("../utility/files");
10
+ const json_1 = require("../utility/json");
11
+ const logging_1 = require("../utility/logging");
12
+ const typescript_1 = require("../utility/typescript");
13
+ const util_1 = require("../utility/util");
14
+ const validation_1 = require("../utility/validation");
15
+ exports.updateMajorVersion = '11';
16
+ exports.updateMinVersion = '10.8.2';
17
+ exports.updateNodeMinVersion = '12.0.0';
18
+ function update(options) {
19
+ return (tree, _context) => {
20
+ return schematics_1.chain([
21
+ check(options),
22
+ util_1.applyRuleIf(exports.updateMinVersion, updateProject(options)),
23
+ util_1.finish(`${chalk.yellowBright('Wichtig!!!')} Hinweise im Update Guide beachten -> https://github.com/IHK-GfI/lux-components/wiki/update-guide-${exports.updateMajorVersion}`)
24
+ ]);
25
+ };
26
+ }
27
+ exports.update = update;
28
+ function updateProject(options) {
29
+ return (tree, _context) => {
30
+ return schematics_1.chain([
31
+ util_1.messageInfoRule(`LUX-Components ${exports.updateMajorVersion} werden aktualisiert...`),
32
+ updateBrowserList(options),
33
+ deleteOldThemeDir(options),
34
+ clearStylesScss(options),
35
+ updateAngularJson(options),
36
+ updateAppComponent(options),
37
+ updateAppModule(options),
38
+ updateTsConfigJson(options),
39
+ addI18N(options),
40
+ index_1.updateDependencies(),
41
+ util_1.messageSuccessRule(`LUX-Components ${exports.updateMajorVersion} wurden aktualisiert.`)
42
+ ]);
43
+ };
44
+ }
45
+ exports.updateProject = updateProject;
46
+ function addI18N(options) {
47
+ return schematics_1.chain([
48
+ util_1.messageInfoRule(`I18N-Unterstützung wird hinzugefügt...`),
49
+ i18nUpdatePackageJson(options),
50
+ i18nUpdateAngularJson(options),
51
+ i18nCopyMessages(options),
52
+ i18nUpdatePolyfills(options),
53
+ i18nUpdateAppModule(options),
54
+ util_1.messageSuccessRule(`I18N-Unterstützung wurde hinzugefügt...`)
55
+ ]);
56
+ }
57
+ exports.addI18N = addI18N;
58
+ function i18nUpdateAngularJson(options) {
59
+ return schematics_1.chain([
60
+ util_1.messageInfoRule(`Die Datei "angular.json" wird angepasst...`),
61
+ (tree, _context) => {
62
+ const filePath = `/angular.json`;
63
+ const newValuesArr = [
64
+ {
65
+ path: ['projects', options.project, 'i18n'],
66
+ value: {
67
+ sourceLocale: {
68
+ 'code': 'de',
69
+ 'baseHref': '/'
70
+ },
71
+ locales: {
72
+ en: 'src/locale/messages.en.xlf'
73
+ }
74
+ },
75
+ message: `Neuen Abschnitt "xi18n" unter projects/${options.project} hinzugefügt.`
76
+ },
77
+ {
78
+ path: ['projects', options.project, 'architect', 'build', 'options', 'localize'],
79
+ value: ["de"],
80
+ message: `Neuen Abschnitt "localize" unter projects/${options.project}/architect/build/options hinzugefügt.`
81
+ },
82
+ {
83
+ path: ['projects', options.project, 'architect', 'build', 'options', 'i18nMissingTranslation'],
84
+ value: "error",
85
+ message: `Neuen Abschnitt "i18nMissingTranslation" unter projects/${options.project}/architect/build/options hinzugefügt.`
86
+ },
87
+ {
88
+ path: ['projects', options.project, 'architect', 'build', 'configurations', 'en'],
89
+ value: {
90
+ "localize": ["en"],
91
+ "aot": true,
92
+ "outputPath": "dist/en",
93
+ "i18nMissingTranslation": "error"
94
+ },
95
+ message: `Neuen Abschnitt "en" unter projects/${options.project}/architect/build/configurations hinzugefügt.`
96
+ },
97
+ {
98
+ path: ['projects', options.project, 'architect', 'serve', 'configurations', 'en'],
99
+ value: {
100
+ "browserTarget": options.project + ":build:en"
101
+ },
102
+ message: `Neuen Abschnitt "en" unter projects/${options.project}/architect/serve/configurations hinzugefügt.`
103
+ }
104
+ ];
105
+ newValuesArr.forEach(change => {
106
+ const tsConfigJson = json_1.readJsonAsString(tree, filePath);
107
+ const edits = jsonc_parser_1.modify(tsConfigJson, change.path, change.value, { formattingOptions: json_1.jsonFormattingOptions });
108
+ tree.overwrite(filePath, jsonc_parser_1.applyEdits(tsConfigJson, edits));
109
+ logging_1.logInfo(change.message);
110
+ });
111
+ return tree;
112
+ },
113
+ util_1.messageSuccessRule(`Die Datei "angular.json" wurde angepasst.`)
114
+ ]);
115
+ }
116
+ exports.i18nUpdateAngularJson = i18nUpdateAngularJson;
117
+ function i18nUpdatePackageJson(options) {
118
+ return schematics_1.chain([
119
+ util_1.messageInfoRule(`Die Datei "package.json" wird angepasst...`),
120
+ (tree, _context) => {
121
+ const filePath = `/package.json`;
122
+ const newValuesArr = [
123
+ { path: ['scripts', 'move-de-files'], value: "node move-de-files.js", message: `Neues Skript "move-de-files" hinzugefügt.` },
124
+ { path: ['scripts', 'xi18n'], value: "ng extract-i18n --output-path src/locale --ivy", message: `Neues Skript "xi18n" hinzugefügt.` }
125
+ ];
126
+ const packageJsonAsNode = json_1.readJson(tree, filePath);
127
+ // Neues start-en-Skript hinzufügen
128
+ const startScriptNode = jsonc_parser_1.findNodeAtLocation(packageJsonAsNode, ['scripts', 'start']);
129
+ if (startScriptNode) {
130
+ newValuesArr.push({
131
+ path: ['scripts', 'start-en'],
132
+ value: startScriptNode.value + ' --configuration en',
133
+ message: `Das neue Skript "start-en" hinzugefügt.`
134
+ });
135
+ }
136
+ else {
137
+ newValuesArr.push({
138
+ path: ['scripts', 'start-en'],
139
+ value: 'ng serve --public-host=http://localhost:4200 --configuration en',
140
+ message: `Das neue Skript "start-en" hinzugefügt.`
141
+ });
142
+ }
143
+ // build-aot-Script anpassen
144
+ const buildAotScriptNode = jsonc_parser_1.findNodeAtLocation(packageJsonAsNode, ['scripts', 'build-aot']);
145
+ if (buildAotScriptNode) {
146
+ newValuesArr.push({
147
+ path: ['scripts', 'build-aot'],
148
+ value: buildAotScriptNode.value + ' && npm run move-de-files',
149
+ message: `Dem Skript "build-aot" den Parameter "&& npm run move-de-files" hinzugefügt.`
150
+ });
151
+ }
152
+ else {
153
+ newValuesArr.push({
154
+ path: ['scripts', 'build-aot'],
155
+ value: 'node --max_old_space_size=4024 ./node_modules/@angular/cli/bin/ng build --aot && npm run move-de-files',
156
+ message: `Das Skript "build-aot" mit dem Parameter "&& npm run move-de-files" hinzugefügt.`
157
+ });
158
+ }
159
+ // buildzentral-Script anpassen
160
+ const buildZentralScriptNode = jsonc_parser_1.findNodeAtLocation(packageJsonAsNode, ['scripts', 'buildzentral']);
161
+ if (buildZentralScriptNode) {
162
+ newValuesArr.push({
163
+ path: ['scripts', 'buildzentral'],
164
+ value: buildZentralScriptNode.value + " && npm run move-de-files",
165
+ message: `Dem Skript "buildzentral" den Parameter "&& npm run move-de-files" hinzugefügt.`
166
+ });
167
+ }
168
+ else {
169
+ newValuesArr.push({
170
+ path: ['scripts', 'buildzentral'],
171
+ value: 'node --max_old_space_size=4024 ./node_modules/@angular/cli/bin/ng build --prod && npm run move-de-files',
172
+ message: `Das Skript "buildzentral" mit dem Parameter "&& npm run move-de-files" hinzugefügt.`
173
+ });
174
+ }
175
+ newValuesArr.forEach(change => {
176
+ const tsConfigJson = json_1.readJsonAsString(tree, filePath);
177
+ const edits = jsonc_parser_1.modify(tsConfigJson, change.path, change.value, { formattingOptions: json_1.jsonFormattingOptions });
178
+ tree.overwrite(filePath, jsonc_parser_1.applyEdits(tsConfigJson, edits));
179
+ logging_1.logInfo(change.message);
180
+ });
181
+ return tree;
182
+ },
183
+ util_1.messageSuccessRule(`Die Datei "package.json" wurde angepasst.`)
184
+ ]);
185
+ }
186
+ exports.i18nUpdatePackageJson = i18nUpdatePackageJson;
187
+ function i18nUpdateAppModule(options) {
188
+ return schematics_1.chain([
189
+ util_1.messageInfoRule(`Die Datei "app.module.ts" wird angepasst...`),
190
+ (tree, _context) => {
191
+ const filePath = (options.path ? options.path : '') + `/src/app/app.module.ts`;
192
+ typescript_1.removeImport(tree, filePath, '@angular/core', 'LOCALE_ID');
193
+ typescript_1.removeImport(tree, filePath, '@angular/common', 'registerLocaleData');
194
+ typescript_1.removeImport(tree, filePath, '@angular/common/locales/global/de');
195
+ typescript_1.removeProvider(tree, filePath, 'LOCALE_ID');
196
+ return tree;
197
+ },
198
+ util_1.messageSuccessRule(`Die Datei "app.module.ts" wurde angepasst.`)
199
+ ]);
200
+ }
201
+ exports.i18nUpdateAppModule = i18nUpdateAppModule;
202
+ function i18nUpdatePolyfills(options) {
203
+ return schematics_1.chain([
204
+ util_1.messageInfoRule(`Import wird in der Datei "polyfills.ts" hinzugefügt...`),
205
+ (tree, _context) => {
206
+ const filePath = (options.path ? options.path : '') + '/src/polyfills.ts';
207
+ const content = tree.read(filePath);
208
+ if (content) {
209
+ let modifiedContent = '/***************************************************************************************************\n * Load \`$localize\` onto the global scope - used if i18n tags appear in Angular templates.\n */\nimport \'@angular/localize/init\';\n\n';
210
+ modifiedContent += content;
211
+ tree.overwrite(filePath, modifiedContent);
212
+ }
213
+ return tree;
214
+ },
215
+ util_1.messageSuccessRule(`Import wird in der Datei "polyfills.ts" hinzugefügt...`)
216
+ ]);
217
+ }
218
+ exports.i18nUpdatePolyfills = i18nUpdatePolyfills;
219
+ function i18nCopyMessages(options) {
220
+ return schematics_1.chain([
221
+ util_1.messageInfoRule(`Sprachdateien werden kopiert...`),
222
+ files_1.moveFilesToDirectory(options, 'files/locale', 'src/locale'),
223
+ files_1.moveFilesToDirectory(options, 'files/scripts', '/'),
224
+ util_1.messageSuccessRule(`Sprachdateien wurden kopiert.`)
225
+ ]);
226
+ }
227
+ exports.i18nCopyMessages = i18nCopyMessages;
228
+ function check(options) {
229
+ return (tree, _context) => {
230
+ logging_1.logInfoWithDescriptor(`Vorbedingungen werden geprüft...`);
231
+ validation_1.validateNodeVersion(_context, exports.updateNodeMinVersion);
232
+ validation_1.validateLuxComponentsVersion(tree, `${exports.updateMinVersion} || ^${exports.updateMajorVersion}.0.0`);
233
+ logging_1.logSuccess(`Vorbedingungen wurden geprüft.`);
234
+ return tree;
235
+ };
236
+ }
237
+ exports.check = check;
238
+ function updateTsConfigJson(options) {
239
+ return schematics_1.chain([
240
+ util_1.messageInfoRule(`Datei "tsconfig.json" wird aktualisiert...`),
241
+ (tree, _context) => {
242
+ const filePath = '/tsconfig.json';
243
+ const newValuesArr = [
244
+ { path: ['compilerOptions', 'strict'], value: false, message: `Die Property "compilerOptions.strict" wurde auf "false" gesetzt.` },
245
+ { path: ['compilerOptions', 'noImplicitReturns'], value: true, message: `Die Property "compilerOptions.noImplicitReturns" wurde auf "true" gesetzt.` },
246
+ { path: ['compilerOptions', 'noFallthroughCasesInSwitch'], value: true, message: `Die Property "compilerOptions.noFallthroughCasesInSwitch" wurde auf "true" gesetzt.` },
247
+ { path: ['compilerOptions', 'forceConsistentCasingInFileNames'], value: true, message: `Die Property "compilerOptions.forceConsistentCasingInFileNames" wurde auf "true" gesetzt.` },
248
+ { path: ['compilerOptions', 'lib'], value: ["es2018", "dom"], message: `Die Property "compilerOptions.lib" wurde auf "["es2018", "dom"]" gesetzt.` },
249
+ { path: ['compilerOptions', 'module'], value: "es2020", message: `Die Property "compilerOptions.module" wurde auf "es2020" gesetzt.` },
250
+ { path: ['angularCompilerOptions', 'strictInputAccessModifiers'], value: true, message: `Die Property "angularCompilerOptions.strictInputAccessModifiers" wurde auf "true" gesetzt.` },
251
+ { path: ['angularCompilerOptions', 'strictTemplates'], value: false, message: `Die Property "angularCompilerOptions.strictTemplates" wurde auf "false" gesetzt.` },
252
+ ];
253
+ newValuesArr.forEach(change => {
254
+ const tsConfigJson = json_1.readJsonAsString(tree, filePath);
255
+ const edits = jsonc_parser_1.modify(tsConfigJson, change.path, change.value, { formattingOptions: json_1.jsonFormattingOptions });
256
+ tree.overwrite(filePath, jsonc_parser_1.applyEdits(tsConfigJson, edits));
257
+ logging_1.logInfo(change.message);
258
+ });
259
+ },
260
+ util_1.messageSuccessRule(`Datei "tsconfig.json" wurde aktualisiert.`),
261
+ ]);
262
+ }
263
+ exports.updateTsConfigJson = updateTsConfigJson;
264
+ function updateBrowserList(options) {
265
+ return schematics_1.chain([
266
+ util_1.messageInfoRule(`Datei ".browserslistrc" wird aktualisiert...`),
267
+ (tree, context) => {
268
+ const filePath = '/.browserslistrc';
269
+ const browserListContent = tree.read(filePath);
270
+ if (browserListContent) {
271
+ const content = browserListContent.toString();
272
+ if (content) {
273
+ let modifiedContent = '';
274
+ const lines = content.split('\n');
275
+ if (lines) {
276
+ lines.forEach(line => {
277
+ if (line.trim().startsWith('IE 9-11')) {
278
+ modifiedContent += 'not IE 9-10' + '\n';
279
+ modifiedContent += 'IE 11' + '\n';
280
+ }
281
+ else {
282
+ modifiedContent += line + '\n';
283
+ }
284
+ });
285
+ if (content !== modifiedContent) {
286
+ tree.overwrite(filePath, modifiedContent);
287
+ logging_1.logInfo(`Einträge für den IE 9-10 entfernt.`);
288
+ }
289
+ }
290
+ }
291
+ }
292
+ else {
293
+ logging_1.logInfo(`Die Datei ".browserslistrc" konnte nicht gefunden werden.`);
294
+ }
295
+ },
296
+ util_1.messageSuccessRule(`Datei ".browserslistrc" wurde aktualisiert.`),
297
+ ]);
298
+ }
299
+ exports.updateBrowserList = updateBrowserList;
300
+ function deleteOldThemeDir(options) {
301
+ return schematics_1.chain([
302
+ util_1.messageInfoRule(`Altes Theming-Verzeichnis '/src/theming/' wird gelöscht...`),
303
+ files_1.deleteFilesInDirectory(options, '/src/theming/', []),
304
+ util_1.messageSuccessRule(`Altes Theming-Verzeichnis wurde gelöscht.`),
305
+ ]);
306
+ }
307
+ exports.deleteOldThemeDir = deleteOldThemeDir;
308
+ function updateAngularJson(options) {
309
+ return (tree, _context) => {
310
+ return schematics_1.chain([
311
+ util_1.messageInfoRule(`Datei "angular.json" wird aktualisiert...`),
312
+ addThemeAssets(options),
313
+ removeThemeAssets(options),
314
+ addNg2PdfViewer(options),
315
+ util_1.messageSuccessRule(`Datei "angular.json" wurde aktualisiert.`),
316
+ ]);
317
+ };
318
+ }
319
+ exports.updateAngularJson = updateAngularJson;
320
+ function addNg2PdfViewer(options) {
321
+ return (tree, context) => {
322
+ var _a;
323
+ const filePath = '/angular.json';
324
+ const value = 'ng2-pdf-viewer';
325
+ let contentAsNode = json_1.readJson(tree, filePath);
326
+ const ngPdfViewerNode = jsonc_parser_1.findNodeAtLocation(contentAsNode, ['projects', options.project, 'architect', 'build', 'options', 'allowedCommonJsDependencies']);
327
+ let found = false;
328
+ if (ngPdfViewerNode) {
329
+ (_a = ngPdfViewerNode.children) === null || _a === void 0 ? void 0 : _a.forEach(child => {
330
+ if (child.value === value) {
331
+ found = true;
332
+ }
333
+ });
334
+ }
335
+ if (!found) {
336
+ const angularJson = json_1.readJsonAsString(tree, filePath);
337
+ const edits = jsonc_parser_1.modify(angularJson, ['projects', options.project, 'architect', 'build', 'options', 'allowedCommonJsDependencies', 0], value, { formattingOptions: json_1.jsonFormattingOptions, isArrayInsertion: true });
338
+ if (edits) {
339
+ tree.overwrite(filePath, jsonc_parser_1.applyEdits(angularJson, edits));
340
+ logging_1.logInfo(`"ng2-pdf-viewer" im Abschnitt "allowedCommonJsDependencies" hinzugefügt.`);
341
+ }
342
+ }
343
+ };
344
+ }
345
+ exports.addNg2PdfViewer = addNg2PdfViewer;
346
+ function clearStylesScss(options) {
347
+ return schematics_1.chain([
348
+ util_1.messageInfoRule(`Datei "styles.scss" wird aktualisiert...`),
349
+ (tree, context) => {
350
+ const filePath = (options.path ? options.path : '') + '/src/styles.scss';
351
+ const content = tree.read(filePath).toString();
352
+ if (content) {
353
+ let modifiedContent = '';
354
+ const lines = content.split('\n');
355
+ if (lines) {
356
+ lines.forEach(line => {
357
+ // Zeilen mit dem folgenden Inhalt werden nicht übernommen.
358
+ if (line.indexOf('@fortawesome/fontawesome-free') < 0 &&
359
+ line.indexOf('material-design-icons.css') < 0 &&
360
+ line.indexOf('@angular/material/theming') < 0 &&
361
+ line.indexOf('theming/luxtheme') < 0 &&
362
+ line.indexOf('mat-core()') < 0 &&
363
+ line.indexOf('angular-material-theme($lux-theme)') < 0) {
364
+ modifiedContent += line + '\n';
365
+ }
366
+ });
367
+ if (content !== modifiedContent) {
368
+ tree.overwrite(filePath, modifiedContent);
369
+ logging_1.logInfo(`Einträge des alten LUX-Themes entfernt.`);
370
+ }
371
+ }
372
+ }
373
+ },
374
+ util_1.messageSuccessRule(`\`Datei "styles.scss" wurde aktualisiert.`)
375
+ ]);
376
+ }
377
+ exports.clearStylesScss = clearStylesScss;
378
+ function addThemeAssets(options) {
379
+ return (tree, context) => {
380
+ const filePath = '/angular.json';
381
+ const value = { "glob": "*.css", "input": "./node_modules/@ihk-gfi/lux-components-theme/prebuilt-themes", "output": "./assets/themes" };
382
+ let contentAsNode = json_1.readJson(tree, filePath);
383
+ const testAssetsNode = jsonc_parser_1.findNodeAtLocation(contentAsNode, ['projects', options.project, 'architect', 'test', 'options', 'assets']);
384
+ if (testAssetsNode) {
385
+ const angularJson = json_1.readJsonAsString(tree, filePath);
386
+ const edits = jsonc_parser_1.modify(angularJson, ['projects', options.project, 'architect', 'test', 'options', 'assets', 0], value, { formattingOptions: json_1.jsonFormattingOptions, isArrayInsertion: true });
387
+ if (edits) {
388
+ tree.overwrite(filePath, jsonc_parser_1.applyEdits(angularJson, edits));
389
+ logging_1.logInfo(`Neues LUX-Theme im Assets-Abschnitt (test) hinzugefügt.`);
390
+ }
391
+ }
392
+ contentAsNode = json_1.readJson(tree, filePath);
393
+ const buildAssetsNode = jsonc_parser_1.findNodeAtLocation(contentAsNode, ['projects', options.project, 'architect', 'build', 'options', 'assets']);
394
+ if (buildAssetsNode) {
395
+ const angularJson = json_1.readJsonAsString(tree, filePath);
396
+ const edits = jsonc_parser_1.modify(angularJson, ['projects', options.project, 'architect', 'build', 'options', 'assets', 0], value, { formattingOptions: json_1.jsonFormattingOptions, isArrayInsertion: true });
397
+ if (edits) {
398
+ tree.overwrite(filePath, jsonc_parser_1.applyEdits(angularJson, edits));
399
+ logging_1.logInfo(`Neues LUX-Theme im Assets-Abschnitt (build) hinzugefügt.`);
400
+ }
401
+ }
402
+ };
403
+ }
404
+ exports.addThemeAssets = addThemeAssets;
405
+ function removeThemeAssets(options) {
406
+ return (tree, context) => {
407
+ const filePath = '/angular.json';
408
+ const value = "src/theming/luxtheme.scss";
409
+ let contentAsNode = json_1.readJson(tree, filePath);
410
+ const testAssetsNode = jsonc_parser_1.findNodeAtLocation(contentAsNode, ['projects', options.project, 'architect', 'test', 'options', 'styles']);
411
+ if (testAssetsNode && testAssetsNode.children) {
412
+ const assetArray = testAssetsNode.children;
413
+ const index = assetArray.findIndex(item => item.value === value);
414
+ if (index >= 0) {
415
+ const angularJson = json_1.readJsonAsString(tree, filePath);
416
+ const edits = jsonc_parser_1.modify(angularJson, ['projects', options.project, 'architect', 'test', 'options', 'styles', index], void 0, { formattingOptions: json_1.jsonFormattingOptions });
417
+ if (edits) {
418
+ tree.overwrite(filePath, jsonc_parser_1.applyEdits(angularJson, edits));
419
+ logging_1.logInfo(`Altes LUX-Theme aus dem Assets-Abschnitt (test) entfernt.`);
420
+ }
421
+ }
422
+ }
423
+ contentAsNode = json_1.readJson(tree, filePath);
424
+ const buildAssetsNode = jsonc_parser_1.findNodeAtLocation(contentAsNode, ['projects', options.project, 'architect', 'build', 'options', 'styles']);
425
+ if (buildAssetsNode && buildAssetsNode.children) {
426
+ const assetArray = buildAssetsNode.children;
427
+ const index = assetArray.findIndex(item => item.value === value);
428
+ if (index >= 0) {
429
+ const angularJson = json_1.readJsonAsString(tree, filePath);
430
+ const edits = jsonc_parser_1.modify(angularJson, ['projects', options.project, 'architect', 'build', 'options', 'styles', index], void 0, { formattingOptions: json_1.jsonFormattingOptions });
431
+ if (edits) {
432
+ tree.overwrite(filePath, jsonc_parser_1.applyEdits(angularJson, edits));
433
+ logging_1.logInfo(`Altes LUX-Theme aus dem Assets-Abschnitt (build) entfernt.`);
434
+ }
435
+ }
436
+ }
437
+ };
438
+ }
439
+ exports.removeThemeAssets = removeThemeAssets;
440
+ function updateAppComponent(options) {
441
+ return schematics_1.chain([
442
+ util_1.messageInfoRule(`AppComponent wird aktualisiert...`),
443
+ (tree, context) => {
444
+ const filePath = (options.path ? options.path : '') + '/src/app/app.component.ts';
445
+ typescript_1.addImport(tree, filePath, '@ihk-gfi/lux-components', 'LuxThemeService');
446
+ typescript_1.addConstructorParameter(tree, filePath, 'private themeService: LuxThemeService');
447
+ typescript_1.addConstructorContent(tree, filePath, 'themeService.loadTheme();', true);
448
+ },
449
+ util_1.messageSuccessRule(`AppComponent wurde aktualisiert.`)
450
+ ]);
451
+ }
452
+ exports.updateAppComponent = updateAppComponent;
453
+ function updateConfigGenerateLuxTagIds(tree, filePath) {
454
+ const content = tree.read(filePath).toString();
455
+ const fileName = filePath.substring(filePath.lastIndexOf('/') + 1, filePath.length);
456
+ const sourceFile = ts.createSourceFile(`${fileName}`, content, ts.ScriptTarget.Latest, true);
457
+ const nodes = typescript_1.getSourceNodes(sourceFile);
458
+ const identifierNode = nodes.find(n => n.kind === ts.SyntaxKind.Identifier && n.getText() === 'luxComponentsConfig');
459
+ if (identifierNode) {
460
+ const objectNode = identifierNode.parent.getChildren().find(n => n.kind === ts.SyntaxKind.ObjectLiteralExpression);
461
+ if (objectNode) {
462
+ const syntaxListNode = objectNode.getChildren().find(n => n.kind === ts.SyntaxKind.SyntaxList);
463
+ if (syntaxListNode) {
464
+ const propertyAssignmentNodes = syntaxListNode.getChildren().filter(n => n.kind === ts.SyntaxKind.PropertyAssignment);
465
+ if (propertyAssignmentNodes) {
466
+ propertyAssignmentNodes.forEach(assignment => {
467
+ const propertyIdentifierNode = assignment.getChildren().find(n => n.kind === ts.SyntaxKind.Identifier);
468
+ if (propertyIdentifierNode && propertyIdentifierNode.getText() === 'generateLuxTagIds') {
469
+ const updateRecorder = tree.beginUpdate(filePath);
470
+ updateRecorder.remove(assignment.pos, assignment.end - assignment.pos);
471
+ updateRecorder.insertLeft(assignment.pos, '\n generateLuxTagIds: environment.generateLuxTagIds');
472
+ if (!content.match(/import.*\{.*environment.*\}.*from.*/g)) {
473
+ updateRecorder.insertLeft(0, "import { environment } from '../environments/environment';\n");
474
+ }
475
+ tree.commitUpdate(updateRecorder);
476
+ logging_1.logInfo(`In der Konfiguration wurde der Wert "generateLuxTagIds: environment.generateLuxTagIds" eingetragen.`);
477
+ }
478
+ });
479
+ }
480
+ }
481
+ }
482
+ }
483
+ }
484
+ function updateConfigLabelConfiguration(tree, filePath) {
485
+ const content = tree.read(filePath).toString();
486
+ const fileName = filePath.substring(filePath.lastIndexOf('/') + 1, filePath.length);
487
+ const sourceFile = ts.createSourceFile(`${fileName}`, content, ts.ScriptTarget.Latest, true);
488
+ const nodes = typescript_1.getSourceNodes(sourceFile);
489
+ const identifierNode = nodes.find(n => n.kind === ts.SyntaxKind.Identifier && n.getText() === 'luxComponentsConfig');
490
+ if (identifierNode) {
491
+ const objectNode = identifierNode.parent.getChildren().find(n => n.kind === ts.SyntaxKind.ObjectLiteralExpression);
492
+ if (objectNode) {
493
+ const syntaxListNode = objectNode.getChildren().find(n => n.kind === ts.SyntaxKind.SyntaxList);
494
+ if (syntaxListNode) {
495
+ const propertyAssignmentNodes = syntaxListNode.getChildren().filter(n => n.kind === ts.SyntaxKind.PropertyAssignment);
496
+ if (propertyAssignmentNodes) {
497
+ propertyAssignmentNodes.forEach(assignment => {
498
+ const propertyIdentifierNode = assignment.getChildren().find(n => n.kind === ts.SyntaxKind.Identifier);
499
+ if (propertyIdentifierNode && propertyIdentifierNode.getText() === 'labelConfiguration') {
500
+ const prevSibling = typescript_1.getPrevSibling(assignment, ts.SyntaxKind.SyntaxList);
501
+ const nextSibling = typescript_1.getNextSibling(assignment, ts.SyntaxKind.SyntaxList);
502
+ const updateRecorder = tree.beginUpdate(filePath);
503
+ if (nextSibling) {
504
+ updateRecorder.remove(assignment.pos, nextSibling.end - assignment.pos);
505
+ }
506
+ else {
507
+ if (prevSibling) {
508
+ updateRecorder.remove(prevSibling.pos, assignment.end - assignment.pos);
509
+ }
510
+ else {
511
+ updateRecorder.remove(assignment.pos, assignment.end - assignment.pos);
512
+ }
513
+ }
514
+ logging_1.logInfo(`Aus der Konfiguration wurde die Property "labelConfiguration" entfernt, damit der Default verwendet wird.`);
515
+ tree.commitUpdate(updateRecorder);
516
+ }
517
+ });
518
+ }
519
+ }
520
+ }
521
+ }
522
+ }
523
+ function deleteDisplayBindingDebugHint(tree, filePath) {
524
+ const content = tree.read(filePath).toString();
525
+ const fileName = filePath.substring(filePath.lastIndexOf('/') + 1, filePath.length);
526
+ const sourceFile = ts.createSourceFile(`${fileName}`, content, ts.ScriptTarget.Latest, true);
527
+ const nodes = typescript_1.getSourceNodes(sourceFile);
528
+ const identifierNode = nodes.find(n => n.kind === ts.SyntaxKind.Identifier && n.getText() === 'luxComponentsConfig');
529
+ if (identifierNode) {
530
+ const objectNode = identifierNode.parent.getChildren().find(n => n.kind === ts.SyntaxKind.ObjectLiteralExpression);
531
+ if (objectNode) {
532
+ const syntaxListNode = objectNode.getChildren().find(n => n.kind === ts.SyntaxKind.SyntaxList);
533
+ if (syntaxListNode) {
534
+ const propertyAssignmentNodes = syntaxListNode
535
+ .getChildren()
536
+ .filter((n) => n.kind === ts.SyntaxKind.PropertyAssignment);
537
+ if (propertyAssignmentNodes) {
538
+ propertyAssignmentNodes.forEach((assignment) => {
539
+ const propertyIdentifierNode = assignment.getChildren().find((n) => n.kind === ts.SyntaxKind.Identifier);
540
+ if (propertyIdentifierNode && propertyIdentifierNode.getText() === 'displayBindingDebugHint') {
541
+ const prevSibling = typescript_1.getPrevSibling(assignment, ts.SyntaxKind.SyntaxList);
542
+ const nextSibling = typescript_1.getNextSibling(assignment, ts.SyntaxKind.SyntaxList);
543
+ const updateRecorder = tree.beginUpdate(filePath);
544
+ if (nextSibling) {
545
+ updateRecorder.remove(assignment.pos, nextSibling.end - assignment.pos);
546
+ }
547
+ else {
548
+ if (prevSibling) {
549
+ updateRecorder.remove(prevSibling.pos, assignment.end - prevSibling.pos);
550
+ }
551
+ else {
552
+ updateRecorder.remove(assignment.pos, assignment.end - assignment.pos);
553
+ }
554
+ }
555
+ logging_1.logInfo(`Aus der Konfiguration wurde die Property "displayBindingDebugHint" entfernt.`);
556
+ tree.commitUpdate(updateRecorder);
557
+ }
558
+ });
559
+ }
560
+ }
561
+ }
562
+ }
563
+ }
564
+ function updateConfiglookupServiceUrl(tree, filePath) {
565
+ const content = tree.read(filePath).toString();
566
+ const fileName = filePath.substring(filePath.lastIndexOf('/') + 1, filePath.length);
567
+ const sourceFile = ts.createSourceFile(`${fileName}`, content, ts.ScriptTarget.Latest, true);
568
+ const nodes = typescript_1.getSourceNodes(sourceFile);
569
+ const identifierNode = nodes.find(n => n.kind === ts.SyntaxKind.Identifier && n.getText() === 'luxComponentsConfig');
570
+ if (identifierNode) {
571
+ const objectNode = identifierNode.parent.getChildren().find(n => n.kind === ts.SyntaxKind.ObjectLiteralExpression);
572
+ if (objectNode) {
573
+ const syntaxListNode = objectNode.getChildren().find(n => n.kind === ts.SyntaxKind.SyntaxList);
574
+ if (syntaxListNode) {
575
+ const propertyAssignmentNodes = syntaxListNode
576
+ .getChildren()
577
+ .filter((n) => n.kind === ts.SyntaxKind.PropertyAssignment);
578
+ if (propertyAssignmentNodes) {
579
+ propertyAssignmentNodes.forEach((assignment) => {
580
+ const propertyIdentifierNode = assignment.getChildren().find((n) => n.kind === ts.SyntaxKind.Identifier);
581
+ const propertyStringNode = assignment.getChildren().find((n) => n.kind === ts.SyntaxKind.StringLiteral);
582
+ if (propertyIdentifierNode && propertyIdentifierNode.getText() === 'lookupServiceUrl' &&
583
+ propertyStringNode && (propertyStringNode.getText() === "'/lookup/'" || propertyStringNode.getText() === '"/lookup/"')) {
584
+ const prevSibling = typescript_1.getPrevSibling(assignment, ts.SyntaxKind.SyntaxList);
585
+ const nextSibling = typescript_1.getNextSibling(assignment, ts.SyntaxKind.SyntaxList);
586
+ const updateRecorder = tree.beginUpdate(filePath);
587
+ if (nextSibling) {
588
+ updateRecorder.remove(assignment.pos, nextSibling.end - assignment.pos);
589
+ }
590
+ else {
591
+ if (prevSibling) {
592
+ updateRecorder.remove(prevSibling.pos, assignment.end - prevSibling.pos);
593
+ }
594
+ else {
595
+ updateRecorder.remove(assignment.pos, assignment.end - assignment.pos);
596
+ }
597
+ }
598
+ logging_1.logInfo(`Aus der Konfiguration wurde die Property "lookupServiceUrl" entfernt. Der Wert entspricht dem Defaultwert.`);
599
+ tree.commitUpdate(updateRecorder);
600
+ }
601
+ });
602
+ }
603
+ }
604
+ }
605
+ }
606
+ }
607
+ function updateAppModule(options) {
608
+ return schematics_1.chain([
609
+ util_1.messageInfoRule(`AppModule wird aktualisiert...`),
610
+ (tree, context) => {
611
+ const filePath = (options.path ? options.path : '') + `/src/app/app.module.ts`;
612
+ updateConfigGenerateLuxTagIds(tree, filePath);
613
+ updateConfigLabelConfiguration(tree, filePath);
614
+ updateConfiglookupServiceUrl(tree, filePath);
615
+ deleteDisplayBindingDebugHint(tree, filePath);
616
+ typescript_1.removeImport(tree, filePath, '@ihk-gfi/lux-components', 'LuxAppFooterButtonService');
617
+ typescript_1.removeImport(tree, filePath, '@ihk-gfi/lux-components', 'LuxAppFooterLinkService');
618
+ typescript_1.removeImport(tree, filePath, '@ihk-gfi/lux-components', 'LuxSnackbarService');
619
+ typescript_1.removeImport(tree, filePath, '@ihk-gfi/lux-components', 'LuxErrorService');
620
+ typescript_1.removeImport(tree, filePath, '@ihk-gfi/lux-components', 'LuxMasterDetailMobileHelperService');
621
+ typescript_1.removeImport(tree, filePath, '@ihk-gfi/lux-components', 'LuxStepperHelperService');
622
+ typescript_1.removeImport(tree, filePath, '@ihk-gfi/lux-components', 'LuxConsoleService');
623
+ typescript_1.removeProvider(tree, filePath, 'LuxAppFooterButtonService');
624
+ typescript_1.removeProvider(tree, filePath, 'LuxAppFooterLinkService');
625
+ typescript_1.removeProvider(tree, filePath, 'LuxSnackbarService');
626
+ typescript_1.removeProvider(tree, filePath, 'LuxErrorService');
627
+ typescript_1.removeProvider(tree, filePath, 'LuxMasterDetailMobileHelperService');
628
+ typescript_1.removeProvider(tree, filePath, 'LuxStepperHelperService');
629
+ typescript_1.removeProvider(tree, filePath, 'LuxConsoleService');
630
+ },
631
+ util_1.messageSuccessRule(`AppModule wurde aktualisiert.`)
632
+ ]);
633
+ }
634
+ exports.updateAppModule = updateAppModule;
635
+ //# sourceMappingURL=index.js.map