UNPKG

@narasaka/drizzle-kit

Version:

Drizzle Kit is a CLI migrator tool for Drizzle ORM. It is probably the one and only tool that lets you completely automatically generate SQL migrations and covers ~95% of the common cases like deletions and renames by prompting user input. <https://github

1,459 lines (1,444 loc) 3.75 MB
#!/usr/bin/env node "use strict"; var __create = Object.create; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __getProtoOf = Object.getPrototypeOf; var __hasOwnProp = Object.prototype.hasOwnProperty; var __esm = (fn, res) => function __init() { return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res; }; var __commonJS = (cb, mod) => function __require() { return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; }; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( // If the importer is in node compatibility mode or this is not an ESM // file that has been converted to a CommonJS file using a Babel- // compatible transform (i.e. "__esModule" has not been set), then set // "default" to the CommonJS "module.exports" for node compatibility. isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod )); var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); // ../node_modules/.pnpm/chalk@5.4.1/node_modules/chalk/source/vendor/ansi-styles/index.js function assembleStyles() { const codes = /* @__PURE__ */ new Map(); for (const [groupName, group] of Object.entries(styles)) { for (const [styleName, style] of Object.entries(group)) { styles[styleName] = { open: `\x1B[${style[0]}m`, close: `\x1B[${style[1]}m` }; group[styleName] = styles[styleName]; codes.set(style[0], style[1]); } Object.defineProperty(styles, groupName, { value: group, enumerable: false }); } Object.defineProperty(styles, "codes", { value: codes, enumerable: false }); styles.color.close = "\x1B[39m"; styles.bgColor.close = "\x1B[49m"; styles.color.ansi = wrapAnsi16(); styles.color.ansi256 = wrapAnsi256(); styles.color.ansi16m = wrapAnsi16m(); styles.bgColor.ansi = wrapAnsi16(ANSI_BACKGROUND_OFFSET); styles.bgColor.ansi256 = wrapAnsi256(ANSI_BACKGROUND_OFFSET); styles.bgColor.ansi16m = wrapAnsi16m(ANSI_BACKGROUND_OFFSET); Object.defineProperties(styles, { rgbToAnsi256: { value(red, green, blue) { if (red === green && green === blue) { if (red < 8) { return 16; } if (red > 248) { return 231; } return Math.round((red - 8) / 247 * 24) + 232; } return 16 + 36 * Math.round(red / 255 * 5) + 6 * Math.round(green / 255 * 5) + Math.round(blue / 255 * 5); }, enumerable: false }, hexToRgb: { value(hex) { const matches = /[a-f\d]{6}|[a-f\d]{3}/i.exec(hex.toString(16)); if (!matches) { return [0, 0, 0]; } let [colorString] = matches; if (colorString.length === 3) { colorString = [...colorString].map((character) => character + character).join(""); } const integer = Number.parseInt(colorString, 16); return [ /* eslint-disable no-bitwise */ integer >> 16 & 255, integer >> 8 & 255, integer & 255 /* eslint-enable no-bitwise */ ]; }, enumerable: false }, hexToAnsi256: { value: (hex) => styles.rgbToAnsi256(...styles.hexToRgb(hex)), enumerable: false }, ansi256ToAnsi: { value(code) { if (code < 8) { return 30 + code; } if (code < 16) { return 90 + (code - 8); } let red; let green; let blue; if (code >= 232) { red = ((code - 232) * 10 + 8) / 255; green = red; blue = red; } else { code -= 16; const remainder = code % 36; red = Math.floor(code / 36) / 5; green = Math.floor(remainder / 6) / 5; blue = remainder % 6 / 5; } const value = Math.max(red, green, blue) * 2; if (value === 0) { return 30; } let result = 30 + (Math.round(blue) << 2 | Math.round(green) << 1 | Math.round(red)); if (value === 2) { result += 60; } return result; }, enumerable: false }, rgbToAnsi: { value: (red, green, blue) => styles.ansi256ToAnsi(styles.rgbToAnsi256(red, green, blue)), enumerable: false }, hexToAnsi: { value: (hex) => styles.ansi256ToAnsi(styles.hexToAnsi256(hex)), enumerable: false } }); return styles; } var ANSI_BACKGROUND_OFFSET, wrapAnsi16, wrapAnsi256, wrapAnsi16m, styles, modifierNames, foregroundColorNames, backgroundColorNames, colorNames, ansiStyles, ansi_styles_default; var init_ansi_styles = __esm({ "../node_modules/.pnpm/chalk@5.4.1/node_modules/chalk/source/vendor/ansi-styles/index.js"() { ANSI_BACKGROUND_OFFSET = 10; wrapAnsi16 = (offset = 0) => (code) => `\x1B[${code + offset}m`; wrapAnsi256 = (offset = 0) => (code) => `\x1B[${38 + offset};5;${code}m`; wrapAnsi16m = (offset = 0) => (red, green, blue) => `\x1B[${38 + offset};2;${red};${green};${blue}m`; styles = { modifier: { reset: [0, 0], // 21 isn't widely supported and 22 does the same thing bold: [1, 22], dim: [2, 22], italic: [3, 23], underline: [4, 24], overline: [53, 55], inverse: [7, 27], hidden: [8, 28], strikethrough: [9, 29] }, color: { black: [30, 39], red: [31, 39], green: [32, 39], yellow: [33, 39], blue: [34, 39], magenta: [35, 39], cyan: [36, 39], white: [37, 39], // Bright color blackBright: [90, 39], gray: [90, 39], // Alias of `blackBright` grey: [90, 39], // Alias of `blackBright` redBright: [91, 39], greenBright: [92, 39], yellowBright: [93, 39], blueBright: [94, 39], magentaBright: [95, 39], cyanBright: [96, 39], whiteBright: [97, 39] }, bgColor: { bgBlack: [40, 49], bgRed: [41, 49], bgGreen: [42, 49], bgYellow: [43, 49], bgBlue: [44, 49], bgMagenta: [45, 49], bgCyan: [46, 49], bgWhite: [47, 49], // Bright color bgBlackBright: [100, 49], bgGray: [100, 49], // Alias of `bgBlackBright` bgGrey: [100, 49], // Alias of `bgBlackBright` bgRedBright: [101, 49], bgGreenBright: [102, 49], bgYellowBright: [103, 49], bgBlueBright: [104, 49], bgMagentaBright: [105, 49], bgCyanBright: [106, 49], bgWhiteBright: [107, 49] } }; modifierNames = Object.keys(styles.modifier); foregroundColorNames = Object.keys(styles.color); backgroundColorNames = Object.keys(styles.bgColor); colorNames = [...foregroundColorNames, ...backgroundColorNames]; ansiStyles = assembleStyles(); ansi_styles_default = ansiStyles; } }); // ../node_modules/.pnpm/chalk@5.4.1/node_modules/chalk/source/vendor/supports-color/index.js function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : import_node_process.default.argv) { const prefix2 = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--"; const position = argv.indexOf(prefix2 + flag); const terminatorPosition = argv.indexOf("--"); return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition); } function envForceColor() { if ("FORCE_COLOR" in env) { if (env.FORCE_COLOR === "true") { return 1; } if (env.FORCE_COLOR === "false") { return 0; } return env.FORCE_COLOR.length === 0 ? 1 : Math.min(Number.parseInt(env.FORCE_COLOR, 10), 3); } } function translateLevel(level) { if (level === 0) { return false; } return { level, hasBasic: true, has256: level >= 2, has16m: level >= 3 }; } function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) { const noFlagForceColor = envForceColor(); if (noFlagForceColor !== void 0) { flagForceColor = noFlagForceColor; } const forceColor = sniffFlags ? flagForceColor : noFlagForceColor; if (forceColor === 0) { return 0; } if (sniffFlags) { if (hasFlag("color=16m") || hasFlag("color=full") || hasFlag("color=truecolor")) { return 3; } if (hasFlag("color=256")) { return 2; } } if ("TF_BUILD" in env && "AGENT_NAME" in env) { return 1; } if (haveStream && !streamIsTTY && forceColor === void 0) { return 0; } const min = forceColor || 0; if (env.TERM === "dumb") { return min; } if (import_node_process.default.platform === "win32") { const osRelease = import_node_os.default.release().split("."); if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) { return Number(osRelease[2]) >= 14931 ? 3 : 2; } return 1; } if ("CI" in env) { if (["GITHUB_ACTIONS", "GITEA_ACTIONS", "CIRCLECI"].some((key) => key in env)) { return 3; } if (["TRAVIS", "APPVEYOR", "GITLAB_CI", "BUILDKITE", "DRONE"].some((sign) => sign in env) || env.CI_NAME === "codeship") { return 1; } return min; } if ("TEAMCITY_VERSION" in env) { return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0; } if (env.COLORTERM === "truecolor") { return 3; } if (env.TERM === "xterm-kitty") { return 3; } if ("TERM_PROGRAM" in env) { const version3 = Number.parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10); switch (env.TERM_PROGRAM) { case "iTerm.app": { return version3 >= 3 ? 3 : 2; } case "Apple_Terminal": { return 2; } } } if (/-256(color)?$/i.test(env.TERM)) { return 2; } if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) { return 1; } if ("COLORTERM" in env) { return 1; } return min; } function createSupportsColor(stream, options = {}) { const level = _supportsColor(stream, { streamIsTTY: stream && stream.isTTY, ...options }); return translateLevel(level); } var import_node_process, import_node_os, import_node_tty, env, flagForceColor, supportsColor, supports_color_default; var init_supports_color = __esm({ "../node_modules/.pnpm/chalk@5.4.1/node_modules/chalk/source/vendor/supports-color/index.js"() { import_node_process = __toESM(require("node:process"), 1); import_node_os = __toESM(require("node:os"), 1); import_node_tty = __toESM(require("node:tty"), 1); ({ env } = import_node_process.default); if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) { flagForceColor = 0; } else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) { flagForceColor = 1; } supportsColor = { stdout: createSupportsColor({ isTTY: import_node_tty.default.isatty(1) }), stderr: createSupportsColor({ isTTY: import_node_tty.default.isatty(2) }) }; supports_color_default = supportsColor; } }); // ../node_modules/.pnpm/chalk@5.4.1/node_modules/chalk/source/utilities.js function stringReplaceAll(string2, substring, replacer) { let index6 = string2.indexOf(substring); if (index6 === -1) { return string2; } const substringLength = substring.length; let endIndex = 0; let returnValue = ""; do { returnValue += string2.slice(endIndex, index6) + substring + replacer; endIndex = index6 + substringLength; index6 = string2.indexOf(substring, endIndex); } while (index6 !== -1); returnValue += string2.slice(endIndex); return returnValue; } function stringEncaseCRLFWithFirstIndex(string2, prefix2, postfix, index6) { let endIndex = 0; let returnValue = ""; do { const gotCR = string2[index6 - 1] === "\r"; returnValue += string2.slice(endIndex, gotCR ? index6 - 1 : index6) + prefix2 + (gotCR ? "\r\n" : "\n") + postfix; endIndex = index6 + 1; index6 = string2.indexOf("\n", endIndex); } while (index6 !== -1); returnValue += string2.slice(endIndex); return returnValue; } var init_utilities = __esm({ "../node_modules/.pnpm/chalk@5.4.1/node_modules/chalk/source/utilities.js"() { } }); // ../node_modules/.pnpm/chalk@5.4.1/node_modules/chalk/source/index.js function createChalk(options) { return chalkFactory(options); } var stdoutColor, stderrColor, GENERATOR, STYLER, IS_EMPTY, levelMapping, styles2, applyOptions, chalkFactory, getModelAnsi, usedModels, proto, createStyler, createBuilder, applyStyle, chalk, chalkStderr, source_default; var init_source = __esm({ "../node_modules/.pnpm/chalk@5.4.1/node_modules/chalk/source/index.js"() { init_ansi_styles(); init_supports_color(); init_utilities(); ({ stdout: stdoutColor, stderr: stderrColor } = supports_color_default); GENERATOR = Symbol("GENERATOR"); STYLER = Symbol("STYLER"); IS_EMPTY = Symbol("IS_EMPTY"); levelMapping = [ "ansi", "ansi", "ansi256", "ansi16m" ]; styles2 = /* @__PURE__ */ Object.create(null); applyOptions = (object, options = {}) => { if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) { throw new Error("The `level` option should be an integer from 0 to 3"); } const colorLevel = stdoutColor ? stdoutColor.level : 0; object.level = options.level === void 0 ? colorLevel : options.level; }; chalkFactory = (options) => { const chalk2 = (...strings) => strings.join(" "); applyOptions(chalk2, options); Object.setPrototypeOf(chalk2, createChalk.prototype); return chalk2; }; Object.setPrototypeOf(createChalk.prototype, Function.prototype); for (const [styleName, style] of Object.entries(ansi_styles_default)) { styles2[styleName] = { get() { const builder = createBuilder(this, createStyler(style.open, style.close, this[STYLER]), this[IS_EMPTY]); Object.defineProperty(this, styleName, { value: builder }); return builder; } }; } styles2.visible = { get() { const builder = createBuilder(this, this[STYLER], true); Object.defineProperty(this, "visible", { value: builder }); return builder; } }; getModelAnsi = (model, level, type, ...arguments_) => { if (model === "rgb") { if (level === "ansi16m") { return ansi_styles_default[type].ansi16m(...arguments_); } if (level === "ansi256") { return ansi_styles_default[type].ansi256(ansi_styles_default.rgbToAnsi256(...arguments_)); } return ansi_styles_default[type].ansi(ansi_styles_default.rgbToAnsi(...arguments_)); } if (model === "hex") { return getModelAnsi("rgb", level, type, ...ansi_styles_default.hexToRgb(...arguments_)); } return ansi_styles_default[type][model](...arguments_); }; usedModels = ["rgb", "hex", "ansi256"]; for (const model of usedModels) { styles2[model] = { get() { const { level } = this; return function(...arguments_) { const styler = createStyler(getModelAnsi(model, levelMapping[level], "color", ...arguments_), ansi_styles_default.color.close, this[STYLER]); return createBuilder(this, styler, this[IS_EMPTY]); }; } }; const bgModel = "bg" + model[0].toUpperCase() + model.slice(1); styles2[bgModel] = { get() { const { level } = this; return function(...arguments_) { const styler = createStyler(getModelAnsi(model, levelMapping[level], "bgColor", ...arguments_), ansi_styles_default.bgColor.close, this[STYLER]); return createBuilder(this, styler, this[IS_EMPTY]); }; } }; } proto = Object.defineProperties(() => { }, { ...styles2, level: { enumerable: true, get() { return this[GENERATOR].level; }, set(level) { this[GENERATOR].level = level; } } }); createStyler = (open, close, parent) => { let openAll; let closeAll; if (parent === void 0) { openAll = open; closeAll = close; } else { openAll = parent.openAll + open; closeAll = close + parent.closeAll; } return { open, close, openAll, closeAll, parent }; }; createBuilder = (self2, _styler, _isEmpty) => { const builder = (...arguments_) => applyStyle(builder, arguments_.length === 1 ? "" + arguments_[0] : arguments_.join(" ")); Object.setPrototypeOf(builder, proto); builder[GENERATOR] = self2; builder[STYLER] = _styler; builder[IS_EMPTY] = _isEmpty; return builder; }; applyStyle = (self2, string2) => { if (self2.level <= 0 || !string2) { return self2[IS_EMPTY] ? "" : string2; } let styler = self2[STYLER]; if (styler === void 0) { return string2; } const { openAll, closeAll } = styler; if (string2.includes("\x1B")) { while (styler !== void 0) { string2 = stringReplaceAll(string2, styler.close, styler.open); styler = styler.parent; } } const lfIndex = string2.indexOf("\n"); if (lfIndex !== -1) { string2 = stringEncaseCRLFWithFirstIndex(string2, closeAll, openAll, lfIndex); } return openAll + string2 + closeAll; }; Object.defineProperties(createChalk.prototype, styles2); chalk = createChalk(); chalkStderr = createChalk({ level: stderrColor ? stderrColor.level : 0 }); source_default = chalk; } }); // ../node_modules/.pnpm/dotenv@16.5.0/node_modules/dotenv/package.json var require_package = __commonJS({ "../node_modules/.pnpm/dotenv@16.5.0/node_modules/dotenv/package.json"(exports2, module2) { module2.exports = { name: "dotenv", version: "16.5.0", description: "Loads environment variables from .env file", main: "lib/main.js", types: "lib/main.d.ts", exports: { ".": { types: "./lib/main.d.ts", require: "./lib/main.js", default: "./lib/main.js" }, "./config": "./config.js", "./config.js": "./config.js", "./lib/env-options": "./lib/env-options.js", "./lib/env-options.js": "./lib/env-options.js", "./lib/cli-options": "./lib/cli-options.js", "./lib/cli-options.js": "./lib/cli-options.js", "./package.json": "./package.json" }, scripts: { "dts-check": "tsc --project tests/types/tsconfig.json", lint: "standard", pretest: "npm run lint && npm run dts-check", test: "tap run --allow-empty-coverage --disable-coverage --timeout=60000", "test:coverage": "tap run --show-full-coverage --timeout=60000 --coverage-report=lcov", prerelease: "npm test", release: "standard-version" }, repository: { type: "git", url: "git://github.com/motdotla/dotenv.git" }, homepage: "https://github.com/motdotla/dotenv#readme", funding: "https://dotenvx.com", keywords: [ "dotenv", "env", ".env", "environment", "variables", "config", "settings" ], readmeFilename: "README.md", license: "BSD-2-Clause", devDependencies: { "@types/node": "^18.11.3", decache: "^4.6.2", sinon: "^14.0.1", standard: "^17.0.0", "standard-version": "^9.5.0", tap: "^19.2.0", typescript: "^4.8.4" }, engines: { node: ">=12" }, browser: { fs: false } }; } }); // ../node_modules/.pnpm/dotenv@16.5.0/node_modules/dotenv/lib/main.js var require_main = __commonJS({ "../node_modules/.pnpm/dotenv@16.5.0/node_modules/dotenv/lib/main.js"(exports2, module2) { var fs7 = require("fs"); var path4 = require("path"); var os3 = require("os"); var crypto7 = require("crypto"); var packageJson = require_package(); var version3 = packageJson.version; var LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg; function parse5(src) { const obj = {}; let lines = src.toString(); lines = lines.replace(/\r\n?/mg, "\n"); let match2; while ((match2 = LINE.exec(lines)) != null) { const key = match2[1]; let value = match2[2] || ""; value = value.trim(); const maybeQuote = value[0]; value = value.replace(/^(['"`])([\s\S]*)\1$/mg, "$2"); if (maybeQuote === '"') { value = value.replace(/\\n/g, "\n"); value = value.replace(/\\r/g, "\r"); } obj[key] = value; } return obj; } function _parseVault(options) { const vaultPath = _vaultPath(options); const result = DotenvModule.configDotenv({ path: vaultPath }); if (!result.parsed) { const err2 = new Error(`MISSING_DATA: Cannot parse ${vaultPath} for an unknown reason`); err2.code = "MISSING_DATA"; throw err2; } const keys = _dotenvKey(options).split(","); const length = keys.length; let decrypted; for (let i4 = 0; i4 < length; i4++) { try { const key = keys[i4].trim(); const attrs = _instructions(result, key); decrypted = DotenvModule.decrypt(attrs.ciphertext, attrs.key); break; } catch (error2) { if (i4 + 1 >= length) { throw error2; } } } return DotenvModule.parse(decrypted); } function _warn(message) { console.log(`[dotenv@${version3}][WARN] ${message}`); } function _debug(message) { console.log(`[dotenv@${version3}][DEBUG] ${message}`); } function _dotenvKey(options) { if (options && options.DOTENV_KEY && options.DOTENV_KEY.length > 0) { return options.DOTENV_KEY; } if (process.env.DOTENV_KEY && process.env.DOTENV_KEY.length > 0) { return process.env.DOTENV_KEY; } return ""; } function _instructions(result, dotenvKey) { let uri; try { uri = new URL(dotenvKey); } catch (error2) { if (error2.code === "ERR_INVALID_URL") { const err2 = new Error("INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=development"); err2.code = "INVALID_DOTENV_KEY"; throw err2; } throw error2; } const key = uri.password; if (!key) { const err2 = new Error("INVALID_DOTENV_KEY: Missing key part"); err2.code = "INVALID_DOTENV_KEY"; throw err2; } const environment = uri.searchParams.get("environment"); if (!environment) { const err2 = new Error("INVALID_DOTENV_KEY: Missing environment part"); err2.code = "INVALID_DOTENV_KEY"; throw err2; } const environmentKey = `DOTENV_VAULT_${environment.toUpperCase()}`; const ciphertext = result.parsed[environmentKey]; if (!ciphertext) { const err2 = new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${environmentKey} in your .env.vault file.`); err2.code = "NOT_FOUND_DOTENV_ENVIRONMENT"; throw err2; } return { ciphertext, key }; } function _vaultPath(options) { let possibleVaultPath = null; if (options && options.path && options.path.length > 0) { if (Array.isArray(options.path)) { for (const filepath of options.path) { if (fs7.existsSync(filepath)) { possibleVaultPath = filepath.endsWith(".vault") ? filepath : `${filepath}.vault`; } } } else { possibleVaultPath = options.path.endsWith(".vault") ? options.path : `${options.path}.vault`; } } else { possibleVaultPath = path4.resolve(process.cwd(), ".env.vault"); } if (fs7.existsSync(possibleVaultPath)) { return possibleVaultPath; } return null; } function _resolveHome(envPath) { return envPath[0] === "~" ? path4.join(os3.homedir(), envPath.slice(1)) : envPath; } function _configVault(options) { const debug = Boolean(options && options.debug); if (debug) { _debug("Loading env from encrypted .env.vault"); } const parsed = DotenvModule._parseVault(options); let processEnv = process.env; if (options && options.processEnv != null) { processEnv = options.processEnv; } DotenvModule.populate(processEnv, parsed, options); return { parsed }; } function configDotenv(options) { const dotenvPath = path4.resolve(process.cwd(), ".env"); let encoding = "utf8"; const debug = Boolean(options && options.debug); if (options && options.encoding) { encoding = options.encoding; } else { if (debug) { _debug("No encoding is specified. UTF-8 is used by default"); } } let optionPaths = [dotenvPath]; if (options && options.path) { if (!Array.isArray(options.path)) { optionPaths = [_resolveHome(options.path)]; } else { optionPaths = []; for (const filepath of options.path) { optionPaths.push(_resolveHome(filepath)); } } } let lastError; const parsedAll = {}; for (const path5 of optionPaths) { try { const parsed = DotenvModule.parse(fs7.readFileSync(path5, { encoding })); DotenvModule.populate(parsedAll, parsed, options); } catch (e4) { if (debug) { _debug(`Failed to load ${path5} ${e4.message}`); } lastError = e4; } } let processEnv = process.env; if (options && options.processEnv != null) { processEnv = options.processEnv; } DotenvModule.populate(processEnv, parsedAll, options); if (lastError) { return { parsed: parsedAll, error: lastError }; } else { return { parsed: parsedAll }; } } function config(options) { if (_dotenvKey(options).length === 0) { return DotenvModule.configDotenv(options); } const vaultPath = _vaultPath(options); if (!vaultPath) { _warn(`You set DOTENV_KEY but you are missing a .env.vault file at ${vaultPath}. Did you forget to build it?`); return DotenvModule.configDotenv(options); } return DotenvModule._configVault(options); } function decrypt(encrypted, keyStr) { const key = Buffer.from(keyStr.slice(-64), "hex"); let ciphertext = Buffer.from(encrypted, "base64"); const nonce = ciphertext.subarray(0, 12); const authTag = ciphertext.subarray(-16); ciphertext = ciphertext.subarray(12, -16); try { const aesgcm = crypto7.createDecipheriv("aes-256-gcm", key, nonce); aesgcm.setAuthTag(authTag); return `${aesgcm.update(ciphertext)}${aesgcm.final()}`; } catch (error2) { const isRange = error2 instanceof RangeError; const invalidKeyLength = error2.message === "Invalid key length"; const decryptionFailed = error2.message === "Unsupported state or unable to authenticate data"; if (isRange || invalidKeyLength) { const err2 = new Error("INVALID_DOTENV_KEY: It must be 64 characters long (or more)"); err2.code = "INVALID_DOTENV_KEY"; throw err2; } else if (decryptionFailed) { const err2 = new Error("DECRYPTION_FAILED: Please check your DOTENV_KEY"); err2.code = "DECRYPTION_FAILED"; throw err2; } else { throw error2; } } } function populate(processEnv, parsed, options = {}) { const debug = Boolean(options && options.debug); const override = Boolean(options && options.override); if (typeof parsed !== "object") { const err2 = new Error("OBJECT_REQUIRED: Please check the processEnv argument being passed to populate"); err2.code = "OBJECT_REQUIRED"; throw err2; } for (const key of Object.keys(parsed)) { if (Object.prototype.hasOwnProperty.call(processEnv, key)) { if (override === true) { processEnv[key] = parsed[key]; } if (debug) { if (override === true) { _debug(`"${key}" is already defined and WAS overwritten`); } else { _debug(`"${key}" is already defined and was NOT overwritten`); } } } else { processEnv[key] = parsed[key]; } } } var DotenvModule = { configDotenv, _configVault, _parseVault, config, decrypt, parse: parse5, populate }; module2.exports.configDotenv = DotenvModule.configDotenv; module2.exports._configVault = DotenvModule._configVault; module2.exports._parseVault = DotenvModule._parseVault; module2.exports.config = DotenvModule.config; module2.exports.decrypt = DotenvModule.decrypt; module2.exports.parse = DotenvModule.parse; module2.exports.populate = DotenvModule.populate; module2.exports = DotenvModule; } }); // ../node_modules/.pnpm/dotenv@16.5.0/node_modules/dotenv/lib/env-options.js var require_env_options = __commonJS({ "../node_modules/.pnpm/dotenv@16.5.0/node_modules/dotenv/lib/env-options.js"(exports2, module2) { var options = {}; if (process.env.DOTENV_CONFIG_ENCODING != null) { options.encoding = process.env.DOTENV_CONFIG_ENCODING; } if (process.env.DOTENV_CONFIG_PATH != null) { options.path = process.env.DOTENV_CONFIG_PATH; } if (process.env.DOTENV_CONFIG_DEBUG != null) { options.debug = process.env.DOTENV_CONFIG_DEBUG; } if (process.env.DOTENV_CONFIG_OVERRIDE != null) { options.override = process.env.DOTENV_CONFIG_OVERRIDE; } if (process.env.DOTENV_CONFIG_DOTENV_KEY != null) { options.DOTENV_KEY = process.env.DOTENV_CONFIG_DOTENV_KEY; } module2.exports = options; } }); // ../node_modules/.pnpm/dotenv@16.5.0/node_modules/dotenv/lib/cli-options.js var require_cli_options = __commonJS({ "../node_modules/.pnpm/dotenv@16.5.0/node_modules/dotenv/lib/cli-options.js"(exports2, module2) { var re = /^dotenv_config_(encoding|path|debug|override|DOTENV_KEY)=(.+)$/; module2.exports = function optionMatcher(args) { return args.reduce(function(acc, cur) { const matches = cur.match(re); if (matches) { acc[matches[1]] = matches[2]; } return acc; }, {}); }; } }); // ../node_modules/.pnpm/hanji@0.0.5/node_modules/hanji/readline.js var require_readline = __commonJS({ "../node_modules/.pnpm/hanji@0.0.5/node_modules/hanji/readline.js"(exports2) { "use strict"; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.prepareReadLine = void 0; var prepareReadLine = () => { const stdin = process.stdin; const stdout = process.stdout; const readline = require("readline"); const rl = readline.createInterface({ input: stdin, escapeCodeTimeout: 50 }); readline.emitKeypressEvents(stdin, rl); return { stdin, stdout, closable: rl }; }; exports2.prepareReadLine = prepareReadLine; } }); // ../node_modules/.pnpm/sisteransi@1.0.5/node_modules/sisteransi/src/index.js var require_src = __commonJS({ "../node_modules/.pnpm/sisteransi@1.0.5/node_modules/sisteransi/src/index.js"(exports2, module2) { "use strict"; var ESC = "\x1B"; var CSI = `${ESC}[`; var beep = "\x07"; var cursor = { to(x4, y2) { if (!y2) return `${CSI}${x4 + 1}G`; return `${CSI}${y2 + 1};${x4 + 1}H`; }, move(x4, y2) { let ret = ""; if (x4 < 0) ret += `${CSI}${-x4}D`; else if (x4 > 0) ret += `${CSI}${x4}C`; if (y2 < 0) ret += `${CSI}${-y2}A`; else if (y2 > 0) ret += `${CSI}${y2}B`; return ret; }, up: (count = 1) => `${CSI}${count}A`, down: (count = 1) => `${CSI}${count}B`, forward: (count = 1) => `${CSI}${count}C`, backward: (count = 1) => `${CSI}${count}D`, nextLine: (count = 1) => `${CSI}E`.repeat(count), prevLine: (count = 1) => `${CSI}F`.repeat(count), left: `${CSI}G`, hide: `${CSI}?25l`, show: `${CSI}?25h`, save: `${ESC}7`, restore: `${ESC}8` }; var scroll = { up: (count = 1) => `${CSI}S`.repeat(count), down: (count = 1) => `${CSI}T`.repeat(count) }; var erase = { screen: `${CSI}2J`, up: (count = 1) => `${CSI}1J`.repeat(count), down: (count = 1) => `${CSI}J`.repeat(count), line: `${CSI}2K`, lineEnd: `${CSI}K`, lineStart: `${CSI}1K`, lines(count) { let clear = ""; for (let i4 = 0; i4 < count; i4++) clear += this.line + (i4 < count - 1 ? cursor.up() : ""); if (count) clear += cursor.left; return clear; } }; module2.exports = { cursor, scroll, erase, beep }; } }); // ../node_modules/.pnpm/hanji@0.0.5/node_modules/hanji/utils.js var require_utils = __commonJS({ "../node_modules/.pnpm/hanji@0.0.5/node_modules/hanji/utils.js"(exports2) { "use strict"; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.clear = void 0; var sisteransi_1 = require_src(); var strip = (str) => { const pattern = [ "[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)", "(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PRZcf-ntqry=><~]))" ].join("|"); const RGX = new RegExp(pattern, "g"); return typeof str === "string" ? str.replace(RGX, "") : str; }; var stringWidth = (str) => [...strip(str)].length; var clear = function(prompt, perLine) { if (!perLine) return sisteransi_1.erase.line + sisteransi_1.cursor.to(0); let rows = 0; const lines = prompt.split(/\r?\n/); for (let line of lines) { rows += 1 + Math.floor(Math.max(stringWidth(line) - 1, 0) / perLine); } return sisteransi_1.erase.lines(rows); }; exports2.clear = clear; } }); // ../node_modules/.pnpm/lodash.throttle@4.1.1/node_modules/lodash.throttle/index.js var require_lodash = __commonJS({ "../node_modules/.pnpm/lodash.throttle@4.1.1/node_modules/lodash.throttle/index.js"(exports2, module2) { var FUNC_ERROR_TEXT = "Expected a function"; var NAN = 0 / 0; var symbolTag = "[object Symbol]"; var reTrim = /^\s+|\s+$/g; var reIsBadHex = /^[-+]0x[0-9a-f]+$/i; var reIsBinary = /^0b[01]+$/i; var reIsOctal = /^0o[0-7]+$/i; var freeParseInt = parseInt; var freeGlobal = typeof global == "object" && global && global.Object === Object && global; var freeSelf = typeof self == "object" && self && self.Object === Object && self; var root = freeGlobal || freeSelf || Function("return this")(); var objectProto = Object.prototype; var objectToString = objectProto.toString; var nativeMax = Math.max; var nativeMin = Math.min; var now = function() { return root.Date.now(); }; function debounce(func, wait, options) { var lastArgs, lastThis, maxWait, result, timerId, lastCallTime, lastInvokeTime = 0, leading = false, maxing = false, trailing = true; if (typeof func != "function") { throw new TypeError(FUNC_ERROR_TEXT); } wait = toNumber(wait) || 0; if (isObject(options)) { leading = !!options.leading; maxing = "maxWait" in options; maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait; trailing = "trailing" in options ? !!options.trailing : trailing; } function invokeFunc(time) { var args = lastArgs, thisArg = lastThis; lastArgs = lastThis = void 0; lastInvokeTime = time; result = func.apply(thisArg, args); return result; } function leadingEdge(time) { lastInvokeTime = time; timerId = setTimeout(timerExpired, wait); return leading ? invokeFunc(time) : result; } function remainingWait(time) { var timeSinceLastCall = time - lastCallTime, timeSinceLastInvoke = time - lastInvokeTime, result2 = wait - timeSinceLastCall; return maxing ? nativeMin(result2, maxWait - timeSinceLastInvoke) : result2; } function shouldInvoke(time) { var timeSinceLastCall = time - lastCallTime, timeSinceLastInvoke = time - lastInvokeTime; return lastCallTime === void 0 || timeSinceLastCall >= wait || timeSinceLastCall < 0 || maxing && timeSinceLastInvoke >= maxWait; } function timerExpired() { var time = now(); if (shouldInvoke(time)) { return trailingEdge(time); } timerId = setTimeout(timerExpired, remainingWait(time)); } function trailingEdge(time) { timerId = void 0; if (trailing && lastArgs) { return invokeFunc(time); } lastArgs = lastThis = void 0; return result; } function cancel() { if (timerId !== void 0) { clearTimeout(timerId); } lastInvokeTime = 0; lastArgs = lastCallTime = lastThis = timerId = void 0; } function flush() { return timerId === void 0 ? result : trailingEdge(now()); } function debounced() { var time = now(), isInvoking = shouldInvoke(time); lastArgs = arguments; lastThis = this; lastCallTime = time; if (isInvoking) { if (timerId === void 0) { return leadingEdge(lastCallTime); } if (maxing) { timerId = setTimeout(timerExpired, wait); return invokeFunc(lastCallTime); } } if (timerId === void 0) { timerId = setTimeout(timerExpired, wait); } return result; } debounced.cancel = cancel; debounced.flush = flush; return debounced; } function throttle(func, wait, options) { var leading = true, trailing = true; if (typeof func != "function") { throw new TypeError(FUNC_ERROR_TEXT); } if (isObject(options)) { leading = "leading" in options ? !!options.leading : leading; trailing = "trailing" in options ? !!options.trailing : trailing; } return debounce(func, wait, { "leading": leading, "maxWait": wait, "trailing": trailing }); } function isObject(value) { var type = typeof value; return !!value && (type == "object" || type == "function"); } function isObjectLike(value) { return !!value && typeof value == "object"; } function isSymbol2(value) { return typeof value == "symbol" || isObjectLike(value) && objectToString.call(value) == symbolTag; } function toNumber(value) { if (typeof value == "number") { return value; } if (isSymbol2(value)) { return NAN; } if (isObject(value)) { var other = typeof value.valueOf == "function" ? value.valueOf() : value; value = isObject(other) ? other + "" : other; } if (typeof value != "string") { return value === 0 ? value : +value; } value = value.replace(reTrim, ""); var isBinary = reIsBinary.test(value); return isBinary || reIsOctal.test(value) ? freeParseInt(value.slice(2), isBinary ? 2 : 8) : reIsBadHex.test(value) ? NAN : +value; } module2.exports = throttle; } }); // ../node_modules/.pnpm/hanji@0.0.5/node_modules/hanji/index.js var require_hanji = __commonJS({ "../node_modules/.pnpm/hanji@0.0.5/node_modules/hanji/index.js"(exports2) { "use strict"; var __awaiter2 = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function(resolve2) { resolve2(value); }); } return new (P || (P = Promise))(function(resolve2, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e4) { reject(e4); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e4) { reject(e4); } } function step(result) { result.done ? resolve2(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; var __importDefault2 = exports2 && exports2.__importDefault || function(mod) { return mod && mod.__esModule ? mod : { "default": mod }; }; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.onTerminate = exports2.renderWithTask = exports2.render = exports2.TaskTerminal = exports2.TaskView = exports2.Terminal = exports2.deferred = exports2.SelectState = exports2.Prompt = void 0; var readline_1 = require_readline(); var sisteransi_1 = require_src(); var utils_1 = require_utils(); var lodash_throttle_1 = __importDefault2(require_lodash()); var Prompt3 = class { constructor() { this.attachCallbacks = []; this.detachCallbacks = []; this.inputCallbacks = []; } requestLayout() { this.terminal.requestLayout(); } on(type, callback) { if (type === "attach") { this.attachCallbacks.push(callback); } else if (type === "detach") { this.detachCallbacks.push(callback); } else if (type === "input") { this.inputCallbacks.push(callback); } } attach(terminal) { this.terminal = terminal; this.attachCallbacks.forEach((it) => it(terminal)); } detach(terminal) { this.detachCallbacks.forEach((it) => it(terminal)); this.terminal = void 0; } input(str, key) { this.inputCallbacks.forEach((it) => it(str, key)); } }; exports2.Prompt = Prompt3; var SelectState3 = class { constructor(items) { this.items = items; this.selectedIdx = 0; } bind(prompt) { prompt.on("input", (str, key) => { const invalidate = this.consume(str, key); if (invalidate) prompt.requestLayout(); }); } consume(str, key) { if (!key) return false; if (key.name === "down") { this.selectedIdx = (this.selectedIdx + 1) % this.items.length; return true; } if (key.name === "up") { this.selectedIdx -= 1; this.selectedIdx = this.selectedIdx < 0 ? this.items.length - 1 : this.selectedIdx; return true; } return false; } }; exports2.SelectState = SelectState3; var deferred = () => { let resolve2; let reject; const promise = new Promise((res, rej) => { resolve2 = res; reject = rej; }); return { resolve: resolve2, reject, promise }; }; exports2.deferred = deferred; var Terminal = class { constructor(view5, stdin, stdout, closable) { this.view = view5; this.stdin = stdin; this.stdout = stdout; this.closable = closable; this.text = ""; this.status = "idle"; if (this.stdin.isTTY) this.stdin.setRawMode(true); const keypress = (str, key) => { if (key.name === "c" && key.ctrl === true) { this.requestLayout(); this.view.detach(this); this.tearDown(keypress); if (terminateHandler) { terminateHandler(this.stdin, this.stdout); return; } this.stdout.write(` ^C `); process.exit(1); } if (key.name === "escape") { this.status = "aborted"; this.requestLayout(); this.view.detach(this); this.tearDown(keypress); this.resolve({ status: "aborted", data: void 0 }); return; } if (key.name === "return") { this.status = "submitted"; this.requestLayout(); this.view.detach(this); this.tearDown(keypress); this.resolve({ status: "submitted", data: this.view.result() }); return; } view5.input(str, key); }; this.stdin.on("keypress", keypress); this.view.attach(this); const { resolve: resolve2, promise } = (0, exports2.deferred)(); this.resolve = resolve2; this.promise = promise; this.renderFunc = (0, lodash_throttle_1.default)((str) => { this.stdout.write(str); }); } tearDown(keypress) { this.stdout.write(sisteransi_1.cursor.show); this.stdin.removeListener("keypress", keypress); if (this.stdin.isTTY) this.stdin.setRawMode(false); this.closable.close(); } result() { return this.promise; } toggleCursor(state2) { if (state2 === "hide") { this.stdout.write(sisteransi_1.cursor.hide); } else { this.stdout.write(sisteransi_1.cursor.show); } } requestLayout() { const string2 = this.view.render(this.status); const clearPrefix = this.text ? (0, utils_1.clear)(this.text, this.stdout.columns) : ""; this.text = string2; this.renderFunc(`${clearPrefix}${string2}`); } }; exports2.Terminal = Terminal; var TaskView2 = class { constructor() { this.attachCallbacks = []; this.detachCallbacks = []; } requestLayout() { this.terminal.requestLayout(); } attach(terminal) { this.terminal = terminal; this.attachCallbacks.forEach((it) => it(terminal)); } detach(terminal) { this.detachCallbacks.forEach((it) => it(terminal)); this.terminal = void 0; } on(type, callback) { if (type === "attach") { this.attachCallbacks.push(callback); } else if (type === "detach") { this.detachCallbacks.push(callback); } } }; exports2.TaskView = TaskView2; var TaskTerminal = class { constructor(view5, stdout) { this.view = view5; this.stdout = stdout; this.text = ""; this.view.attach(this); } requestLayout() { const string2 = this.view.render("pending"); const clearPrefix = this.text ? (0, utils_1.clear)(this.text, this.stdout.columns) : ""; this.text = string2; this.stdout.write(`${clearPrefix}${string2}`); } clear() { const string2 = this.view.render("done"); this.view.detach(this); const clearPrefix = this.text ? (0, utils_1.clear)(this.text, this.stdout.columns) : ""; this.stdout.write(`${clearPrefix}${string2}`); } }; exports2.TaskTerminal = TaskTerminal; function render10(view5) { const { stdin, stdout, closable } = (0, readline_1.prepareReadLine)(); if (view5 instanceof Prompt3) { const terminal = new Terminal(view5, stdin, stdout, closable); terminal.requestLayout(); return terminal.result(); } stdout.write(`${view5} `); closable.close(); return; } exports2.render = render10; function renderWithTask7(view5, task) { return __awaiter2(this, void 0, void 0, function* () { const terminal = new TaskTerminal(view5, process.stdout); terminal.requestLayout(); const result = yield task; terminal.clear(); return result; }); } exports2.renderWithTask = renderWithTask7; var terminateHandler; function onTerminate(callback) { terminateHandler = callback; } exports2.onTerminate = onTerminate; } }); // ../node_modules/.pnpm/zod@3.25.42/node_modules/zod/dist/esm/v3/helpers/util.js var util, objectUtil, ZodParsedType, getParsedType; var init_util = __esm({ "../node_modules/.pnpm/zod@3.25.42/node_modules/zod/dist/esm/v3/helpers/util.js"() { (function(util2) { util2.assertEqual = (_3) => { }; function assertIs(_arg) { } util2.assertIs = assertIs; function assertNever(_x) { throw new Error(); }