♻️ Refactor import statements and update script metadata for improved readability and dependency management
This commit is contained in:
@@ -1,23 +1,15 @@
|
||||
// Reference:
|
||||
// - https://docs.deno.com/runtime/fundamentals/testing/
|
||||
|
||||
import { decodeBase64, encodeBase64 } from "jsr:@std/encoding/base64";
|
||||
import { encodeBase32 } from "jsr:@std/encoding/base32";
|
||||
import { dirname, fromFileUrl } from "jsr:@std/path";
|
||||
import { toArrayBuffer } from "jsr:@std/streams";
|
||||
import { spawn, SpawnOptionsWithoutStdio } from "node:child_process";
|
||||
import {
|
||||
createWriteStream,
|
||||
mkdir,
|
||||
readFile,
|
||||
readFileSync,
|
||||
rm,
|
||||
stat,
|
||||
writeFile,
|
||||
} from "node:fs";
|
||||
import { pipeline } from "node:stream";
|
||||
import { promisify } from "node:util";
|
||||
import { getRandomValues } from "node:crypto";
|
||||
import {decodeBase64, encodeBase64} from "jsr:@std/encoding/base64";
|
||||
import {encodeBase32} from "jsr:@std/encoding/base32";
|
||||
import {dirname, fromFileUrl} from "jsr:@std/path";
|
||||
import {toArrayBuffer} from "jsr:@std/streams";
|
||||
import {spawn, SpawnOptionsWithoutStdio} from "node:child_process";
|
||||
import {createWriteStream, mkdir, readFile, readFileSync, rm, stat, writeFile,} from "node:fs";
|
||||
import {pipeline} from "node:stream";
|
||||
import {promisify} from "node:util";
|
||||
import {getRandomValues} from "node:crypto";
|
||||
|
||||
// reference: https://docs.deno.com/examples/hex_base64_encoding/
|
||||
// import { decodeBase64, encodeBase64 } from "jsr:@std/encoding/base64";
|
||||
@@ -1029,7 +1021,9 @@ async function __getMasterEncryptionKey1(): Promise<string> {
|
||||
|
||||
async function __getMasterEncryptionKey2(): Promise<string> {
|
||||
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);
|
||||
if (!__masterEncryptionKey2) {
|
||||
__masterEncryptionKey2 = encodeBase64(random(4096));
|
||||
@@ -1124,7 +1118,9 @@ export async function readWithLocalCache<T>(
|
||||
throw new Error("Key and read callback function are both required.");
|
||||
}
|
||||
const cacheKeyHash = await sha256AndBase32OfString(cacheKey);
|
||||
const basePath = options?.basePath ?? "~/.cache/local-cache";
|
||||
const basePath = resolveFilename(
|
||||
options?.basePath ?? "~/.cache/local-cache",
|
||||
);
|
||||
const cacheDir = joinPath(
|
||||
basePath,
|
||||
cacheKeyHash.substring(0, 2),
|
||||
|
||||
Reference in New Issue
Block a user