ppcos 0.4.3 → 1.0.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/lib/utils/api-client.js +1 -1
- package/lib/utils/skills-fetcher.js +20 -18
- package/package.json +1 -1
package/lib/utils/api-client.js
CHANGED
|
@@ -111,7 +111,7 @@ export async function downloadSkills(sessionToken) {
|
|
|
111
111
|
throw new Error(error.error || 'Failed to download skills');
|
|
112
112
|
}
|
|
113
113
|
|
|
114
|
-
return response
|
|
114
|
+
return response;
|
|
115
115
|
} catch (error) {
|
|
116
116
|
logger.error(`API error: ${error.message}`);
|
|
117
117
|
throw error;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { existsSync, mkdirSync } from 'fs';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { existsSync, mkdirSync, writeFileSync, unlinkSync } from 'fs';
|
|
2
|
+
import { Open } from 'unzipper';
|
|
3
|
+
import { join } from 'path';
|
|
4
|
+
import { tmpdir } from 'os';
|
|
4
5
|
import { downloadSkills } from './api-client.js';
|
|
5
6
|
import { readAuth } from './auth.js';
|
|
6
7
|
import logger from './logger.js';
|
|
@@ -22,21 +23,22 @@ export async function fetchSkills(targetDir) {
|
|
|
22
23
|
}
|
|
23
24
|
|
|
24
25
|
// Download skills
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
//
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
//
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
26
|
+
const response = await downloadSkills(auth.sessionToken);
|
|
27
|
+
|
|
28
|
+
// Write zip to temp file first, then extract from disk.
|
|
29
|
+
// Streaming extraction (Extract) silently drops files when HTTP chunks
|
|
30
|
+
// don't align with zip entry boundaries. Open.file() reads the central
|
|
31
|
+
// directory and extracts every entry reliably.
|
|
32
|
+
const tempZip = join(tmpdir(), `ppcos-skills-${Date.now()}.zip`);
|
|
33
|
+
try {
|
|
34
|
+
const buffer = Buffer.from(await response.arrayBuffer());
|
|
35
|
+
writeFileSync(tempZip, buffer);
|
|
36
|
+
|
|
37
|
+
const directory = await Open.file(tempZip);
|
|
38
|
+
await directory.extract({ path: targetDir });
|
|
39
|
+
} finally {
|
|
40
|
+
try { unlinkSync(tempZip); } catch {}
|
|
41
|
+
}
|
|
40
42
|
}
|
|
41
43
|
|
|
42
44
|
/**
|