airail 0.1.1 → 0.1.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/dist/cli/add.js +5 -5
- package/dist/cli/config.js +11 -11
- package/dist/cli/index.js +11 -8
- package/dist/cli/update.js +2 -2
- package/package.json +1 -1
package/dist/cli/add.js
CHANGED
|
@@ -45,7 +45,7 @@ async function cmdAdd(arg) {
|
|
|
45
45
|
const config = (0, utils_1.requireAirailJson)(claudeDir);
|
|
46
46
|
if (!arg) {
|
|
47
47
|
console.error((0, colors_1.err)('用法: airail add <包名[@版本]|路径>'));
|
|
48
|
-
|
|
48
|
+
throw new Error('');
|
|
49
49
|
}
|
|
50
50
|
if (config.pack) {
|
|
51
51
|
console.log((0, colors_1.warn)(`当前已安装 pack: ${config.pack}`));
|
|
@@ -56,7 +56,7 @@ async function cmdAdd(arg) {
|
|
|
56
56
|
const localPath = path.resolve(arg);
|
|
57
57
|
if (!fs.existsSync(localPath)) {
|
|
58
58
|
console.error((0, colors_1.err)(`路径不存在: ${localPath}`));
|
|
59
|
-
|
|
59
|
+
throw new Error('');
|
|
60
60
|
}
|
|
61
61
|
const packName = readPackName(localPath);
|
|
62
62
|
(0, utils_1.installPackFromDir)(localPath, packName, claudeDir);
|
|
@@ -69,7 +69,7 @@ async function cmdAdd(arg) {
|
|
|
69
69
|
const rc = (0, utils_1.readRc)();
|
|
70
70
|
if (!rc.configServer) {
|
|
71
71
|
console.error((0, colors_1.err)('未配置配置仓库,请先执行: airail config setup'));
|
|
72
|
-
|
|
72
|
+
throw new Error('');
|
|
73
73
|
}
|
|
74
74
|
await installPackFromConfigCenter(arg, claudeDir, config, rc);
|
|
75
75
|
(0, utils_1.writeAirailJson)(claudeDir, config);
|
|
@@ -113,13 +113,13 @@ async function installPackFromConfigCenter(packNameWithVersion, claudeDir, confi
|
|
|
113
113
|
}
|
|
114
114
|
catch (e) {
|
|
115
115
|
console.error((0, colors_1.err)(`获取规范包列表失败: ${e.message}`));
|
|
116
|
-
|
|
116
|
+
throw new Error('');
|
|
117
117
|
}
|
|
118
118
|
const pack = packs.find(p => p.name === packName);
|
|
119
119
|
if (!pack) {
|
|
120
120
|
console.error((0, colors_1.err)(`规范包 "${packName}" 不存在。`));
|
|
121
121
|
console.log((0, colors_1.info)(`可用规范包: ${packs.map(p => p.name).join(', ')}`));
|
|
122
|
-
|
|
122
|
+
throw new Error('');
|
|
123
123
|
}
|
|
124
124
|
// 使用用户指定的版本,如果没有指定则使用配置仓库的版本
|
|
125
125
|
const gitRef = userVersion || pack.gitRef;
|
package/dist/cli/config.js
CHANGED
|
@@ -104,19 +104,19 @@ async function listConfigs() {
|
|
|
104
104
|
const rc = (0, utils_1.readRc)();
|
|
105
105
|
if (!rc.configServer) {
|
|
106
106
|
console.error((0, colors_1.err)('未配置配置仓库,请先执行: airail config setup'));
|
|
107
|
-
|
|
107
|
+
throw new Error('');
|
|
108
108
|
}
|
|
109
109
|
try {
|
|
110
110
|
ensureConfigRepo(rc.configServer, rc.configToken);
|
|
111
111
|
}
|
|
112
112
|
catch (e) {
|
|
113
113
|
console.error((0, colors_1.err)(e.message));
|
|
114
|
-
|
|
114
|
+
throw new Error('');
|
|
115
115
|
}
|
|
116
116
|
const indexPath = path.join(CONFIG_REPO_DIR, 'settings', 'index.json');
|
|
117
117
|
if (!fs.existsSync(indexPath)) {
|
|
118
118
|
console.error((0, colors_1.err)('配置仓库中未找到 settings/index.json'));
|
|
119
|
-
|
|
119
|
+
throw new Error('');
|
|
120
120
|
}
|
|
121
121
|
let entries;
|
|
122
122
|
try {
|
|
@@ -124,7 +124,7 @@ async function listConfigs() {
|
|
|
124
124
|
}
|
|
125
125
|
catch (e) {
|
|
126
126
|
console.error((0, colors_1.err)(`读取配置列表失败: ${e.message}`));
|
|
127
|
-
|
|
127
|
+
throw new Error('');
|
|
128
128
|
}
|
|
129
129
|
if (entries.length === 0) {
|
|
130
130
|
console.log((0, colors_1.warn)('暂无可用配置。'));
|
|
@@ -139,20 +139,20 @@ async function useConfig(name) {
|
|
|
139
139
|
const rc = (0, utils_1.readRc)();
|
|
140
140
|
if (!rc.configServer) {
|
|
141
141
|
console.error((0, colors_1.err)('未配置配置仓库,请先执行: airail config setup'));
|
|
142
|
-
|
|
142
|
+
throw new Error('');
|
|
143
143
|
}
|
|
144
144
|
try {
|
|
145
145
|
ensureConfigRepo(rc.configServer, rc.configToken);
|
|
146
146
|
}
|
|
147
147
|
catch (e) {
|
|
148
148
|
console.error((0, colors_1.err)(e.message));
|
|
149
|
-
|
|
149
|
+
throw new Error('');
|
|
150
150
|
}
|
|
151
151
|
// 获取配置清单
|
|
152
152
|
const indexPath = path.join(CONFIG_REPO_DIR, 'settings', 'index.json');
|
|
153
153
|
if (!fs.existsSync(indexPath)) {
|
|
154
154
|
console.error((0, colors_1.err)('配置仓库中未找到 settings/index.json'));
|
|
155
|
-
|
|
155
|
+
throw new Error('');
|
|
156
156
|
}
|
|
157
157
|
let entries;
|
|
158
158
|
try {
|
|
@@ -160,7 +160,7 @@ async function useConfig(name) {
|
|
|
160
160
|
}
|
|
161
161
|
catch (e) {
|
|
162
162
|
console.error((0, colors_1.err)(`读取配置列表失败: ${e.message}`));
|
|
163
|
-
|
|
163
|
+
throw new Error('');
|
|
164
164
|
}
|
|
165
165
|
if (entries.length === 0) {
|
|
166
166
|
console.log((0, colors_1.warn)('暂无可用配置。'));
|
|
@@ -171,7 +171,7 @@ async function useConfig(name) {
|
|
|
171
171
|
if (name) {
|
|
172
172
|
if (!entries.find(e => e.name === name)) {
|
|
173
173
|
console.error((0, colors_1.err)(`配置 "${name}" 不存在,可用: ${entries.map(e => e.name).join(', ')}`));
|
|
174
|
-
|
|
174
|
+
throw new Error('');
|
|
175
175
|
}
|
|
176
176
|
chosen = name;
|
|
177
177
|
}
|
|
@@ -188,7 +188,7 @@ async function useConfig(name) {
|
|
|
188
188
|
const settingsPath = path.join(CONFIG_REPO_DIR, 'settings', `${chosen}.json`);
|
|
189
189
|
if (!fs.existsSync(settingsPath)) {
|
|
190
190
|
console.error((0, colors_1.err)(`配置文件不存在: settings/${chosen}.json`));
|
|
191
|
-
|
|
191
|
+
throw new Error('');
|
|
192
192
|
}
|
|
193
193
|
let content;
|
|
194
194
|
try {
|
|
@@ -197,7 +197,7 @@ async function useConfig(name) {
|
|
|
197
197
|
}
|
|
198
198
|
catch (e) {
|
|
199
199
|
console.error((0, colors_1.err)(`读取配置失败: ${e.message}`));
|
|
200
|
-
|
|
200
|
+
throw new Error('');
|
|
201
201
|
}
|
|
202
202
|
const globalClaudeDir = path.join(os.homedir(), '.claude');
|
|
203
203
|
if (!fs.existsSync(globalClaudeDir)) {
|
package/dist/cli/index.js
CHANGED
|
@@ -83,21 +83,24 @@ async function executeCommand(cmd, args) {
|
|
|
83
83
|
config: () => (0, config_1.cmdConfig)(args[0], ...args.slice(1)),
|
|
84
84
|
};
|
|
85
85
|
if (cmd === 'exit') {
|
|
86
|
-
return false;
|
|
86
|
+
return { shouldContinue: false, success: true };
|
|
87
87
|
}
|
|
88
88
|
const handler = commands[cmd];
|
|
89
89
|
if (!handler) {
|
|
90
90
|
console.log(`未知命令: ${cmd}`);
|
|
91
91
|
printHelp();
|
|
92
|
-
return true;
|
|
92
|
+
return { shouldContinue: true, success: false };
|
|
93
93
|
}
|
|
94
94
|
try {
|
|
95
95
|
await handler();
|
|
96
|
+
return { shouldContinue: true, success: true };
|
|
96
97
|
}
|
|
97
98
|
catch (e) {
|
|
98
|
-
|
|
99
|
+
if (e.message) {
|
|
100
|
+
console.error(e.message);
|
|
101
|
+
}
|
|
102
|
+
return { shouldContinue: true, success: false };
|
|
99
103
|
}
|
|
100
|
-
return true;
|
|
101
104
|
}
|
|
102
105
|
function startInteractiveMode() {
|
|
103
106
|
printBanner();
|
|
@@ -116,7 +119,7 @@ function startInteractiveMode() {
|
|
|
116
119
|
return;
|
|
117
120
|
}
|
|
118
121
|
const [cmd, ...args] = input.split(/\s+/);
|
|
119
|
-
const shouldContinue = await executeCommand(cmd, args);
|
|
122
|
+
const { shouldContinue } = await executeCommand(cmd, args);
|
|
120
123
|
if (!shouldContinue) {
|
|
121
124
|
rl.close();
|
|
122
125
|
process.exit(0);
|
|
@@ -136,9 +139,9 @@ function runCLI() {
|
|
|
136
139
|
return;
|
|
137
140
|
}
|
|
138
141
|
// 有参数:直接执行命令(不显示 banner)
|
|
139
|
-
executeCommand(cmd, args).then((shouldContinue) => {
|
|
140
|
-
if (!shouldContinue) {
|
|
141
|
-
process.exit(0);
|
|
142
|
+
executeCommand(cmd, args).then(({ shouldContinue, success }) => {
|
|
143
|
+
if (!shouldContinue || !success) {
|
|
144
|
+
process.exit(success ? 0 : 1);
|
|
142
145
|
}
|
|
143
146
|
}).catch((e) => {
|
|
144
147
|
console.error(e.message);
|
package/dist/cli/update.js
CHANGED
|
@@ -42,10 +42,10 @@ async function cmdUpdate() {
|
|
|
42
42
|
const config = (0, utils_1.requireAirailJson)(claudeDir);
|
|
43
43
|
if (!config.pack) {
|
|
44
44
|
console.error((0, colors_1.err)('未安装任何 pack,无需更新。'));
|
|
45
|
-
|
|
45
|
+
throw new Error('');
|
|
46
46
|
}
|
|
47
47
|
// 从 airail.json 读取 pack 来源信息(需要扩展 AirailJson 结构)
|
|
48
48
|
// 暂时简化:提示用户重新 add
|
|
49
49
|
console.error((0, colors_1.err)('update 功能开发中,请使用 airail add 重新安装。'));
|
|
50
|
-
|
|
50
|
+
throw new Error('');
|
|
51
51
|
}
|