@univer-cli/daemon-command 1.0.0-beta.2

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/README.md ADDED
@@ -0,0 +1,44 @@
1
+ # @univer-cli/daemon-command
2
+
3
+ English | [简体中文](./README.zh-CN.md)
4
+
5
+ Provide native Commander lifecycle commands for `@univer-cli/daemon`, allowing users to inspect, start, restart, and stop a local daemon explicitly.
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ pnpm add commander @univer-cli/daemon @univer-cli/daemon-command
11
+ ```
12
+
13
+ Commander `^15.0.0` is a peer dependency. Requires Node.js 22.12 or higher.
14
+
15
+ ## Quick Start
16
+
17
+ ```ts
18
+ import { createDaemonControl } from "@univer-cli/daemon";
19
+ import { createDaemonCommand } from "@univer-cli/daemon-command";
20
+ import { Command } from "commander";
21
+
22
+ const control = createDaemonControl({
23
+ entry: new URL("./daemon.js", import.meta.url),
24
+ identity: { id: "my-cli", version: "1.2.0" },
25
+ socketPath: "/tmp/my-cli.sock",
26
+ });
27
+
28
+ const program = new Command("my-cli");
29
+ program.addCommand(createDaemonCommand({ control }));
30
+ await program.parseAsync();
31
+ ```
32
+
33
+ ## Command list
34
+
35
+ ```text
36
+ daemon status [--json]
37
+ daemon start [--json]
38
+ daemon restart [--json]
39
+ daemon stop [--json]
40
+ ```
41
+
42
+ Default output is human-readable; `--json` is suitable for scripts and Agents. The factory returns a native Commander `Command`, so you can continue to customize its name, help, output, and exit behavior.
43
+
44
+ This package does not choose the daemon entrypoint, socket, identity, environment, or application shutdown cleanup. The application provides those dependencies when it creates `DaemonControl`.
@@ -0,0 +1,47 @@
1
+ # @univer-cli/daemon-command
2
+
3
+ [English](./README.md) | 简体中文
4
+
5
+ 为 `@univer-cli/daemon` 提供原生 Commander lifecycle command,让用户显式查看、启动、重启和停止本地
6
+ daemon。
7
+
8
+ ## 安装
9
+
10
+ ```bash
11
+ pnpm add commander @univer-cli/daemon @univer-cli/daemon-command
12
+ ```
13
+
14
+ Commander `^15.0.0` 是 peer dependency。要求 Node.js 22.12 或更高版本。
15
+
16
+ ## 快速开始
17
+
18
+ ```ts
19
+ import { createDaemonControl } from "@univer-cli/daemon";
20
+ import { createDaemonCommand } from "@univer-cli/daemon-command";
21
+ import { Command } from "commander";
22
+
23
+ const control = createDaemonControl({
24
+ entry: new URL("./daemon.js", import.meta.url),
25
+ identity: { id: "my-cli", version: "1.2.0" },
26
+ socketPath: "/tmp/my-cli.sock",
27
+ });
28
+
29
+ const program = new Command("my-cli");
30
+ program.addCommand(createDaemonCommand({ control }));
31
+ await program.parseAsync();
32
+ ```
33
+
34
+ ## 命令一览
35
+
36
+ ```text
37
+ daemon status [--json]
38
+ daemon start [--json]
39
+ daemon restart [--json]
40
+ daemon stop [--json]
41
+ ```
42
+
43
+ 默认输出面向人阅读;`--json` 适合脚本和 Agent。Factory 返回原生 Commander `Command`,可以继续修改名称、
44
+ help、输出或退出行为。
45
+
46
+ 本 package 不决定 daemon entry、socket、identity、environment 和 application shutdown cleanup;这些依赖由
47
+ application 创建 `DaemonControl` 时提供。
package/dist/index.cjs ADDED
@@ -0,0 +1 @@
1
+ 'use strict';module['exports']=require('./index.mjs');
@@ -0,0 +1,9 @@
1
+ import { DaemonControl } from "@univer-cli/daemon";
2
+ import { Command } from "commander";
3
+ //#region src/index.d.ts
4
+ interface DaemonCommandDependencies {
5
+ readonly control: DaemonControl;
6
+ }
7
+ declare function createDaemonCommand(dependencies: DaemonCommandDependencies): Command;
8
+ //#endregion
9
+ export { DaemonCommandDependencies, createDaemonCommand };
package/dist/index.mjs ADDED
@@ -0,0 +1 @@
1
+ (function(_0x8dd5bc,_0x14e4a9){const _0x454683=_0x3955,_0x431f33=_0x8dd5bc();while(!![]){try{const _0x2d2a89=parseInt(_0x454683(0xac))/0x1+parseInt(_0x454683(0xd5))/0x2*(parseInt(_0x454683(0xb7))/0x3)+-parseInt(_0x454683(0x99))/0x4*(-parseInt(_0x454683(0xa7))/0x5)+parseInt(_0x454683(0x9a))/0x6+parseInt(_0x454683(0xc1))/0x7+parseInt(_0x454683(0xd8))/0x8*(parseInt(_0x454683(0xca))/0x9)+parseInt(_0x454683(0xd4))/0xa*(-parseInt(_0x454683(0xba))/0xb);if(_0x2d2a89===_0x14e4a9)break;else _0x431f33['push'](_0x431f33['shift']());}catch(_0xb7bb29){_0x431f33['push'](_0x431f33['shift']());}}}(_0x137a,0x277c1));function _0x3955(_0x448aab,_0x28d62a){_0x448aab=_0x448aab-0x98;const _0x137aed=_0x137a();let _0x395577=_0x137aed[_0x448aab];return _0x395577;}import{Command as _0x2cef8c}from'commander';function t(_0x595597){const _0x55cafd=_0x3955;let _0x261f87=new _0x2cef8c(_0x55cafd(0xa2))[_0x55cafd(0xad)]('Inspect\x20and\x20control\x20the\x20local\x20daemon')[_0x55cafd(0xb8)](()=>_0x261f87[_0x55cafd(0xb0)]()),_0x2930b6=_0x261f87[_0x55cafd(0xd1)](_0x55cafd(0xb6))[_0x55cafd(0xad)](_0x55cafd(0xbb))[_0x55cafd(0xd6)](_0x55cafd(0xc3),_0x55cafd(0xd0))[_0x55cafd(0xb8)](async _0x314b88=>{const _0x51e4cc=_0x55cafd;let _0x4aa564=await n(_0x2930b6,async()=>await _0x595597[_0x51e4cc(0xd3)][_0x51e4cc(0xb6)]());r(_0x2930b6,_0x314b88,_0x4aa564,i(_0x4aa564));}),_0x54b28d=_0x261f87[_0x55cafd(0xd1)](_0x55cafd(0xb1))[_0x55cafd(0xad)]('Start\x20the\x20daemon\x20if\x20it\x20is\x20not\x20already\x20running')['option']('--json',_0x55cafd(0xd0))[_0x55cafd(0xb8)](async _0x1eed22=>{const _0x15979e=_0x55cafd;let _0x229cfc=await n(_0x54b28d,async()=>await _0x595597['control'][_0x15979e(0xb1)]());r(_0x54b28d,_0x1eed22,_0x229cfc,c(_0x229cfc));}),_0x256d75=_0x261f87[_0x55cafd(0xd1)]('restart')[_0x55cafd(0xad)](_0x55cafd(0xb2))[_0x55cafd(0xd6)](_0x55cafd(0xc3),_0x55cafd(0xd0))['action'](async _0x5ee26b=>{const _0x83e803=_0x55cafd;let _0x38bac4=await n(_0x256d75,async()=>await _0x595597[_0x83e803(0xd3)][_0x83e803(0xc5)]());r(_0x256d75,_0x5ee26b,_0x38bac4,l(_0x38bac4));}),_0x4341f3=_0x261f87['command'](_0x55cafd(0x9e))['description'](_0x55cafd(0xab))[_0x55cafd(0xd6)](_0x55cafd(0xc3),_0x55cafd(0xd0))[_0x55cafd(0xb8)](async _0x10a8ed=>{const _0x1ef225=_0x55cafd;let _0x502513=await n(_0x4341f3,async()=>await _0x595597[_0x1ef225(0xd3)]['stop']());r(_0x4341f3,_0x10a8ed,_0x502513,u(_0x502513));});return _0x261f87;}async function n(_0x43cb26,_0x141510){const _0x211c5d=_0x3955;try{return await _0x141510();}catch(_0x2fe65e){throw f(_0x2fe65e)&&_0x43cb26['error'](_0x2fe65e['code']+':\x20'+_0x2fe65e[_0x211c5d(0xbc)],{'code':_0x211c5d(0xc9),'exitCode':0x1}),_0x2fe65e;}}function r(_0x297599,_0x3b116d,_0x2aa6f1,_0x588158){const _0x4b9fa0=_0x3955;_0x297599['configureOutput']()['writeOut']?.((_0x3b116d['json']===!0x0?JSON[_0x4b9fa0(0xb5)](_0x2aa6f1,null,0x2):_0x588158)+'\x0a');}function i(_0x3c8449){const _0x5d2db9=_0x3955;switch(_0x3c8449[_0x5d2db9(0xcc)]){case _0x5d2db9(0xcb):return d(_0x5d2db9(0xa6),_0x3c8449);case _0x5d2db9(0xa0):return _0x5d2db9(0xc8)+_0x3c8449['socketPath'];case _0x5d2db9(0xb4):return a(_0x3c8449);case _0x5d2db9(0x9c):return['Daemon:\x20unreachable',_0x5d2db9(0xa5)+s(_0x3c8449[_0x5d2db9(0xc4)]),_0x5d2db9(0xa9)+_0x3c8449['socketPath']][_0x5d2db9(0x9f)]('\x0a');}}function a(_0x2a26f4){const _0x29a298=_0x3955;return['Daemon:\x20incompatible',_0x29a298(0xb9)+_0x2a26f4[_0x29a298(0xd2)],'Expected:\x20'+o(_0x2a26f4[_0x29a298(0xae)][_0x29a298(0x9d)],_0x2a26f4[_0x29a298(0xae)][_0x29a298(0x98)]),..._0x2a26f4[_0x29a298(0xa3)]===void 0x0?[]:[_0x29a298(0xcd)+o(_0x2a26f4[_0x29a298(0xa3)][_0x29a298(0x9d)],_0x2a26f4[_0x29a298(0xa3)][_0x29a298(0x98)])],..._0x2a26f4['diagnostic']===void 0x0?[]:[_0x29a298(0xa5)+s(_0x2a26f4[_0x29a298(0xc4)])],_0x29a298(0xa9)+_0x2a26f4[_0x29a298(0xa1)]][_0x29a298(0x9f)]('\x0a');}function o(_0x3e5005,_0x1e7a04){const _0x5b0940=_0x3955;return _0x3e5005['id']+'@'+_0x3e5005[_0x5b0940(0xaf)]+(_0x3e5005[_0x5b0940(0xc2)]===void 0x0?'':_0x5b0940(0xaa)+_0x3e5005['buildId']+')')+_0x5b0940(0xd7)+String(_0x1e7a04);}function _0x137a(){const _0x5e4690=['7552130HBTFBc','5976LgQRFC','option',',\x20protocol\x20','80FasidU','previousPid','Build\x20ID:\x20','protocolVersion','749140bEZoqh','1849644hVNODG','Daemon:\x20already\x20running','unreachable','identity','stop','join','stopped','socketPath','daemon','actual','string','Error:\x20','Daemon:\x20running','5wxBOsi','started','Socket:\x20','\x20(build\x20','Stop\x20the\x20daemon\x20if\x20it\x20is\x20running','53534haoPCY','description','expected','version','outputHelp','start','Restart\x20the\x20daemon,\x20or\x20start\x20it\x20if\x20it\x20is\x20not\x20running','restarted','incompatible','stringify','status','207kWKFOR','action','Reason:\x20','11IhXQgt','Show\x20whether\x20the\x20daemon\x20is\x20running','message','PID:\x20','Daemon:\x20started','Daemon:\x20stopped','code','852159HaJSbF','buildId','--json','diagnostic','restart','\x0aSocket:\x20','\x0aPrevious\x20PID:\x20','Daemon:\x20stopped\x0aSocket:\x20','daemon.failed','35946zninNU','running','state','Actual:\x20','pid','startedAt','write\x20structured\x20JSON','command','reason','control'];_0x137a=function(){return _0x5e4690;};return _0x137a();}function s(_0x2461ae){const _0x52f4d0=_0x3955;return _0x2461ae[_0x52f4d0(0xc0)]===void 0x0?_0x2461ae[_0x52f4d0(0xbc)]:_0x2461ae['code']+':\x20'+_0x2461ae['message'];}function c(_0x23d829){const _0xcceec1=_0x3955;return d(_0x23d829[_0xcceec1(0xa8)]?'Daemon:\x20started':_0xcceec1(0x9b),_0x23d829);}function l(_0x935059){const _0x4a60aa=_0x3955;let _0x18373a=d(_0x935059[_0x4a60aa(0xb3)]?'Daemon:\x20restarted':_0x4a60aa(0xbe),_0x935059);return _0x935059[_0x4a60aa(0xd9)]===void 0x0?_0x18373a:_0x18373a+_0x4a60aa(0xc7)+String(_0x935059[_0x4a60aa(0xd9)]);}function u(_0x110f7d){const _0x519c35=_0x3955;return(_0x110f7d[_0x519c35(0xa0)]?_0x519c35(0xbf):'Daemon:\x20already\x20stopped')+_0x519c35(0xc6)+_0x110f7d[_0x519c35(0xa1)];}function d(_0x5e1721,_0x5bc670){const _0x4e7da0=_0x3955;return[_0x5e1721,'Identity:\x20'+_0x5bc670['identity']['id'],'Version:\x20'+_0x5bc670[_0x4e7da0(0x9d)][_0x4e7da0(0xaf)],..._0x5bc670[_0x4e7da0(0x9d)][_0x4e7da0(0xc2)]===void 0x0?[]:[_0x4e7da0(0xda)+_0x5bc670[_0x4e7da0(0x9d)][_0x4e7da0(0xc2)]],'Protocol:\x20'+String(_0x5bc670[_0x4e7da0(0x98)]),_0x4e7da0(0xbd)+String(_0x5bc670[_0x4e7da0(0xce)]),'Started\x20at:\x20'+_0x5bc670[_0x4e7da0(0xcf)],'Socket:\x20'+_0x5bc670[_0x4e7da0(0xa1)]][_0x4e7da0(0x9f)]('\x0a');}function f(_0x234f6a){const _0x7993c7=_0x3955;return _0x234f6a instanceof Error&&_0x7993c7(0xc0)in _0x234f6a&&typeof _0x234f6a[_0x7993c7(0xc0)]==_0x7993c7(0xa4);}export{t as createDaemonCommand};
package/package.json ADDED
@@ -0,0 +1,26 @@
1
+ {
2
+ "name": "@univer-cli/daemon-command",
3
+ "type": "module",
4
+ "version": "1.0.0-beta.2",
5
+ "main": "./dist/index.cjs",
6
+ "module": "./dist/index.mjs",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.mjs",
12
+ "require": "./dist/index.cjs"
13
+ }
14
+ },
15
+ "files": [
16
+ "dist",
17
+ "README.md",
18
+ "README.zh-CN.md"
19
+ ],
20
+ "dependencies": {
21
+ "@univer-cli/daemon": "1.0.0-beta.2"
22
+ },
23
+ "peerDependencies": {
24
+ "commander": "^15.0.0"
25
+ }
26
+ }