@storm-software/linting-tools
Version:
⚡ A package containing various linting tools used to validate syntax, enforce design standards, and format code in a Storm workspace.
1,487 lines (1,476 loc) • 118 kB
JavaScript
import {
require_semver
} from "./chunk-X4CBG64A.js";
import {
__commonJS,
__dirname,
__require,
__toESM,
init_esm_shims
} from "./chunk-LXPMPMVD.js";
// ../../node_modules/.pnpm/ini@1.3.8/node_modules/ini/ini.js
var require_ini = __commonJS({
"../../node_modules/.pnpm/ini@1.3.8/node_modules/ini/ini.js"(exports) {
init_esm_shims();
exports.parse = exports.decode = decode;
exports.stringify = exports.encode = encode;
exports.safe = safe;
exports.unsafe = unsafe;
var eol = typeof process !== "undefined" && process.platform === "win32" ? "\r\n" : "\n";
function encode(obj, opt) {
var children = [];
var out = "";
if (typeof opt === "string") {
opt = {
section: opt,
whitespace: false
};
} else {
opt = opt || {};
opt.whitespace = opt.whitespace === true;
}
var separator = opt.whitespace ? " = " : "=";
Object.keys(obj).forEach(function(k, _, __) {
var val = obj[k];
if (val && Array.isArray(val)) {
val.forEach(function(item) {
out += safe(k + "[]") + separator + safe(item) + "\n";
});
} else if (val && typeof val === "object")
children.push(k);
else
out += safe(k) + separator + safe(val) + eol;
});
if (opt.section && out.length)
out = "[" + safe(opt.section) + "]" + eol + out;
children.forEach(function(k, _, __) {
var nk = dotSplit(k).join("\\.");
var section = (opt.section ? opt.section + "." : "") + nk;
var child = encode(obj[k], {
section,
whitespace: opt.whitespace
});
if (out.length && child.length)
out += eol;
out += child;
});
return out;
}
function dotSplit(str) {
return str.replace(/\1/g, "LITERAL\\1LITERAL").replace(/\\\./g, "").split(/\./).map(function(part) {
return part.replace(/\1/g, "\\.").replace(/\2LITERAL\\1LITERAL\2/g, "");
});
}
function decode(str) {
var out = {};
var p = out;
var section = null;
var re = /^\[([^\]]*)\]$|^([^=]+)(=(.*))?$/i;
var lines = str.split(/[\r\n]+/g);
lines.forEach(function(line, _, __) {
if (!line || line.match(/^\s*[;#]/))
return;
var match = line.match(re);
if (!match)
return;
if (match[1] !== void 0) {
section = unsafe(match[1]);
if (section === "__proto__") {
p = {};
return;
}
p = out[section] = out[section] || {};
return;
}
var key = unsafe(match[2]);
if (key === "__proto__")
return;
var value = match[3] ? unsafe(match[4]) : true;
switch (value) {
case "true":
case "false":
case "null":
value = JSON.parse(value);
}
if (key.length > 2 && key.slice(-2) === "[]") {
key = key.substring(0, key.length - 2);
if (key === "__proto__")
return;
if (!p[key])
p[key] = [];
else if (!Array.isArray(p[key]))
p[key] = [p[key]];
}
if (Array.isArray(p[key]))
p[key].push(value);
else
p[key] = value;
});
Object.keys(out).filter(function(k, _, __) {
if (!out[k] || typeof out[k] !== "object" || Array.isArray(out[k]))
return false;
var parts = dotSplit(k);
var p2 = out;
var l = parts.pop();
var nl = l.replace(/\\\./g, ".");
parts.forEach(function(part, _2, __2) {
if (part === "__proto__")
return;
if (!p2[part] || typeof p2[part] !== "object")
p2[part] = {};
p2 = p2[part];
});
if (p2 === out && nl === l)
return false;
p2[nl] = out[k];
return true;
}).forEach(function(del, _, __) {
delete out[del];
});
return out;
}
function isQuoted(val) {
return val.charAt(0) === '"' && val.slice(-1) === '"' || val.charAt(0) === "'" && val.slice(-1) === "'";
}
function safe(val) {
return typeof val !== "string" || val.match(/[=\r\n]/) || val.match(/^\[/) || val.length > 1 && isQuoted(val) || val !== val.trim() ? JSON.stringify(val) : val.replace(/;/g, "\\;").replace(/#/g, "\\#");
}
function unsafe(val, doUnesc) {
val = (val || "").trim();
if (isQuoted(val)) {
if (val.charAt(0) === "'")
val = val.substr(1, val.length - 2);
try {
val = JSON.parse(val);
} catch (_) {
}
} else {
var esc = false;
var unesc = "";
for (var i = 0, l = val.length; i < l; i++) {
var c = val.charAt(i);
if (esc) {
if ("\\;#".indexOf(c) !== -1)
unesc += c;
else
unesc += "\\" + c;
esc = false;
} else if (";#".indexOf(c) !== -1)
break;
else if (c === "\\")
esc = true;
else
unesc += c;
}
if (esc)
unesc += "\\";
return unesc.trim();
}
return val;
}
}
});
// ../../node_modules/.pnpm/strip-json-comments@2.0.1/node_modules/strip-json-comments/index.js
var require_strip_json_comments = __commonJS({
"../../node_modules/.pnpm/strip-json-comments@2.0.1/node_modules/strip-json-comments/index.js"(exports, module) {
"use strict";
init_esm_shims();
var singleComment = 1;
var multiComment = 2;
function stripWithoutWhitespace() {
return "";
}
function stripWithWhitespace(str, start, end) {
return str.slice(start, end).replace(/\S/g, " ");
}
module.exports = function(str, opts) {
opts = opts || {};
var currentChar;
var nextChar;
var insideString = false;
var insideComment = false;
var offset = 0;
var ret = "";
var strip = opts.whitespace === false ? stripWithoutWhitespace : stripWithWhitespace;
for (var i = 0; i < str.length; i++) {
currentChar = str[i];
nextChar = str[i + 1];
if (!insideComment && currentChar === '"') {
var escaped = str[i - 1] === "\\" && str[i - 2] !== "\\";
if (!escaped) {
insideString = !insideString;
}
}
if (insideString) {
continue;
}
if (!insideComment && currentChar + nextChar === "//") {
ret += str.slice(offset, i);
offset = i;
insideComment = singleComment;
i++;
} else if (insideComment === singleComment && currentChar + nextChar === "\r\n") {
i++;
insideComment = false;
ret += strip(str, offset, i);
offset = i;
continue;
} else if (insideComment === singleComment && currentChar === "\n") {
insideComment = false;
ret += strip(str, offset, i);
offset = i;
} else if (!insideComment && currentChar + nextChar === "/*") {
ret += str.slice(offset, i);
offset = i;
insideComment = multiComment;
i++;
continue;
} else if (insideComment === multiComment && currentChar + nextChar === "*/") {
i++;
insideComment = false;
ret += strip(str, offset, i + 1);
offset = i + 1;
continue;
}
}
return ret + (insideComment ? strip(str.substr(offset)) : str.substr(offset));
};
}
});
// ../../node_modules/.pnpm/rc@1.2.8/node_modules/rc/lib/utils.js
import * as __import_fs from "fs";
import * as __import_path from "path";
var require_utils = __commonJS({
"../../node_modules/.pnpm/rc@1.2.8/node_modules/rc/lib/utils.js"(exports) {
init_esm_shims();
var __import_ini = __toESM(require_ini());
var __import_stripJsonComments = __toESM(require_strip_json_comments());
var fs = __import_fs;
var ini = __import_ini;
var path = __import_path;
var stripJsonComments = __import_stripJsonComments;
var parse = exports.parse = function(content) {
if (/^\s*{/.test(content))
return JSON.parse(stripJsonComments(content));
return ini.parse(content);
};
var file = exports.file = function() {
var args = [].slice.call(arguments).filter(function(arg) {
return arg != null;
});
for (var i in args)
if ("string" !== typeof args[i])
return;
var file2 = path.join.apply(null, args);
var content;
try {
return fs.readFileSync(file2, "utf-8");
} catch (err) {
return;
}
};
var json = exports.json = function() {
var content = file.apply(null, arguments);
return content ? parse(content) : null;
};
var env = exports.env = function(prefix, env2) {
env2 = env2 || process.env;
var obj = {};
var l = prefix.length;
for (var k in env2) {
if (k.toLowerCase().indexOf(prefix.toLowerCase()) === 0) {
var keypath = k.substring(l).split("__");
var _emptyStringIndex;
while ((_emptyStringIndex = keypath.indexOf("")) > -1) {
keypath.splice(_emptyStringIndex, 1);
}
var cursor = obj;
keypath.forEach(function _buildSubObj(_subkey, i) {
if (!_subkey || typeof cursor !== "object")
return;
if (i === keypath.length - 1)
cursor[_subkey] = env2[k];
if (cursor[_subkey] === void 0)
cursor[_subkey] = {};
cursor = cursor[_subkey];
});
}
}
return obj;
};
var find = exports.find = function() {
var rel = path.join.apply(null, [].slice.call(arguments));
function find2(start, rel2) {
var file2 = path.join(start, rel2);
try {
fs.statSync(file2);
return file2;
} catch (err) {
if (path.dirname(start) !== start)
return find2(path.dirname(start), rel2);
}
}
return find2(process.cwd(), rel);
};
}
});
// ../../node_modules/.pnpm/deep-extend@0.6.0/node_modules/deep-extend/lib/deep-extend.js
var require_deep_extend = __commonJS({
"../../node_modules/.pnpm/deep-extend@0.6.0/node_modules/deep-extend/lib/deep-extend.js"(exports, module) {
"use strict";
init_esm_shims();
function isSpecificValue(val) {
return val instanceof Buffer || val instanceof Date || val instanceof RegExp ? true : false;
}
function cloneSpecificValue(val) {
if (val instanceof Buffer) {
var x = Buffer.alloc ? Buffer.alloc(val.length) : new Buffer(val.length);
val.copy(x);
return x;
} else if (val instanceof Date) {
return new Date(val.getTime());
} else if (val instanceof RegExp) {
return new RegExp(val);
} else {
throw new Error("Unexpected situation");
}
}
function deepCloneArray(arr) {
var clone = [];
arr.forEach(function(item, index) {
if (typeof item === "object" && item !== null) {
if (Array.isArray(item)) {
clone[index] = deepCloneArray(item);
} else if (isSpecificValue(item)) {
clone[index] = cloneSpecificValue(item);
} else {
clone[index] = deepExtend({}, item);
}
} else {
clone[index] = item;
}
});
return clone;
}
function safeGetProperty(object, property) {
return property === "__proto__" ? void 0 : object[property];
}
var deepExtend = module.exports = function() {
if (arguments.length < 1 || typeof arguments[0] !== "object") {
return false;
}
if (arguments.length < 2) {
return arguments[0];
}
var target = arguments[0];
var args = Array.prototype.slice.call(arguments, 1);
var val, src, clone;
args.forEach(function(obj) {
if (typeof obj !== "object" || obj === null || Array.isArray(obj)) {
return;
}
Object.keys(obj).forEach(function(key) {
src = safeGetProperty(target, key);
val = safeGetProperty(obj, key);
if (val === target) {
return;
} else if (typeof val !== "object" || val === null) {
target[key] = val;
return;
} else if (Array.isArray(val)) {
target[key] = deepCloneArray(val);
return;
} else if (isSpecificValue(val)) {
target[key] = cloneSpecificValue(val);
return;
} else if (typeof src !== "object" || src === null || Array.isArray(src)) {
target[key] = deepExtend({}, val);
return;
} else {
target[key] = deepExtend(src, val);
return;
}
});
});
return target;
};
}
});
// ../../node_modules/.pnpm/minimist@1.2.8/node_modules/minimist/index.js
var require_minimist = __commonJS({
"../../node_modules/.pnpm/minimist@1.2.8/node_modules/minimist/index.js"(exports, module) {
"use strict";
init_esm_shims();
function hasKey(obj, keys) {
var o = obj;
keys.slice(0, -1).forEach(function(key2) {
o = o[key2] || {};
});
var key = keys[keys.length - 1];
return key in o;
}
function isNumber(x) {
if (typeof x === "number") {
return true;
}
if (/^0x[0-9a-f]+$/i.test(x)) {
return true;
}
return /^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(x);
}
function isConstructorOrProto(obj, key) {
return key === "constructor" && typeof obj[key] === "function" || key === "__proto__";
}
module.exports = function(args, opts) {
if (!opts) {
opts = {};
}
var flags = {
bools: {},
strings: {},
unknownFn: null
};
if (typeof opts.unknown === "function") {
flags.unknownFn = opts.unknown;
}
if (typeof opts.boolean === "boolean" && opts.boolean) {
flags.allBools = true;
} else {
[].concat(opts.boolean).filter(Boolean).forEach(function(key2) {
flags.bools[key2] = true;
});
}
var aliases = {};
function aliasIsBoolean(key2) {
return aliases[key2].some(function(x) {
return flags.bools[x];
});
}
Object.keys(opts.alias || {}).forEach(function(key2) {
aliases[key2] = [].concat(opts.alias[key2]);
aliases[key2].forEach(function(x) {
aliases[x] = [key2].concat(aliases[key2].filter(function(y) {
return x !== y;
}));
});
});
[].concat(opts.string).filter(Boolean).forEach(function(key2) {
flags.strings[key2] = true;
if (aliases[key2]) {
[].concat(aliases[key2]).forEach(function(k) {
flags.strings[k] = true;
});
}
});
var defaults = opts.default || {};
var argv = { _: [] };
function argDefined(key2, arg2) {
return flags.allBools && /^--[^=]+$/.test(arg2) || flags.strings[key2] || flags.bools[key2] || aliases[key2];
}
function setKey(obj, keys, value2) {
var o = obj;
for (var i2 = 0; i2 < keys.length - 1; i2++) {
var key2 = keys[i2];
if (isConstructorOrProto(o, key2)) {
return;
}
if (o[key2] === void 0) {
o[key2] = {};
}
if (o[key2] === Object.prototype || o[key2] === Number.prototype || o[key2] === String.prototype) {
o[key2] = {};
}
if (o[key2] === Array.prototype) {
o[key2] = [];
}
o = o[key2];
}
var lastKey = keys[keys.length - 1];
if (isConstructorOrProto(o, lastKey)) {
return;
}
if (o === Object.prototype || o === Number.prototype || o === String.prototype) {
o = {};
}
if (o === Array.prototype) {
o = [];
}
if (o[lastKey] === void 0 || flags.bools[lastKey] || typeof o[lastKey] === "boolean") {
o[lastKey] = value2;
} else if (Array.isArray(o[lastKey])) {
o[lastKey].push(value2);
} else {
o[lastKey] = [o[lastKey], value2];
}
}
function setArg(key2, val, arg2) {
if (arg2 && flags.unknownFn && !argDefined(key2, arg2)) {
if (flags.unknownFn(arg2) === false) {
return;
}
}
var value2 = !flags.strings[key2] && isNumber(val) ? Number(val) : val;
setKey(argv, key2.split("."), value2);
(aliases[key2] || []).forEach(function(x) {
setKey(argv, x.split("."), value2);
});
}
Object.keys(flags.bools).forEach(function(key2) {
setArg(key2, defaults[key2] === void 0 ? false : defaults[key2]);
});
var notFlags = [];
if (args.indexOf("--") !== -1) {
notFlags = args.slice(args.indexOf("--") + 1);
args = args.slice(0, args.indexOf("--"));
}
for (var i = 0; i < args.length; i++) {
var arg = args[i];
var key;
var next;
if (/^--.+=/.test(arg)) {
var m = arg.match(/^--([^=]+)=([\s\S]*)$/);
key = m[1];
var value = m[2];
if (flags.bools[key]) {
value = value !== "false";
}
setArg(key, value, arg);
} else if (/^--no-.+/.test(arg)) {
key = arg.match(/^--no-(.+)/)[1];
setArg(key, false, arg);
} else if (/^--.+/.test(arg)) {
key = arg.match(/^--(.+)/)[1];
next = args[i + 1];
if (next !== void 0 && !/^(-|--)[^-]/.test(next) && !flags.bools[key] && !flags.allBools && (aliases[key] ? !aliasIsBoolean(key) : true)) {
setArg(key, next, arg);
i += 1;
} else if (/^(true|false)$/.test(next)) {
setArg(key, next === "true", arg);
i += 1;
} else {
setArg(key, flags.strings[key] ? "" : true, arg);
}
} else if (/^-[^-]+/.test(arg)) {
var letters = arg.slice(1, -1).split("");
var broken = false;
for (var j = 0; j < letters.length; j++) {
next = arg.slice(j + 2);
if (next === "-") {
setArg(letters[j], next, arg);
continue;
}
if (/[A-Za-z]/.test(letters[j]) && next[0] === "=") {
setArg(letters[j], next.slice(1), arg);
broken = true;
break;
}
if (/[A-Za-z]/.test(letters[j]) && /-?\d+(\.\d*)?(e-?\d+)?$/.test(next)) {
setArg(letters[j], next, arg);
broken = true;
break;
}
if (letters[j + 1] && letters[j + 1].match(/\W/)) {
setArg(letters[j], arg.slice(j + 2), arg);
broken = true;
break;
} else {
setArg(letters[j], flags.strings[letters[j]] ? "" : true, arg);
}
}
key = arg.slice(-1)[0];
if (!broken && key !== "-") {
if (args[i + 1] && !/^(-|--)[^-]/.test(args[i + 1]) && !flags.bools[key] && (aliases[key] ? !aliasIsBoolean(key) : true)) {
setArg(key, args[i + 1], arg);
i += 1;
} else if (args[i + 1] && /^(true|false)$/.test(args[i + 1])) {
setArg(key, args[i + 1] === "true", arg);
i += 1;
} else {
setArg(key, flags.strings[key] ? "" : true, arg);
}
}
} else {
if (!flags.unknownFn || flags.unknownFn(arg) !== false) {
argv._.push(flags.strings._ || !isNumber(arg) ? arg : Number(arg));
}
if (opts.stopEarly) {
argv._.push.apply(argv._, args.slice(i + 1));
break;
}
}
}
Object.keys(defaults).forEach(function(k) {
if (!hasKey(argv, k.split("."))) {
setKey(argv, k.split("."), defaults[k]);
(aliases[k] || []).forEach(function(x) {
setKey(argv, x.split("."), defaults[k]);
});
}
});
if (opts["--"]) {
argv["--"] = notFlags.slice();
} else {
notFlags.forEach(function(k) {
argv._.push(k);
});
}
return argv;
};
}
});
// ../../node_modules/.pnpm/rc@1.2.8/node_modules/rc/index.js
import * as __import_path2 from "path";
var require_rc = __commonJS({
"../../node_modules/.pnpm/rc@1.2.8/node_modules/rc/index.js"(exports, module) {
init_esm_shims();
var __import___lib_utils = __toESM(require_utils());
var __import_deepExtend = __toESM(require_deep_extend());
var __import_minimist = __toESM(require_minimist());
var cc = __import___lib_utils;
var join = __import_path2.join;
var deepExtend = __import_deepExtend;
var etc = "/etc";
var win = process.platform === "win32";
var home = win ? process.env.USERPROFILE : process.env.HOME;
module.exports = function(name, defaults, argv, parse) {
if ("string" !== typeof name)
throw new Error("rc(name): name *must* be string");
if (!argv)
argv = __import_minimist(process.argv.slice(2));
defaults = ("string" === typeof defaults ? cc.json(defaults) : defaults) || {};
parse = parse || cc.parse;
var env = cc.env(name + "_");
var configs = [defaults];
var configFiles = [];
function addConfigFile(file) {
if (configFiles.indexOf(file) >= 0) return;
var fileConfig = cc.file(file);
if (fileConfig) {
configs.push(parse(fileConfig));
configFiles.push(file);
}
}
if (!win)
[
join(etc, name, "config"),
join(etc, name + "rc")
].forEach(addConfigFile);
if (home)
[
join(home, ".config", name, "config"),
join(home, ".config", name),
join(home, "." + name, "config"),
join(home, "." + name + "rc")
].forEach(addConfigFile);
addConfigFile(cc.find("." + name + "rc"));
if (env.config) addConfigFile(env.config);
if (argv.config) addConfigFile(argv.config);
return deepExtend.apply(null, configs.concat([
env,
argv,
configFiles.length ? { configs: configFiles, config: configFiles[configFiles.length - 1] } : void 0
]));
};
}
});
// ../../node_modules/.pnpm/graceful-fs@4.2.10/node_modules/graceful-fs/polyfills.js
import * as __import_constants from "constants";
var require_polyfills = __commonJS({
"../../node_modules/.pnpm/graceful-fs@4.2.10/node_modules/graceful-fs/polyfills.js"(exports, module) {
init_esm_shims();
var constants = __import_constants;
var origCwd = process.cwd;
var cwd = null;
var platform = process.env.GRACEFUL_FS_PLATFORM || process.platform;
process.cwd = function() {
if (!cwd)
cwd = origCwd.call(process);
return cwd;
};
try {
process.cwd();
} catch (er) {
}
if (typeof process.chdir === "function") {
chdir = process.chdir;
process.chdir = function(d) {
cwd = null;
chdir.call(process, d);
};
if (Object.setPrototypeOf) Object.setPrototypeOf(process.chdir, chdir);
}
var chdir;
module.exports = patch;
function patch(fs) {
if (constants.hasOwnProperty("O_SYMLINK") && process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)) {
patchLchmod(fs);
}
if (!fs.lutimes) {
patchLutimes(fs);
}
fs.chown = chownFix(fs.chown);
fs.fchown = chownFix(fs.fchown);
fs.lchown = chownFix(fs.lchown);
fs.chmod = chmodFix(fs.chmod);
fs.fchmod = chmodFix(fs.fchmod);
fs.lchmod = chmodFix(fs.lchmod);
fs.chownSync = chownFixSync(fs.chownSync);
fs.fchownSync = chownFixSync(fs.fchownSync);
fs.lchownSync = chownFixSync(fs.lchownSync);
fs.chmodSync = chmodFixSync(fs.chmodSync);
fs.fchmodSync = chmodFixSync(fs.fchmodSync);
fs.lchmodSync = chmodFixSync(fs.lchmodSync);
fs.stat = statFix(fs.stat);
fs.fstat = statFix(fs.fstat);
fs.lstat = statFix(fs.lstat);
fs.statSync = statFixSync(fs.statSync);
fs.fstatSync = statFixSync(fs.fstatSync);
fs.lstatSync = statFixSync(fs.lstatSync);
if (fs.chmod && !fs.lchmod) {
fs.lchmod = function(path, mode, cb) {
if (cb) process.nextTick(cb);
};
fs.lchmodSync = function() {
};
}
if (fs.chown && !fs.lchown) {
fs.lchown = function(path, uid, gid, cb) {
if (cb) process.nextTick(cb);
};
fs.lchownSync = function() {
};
}
if (platform === "win32") {
fs.rename = typeof fs.rename !== "function" ? fs.rename : function(fs$rename) {
function rename(from, to, cb) {
var start = Date.now();
var backoff = 0;
fs$rename(from, to, function CB(er) {
if (er && (er.code === "EACCES" || er.code === "EPERM") && Date.now() - start < 6e4) {
setTimeout(function() {
fs.stat(to, function(stater, st) {
if (stater && stater.code === "ENOENT")
fs$rename(from, to, CB);
else
cb(er);
});
}, backoff);
if (backoff < 100)
backoff += 10;
return;
}
if (cb) cb(er);
});
}
if (Object.setPrototypeOf) Object.setPrototypeOf(rename, fs$rename);
return rename;
}(fs.rename);
}
fs.read = typeof fs.read !== "function" ? fs.read : function(fs$read) {
function read(fd, buffer, offset, length, position, callback_) {
var callback;
if (callback_ && typeof callback_ === "function") {
var eagCounter = 0;
callback = function(er, _, __) {
if (er && er.code === "EAGAIN" && eagCounter < 10) {
eagCounter++;
return fs$read.call(fs, fd, buffer, offset, length, position, callback);
}
callback_.apply(this, arguments);
};
}
return fs$read.call(fs, fd, buffer, offset, length, position, callback);
}
if (Object.setPrototypeOf) Object.setPrototypeOf(read, fs$read);
return read;
}(fs.read);
fs.readSync = typeof fs.readSync !== "function" ? fs.readSync : /* @__PURE__ */ function(fs$readSync) {
return function(fd, buffer, offset, length, position) {
var eagCounter = 0;
while (true) {
try {
return fs$readSync.call(fs, fd, buffer, offset, length, position);
} catch (er) {
if (er.code === "EAGAIN" && eagCounter < 10) {
eagCounter++;
continue;
}
throw er;
}
}
};
}(fs.readSync);
function patchLchmod(fs2) {
fs2.lchmod = function(path, mode, callback) {
fs2.open(
path,
constants.O_WRONLY | constants.O_SYMLINK,
mode,
function(err, fd) {
if (err) {
if (callback) callback(err);
return;
}
fs2.fchmod(fd, mode, function(err2) {
fs2.close(fd, function(err22) {
if (callback) callback(err2 || err22);
});
});
}
);
};
fs2.lchmodSync = function(path, mode) {
var fd = fs2.openSync(path, constants.O_WRONLY | constants.O_SYMLINK, mode);
var threw = true;
var ret;
try {
ret = fs2.fchmodSync(fd, mode);
threw = false;
} finally {
if (threw) {
try {
fs2.closeSync(fd);
} catch (er) {
}
} else {
fs2.closeSync(fd);
}
}
return ret;
};
}
function patchLutimes(fs2) {
if (constants.hasOwnProperty("O_SYMLINK") && fs2.futimes) {
fs2.lutimes = function(path, at, mt, cb) {
fs2.open(path, constants.O_SYMLINK, function(er, fd) {
if (er) {
if (cb) cb(er);
return;
}
fs2.futimes(fd, at, mt, function(er2) {
fs2.close(fd, function(er22) {
if (cb) cb(er2 || er22);
});
});
});
};
fs2.lutimesSync = function(path, at, mt) {
var fd = fs2.openSync(path, constants.O_SYMLINK);
var ret;
var threw = true;
try {
ret = fs2.futimesSync(fd, at, mt);
threw = false;
} finally {
if (threw) {
try {
fs2.closeSync(fd);
} catch (er) {
}
} else {
fs2.closeSync(fd);
}
}
return ret;
};
} else if (fs2.futimes) {
fs2.lutimes = function(_a, _b, _c, cb) {
if (cb) process.nextTick(cb);
};
fs2.lutimesSync = function() {
};
}
}
function chmodFix(orig) {
if (!orig) return orig;
return function(target, mode, cb) {
return orig.call(fs, target, mode, function(er) {
if (chownErOk(er)) er = null;
if (cb) cb.apply(this, arguments);
});
};
}
function chmodFixSync(orig) {
if (!orig) return orig;
return function(target, mode) {
try {
return orig.call(fs, target, mode);
} catch (er) {
if (!chownErOk(er)) throw er;
}
};
}
function chownFix(orig) {
if (!orig) return orig;
return function(target, uid, gid, cb) {
return orig.call(fs, target, uid, gid, function(er) {
if (chownErOk(er)) er = null;
if (cb) cb.apply(this, arguments);
});
};
}
function chownFixSync(orig) {
if (!orig) return orig;
return function(target, uid, gid) {
try {
return orig.call(fs, target, uid, gid);
} catch (er) {
if (!chownErOk(er)) throw er;
}
};
}
function statFix(orig) {
if (!orig) return orig;
return function(target, options, cb) {
if (typeof options === "function") {
cb = options;
options = null;
}
function callback(er, stats) {
if (stats) {
if (stats.uid < 0) stats.uid += 4294967296;
if (stats.gid < 0) stats.gid += 4294967296;
}
if (cb) cb.apply(this, arguments);
}
return options ? orig.call(fs, target, options, callback) : orig.call(fs, target, callback);
};
}
function statFixSync(orig) {
if (!orig) return orig;
return function(target, options) {
var stats = options ? orig.call(fs, target, options) : orig.call(fs, target);
if (stats) {
if (stats.uid < 0) stats.uid += 4294967296;
if (stats.gid < 0) stats.gid += 4294967296;
}
return stats;
};
}
function chownErOk(er) {
if (!er)
return true;
if (er.code === "ENOSYS")
return true;
var nonroot = !process.getuid || process.getuid() !== 0;
if (nonroot) {
if (er.code === "EINVAL" || er.code === "EPERM")
return true;
}
return false;
}
}
}
});
// ../../node_modules/.pnpm/graceful-fs@4.2.10/node_modules/graceful-fs/legacy-streams.js
import * as __import_stream from "stream";
var require_legacy_streams = __commonJS({
"../../node_modules/.pnpm/graceful-fs@4.2.10/node_modules/graceful-fs/legacy-streams.js"(exports, module) {
init_esm_shims();
var Stream = __import_stream.Stream;
module.exports = legacy;
function legacy(fs) {
return {
ReadStream,
WriteStream
};
function ReadStream(path, options) {
if (!(this instanceof ReadStream)) return new ReadStream(path, options);
Stream.call(this);
var self = this;
this.path = path;
this.fd = null;
this.readable = true;
this.paused = false;
this.flags = "r";
this.mode = 438;
this.bufferSize = 64 * 1024;
options = options || {};
var keys = Object.keys(options);
for (var index = 0, length = keys.length; index < length; index++) {
var key = keys[index];
this[key] = options[key];
}
if (this.encoding) this.setEncoding(this.encoding);
if (this.start !== void 0) {
if ("number" !== typeof this.start) {
throw TypeError("start must be a Number");
}
if (this.end === void 0) {
this.end = Infinity;
} else if ("number" !== typeof this.end) {
throw TypeError("end must be a Number");
}
if (this.start > this.end) {
throw new Error("start must be <= end");
}
this.pos = this.start;
}
if (this.fd !== null) {
process.nextTick(function() {
self._read();
});
return;
}
fs.open(this.path, this.flags, this.mode, function(err, fd) {
if (err) {
self.emit("error", err);
self.readable = false;
return;
}
self.fd = fd;
self.emit("open", fd);
self._read();
});
}
function WriteStream(path, options) {
if (!(this instanceof WriteStream)) return new WriteStream(path, options);
Stream.call(this);
this.path = path;
this.fd = null;
this.writable = true;
this.flags = "w";
this.encoding = "binary";
this.mode = 438;
this.bytesWritten = 0;
options = options || {};
var keys = Object.keys(options);
for (var index = 0, length = keys.length; index < length; index++) {
var key = keys[index];
this[key] = options[key];
}
if (this.start !== void 0) {
if ("number" !== typeof this.start) {
throw TypeError("start must be a Number");
}
if (this.start < 0) {
throw new Error("start must be >= zero");
}
this.pos = this.start;
}
this.busy = false;
this._queue = [];
if (this.fd === null) {
this._open = fs.open;
this._queue.push([this._open, this.path, this.flags, this.mode, void 0]);
this.flush();
}
}
}
}
});
// ../../node_modules/.pnpm/graceful-fs@4.2.10/node_modules/graceful-fs/clone.js
var require_clone = __commonJS({
"../../node_modules/.pnpm/graceful-fs@4.2.10/node_modules/graceful-fs/clone.js"(exports, module) {
"use strict";
init_esm_shims();
module.exports = clone;
var getPrototypeOf = Object.getPrototypeOf || function(obj) {
return obj.__proto__;
};
function clone(obj) {
if (obj === null || typeof obj !== "object")
return obj;
if (obj instanceof Object)
var copy = { __proto__: getPrototypeOf(obj) };
else
var copy = /* @__PURE__ */ Object.create(null);
Object.getOwnPropertyNames(obj).forEach(function(key) {
Object.defineProperty(copy, key, Object.getOwnPropertyDescriptor(obj, key));
});
return copy;
}
}
});
// ../../node_modules/.pnpm/graceful-fs@4.2.10/node_modules/graceful-fs/graceful-fs.js
import * as __import_fs2 from "fs";
import * as __import_util from "util";
import * as __import_assert from "assert";
var require_graceful_fs = __commonJS({
"../../node_modules/.pnpm/graceful-fs@4.2.10/node_modules/graceful-fs/graceful-fs.js"(exports, module) {
init_esm_shims();
var __import___polyfills_js = __toESM(require_polyfills());
var __import___legacyStreams_js = __toESM(require_legacy_streams());
var __import___clone_js = __toESM(require_clone());
var fs = __import_fs2;
var polyfills = __import___polyfills_js;
var legacy = __import___legacyStreams_js;
var clone = __import___clone_js;
var util = __import_util;
var gracefulQueue;
var previousSymbol;
if (typeof Symbol === "function" && typeof Symbol.for === "function") {
gracefulQueue = Symbol.for("graceful-fs.queue");
previousSymbol = Symbol.for("graceful-fs.previous");
} else {
gracefulQueue = "___graceful-fs.queue";
previousSymbol = "___graceful-fs.previous";
}
function noop() {
}
function publishQueue(context, queue2) {
Object.defineProperty(context, gracefulQueue, {
get: function() {
return queue2;
}
});
}
var debug = noop;
if (util.debuglog)
debug = util.debuglog("gfs4");
else if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || ""))
debug = function() {
var m = util.format.apply(util, arguments);
m = "GFS4: " + m.split(/\n/).join("\nGFS4: ");
console.error(m);
};
if (!fs[gracefulQueue]) {
queue = global[gracefulQueue] || [];
publishQueue(fs, queue);
fs.close = function(fs$close) {
function close(fd, cb) {
return fs$close.call(fs, fd, function(err) {
if (!err) {
resetQueue();
}
if (typeof cb === "function")
cb.apply(this, arguments);
});
}
Object.defineProperty(close, previousSymbol, {
value: fs$close
});
return close;
}(fs.close);
fs.closeSync = function(fs$closeSync) {
function closeSync(fd) {
fs$closeSync.apply(fs, arguments);
resetQueue();
}
Object.defineProperty(closeSync, previousSymbol, {
value: fs$closeSync
});
return closeSync;
}(fs.closeSync);
if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || "")) {
process.on("exit", function() {
debug(fs[gracefulQueue]);
__import_assert.equal(fs[gracefulQueue].length, 0);
});
}
}
var queue;
if (!global[gracefulQueue]) {
publishQueue(global, fs[gracefulQueue]);
}
module.exports = patch(clone(fs));
if (process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH && !fs.__patched) {
module.exports = patch(fs);
fs.__patched = true;
}
function patch(fs2) {
polyfills(fs2);
fs2.gracefulify = patch;
fs2.createReadStream = createReadStream;
fs2.createWriteStream = createWriteStream;
var fs$readFile = fs2.readFile;
fs2.readFile = readFile;
function readFile(path, options, cb) {
if (typeof options === "function")
cb = options, options = null;
return go$readFile(path, options, cb);
function go$readFile(path2, options2, cb2, startTime) {
return fs$readFile(path2, options2, function(err) {
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
enqueue([go$readFile, [path2, options2, cb2], err, startTime || Date.now(), Date.now()]);
else {
if (typeof cb2 === "function")
cb2.apply(this, arguments);
}
});
}
}
var fs$writeFile = fs2.writeFile;
fs2.writeFile = writeFile;
function writeFile(path, data, options, cb) {
if (typeof options === "function")
cb = options, options = null;
return go$writeFile(path, data, options, cb);
function go$writeFile(path2, data2, options2, cb2, startTime) {
return fs$writeFile(path2, data2, options2, function(err) {
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
enqueue([go$writeFile, [path2, data2, options2, cb2], err, startTime || Date.now(), Date.now()]);
else {
if (typeof cb2 === "function")
cb2.apply(this, arguments);
}
});
}
}
var fs$appendFile = fs2.appendFile;
if (fs$appendFile)
fs2.appendFile = appendFile;
function appendFile(path, data, options, cb) {
if (typeof options === "function")
cb = options, options = null;
return go$appendFile(path, data, options, cb);
function go$appendFile(path2, data2, options2, cb2, startTime) {
return fs$appendFile(path2, data2, options2, function(err) {
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
enqueue([go$appendFile, [path2, data2, options2, cb2], err, startTime || Date.now(), Date.now()]);
else {
if (typeof cb2 === "function")
cb2.apply(this, arguments);
}
});
}
}
var fs$copyFile = fs2.copyFile;
if (fs$copyFile)
fs2.copyFile = copyFile;
function copyFile(src, dest, flags, cb) {
if (typeof flags === "function") {
cb = flags;
flags = 0;
}
return go$copyFile(src, dest, flags, cb);
function go$copyFile(src2, dest2, flags2, cb2, startTime) {
return fs$copyFile(src2, dest2, flags2, function(err) {
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
enqueue([go$copyFile, [src2, dest2, flags2, cb2], err, startTime || Date.now(), Date.now()]);
else {
if (typeof cb2 === "function")
cb2.apply(this, arguments);
}
});
}
}
var fs$readdir = fs2.readdir;
fs2.readdir = readdir;
var noReaddirOptionVersions = /^v[0-5]\./;
function readdir(path, options, cb) {
if (typeof options === "function")
cb = options, options = null;
var go$readdir = noReaddirOptionVersions.test(process.version) ? function go$readdir2(path2, options2, cb2, startTime) {
return fs$readdir(path2, fs$readdirCallback(
path2,
options2,
cb2,
startTime
));
} : function go$readdir2(path2, options2, cb2, startTime) {
return fs$readdir(path2, options2, fs$readdirCallback(
path2,
options2,
cb2,
startTime
));
};
return go$readdir(path, options, cb);
function fs$readdirCallback(path2, options2, cb2, startTime) {
return function(err, files) {
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
enqueue([
go$readdir,
[path2, options2, cb2],
err,
startTime || Date.now(),
Date.now()
]);
else {
if (files && files.sort)
files.sort();
if (typeof cb2 === "function")
cb2.call(this, err, files);
}
};
}
}
if (process.version.substr(0, 4) === "v0.8") {
var legStreams = legacy(fs2);
ReadStream = legStreams.ReadStream;
WriteStream = legStreams.WriteStream;
}
var fs$ReadStream = fs2.ReadStream;
if (fs$ReadStream) {
ReadStream.prototype = Object.create(fs$ReadStream.prototype);
ReadStream.prototype.open = ReadStream$open;
}
var fs$WriteStream = fs2.WriteStream;
if (fs$WriteStream) {
WriteStream.prototype = Object.create(fs$WriteStream.prototype);
WriteStream.prototype.open = WriteStream$open;
}
Object.defineProperty(fs2, "ReadStream", {
get: function() {
return ReadStream;
},
set: function(val) {
ReadStream = val;
},
enumerable: true,
configurable: true
});
Object.defineProperty(fs2, "WriteStream", {
get: function() {
return WriteStream;
},
set: function(val) {
WriteStream = val;
},
enumerable: true,
configurable: true
});
var FileReadStream = ReadStream;
Object.defineProperty(fs2, "FileReadStream", {
get: function() {
return FileReadStream;
},
set: function(val) {
FileReadStream = val;
},
enumerable: true,
configurable: true
});
var FileWriteStream = WriteStream;
Object.defineProperty(fs2, "FileWriteStream", {
get: function() {
return FileWriteStream;
},
set: function(val) {
FileWriteStream = val;
},
enumerable: true,
configurable: true
});
function ReadStream(path, options) {
if (this instanceof ReadStream)
return fs$ReadStream.apply(this, arguments), this;
else
return ReadStream.apply(Object.create(ReadStream.prototype), arguments);
}
function ReadStream$open() {
var that = this;
open(that.path, that.flags, that.mode, function(err, fd) {
if (err) {
if (that.autoClose)
that.destroy();
that.emit("error", err);
} else {
that.fd = fd;
that.emit("open", fd);
that.read();
}
});
}
function WriteStream(path, options) {
if (this instanceof WriteStream)
return fs$WriteStream.apply(this, arguments), this;
else
return WriteStream.apply(Object.create(WriteStream.prototype), arguments);
}
function WriteStream$open() {
var that = this;
open(that.path, that.flags, that.mode, function(err, fd) {
if (err) {
that.destroy();
that.emit("error", err);
} else {
that.fd = fd;
that.emit("open", fd);
}
});
}
function createReadStream(path, options) {
return new fs2.ReadStream(path, options);
}
function createWriteStream(path, options) {
return new fs2.WriteStream(path, options);
}
var fs$open = fs2.open;
fs2.open = open;
function open(path, flags, mode, cb) {
if (typeof mode === "function")
cb = mode, mode = null;
return go$open(path, flags, mode, cb);
function go$open(path2, flags2, mode2, cb2, startTime) {
return fs$open(path2, flags2, mode2, function(err, fd) {
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
enqueue([go$open, [path2, flags2, mode2, cb2], err, startTime || Date.now(), Date.now()]);
else {
if (typeof cb2 === "function")
cb2.apply(this, arguments);
}
});
}
}
return fs2;
}
function enqueue(elem) {
debug("ENQUEUE", elem[0].name, elem[1]);
fs[gracefulQueue].push(elem);
retry();
}
var retryTimer;
function resetQueue() {
var now = Date.now();
for (var i = 0; i < fs[gracefulQueue].length; ++i) {
if (fs[gracefulQueue][i].length > 2) {
fs[gracefulQueue][i][3] = now;
fs[gracefulQueue][i][4] = now;
}
}
retry();
}
function retry() {
clearTimeout(retryTimer);
retryTimer = void 0;
if (fs[gracefulQueue].length === 0)
return;
var elem = fs[gracefulQueue].shift();
var fn = elem[0];
var args = elem[1];
var err = elem[2];
var startTime = elem[3];
var lastTime = elem[4];
if (startTime === void 0) {
debug("RETRY", fn.name, args);
fn.apply(null, args);
} else if (Date.now() - startTime >= 6e4) {
debug("TIMEOUT", fn.name, args);
var cb = args.pop();
if (typeof cb === "function")
cb.call(null, err);
} else {
var sinceAttempt = Date.now() - lastTime;
var sinceStart = Math.max(lastTime - startTime, 1);
var desiredDelay = Math.min(sinceStart * 1.2, 100);
if (sinceAttempt >= desiredDelay) {
debug("RETRY", fn.name, args);
fn.apply(null, args.concat([startTime]));
} else {
fs[gracefulQueue].push(elem);
}
}
if (retryTimer === void 0) {
retryTimer = setTimeout(retry, 0);
}
}
}
});
// ../../node_modules/.pnpm/@pnpm+network.ca-file@1.0.2/node_modules/@pnpm/network.ca-file/dist/ca-file.js
var require_ca_file = __commonJS({
"../../node_modules/.pnpm/@pnpm+network.ca-file@1.0.2/node_modules/@pnpm/network.ca-file/dist/ca-file.js"(exports) {
init_esm_shims();
var __import_gracefulFs = __toESM(require_graceful_fs());
var __importDefault = exports && exports.__importDefault || function(mod) {
return mod && mod.__esModule ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.readCAFileSync = void 0;
var graceful_fs_1 = __importDefault(__import_gracefulFs);
function readCAFileSync(filePath) {
try {
const contents = graceful_fs_1.default.readFileSync(filePath, "utf8");
const delim = "-----END CERTIFICATE-----";
const