dsh-config-manager 0.7.0 → 0.8.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/lib/adapters/test-helpers.d.ts +7 -0
- package/lib/adapters/test-helpers.js +11 -0
- package/lib/cli/actions.js +1 -1
- package/lib/client.d.ts +9 -2
- package/lib/client.js +685 -649
- package/lib/core/backup.d.ts +9 -1
- package/lib/core/backup.js +21 -0
- package/lib/core/messages-core.d.ts +3 -0
- package/lib/core/messages-core.js +6 -0
- package/lib/core/messages.d.ts +5 -0
- package/lib/core/messages.js +10 -0
- package/lib/core/model-tools.js +2 -0
- package/lib/core/phase4-crash-child.js +1 -1
- package/lib/core/plugin-cli.d.ts +11 -0
- package/lib/core/plugin-cli.js +30 -0
- package/lib/core/restore-wal.d.ts +2 -0
- package/lib/core/restore-wal.js +11 -6
- package/lib/core/restore.d.ts +15 -2
- package/lib/core/restore.js +65 -3
- package/lib/core/snapshot-diff.js +2 -1
- package/lib/core/types.d.ts +32 -0
- package/lib/index.d.ts +6 -1
- package/lib/index.js +17 -16
- package/lib/routes/route-support.d.ts +5 -0
- package/lib/routes/route-support.js +28 -2
- package/lib/routes/sync.js +3 -0
- package/lib/sync/merge-preview-view.d.ts +78 -0
- package/lib/sync/merge-preview-view.js +46 -0
- package/lib/sync/merge.d.ts +2 -1
- package/lib/sync/merge.js +9 -4
- package/lib/sync/plugin-removal-apply.d.ts +95 -0
- package/lib/sync/plugin-removal-apply.js +158 -0
- package/lib/sync/plugin-removals.d.ts +90 -0
- package/lib/sync/plugin-removals.js +167 -0
- package/lib/sync/sync-engine.d.ts +34 -43
- package/lib/sync/sync-engine.js +50 -42
- package/lib/sync/sync-selection.d.ts +8 -0
- package/lib/sync/sync-selection.js +6 -0
- package/lib/sync/workspace-merge.d.ts +8 -1
- package/lib/ui/restore-plan-view.js +1 -0
- package/lib/ui/sync-settings-view.d.ts +10 -0
- package/lib/ui/sync-settings-view.js +2 -0
- package/package.json +1 -1
- package/src/adapters/test-helpers.ts +10 -0
- package/src/cli/actions.ts +1 -1
- package/src/client/common/info-hint-guard.test.ts +2 -1
- package/src/client/run-store.test.ts +7 -5
- package/src/client/run-store.ts +4 -5
- package/src/client/sync/SyncPanel.tsx +10 -0
- package/src/client/sync/SyncSectionPickerDialog.tsx +17 -1
- package/src/client/sync/sync-locales.ts +4 -0
- package/src/client/sync/sync-view.ts +6 -0
- package/src/core/backup.ts +21 -1
- package/src/core/messages-core.ts +6 -0
- package/src/core/messages.ts +10 -0
- package/src/core/model-tools.ts +2 -0
- package/src/core/phase4-crash-child.ts +1 -1
- package/src/core/plugin-cli.ts +37 -0
- package/src/core/restore-plugin-install.test.ts +116 -0
- package/src/core/restore-wal.ts +12 -6
- package/src/core/restore.ts +79 -4
- package/src/core/smoke.test.ts +5 -0
- package/src/core/snapshot-diff.test.ts +1 -1
- package/src/core/snapshot-diff.ts +2 -1
- package/src/core/types.ts +31 -0
- package/src/index.ts +21 -21
- package/src/routes/route-support.ts +27 -2
- package/src/routes/sync.ts +3 -0
- package/src/security/security.test.ts +1 -0
- package/src/sync/merge-preview-view.ts +97 -0
- package/src/sync/merge.test.ts +17 -15
- package/src/sync/merge.ts +10 -3
- package/src/sync/plugin-removal-apply.ts +198 -0
- package/src/sync/plugin-removals.test.ts +221 -0
- package/src/sync/plugin-removals.ts +208 -0
- package/src/sync/sync-engine.test.ts +251 -1
- package/src/sync/sync-engine.ts +84 -83
- package/src/sync/sync-selection.test.ts +29 -7
- package/src/sync/sync-selection.ts +13 -0
- package/src/sync/workspace-merge.ts +9 -0
- package/src/ui/restore-plan-view.test.ts +1 -1
- package/src/ui/restore-plan-view.ts +1 -0
- package/src/ui/snapshots-view.test.ts +1 -1
- package/src/ui/sync-settings-view.test.ts +20 -0
- package/src/ui/sync-settings-view.ts +12 -0
|
@@ -231,6 +231,11 @@ export interface RestoreExecutor {
|
|
|
231
231
|
ok: boolean;
|
|
232
232
|
message?: string;
|
|
233
233
|
}>;
|
|
234
|
+
/** 装回跟远端删掉的插件(官方通道,issue 132 的反向);失败返回 { ok:false, message } */
|
|
235
|
+
installPlugin(name: string, target: string): Promise<{
|
|
236
|
+
ok: boolean;
|
|
237
|
+
message?: string;
|
|
238
|
+
}>;
|
|
234
239
|
/**
|
|
235
240
|
* home 相对路径 → 磁盘绝对路径(逐动作 WAL 用:journal 的 ref 必须是绝对路径,
|
|
236
241
|
* reconcile 的 verifyStepFingerprint 直接拿它读盘算指纹)。缺省 = 不登记 WAL。
|
|
@@ -24,7 +24,7 @@ import { collectCredentialRefs } from '../security/credentials-yaml.js';
|
|
|
24
24
|
import { decryptCredentials, SecurityError } from '../security/index.js';
|
|
25
25
|
import { engineMsg } from '../core/engine-locale.js';
|
|
26
26
|
import { createPreRestoreAttemptDir } from '../core/restore.js';
|
|
27
|
-
import { collectRestoreWalEntries, createRestoreWal, restoreActionStepId, restoreWalHandlesFromSteps } from '../core/restore-wal.js';
|
|
27
|
+
import { collectRestoreWalEntries, createRestoreWal, isExternalPluginKind, restoreActionStepId, restoreWalHandlesFromSteps } from '../core/restore-wal.js';
|
|
28
28
|
import { GIST_PROVIDER, cloudSecretRef, isS3CompatProvider, isWebDavConfig, normalizeGitSubdir, parseSyncChannel, validateCloudChannelInput, validateRepoUrl, validateWebDavUrl } from '../sync/sync-config.js';
|
|
29
29
|
import { DEFAULT_AUTOSYNC_AUTO_APPLY_TIER, DEFAULT_AUTOSYNC_CONFLICT_POLICY, DEFAULT_AUTOSYNC_REALTIME, DEFAULT_AUTOSYNC_REMOTE_CHECK_MS, lastRunFailureMessage, readAllAutosyncConfigs, readAutosyncConfig } from '../sync/autosync-config.js';
|
|
30
30
|
import { SYNC_CHANNELS } from '../sync/sync-config.js';
|
|
@@ -459,6 +459,7 @@ export async function executeRestorePlan(plan, exec, onAction, journal, resumeHi
|
|
|
459
459
|
snapshotId: plan.snapshotId,
|
|
460
460
|
restored: [],
|
|
461
461
|
removedPlugins: [],
|
|
462
|
+
installedPlugins: [],
|
|
462
463
|
manualHints: [],
|
|
463
464
|
failed: [],
|
|
464
465
|
skipped: [],
|
|
@@ -469,7 +470,7 @@ export async function executeRestorePlan(plan, exec, onAction, journal, resumeHi
|
|
|
469
470
|
const wal = createRestoreWal(journal);
|
|
470
471
|
const walByAction = new Map();
|
|
471
472
|
const resume = resumeHint;
|
|
472
|
-
const absOf = (action) => action.kind
|
|
473
|
+
const absOf = (action) => isExternalPluginKind(action.kind) || action.target === undefined || exec.absPath === undefined
|
|
473
474
|
? null
|
|
474
475
|
: exec.absPath(action.target);
|
|
475
476
|
if (wal !== null && exec.absPath !== undefined) {
|
|
@@ -543,6 +544,23 @@ export async function executeRestorePlan(plan, exec, onAction, journal, resumeHi
|
|
|
543
544
|
}
|
|
544
545
|
break;
|
|
545
546
|
}
|
|
547
|
+
case 'pluginInstall': {
|
|
548
|
+
const name = action.pluginName;
|
|
549
|
+
const target = action.pluginTarget ?? name;
|
|
550
|
+
if (name === undefined || target === undefined)
|
|
551
|
+
throw new Error(engineMsg('restore.missingPluginName'));
|
|
552
|
+
const result = await exec.installPlugin(name, target);
|
|
553
|
+
if (result.ok) {
|
|
554
|
+
report.installedPlugins.push(target);
|
|
555
|
+
}
|
|
556
|
+
else {
|
|
557
|
+
const reason = result.message ?? engineMsg('restore.pluginInstallFailed');
|
|
558
|
+
report.failed.push({ item: `plugin:${name}`, reason });
|
|
559
|
+
settleStatus = 'attention';
|
|
560
|
+
settleMessage = reason;
|
|
561
|
+
}
|
|
562
|
+
break;
|
|
563
|
+
}
|
|
546
564
|
case 'credentialHint':
|
|
547
565
|
report.manualHints.push(action.manualHint ?? action.description);
|
|
548
566
|
break;
|
|
@@ -612,6 +630,14 @@ export function makeRestoreExecutor(snapshotDir, host, profile) {
|
|
|
612
630
|
const tail = output.split('\n').slice(-8).join('\n') || msgOf(host)('host.restoreNoOutput');
|
|
613
631
|
return { ok: false, message: msgOf(host)('host.restoreUninstallFailed', { name, code: String(result.exitCode), tail }) };
|
|
614
632
|
},
|
|
633
|
+
installPlugin: async (name, target) => {
|
|
634
|
+
const result = await runDshPlugin(profileDir, profile, ['add', target]);
|
|
635
|
+
if (result.exitCode === 0)
|
|
636
|
+
return { ok: true };
|
|
637
|
+
const output = `${result.stderr}\n${result.stdout}`.trim();
|
|
638
|
+
const tail = output.split('\n').slice(-8).join('\n') || msgOf(host)('host.restoreNoOutput');
|
|
639
|
+
return { ok: false, message: engineMsg('restore.installFailedExit', { name, code: String(result.exitCode), tail }) };
|
|
640
|
+
},
|
|
615
641
|
};
|
|
616
642
|
}
|
|
617
643
|
/**
|
package/lib/routes/sync.js
CHANGED
|
@@ -1174,6 +1174,9 @@ export function syncRoutes(env) {
|
|
|
1174
1174
|
encrypt: body['encrypt'] === true,
|
|
1175
1175
|
// 安全兜底:includeSecrets 必须同时 encrypt(密钥绝不明文进同步通道)
|
|
1176
1176
|
includeSecrets: body['includeSecrets'] === true && body['encrypt'] === true,
|
|
1177
|
+
// issue #132:跟随远端删除插件。缺省关;请求体非 true 一律按关处理
|
|
1178
|
+
// (重新保存表单时收起开关 = 明确关掉,不留上一次的 true)
|
|
1179
|
+
deletePlugins: body['deletePlugins'] === true,
|
|
1177
1180
|
};
|
|
1178
1181
|
// 加密/解密密码持久化(用户要求:勾选即记住,取消勾选或主动删除才清)。
|
|
1179
1182
|
// 值只写进 DSH credentials(绝不进 sync-selection.json / 日志 / 响应);
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import type { SectionData, SectionId } from '../schema/types.ts';
|
|
2
|
+
import type { MergeConflictReason, MergeSectionResult } from './merge.ts';
|
|
3
|
+
/** plan 的单个分区结果 → 预览视图(三侧都只回传可读文本,绝不回传原始值)。 */
|
|
4
|
+
export declare function mergePreviewSectionView(result: MergeSectionResult): MergePreviewSectionView;
|
|
5
|
+
/**
|
|
6
|
+
* issue #91:走只读 `preview()` 拿到的产物,能否直接与该分区**基线 hash**(push 时按 export() 产物记录)比对。
|
|
7
|
+
*
|
|
8
|
+
* 为什么需要这个判定:`plugins` 适配器的 `preview()` 走 `collect(…, pack=false)` —— 刻意**不做**
|
|
9
|
+
* 本地源(`link:` / `file:`)插件的 `npm pack`。于是当 profile 里存在本地源插件时,预览产物既没有
|
|
10
|
+
* `localTarballs`、插件 spec 也保持原样(export() 会改写成 `file:<tarball>`),与基线**不同口径**:
|
|
11
|
+
* 此时既不能断言「无变化」(本地插件源码改了体积/内容,预览看不见),也不该为了比对去打包
|
|
12
|
+
* (那正是本 issue 的缺陷本身)。
|
|
13
|
+
*
|
|
14
|
+
* 返回 true = 该分区本趟**不可比** ⇒ 调用方只能保守报「有变化」并如实说明原因。
|
|
15
|
+
* 其余分区的 preview() 产物与 export() 逐字节相同(文件类分区不走 preview(),见 previewPush)。
|
|
16
|
+
*/
|
|
17
|
+
export declare function previewCaliberDiffersFromExport(sectionId: SectionId, data: SectionData): boolean;
|
|
18
|
+
/** previewMerge 的单条冲突视图(三侧文本都已截断 + redact;绝不回传原始值对象)。 */
|
|
19
|
+
export interface MergePreviewConflictView {
|
|
20
|
+
/** 冲突位置:JSON 分区是 top-level key;文件类分区是 relativePath;'$' = 整分区冲突。 */
|
|
21
|
+
path: string;
|
|
22
|
+
kind: 'key' | 'file';
|
|
23
|
+
/** 冲突成因(可选:旧数据/旧 merge 结果没有该字段,界面缺省按 'both-modified' 措辞)。 */
|
|
24
|
+
reason?: MergeConflictReason;
|
|
25
|
+
/** 本机侧的可读预览(≤ 2 KiB,超出截断加省略号;已过 redact())。 */
|
|
26
|
+
localPreview: string;
|
|
27
|
+
/** 远端侧的可读预览(同上)。 */
|
|
28
|
+
remotePreview: string;
|
|
29
|
+
/** 共同祖先侧的可读预览(同上;无祖先时为空串)。 */
|
|
30
|
+
ancestorPreview: string;
|
|
31
|
+
}
|
|
32
|
+
/** previewMerge 的单个分区视图。 */
|
|
33
|
+
export interface MergePreviewSectionView {
|
|
34
|
+
id: SectionId;
|
|
35
|
+
decision: MergeSectionResult['decision'];
|
|
36
|
+
/** 自动合并并入的变更点数量(仅 decision === 'merge' 时有意义;缺省 = 未统计)。 */
|
|
37
|
+
autoMerged?: number;
|
|
38
|
+
conflictCount: number;
|
|
39
|
+
conflicts: MergePreviewConflictView[];
|
|
40
|
+
}
|
|
41
|
+
/** previewMerge 结果(只读、零写入)。 */
|
|
42
|
+
export interface MergePreview {
|
|
43
|
+
/** 预览是否成功产出(远端无快照 → false + message,分区清单为空)。 */
|
|
44
|
+
ok: boolean;
|
|
45
|
+
/** 本次预览针对的**远端**快照 id;'' = 远端无快照。 */
|
|
46
|
+
snapshotId: string;
|
|
47
|
+
/** 是否拿到了本地祖先副本(false = 退化为两方合并 → 所有双侧差异都会呈现为 conflict)。 */
|
|
48
|
+
hasAncestor: boolean;
|
|
49
|
+
sections: MergePreviewSectionView[];
|
|
50
|
+
/** 与 risk.ts 的 classifyMergePlan 同口径计数:auto = 可自动应用,review = 需人工,conflicts = 冲突,skipped = 跳过。 */
|
|
51
|
+
summary: {
|
|
52
|
+
auto: number;
|
|
53
|
+
review: number;
|
|
54
|
+
conflicts: number;
|
|
55
|
+
skipped: number;
|
|
56
|
+
};
|
|
57
|
+
message?: string;
|
|
58
|
+
reason?: 'remote-empty';
|
|
59
|
+
/**
|
|
60
|
+
* 本轮合并**将卸载**的插件(issue #132):确认页必须单列出来,用户据此可以整轮取消。
|
|
61
|
+
* 仅在 plugins 分区可应用(useRemote/keepLocal/merge)时才有条目 —— 分区冲突时不删。
|
|
62
|
+
*/
|
|
63
|
+
pluginRemovals?: {
|
|
64
|
+
name: string;
|
|
65
|
+
version: string;
|
|
66
|
+
}[];
|
|
67
|
+
/** 远端删了、本机却改过 → 不删,等人工裁决(与 conflict 清单同语义,这里为插件专列) */
|
|
68
|
+
pluginRemovalConflicts?: {
|
|
69
|
+
name: string;
|
|
70
|
+
ancestorVersion: string;
|
|
71
|
+
localVersion: string;
|
|
72
|
+
}[];
|
|
73
|
+
/** 考察过但没删的条目及原因(含开关关闭 = 'switch-off',界面据此如实说明) */
|
|
74
|
+
pluginRemovalSkipped?: {
|
|
75
|
+
name: string;
|
|
76
|
+
reason: string;
|
|
77
|
+
}[];
|
|
78
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 合并预览的**可渲染视图**(分区结果 → 界面结构),与「预览产物能否与基线比对」的判定。
|
|
3
|
+
*
|
|
4
|
+
* 为什么独立成文件:sync-engine 已顶到文件体量棘轮(tests/file-size-ratchet.test.ts),
|
|
5
|
+
* 而这两件事都只依赖 merge.ts 的结果类型与预览文本工具,不碰引擎实例状态;放这里可单测,
|
|
6
|
+
* 也让引擎只管编排。类型经 sync-engine 再导出,既有导入方(model-tools 等)无需改动。
|
|
7
|
+
*/
|
|
8
|
+
import { isLocalPluginSpec } from '../core/local-plugin-pack.js';
|
|
9
|
+
import { previewTextOf } from './merge-preview-text.js';
|
|
10
|
+
/** plan 的单个分区结果 → 预览视图(三侧都只回传可读文本,绝不回传原始值)。 */
|
|
11
|
+
export function mergePreviewSectionView(result) {
|
|
12
|
+
const conflicts = result.conflicts.map((c) => ({
|
|
13
|
+
path: c.path,
|
|
14
|
+
kind: c.kind,
|
|
15
|
+
...(c.reason !== undefined ? { reason: c.reason } : {}),
|
|
16
|
+
localPreview: previewTextOf(c.local),
|
|
17
|
+
remotePreview: previewTextOf(c.remote),
|
|
18
|
+
ancestorPreview: previewTextOf(c.ancestor),
|
|
19
|
+
}));
|
|
20
|
+
return {
|
|
21
|
+
id: result.id,
|
|
22
|
+
decision: result.decision,
|
|
23
|
+
...(result.autoMerged !== undefined ? { autoMerged: result.autoMerged } : {}),
|
|
24
|
+
conflictCount: result.conflicts.length,
|
|
25
|
+
conflicts,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* issue #91:走只读 `preview()` 拿到的产物,能否直接与该分区**基线 hash**(push 时按 export() 产物记录)比对。
|
|
30
|
+
*
|
|
31
|
+
* 为什么需要这个判定:`plugins` 适配器的 `preview()` 走 `collect(…, pack=false)` —— 刻意**不做**
|
|
32
|
+
* 本地源(`link:` / `file:`)插件的 `npm pack`。于是当 profile 里存在本地源插件时,预览产物既没有
|
|
33
|
+
* `localTarballs`、插件 spec 也保持原样(export() 会改写成 `file:<tarball>`),与基线**不同口径**:
|
|
34
|
+
* 此时既不能断言「无变化」(本地插件源码改了体积/内容,预览看不见),也不该为了比对去打包
|
|
35
|
+
* (那正是本 issue 的缺陷本身)。
|
|
36
|
+
*
|
|
37
|
+
* 返回 true = 该分区本趟**不可比** ⇒ 调用方只能保守报「有变化」并如实说明原因。
|
|
38
|
+
* 其余分区的 preview() 产物与 export() 逐字节相同(文件类分区不走 preview(),见 previewPush)。
|
|
39
|
+
*/
|
|
40
|
+
export function previewCaliberDiffersFromExport(sectionId, data) {
|
|
41
|
+
if (sectionId !== 'plugins')
|
|
42
|
+
return false;
|
|
43
|
+
const plugins = data.plugins;
|
|
44
|
+
return Array.isArray(plugins) && plugins.some((p) => isLocalPluginSpec(p?.spec));
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=merge-preview-view.js.map
|
package/lib/sync/merge.d.ts
CHANGED
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
* 文件级(FilesSection 内的 relativePath)才是真正的删除语义,那里按 modify/delete 判冲突。
|
|
31
31
|
*/
|
|
32
32
|
import type { SectionData, SectionId } from '../schema/types.ts';
|
|
33
|
+
import type { GranularMergeHooks } from './workspace-merge.ts';
|
|
33
34
|
/**
|
|
34
35
|
* 分区级决胜结果(三方合并,2026-10 收口):
|
|
35
36
|
* - 'skip' :双侧相对祖先都未改(或本就无变化)—— 不产生任何写入;
|
|
@@ -74,4 +75,4 @@ export interface MergePlan {
|
|
|
74
75
|
sections: MergeSectionResult[];
|
|
75
76
|
}
|
|
76
77
|
/** 主入口:三方合并。纯函数,无副作用。 */
|
|
77
|
-
export declare function merge(local: Partial<Record<SectionId, SectionData>>, remote: Partial<Record<SectionId, SectionData>>, ancestor?: Partial<Record<SectionId, SectionData
|
|
78
|
+
export declare function merge(local: Partial<Record<SectionId, SectionData>>, remote: Partial<Record<SectionId, SectionData>>, ancestor?: Partial<Record<SectionId, SectionData>>, hooks?: GranularMergeHooks): MergePlan;
|
package/lib/sync/merge.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { hashSection } from './sync-state.js';
|
|
2
2
|
import { mergeBytesThreeWay, mergeJsonValues } from './text-merge.js';
|
|
3
|
+
import { mergePluginsSection } from './plugin-removals.js';
|
|
3
4
|
import { mergeWorkspacesSection } from './workspace-merge.js';
|
|
4
5
|
/** 收集 local/remote/ancestor 三个快照中出现过的所有分区 id。 */
|
|
5
6
|
function unionSectionIds(local, remote, ancestor) {
|
|
@@ -223,9 +224,13 @@ function mergeFilesSectionGranular(local, remote, ancestor) {
|
|
|
223
224
|
*/
|
|
224
225
|
const GRANULAR_MERGES = {
|
|
225
226
|
workspaces: mergeWorkspacesSection,
|
|
227
|
+
// plugins(issue #132):plugins 是**数组**,通用 JSON 合并对「两侧各自改过」一律判冲突 ——
|
|
228
|
+
// 本机装了 Y、远端删了 X 就会整分区冲突,X 永远删不掉、Y 也永远同步不出去。
|
|
229
|
+
// 钩子按包名做三方逐条判定(本地新增保留 / 远端删除跟随 / 版本冲突交人工)。
|
|
230
|
+
plugins: mergePluginsSection,
|
|
226
231
|
};
|
|
227
232
|
/** 单分区三方合并(决策链见文件头注释)。 */
|
|
228
|
-
function mergeSectionTriple(id, lData, rData, aData, h) {
|
|
233
|
+
function mergeSectionTriple(id, lData, rData, aData, h, hooks) {
|
|
229
234
|
// ⓪ 形状闸门(先于一切取舍):远端载荷来自不可信输入(解析层只保证整体是合法 JSON,
|
|
230
235
|
// 不保证每个分区的值形状正确)。值形状不对时**绝不原样采用** —— 那等于把畸形数据
|
|
231
236
|
// 写进本机配置;一律按 conflict(reason='format') 交用户裁决。
|
|
@@ -288,7 +293,7 @@ function mergeSectionTriple(id, lData, rData, aData, h) {
|
|
|
288
293
|
// 没有祖先时也应并集(否则首轮同步就整分区冲突),字段取值分歧由钩子逐键如实报冲突。
|
|
289
294
|
const granular = GRANULAR_MERGES[id];
|
|
290
295
|
if (granular !== undefined) {
|
|
291
|
-
const res = granular(local, remote, aData);
|
|
296
|
+
const res = granular(local, remote, aData, hooks);
|
|
292
297
|
if (res !== undefined) {
|
|
293
298
|
if (res.conflicts.length > 0)
|
|
294
299
|
return { id, decision: 'conflict', conflicts: res.conflicts };
|
|
@@ -358,7 +363,7 @@ function mergeSectionTriple(id, lData, rData, aData, h) {
|
|
|
358
363
|
};
|
|
359
364
|
}
|
|
360
365
|
/** 主入口:三方合并。纯函数,无副作用。 */
|
|
361
|
-
export function merge(local, remote, ancestor) {
|
|
366
|
+
export function merge(local, remote, ancestor, hooks = {}) {
|
|
362
367
|
const l = local;
|
|
363
368
|
const r = remote;
|
|
364
369
|
const a = ancestor;
|
|
@@ -366,7 +371,7 @@ export function merge(local, remote, ancestor) {
|
|
|
366
371
|
const hashes = computeHashes(l, r, a, ids);
|
|
367
372
|
const results = [];
|
|
368
373
|
for (const id of ids) {
|
|
369
|
-
results.push(mergeSectionTriple(id, l[id], r[id], a ? a[id] : undefined, hashes.get(id)));
|
|
374
|
+
results.push(mergeSectionTriple(id, l[id], r[id], a ? a[id] : undefined, hashes.get(id), hooks));
|
|
370
375
|
}
|
|
371
376
|
return { sections: results };
|
|
372
377
|
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import type { MsgFunc } from '../core/messages.ts';
|
|
2
|
+
import type { SnapshotPluginRemoval } from '../core/types.ts';
|
|
3
|
+
import type { SectionData, SectionId } from '../schema/types.ts';
|
|
4
|
+
import type { PluginRemovalEntry, PluginRemovalPlan } from './plugin-removals.ts';
|
|
5
|
+
/** 一条插件卸载结果(reinstallTarget 供 undo 与人工补装使用)。 */
|
|
6
|
+
export interface PluginRemovalReportItem {
|
|
7
|
+
name: string;
|
|
8
|
+
version: string;
|
|
9
|
+
/** 重装目标:`name@version`(版本未知时退回裸包名) */
|
|
10
|
+
reinstallTarget: string;
|
|
11
|
+
ok: boolean;
|
|
12
|
+
/** 失败原因(已由 CLI 分类器给出可操作文案);ok=true 时缺省 */
|
|
13
|
+
message?: string;
|
|
14
|
+
}
|
|
15
|
+
/** 预览侧的删除视图(确认页据此单列「将删除:X@1.2.3」,用户可整轮取消)。 */
|
|
16
|
+
export interface PluginRemovalPreviewView {
|
|
17
|
+
pluginRemovals: {
|
|
18
|
+
name: string;
|
|
19
|
+
version: string;
|
|
20
|
+
}[];
|
|
21
|
+
pluginRemovalConflicts: {
|
|
22
|
+
name: string;
|
|
23
|
+
ancestorVersion: string;
|
|
24
|
+
localVersion: string;
|
|
25
|
+
}[];
|
|
26
|
+
pluginRemovalSkipped: {
|
|
27
|
+
name: string;
|
|
28
|
+
reason: string;
|
|
29
|
+
}[];
|
|
30
|
+
}
|
|
31
|
+
/** 判据输入侧的「已装插件」最小形状(PluginInfo 与 PluginEntry 都能直接传)。 */
|
|
32
|
+
type InstalledPlugin = {
|
|
33
|
+
name: string;
|
|
34
|
+
version: string;
|
|
35
|
+
enabled?: boolean;
|
|
36
|
+
spec?: string;
|
|
37
|
+
bundlesOnly?: boolean;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* 把某个分区载荷里的插件清单抽成判据要的形状(不认识 = undefined)。
|
|
41
|
+
*
|
|
42
|
+
* 为什么直接从「本轮合并的三方输入」读而不是再 export 一次:那三个载荷就是本轮合并的真实输入,
|
|
43
|
+
* 再 export 会拿到「已经写了一半」的状态,判据与合并结论就会打架。
|
|
44
|
+
*/
|
|
45
|
+
export declare function pluginEntriesOf(data: SectionData | undefined): PluginRemovalEntry[] | undefined;
|
|
46
|
+
/** 三方输入 + 本机已装 → 删除计划(预览与执行共用同一份判据)。 */
|
|
47
|
+
export declare function pluginRemovalPlanOf(args: {
|
|
48
|
+
ancestor?: SectionData;
|
|
49
|
+
remote?: SectionData;
|
|
50
|
+
installed: readonly InstalledPlugin[];
|
|
51
|
+
enabled: boolean;
|
|
52
|
+
selfName?: string;
|
|
53
|
+
}): PluginRemovalPlan;
|
|
54
|
+
/**
|
|
55
|
+
* 执行删除(逐项失败不阻断)。
|
|
56
|
+
*
|
|
57
|
+
* 为什么只在 plugins 分区真的被应用时才动:分区冲突/跳过 = 本轮还没确定「远端删了它」,
|
|
58
|
+
* 此时删本机插件等于拿未裁决的远端差异动用户机器。
|
|
59
|
+
*/
|
|
60
|
+
export declare function applyPluginRemovalStep(args: {
|
|
61
|
+
appliedIds: readonly SectionId[];
|
|
62
|
+
plan: PluginRemovalPlan | undefined;
|
|
63
|
+
enabled: boolean;
|
|
64
|
+
uninstall: (name: string) => Promise<unknown>;
|
|
65
|
+
msg: MsgFunc;
|
|
66
|
+
}): Promise<{
|
|
67
|
+
removals: PluginRemovalReportItem[];
|
|
68
|
+
warnings: string[];
|
|
69
|
+
}>;
|
|
70
|
+
/**
|
|
71
|
+
* 把「本轮删掉哪些插件」写进本次回滚快照(undo 线索)。
|
|
72
|
+
*
|
|
73
|
+
* 写不进去不中止同步(分区已落地且已重导出),但必须留一条可见告警 ——
|
|
74
|
+
* 报告里的 reinstallTarget 仍可人工执行,静默丢失 undo 线索才是真问题。
|
|
75
|
+
*/
|
|
76
|
+
export declare function recordPluginRemovalUndo(args: {
|
|
77
|
+
removals: readonly PluginRemovalReportItem[];
|
|
78
|
+
snapshotId: string;
|
|
79
|
+
record?: (id: string, entries: SnapshotPluginRemoval[]) => Promise<void>;
|
|
80
|
+
msg: MsgFunc;
|
|
81
|
+
}): Promise<string[]>;
|
|
82
|
+
/**
|
|
83
|
+
* 预览侧的删除视图:确认页必须能单列「将删除:X@1.2.3」让用户整轮取消,
|
|
84
|
+
* 也必须如实说明「开关关着,所以没删」与「远端删了但本机改过」两种不删的原因。
|
|
85
|
+
*
|
|
86
|
+
* plugins 分区本轮不可应用(conflict / skip)时不列删除项:那时「远端删了它」还没被用户确认。
|
|
87
|
+
*/
|
|
88
|
+
export declare function pluginRemovalPreviewOf(args: {
|
|
89
|
+
plan: PluginRemovalPlan | undefined;
|
|
90
|
+
sections: readonly {
|
|
91
|
+
id: SectionId;
|
|
92
|
+
decision: string;
|
|
93
|
+
}[];
|
|
94
|
+
}): PluginRemovalPreviewView | undefined;
|
|
95
|
+
export {};
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* issue #132:跟随远端删除插件的**编排层**(判据 → 卸载 → 告警 → undo 线索)。
|
|
3
|
+
*
|
|
4
|
+
* 为什么从 sync-engine 下沉:引擎已顶到文件体量棘轮(tests/file-size-ratchet.test.ts),
|
|
5
|
+
* 而这部分只依赖「三方载荷 + 本机已装清单 + 卸载函数 + msg」,不碰引擎内部状态;
|
|
6
|
+
* 独立成模块后可单独测,也不会把引擎继续堆高。判据本体仍留在 ./plugin-removals.ts(纯函数、零 IO)。
|
|
7
|
+
*
|
|
8
|
+
* 三条语义在此定型,改之前先读 issue #132 的裁决:
|
|
9
|
+
* 1. 开关关闭 = **不删但也绝不装作没有候选**:逐项发 warning 说明「开着会删谁」;
|
|
10
|
+
* 2. 卸载失败(含 desktop 保留档案被 CLI 拒)逐项进报告 + warning,不阻断其余项、不回滚整轮;
|
|
11
|
+
* 3. undo 线索只写「真的删成功」的那些,写不进去只告警(报告里的 reinstallTarget 仍是人工兜底)。
|
|
12
|
+
*/
|
|
13
|
+
import { registerMessageCatalog } from '../core/engine-locale.js';
|
|
14
|
+
import { pluginInstallTarget } from '../core/plugin-cli.js';
|
|
15
|
+
import { planPluginRemovals } from './plugin-removals.js';
|
|
16
|
+
const zh = {
|
|
17
|
+
'sync.pluginRemoveDone': '已跟随远端删除插件 {name}@{version}(可随时用 "{name}@{version}" 重装)',
|
|
18
|
+
'sync.pluginRemoveFailed': '删除插件 {name} 失败:{reason}(其余项继续,失败项下一轮会重新判定)',
|
|
19
|
+
'sync.pluginRemoveConflict': '插件 {name} 远端已删除,但本机改过(本机 {local},共同祖先 {ancestor}):未删除,请人工确认',
|
|
20
|
+
'sync.pluginRemoveSkipped': '插件 {name} 在远端已删除,但"跟随删除插件"未开启:已保留(开启后会删除)',
|
|
21
|
+
'sync.pluginRemoveUndoUnrecorded': '插件已经删除,但没能写进本次回滚快照的 undo 记录({names}):恢复这份快照不会自动装回它们,需要时请手动执行 dsh plugin add',
|
|
22
|
+
};
|
|
23
|
+
const en = {
|
|
24
|
+
'sync.pluginRemoveDone': 'Removed plugin {name}@{version} to follow the remote (reinstall anytime with "{name}@{version}")',
|
|
25
|
+
'sync.pluginRemoveFailed': 'Could not remove plugin {name}: {reason} (the remaining items continue; this one is re-evaluated next round)',
|
|
26
|
+
'sync.pluginRemoveConflict': 'Plugin {name} was deleted remotely but changed locally (local {local}, common ancestor {ancestor}): not removed, needs a human decision',
|
|
27
|
+
'sync.pluginRemoveSkipped': 'Plugin {name} was deleted remotely, but "delete plugins to follow the remote" is off: kept (it will be removed once enabled)',
|
|
28
|
+
'sync.pluginRemoveUndoUnrecorded': 'The plugin(s) were removed, but the undo record could not be written into this rollback snapshot ({names}): restoring that snapshot will not reinstall them — run dsh plugin add manually if needed',
|
|
29
|
+
};
|
|
30
|
+
registerMessageCatalog({ id: 'sync-plugin-removal', zh, en });
|
|
31
|
+
/**
|
|
32
|
+
* 把某个分区载荷里的插件清单抽成判据要的形状(不认识 = undefined)。
|
|
33
|
+
*
|
|
34
|
+
* 为什么直接从「本轮合并的三方输入」读而不是再 export 一次:那三个载荷就是本轮合并的真实输入,
|
|
35
|
+
* 再 export 会拿到「已经写了一半」的状态,判据与合并结论就会打架。
|
|
36
|
+
*/
|
|
37
|
+
export function pluginEntriesOf(data) {
|
|
38
|
+
if (data === null || typeof data !== 'object')
|
|
39
|
+
return undefined;
|
|
40
|
+
const obj = data;
|
|
41
|
+
if (obj.version !== 1 || !Array.isArray(obj.plugins))
|
|
42
|
+
return undefined;
|
|
43
|
+
const out = [];
|
|
44
|
+
for (const raw of obj.plugins) {
|
|
45
|
+
if (raw === null || typeof raw !== 'object')
|
|
46
|
+
continue;
|
|
47
|
+
const p = raw;
|
|
48
|
+
if (typeof p.name !== 'string' || p.name === '')
|
|
49
|
+
continue;
|
|
50
|
+
out.push({
|
|
51
|
+
name: p.name,
|
|
52
|
+
version: typeof p.version === 'string' ? p.version : '',
|
|
53
|
+
...(typeof p.spec === 'string' ? { spec: p.spec } : {}),
|
|
54
|
+
...(p.bundlesOnly === true ? { bundlesOnly: true } : {}),
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
return out;
|
|
58
|
+
}
|
|
59
|
+
/** 三方输入 + 本机已装 → 删除计划(预览与执行共用同一份判据)。 */
|
|
60
|
+
export function pluginRemovalPlanOf(args) {
|
|
61
|
+
return planPluginRemovals({
|
|
62
|
+
enabled: args.enabled,
|
|
63
|
+
ancestor: pluginEntriesOf(args.ancestor),
|
|
64
|
+
remote: pluginEntriesOf(args.remote),
|
|
65
|
+
local: args.installed,
|
|
66
|
+
selfName: args.selfName ?? '',
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* 执行删除(逐项失败不阻断)。
|
|
71
|
+
*
|
|
72
|
+
* 为什么只在 plugins 分区真的被应用时才动:分区冲突/跳过 = 本轮还没确定「远端删了它」,
|
|
73
|
+
* 此时删本机插件等于拿未裁决的远端差异动用户机器。
|
|
74
|
+
*/
|
|
75
|
+
export async function applyPluginRemovalStep(args) {
|
|
76
|
+
const removals = [];
|
|
77
|
+
const warnings = [];
|
|
78
|
+
if (!args.appliedIds.includes('plugins'))
|
|
79
|
+
return { removals, warnings };
|
|
80
|
+
const plan = args.plan;
|
|
81
|
+
if (plan === undefined)
|
|
82
|
+
return { removals, warnings };
|
|
83
|
+
for (const c of plan.conflicts) {
|
|
84
|
+
warnings.push(args.msg('sync.pluginRemoveConflict', {
|
|
85
|
+
name: c.name, local: c.localVersion, ancestor: c.ancestorVersion,
|
|
86
|
+
}));
|
|
87
|
+
}
|
|
88
|
+
if (!args.enabled) {
|
|
89
|
+
// 开关关:把「打开后会删什么」如实说出来(不删,但也绝不装作没有候选)
|
|
90
|
+
for (const k of plan.kept) {
|
|
91
|
+
if (k.reason === 'switch-off')
|
|
92
|
+
warnings.push(args.msg('sync.pluginRemoveSkipped', { name: k.name }));
|
|
93
|
+
}
|
|
94
|
+
return { removals, warnings };
|
|
95
|
+
}
|
|
96
|
+
for (const r of plan.removals) {
|
|
97
|
+
// 重装目标与导入侧同一决策(core/plugin-cli.ts 的 pluginInstallTarget):github:/git+/file:/link:
|
|
98
|
+
// 这类来源只靠 name@version 装不回同一份代码,必须带祖先记录的 spec。
|
|
99
|
+
const reinstallTarget = pluginInstallTarget(r.name, {
|
|
100
|
+
...(r.version === '' ? {} : { version: r.version }),
|
|
101
|
+
...(r.spec === undefined ? {} : { spec: r.spec }),
|
|
102
|
+
});
|
|
103
|
+
try {
|
|
104
|
+
await args.uninstall(r.name);
|
|
105
|
+
removals.push({ name: r.name, version: r.version, reinstallTarget, ok: true });
|
|
106
|
+
warnings.push(args.msg('sync.pluginRemoveDone', { name: r.name, version: r.version }));
|
|
107
|
+
}
|
|
108
|
+
catch (error) {
|
|
109
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
110
|
+
removals.push({ name: r.name, version: r.version, reinstallTarget, ok: false, message: reason });
|
|
111
|
+
warnings.push(args.msg('sync.pluginRemoveFailed', { name: r.name, reason }));
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return { removals, warnings };
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* 把「本轮删掉哪些插件」写进本次回滚快照(undo 线索)。
|
|
118
|
+
*
|
|
119
|
+
* 写不进去不中止同步(分区已落地且已重导出),但必须留一条可见告警 ——
|
|
120
|
+
* 报告里的 reinstallTarget 仍可人工执行,静默丢失 undo 线索才是真问题。
|
|
121
|
+
*/
|
|
122
|
+
export async function recordPluginRemovalUndo(args) {
|
|
123
|
+
const removed = args.removals.filter((r) => r.ok);
|
|
124
|
+
if (removed.length === 0)
|
|
125
|
+
return [];
|
|
126
|
+
const names = removed.map((r) => r.reinstallTarget).join(', ');
|
|
127
|
+
const entries = removed.map((r) => ({ name: r.name, version: r.version, target: r.reinstallTarget }));
|
|
128
|
+
if (args.record === undefined)
|
|
129
|
+
return [args.msg('sync.pluginRemoveUndoUnrecorded', { names })];
|
|
130
|
+
try {
|
|
131
|
+
await args.record(args.snapshotId, entries);
|
|
132
|
+
return [];
|
|
133
|
+
}
|
|
134
|
+
catch (error) {
|
|
135
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
136
|
+
return [args.msg('sync.pluginRemoveUndoUnrecorded', { names }), reason];
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* 预览侧的删除视图:确认页必须能单列「将删除:X@1.2.3」让用户整轮取消,
|
|
141
|
+
* 也必须如实说明「开关关着,所以没删」与「远端删了但本机改过」两种不删的原因。
|
|
142
|
+
*
|
|
143
|
+
* plugins 分区本轮不可应用(conflict / skip)时不列删除项:那时「远端删了它」还没被用户确认。
|
|
144
|
+
*/
|
|
145
|
+
export function pluginRemovalPreviewOf(args) {
|
|
146
|
+
if (args.plan === undefined)
|
|
147
|
+
return undefined;
|
|
148
|
+
const section = args.sections.find((s) => s.id === 'plugins');
|
|
149
|
+
const applied = section !== undefined && section.decision !== 'conflict' && section.decision !== 'skip';
|
|
150
|
+
return {
|
|
151
|
+
pluginRemovals: applied ? args.plan.removals.map((r) => ({ name: r.name, version: r.version })) : [],
|
|
152
|
+
pluginRemovalConflicts: args.plan.conflicts.map((c) => ({
|
|
153
|
+
name: c.name, ancestorVersion: c.ancestorVersion, localVersion: c.localVersion,
|
|
154
|
+
})),
|
|
155
|
+
pluginRemovalSkipped: args.plan.kept.map((k) => ({ name: k.name, reason: k.reason })),
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
//# sourceMappingURL=plugin-removal-apply.js.map
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* #132:同步「跟随远端删除插件」的**唯一判据**与 plugins 分区的按名三方合并。
|
|
3
|
+
*
|
|
4
|
+
* 为什么必须单独一个模块:
|
|
5
|
+
* 1. 删除判定是纯逻辑(开关 × 祖先 × 远端 × 本机),散进引擎里既测不了也说不清;
|
|
6
|
+
* 2. plugins 分区不能走通用 JSON 合并 —— `merge.ts` 的 `mergeJsonValues` 对数组一律「两侧都改
|
|
7
|
+
* 且不逐字相等 → 冲突」,而本分区的日常形态恰恰是「A 机卸载了 X、B 机新装了 Y」,通用路径
|
|
8
|
+
* 会把它报成整分区冲突,于是删除永远进不了自动应用(issue #132 的行为表 A→B 走不通)。
|
|
9
|
+
*
|
|
10
|
+
* 删除判据(缺一不可,全部满足才删):
|
|
11
|
+
* - 开关打开(`SyncSelection.deletePlugins`,缺省关);
|
|
12
|
+
* - **祖先**里有它(A 机那轮同步见过的状态)——没有祖先就没有「谁删了它」的证据;
|
|
13
|
+
* - **远端**没有它(= 有人在另一台机器上卸载了);
|
|
14
|
+
* - **本机装着**(卸载才有意义);
|
|
15
|
+
* - 本机版本**仍等于祖先版本**(本地改过 = 用户在自己这台机器上动过它,绝不替用户做决定,
|
|
16
|
+
* 报 `version-changed` 冲突交人裁决);
|
|
17
|
+
* - 不是本插件自己、不是 bundlesOnly 条目(后者由 DSH 自身安装位置解析,`dsh plugin remove`
|
|
18
|
+
* 对它无意义,见 `core/plugin-cli.ts` 的 `isBundlesOnlyEntry`)。
|
|
19
|
+
*
|
|
20
|
+
* 纯函数、零 I/O:引擎调用它拿计划,UI 调用它拿「将删除」清单。
|
|
21
|
+
*/
|
|
22
|
+
import type { SectionData } from '../schema/types.ts';
|
|
23
|
+
import type { GranularMergeOutcome } from './workspace-merge.ts';
|
|
24
|
+
/** 一条「该卸载」的结论(version = 祖先/本机一致的版本,用于报告与回滚重装目标)。 */
|
|
25
|
+
export interface PluginRemoval {
|
|
26
|
+
name: string;
|
|
27
|
+
version: string;
|
|
28
|
+
/** 祖先条目里的安装源(github:/git+/file:/link: 等);重装目标要用它,否则装不回同一来源 */
|
|
29
|
+
spec?: string;
|
|
30
|
+
}
|
|
31
|
+
/** 未删的原因:每一条都要能对用户解释(报告里逐项列出,绝不静默跳过)。 */
|
|
32
|
+
export type PluginRemovalKeptReason = 'still-in-remote' | 'self' | 'bundles-only' | 'not-installed' | 'switch-off';
|
|
33
|
+
export interface PluginRemovalConflict {
|
|
34
|
+
name: string;
|
|
35
|
+
reason: 'version-changed';
|
|
36
|
+
ancestorVersion: string;
|
|
37
|
+
localVersion: string;
|
|
38
|
+
}
|
|
39
|
+
export interface PluginRemovalPlan {
|
|
40
|
+
/** 该执行 `dsh plugin remove` 的插件(顺序 = 祖先顺序,便于报告比对) */
|
|
41
|
+
removals: PluginRemoval[];
|
|
42
|
+
/** 本机改过、远端删了 → 交人裁决(不删也不静默保留) */
|
|
43
|
+
conflicts: PluginRemovalConflict[];
|
|
44
|
+
/** 考察过但不删的条目及原因 */
|
|
45
|
+
kept: {
|
|
46
|
+
name: string;
|
|
47
|
+
reason: PluginRemovalKeptReason;
|
|
48
|
+
}[];
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* 判据只需要这几个字段:`PluginEntry` 与宿主的 `PluginInfo`(listInstalled 的返回值)都能直接传入,
|
|
52
|
+
* 不必为了调用它先拼一个完整的分区条目。
|
|
53
|
+
*/
|
|
54
|
+
export interface PluginRemovalEntry {
|
|
55
|
+
name: string;
|
|
56
|
+
version: string;
|
|
57
|
+
spec?: string;
|
|
58
|
+
bundlesOnly?: boolean;
|
|
59
|
+
}
|
|
60
|
+
export interface PluginRemovalInput {
|
|
61
|
+
/** 同步选择里的开关(缺省关);关 = 一个都不删 */
|
|
62
|
+
enabled: boolean;
|
|
63
|
+
/** 共同祖先快照里的插件清单(undefined = 没有祖先副本) */
|
|
64
|
+
ancestor: readonly PluginRemovalEntry[] | undefined;
|
|
65
|
+
/** 远端快照里的插件清单(undefined = 远端没有该分区) */
|
|
66
|
+
remote: readonly PluginRemovalEntry[] | undefined;
|
|
67
|
+
/** 本机当前已装(plugins 分区导出的口径) */
|
|
68
|
+
local: readonly PluginRemovalEntry[];
|
|
69
|
+
/** 本插件自己的包名(永不删) */
|
|
70
|
+
selfName: string | undefined;
|
|
71
|
+
}
|
|
72
|
+
/** 判定「该不该删」。调用方只在 `applied` 含 plugins 时才真正执行。 */
|
|
73
|
+
export declare function planPluginRemovals(input: PluginRemovalInput): PluginRemovalPlan;
|
|
74
|
+
/**
|
|
75
|
+
* plugins 分区的按名三方合并(`merge.ts` 的 `GRANULAR_MERGES.plugins`)。
|
|
76
|
+
*
|
|
77
|
+
* 逐名规则与 git 同口径,祖先只用于判断「谁动了它」,绝不猜:
|
|
78
|
+
* - 两侧都有:身份相同 → 保留;某一侧与祖先相同 → 取另一侧;两侧都变(或没有祖先)→ both-modified 冲突;
|
|
79
|
+
* - 只有本机:有祖先且与祖先相同 → 跟随远端删除(真删除);无祖先 → 本机独有,保留;有祖先且不同 →
|
|
80
|
+
* modify-delete 冲突(用户在 A 机卸载、B 机却升级过它,不能替用户选);
|
|
81
|
+
* - 只有远端:有祖先且与祖先相同 → 本机删除,跟随(不复活);无祖先 → 远端独有,采纳;有祖先且不同 →
|
|
82
|
+
* delete-modify 冲突;
|
|
83
|
+
* - 两侧都没有:消失。
|
|
84
|
+
*
|
|
85
|
+
* 插件列表以外的字段不一致时返回 `undefined`:patch 行/pnpm-workspace 有各自的既有口径,
|
|
86
|
+
* 在这里再造一套合并只会和通用路径打架(通用路径会整分区处理,其中包含 plugins 数组的旧行为)。
|
|
87
|
+
*/
|
|
88
|
+
export declare function mergePluginsSection(local: SectionData, remote: SectionData, ancestor: SectionData | undefined, hooks?: {
|
|
89
|
+
deletePlugins?: boolean;
|
|
90
|
+
}): GranularMergeOutcome | undefined;
|