@kandiforge/spectacle 0.45.19 → 0.45.25
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/package.json +1 -1
- package/scripts/install.js +39 -7
package/package.json
CHANGED
package/scripts/install.js
CHANGED
|
@@ -6,7 +6,7 @@ const https = require('https');
|
|
|
6
6
|
const { execSync } = require('child_process');
|
|
7
7
|
|
|
8
8
|
// This version MUST match package.json
|
|
9
|
-
const RELEASE_VERSION = '0.45.
|
|
9
|
+
const RELEASE_VERSION = '0.45.25';
|
|
10
10
|
const GITHUB_REPO = 'KandiForge/distribution';
|
|
11
11
|
const PACKAGE_NAME = '@kandiforge/spectacle';
|
|
12
12
|
|
|
@@ -58,7 +58,7 @@ function getArchName(arch) {
|
|
|
58
58
|
|
|
59
59
|
function downloadFile(url, destPath) {
|
|
60
60
|
return new Promise((resolve, reject) => {
|
|
61
|
-
https.get(url, (response) => {
|
|
61
|
+
const request = https.get(url, (response) => {
|
|
62
62
|
if (response.statusCode === 302 || response.statusCode === 301) {
|
|
63
63
|
// Follow redirect
|
|
64
64
|
return downloadFile(response.headers.location, destPath)
|
|
@@ -72,10 +72,11 @@ function downloadFile(url, destPath) {
|
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
const file = fs.createWriteStream(destPath);
|
|
75
|
+
|
|
75
76
|
response.pipe(file);
|
|
76
77
|
|
|
77
|
-
file
|
|
78
|
-
|
|
78
|
+
// Wait for the file to be fully written and closed
|
|
79
|
+
file.on('close', () => {
|
|
79
80
|
resolve();
|
|
80
81
|
});
|
|
81
82
|
|
|
@@ -83,7 +84,23 @@ function downloadFile(url, destPath) {
|
|
|
83
84
|
fs.unlink(destPath, () => {});
|
|
84
85
|
reject(err);
|
|
85
86
|
});
|
|
86
|
-
|
|
87
|
+
|
|
88
|
+
response.on('error', (err) => {
|
|
89
|
+
file.close();
|
|
90
|
+
fs.unlink(destPath, () => {});
|
|
91
|
+
reject(err);
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
request.on('error', (err) => {
|
|
96
|
+
reject(err);
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
// Set a timeout for the request
|
|
100
|
+
request.setTimeout(300000, () => {
|
|
101
|
+
request.destroy();
|
|
102
|
+
reject(new Error('Download timed out after 5 minutes'));
|
|
103
|
+
});
|
|
87
104
|
});
|
|
88
105
|
}
|
|
89
106
|
|
|
@@ -93,7 +110,8 @@ function downloadFile(url, destPath) {
|
|
|
93
110
|
function extractZip(zipPath, destDir) {
|
|
94
111
|
try {
|
|
95
112
|
const psCommand = `powershell -Command "Expand-Archive -Path '${zipPath}' -DestinationPath '${destDir}' -Force"`;
|
|
96
|
-
|
|
113
|
+
// Use cwd option to avoid "getcwd: cannot access parent directories" error
|
|
114
|
+
execSync(psCommand, { stdio: 'pipe', cwd: destDir });
|
|
97
115
|
} catch (error) {
|
|
98
116
|
throw new Error(`Failed to extract ZIP file: ${error.message}`);
|
|
99
117
|
}
|
|
@@ -175,7 +193,9 @@ async function install() {
|
|
|
175
193
|
if (isZip) {
|
|
176
194
|
extractZip(tempFile, binDir);
|
|
177
195
|
} else {
|
|
178
|
-
|
|
196
|
+
// Use cwd option to avoid "getcwd: cannot access parent directories" error
|
|
197
|
+
// This happens when npm updates delete the current working directory
|
|
198
|
+
execSync(`tar -xzf "${tempFile}" -C "${binDir}"`, { stdio: 'pipe', cwd: binDir });
|
|
179
199
|
}
|
|
180
200
|
|
|
181
201
|
// Clean up archive
|
|
@@ -203,6 +223,18 @@ async function install() {
|
|
|
203
223
|
}
|
|
204
224
|
}
|
|
205
225
|
|
|
226
|
+
// Move gui-web assets to bin directory (for /app web UI)
|
|
227
|
+
const guiWebSrc = path.join(extractedDir, 'gui-web');
|
|
228
|
+
const guiWebDest = path.join(binDir, 'gui-web');
|
|
229
|
+
if (fs.existsSync(guiWebSrc)) {
|
|
230
|
+
// Remove existing gui-web if present
|
|
231
|
+
if (fs.existsSync(guiWebDest)) {
|
|
232
|
+
fs.rmSync(guiWebDest, { recursive: true });
|
|
233
|
+
}
|
|
234
|
+
fs.renameSync(guiWebSrc, guiWebDest);
|
|
235
|
+
logInfo('Installed gui-web assets for /app web UI');
|
|
236
|
+
}
|
|
237
|
+
|
|
206
238
|
// Clean up the extracted directory
|
|
207
239
|
if (fs.existsSync(extractedDir)) {
|
|
208
240
|
fs.rmSync(extractedDir, { recursive: true });
|