@kaiba-cloud/cli 0.2.1 → 1.0.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/dist/cli.js +30 -6
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1297,7 +1297,7 @@ var HubClient = class {
|
|
|
1297
1297
|
};
|
|
1298
1298
|
|
|
1299
1299
|
// src/version.ts
|
|
1300
|
-
var CLI_VERSION = true ? "0.
|
|
1300
|
+
var CLI_VERSION = true ? "1.0.0" : "0.0.0-dev";
|
|
1301
1301
|
|
|
1302
1302
|
// src/commands/auth.ts
|
|
1303
1303
|
function peekNonInteractive(context) {
|
|
@@ -8812,6 +8812,8 @@ function renderRootHelp(registry) {
|
|
|
8812
8812
|
}
|
|
8813
8813
|
|
|
8814
8814
|
// src/cli.ts
|
|
8815
|
+
import { realpathSync as realpathSync2 } from "node:fs";
|
|
8816
|
+
import { pathToFileURL } from "node:url";
|
|
8815
8817
|
var DEFAULT_HUB_URL = "https://cloud.kaiba.ai";
|
|
8816
8818
|
function peekFlag(argv, name) {
|
|
8817
8819
|
for (let index = 0; index < argv.length; index += 1) {
|
|
@@ -8914,12 +8916,24 @@ async function run3(options) {
|
|
|
8914
8916
|
return error.exitCode;
|
|
8915
8917
|
}
|
|
8916
8918
|
const message2 = error instanceof Error ? error.message : String(error);
|
|
8917
|
-
output.failure(
|
|
8918
|
-
new CliError({ code: "internal", message: message2, exitCode: ExitCode.Error })
|
|
8919
|
-
);
|
|
8919
|
+
output.failure(toCliError(error, message2));
|
|
8920
8920
|
return ExitCode.Error;
|
|
8921
8921
|
}
|
|
8922
8922
|
}
|
|
8923
|
+
function toCliError(error, message2) {
|
|
8924
|
+
const cause = error?.cause;
|
|
8925
|
+
const isConnectionFailure = message2 === "fetch failed" || typeof cause?.code === "string" && ["ECONNREFUSED", "ENOTFOUND", "ETIMEDOUT", "ECONNRESET", "EAI_AGAIN", "UND_ERR_CONNECT_TIMEOUT"].includes(cause.code);
|
|
8926
|
+
if (!isConnectionFailure) {
|
|
8927
|
+
return new CliError({ code: "internal", message: message2, exitCode: ExitCode.Error });
|
|
8928
|
+
}
|
|
8929
|
+
return new CliError({
|
|
8930
|
+
code: "hub-unavailable",
|
|
8931
|
+
message: `Could not reach the hub${cause?.code ? ` (${cause.code})` : ""}.`,
|
|
8932
|
+
exitCode: ExitCode.Error,
|
|
8933
|
+
hint: "Check the hub is running and that the URL is right \u2014 `kaiba whoami` reports the one in use. Nothing was changed.",
|
|
8934
|
+
...cause?.code && { details: { cause: cause.code } }
|
|
8935
|
+
});
|
|
8936
|
+
}
|
|
8923
8937
|
async function maybeNotifyUpgrade(options) {
|
|
8924
8938
|
const { argv, streams, env, isTty, mode, quiet, context } = options;
|
|
8925
8939
|
const eligible = shouldCheck({
|
|
@@ -8956,8 +8970,18 @@ async function main() {
|
|
|
8956
8970
|
});
|
|
8957
8971
|
process.exitCode = code;
|
|
8958
8972
|
}
|
|
8959
|
-
|
|
8960
|
-
|
|
8973
|
+
function invokedDirectly() {
|
|
8974
|
+
const entry = process.argv[1];
|
|
8975
|
+
if (!entry) {
|
|
8976
|
+
return false;
|
|
8977
|
+
}
|
|
8978
|
+
try {
|
|
8979
|
+
return import.meta.url === pathToFileURL(realpathSync2(entry)).href;
|
|
8980
|
+
} catch {
|
|
8981
|
+
return false;
|
|
8982
|
+
}
|
|
8983
|
+
}
|
|
8984
|
+
if (invokedDirectly()) {
|
|
8961
8985
|
void main();
|
|
8962
8986
|
}
|
|
8963
8987
|
export {
|