@botskill/cli 1.0.2 → 1.0.3
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 +54 -50
- package/scripts/release.js +81 -0
- package/src/index.js +11 -1
- package/src/lib/constants.js +1 -1
package/package.json
CHANGED
|
@@ -1,50 +1,54 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@botskill/cli",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "CLI tool for BotSkill - AI agent skills platform",
|
|
5
|
-
"main": "src/index.js",
|
|
6
|
-
"bin": {
|
|
7
|
-
"skm": "src/index.js"
|
|
8
|
-
},
|
|
9
|
-
"type": "module",
|
|
10
|
-
"scripts": {
|
|
11
|
-
"start": "node src/index.js",
|
|
12
|
-
"dev": "node src/index.js",
|
|
13
|
-
"build": "node scripts/build.js",
|
|
14
|
-
"build:restore": "node scripts/build.js --restore",
|
|
15
|
-
"prepublishOnly": "npm run build",
|
|
16
|
-
"postpublish": "npm run build:restore",
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
"
|
|
22
|
-
"scripts"
|
|
23
|
-
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
"
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@botskill/cli",
|
|
3
|
+
"version": "1.0.3",
|
|
4
|
+
"description": "CLI tool for BotSkill - AI agent skills platform",
|
|
5
|
+
"main": "src/index.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"skm": "src/index.js"
|
|
8
|
+
},
|
|
9
|
+
"type": "module",
|
|
10
|
+
"scripts": {
|
|
11
|
+
"start": "node src/index.js",
|
|
12
|
+
"dev": "node src/index.js",
|
|
13
|
+
"build": "node scripts/build.js",
|
|
14
|
+
"build:restore": "node scripts/build.js --restore",
|
|
15
|
+
"prepublishOnly": "npm run build",
|
|
16
|
+
"postpublish": "npm run build:restore",
|
|
17
|
+
"release": "node scripts/release.js patch",
|
|
18
|
+
"release:patch": "node scripts/release.js patch",
|
|
19
|
+
"release:minor": "node scripts/release.js minor",
|
|
20
|
+
"release:major": "node scripts/release.js major",
|
|
21
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
22
|
+
"postinstall": "node scripts/postinstall.js"
|
|
23
|
+
},
|
|
24
|
+
"files": [
|
|
25
|
+
"src",
|
|
26
|
+
"scripts"
|
|
27
|
+
],
|
|
28
|
+
"keywords": [
|
|
29
|
+
"cli",
|
|
30
|
+
"ai",
|
|
31
|
+
"skills",
|
|
32
|
+
"agents",
|
|
33
|
+
"management",
|
|
34
|
+
"tool"
|
|
35
|
+
],
|
|
36
|
+
"author": "BotSkill Team",
|
|
37
|
+
"license": "MIT",
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"adm-zip": "^0.5.16",
|
|
40
|
+
"axios": "^1.6.0",
|
|
41
|
+
"commander": "^11.0.0",
|
|
42
|
+
"configstore": "^6.0.0",
|
|
43
|
+
"form-data": "^4.0.5",
|
|
44
|
+
"fs-extra": "^11.1.1",
|
|
45
|
+
"inquirer": "^9.2.0",
|
|
46
|
+
"tar": "^6.2.0"
|
|
47
|
+
},
|
|
48
|
+
"engines": {
|
|
49
|
+
"node": ">=16.0.0"
|
|
50
|
+
},
|
|
51
|
+
"publishConfig": {
|
|
52
|
+
"access": "public"
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* 发布脚本:自动增加版本号并发布
|
|
4
|
+
* 用法:
|
|
5
|
+
* npm run release # patch 版本 (1.0.2 -> 1.0.3),默认使用 https://botskill.ai
|
|
6
|
+
* npm run release:minor # minor 版本 (1.0.2 -> 1.1.0)
|
|
7
|
+
* npm run release:major # major 版本 (1.0.2 -> 2.0.0)
|
|
8
|
+
* npm run release -- --dry-run # 预览版本号变化,不实际发布
|
|
9
|
+
* BOTSKILL_API_URL=其他URL npm run release # 使用自定义 API URL
|
|
10
|
+
*/
|
|
11
|
+
import { execSync } from 'child_process';
|
|
12
|
+
import { readFileSync, writeFileSync } from 'fs';
|
|
13
|
+
import { fileURLToPath } from 'url';
|
|
14
|
+
import { dirname, join } from 'path';
|
|
15
|
+
|
|
16
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
17
|
+
const packageJsonPath = join(__dirname, '../package.json');
|
|
18
|
+
|
|
19
|
+
// 解析命令行参数
|
|
20
|
+
const args = process.argv.slice(2);
|
|
21
|
+
const isDryRun = args.includes('--dry-run');
|
|
22
|
+
const versionType = args.find(arg => ['patch', 'minor', 'major'].includes(arg)) || 'patch';
|
|
23
|
+
|
|
24
|
+
// 读取当前版本
|
|
25
|
+
const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf8'));
|
|
26
|
+
const currentVersion = packageJson.version;
|
|
27
|
+
console.log(`当前版本: ${currentVersion}`);
|
|
28
|
+
|
|
29
|
+
// 计算新版本号
|
|
30
|
+
const [major, minor, patch] = currentVersion.split('.').map(Number);
|
|
31
|
+
let newVersion;
|
|
32
|
+
switch (versionType) {
|
|
33
|
+
case 'major':
|
|
34
|
+
newVersion = `${major + 1}.0.0`;
|
|
35
|
+
break;
|
|
36
|
+
case 'minor':
|
|
37
|
+
newVersion = `${major}.${minor + 1}.0`;
|
|
38
|
+
break;
|
|
39
|
+
case 'patch':
|
|
40
|
+
default:
|
|
41
|
+
newVersion = `${major}.${minor}.${patch + 1}`;
|
|
42
|
+
break;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
console.log(`新版本: ${newVersion}`);
|
|
46
|
+
|
|
47
|
+
// 获取 API URL(发布时默认使用生产环境)
|
|
48
|
+
const apiUrl = process.env.BOTSKILL_API_URL || 'https://botskill.ai';
|
|
49
|
+
console.log(`使用 API URL: ${apiUrl}`);
|
|
50
|
+
|
|
51
|
+
if (isDryRun) {
|
|
52
|
+
console.log('\n[DRY RUN] 预览模式,不会实际修改版本号或发布');
|
|
53
|
+
process.exit(0);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// 更新 package.json 中的版本号
|
|
57
|
+
packageJson.version = newVersion;
|
|
58
|
+
writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2) + '\n');
|
|
59
|
+
console.log(`✓ 已更新 package.json 版本号为 ${newVersion}`);
|
|
60
|
+
|
|
61
|
+
try {
|
|
62
|
+
// 构建
|
|
63
|
+
console.log('\n开始构建...');
|
|
64
|
+
execSync(`npm run build`, { stdio: 'inherit', env: { ...process.env, BOTSKILL_API_URL: apiUrl } });
|
|
65
|
+
|
|
66
|
+
// 发布
|
|
67
|
+
console.log('\n开始发布到 npm...');
|
|
68
|
+
execSync(`npm publish`, { stdio: 'inherit' });
|
|
69
|
+
|
|
70
|
+
// 恢复构建文件
|
|
71
|
+
console.log('\n恢复构建文件...');
|
|
72
|
+
execSync(`npm run build:restore`, { stdio: 'inherit' });
|
|
73
|
+
|
|
74
|
+
console.log(`\n✓ 成功发布 ${newVersion} 版本!`);
|
|
75
|
+
} catch (error) {
|
|
76
|
+
console.error('\n✗ 发布失败,正在恢复版本号...');
|
|
77
|
+
// 恢复版本号
|
|
78
|
+
packageJson.version = currentVersion;
|
|
79
|
+
writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2) + '\n');
|
|
80
|
+
process.exit(1);
|
|
81
|
+
}
|
package/src/index.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
import { Command } from 'commander';
|
|
4
|
+
import { readFileSync } from 'fs';
|
|
5
|
+
import { fileURLToPath } from 'url';
|
|
6
|
+
import { dirname, join } from 'path';
|
|
4
7
|
import { initCommand } from './commands/init.js';
|
|
5
8
|
import { loginCommand } from './commands/login.js';
|
|
6
9
|
import { logoutCommand } from './commands/logout.js';
|
|
@@ -13,12 +16,19 @@ import { searchCommand } from './commands/search.js';
|
|
|
13
16
|
import { infoCommand } from './commands/info.js';
|
|
14
17
|
import { helpCommand } from './commands/help.js';
|
|
15
18
|
|
|
19
|
+
// 读取 package.json 中的版本号
|
|
20
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
21
|
+
const __dirname = dirname(__filename);
|
|
22
|
+
const packageJsonPath = join(__dirname, '../package.json');
|
|
23
|
+
const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf8'));
|
|
24
|
+
const version = packageJson.version || '0.0.0';
|
|
25
|
+
|
|
16
26
|
const program = new Command();
|
|
17
27
|
|
|
18
28
|
program
|
|
19
29
|
.name('skm')
|
|
20
30
|
.description('CLI tool for managing BotSkill - a platform for AI agent skills')
|
|
21
|
-
.version(
|
|
31
|
+
.version(version);
|
|
22
32
|
|
|
23
33
|
program.addCommand(initCommand);
|
|
24
34
|
program.addCommand(loginCommand);
|
package/src/lib/constants.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* 发布生产: BOTSKILL_API_URL=https://api.botskill.ai npm run build
|
|
4
4
|
* 开发/本地: 保持 __DEFAULT_API_URL__ 时使用 localhost
|
|
5
5
|
*/
|
|
6
|
-
export const DEFAULT_API_URL = "
|
|
6
|
+
export const DEFAULT_API_URL = "http://localhost:3001/api";
|
|
7
7
|
export const FALLBACK_API_URL = 'http://localhost:3001/api';
|
|
8
8
|
|
|
9
9
|
export const getDefaultApiUrl = () =>
|