@shopify/create-app
Version:
A CLI tool to create a new Shopify app.
1,392 lines • 54.4 kB
JavaScript
import {
mimicFunction
} from "./chunk-CM6ALOD7.js";
import {
require_get_stream
} from "./chunk-JGGOQOPO.js";
import {
outputContent,
outputDebug
} from "./chunk-PK2M5CKS.js";
import {
__commonJS,
__require,
__toESM,
init_cjs_shims
} from "./chunk-3XNI6LP4.js";
// ../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/windows.js
var require_windows = __commonJS({
"../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/windows.js"(exports, module) {
init_cjs_shims();
module.exports = isexe;
isexe.sync = sync;
var fs = __require("fs");
function checkPathExt(path3, options) {
var pathext = options.pathExt !== void 0 ? options.pathExt : process.env.PATHEXT;
if (!pathext || (pathext = pathext.split(";"), pathext.indexOf("") !== -1))
return !0;
for (var i = 0; i < pathext.length; i++) {
var p = pathext[i].toLowerCase();
if (p && path3.substr(-p.length).toLowerCase() === p)
return !0;
}
return !1;
}
function checkStat(stat, path3, options) {
return !stat.isSymbolicLink() && !stat.isFile() ? !1 : checkPathExt(path3, options);
}
function isexe(path3, options, cb) {
fs.stat(path3, function(er, stat) {
cb(er, er ? !1 : checkStat(stat, path3, options));
});
}
function sync(path3, options) {
return checkStat(fs.statSync(path3), path3, options);
}
}
});
// ../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/mode.js
var require_mode = __commonJS({
"../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/mode.js"(exports, module) {
init_cjs_shims();
module.exports = isexe;
isexe.sync = sync;
var fs = __require("fs");
function isexe(path3, options, cb) {
fs.stat(path3, function(er, stat) {
cb(er, er ? !1 : checkStat(stat, options));
});
}
function sync(path3, options) {
return checkStat(fs.statSync(path3), options);
}
function checkStat(stat, options) {
return stat.isFile() && checkMode(stat, options);
}
function checkMode(stat, options) {
var mod = stat.mode, uid = stat.uid, gid = stat.gid, myUid = options.uid !== void 0 ? options.uid : process.getuid && process.getuid(), myGid = options.gid !== void 0 ? options.gid : process.getgid && process.getgid(), u = parseInt("100", 8), g = parseInt("010", 8), o = parseInt("001", 8), ug = u | g, ret = mod & o || mod & g && gid === myGid || mod & u && uid === myUid || mod & ug && myUid === 0;
return ret;
}
}
});
// ../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/index.js
var require_isexe = __commonJS({
"../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/index.js"(exports, module) {
init_cjs_shims();
var fs = __require("fs"), core;
process.platform === "win32" || global.TESTING_WINDOWS ? core = require_windows() : core = require_mode();
module.exports = isexe;
isexe.sync = sync;
function isexe(path3, options, cb) {
if (typeof options == "function" && (cb = options, options = {}), !cb) {
if (typeof Promise != "function")
throw new TypeError("callback not provided");
return new Promise(function(resolve, reject) {
isexe(path3, options || {}, function(er, is) {
er ? reject(er) : resolve(is);
});
});
}
core(path3, options || {}, function(er, is) {
er && (er.code === "EACCES" || options && options.ignoreErrors) && (er = null, is = !1), cb(er, is);
});
}
function sync(path3, options) {
try {
return core.sync(path3, options || {});
} catch (er) {
if (options && options.ignoreErrors || er.code === "EACCES")
return !1;
throw er;
}
}
}
});
// ../../node_modules/.pnpm/which@2.0.2/node_modules/which/which.js
var require_which = __commonJS({
"../../node_modules/.pnpm/which@2.0.2/node_modules/which/which.js"(exports, module) {
init_cjs_shims();
var isWindows = process.platform === "win32" || process.env.OSTYPE === "cygwin" || process.env.OSTYPE === "msys", path3 = __require("path"), COLON = isWindows ? ";" : ":", isexe = require_isexe(), getNotFoundError = (cmd) => Object.assign(new Error(`not found: ${cmd}`), { code: "ENOENT" }), getPathInfo = (cmd, opt) => {
let colon = opt.colon || COLON, 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)
], pathExtExe = isWindows ? opt.pathExt || process.env.PATHEXT || ".EXE;.CMD;.BAT;.COM" : "", pathExt = isWindows ? pathExtExe.split(colon) : [""];
return isWindows && cmd.indexOf(".") !== -1 && pathExt[0] !== "" && pathExt.unshift(""), {
pathEnv,
pathExt,
pathExtExe
};
}, which = (cmd, opt, cb) => {
typeof opt == "function" && (cb = opt, opt = {}), opt || (opt = {});
let { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt), found = [], step = (i) => new Promise((resolve, reject) => {
if (i === pathEnv.length)
return opt.all && found.length ? resolve(found) : reject(getNotFoundError(cmd));
let ppRaw = pathEnv[i], pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw, pCmd = path3.join(pathPart, cmd), p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
resolve(subStep(p, i, 0));
}), subStep = (p, i, ii) => new Promise((resolve, reject) => {
if (ii === pathExt.length)
return resolve(step(i + 1));
let ext = pathExt[ii];
isexe(p + ext, { pathExt: pathExtExe }, (er, is) => {
if (!er && is)
if (opt.all)
found.push(p + ext);
else
return resolve(p + ext);
return resolve(subStep(p, i, ii + 1));
});
});
return cb ? step(0).then((res) => cb(null, res), cb) : step(0);
}, whichSync = (cmd, opt) => {
opt = opt || {};
let { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt), found = [];
for (let i = 0; i < pathEnv.length; i++) {
let ppRaw = pathEnv[i], pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw, pCmd = path3.join(pathPart, cmd), p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
for (let j = 0; j < pathExt.length; j++) {
let cur = p + pathExt[j];
try {
if (isexe.sync(cur, { pathExt: pathExtExe }))
if (opt.all)
found.push(cur);
else
return cur;
} catch {
}
}
}
if (opt.all && found.length)
return found;
if (opt.nothrow)
return null;
throw getNotFoundError(cmd);
};
module.exports = which;
which.sync = whichSync;
}
});
// ../../node_modules/.pnpm/path-key@3.1.1/node_modules/path-key/index.js
var require_path_key = __commonJS({
"../../node_modules/.pnpm/path-key@3.1.1/node_modules/path-key/index.js"(exports, module) {
"use strict";
init_cjs_shims();
var pathKey2 = (options = {}) => {
let environment = options.env || process.env;
return (options.platform || process.platform) !== "win32" ? "PATH" : Object.keys(environment).reverse().find((key) => key.toUpperCase() === "PATH") || "Path";
};
module.exports = pathKey2;
module.exports.default = pathKey2;
}
});
// ../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/resolveCommand.js
var require_resolveCommand = __commonJS({
"../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/resolveCommand.js"(exports, module) {
"use strict";
init_cjs_shims();
var path3 = __require("path"), which = require_which(), getPathKey = require_path_key();
function resolveCommandAttempt(parsed, withoutPathExt) {
let env = parsed.options.env || process.env, cwd = process.cwd(), hasCustomCwd = parsed.options.cwd != null, shouldSwitchCwd = hasCustomCwd && process.chdir !== void 0 && !process.chdir.disabled;
if (shouldSwitchCwd)
try {
process.chdir(parsed.options.cwd);
} catch {
}
let resolved;
try {
resolved = which.sync(parsed.command, {
path: env[getPathKey({ env })],
pathExt: withoutPathExt ? path3.delimiter : void 0
});
} catch {
} finally {
shouldSwitchCwd && process.chdir(cwd);
}
return resolved && (resolved = path3.resolve(hasCustomCwd ? parsed.options.cwd : "", resolved)), resolved;
}
function resolveCommand(parsed) {
return resolveCommandAttempt(parsed) || resolveCommandAttempt(parsed, !0);
}
module.exports = resolveCommand;
}
});
// ../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/escape.js
var require_escape = __commonJS({
"../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/escape.js"(exports, module) {
"use strict";
init_cjs_shims();
var metaCharsRegExp = /([()\][%!^"`<>&|;, *?])/g;
function escapeCommand(arg) {
return arg = arg.replace(metaCharsRegExp, "^$1"), arg;
}
function escapeArgument(arg, doubleEscapeMetaChars) {
return arg = `${arg}`, arg = arg.replace(/(?=(\\+?)?)\1"/g, '$1$1\\"'), arg = arg.replace(/(?=(\\+?)?)\1$/, "$1$1"), arg = `"${arg}"`, arg = arg.replace(metaCharsRegExp, "^$1"), doubleEscapeMetaChars && (arg = arg.replace(metaCharsRegExp, "^$1")), arg;
}
module.exports.command = escapeCommand;
module.exports.argument = escapeArgument;
}
});
// ../../node_modules/.pnpm/shebang-regex@3.0.0/node_modules/shebang-regex/index.js
var require_shebang_regex = __commonJS({
"../../node_modules/.pnpm/shebang-regex@3.0.0/node_modules/shebang-regex/index.js"(exports, module) {
"use strict";
init_cjs_shims();
module.exports = /^#!(.*)/;
}
});
// ../../node_modules/.pnpm/shebang-command@2.0.0/node_modules/shebang-command/index.js
var require_shebang_command = __commonJS({
"../../node_modules/.pnpm/shebang-command@2.0.0/node_modules/shebang-command/index.js"(exports, module) {
"use strict";
init_cjs_shims();
var shebangRegex = require_shebang_regex();
module.exports = (string = "") => {
let match = string.match(shebangRegex);
if (!match)
return null;
let [path3, argument] = match[0].replace(/#! ?/, "").split(" "), binary = path3.split("/").pop();
return binary === "env" ? argument : argument ? `${binary} ${argument}` : binary;
};
}
});
// ../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/readShebang.js
var require_readShebang = __commonJS({
"../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/readShebang.js"(exports, module) {
"use strict";
init_cjs_shims();
var fs = __require("fs"), shebangCommand = require_shebang_command();
function readShebang(command) {
let buffer = Buffer.alloc(150), fd;
try {
fd = fs.openSync(command, "r"), fs.readSync(fd, buffer, 0, 150, 0), fs.closeSync(fd);
} catch {
}
return shebangCommand(buffer.toString());
}
module.exports = readShebang;
}
});
// ../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/parse.js
var require_parse = __commonJS({
"../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/parse.js"(exports, module) {
"use strict";
init_cjs_shims();
var path3 = __require("path"), resolveCommand = require_resolveCommand(), escape = require_escape(), readShebang = require_readShebang(), isWin = process.platform === "win32", isExecutableRegExp = /\.(?:com|exe)$/i, isCmdShimRegExp = /node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;
function detectShebang(parsed) {
parsed.file = resolveCommand(parsed);
let shebang = parsed.file && readShebang(parsed.file);
return shebang ? (parsed.args.unshift(parsed.file), parsed.command = shebang, resolveCommand(parsed)) : parsed.file;
}
function parseNonShell(parsed) {
if (!isWin)
return parsed;
let commandFile = detectShebang(parsed), needsShell = !isExecutableRegExp.test(commandFile);
if (parsed.options.forceShell || needsShell) {
let needsDoubleEscapeMetaChars = isCmdShimRegExp.test(commandFile);
parsed.command = path3.normalize(parsed.command), parsed.command = escape.command(parsed.command), parsed.args = parsed.args.map((arg) => escape.argument(arg, needsDoubleEscapeMetaChars));
let shellCommand = [parsed.command].concat(parsed.args).join(" ");
parsed.args = ["/d", "/s", "/c", `"${shellCommand}"`], parsed.command = process.env.comspec || "cmd.exe", parsed.options.windowsVerbatimArguments = !0;
}
return parsed;
}
function parse(command, args, options) {
args && !Array.isArray(args) && (options = args, args = null), args = args ? args.slice(0) : [], options = Object.assign({}, options);
let parsed = {
command,
args,
options,
file: void 0,
original: {
command,
args
}
};
return options.shell ? parsed : parseNonShell(parsed);
}
module.exports = parse;
}
});
// ../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/enoent.js
var require_enoent = __commonJS({
"../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/enoent.js"(exports, module) {
"use strict";
init_cjs_shims();
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;
let originalEmit = cp.emit;
cp.emit = function(name, arg1) {
if (name === "exit") {
let err = verifyENOENT(arg1, parsed);
if (err)
return originalEmit.call(cp, "error", err);
}
return originalEmit.apply(cp, arguments);
};
}
function verifyENOENT(status, parsed) {
return isWin && status === 1 && !parsed.file ? notFoundError(parsed.original, "spawn") : null;
}
function verifyENOENTSync(status, parsed) {
return isWin && status === 1 && !parsed.file ? notFoundError(parsed.original, "spawnSync") : null;
}
module.exports = {
hookChildProcess,
verifyENOENT,
verifyENOENTSync,
notFoundError
};
}
});
// ../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/index.js
var require_cross_spawn = __commonJS({
"../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/index.js"(exports, module) {
"use strict";
init_cjs_shims();
var cp = __require("child_process"), parse = require_parse(), enoent = require_enoent();
function spawn(command, args, options) {
let parsed = parse(command, args, options), spawned = cp.spawn(parsed.command, parsed.args, parsed.options);
return enoent.hookChildProcess(spawned, parsed), spawned;
}
function spawnSync(command, args, options) {
let parsed = parse(command, args, options), result = cp.spawnSync(parsed.command, parsed.args, parsed.options);
return result.error = result.error || enoent.verifyENOENTSync(result.status, parsed), result;
}
module.exports = spawn;
module.exports.spawn = spawn;
module.exports.sync = spawnSync;
module.exports._parse = parse;
module.exports._enoent = enoent;
}
});
// ../../node_modules/.pnpm/signal-exit@3.0.7/node_modules/signal-exit/signals.js
var require_signals = __commonJS({
"../../node_modules/.pnpm/signal-exit@3.0.7/node_modules/signal-exit/signals.js"(exports, module) {
init_cjs_shims();
module.exports = [
"SIGABRT",
"SIGALRM",
"SIGHUP",
"SIGINT",
"SIGTERM"
];
process.platform !== "win32" && module.exports.push(
"SIGVTALRM",
"SIGXCPU",
"SIGXFSZ",
"SIGUSR2",
"SIGTRAP",
"SIGSYS",
"SIGQUIT",
"SIGIOT"
// should detect profiler and enable/disable accordingly.
// see #21
// 'SIGPROF'
);
process.platform === "linux" && module.exports.push(
"SIGIO",
"SIGPOLL",
"SIGPWR",
"SIGSTKFLT",
"SIGUNUSED"
);
}
});
// ../../node_modules/.pnpm/signal-exit@3.0.7/node_modules/signal-exit/index.js
var require_signal_exit = __commonJS({
"../../node_modules/.pnpm/signal-exit@3.0.7/node_modules/signal-exit/index.js"(exports, module) {
init_cjs_shims();
var process6 = global.process, processOk = function(process7) {
return process7 && typeof process7 == "object" && typeof process7.removeListener == "function" && typeof process7.emit == "function" && typeof process7.reallyExit == "function" && typeof process7.listeners == "function" && typeof process7.kill == "function" && typeof process7.pid == "number" && typeof process7.on == "function";
};
processOk(process6) ? (assert = __require("assert"), signals = require_signals(), isWin = /^win/i.test(process6.platform), EE = __require("events"), typeof EE != "function" && (EE = EE.EventEmitter), process6.__signal_exit_emitter__ ? emitter = process6.__signal_exit_emitter__ : (emitter = process6.__signal_exit_emitter__ = new EE(), emitter.count = 0, emitter.emitted = {}), emitter.infinite || (emitter.setMaxListeners(1 / 0), emitter.infinite = !0), module.exports = function(cb, opts) {
if (!processOk(global.process))
return function() {
};
assert.equal(typeof cb, "function", "a callback must be provided for exit handler"), loaded === !1 && load();
var ev = "exit";
opts && opts.alwaysLast && (ev = "afterexit");
var remove = function() {
emitter.removeListener(ev, cb), emitter.listeners("exit").length === 0 && emitter.listeners("afterexit").length === 0 && unload();
};
return emitter.on(ev, cb), remove;
}, unload = function() {
!loaded || !processOk(global.process) || (loaded = !1, signals.forEach(function(sig) {
try {
process6.removeListener(sig, sigListeners[sig]);
} catch {
}
}), process6.emit = originalProcessEmit, process6.reallyExit = originalProcessReallyExit, emitter.count -= 1);
}, module.exports.unload = unload, emit = function(event, code, signal) {
emitter.emitted[event] || (emitter.emitted[event] = !0, emitter.emit(event, code, signal));
}, sigListeners = {}, signals.forEach(function(sig) {
sigListeners[sig] = function() {
if (processOk(global.process)) {
var listeners = process6.listeners(sig);
listeners.length === emitter.count && (unload(), emit("exit", null, sig), emit("afterexit", null, sig), isWin && sig === "SIGHUP" && (sig = "SIGINT"), process6.kill(process6.pid, sig));
}
};
}), module.exports.signals = function() {
return signals;
}, loaded = !1, load = function() {
loaded || !processOk(global.process) || (loaded = !0, emitter.count += 1, signals = signals.filter(function(sig) {
try {
return process6.on(sig, sigListeners[sig]), !0;
} catch {
return !1;
}
}), process6.emit = processEmit, process6.reallyExit = processReallyExit);
}, module.exports.load = load, originalProcessReallyExit = process6.reallyExit, processReallyExit = function(code) {
processOk(global.process) && (process6.exitCode = code || /* istanbul ignore next */
0, emit("exit", process6.exitCode, null), emit("afterexit", process6.exitCode, null), originalProcessReallyExit.call(process6, process6.exitCode));
}, originalProcessEmit = process6.emit, processEmit = function(ev, arg) {
if (ev === "exit" && processOk(global.process)) {
arg !== void 0 && (process6.exitCode = arg);
var ret = originalProcessEmit.apply(this, arguments);
return emit("exit", process6.exitCode, null), emit("afterexit", process6.exitCode, null), ret;
} else
return originalProcessEmit.apply(this, arguments);
}) : module.exports = function() {
return function() {
};
};
var assert, signals, isWin, EE, emitter, unload, emit, sigListeners, loaded, load, originalProcessReallyExit, processReallyExit, originalProcessEmit, processEmit;
}
});
// ../../node_modules/.pnpm/merge-stream@2.0.0/node_modules/merge-stream/index.js
var require_merge_stream = __commonJS({
"../../node_modules/.pnpm/merge-stream@2.0.0/node_modules/merge-stream/index.js"(exports, module) {
"use strict";
init_cjs_shims();
var { PassThrough } = __require("stream");
module.exports = function() {
var sources = [], output = new PassThrough({ objectMode: !0 });
return output.setMaxListeners(0), output.add = add, output.isEmpty = isEmpty, output.on("unpipe", remove), Array.prototype.slice.call(arguments).forEach(add), output;
function add(source) {
return Array.isArray(source) ? (source.forEach(add), this) : (sources.push(source), source.once("end", remove.bind(null, source)), source.once("error", output.emit.bind(output, "error")), source.pipe(output, { end: !1 }), this);
}
function isEmpty() {
return sources.length == 0;
}
function remove(source) {
sources = sources.filter(function(it) {
return it !== source;
}), !sources.length && output.readable && output.end();
}
};
}
});
// ../cli-kit/dist/public/node/os.js
init_cjs_shims();
// ../../node_modules/.pnpm/execa@7.2.0/node_modules/execa/index.js
init_cjs_shims();
var import_cross_spawn = __toESM(require_cross_spawn(), 1);
import { Buffer as Buffer3 } from "node:buffer";
import path2 from "node:path";
import childProcess from "node:child_process";
import process5 from "node:process";
// ../../node_modules/.pnpm/strip-final-newline@3.0.0/node_modules/strip-final-newline/index.js
init_cjs_shims();
function stripFinalNewline(input) {
let LF = typeof input == "string" ? `
` : 10, CR = typeof input == "string" ? "\r" : 13;
return input[input.length - 1] === LF && (input = input.slice(0, -1)), input[input.length - 1] === CR && (input = input.slice(0, -1)), input;
}
// ../../node_modules/.pnpm/npm-run-path@5.3.0/node_modules/npm-run-path/index.js
init_cjs_shims();
import process2 from "node:process";
import path from "node:path";
import { fileURLToPath } from "node:url";
// ../../node_modules/.pnpm/path-key@4.0.0/node_modules/path-key/index.js
init_cjs_shims();
function pathKey(options = {}) {
let {
env = process.env,
platform = process.platform
} = options;
return platform !== "win32" ? "PATH" : Object.keys(env).reverse().find((key) => key.toUpperCase() === "PATH") || "Path";
}
// ../../node_modules/.pnpm/npm-run-path@5.3.0/node_modules/npm-run-path/index.js
var npmRunPath = ({
cwd = process2.cwd(),
path: pathOption = process2.env[pathKey()],
preferLocal = !0,
execPath = process2.execPath,
addExecPath = !0
} = {}) => {
let cwdString = cwd instanceof URL ? fileURLToPath(cwd) : cwd, cwdPath = path.resolve(cwdString), result = [];
return preferLocal && applyPreferLocal(result, cwdPath), addExecPath && applyExecPath(result, execPath, cwdPath), [...result, pathOption].join(path.delimiter);
}, applyPreferLocal = (result, cwdPath) => {
let previous;
for (; previous !== cwdPath; )
result.push(path.join(cwdPath, "node_modules/.bin")), previous = cwdPath, cwdPath = path.resolve(cwdPath, "..");
}, applyExecPath = (result, execPath, cwdPath) => {
let execPathString = execPath instanceof URL ? fileURLToPath(execPath) : execPath;
result.push(path.resolve(cwdPath, execPathString, ".."));
}, npmRunPathEnv = ({ env = process2.env, ...options } = {}) => {
env = { ...env };
let pathName = pathKey({ env });
return options.path = env[pathName], env[pathName] = npmRunPath(options), env;
};
// ../../node_modules/.pnpm/onetime@6.0.0/node_modules/onetime/index.js
init_cjs_shims();
var calledFunctions = /* @__PURE__ */ new WeakMap(), onetime = (function_, options = {}) => {
if (typeof function_ != "function")
throw new TypeError("Expected a function");
let returnValue, callCount = 0, functionName = function_.displayName || function_.name || "<anonymous>", onetime2 = function(...arguments_) {
if (calledFunctions.set(onetime2, ++callCount), callCount === 1)
returnValue = function_.apply(this, arguments_), function_ = null;
else if (options.throw === !0)
throw new Error(`Function \`${functionName}\` can only be called once`);
return returnValue;
};
return mimicFunction(onetime2, function_), calledFunctions.set(onetime2, callCount), onetime2;
};
onetime.callCount = (function_) => {
if (!calledFunctions.has(function_))
throw new Error(`The given function \`${function_.name}\` is not wrapped by the \`onetime\` package`);
return calledFunctions.get(function_);
};
var onetime_default = onetime;
// ../../node_modules/.pnpm/execa@7.2.0/node_modules/execa/lib/error.js
init_cjs_shims();
import process3 from "node:process";
// ../../node_modules/.pnpm/human-signals@4.3.1/node_modules/human-signals/build/src/main.js
init_cjs_shims();
import { constants as constants2 } from "node:os";
// ../../node_modules/.pnpm/human-signals@4.3.1/node_modules/human-signals/build/src/realtime.js
init_cjs_shims();
var getRealtimeSignals = () => {
let length = SIGRTMAX - SIGRTMIN + 1;
return Array.from({ length }, getRealtimeSignal);
}, getRealtimeSignal = (value, index) => ({
name: `SIGRT${index + 1}`,
number: SIGRTMIN + index,
action: "terminate",
description: "Application-specific signal (realtime)",
standard: "posix"
}), SIGRTMIN = 34, SIGRTMAX = 64;
// ../../node_modules/.pnpm/human-signals@4.3.1/node_modules/human-signals/build/src/signals.js
init_cjs_shims();
import { constants } from "node:os";
// ../../node_modules/.pnpm/human-signals@4.3.1/node_modules/human-signals/build/src/core.js
init_cjs_shims();
var SIGNALS = [
{
name: "SIGHUP",
number: 1,
action: "terminate",
description: "Terminal closed",
standard: "posix"
},
{
name: "SIGINT",
number: 2,
action: "terminate",
description: "User interruption with CTRL-C",
standard: "ansi"
},
{
name: "SIGQUIT",
number: 3,
action: "core",
description: "User interruption with CTRL-\\",
standard: "posix"
},
{
name: "SIGILL",
number: 4,
action: "core",
description: "Invalid machine instruction",
standard: "ansi"
},
{
name: "SIGTRAP",
number: 5,
action: "core",
description: "Debugger breakpoint",
standard: "posix"
},
{
name: "SIGABRT",
number: 6,
action: "core",
description: "Aborted",
standard: "ansi"
},
{
name: "SIGIOT",
number: 6,
action: "core",
description: "Aborted",
standard: "bsd"
},
{
name: "SIGBUS",
number: 7,
action: "core",
description: "Bus error due to misaligned, non-existing address or paging error",
standard: "bsd"
},
{
name: "SIGEMT",
number: 7,
action: "terminate",
description: "Command should be emulated but is not implemented",
standard: "other"
},
{
name: "SIGFPE",
number: 8,
action: "core",
description: "Floating point arithmetic error",
standard: "ansi"
},
{
name: "SIGKILL",
number: 9,
action: "terminate",
description: "Forced termination",
standard: "posix",
forced: !0
},
{
name: "SIGUSR1",
number: 10,
action: "terminate",
description: "Application-specific signal",
standard: "posix"
},
{
name: "SIGSEGV",
number: 11,
action: "core",
description: "Segmentation fault",
standard: "ansi"
},
{
name: "SIGUSR2",
number: 12,
action: "terminate",
description: "Application-specific signal",
standard: "posix"
},
{
name: "SIGPIPE",
number: 13,
action: "terminate",
description: "Broken pipe or socket",
standard: "posix"
},
{
name: "SIGALRM",
number: 14,
action: "terminate",
description: "Timeout or timer",
standard: "posix"
},
{
name: "SIGTERM",
number: 15,
action: "terminate",
description: "Termination",
standard: "ansi"
},
{
name: "SIGSTKFLT",
number: 16,
action: "terminate",
description: "Stack is empty or overflowed",
standard: "other"
},
{
name: "SIGCHLD",
number: 17,
action: "ignore",
description: "Child process terminated, paused or unpaused",
standard: "posix"
},
{
name: "SIGCLD",
number: 17,
action: "ignore",
description: "Child process terminated, paused or unpaused",
standard: "other"
},
{
name: "SIGCONT",
number: 18,
action: "unpause",
description: "Unpaused",
standard: "posix",
forced: !0
},
{
name: "SIGSTOP",
number: 19,
action: "pause",
description: "Paused",
standard: "posix",
forced: !0
},
{
name: "SIGTSTP",
number: 20,
action: "pause",
description: 'Paused using CTRL-Z or "suspend"',
standard: "posix"
},
{
name: "SIGTTIN",
number: 21,
action: "pause",
description: "Background process cannot read terminal input",
standard: "posix"
},
{
name: "SIGBREAK",
number: 21,
action: "terminate",
description: "User interruption with CTRL-BREAK",
standard: "other"
},
{
name: "SIGTTOU",
number: 22,
action: "pause",
description: "Background process cannot write to terminal output",
standard: "posix"
},
{
name: "SIGURG",
number: 23,
action: "ignore",
description: "Socket received out-of-band data",
standard: "bsd"
},
{
name: "SIGXCPU",
number: 24,
action: "core",
description: "Process timed out",
standard: "bsd"
},
{
name: "SIGXFSZ",
number: 25,
action: "core",
description: "File too big",
standard: "bsd"
},
{
name: "SIGVTALRM",
number: 26,
action: "terminate",
description: "Timeout or timer",
standard: "bsd"
},
{
name: "SIGPROF",
number: 27,
action: "terminate",
description: "Timeout or timer",
standard: "bsd"
},
{
name: "SIGWINCH",
number: 28,
action: "ignore",
description: "Terminal window size changed",
standard: "bsd"
},
{
name: "SIGIO",
number: 29,
action: "terminate",
description: "I/O is available",
standard: "other"
},
{
name: "SIGPOLL",
number: 29,
action: "terminate",
description: "Watched event",
standard: "other"
},
{
name: "SIGINFO",
number: 29,
action: "ignore",
description: "Request for process information",
standard: "other"
},
{
name: "SIGPWR",
number: 30,
action: "terminate",
description: "Device running out of power",
standard: "systemv"
},
{
name: "SIGSYS",
number: 31,
action: "core",
description: "Invalid system call",
standard: "other"
},
{
name: "SIGUNUSED",
number: 31,
action: "terminate",
description: "Invalid system call",
standard: "other"
}
];
// ../../node_modules/.pnpm/human-signals@4.3.1/node_modules/human-signals/build/src/signals.js
var getSignals = () => {
let realtimeSignals = getRealtimeSignals();
return [...SIGNALS, ...realtimeSignals].map(normalizeSignal);
}, normalizeSignal = ({
name,
number: defaultNumber,
description,
action,
forced = !1,
standard
}) => {
let {
signals: { [name]: constantSignal }
} = constants, supported = constantSignal !== void 0;
return { name, number: supported ? constantSignal : defaultNumber, description, supported, action, forced, standard };
};
// ../../node_modules/.pnpm/human-signals@4.3.1/node_modules/human-signals/build/src/main.js
var getSignalsByName = () => {
let signals = getSignals();
return Object.fromEntries(signals.map(getSignalByName));
}, getSignalByName = ({
name,
number,
description,
supported,
action,
forced,
standard
}) => [name, { name, number, description, supported, action, forced, standard }], signalsByName = getSignalsByName(), getSignalsByNumber = () => {
let signals = getSignals(), length = 65, signalsA = Array.from({ length }, (value, number) => getSignalByNumber(number, signals));
return Object.assign({}, ...signalsA);
}, getSignalByNumber = (number, signals) => {
let signal = findSignalByNumber(number, signals);
if (signal === void 0)
return {};
let { name, description, supported, action, forced, standard } = signal;
return {
[number]: {
name,
number,
description,
supported,
action,
forced,
standard
}
};
}, findSignalByNumber = (number, signals) => {
let signal = signals.find(({ name }) => constants2.signals[name] === number);
return signal !== void 0 ? signal : signals.find((signalA) => signalA.number === number);
}, signalsByNumber = getSignalsByNumber();
// ../../node_modules/.pnpm/execa@7.2.0/node_modules/execa/lib/error.js
var getErrorPrefix = ({ timedOut, timeout, errorCode, signal, signalDescription, exitCode, isCanceled }) => timedOut ? `timed out after ${timeout} milliseconds` : isCanceled ? "was canceled" : errorCode !== void 0 ? `failed with ${errorCode}` : signal !== void 0 ? `was killed with ${signal} (${signalDescription})` : exitCode !== void 0 ? `failed with exit code ${exitCode}` : "failed", makeError = ({
stdout,
stderr,
all,
error,
signal,
exitCode,
command,
escapedCommand,
timedOut,
isCanceled,
killed,
parsed: { options: { timeout, cwd = process3.cwd() } }
}) => {
exitCode = exitCode === null ? void 0 : exitCode, signal = signal === null ? void 0 : signal;
let signalDescription = signal === void 0 ? void 0 : signalsByName[signal].description, errorCode = error && error.code, execaMessage = `Command ${getErrorPrefix({ timedOut, timeout, errorCode, signal, signalDescription, exitCode, isCanceled })}: ${command}`, isError = Object.prototype.toString.call(error) === "[object Error]", shortMessage = isError ? `${execaMessage}
${error.message}` : execaMessage, message = [shortMessage, stderr, stdout].filter(Boolean).join(`
`);
return isError ? (error.originalMessage = error.message, error.message = message) : error = new Error(message), error.shortMessage = shortMessage, error.command = command, error.escapedCommand = escapedCommand, error.exitCode = exitCode, error.signal = signal, error.signalDescription = signalDescription, error.stdout = stdout, error.stderr = stderr, error.cwd = cwd, all !== void 0 && (error.all = all), "bufferedData" in error && delete error.bufferedData, error.failed = !0, error.timedOut = !!timedOut, error.isCanceled = isCanceled, error.killed = killed && !timedOut, error;
};
// ../../node_modules/.pnpm/execa@7.2.0/node_modules/execa/lib/stdio.js
init_cjs_shims();
var aliases = ["stdin", "stdout", "stderr"], hasAlias = (options) => aliases.some((alias) => options[alias] !== void 0), normalizeStdio = (options) => {
if (!options)
return;
let { stdio } = options;
if (stdio === void 0)
return aliases.map((alias) => options[alias]);
if (hasAlias(options))
throw new Error(`It's not possible to provide \`stdio\` in combination with one of ${aliases.map((alias) => `\`${alias}\``).join(", ")}`);
if (typeof stdio == "string")
return stdio;
if (!Array.isArray(stdio))
throw new TypeError(`Expected \`stdio\` to be of type \`string\` or \`Array\`, got \`${typeof stdio}\``);
let length = Math.max(stdio.length, aliases.length);
return Array.from({ length }, (value, index) => stdio[index]);
};
// ../../node_modules/.pnpm/execa@7.2.0/node_modules/execa/lib/kill.js
init_cjs_shims();
var import_signal_exit = __toESM(require_signal_exit(), 1);
import os from "node:os";
var DEFAULT_FORCE_KILL_TIMEOUT = 1e3 * 5, spawnedKill = (kill, signal = "SIGTERM", options = {}) => {
let killResult = kill(signal);
return setKillTimeout(kill, signal, options, killResult), killResult;
}, setKillTimeout = (kill, signal, options, killResult) => {
if (!shouldForceKill(signal, options, killResult))
return;
let timeout = getForceKillAfterTimeout(options), t = setTimeout(() => {
kill("SIGKILL");
}, timeout);
t.unref && t.unref();
}, shouldForceKill = (signal, { forceKillAfterTimeout }, killResult) => isSigterm(signal) && forceKillAfterTimeout !== !1 && killResult, isSigterm = (signal) => signal === os.constants.signals.SIGTERM || typeof signal == "string" && signal.toUpperCase() === "SIGTERM", getForceKillAfterTimeout = ({ forceKillAfterTimeout = !0 }) => {
if (forceKillAfterTimeout === !0)
return DEFAULT_FORCE_KILL_TIMEOUT;
if (!Number.isFinite(forceKillAfterTimeout) || forceKillAfterTimeout < 0)
throw new TypeError(`Expected the \`forceKillAfterTimeout\` option to be a non-negative integer, got \`${forceKillAfterTimeout}\` (${typeof forceKillAfterTimeout})`);
return forceKillAfterTimeout;
}, spawnedCancel = (spawned, context) => {
spawned.kill() && (context.isCanceled = !0);
}, timeoutKill = (spawned, signal, reject) => {
spawned.kill(signal), reject(Object.assign(new Error("Timed out"), { timedOut: !0, signal }));
}, setupTimeout = (spawned, { timeout, killSignal = "SIGTERM" }, spawnedPromise) => {
if (timeout === 0 || timeout === void 0)
return spawnedPromise;
let timeoutId, timeoutPromise = new Promise((resolve, reject) => {
timeoutId = setTimeout(() => {
timeoutKill(spawned, killSignal, reject);
}, timeout);
}), safeSpawnedPromise = spawnedPromise.finally(() => {
clearTimeout(timeoutId);
});
return Promise.race([timeoutPromise, safeSpawnedPromise]);
}, validateTimeout = ({ timeout }) => {
if (timeout !== void 0 && (!Number.isFinite(timeout) || timeout < 0))
throw new TypeError(`Expected the \`timeout\` option to be a non-negative integer, got \`${timeout}\` (${typeof timeout})`);
}, setExitHandler = async (spawned, { cleanup, detached }, timedPromise) => {
if (!cleanup || detached)
return timedPromise;
let removeExitHandler = (0, import_signal_exit.default)(() => {
spawned.kill();
});
return timedPromise.finally(() => {
removeExitHandler();
});
};
// ../../node_modules/.pnpm/execa@7.2.0/node_modules/execa/lib/pipe.js
init_cjs_shims();
import { createWriteStream } from "node:fs";
import { ChildProcess } from "node:child_process";
// ../../node_modules/.pnpm/is-stream@3.0.0/node_modules/is-stream/index.js
init_cjs_shims();
function isStream(stream) {
return stream !== null && typeof stream == "object" && typeof stream.pipe == "function";
}
function isWritableStream(stream) {
return isStream(stream) && stream.writable !== !1 && typeof stream._write == "function" && typeof stream._writableState == "object";
}
// ../../node_modules/.pnpm/execa@7.2.0/node_modules/execa/lib/pipe.js
var isExecaChildProcess = (target) => target instanceof ChildProcess && typeof target.then == "function", pipeToTarget = (spawned, streamName, target) => {
if (typeof target == "string")
return spawned[streamName].pipe(createWriteStream(target)), spawned;
if (isWritableStream(target))
return spawned[streamName].pipe(target), spawned;
if (!isExecaChildProcess(target))
throw new TypeError("The second argument must be a string, a stream or an Execa child process.");
if (!isWritableStream(target.stdin))
throw new TypeError("The target child process's stdin must be available.");
return spawned[streamName].pipe(target.stdin), target;
}, addPipeMethods = (spawned) => {
spawned.stdout !== null && (spawned.pipeStdout = pipeToTarget.bind(void 0, spawned, "stdout")), spawned.stderr !== null && (spawned.pipeStderr = pipeToTarget.bind(void 0, spawned, "stderr")), spawned.all !== void 0 && (spawned.pipeAll = pipeToTarget.bind(void 0, spawned, "all"));
};
// ../../node_modules/.pnpm/execa@7.2.0/node_modules/execa/lib/stream.js
init_cjs_shims();
import { createReadStream, readFileSync } from "node:fs";
var import_get_stream = __toESM(require_get_stream(), 1), import_merge_stream = __toESM(require_merge_stream(), 1), validateInputOptions = (input) => {
if (input !== void 0)
throw new TypeError("The `input` and `inputFile` options cannot be both set.");
}, getInputSync = ({ input, inputFile }) => typeof inputFile != "string" ? input : (validateInputOptions(input), readFileSync(inputFile)), handleInputSync = (options) => {
let input = getInputSync(options);
if (isStream(input))
throw new TypeError("The `input` option cannot be a stream in sync mode");
return input;
}, getInput = ({ input, inputFile }) => typeof inputFile != "string" ? input : (validateInputOptions(input), createReadStream(inputFile)), handleInput = (spawned, options) => {
let input = getInput(options);
input !== void 0 && (isStream(input) ? input.pipe(spawned.stdin) : spawned.stdin.end(input));
}, makeAllStream = (spawned, { all }) => {
if (!all || !spawned.stdout && !spawned.stderr)
return;
let mixed = (0, import_merge_stream.default)();
return spawned.stdout && mixed.add(spawned.stdout), spawned.stderr && mixed.add(spawned.stderr), mixed;
}, getBufferedData = async (stream, streamPromise) => {
if (!(!stream || streamPromise === void 0)) {
stream.destroy();
try {
return await streamPromise;
} catch (error) {
return error.bufferedData;
}
}
}, getStreamPromise = (stream, { encoding, buffer, maxBuffer }) => {
if (!(!stream || !buffer))
return encoding ? (0, import_get_stream.default)(stream, { encoding, maxBuffer }) : import_get_stream.default.buffer(stream, { maxBuffer });
}, getSpawnedResult = async ({ stdout, stderr, all }, { encoding, buffer, maxBuffer }, processDone) => {
let stdoutPromise = getStreamPromise(stdout, { encoding, buffer, maxBuffer }), stderrPromise = getStreamPromise(stderr, { encoding, buffer, maxBuffer }), allPromise = getStreamPromise(all, { encoding, buffer, maxBuffer: maxBuffer * 2 });
try {
return await Promise.all([processDone, stdoutPromise, stderrPromise, allPromise]);
} catch (error) {
return Promise.all([
{ error, signal: error.signal, timedOut: error.timedOut },
getBufferedData(stdout, stdoutPromise),
getBufferedData(stderr, stderrPromise),
getBufferedData(all, allPromise)
]);
}
};
// ../../node_modules/.pnpm/execa@7.2.0/node_modules/execa/lib/promise.js
init_cjs_shims();
var nativePromisePrototype = (async () => {
})().constructor.prototype, descriptors = ["then", "catch", "finally"].map((property) => [
property,
Reflect.getOwnPropertyDescriptor(nativePromisePrototype, property)
]), mergePromise = (spawned, promise) => {
for (let [property, descriptor] of descriptors) {
let value = typeof promise == "function" ? (...args) => Reflect.apply(descriptor.value, promise(), args) : descriptor.value.bind(promise);
Reflect.defineProperty(spawned, property, { ...descriptor, value });
}
}, getSpawnedPromise = (spawned) => new Promise((resolve, reject) => {
spawned.on("exit", (exitCode, signal) => {
resolve({ exitCode, signal });
}), spawned.on("error", (error) => {
reject(error);
}), spawned.stdin && spawned.stdin.on("error", (error) => {
reject(error);
});
});
// ../../node_modules/.pnpm/execa@7.2.0/node_modules/execa/lib/command.js
init_cjs_shims();
import { Buffer as Buffer2 } from "node:buffer";
import { ChildProcess as ChildProcess2 } from "node:child_process";
var normalizeArgs = (file, args = []) => Array.isArray(args) ? [file, ...args] : [file], NO_ESCAPE_REGEXP = /^[\w.-]+$/, DOUBLE_QUOTES_REGEXP = /"/g, escapeArg = (arg) => typeof arg != "string" || NO_ESCAPE_REGEXP.test(arg) ? arg : `"${arg.replace(DOUBLE_QUOTES_REGEXP, '\\"')}"`, joinCommand = (file, args) => normalizeArgs(file, args).join(" "), getEscapedCommand = (file, args) => normalizeArgs(file, args).map((arg) => escapeArg(arg)).join(" "), SPACES_REGEXP = / +/g;
var parseExpression = (expression) => {
let typeOfExpression = typeof expression;
if (typeOfExpression === "string")
return expression;
if (typeOfExpression === "number")
return String(expression);
if (typeOfExpression === "object" && expression !== null && !(expression instanceof ChildProcess2) && "stdout" in expression) {
let typeOfStdout = typeof expression.stdout;
if (typeOfStdout === "string")
return expression.stdout;
if (Buffer2.isBuffer(expression.stdout))
return expression.stdout.toString();
throw new TypeError(`Unexpected "${typeOfStdout}" stdout in template expression`);
}
throw new TypeError(`Unexpected "${typeOfExpression}" in template expression`);
}, concatTokens = (tokens, nextTokens, isNew) => isNew || tokens.length === 0 || nextTokens.length === 0 ? [...tokens, ...nextTokens] : [
...tokens.slice(0, -1),
`${tokens[tokens.length - 1]}${nextTokens[0]}`,
...nextTokens.slice(1)
], parseTemplate = ({ templates, expressions, tokens, index, template }) => {
let templateString = template ?? templates.raw[index], templateTokens = templateString.split(SPACES_REGEXP).filter(Boolean), newTokens = concatTokens(
tokens,
templateTokens,
templateString.startsWith(" ")
);
if (index === expressions.length)
return newTokens;
let expression = expressions[index], expressionTokens = Array.isArray(expression) ? expression.map((expression2) => parseExpression(expression2)) : [parseExpression(expression)];
return concatTokens(
newTokens,
expressionTokens,
templateString.endsWith(" ")
);
}, parseTemplates = (templates, expressions) => {
let tokens = [];
for (let [index, template] of templates.entries())
tokens = parseTemplate({ templates, expressions, tokens, index, template });
return tokens;
};
// ../../node_modules/.pnpm/execa@7.2.0/node_modules/execa/lib/verbose.js
init_cjs_shims();
import { debuglog } from "node:util";
import process4 from "node:process";
var verboseDefault = debuglog("execa").enabled, padField = (field, padding) => String(field).padStart(padding, "0"), getTimestamp = () => {
let date = /* @__PURE__ */ new Date();
return `${padField(date.getHours(), 2)}:${padField(date.getMinutes(), 2)}:${padField(date.getSeconds(), 2)}.${padField(date.getMilliseconds(), 3)}`;
}, logCommand = (escapedCommand, { verbose }) => {
verbose && process4.stderr.write(`[${getTimestamp()}] ${escapedCommand}
`);
};
// ../../node_modules/.pnpm/execa@7.2.0/node_modules/execa/index.js
var DEFAULT_MAX_BUFFER = 1e3 * 1e3 * 100, getEnv = ({ env: envOption, extendEnv, preferLocal, localDir, execPath }) => {
let env = extendEnv ? { ...process5.env, ...envOption } : envOption;
return preferLocal ? npmRunPathEnv({ env, cwd: localDir, execPath }) : env;
}, handleArguments = (file, args, options = {}) => {
let parsed = import_cross_spawn.default._parse(file, args, options);
return file = parsed.command, args = parsed.args, options = parsed.options, options = {
maxBuffer: DEFAULT_MAX_BUFFER,
buffer: !0,
stripFinalNewline: !0,
extendEnv: !0,
preferLocal: !1,
localDir: options.cwd || process5.cwd(),
execPath: process5.execPath,
encoding: "utf8",
reject: !0,
cleanup: !0,
all: !1,
windowsHide: !0,
verbose: verboseDefault,
...options
}, options.env = getEnv(options), options.stdio = normalizeStdio(options), process5.platform === "win32" && path2.basename(file, ".exe") === "cmd" && args.unshift("/q"), { file, args, options, parsed };
}, handleOutput = (options, value, error) => typeof value != "string" && !Buffer3.isBuffer(value) ? error === void 0 ? void 0 : "" : options.stripFinalNewline ? stripFinalNewline(value) : value;
function execa(file, args, options) {
let parsed = handleArguments(file, args, options), command = joinCommand(file, args), escapedCommand = getEscapedCommand(file, args);
logCommand(escapedCommand, parsed.options), validateTimeout(parsed.options);
let spawned;
try {
spawned = childProcess.spawn(parsed.file, parsed.args, parsed.options);
} catch (error) {
let dummySpawned = new childProcess.ChildProcess(), errorPromise = Promise.reject(makeError({
error,
stdout: "",
stderr: "",
all: "",
command,
escapedCommand,
parsed,
timedOut: !1,
isCanceled: !1,
killed: !1
}));
return mergePromise(dummySpawned, errorPromise), dummySpawned;
}
let spawnedPromise = getSpawnedPromise(spawned), timedPromise = setupTimeout(spawned, parsed.options, spawnedPromise), processDone = setExitHandler(spawned, parsed.options, timedPromise), context = { isCanceled: !1 };
spawned.kill = spawnedKill.bind(null, spawned.kill.bind(spawned)), spawned.cancel = spawnedCancel.bind(null, spawned, context);
let handlePromiseOnce = onetime_default(async () => {
let [{ error, exitCode, signal, timedOut }, stdoutResult, stderrResult, allResult] = await getSpawnedResult(spawned, parsed.options, processDone), stdout = handleOutput(parsed.options, stdoutResult), stderr = handleOutput(parsed.options, stderrResult), all = handleOutput(parsed.options, allResult);
if (error || exitCode !== 0 || signal !== null) {
let returnedError = makeError({
error,
exitCode,
signal,
stdout,
stderr,
all,
command,
escapedCommand,
parsed,
timedOut,
isCanceled: context.isCanceled || (parsed.options.signal ? parsed.options.signal.aborted : !1),
killed: spawned.killed
});
if (!parsed.options.reject)
return returnedError;
throw returnedError;
}
return {
command,
escapedCommand,
exitCode: 0,
stdout,
stderr,
all,
failed: !1,
timedOut: !1,
isCanceled: !1,
killed: !1
};
});
return handleInput(spawned, parsed.options), spawned.all = makeAllStream(spawned, parsed.options), addPipeMethods(spawned), mergePromise(spawned, handlePromiseOnce), spawned;
}
function execaSync(file, args, options) {
let parsed = handleArguments(file, args, options), command = joinCommand(file, args), escapedCommand = getEscapedCommand(file, args);
logCommand(escapedCommand, parsed.options);
let input = handleInputSync(parsed.options), result;
try {
result = childProcess.spawnSync(parsed.file, parsed.args, { ...parsed.options, input });
} catch (error) {
throw makeError({
error,
stdout: "",
stderr: "",
all: "",
command,
escapedCommand,
parsed,
timedOut: !1,
isCanceled: !1,
killed: !1
});
}
let stdout = handleOutput(parsed.options, result.stdout, result.error), stderr = handleOutput(parsed.options, result.stderr, result.error);
if (result.error || result.status !== 0 || result.signal !== null) {
let error = makeError({
stdout,
stderr,
error: result.error,
signal: result.signal,
exitCode: result.status,
command,
escapedCommand,
parsed,
timedOut: result.error && result.error.code === "ETIMEDOUT",
isCanceled: !1,
killed: result.signal !== null
});
if (!parsed.options.reject)
return error;
throw error;
}
return {
command,
escapedCommand,
exitCode: 0,
stdout,
stderr,
failed: !1,
timedOut: !1,
isCanceled: !1,
killed: !1
};
}
var normalizeScriptStdin = ({ input, inputFile, stdio }) => input === void 0 && inputFile === void 0 && stdio === void 0 ? { stdin: "inherit" } : {}, normalizeScriptOptions = (options = {}) => ({
preferLocal: !0,
...normalizeScriptStdin(options),
...options
});
function create$(options) {
function $2(templatesOrOptions, ...expressions) {
if (!Array.isArray(templatesOrOptions))
return create$({ ...options, ...templatesOrOptions });
let [file, ...args] = parseTemplates(templatesOrOptions, expressions);
return execa(file, args, normalizeScriptOptions(options));
}
return $2.sync = (templates, ...expressions) => {
if (!Array.isArray(templates))
throw new TypeError("Please use $(options).sync`command` instead of $.sync(options)`command`.");
let [file, ...args] = parseTemplates(templates, expressions);
return execaSync(file, args, normalizeScriptOptions(options));
}, $2;
}
var $ = create$();
// ../cli-kit/dist/public/node/os.js
import { userInfo as osUserInfo } from "os";
async function username(platform = process.platform) {
outputDebug(outputContent`Obtaining user name...`);
let environmentVariable = getEnvironmentVariable();
if (environmentVariable)
return environmentVariable;
let userInfoUsername = getUsernameFromOsUserInfo();
if (userInfoUsername)
return userInfoUsername;
try {
if (platform === "win32") {
let { stdout } = await execa("whoami");
return cleanWindowsCommand(stdout);
}
let { stdout: userId } = await execa("id", ["-u"]);
try {
let { stdout } = await execa("id", ["-un", userId]);
return stdout;
} catch {
}
return makeUsernameFromId(userId);
} catch {
return null;
}
}
var ARCH_MAP = {
x64: "amd64",
ia32: "386"
};
function platformAndArch(platform = process.platform, arch = process.arch) {
let archString = ARCH_MAP[arch] ?? arch;
return { platform: platform.match(/^win.+/) ? "windows" : platform, arch: archString };
}
function getEnvironmentVariable() {
let { env } = process;
return env.SUDO_USER || env.C9_USER || env.LOGNAME || env.USER || env.LNAME || env.USERNAME;
}
function getUsernameFromOsUserInfo() {
try {
return osUserInfo().username;
} catch {
return null;
}
}
function cleanWindowsCommand(value) {
return value.replace(/^.*\\/, "");
}
function makeUsernameFromId(userId) {
return `no-username-${userId}`;
}
export {
require_signal_exit,
execa,
username,
platformAndArch
};
//# sourceMappingURL=chunk-JMC4PKOZ.js.map