opencommit
Version:
Auto-generate impressive commits in 1 second. Killing lame commits with AI 🤯🔫
1,514 lines (1,490 loc) • 3.97 MB
JavaScript
#!/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, all3) => {
for (var name in all3)
__defProp(target, name, { get: all3[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
));
// node_modules/sisteransi/src/index.js
var require_src = __commonJS({
"node_modules/sisteransi/src/index.js"(exports2, module2) {
"use strict";
var ESC = "\x1B";
var CSI = `${ESC}[`;
var beep = "\x07";
var cursor = {
to(x5, y6) {
if (!y6) return `${CSI}${x5 + 1}G`;
return `${CSI}${y6 + 1};${x5 + 1}H`;
},
move(x5, y6) {
let ret = "";
if (x5 < 0) ret += `${CSI}${-x5}D`;
else if (x5 > 0) ret += `${CSI}${x5}C`;
if (y6 < 0) ret += `${CSI}${-y6}A`;
else if (y6 > 0) ret += `${CSI}${y6}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 i3 = 0; i3 < count; i3++)
clear += this.line + (i3 < count - 1 ? cursor.up() : "");
if (count)
clear += cursor.left;
return clear;
}
};
module2.exports = { cursor, scroll, erase, beep };
}
});
// node_modules/picocolors/picocolors.js
var require_picocolors = __commonJS({
"node_modules/picocolors/picocolors.js"(exports2, module2) {
var p4 = process || {};
var argv = p4.argv || [];
var env2 = p4.env || {};
var isColorSupported = !(!!env2.NO_COLOR || argv.includes("--no-color")) && (!!env2.FORCE_COLOR || argv.includes("--color") || p4.platform === "win32" || (p4.stdout || {}).isTTY && env2.TERM !== "dumb" || !!env2.CI);
var formatter = (open, close, replace = open) => (input) => {
let string = "" + input, index = string.indexOf(close, open.length);
return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close;
};
var replaceClose = (string, close, replace, index) => {
let result = "", cursor = 0;
do {
result += string.substring(cursor, index) + replace;
cursor = index + close.length;
index = string.indexOf(close, cursor);
} while (~index);
return result + string.substring(cursor);
};
var createColors = (enabled2 = isColorSupported) => {
let f4 = enabled2 ? formatter : () => String;
return {
isColorSupported: enabled2,
reset: f4("\x1B[0m", "\x1B[0m"),
bold: f4("\x1B[1m", "\x1B[22m", "\x1B[22m\x1B[1m"),
dim: f4("\x1B[2m", "\x1B[22m", "\x1B[22m\x1B[2m"),
italic: f4("\x1B[3m", "\x1B[23m"),
underline: f4("\x1B[4m", "\x1B[24m"),
inverse: f4("\x1B[7m", "\x1B[27m"),
hidden: f4("\x1B[8m", "\x1B[28m"),
strikethrough: f4("\x1B[9m", "\x1B[29m"),
black: f4("\x1B[30m", "\x1B[39m"),
red: f4("\x1B[31m", "\x1B[39m"),
green: f4("\x1B[32m", "\x1B[39m"),
yellow: f4("\x1B[33m", "\x1B[39m"),
blue: f4("\x1B[34m", "\x1B[39m"),
magenta: f4("\x1B[35m", "\x1B[39m"),
cyan: f4("\x1B[36m", "\x1B[39m"),
white: f4("\x1B[37m", "\x1B[39m"),
gray: f4("\x1B[90m", "\x1B[39m"),
bgBlack: f4("\x1B[40m", "\x1B[49m"),
bgRed: f4("\x1B[41m", "\x1B[49m"),
bgGreen: f4("\x1B[42m", "\x1B[49m"),
bgYellow: f4("\x1B[43m", "\x1B[49m"),
bgBlue: f4("\x1B[44m", "\x1B[49m"),
bgMagenta: f4("\x1B[45m", "\x1B[49m"),
bgCyan: f4("\x1B[46m", "\x1B[49m"),
bgWhite: f4("\x1B[47m", "\x1B[49m"),
blackBright: f4("\x1B[90m", "\x1B[39m"),
redBright: f4("\x1B[91m", "\x1B[39m"),
greenBright: f4("\x1B[92m", "\x1B[39m"),
yellowBright: f4("\x1B[93m", "\x1B[39m"),
blueBright: f4("\x1B[94m", "\x1B[39m"),
magentaBright: f4("\x1B[95m", "\x1B[39m"),
cyanBright: f4("\x1B[96m", "\x1B[39m"),
whiteBright: f4("\x1B[97m", "\x1B[39m"),
bgBlackBright: f4("\x1B[100m", "\x1B[49m"),
bgRedBright: f4("\x1B[101m", "\x1B[49m"),
bgGreenBright: f4("\x1B[102m", "\x1B[49m"),
bgYellowBright: f4("\x1B[103m", "\x1B[49m"),
bgBlueBright: f4("\x1B[104m", "\x1B[49m"),
bgMagentaBright: f4("\x1B[105m", "\x1B[49m"),
bgCyanBright: f4("\x1B[106m", "\x1B[49m"),
bgWhiteBright: f4("\x1B[107m", "\x1B[49m")
};
};
module2.exports = createColors();
module2.exports.createColors = createColors;
}
});
// node_modules/isexe/windows.js
var require_windows = __commonJS({
"node_modules/isexe/windows.js"(exports2, module2) {
module2.exports = isexe;
isexe.sync = sync;
var fs7 = require("fs");
function checkPathExt(path5, options) {
var pathext = options.pathExt !== void 0 ? options.pathExt : process.env.PATHEXT;
if (!pathext) {
return true;
}
pathext = pathext.split(";");
if (pathext.indexOf("") !== -1) {
return true;
}
for (var i3 = 0; i3 < pathext.length; i3++) {
var p4 = pathext[i3].toLowerCase();
if (p4 && path5.substr(-p4.length).toLowerCase() === p4) {
return true;
}
}
return false;
}
function checkStat(stat, path5, options) {
if (!stat.isSymbolicLink() && !stat.isFile()) {
return false;
}
return checkPathExt(path5, options);
}
function isexe(path5, options, cb) {
fs7.stat(path5, function(er2, stat) {
cb(er2, er2 ? false : checkStat(stat, path5, options));
});
}
function sync(path5, options) {
return checkStat(fs7.statSync(path5), path5, options);
}
}
});
// node_modules/isexe/mode.js
var require_mode = __commonJS({
"node_modules/isexe/mode.js"(exports2, module2) {
module2.exports = isexe;
isexe.sync = sync;
var fs7 = require("fs");
function isexe(path5, options, cb) {
fs7.stat(path5, function(er2, stat) {
cb(er2, er2 ? false : checkStat(stat, options));
});
}
function sync(path5, options) {
return checkStat(fs7.statSync(path5), options);
}
function checkStat(stat, options) {
return stat.isFile() && checkMode(stat, options);
}
function checkMode(stat, options) {
var mod = stat.mode;
var uid = stat.uid;
var gid = stat.gid;
var myUid = options.uid !== void 0 ? options.uid : process.getuid && process.getuid();
var myGid = options.gid !== void 0 ? options.gid : process.getgid && process.getgid();
var u3 = parseInt("100", 8);
var g4 = parseInt("010", 8);
var o3 = parseInt("001", 8);
var ug = u3 | g4;
var ret = mod & o3 || mod & g4 && gid === myGid || mod & u3 && uid === myUid || mod & ug && myUid === 0;
return ret;
}
}
});
// node_modules/isexe/index.js
var require_isexe = __commonJS({
"node_modules/isexe/index.js"(exports2, module2) {
var fs7 = require("fs");
var core;
if (process.platform === "win32" || global.TESTING_WINDOWS) {
core = require_windows();
} else {
core = require_mode();
}
module2.exports = isexe;
isexe.sync = sync;
function isexe(path5, options, cb) {
if (typeof options === "function") {
cb = options;
options = {};
}
if (!cb) {
if (typeof Promise !== "function") {
throw new TypeError("callback not provided");
}
return new Promise(function(resolve, reject) {
isexe(path5, options || {}, function(er2, is) {
if (er2) {
reject(er2);
} else {
resolve(is);
}
});
});
}
core(path5, options || {}, function(er2, is) {
if (er2) {
if (er2.code === "EACCES" || options && options.ignoreErrors) {
er2 = null;
is = false;
}
}
cb(er2, is);
});
}
function sync(path5, options) {
try {
return core.sync(path5, options || {});
} catch (er2) {
if (options && options.ignoreErrors || er2.code === "EACCES") {
return false;
} else {
throw er2;
}
}
}
}
});
// node_modules/which/which.js
var require_which = __commonJS({
"node_modules/which/which.js"(exports2, module2) {
var isWindows = process.platform === "win32" || process.env.OSTYPE === "cygwin" || process.env.OSTYPE === "msys";
var path5 = require("path");
var COLON = isWindows ? ";" : ":";
var isexe = require_isexe();
var getNotFoundError = (cmd) => Object.assign(new Error(`not found: ${cmd}`), { code: "ENOENT" });
var getPathInfo = (cmd, opt) => {
const colon = opt.colon || COLON;
const pathEnv = cmd.match(/\//) || isWindows && cmd.match(/\\/) ? [""] : [
// windows always checks the cwd first
...isWindows ? [process.cwd()] : [],
...(opt.path || process.env.PATH || /* istanbul ignore next: very unusual */
"").split(colon)
];
const pathExtExe = isWindows ? opt.pathExt || process.env.PATHEXT || ".EXE;.CMD;.BAT;.COM" : "";
const pathExt = isWindows ? pathExtExe.split(colon) : [""];
if (isWindows) {
if (cmd.indexOf(".") !== -1 && pathExt[0] !== "")
pathExt.unshift("");
}
return {
pathEnv,
pathExt,
pathExtExe
};
};
var which = (cmd, opt, cb) => {
if (typeof opt === "function") {
cb = opt;
opt = {};
}
if (!opt)
opt = {};
const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
const found = [];
const step = (i3) => new Promise((resolve, reject) => {
if (i3 === pathEnv.length)
return opt.all && found.length ? resolve(found) : reject(getNotFoundError(cmd));
const ppRaw = pathEnv[i3];
const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
const pCmd = path5.join(pathPart, cmd);
const p4 = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
resolve(subStep(p4, i3, 0));
});
const subStep = (p4, i3, ii) => new Promise((resolve, reject) => {
if (ii === pathExt.length)
return resolve(step(i3 + 1));
const ext = pathExt[ii];
isexe(p4 + ext, { pathExt: pathExtExe }, (er2, is) => {
if (!er2 && is) {
if (opt.all)
found.push(p4 + ext);
else
return resolve(p4 + ext);
}
return resolve(subStep(p4, i3, ii + 1));
});
});
return cb ? step(0).then((res) => cb(null, res), cb) : step(0);
};
var whichSync = (cmd, opt) => {
opt = opt || {};
const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
const found = [];
for (let i3 = 0; i3 < pathEnv.length; i3++) {
const ppRaw = pathEnv[i3];
const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
const pCmd = path5.join(pathPart, cmd);
const p4 = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
for (let j4 = 0; j4 < pathExt.length; j4++) {
const cur = p4 + pathExt[j4];
try {
const is = isexe.sync(cur, { pathExt: pathExtExe });
if (is) {
if (opt.all)
found.push(cur);
else
return cur;
}
} catch (ex) {
}
}
}
if (opt.all && found.length)
return found;
if (opt.nothrow)
return null;
throw getNotFoundError(cmd);
};
module2.exports = which;
which.sync = whichSync;
}
});
// node_modules/path-key/index.js
var require_path_key = __commonJS({
"node_modules/path-key/index.js"(exports2, module2) {
"use strict";
var pathKey2 = (options = {}) => {
const environment = options.env || process.env;
const platform = options.platform || process.platform;
if (platform !== "win32") {
return "PATH";
}
return Object.keys(environment).reverse().find((key) => key.toUpperCase() === "PATH") || "Path";
};
module2.exports = pathKey2;
module2.exports.default = pathKey2;
}
});
// node_modules/cross-spawn/lib/util/resolveCommand.js
var require_resolveCommand = __commonJS({
"node_modules/cross-spawn/lib/util/resolveCommand.js"(exports2, module2) {
"use strict";
var path5 = require("path");
var which = require_which();
var getPathKey = require_path_key();
function resolveCommandAttempt(parsed, withoutPathExt) {
const env2 = parsed.options.env || process.env;
const cwd = process.cwd();
const hasCustomCwd = parsed.options.cwd != null;
const shouldSwitchCwd = hasCustomCwd && process.chdir !== void 0 && !process.chdir.disabled;
if (shouldSwitchCwd) {
try {
process.chdir(parsed.options.cwd);
} catch (err) {
}
}
let resolved;
try {
resolved = which.sync(parsed.command, {
path: env2[getPathKey({ env: env2 })],
pathExt: withoutPathExt ? path5.delimiter : void 0
});
} catch (e3) {
} finally {
if (shouldSwitchCwd) {
process.chdir(cwd);
}
}
if (resolved) {
resolved = path5.resolve(hasCustomCwd ? parsed.options.cwd : "", resolved);
}
return resolved;
}
function resolveCommand(parsed) {
return resolveCommandAttempt(parsed) || resolveCommandAttempt(parsed, true);
}
module2.exports = resolveCommand;
}
});
// node_modules/cross-spawn/lib/util/escape.js
var require_escape = __commonJS({
"node_modules/cross-spawn/lib/util/escape.js"(exports2, module2) {
"use strict";
var metaCharsRegExp = /([()\][%!^"`<>&|;, *?])/g;
function escapeCommand(arg) {
arg = arg.replace(metaCharsRegExp, "^$1");
return arg;
}
function escapeArgument(arg, doubleEscapeMetaChars) {
arg = `${arg}`;
arg = arg.replace(/(?=(\\+?)?)\1"/g, '$1$1\\"');
arg = arg.replace(/(?=(\\+?)?)\1$/, "$1$1");
arg = `"${arg}"`;
arg = arg.replace(metaCharsRegExp, "^$1");
if (doubleEscapeMetaChars) {
arg = arg.replace(metaCharsRegExp, "^$1");
}
return arg;
}
module2.exports.command = escapeCommand;
module2.exports.argument = escapeArgument;
}
});
// node_modules/shebang-regex/index.js
var require_shebang_regex = __commonJS({
"node_modules/shebang-regex/index.js"(exports2, module2) {
"use strict";
module2.exports = /^#!(.*)/;
}
});
// node_modules/shebang-command/index.js
var require_shebang_command = __commonJS({
"node_modules/shebang-command/index.js"(exports2, module2) {
"use strict";
var shebangRegex = require_shebang_regex();
module2.exports = (string = "") => {
const match = string.match(shebangRegex);
if (!match) {
return null;
}
const [path5, argument] = match[0].replace(/#! ?/, "").split(" ");
const binary = path5.split("/").pop();
if (binary === "env") {
return argument;
}
return argument ? `${binary} ${argument}` : binary;
};
}
});
// node_modules/cross-spawn/lib/util/readShebang.js
var require_readShebang = __commonJS({
"node_modules/cross-spawn/lib/util/readShebang.js"(exports2, module2) {
"use strict";
var fs7 = require("fs");
var shebangCommand = require_shebang_command();
function readShebang(command) {
const size = 150;
const buffer = Buffer.alloc(size);
let fd;
try {
fd = fs7.openSync(command, "r");
fs7.readSync(fd, buffer, 0, size, 0);
fs7.closeSync(fd);
} catch (e3) {
}
return shebangCommand(buffer.toString());
}
module2.exports = readShebang;
}
});
// node_modules/cross-spawn/lib/parse.js
var require_parse = __commonJS({
"node_modules/cross-spawn/lib/parse.js"(exports2, module2) {
"use strict";
var path5 = require("path");
var resolveCommand = require_resolveCommand();
var escape2 = require_escape();
var readShebang = require_readShebang();
var isWin = process.platform === "win32";
var isExecutableRegExp = /\.(?:com|exe)$/i;
var isCmdShimRegExp = /node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;
function detectShebang(parsed) {
parsed.file = resolveCommand(parsed);
const shebang = parsed.file && readShebang(parsed.file);
if (shebang) {
parsed.args.unshift(parsed.file);
parsed.command = shebang;
return resolveCommand(parsed);
}
return parsed.file;
}
function parseNonShell(parsed) {
if (!isWin) {
return parsed;
}
const commandFile = detectShebang(parsed);
const needsShell = !isExecutableRegExp.test(commandFile);
if (parsed.options.forceShell || needsShell) {
const needsDoubleEscapeMetaChars = isCmdShimRegExp.test(commandFile);
parsed.command = path5.normalize(parsed.command);
parsed.command = escape2.command(parsed.command);
parsed.args = parsed.args.map((arg) => escape2.argument(arg, needsDoubleEscapeMetaChars));
const shellCommand = [parsed.command].concat(parsed.args).join(" ");
parsed.args = ["/d", "/s", "/c", `"${shellCommand}"`];
parsed.command = process.env.comspec || "cmd.exe";
parsed.options.windowsVerbatimArguments = true;
}
return parsed;
}
function parse(command, args, options) {
if (args && !Array.isArray(args)) {
options = args;
args = null;
}
args = args ? args.slice(0) : [];
options = Object.assign({}, options);
const parsed = {
command,
args,
options,
file: void 0,
original: {
command,
args
}
};
return options.shell ? parsed : parseNonShell(parsed);
}
module2.exports = parse;
}
});
// node_modules/cross-spawn/lib/enoent.js
var require_enoent = __commonJS({
"node_modules/cross-spawn/lib/enoent.js"(exports2, module2) {
"use strict";
var isWin = process.platform === "win32";
function notFoundError(original, syscall) {
return Object.assign(new Error(`${syscall} ${original.command} ENOENT`), {
code: "ENOENT",
errno: "ENOENT",
syscall: `${syscall} ${original.command}`,
path: original.command,
spawnargs: original.args
});
}
function hookChildProcess(cp, parsed) {
if (!isWin) {
return;
}
const originalEmit = cp.emit;
cp.emit = function(name, arg1) {
if (name === "exit") {
const err = verifyENOENT(arg1, parsed);
if (err) {
return originalEmit.call(cp, "error", err);
}
}
return originalEmit.apply(cp, arguments);
};
}
function verifyENOENT(status, parsed) {
if (isWin && status === 1 && !parsed.file) {
return notFoundError(parsed.original, "spawn");
}
return null;
}
function verifyENOENTSync(status, parsed) {
if (isWin && status === 1 && !parsed.file) {
return notFoundError(parsed.original, "spawnSync");
}
return null;
}
module2.exports = {
hookChildProcess,
verifyENOENT,
verifyENOENTSync,
notFoundError
};
}
});
// node_modules/cross-spawn/index.js
var require_cross_spawn = __commonJS({
"node_modules/cross-spawn/index.js"(exports2, module2) {
"use strict";
var cp = require("child_process");
var parse = require_parse();
var enoent = require_enoent();
function spawn(command, args, options) {
const parsed = parse(command, args, options);
const spawned = cp.spawn(parsed.command, parsed.args, parsed.options);
enoent.hookChildProcess(spawned, parsed);
return spawned;
}
function spawnSync(command, args, options) {
const parsed = parse(command, args, options);
const result = cp.spawnSync(parsed.command, parsed.args, parsed.options);
result.error = result.error || enoent.verifyENOENTSync(result.status, parsed);
return result;
}
module2.exports = spawn;
module2.exports.spawn = spawn;
module2.exports.sync = spawnSync;
module2.exports._parse = parse;
module2.exports._enoent = enoent;
}
});
// node_modules/signal-exit/signals.js
var require_signals = __commonJS({
"node_modules/signal-exit/signals.js"(exports2, module2) {
module2.exports = [
"SIGABRT",
"SIGALRM",
"SIGHUP",
"SIGINT",
"SIGTERM"
];
if (process.platform !== "win32") {
module2.exports.push(
"SIGVTALRM",
"SIGXCPU",
"SIGXFSZ",
"SIGUSR2",
"SIGTRAP",
"SIGSYS",
"SIGQUIT",
"SIGIOT"
// should detect profiler and enable/disable accordingly.
// see #21
// 'SIGPROF'
);
}
if (process.platform === "linux") {
module2.exports.push(
"SIGIO",
"SIGPOLL",
"SIGPWR",
"SIGSTKFLT",
"SIGUNUSED"
);
}
}
});
// node_modules/signal-exit/index.js
var require_signal_exit = __commonJS({
"node_modules/signal-exit/index.js"(exports2, module2) {
var process9 = global.process;
var processOk = function(process10) {
return process10 && typeof process10 === "object" && typeof process10.removeListener === "function" && typeof process10.emit === "function" && typeof process10.reallyExit === "function" && typeof process10.listeners === "function" && typeof process10.kill === "function" && typeof process10.pid === "number" && typeof process10.on === "function";
};
if (!processOk(process9)) {
module2.exports = function() {
return function() {
};
};
} else {
assert = require("assert");
signals = require_signals();
isWin = /^win/i.test(process9.platform);
EE = require("events");
if (typeof EE !== "function") {
EE = EE.EventEmitter;
}
if (process9.__signal_exit_emitter__) {
emitter = process9.__signal_exit_emitter__;
} else {
emitter = process9.__signal_exit_emitter__ = new EE();
emitter.count = 0;
emitter.emitted = {};
}
if (!emitter.infinite) {
emitter.setMaxListeners(Infinity);
emitter.infinite = true;
}
module2.exports = function(cb, opts) {
if (!processOk(global.process)) {
return function() {
};
}
assert.equal(typeof cb, "function", "a callback must be provided for exit handler");
if (loaded === false) {
load();
}
var ev = "exit";
if (opts && opts.alwaysLast) {
ev = "afterexit";
}
var remove = function() {
emitter.removeListener(ev, cb);
if (emitter.listeners("exit").length === 0 && emitter.listeners("afterexit").length === 0) {
unload();
}
};
emitter.on(ev, cb);
return remove;
};
unload = function unload2() {
if (!loaded || !processOk(global.process)) {
return;
}
loaded = false;
signals.forEach(function(sig) {
try {
process9.removeListener(sig, sigListeners[sig]);
} catch (er2) {
}
});
process9.emit = originalProcessEmit;
process9.reallyExit = originalProcessReallyExit;
emitter.count -= 1;
};
module2.exports.unload = unload;
emit = function emit2(event, code, signal) {
if (emitter.emitted[event]) {
return;
}
emitter.emitted[event] = true;
emitter.emit(event, code, signal);
};
sigListeners = {};
signals.forEach(function(sig) {
sigListeners[sig] = function listener() {
if (!processOk(global.process)) {
return;
}
var listeners = process9.listeners(sig);
if (listeners.length === emitter.count) {
unload();
emit("exit", null, sig);
emit("afterexit", null, sig);
if (isWin && sig === "SIGHUP") {
sig = "SIGINT";
}
process9.kill(process9.pid, sig);
}
};
});
module2.exports.signals = function() {
return signals;
};
loaded = false;
load = function load2() {
if (loaded || !processOk(global.process)) {
return;
}
loaded = true;
emitter.count += 1;
signals = signals.filter(function(sig) {
try {
process9.on(sig, sigListeners[sig]);
return true;
} catch (er2) {
return false;
}
});
process9.emit = processEmit;
process9.reallyExit = processReallyExit;
};
module2.exports.load = load;
originalProcessReallyExit = process9.reallyExit;
processReallyExit = function processReallyExit2(code) {
if (!processOk(global.process)) {
return;
}
process9.exitCode = code || /* istanbul ignore next */
0;
emit("exit", process9.exitCode, null);
emit("afterexit", process9.exitCode, null);
originalProcessReallyExit.call(process9, process9.exitCode);
};
originalProcessEmit = process9.emit;
processEmit = function processEmit2(ev, arg) {
if (ev === "exit" && processOk(global.process)) {
if (arg !== void 0) {
process9.exitCode = arg;
}
var ret = originalProcessEmit.apply(this, arguments);
emit("exit", process9.exitCode, null);
emit("afterexit", process9.exitCode, null);
return ret;
} else {
return originalProcessEmit.apply(this, arguments);
}
};
}
var assert;
var signals;
var isWin;
var EE;
var emitter;
var unload;
var emit;
var sigListeners;
var loaded;
var load;
var originalProcessReallyExit;
var processReallyExit;
var originalProcessEmit;
var processEmit;
}
});
// node_modules/get-stream/buffer-stream.js
var require_buffer_stream = __commonJS({
"node_modules/get-stream/buffer-stream.js"(exports2, module2) {
"use strict";
var { PassThrough: PassThroughStream } = require("stream");
module2.exports = (options) => {
options = { ...options };
const { array } = options;
let { encoding } = options;
const isBuffer2 = encoding === "buffer";
let objectMode = false;
if (array) {
objectMode = !(encoding || isBuffer2);
} else {
encoding = encoding || "utf8";
}
if (isBuffer2) {
encoding = null;
}
const stream4 = new PassThroughStream({ objectMode });
if (encoding) {
stream4.setEncoding(encoding);
}
let length = 0;
const chunks = [];
stream4.on("data", (chunk) => {
chunks.push(chunk);
if (objectMode) {
length = chunks.length;
} else {
length += chunk.length;
}
});
stream4.getBufferedValue = () => {
if (array) {
return chunks;
}
return isBuffer2 ? Buffer.concat(chunks, length) : chunks.join("");
};
stream4.getBufferedLength = () => length;
return stream4;
};
}
});
// node_modules/get-stream/index.js
var require_get_stream = __commonJS({
"node_modules/get-stream/index.js"(exports2, module2) {
"use strict";
var { constants: BufferConstants } = require("buffer");
var stream4 = require("stream");
var { promisify } = require("util");
var bufferStream = require_buffer_stream();
var streamPipelinePromisified = promisify(stream4.pipeline);
var MaxBufferError = class extends Error {
constructor() {
super("maxBuffer exceeded");
this.name = "MaxBufferError";
}
};
async function getStream3(inputStream, options) {
if (!inputStream) {
throw new Error("Expected a stream");
}
options = {
maxBuffer: Infinity,
...options
};
const { maxBuffer } = options;
const stream5 = bufferStream(options);
await new Promise((resolve, reject) => {
const rejectPromise = (error) => {
if (error && stream5.getBufferedLength() <= BufferConstants.MAX_LENGTH) {
error.bufferedData = stream5.getBufferedValue();
}
reject(error);
};
(async () => {
try {
await streamPipelinePromisified(inputStream, stream5);
resolve();
} catch (error) {
rejectPromise(error);
}
})();
stream5.on("data", () => {
if (stream5.getBufferedLength() > maxBuffer) {
rejectPromise(new MaxBufferError());
}
});
});
return stream5.getBufferedValue();
}
module2.exports = getStream3;
module2.exports.buffer = (stream5, options) => getStream3(stream5, { ...options, encoding: "buffer" });
module2.exports.array = (stream5, options) => getStream3(stream5, { ...options, array: true });
module2.exports.MaxBufferError = MaxBufferError;
}
});
// node_modules/merge-stream/index.js
var require_merge_stream = __commonJS({
"node_modules/merge-stream/index.js"(exports2, module2) {
"use strict";
var { PassThrough } = require("stream");
module2.exports = function() {
var sources = [];
var output = new PassThrough({ objectMode: true });
output.setMaxListeners(0);
output.add = add;
output.isEmpty = isEmpty;
output.on("unpipe", remove);
Array.prototype.slice.call(arguments).forEach(add);
return output;
function add(source) {
if (Array.isArray(source)) {
source.forEach(add);
return this;
}
sources.push(source);
source.once("end", remove.bind(null, source));
source.once("error", output.emit.bind(output, "error"));
source.pipe(output, { end: false });
return this;
}
function isEmpty() {
return sources.length == 0;
}
function remove(source) {
sources = sources.filter(function(it2) {
return it2 !== source;
});
if (!sources.length && output.readable) {
output.end();
}
}
};
}
});
// node_modules/dotenv/package.json
var require_package = __commonJS({
"node_modules/dotenv/package.json"(exports2, module2) {
module2.exports = {
name: "dotenv",
version: "16.4.5",
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",
"lint-readme": "standard-markdown",
pretest: "npm run lint && npm run dts-check",
test: "tap tests/*.js --100 -Rspec",
"test:coverage": "tap --coverage-report=lcov",
prerelease: "npm test",
release: "standard-version"
},
repository: {
type: "git",
url: "git://github.com/motdotla/dotenv.git"
},
funding: "https://dotenvx.com",
keywords: [
"dotenv",
"env",
".env",
"environment",
"variables",
"config",
"settings"
],
readmeFilename: "README.md",
license: "BSD-2-Clause",
devDependencies: {
"@definitelytyped/dtslint": "^0.0.133",
"@types/node": "^18.11.3",
decache: "^4.6.1",
sinon: "^14.0.1",
standard: "^17.0.0",
"standard-markdown": "^7.1.0",
"standard-version": "^9.5.0",
tap: "^16.3.0",
tar: "^6.1.11",
typescript: "^4.8.4"
},
engines: {
node: ">=12"
},
browser: {
fs: false
}
};
}
});
// node_modules/dotenv/lib/main.js
var require_main = __commonJS({
"node_modules/dotenv/lib/main.js"(exports2, module2) {
var fs7 = require("fs");
var path5 = require("path");
var os4 = require("os");
var crypto3 = require("crypto");
var packageJson = require_package();
var version = packageJson.version;
var LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg;
function parse(src) {
const obj = {};
let lines = src.toString();
lines = lines.replace(/\r\n?/mg, "\n");
let match;
while ((match = LINE.exec(lines)) != null) {
const key = match[1];
let value = match[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 err = new Error(`MISSING_DATA: Cannot parse ${vaultPath} for an unknown reason`);
err.code = "MISSING_DATA";
throw err;
}
const keys = _dotenvKey(options).split(",");
const length = keys.length;
let decrypted;
for (let i3 = 0; i3 < length; i3++) {
try {
const key = keys[i3].trim();
const attrs = _instructions(result, key);
decrypted = DotenvModule.decrypt(attrs.ciphertext, attrs.key);
break;
} catch (error) {
if (i3 + 1 >= length) {
throw error;
}
}
}
return DotenvModule.parse(decrypted);
}
function _log(message) {
console.log(`[dotenv@${version}][INFO] ${message}`);
}
function _warn(message) {
console.log(`[dotenv@${version}][WARN] ${message}`);
}
function _debug(message) {
console.log(`[dotenv@${version}][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 (error) {
if (error.code === "ERR_INVALID_URL") {
const err = new Error("INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=development");
err.code = "INVALID_DOTENV_KEY";
throw err;
}
throw error;
}
const key = uri.password;
if (!key) {
const err = new Error("INVALID_DOTENV_KEY: Missing key part");
err.code = "INVALID_DOTENV_KEY";
throw err;
}
const environment = uri.searchParams.get("environment");
if (!environment) {
const err = new Error("INVALID_DOTENV_KEY: Missing environment part");
err.code = "INVALID_DOTENV_KEY";
throw err;
}
const environmentKey = `DOTENV_VAULT_${environment.toUpperCase()}`;
const ciphertext = result.parsed[environmentKey];
if (!ciphertext) {
const err = new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${environmentKey} in your .env.vault file.`);
err.code = "NOT_FOUND_DOTENV_ENVIRONMENT";
throw err;
}
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 = path5.resolve(process.cwd(), ".env.vault");
}
if (fs7.existsSync(possibleVaultPath)) {
return possibleVaultPath;
}
return null;
}
function _resolveHome(envPath) {
return envPath[0] === "~" ? path5.join(os4.homedir(), envPath.slice(1)) : envPath;
}
function _configVault(options) {
_log("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 = path5.resolve(process.cwd(), ".env");
let encoding = "utf8";
const debug3 = Boolean(options && options.debug);
if (options && options.encoding) {
encoding = options.encoding;
} else {
if (debug3) {
_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 path6 of optionPaths) {
try {
const parsed = DotenvModule.parse(fs7.readFileSync(path6, { encoding }));
DotenvModule.populate(parsedAll, parsed, options);
} catch (e3) {
if (debug3) {
_debug(`Failed to load ${path6} ${e3.message}`);
}
lastError = e3;
}
}
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 config7(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 = crypto3.createDecipheriv("aes-256-gcm", key, nonce);
aesgcm.setAuthTag(authTag);
return `${aesgcm.update(ciphertext)}${aesgcm.final()}`;
} catch (error) {
const isRange = error instanceof RangeError;
const invalidKeyLength = error.message === "Invalid key length";
const decryptionFailed = error.message === "Unsupported state or unable to authenticate data";
if (isRange || invalidKeyLength) {
const err = new Error("INVALID_DOTENV_KEY: It must be 64 characters long (or more)");
err.code = "INVALID_DOTENV_KEY";
throw err;
} else if (decryptionFailed) {
const err = new Error("DECRYPTION_FAILED: Please check your DOTENV_KEY");
err.code = "DECRYPTION_FAILED";
throw err;
} else {
throw error;
}
}
}
function populate(processEnv, parsed, options = {}) {
const debug3 = Boolean(options && options.debug);
const override = Boolean(options && options.override);
if (typeof parsed !== "object") {
const err = new Error("OBJECT_REQUIRED: Please check the processEnv argument being passed to populate");
err.code = "OBJECT_REQUIRED";
throw err;
}
for (const key of Object.keys(parsed)) {
if (Object.prototype.hasOwnProperty.call(processEnv, key)) {
if (override === true) {
processEnv[key] = parsed[key];
}
if (debug3) {
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: config7,
decrypt,
parse,
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/ini/lib/ini.js
var require_ini = __commonJS({
"node_modules/ini/lib/ini.js"(exports2, module2) {
var { hasOwnProperty: hasOwnProperty2 } = Object.prototype;
var eol = typeof process !== "undefined" && process.platform === "win32" ? "\r\n" : "\n";
var encode3 = (obj, opt) => {
const children = [];
let out = "";
if (typeof opt === "string") {
opt = {
section: opt,
whitespace: false
};
} else {
opt = opt || /* @__PURE__ */ Object.create(null);
opt.whitespace = opt.whitespace === true;
}
const separator = opt.whitespace ? " = " : "=";
for (const k7 of Object.keys(obj)) {
const val = obj[k7];
if (val && Array.isArray(val)) {
for (const item of val) {
out += safe(k7 + "[]") + separator + safe(item) + eol;
}
} else if (val && typeof val === "object") {
children.push(k7);
} else {
out += safe(k7) + separator + safe(val) + eol;
}
}
if (opt.section && out.length) {
out = "[" + safe(opt.section) + "]" + eol + out;
}
for (const k7 of children) {
const nk = dotSplit(k7).join("\\.");
const section = (opt.section ? opt.section + "." : "") + nk;
const { whitespace } = opt;
const child = encode3(obj[k7], {
section,
whitespace
});
if (out.length && child.length) {
out += eol;
}
out += child;
}
return out;
};
var dotSplit = (str2) => str2.replace(/\1/g, "LITERAL\\1LITERAL").replace(/\\\./g, "").split(/\./).map((part) => part.replace(/\1/g, "\\.").replace(/\2LITERAL\\1LITERAL\2/g, ""));
var decode = (str2) => {
const out = /* @__PURE__ */ Object.create(null);
let p4 = out;
let section = null;
const re3 = /^\[([^\]]*)\]$|^([^=]+)(=(.*))?$/i;
const lines = str2.split(/[\r\n]+/g);
for (const line of lines) {
if (!line || line.match(/^\s*[;#]/)) {
continue;
}
const match = line.match(re3);
if (!match) {
continue;
}
if (match[1] !== void 0) {
section = unsafe(match[1]);
if (section === "__proto__") {
p4 = /* @__PURE__ */ Object.create(null);
continue;
}
p4 = out[section] = out[section] || /* @__PURE__ */ Object.create(null);
continue;
}
const keyRaw = unsafe(match[2]);
const isArray2 = keyRaw.length > 2 && keyRaw.slice(-2) === "[]";
const key = isArray2 ? keyRaw.slice(0, -2) : keyRaw;
if (key === "__proto__") {
continue;
}
const valueRaw = match[3] ? unsafe(match[4]) : true;
const value = valueRaw === "true" || valueRaw === "false" || valueRaw === "null" ? JSON.parse(valueRaw) : valueRaw;
if (isArray2) {
if (!hasOwnProperty2.call(p4, key)) {
p4[key] = [];
} else if (!Array.isArray(p4[key])) {
p4[key] = [p4[key]];
}
}
if (Array.isArray(p4[key])) {
p4[key].push(value);
} else {
p4[key] = value;
}
}
const remove = [];
for (const k7 of Object.keys(out)) {
if (!hasOwnProperty2.call(out, k7) || typeof out[k7] !== "object" || Array.isArray(out[k7])) {
continue;
}
const parts = dotSplit(k7);
p4 = out;
const l3 = parts.pop();
const nl = l3.replace(/\\\./g, ".");
for (const part of parts) {
if (part === "__proto__") {
continue;
}
if (!hasOwnProperty2.call(p4, part) || typeof p4[part] !== "object") {
p4[part] = /* @__PURE__ */ Object.create(null);
}
p4 = p4[part];
}
if (p4 === out && nl === l3) {
continue;
}
p4[nl] = out[k7];
remove.push(k7);
}
for (const del of remove) {
delete out[del];
}
return out;
};
var isQuoted = (val) => {
return val.startsWith('"') && val.endsWith('"') || val.startsWith("'") && val.endsWith("'");
};
var safe = (val) => {
if (typeof val !== "string" || val.match(/[=\r\n]/) || val.match(/^\[/) || val.length > 1 && isQuoted(val) || val !== val.trim()) {
return JSON.stringify(val);
}
return val.split(";").join("\\;").split("#").join("\\#");
};
var unsafe = (val, doUnesc) => {
val = (val || "").trim();
if (isQuoted(val)) {
if (val.charAt(0) === "'") {
val = val.slice(1, -1);
}
try {
val = JSON.parse(val);
} catch {
}
} else {
let esc = false;
let unesc = "";
for (let i3 = 0, l3 = val.length; i3 < l3; i3++) {
const c3 = val.charAt(i3);
if (esc) {
if ("\\;#".indexOf(c3) !== -1) {
unesc += c3;
} else {
unesc += "\\" + c3;
}
esc = false;
} else if (";#".indexOf(c3) !== -1) {
break;
} else if (c3 === "\\") {
esc = true;
} else {
unesc += c3;
}
}
if (esc) {
unesc += "\\";
}
return unesc.trim();
}
return val;
};
module2.exports = {
parse: decode,
decode,
stringify: encode3,
encode: encode3,
safe,
unsafe
};
}
});
// node_modules/webidl-conversions/li