@diplodoc/cli-tests 5.34.3 → 5.34.5

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.
@@ -71,9 +71,7 @@ export async function compareDirectories(
71
71
  nodir: true,
72
72
  posix: true,
73
73
  })
74
- )
75
- .map(bundleless)
76
- .sort();
74
+ ).sort();
77
75
 
78
76
  let filesForSnapshot;
79
77
 
@@ -87,7 +85,7 @@ export async function compareDirectories(
87
85
  // This is necessary for better test stability
88
86
  // We do not care in what order these files were received and processed
89
87
  // We sort only the final list and put it in the snapshot
90
- filesForSnapshot = filesForSnapshot.map(hashless).sort();
88
+ filesForSnapshot = filesForSnapshot.map(bundleless).map(hashless).sort();
91
89
 
92
90
  if (!ignoreFileList) {
93
91
  expect(JSON.stringify(filesForSnapshot, null, 2)).toMatchSnapshot('filelist');
@@ -39,11 +39,24 @@ export function bundleless(text: string): string {
39
39
  for (const [entryKey, entry] of Object.entries(assets)) {
40
40
  for (const [typeKey, type] of Object.entries(entry)) {
41
41
  for (let index = 0; index < type.length; index++) {
42
- let prev = '';
43
- while (prev !== text) {
44
- prev = text;
45
- text = text.replace(type[index], `${entryKey}-${typeKey}-${index}`);
42
+ // Extract base name from manifest filename (e.g. "app-3ff8bc0b40bc2914.js" -> "app")
43
+ // Also handles suffixes like "vendor-00121562c7b7d3b5.rtl.css" -> base="vendor", suffix=".rtl", ext="css"
44
+ const filename = type[index];
45
+ const match = filename.match(/^(.+?)-[a-z0-9]{12,16}(\.[a-z]+)*\.([a-z]+)$/);
46
+ if (!match) {
47
+ // Fallback: exact string replacement for filenames without hash pattern
48
+ let prev = '';
49
+ while (prev !== text) {
50
+ prev = text;
51
+ text = text.replace(filename, `${entryKey}-${typeKey}-${index}`);
52
+ }
53
+ continue;
46
54
  }
55
+
56
+ const [, base, suffixes, ext] = match;
57
+ const suffixPattern = suffixes ? suffixes.replace(/\./g, '\\.') : '';
58
+ const pattern = new RegExp(`${base}-[a-z0-9]{12,16}${suffixPattern}\\.${ext}`, 'g');
59
+ text = text.replace(pattern, `${entryKey}-${typeKey}-${index}`);
47
60
  }
48
61
  }
49
62
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@diplodoc/cli-tests",
3
- "version": "5.34.3",
3
+ "version": "5.34.5",
4
4
  "bin": {
5
5
  "diplodoc-cli-test": "bin.mjs"
6
6
  },