/opt/canhelp/node_modules/gel/dist
NameSizeModeActions
codecs/-0755rm
datatypes/-0755rm
errors/-0755rm
primitives/-0755rm
reflection/-0755rm
baseClient.d.ts58870644editdlrm
baseClient.js198870644editdlrm
baseConn.d.ts48900644editdlrm
baseConn.js315880644editdlrm
browserClient.d.ts2000644editdlrm
browserClient.js12120644editdlrm
browserCrypto.d.ts910644editdlrm
browserCrypto.js7240644editdlrm
cli.mjs74390755editdlrm
codecTypeRegistry.d.ts1950644editdlrm
codecTypeRegistry.js770644editdlrm
conUtils.d.ts55400644editdlrm
conUtils.js362590644editdlrm
conUtils.server.d.ts5550644editdlrm
conUtils.server.js32660644editdlrm
credentials.d.ts5610644editdlrm
credentials.js41580644editdlrm
cryptoUtils.d.ts1060644editdlrm
cryptoUtils.js8110644editdlrm
fetchConn.d.ts28000644editdlrm
fetchConn.js75450644editdlrm
httpScram.d.ts2290644editdlrm
httpScram.js39700644editdlrm
ifaces.d.ts25300644editdlrm
ifaces.js28470644editdlrm
index.browser.d.ts8670644editdlrm
index.browser.js19730644editdlrm
index.node.d.ts12750644editdlrm
index.node.js32660644editdlrm
index.shared.d.ts18960644editdlrm
index.shared.js54860644editdlrm
nodeClient.d.ts2400644editdlrm
nodeClient.js15290644editdlrm
nodeCrypto.d.ts910644editdlrm
nodeCrypto.js9170644editdlrm
options.d.ts42540644editdlrm
options.js112490644editdlrm
platform.d.ts1240644editdlrm
platform.js17310644editdlrm
rawConn.d.ts12180644editdlrm
rawConn.js173140644editdlrm
retry.d.ts11530644editdlrm
retry.js39250644editdlrm
scram.d.ts17230644editdlrm
scram.js60040644editdlrm
systemUtils.d.ts4830644editdlrm
systemUtils.js38400644editdlrm
transaction.d.ts17380644editdlrm
transaction.js81130644editdlrm
typeutil.d.ts2430644editdlrm
typeutil.js770644editdlrm
utils.d.ts19250644editdlrm
utils.js37270644editdlrm
Edit: /opt/canhelp/node_modules/gel/dist/cli.mjs (7439B)
#!/usr/bin/env node import { execSync } from "node:child_process"; import { createWriteStream } from "node:fs"; import * as os from "node:os"; import * as fs from "node:fs/promises"; import * as path from "node:path"; import { fileURLToPath } from "node:url"; import * as process from "node:process"; import envPaths from "env-paths"; import Debug from "debug"; import which from "which"; import { quote } from "shell-quote"; const debug = Debug("gel:cli"); const IS_TTY = process.stdout.isTTY; const SCRIPT_LOCATION = await fs.realpath(fileURLToPath(import.meta.url)); const EDGEDB_PKG_ROOT = "https://packages.edgedb.com"; const CACHE_DIR = envPaths("gel", { suffix: "" }).cache; const CACHED_CLI_PATH = path.join(CACHE_DIR, "/bin/gel"); const SCRIPT_NAME = import.meta.url.split("/").pop() || "gel"; debug("Process argv:", process.argv); let args = process.argv.slice(2); if (args[0] === SCRIPT_NAME) { args = args.slice(1); } await main(args); async function main(args) { debug(`Running CLI wrapper from: ${fileURLToPath(import.meta.url)}`); debug("Starting main function with args:", args); debug(` - IS_TTY: ${IS_TTY}`); debug(` - SCRIPT_LOCATION: ${SCRIPT_LOCATION}`); debug(` - EDGEDB_PKG_ROOT: ${EDGEDB_PKG_ROOT}`); debug(` - CACHE_DIR: ${CACHE_DIR}`); debug(` - CACHED_CLI_PATH: ${CACHED_CLI_PATH}`); if (args.length === 1 && args[0] === "--succeed-if-cli-bin-wrapper") { process.exit(0); } const cliLocation = (await whichGelCli()) ?? (await getCliLocationFromCachedCli()) ?? (await getCachedCliLocation()) ?? null; if (cliLocation === null) { throw Error("Failed to find or install Gel CLI."); } try { runCli(args, cliLocation); } catch (err) { if (typeof err === "object" && err !== null && "status" in err && typeof err.status === "number") { process.exit(err.status); } else { console.error(err); } process.exit(1); } process.exit(0); } async function whichGelCli() { debug("Checking if CLI is in PATH..."); const locations = (await which(SCRIPT_NAME, { nothrow: true, all: true })) || []; for (const location of locations) { const actualLocation = await fs.realpath(location); debug(` - CLI found in PATH at: ${location} (resolved to: ${actualLocation})`); if (actualLocation === SCRIPT_LOCATION) { debug(" - CLI found in PATH is the current script. Ignoring."); continue; } const lowerCaseLocation = actualLocation.toLowerCase(); if (lowerCaseLocation.endsWith(".cmd") || lowerCaseLocation.endsWith(".ps1")) { debug(" - CLI found in PATH is a Windows script. Ignoring."); continue; } if (lowerCaseLocation.includes("node_modules/.bin")) { debug(" - CLI found in PATH is in a node_modules/.bin directory. Ignoring."); continue; } try { runCli(["--succeed-if-cli-bin-wrapper"], actualLocation, { stdio: "ignore", }); debug(" - CLI found in PATH is wrapper script. Ignoring."); continue; } catch (_err) { debug(" - CLI found in PATH is not a wrapper script. Using."); } return location; } debug(" - No CLI found in PATH."); return null; } async function getCachedCliLocation() { try { const stats = await fs.stat(CACHED_CLI_PATH); if (!stats.isFile()) { debug(" - Object found at cached CLI path is not a file. Downloading..."); await downloadCliPackage(); } } catch (_err) { debug(" - No cached CLI found. Downloading..."); await downloadCliPackage(); } await fs.access(CACHED_CLI_PATH, fs.constants.F_OK); return CACHED_CLI_PATH; } async function getCliLocationFromCachedCli() { debug("Installing temporary CLI to get install directory..."); const cachedCliLocation = await getCachedCliLocation(); const installDir = getInstallDir(cachedCliLocation); const binaryPath = path.join(installDir, "gel"); debug(" - CLI installed at:", binaryPath); try { debug(" - CLI binary found in path:", binaryPath); await fs.access(binaryPath, fs.constants.F_OK); return binaryPath; } catch { debug(" - CLI binary not found in path:", binaryPath); return null; } } async function downloadCliPackage() { debug("Downloading CLI package..."); const cliPkgUrl = await findPackageUrl(); const downloadDir = path.dirname(CACHED_CLI_PATH); await fs.mkdir(downloadDir, { recursive: true }).catch((error) => { if (error.code !== "EEXIST") throw error; }); await downloadFile(cliPkgUrl, CACHED_CLI_PATH); debug(" - CLI package downloaded to:", CACHED_CLI_PATH); const fd = await fs.open(CACHED_CLI_PATH, "r+"); await fd.chmod(0o755); await fd.datasync(); await fd.close(); } function runCli(args, pathToCli, execOptions = { stdio: "inherit" }) { const command = quote([pathToCli, ...args]); debug(`Running Gel CLI: ${command}`); return execSync(command, execOptions); } async function findPackageUrl() { const arch = os.arch(); const platform = os.platform(); debug("Getting base distribution for:", platform, arch); let dist = ""; let ext = ""; if (arch === "x64") { dist += "x86_64"; } else if (arch === "arm64") { dist += "aarch64"; } else { throw new Error(`Unsupported architecture: ${arch}`); } if (platform === "win32") { dist += "-pc-windows-msvc"; ext = ".exe"; } else if (platform === "darwin") { dist += "-apple-darwin"; } else if (platform === "linux") { dist += "-unknown-linux-musl"; } else { throw new Error(`Unsupported OS: ${platform}`); } const pkg = new URL(`/dist/${dist}/gel-cli${ext}`, EDGEDB_PKG_ROOT); debug(" - Package URL:", pkg.href); return pkg; } async function downloadFile(url, path) { debug("Downloading file from URL:", url); const response = await fetch(url); if (!response.ok || !response.body) { throw new Error(`Download from ${url} failed: ${response.statusText}`); } const fileStream = createWriteStream(path, { flush: true }); if (response.body) { for await (const chunk of streamReader(response.body)) { fileStream.write(chunk); } fileStream.end(); debug(" - File downloaded successfully."); } else { throw new Error(" - Download failed: no response body"); } } function getInstallDir(cliPath) { debug("Getting install directory for CLI path:", cliPath); const installDir = runCli(["info", "--get", "install-dir"], cliPath, { stdio: "pipe", }) .toString() .trim(); debug(" - Install directory:", installDir); return installDir; } async function* streamReader(readableStream) { debug("Reading stream..."); const reader = readableStream.getReader(); while (true) { const { done, value } = await reader.read(); if (done) break; yield value; } debug(" - Stream reading completed."); }