viteboard 0.1.7 → 0.1.8
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.
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { promises as fs } from "node:fs";
|
|
2
2
|
import * as path from "node:path";
|
|
3
3
|
import { createHash } from "node:crypto";
|
|
4
|
+
import { execFile } from "node:child_process";
|
|
5
|
+
import { promisify } from "node:util";
|
|
4
6
|
import { fileURLToPath } from "node:url";
|
|
5
7
|
|
|
6
8
|
const WORKSPACE_DIR = ".workspace";
|
|
@@ -27,6 +29,7 @@ const MANAGED_ASSET_RE = /^assets\/[a-f0-9]{64}\.(png|jpe?g|webp|gif|svg)$/i;
|
|
|
27
29
|
const ACTOR_TTL_MS = 30000;
|
|
28
30
|
const LOCK_TTL_MS = 30000;
|
|
29
31
|
const ROOT_LINK_HEADER = '</llms.txt>; rel="describedby"; type="text/plain", </.well-known/viteboard.json>; rel="alternate"; type="application/json"';
|
|
32
|
+
const execFileAsync = promisify(execFile);
|
|
30
33
|
|
|
31
34
|
export function createContentApiPlugin() {
|
|
32
35
|
const cwd = process.cwd();
|
|
@@ -364,7 +367,62 @@ export function createContentApiPlugin() {
|
|
|
364
367
|
}
|
|
365
368
|
|
|
366
369
|
async function pickProjectFromSystemDialog() {
|
|
367
|
-
|
|
370
|
+
if (process.platform === "darwin") {
|
|
371
|
+
try {
|
|
372
|
+
const { stdout } = await execFileAsync("osascript", [
|
|
373
|
+
"-e",
|
|
374
|
+
'set chosenFolder to choose folder with prompt "Select a project root to add to ViteBoard"',
|
|
375
|
+
"-e",
|
|
376
|
+
'POSIX path of chosenFolder',
|
|
377
|
+
]);
|
|
378
|
+
const picked = stdout.trim();
|
|
379
|
+
return picked || null;
|
|
380
|
+
} catch {
|
|
381
|
+
return null;
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
if (process.platform === "win32") {
|
|
386
|
+
const script = [
|
|
387
|
+
"Add-Type -AssemblyName System.Windows.Forms",
|
|
388
|
+
'$dialog = New-Object System.Windows.Forms.FolderBrowserDialog',
|
|
389
|
+
'$dialog.Description = "Select a project root to add to ViteBoard"',
|
|
390
|
+
'$dialog.ShowNewFolderButton = $false',
|
|
391
|
+
'if ($dialog.ShowDialog() -eq [System.Windows.Forms.DialogResult]::OK) {',
|
|
392
|
+
' [Console]::Out.Write($dialog.SelectedPath)',
|
|
393
|
+
'}',
|
|
394
|
+
].join("; ");
|
|
395
|
+
try {
|
|
396
|
+
const { stdout } = await execFileAsync("powershell", [
|
|
397
|
+
"-NoProfile",
|
|
398
|
+
"-STA",
|
|
399
|
+
"-Command",
|
|
400
|
+
script,
|
|
401
|
+
]);
|
|
402
|
+
const picked = stdout.trim();
|
|
403
|
+
return picked || null;
|
|
404
|
+
} catch {
|
|
405
|
+
return null;
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
const linuxPickers = [
|
|
410
|
+
["zenity", ["--file-selection", "--directory", "--title=Select a project root to add to ViteBoard"]],
|
|
411
|
+
["kdialog", ["--getexistingdirectory", ".", "Select a project root to add to ViteBoard"]],
|
|
412
|
+
];
|
|
413
|
+
let sawInstalledPicker = false;
|
|
414
|
+
for (const [command, args] of linuxPickers) {
|
|
415
|
+
try {
|
|
416
|
+
await execFileAsync("which", [command]);
|
|
417
|
+
sawInstalledPicker = true;
|
|
418
|
+
const { stdout } = await execFileAsync(command, args);
|
|
419
|
+
const picked = stdout.trim();
|
|
420
|
+
if (picked) return picked;
|
|
421
|
+
} catch {
|
|
422
|
+
if (sawInstalledPicker) return null;
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
throw new Error("No supported folder picker found. Install zenity or kdialog.");
|
|
368
426
|
}
|
|
369
427
|
|
|
370
428
|
async function sendMachineFile(res, fileName, contentType) {
|