@ihk-gfi/lux-components-update 19.7.0 → 19.7.1

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ihk-gfi/lux-components-update",
3
- "version": "19.7.0",
3
+ "version": "19.7.1",
4
4
  "description": "Schematics für die Aktualisierung von LUX-Applikationen",
5
5
  "private": false,
6
6
  "publishConfig": {
@@ -45,7 +45,7 @@ function updateProject(options) {
45
45
  updateKarmaConfJs(options),
46
46
  updateMainTs(options),
47
47
  updateTestTs(options),
48
- (0, files_1.deleteFile)(options.path ?? '', '.eslintrc.json'),
48
+ (0, files_1.deleteFile)(options, '.eslintrc.json'),
49
49
  updateMessages(options),
50
50
  (0, util_1.messageSuccessRule)(`LUX-Components ${exports.updateMajorVersion} wurden aktualisiert.`)
51
51
  ]);
@@ -60,9 +60,6 @@ function deleteLineFromFile(tree, _context, filePath, searchString, withLog = tr
60
60
  }
61
61
  }
62
62
  }
63
- // Doppelte Zeilenumbrüche entfernen
64
- content = content.replace(new RegExp('\r\n', 'g'), '\r\n');
65
- content = content.replace(new RegExp('\r\n\r\n', 'g'), '\r\n');
66
63
  tree.overwrite(filePath, content);
67
64
  changed = true;
68
65
  }
@@ -105,6 +102,37 @@ function writeLinesToFile(tree, _context, filePath, ...lines) {
105
102
  (0, logging_1.logInfo)(`Erstelle die Datei "${filePath}" und füge Inhalt hinzu.`);
106
103
  }
107
104
  }
105
+ function isIgnoredPath(filePath, ignoreSpecFiles = false) {
106
+ if (['/node_modules/', '/.idea/', '/coverage/', '/dist/', '/.git/', '/.angular/', '/.cache/', '/tmp/', '/out/', '/src-gen/'].some((segment) => filePath.includes(segment))) {
107
+ return true;
108
+ }
109
+ return ignoreSpecFiles && filePath.endsWith('.spec.ts');
110
+ }
111
+ /**
112
+ * Traversiert Verzeichnisse rekursiv, bricht aber früh ab, wenn ein Verzeichnis
113
+ * in den Ignore-Regeln ist. Dadurch wird das Betreten großer Ordner wie
114
+ * node_modules verhindert und die Laufzeit erheblich verbessert.
115
+ */
116
+ function visitWithPrune(tree, startDirPath, fileCallback, ignoreSpecFiles = false) {
117
+ const dir = tree.getDir(startDirPath);
118
+ if (!dir) {
119
+ return;
120
+ }
121
+ // Prüfen, ob das gesamte Verzeichnis ignoriert werden soll
122
+ if (isIgnoredPath(dir.path + '/', ignoreSpecFiles)) {
123
+ return;
124
+ }
125
+ // Dateien im aktuellen Verzeichnis verarbeiten
126
+ dir.subfiles.forEach((fileName) => {
127
+ const filePath = (0, core_1.join)(dir.path, fileName);
128
+ fileCallback(filePath);
129
+ });
130
+ // Rekursiv in Unterverzeichnisse gehen (nur die erlaubten)
131
+ dir.subdirs.forEach((subdir) => {
132
+ const subdirPath = `${dir.path}/${subdir}`;
133
+ visitWithPrune(tree, subdirPath, fileCallback, ignoreSpecFiles);
134
+ });
135
+ }
108
136
  /**
109
137
  * Iteriert über alle Dateien vom Root-Pfad aus.
110
138
  * Über die filePathEndings lassen sich Einschränkungen bzgl. des Datei-Typs festlegen (z.B. .html).
@@ -114,18 +142,15 @@ function writeLinesToFile(tree, _context, filePath, ...lines) {
114
142
  * @param callback(filePath, content)
115
143
  * @param filePathEndings Z.B. .html, .ts, src/styles.scss,...
116
144
  */
