ticketpro-auto-setup 1.1.5 → 1.1.6
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/installers/code-abyss.js +41 -28
- package/package.json +1 -1
|
@@ -7,7 +7,7 @@ import fs from 'node:fs';
|
|
|
7
7
|
import path from 'node:path';
|
|
8
8
|
import { spawn } from 'node:child_process';
|
|
9
9
|
import ora from 'ora';
|
|
10
|
-
import { execAsync } from '../utils/shell.js';
|
|
10
|
+
import { execAsync, execCommand } from '../utils/shell.js';
|
|
11
11
|
import { getPlatform, getClaudeDir } from '../utils/platform.js';
|
|
12
12
|
import { log } from '../utils/logger.js';
|
|
13
13
|
/**
|
|
@@ -133,26 +133,13 @@ function spawnCodeAbyss(command, args) {
|
|
|
133
133
|
/**
|
|
134
134
|
* 兜底确保 statusLine 指向 ccline。
|
|
135
135
|
* 某些环境下 code-abyss 可能因配置合并策略未写入该字段,
|
|
136
|
-
*
|
|
136
|
+
* 或写入了 ~/.claude/ccline/ccline 但该路径实际不存在(例如 nvm 全局安装)。
|
|
137
137
|
*/
|
|
138
138
|
function ensureCclineStatusLine() {
|
|
139
139
|
try {
|
|
140
|
+
const { homeDir } = getPlatform();
|
|
140
141
|
const claudeDir = getClaudeDir();
|
|
141
142
|
const settingsPath = path.join(claudeDir, 'settings.json');
|
|
142
|
-
// 兜底:如果 ~/.claude/ccline/ccline 不存在,但系统 PATH 有 ccline,
|
|
143
|
-
// 创建一个软链接到 ~/.claude/ccline/ccline,确保 statusLine 路径稳定可用。
|
|
144
|
-
const cclineDir = path.join(claudeDir, 'ccline');
|
|
145
|
-
const localCcline = path.join(cclineDir, 'ccline');
|
|
146
|
-
if (!fs.existsSync(localCcline)) {
|
|
147
|
-
const globalPath = '/usr/local/bin/ccline';
|
|
148
|
-
if (fs.existsSync(globalPath)) {
|
|
149
|
-
fs.mkdirSync(cclineDir, { recursive: true });
|
|
150
|
-
try {
|
|
151
|
-
fs.symlinkSync(globalPath, localCcline);
|
|
152
|
-
}
|
|
153
|
-
catch { /* ignore */ }
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
143
|
if (!fs.existsSync(settingsPath))
|
|
157
144
|
return;
|
|
158
145
|
let settings = {};
|
|
@@ -162,20 +149,46 @@ function ensureCclineStatusLine() {
|
|
|
162
149
|
catch {
|
|
163
150
|
return;
|
|
164
151
|
}
|
|
165
|
-
const
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
};
|
|
152
|
+
const cclineDir = path.join(claudeDir, 'ccline');
|
|
153
|
+
const localCcline = path.join(cclineDir, 'ccline');
|
|
154
|
+
// 动态解析全局 ccline 路径(兼容 nvm: ~/.nvm/.../bin/ccline)
|
|
155
|
+
let resolvedGlobal = '';
|
|
156
|
+
const whichResult = execCommand('command -v ccline', { cwd: homeDir, timeout: 5000 });
|
|
157
|
+
if (whichResult.success) {
|
|
158
|
+
resolvedGlobal = whichResult.stdout.split('\n').pop()?.trim() ?? '';
|
|
159
|
+
}
|
|
160
|
+
// 如果本地路径不存在,但全局 ccline 存在,创建软链接到本地稳定路径
|
|
161
|
+
if (!fs.existsSync(localCcline) && resolvedGlobal && fs.existsSync(resolvedGlobal)) {
|
|
162
|
+
fs.mkdirSync(cclineDir, { recursive: true });
|
|
163
|
+
try {
|
|
164
|
+
fs.symlinkSync(resolvedGlobal, localCcline);
|
|
165
|
+
log.success(`ccline linked: ${localCcline} -> ${resolvedGlobal}`);
|
|
166
|
+
}
|
|
167
|
+
catch {
|
|
168
|
+
// ignore
|
|
169
|
+
}
|
|
170
|
+
}
|
|
170
171
|
const current = settings.statusLine;
|
|
171
|
-
const
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
172
|
+
const currentCommand = current && typeof current === 'object' && typeof current.command === 'string'
|
|
173
|
+
? current.command
|
|
174
|
+
: '';
|
|
175
|
+
const localCmd = '~/.claude/ccline/ccline';
|
|
176
|
+
const fallbackCmd = resolvedGlobal && fs.existsSync(resolvedGlobal) ? resolvedGlobal : localCmd;
|
|
177
|
+
// 需要补丁的条件:
|
|
178
|
+
// 1) 没有 statusLine
|
|
179
|
+
// 2) statusLine 不是 ccline
|
|
180
|
+
// 3) statusLine 指向本地 ccline 但本地文件不存在(坏链路)
|
|
181
|
+
const needPatch = !currentCommand ||
|
|
182
|
+
!currentCommand.includes('ccline') ||
|
|
183
|
+
(currentCommand.includes('~/.claude/ccline/ccline') && !fs.existsSync(localCcline));
|
|
184
|
+
if (needPatch) {
|
|
185
|
+
settings.statusLine = {
|
|
186
|
+
type: 'command',
|
|
187
|
+
command: fs.existsSync(localCcline) ? localCmd : fallbackCmd,
|
|
188
|
+
padding: 0,
|
|
189
|
+
};
|
|
177
190
|
fs.writeFileSync(settingsPath, JSON.stringify(settings, null, 2), 'utf-8');
|
|
178
|
-
log.success(
|
|
191
|
+
log.success(`ccline statusLine patched: ${settings.statusLine.command}`);
|
|
179
192
|
}
|
|
180
193
|
}
|
|
181
194
|
catch {
|