@hcmai/cli 0.25.0 → 0.25.1
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/index.js +181 -81
- package/dist/index.js.map +1 -1
- package/dist/skills/manifest.json +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -10336,6 +10336,7 @@ var WORKSPACE_CONTEXT_KIND = "hcm-workspace";
|
|
|
10336
10336
|
var WORKSPACE_CONTEXT_VERSION = 1;
|
|
10337
10337
|
var WORKSPACE_STATE_DIR = ".hcm";
|
|
10338
10338
|
var WORKSPACE_PULL_MANIFEST_FILE = "workspace-manifest.json";
|
|
10339
|
+
var WORKSPACE_PULL_INCOMPLETE_FILE = "workspace-pull-incomplete.json";
|
|
10339
10340
|
var MINI_APPS_DIR = "mini_apps";
|
|
10340
10341
|
var RAW_WORKSPACE_EXCLUDED_DIRS = /* @__PURE__ */ new Set([
|
|
10341
10342
|
".git",
|
|
@@ -10503,13 +10504,34 @@ async function workspacePullCommand(args) {
|
|
|
10503
10504
|
);
|
|
10504
10505
|
const context = buildWorkspaceContext({
|
|
10505
10506
|
workspaceKey,
|
|
10506
|
-
profile:
|
|
10507
|
+
profile: client3.profile ?? args.env ?? args.profile ?? existing?.profile,
|
|
10507
10508
|
tenantId: client3.tenantId ?? existing?.tenantId,
|
|
10508
10509
|
endpoint: client3.endpoint ?? existing?.endpoint
|
|
10509
10510
|
});
|
|
10511
|
+
const files = await listWorkspaceFilesForSync(client3.raw(), workspaceKey);
|
|
10512
|
+
const localFiles = await readWorkspaceRawLocalFiles(rootDir);
|
|
10513
|
+
const remotePaths = new Set(files.data.map((file) => file.relativePath));
|
|
10514
|
+
const manifest2 = await readWorkspaceRawManifest(rootDir, context, true);
|
|
10515
|
+
const sameTarget = (manifest2.endpoint ?? existing?.endpoint) === context.endpoint && (manifest2.tenantId ?? existing?.tenantId) === context.tenantId && !!context.endpoint && !!context.tenantId && (manifest2.profile === void 0 || manifest2.profile === existing?.profile || manifest2.endpoint !== void 0 && manifest2.tenantId !== void 0);
|
|
10516
|
+
const previous = sameTarget ? workspaceRawBaselineByPath(manifest2) : /* @__PURE__ */ new Map();
|
|
10517
|
+
const remoteDeleted = localFiles.filter((file) => previous.has(file.localPath) && !remotePaths.has(file.localPath));
|
|
10518
|
+
if (remoteDeleted.length) {
|
|
10519
|
+
throw new CliError26({
|
|
10520
|
+
code: CliErrorCode27.BUSINESS_RULE_VIOLATION,
|
|
10521
|
+
message: `\u8FDC\u7AEF\u5DF2\u5220\u9664\u66FE\u540C\u6B65\u7684\u6587\u4EF6\uFF0C\u672C\u5730\u4ECD\u4FDD\u7559\u5185\u5BB9\uFF1A${remoteDeleted.map((file) => file.localPath).join(", ")}\u3002\u672A\u91CD\u5EFA\u540C\u6B65\u57FA\u7EBF\u3002`,
|
|
10522
|
+
context: {
|
|
10523
|
+
reason: "WORKSPACE_REMOTE_FILE_DELETED",
|
|
10524
|
+
paths: remoteDeleted.map((file) => file.localPath),
|
|
10525
|
+
nextStep: "\u4FDD\u7559\u5F53\u524D\u76EE\u5F55\uFF0Cpull \u5230\u65B0\u7684\u7A7A\u76EE\u5F55\u6838\u5BF9\u8FDC\u7AEF\u5220\u9664\u610F\u56FE\uFF1B\u660E\u786E\u9700\u8981\u6062\u590D\u7684\u5185\u5BB9\u518D\u5408\u5E76\u5230\u65B0\u76EE\u5F55\uFF0C\u5148 push --dry-run \u6838\u5BF9\u3002"
|
|
10526
|
+
}
|
|
10527
|
+
});
|
|
10528
|
+
}
|
|
10510
10529
|
await fs9.mkdir(rootDir, { recursive: true });
|
|
10511
|
-
await
|
|
10512
|
-
|
|
10530
|
+
await fs9.mkdir(path10.join(rootDir, WORKSPACE_STATE_DIR), { recursive: true });
|
|
10531
|
+
await fs9.writeFile(
|
|
10532
|
+
path10.join(rootDir, WORKSPACE_STATE_DIR, WORKSPACE_PULL_INCOMPLETE_FILE),
|
|
10533
|
+
JSON.stringify(context, null, 2) + "\n"
|
|
10534
|
+
);
|
|
10513
10535
|
const miniApps = detectRemoteMiniApps(files.data);
|
|
10514
10536
|
const pulledMiniApps = [];
|
|
10515
10537
|
for (const appCode of miniApps) {
|
|
@@ -10520,7 +10542,7 @@ async function workspacePullCommand(args) {
|
|
|
10520
10542
|
targetDir: path10.join(rootDir, MINI_APPS_DIR, appCode),
|
|
10521
10543
|
tenantId: client3.tenantId,
|
|
10522
10544
|
endpoint: client3.endpoint,
|
|
10523
|
-
profile:
|
|
10545
|
+
profile: context.profile,
|
|
10524
10546
|
force: !!args.force
|
|
10525
10547
|
});
|
|
10526
10548
|
pulledMiniApps.push(result);
|
|
@@ -10529,20 +10551,34 @@ async function workspacePullCommand(args) {
|
|
|
10529
10551
|
(file) => !isDirectoryMarker(file.relativePath) && !isMiniAppPath(file.relativePath)
|
|
10530
10552
|
);
|
|
10531
10553
|
const pulledRawFiles = [];
|
|
10532
|
-
const
|
|
10554
|
+
const snapshots = [];
|
|
10533
10555
|
for (const file of rawFiles) {
|
|
10534
10556
|
const content = await loadWorkspaceFileContent(client3.raw(), file.id);
|
|
10557
|
+
if (content.workspaceKey !== workspaceKey || content.relativePath !== file.relativePath) {
|
|
10558
|
+
throw new CliError26({
|
|
10559
|
+
code: CliErrorCode27.NETWORK_ERROR,
|
|
10560
|
+
message: `load-content \u56DE\u6267\u4E0E\u76EE\u6807\u5DE5\u4F5C\u533A\u6216\u6587\u4EF6\u4E0D\u7B26\uFF1A${file.relativePath}`,
|
|
10561
|
+
context: {
|
|
10562
|
+
reason: "INVALID_WORKSPACE_FILE_CONTENT",
|
|
10563
|
+
nextStep: "\u6838\u5BF9\u6587\u4EF6\u5217\u8868\u548C load-content \u56DE\u6267\u540E\u91CD\u8BD5\uFF1B\u672C\u6B21\u672A\u66F4\u65B0\u540C\u6B65\u57FA\u7EBF\u3002"
|
|
10564
|
+
}
|
|
10565
|
+
});
|
|
10566
|
+
}
|
|
10535
10567
|
const target = path10.join(rootDir, content.relativePath);
|
|
10536
10568
|
await writeTextFile(target, content.content, !!args.force);
|
|
10537
10569
|
pulledRawFiles.push(content.relativePath);
|
|
10538
|
-
|
|
10570
|
+
snapshots.push({
|
|
10571
|
+
localPath: file.relativePath,
|
|
10572
|
+
remotePath: file.relativePath,
|
|
10573
|
+
fileId: file.id,
|
|
10574
|
+
sha256: sha2563(content.content),
|
|
10575
|
+
size: Buffer.byteLength(content.content, "utf8"),
|
|
10576
|
+
lastModified: file.lastModified
|
|
10577
|
+
});
|
|
10539
10578
|
}
|
|
10540
|
-
await writeWorkspaceRawState(
|
|
10541
|
-
|
|
10542
|
-
|
|
10543
|
-
await readWorkspaceRawLocalFiles(rootDir),
|
|
10544
|
-
rawRemoteByLocalPath
|
|
10545
|
-
);
|
|
10579
|
+
await writeWorkspaceRawState(rootDir, context, snapshots);
|
|
10580
|
+
await writeWorkspaceContext(rootDir, context);
|
|
10581
|
+
await fs9.unlink(path10.join(rootDir, WORKSPACE_STATE_DIR, WORKSPACE_PULL_INCOMPLETE_FILE));
|
|
10546
10582
|
writeWorkspacePullResult(
|
|
10547
10583
|
{
|
|
10548
10584
|
workspaceKey,
|
|
@@ -10552,7 +10588,8 @@ async function workspacePullCommand(args) {
|
|
|
10552
10588
|
appCode: item.appCode,
|
|
10553
10589
|
files: item.files.length
|
|
10554
10590
|
})),
|
|
10555
|
-
rawFiles: pulledRawFiles
|
|
10591
|
+
rawFiles: pulledRawFiles,
|
|
10592
|
+
preservedLocalFiles: localFiles.filter((file) => !remotePaths.has(file.localPath)).map((file) => file.localPath)
|
|
10556
10593
|
},
|
|
10557
10594
|
args.output ?? "table"
|
|
10558
10595
|
);
|
|
@@ -10625,29 +10662,28 @@ async function workspaceRmCommand(relativePath, args) {
|
|
|
10625
10662
|
throw new Error(`workspace rm refuses non-regular files: ${normalized}`);
|
|
10626
10663
|
}
|
|
10627
10664
|
const manifest2 = await readWorkspaceRawManifest(rootDir, context);
|
|
10628
|
-
let manifestEntry = manifest2.
|
|
10629
|
-
if (!manifestEntry
|
|
10630
|
-
const client3 = await
|
|
10631
|
-
|
|
10632
|
-
|
|
10633
|
-
|
|
10634
|
-
|
|
10635
|
-
|
|
10636
|
-
|
|
10637
|
-
|
|
10638
|
-
|
|
10639
|
-
|
|
10640
|
-
|
|
10641
|
-
|
|
10642
|
-
|
|
10643
|
-
|
|
10644
|
-
|
|
10645
|
-
|
|
10646
|
-
|
|
10647
|
-
|
|
10648
|
-
|
|
10649
|
-
|
|
10650
|
-
}
|
|
10665
|
+
let manifestEntry = workspaceRawBaselineByPath(manifest2).get(normalized);
|
|
10666
|
+
if (!manifestEntry) {
|
|
10667
|
+
const client3 = HcmClient23.fromAuthContext(await getActiveAuthContextFromCli(
|
|
10668
|
+
args,
|
|
10669
|
+
{ fallbackEnv: context.profile }
|
|
10670
|
+
));
|
|
10671
|
+
const remote = (await listWorkspaceFilesForSync(client3.raw(), context.workspaceKey)).data.find(
|
|
10672
|
+
(file) => file.relativePath === normalized
|
|
10673
|
+
);
|
|
10674
|
+
if (remote) {
|
|
10675
|
+
const content = await loadWorkspaceFileContent(client3.raw(), remote.id);
|
|
10676
|
+
manifestEntry = {
|
|
10677
|
+
localPath: normalized,
|
|
10678
|
+
remotePath: remote.relativePath,
|
|
10679
|
+
fileId: remote.id,
|
|
10680
|
+
sha256: sha2563(content.content),
|
|
10681
|
+
size: Buffer.byteLength(content.content, "utf8"),
|
|
10682
|
+
lastModified: remote.lastModified
|
|
10683
|
+
};
|
|
10684
|
+
manifest2.files = manifest2.files.filter((file) => file.localPath !== normalized);
|
|
10685
|
+
manifest2.files.push(manifestEntry);
|
|
10686
|
+
await writeWorkspaceRawManifest(rootDir, manifest2);
|
|
10651
10687
|
}
|
|
10652
10688
|
}
|
|
10653
10689
|
if (!stat) {
|
|
@@ -11087,7 +11123,22 @@ async function writeTextFile(file, content, force) {
|
|
|
11087
11123
|
await fs9.mkdir(path10.dirname(file), { recursive: true });
|
|
11088
11124
|
await fs9.writeFile(file, content);
|
|
11089
11125
|
}
|
|
11090
|
-
async function readWorkspaceRawManifest(rootDir, context) {
|
|
11126
|
+
async function readWorkspaceRawManifest(rootDir, context, forPull = false) {
|
|
11127
|
+
if (!forPull) {
|
|
11128
|
+
try {
|
|
11129
|
+
await fs9.access(path10.join(rootDir, WORKSPACE_STATE_DIR, WORKSPACE_PULL_INCOMPLETE_FILE));
|
|
11130
|
+
throw new CliError26({
|
|
11131
|
+
code: CliErrorCode27.BUSINESS_RULE_VIOLATION,
|
|
11132
|
+
message: "\u4E0A\u6B21 workspace pull \u672A\u5B8C\u6210\uFF0C\u672C\u5730\u53EF\u80FD\u6DF7\u6709\u4E0D\u540C\u76EE\u6807\u7684\u5185\u5BB9\uFF0C\u4E0D\u80FD\u7EE7\u7EED\u540C\u6B65\u3002",
|
|
11133
|
+
context: {
|
|
11134
|
+
reason: "WORKSPACE_PULL_INCOMPLETE",
|
|
11135
|
+
nextStep: `\u4FDD\u7559\u76EE\u5F55\u5E76\u5907\u4EFD\u672C\u5730\u4FEE\u6539\uFF1B\u67E5\u770B .hcm/${WORKSPACE_PULL_INCOMPLETE_FILE} \u4E2D\u7684\u76EE\u6807\uFF0C\u7528\u539F pull \u53C2\u6570\u6210\u529F\u91CD\u8BD5\u540E\u518D verify/push\u3002`
|
|
11136
|
+
}
|
|
11137
|
+
});
|
|
11138
|
+
} catch (e) {
|
|
11139
|
+
if (e.code !== "ENOENT") throw e;
|
|
11140
|
+
}
|
|
11141
|
+
}
|
|
11091
11142
|
try {
|
|
11092
11143
|
const parsed = JSON.parse(
|
|
11093
11144
|
await fs9.readFile(
|
|
@@ -11095,51 +11146,38 @@ async function readWorkspaceRawManifest(rootDir, context) {
|
|
|
11095
11146
|
"utf-8"
|
|
11096
11147
|
)
|
|
11097
11148
|
);
|
|
11098
|
-
if (parsed.version !== WORKSPACE_CONTEXT_VERSION || parsed.workspaceKey !== context.workspaceKey) {
|
|
11149
|
+
if (parsed.version !== WORKSPACE_CONTEXT_VERSION || parsed.workspaceKey !== context.workspaceKey && !forPull) {
|
|
11099
11150
|
throw new Error(
|
|
11100
11151
|
`${WORKSPACE_PULL_MANIFEST_FILE} does not match workspace ${context.workspaceKey}`
|
|
11101
11152
|
);
|
|
11102
11153
|
}
|
|
11103
|
-
return parsed;
|
|
11154
|
+
if (parsed.workspaceKey === context.workspaceKey) return parsed;
|
|
11104
11155
|
} catch (e) {
|
|
11105
11156
|
if (e.code !== "ENOENT") throw e;
|
|
11106
|
-
return {
|
|
11107
|
-
version: WORKSPACE_CONTEXT_VERSION,
|
|
11108
|
-
workspaceKey: context.workspaceKey,
|
|
11109
|
-
profile: context.profile,
|
|
11110
|
-
pulledAt: (/* @__PURE__ */ new Date(0)).toISOString(),
|
|
11111
|
-
files: []
|
|
11112
|
-
};
|
|
11113
11157
|
}
|
|
11158
|
+
return {
|
|
11159
|
+
version: WORKSPACE_CONTEXT_VERSION,
|
|
11160
|
+
workspaceKey: context.workspaceKey,
|
|
11161
|
+
profile: context.profile,
|
|
11162
|
+
endpoint: context.endpoint,
|
|
11163
|
+
tenantId: context.tenantId,
|
|
11164
|
+
pulledAt: (/* @__PURE__ */ new Date(0)).toISOString(),
|
|
11165
|
+
files: []
|
|
11166
|
+
};
|
|
11114
11167
|
}
|
|
11115
|
-
async function writeWorkspaceRawState(rootDir, context,
|
|
11116
|
-
|
|
11117
|
-
|
|
11118
|
-
|
|
11119
|
-
|
|
11120
|
-
|
|
11121
|
-
|
|
11122
|
-
|
|
11123
|
-
|
|
11124
|
-
|
|
11125
|
-
|
|
11126
|
-
|
|
11127
|
-
);
|
|
11128
|
-
await fs9.writeFile(
|
|
11129
|
-
path10.join(stateDir, WORKSPACE_PULL_MANIFEST_FILE),
|
|
11130
|
-
JSON.stringify(
|
|
11131
|
-
{
|
|
11132
|
-
version: WORKSPACE_CONTEXT_VERSION,
|
|
11133
|
-
workspaceKey: context.workspaceKey,
|
|
11134
|
-
profile: context.profile,
|
|
11135
|
-
pulledAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
11136
|
-
files: snapshots
|
|
11137
|
-
},
|
|
11138
|
-
null,
|
|
11139
|
-
2
|
|
11140
|
-
) + "\n",
|
|
11141
|
-
"utf-8"
|
|
11142
|
-
);
|
|
11168
|
+
async function writeWorkspaceRawState(rootDir, context, snapshots) {
|
|
11169
|
+
await writeWorkspaceRawManifest(rootDir, {
|
|
11170
|
+
version: WORKSPACE_CONTEXT_VERSION,
|
|
11171
|
+
workspaceKey: context.workspaceKey,
|
|
11172
|
+
profile: context.profile,
|
|
11173
|
+
endpoint: context.endpoint,
|
|
11174
|
+
tenantId: context.tenantId,
|
|
11175
|
+
pulledAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
11176
|
+
files: snapshots
|
|
11177
|
+
});
|
|
11178
|
+
}
|
|
11179
|
+
function workspaceRawBaselineByPath(manifest2) {
|
|
11180
|
+
return new Map(manifest2.files.filter((file) => typeof file.fileId === "string" && file.fileId.trim().length > 0).map((file) => [file.localPath, file]));
|
|
11143
11181
|
}
|
|
11144
11182
|
async function writeWorkspaceRawManifest(rootDir, manifest2) {
|
|
11145
11183
|
const stateDir = path10.join(rootDir, WORKSPACE_STATE_DIR);
|
|
@@ -11234,7 +11272,7 @@ ${formatPreflightIssues(result.preflight.issues, " ")}`,
|
|
|
11234
11272
|
}
|
|
11235
11273
|
if (plan.conflicts.length) return result;
|
|
11236
11274
|
const localByPath = new Map(localFiles.map((file) => [file.localPath, file]));
|
|
11237
|
-
const snapshots =
|
|
11275
|
+
const snapshots = workspaceRawBaselineByPath(manifest2);
|
|
11238
11276
|
const committed = [];
|
|
11239
11277
|
const operations = plan.operations;
|
|
11240
11278
|
for (const [index, operation] of operations.entries()) {
|
|
@@ -11451,8 +11489,36 @@ function formatPreflightSummary(preflight, indent2 = "") {
|
|
|
11451
11489
|
if (preflight.nextStep) lines.push(`${indent2} next: ${preflight.nextStep}`);
|
|
11452
11490
|
return lines.join("\n");
|
|
11453
11491
|
}
|
|
11454
|
-
async function
|
|
11492
|
+
async function listWorkspaceFilesForSync(http, workspaceKey) {
|
|
11455
11493
|
const list = await listWorkspaceFiles(http, workspaceKey, { pageSize: 5e3 });
|
|
11494
|
+
if (list.total !== list.data.length || new Set(list.data.map((file) => file.relativePath)).size !== list.data.length) {
|
|
11495
|
+
throw new CliError26({
|
|
11496
|
+
code: CliErrorCode27.NETWORK_ERROR,
|
|
11497
|
+
message: `\u5DE5\u4F5C\u533A\u8FDC\u7AEF\u6587\u4EF6\u6E05\u5355\u4E0D\u5B8C\u6574\uFF1A\u6536\u5230 ${list.data.length} \u6761\uFF0C\u603B\u6570 ${list.total}\uFF0C\u65E0\u6CD5\u5224\u5B9A\u6587\u4EF6\u662F\u5426\u7F3A\u5931\u3002`,
|
|
11498
|
+
context: {
|
|
11499
|
+
reason: "INCOMPLETE_WORKSPACE_FILE_LIST",
|
|
11500
|
+
nextStep: "\u68C0\u67E5\u670D\u52A1\u7AEF\u6587\u4EF6\u5217\u8868\u7684\u5206\u9875\u53CA\u54CD\u5E94\u5B8C\u6574\u6027\u540E\u91CD\u8BD5\uFF1B\u4FDD\u7559\u672C\u5730\u76EE\u5F55\u548C\u540C\u6B65\u57FA\u7EBF\u3002"
|
|
11501
|
+
}
|
|
11502
|
+
});
|
|
11503
|
+
}
|
|
11504
|
+
if (list.data.some((file) => {
|
|
11505
|
+
const relativePath = file.relativePath.replace(/\/$/, "");
|
|
11506
|
+
try {
|
|
11507
|
+
return !file.id.trim() || file.workspaceKey !== workspaceKey || normalizeRelativePath(relativePath) !== relativePath;
|
|
11508
|
+
} catch {
|
|
11509
|
+
return true;
|
|
11510
|
+
}
|
|
11511
|
+
})) {
|
|
11512
|
+
throw new CliError26({
|
|
11513
|
+
code: CliErrorCode27.NETWORK_ERROR,
|
|
11514
|
+
message: "\u5DE5\u4F5C\u533A\u6587\u4EF6\u5217\u8868\u542B\u6709\u65E0\u6548\u7684 ID\u3001\u5DE5\u4F5C\u533A\u6216\u6587\u4EF6\u8DEF\u5F84\u3002",
|
|
11515
|
+
context: { reason: "INVALID_WORKSPACE_FILE_LIST", nextStep: "\u6838\u5BF9\u76EE\u6807\u5DE5\u4F5C\u533A\u6587\u4EF6\u5217\u8868\u540E\u91CD\u8BD5\uFF1B\u4E0D\u80FD\u7528\u65E0\u6548\u8BB0\u5F55\u5224\u65AD\u8FDC\u7AEF\u5B58\u5728\u6027\u3002" }
|
|
11516
|
+
});
|
|
11517
|
+
}
|
|
11518
|
+
return list;
|
|
11519
|
+
}
|
|
11520
|
+
async function loadWorkspaceRawRemoteFiles(http, workspaceKey) {
|
|
11521
|
+
const list = await listWorkspaceFilesForSync(http, workspaceKey);
|
|
11456
11522
|
const result = [];
|
|
11457
11523
|
for (const item of list.data) {
|
|
11458
11524
|
if (isDirectoryMarker(item.relativePath) || isMiniAppPath(item.relativePath)) continue;
|
|
@@ -11463,7 +11529,7 @@ async function loadWorkspaceRawRemoteFiles(http, workspaceKey) {
|
|
|
11463
11529
|
}
|
|
11464
11530
|
function buildWorkspaceRawPushPlan(manifest2, localFiles, remoteFiles) {
|
|
11465
11531
|
const status = computeWorkspaceRawStatus(manifest2, localFiles);
|
|
11466
|
-
const baseByLocal =
|
|
11532
|
+
const baseByLocal = workspaceRawBaselineByPath(manifest2);
|
|
11467
11533
|
const remoteByLocal = new Map(remoteFiles.map((file) => [file.item.relativePath, file]));
|
|
11468
11534
|
const operations = [];
|
|
11469
11535
|
const conflicts = [];
|
|
@@ -11530,6 +11596,10 @@ function buildWorkspaceRawPushPlan(manifest2, localFiles, remoteFiles) {
|
|
|
11530
11596
|
}
|
|
11531
11597
|
continue;
|
|
11532
11598
|
}
|
|
11599
|
+
if (!remote) {
|
|
11600
|
+
conflicts.push(workspaceRawConflict(entry, "remote file was deleted after last pull"));
|
|
11601
|
+
continue;
|
|
11602
|
+
}
|
|
11533
11603
|
operations.push({
|
|
11534
11604
|
operation: "skip",
|
|
11535
11605
|
localPath: entry.localPath,
|
|
@@ -11541,7 +11611,7 @@ function buildWorkspaceRawPushPlan(manifest2, localFiles, remoteFiles) {
|
|
|
11541
11611
|
return { operations, conflicts };
|
|
11542
11612
|
}
|
|
11543
11613
|
function computeWorkspaceRawStatus(manifest2, localFiles) {
|
|
11544
|
-
const baseByLocal =
|
|
11614
|
+
const baseByLocal = workspaceRawBaselineByPath(manifest2);
|
|
11545
11615
|
const localByPath = new Map(localFiles.map((file) => [file.localPath, file]));
|
|
11546
11616
|
const paths = [.../* @__PURE__ */ new Set([...baseByLocal.keys(), ...localByPath.keys()])].sort();
|
|
11547
11617
|
return paths.map((localPath) => {
|
|
@@ -11863,8 +11933,10 @@ function writeWorkspacePullResult(result, format) {
|
|
|
11863
11933
|
`directory: ${result.rootDir}`,
|
|
11864
11934
|
`remote files: ${result.totalRemoteFiles}`,
|
|
11865
11935
|
`mini apps: ${result.miniApps.length}`,
|
|
11866
|
-
`raw files: ${result.rawFiles.length}
|
|
11936
|
+
`raw files: ${result.rawFiles.length}`,
|
|
11937
|
+
`preserved local-only files (added): ${result.preservedLocalFiles.length}`
|
|
11867
11938
|
];
|
|
11939
|
+
for (const file of result.preservedLocalFiles) lines.push(` + ${file}`);
|
|
11868
11940
|
if (result.miniApps.length) {
|
|
11869
11941
|
lines.push("mini artifacts:");
|
|
11870
11942
|
for (const app of result.miniApps) lines.push(` - ${app.appCode}: ${app.files} files`);
|
|
@@ -14385,6 +14457,24 @@ function classifyGitFailure(e, repoDisplay) {
|
|
|
14385
14457
|
}
|
|
14386
14458
|
function makeGitRunner(repoDisplay) {
|
|
14387
14459
|
return async (args, opts = {}) => {
|
|
14460
|
+
const env2 = { ...process.env, GIT_TERMINAL_PROMPT: "0", GCM_INTERACTIVE: "never" };
|
|
14461
|
+
for (const key2 of [
|
|
14462
|
+
"GIT_ALTERNATE_OBJECT_DIRECTORIES",
|
|
14463
|
+
"GIT_CONFIG",
|
|
14464
|
+
"GIT_CONFIG_PARAMETERS",
|
|
14465
|
+
"GIT_CONFIG_COUNT",
|
|
14466
|
+
"GIT_OBJECT_DIRECTORY",
|
|
14467
|
+
"GIT_DIR",
|
|
14468
|
+
"GIT_WORK_TREE",
|
|
14469
|
+
"GIT_IMPLICIT_WORK_TREE",
|
|
14470
|
+
"GIT_GRAFT_FILE",
|
|
14471
|
+
"GIT_INDEX_FILE",
|
|
14472
|
+
"GIT_NO_REPLACE_OBJECTS",
|
|
14473
|
+
"GIT_REPLACE_REF_BASE",
|
|
14474
|
+
"GIT_PREFIX",
|
|
14475
|
+
"GIT_SHALLOW_FILE",
|
|
14476
|
+
"GIT_COMMON_DIR"
|
|
14477
|
+
]) delete env2[key2];
|
|
14388
14478
|
try {
|
|
14389
14479
|
const pending = promisify2(execFile2)("git", args, {
|
|
14390
14480
|
cwd: opts.cwd,
|
|
@@ -14392,7 +14482,7 @@ function makeGitRunner(repoDisplay) {
|
|
|
14392
14482
|
maxBuffer: 1 << 26,
|
|
14393
14483
|
timeout: opts.timeoutMs ?? GIT_NETWORK_TIMEOUT_MS,
|
|
14394
14484
|
// 🔴 不许 git 停下来问口令:agent 跑它时没人回答,只会一直挂着。凭据缺就当场报认证失败。
|
|
14395
|
-
env:
|
|
14485
|
+
env: env2
|
|
14396
14486
|
});
|
|
14397
14487
|
pending.child.stdin?.end();
|
|
14398
14488
|
const { stdout } = await pending;
|
|
@@ -14447,7 +14537,17 @@ function latestVersionTag(tags) {
|
|
|
14447
14537
|
return [...tags.keys()].filter((t) => SEMVER_TAG.test(t)).sort(compareTags).pop();
|
|
14448
14538
|
}
|
|
14449
14539
|
async function listRemoteTags(deps) {
|
|
14450
|
-
|
|
14540
|
+
const context = await fsp4.mkdtemp(path13.join(os5.tmpdir(), "hcm-method-tags-"));
|
|
14541
|
+
try {
|
|
14542
|
+
await deps.git(["init", "--quiet", context], { timeoutMs: 1e4 });
|
|
14543
|
+
await deps.git(["remote", "add", "origin", deps.repoUrl], { cwd: context, timeoutMs: 1e4 });
|
|
14544
|
+
return parseLsRemoteTags(await deps.git(["ls-remote", "--tags", deps.repoUrl], {
|
|
14545
|
+
cwd: context,
|
|
14546
|
+
timeoutMs: GIT_LS_REMOTE_TIMEOUT_MS
|
|
14547
|
+
}));
|
|
14548
|
+
} finally {
|
|
14549
|
+
await fsp4.rm(context, { recursive: true, force: true });
|
|
14550
|
+
}
|
|
14451
14551
|
}
|
|
14452
14552
|
function resolveRef(tags, ref, deps) {
|
|
14453
14553
|
const versions = [...tags.keys()].filter((t) => SEMVER_TAG.test(t)).sort(compareTags).reverse();
|