@midships-global/frodo-cli
Version:
A command line interface to manage ForgeRock Identity Cloud tenants, ForgeOps deployments, and classic deployments.
839 lines (820 loc) • 30.7 kB
JavaScript
;Object.defineProperty(exports, "__esModule", {value: true});
var _chunkHEKQUNOBcjs = require('./chunk-HEKQUNOB.cjs');
// node_modules/resolve/lib/homedir.js
var require_homedir = _chunkHEKQUNOBcjs.__commonJS.call(void 0, {
"node_modules/resolve/lib/homedir.js"(exports, module) {
"use strict";
_chunkHEKQUNOBcjs.init_cjs_shims.call(void 0, );
var os = _chunkHEKQUNOBcjs.__require.call(void 0, "os");
module.exports = os.homedir || function homedir() {
var home = process.env.HOME;
var user = process.env.LOGNAME || process.env.USER || process.env.LNAME || process.env.USERNAME;
if (process.platform === "win32") {
return process.env.USERPROFILE || process.env.HOMEDRIVE + process.env.HOMEPATH || home || null;
}
if (process.platform === "darwin") {
return home || (user ? "/Users/" + user : null);
}
if (process.platform === "linux") {
return home || (process.getuid() === 0 ? "/root" : user ? "/home/" + user : null);
}
return home || null;
};
}
});
// node_modules/resolve/lib/caller.js
var require_caller = _chunkHEKQUNOBcjs.__commonJS.call(void 0, {
"node_modules/resolve/lib/caller.js"(exports, module) {
"use strict";
_chunkHEKQUNOBcjs.init_cjs_shims.call(void 0, );
module.exports = function() {
var origPrepareStackTrace = Error.prepareStackTrace;
Error.prepareStackTrace = function(_, stack2) {
return stack2;
};
var stack = new Error().stack;
Error.prepareStackTrace = origPrepareStackTrace;
return stack[2].getFileName();
};
}
});
// node_modules/path-parse/index.js
var require_path_parse = _chunkHEKQUNOBcjs.__commonJS.call(void 0, {
"node_modules/path-parse/index.js"(exports, module) {
"use strict";
_chunkHEKQUNOBcjs.init_cjs_shims.call(void 0, );
var isWindows = process.platform === "win32";
var splitWindowsRe = /^(((?:[a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/]+[^\\\/]+)?[\\\/]?)(?:[^\\\/]*[\\\/])*)((\.{1,2}|[^\\\/]+?|)(\.[^.\/\\]*|))[\\\/]*$/;
var win32 = {};
function win32SplitPath(filename) {
return splitWindowsRe.exec(filename).slice(1);
}
win32.parse = function(pathString) {
if (typeof pathString !== "string") {
throw new TypeError(
"Parameter 'pathString' must be a string, not " + typeof pathString
);
}
var allParts = win32SplitPath(pathString);
if (!allParts || allParts.length !== 5) {
throw new TypeError("Invalid path '" + pathString + "'");
}
return {
root: allParts[1],
dir: allParts[0] === allParts[1] ? allParts[0] : allParts[0].slice(0, -1),
base: allParts[2],
ext: allParts[4],
name: allParts[3]
};
};
var splitPathRe = /^((\/?)(?:[^\/]*\/)*)((\.{1,2}|[^\/]+?|)(\.[^.\/]*|))[\/]*$/;
var posix = {};
function posixSplitPath(filename) {
return splitPathRe.exec(filename).slice(1);
}
posix.parse = function(pathString) {
if (typeof pathString !== "string") {
throw new TypeError(
"Parameter 'pathString' must be a string, not " + typeof pathString
);
}
var allParts = posixSplitPath(pathString);
if (!allParts || allParts.length !== 5) {
throw new TypeError("Invalid path '" + pathString + "'");
}
return {
root: allParts[1],
dir: allParts[0].slice(0, -1),
base: allParts[2],
ext: allParts[4],
name: allParts[3]
};
};
if (isWindows)
module.exports = win32.parse;
else
module.exports = posix.parse;
module.exports.posix = posix.parse;
module.exports.win32 = win32.parse;
}
});
// node_modules/resolve/lib/node-modules-paths.js
var require_node_modules_paths = _chunkHEKQUNOBcjs.__commonJS.call(void 0, {
"node_modules/resolve/lib/node-modules-paths.js"(exports, module) {
"use strict";
_chunkHEKQUNOBcjs.init_cjs_shims.call(void 0, );
var path = _chunkHEKQUNOBcjs.__require.call(void 0, "path");
var parse = path.parse || require_path_parse();
var getNodeModulesDirs = function getNodeModulesDirs2(absoluteStart, modules) {
var prefix = "/";
if (/^([A-Za-z]:)/.test(absoluteStart)) {
prefix = "";
} else if (/^\\\\/.test(absoluteStart)) {
prefix = "\\\\";
}
var paths = [absoluteStart];
var parsed = parse(absoluteStart);
while (parsed.dir !== paths[paths.length - 1]) {
paths.push(parsed.dir);
parsed = parse(parsed.dir);
}
return paths.reduce(function(dirs, aPath) {
return dirs.concat(modules.map(function(moduleDir) {
return path.resolve(prefix, aPath, moduleDir);
}));
}, []);
};
module.exports = function nodeModulesPaths(start, opts, request) {
var modules = opts && opts.moduleDirectory ? [].concat(opts.moduleDirectory) : ["node_modules"];
if (opts && typeof opts.paths === "function") {
return opts.paths(
request,
start,
function() {
return getNodeModulesDirs(start, modules);
},
opts
);
}
var dirs = getNodeModulesDirs(start, modules);
return opts && opts.paths ? dirs.concat(opts.paths) : dirs;
};
}
});
// node_modules/resolve/lib/normalize-options.js
var require_normalize_options = _chunkHEKQUNOBcjs.__commonJS.call(void 0, {
"node_modules/resolve/lib/normalize-options.js"(exports, module) {
"use strict";
_chunkHEKQUNOBcjs.init_cjs_shims.call(void 0, );
module.exports = function(x, opts) {
return opts || {};
};
}
});
// node_modules/function-bind/implementation.js
var require_implementation = _chunkHEKQUNOBcjs.__commonJS.call(void 0, {
"node_modules/function-bind/implementation.js"(exports, module) {
"use strict";
_chunkHEKQUNOBcjs.init_cjs_shims.call(void 0, );
var ERROR_MESSAGE = "Function.prototype.bind called on incompatible ";
var toStr = Object.prototype.toString;
var max = Math.max;
var funcType = "[object Function]";
var concatty = function concatty2(a, b) {
var arr = [];
for (var i = 0; i < a.length; i += 1) {
arr[i] = a[i];
}
for (var j = 0; j < b.length; j += 1) {
arr[j + a.length] = b[j];
}
return arr;
};
var slicy = function slicy2(arrLike, offset) {
var arr = [];
for (var i = offset || 0, j = 0; i < arrLike.length; i += 1, j += 1) {
arr[j] = arrLike[i];
}
return arr;
};
var joiny = function(arr, joiner) {
var str = "";
for (var i = 0; i < arr.length; i += 1) {
str += arr[i];
if (i + 1 < arr.length) {
str += joiner;
}
}
return str;
};
module.exports = function bind(that) {
var target = this;
if (typeof target !== "function" || toStr.apply(target) !== funcType) {
throw new TypeError(ERROR_MESSAGE + target);
}
var args = slicy(arguments, 1);
var bound;
var binder = function() {
if (this instanceof bound) {
var result = target.apply(
this,
concatty(args, arguments)
);
if (Object(result) === result) {
return result;
}
return this;
}
return target.apply(
that,
concatty(args, arguments)
);
};
var boundLength = max(0, target.length - args.length);
var boundArgs = [];
for (var i = 0; i < boundLength; i++) {
boundArgs[i] = "$" + i;
}
bound = Function("binder", "return function (" + joiny(boundArgs, ",") + "){ return binder.apply(this,arguments); }")(binder);
if (target.prototype) {
var Empty = function Empty2() {
};
Empty.prototype = target.prototype;
bound.prototype = new Empty();
Empty.prototype = null;
}
return bound;
};
}
});
// node_modules/function-bind/index.js
var require_function_bind = _chunkHEKQUNOBcjs.__commonJS.call(void 0, {
"node_modules/function-bind/index.js"(exports, module) {
"use strict";
_chunkHEKQUNOBcjs.init_cjs_shims.call(void 0, );
var implementation = require_implementation();
module.exports = Function.prototype.bind || implementation;
}
});
// node_modules/hasown/index.js
var require_hasown = _chunkHEKQUNOBcjs.__commonJS.call(void 0, {
"node_modules/hasown/index.js"(exports, module) {
"use strict";
_chunkHEKQUNOBcjs.init_cjs_shims.call(void 0, );
var call = Function.prototype.call;
var $hasOwn = Object.prototype.hasOwnProperty;
var bind = require_function_bind();
module.exports = bind.call(call, $hasOwn);
}
});
// node_modules/is-core-module/core.json
var require_core = _chunkHEKQUNOBcjs.__commonJS.call(void 0, {
"node_modules/is-core-module/core.json"(exports, module) {
module.exports = {
assert: true,
"node:assert": [">= 14.18 && < 15", ">= 16"],
"assert/strict": ">= 15",
"node:assert/strict": ">= 16",
async_hooks: ">= 8",
"node:async_hooks": [">= 14.18 && < 15", ">= 16"],
buffer_ieee754: ">= 0.5 && < 0.9.7",
buffer: true,
"node:buffer": [">= 14.18 && < 15", ">= 16"],
child_process: true,
"node:child_process": [">= 14.18 && < 15", ">= 16"],
cluster: ">= 0.5",
"node:cluster": [">= 14.18 && < 15", ">= 16"],
console: true,
"node:console": [">= 14.18 && < 15", ">= 16"],
constants: true,
"node:constants": [">= 14.18 && < 15", ">= 16"],
crypto: true,
"node:crypto": [">= 14.18 && < 15", ">= 16"],
_debug_agent: ">= 1 && < 8",
_debugger: "< 8",
dgram: true,
"node:dgram": [">= 14.18 && < 15", ">= 16"],
diagnostics_channel: [">= 14.17 && < 15", ">= 15.1"],
"node:diagnostics_channel": [">= 14.18 && < 15", ">= 16"],
dns: true,
"node:dns": [">= 14.18 && < 15", ">= 16"],
"dns/promises": ">= 15",
"node:dns/promises": ">= 16",
domain: ">= 0.7.12",
"node:domain": [">= 14.18 && < 15", ">= 16"],
events: true,
"node:events": [">= 14.18 && < 15", ">= 16"],
freelist: "< 6",
fs: true,
"node:fs": [">= 14.18 && < 15", ">= 16"],
"fs/promises": [">= 10 && < 10.1", ">= 14"],
"node:fs/promises": [">= 14.18 && < 15", ">= 16"],
_http_agent: ">= 0.11.1",
"node:_http_agent": [">= 14.18 && < 15", ">= 16"],
_http_client: ">= 0.11.1",
"node:_http_client": [">= 14.18 && < 15", ">= 16"],
_http_common: ">= 0.11.1",
"node:_http_common": [">= 14.18 && < 15", ">= 16"],
_http_incoming: ">= 0.11.1",
"node:_http_incoming": [">= 14.18 && < 15", ">= 16"],
_http_outgoing: ">= 0.11.1",
"node:_http_outgoing": [">= 14.18 && < 15", ">= 16"],
_http_server: ">= 0.11.1",
"node:_http_server": [">= 14.18 && < 15", ">= 16"],
http: true,
"node:http": [">= 14.18 && < 15", ">= 16"],
http2: ">= 8.8",
"node:http2": [">= 14.18 && < 15", ">= 16"],
https: true,
"node:https": [">= 14.18 && < 15", ">= 16"],
inspector: ">= 8",
"node:inspector": [">= 14.18 && < 15", ">= 16"],
"inspector/promises": [">= 19"],
"node:inspector/promises": [">= 19"],
_linklist: "< 8",
module: true,
"node:module": [">= 14.18 && < 15", ">= 16"],
net: true,
"node:net": [">= 14.18 && < 15", ">= 16"],
"node-inspect/lib/_inspect": ">= 7.6 && < 12",
"node-inspect/lib/internal/inspect_client": ">= 7.6 && < 12",
"node-inspect/lib/internal/inspect_repl": ">= 7.6 && < 12",
os: true,
"node:os": [">= 14.18 && < 15", ">= 16"],
path: true,
"node:path": [">= 14.18 && < 15", ">= 16"],
"path/posix": ">= 15.3",
"node:path/posix": ">= 16",
"path/win32": ">= 15.3",
"node:path/win32": ">= 16",
perf_hooks: ">= 8.5",
"node:perf_hooks": [">= 14.18 && < 15", ">= 16"],
process: ">= 1",
"node:process": [">= 14.18 && < 15", ">= 16"],
punycode: ">= 0.5",
"node:punycode": [">= 14.18 && < 15", ">= 16"],
querystring: true,
"node:querystring": [">= 14.18 && < 15", ">= 16"],
readline: true,
"node:readline": [">= 14.18 && < 15", ">= 16"],
"readline/promises": ">= 17",
"node:readline/promises": ">= 17",
repl: true,
"node:repl": [">= 14.18 && < 15", ">= 16"],
"node:sea": [">= 20.12 && < 21", ">= 21.7"],
smalloc: ">= 0.11.5 && < 3",
_stream_duplex: ">= 0.9.4",
"node:_stream_duplex": [">= 14.18 && < 15", ">= 16"],
_stream_transform: ">= 0.9.4",
"node:_stream_transform": [">= 14.18 && < 15", ">= 16"],
_stream_wrap: ">= 1.4.1",
"node:_stream_wrap": [">= 14.18 && < 15", ">= 16"],
_stream_passthrough: ">= 0.9.4",
"node:_stream_passthrough": [">= 14.18 && < 15", ">= 16"],
_stream_readable: ">= 0.9.4",
"node:_stream_readable": [">= 14.18 && < 15", ">= 16"],
_stream_writable: ">= 0.9.4",
"node:_stream_writable": [">= 14.18 && < 15", ">= 16"],
stream: true,
"node:stream": [">= 14.18 && < 15", ">= 16"],
"stream/consumers": ">= 16.7",
"node:stream/consumers": ">= 16.7",
"stream/promises": ">= 15",
"node:stream/promises": ">= 16",
"stream/web": ">= 16.5",
"node:stream/web": ">= 16.5",
string_decoder: true,
"node:string_decoder": [">= 14.18 && < 15", ">= 16"],
sys: [">= 0.4 && < 0.7", ">= 0.8"],
"node:sys": [">= 14.18 && < 15", ">= 16"],
"test/reporters": ">= 19.9 && < 20.2",
"node:test/reporters": [">= 18.17 && < 19", ">= 19.9", ">= 20"],
"test/mock_loader": ">= 22.3 && < 22.7",
"node:test/mock_loader": ">= 22.3 && < 22.7",
"node:test": [">= 16.17 && < 17", ">= 18"],
timers: true,
"node:timers": [">= 14.18 && < 15", ">= 16"],
"timers/promises": ">= 15",
"node:timers/promises": ">= 16",
_tls_common: ">= 0.11.13",
"node:_tls_common": [">= 14.18 && < 15", ">= 16"],
_tls_legacy: ">= 0.11.3 && < 10",
_tls_wrap: ">= 0.11.3",
"node:_tls_wrap": [">= 14.18 && < 15", ">= 16"],
tls: true,
"node:tls": [">= 14.18 && < 15", ">= 16"],
trace_events: ">= 10",
"node:trace_events": [">= 14.18 && < 15", ">= 16"],
tty: true,
"node:tty": [">= 14.18 && < 15", ">= 16"],
url: true,
"node:url": [">= 14.18 && < 15", ">= 16"],
util: true,
"node:util": [">= 14.18 && < 15", ">= 16"],
"util/types": ">= 15.3",
"node:util/types": ">= 16",
"v8/tools/arguments": ">= 10 && < 12",
"v8/tools/codemap": [">= 4.4 && < 5", ">= 5.2 && < 12"],
"v8/tools/consarray": [">= 4.4 && < 5", ">= 5.2 && < 12"],
"v8/tools/csvparser": [">= 4.4 && < 5", ">= 5.2 && < 12"],
"v8/tools/logreader": [">= 4.4 && < 5", ">= 5.2 && < 12"],
"v8/tools/profile_view": [">= 4.4 && < 5", ">= 5.2 && < 12"],
"v8/tools/splaytree": [">= 4.4 && < 5", ">= 5.2 && < 12"],
v8: ">= 1",
"node:v8": [">= 14.18 && < 15", ">= 16"],
vm: true,
"node:vm": [">= 14.18 && < 15", ">= 16"],
wasi: [">= 13.4 && < 13.5", ">= 18.17 && < 19", ">= 20"],
"node:wasi": [">= 18.17 && < 19", ">= 20"],
worker_threads: ">= 11.7",
"node:worker_threads": [">= 14.18 && < 15", ">= 16"],
zlib: ">= 0.5",
"node:zlib": [">= 14.18 && < 15", ">= 16"]
};
}
});
// node_modules/is-core-module/index.js
var require_is_core_module = _chunkHEKQUNOBcjs.__commonJS.call(void 0, {
"node_modules/is-core-module/index.js"(exports, module) {
"use strict";
_chunkHEKQUNOBcjs.init_cjs_shims.call(void 0, );
var hasOwn = require_hasown();
function specifierIncluded(current, specifier) {
var nodeParts = current.split(".");
var parts = specifier.split(" ");
var op = parts.length > 1 ? parts[0] : "=";
var versionParts = (parts.length > 1 ? parts[1] : parts[0]).split(".");
for (var i = 0; i < 3; ++i) {
var cur = parseInt(nodeParts[i] || 0, 10);
var ver = parseInt(versionParts[i] || 0, 10);
if (cur === ver) {
continue;
}
if (op === "<") {
return cur < ver;
}
if (op === ">=") {
return cur >= ver;
}
return false;
}
return op === ">=";
}
function matchesRange(current, range) {
var specifiers = range.split(/ ?&& ?/);
if (specifiers.length === 0) {
return false;
}
for (var i = 0; i < specifiers.length; ++i) {
if (!specifierIncluded(current, specifiers[i])) {
return false;
}
}
return true;
}
function versionIncluded(nodeVersion, specifierValue) {
if (typeof specifierValue === "boolean") {
return specifierValue;
}
var current = typeof nodeVersion === "undefined" ? process.versions && process.versions.node : nodeVersion;
if (typeof current !== "string") {
throw new TypeError(typeof nodeVersion === "undefined" ? "Unable to determine current node version" : "If provided, a valid node version is required");
}
if (specifierValue && typeof specifierValue === "object") {
for (var i = 0; i < specifierValue.length; ++i) {
if (matchesRange(current, specifierValue[i])) {
return true;
}
}
return false;
}
return matchesRange(current, specifierValue);
}
var data = require_core();
module.exports = function isCore(x, nodeVersion) {
return hasOwn(data, x) && versionIncluded(nodeVersion, data[x]);
};
}
});
// node_modules/resolve/lib/async.js
var require_async = _chunkHEKQUNOBcjs.__commonJS.call(void 0, {
"node_modules/resolve/lib/async.js"(exports, module) {
"use strict";
_chunkHEKQUNOBcjs.init_cjs_shims.call(void 0, );
var fs = _chunkHEKQUNOBcjs.__require.call(void 0, "fs");
var getHomedir = require_homedir();
var path = _chunkHEKQUNOBcjs.__require.call(void 0, "path");
var caller = require_caller();
var nodeModulesPaths = require_node_modules_paths();
var normalizeOptions = require_normalize_options();
var isCore = require_is_core_module();
var realpathFS = process.platform !== "win32" && fs.realpath && typeof fs.realpath.native === "function" ? fs.realpath.native : fs.realpath;
var homedir = getHomedir();
var defaultPaths = function() {
return [
path.join(homedir, ".node_modules"),
path.join(homedir, ".node_libraries")
];
};
var defaultIsFile = function isFile(file, cb) {
fs.stat(file, function(err, stat) {
if (!err) {
return cb(null, stat.isFile() || stat.isFIFO());
}
if (err.code === "ENOENT" || err.code === "ENOTDIR") return cb(null, false);
return cb(err);
});
};
var defaultIsDir = function isDirectory(dir, cb) {
fs.stat(dir, function(err, stat) {
if (!err) {
return cb(null, stat.isDirectory());
}
if (err.code === "ENOENT" || err.code === "ENOTDIR") return cb(null, false);
return cb(err);
});
};
var defaultRealpath = function realpath(x, cb) {
realpathFS(x, function(realpathErr, realPath) {
if (realpathErr && realpathErr.code !== "ENOENT") cb(realpathErr);
else cb(null, realpathErr ? x : realPath);
});
};
var maybeRealpath = function maybeRealpath2(realpath, x, opts, cb) {
if (opts && opts.preserveSymlinks === false) {
realpath(x, cb);
} else {
cb(null, x);
}
};
var defaultReadPackage = function defaultReadPackage2(readFile, pkgfile, cb) {
readFile(pkgfile, function(readFileErr, body) {
if (readFileErr) cb(readFileErr);
else {
try {
var pkg = JSON.parse(body);
cb(null, pkg);
} catch (jsonErr) {
cb(null);
}
}
});
};
var getPackageCandidates = function getPackageCandidates2(x, start, opts) {
var dirs = nodeModulesPaths(start, opts, x);
for (var i = 0; i < dirs.length; i++) {
dirs[i] = path.join(dirs[i], x);
}
return dirs;
};
module.exports = function resolve2(x, options, callback) {
var cb = callback;
var opts = options;
if (typeof options === "function") {
cb = opts;
opts = {};
}
if (typeof x !== "string") {
var err = new TypeError("Path must be a string.");
return process.nextTick(function() {
cb(err);
});
}
opts = normalizeOptions(x, opts);
var isFile = opts.isFile || defaultIsFile;
var isDirectory = opts.isDirectory || defaultIsDir;
var readFile = opts.readFile || fs.readFile;
var realpath = opts.realpath || defaultRealpath;
var readPackage = opts.readPackage || defaultReadPackage;
if (opts.readFile && opts.readPackage) {
var conflictErr = new TypeError("`readFile` and `readPackage` are mutually exclusive.");
return process.nextTick(function() {
cb(conflictErr);
});
}
var packageIterator = opts.packageIterator;
var extensions = opts.extensions || [".js"];
var includeCoreModules = opts.includeCoreModules !== false;
var basedir = opts.basedir || path.dirname(caller());
var parent = opts.filename || basedir;
opts.paths = opts.paths || defaultPaths();
var absoluteStart = path.resolve(basedir);
maybeRealpath(
realpath,
absoluteStart,
opts,
function(err2, realStart) {
if (err2) cb(err2);
else init(realStart);
}
);
var res;
function init(basedir2) {
if (/^(?:\.\.?(?:\/|$)|\/|([A-Za-z]:)?[/\\])/.test(x)) {
res = path.resolve(basedir2, x);
if (x === "." || x === ".." || x.slice(-1) === "/") res += "/";
if (/\/$/.test(x) && res === basedir2) {
loadAsDirectory(res, opts.package, onfile);
} else loadAsFile(res, opts.package, onfile);
} else if (includeCoreModules && isCore(x)) {
return cb(null, x);
} else loadNodeModules(x, basedir2, function(err2, n, pkg) {
if (err2) cb(err2);
else if (n) {
return maybeRealpath(realpath, n, opts, function(err3, realN) {
if (err3) {
cb(err3);
} else {
cb(null, realN, pkg);
}
});
} else {
var moduleError = new Error("Cannot find module '" + x + "' from '" + parent + "'");
moduleError.code = "MODULE_NOT_FOUND";
cb(moduleError);
}
});
}
function onfile(err2, m, pkg) {
if (err2) cb(err2);
else if (m) cb(null, m, pkg);
else loadAsDirectory(res, function(err3, d, pkg2) {
if (err3) cb(err3);
else if (d) {
maybeRealpath(realpath, d, opts, function(err4, realD) {
if (err4) {
cb(err4);
} else {
cb(null, realD, pkg2);
}
});
} else {
var moduleError = new Error("Cannot find module '" + x + "' from '" + parent + "'");
moduleError.code = "MODULE_NOT_FOUND";
cb(moduleError);
}
});
}
function loadAsFile(x2, thePackage, callback2) {
var loadAsFilePackage = thePackage;
var cb2 = callback2;
if (typeof loadAsFilePackage === "function") {
cb2 = loadAsFilePackage;
loadAsFilePackage = void 0;
}
var exts = [""].concat(extensions);
load(exts, x2, loadAsFilePackage);
function load(exts2, x3, loadPackage) {
if (exts2.length === 0) return cb2(null, void 0, loadPackage);
var file = x3 + exts2[0];
var pkg = loadPackage;
if (pkg) onpkg(null, pkg);
else loadpkg(path.dirname(file), onpkg);
function onpkg(err2, pkg_, dir) {
pkg = pkg_;
if (err2) return cb2(err2);
if (dir && pkg && opts.pathFilter) {
var rfile = path.relative(dir, file);
var rel = rfile.slice(0, rfile.length - exts2[0].length);
var r = opts.pathFilter(pkg, x3, rel);
if (r) return load(
[""].concat(extensions.slice()),
path.resolve(dir, r),
pkg
);
}
isFile(file, onex);
}
function onex(err2, ex) {
if (err2) return cb2(err2);
if (ex) return cb2(null, file, pkg);
load(exts2.slice(1), x3, pkg);
}
}
}
function loadpkg(dir, cb2) {
if (dir === "" || dir === "/") return cb2(null);
if (process.platform === "win32" && /^\w:[/\\]*$/.test(dir)) {
return cb2(null);
}
if (/[/\\]node_modules[/\\]*$/.test(dir)) return cb2(null);
maybeRealpath(realpath, dir, opts, function(unwrapErr, pkgdir) {
if (unwrapErr) return loadpkg(path.dirname(dir), cb2);
var pkgfile = path.join(pkgdir, "package.json");
isFile(pkgfile, function(err2, ex) {
if (!ex) return loadpkg(path.dirname(dir), cb2);
readPackage(readFile, pkgfile, function(err3, pkgParam) {
if (err3) cb2(err3);
var pkg = pkgParam;
if (pkg && opts.packageFilter) {
pkg = opts.packageFilter(pkg, pkgfile);
}
cb2(null, pkg, dir);
});
});
});
}
function loadAsDirectory(x2, loadAsDirectoryPackage, callback2) {
var cb2 = callback2;
var fpkg = loadAsDirectoryPackage;
if (typeof fpkg === "function") {
cb2 = fpkg;
fpkg = opts.package;
}
maybeRealpath(realpath, x2, opts, function(unwrapErr, pkgdir) {
if (unwrapErr) return cb2(unwrapErr);
var pkgfile = path.join(pkgdir, "package.json");
isFile(pkgfile, function(err2, ex) {
if (err2) return cb2(err2);
if (!ex) return loadAsFile(path.join(x2, "index"), fpkg, cb2);
readPackage(readFile, pkgfile, function(err3, pkgParam) {
if (err3) return cb2(err3);
var pkg = pkgParam;
if (pkg && opts.packageFilter) {
pkg = opts.packageFilter(pkg, pkgfile);
}
if (pkg && pkg.main) {
if (typeof pkg.main !== "string") {
var mainError = new TypeError("package \u201C" + pkg.name + "\u201D `main` must be a string");
mainError.code = "INVALID_PACKAGE_MAIN";
return cb2(mainError);
}
if (pkg.main === "." || pkg.main === "./") {
pkg.main = "index";
}
loadAsFile(path.resolve(x2, pkg.main), pkg, function(err4, m, pkg2) {
if (err4) return cb2(err4);
if (m) return cb2(null, m, pkg2);
if (!pkg2) return loadAsFile(path.join(x2, "index"), pkg2, cb2);
var dir = path.resolve(x2, pkg2.main);
loadAsDirectory(dir, pkg2, function(err5, n, pkg3) {
if (err5) return cb2(err5);
if (n) return cb2(null, n, pkg3);
loadAsFile(path.join(x2, "index"), pkg3, cb2);
});
});
return;
}
loadAsFile(path.join(x2, "/index"), pkg, cb2);
});
});
});
}
function processDirs(cb2, dirs) {
if (dirs.length === 0) return cb2(null, void 0);
var dir = dirs[0];
isDirectory(path.dirname(dir), isdir);
function isdir(err2, isdir2) {
if (err2) return cb2(err2);
if (!isdir2) return processDirs(cb2, dirs.slice(1));
loadAsFile(dir, opts.package, onfile2);
}
function onfile2(err2, m, pkg) {
if (err2) return cb2(err2);
if (m) return cb2(null, m, pkg);
loadAsDirectory(dir, opts.package, ondir);
}
function ondir(err2, n, pkg) {
if (err2) return cb2(err2);
if (n) return cb2(null, n, pkg);
processDirs(cb2, dirs.slice(1));
}
}
function loadNodeModules(x2, start, cb2) {
var thunk = function() {
return getPackageCandidates(x2, start, opts);
};
processDirs(
cb2,
packageIterator ? packageIterator(x2, start, thunk, opts) : thunk()
);
}
};
}
});
// node_modules/resolve/async.js
var require_async2 = _chunkHEKQUNOBcjs.__commonJS.call(void 0, {
"node_modules/resolve/async.js"(exports, module) {
"use strict";
_chunkHEKQUNOBcjs.init_cjs_shims.call(void 0, );
module.exports = require_async();
}
});
// src/loader.ts
_chunkHEKQUNOBcjs.init_cjs_shims.call(void 0, );
var import_async = _chunkHEKQUNOBcjs.__toESM.call(void 0, require_async2(), 1);
var _module = require('module');
var _path = require('path');
var _process = require('process');
var _url = require('url');
var _util = require('util');
var resolveAsync = _util.promisify.call(void 0, import_async.default);
var baseURL = _url.pathToFileURL.call(void 0, _process.cwd.call(void 0, ) + "/").href;
async function resolve(specifier, context, next) {
const { parentURL = baseURL } = context;
if (specifier.startsWith("node:") || _module.builtinModules.includes(specifier)) {
return next(specifier, context);
}
if (specifier.startsWith("file://")) {
specifier = _url.fileURLToPath.call(void 0, specifier);
}
const parentPath = _url.fileURLToPath.call(void 0, parentURL);
let url;
try {
const resolution = await resolveAsync(specifier, {
basedir: _path.dirname.call(void 0, parentPath),
// For whatever reason, --experimental-specifier-resolution=node doesn't search for .mjs extensions
// but it does search for index.mjs files within directories
extensions: [".js", ".json", ".node", ".mjs"]
});
url = _url.pathToFileURL.call(void 0, resolution).href;
} catch (error) {
if (error.code === "MODULE_NOT_FOUND") {
error.code = "ERR_MODULE_NOT_FOUND";
}
throw error;
}
return next(url, context);
}
exports.resolve = resolve;
//# sourceMappingURL=loader.cjs.map