@tessl/cli 0.69.0 → 0.70.1
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/tessl.js +36 -2
- package/package.json +1 -1
package/bin/tessl.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// installer/src/main.ts
|
|
4
|
-
import { existsSync as existsSync3 } from "node:fs";
|
|
4
|
+
import { existsSync as existsSync3, rmSync } from "node:fs";
|
|
5
5
|
import { createInterface } from "node:readline";
|
|
6
6
|
|
|
7
7
|
// installer/src/channels.ts
|
|
@@ -211,6 +211,33 @@ async function createSymlinkAtomic(target, linkPath) {
|
|
|
211
211
|
await rename(tempPath, linkPath);
|
|
212
212
|
}
|
|
213
213
|
|
|
214
|
+
// installer/src/validate.ts
|
|
215
|
+
import { spawnSync } from "node:child_process";
|
|
216
|
+
function validateBinary(binaryPath) {
|
|
217
|
+
try {
|
|
218
|
+
const result = spawnSync(binaryPath, ["--version"], {
|
|
219
|
+
stdio: "pipe",
|
|
220
|
+
timeout: 1e4,
|
|
221
|
+
env: { ...process.env, TESSL_AUTO_UPDATE_INTERVAL_MINUTES: "0" }
|
|
222
|
+
});
|
|
223
|
+
if (result.error) {
|
|
224
|
+
return { success: false, error: result.error.message };
|
|
225
|
+
}
|
|
226
|
+
if (result.status !== 0) {
|
|
227
|
+
return {
|
|
228
|
+
success: false,
|
|
229
|
+
error: `--version exited with code ${result.status}`
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
return { success: true };
|
|
233
|
+
} catch (err) {
|
|
234
|
+
return {
|
|
235
|
+
success: false,
|
|
236
|
+
error: err instanceof Error ? err.message : String(err)
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
|
|
214
241
|
// installer/src/main.ts
|
|
215
242
|
function isInteractive() {
|
|
216
243
|
return process.stdin.isTTY === true && process.stdout.isTTY === true;
|
|
@@ -238,7 +265,7 @@ function printUnsupportedPlatformMessage() {
|
|
|
238
265
|
async function prepareBinary() {
|
|
239
266
|
const symlinkPath = getSymlinkPath();
|
|
240
267
|
const symlinkTarget = await getExistingBinaryPath(symlinkPath);
|
|
241
|
-
const installerVersion = "0.
|
|
268
|
+
const installerVersion = "0.70.1";
|
|
242
269
|
const isTestOrDevBuild = installerVersion.includes("test") || installerVersion.includes("dev");
|
|
243
270
|
let symlinkMismatch = false;
|
|
244
271
|
if (isTestOrDevBuild && symlinkTarget) {
|
|
@@ -276,6 +303,13 @@ async function prepareBinary() {
|
|
|
276
303
|
clearInterval(progressInterval);
|
|
277
304
|
console.log("");
|
|
278
305
|
}
|
|
306
|
+
const validation = validateBinary(binaryPath);
|
|
307
|
+
if (!validation.success) {
|
|
308
|
+
try {
|
|
309
|
+
rmSync(binaryPath, { force: true });
|
|
310
|
+
} catch {}
|
|
311
|
+
throw new Error(`${validation.error}. Removed the corrupt file — please try again.`);
|
|
312
|
+
}
|
|
279
313
|
const shouldCreateSymlink = !isInteractive() || await promptConfirmation(`Install Tessl CLI to ${symlinkPath}?`);
|
|
280
314
|
if (shouldCreateSymlink) {
|
|
281
315
|
await createSymlinkAtomic(binaryPath, symlinkPath);
|