@lumi-ai-lab/harness-data 0.0.11 → 0.0.12
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/package.json +1 -1
- package/src/commands/update.js +14 -6
package/package.json
CHANGED
package/src/commands/update.js
CHANGED
|
@@ -7,6 +7,7 @@ import { installToolsFromManifest, manifestDigest, readManifest } from "../lib/m
|
|
|
7
7
|
import { packageVersion } from "../lib/package.js";
|
|
8
8
|
import { platformKey } from "../lib/platform.js";
|
|
9
9
|
import { githubToken, latestRelease } from "../lib/github.js";
|
|
10
|
+
import { protocolFromUrl, runGitWithProtocol } from "../lib/git-auth.js";
|
|
10
11
|
import { buildAndCheck, installRuntimeBundle, printDoctorSummary } from "./install.js";
|
|
11
12
|
import { collectDoctor } from "./doctor.js";
|
|
12
13
|
import { action, blank, header, ok, shortSha, skip, step, warn } from "../lib/log.js";
|
|
@@ -87,7 +88,14 @@ async function maybeUpdateTool(runtimeDir, manifest, tool, options, state) {
|
|
|
87
88
|
return result;
|
|
88
89
|
}
|
|
89
90
|
|
|
90
|
-
async function
|
|
91
|
+
async function updateWikisGit(wikisDir, args, options) {
|
|
92
|
+
const remote = (await run("git", ["-C", wikisDir, "remote", "get-url", "origin"], { ...options, allowFailure: true })).stdout.trim();
|
|
93
|
+
const protocol = protocolFromUrl(remote);
|
|
94
|
+
if (!protocol) return run("git", ["-C", wikisDir, ...args], options);
|
|
95
|
+
return runGitWithProtocol(protocol, ["-C", wikisDir, ...args], options);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export async function updateWikis(runtimeDir, options, state) {
|
|
91
99
|
const wikisDir = path.join(runtimeDir, "wikis");
|
|
92
100
|
if (!githubToken(options) && state.installMode !== "github-token") {
|
|
93
101
|
skip("harness-data-wikis 为本地路径模式,请手动检查");
|
|
@@ -97,9 +105,9 @@ async function updateWikis(runtimeDir, options, state) {
|
|
|
97
105
|
skip("harness-data-wikis 不是 git checkout");
|
|
98
106
|
return null;
|
|
99
107
|
}
|
|
100
|
-
await
|
|
101
|
-
const local = (await run("git", ["-C", wikisDir, "rev-parse", "HEAD"])).stdout.trim();
|
|
102
|
-
const remote = (await run("git", ["-C", wikisDir, "rev-parse", "origin/HEAD"], { allowFailure: true })).stdout.trim();
|
|
108
|
+
await updateWikisGit(wikisDir, ["fetch", "origin"], options);
|
|
109
|
+
const local = (await run("git", ["-C", wikisDir, "rev-parse", "HEAD"], options)).stdout.trim();
|
|
110
|
+
const remote = (await run("git", ["-C", wikisDir, "rev-parse", "origin/HEAD"], { ...options, allowFailure: true })).stdout.trim();
|
|
103
111
|
if (!remote || local === remote) {
|
|
104
112
|
ok(`harness-data-wikis 已是最新 ${shortSha(local)}`);
|
|
105
113
|
return null;
|
|
@@ -110,8 +118,8 @@ async function updateWikis(runtimeDir, options, state) {
|
|
|
110
118
|
options.skippedUpdates?.push(`harness-data-wikis ${shortSha(remote)}`);
|
|
111
119
|
return null;
|
|
112
120
|
}
|
|
113
|
-
await
|
|
114
|
-
const commit = (await run("git", ["-C", wikisDir, "rev-parse", "HEAD"])).stdout.trim();
|
|
121
|
+
await updateWikisGit(wikisDir, ["pull", "--ff-only"], options);
|
|
122
|
+
const commit = (await run("git", ["-C", wikisDir, "rev-parse", "HEAD"], options)).stdout.trim();
|
|
115
123
|
ok(`harness-data-wikis 已更新到 ${shortSha(commit)}`);
|
|
116
124
|
return { commit };
|
|
117
125
|
}
|