@vobs/cli 1.7.4 → 1.7.7
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/cli.cjs +551 -5
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +551 -5
- package/dist/cli.js.map +1 -1
- package/dist/commands/dsh.cjs +677 -0
- package/dist/commands/dsh.cjs.map +1 -0
- package/dist/commands/dsh.d.cts +43 -0
- package/dist/commands/dsh.d.ts +43 -0
- package/dist/commands/dsh.js +638 -0
- package/dist/commands/dsh.js.map +1 -0
- package/dist/commands/generate.cjs.map +1 -1
- package/dist/commands/generate.js.map +1 -1
- package/dist/commands/index.cjs +543 -5
- package/dist/commands/index.cjs.map +1 -1
- package/dist/commands/index.d.cts +2 -0
- package/dist/commands/index.d.ts +2 -0
- package/dist/commands/index.js +540 -5
- package/dist/commands/index.js.map +1 -1
- package/dist/commands/init.cjs +5 -2
- package/dist/commands/init.cjs.map +1 -1
- package/dist/commands/init.js +5 -2
- package/dist/commands/init.js.map +1 -1
- package/dist/index.cjs +553 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +551 -5
- package/dist/index.js.map +1 -1
- package/dist/repl.cjs +5 -2
- package/dist/repl.cjs.map +1 -1
- package/dist/repl.js +5 -2
- package/dist/repl.js.map +1 -1
- package/dist/start.cjs +553 -7
- package/dist/start.cjs.map +1 -1
- package/dist/start.js +551 -5
- package/dist/start.js.map +1 -1
- package/dist/templates/dsh-plugin/README.md.hbs +54 -0
- package/dist/templates/dsh-plugin/cordis.patch.yml.hbs +7 -0
- package/dist/templates/dsh-plugin/package.json.hbs +40 -0
- package/dist/templates/dsh-plugin/src/client/index.tsx.hbs +24 -0
- package/dist/templates/dsh-plugin/src/client/panel.tsx.hbs +45 -0
- package/dist/templates/dsh-plugin/src/client/styles.ts.hbs +65 -0
- package/dist/templates/dsh-plugin/src/host/index.ts.hbs +20 -0
- package/dist/templates/dsh-plugin/tsconfig.json.hbs +19 -0
- package/dist/templates/dsh-plugin/vite.config.ts.hbs +13 -0
- package/dist/utils/file.cjs +5 -2
- package/dist/utils/file.cjs.map +1 -1
- package/dist/utils/file.d.cts +2 -2
- package/dist/utils/file.d.ts +2 -2
- package/dist/utils/file.js +5 -2
- package/dist/utils/file.js.map +1 -1
- package/package.json +1 -1
- package/src/cli.ts +28 -0
- package/src/commands/dsh.test.ts +279 -0
- package/src/commands/dsh.ts +673 -0
- package/src/commands/index.ts +2 -1
- package/src/templates/dsh-plugin/README.md.hbs +54 -0
- package/src/templates/dsh-plugin/cordis.patch.yml.hbs +7 -0
- package/src/templates/dsh-plugin/package.json.hbs +40 -0
- package/src/templates/dsh-plugin/src/client/index.tsx.hbs +24 -0
- package/src/templates/dsh-plugin/src/client/panel.tsx.hbs +45 -0
- package/src/templates/dsh-plugin/src/client/styles.ts.hbs +65 -0
- package/src/templates/dsh-plugin/src/host/index.ts.hbs +20 -0
- package/src/templates/dsh-plugin/tsconfig.json.hbs +19 -0
- package/src/templates/dsh-plugin/vite.config.ts.hbs +13 -0
- package/src/utils/file.ts +7 -3
package/dist/start.cjs
CHANGED
|
@@ -104,13 +104,13 @@ function ensureDir(dir) {
|
|
|
104
104
|
__name(ensureDir, "ensureDir");
|
|
105
105
|
async function copyDirRecursive(srcDir, destDir, context) {
|
|
106
106
|
const { readdirSync } = await import("fs");
|
|
107
|
-
const { join } = await import("path");
|
|
107
|
+
const { join: join2 } = await import("path");
|
|
108
108
|
const entries = readdirSync(srcDir, { withFileTypes: true });
|
|
109
109
|
for (const entry of entries) {
|
|
110
|
-
const srcPath =
|
|
110
|
+
const srcPath = join2(srcDir, entry.name);
|
|
111
111
|
const isHbs = entry.name.endsWith(".hbs");
|
|
112
112
|
const destName = isHbs ? entry.name.slice(0, -4) : entry.name;
|
|
113
|
-
const destPath =
|
|
113
|
+
const destPath = join2(destDir, destName);
|
|
114
114
|
if (entry.isDirectory()) {
|
|
115
115
|
ensureDir(destPath);
|
|
116
116
|
await copyDirRecursive(srcPath, destPath, context);
|
|
@@ -124,8 +124,11 @@ async function copyDirRecursive(srcDir, destDir, context) {
|
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
126
|
__name(copyDirRecursive, "copyDirRecursive");
|
|
127
|
-
async function scaffoldProject(targetDir, context) {
|
|
128
|
-
const templateDir = (0, import_node_path.resolve)(TEMPLATES_ROOT,
|
|
127
|
+
async function scaffoldProject(targetDir, context, template = "basic") {
|
|
128
|
+
const templateDir = (0, import_node_path.resolve)(TEMPLATES_ROOT, template);
|
|
129
|
+
if (!(0, import_node_fs.existsSync)(templateDir)) {
|
|
130
|
+
throw new Error(`\u6A21\u677F\u4E0D\u5B58\u5728: ${template}\uFF08\u53EF\u7528\u6A21\u677F\u89C1 ${TEMPLATES_ROOT}\uFF09`);
|
|
131
|
+
}
|
|
129
132
|
ensureDir(targetDir);
|
|
130
133
|
await copyDirRecursive(templateDir, targetDir, context);
|
|
131
134
|
}
|
|
@@ -356,6 +359,535 @@ async function addCommand(options) {
|
|
|
356
359
|
}
|
|
357
360
|
__name(addCommand, "addCommand");
|
|
358
361
|
|
|
362
|
+
// packages/cli/src/commands/dsh.ts
|
|
363
|
+
var import_node_fs3 = require("fs");
|
|
364
|
+
var import_promises = require("fs/promises");
|
|
365
|
+
var import_node_child_process3 = require("child_process");
|
|
366
|
+
var import_node_http = require("http");
|
|
367
|
+
var import_node_module = require("module");
|
|
368
|
+
var import_node_path5 = require("path");
|
|
369
|
+
var p4 = __toESM(require("@clack/prompts"), 1);
|
|
370
|
+
var PLATFORM_MODULES = ["react", "react-dom"];
|
|
371
|
+
var vobsVersion = /* @__PURE__ */ __name(() => {
|
|
372
|
+
try {
|
|
373
|
+
const manifest = JSON.parse(
|
|
374
|
+
(0, import_node_fs3.readFileSync)(new URL("../../package.json", __VOBS_CJS_FILE_URL), "utf8")
|
|
375
|
+
);
|
|
376
|
+
return manifest.version ?? "1.7.5";
|
|
377
|
+
} catch {
|
|
378
|
+
return "1.7.5";
|
|
379
|
+
}
|
|
380
|
+
}, "vobsVersion");
|
|
381
|
+
function toRowId(packageName) {
|
|
382
|
+
return packageName.replace(/^@[^/]+\//u, "");
|
|
383
|
+
}
|
|
384
|
+
__name(toRowId, "toRowId");
|
|
385
|
+
async function dshInitCommand(target, options) {
|
|
386
|
+
const name = target ?? await p4.text({
|
|
387
|
+
message: "\u63D2\u4EF6\u5305\u540D\uFF08npm \u5305\u540D\uFF0C\u5C0F\u5199\uFF09:",
|
|
388
|
+
placeholder: "dsh-plugin-my-panel",
|
|
389
|
+
validate: /* @__PURE__ */ __name((value) => /^[a-z0-9][a-z0-9._~-]*$/u.test(value) ? void 0 : "\u5FC5\u987B\u662F\u5408\u6CD5\u7684 npm \u5305\u540D", "validate")
|
|
390
|
+
});
|
|
391
|
+
if (p4.isCancel(name)) {
|
|
392
|
+
p4.cancel("\u5DF2\u53D6\u6D88");
|
|
393
|
+
return;
|
|
394
|
+
}
|
|
395
|
+
const packageManager = options.pm ?? await p4.select({
|
|
396
|
+
message: "\u5305\u7BA1\u7406\u5668:",
|
|
397
|
+
options: [
|
|
398
|
+
{ value: "pnpm", label: "pnpm" },
|
|
399
|
+
{ value: "npm", label: "npm" }
|
|
400
|
+
]
|
|
401
|
+
});
|
|
402
|
+
if (p4.isCancel(packageManager)) {
|
|
403
|
+
p4.cancel("\u5DF2\u53D6\u6D88");
|
|
404
|
+
return;
|
|
405
|
+
}
|
|
406
|
+
const targetDir = options.dir !== void 0 ? (0, import_node_path5.resolve)(options.dir) : (0, import_node_path5.resolve)(process.cwd(), name);
|
|
407
|
+
const rowId = toRowId(name);
|
|
408
|
+
const displayName = rowId.replace(/^dsh-plugin-/u, "").split("-").map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join(" ");
|
|
409
|
+
logger.step(`\u521B\u5EFA DSH \u63D2\u4EF6\u9879\u76EE ${name} \u2026`);
|
|
410
|
+
await scaffoldProject(
|
|
411
|
+
targetDir,
|
|
412
|
+
{ packageName: name, rowId, displayName, vobsVersion: vobsVersion() },
|
|
413
|
+
"dsh-plugin"
|
|
414
|
+
);
|
|
415
|
+
ensureDir(targetDir);
|
|
416
|
+
(0, import_node_fs3.writeFileSync)(
|
|
417
|
+
(0, import_node_path5.resolve)(targetDir, ".gitignore"),
|
|
418
|
+
["node_modules/", "*.log", "*.tsbuildinfo", "", "# lib/ \u662F\u6784\u5EFA\u4EA7\u7269\uFF0C\u5FC5\u987B\u63D0\u4EA4\uFF1ADSH \u5B89\u88C5\u65F6\u4E0D\u4F1A\u6784\u5EFA\u4F60\u7684\u5305\u3002", ""].join("\n"),
|
|
419
|
+
"utf8"
|
|
420
|
+
);
|
|
421
|
+
logger.success("\u9879\u76EE\u5DF2\u751F\u6210");
|
|
422
|
+
logger.step("\u5B89\u88C5\u4F9D\u8D56 \u2026");
|
|
423
|
+
try {
|
|
424
|
+
installDependencies(targetDir, packageManager);
|
|
425
|
+
logger.success("\u4F9D\u8D56\u5DF2\u5B89\u88C5");
|
|
426
|
+
} catch {
|
|
427
|
+
logger.warn(`\u4F9D\u8D56\u5B89\u88C5\u5931\u8D25\uFF0C\u8BF7\u624B\u52A8\u6267\u884C ${packageManager} install`);
|
|
428
|
+
}
|
|
429
|
+
logger.step("\u4E0B\u4E00\u6B65");
|
|
430
|
+
console.log(`
|
|
431
|
+
cd ${name}
|
|
432
|
+
${packageManager} run dev # \u672C\u5730\u9884\u89C8\uFF0C\u4E0D\u7528\u88C5\u8FDB DSH
|
|
433
|
+
${packageManager} run build # \u4EA7\u51FA lib/{index,client}.js
|
|
434
|
+
|
|
435
|
+
# \u63D0\u4EA4\u4EA7\u7269\u5E76\u6253 tag \u4E4B\u540E\uFF0C\u5728 DSH \u63D2\u4EF6\u9875\u586B\uFF1A
|
|
436
|
+
github:<owner>/<repo>#v0.1.0&path:/<\u672C\u5305\u5728\u4ED3\u5E93\u4E2D\u7684\u8DEF\u5F84>
|
|
437
|
+
`);
|
|
438
|
+
}
|
|
439
|
+
__name(dshInitCommand, "dshInitCommand");
|
|
440
|
+
async function dshBuildCommand() {
|
|
441
|
+
const projectDir = process.cwd();
|
|
442
|
+
const configFile = (0, import_node_path5.resolve)(projectDir, "vite.config.ts");
|
|
443
|
+
if (!(0, import_node_fs3.existsSync)(configFile)) {
|
|
444
|
+
logger.error("\u5F53\u524D\u76EE\u5F55\u6CA1\u6709 vite.config.ts\uFF0C\u8BF7\u5728\u63D2\u4EF6\u9879\u76EE\u6839\u76EE\u5F55\u8FD0\u884C\u3002");
|
|
445
|
+
process.exitCode = 1;
|
|
446
|
+
return;
|
|
447
|
+
}
|
|
448
|
+
const manifest = readManifest(projectDir);
|
|
449
|
+
if (manifest === void 0) {
|
|
450
|
+
logger.error("\u8BFB\u4E0D\u5230 package.json\u3002");
|
|
451
|
+
process.exitCode = 1;
|
|
452
|
+
return;
|
|
453
|
+
}
|
|
454
|
+
const hostEntry = resolveExport(manifest, ".");
|
|
455
|
+
if (hostEntry === void 0) {
|
|
456
|
+
logger.error('package.json \u7684 exports \u91CC\u6CA1\u6709 "."\uFF0CDSH \u52A0\u8F7D\u4E0D\u5230 Host \u4FA7\u63D2\u4EF6\u3002');
|
|
457
|
+
process.exitCode = 1;
|
|
458
|
+
return;
|
|
459
|
+
}
|
|
460
|
+
const { build: build2 } = await import("vite");
|
|
461
|
+
logger.info("\u6784\u5EFA\u5BA2\u6237\u7AEF\u4EA7\u7269 \u2026");
|
|
462
|
+
await build2({ configFile, mode: "production" });
|
|
463
|
+
logger.info("\u6784\u5EFA Host \u4EA7\u7269 \u2026");
|
|
464
|
+
const hostTarget = (0, import_node_path5.resolve)(projectDir, hostEntry.replace(/^\.\//u, ""));
|
|
465
|
+
const hostEntrySource = (0, import_node_path5.resolve)(projectDir, "src", "host", "index.ts");
|
|
466
|
+
if (!(0, import_node_fs3.existsSync)(hostEntrySource)) {
|
|
467
|
+
logger.warn(`\u6CA1\u6709\u627E\u5230 ${hostEntrySource}\uFF0C\u8DF3\u8FC7 Host \u6784\u5EFA\u3002`);
|
|
468
|
+
return;
|
|
469
|
+
}
|
|
470
|
+
await build2({
|
|
471
|
+
configFile: false,
|
|
472
|
+
root: projectDir,
|
|
473
|
+
logLevel: "warn",
|
|
474
|
+
build: {
|
|
475
|
+
outDir: (0, import_node_path5.relative)(projectDir, (0, import_node_path5.dirname)(hostTarget)) || ".",
|
|
476
|
+
emptyOutDir: false,
|
|
477
|
+
target: "es2022",
|
|
478
|
+
minify: false,
|
|
479
|
+
sourcemap: false,
|
|
480
|
+
lib: {
|
|
481
|
+
entry: hostEntrySource,
|
|
482
|
+
formats: ["es"],
|
|
483
|
+
fileName: /* @__PURE__ */ __name(() => (0, import_node_path5.basename)(hostTarget), "fileName")
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
});
|
|
487
|
+
logger.success("\u6784\u5EFA\u5B8C\u6210 \u2192 \u5BA2\u6237\u7AEF\u4E0E Host \u4EA7\u7269\u90FD\u5DF2\u5C31\u4F4D");
|
|
488
|
+
}
|
|
489
|
+
__name(dshBuildCommand, "dshBuildCommand");
|
|
490
|
+
function resolveExport(manifest, key) {
|
|
491
|
+
const exportsField = manifest.exports ?? {};
|
|
492
|
+
const entry = exportsField[key];
|
|
493
|
+
if (typeof entry === "string") return entry;
|
|
494
|
+
if (typeof entry === "object" && entry !== null) {
|
|
495
|
+
const record = entry;
|
|
496
|
+
for (const condition of ["default", "import", "require"]) {
|
|
497
|
+
const value = record[condition];
|
|
498
|
+
if (typeof value === "string") return value;
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
return void 0;
|
|
502
|
+
}
|
|
503
|
+
__name(resolveExport, "resolveExport");
|
|
504
|
+
function buildPreviewHtml(options) {
|
|
505
|
+
const name = JSON.stringify(options.packageName).replace(/</gu, "\\u003c");
|
|
506
|
+
const title = (options.title ?? options.packageName).replace(/[<>&]/gu, "");
|
|
507
|
+
return `<!doctype html>
|
|
508
|
+
<html lang="zh-CN">
|
|
509
|
+
<head>
|
|
510
|
+
<meta charset="utf-8">
|
|
511
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
512
|
+
<title>vobs preview \xB7 ${title}</title>
|
|
513
|
+
</head>
|
|
514
|
+
<body>
|
|
515
|
+
<div id="root"></div>
|
|
516
|
+
|
|
517
|
+
<!-- 1. \u5148\u88C5\u57AB\u7247\uFF1A\u5FC5\u987B\u5728\u63D2\u4EF6 bundle \u4E4B\u524D\uFF0C\u6355\u83B7\u5B83\u7684 factory \u6CE8\u518C -->
|
|
518
|
+
<script>
|
|
519
|
+
window.__VOBS_DSH_PREVIEW__ = { factories: new Map() };
|
|
520
|
+
window.__ModuleLoader__ = {
|
|
521
|
+
load: function (entry) { window.__VOBS_DSH_PREVIEW__.factories.set(entry.id, entry.factory); }
|
|
522
|
+
};
|
|
523
|
+
</script>
|
|
524
|
+
|
|
525
|
+
<!-- 2. \u63D2\u4EF6\u4EA7\u7269\uFF1A\u5B83\u53EA\u6CE8\u518C factory\uFF0C\u4E0D\u4EA7\u751F\u526F\u4F5C\u7528 -->
|
|
526
|
+
<script src="/client.js"></script>
|
|
527
|
+
|
|
528
|
+
<!-- 3. \u542F\u52A8\u9884\u89C8\u5916\u58F3 -->
|
|
529
|
+
<script type="module">
|
|
530
|
+
import { startPreview } from '/preview.js';
|
|
531
|
+
window.__VOBS_PREVIEW__ = startPreview({
|
|
532
|
+
container: document.getElementById('root'),
|
|
533
|
+
packageName: ${name}
|
|
534
|
+
});
|
|
535
|
+
</script>
|
|
536
|
+
|
|
537
|
+
<!-- 4. \u91CD\u5EFA\u540E\u81EA\u52A8\u5237\u65B0\uFF1B?static=1 \u5173\u6389\u957F\u8FDE\u63A5\uFF0C\u4FBF\u4E8E\u65E0\u5934\u622A\u56FE\u4E0E CI \u65AD\u8A00 -->
|
|
538
|
+
<script>
|
|
539
|
+
if (!location.search.includes('static')) {
|
|
540
|
+
new EventSource('/events').addEventListener('reload', function () { location.reload(); });
|
|
541
|
+
}
|
|
542
|
+
</script>
|
|
543
|
+
</body>
|
|
544
|
+
</html>
|
|
545
|
+
`;
|
|
546
|
+
}
|
|
547
|
+
__name(buildPreviewHtml, "buildPreviewHtml");
|
|
548
|
+
async function dshDevCommand(options) {
|
|
549
|
+
const projectDir = process.cwd();
|
|
550
|
+
const manifest = readManifest(projectDir);
|
|
551
|
+
if (manifest === void 0) {
|
|
552
|
+
logger.error("\u5F53\u524D\u76EE\u5F55\u6CA1\u6709\u53EF\u8BFB\u7684 package.json\u3002");
|
|
553
|
+
process.exitCode = 1;
|
|
554
|
+
return;
|
|
555
|
+
}
|
|
556
|
+
if (readManifest(projectDir)?.dsh === void 0) {
|
|
557
|
+
logger.error("\u8FD9\u4E0D\u662F\u4E00\u4E2A DSH \u63D2\u4EF6\u9879\u76EE\uFF08package.json \u91CC\u6CA1\u6709 dsh \u5B57\u6BB5\uFF09\u3002");
|
|
558
|
+
process.exitCode = 1;
|
|
559
|
+
return;
|
|
560
|
+
}
|
|
561
|
+
const packageName = typeof manifest.name === "string" ? manifest.name : "dsh-plugin";
|
|
562
|
+
const clientEntry = resolveExport(manifest, "./client");
|
|
563
|
+
if (clientEntry === void 0) {
|
|
564
|
+
logger.error('package.json \u7684 exports \u91CC\u6CA1\u6709 "./client"\uFF0C\u9875\u9762\u62FF\u4E0D\u5230\u5BA2\u6237\u7AEF bundle\u3002');
|
|
565
|
+
process.exitCode = 1;
|
|
566
|
+
return;
|
|
567
|
+
}
|
|
568
|
+
const clientFile = (0, import_node_path5.resolve)(projectDir, clientEntry.replace(/^\.\//u, ""));
|
|
569
|
+
let previewFile;
|
|
570
|
+
try {
|
|
571
|
+
const projectRequire = (0, import_node_module.createRequire)((0, import_node_path5.join)(projectDir, "package.json"));
|
|
572
|
+
let packageRoot;
|
|
573
|
+
try {
|
|
574
|
+
packageRoot = (0, import_node_path5.dirname)(projectRequire.resolve("@vobs/dsh/package.json"));
|
|
575
|
+
} catch {
|
|
576
|
+
packageRoot = (0, import_node_path5.dirname)((0, import_node_path5.dirname)(projectRequire.resolve("@vobs/dsh")));
|
|
577
|
+
}
|
|
578
|
+
const candidate = (0, import_node_path5.join)(packageRoot, "dist", "preview.js");
|
|
579
|
+
previewFile = (0, import_node_fs3.existsSync)(candidate) ? candidate : void 0;
|
|
580
|
+
} catch {
|
|
581
|
+
previewFile = void 0;
|
|
582
|
+
}
|
|
583
|
+
if (previewFile === void 0) {
|
|
584
|
+
logger.error("\u9879\u76EE\u91CC\u627E\u4E0D\u5230 @vobs/dsh \u7684\u9884\u89C8\u8FD0\u884C\u65F6\u3002\u5148\u5B89\u88C5\u4F9D\u8D56\uFF1Apnpm add -D @vobs/dsh");
|
|
585
|
+
process.exitCode = 1;
|
|
586
|
+
return;
|
|
587
|
+
}
|
|
588
|
+
const port = options.port ?? 5199;
|
|
589
|
+
const clients = /* @__PURE__ */ new Set();
|
|
590
|
+
const broadcast = /* @__PURE__ */ __name((event) => {
|
|
591
|
+
for (const client of clients) client.write(`event: ${event}
|
|
592
|
+
data: 1
|
|
593
|
+
|
|
594
|
+
`);
|
|
595
|
+
}, "broadcast");
|
|
596
|
+
logger.info("\u6784\u5EFA\u4EA7\u7269 \u2026");
|
|
597
|
+
const { build: build2 } = await import("vite");
|
|
598
|
+
const configFile = (0, import_node_path5.resolve)(projectDir, "vite.config.ts");
|
|
599
|
+
let buildError;
|
|
600
|
+
try {
|
|
601
|
+
const watcher = await build2({
|
|
602
|
+
configFile,
|
|
603
|
+
mode: "development",
|
|
604
|
+
logLevel: "warn",
|
|
605
|
+
build: { watch: {} }
|
|
606
|
+
});
|
|
607
|
+
watcher.on("event", (event) => {
|
|
608
|
+
if (event.code === "END") {
|
|
609
|
+
buildError = void 0;
|
|
610
|
+
logger.success("\u91CD\u65B0\u6784\u5EFA\u5B8C\u6210");
|
|
611
|
+
broadcast("reload");
|
|
612
|
+
} else if (event.code === "ERROR") {
|
|
613
|
+
buildError = event.error?.message ?? "\u6784\u5EFA\u5931\u8D25";
|
|
614
|
+
logger.error(buildError);
|
|
615
|
+
}
|
|
616
|
+
});
|
|
617
|
+
process.on("SIGINT", () => {
|
|
618
|
+
void watcher.close().then(() => process.exit(0));
|
|
619
|
+
});
|
|
620
|
+
} catch (error2) {
|
|
621
|
+
logger.error(`\u6784\u5EFA\u5931\u8D25\uFF1A${error2 instanceof Error ? error2.message : String(error2)}`);
|
|
622
|
+
process.exitCode = 1;
|
|
623
|
+
return;
|
|
624
|
+
}
|
|
625
|
+
const server = (0, import_node_http.createServer)((request, response) => {
|
|
626
|
+
const url = (request.url ?? "/").split("?")[0];
|
|
627
|
+
if (url === "/events") {
|
|
628
|
+
response.writeHead(200, {
|
|
629
|
+
"content-type": "text/event-stream",
|
|
630
|
+
"cache-control": "no-store",
|
|
631
|
+
connection: "keep-alive"
|
|
632
|
+
});
|
|
633
|
+
response.write(": connected\n\n");
|
|
634
|
+
clients.add(response);
|
|
635
|
+
request.on("close", () => clients.delete(response));
|
|
636
|
+
return;
|
|
637
|
+
}
|
|
638
|
+
const send = /* @__PURE__ */ __name((body, type) => {
|
|
639
|
+
response.writeHead(200, { "content-type": type, "cache-control": "no-store" });
|
|
640
|
+
response.end(body);
|
|
641
|
+
}, "send");
|
|
642
|
+
if (url === "/") {
|
|
643
|
+
send(buildPreviewHtml({ packageName }), "text/html; charset=utf-8");
|
|
644
|
+
return;
|
|
645
|
+
}
|
|
646
|
+
if (url === "/preview.js") {
|
|
647
|
+
void (0, import_promises.readFile)(previewFile).then((body) => send(body, "text/javascript; charset=utf-8"));
|
|
648
|
+
return;
|
|
649
|
+
}
|
|
650
|
+
if (url === "/client.js") {
|
|
651
|
+
if (!(0, import_node_fs3.existsSync)(clientFile)) {
|
|
652
|
+
response.writeHead(503, { "content-type": "text/plain; charset=utf-8" });
|
|
653
|
+
response.end(`\u8FD8\u6CA1\u6709\u4EA7\u7269\uFF1A${clientEntry}
|
|
654
|
+
${buildError ?? ""}`);
|
|
655
|
+
return;
|
|
656
|
+
}
|
|
657
|
+
void (0, import_promises.readFile)(clientFile).then((body) => send(body, "text/javascript; charset=utf-8"));
|
|
658
|
+
return;
|
|
659
|
+
}
|
|
660
|
+
response.writeHead(404, { "content-type": "text/plain; charset=utf-8" });
|
|
661
|
+
response.end("not found");
|
|
662
|
+
});
|
|
663
|
+
await new Promise((resolveListen) => {
|
|
664
|
+
server.listen(port, "127.0.0.1", resolveListen);
|
|
665
|
+
});
|
|
666
|
+
logger.success(`\u9884\u89C8\u5DF2\u5C31\u7EEA\uFF1Ahttp://127.0.0.1:${port}/`);
|
|
667
|
+
console.log("\n \u6539\u4EE3\u7801\u4F1A\u81EA\u52A8\u91CD\u5EFA\u5E76\u5237\u65B0\u9875\u9762\uFF1BCtrl+C \u9000\u51FA\u3002\n");
|
|
668
|
+
}
|
|
669
|
+
__name(dshDevCommand, "dshDevCommand");
|
|
670
|
+
function readManifest(dir) {
|
|
671
|
+
try {
|
|
672
|
+
return JSON.parse((0, import_node_fs3.readFileSync)((0, import_node_path5.resolve)(dir, "package.json"), "utf8"));
|
|
673
|
+
} catch {
|
|
674
|
+
return void 0;
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
__name(readManifest, "readManifest");
|
|
678
|
+
function collectIssues(dir) {
|
|
679
|
+
const result = { errors: [], warnings: [], passed: [] };
|
|
680
|
+
const manifest = readManifest(dir);
|
|
681
|
+
if (manifest === void 0) {
|
|
682
|
+
result.errors.push("\u8BFB\u4E0D\u5230 package.json\uFF08JSON \u8BED\u6CD5\u9519\u8BEF\u6216\u6587\u4EF6\u7F3A\u5931\uFF09");
|
|
683
|
+
return result;
|
|
684
|
+
}
|
|
685
|
+
const name = typeof manifest.name === "string" ? manifest.name : "";
|
|
686
|
+
if (name === "") result.errors.push("package.json \u7F3A\u5C11 name");
|
|
687
|
+
else result.passed.push(`\u5305\u540D ${name}`);
|
|
688
|
+
const dsh = manifest.dsh ?? {};
|
|
689
|
+
const bundle = dsh.bundle ?? {};
|
|
690
|
+
const client = dsh.client ?? {};
|
|
691
|
+
if (typeof bundle.patch !== "string") {
|
|
692
|
+
result.errors.push("\u7F3A\u5C11 dsh.bundle.patch \u2014\u2014 DSH \u4E0D\u4F1A\u628A\u8FD9\u4E2A\u5305\u5F53\u4F5C\u7EC4\u5408\u5305\uFF08bundle\uFF09");
|
|
693
|
+
} else {
|
|
694
|
+
const patchPath = (0, import_node_path5.resolve)(dir, bundle.patch.replace(/^\.\//u, ""));
|
|
695
|
+
if (!(0, import_node_fs3.existsSync)(patchPath)) {
|
|
696
|
+
result.errors.push(`dsh.bundle.patch \u6307\u5411\u7684 ${bundle.patch} \u4E0D\u5B58\u5728`);
|
|
697
|
+
} else {
|
|
698
|
+
const text5 = (0, import_node_fs3.readFileSync)(patchPath, "utf8");
|
|
699
|
+
if (!text5.includes("insert:")) result.errors.push("cordis.patch.yml \u91CC\u6CA1\u6709 insert: \u6BB5\u843D\uFF0C\u63D2\u4EF6\u884C\u4E0D\u4F1A\u8FDB\u7EC4\u5408\u6811");
|
|
700
|
+
else if (name !== "" && !text5.includes(name)) {
|
|
701
|
+
result.warnings.push(`cordis.patch.yml \u91CC\u6CA1\u6709\u51FA\u73B0\u5305\u540D ${name}\uFF0C\u786E\u8BA4 insert \u7684 name \u5199\u5BF9\u4E86`);
|
|
702
|
+
} else result.passed.push("cordis.patch.yml \u4F1A\u63D2\u5165\u672C\u5305\u7684\u884C");
|
|
703
|
+
}
|
|
704
|
+
}
|
|
705
|
+
if (client.platform !== "web") {
|
|
706
|
+
result.errors.push("dsh.client.platform \u5FC5\u987B\u662F 'web' \u2014\u2014 \u5426\u5219 DSH \u4E0D\u4F1A\u7ED9\u9875\u9762\u63D0\u4F9B\u5BA2\u6237\u7AEF bundle");
|
|
707
|
+
} else result.passed.push("dsh.client.platform = web");
|
|
708
|
+
const exportsField = manifest.exports ?? {};
|
|
709
|
+
const hostEntry = exportsField["."];
|
|
710
|
+
const clientEntry = exportsField["./client"];
|
|
711
|
+
if (typeof hostEntry !== "string") result.errors.push('exports["."] \u672A\u58F0\u660E \u2014\u2014 DSH \u52A0\u8F7D\u4E0D\u5230 Host \u4FA7\u63D2\u4EF6');
|
|
712
|
+
else if (!(0, import_node_fs3.existsSync)((0, import_node_path5.resolve)(dir, hostEntry.replace(/^\.\//u, "")))) {
|
|
713
|
+
result.errors.push(`exports["."] \u6307\u5411\u7684 ${hostEntry} \u4E0D\u5B58\u5728\uFF0C\u5148\u6784\u5EFA`);
|
|
714
|
+
} else result.passed.push("Host \u5165\u53E3\u5B58\u5728");
|
|
715
|
+
if (typeof clientEntry !== "string") result.errors.push('exports["./client"] \u672A\u58F0\u660E \u2014\u2014 \u9875\u9762\u62FF\u4E0D\u5230\u5BA2\u6237\u7AEF bundle');
|
|
716
|
+
const scripts = manifest.scripts ?? {};
|
|
717
|
+
if (scripts.prepare !== void 0 || scripts.postinstall !== void 0) {
|
|
718
|
+
result.errors.push("\u58F0\u660E\u4E86 prepare / postinstall \u2014\u2014 DSH \u5B89\u88C5\u65F6\u4E0D\u6784\u5EFA\uFF0C\u4EA7\u7269\u5FC5\u987B\u9884\u5148\u63D0\u4EA4");
|
|
719
|
+
} else result.passed.push("\u6CA1\u6709\u5B89\u88C5\u671F\u751F\u547D\u5468\u671F\u94A9\u5B50");
|
|
720
|
+
const dependencyText = JSON.stringify({
|
|
721
|
+
dependencies: manifest.dependencies,
|
|
722
|
+
peerDependencies: manifest.peerDependencies,
|
|
723
|
+
devDependencies: manifest.devDependencies
|
|
724
|
+
});
|
|
725
|
+
if (dependencyText.includes("workspace:")) {
|
|
726
|
+
result.errors.push("\u4F9D\u8D56\u91CC\u51FA\u73B0\u4E86 workspace: \u534F\u8BAE \u2014\u2014 GitHub \u5B50\u76EE\u5F55\u76F4\u88C5\u65F6\u89E3\u6790\u4E0D\u4E86");
|
|
727
|
+
} else result.passed.push("\u6CA1\u6709 workspace: \u534F\u8BAE\u4F9D\u8D56");
|
|
728
|
+
if (typeof clientEntry === "string") {
|
|
729
|
+
const clientPath = (0, import_node_path5.resolve)(dir, clientEntry.replace(/^\.\//u, ""));
|
|
730
|
+
if (!(0, import_node_fs3.existsSync)(clientPath)) {
|
|
731
|
+
result.errors.push(`\u5BA2\u6237\u7AEF\u4EA7\u7269 ${clientEntry} \u4E0D\u5B58\u5728\uFF0C\u5148\u8FD0\u884C\u6784\u5EFA`);
|
|
732
|
+
} else {
|
|
733
|
+
const code = (0, import_node_fs3.readFileSync)(clientPath, "utf8");
|
|
734
|
+
const loads = (code.match(/__ModuleLoader__\.load\(/gu) ?? []).length;
|
|
735
|
+
if (loads !== 1) result.errors.push(`\u5BA2\u6237\u7AEF\u4EA7\u7269\u91CC __ModuleLoader__.load \u51FA\u73B0 ${loads} \u6B21\uFF0C\u5E94\u4E3A 1 \u6B21\uFF08\u5148\u6784\u5EFA\uFF09`);
|
|
736
|
+
else result.passed.push("\u4EA7\u7269\u5F62\u6001\u662F DSH \u5BA2\u6237\u7AEF\u6A21\u5757\u534F\u8BAE");
|
|
737
|
+
if (code.includes("import(")) result.errors.push("\u5BA2\u6237\u7AEF\u4EA7\u7269\u91CC\u6709\u52A8\u6001 import()\uFF0CDSH \u53EA\u652F\u6301\u81EA\u5305\u542B chunk");
|
|
738
|
+
const requires = [...code.matchAll(/require\((['"])([^'"]+)\1\)/gu)].map((match) => match[2] ?? "");
|
|
739
|
+
const foreign = requires.filter((id) => !PLATFORM_MODULES.includes(id) && !id.startsWith("@deepseek-ai/"));
|
|
740
|
+
if (foreign.length > 0) {
|
|
741
|
+
result.errors.push(`\u4EA7\u7269 require \u4E86\u975E\u5E73\u53F0\u6A21\u5757\uFF1A${[...new Set(foreign)].join(", ")} \u2014\u2014 \u4F9D\u8D56\u6CA1\u6709\u88AB\u6253\u8FDB\u4EA7\u7269`);
|
|
742
|
+
} else if (requires.length > 0) {
|
|
743
|
+
result.passed.push(`\u4EA7\u7269\u53EA require \u5E73\u53F0\u6A21\u5757\uFF08${[...new Set(requires)].join(", ")}\uFF09`);
|
|
744
|
+
}
|
|
745
|
+
if (name !== "" && !code.includes(`"${name}"`) && !code.includes(`'${name}'`)) {
|
|
746
|
+
result.warnings.push(`\u4EA7\u7269\u91CC\u7684\u6A21\u5757 id \u4E0E\u5305\u540D ${name} \u4E0D\u4E00\u81F4\uFF0C\u68C0\u67E5 dshBundle({ id })`);
|
|
747
|
+
}
|
|
748
|
+
}
|
|
749
|
+
}
|
|
750
|
+
return result;
|
|
751
|
+
}
|
|
752
|
+
__name(collectIssues, "collectIssues");
|
|
753
|
+
function dshCheckCommand() {
|
|
754
|
+
const dir = process.cwd();
|
|
755
|
+
const result = collectIssues(dir);
|
|
756
|
+
logger.step("DSH \u63D2\u4EF6\u88C5\u524D\u6821\u9A8C");
|
|
757
|
+
for (const item of result.passed) console.log(` \u2714 ${item}`);
|
|
758
|
+
for (const item of result.warnings) console.log(` \u26A0 ${item}`);
|
|
759
|
+
for (const item of result.errors) console.log(` \u2716 ${item}`);
|
|
760
|
+
if (result.errors.length > 0) {
|
|
761
|
+
logger.error(`${result.errors.length} \u9879\u4E0D\u901A\u8FC7\uFF0C\u88C5\u8FDB DSH \u540E\u4E0D\u4F1A\u6B63\u5E38\u5DE5\u4F5C\u3002`);
|
|
762
|
+
process.exitCode = 1;
|
|
763
|
+
return;
|
|
764
|
+
}
|
|
765
|
+
logger.success(`\u5168\u90E8\u901A\u8FC7\uFF08${result.passed.length} \u9879${result.warnings.length > 0 ? `\uFF0C${result.warnings.length} \u6761\u8B66\u544A` : ""}\uFF09`);
|
|
766
|
+
}
|
|
767
|
+
__name(dshCheckCommand, "dshCheckCommand");
|
|
768
|
+
function readPnpmVersion() {
|
|
769
|
+
try {
|
|
770
|
+
return (0, import_node_child_process3.execSync)("pnpm --version", { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }).trim();
|
|
771
|
+
} catch {
|
|
772
|
+
return void 0;
|
|
773
|
+
}
|
|
774
|
+
}
|
|
775
|
+
__name(readPnpmVersion, "readPnpmVersion");
|
|
776
|
+
var majorOf = /* @__PURE__ */ __name((version) => {
|
|
777
|
+
const major = Number.parseInt((version ?? "").split(".")[0] ?? "", 10);
|
|
778
|
+
return Number.isFinite(major) ? major : 0;
|
|
779
|
+
}, "majorOf");
|
|
780
|
+
function buildInstallSpec(options) {
|
|
781
|
+
if (options.spec !== void 0) return { spec: options.spec };
|
|
782
|
+
if (options.from !== void 0) {
|
|
783
|
+
const target = (0, import_node_path5.resolve)(options.from);
|
|
784
|
+
if (!(0, import_node_fs3.existsSync)(target)) return { error: `--from \u6307\u5411\u7684\u8DEF\u5F84\u4E0D\u5B58\u5728\uFF1A${target}` };
|
|
785
|
+
return { spec: target };
|
|
786
|
+
}
|
|
787
|
+
if (options.repo !== void 0) {
|
|
788
|
+
const ref = options.tag !== void 0 && options.tag !== "" ? `#${options.tag}` : "";
|
|
789
|
+
const sub = options.subpath !== void 0 && options.subpath !== "" ? `${ref === "" ? "#" : "&"}path:${options.subpath}` : "";
|
|
790
|
+
return { spec: `github:${options.repo}${ref}${sub}` };
|
|
791
|
+
}
|
|
792
|
+
return { error: "\u9700\u8981 --spec\u3001--from \u6216 --repo \u4E4B\u4E00\u6765\u6307\u5B9A\u5B89\u88C5\u6765\u6E90\u3002" };
|
|
793
|
+
}
|
|
794
|
+
__name(buildInstallSpec, "buildInstallSpec");
|
|
795
|
+
var CMD_NEEDS_QUOTE = /[\s&|<>^()"']/u;
|
|
796
|
+
function quoteForCmd(part) {
|
|
797
|
+
return CMD_NEEDS_QUOTE.test(part) ? `"${part.replace(/"/gu, '""')}"` : part;
|
|
798
|
+
}
|
|
799
|
+
__name(quoteForCmd, "quoteForCmd");
|
|
800
|
+
function buildShellCommand(exe, args) {
|
|
801
|
+
return [exe, ...args].map(quoteForCmd).join(" ");
|
|
802
|
+
}
|
|
803
|
+
__name(buildShellCommand, "buildShellCommand");
|
|
804
|
+
function spawnDsh(args, dry) {
|
|
805
|
+
if (dry) {
|
|
806
|
+
console.log(`
|
|
807
|
+
${buildShellCommand("dsh", args)}
|
|
808
|
+
`);
|
|
809
|
+
return 0;
|
|
810
|
+
}
|
|
811
|
+
if (process.platform === "win32") {
|
|
812
|
+
const result2 = (0, import_node_child_process3.spawnSync)(buildShellCommand("dsh", args), { stdio: "inherit", shell: true });
|
|
813
|
+
return result2.status ?? 1;
|
|
814
|
+
}
|
|
815
|
+
const result = (0, import_node_child_process3.spawnSync)("dsh", args, { stdio: "inherit" });
|
|
816
|
+
return result.status ?? 1;
|
|
817
|
+
}
|
|
818
|
+
__name(spawnDsh, "spawnDsh");
|
|
819
|
+
function dshInstallCommand(options) {
|
|
820
|
+
const profile = options.profile ?? "desktop";
|
|
821
|
+
const { spec, error: error2 } = buildInstallSpec(options);
|
|
822
|
+
if (spec === void 0) {
|
|
823
|
+
logger.error(error2 ?? "\u672A\u77E5\u9519\u8BEF");
|
|
824
|
+
process.exitCode = 1;
|
|
825
|
+
return;
|
|
826
|
+
}
|
|
827
|
+
const usesSubpath = spec.includes("path:");
|
|
828
|
+
const pnpmVersion = readPnpmVersion();
|
|
829
|
+
if (usesSubpath && pnpmVersion !== void 0 && majorOf(pnpmVersion) < 11) {
|
|
830
|
+
logger.warn(
|
|
831
|
+
`\u68C0\u6D4B\u5230 pnpm ${pnpmVersion}\uFF1A11 \u4EE5\u4E0B\u4E0D\u652F\u6301 git \u5B50\u76EE\u5F55\u8BED\u6CD5\uFF08#\u2026&path:\uFF09\uFF0C\u4F1A\u9759\u9ED8\u88C5\u6210\u4ED3\u5E93\u6839\u800C\u4E0D\u662F\u4F60\u60F3\u8981\u7684\u5B50\u5305\u3002DSH \u5185\u7F6E\u7684 pnpm 11 \u4E0D\u53D7\u5F71\u54CD \u2014\u2014 \u5EFA\u8BAE\u6539\u7528 DSH \u63D2\u4EF6\u9875\u5B89\u88C5\u3002`
|
|
832
|
+
);
|
|
833
|
+
}
|
|
834
|
+
if (usesSubpath && process.platform === "win32") {
|
|
835
|
+
logger.info("Windows\uFF1A\u4F1A\u901A\u8FC7 cmd /d /s /c \u6267\u884C\uFF0C\u907F\u514D & \u88AB\u5F53\u6210\u547D\u4EE4\u5206\u9694\u7B26\u3002");
|
|
836
|
+
}
|
|
837
|
+
logger.step(`\u5B89\u88C5\u5230 profile\u300C${profile}\u300D`);
|
|
838
|
+
console.log(` spec: ${spec}`);
|
|
839
|
+
if (!(0, import_node_path5.isAbsolute)(spec) && !spec.startsWith("github:") && !spec.startsWith("git+") && !spec.startsWith("http")) {
|
|
840
|
+
logger.warn("\u8FD9\u4E2A spec \u65E2\u4E0D\u662F\u7EDD\u5BF9\u8DEF\u5F84\u4E5F\u4E0D\u662F git/URL\uFF0C\u786E\u8BA4\u6CA1\u6709\u5199\u9519\u3002");
|
|
841
|
+
}
|
|
842
|
+
const status = spawnDsh(["plugin", "--profile", profile, "add", spec], options.dry === true);
|
|
843
|
+
if (options.dry === true) {
|
|
844
|
+
logger.info("dry run\uFF1A\u4EE5\u4E0A\u547D\u4EE4\u6CA1\u6709\u6267\u884C\u3002");
|
|
845
|
+
return;
|
|
846
|
+
}
|
|
847
|
+
if (status !== 0) {
|
|
848
|
+
logger.error(`\u5B89\u88C5\u5931\u8D25\uFF08\u9000\u51FA\u7801 ${status}\uFF09\u3002\u8BCA\u65AD\u65E5\u5FD7\u5728 ~/.dsh/profiles/${profile}/.plugin-manager/logs/`);
|
|
849
|
+
process.exitCode = status;
|
|
850
|
+
return;
|
|
851
|
+
}
|
|
852
|
+
logger.success("\u5B89\u88C5\u5B8C\u6210 \u2014\u2014 \u5B8C\u5168\u9000\u51FA DSH \u518D\u6253\u5F00\u5373\u53EF\u751F\u6548");
|
|
853
|
+
}
|
|
854
|
+
__name(dshInstallCommand, "dshInstallCommand");
|
|
855
|
+
var ACTIONS = {
|
|
856
|
+
init: "\u521B\u5EFA\u4E00\u4E2A DSH \u63D2\u4EF6\u9879\u76EE",
|
|
857
|
+
dev: "\u672C\u5730\u9884\u89C8\uFF08\u6D4F\u89C8\u5668\u91CC\u770B\u9762\u677F\uFF0C\u4E0D\u7528\u88C5\u8FDB DSH\uFF09",
|
|
858
|
+
build: "\u6784\u5EFA lib/{index,client}.js",
|
|
859
|
+
check: "\u88C5\u524D\u4E00\u81F4\u6027\u6821\u9A8C",
|
|
860
|
+
install: "\u628A\u63D2\u4EF6\u88C5\u8FDB DSH profile"
|
|
861
|
+
};
|
|
862
|
+
async function dshCommand(action, target, options) {
|
|
863
|
+
switch (action) {
|
|
864
|
+
case "init":
|
|
865
|
+
case "create":
|
|
866
|
+
await dshInitCommand(target, options);
|
|
867
|
+
return;
|
|
868
|
+
case "dev":
|
|
869
|
+
await dshDevCommand(options);
|
|
870
|
+
return;
|
|
871
|
+
case "build":
|
|
872
|
+
await dshBuildCommand();
|
|
873
|
+
return;
|
|
874
|
+
case "check":
|
|
875
|
+
dshCheckCommand();
|
|
876
|
+
return;
|
|
877
|
+
case "install":
|
|
878
|
+
dshInstallCommand(options);
|
|
879
|
+
return;
|
|
880
|
+
default:
|
|
881
|
+
logger.error(`\u672A\u77E5\u5B50\u547D\u4EE4: ${action ?? "(\u7A7A)"}`);
|
|
882
|
+
console.log("\n \u53EF\u7528\u5B50\u547D\u4EE4\uFF1A");
|
|
883
|
+
for (const [name, description] of Object.entries(ACTIONS)) {
|
|
884
|
+
console.log(` vobs dsh ${name.padEnd(8)} ${description}`);
|
|
885
|
+
}
|
|
886
|
+
process.exitCode = 1;
|
|
887
|
+
}
|
|
888
|
+
}
|
|
889
|
+
__name(dshCommand, "dshCommand");
|
|
890
|
+
|
|
359
891
|
// packages/cli/src/banner.ts
|
|
360
892
|
var BANNER_LINE1 = "\u{1D5E9}\u{1D5E2}\u{1D5D5}\u{1D5E6} \u{1D5D6}\u{1D5DF}\u{1D5DC} \u{1D603}\u{1D7ED}.\u{1D7EC}";
|
|
361
893
|
var BANNER_TAGLINE = "Signals First \xB7 Zero Re-renders \xB7 Ultra Lightweight";
|
|
@@ -432,6 +964,20 @@ function createCLI() {
|
|
|
432
964
|
dev: options.dev
|
|
433
965
|
});
|
|
434
966
|
});
|
|
967
|
+
cli.command("dsh <action> [target]", "DSH \u63D2\u4EF6\u5DE5\u5177\u94FE\uFF08init / dev / build / check / install\uFF09").option("--dir <dir>", "init\uFF1A\u76EE\u6807\u76EE\u5F55").option("--pm <pm>", "init\uFF1A\u5305\u7BA1\u7406\u5668\uFF08pnpm/npm\uFF09").option("--port <port>", "dev\uFF1A\u9884\u89C8\u7AEF\u53E3", { default: 5199 }).option("--profile <name>", "install\uFF1ADSH profile \u540D", { default: "desktop" }).option("--spec <spec>", "install\uFF1A\u5B8C\u6574\u5B89\u88C5 spec").option("--repo <owner/name>", "install\uFF1AGitHub owner/name").option("--tag <ref>", "install\uFF1AGit tag / \u5206\u652F / commit").option("--subpath <path>", "install\uFF1A\u4ED3\u5E93\u5185\u5B50\u76EE\u5F55").option("--from <path>", "install\uFF1A\u4ECE\u672C\u5730\u76EE\u5F55\u5B89\u88C5").option("--dry", "install\uFF1A\u53EA\u6253\u5370\u547D\u4EE4\uFF0C\u4E0D\u6267\u884C").action(async (action, target, options) => {
|
|
968
|
+
await dshCommand(action, target, {
|
|
969
|
+
dir: options.dir,
|
|
970
|
+
pm: options.pm,
|
|
971
|
+
profile: options.profile,
|
|
972
|
+
spec: options.spec,
|
|
973
|
+
repo: options.repo,
|
|
974
|
+
tag: options.tag,
|
|
975
|
+
subpath: options.subpath,
|
|
976
|
+
from: options.from,
|
|
977
|
+
dry: options.dry === true,
|
|
978
|
+
port: options.port === void 0 ? void 0 : Number(options.port)
|
|
979
|
+
});
|
|
980
|
+
});
|
|
435
981
|
cli.command("logo", "Show the vobs CLI logo and version info").action(() => {
|
|
436
982
|
showLogo();
|
|
437
983
|
});
|
|
@@ -445,12 +991,12 @@ function createCLI() {
|
|
|
445
991
|
__name(createCLI, "createCLI");
|
|
446
992
|
|
|
447
993
|
// packages/cli/src/repl.ts
|
|
448
|
-
var
|
|
994
|
+
var import_promises2 = require("readline/promises");
|
|
449
995
|
var import_node_process = require("process");
|
|
450
996
|
var import_picocolors2 = __toESM(require("picocolors"), 1);
|
|
451
997
|
async function startRepl() {
|
|
452
998
|
showLogo();
|
|
453
|
-
const rl = (0,
|
|
999
|
+
const rl = (0, import_promises2.createInterface)({
|
|
454
1000
|
input: import_node_process.stdin,
|
|
455
1001
|
output: import_node_process.stdout,
|
|
456
1002
|
prompt: ` ${import_picocolors2.default.magenta("\u276F")} `,
|