@liuchen64/dsh-config-sync 0.0.0-stage → 0.1.0
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/client.js +361 -0
- package/cordis.patch.yml +14 -0
- package/dist/index.d.ts +40 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +32 -0
- package/dist/index.js.map +1 -0
- package/dist/internal/config/options.d.ts +26 -0
- package/dist/internal/config/options.d.ts.map +1 -0
- package/dist/internal/config/options.js +36 -0
- package/dist/internal/config/options.js.map +1 -0
- package/dist/internal/rpc/endpoints.d.ts +27 -0
- package/dist/internal/rpc/endpoints.d.ts.map +1 -0
- package/dist/internal/rpc/endpoints.js +70 -0
- package/dist/internal/rpc/endpoints.js.map +1 -0
- package/dist/internal/sync/backup.d.ts +14 -0
- package/dist/internal/sync/backup.d.ts.map +1 -0
- package/dist/internal/sync/backup.js +35 -0
- package/dist/internal/sync/backup.js.map +1 -0
- package/dist/internal/sync/git.d.ts +21 -0
- package/dist/internal/sync/git.d.ts.map +1 -0
- package/dist/internal/sync/git.js +87 -0
- package/dist/internal/sync/git.js.map +1 -0
- package/dist/internal/sync/include.d.ts +23 -0
- package/dist/internal/sync/include.d.ts.map +1 -0
- package/dist/internal/sync/include.js +40 -0
- package/dist/internal/sync/include.js.map +1 -0
- package/dist/internal/sync/inspect.d.ts +25 -0
- package/dist/internal/sync/inspect.d.ts.map +1 -0
- package/dist/internal/sync/inspect.js +59 -0
- package/dist/internal/sync/inspect.js.map +1 -0
- package/dist/internal/sync/service.d.ts +81 -0
- package/dist/internal/sync/service.d.ts.map +1 -0
- package/dist/internal/sync/service.js +249 -0
- package/dist/internal/sync/service.js.map +1 -0
- package/package.json +51 -3
- package/README.md +0 -3
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* service.ts — 同步状态机与 git 操作序列
|
|
3
|
+
*
|
|
4
|
+
* 状态:unbound → idle → syncing → idle / conflict / error。
|
|
5
|
+
* 进程内用一条 Promise 链做互斥,同一时刻只有一次同步;跨进程交给 git 自己的锁。
|
|
6
|
+
*/
|
|
7
|
+
import { existsSync } from 'node:fs';
|
|
8
|
+
import { stat } from 'node:fs/promises';
|
|
9
|
+
import { join } from 'node:path';
|
|
10
|
+
import { backupLocal } from './backup.js';
|
|
11
|
+
import { classifyGitFailure, runGit } from './git.js';
|
|
12
|
+
import { buildPathspecs, checkSizes } from './include.js';
|
|
13
|
+
import { deriveState, listAllFiles, parseNameStatus, } from './inspect.js';
|
|
14
|
+
/** 带归类的 git 失败,供状态机区分冲突与普通错误 */
|
|
15
|
+
class GitFailure extends Error {
|
|
16
|
+
kind;
|
|
17
|
+
constructor(kind, message) {
|
|
18
|
+
super(message);
|
|
19
|
+
this.kind = kind;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
/** 取 stderr 首行作为提示,避免把多行原始输出直接甩到界面 */
|
|
23
|
+
function firstLine(text) {
|
|
24
|
+
return text.trim().split(/\r?\n/)[0] ?? '';
|
|
25
|
+
}
|
|
26
|
+
function failureOf(action, result) {
|
|
27
|
+
const detail = firstLine(result.stderr) || `git 退出码 ${result.code}`;
|
|
28
|
+
return new GitFailure(classifyGitFailure(result.stderr), `${action}失败:${detail}`);
|
|
29
|
+
}
|
|
30
|
+
/** 吞掉结果,只用于串行链上记录完成 */
|
|
31
|
+
function ignore() { }
|
|
32
|
+
export class ConfigSyncService {
|
|
33
|
+
options;
|
|
34
|
+
phase;
|
|
35
|
+
lastSyncAt = null;
|
|
36
|
+
failure = null;
|
|
37
|
+
/** 串行链:把并发调用排队,而不是互骂 git 锁 */
|
|
38
|
+
queue = Promise.resolve();
|
|
39
|
+
constructor(options) {
|
|
40
|
+
this.options = options;
|
|
41
|
+
this.phase = options.remote === '' ? 'unbound' : 'idle';
|
|
42
|
+
}
|
|
43
|
+
/** 当前状态快照,供 RPC 端点直读 */
|
|
44
|
+
status() {
|
|
45
|
+
return {
|
|
46
|
+
phase: this.phase,
|
|
47
|
+
remote: this.options.remote,
|
|
48
|
+
branch: this.options.branch,
|
|
49
|
+
lastSyncAt: this.lastSyncAt,
|
|
50
|
+
failure: this.failure,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
/** 提交本地改动 → 拉取 → 推送 */
|
|
54
|
+
sync() {
|
|
55
|
+
return this.exclusive(() => this.guard(async () => {
|
|
56
|
+
await this.ensureRepo();
|
|
57
|
+
const committed = await this.commitAll();
|
|
58
|
+
await this.pullOnce();
|
|
59
|
+
await this.pushOnce();
|
|
60
|
+
return { ok: true, committed, backup: null };
|
|
61
|
+
}));
|
|
62
|
+
}
|
|
63
|
+
/** 只拉取 */
|
|
64
|
+
pull() {
|
|
65
|
+
return this.exclusive(() => this.guard(async () => {
|
|
66
|
+
await this.ensureRepo();
|
|
67
|
+
await this.pullOnce();
|
|
68
|
+
return { ok: true, committed: 0, backup: null };
|
|
69
|
+
}));
|
|
70
|
+
}
|
|
71
|
+
/** 只推送 */
|
|
72
|
+
push() {
|
|
73
|
+
return this.exclusive(() => this.guard(async () => {
|
|
74
|
+
await this.ensureRepo();
|
|
75
|
+
await this.pushOnce();
|
|
76
|
+
return { ok: true, committed: 0, backup: null };
|
|
77
|
+
}));
|
|
78
|
+
}
|
|
79
|
+
/** 对照本地与远端,供「用哪边」的选择界面使用 */
|
|
80
|
+
async inspect() {
|
|
81
|
+
const { branch } = this.options;
|
|
82
|
+
await this.ensureRepo();
|
|
83
|
+
const fetched = await this.git(['fetch', 'origin', branch]);
|
|
84
|
+
const remoteRef = `origin/${branch}`;
|
|
85
|
+
const remoteHead = await this.git(['rev-parse', '--verify', remoteRef]);
|
|
86
|
+
const remoteExists = fetched.code === 0 && remoteHead.code === 0;
|
|
87
|
+
if (!remoteExists) {
|
|
88
|
+
return { state: 'remote-empty', localChanges: [], remoteChanges: [] };
|
|
89
|
+
}
|
|
90
|
+
const hasCommit = (await this.git(['rev-parse', '--verify', 'HEAD'])).code === 0;
|
|
91
|
+
const ancestor = await this.git(['merge-base', 'HEAD', remoteRef]);
|
|
92
|
+
const localChanges = hasCommit
|
|
93
|
+
? parseNameStatus((await this.must(['diff', '--name-status', remoteRef, 'HEAD'], '比较本地改动')).stdout)
|
|
94
|
+
: [];
|
|
95
|
+
// 本地还没有提交时,远端的内容就是它的全部
|
|
96
|
+
const remoteChanges = hasCommit
|
|
97
|
+
? parseNameStatus((await this.must(['diff', '--name-status', 'HEAD', remoteRef], '比较远端改动')).stdout)
|
|
98
|
+
: listAllFiles((await this.must(['ls-tree', '-r', '--name-only', remoteRef], '读取远端文件')).stdout);
|
|
99
|
+
return {
|
|
100
|
+
state: deriveState({
|
|
101
|
+
remoteExists,
|
|
102
|
+
hasCommonAncestor: ancestor.code === 0,
|
|
103
|
+
localChanges: localChanges.length,
|
|
104
|
+
remoteChanges: remoteChanges.length,
|
|
105
|
+
}),
|
|
106
|
+
localChanges,
|
|
107
|
+
remoteChanges,
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
/** 用远端覆盖本地:先备份白名单内容,再硬对齐远端 */
|
|
111
|
+
forcePull() {
|
|
112
|
+
return this.exclusive(() => this.guard(async () => {
|
|
113
|
+
await this.ensureRepo();
|
|
114
|
+
const backup = await backupLocal(this.options.home, this.options.include);
|
|
115
|
+
await this.abortRebase();
|
|
116
|
+
await this.must(['fetch', 'origin', this.options.branch], '拉取远端');
|
|
117
|
+
await this.must(['reset', '--hard', `origin/${this.options.branch}`], '对齐远端');
|
|
118
|
+
return { ok: true, committed: 0, backup };
|
|
119
|
+
}));
|
|
120
|
+
}
|
|
121
|
+
/** 用本地覆盖远端:先把本地改动提交,再强推(lease 兜住中途被别人改过的情况) */
|
|
122
|
+
forcePush() {
|
|
123
|
+
return this.exclusive(() => this.guard(async () => {
|
|
124
|
+
await this.ensureRepo();
|
|
125
|
+
const committed = await this.commitAll();
|
|
126
|
+
await this.abortRebase();
|
|
127
|
+
await this.git(['fetch', 'origin', this.options.branch]);
|
|
128
|
+
await this.must(['push', '--force-with-lease', '-u', 'origin', this.options.branch], '强制推送');
|
|
129
|
+
return { ok: true, committed, backup: null };
|
|
130
|
+
}));
|
|
131
|
+
}
|
|
132
|
+
exclusive(task) {
|
|
133
|
+
const run = this.queue.then(task, task);
|
|
134
|
+
this.queue = run.then(ignore, ignore);
|
|
135
|
+
return run;
|
|
136
|
+
}
|
|
137
|
+
/** 统一处理未绑定、状态流转与异常归类 */
|
|
138
|
+
async guard(task) {
|
|
139
|
+
if (this.options.remote === '') {
|
|
140
|
+
return {
|
|
141
|
+
ok: false,
|
|
142
|
+
failure: { kind: 'unbound', message: '未配置 remote,先在插件配置里补上远端地址' },
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
this.phase = 'syncing';
|
|
146
|
+
this.failure = null;
|
|
147
|
+
try {
|
|
148
|
+
const outcome = await task();
|
|
149
|
+
this.phase = 'idle';
|
|
150
|
+
this.lastSyncAt = new Date().toISOString();
|
|
151
|
+
return outcome;
|
|
152
|
+
}
|
|
153
|
+
catch (error) {
|
|
154
|
+
const kind = this.kindOf(error);
|
|
155
|
+
this.failure = {
|
|
156
|
+
kind,
|
|
157
|
+
message: error instanceof Error ? error.message : String(error),
|
|
158
|
+
};
|
|
159
|
+
this.phase = kind === 'conflict' || kind === 'diverged' ? 'conflict' : 'error';
|
|
160
|
+
return { ok: false, failure: this.failure };
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
/** git 超时走 AbortController,归到网络类 */
|
|
164
|
+
kindOf(error) {
|
|
165
|
+
if (error instanceof GitFailure)
|
|
166
|
+
return error.kind;
|
|
167
|
+
if (error instanceof Error && error.name === 'AbortError')
|
|
168
|
+
return 'network';
|
|
169
|
+
return 'other';
|
|
170
|
+
}
|
|
171
|
+
async git(args) {
|
|
172
|
+
return runGit(this.options.home, args);
|
|
173
|
+
}
|
|
174
|
+
async must(args, action) {
|
|
175
|
+
const result = await this.git(args);
|
|
176
|
+
if (result.code !== 0)
|
|
177
|
+
throw failureOf(action, result);
|
|
178
|
+
return result;
|
|
179
|
+
}
|
|
180
|
+
/** 首次同步时在 $DSH_HOME 初始化仓库,并把 origin 对齐到配置值 */
|
|
181
|
+
async ensureRepo() {
|
|
182
|
+
const { home, remote, branch } = this.options;
|
|
183
|
+
if (!existsSync(join(home, '.git'))) {
|
|
184
|
+
await this.must(['init', '-b', branch], '初始化仓库');
|
|
185
|
+
await this.must(['remote', 'add', 'origin', remote], '设置远端');
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
const current = await this.git(['remote', 'get-url', 'origin']);
|
|
189
|
+
if (current.code !== 0) {
|
|
190
|
+
await this.must(['remote', 'add', 'origin', remote], '设置远端');
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
if (current.stdout.trim() !== remote) {
|
|
194
|
+
await this.must(['remote', 'set-url', 'origin', remote], '更新远端');
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
/** 按白名单暂存并提交;没有变化就不产生空提交 */
|
|
198
|
+
async commitAll() {
|
|
199
|
+
const { home, include } = this.options;
|
|
200
|
+
await this.must(['add', '-A', '--', ...buildPathspecs(include)], '暂存配置');
|
|
201
|
+
const staged = await this.must(['diff', '--cached', '--name-only'], '读取暂存清单');
|
|
202
|
+
const paths = staged.stdout
|
|
203
|
+
.split(/\r?\n/)
|
|
204
|
+
.map((line) => line.trim())
|
|
205
|
+
.filter((line) => line !== '');
|
|
206
|
+
if (paths.length === 0)
|
|
207
|
+
return 0;
|
|
208
|
+
const files = [];
|
|
209
|
+
for (const path of paths) {
|
|
210
|
+
const info = await stat(join(home, path)).catch(() => null);
|
|
211
|
+
if (info?.isFile())
|
|
212
|
+
files.push({ path, size: info.size });
|
|
213
|
+
}
|
|
214
|
+
const oversize = checkSizes(files);
|
|
215
|
+
if (oversize !== null)
|
|
216
|
+
throw new GitFailure('other', oversize);
|
|
217
|
+
await this.must(['commit', '-m', `chore(dsh): 同步配置(${paths.length} 个文件)`], '提交');
|
|
218
|
+
return paths.length;
|
|
219
|
+
}
|
|
220
|
+
async pullOnce() {
|
|
221
|
+
const { branch } = this.options;
|
|
222
|
+
const heads = await this.must(['ls-remote', '--heads', 'origin', branch], '查询远端分支');
|
|
223
|
+
if (heads.stdout.trim() === '')
|
|
224
|
+
return;
|
|
225
|
+
const hasCommit = (await this.git(['rev-parse', '--verify', 'HEAD'])).code === 0;
|
|
226
|
+
if (!hasCommit) {
|
|
227
|
+
// 本地没有提交、远端有历史:两条无关历史,必须让人选用哪边,不能悄悄覆盖
|
|
228
|
+
throw new GitFailure('diverged', '本地还没有提交,远端已有历史,需要选择用哪边覆盖');
|
|
229
|
+
}
|
|
230
|
+
const pull = await this.git(['pull', '--rebase', '--autostash', 'origin', branch]);
|
|
231
|
+
if (pull.code !== 0) {
|
|
232
|
+
await this.abortRebase();
|
|
233
|
+
throw failureOf('拉取远端', pull);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
async pushOnce() {
|
|
237
|
+
await this.must(['push', '-u', 'origin', this.options.branch], '推送');
|
|
238
|
+
}
|
|
239
|
+
/** 清掉残留的 rebase 中间态,否则后续 git 操作全被卡住 */
|
|
240
|
+
async abortRebase() {
|
|
241
|
+
const { home } = this.options;
|
|
242
|
+
const inProgress = existsSync(join(home, '.git', 'rebase-merge')) ||
|
|
243
|
+
existsSync(join(home, '.git', 'rebase-apply'));
|
|
244
|
+
if (!inProgress)
|
|
245
|
+
return;
|
|
246
|
+
await this.git(['rebase', '--abort']);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
//# sourceMappingURL=service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service.js","sourceRoot":"","sources":["../../../src/internal/sync/service.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CA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uCAAuC;IAC/B,KAAK,CAAC,WAAW;QACvB,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC;QAC9B,MAAM,UAAU,GACd,UAAU,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,cAAc,CAAC,CAAC;YAC9C,UAAU,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,cAAc,CAAC,CAAC,CAAC;QACjD,IAAI,CAAC,UAAU;YAAE,OAAO;QACxB,MAAM,IAAI,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC,CAAC;IACxC,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,54 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@liuchen64/dsh-config-sync",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "DSH 插件:把本机配置同步到 git 仓库,侧边栏可查看状态并手动同步",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"dsh",
|
|
8
|
+
"dsh-plugin",
|
|
9
|
+
"config",
|
|
10
|
+
"git",
|
|
11
|
+
"sync"
|
|
12
|
+
],
|
|
13
|
+
"license": "MIT",
|
|
14
|
+
"main": "./dist/index.js",
|
|
15
|
+
"exports": {
|
|
16
|
+
".": {
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
18
|
+
"import": "./dist/index.js",
|
|
19
|
+
"default": "./dist/index.js"
|
|
20
|
+
},
|
|
21
|
+
"./client": "./client.js"
|
|
22
|
+
},
|
|
23
|
+
"files": [
|
|
24
|
+
"dist",
|
|
25
|
+
"client.js",
|
|
26
|
+
"cordis.patch.yml"
|
|
27
|
+
],
|
|
28
|
+
"publishConfig": {
|
|
29
|
+
"access": "public"
|
|
30
|
+
},
|
|
31
|
+
"repository": {
|
|
32
|
+
"type": "git",
|
|
33
|
+
"url": "git+https://gitee.com/folding-fan/dsh-extension-lc.git",
|
|
34
|
+
"directory": "plugins/config-sync"
|
|
35
|
+
},
|
|
36
|
+
"dependencies": {},
|
|
37
|
+
"dsh": {
|
|
38
|
+
"bundle": {
|
|
39
|
+
"patch": "./cordis.patch.yml"
|
|
40
|
+
},
|
|
41
|
+
"client": {
|
|
42
|
+
"platform": "web",
|
|
43
|
+
"immediately": true,
|
|
44
|
+
"inject": [
|
|
45
|
+
"@deepseek-ai/dsh-client-connection",
|
|
46
|
+
"@deepseek-ai/dsh-client-ui-sidebar"
|
|
47
|
+
]
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
"scripts": {
|
|
51
|
+
"build": "tsc -b",
|
|
52
|
+
"test": "pnpm build && node --test --test-isolation=none \"test/**/*.test.ts\""
|
|
53
|
+
}
|
|
6
54
|
}
|
package/README.md
DELETED