hunter-harness 0.2.2 → 0.2.4
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/bin.js +28 -2
- package/package.json +1 -1
package/dist/bin.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// src/bin.ts
|
|
4
|
+
import { realpathSync } from "node:fs";
|
|
4
5
|
import { pathToFileURL } from "node:url";
|
|
5
6
|
import { createInterface } from "node:readline/promises";
|
|
6
7
|
import { Command, CommanderError } from "commander";
|
|
@@ -5150,11 +5151,27 @@ async function resolveWorkflowResourcesRoot(options, argv = []) {
|
|
|
5150
5151
|
} catch (error) {
|
|
5151
5152
|
if (error instanceof WorkflowDataResolutionError) throw error;
|
|
5152
5153
|
throw new WorkflowDataResolutionError(
|
|
5153
|
-
|
|
5154
|
+
describeWorkflowDataFetchFailure(error, packageSpec),
|
|
5154
5155
|
"WORKFLOW_DATA_UNAVAILABLE"
|
|
5155
5156
|
);
|
|
5156
5157
|
}
|
|
5157
5158
|
}
|
|
5159
|
+
function describeWorkflowDataFetchFailure(error, packageSpec) {
|
|
5160
|
+
const detailRaw = error instanceof Error ? error.message : String(error);
|
|
5161
|
+
const detail = detailRaw.length > 240 ? detailRaw.slice(0, 240) + "\u2026" : detailRaw;
|
|
5162
|
+
const code = error !== null && typeof error === "object" && "code" in error ? String(error.code) : "";
|
|
5163
|
+
const hintRoot = "\u8BBE\u7F6E HUNTER_HARNESS_RESOURCES_ROOT \u6307\u5411\u542B harness/ \u7684\u76EE\u5F55";
|
|
5164
|
+
if (code === "ERR_MODULE_NOT_FOUND" || /Cannot find package ['"]pacote['"]/i.test(detailRaw)) {
|
|
5165
|
+
return `\u65E0\u6CD5\u83B7\u53D6\u5DE5\u4F5C\u6D41\u6570\u636E\u5305 ${packageSpec}\uFF1A\u7F3A\u5C11\u53EF\u9009\u4F9D\u8D56 pacote\uFF08npx/npm \u5B89\u88C5 CLI \u65F6\u672A\u88C5\u4E0A\uFF09\u3002\u8BF7\u91CD\u88C5 hunter-harness\uFF0C\u6216${hintRoot}\u3002\u539F\u56E0\uFF1A${detail}`;
|
|
5166
|
+
}
|
|
5167
|
+
if (code === "ECONNRESET" || code === "ETIMEDOUT" || code === "ENOTFOUND" || code === "EAI_AGAIN" || code === "ECONNREFUSED" || /ECONNRESET|ETIMEDOUT|socket disconnected|TLS connection/i.test(detailRaw)) {
|
|
5168
|
+
return `\u65E0\u6CD5\u83B7\u53D6\u5DE5\u4F5C\u6D41\u6570\u636E\u5305 ${packageSpec}\uFF1A\u4ECE npm \u4E0B\u8F7D\u5931\u8D25\uFF08\u7F51\u7EDC/TLS\uFF09\u3002\u53EF\u5148\u8BBE\u7F6E NODE_OPTIONS=--dns-result-order=ipv4first \u540E\u91CD\u8BD5\uFF0C\u6216${hintRoot}\u3002\u539F\u56E0\uFF1A${code !== "" ? code + " " : ""}${detail}`;
|
|
5169
|
+
}
|
|
5170
|
+
if (code === "E404" || /\b404\b|Not Found/i.test(detailRaw)) {
|
|
5171
|
+
return `\u65E0\u6CD5\u83B7\u53D6\u5DE5\u4F5C\u6D41\u6570\u636E\u5305 ${packageSpec}\uFF1Anpm \u4E0A\u627E\u4E0D\u5230\u8BE5\u5305\u6216\u65E0\u6743\u8BBF\u95EE\u3002\u8BF7\u786E\u8BA4\u5DF2\u53D1\u5E03\u5BF9\u5E94 scope \u7684 workflow \u6570\u636E\u5305\uFF0C\u6216${hintRoot}\u3002\u539F\u56E0\uFF1A${detail}`;
|
|
5172
|
+
}
|
|
5173
|
+
return `\u65E0\u6CD5\u83B7\u53D6\u5DE5\u4F5C\u6D41\u6570\u636E\u5305 ${packageSpec}\uFF1A\u672C\u5730\u7F13\u5B58\u4E0D\u5B58\u5728\u4E14\u83B7\u53D6\u5931\u8D25\u3002\u53EF${hintRoot}\u3002\u539F\u56E0\uFF1A${code !== "" ? code + " " : ""}${detail}`;
|
|
5174
|
+
}
|
|
5158
5175
|
async function readWorkflowFamilyManifest(resourcesRoot) {
|
|
5159
5176
|
const manifestPath = join16(resourcesRoot, "hunter-workflow-family.json");
|
|
5160
5177
|
if (!await pathExists3(manifestPath)) return {};
|
|
@@ -5246,9 +5263,18 @@ async function runCli(argv, overrides = {}) {
|
|
|
5246
5263
|
throw error;
|
|
5247
5264
|
}
|
|
5248
5265
|
}
|
|
5249
|
-
|
|
5266
|
+
function isDirectCliEntrypoint(entry = process.argv[1], metaUrl = import.meta.url) {
|
|
5267
|
+
if (entry === void 0) return false;
|
|
5268
|
+
try {
|
|
5269
|
+
return metaUrl === pathToFileURL(realpathSync(entry)).href;
|
|
5270
|
+
} catch {
|
|
5271
|
+
return metaUrl === pathToFileURL(entry).href;
|
|
5272
|
+
}
|
|
5273
|
+
}
|
|
5274
|
+
if (isDirectCliEntrypoint()) {
|
|
5250
5275
|
process.exitCode = await runCli(process.argv.slice(2));
|
|
5251
5276
|
}
|
|
5252
5277
|
export {
|
|
5278
|
+
isDirectCliEntrypoint,
|
|
5253
5279
|
runCli
|
|
5254
5280
|
};
|