/
opt
/
canhelp
/
node_modules
/
gel
/
dist
/
/opt/canhelp/node_modules/gel/dist
mkdir
upload
Name
Size
Mode
Actions
codecs/
-
0755
rm
datatypes/
-
0755
rm
errors/
-
0755
rm
primitives/
-
0755
rm
reflection/
-
0755
rm
baseClient.d.ts
5887
0644
edit
dl
rm
baseClient.js
19887
0644
edit
dl
rm
baseConn.d.ts
4890
0644
edit
dl
rm
baseConn.js
31588
0644
edit
dl
rm
browserClient.d.ts
200
0644
edit
dl
rm
browserClient.js
1212
0644
edit
dl
rm
browserCrypto.d.ts
91
0644
edit
dl
rm
browserCrypto.js
724
0644
edit
dl
rm
cli.mjs
7439
0755
edit
dl
rm
codecTypeRegistry.d.ts
195
0644
edit
dl
rm
codecTypeRegistry.js
77
0644
edit
dl
rm
conUtils.d.ts
5540
0644
edit
dl
rm
conUtils.js
36259
0644
edit
dl
rm
conUtils.server.d.ts
555
0644
edit
dl
rm
conUtils.server.js
3266
0644
edit
dl
rm
credentials.d.ts
561
0644
edit
dl
rm
credentials.js
4158
0644
edit
dl
rm
cryptoUtils.d.ts
106
0644
edit
dl
rm
cryptoUtils.js
811
0644
edit
dl
rm
fetchConn.d.ts
2800
0644
edit
dl
rm
fetchConn.js
7545
0644
edit
dl
rm
httpScram.d.ts
229
0644
edit
dl
rm
httpScram.js
3970
0644
edit
dl
rm
ifaces.d.ts
2530
0644
edit
dl
rm
ifaces.js
2847
0644
edit
dl
rm
index.browser.d.ts
867
0644
edit
dl
rm
index.browser.js
1973
0644
edit
dl
rm
index.node.d.ts
1275
0644
edit
dl
rm
index.node.js
3266
0644
edit
dl
rm
index.shared.d.ts
1896
0644
edit
dl
rm
index.shared.js
5486
0644
edit
dl
rm
nodeClient.d.ts
240
0644
edit
dl
rm
nodeClient.js
1529
0644
edit
dl
rm
nodeCrypto.d.ts
91
0644
edit
dl
rm
nodeCrypto.js
917
0644
edit
dl
rm
options.d.ts
4254
0644
edit
dl
rm
options.js
11249
0644
edit
dl
rm
platform.d.ts
124
0644
edit
dl
rm
platform.js
1731
0644
edit
dl
rm
rawConn.d.ts
1218
0644
edit
dl
rm
rawConn.js
17314
0644
edit
dl
rm
retry.d.ts
1153
0644
edit
dl
rm
retry.js
3925
0644
edit
dl
rm
scram.d.ts
1723
0644
edit
dl
rm
scram.js
6004
0644
edit
dl
rm
systemUtils.d.ts
483
0644
edit
dl
rm
systemUtils.js
3840
0644
edit
dl
rm
transaction.d.ts
1738
0644
edit
dl
rm
transaction.js
8113
0644
edit
dl
rm
typeutil.d.ts
243
0644
edit
dl
rm
typeutil.js
77
0644
edit
dl
rm
utils.d.ts
1925
0644
edit
dl
rm
utils.js
3727
0644
edit
dl
rm
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."); }
Save
cmd:
run