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