117
- function iterateFilesAndModifyContent(tree, rootPath = '', callback, ...filePathEndings) {
118
- tree.getDir(rootPath).visit((filePath) => {
119
- // Ignoriere folende Odner
120
- if (filePath.startsWith('/node_modules/') ||
121
- filePath.startsWith('/.idea/') ||
122
- filePath.startsWith('/coverage/') ||
123
- filePath.startsWith('/dist/')) {
124
- return;
125
- }
145
+ function iterateFilesAndModifyContent(tree, rootPath = '', verbose = false, callback, ...filePathEndings) {
146
+ const normalizedRootPath = rootPath && rootPath.trim() ? rootPath.trim() : '/';
147
+ if (verbose) {
148
+ (0, logging_1.logDebug)(`Suche nach "${filePathEndings.length > 0 ? filePathEndings.join(', ') : 'allen'}" Dateien unter dem Pfad "${normalizedRootPath}"...`);
149
+ }
150
+ visitWithPrune(tree, normalizedRootPath, (filePath) => {
126
151
  // Endung der Datei mit erlaubten Endungen abgleichen
127
152
  let modifyFile = false;
128
- for (let fileEnding of filePathEndings) {
153
+ for (const fileEnding of filePathEndings) {
129
154
  if (filePath.endsWith(fileEnding)) {
130
155
  modifyFile = true;
131
156
  break;
@@ -133,8 +158,14 @@ function iterateFilesAndModifyContent(tree, rootPath = '', callback, ...filePath
133
158
  }
134
159
  // Besitzt die Datei die richtige Endung?
135
160
  if (!modifyFile) {
161
+ if (verbose) {
162
+ (0, logging_1.logDebug)(`${filePath} wurde übersprungen...`);
163
+ }
136
164
  return;
137
165
  }
166
+ if (verbose) {
167
+ (0, logging_1.logDebug)(`${filePath} wird verarbeitet...`);
168
+ }
138
169
  // Inhalt auslesen
139
170
  const content = tree.read(filePath);
140
171
  // Wenn die Datei keinen Inhalt hat, die nächste Datei aufrufen
@@ -143,6 +174,9 @@ function iterateFilesAndModifyContent(tree, rootPath = '', callback, ...filePath
143
174
  }
144
175
  // Callback mit aktuellem Pfad + Inhalt der Datei aufrufen
145
176
  callback(filePath, content.toString());
177
+ if (verbose) {
178
+ (0, logging_1.logInfo)(`${filePath} wurde verarbeitet.`);
179
+ }
146
180
  });
147
181
  }
148
182
  /**
@@ -216,18 +250,10 @@ function deleteFilesInDirectory(options, path, exclude) {
216
250
  };
217
251
  }
218
252
  function searchInComponentAndModifyModule(tree, rootPath, searchStrings, callback, ...filePathEndings) {
219
- tree.getDir(rootPath).visit((filePath) => {
220
- // Ignoriere folende Odner
221
- if (filePath.startsWith('/node_modules/') ||
222
- filePath.startsWith('/.idea/') ||
223
- filePath.startsWith('/coverage/') ||
224
- filePath.startsWith('/dist/') ||
225
- filePath.endsWith('.spec.ts')) {
226
- return;
227
- }
253
+ visitWithPrune(tree, rootPath, (filePath) => {
228
254
  // Endung der Datei mit erlaubten Endungen abgleichen
229
255
  let modifyFile = false;
230
- for (let fileEnding of filePathEndings) {
256
+ for (const fileEnding of filePathEndings) {
231
257
  if (filePath.endsWith(fileEnding)) {
232
258
  modifyFile = true;
233
259
  break;
@@ -255,12 +281,12 @@ function searchInComponentAndModifyModule(tree, rootPath, searchStrings, callbac
255
281
  // den Ordner der gefundenen Datei nehmen
256
282
  const fileDir = filePath.substring(0, filePath.lastIndexOf('/'));
257
283
  const modulePath = findModule(tree, fileDir);
258
- let moduleContent = tree.read(modulePath);
284
+ const moduleContent = tree.read(modulePath);
259
285
  if (moduleContent) {
260
286
  // Callback mit aktuellem Pfad + Inhalt der Datei aufrufen
261
287
  callback(modulePath, moduleContent.toString());
262
288
  }
263
- });
289
+ }, true);
264
290
  }
265
291
  /**
266
292
  * Function to find the "closest" module to a generated file's path.
@@ -315,7 +341,7 @@ function replaceRule(options, startMsg, endMsg, filePattern, ...replaceItems) {
315
341
  return (0, schematics_1.chain)([
316
342
  (0, util_1.messageInfoRule)(startMsg),
317
343
  (tree, _context) => {
318
- iterateFilesAndModifyContent(tree, options.path, (filePath, content) => {
344
+ iterateFilesAndModifyContent(tree, options.path, !!options.verbose, (filePath, content) => {
319
345
  let result = content;
320
346
  replaceItems.forEach((item) => {
321
347
  if (typeof item.find === 'string') {
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.formattedSchematicsException = exports.logError = exports.logWarn = exports.logSuccess = exports.logInfo = exports.logInfoWithDescriptor = exports.TAB = void 0;
3
+ exports.formattedSchematicsException = exports.logError = exports.logWarn = exports.logSuccess = exports.logInfo = exports.logDebug = exports.logInfoWithDescriptor = exports.TAB = void 0;
4
4
  const schematics_1 = require("@angular-devkit/schematics");
5
5
  const chalk = require("chalk");
6
6
  exports.TAB = '\t ';
@@ -9,16 +9,25 @@ exports.TAB = '\t ';
9
9
  * @param messages
10
10
  */
11
11
  const logInfoWithDescriptor = (...messages) => {
12
- let message = generateLogMessage(...messages);
12
+ const message = generateLogMessage(...messages);
13
13
  console.log(chalk.blueBright(`[INFO]${exports.TAB}${message}`));
14
14
  };
15
15
  exports.logInfoWithDescriptor = logInfoWithDescriptor;
16
+ /**
17
+ * Erzeugt eine Info-Log-Ausgabe in hellem Weiß ohne Icon.
18
+ * @param messages
19
+ */
20
+ const logDebug = (...messages) => {
21
+ const message = generateLogMessage(...messages);
22
+ console.log(chalk.grey(`${exports.TAB}${message}`));
23
+ };
24
+ exports.logDebug = logDebug;
16
25
  /**
17
26
  * Erzeugt eine Info-Log-Ausgabe in hellem Weiß ohne Icon.
18
27
  * @param messages
19
28
  */
20
29
  const logInfo = (...messages) => {
21
- let message = generateLogMessage(...messages);
30
+ const message = generateLogMessage(...messages);
22
31
  console.log(chalk.whiteBright(`${exports.TAB}${message}`));
23
32
  };
24
33
  exports.logInfo = logInfo;
@@ -27,7 +36,7 @@ exports.logInfo = logInfo;
27
36
  * @param messages
28
37
  */
29
38
  const logSuccess = (...messages) => {
30
- let message = generateLogMessage(...messages);
39
+ const message = generateLogMessage(...messages);
31
40
  console.log(chalk.yellowBright(`[SUCCESS] ${message}`));
32
41
  };
33
42
  exports.logSuccess = logSuccess;
@@ -36,7 +45,7 @@ exports.logSuccess = logSuccess;
36
45
  * @param messages
37
46
  */
38
47
  const logWarn = (...messages) => {
39
- let message = generateLogMessage(...messages);
48
+ const message = generateLogMessage(...messages);
40
49
  console.log(chalk.yellowBright(`[WARN] ${message}`));
41
50
  };
42
51
  exports.logWarn = logWarn;
@@ -56,7 +65,7 @@ exports.logError = logError;
56
65
  * @constructor
57
66
  */
58
67
  const formattedSchematicsException = (...messages) => {
59
- let message = generateLogMessage(...messages);
68
+ const message = generateLogMessage(...messages);
60
69
  // Die eigentliche Exception zum Aufrufer zurückgeben '
61
70
  return new schematics_1.SchematicsException(`[ERROR] ${message}`);
62
71
  };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });