@lvnt/release-radar 1.9.2 → 1.9.3
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/dist/asset-mirror.d.ts +4 -0
- package/dist/asset-mirror.js +22 -5
- package/package.json +1 -1
package/dist/asset-mirror.d.ts
CHANGED
|
@@ -20,6 +20,10 @@ export declare class AssetMirror {
|
|
|
20
20
|
* Mirror a single tool (legacy method, still used for /mirror command)
|
|
21
21
|
*/
|
|
22
22
|
mirror(toolName: string, version: string, config: MirrorConfig, filenameTemplate: string): Promise<MirrorResult>;
|
|
23
|
+
/**
|
|
24
|
+
* Small delay to prevent buffer exhaustion on low-memory systems (RPi)
|
|
25
|
+
*/
|
|
26
|
+
private sleep;
|
|
23
27
|
/**
|
|
24
28
|
* Mirror multiple tools into a single batch release
|
|
25
29
|
*/
|
package/dist/asset-mirror.js
CHANGED
|
@@ -41,6 +41,12 @@ export class AssetMirror {
|
|
|
41
41
|
return { success: false, error: message };
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
|
+
/**
|
|
45
|
+
* Small delay to prevent buffer exhaustion on low-memory systems (RPi)
|
|
46
|
+
*/
|
|
47
|
+
sleep(ms) {
|
|
48
|
+
return new Promise(resolve => setTimeout(resolve, ms));
|
|
49
|
+
}
|
|
44
50
|
/**
|
|
45
51
|
* Mirror multiple tools into a single batch release
|
|
46
52
|
*/
|
|
@@ -49,8 +55,9 @@ export class AssetMirror {
|
|
|
49
55
|
const results = new Map();
|
|
50
56
|
const downloadedFiles = [];
|
|
51
57
|
console.log(`[AssetMirror] Starting batch mirror for ${items.length} items, tag: ${tag}`);
|
|
52
|
-
// Download all files first
|
|
53
|
-
for (
|
|
58
|
+
// Download all files first (with delays to prevent buffer exhaustion)
|
|
59
|
+
for (let i = 0; i < items.length; i++) {
|
|
60
|
+
const item = items[i];
|
|
54
61
|
const filename = this.applyVersion(item.filenameTemplate, item.version);
|
|
55
62
|
const downloadUrl = `github.com/${this.repo}/releases/download/${tag}/${filename}`;
|
|
56
63
|
try {
|
|
@@ -68,11 +75,19 @@ export class AssetMirror {
|
|
|
68
75
|
await this.downloadFile(sourceUrl, tempPath);
|
|
69
76
|
downloadedFiles.push({ path: tempPath, filename });
|
|
70
77
|
results.set(item.toolName, { success: true, downloadUrl });
|
|
78
|
+
// Add delay between downloads to let buffers clear (except after last item)
|
|
79
|
+
if (i < items.length - 1) {
|
|
80
|
+
await this.sleep(1000);
|
|
81
|
+
}
|
|
71
82
|
}
|
|
72
83
|
catch (error) {
|
|
73
84
|
const message = error instanceof Error ? error.message : String(error);
|
|
74
85
|
console.error(`[AssetMirror] Failed to download ${item.toolName}: ${message}`);
|
|
75
86
|
results.set(item.toolName, { success: false, error: message });
|
|
87
|
+
// Also add delay after failures
|
|
88
|
+
if (i < items.length - 1) {
|
|
89
|
+
await this.sleep(1000);
|
|
90
|
+
}
|
|
76
91
|
}
|
|
77
92
|
}
|
|
78
93
|
// Create single release with all downloaded files
|
|
@@ -126,6 +141,7 @@ export class AssetMirror {
|
|
|
126
141
|
execSync(`gh release view ${tag} --repo ${this.repo}`, {
|
|
127
142
|
encoding: 'utf-8',
|
|
128
143
|
stdio: ['pipe', 'pipe', 'pipe'],
|
|
144
|
+
maxBuffer: 10 * 1024 * 1024,
|
|
129
145
|
});
|
|
130
146
|
return true;
|
|
131
147
|
}
|
|
@@ -159,7 +175,7 @@ export class AssetMirror {
|
|
|
159
175
|
`-H 'Accept: application/json; api-version=7.2-preview.1' ` +
|
|
160
176
|
`-H 'Content-Type: application/json' ` +
|
|
161
177
|
`--data '${query}'`;
|
|
162
|
-
const response = execSync(cmd, { encoding: 'utf-8', timeout: 30000 });
|
|
178
|
+
const response = execSync(cmd, { encoding: 'utf-8', timeout: 30000, maxBuffer: 10 * 1024 * 1024 });
|
|
163
179
|
const data = JSON.parse(response);
|
|
164
180
|
const versions = data.results?.[0]?.extensions?.[0]?.versions || [];
|
|
165
181
|
// Find matching version - with or without platform filter
|
|
@@ -186,6 +202,7 @@ export class AssetMirror {
|
|
|
186
202
|
execSync(`curl -sS -L -o "${destPath}" "${url}"`, {
|
|
187
203
|
encoding: 'utf-8',
|
|
188
204
|
timeout: 300000, // 5 minutes for large files
|
|
205
|
+
maxBuffer: 10 * 1024 * 1024,
|
|
189
206
|
});
|
|
190
207
|
if (!existsSync(destPath)) {
|
|
191
208
|
throw new Error('Download failed - file not created');
|
|
@@ -195,7 +212,7 @@ export class AssetMirror {
|
|
|
195
212
|
const title = `${toolName} ${version}`;
|
|
196
213
|
const notes = `Mirrored for Nexus proxy access.`;
|
|
197
214
|
execSync(`gh release create "${tag}" "${filePath}#${filename}" ` +
|
|
198
|
-
`--repo ${this.repo} --title "${title}" --notes "${notes}"`, { encoding: 'utf-8', timeout: 300000 });
|
|
215
|
+
`--repo ${this.repo} --title "${title}" --notes "${notes}"`, { encoding: 'utf-8', timeout: 300000, maxBuffer: 10 * 1024 * 1024 });
|
|
199
216
|
}
|
|
200
217
|
async createBatchRelease(tag, files, items) {
|
|
201
218
|
const date = new Date().toLocaleDateString('en-US', {
|
|
@@ -213,7 +230,7 @@ export class AssetMirror {
|
|
|
213
230
|
// Build file arguments for gh release create
|
|
214
231
|
const fileArgs = files.map(f => `"${f.path}#${f.filename}"`).join(' ');
|
|
215
232
|
execSync(`gh release create "${tag}" ${fileArgs} ` +
|
|
216
|
-
`--repo ${this.repo} --title "${title}" --notes "${notes}"`, { encoding: 'utf-8', timeout: 600000 } // 10 minutes for multiple uploads
|
|
233
|
+
`--repo ${this.repo} --title "${title}" --notes "${notes}"`, { encoding: 'utf-8', timeout: 600000, maxBuffer: 10 * 1024 * 1024 } // 10 minutes for multiple uploads
|
|
217
234
|
);
|
|
218
235
|
}
|
|
219
236
|
}
|