MCPcopy Create free account
hub / github.com/TechJeeper/Printventory / main

Function main

scripts/create-github-source-zip.js:105–165  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

103const EXTRA_DOCS = ['README.md', 'GUIDE.md', 'LICENSE.txt'];
104
105async function main() {
106 const pkg = JSON.parse(fs.readFileSync(path.join(projectRoot, 'package.json'), 'utf8'));
107 const version = pkg.version;
108
109 const paths = new Set();
110
111 addBuildFilesFromPackageJson(paths);
112 addElectronBuildResources(paths, pkg);
113 addRootMediaForDocker(paths);
114
115 for (const f of EXTRA_ALWAYS) {
116 paths.add(f);
117 }
118 for (const f of EXTRA_DOCS) {
119 if (fs.existsSync(path.join(projectRoot, f))) paths.add(f);
120 }
121
122 const scriptFiles = [];
123 walkDirFiles(path.join(projectRoot, 'scripts'), 'scripts', scriptFiles);
124 scriptFiles.forEach((r) => paths.add(r));
125
126 const missing = [];
127 const toZip = [];
128 for (const rel of paths) {
129 const abs = path.join(projectRoot, rel);
130 if (!fs.existsSync(abs)) {
131 missing.push(rel);
132 continue;
133 }
134 toZip.push(rel);
135 }
136
137 if (missing.length) {
138 console.warn('Optional or missing paths (skipped):');
139 missing.forEach((m) => console.warn(` - ${m}`));
140 }
141
142 toZip.sort((a, b) => a.localeCompare(b));
143
144 const zip = new JSZip();
145 for (const rel of toZip) {
146 const abs = path.join(projectRoot, rel);
147 const data = fs.readFileSync(abs);
148 zip.file(posix(rel), data);
149 }
150
151 const distDir = path.join(projectRoot, 'dist');
152 if (!fs.existsSync(distDir)) fs.mkdirSync(distDir, { recursive: true });
153
154 const outName = `printventory-github-source-${version}.zip`;
155 const outPath = path.join(distDir, outName);
156
157 const buf = await zip.generateAsync({
158 type: 'nodebuffer',
159 compression: 'DEFLATE',
160 compressionOptions: { level: 6 },
161 });
162 fs.writeFileSync(outPath, buf);

Callers 1

Calls 6

addRootMediaForDockerFunction · 0.85
walkDirFilesFunction · 0.85
posixFunction · 0.85
parseMethod · 0.80

Tested by

no test coverage detected