@appthen/cli 1.1.19 → 1.1.21
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/main.js +73 -0
- package/dist/index.js +15 -28
- package/package.json +3 -1
- package/dist/index.js.map +0 -1
package/bin/main.js
CHANGED
|
@@ -285,5 +285,78 @@ program
|
|
|
285
285
|
});
|
|
286
286
|
});
|
|
287
287
|
|
|
288
|
+
/**
|
|
289
|
+
* connect命令
|
|
290
|
+
* 用于启动websocket连接服务
|
|
291
|
+
* 必需参数:
|
|
292
|
+
* -p, --id: 项目ID
|
|
293
|
+
* -a, --auth: 认证token
|
|
294
|
+
* 可选参数:
|
|
295
|
+
* -c, --cwd: 指定工作目录
|
|
296
|
+
* -q, --quiet: 安静模式
|
|
297
|
+
* -vb, --verbose: 详细模式
|
|
298
|
+
* --daemon: 以守护进程方式运行
|
|
299
|
+
* --debug: 调试模式,进程不会自动退出
|
|
300
|
+
*/
|
|
301
|
+
program
|
|
302
|
+
.command('connect')
|
|
303
|
+
.description('start websocket connection service')
|
|
304
|
+
.requiredOption('-p, --id <id>', 'project id')
|
|
305
|
+
.requiredOption('-a, --auth <auth>', 'auth token')
|
|
306
|
+
.option('-c, --cwd <cwd>', 'specify the working directory', '.')
|
|
307
|
+
.option(
|
|
308
|
+
'-q, --quiet',
|
|
309
|
+
'be quiet, do not output anything unless get error',
|
|
310
|
+
false
|
|
311
|
+
)
|
|
312
|
+
.option('-vb, --verbose', 'be verbose, output more information', false)
|
|
313
|
+
.option('--daemon', 'run as daemon process', false)
|
|
314
|
+
.option('--debug', 'debug mode, process will not exit automatically', false)
|
|
315
|
+
.action(async function doConnect(command) {
|
|
316
|
+
var options = command.opts();
|
|
317
|
+
if (options.cwd) {
|
|
318
|
+
process.chdir(options.cwd);
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
try {
|
|
322
|
+
const retCode = await require('../dist/index.js').startConnecting({
|
|
323
|
+
...options,
|
|
324
|
+
daemon: options.daemon,
|
|
325
|
+
debug: options.debug
|
|
326
|
+
});
|
|
327
|
+
if (!options.debug) {
|
|
328
|
+
process.exit(retCode);
|
|
329
|
+
}
|
|
330
|
+
} catch (error) {
|
|
331
|
+
console.error('连接失败:', error);
|
|
332
|
+
if (!options.debug) {
|
|
333
|
+
process.exit(1);
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
});
|
|
337
|
+
|
|
338
|
+
/**
|
|
339
|
+
* stop-connect命令
|
|
340
|
+
* 停止websocket连接服务
|
|
341
|
+
*/
|
|
342
|
+
program
|
|
343
|
+
.command('stop-connect')
|
|
344
|
+
.description('stop websocket connection service')
|
|
345
|
+
.action(async function doStopConnect() {
|
|
346
|
+
try {
|
|
347
|
+
const stopped = require('../dist/index.js').stopConnecting();
|
|
348
|
+
if (stopped) {
|
|
349
|
+
console.log('服务已停止');
|
|
350
|
+
process.exit(0);
|
|
351
|
+
} else {
|
|
352
|
+
console.log('没有找到运行中的服务');
|
|
353
|
+
process.exit(1);
|
|
354
|
+
}
|
|
355
|
+
} catch (error) {
|
|
356
|
+
console.error('停止服务失败:', error);
|
|
357
|
+
process.exit(1);
|
|
358
|
+
}
|
|
359
|
+
});
|
|
360
|
+
|
|
288
361
|
// 解析命令行参数
|
|
289
362
|
program.parse(process.argv);
|