alemonjs 2.1.46 → 2.1.47

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/README.md CHANGED
@@ -165,12 +165,12 @@ alemonc login telegram
165
165
 
166
166
  根据平台交互式提示输入所需字段:
167
167
 
168
- | 平台 | 必填字段 | 可选字段 |
169
- |------|---------|---------|
170
- | discord | token | — |
171
- | kook | token | — |
172
- | qq-bot | app_id, token, secret | — |
173
- | onebot | url | token |
174
- | telegram | token | proxy |
168
+ | 平台 | 必填字段 | 可选字段 |
169
+ | -------- | --------------------- | -------- |
170
+ | discord | token | — |
171
+ | kook | token | — |
172
+ | qq-bot | app_id, token, secret | — |
173
+ | onebot | url | token |
174
+ | telegram | token | proxy |
175
175
 
176
176
  配置保存到 `alemon.config.yaml`,已有值回车可保留。
package/bin/alemonc.js CHANGED
@@ -1,12 +1,12 @@
1
1
  #!/usr/bin/env node
2
- import {updateConfig} from './updateConfig.js';
3
- import {run} from './run.js';
4
- import {start} from './start.js';
5
- import {versionUpdate} from './versionUpdate.js';
6
- import {info} from './info.js';
7
- import {platformAdd, platformRemove, platformList} from './platform.js';
8
- import {login} from './login.js';
9
- import {Command} from 'commander';
2
+ import { updateConfig } from './updateConfig.js';
3
+ import { run } from './run.js';
4
+ import { start } from './start.js';
5
+ import { versionUpdate } from './versionUpdate.js';
6
+ import { info } from './info.js';
7
+ import { platformAdd, platformRemove, platformList } from './platform.js';
8
+ import { login } from './login.js';
9
+ import { Command } from 'commander';
10
10
  const program = new Command();
11
11
 
12
12
  program.name('alemonc').description('CLI to some alemonc actions and scripts').version('1.0.0');
package/bin/info.js CHANGED
@@ -1,93 +1,93 @@
1
1
  #!/usr/bin/env node
2
- import {join} from 'path';
2
+ import { join } from 'path';
3
3
  import fs from 'fs';
4
- import {execSync} from 'child_process';
4
+ import { execSync } from 'child_process';
5
5
  import YAML from 'yaml';
6
6
 
7
7
  /**
8
8
  * 输出项目诊断信息
9
9
  */
