@lumi-ai-lab/harness-data 0.0.17 → 0.0.19
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/doctor.js +5 -3
- package/src/commands/install.js +12 -6
- package/src/lib/config.js +1 -1
- package/src/lib/github.js +17 -3
package/package.json
CHANGED
package/src/commands/doctor.js
CHANGED
|
@@ -61,9 +61,11 @@ export async function collectDoctor(workspace, options = {}) {
|
|
|
61
61
|
const add = (name, ok, detail = "") => checks.push({ name, ok, detail });
|
|
62
62
|
|
|
63
63
|
add("runtime", fs.existsSync(path.join(workspace, "bootstrap", "cli-manifest.json")) && fs.existsSync(path.join(workspace, "agents")), workspace);
|
|
64
|
-
add("wikis/
|
|
65
|
-
add("wikis/
|
|
66
|
-
add("wikis/
|
|
64
|
+
add("wikis/index.md", fs.existsSync(path.join(workspace, "wikis", "index.md")));
|
|
65
|
+
add("wikis/metrics", fs.existsSync(path.join(workspace, "wikis", "metrics")));
|
|
66
|
+
add("wikis/reports", fs.existsSync(path.join(workspace, "wikis", "reports")));
|
|
67
|
+
add("wikis/dims", fs.existsSync(path.join(workspace, "wikis", "dims")));
|
|
68
|
+
add("wikis/rules", fs.existsSync(path.join(workspace, "wikis", "rules")));
|
|
67
69
|
for (const binary of ["data-harness-cli", "qdm-cmr-cli", "qdm-indicators-cli", "cas-cli"]) {
|
|
68
70
|
add(`bin/${binary}`, existsExecutable(path.join(workspace, "bin", binaryName(binary))));
|
|
69
71
|
}
|
package/src/commands/install.js
CHANGED
|
@@ -179,15 +179,20 @@ async function installWikis(runtimeDir, options = {}) {
|
|
|
179
179
|
|
|
180
180
|
const auto = path.join(runtimeDir, "harness-data-wikis");
|
|
181
181
|
const source = fs.existsSync(auto) ? auto : path.resolve(await ask("请输入 harness-data-wikis 的绝对路径:", options));
|
|
182
|
-
|
|
183
|
-
if (!fs.existsSync(path.join(source, dir))) throw new Error(`harness-data-wikis missing ${dir}/: ${source}`);
|
|
184
|
-
}
|
|
182
|
+
validateLocalWikisSource(source);
|
|
185
183
|
fs.rmSync(target, { recursive: true, force: true });
|
|
186
184
|
fs.cpSync(source, target, { recursive: true });
|
|
187
185
|
ok(`harness-data-wikis 本地路径 ${source}`);
|
|
188
186
|
return { mode: "local-path", source, path: target };
|
|
189
187
|
}
|
|
190
188
|
|
|
189
|
+
export function validateLocalWikisSource(source) {
|
|
190
|
+
if (!fs.existsSync(path.join(source, "index.md"))) throw new Error(`harness-data-wikis missing index.md: ${source}`);
|
|
191
|
+
for (const dir of ["metrics", "reports", "dims", "rules"]) {
|
|
192
|
+
if (!fs.existsSync(path.join(source, dir))) throw new Error(`harness-data-wikis missing ${dir}/: ${source}`);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
191
196
|
function casConfigDir(runtimeDir) {
|
|
192
197
|
return path.join(runtimeDir, ".qdm-auth", "cas");
|
|
193
198
|
}
|
|
@@ -239,9 +244,10 @@ export function printDoctorSummary(doctor, options = {}) {
|
|
|
239
244
|
const warnings = doctor.checks.filter((check) => !check.ok && nonBlocking(check));
|
|
240
245
|
if (!failed.length) {
|
|
241
246
|
ok("runtime");
|
|
242
|
-
ok("wikis/
|
|
243
|
-
ok("wikis/
|
|
244
|
-
ok("wikis/
|
|
247
|
+
ok("wikis/metrics");
|
|
248
|
+
ok("wikis/reports");
|
|
249
|
+
ok("wikis/dims");
|
|
250
|
+
ok("wikis/rules");
|
|
245
251
|
ok("4 个 CLI");
|
|
246
252
|
ok("本地配置");
|
|
247
253
|
ok("CAS 凭证");
|
package/src/lib/config.js
CHANGED
|
@@ -31,7 +31,7 @@ export function writeLocalConfig(workspace, options = {}) {
|
|
|
31
31
|
}
|
|
32
32
|
const bin = (name) => path.join(workspace, "bin", binaryName(name)).replaceAll("\\", "/");
|
|
33
33
|
const casConfigDir = path.join(workspace, ".qdm-auth", "cas").replaceAll("\\", "/");
|
|
34
|
-
fs.writeFileSync(harness, `paths:\n
|
|
34
|
+
fs.writeFileSync(harness, `paths:\n knowledge: wikis\n\ncli:\n qdm_cmr_cli: ${bin("qdm-cmr-cli")}\n qdm_indicators_cli: ${bin("qdm-indicators-cli")}\n qdm_cas_cli: ${bin("cas-cli")}\n`);
|
|
35
35
|
fs.writeFileSync(env, `export QDM_CMR_CLI="${bin("qdm-cmr-cli")}"\nexport QDM_INDICATORS_CLI="${bin("qdm-indicators-cli")}"\nexport QDM_CAS_CLI="${bin("cas-cli")}"\nexport QDM_CAS_CONFIG_DIR="${casConfigDir}"\n`);
|
|
36
36
|
}
|
|
37
37
|
|
package/src/lib/github.js
CHANGED
|
@@ -47,11 +47,25 @@ export function findReleaseAsset(release, name) {
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
export async function downloadReleaseAsset(asset, file, options = {}) {
|
|
50
|
-
const
|
|
51
|
-
await download(asset.url, file, headers, {
|
|
50
|
+
const downloadOptions = {
|
|
52
51
|
progressLabel: options.progressLabel,
|
|
53
52
|
log: options.log,
|
|
54
53
|
progress: options.progress,
|
|
55
54
|
progressWriter: options.progressWriter
|
|
56
|
-
}
|
|
55
|
+
};
|
|
56
|
+
const publicUrl = asset.browser_download_url || asset.url;
|
|
57
|
+
const token = githubToken(options);
|
|
58
|
+
|
|
59
|
+
if (token) {
|
|
60
|
+
const headers = { ...githubHeaders(options), Accept: "application/octet-stream" };
|
|
61
|
+
try {
|
|
62
|
+
await download(asset.url, file, headers, downloadOptions);
|
|
63
|
+
return;
|
|
64
|
+
} catch (error) {
|
|
65
|
+
fs.rmSync(file, { force: true });
|
|
66
|
+
if (!asset.browser_download_url) throw error;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
await download(publicUrl, file, { "User-Agent": userAgent }, downloadOptions);
|
|
57
71
|
}
|