cadet-agent 0.20.0 → 0.20.2

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 (2) hide show
  1. package/package.json +1 -1
  2. package/src/install.mjs +15 -11
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cadet-agent",
3
- "version": "0.20.0",
3
+ "version": "0.20.2",
4
4
  "description": "Cross-IDE agent framework for Unity/C# game-development — one-command install",
5
5
  "type": "module",
6
6
  "bin": {
package/src/install.mjs CHANGED
@@ -59,7 +59,7 @@ function* centralDirectoryEntries(buf, cdOffset, cdSize) {
59
59
  const extraLen = read16(buf, off + 30);
60
60
  const commentLen = read16(buf, off + 32);
61
61
  const localHeaderOff = read32(buf, off + 42);
62
- const filename = buf.toString('utf-8', off + 46, off + 46 + filenameLen);
62
+ const filename = buf.toString('utf-8', off + 46, off + 46 + filenameLen).replace(/\\/g, '/');
63
63
 
64
64
  // Skip directory entries (trailing / in filename, or uncompressedSize == 0 with no method)
65
65
  if (!filename.endsWith('/')) {
@@ -109,7 +109,7 @@ function extractFile(buf, entry, targetDir) {
109
109
  });
110
110
  }
111
111
 
112
- async function extractZip(buf, targetDir) {
112
+ export async function extractZip(buf, targetDir) {
113
113
  const eocdOff = findEocd(buf);
114
114
  const cdSize = read32(buf, eocdOff + 12);
115
115
  const cdOff = read32(buf, eocdOff + 16);
@@ -276,15 +276,19 @@ function matchesManagedPath(filename, managedPaths) {
276
276
  }
277
277
 
278
278
  function walkDir(dir, fn) {
279
- const entries = readdirSync(dir, { withFileTypes: true });
280
- for (const entry of entries) {
281
- const fullPath = join(dir, entry.name);
282
- if (entry.isDirectory()) {
283
- walkDir(fullPath, fn);
284
- } else {
285
- fn(fullPath, relative(dir, fullPath));
279
+ const root = dir;
280
+ const walk = (current) => {
281
+ for (const entry of readdirSync(current, { withFileTypes: true })) {
282
+ const fullPath = join(current, entry.name);
283
+ if (entry.isDirectory()) {
284
+ walk(fullPath);
285
+ } else {
286
+ // rel must be relative to the walked root, not the current subdirectory
287
+ fn(fullPath, relative(root, fullPath));
288
+ }
286
289
  }
287
- }
290
+ };
291
+ walk(root);
288
292
  }
289
293
 
290
294
  function deleteObsoleteManagedFiles(targetDir, managedPaths, zipFilenames) {
@@ -320,7 +324,7 @@ function deleteObsoleteManagedFiles(targetDir, managedPaths, zipFilenames) {
320
324
  return deleted;
321
325
  }
322
326
 
323
- async function extractZipWithManifest(buf, targetDir, { preserved, managed }) {
327
+ export async function extractZipWithManifest(buf, targetDir, { preserved, managed }) {
324
328
  const eocdOff = findEocd(buf);
325
329
  const cdSize = read32(buf, eocdOff + 12);
326
330
  const cdOff = read32(buf, eocdOff + 16);