10
10
  export function info() {
11
- console.log('=== AlemonJS 项目信息 ===\n');
11
+ console.log('=== AlemonJS 项目信息 ===\n');
12
12
 
13
- // Node 版本
14
- console.log(`Node.js: ${process.version}`);
15
- console.log(`Platform: ${process.platform} ${process.arch}`);
13
+ // Node 版本
14
+ console.log(`Node.js: ${process.version}`);
15
+ console.log(`Platform: ${process.platform} ${process.arch}`);
16
16
 
17
- // package.json
18
- const pkgPath = join(process.cwd(), 'package.json');
19
- if (!fs.existsSync(pkgPath)) {
20
- console.log('\n未找到 package.json');
21
- return;
22
- }
17
+ // package.json
18
+ const pkgPath = join(process.cwd(), 'package.json');
19
+ if (!fs.existsSync(pkgPath)) {
20
+ console.log('\n未找到 package.json');
21
+ return;
22
+ }
23
23
 
24
- const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
25
- console.log(`项目名: ${pkg.name || '-'}`);
26
- console.log(`版本: ${pkg.version || '-'}`);
24
+ const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
25
+ console.log(`项目名: ${pkg.name || '-'}`);
26
+ console.log(`版本: ${pkg.version || '-'}`);
27
27
 
28
- // alemonjs 相关依赖
29
- const depFields = ['dependencies', 'devDependencies'];
30
- const related = [];
31
- for (const field of depFields) {
32
- const deps = pkg[field];
33
- if (!deps) continue;
34
- for (const [name, ver] of Object.entries(deps)) {
35
- if (name === 'alemonjs' || name.startsWith('@alemonjs/')) {
36
- related.push({name, ver, dev: field === 'devDependencies'});
37
- }
38
- }
28
+ // alemonjs 相关依赖
29
+ const depFields = ['dependencies', 'devDependencies'];
30
+ const related = [];
31
+ for (const field of depFields) {
32
+ const deps = pkg[field];
33
+ if (!deps) continue;
34
+ for (const [name, ver] of Object.entries(deps)) {
35
+ if (name === 'alemonjs' || name.startsWith('@alemonjs/')) {
36
+ related.push({ name, ver, dev: field === 'devDependencies' });
37
+ }
39
38
  }
39
+ }
40
40
 
41
- console.log(`\n--- 已安装平台/依赖 (${related.length}) ---`);
42
- if (related.length === 0) {
43
- console.log(' 无');
44
- } else {
45
- for (const item of related) {
46
- const tag = item.dev ? ' (dev)' : '';
47
- console.log(` ${item.name}@${item.ver}${tag}`);
48
- }
41
+ console.log(`\n--- 已安装平台/依赖 (${related.length}) ---`);
42
+ if (related.length === 0) {
43
+ console.log(' 无');
44
+ } else {
45
+ for (const item of related) {
46
+ const tag = item.dev ? ' (dev)' : '';
47
+ console.log(` ${item.name}@${item.ver}${tag}`);
49
48
  }
49
+ }
50
50
 
51
- // alemon.config.yaml 摘要
52
- const configPath = join(process.cwd(), 'alemon.config.yaml');
53
- if (fs.existsSync(configPath)) {
54
- const config = YAML.parse(fs.readFileSync(configPath, 'utf8')) ?? {};
55
- const keys = Object.keys(config);
56
- console.log(`\n--- 配置摘要 (alemon.config.yaml) ---`);
57
- if (keys.length === 0) {
58
- console.log(' 空配置');
51
+ // alemon.config.yaml 摘要
52
+ const configPath = join(process.cwd(), 'alemon.config.yaml');
53
+ if (fs.existsSync(configPath)) {
54
+ const config = YAML.parse(fs.readFileSync(configPath, 'utf8')) ?? {};
55
+ const keys = Object.keys(config);
56
+ console.log(`\n--- 配置摘要 (alemon.config.yaml) ---`);
57
+ if (keys.length === 0) {
58
+ console.log(' 空配置');
59
+ } else {
60
+ for (const key of keys) {
61
+ const val = config[key];
62
+ if (Array.isArray(val)) {
63
+ console.log(` ${key}: [${val.join(', ')}]`);
64
+ } else if (typeof val === 'object' && val !== null) {
65
+ console.log(` ${key}: { ${Object.keys(val).join(', ')} }`);
59
66
  } else {
60
- for (const key of keys) {
61
- const val = config[key];
62
- if (Array.isArray(val)) {
63
- console.log(` ${key}: [${val.join(', ')}]`);
64
- } else if (typeof val === 'object' && val !== null) {
65
- console.log(` ${key}: { ${Object.keys(val).join(', ')} }`);
66
- } else {
67
- console.log(` ${key}: ${val}`);
68
- }
69
- }
67
+ console.log(` ${key}: ${val}`);
70
68
  }
71
- } else {
72
- console.log('\n未找到 alemon.config.yaml');
69
+ }
73
70
  }
71
+ } else {
72
+ console.log('\n未找到 alemon.config.yaml');
73
+ }
74
74
 
75
- // .env 检查
76
- const envPath = join(process.cwd(), '.env');
77
- if (fs.existsSync(envPath)) {
78
- const envContent = fs.readFileSync(envPath, 'utf8');
79
- const envKeys = envContent
80
- .split('\n')
81
- .filter(l => l.trim() && !l.trim().startsWith('#'))
82
- .map(l => l.split('=')[0].trim())
83
- .filter(Boolean);
84
- console.log(`\n--- 环境变量 (.env) ---`);
85
- console.log(` 已配置 ${envKeys.length} 个变量: ${envKeys.join(', ')}`);
86
- }
75
+ // .env 检查
76
+ const envPath = join(process.cwd(), '.env');
77
+ if (fs.existsSync(envPath)) {
78
+ const envContent = fs.readFileSync(envPath, 'utf8');
79
+ const envKeys = envContent
80
+ .split('\n')
81
+ .filter(l => l.trim() && !l.trim().startsWith('#'))
82
+ .map(l => l.split('=')[0].trim())
83
+ .filter(Boolean);
84
+ console.log(`\n--- 环境变量 (.env) ---`);
85
+ console.log(` 已配置 ${envKeys.length} 个变量: ${envKeys.join(', ')}`);
86
+ }
87
87
 
88
- // 包管理器
89
- let pm = 'npm';
90
- if (fs.existsSync(join(process.cwd(), 'pnpm-lock.yaml'))) pm = 'pnpm';
91
- else if (fs.existsSync(join(process.cwd(), 'yarn.lock'))) pm = 'yarn';
92
- console.log(`\n包管理器: ${pm}`);
88
+ // 包管理器
89
+ let pm = 'npm';
90
+ if (fs.existsSync(join(process.cwd(), 'pnpm-lock.yaml'))) pm = 'pnpm';
91
+ else if (fs.existsSync(join(process.cwd(), 'yarn.lock'))) pm = 'yarn';
92
+ console.log(`\n包管理器: ${pm}`);
93
93
  }
package/bin/login.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
- import {join} from 'path';
2
+ import { join } from 'path';
3
3
  import fs from 'fs';
4
- import {createInterface} from 'readline';
4
+ import { createInterface } from 'readline';
5
5
  import YAML from 'yaml';
6
6
 
7
7
  const configPath = join(process.cwd(), 'alemon.config.yaml');
@@ -10,36 +10,32 @@ const configPath = join(process.cwd(), 'alemon.config.yaml');
10
10
  * 平台所需的配置字段定义
11
11
  */
12
12
  const platformFields = {
13
- discord: [
14
- {key: 'token', label: 'Bot Token', required: true, secret: true}
15
- ],
16
- kook: [
17
- {key: 'token', label: 'Bot Token', required: true, secret: true}
18
- ],
19
- telegram: [
20
- {key: 'token', label: 'Bot Token (从 @BotFather 获取)', required: true, secret: true},
21
- {key: 'proxy', label: '代理地址 (可选, 如 http://127.0.0.1:7890)', required: false}
22
- ],
23
- 'qq-bot': [
24
- {key: 'app_id', label: 'AppID', required: true},
25
- {key: 'token', label: 'Token', required: true, secret: true},
26
- {key: 'secret', label: 'AppSecret', required: true, secret: true}
27
- ],
28
- onebot: [
29
- {key: 'url', label: 'WebSocket 地址 (如 ws://127.0.0.1:6700)', required: true},
30
- {key: 'token', label: 'Access Token (可选)', required: false, secret: true}
31
- ]
13
+ discord: [{ key: 'token', label: 'Bot Token', required: true, secret: true }],
14
+ kook: [{ key: 'token', label: 'Bot Token', required: true, secret: true }],
15
+ telegram: [
16
+ { key: 'token', label: 'Bot Token (从 @BotFather 获取)', required: true, secret: true },
17
+ { key: 'proxy', label: '代理地址 (可选, 如 http://127.0.0.1:7890)', required: false }
18
+ ],
19
+ 'qq-bot': [
20
+ { key: 'app_id', label: 'AppID', required: true },
21
+ { key: 'token', label: 'Token', required: true, secret: true },
22
+ { key: 'secret', label: 'AppSecret', required: true, secret: true }
23
+ ],
24
+ onebot: [
25
+ { key: 'url', label: 'WebSocket 地址 (如 ws://127.0.0.1:6700)', required: true },
26
+ { key: 'token', label: 'Access Token (可选)', required: false, secret: true }
27
+ ]
32
28
  };
33
29
 
34
30
  /**
35
31
  * 提示输入
36
32
  */
37
33
  function prompt(rl, question) {
38
- return new Promise(resolve => {
39
- rl.question(question, answer => {
40
- resolve(answer.trim());
41
- });
34
+ return new Promise(resolve => {
35
+ rl.question(question, answer => {
36
+ resolve(answer.trim());
42
37
  });
38
+ });
43
39
  }
44
40
 
45
41
  /**
@@ -47,52 +43,52 @@ function prompt(rl, question) {
47
43
  * @param {string} name 平台名
48
44
  */
49
45
  export async function login(name) {
50
- const fields = platformFields[name];
51
- if (!fields) {
52
- const supported = Object.keys(platformFields).join(', ');
53
- console.error(`不支持的平台: ${name}`);
54
- console.log(`支持的平台: ${supported}`);
55
- process.exit(1);
56
- }
46
+ const fields = platformFields[name];
47
+ if (!fields) {
48
+ const supported = Object.keys(platformFields).join(', ');
49
+ console.error(`不支持的平台: ${name}`);
50
+ console.log(`支持的平台: ${supported}`);
51
+ process.exit(1);
52
+ }
57
53
 
58
- console.log(`\n=== 配置 ${name} 平台 ===\n`);
54
+ console.log(`\n=== 配置 ${name} 平台 ===\n`);
59
55
 
60
- // 读取现有配置
61
- let config = {};
62
- if (fs.existsSync(configPath)) {
63
- config = YAML.parse(fs.readFileSync(configPath, 'utf8')) ?? {};
64
- }
65
- const existing = config[name] || {};
56
+ // 读取现有配置
57
+ let config = {};
58
+ if (fs.existsSync(configPath)) {
59
+ config = YAML.parse(fs.readFileSync(configPath, 'utf8')) ?? {};
60
+ }
61
+ const existing = config[name] || {};
66
62
 
67
- const rl = createInterface({
68
- input: process.stdin,
69
- output: process.stdout
70
- });
63
+ const rl = createInterface({
64
+ input: process.stdin,
65
+ output: process.stdout
66
+ });
71
67
 
72
- const result = {...existing};
68
+ const result = { ...existing };
73
69
 
74
- for (const field of fields) {
75
- const current = existing[field.key];
76
- const mask = field.secret && current ? current.slice(0, 4) + '****' : current;
77
- const hint = current ? ` [当前: ${mask}, 回车保留]` : (field.required ? '' : ' [可选, 回车跳过]');
70
+ for (const field of fields) {
71
+ const current = existing[field.key];
72
+ const mask = field.secret && current ? current.slice(0, 4) + '****' : current;
73
+ const hint = current ? ` [当前: ${mask}, 回车保留]` : field.required ? '' : ' [可选, 回车跳过]';
78
74
 
79
- const answer = await prompt(rl, `${field.label}${hint}: `);
75
+ const answer = await prompt(rl, `${field.label}${hint}: `);
80
76
 
81
- if (answer) {
82
- result[field.key] = answer;
83
- } else if (!current && field.required) {
84
- console.error(`${field.label} 是必填项`);
85
- rl.close();
86
- process.exit(1);
87
- }
77
+ if (answer) {
78
+ result[field.key] = answer;
79
+ } else if (!current && field.required) {
80
+ console.error(`${field.label} 是必填项`);
81
+ rl.close();
82
+ process.exit(1);
88
83
  }
84
+ }
89
85
 
90
- rl.close();
86
+ rl.close();
91
87
 
92
- // 写入配置
93
- config[name] = result;
94
- fs.writeFileSync(configPath, YAML.stringify(config));
88
+ // 写入配置
89
+ config[name] = result;
90
+ fs.writeFileSync(configPath, YAML.stringify(config));
95
91
 
96
- console.log(`\n✓ ${name} 配置已保存到 alemon.config.yaml`);
97
- console.log(' 提示: 请确保 alemon.config.yaml 已加入 .gitignore,避免泄露密钥');
92
+ console.log(`\n✓ ${name} 配置已保存到 alemon.config.yaml`);
93
+ console.log(' 提示: 请确保 alemon.config.yaml 已加入 .gitignore,避免泄露密钥');
98
94
  }
package/bin/platform.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
- import {join} from 'path';
2
+ import { join } from 'path';
3
3
  import fs from 'fs';
4
- import {execSync} from 'child_process';
4
+ import { execSync } from 'child_process';
5
5
  import YAML from 'yaml';
6
6
 
7
7
  const configPath = join(process.cwd(), 'alemon.config.yaml');
@@ -10,26 +10,26 @@ const configPath = join(process.cwd(), 'alemon.config.yaml');
10
10
  * 检测包管理器
11
11
  */
12
12
  function detectPM() {
13
- if (fs.existsSync(join(process.cwd(), 'pnpm-lock.yaml'))) return 'pnpm';
14
- if (fs.existsSync(join(process.cwd(), 'yarn.lock'))) return 'yarn';
15
- return 'npm';
13
+ if (fs.existsSync(join(process.cwd(), 'pnpm-lock.yaml'))) return 'pnpm';
14
+ if (fs.existsSync(join(process.cwd(), 'yarn.lock'))) return 'yarn';
15
+ return 'npm';
16
16
  }
17
17
 
18
18
  /**
19
19
  * 读取配置
20
20
  */
21
21
  function readConfig() {
22
- if (fs.existsSync(configPath)) {
23
- return YAML.parse(fs.readFileSync(configPath, 'utf8')) ?? {};
24
- }
25
- return {};
22
+ if (fs.existsSync(configPath)) {
23
+ return YAML.parse(fs.readFileSync(configPath, 'utf8')) ?? {};
24
+ }
25
+ return {};
26
26
  }
27
27
 
28
28
  /**
29
29
  * 写入配置
30
30
  */
31
31
  function writeConfig(config) {
32
- fs.writeFileSync(configPath, YAML.stringify(config));
32
+ fs.writeFileSync(configPath, YAML.stringify(config));
33
33
  }
34
34
 
35
35
  /**
@@ -37,48 +37,46 @@ function writeConfig(config) {
37
37
  * @param {string} name 平台名(如 discord, kook, qq-bot)
38
38
  */
39
39
  export function platformAdd(name) {
40
- const pkgName = `@alemonjs/${name}`;
41
- const pm = detectPM();
42
-
43
- // 1. 检查是否已安装
44
- const pkgPath = join(process.cwd(), 'package.json');
45
- if (!fs.existsSync(pkgPath)) {
46
- console.error('未找到 package.json');
47
- process.exit(1);
48
- }
49
-
50
- const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
51
- const allDeps = {...pkg.dependencies, ...pkg.devDependencies};
52
-
53
- if (allDeps[pkgName]) {
54
- console.log(`${pkgName} 已安装 (${allDeps[pkgName]})`);
55
- } else {
56
- // 2. 安装
57
- console.log(`正在安装 ${pkgName}...`);
58
- try {
59
- const cmd = pm === 'npm' ? `npm install ${pkgName}` :
60
- pm === 'pnpm' ? `pnpm add ${pkgName}` :
61
- `yarn add ${pkgName}`;
62
- execSync(cmd, {stdio: 'inherit', timeout: 60000});
63
- console.log(`✓ ${pkgName} 安装完成`);
64
- } catch {
65
- console.error(`✗ ${pkgName} 安装失败`);
66
- process.exit(1);
67
- }
68
- }
69
-
70
- // 3. 注册到配置
71
- const config = readConfig();
72
- if (!Array.isArray(config.platforms)) {
73
- config.platforms = [];
74
- }
75
- if (!config.platforms.includes(name)) {
76
- config.platforms.push(name);
77
- writeConfig(config);
78
- console.log(`✓ 已将 ${name} 添加到 alemon.config.yaml`);
79
- } else {
80
- console.log(`${name} 已在配置中`);
40
+ const pkgName = `@alemonjs/${name}`;
41
+ const pm = detectPM();
42
+
43
+ // 1. 检查是否已安装
44
+ const pkgPath = join(process.cwd(), 'package.json');
45
+ if (!fs.existsSync(pkgPath)) {
46
+ console.error('未找到 package.json');
47
+ process.exit(1);
48
+ }
49
+
50
+ const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
51
+ const allDeps = { ...pkg.dependencies, ...pkg.devDependencies };
52
+
53
+ if (allDeps[pkgName]) {
54
+ console.log(`${pkgName} 已安装 (${allDeps[pkgName]})`);
55
+ } else {
56
+ // 2. 安装
57
+ console.log(`正在安装 ${pkgName}...`);
58
+ try {
59
+ const cmd = pm === 'npm' ? `npm install ${pkgName}` : pm === 'pnpm' ? `pnpm add ${pkgName}` : `yarn add ${pkgName}`;
60
+ execSync(cmd, { stdio: 'inherit', timeout: 60000 });
61
+ console.log(`✓ ${pkgName} 安装完成`);
62
+ } catch {
63
+ console.error(`✗ ${pkgName} 安装失败`);
64
+ process.exit(1);
81
65
  }
66
+ }
67
+
68
+ // 3. 注册到配置
69
+ const config = readConfig();
70
+ if (!Array.isArray(config.platforms)) {
71
+ config.platforms = [];
72
+ }
73
+ if (!config.platforms.includes(name)) {
74
+ config.platforms.push(name);
75
+ writeConfig(config);
76
+ console.log(`✓ 已将 ${name} 添加到 alemon.config.yaml`);
77
+ } else {
78
+ console.log(`${name} 已在配置中`);
79
+ }
82
80
  }
83
81
 
84
82
  /**
@@ -86,71 +84,69 @@ export function platformAdd(name) {
86
84
  * @param {string} name 平台名
87
85
  */
88
86
  export function platformRemove(name) {
89
- const pkgName = `@alemonjs/${name}`;
90
- const pm = detectPM();
91
-
92
- // 1. 卸载包
93
- const pkgPath = join(process.cwd(), 'package.json');
94
- if (fs.existsSync(pkgPath)) {
95
- const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
96
- const allDeps = {...pkg.dependencies, ...pkg.devDependencies};
97
-
98
- if (allDeps[pkgName]) {
99
- console.log(`正在卸载 ${pkgName}...`);
100
- try {
101
- const cmd = pm === 'npm' ? `npm uninstall ${pkgName}` :
102
- pm === 'pnpm' ? `pnpm remove ${pkgName}` :
103
- `yarn remove ${pkgName}`;
104
- execSync(cmd, {stdio: 'inherit', timeout: 60000});
105
- console.log(`✓ ${pkgName} 已卸载`);
106
- } catch {
107
- console.warn(`✗ ${pkgName} 卸载失败,请手动移除`);
108
- }
109
- } else {
110
- console.log(`${pkgName} 未安装,跳过卸载`);
111
- }
112
- }
87
+ const pkgName = `@alemonjs/${name}`;
88
+ const pm = detectPM();
89
+
90
+ // 1. 卸载包
91
+ const pkgPath = join(process.cwd(), 'package.json');
92
+ if (fs.existsSync(pkgPath)) {
93
+ const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
94
+ const allDeps = { ...pkg.dependencies, ...pkg.devDependencies };
113
95
 
114
- // 2. 从配置中移除
115
- const config = readConfig();
116
- if (Array.isArray(config.platforms)) {
117
- const idx = config.platforms.indexOf(name);
118
- if (idx !== -1) {
119
- config.platforms.splice(idx, 1);
120
- writeConfig(config);
121
- console.log(`✓ 已从 alemon.config.yaml 移除 ${name}`);
122
- }
96
+ if (allDeps[pkgName]) {
97
+ console.log(`正在卸载 ${pkgName}...`);
98
+ try {
99
+ const cmd = pm === 'npm' ? `npm uninstall ${pkgName}` : pm === 'pnpm' ? `pnpm remove ${pkgName}` : `yarn remove ${pkgName}`;
100
+ execSync(cmd, { stdio: 'inherit', timeout: 60000 });
101
+ console.log(`✓ ${pkgName} 已卸载`);
102
+ } catch {
103
+ console.warn(`✗ ${pkgName} 卸载失败,请手动移除`);
104
+ }
105
+ } else {
106
+ console.log(`${pkgName} 未安装,跳过卸载`);
107
+ }
108
+ }
109
+
110
+ // 2. 从配置中移除
111
+ const config = readConfig();
112
+ if (Array.isArray(config.platforms)) {
113
+ const idx = config.platforms.indexOf(name);
114
+ if (idx !== -1) {
115
+ config.platforms.splice(idx, 1);
116
+ writeConfig(config);
117
+ console.log(`✓ 已从 alemon.config.yaml 移除 ${name}`);
123
118
  }
119
+ }
124
120
  }
125
121
 
126
122
  /**
127
123
  * 列出已安装平台
128
124
  */
129
125
  export function platformList() {
130
- const pkgPath = join(process.cwd(), 'package.json');
131
- if (!fs.existsSync(pkgPath)) {
132
- console.error('未找到 package.json');
133
- return;
134
- }
135
-
136
- const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
137
- const allDeps = {...pkg.dependencies, ...pkg.devDependencies};
138
- const installed = Object.keys(allDeps).filter(n => n.startsWith('@alemonjs/'));
139
-
140
- const config = readConfig();
141
- const configured = Array.isArray(config.platforms) ? config.platforms : [];
142
-
143
- console.log('=== 平台列表 ===\n');
144
-
145
- if (installed.length === 0) {
146
- console.log('未安装任何 @alemonjs/* 平台包');
147
- return;
148
- }
149
-
150
- for (const name of installed) {
151
- const short = name.replace('@alemonjs/', '');
152
- const inConfig = configured.includes(short);
153
- const ver = allDeps[name];
154
- console.log(` ${inConfig ? '●' : '○'} ${short} (${ver})${inConfig ? '' : ' [未注册到配置]'}`);
155
- }
126
+ const pkgPath = join(process.cwd(), 'package.json');
127
+ if (!fs.existsSync(pkgPath)) {
128
+ console.error('未找到 package.json');
129
+ return;
130
+ }
131
+
132
+ const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
133
+ const allDeps = { ...pkg.dependencies, ...pkg.devDependencies };
134
+ const installed = Object.keys(allDeps).filter(n => n.startsWith('@alemonjs/'));
135
+
136
+ const config = readConfig();
137
+ const configured = Array.isArray(config.platforms) ? config.platforms : [];
138
+
139
+ console.log('=== 平台列表 ===\n');
140
+
141
+ if (installed.length === 0) {
142
+ console.log('未安装任何 @alemonjs/* 平台包');
143
+ return;
144
+ }
145
+
146
+ for (const name of installed) {
147
+ const short = name.replace('@alemonjs/', '');
148
+ const inConfig = configured.includes(short);
149
+ const ver = allDeps[name];
150
+ console.log(` ${inConfig ? '●' : '○'} ${short} (${ver})${inConfig ? '' : ' [未注册到配置]'}`);
151
+ }
156
152
  }
@@ -1,70 +1,70 @@
1
1
  #!/usr/bin/env node
2
- import {join} from 'path';
2
+ import { join } from 'path';
3
3
  import fs from 'fs';
4
- import {execSync} from 'child_process';
4
+ import { execSync } from 'child_process';
5
5
 
6
6
  /**
7
7
  * 检查并更新 alemonjs 相关包到最新版本
8
8
  */
9
9
  export async function versionUpdate() {
10
- const pkgPath = join(process.cwd(), 'package.json');
10
+ const pkgPath = join(process.cwd(), 'package.json');
11
11
 
12
- if (!fs.existsSync(pkgPath)) {
13
- console.error('未找到 package.json');
14
- process.exit(1);
15
- }
12
+ if (!fs.existsSync(pkgPath)) {
13
+ console.error('未找到 package.json');
14
+ process.exit(1);
15
+ }
16
16
 
17
- const raw = fs.readFileSync(pkgPath, 'utf8');
18
- const pkg = JSON.parse(raw);
17
+ const raw = fs.readFileSync(pkgPath, 'utf8');
18
+ const pkg = JSON.parse(raw);
19
19
 
20
- const depFields = ['dependencies', 'devDependencies'];
21
- const matched = [];
20
+ const depFields = ['dependencies', 'devDependencies'];
21
+ const matched = [];
22
22
 
23
- for (const field of depFields) {
24
- const deps = pkg[field];
25
- if (!deps) continue;
26
- for (const name of Object.keys(deps)) {
27
- if (name === 'alemonjs' || name.startsWith('@alemonjs/')) {
28
- matched.push({field, name, current: deps[name]});
29
- }
30
- }
23
+ for (const field of depFields) {
24
+ const deps = pkg[field];
25
+ if (!deps) continue;
26
+ for (const name of Object.keys(deps)) {
27
+ if (name === 'alemonjs' || name.startsWith('@alemonjs/')) {
28
+ matched.push({ field, name, current: deps[name] });
29
+ }
31
30
  }
31
+ }
32
32
 
33
- if (matched.length === 0) {
34
- console.log('未找到 alemonjs 或 @alemonjs/* 相关依赖');
35
- return;
36
- }
33
+ if (matched.length === 0) {
34
+ console.log('未找到 alemonjs 或 @alemonjs/* 相关依赖');
35
+ return;
36
+ }
37
37
 
38
- console.log(`找到 ${matched.length} 个相关包,正在查询最新版本...\n`);
38
+ console.log(`找到 ${matched.length} 个相关包,正在查询最新版本...\n`);
39
39
 
40
- let updated = 0;
40
+ let updated = 0;
41
41
 
42
- for (const item of matched) {
43
- try {
44
- const latest = execSync(`npm view ${item.name} version`, {
45
- encoding: 'utf8',
46
- timeout: 15000
47
- }).trim();
42
+ for (const item of matched) {
43
+ try {
44
+ const latest = execSync(`npm view ${item.name} version`, {
45
+ encoding: 'utf8',
46
+ timeout: 15000
47
+ }).trim();
48
48
 
49
- const currentClean = item.current.replace(/^[\^~>=<]*/, '');
49
+ const currentClean = item.current.replace(/^[\^~>=<]*/, '');
50
50
 
51
- if (currentClean === latest) {
52
- console.log(` ✓ ${item.name} 已是最新 (${latest})`);
53
- } else {
54
- const prefix = item.current.match(/^([\^~]?)/)?.[1] ?? '^';
55
- pkg[item.field][item.name] = `${prefix}${latest}`;
56
- console.log(` ↑ ${item.name} ${item.current} → ${prefix}${latest}`);
57
- updated++;
58
- }
59
- } catch {
60
- console.warn(` ✗ ${item.name} 查询失败,跳过`);
61
- }
51
+ if (currentClean === latest) {
52
+ console.log(` ✓ ${item.name} 已是最新 (${latest})`);
53
+ } else {
54
+ const prefix = item.current.match(/^([\^~]?)/)?.[1] ?? '^';
55
+ pkg[item.field][item.name] = `${prefix}${latest}`;
56
+ console.log(` ↑ ${item.name} ${item.current} → ${prefix}${latest}`);
57
+ updated++;
58
+ }
59
+ } catch {
60
+ console.warn(` ✗ ${item.name} 查询失败,跳过`);
62
61
  }
62
+ }
63
63
 
64
- if (updated > 0) {
65
- fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + '\n');
66
- console.log(`\n已更新 ${updated} 个包,请执行 npm install 安装最新版本`);
67
- } else {
68
- console.log('\n所有包均为最新版本');
69
- }
64
+ if (updated > 0) {
65
+ fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + '\n');
66
+ console.log(`\n已更新 ${updated} 个包,请执行 npm install 安装最新版本`);
67
+ } else {
68
+ console.log('\n所有包均为最新版本');
69
+ }
70
70
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "alemonjs",
3
- "version": "2.1.46",
3
+ "version": "2.1.47",
4
4
  "description": "bot script",
5
5
  "author": "lemonade",
6
6
  "license": "MIT",
@@ -28,8 +28,8 @@
28
28
  },
29
29
  "dependencies": {
30
30
  "@koa/cors": "^5.0.0",
31
- "axios": "^1.10.0",
32
- "chalk": "^5.3.0",
31
+ "axios": "^1.14.0",
32
+ "chalk": "^5.6.2",
33
33
  "commander": "^13.1.0",
34
34
  "file-type": "21.0.0",
35
35
  "flatted": "^3.3.3",