♻️ Refactor import statements and update script metadata for improved readability and dependency management
This commit is contained in:
@@ -6,15 +6,7 @@ import { encodeBase32 } from "jsr:@std/encoding/base32";
|
|||||||
import {dirname, fromFileUrl} from "jsr:@std/path";
|
import {dirname, fromFileUrl} from "jsr:@std/path";
|
||||||
import {toArrayBuffer} from "jsr:@std/streams";
|
import {toArrayBuffer} from "jsr:@std/streams";
|
||||||
import {spawn, SpawnOptionsWithoutStdio} from "node:child_process";
|
import {spawn, SpawnOptionsWithoutStdio} from "node:child_process";
|
||||||
import {
|
import {createWriteStream, mkdir, readFile, readFileSync, rm, stat, writeFile,} from "node:fs";
|
||||||
createWriteStream,
|
|
||||||
mkdir,
|
|
||||||
readFile,
|
|
||||||
readFileSync,
|
|
||||||
rm,
|
|
||||||
stat,
|
|
||||||
writeFile,
|
|
||||||
} from "node:fs";
|
|
||||||
import {pipeline} from "node:stream";
|
import {pipeline} from "node:stream";
|
||||||
import {promisify} from "node:util";
|
import {promisify} from "node:util";
|
||||||
import {getRandomValues} from "node:crypto";
|
import {getRandomValues} from "node:crypto";
|
||||||
@@ -1029,7 +1021,9 @@ async function __getMasterEncryptionKey1(): Promise<string> {
|
|||||||
|
|
||||||
async function __getMasterEncryptionKey2(): Promise<string> {
|
async function __getMasterEncryptionKey2(): Promise<string> {
|
||||||
if (!__masterEncryptionKey2) {
|
if (!__masterEncryptionKey2) {
|
||||||
const filename = "~/.deno-common-mod-master-encryption-key-2";
|
const filename = resolveFilename(
|
||||||
|
"~/.deno-common-mod-master-encryption-key-2",
|
||||||
|
);
|
||||||
__masterEncryptionKey2 = await readFileToString(filename);
|
__masterEncryptionKey2 = await readFileToString(filename);
|
||||||
if (!__masterEncryptionKey2) {
|
if (!__masterEncryptionKey2) {
|
||||||
__masterEncryptionKey2 = encodeBase64(random(4096));
|
__masterEncryptionKey2 = encodeBase64(random(4096));
|
||||||
@@ -1124,7 +1118,9 @@ export async function readWithLocalCache<T>(
|
|||||||
throw new Error("Key and read callback function are both required.");
|
throw new Error("Key and read callback function are both required.");
|
||||||
}
|
}
|
||||||
const cacheKeyHash = await sha256AndBase32OfString(cacheKey);
|
const cacheKeyHash = await sha256AndBase32OfString(cacheKey);
|
||||||
const basePath = options?.basePath ?? "~/.cache/local-cache";
|
const basePath = resolveFilename(
|
||||||
|
options?.basePath ?? "~/.cache/local-cache",
|
||||||
|
);
|
||||||
const cacheDir = joinPath(
|
const cacheDir = joinPath(
|
||||||
basePath,
|
basePath,
|
||||||
cacheKeyHash.substring(0, 2),
|
cacheKeyHash.substring(0, 2),
|
||||||
|
|||||||
@@ -118,11 +118,11 @@
|
|||||||
"get-secret.ts": {
|
"get-secret.ts": {
|
||||||
"script_name": "get-secret.ts",
|
"script_name": "get-secret.ts",
|
||||||
"script_length": 739,
|
"script_length": 739,
|
||||||
"script_sha256": "e036f5411904d53f7525f4830eb51282df3a9f07a3e6f8b23d5385b4f24ec676",
|
"script_sha256": "0d4123bc38361c42044050eb46296c443168dd9c882db8b1282e858043096e63",
|
||||||
"script_full_url": "https://git.hatter.ink/hatter/ts-scripts/raw/branch/main/single-scripts/get-secret.ts",
|
"script_full_url": "https://git.hatter.ink/hatter/ts-scripts/raw/branch/main/single-scripts/get-secret.ts",
|
||||||
"single_script_file": true,
|
"single_script_file": true,
|
||||||
"publish_time": 1775239056991,
|
"publish_time": 1775239056991,
|
||||||
"update_time": 1775453129788
|
"update_time": 1775487544902
|
||||||
},
|
},
|
||||||
"git-check.ts": {
|
"git-check.ts": {
|
||||||
"script_name": "git-check.ts",
|
"script_name": "git-check.ts",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env -S deno run -A
|
#!/usr/bin/env -S deno run -A
|
||||||
|
|
||||||
import {args, exit, getSecretValue,} from "https://script.hatter.ink/@66/deno-commons-mod.ts";
|
import {args, exit, getSecretValue,} from "https://script.hatter.ink/@67/deno-commons-mod.ts";
|
||||||
import {parseArgs} from "jsr:@std/cli/parse-args";
|
import {parseArgs} from "jsr:@std/cli/parse-args";
|
||||||
|
|
||||||
const flags = parseArgs(args(), {
|
const flags = parseArgs(args(), {
|
||||||
|
|||||||
Reference in New Issue
Block a user