@oxiaom/adoremix 1.0.31 → 1.0.33

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oxiaom/adoremix",
3
- "version": "1.0.31",
3
+ "version": "1.0.33",
4
4
  "description": "AdoreMix broadcast server - cross-platform installer, runner and service manager",
5
5
  "bin": {
6
6
  "adoremix": "./bin/adoremix.js"
package/src/cli.js CHANGED
@@ -425,6 +425,33 @@ function buildProgram() {
425
425
  }
426
426
  });
427
427
 
428
+ program
429
+ .command('uninstall')
430
+ .description('完全卸载:停服务 + 卸载 systemd 服务;加 --purge 删除工作目录(含配置/数据库,不可恢复)')
431
+ .option('--workdir <path>')
432
+ .option('--purge', '同时删除工作目录(含所有数据)')
433
+ .action(async (opts) => {
434
+ const fs = require('fs');
435
+ const workdir = resolveWorkdir(opts.workdir);
436
+ try {
437
+ const svc = require('./service');
438
+ svc.uninstall({ workdir });
439
+ logger.ok('系统服务已卸载');
440
+ } catch (e) {
441
+ logger.warn(`服务卸载跳过:${e.message}`);
442
+ }
443
+ try {
444
+ await runner.stop(runnerOpts(opts));
445
+ } catch (e) {
446
+ logger.warn(`停止跳过:${e.message}`);
447
+ }
448
+ if (opts.purge) {
449
+ fs.rmSync(workdir, { recursive: true, force: true });
450
+ logger.ok(`已删除工作目录 ${workdir}`);
451
+ }
452
+ logger.ok('卸载完成');
453
+ });
454
+
428
455
  return program;
429
456
  }
430
457
 
package/src/config/ini.js CHANGED
@@ -1,6 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  const fs = require('fs');
4
+ const path = require('path');
4
5
  const ini = require('ini');
5
6
 
6
7
  function read(configPath) {
@@ -10,6 +11,8 @@ function read(configPath) {
10
11
  }
11
12
 
12
13
  function write(configPath, obj) {
14
+ // 工作目录可能被 uninstall --purge 删掉,写 config.ini 前确保父目录存在
15
+ fs.mkdirSync(path.dirname(configPath), { recursive: true });
13
16
  const txt = ini.stringify(obj, {
14
17
  section: '',
15
18
  whitespace: true,