shin-engine 1.0.4 → 1.0.6
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/bin/ee.js +34 -12
- package/package.json +1 -1
package/bin/ee.js
CHANGED
|
@@ -25,16 +25,27 @@ function sleep(ms) { return new Promise(r => setTimeout(r, ms)); }
|
|
|
25
25
|
|
|
26
26
|
function download(url, dest) {
|
|
27
27
|
return new Promise((resolve, reject) => {
|
|
28
|
-
const
|
|
28
|
+
const fs = require("fs");
|
|
29
|
+
const file = fs.createWriteStream(dest);
|
|
29
30
|
const proto = url.startsWith("https") ? https : http;
|
|
30
31
|
proto.get(url, res => {
|
|
31
32
|
if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
|
|
33
|
+
file.close();
|
|
34
|
+
fs.unlink(dest, () => {});
|
|
32
35
|
download(res.headers.location, dest).then(resolve).catch(reject);
|
|
33
36
|
return;
|
|
34
37
|
}
|
|
35
38
|
res.pipe(file);
|
|
36
|
-
file.on("finish", () => {
|
|
37
|
-
|
|
39
|
+
file.on("finish", () => {
|
|
40
|
+
file.close();
|
|
41
|
+
// Small delay to ensure OS releases file lock
|
|
42
|
+
setTimeout(resolve, 500);
|
|
43
|
+
});
|
|
44
|
+
}).on("error", err => {
|
|
45
|
+
file.close();
|
|
46
|
+
fs.unlink(dest, () => {});
|
|
47
|
+
reject(err);
|
|
48
|
+
});
|
|
38
49
|
});
|
|
39
50
|
}
|
|
40
51
|
|
|
@@ -48,22 +59,33 @@ function isRunning() {
|
|
|
48
59
|
} catch { return false; }
|
|
49
60
|
}
|
|
50
61
|
|
|
62
|
+
function installJava() {
|
|
63
|
+
try {
|
|
64
|
+
execSync("winget install --id EclipseAdoptium.Temurin.21.JDK --accept-package-agreements --silent 2>&1", { encoding: "utf-8", timeout: 120000 });
|
|
65
|
+
ok("Java 21 installed via winget");
|
|
66
|
+
} catch {
|
|
67
|
+
log(" Auto-install failed. Install manually from: https://adoptium.net/");
|
|
68
|
+
process.exit(1);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
51
72
|
async function ensureSetup() {
|
|
52
73
|
if (existsSync(JAR)) return true;
|
|
53
74
|
|
|
54
75
|
step("SHIN first-time setup");
|
|
55
76
|
|
|
56
|
-
// Check Java
|
|
77
|
+
// Check/Install Java
|
|
57
78
|
try {
|
|
58
79
|
const v = execSync("java -version 2>&1", { encoding: "utf-8" });
|
|
59
80
|
if (!v.match(/"(\d+)/) || parseInt(v.match(/"(\d+)/)[1]) < 21) {
|
|
60
|
-
log(" Java
|
|
61
|
-
|
|
81
|
+
log(" Java version too old. Installing Java 21...");
|
|
82
|
+
installJava();
|
|
83
|
+
} else {
|
|
84
|
+
ok("Java found");
|
|
62
85
|
}
|
|
63
|
-
ok("Java found");
|
|
64
86
|
} catch {
|
|
65
|
-
log(" Java
|
|
66
|
-
|
|
87
|
+
log(" Java not found. Installing Java 21...");
|
|
88
|
+
installJava();
|
|
67
89
|
}
|
|
68
90
|
|
|
69
91
|
// Download EE
|
|
@@ -78,14 +100,14 @@ async function ensureSetup() {
|
|
|
78
100
|
return false;
|
|
79
101
|
}
|
|
80
102
|
|
|
81
|
-
// Extract
|
|
103
|
+
// Extract
|
|
82
104
|
step("Extracting...");
|
|
83
105
|
try {
|
|
84
106
|
execSync(
|
|
85
|
-
`powershell -Command "Expand-Archive -Path '${zipPath}' -DestinationPath '${EE_HOME}' -Force"`,
|
|
107
|
+
`powershell -Command "Start-Sleep 1; Expand-Archive -Path '${zipPath}' -DestinationPath '${EE_HOME}' -Force"`,
|
|
86
108
|
{ encoding: "utf-8", timeout: 30000 }
|
|
87
109
|
);
|
|
88
|
-
|
|
110
|
+
execSync(`del "${zipPath}"`, { encoding: "utf-8", timeout: 5000 });
|
|
89
111
|
ok("Extracted to " + EE_HOME);
|
|
90
112
|
} catch (e) {
|
|
91
113
|
log(" Extraction failed: " + e.message);
|