Update checked-in dependencies
This commit is contained in:
parent
4fad06f438
commit
40a500c743
4168 changed files with 298222 additions and 374905 deletions
195
node_modules/@pkgr/utils/lib/index.cjs
generated
vendored
195
node_modules/@pkgr/utils/lib/index.cjs
generated
vendored
|
|
@ -1,26 +1,34 @@
|
|||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
var node_child_process = require('node:child_process');
|
||||
var path = require('node:path');
|
||||
var node_url = require('node:url');
|
||||
var spawn = require('cross-spawn');
|
||||
var open = require('open');
|
||||
var picocolors = require('picocolors');
|
||||
var node_module = require('node:module');
|
||||
var fs = require('node:fs');
|
||||
var isGlob = require('is-glob');
|
||||
|
||||
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
||||
|
||||
var path__default = /*#__PURE__*/_interopDefaultLegacy(path);
|
||||
var spawn__default = /*#__PURE__*/_interopDefaultLegacy(spawn);
|
||||
var open__default = /*#__PURE__*/_interopDefaultLegacy(open);
|
||||
var picocolors__default = /*#__PURE__*/_interopDefaultLegacy(picocolors);
|
||||
var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);
|
||||
var isGlob__default = /*#__PURE__*/_interopDefaultLegacy(isGlob);
|
||||
|
||||
var __async = (__this, __arguments, generator) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
var fulfilled = (value) => {
|
||||
try {
|
||||
step(generator.next(value));
|
||||
} catch (e) {
|
||||
reject(e);
|
||||
}
|
||||
};
|
||||
var rejected = (value) => {
|
||||
try {
|
||||
step(generator.throw(value));
|
||||
} catch (e) {
|
||||
reject(e);
|
||||
}
|
||||
};
|
||||
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
||||
step((generator = generator.apply(__this, __arguments)).next());
|
||||
});
|
||||
};
|
||||
const import_meta$1 = {};
|
||||
const OSX_CHROME = "google chrome";
|
||||
function getBrowserEnv() {
|
||||
|
|
@ -40,79 +48,89 @@ function getBrowserEnv() {
|
|||
}
|
||||
function executeNodeScript(scriptPath, url) {
|
||||
const extraArgs = process.argv.slice(2);
|
||||
const child = spawn__default["default"](process.execPath, [scriptPath, ...extraArgs, url], {
|
||||
const child = spawn(process.execPath, [scriptPath, ...extraArgs, url], {
|
||||
stdio: "inherit"
|
||||
});
|
||||
child.on("close", (code) => {
|
||||
if (code !== 0) {
|
||||
console.log();
|
||||
console.log(
|
||||
picocolors__default["default"].red(
|
||||
picocolors.red(
|
||||
"The script specified as BROWSER environment variable failed."
|
||||
)
|
||||
);
|
||||
console.log(`${picocolors__default["default"].cyan(scriptPath)} exited with code ${code}`);
|
||||
console.log(`${picocolors.cyan(scriptPath)} exited with code ${code}`);
|
||||
console.log();
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
function startBrowserProcess(browser, url, args) {
|
||||
const shouldTryOpenChromiumWithAppleScript = process.platform === "darwin" && (typeof browser !== "string" || browser === OSX_CHROME);
|
||||
if (shouldTryOpenChromiumWithAppleScript) {
|
||||
const supportedChromiumBrowsers = [
|
||||
"Google Chrome Canary",
|
||||
"Google Chrome",
|
||||
"Microsoft Edge",
|
||||
"Brave Browser",
|
||||
"Vivaldi",
|
||||
"Chromium"
|
||||
];
|
||||
const _dirname = typeof __dirname === "undefined" ? path__default["default"].dirname(node_url.fileURLToPath(import_meta$1.url)) : __dirname;
|
||||
for (const chromiumBrowser of supportedChromiumBrowsers) {
|
||||
try {
|
||||
node_child_process.execSync('ps cax | grep "' + chromiumBrowser + '"');
|
||||
node_child_process.execSync(
|
||||
'osascript ../openChrome.applescript "' + encodeURI(url) + '" "' + chromiumBrowser + '"',
|
||||
{
|
||||
cwd: _dirname,
|
||||
stdio: "ignore"
|
||||
}
|
||||
);
|
||||
return true;
|
||||
} catch (e) {
|
||||
return __async(this, null, function* () {
|
||||
const shouldTryOpenChromiumWithAppleScript = process.platform === "darwin" && (typeof browser !== "string" || browser === OSX_CHROME);
|
||||
if (shouldTryOpenChromiumWithAppleScript) {
|
||||
const supportedChromiumBrowsers = [
|
||||
"Google Chrome Canary",
|
||||
"Google Chrome",
|
||||
"Microsoft Edge",
|
||||
"Brave Browser",
|
||||
"Vivaldi",
|
||||
"Chromium"
|
||||
];
|
||||
const _dirname = typeof __dirname === "undefined" ? path.dirname(node_url.fileURLToPath(import_meta$1.url)) : __dirname;
|
||||
for (const chromiumBrowser of supportedChromiumBrowsers) {
|
||||
try {
|
||||
node_child_process.execSync('ps cax | grep "' + chromiumBrowser + '"');
|
||||
node_child_process.execSync(
|
||||
'osascript ../openChrome.applescript "' + // lgtm [js/shell-command-constructed-from-input]
|
||||
encodeURI(url) + '" "' + chromiumBrowser + '"',
|
||||
{
|
||||
cwd: _dirname,
|
||||
stdio: "ignore"
|
||||
}
|
||||
);
|
||||
return true;
|
||||
} catch (e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (process.platform === "darwin" && browser === "open") {
|
||||
browser = void 0;
|
||||
}
|
||||
try {
|
||||
open__default["default"](url, {
|
||||
app: browser ? {
|
||||
name: browser,
|
||||
arguments: args
|
||||
} : void 0,
|
||||
wait: false
|
||||
}).catch(() => {
|
||||
});
|
||||
return true;
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
if (process.platform === "darwin" && browser === "open") {
|
||||
browser = void 0;
|
||||
}
|
||||
try {
|
||||
const open = (yield import('open')).default;
|
||||
open(url, {
|
||||
app: browser ? {
|
||||
name: browser,
|
||||
arguments: args
|
||||
} : void 0,
|
||||
wait: false
|
||||
}).catch(() => {
|
||||
});
|
||||
return true;
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
function openBrowser(url) {
|
||||
const { action, value, args } = getBrowserEnv();
|
||||
switch (action) {
|
||||
case 0 /* NONE */:
|
||||
return false;
|
||||
case 2 /* SCRIPT */:
|
||||
return executeNodeScript(value, url);
|
||||
case 1 /* BROWSER */:
|
||||
return startBrowserProcess(value, url, args);
|
||||
default:
|
||||
throw new Error("Not implemented.");
|
||||
}
|
||||
return __async(this, null, function* () {
|
||||
const { action, value, args } = getBrowserEnv();
|
||||
switch (action) {
|
||||
case 0 /* NONE */: {
|
||||
return false;
|
||||
}
|
||||
case 2 /* SCRIPT */: {
|
||||
return executeNodeScript(value, url);
|
||||
}
|
||||
case 1 /* BROWSER */: {
|
||||
return startBrowserProcess(value, url, args);
|
||||
}
|
||||
default: {
|
||||
throw new Error("Not implemented.");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
const import_meta = {};
|
||||
|
|
@ -134,6 +152,7 @@ const SCRIPT_RUNNERS = {
|
|||
const SCRIPT_EXECUTORS = {
|
||||
npm: "npx",
|
||||
pnpm: "pnpx",
|
||||
// same as 'pnpm dlx'
|
||||
yarn: "yarn dlx"
|
||||
};
|
||||
|
||||
|
|
@ -158,7 +177,7 @@ const isSvelteAvailable = isPkgAvailable("svelte");
|
|||
const isVueAvailable = isPkgAvailable("vue");
|
||||
const tryFile = (filePath, includeDir = false) => {
|
||||
if (typeof filePath === "string") {
|
||||
return fs__default["default"].existsSync(filePath) && (includeDir || fs__default["default"].statSync(filePath).isFile()) ? filePath : "";
|
||||
return fs.existsSync(filePath) && (includeDir || fs.statSync(filePath).isFile()) ? filePath : "";
|
||||
}
|
||||
for (const file of filePath != null ? filePath : []) {
|
||||
if (tryFile(file, includeDir)) {
|
||||
|
|
@ -172,37 +191,39 @@ const tryExtensions = (filepath, extensions = EXTENSIONS) => {
|
|||
return ext == null ? "" : filepath + ext;
|
||||
};
|
||||
const tryGlob = (paths, options = {}) => {
|
||||
const { absolute = true, baseDir = CWD } = typeof options === "string" ? { baseDir: options } : options;
|
||||
const {
|
||||
absolute = true,
|
||||
baseDir = CWD,
|
||||
ignore = ["**/node_modules/**"]
|
||||
} = typeof options === "string" ? { baseDir: options } : options;
|
||||
return paths.reduce(
|
||||
(acc, pkg) => [
|
||||
...acc,
|
||||
...isGlob__default["default"](pkg) ? tryRequirePkg("tiny-glob/sync")(
|
||||
pkg,
|
||||
{
|
||||
absolute,
|
||||
cwd: baseDir
|
||||
}
|
||||
) : [tryFile(path__default["default"].resolve(baseDir, pkg), true)]
|
||||
...isGlob(pkg) ? tryRequirePkg("fast-glob").sync(pkg, {
|
||||
cwd: baseDir,
|
||||
ignore,
|
||||
onlyFiles: false
|
||||
}).map((file) => absolute ? path.resolve(baseDir, file) : file) : [tryFile(path.resolve(baseDir, pkg), true)]
|
||||
].filter(Boolean),
|
||||
[]
|
||||
);
|
||||
};
|
||||
const identify = (_) => !!_;
|
||||
const findUp = (searchEntry, searchFile = "package.json") => {
|
||||
console.assert(path__default["default"].isAbsolute(searchEntry));
|
||||
if (!tryFile(searchEntry, true) || searchEntry !== CWD && !searchEntry.startsWith(CWD + path__default["default"].sep)) {
|
||||
console.assert(path.isAbsolute(searchEntry));
|
||||
if (!tryFile(searchEntry, true) || searchEntry !== CWD && !searchEntry.startsWith(CWD + path.sep)) {
|
||||
return "";
|
||||
}
|
||||
searchEntry = path__default["default"].resolve(
|
||||
fs__default["default"].statSync(searchEntry).isDirectory() ? searchEntry : path__default["default"].resolve(searchEntry, "..")
|
||||
searchEntry = path.resolve(
|
||||
fs.statSync(searchEntry).isDirectory() ? searchEntry : path.resolve(searchEntry, "..")
|
||||
);
|
||||
do {
|
||||
const searched = tryFile(path__default["default"].resolve(searchEntry, searchFile));
|
||||
const searched = tryFile(path.resolve(searchEntry, searchFile));
|
||||
if (searched) {
|
||||
return searched;
|
||||
}
|
||||
searchEntry = path__default["default"].resolve(searchEntry, "..");
|
||||
} while (searchEntry === CWD || searchEntry.startsWith(CWD + path__default["default"].sep));
|
||||
searchEntry = path.resolve(searchEntry, "..");
|
||||
} while (searchEntry === CWD || searchEntry.startsWith(CWD + path.sep));
|
||||
return "";
|
||||
};
|
||||
const arrayify = (...args) => args.reduce((arr, curr) => {
|
||||
|
|
@ -241,11 +262,15 @@ const getScriptExecutor = () => {
|
|||
};
|
||||
|
||||
var _a, _b, _c, _d;
|
||||
const pkg = (_a = tryRequirePkg(path__default["default"].resolve("package.json"))) != null ? _a : {};
|
||||
const lernaConfig = (_b = tryRequirePkg(path__default["default"].resolve("lerna.json"))) != null ? _b : {};
|
||||
const pkg = (_a = tryRequirePkg(path.resolve("package.json"))) != null ? _a : {};
|
||||
const lernaConfig = (_b = tryRequirePkg(path.resolve("lerna.json"))) != null ? _b : {};
|
||||
const pkgsPath = (_d = (_c = lernaConfig.packages) != null ? _c : pkg.workspaces) != null ? _d : [];
|
||||
const isMonorepo = Array.isArray(pkgsPath) && pkgsPath.length > 0;
|
||||
const monorepoPkgs = isMonorepo ? tryGlob(pkgsPath) : [];
|
||||
const monorepoPkgs = isMonorepo ? tryGlob(
|
||||
pkgsPath.map(
|
||||
(pkg2) => pkg2.endsWith("/package.json") ? pkg2 : `${pkg2}/package.json`
|
||||
)
|
||||
) : [];
|
||||
|
||||
exports.CWD = CWD;
|
||||
exports.DEV = DEV;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue