feat: update kpxcenv.ts
This commit is contained in:
@@ -17,12 +17,12 @@
|
||||
},
|
||||
"kpxcenv.ts": {
|
||||
"script_name": "kpxcenv.ts",
|
||||
"script_length": 3622,
|
||||
"script_sha256": "e2e35aa9a535837a7f663c0b35857d78c178b96451d24be3137dcc0e783cce9c",
|
||||
"script_length": 3571,
|
||||
"script_sha256": "f935fb98d2601039aaa9dd1f2499d6c5b46a9ebba41230b541efb06451a4051f",
|
||||
"script_full_url": "https://git.hatter.ink/hatter/ts-scripts/raw/branch/main/single-scripts/kpxcenv.ts",
|
||||
"single_script_file": true,
|
||||
"publish_time": 1737272626141,
|
||||
"update_time": 1737272626141
|
||||
"update_time": 1737275834687
|
||||
},
|
||||
"print-env.ts": {
|
||||
"script_name": "print-env.ts",
|
||||
|
||||
@@ -6,7 +6,11 @@
|
||||
// - https://docs.deno.com/api/deno/~/Deno.CommandOptions
|
||||
// - https://github.com/aliyun/aliyun-cli
|
||||
|
||||
import {compareVersion, isEnvOn,} from "https://hatter.ink/script/fetch/library/deno-commons-mod.ts";
|
||||
import {
|
||||
compareVersion,
|
||||
isEnvOn,
|
||||
log,
|
||||
} from "https://hatter.ink/script/fetch/library/deno-commons-mod.ts?202501191623";
|
||||
|
||||
const args = Deno.args;
|
||||
if (args.length == 0) {
|
||||
@@ -32,11 +36,11 @@ const xdrRuntimeDir = Deno.env.get("XDG_RUNTIME_DIR");
|
||||
if (xdrRuntimeDir == null) {
|
||||
const tmpdir = Deno.env.get("TMPDIR");
|
||||
if (tmpdir == null) {
|
||||
console.error("[ERROR] Environment XDG_RUNTIME_DIR is not set.");
|
||||
log.error("Environment XDG_RUNTIME_DIR is not set.");
|
||||
Deno.exit(1);
|
||||
}
|
||||
if (isDebug) {
|
||||
console.debug("[DEBUG] Set env XDG_RUNTIME_DIR=" + tmpdir);
|
||||
log.debug("Set env XDG_RUNTIME_DIR=" + tmpdir);
|
||||
}
|
||||
Deno.env.set("XDG_RUNTIME_DIR", tmpdir);
|
||||
}
|
||||
@@ -44,7 +48,7 @@ const shellCommand = Deno.env.get("KPXC_SHELL") || "bash";
|
||||
const region = Deno.env.get("KPXC_REGION") || "cn-hangzhou";
|
||||
|
||||
if (compareVersion(Deno.version.deno, "1.18.0") < 0) {
|
||||
console.error("[ERROR] Require deno version >= 1.18.0 .");
|
||||
log.error("Require deno version >= 1.18.0 .");
|
||||
Deno.exit(1);
|
||||
}
|
||||
|
||||
@@ -61,8 +65,8 @@ async function commandExists(cmd: string): Promise<boolean> {
|
||||
}
|
||||
|
||||
if (!await commandExists(KEEPASSXC_PROXY_COMMAND)) {
|
||||
console.error(
|
||||
"[ERROR] Command kpxcpc is not installed, please install from: https://github.com/nwwdles/kpxcpc",
|
||||
log.error(
|
||||
"Command kpxcpc is not installed, please install from: https://github.com/nwwdles/kpxcpc",
|
||||
);
|
||||
Deno.exit(1);
|
||||
}
|
||||
@@ -86,14 +90,14 @@ const kpxcpcCmdStdoutString = new TextDecoder().decode(kpxcpcCmdStdout);
|
||||
const kpxcpcCmdJsonObjects = JSON.parse(kpxcpcCmdStdoutString);
|
||||
|
||||
if (kpxcpcCmdJsonObjects.length == 0) {
|
||||
console.error(
|
||||
"[ERROR] Should not happen, since KeepassXC return JSON array is empty.",
|
||||
log.error(
|
||||
"Should not happen, since KeepassXC return JSON array is empty.",
|
||||
);
|
||||
Deno.exit(1);
|
||||
}
|
||||
if (kpxcpcCmdJsonObjects.length > 1) {
|
||||
console.warn(
|
||||
"[WARN] Get more than one vaule from KeepassXC, default use the first.",
|
||||
log.warn(
|
||||
"Get more than one vaule from KeepassXC, default use the first.",
|
||||
);
|
||||
}
|
||||
const kpxcpcCmdJsonObject = kpxcpcCmdJsonObjects[0];
|
||||
@@ -103,7 +107,7 @@ const accessKeyId = kpxcpcCmdJsonObject.login;
|
||||
const accessKeySecret = kpxcpcCmdJsonObject.password;
|
||||
|
||||
if (isDebug) {
|
||||
console.debug("[DEBUG] Found object: ", kpxcpcCmdJsonObject);
|
||||
log.debug("Found object: ", kpxcpcCmdJsonObject);
|
||||
}
|
||||
|
||||
const command = new Deno.Command(shellCommand, {
|
||||
|
||||
Reference in New Issue
Block a user