@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,355 @@
1
+ import { join, Path, strings } from '@angular-devkit/core';
2
+ import {
3
+ apply,
4
+ DirEntry,
5
+ forEach,
6
+ MergeStrategy,
7
+ mergeWith,
8
+ Rule,
9
+ SchematicContext,
10
+ template,
11
+ Tree,
12
+ url
13
+ } from '@angular-devkit/schematics';
14
+ import { logInfo, logInfoWithDescriptor, logSuccess } from './logging';
15
+
16
+ /**
17
+ * Entfernt eine Zeile aus der Datei, die den searchString beinhaltet.
18
+ * Gibt eine Log-Ausgabe aus, wenn die Datei nicht gefunden werden konnte.
19
+ * @param tree
20
+ * @param context
21
+ * @param filePath
22
+ * @param searchString
23
+ */
24
+ export function deleteLineFromFile(tree: Tree, context: SchematicContext, filePath: string, searchString: string) {
25
+ const fileContent: Buffer | null = tree.read(filePath);
26
+ if (fileContent) {
27
+ // String der Datei erhalten
28
+ let content: string = fileContent.toString();
29
+
30
+ if (content.indexOf(searchString) !== -1) {
31
+ // Standard-Separator
32
+ let separator = '\r\n';
33
+
34
+ // Wenn nicht gefunden, nur \n als Separator nutzen
35
+ if (content.indexOf(separator) === -1) {
36
+ separator = '\n';
37
+ }
38
+
39
+ // Alle Zeilen der Datei erhalten
40
+ const lines: string[] = content.split(separator);
41
+
42
+ // Lines iterieren und nach der dependency suchen
43
+ for (let i = 0; i < lines.length; i++) {
44
+ // Wenn gefunden, die Zeile entfernen
45
+ if (lines[i].indexOf(searchString) > -1) {
46
+ content = content.replace(lines[i], '');
47
+
48
+ // Sonderbehandlung für die .json-Dateien
49
+ // Wenn man aus einem Block die letzte Zeile entfernt,
50
+ // muss in der Zeile davor das Komma entfernt werden.
51
+ // Beispiel:
52
+ // "dependencies": {
53
+ // "@angular/common": "9.1.0",
54
+ // "lux-components": "1.8.3"
55
+ // },
56
+ // Entfernt man die Zeile "lux-components...",
57
+ // muss das Komma aus der Zeile "@angular/common..." ebenfalls
58
+ // entfernt werden, sonst ist dsa Json ungültig.
59
+ if (filePath.endsWith('.json') && i + 1 < lines.length) {
60
+ if (i > 0 && (lines[i + 1].trim() === '}' || lines[i + 1].trim() === '},')) {
61
+ content = content.replace(lines[i - 1], lines[i - 1].substring(0, lines[i - 1].lastIndexOf(',')));
62
+ }
63
+ }
64
+ }
65
+ }
66
+ // Doppelte Zeilenumbrüche entfernen
67
+ content = content.replace(new RegExp('\r\n', 'g'), '\r\n');
68
+ content = content.replace(new RegExp('\r\n\r\n', 'g'), '\r\n');
69
+
70
+ tree.overwrite(filePath, content);
71
+ } else {
72
+ logInfo(`Die Datei "${filePath}" enthält den String "${searchString}" nicht.`);
73
+ }
74
+ } else {
75
+ logInfo(`Die Datei "${filePath}" wurde nicht gefunden.`);
76
+ }
77
+ }
78
+
79
+ /**
80
+ * Schreibt die übergebenen Zeilen in die Datei.
81
+ * Wenn die Datei existiert, wird der neue Inhalt am Ende der Datei angehangen.
82
+ * Wenn die Datei nicht exitiert, wird diese mit dem Inhalt erstellt.
83
+ * @param tree
84
+ * @param context
85
+ * @param filePath
86
+ * @param lines
87
+ */
88
+ export function writeLinesToFile(tree: Tree, context: SchematicContext, filePath: string, ...lines: string[]) {
89
+ const fileContent: Buffer | null = tree.read(filePath);
90
+ let content: string = '';
91
+
92
+ lines.forEach((line: string) => {
93
+ if (fileContent && fileContent.toString().indexOf(line) === -1) {
94
+ content += line + '\r\n';
95
+ }
96
+ });
97
+
98
+ if (fileContent !== null) {
99
+ tree.overwrite(filePath, fileContent.toString() + '\r\n' + content);
100
+ logInfo(`Überschreibe die Datei "${filePath}".`);
101
+ } else {
102
+ tree.create(filePath, content);
103
+ logInfo(`Erstelle die Datei "${filePath}" und füge Inhalt hinzu.`);
104
+ }
105
+ }
106
+
107
+ /**
108
+ * Iteriert über alle Dateien vom Root-Pfad aus.
109
+ * Über die filePathEndings lassen sich Einschränkungen bzgl. des Datei-Typs festlegen (z.B. .html).
110
+ * Wenn eine Datei die passende Endung und Inhalt hat, wird der Callback mit Pfad und Content aufgerufen.
111
+ * @param tree
112
+ * @param rootPath
113
+ * @param callback(filePath, content)
114
+ * @param filePathEndings Z.B. .html, .ts, src/styles.scss,...
115
+ */
116
+ export function iterateFilesAndModifyContent(
117
+ tree: Tree,
118
+ rootPath: string = '',
119
+ callback: Function,
120
+ ...filePathEndings: string[]
121
+ ) {
122
+ tree.getDir(rootPath).visit((filePath: string) => {
123
+ // Ignoriere folende Odner
124
+ if (
125
+ filePath.startsWith('/node_modules/') ||
126
+ filePath.startsWith('/.idea/') ||
127
+ filePath.startsWith('/coverage/') ||
128
+ filePath.startsWith('/dist/')
129
+ ) {
130
+ return;
131
+ }
132
+
133
+ // Endung der Datei mit erlaubten Endungen abgleichen
134
+ let modifyFile: boolean = false;
135
+ for (let fileEnding of filePathEndings) {
136
+ if (filePath.endsWith(fileEnding)) {
137
+ modifyFile = true;
138
+ break;
139
+ }
140
+ }
141
+ // Besitzt die Datei die richtige Endung?
142
+ if (!modifyFile) {
143
+ return;
144
+ }
145
+ // Inhalt auslesen
146
+ const content = tree.read(filePath);
147
+ // Wenn die Datei keinen Inhalt hat, die nächste Datei aufrufen
148
+ if (!content) {
149
+ return;
150
+ }
151
+
152
+ // Callback mit aktuellem Pfad + Inhalt der Datei aufrufen
153
+ callback(filePath, content.toString());
154
+ });
155
+ }
156
+
157
+ /**
158
+ * Diese Methode ersetzt die angegebene Dateien. Sollten diese nicht existieren, werden sie neu angelegt.
159
+ *
160
+ * @param options Die Optionen.
161
+ * @param sourcePath Ein Quellpfad (z.B. files/theming für alle Dateien unter /theming).
162
+ * @param targetPath Ein Zielpfad (z.B. src/theming/).
163
+ */
164
+ export function moveFilesToDirectory(options: any, sourcePath: string, targetPath: string): Rule {
165
+ return (tree: Tree, context: SchematicContext) => {
166
+ if (!targetPath.startsWith('/')) {
167
+ targetPath = '/' + targetPath;
168
+ }
169
+ if (!sourcePath.startsWith('/')) {
170
+ sourcePath = '/' + sourcePath;
171
+ }
172
+
173
+ targetPath = (options.path ? options.path : '') + targetPath;
174
+
175
+ const templateSource = apply(url('.' + sourcePath), [
176
+ template({
177
+ ...strings,
178
+ ...options
179
+ }),
180
+ forEach((file) => {
181
+ let newTargetPath = targetPath + file.path;
182
+ newTargetPath = newTargetPath.replace('//', '/');
183
+
184
+ if (tree.exists(newTargetPath)) {
185
+ tree.overwrite(newTargetPath, file.content);
186
+ logInfo(`Datei '${newTargetPath}' aktualisiert.`);
187
+ } else {
188
+ tree.create(newTargetPath, file.content);
189
+ logInfo(`Datei '${newTargetPath}' angelegt.`);
190
+ }
191
+ return null;
192
+ })
193
+ ]);
194
+
195
+ return mergeWith(templateSource, MergeStrategy.Overwrite);
196
+ };
197
+ }
198
+
199
+ /**
200
+ * Diese Methode löscht die Dateien in dem angegebenen Ordner.
201
+ *
202
+ * @param options Die Optionen.
203
+ * @param path Der Pfad.
204
+ * @param exclude Ein Array mit Dateinamen, die nicht gelöscht werden sollen.
205
+ */
206
+ export function deleteFilesInDirectory(options: any, path: string, exclude: string[]): Rule {
207
+ return (tree: Tree, context: SchematicContext) => {
208
+ if (!path.startsWith('/')) {
209
+ path = '/' + path;
210
+ }
211
+
212
+ if (!path.endsWith('/')) {
213
+ path = path + '/';
214
+ }
215
+
216
+ path = (options.path ? options.path : '') + path;
217
+
218
+ const dir = tree.getDir(path);
219
+ if (dir) {
220
+ dir.subfiles.forEach((filePath) => {
221
+ if (!exclude.find((excludeFilePath) => excludeFilePath === filePath)) {
222
+ tree.delete(path + filePath);
223
+ logInfo(filePath + ' gelöscht.');
224
+ }
225
+ });
226
+ }
227
+
228
+ return tree;
229
+ };
230
+ }
231
+
232
+ export function searchInComponentAndModifyModule(
233
+ tree: Tree,
234
+ rootPath: string,
235
+ searchStrings: string[],
236
+ callback: Function,
237
+ ...filePathEndings: string[]
238
+ ) {
239
+ tree.getDir(rootPath).visit((filePath: string) => {
240
+ // Ignoriere folende Odner
241
+ if (
242
+ filePath.startsWith('/node_modules/') ||
243
+ filePath.startsWith('/.idea/') ||
244
+ filePath.startsWith('/coverage/') ||
245
+ filePath.startsWith('/dist/') ||
246
+ filePath.endsWith('.spec.ts')
247
+ ) {
248
+ return;
249
+ }
250
+
251
+ // Endung der Datei mit erlaubten Endungen abgleichen
252
+ let modifyFile: boolean = false;
253
+ for (let fileEnding of filePathEndings) {
254
+ if (filePath.endsWith(fileEnding)) {
255
+ modifyFile = true;
256
+ break;
257
+ }
258
+ }
259
+ // Besitzt die Datei die richtige Endung?
260
+ if (!modifyFile) {
261
+ return;
262
+ }
263
+ // Inhalt auslesen
264
+ const content = tree.read(filePath);
265
+ // Wenn die Datei keinen Inhalt hat, die nächste Datei aufrufen
266
+ if (!content) {
267
+ return;
268
+ }
269
+
270
+ let foundSearchString: string = '';
271
+ searchStrings.forEach((searchString: string) => {
272
+ if (!foundSearchString && content.toString().indexOf(searchString) > -1) {
273
+ foundSearchString = searchString;
274
+ }
275
+ });
276
+
277
+ if (!foundSearchString) {
278
+ return;
279
+ }
280
+
281
+ // den Ordner der gefundenen Datei nehmen
282
+ const fileDir = filePath.substring(0, filePath.lastIndexOf('/'));
283
+ const modulePath: Path = findModule(tree, fileDir);
284
+ let moduleContent = tree.read(modulePath);
285
+ if (moduleContent) {
286
+ // Callback mit aktuellem Pfad + Inhalt der Datei aufrufen
287
+ callback(modulePath, moduleContent.toString());
288
+ }
289
+ });
290
+ }
291
+
292
+ /**
293
+ * Function to find the "closest" module to a generated file's path.
294
+ *
295
+ * Source: https://github.com/angular/angular-cli/blob/master/packages/schematics/angular/utility/find-module.ts
296
+ */
297
+ export function findModule(
298
+ host: Tree,
299
+ generateDir: string,
300
+ moduleExt = '.module.ts',
301
+ routingModuleExt = '-routing.module.ts'
302
+ ): Path {
303
+ let dir: DirEntry | null = host.getDir('/' + generateDir);
304
+ let foundRoutingModule = false;
305
+
306
+ while (dir) {
307
+ const allMatches = dir.subfiles.filter((p) => p.endsWith(moduleExt));
308
+ const filteredMatches = allMatches.filter((p) => !p.endsWith(routingModuleExt));
309
+
310
+ foundRoutingModule = foundRoutingModule || allMatches.length !== filteredMatches.length;
311
+
312
+ if (filteredMatches.length == 1) {
313
+ return join(dir.path, filteredMatches[0]);
314
+ } else if (filteredMatches.length > 1) {
315
+ throw new Error(
316
+ 'More than one module matches. Use skip-import option to skip importing ' +
317
+ 'the component into the closest module.'
318
+ );
319
+ }
320
+
321
+ dir = dir.parent;
322
+ }
323
+
324
+ const errorMsg = foundRoutingModule
325
+ ? 'Could not find a non Routing NgModule.' +
326
+ `\nModules with suffix '${routingModuleExt}' are strictly reserved for routing.` +
327
+ '\nUse the skip-import option to skip importing in NgModule.'
328
+ : 'Could not find an NgModule. Use the skip-import option to skip importing in NgModule.';
329
+
330
+ throw new Error(errorMsg);
331
+ }
332
+
333
+ /**
334
+ * Löscht die Datei aus dem gegebenen Pfad.
335
+ * @param options
336
+ * @param targetPath
337
+ */
338
+ export function deleteFile(options: any, targetPath: string): Rule {
339
+ return (tree: Tree, context: SchematicContext) => {
340
+ logInfoWithDescriptor('Lösche Datei ' + targetPath + '.');
341
+ if (!targetPath.startsWith('/')) {
342
+ targetPath = '/' + targetPath;
343
+ }
344
+
345
+ targetPath = (options.path ? options.path : '') + targetPath;
346
+
347
+ if (tree.exists(targetPath)) {
348
+ tree.delete(targetPath);
349
+ logSuccess(targetPath + ' erfolgreich gelöscht.');
350
+ } else {
351
+ logSuccess(targetPath + ' konnte nicht gefunden werden.');
352
+ }
353
+ return tree;
354
+ };
355
+ }
@@ -0,0 +1,49 @@
1
+ export declare class CheerioInfo {
2
+ content: string;
3
+ updated: boolean;
4
+ constructor(content: string);
5
+ }
6
+ /**
7
+ * Diese Methode fügt ein neues Attribut hinzu, das zum Selektor passt.
8
+ *
9
+ * @param content
10
+ * @param selector
11
+ * @param attrName
12
+ * @param attrValue
13
+ */
14
+ export declare function addAttribute(content: string, selector: string, attrName: string, attrValue: string): CheerioInfo;
15
+ /**
16
+ * Diese Methode fügt den Wert ans Ende des Attributwertes an, das zum Selektor passt.
17
+ *
18
+ * @param content
19
+ * @param selector
20
+ * @param attrName
21
+ * @param attrValue
22
+ */
23
+ export declare function appendAttribute(content: string, selector: string, attrName: string, attrValue: string): CheerioInfo;
24
+ /**
25
+ * Diese Methode benennt ein Attribut um, die zum Selektor passen.
26
+ *
27
+ * @param content Der Inhalt eines HTML-Templates.
28
+ * @param selector Ein beliebiger Selektor (z.B. lux-list).
29
+ * @param attrNameOld Ein beliebiger Attributname (z.B. luxItem).
30
+ * @param attrNameNew Ein beliebiger neuer Attributname.
31
+ */
32
+ export declare function renameAttribute(content: string, selector: string, attrNameOld: string, attrNameNew: string): CheerioInfo;
33
+ /**
34
+ * Diese Methode setzt den neuen Wert für das Attribut, die zum Selektor passen.
35
+ *
36
+ * @param content Der Inhalt eines HTML-Templates.
37
+ * @param selector Ein beliebiger Selektor (z.B. lux-list).
38
+ * @param attrName Ein beliebiger Attributname (z.B. luxItem).
39
+ * @param attrValue Ein beliebiger Wert.
40
+ */
41
+ export declare function updateAttribute(content: string, selector: string, attrName: string, attrValue: string): CheerioInfo;
42
+ /**
43
+ * Diese Methode entfernt das Attribut für alle Elemente, die zum Selektor passen.
44
+ *
45
+ * @param content Der Inhalt eines HTML-Templates.
46
+ * @param selector Ein beliebiger Selektor (z.B. lux-list).
47
+ * @param attrName Ein beliebiger Attributname (z.B. luxListItem).
48
+ */
49
+ export declare function removeAttribute(content: string, selector: string, attrName: string): CheerioInfo;
@@ -0,0 +1,183 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.removeAttribute = exports.updateAttribute = exports.renameAttribute = exports.appendAttribute = exports.addAttribute = exports.CheerioInfo = void 0;
4
+ const cheerio = require('cheerio');
5
+ const luxCherioParserOptions = { xmlMode: true, decodeEntities: false, selfClosingTags: false };
6
+ class CheerioInfo {
7
+ constructor(content) {
8
+ this.content = content;
9
+ this.updated = false;
10
+ }
11
+ }
12
+ exports.CheerioInfo = CheerioInfo;
13
+ /**
14
+ * Diese Methode fügt ein neues Attribut hinzu, das zum Selektor passt.
15
+ *
16
+ * @param content
17
+ * @param selector
18
+ * @param attrName
19
+ * @param attrValue
20
+ */
21
+ function addAttribute(content, selector, attrName, attrValue) {
22
+ const $ = cheerio.load(content, luxCherioParserOptions);
23
+ const result = new CheerioInfo(content);
24
+ $(selector).each(function (i, elem) {
25
+ $(elem).attr(attrName, attrValue);
26
+ result.updated = true;
27
+ });
28
+ if (result.updated) {
29
+ result.content = $.xml();
30
+ }
31
+ return result;
32
+ }
33
+ exports.addAttribute = addAttribute;
34
+ /**
35
+ * Diese Methode fügt den Wert ans Ende des Attributwertes an, das zum Selektor passt.
36
+ *
37
+ * @param content
38
+ * @param selector
39
+ * @param attrName
40
+ * @param attrValue
41
+ */
42
+ function appendAttribute(content, selector, attrName, attrValue) {
43
+ const $ = cheerio.load(content, luxCherioParserOptions);
44
+ const result = new CheerioInfo(content);
45
+ $(selector).each(function (i, elem) {
46
+ $(elem).attr(attrName, $(elem).attr(attrName) + attrValue);
47
+ result.updated = true;
48
+ });
49
+ if (result.updated) {
50
+ result.content = $.xml();
51
+ }
52
+ return result;
53
+ }
54
+ exports.appendAttribute = appendAttribute;
55
+ /**
56
+ * Diese Methode benennt ein Attribut um, die zum Selektor passen.
57
+ *
58
+ * @param content Der Inhalt eines HTML-Templates.
59
+ * @param selector Ein beliebiger Selektor (z.B. lux-list).
60
+ * @param attrNameOld Ein beliebiger Attributname (z.B. luxItem).
61
+ * @param attrNameNew Ein beliebiger neuer Attributname.
62
+ */
63
+ function renameAttribute(content, selector, attrNameOld, attrNameNew) {
64
+ const $ = cheerio.load(content, luxCherioParserOptions);
65
+ const result = new CheerioInfo(content);
66
+ $(selector).each(function (i, elem) {
67
+ const attrNameNoBindingOld = attrNameOld;
68
+ const attrNameNoBindingNew = attrNameNew;
69
+ const attrValueNoBinding = $(elem).attr(attrNameNoBindingOld);
70
+ if (attrValueNoBinding) {
71
+ $(elem).removeAttr(attrNameNoBindingOld);
72
+ $(elem).attr(attrNameNoBindingNew, attrValueNoBinding);
73
+ result.updated = true;
74
+ }
75
+ const attrNameDataBindingOld = '[' + attrNameOld + ']';
76
+ const attrNameDataBindingNew = '[' + attrNameNew + ']';
77
+ const attrNameDataBindingValue = $(elem).attr(attrNameDataBindingOld);
78
+ if (attrNameDataBindingValue) {
79
+ $(elem).removeAttr(attrNameDataBindingOld);
80
+ $(elem).attr(attrNameDataBindingNew, attrNameDataBindingValue);
81
+ result.updated = true;
82
+ }
83
+ const attrNameTwoWayBindingOld = '[(' + attrNameOld + ')]';
84
+ const attrNameTwoWayBindingNew = '[(' + attrNameNew + ')]';
85
+ const attrValueTwoWayBinding = $(elem).attr(attrNameTwoWayBindingOld);
86
+ if (attrValueTwoWayBinding) {
87
+ $(elem).removeAttr(attrNameTwoWayBindingOld);
88
+ $(elem).attr(attrNameTwoWayBindingNew, attrValueTwoWayBinding);
89
+ result.updated = true;
90
+ }
91
+ const attrNameEventBindingOld = '(' + attrNameOld + ')';
92
+ const attrNameEventBindingNew = '(' + attrNameNew + ')';
93
+ const attrValueEventBinding = $(elem).attr(attrNameEventBindingOld);
94
+ if (attrValueEventBinding) {
95
+ $(elem).removeAttr(attrNameEventBindingOld);
96
+ $(elem).attr(attrNameEventBindingNew, attrValueEventBinding);
97
+ result.updated = true;
98
+ }
99
+ });
100
+ if (result.updated) {
101
+ result.content = $.xml();
102
+ }
103
+ return result;
104
+ }
105
+ exports.renameAttribute = renameAttribute;
106
+ /**
107
+ * Diese Methode setzt den neuen Wert für das Attribut, die zum Selektor passen.
108
+ *
109
+ * @param content Der Inhalt eines HTML-Templates.
110
+ * @param selector Ein beliebiger Selektor (z.B. lux-list).
111
+ * @param attrName Ein beliebiger Attributname (z.B. luxItem).
112
+ * @param attrValue Ein beliebiger Wert.
113
+ */
114
+ function updateAttribute(content, selector, attrName, attrValue) {
115
+ const $ = cheerio.load(content, luxCherioParserOptions);
116
+ const result = new CheerioInfo(content);
117
+ $(selector).each(function (i, elem) {
118
+ const attrNameNoBinding = attrName;
119
+ if ($(elem).attr(attrNameNoBinding)) {
120
+ $(elem).attr(attrNameNoBinding, attrValue);
121
+ result.updated = true;
122
+ }
123
+ const attrNameDataBinding = '[' + attrName + ']';
124
+ if ($(elem).attr(attrNameDataBinding)) {
125
+ $(elem).attr(attrNameDataBinding, attrValue);
126
+ result.updated = true;
127
+ }
128
+ const attrNameTwoWayBinding = '[(' + attrName + ')]';
129
+ if ($(elem).attr(attrNameTwoWayBinding)) {
130
+ $(elem).attr(attrNameTwoWayBinding, attrValue);
131
+ result.updated = true;
132
+ }
133
+ const attrNameEventBinding = '(' + attrName + ')';
134
+ if ($(elem).attr(attrNameEventBinding)) {
135
+ $(elem).attr(attrNameEventBinding, attrValue);
136
+ result.updated = true;
137
+ }
138
+ });
139
+ if (result.updated) {
140
+ result.content = $.xml();
141
+ }
142
+ return result;
143
+ }
144
+ exports.updateAttribute = updateAttribute;
145
+ /**
146
+ * Diese Methode entfernt das Attribut für alle Elemente, die zum Selektor passen.
147
+ *
148
+ * @param content Der Inhalt eines HTML-Templates.
149
+ * @param selector Ein beliebiger Selektor (z.B. lux-list).
150
+ * @param attrName Ein beliebiger Attributname (z.B. luxListItem).
151
+ */
152
+ function removeAttribute(content, selector, attrName) {
153
+ const $ = cheerio.load(content, luxCherioParserOptions);
154
+ const result = new CheerioInfo(content);
155
+ $(selector).each(function (i, elem) {
156
+ const attrNameNoBinding = attrName;
157
+ if ($(elem).attr(attrNameNoBinding)) {
158
+ $(elem).removeAttr(attrNameNoBinding);
159
+ result.updated = true;
160
+ }
161
+ const attrNameDataBinding = '[' + attrName + ']';
162
+ if ($(elem).attr(attrNameDataBinding)) {
163
+ $(elem).removeAttr(attrNameDataBinding);
164
+ result.updated = true;
165
+ }
166
+ const attrNameTwoWayBinding = '[(' + attrName + ')]';
167
+ if ($(elem).attr(attrNameTwoWayBinding)) {
168
+ $(elem).removeAttr(attrNameTwoWayBinding);
169
+ result.updated = true;
170
+ }
171
+ const attrNameEventBinding = '(' + attrName + ')';
172
+ if ($(elem).attr(attrNameEventBinding)) {
173
+ $(elem).removeAttr(attrNameEventBinding);
174
+ result.updated = true;
175
+ }
176
+ });
177
+ if (result.updated) {
178
+ result.content = $.xml();
179
+ }
180
+ return result;
181
+ }
182
+ exports.removeAttribute = removeAttribute;
183
+ //# sourceMappingURL=html.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"html.js","sourceRoot":"","sources":["html.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;AAEnC,MAAM,sBAAsB,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,KAAK,EAAE,eAAe,EAAE,KAAK,EAAE,CAAC;AAEhG,MAAa,WAAW;IAItB,YAAY,OAAe;QACzB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;IACvB,CAAC;CACF;AARD,kCAQC;AAED;;;;;;;GAOG;AACH,SAAgB,YAAY,CAAC,OAAe,EAAE,QAAgB,EAAE,QAAgB,EAAE,SAAiB;IACjG,MAAM,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,sBAAsB,CAAC,CAAC;IAExD,MAAM,MAAM,GAAG,IAAI,WAAW,CAAC,OAAO,CAAC,CAAC;IAExC,CAAC,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,IAAI;QAChC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;QAClC,MAAM,CAAC,OAAO,GAAG,IAAI,CAAC;IACxB,CAAC,CAAC,CAAC;IAEH,IAAI,MAAM,CAAC,OAAO,EAAE;QAClB,MAAM,CAAC,OAAO,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC;KAC1B;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAfD,oCAeC;AAED;;;;;;;GAOG;AACH,SAAgB,eAAe,CAAC,OAAe,EAAE,QAAgB,EAAE,QAAgB,EAAE,SAAiB;IACpG,MAAM,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,sBAAsB,CAAC,CAAC;IAExD,MAAM,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