MCPcopy Create free account
hub / github.com/CreminiAI/skillpack / zipCommand

Function zipCommand

src/commands/zip.ts:23–107  ·  view source on GitHub ↗
(workDir: string)

Source from the content-addressed store, hash-verified

21/**
22 * Package the pack as a lightweight zip file.
23 * Includes: skillpack.json, optional job.json, optional app.html,
24 * optional AGENTS.md / SOUL.md, start.sh, start.bat, skills/
25 * Does NOT include server/, web/, or any other runtime files.
26 */
27export async function zipCommand(
28 workDir: string,
29 options: ZipCommandOptions = {},
30): Promise<string> {
31 const config = loadConfig(workDir);
32 const slug = config.name.toLowerCase().replace(/\s+/g, "-");
33 const zipName = `${slug}.zip`;
34 const zipPath = path.join(workDir, zipName);
35
36 if (!options.skipSkillInstall) {
37 // Reinstall each skill independently so one failure does not block the rest.
38 for (const skill of config.skills) {
39 try {
40 installSkills(workDir, [skill]);
41 } catch (err) {
42 console.warn(
43 chalk.yellow(`Warning: Could not install skill "${skill.name}": ${err}`),
44 );
45 }
46 }
47 }
48 syncSkillDescriptions(workDir, config);
49 saveConfig(workDir, config);
50
51 console.log(chalk.blue(`Packaging ${config.name}...`));
52
53 const output = fs.createWriteStream(zipPath);
54 const archive = archiver("zip", { zlib: { level: 9 } });
55
56 return new Promise((resolve, reject) => {
57 output.on("close", () => {
58 console.log(
59 chalk.green(
60 `Packaging complete: ${zipName} (${(archive.pointer() / 1024).toFixed(1)} KB)`,
61 ),
62 );
63 resolve(zipPath);
64 });
65
66 archive.on("error", (err) => reject(err));
67 archive.pipe(output);
68
69 const prefix = slug;
70
71 // 1. skillpack.json
72 archive.file(getPackPath(workDir), {
73 name: `${prefix}/${PACK_FILE}`,
74 });
75
76 // 2. optional scheduled jobs
77 const jobFilePath = getJobFilePath(workDir);
78 if (fs.existsSync(jobFilePath)) {
79 archive.file(jobFilePath, { name: `${prefix}/${JOB_FILE}` });
80 }

Callers 3

cli.tsFile · 0.85
interactiveCreateFunction · 0.85
zip.test.tsFile · 0.85

Calls 7

loadConfigFunction · 0.90
installSkillsFunction · 0.85
syncSkillDescriptionsFunction · 0.85
saveConfigFunction · 0.85
getPackPathFunction · 0.85
getJobFilePathFunction · 0.85
onMethod · 0.65

Tested by

no test coverage detected