@fragment-dev/cli
Version:
1,609 lines (1,595 loc) • 2.24 MB
JavaScript
import {
parseJSON
} from "./chunk-UDU5PBTV.js";
import {
readVersionFile,
updateVersionFile
} from "./chunk-LJSFUVJW.js";
import {
require_graphql
} from "./chunk-QF5EN33L.js";
import {
getFragmentCliVersion
} from "./chunk-CW4UI44G.js";
import {
attemptToCacheToken,
getToken,
readUnexpiredAccessToken
} from "./chunk-E7E3SSNY.js";
import {
FRAGMENT_AUTH_PATH,
FRAGMENT_HOME,
getPosthogApiKey
} from "./chunk-WS2PJBP6.js";
import {
require_ansi_styles,
require_has_flag,
require_source
} from "./chunk-M5OAS5QZ.js";
import {
__commonJS,
__require,
__toESM,
init_cjs_shims
} from "./chunk-7GH3YGSC.js";
// ../../node_modules/@oclif/core/lib/util/util.js
var require_util = __commonJS({
"../../node_modules/@oclif/core/lib/util/util.js"(exports) {
"use strict";
init_cjs_shims();
Object.defineProperty(exports, "__esModule", { value: true });
exports.pickBy = pickBy;
exports.compact = compact;
exports.uniqBy = uniqBy;
exports.last = last;
exports.sortBy = sortBy;
exports.castArray = castArray;
exports.isProd = isProd;
exports.maxBy = maxBy;
exports.sumBy = sumBy;
exports.capitalize = capitalize;
exports.isTruthy = isTruthy;
exports.isNotFalsy = isNotFalsy;
exports.uniq = uniq;
exports.mapValues = mapValues;
exports.mergeNestedObjects = mergeNestedObjects;
function pickBy(obj, fn) {
return Object.entries(obj).reduce((o, [k, v]) => {
if (fn(v))
o[k] = v;
return o;
}, {});
}
function compact(a) {
return a.filter((a2) => Boolean(a2));
}
function uniqBy(arr, fn) {
return arr.filter((a, i) => {
const aVal = fn(a);
return !arr.some((b, j) => j > i && fn(b) === aVal);
});
}
function last(arr) {
if (!arr)
return;
return arr.at(-1);
}
function compare2(a, b) {
a = a === void 0 ? 0 : a;
b = b === void 0 ? 0 : b;
if (Array.isArray(a) && Array.isArray(b)) {
if (a.length === 0 && b.length === 0)
return 0;
const diff = compare2(a[0], b[0]);
if (diff !== 0)
return diff;
return compare2(a.slice(1), b.slice(1));
}
if (a < b)
return -1;
if (a > b)
return 1;
return 0;
}
function sortBy(arr, fn) {
return arr.sort((a, b) => compare2(fn(a), fn(b)));
}
function castArray(input) {
if (input === void 0)
return [];
return Array.isArray(input) ? input : [input];
}
function isProd() {
return !["development", "test"].includes(process.env.NODE_ENV ?? "");
}
function maxBy(arr, fn) {
if (arr.length === 0) {
return void 0;
}
return arr.reduce((maxItem, i) => {
const curr = fn(i);
const max = fn(maxItem);
return curr > max ? i : maxItem;
});
}
function sumBy(arr, fn) {
return arr.reduce((sum, i) => sum + fn(i), 0);
}
function capitalize(s) {
return s ? s.charAt(0).toUpperCase() + s.slice(1).toLowerCase() : "";
}
function isTruthy(input) {
return ["1", "true", "y", "yes"].includes(input.toLowerCase());
}
function isNotFalsy(input) {
return !["0", "false", "n", "no"].includes(input.toLowerCase());
}
function uniq(arr) {
return [...new Set(arr)].sort();
}
function mapValues(obj, fn) {
return Object.entries(obj).reduce((o, [k, v]) => {
o[k] = fn(v, k);
return o;
}, {});
}
function get(obj, path) {
return path.split(".").reduce((o, p) => o?.[p], obj);
}
function mergeNestedObjects(objs, path) {
return Object.fromEntries(objs.flatMap((o) => Object.entries(get(o, path) ?? {})).reverse());
}
}
});
// ../../node_modules/@oclif/core/lib/util/fs.js
var require_fs = __commonJS({
"../../node_modules/@oclif/core/lib/util/fs.js"(exports) {
"use strict";
init_cjs_shims();
Object.defineProperty(exports, "__esModule", { value: true });
exports.fileExists = exports.dirExists = void 0;
exports.readJson = readJson;
exports.safeReadJson = safeReadJson;
exports.existsSync = existsSync2;
var node_fs_1 = __require("node:fs");
var promises_1 = __require("node:fs/promises");
var util_1 = require_util();
var dirExists = async (input) => {
let dirStat;
try {
dirStat = await (0, promises_1.stat)(input);
} catch {
throw new Error(`No directory found at ${input}`);
}
if (!dirStat.isDirectory()) {
throw new Error(`${input} exists but is not a directory`);
}
return input;
};
exports.dirExists = dirExists;
var fileExists = async (input) => {
let fileStat;
try {
fileStat = await (0, promises_1.stat)(input);
} catch {
throw new Error(`No file found at ${input}`);
}
if (!fileStat.isFile()) {
throw new Error(`${input} exists but is not a file`);
}
return input;
};
exports.fileExists = fileExists;
var ProdOnlyCache = class extends Map {
set(key, value) {
if ((0, util_1.isProd)() ?? false) {
super.set(key, value);
}
return this;
}
};
var cache = new ProdOnlyCache();
async function readJson(path, useCache = true) {
if (useCache && cache.has(path)) {
return JSON.parse(cache.get(path));
}
const contents = await (0, promises_1.readFile)(path, "utf8");
cache.set(path, contents);
return JSON.parse(contents);
}
async function safeReadJson(path, useCache = true) {
try {
return await readJson(path, useCache);
} catch {
}
}
function existsSync2(path) {
return (0, node_fs_1.existsSync)(path);
}
}
});
// ../../node_modules/@oclif/core/lib/args.js
var require_args = __commonJS({
"../../node_modules/@oclif/core/lib/args.js"(exports) {
"use strict";
init_cjs_shims();
Object.defineProperty(exports, "__esModule", { value: true });
exports.string = exports.url = exports.file = exports.directory = exports.integer = exports.boolean = void 0;
exports.custom = custom;
var node_url_1 = __require("node:url");
var fs_1 = require_fs();
var util_1 = require_util();
function custom(defaults) {
return (options = {}) => ({
parse: async (i, _context, _opts) => i,
...defaults,
...options,
input: [],
type: "option"
});
}
exports.boolean = custom({
parse: async (b) => Boolean(b) && (0, util_1.isNotFalsy)(b)
});
exports.integer = custom({
async parse(input, _, opts) {
if (!/^-?\d+$/.test(input))
throw new Error(`Expected an integer but received: ${input}`);
const num = Number.parseInt(input, 10);
if (opts.min !== void 0 && num < opts.min)
throw new Error(`Expected an integer greater than or equal to ${opts.min} but received: ${input}`);
if (opts.max !== void 0 && num > opts.max)
throw new Error(`Expected an integer less than or equal to ${opts.max} but received: ${input}`);
return num;
}
});
exports.directory = custom({
async parse(input, _, opts) {
if (opts.exists)
return (0, fs_1.dirExists)(input);
return input;
}
});
exports.file = custom({
async parse(input, _, opts) {
if (opts.exists)
return (0, fs_1.fileExists)(input);
return input;
}
});
exports.url = custom({
async parse(input) {
try {
return new node_url_1.URL(input);
} catch {
throw new Error(`Expected a valid url but received: ${input}`);
}
}
});
var stringArg = custom({});
exports.string = stringArg;
}
});
// ../../node_modules/@oclif/core/lib/cache.js
var require_cache = __commonJS({
"../../node_modules/@oclif/core/lib/cache.js"(exports) {
"use strict";
init_cjs_shims();
Object.defineProperty(exports, "__esModule", { value: true });
var node_fs_1 = __require("node:fs");
var node_path_1 = __require("node:path");
var Cache = class _Cache extends Map {
static instance;
constructor() {
super();
this.set("@oclif/core", this.getOclifCoreMeta());
}
static getInstance() {
if (!_Cache.instance) {
_Cache.instance = new _Cache();
}
return _Cache.instance;
}
get(key) {
return super.get(key);
}
getOclifCoreMeta() {
try {
return { name: "@oclif/core", version: __require("@oclif/core/package.json").version };
} catch {
try {
return {
name: "@oclif/core",
version: JSON.parse((0, node_fs_1.readFileSync)((0, node_path_1.join)(__dirname, "..", "package.json"), "utf8")).version
};
} catch {
return { name: "@oclif/core", version: "unknown" };
}
}
}
};
exports.default = Cache;
}
});
// ../../node_modules/ejs/lib/utils.js
var require_utils = __commonJS({
"../../node_modules/ejs/lib/utils.js"(exports) {
"use strict";
init_cjs_shims();
var regExpChars = /[|\\{}()[\]^$+*?.]/g;
var hasOwnProperty = Object.prototype.hasOwnProperty;
var hasOwn = function(obj, key) {
return hasOwnProperty.apply(obj, [key]);
};
exports.escapeRegExpChars = function(string) {
if (!string) {
return "";
}
return String(string).replace(regExpChars, "\\$&");
};
var _ENCODE_HTML_RULES = {
"&": "&",
"<": "<",
">": ">",
'"': """,
"'": "'"
};
var _MATCH_HTML = /[&<>'"]/g;
function encode_char(c) {
return _ENCODE_HTML_RULES[c] || c;
}
var escapeFuncStr = `var _ENCODE_HTML_RULES = {
"&": "&"
, "<": "<"
, ">": ">"
, '"': """
, "'": "'"
}
, _MATCH_HTML = /[&<>'"]/g;
function encode_char(c) {
return _ENCODE_HTML_RULES[c] || c;
};
`;
exports.escapeXML = function(markup) {
return markup == void 0 ? "" : String(markup).replace(_MATCH_HTML, encode_char);
};
function escapeXMLToString() {
return Function.prototype.toString.call(this) + ";\n" + escapeFuncStr;
}
try {
if (typeof Object.defineProperty === "function") {
Object.defineProperty(exports.escapeXML, "toString", { value: escapeXMLToString });
} else {
exports.escapeXML.toString = escapeXMLToString;
}
} catch (err) {
console.warn("Unable to set escapeXML.toString (is the Function prototype frozen?)");
}
exports.shallowCopy = function(to, from) {
from = from || {};
if (to !== null && to !== void 0) {
for (var p in from) {
if (!hasOwn(from, p)) {
continue;
}
if (p === "__proto__" || p === "constructor") {
continue;
}
to[p] = from[p];
}
}
return to;
};
exports.shallowCopyFromList = function(to, from, list) {
list = list || [];
from = from || {};
if (to !== null && to !== void 0) {
for (var i = 0; i < list.length; i++) {
var p = list[i];
if (typeof from[p] != "undefined") {
if (!hasOwn(from, p)) {
continue;
}
if (p === "__proto__" || p === "constructor") {
continue;
}
to[p] = from[p];
}
}
}
return to;
};
exports.cache = {
_data: {},
set: function(key, val) {
this._data[key] = val;
},
get: function(key) {
return this._data[key];
},
remove: function(key) {
delete this._data[key];
},
reset: function() {
this._data = {};
}
};
exports.hyphenToCamel = function(str) {
return str.replace(/-[a-z]/g, function(match) {
return match[1].toUpperCase();
});
};
exports.createNullProtoObjWherePossible = function() {
if (typeof Object.create == "function") {
return function() {
return /* @__PURE__ */ Object.create(null);
};
}
if (!({ __proto__: null } instanceof Object)) {
return function() {
return { __proto__: null };
};
}
return function() {
return {};
};
}();
exports.hasOwnOnlyObject = function(obj) {
var o = exports.createNullProtoObjWherePossible();
for (var p in obj) {
if (hasOwn(obj, p)) {
o[p] = obj[p];
}
}
return o;
};
}
});
// ../../node_modules/ejs/package.json
var require_package = __commonJS({
"../../node_modules/ejs/package.json"(exports, module) {
module.exports = {
name: "ejs",
description: "Embedded JavaScript templates",
keywords: [
"template",
"engine",
"ejs"
],
version: "3.1.10",
author: "Matthew Eernisse <mde@fleegix.org> (http://fleegix.org)",
license: "Apache-2.0",
bin: {
ejs: "./bin/cli.js"
},
main: "./lib/ejs.js",
jsdelivr: "ejs.min.js",
unpkg: "ejs.min.js",
repository: {
type: "git",
url: "git://github.com/mde/ejs.git"
},
bugs: "https://github.com/mde/ejs/issues",
homepage: "https://github.com/mde/ejs",
dependencies: {
jake: "^10.8.5"
},
devDependencies: {
browserify: "^16.5.1",
eslint: "^6.8.0",
"git-directory-deploy": "^1.5.1",
jsdoc: "^4.0.2",
"lru-cache": "^4.0.1",
mocha: "^10.2.0",
"uglify-js": "^3.3.16"
},
engines: {
node: ">=0.10.0"
},
scripts: {
test: "npx jake test"
}
};
}
});
// ../../node_modules/ejs/lib/ejs.js
var require_ejs = __commonJS({
"../../node_modules/ejs/lib/ejs.js"(exports) {
"use strict";
init_cjs_shims();
var fs = __require("fs");
var path = __require("path");
var utils = require_utils();
var scopeOptionWarned = false;
var _VERSION_STRING = require_package().version;
var _DEFAULT_OPEN_DELIMITER = "<";
var _DEFAULT_CLOSE_DELIMITER = ">";
var _DEFAULT_DELIMITER = "%";
var _DEFAULT_LOCALS_NAME = "locals";
var _NAME = "ejs";
var _REGEX_STRING = "(<%%|%%>|<%=|<%-|<%_|<%#|<%|%>|-%>|_%>)";
var _OPTS_PASSABLE_WITH_DATA = [
"delimiter",
"scope",
"context",
"debug",
"compileDebug",
"client",
"_with",
"rmWhitespace",
"strict",
"filename",
"async"
];
var _OPTS_PASSABLE_WITH_DATA_EXPRESS = _OPTS_PASSABLE_WITH_DATA.concat("cache");
var _BOM = /^\uFEFF/;
var _JS_IDENTIFIER = /^[a-zA-Z_$][0-9a-zA-Z_$]*$/;
exports.cache = utils.cache;
exports.fileLoader = fs.readFileSync;
exports.localsName = _DEFAULT_LOCALS_NAME;
exports.promiseImpl = new Function("return this;")().Promise;
exports.resolveInclude = function(name, filename, isDir) {
var dirname2 = path.dirname;
var extname = path.extname;
var resolve = path.resolve;
var includePath = resolve(isDir ? filename : dirname2(filename), name);
var ext = extname(name);
if (!ext) {
includePath += ".ejs";
}
return includePath;
};
function resolvePaths(name, paths) {
var filePath;
if (paths.some(function(v) {
filePath = exports.resolveInclude(name, v, true);
return fs.existsSync(filePath);
})) {
return filePath;
}
}
function getIncludePath(path2, options) {
var includePath;
var filePath;
var views = options.views;
var match = /^[A-Za-z]+:\\|^\//.exec(path2);
if (match && match.length) {
path2 = path2.replace(/^\/*/, "");
if (Array.isArray(options.root)) {
includePath = resolvePaths(path2, options.root);
} else {
includePath = exports.resolveInclude(path2, options.root || "/", true);
}
} else {
if (options.filename) {
filePath = exports.resolveInclude(path2, options.filename);
if (fs.existsSync(filePath)) {
includePath = filePath;
}
}
if (!includePath && Array.isArray(views)) {
includePath = resolvePaths(path2, views);
}
if (!includePath && typeof options.includer !== "function") {
throw new Error('Could not find the include file "' + options.escapeFunction(path2) + '"');
}
}
return includePath;
}
function handleCache(options, template) {
var func;
var filename = options.filename;
var hasTemplate = arguments.length > 1;
if (options.cache) {
if (!filename) {
throw new Error("cache option requires a filename");
}
func = exports.cache.get(filename);
if (func) {
return func;
}
if (!hasTemplate) {
template = fileLoader(filename).toString().replace(_BOM, "");
}
} else if (!hasTemplate) {
if (!filename) {
throw new Error("Internal EJS error: no file name or template provided");
}
template = fileLoader(filename).toString().replace(_BOM, "");
}
func = exports.compile(template, options);
if (options.cache) {
exports.cache.set(filename, func);
}
return func;
}
function tryHandleCache(options, data, cb) {
var result;
if (!cb) {
if (typeof exports.promiseImpl == "function") {
return new exports.promiseImpl(function(resolve, reject) {
try {
result = handleCache(options)(data);
resolve(result);
} catch (err) {
reject(err);
}
});
} else {
throw new Error("Please provide a callback function");
}
} else {
try {
result = handleCache(options)(data);
} catch (err) {
return cb(err);
}
cb(null, result);
}
}
function fileLoader(filePath) {
return exports.fileLoader(filePath);
}
function includeFile(path2, options) {
var opts = utils.shallowCopy(utils.createNullProtoObjWherePossible(), options);
opts.filename = getIncludePath(path2, opts);
if (typeof options.includer === "function") {
var includerResult = options.includer(path2, opts.filename);
if (includerResult) {
if (includerResult.filename) {
opts.filename = includerResult.filename;
}
if (includerResult.template) {
return handleCache(opts, includerResult.template);
}
}
}
return handleCache(opts);
}
function rethrow(err, str, flnm, lineno, esc) {
var lines = str.split("\n");
var start = Math.max(lineno - 3, 0);
var end = Math.min(lines.length, lineno + 3);
var filename = esc(flnm);
var context = lines.slice(start, end).map(function(line, i) {
var curr = i + start + 1;
return (curr == lineno ? " >> " : " ") + curr + "| " + line;
}).join("\n");
err.path = filename;
err.message = (filename || "ejs") + ":" + lineno + "\n" + context + "\n\n" + err.message;
throw err;
}
function stripSemi(str) {
return str.replace(/;(\s*$)/, "$1");
}
exports.compile = function compile(template, opts) {
var templ;
if (opts && opts.scope) {
if (!scopeOptionWarned) {
console.warn("`scope` option is deprecated and will be removed in EJS 3");
scopeOptionWarned = true;
}
if (!opts.context) {
opts.context = opts.scope;
}
delete opts.scope;
}
templ = new Template(template, opts);
return templ.compile();
};
exports.render = function(template, d, o) {
var data = d || utils.createNullProtoObjWherePossible();
var opts = o || utils.createNullProtoObjWherePossible();
if (arguments.length == 2) {
utils.shallowCopyFromList(opts, data, _OPTS_PASSABLE_WITH_DATA);
}
return handleCache(opts, template)(data);
};
exports.renderFile = function() {
var args = Array.prototype.slice.call(arguments);
var filename = args.shift();
var cb;
var opts = { filename };
var data;
var viewOpts;
if (typeof arguments[arguments.length - 1] == "function") {
cb = args.pop();
}
if (args.length) {
data = args.shift();
if (args.length) {
utils.shallowCopy(opts, args.pop());
} else {
if (data.settings) {
if (data.settings.views) {
opts.views = data.settings.views;
}
if (data.settings["view cache"]) {
opts.cache = true;
}
viewOpts = data.settings["view options"];
if (viewOpts) {
utils.shallowCopy(opts, viewOpts);
}
}
utils.shallowCopyFromList(opts, data, _OPTS_PASSABLE_WITH_DATA_EXPRESS);
}
opts.filename = filename;
} else {
data = utils.createNullProtoObjWherePossible();
}
return tryHandleCache(opts, data, cb);
};
exports.Template = Template;
exports.clearCache = function() {
exports.cache.reset();
};
function Template(text, optsParam) {
var opts = utils.hasOwnOnlyObject(optsParam);
var options = utils.createNullProtoObjWherePossible();
this.templateText = text;
this.mode = null;
this.truncate = false;
this.currentLine = 1;
this.source = "";
options.client = opts.client || false;
options.escapeFunction = opts.escape || opts.escapeFunction || utils.escapeXML;
options.compileDebug = opts.compileDebug !== false;
options.debug = !!opts.debug;
options.filename = opts.filename;
options.openDelimiter = opts.openDelimiter || exports.openDelimiter || _DEFAULT_OPEN_DELIMITER;
options.closeDelimiter = opts.closeDelimiter || exports.closeDelimiter || _DEFAULT_CLOSE_DELIMITER;
options.delimiter = opts.delimiter || exports.delimiter || _DEFAULT_DELIMITER;
options.strict = opts.strict || false;
options.context = opts.context;
options.cache = opts.cache || false;
options.rmWhitespace = opts.rmWhitespace;
options.root = opts.root;
options.includer = opts.includer;
options.outputFunctionName = opts.outputFunctionName;
options.localsName = opts.localsName || exports.localsName || _DEFAULT_LOCALS_NAME;
options.views = opts.views;
options.async = opts.async;
options.destructuredLocals = opts.destructuredLocals;
options.legacyInclude = typeof opts.legacyInclude != "undefined" ? !!opts.legacyInclude : true;
if (options.strict) {
options._with = false;
} else {
options._with = typeof opts._with != "undefined" ? opts._with : true;
}
this.opts = options;
this.regex = this.createRegex();
}
Template.modes = {
EVAL: "eval",
ESCAPED: "escaped",
RAW: "raw",
COMMENT: "comment",
LITERAL: "literal"
};
Template.prototype = {
createRegex: function() {
var str = _REGEX_STRING;
var delim = utils.escapeRegExpChars(this.opts.delimiter);
var open = utils.escapeRegExpChars(this.opts.openDelimiter);
var close = utils.escapeRegExpChars(this.opts.closeDelimiter);
str = str.replace(/%/g, delim).replace(/</g, open).replace(/>/g, close);
return new RegExp(str);
},
compile: function() {
var src;
var fn;
var opts = this.opts;
var prepended = "";
var appended = "";
var escapeFn = opts.escapeFunction;
var ctor;
var sanitizedFilename = opts.filename ? JSON.stringify(opts.filename) : "undefined";
if (!this.source) {
this.generateSource();
prepended += ' var __output = "";\n function __append(s) { if (s !== undefined && s !== null) __output += s }\n';
if (opts.outputFunctionName) {
if (!_JS_IDENTIFIER.test(opts.outputFunctionName)) {
throw new Error("outputFunctionName is not a valid JS identifier.");
}
prepended += " var " + opts.outputFunctionName + " = __append;\n";
}
if (opts.localsName && !_JS_IDENTIFIER.test(opts.localsName)) {
throw new Error("localsName is not a valid JS identifier.");
}
if (opts.destructuredLocals && opts.destructuredLocals.length) {
var destructuring = " var __locals = (" + opts.localsName + " || {}),\n";
for (var i = 0; i < opts.destructuredLocals.length; i++) {
var name = opts.destructuredLocals[i];
if (!_JS_IDENTIFIER.test(name)) {
throw new Error("destructuredLocals[" + i + "] is not a valid JS identifier.");
}
if (i > 0) {
destructuring += ",\n ";
}
destructuring += name + " = __locals." + name;
}
prepended += destructuring + ";\n";
}
if (opts._with !== false) {
prepended += " with (" + opts.localsName + " || {}) {\n";
appended += " }\n";
}
appended += " return __output;\n";
this.source = prepended + this.source + appended;
}
if (opts.compileDebug) {
src = "var __line = 1\n , __lines = " + JSON.stringify(this.templateText) + "\n , __filename = " + sanitizedFilename + ";\ntry {\n" + this.source + "} catch (e) {\n rethrow(e, __lines, __filename, __line, escapeFn);\n}\n";
} else {
src = this.source;
}
if (opts.client) {
src = "escapeFn = escapeFn || " + escapeFn.toString() + ";\n" + src;
if (opts.compileDebug) {
src = "rethrow = rethrow || " + rethrow.toString() + ";\n" + src;
}
}
if (opts.strict) {
src = '"use strict";\n' + src;
}
if (opts.debug) {
console.log(src);
}
if (opts.compileDebug && opts.filename) {
src = src + "\n//# sourceURL=" + sanitizedFilename + "\n";
}
try {
if (opts.async) {
try {
ctor = new Function("return (async function(){}).constructor;")();
} catch (e) {
if (e instanceof SyntaxError) {
throw new Error("This environment does not support async/await");
} else {
throw e;
}
}
} else {
ctor = Function;
}
fn = new ctor(opts.localsName + ", escapeFn, include, rethrow", src);
} catch (e) {
if (e instanceof SyntaxError) {
if (opts.filename) {
e.message += " in " + opts.filename;
}
e.message += " while compiling ejs\n\n";
e.message += "If the above error is not helpful, you may want to try EJS-Lint:\n";
e.message += "https://github.com/RyanZim/EJS-Lint";
if (!opts.async) {
e.message += "\n";
e.message += "Or, if you meant to create an async function, pass `async: true` as an option.";
}
}
throw e;
}
var returnedFn = opts.client ? fn : function anonymous(data) {
var include = function(path2, includeData) {
var d = utils.shallowCopy(utils.createNullProtoObjWherePossible(), data);
if (includeData) {
d = utils.shallowCopy(d, includeData);
}
return includeFile(path2, opts)(d);
};
return fn.apply(
opts.context,
[data || utils.createNullProtoObjWherePossible(), escapeFn, include, rethrow]
);
};
if (opts.filename && typeof Object.defineProperty === "function") {
var filename = opts.filename;
var basename = path.basename(filename, path.extname(filename));
try {
Object.defineProperty(returnedFn, "name", {
value: basename,
writable: false,
enumerable: false,
configurable: true
});
} catch (e) {
}
}
return returnedFn;
},
generateSource: function() {
var opts = this.opts;
if (opts.rmWhitespace) {
this.templateText = this.templateText.replace(/[\r\n]+/g, "\n").replace(/^\s+|\s+$/gm, "");
}
this.templateText = this.templateText.replace(/[ \t]*<%_/gm, "<%_").replace(/_%>[ \t]*/gm, "_%>");
var self2 = this;
var matches = this.parseTemplateText();
var d = this.opts.delimiter;
var o = this.opts.openDelimiter;
var c = this.opts.closeDelimiter;
if (matches && matches.length) {
matches.forEach(function(line, index) {
var closing;
if (line.indexOf(o + d) === 0 && line.indexOf(o + d + d) !== 0) {
closing = matches[index + 2];
if (!(closing == d + c || closing == "-" + d + c || closing == "_" + d + c)) {
throw new Error('Could not find matching close tag for "' + line + '".');
}
}
self2.scanLine(line);
});
}
},
parseTemplateText: function() {
var str = this.templateText;
var pat = this.regex;
var result = pat.exec(str);
var arr = [];
var firstPos;
while (result) {
firstPos = result.index;
if (firstPos !== 0) {
arr.push(str.substring(0, firstPos));
str = str.slice(firstPos);
}
arr.push(result[0]);
str = str.slice(result[0].length);
result = pat.exec(str);
}
if (str) {
arr.push(str);
}
return arr;
},
_addOutput: function(line) {
if (this.truncate) {
line = line.replace(/^(?:\r\n|\r|\n)/, "");
this.truncate = false;
}
if (!line) {
return line;
}
line = line.replace(/\\/g, "\\\\");
line = line.replace(/\n/g, "\\n");
line = line.replace(/\r/g, "\\r");
line = line.replace(/"/g, '\\"');
this.source += ' ; __append("' + line + '")\n';
},
scanLine: function(line) {
var self2 = this;
var d = this.opts.delimiter;
var o = this.opts.openDelimiter;
var c = this.opts.closeDelimiter;
var newLineCount = 0;
newLineCount = line.split("\n").length - 1;
switch (line) {
case o + d:
case o + d + "_":
this.mode = Template.modes.EVAL;
break;
case o + d + "=":
this.mode = Template.modes.ESCAPED;
break;
case o + d + "-":
this.mode = Template.modes.RAW;
break;
case o + d + "#":
this.mode = Template.modes.COMMENT;
break;
case o + d + d:
this.mode = Template.modes.LITERAL;
this.source += ' ; __append("' + line.replace(o + d + d, o + d) + '")\n';
break;
case d + d + c:
this.mode = Template.modes.LITERAL;
this.source += ' ; __append("' + line.replace(d + d + c, d + c) + '")\n';
break;
case d + c:
case "-" + d + c:
case "_" + d + c:
if (this.mode == Template.modes.LITERAL) {
this._addOutput(line);
}
this.mode = null;
this.truncate = line.indexOf("-") === 0 || line.indexOf("_") === 0;
break;
default:
if (this.mode) {
switch (this.mode) {
case Template.modes.EVAL:
case Template.modes.ESCAPED:
case Template.modes.RAW:
if (line.lastIndexOf("//") > line.lastIndexOf("\n")) {
line += "\n";
}
}
switch (this.mode) {
case Template.modes.EVAL:
this.source += " ; " + line + "\n";
break;
case Template.modes.ESCAPED:
this.source += " ; __append(escapeFn(" + stripSemi(line) + "))\n";
break;
case Template.modes.RAW:
this.source += " ; __append(" + stripSemi(line) + ")\n";
break;
case Template.modes.COMMENT:
break;
case Template.modes.LITERAL:
this._addOutput(line);
break;
}
} else {
this._addOutput(line);
}
}
if (self2.opts.compileDebug && newLineCount) {
this.currentLine += newLineCount;
this.source += " ; __line = " + this.currentLine + "\n";
}
}
};
exports.escapeXML = utils.escapeXML;
exports.__express = exports.renderFile;
exports.VERSION = _VERSION_STRING;
exports.name = _NAME;
if (typeof window != "undefined") {
window.ejs = exports;
}
}
});
// ../../node_modules/is-docker/index.js
var require_is_docker = __commonJS({
"../../node_modules/is-docker/index.js"(exports, module) {
"use strict";
init_cjs_shims();
var fs = __require("fs");
var isDocker;
function hasDockerEnv() {
try {
fs.statSync("/.dockerenv");
return true;
} catch (_) {
return false;
}
}
function hasDockerCGroup() {
try {
return fs.readFileSync("/proc/self/cgroup", "utf8").includes("docker");
} catch (_) {
return false;
}
}
module.exports = () => {
if (isDocker === void 0) {
isDocker = hasDockerEnv() || hasDockerCGroup();
}
return isDocker;
};
}
});
// ../../node_modules/is-wsl/index.js
var require_is_wsl = __commonJS({
"../../node_modules/is-wsl/index.js"(exports, module) {
"use strict";
init_cjs_shims();
var os = __require("os");
var fs = __require("fs");
var isDocker = require_is_docker();
var isWsl = () => {
if (process.platform !== "linux") {
return false;
}
if (os.release().toLowerCase().includes("microsoft")) {
if (isDocker()) {
return false;
}
return true;
}
try {
return fs.readFileSync("/proc/version", "utf8").toLowerCase().includes("microsoft") ? !isDocker() : false;
} catch (_) {
return false;
}
};
if (process.env.__IS_WSL_TEST__) {
module.exports = isWsl;
} else {
module.exports = isWsl();
}
}
});
// ../../node_modules/ms/index.js
var require_ms = __commonJS({
"../../node_modules/ms/index.js"(exports, module) {
init_cjs_shims();
var s = 1e3;
var m = s * 60;
var h = m * 60;
var d = h * 24;
var w = d * 7;
var y = d * 365.25;
module.exports = function(val, options) {
options = options || {};
var type = typeof val;
if (type === "string" && val.length > 0) {
return parse2(val);
} else if (type === "number" && isFinite(val)) {
return options.long ? fmtLong(val) : fmtShort(val);
}
throw new Error(
"val is not a non-empty string or a valid number. val=" + JSON.stringify(val)
);
};
function parse2(str) {
str = String(str);
if (str.length > 100) {
return;
}
var match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(
str
);
if (!match) {
return;
}
var n = parseFloat(match[1]);
var type = (match[2] || "ms").toLowerCase();
switch (type) {
case "years":
case "year":
case "yrs":
case "yr":
case "y":
return n * y;
case "weeks":
case "week":
case "w":
return n * w;
case "days":
case "day":
case "d":
return n * d;
case "hours":
case "hour":
case "hrs":
case "hr":
case "h":
return n * h;
case "minutes":
case "minute":
case "mins":
case "min":
case "m":
return n * m;
case "seconds":
case "second":
case "secs":
case "sec":
case "s":
return n * s;
case "milliseconds":
case "millisecond":
case "msecs":
case "msec":
case "ms":
return n;
default:
return void 0;
}
}
function fmtShort(ms) {
var msAbs = Math.abs(ms);
if (msAbs >= d) {
return Math.round(ms / d) + "d";
}
if (msAbs >= h) {
return Math.round(ms / h) + "h";
}
if (msAbs >= m) {
return Math.round(ms / m) + "m";
}
if (msAbs >= s) {
return Math.round(ms / s) + "s";
}
return ms + "ms";
}
function fmtLong(ms) {
var msAbs = Math.abs(ms);
if (msAbs >= d) {
return plural(ms, msAbs, d, "day");
}
if (msAbs >= h) {
return plural(ms, msAbs, h, "hour");
}
if (msAbs >= m) {
return plural(ms, msAbs, m, "minute");
}
if (msAbs >= s) {
return plural(ms, msAbs, s, "second");
}
return ms + " ms";
}
function plural(ms, msAbs, n, name) {
var isPlural = msAbs >= n * 1.5;
return Math.round(ms / n) + " " + name + (isPlural ? "s" : "");
}
}
});
// ../../node_modules/debug/src/common.js
var require_common = __commonJS({
"../../node_modules/debug/src/common.js"(exports, module) {
init_cjs_shims();
function setup(env) {
createDebug.debug = createDebug;
createDebug.default = createDebug;
createDebug.coerce = coerce;
createDebug.disable = disable;
createDebug.enable = enable;
createDebug.enabled = enabled;
createDebug.humanize = require_ms();
createDebug.destroy = destroy;
Object.keys(env).forEach((key) => {
createDebug[key] = env[key];
});
createDebug.names = [];
createDebug.skips = [];
createDebug.formatters = {};
function selectColor(namespace) {
let hash = 0;
for (let i = 0; i < namespace.length; i++) {
hash = (hash << 5) - hash + namespace.charCodeAt(i);
hash |= 0;
}
return createDebug.colors[Math.abs(hash) % createDebug.colors.length];
}
createDebug.selectColor = selectColor;
function createDebug(namespace) {
let prevTime;
let enableOverride = null;
let namespacesCache;
let enabledCache;
function debug(...args) {
if (!debug.enabled) {
return;
}
const self2 = debug;
const curr = Number(/* @__PURE__ */ new Date());
const ms = curr - (prevTime || curr);
self2.diff = ms;
self2.prev = prevTime;
self2.curr = curr;
prevTime = curr;
args[0] = createDebug.coerce(args[0]);
if (typeof args[0] !== "string") {
args.unshift("%O");
}
let index = 0;
args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => {
if (match === "%%") {
return "%";
}
index++;
const formatter = createDebug.formatters[format];
if (typeof formatter === "function") {
const val = args[index];
match = formatter.call(self2, val);
args.splice(index, 1);
index--;
}
return match;
});
createDebug.formatArgs.call(self2, args);
const logFn = self2.log || createDebug.log;
logFn.apply(self2, args);
}
debug.namespace = namespace;
debug.useColors = createDebug.useColors();
debug.color = createDebug.selectColor(namespace);
debug.extend = extend;
debug.destroy = createDebug.destroy;
Object.defineProperty(debug, "enabled", {
enumerable: true,
configurable: false,
get: () => {
if (enableOverride !== null) {
return enableOverride;
}
if (namespacesCache !== createDebug.namespaces) {
namespacesCache = createDebug.namespaces;
enabledCache = createDebug.enabled(namespace);
}
return enabledCache;
},
set: (v) => {
enableOverride = v;
}
});
if (typeof createDebug.init === "function") {
createDebug.init(debug);
}
return debug;
}
function extend(namespace, delimiter) {
const newDebug = createDebug(this.namespace + (typeof delimiter === "undefined" ? ":" : delimiter) + namespace);
newDebug.log = this.log;
return newDebug;
}
function enable(namespaces) {
createDebug.save(namespaces);
createDebug.namespaces = namespaces;
createDebug.names = [];
createDebug.skips = [];
let i;
const split = (typeof namespaces === "string" ? namespaces : "").split(/[\s,]+/);
const len = split.length;
for (i = 0; i < len; i++) {
if (!split[i]) {
continue;
}
namespaces = split[i].replace(/\*/g, ".*?");
if (namespaces[0] === "-") {
createDebug.skips.push(new RegExp("^" + namespaces.slice(1) + "$"));
} else {
createDebug.names.push(new RegExp("^" + namespaces + "$"));
}
}
}
function disable() {
const namespaces = [
...createDebug.names.map(toNamespace),
...createDebug.skips.map(toNamespace).map((namespace) => "-" + namespace)
].join(",");
createDebug.enable("");
return namespaces;
}
function enabled(name) {
if (name[name.length - 1] === "*") {
return true;
}
let i;
let len;
for (i = 0, len = createDebug.skips.length; i < len; i++) {
if (createDebug.skips[i].test(name)) {
return false;
}
}
for (i = 0, len = createDebug.names.length; i < len; i++) {
if (createDebug.names[i].test(name)) {
return true;
}
}
return false;
}
function toNamespace(regexp) {
return regexp.toString().substring(2, regexp.toString().length - 2).replace(/\.\*\?$/, "*");
}
function coerce(val) {
if (val instanceof Error) {
return val.stack || val.message;
}
return val;
}
function destroy() {
console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
}
createDebug.enable(createDebug.load());
return createDebug;
}
module.exports = setup;
}
});
// ../../node_modules/debug/src/browser.js
var require_browser = __commonJS({
"../../node_modules/debug/src/browser.js"(exports, module) {
init_cjs_shims();
exports.formatArgs = formatArgs;
exports.save = save;
exports.load = load;
exports.useColors = useColors;
exports.storage = localstorage();
exports.destroy = /* @__PURE__ */ (() => {
let warned = false;
return () => {
if (!warned) {
warned = true;
console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
}
};
})();
exports.colors = [
"#0000CC",
"#0000FF",
"#0033CC",
"#0033FF",
"#0066CC",
"#0066FF",
"#0099CC",
"#0099FF",
"#00CC00",
"#00CC33",
"#00CC66",
"#00CC99",
"#00CCCC",
"#00CCFF",
"#3300CC",
"#3300FF",
"#3333CC",
"#3333FF",
"#3366CC",
"#3366FF",
"#3399CC",
"#3399FF",
"#33CC00",
"#33CC33",
"#33CC66",
"#33CC99",
"#33CCCC",
"#33CCFF",
"#6600CC",
"#6600FF",
"#6633CC",
"#6633FF",
"#66CC00",
"#66CC33",
"#9900CC",
"#9900FF",
"#9933CC",
"#9933FF",
"#99CC00",
"#99CC33",
"#CC0000",
"#CC0033",
"#CC0066",
"#CC0099",
"#CC00CC",
"#CC00FF",
"#CC3300",
"#CC3333",
"#CC3366",
"#CC3399",
"#CC33CC",
"#CC33FF",
"#CC6600",
"#CC6633",
"#CC9900",
"#CC9933",
"#CCCC00",
"#CCCC33",
"#FF0000",
"#FF0033",
"#FF0066",
"#FF0099",
"#FF00CC",
"#FF00FF",
"#FF3300",
"#FF3333",
"#FF3366",
"#FF3399",
"#FF33CC",
"#FF33FF",
"#FF6600",
"#FF6633",
"#FF9900",
"#FF9933",
"#FFCC00",
"#FFCC33"
];
function useColors() {
if (typeof window !== "undefined" && window.process && (window.process.type === "renderer" || window.process.__nwjs)) {
return true;
}
if (typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
return false;
}
let m;
return typeof document !== "undefined" && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance || // Is firebug? http://stackoverflow.com/a/398120/376773
typeof window !== "undefined" && window.console && (window.console.firebug || window.console.exception && window.console.table) || // Is firefox >= v31?
// https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
typeof navigator !== "undefined" && navigator.userAgent && (m = navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)) && parseInt(m[1], 10) >= 31 || // Double check webkit in userAgent just in case we are in a worker
typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/);
}
function formatArgs(args) {
args[0] = (this.useColors ? "%c" : "") + this.namespace + (this.useColors ? " %c" : " ") + args[0] + (this.useColors ? "%c " : " ") + "+" + module.exports.humanize(this.diff);
if (!this.useColors) {
return;
}
const c = "color: " + this.color;
args.splice(1, 0, c, "color: inherit");
let index = 0;
let lastC = 0;
args[0].replace(/%[a-zA-Z%]/g, (match) => {
if (match === "%%") {
return;
}
index++;
if (match === "%c") {
lastC = index;
}
});
args.splice(lastC, 0, c);
}
exports.log = console.debug || console.log || (() => {
});
function save(namespaces) {
try {
if (namespaces) {
exports.storage.setItem("debug", namespaces);
} else {
exports.storage.removeItem("debug");
}
} catch (error) {
}
}
function load() {
let r;
try {
r = exports.storage.getItem("debug");
} catch (error) {
}
if (!r && typeof process !== "undefined" && "env" in process) {
r = process.env.DEBUG;
}
return r;
}
function localstorage() {
try {
return localStorage;
} catch (error) {
}
}
module.exports = require_common()(exports);
var { formatters } = module.exports;
formatters.j = function(v) {
try {
return JSON.stringify(v);
} catch (error) {
return "[UnexpectedJSONParseError]: " + error.message;
}
};
}
});
// ../../node_modules/supports-color/index.js
var require_supports_color = __commonJS({
"../../node_modules/supports-color/index.js"(exports, module) {
"use strict";
init_cjs_shims();
var os = __require("os");
var tty = __require("tty");
var hasFlag = require_has_flag();
var { env } = process;
var flagForceColor;
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;
}
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;