@voidzero-dev/vite-plus-core 0.1.12-alpha.1 → 0.1.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/tsdown/{build-B1oBkI4C-Dh08ogRE.js → build-CGB4R_gC-Dyc6Tj-y.js} +2 -2
- package/dist/tsdown/{build-CpOl_krN-CHw39ynq.js → build-Dh89hfzV-CSN02Okj.js} +107 -66
- package/dist/tsdown/{debug-C4FmgzkJ-BcERCViE.js → debug-C4FmgzkJ-58KiZwv5.js} +2 -2
- package/dist/tsdown/{detect-J1_Vd1yf-BnOcNWHf.js → detect-DN3DXXYt-hqP1wKSG.js} +2 -8
- package/dist/tsdown/index-types.d.ts +6 -6
- package/dist/tsdown/index.js +4 -4
- package/dist/tsdown/{main-4fHWraTN.js → main-BR1iuPKy.js} +114 -133
- package/dist/tsdown/run.js +5 -5
- package/package.json +6 -6
- package/dist/tsdown/index-node-Bpsmc0eX-CRDsfhY9.js +0 -249
- /package/dist/tsdown/{dist-BTs7u0nu.js → dist-BWGgEAtQ.js} +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import "./main-
|
|
1
|
+
import "./main-BR1iuPKy.js";
|
|
2
2
|
import "./node-B3Gdtau1.js";
|
|
3
|
-
import { t as build$1 } from "./build-
|
|
3
|
+
import { t as build$1 } from "./build-Dh89hfzV-CSN02Okj.js";
|
|
4
4
|
import "./filename-UU7z2A9Z.js";
|
|
5
5
|
export { build$1 as build };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { r as __toESM, t as __commonJSMin } from "./chunk-CSNpwdVU.js";
|
|
2
|
-
import { C as resolveComma, E as toArray, S as promiseWithResolvers, T as slash, _ as debounce, a as createLogger, b as noop, c as globalLogger, d as bold, f as dim, g as yellow, h as underline, i as LogLevels, l as prettyFormat, m as red, n as
|
|
2
|
+
import { C as resolveComma, E as toArray, S as promiseWithResolvers, T as slash, _ as debounce, a as createLogger, b as noop, c as globalLogger, d as bold, f as dim, g as yellow, h as underline, i as LogLevels, l as prettyFormat, m as red, n as z, o as generateColor, p as green, r as version, s as getNameLabel, t as R, u as blue, v as importWithError, w as resolveRegex, x as pkgExists, y as matchPattern } from "./main-BR1iuPKy.js";
|
|
3
3
|
import { t as createDebug } from "./node-B3Gdtau1.js";
|
|
4
4
|
import { i as RE_JS, n as RE_DTS, o as RE_NODE_MODULES$1, t as RE_CSS } from "./filename-UU7z2A9Z.js";
|
|
5
5
|
import module$1, { builtinModules, createRequire, isBuiltin } from "node:module";
|
|
@@ -7,21 +7,21 @@ import { pathToFileURL } from "node:url";
|
|
|
7
7
|
import process$1, { env } from "node:process";
|
|
8
8
|
import readline from "node:readline";
|
|
9
9
|
import { formatWithOptions, inspect, promisify } from "node:util";
|
|
10
|
-
import { createRequire as createRequire$1 } from "module";
|
|
11
10
|
import path, { dirname, isAbsolute, join, parse, resolve } from "node:path";
|
|
12
11
|
import { VERSION, build, watch } from "@voidzero-dev/vite-plus-core/rolldown";
|
|
13
|
-
import { access, chmod, cp, mkdir, mkdtemp, readFile, rm, stat, writeFile } from "node:fs/promises";
|
|
12
|
+
import { access, chmod, cp, mkdir, mkdtemp, readFile, readdir, rm, stat, writeFile } from "node:fs/promises";
|
|
14
13
|
import { and, id, importerId, include } from "@voidzero-dev/vite-plus-core/rolldown/filter";
|
|
15
14
|
import * as nativeFs$1 from "fs";
|
|
16
15
|
import nativeFs from "fs";
|
|
17
16
|
import path$1, { basename, dirname as dirname$1, normalize as normalize$1, posix, relative, resolve as resolve$1, sep } from "path";
|
|
18
17
|
import { fileURLToPath as fileURLToPath$1 } from "url";
|
|
18
|
+
import { createRequire as createRequire$1 } from "module";
|
|
19
19
|
import { tmpdir } from "node:os";
|
|
20
20
|
import fs$1, { existsSync, readFileSync, writeFileSync } from "node:fs";
|
|
21
21
|
import { Buffer } from "node:buffer";
|
|
22
22
|
import { brotliCompress, gzip } from "node:zlib";
|
|
23
23
|
import { importGlobPlugin } from "@voidzero-dev/vite-plus-core/rolldown/experimental";
|
|
24
|
-
//#region ../../node_modules/.pnpm/tsdown@0.21.
|
|
24
|
+
//#region ../../node_modules/.pnpm/tsdown@0.21.3_@arethetypeswrong+core@0.18.2_@tsdown+css@0.21.3_@tsdown+exe@0.21.3_@type_38be87ebcd54001dc11621ca3e3d3fad/node_modules/tsdown/dist/fs-Dd6Htx2P.mjs
|
|
25
25
|
function fsExists(path) {
|
|
26
26
|
return access(path).then(() => true, () => false);
|
|
27
27
|
}
|
|
@@ -64,7 +64,7 @@ function stripExtname(filePath) {
|
|
|
64
64
|
return filePath.slice(0, -ext.length);
|
|
65
65
|
}
|
|
66
66
|
//#endregion
|
|
67
|
-
//#region ../../node_modules/.pnpm/tsdown@0.21.
|
|
67
|
+
//#region ../../node_modules/.pnpm/tsdown@0.21.3_@arethetypeswrong+core@0.18.2_@tsdown+css@0.21.3_@tsdown+exe@0.21.3_@type_38be87ebcd54001dc11621ca3e3d3fad/node_modules/tsdown/dist/format-DPVBd8E4.mjs
|
|
68
68
|
const shimFile = path.resolve(import.meta.dirname, "..", "esm-shims.js");
|
|
69
69
|
function getShimsInject(format, platform) {
|
|
70
70
|
if (format === "es" && platform === "node") return {
|
|
@@ -3076,7 +3076,7 @@ function createConfigCoreLoader(options) {
|
|
|
3076
3076
|
};
|
|
3077
3077
|
}
|
|
3078
3078
|
//#endregion
|
|
3079
|
-
//#region ../../node_modules/.pnpm/tsdown@0.21.
|
|
3079
|
+
//#region ../../node_modules/.pnpm/tsdown@0.21.3_@arethetypeswrong+core@0.18.2_@tsdown+css@0.21.3_@tsdown+exe@0.21.3_@type_38be87ebcd54001dc11621ca3e3d3fad/node_modules/tsdown/dist/options-CoPog4o1.mjs
|
|
3080
3080
|
const __cjs_require$1 = createRequire(import.meta.url);
|
|
3081
3081
|
const picomatch = __cjs_require$1("./npm_entry_picomatch.cjs");
|
|
3082
3082
|
const satisfies$1 = __cjs_require$1("./npm_entry_semver_functions_satisfies.cjs");
|
|
@@ -3148,7 +3148,7 @@ function isGlobEntry(entry) {
|
|
|
3148
3148
|
return Object.keys(entry).some((key) => key.includes("*"));
|
|
3149
3149
|
}
|
|
3150
3150
|
async function resolveObjectEntry(entries, cwd) {
|
|
3151
|
-
|
|
3151
|
+
const entry = Object.fromEntries((await Promise.all(Object.entries(entries).map(async ([key, value]) => {
|
|
3152
3152
|
if (!key.includes("*")) {
|
|
3153
3153
|
if (Array.isArray(value)) throw new TypeError(`Object entry "${key}" cannot have an array value when the key is not a glob pattern.`);
|
|
3154
3154
|
return [[key, value]];
|
|
@@ -3168,7 +3168,8 @@ async function resolveObjectEntry(entries, cwd) {
|
|
|
3168
3168
|
}
|
|
3169
3169
|
if (valueGlobBase === void 0) throw new Error(`Cannot determine base directory for value glob patterns of key "${key}".`);
|
|
3170
3170
|
return files.map((file) => [slash(key.replaceAll("*", stripExtname(path.relative(valueGlobBase, file)))), path.resolve(cwd, file)]);
|
|
3171
|
-
}))).flat())
|
|
3171
|
+
}))).flat());
|
|
3172
|
+
return [entry, lowestCommonAncestor(...Object.values(entry))];
|
|
3172
3173
|
}
|
|
3173
3174
|
async function resolveArrayEntry(entries, cwd, root) {
|
|
3174
3175
|
const stringEntries = [];
|
|
@@ -3249,7 +3250,7 @@ async function buildSingleExe(config, bundledFile, outputFile, executable, targe
|
|
|
3249
3250
|
await writeFile(seaConfigPath, JSON.stringify(seaConfig));
|
|
3250
3251
|
debug$3$2("Wrote sea-config.json: %O -> %s", seaConfig, seaConfigPath);
|
|
3251
3252
|
debug$3$2("Running: %s --build-sea %s", process$1.execPath, seaConfigPath);
|
|
3252
|
-
await
|
|
3253
|
+
await R(process$1.execPath, ["--build-sea", seaConfigPath], {
|
|
3253
3254
|
nodeOptions: { stdio: [
|
|
3254
3255
|
"ignore",
|
|
3255
3256
|
"ignore",
|
|
@@ -3262,7 +3263,7 @@ async function buildSingleExe(config, bundledFile, outputFile, executable, targe
|
|
|
3262
3263
|
else await fsRemove(tempDir);
|
|
3263
3264
|
}
|
|
3264
3265
|
if ((target?.platform || process$1.platform) === "darwin") try {
|
|
3265
|
-
await
|
|
3266
|
+
await R("codesign", [
|
|
3266
3267
|
"--sign",
|
|
3267
3268
|
"-",
|
|
3268
3269
|
outputPath
|
|
@@ -3638,7 +3639,7 @@ async function nativeImport(id) {
|
|
|
3638
3639
|
return mod.default || mod;
|
|
3639
3640
|
}
|
|
3640
3641
|
async function unrunImport(id) {
|
|
3641
|
-
const { unrun } = await import("./dist-
|
|
3642
|
+
const { unrun } = await import("./dist-BWGgEAtQ.js");
|
|
3642
3643
|
const { module } = await unrun({ path: pathToFileURL(id).href });
|
|
3643
3644
|
return module;
|
|
3644
3645
|
}
|
|
@@ -3831,7 +3832,51 @@ function filterConfig(filter, configCwd, name) {
|
|
|
3831
3832
|
return toArray(filter).some((value) => name && name === value || cwd === value);
|
|
3832
3833
|
}
|
|
3833
3834
|
//#endregion
|
|
3834
|
-
//#region ../../node_modules/.pnpm/tsdown@0.21.
|
|
3835
|
+
//#region ../../node_modules/.pnpm/tsdown@0.21.3_@arethetypeswrong+core@0.18.2_@tsdown+css@0.21.3_@tsdown+exe@0.21.3_@type_38be87ebcd54001dc11621ca3e3d3fad/node_modules/tsdown/dist/watch-CS1xCZMR.mjs
|
|
3836
|
+
async function copy(options) {
|
|
3837
|
+
if (!options.copy) return;
|
|
3838
|
+
const resolved = await resolveCopyEntries(options);
|
|
3839
|
+
await Promise.all(resolved.map(({ from, to, verbose }) => {
|
|
3840
|
+
if (verbose) options.logger.info(options.nameLabel, `Copying files from ${path.relative(options.cwd, from)} to ${path.relative(options.cwd, to)}`);
|
|
3841
|
+
return fsCopy(from, to);
|
|
3842
|
+
}));
|
|
3843
|
+
}
|
|
3844
|
+
async function resolveCopyEntries(options) {
|
|
3845
|
+
const copy = toArray(typeof options.copy === "function" ? await options.copy(options) : options.copy);
|
|
3846
|
+
if (!copy.length) return [];
|
|
3847
|
+
const resolved = (await Promise.all(copy.map(async (entry) => {
|
|
3848
|
+
if (typeof entry === "string") entry = { from: [entry] };
|
|
3849
|
+
let from = toArray(entry.from);
|
|
3850
|
+
if (from.some((f) => isDynamicPattern(f))) from = await glob(from, {
|
|
3851
|
+
cwd: options.cwd,
|
|
3852
|
+
onlyFiles: true,
|
|
3853
|
+
expandDirectories: false
|
|
3854
|
+
});
|
|
3855
|
+
return from.map((file) => resolveCopyEntry({
|
|
3856
|
+
...entry,
|
|
3857
|
+
from: file
|
|
3858
|
+
}, options.cwd, options.outDir));
|
|
3859
|
+
}))).flat();
|
|
3860
|
+
if (!resolved.length) options.logger.warn(options.nameLabel, `No files matched for copying.`);
|
|
3861
|
+
return resolved;
|
|
3862
|
+
}
|
|
3863
|
+
function resolveCopyEntry(entry, cwd, outDir) {
|
|
3864
|
+
const { flatten = true, rename } = entry;
|
|
3865
|
+
const from = path.resolve(cwd, entry.from);
|
|
3866
|
+
const to = entry.to ? path.resolve(cwd, entry.to) : outDir;
|
|
3867
|
+
const { base, dir } = path.parse(path.relative(cwd, from));
|
|
3868
|
+
const destFolder = flatten || !flatten && !dir ? to : dir.replace(dir.split(path.sep)[0], to);
|
|
3869
|
+
const dest = path.join(destFolder, rename ? renameTarget(base, rename, from) : base);
|
|
3870
|
+
return {
|
|
3871
|
+
...entry,
|
|
3872
|
+
from,
|
|
3873
|
+
to: dest
|
|
3874
|
+
};
|
|
3875
|
+
}
|
|
3876
|
+
function renameTarget(target, rename, src) {
|
|
3877
|
+
const parsedPath = path.parse(target);
|
|
3878
|
+
return typeof rename === "string" ? rename : rename(parsedPath.name, parsedPath.ext.replace(".", ""), src);
|
|
3879
|
+
}
|
|
3835
3880
|
/**
|
|
3836
3881
|
* The `node:` protocol was added in Node.js v14.18.0.
|
|
3837
3882
|
* @see https://nodejs.org/api/esm.html#node-imports
|
|
@@ -3977,11 +4022,15 @@ function WatchPlugin(configFiles, { config, chunks }) {
|
|
|
3977
4022
|
inputOptions.watch.exclude = toArray(inputOptions.watch.exclude);
|
|
3978
4023
|
inputOptions.watch.exclude.push(...config.ignoreWatch);
|
|
3979
4024
|
} : void 0,
|
|
3980
|
-
buildStart() {
|
|
4025
|
+
async buildStart() {
|
|
3981
4026
|
config.tsconfig && this.addWatchFile(config.tsconfig);
|
|
3982
4027
|
for (const file of configFiles) this.addWatchFile(file);
|
|
3983
4028
|
if (typeof config.watch !== "boolean") for (const file of resolveComma(toArray(config.watch))) this.addWatchFile(file);
|
|
3984
4029
|
if (config.pkg) this.addWatchFile(config.pkg.packageJsonPath);
|
|
4030
|
+
if (config.copy) {
|
|
4031
|
+
const resolvedEntries = await resolveCopyEntries(config);
|
|
4032
|
+
for (const entry of resolvedEntries) this.addWatchFile(entry.from);
|
|
4033
|
+
}
|
|
3985
4034
|
},
|
|
3986
4035
|
generateBundle: {
|
|
3987
4036
|
order: "post",
|
|
@@ -4160,7 +4209,7 @@ var Hookable = class {
|
|
|
4160
4209
|
}
|
|
4161
4210
|
};
|
|
4162
4211
|
//#endregion
|
|
4163
|
-
//#region ../../node_modules/.pnpm/tsdown@0.21.
|
|
4212
|
+
//#region ../../node_modules/.pnpm/tsdown@0.21.3_@arethetypeswrong+core@0.18.2_@tsdown+css@0.21.3_@tsdown+exe@0.21.3_@type_38be87ebcd54001dc11621ca3e3d3fad/node_modules/tsdown/dist/build-Dh89hfzV.mjs
|
|
4164
4213
|
const __cjs_require = createRequire(import.meta.url);
|
|
4165
4214
|
const satisfies = __cjs_require("./npm_entry_semver_functions_satisfies.cjs");
|
|
4166
4215
|
const coerce = __cjs_require("./npm_entry_semver_functions_coerce.cjs");
|
|
@@ -4251,49 +4300,6 @@ function warnLegacyCJS(config) {
|
|
|
4251
4300
|
return version && satisfies(version, "^20.19.0 || >=22.12.0");
|
|
4252
4301
|
})) config.logger.warnOnce("We recommend using the ESM format instead of CommonJS.\nThe ESM format is compatible with modern platforms and runtimes, and most new libraries are now distributed only in ESM format.\nLearn more at https://nodejs.org/en/learn/modules/publishing-a-package#how-did-we-get-here");
|
|
4253
4302
|
}
|
|
4254
|
-
async function copy(options) {
|
|
4255
|
-
if (!options.copy) return;
|
|
4256
|
-
const copy = toArray(typeof options.copy === "function" ? await options.copy(options) : options.copy);
|
|
4257
|
-
if (!copy.length) return;
|
|
4258
|
-
const resolved = (await Promise.all(copy.map(async (entry) => {
|
|
4259
|
-
if (typeof entry === "string") entry = { from: [entry] };
|
|
4260
|
-
let from = toArray(entry.from);
|
|
4261
|
-
if (from.some((f) => isDynamicPattern(f))) from = await glob(from, {
|
|
4262
|
-
cwd: options.cwd,
|
|
4263
|
-
onlyFiles: true,
|
|
4264
|
-
expandDirectories: false
|
|
4265
|
-
});
|
|
4266
|
-
return from.map((file) => resolveCopyEntry({
|
|
4267
|
-
...entry,
|
|
4268
|
-
from: file
|
|
4269
|
-
}));
|
|
4270
|
-
}))).flat();
|
|
4271
|
-
if (!resolved.length) {
|
|
4272
|
-
options.logger.warn(options.nameLabel, `No files matched for copying.`);
|
|
4273
|
-
return;
|
|
4274
|
-
}
|
|
4275
|
-
await Promise.all(resolved.map(({ from, to, verbose }) => {
|
|
4276
|
-
if (verbose) options.logger.info(options.nameLabel, `Copying files from ${path.relative(options.cwd, from)} to ${path.relative(options.cwd, to)}`);
|
|
4277
|
-
return fsCopy(from, to);
|
|
4278
|
-
}));
|
|
4279
|
-
function resolveCopyEntry(entry) {
|
|
4280
|
-
const { flatten = true, rename } = entry;
|
|
4281
|
-
const from = path.resolve(options.cwd, entry.from);
|
|
4282
|
-
const to = entry.to ? path.resolve(options.cwd, entry.to) : options.outDir;
|
|
4283
|
-
const { base, dir } = path.parse(path.relative(options.cwd, from));
|
|
4284
|
-
const destFolder = flatten || !flatten && !dir ? to : dir.replace(dir.split(path.sep)[0], to);
|
|
4285
|
-
const dest = path.join(destFolder, rename ? renameTarget(base, rename, from) : base);
|
|
4286
|
-
return {
|
|
4287
|
-
...entry,
|
|
4288
|
-
from,
|
|
4289
|
-
to: dest
|
|
4290
|
-
};
|
|
4291
|
-
}
|
|
4292
|
-
}
|
|
4293
|
-
function renameTarget(target, rename, src) {
|
|
4294
|
-
const parsedPath = path.parse(target);
|
|
4295
|
-
return typeof rename === "string" ? rename : rename(parsedPath.name, parsedPath.ext.replace(".", ""), src);
|
|
4296
|
-
}
|
|
4297
4303
|
async function startDevtoolsUI(config) {
|
|
4298
4304
|
const { start } = await importWithError("@vitejs/devtools/cli-commands");
|
|
4299
4305
|
await start({
|
|
@@ -4318,7 +4324,7 @@ function executeOnSuccess(config) {
|
|
|
4318
4324
|
if (!config.onSuccess) return;
|
|
4319
4325
|
const ab = new AbortController();
|
|
4320
4326
|
if (typeof config.onSuccess === "string") {
|
|
4321
|
-
const p =
|
|
4327
|
+
const p = z(config.onSuccess, [], { nodeOptions: {
|
|
4322
4328
|
shell: true,
|
|
4323
4329
|
stdio: "inherit",
|
|
4324
4330
|
cwd: config.cwd
|
|
@@ -4496,15 +4502,11 @@ async function bundleDone(bundleByPkg, bundle) {
|
|
|
4496
4502
|
async function packTarball(packageJsonPath) {
|
|
4497
4503
|
const pkgDir = path.dirname(packageJsonPath);
|
|
4498
4504
|
const destination = await mkdtemp(path.join(tmpdir(), "tsdown-pack-"));
|
|
4499
|
-
const
|
|
4505
|
+
const { detect } = await import("./detect-DN3DXXYt-hqP1wKSG.js");
|
|
4500
4506
|
try {
|
|
4501
4507
|
const detected = await detect({ cwd: pkgDir });
|
|
4502
4508
|
if (detected?.name === "deno") throw new Error(`Cannot pack tarball for Deno projects at ${pkgDir}`);
|
|
4503
|
-
return readFile(await pack(pkgDir,
|
|
4504
|
-
destination,
|
|
4505
|
-
packageManager: detected?.name,
|
|
4506
|
-
ignoreScripts: true
|
|
4507
|
-
}));
|
|
4509
|
+
return readFile(await pack(pkgDir, detected, destination, true));
|
|
4508
4510
|
} finally {
|
|
4509
4511
|
await fsRemove(destination);
|
|
4510
4512
|
}
|
|
@@ -4528,11 +4530,50 @@ function mergeInlinedDeps(bundles) {
|
|
|
4528
4530
|
if (!merged.has(pkgName)) merged.set(pkgName, /* @__PURE__ */ new Set());
|
|
4529
4531
|
for (const v of versions) merged.get(pkgName).add(v);
|
|
4530
4532
|
}
|
|
4531
|
-
if (!merged.size) return
|
|
4533
|
+
if (!merged.size) return;
|
|
4534
|
+
const sorted = [...merged.entries()].toSorted(([a], [b]) => a.localeCompare(b));
|
|
4532
4535
|
const result = {};
|
|
4533
|
-
for (const [pkgName, versions] of
|
|
4536
|
+
for (const [pkgName, versions] of sorted) result[pkgName] = versions.size === 1 ? [...versions][0] : [...versions].toSorted();
|
|
4534
4537
|
return result;
|
|
4535
4538
|
}
|
|
4539
|
+
async function pack(dir, pm, destination, ignoreScripts) {
|
|
4540
|
+
pm ||= {
|
|
4541
|
+
name: "npm",
|
|
4542
|
+
agent: "npm"
|
|
4543
|
+
};
|
|
4544
|
+
if (pm.name === "deno") throw new Error(`Cannot pack tarball for Deno projects at ${dir}`);
|
|
4545
|
+
const command = pm.name;
|
|
4546
|
+
const args = ["pack"];
|
|
4547
|
+
if (pm.name === "bun") args.unshift("pm");
|
|
4548
|
+
const outFile = path.join(destination, "package.tgz");
|
|
4549
|
+
if (destination) switch (pm.agent) {
|
|
4550
|
+
case "yarn":
|
|
4551
|
+
args.push("-f", outFile);
|
|
4552
|
+
break;
|
|
4553
|
+
case "yarn@berry":
|
|
4554
|
+
args.push("-o", outFile);
|
|
4555
|
+
break;
|
|
4556
|
+
case "bun":
|
|
4557
|
+
args.push("--destination", destination);
|
|
4558
|
+
break;
|
|
4559
|
+
default:
|
|
4560
|
+
args.push("--pack-destination", destination);
|
|
4561
|
+
break;
|
|
4562
|
+
}
|
|
4563
|
+
if (ignoreScripts) switch (pm.agent) {
|
|
4564
|
+
case "pnpm":
|
|
4565
|
+
args.push("--config.ignore-scripts=true");
|
|
4566
|
+
break;
|
|
4567
|
+
case "yarn@berry": break;
|
|
4568
|
+
default:
|
|
4569
|
+
args.push("--ignore-scripts");
|
|
4570
|
+
break;
|
|
4571
|
+
}
|
|
4572
|
+
const output = await R(command, args, { nodeOptions: { cwd: dir } });
|
|
4573
|
+
const tarballFile = await readdir(destination).then((files) => files.find((file) => file.endsWith(".tgz")));
|
|
4574
|
+
if (!tarballFile) throw new Error(`Failed to find packed tarball file in ${destination}. Command output:\n${JSON.stringify(output, null, 2)}`);
|
|
4575
|
+
return path.join(destination, tarballFile);
|
|
4576
|
+
}
|
|
4536
4577
|
function resolveJsOutputExtension(packageType, format, fixedExtension) {
|
|
4537
4578
|
switch (format) {
|
|
4538
4579
|
case "es": return !fixedExtension && packageType === "module" ? "js" : "mjs";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { C as resolveComma, E as toArray } from "./main-
|
|
1
|
+
import { C as resolveComma, E as toArray } from "./main-BR1iuPKy.js";
|
|
2
2
|
import { n as enable, r as namespaces, t as createDebug } from "./node-B3Gdtau1.js";
|
|
3
|
-
//#region ../../node_modules/.pnpm/tsdown@0.21.
|
|
3
|
+
//#region ../../node_modules/.pnpm/tsdown@0.21.3_@arethetypeswrong+core@0.18.2_@tsdown+css@0.21.3_@tsdown+exe@0.21.3_@type_38be87ebcd54001dc11621ca3e3d3fad/node_modules/tsdown/dist/debug-C4FmgzkJ.mjs
|
|
4
4
|
const debugLog = createDebug("tsdown:debug");
|
|
5
5
|
function enableDebug(debug) {
|
|
6
6
|
if (!debug) return;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import process from "node:process";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import fs from "node:fs/promises";
|
|
4
|
-
//#region ../../node_modules/.pnpm/tsdown@0.21.
|
|
4
|
+
//#region ../../node_modules/.pnpm/tsdown@0.21.3_@arethetypeswrong+core@0.18.2_@tsdown+css@0.21.3_@tsdown+exe@0.21.3_@type_38be87ebcd54001dc11621ca3e3d3fad/node_modules/tsdown/dist/detect-DN3DXXYt.mjs
|
|
5
5
|
const AGENTS = [
|
|
6
6
|
"npm",
|
|
7
7
|
"yarn",
|
|
@@ -40,12 +40,6 @@ async function pathExists(path2, type) {
|
|
|
40
40
|
return false;
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
|
-
function getUserAgent() {
|
|
44
|
-
const userAgent = process.env.npm_config_user_agent;
|
|
45
|
-
if (!userAgent) return null;
|
|
46
|
-
const name = userAgent.split("/")[0];
|
|
47
|
-
return AGENTS.includes(name) ? name : null;
|
|
48
|
-
}
|
|
49
43
|
function* lookup(cwd = process.cwd()) {
|
|
50
44
|
let directory = path.resolve(cwd);
|
|
51
45
|
const { root } = path.parse(directory);
|
|
@@ -160,4 +154,4 @@ function isMetadataYarnClassic(metadataPath) {
|
|
|
160
154
|
return metadataPath.endsWith(".yarn_integrity");
|
|
161
155
|
}
|
|
162
156
|
//#endregion
|
|
163
|
-
export { detect
|
|
157
|
+
export { detect };
|
|
@@ -2,7 +2,7 @@ import * as Rolldown from "@voidzero-dev/vite-plus-core/rolldown";
|
|
|
2
2
|
import { BuildOptions, ChecksOptions, ExternalOption, InputOptions, InternalModuleFormat, MinifyOptions, ModuleFormat, ModuleTypes, OutputAsset, OutputChunk, OutputOptions, TreeshakingOptions } from "@voidzero-dev/vite-plus-core/rolldown";
|
|
3
3
|
import { IsolatedDeclarationsOptions } from "@voidzero-dev/vite-plus-core/rolldown/experimental";
|
|
4
4
|
|
|
5
|
-
//#region ../../node_modules/.pnpm/tsdown@0.21.
|
|
5
|
+
//#region ../../node_modules/.pnpm/tsdown@0.21.3_@arethetypeswrong+core@0.18.2_@tsdown+css@0.21.3_@tsdown+exe@0.21.3_@type_38be87ebcd54001dc11621ca3e3d3fad/node_modules/tsdown/dist/logger-DtCm1ySP.d.mts
|
|
6
6
|
//#region src/utils/types.d.ts
|
|
7
7
|
type Overwrite<T, U> = Omit<T, keyof U> & U;
|
|
8
8
|
type Awaitable<T> = T | Promise<T>;
|
|
@@ -8473,7 +8473,7 @@ interface GlobDependency {
|
|
|
8473
8473
|
glob: string;
|
|
8474
8474
|
}
|
|
8475
8475
|
//#endregion
|
|
8476
|
-
//#region ../../node_modules/.pnpm/@tsdown+css@0.21.
|
|
8476
|
+
//#region ../../node_modules/.pnpm/@tsdown+css@0.21.3_jiti@2.6.1_postcss-import@16.1.1_postcss@8.5.8__postcss@8.5.8_sass-e_51db9ed59721905a0258cdc790ed7d6f/node_modules/@tsdown/css/dist/index.d.mts
|
|
8477
8477
|
//#region src/options.d.ts
|
|
8478
8478
|
type LightningCSSOptions = Omit<TransformOptions<any>, "filename" | "code">;
|
|
8479
8479
|
interface CssOptions {
|
|
@@ -9526,7 +9526,7 @@ interface StartOptions {
|
|
|
9526
9526
|
open?: boolean;
|
|
9527
9527
|
}
|
|
9528
9528
|
//#endregion
|
|
9529
|
-
//#region ../../node_modules/.pnpm/@tsdown+exe@0.21.
|
|
9529
|
+
//#region ../../node_modules/.pnpm/@tsdown+exe@0.21.3_tsdown@0.21.3/node_modules/@tsdown/exe/dist/index.d.mts
|
|
9530
9530
|
//#region src/platform.d.ts
|
|
9531
9531
|
type ExePlatform = "win" | "darwin" | "linux";
|
|
9532
9532
|
type ExeArch = "x64" | "arm64";
|
|
@@ -9667,7 +9667,7 @@ interface Options$1 {
|
|
|
9667
9667
|
depKinds?: Array<DepKind>;
|
|
9668
9668
|
}
|
|
9669
9669
|
//#endregion
|
|
9670
|
-
//#region ../../node_modules/.pnpm/tsdown@0.21.
|
|
9670
|
+
//#region ../../node_modules/.pnpm/tsdown@0.21.3_@arethetypeswrong+core@0.18.2_@tsdown+css@0.21.3_@tsdown+exe@0.21.3_@type_38be87ebcd54001dc11621ca3e3d3fad/node_modules/tsdown/dist/types-D2Jnze_i.d.mts
|
|
9671
9671
|
//#region src/features/copy.d.ts
|
|
9672
9672
|
interface CopyEntry {
|
|
9673
9673
|
/**
|
|
@@ -10791,7 +10791,7 @@ type ResolvedConfig = Overwrite<MarkPartial<Omit<UserConfig, "workspace" | "from
|
|
|
10791
10791
|
exe: false | ExeOptions;
|
|
10792
10792
|
}>; //#endregion
|
|
10793
10793
|
//#endregion
|
|
10794
|
-
//#region ../../node_modules/.pnpm/tsdown@0.21.
|
|
10794
|
+
//#region ../../node_modules/.pnpm/tsdown@0.21.3_@arethetypeswrong+core@0.18.2_@tsdown+css@0.21.3_@tsdown+exe@0.21.3_@type_38be87ebcd54001dc11621ca3e3d3fad/node_modules/tsdown/dist/config-D9p_BCF3.d.mts
|
|
10795
10795
|
//#region src/config/options.d.ts
|
|
10796
10796
|
/**
|
|
10797
10797
|
* Resolve user config into resolved configs
|
|
@@ -10811,7 +10811,7 @@ declare function defineConfig(options: UserConfig[]): UserConfig[];
|
|
|
10811
10811
|
declare function defineConfig(options: UserConfigFn): UserConfigFn;
|
|
10812
10812
|
declare function defineConfig(options: UserConfigExport): UserConfigExport; //#endregion
|
|
10813
10813
|
//#endregion
|
|
10814
|
-
//#region ../../node_modules/.pnpm/tsdown@0.21.
|
|
10814
|
+
//#region ../../node_modules/.pnpm/tsdown@0.21.3_@arethetypeswrong+core@0.18.2_@tsdown+css@0.21.3_@tsdown+exe@0.21.3_@type_38be87ebcd54001dc11621ca3e3d3fad/node_modules/tsdown/dist/index.d.mts
|
|
10815
10815
|
//#region src/build.d.ts
|
|
10816
10816
|
/**
|
|
10817
10817
|
* Build with tsdown.
|
package/dist/tsdown/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { c as globalLogger } from "./main-
|
|
1
|
+
import { c as globalLogger } from "./main-BR1iuPKy.js";
|
|
2
2
|
import "./node-B3Gdtau1.js";
|
|
3
|
-
import { t as enableDebug } from "./debug-C4FmgzkJ-
|
|
4
|
-
import { i as resolveUserConfig, n as buildWithConfigs, r as mergeConfig, t as build$1 } from "./build-
|
|
3
|
+
import { t as enableDebug } from "./debug-C4FmgzkJ-58KiZwv5.js";
|
|
4
|
+
import { i as resolveUserConfig, n as buildWithConfigs, r as mergeConfig, t as build$1 } from "./build-Dh89hfzV-CSN02Okj.js";
|
|
5
5
|
import "./filename-UU7z2A9Z.js";
|
|
6
6
|
import * as Rolldown from "@voidzero-dev/vite-plus-core/rolldown";
|
|
7
|
-
//#region ../../node_modules/.pnpm/tsdown@0.21.
|
|
7
|
+
//#region ../../node_modules/.pnpm/tsdown@0.21.3_@arethetypeswrong+core@0.18.2_@tsdown+css@0.21.3_@tsdown+exe@0.21.3_@type_38be87ebcd54001dc11621ca3e3d3fad/node_modules/tsdown/dist/config.mjs
|
|
8
8
|
function defineConfig(options) {
|
|
9
9
|
return options;
|
|
10
10
|
}
|
|
@@ -3,7 +3,6 @@ import { createRequire } from "node:module";
|
|
|
3
3
|
import { pathToFileURL } from "node:url";
|
|
4
4
|
import process$1, { cwd } from "node:process";
|
|
5
5
|
import readline from "node:readline";
|
|
6
|
-
import { createRequire as createRequire$1 } from "module";
|
|
7
6
|
import { spawn } from "node:child_process";
|
|
8
7
|
import { delimiter, dirname, normalize, resolve } from "node:path";
|
|
9
8
|
import { PassThrough } from "node:stream";
|
|
@@ -173,7 +172,7 @@ const { Ansis, fg, bg, rgb, bgRgb, hex, bgHex, reset, inverse, hidden, visible,
|
|
|
173
172
|
module.exports = w, w.default = w;
|
|
174
173
|
})))(), 1)).default;
|
|
175
174
|
//#endregion
|
|
176
|
-
//#region ../../node_modules/.pnpm/tsdown@0.21.
|
|
175
|
+
//#region ../../node_modules/.pnpm/tsdown@0.21.3_@arethetypeswrong+core@0.18.2_@tsdown+css@0.21.3_@tsdown+exe@0.21.3_@type_38be87ebcd54001dc11621ca3e3d3fad/node_modules/tsdown/dist/logger-BU0v7CAk.mjs
|
|
177
176
|
const LogLevels = {
|
|
178
177
|
silent: 0,
|
|
179
178
|
error: 1,
|
|
@@ -297,73 +296,55 @@ function hue2rgb(p, q, t) {
|
|
|
297
296
|
return p;
|
|
298
297
|
}
|
|
299
298
|
//#endregion
|
|
300
|
-
//#region ../../node_modules/.pnpm/tsdown@0.21.
|
|
301
|
-
var version = "0.21.
|
|
299
|
+
//#region ../../node_modules/.pnpm/tsdown@0.21.3_@arethetypeswrong+core@0.18.2_@tsdown+css@0.21.3_@tsdown+exe@0.21.3_@type_38be87ebcd54001dc11621ca3e3d3fad/node_modules/tsdown/dist/package-CaVX988O.mjs
|
|
300
|
+
var version = "0.21.3";
|
|
302
301
|
//#endregion
|
|
303
|
-
//#region ../../node_modules/.pnpm/tinyexec@1.0.
|
|
304
|
-
var l =
|
|
305
|
-
var u =
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
var p = Object.getPrototypeOf;
|
|
309
|
-
var m = Object.prototype.hasOwnProperty;
|
|
310
|
-
var h = (e, t) => () => (t || e((t = { exports: {} }).exports, t), t.exports);
|
|
311
|
-
var g = (e, t, n, r) => {
|
|
312
|
-
if (t && typeof t === "object" || typeof t === "function") for (var i = f(t), a = 0, o = i.length, s; a < o; a++) {
|
|
313
|
-
s = i[a];
|
|
314
|
-
if (!m.call(e, s) && s !== n) u(e, s, {
|
|
315
|
-
get: ((e) => t[e]).bind(null, s),
|
|
316
|
-
enumerable: !(r = d(t, s)) || r.enumerable
|
|
317
|
-
});
|
|
318
|
-
}
|
|
319
|
-
return e;
|
|
320
|
-
};
|
|
321
|
-
var _ = (e, t, n) => (n = e != null ? l(p(e)) : {}, g(t || !e || !e.__esModule ? u(n, "default", {
|
|
322
|
-
value: e,
|
|
323
|
-
enumerable: true
|
|
324
|
-
}) : n, e));
|
|
325
|
-
var v = /* @__PURE__ */ createRequire$1(import.meta.url);
|
|
326
|
-
const y = /^path$/i;
|
|
327
|
-
const b = {
|
|
302
|
+
//#region ../../node_modules/.pnpm/tinyexec@1.0.4/node_modules/tinyexec/dist/main.mjs
|
|
303
|
+
var l = (e, t) => () => (t || e((t = { exports: {} }).exports, t), t.exports);
|
|
304
|
+
var u = /* @__PURE__ */ createRequire(import.meta.url);
|
|
305
|
+
const d = /^path$/i;
|
|
306
|
+
const f = {
|
|
328
307
|
key: "PATH",
|
|
329
308
|
value: ""
|
|
330
309
|
};
|
|
331
|
-
function
|
|
310
|
+
function p(e) {
|
|
332
311
|
for (const t in e) {
|
|
333
|
-
if (!Object.prototype.hasOwnProperty.call(e, t) || !
|
|
312
|
+
if (!Object.prototype.hasOwnProperty.call(e, t) || !d.test(t)) continue;
|
|
334
313
|
const n = e[t];
|
|
335
|
-
if (!n) return
|
|
314
|
+
if (!n) return f;
|
|
336
315
|
return {
|
|
337
316
|
key: t,
|
|
338
317
|
value: n
|
|
339
318
|
};
|
|
340
319
|
}
|
|
341
|
-
return
|
|
320
|
+
return f;
|
|
342
321
|
}
|
|
343
|
-
function
|
|
322
|
+
function m(e, t) {
|
|
344
323
|
const i = t.value.split(delimiter);
|
|
345
|
-
|
|
346
|
-
let s;
|
|
324
|
+
const o = [];
|
|
325
|
+
let s = e;
|
|
326
|
+
let c;
|
|
347
327
|
do {
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
} while (
|
|
328
|
+
o.push(resolve(s, "node_modules", ".bin"));
|
|
329
|
+
c = s;
|
|
330
|
+
s = dirname(s);
|
|
331
|
+
} while (s !== c);
|
|
332
|
+
const l = o.concat(i).join(delimiter);
|
|
352
333
|
return {
|
|
353
334
|
key: t.key,
|
|
354
|
-
value:
|
|
335
|
+
value: l
|
|
355
336
|
};
|
|
356
337
|
}
|
|
357
|
-
function
|
|
338
|
+
function h(e, t) {
|
|
358
339
|
const n = {
|
|
359
340
|
...process.env,
|
|
360
341
|
...t
|
|
361
342
|
};
|
|
362
|
-
const r =
|
|
343
|
+
const r = m(e, p(n));
|
|
363
344
|
n[r.key] = r.value;
|
|
364
345
|
return n;
|
|
365
346
|
}
|
|
366
|
-
const
|
|
347
|
+
const g = (e) => {
|
|
367
348
|
let t = e.length;
|
|
368
349
|
const n = new PassThrough();
|
|
369
350
|
const r = () => {
|
|
@@ -375,10 +356,10 @@ const w = (e) => {
|
|
|
375
356
|
}
|
|
376
357
|
return n;
|
|
377
358
|
};
|
|
378
|
-
var
|
|
359
|
+
var _ = /* @__PURE__ */ l(((e, t) => {
|
|
379
360
|
t.exports = a;
|
|
380
361
|
a.sync = o;
|
|
381
|
-
var n =
|
|
362
|
+
var n = u("fs");
|
|
382
363
|
function r(e, t) {
|
|
383
364
|
var n = t.pathExt !== void 0 ? t.pathExt : process.env.PATHEXT;
|
|
384
365
|
if (!n) return true;
|
|
@@ -402,11 +383,11 @@ var T = h((exports, t) => {
|
|
|
402
383
|
function o(e, t) {
|
|
403
384
|
return i(n.statSync(e), e, t);
|
|
404
385
|
}
|
|
405
|
-
});
|
|
406
|
-
var
|
|
386
|
+
}));
|
|
387
|
+
var v = /* @__PURE__ */ l(((e, t) => {
|
|
407
388
|
t.exports = r;
|
|
408
389
|
r.sync = i;
|
|
409
|
-
var n =
|
|
390
|
+
var n = u("fs");
|
|
410
391
|
function r(e, t, r) {
|
|
411
392
|
n.stat(e, function(e, n) {
|
|
412
393
|
r(e, e ? false : a(n, t));
|
|
@@ -430,52 +411,52 @@ var E = h((exports, t) => {
|
|
|
430
411
|
var u = s | c;
|
|
431
412
|
return n & l || n & c && i === o || n & s && r === a || n & u && a === 0;
|
|
432
413
|
}
|
|
433
|
-
});
|
|
434
|
-
var
|
|
435
|
-
|
|
436
|
-
var
|
|
437
|
-
if (process.platform === "win32" || global.TESTING_WINDOWS)
|
|
438
|
-
else
|
|
439
|
-
t.exports =
|
|
440
|
-
|
|
441
|
-
function
|
|
414
|
+
}));
|
|
415
|
+
var y = /* @__PURE__ */ l(((e, t) => {
|
|
416
|
+
u("fs");
|
|
417
|
+
var n;
|
|
418
|
+
if (process.platform === "win32" || global.TESTING_WINDOWS) n = _();
|
|
419
|
+
else n = v();
|
|
420
|
+
t.exports = r;
|
|
421
|
+
r.sync = i;
|
|
422
|
+
function r(e, t, i) {
|
|
442
423
|
if (typeof t === "function") {
|
|
443
|
-
|
|
424
|
+
i = t;
|
|
444
425
|
t = {};
|
|
445
426
|
}
|
|
446
|
-
if (!
|
|
427
|
+
if (!i) {
|
|
447
428
|
if (typeof Promise !== "function") throw new TypeError("callback not provided");
|
|
448
|
-
return new Promise(function(n,
|
|
449
|
-
|
|
450
|
-
if (e)
|
|
429
|
+
return new Promise(function(n, i) {
|
|
430
|
+
r(e, t || {}, function(e, t) {
|
|
431
|
+
if (e) i(e);
|
|
451
432
|
else n(t);
|
|
452
433
|
});
|
|
453
434
|
});
|
|
454
435
|
}
|
|
455
|
-
|
|
436
|
+
n(e, t || {}, function(e, n) {
|
|
456
437
|
if (e) {
|
|
457
438
|
if (e.code === "EACCES" || t && t.ignoreErrors) {
|
|
458
439
|
e = null;
|
|
459
|
-
|
|
440
|
+
n = false;
|
|
460
441
|
}
|
|
461
442
|
}
|
|
462
|
-
|
|
443
|
+
i(e, n);
|
|
463
444
|
});
|
|
464
445
|
}
|
|
465
|
-
function
|
|
446
|
+
function i(e, t) {
|
|
466
447
|
try {
|
|
467
|
-
return
|
|
448
|
+
return n.sync(e, t || {});
|
|
468
449
|
} catch (e) {
|
|
469
450
|
if (t && t.ignoreErrors || e.code === "EACCES") return false;
|
|
470
451
|
else throw e;
|
|
471
452
|
}
|
|
472
453
|
}
|
|
473
|
-
});
|
|
474
|
-
var
|
|
454
|
+
}));
|
|
455
|
+
var b = /* @__PURE__ */ l(((e, t) => {
|
|
475
456
|
const n = process.platform === "win32" || process.env.OSTYPE === "cygwin" || process.env.OSTYPE === "msys";
|
|
476
|
-
const r =
|
|
457
|
+
const r = u("path");
|
|
477
458
|
const i = n ? ";" : ":";
|
|
478
|
-
const a =
|
|
459
|
+
const a = y();
|
|
479
460
|
const o = (e) => Object.assign(/* @__PURE__ */ new Error(`not found: ${e}`), { code: "ENOENT" });
|
|
480
461
|
const s = (e, t) => {
|
|
481
462
|
const r = t.colon || i;
|
|
@@ -540,8 +521,8 @@ var O = h((exports, t) => {
|
|
|
540
521
|
};
|
|
541
522
|
t.exports = c;
|
|
542
523
|
c.sync = l;
|
|
543
|
-
});
|
|
544
|
-
var
|
|
524
|
+
}));
|
|
525
|
+
var x = /* @__PURE__ */ l(((e, t) => {
|
|
545
526
|
const n = (e = {}) => {
|
|
546
527
|
const t = e.env || process.env;
|
|
547
528
|
if ((e.platform || process.platform) !== "win32") return "PATH";
|
|
@@ -549,11 +530,11 @@ var k = h((exports, t) => {
|
|
|
549
530
|
};
|
|
550
531
|
t.exports = n;
|
|
551
532
|
t.exports.default = n;
|
|
552
|
-
});
|
|
553
|
-
var
|
|
554
|
-
const n =
|
|
555
|
-
const r =
|
|
556
|
-
const i =
|
|
533
|
+
}));
|
|
534
|
+
var S = /* @__PURE__ */ l(((e, t) => {
|
|
535
|
+
const n = u("path");
|
|
536
|
+
const r = b();
|
|
537
|
+
const i = x();
|
|
557
538
|
function a(e, t) {
|
|
558
539
|
const a = e.options.env || process.env;
|
|
559
540
|
const o = process.cwd();
|
|
@@ -578,8 +559,8 @@ var A = h((exports, t) => {
|
|
|
578
559
|
return a(e) || a(e, true);
|
|
579
560
|
}
|
|
580
561
|
t.exports = o;
|
|
581
|
-
});
|
|
582
|
-
var
|
|
562
|
+
}));
|
|
563
|
+
var C = /* @__PURE__ */ l(((e, t) => {
|
|
583
564
|
const n = /([()\][%!^"`<>&|;, *?])/g;
|
|
584
565
|
function r(e) {
|
|
585
566
|
e = e.replace(n, "^$1");
|
|
@@ -587,8 +568,8 @@ var j = h((exports, t) => {
|
|
|
587
568
|
}
|
|
588
569
|
function i(e, t) {
|
|
589
570
|
e = `${e}`;
|
|
590
|
-
e = e.replace(/(
|
|
591
|
-
e = e.replace(/(
|
|
571
|
+
e = e.replace(/(?=(\\+?)?)\1"/g, "$1$1\\\"");
|
|
572
|
+
e = e.replace(/(?=(\\+?)?)\1$/, "$1$1");
|
|
592
573
|
e = `"${e}"`;
|
|
593
574
|
e = e.replace(n, "^$1");
|
|
594
575
|
if (t) e = e.replace(n, "^$1");
|
|
@@ -596,12 +577,12 @@ var j = h((exports, t) => {
|
|
|
596
577
|
}
|
|
597
578
|
t.exports.command = r;
|
|
598
579
|
t.exports.argument = i;
|
|
599
|
-
});
|
|
600
|
-
var
|
|
580
|
+
}));
|
|
581
|
+
var w = /* @__PURE__ */ l(((e, t) => {
|
|
601
582
|
t.exports = /^#!(.*)/;
|
|
602
|
-
});
|
|
603
|
-
var
|
|
604
|
-
const n =
|
|
583
|
+
}));
|
|
584
|
+
var T = /* @__PURE__ */ l(((e, t) => {
|
|
585
|
+
const n = w();
|
|
605
586
|
t.exports = (e = "") => {
|
|
606
587
|
const t = e.match(n);
|
|
607
588
|
if (!t) return null;
|
|
@@ -610,10 +591,10 @@ var N = h((exports, t) => {
|
|
|
610
591
|
if (a === "env") return i;
|
|
611
592
|
return i ? `${a} ${i}` : a;
|
|
612
593
|
};
|
|
613
|
-
});
|
|
614
|
-
var
|
|
615
|
-
const n =
|
|
616
|
-
const r =
|
|
594
|
+
}));
|
|
595
|
+
var E = /* @__PURE__ */ l(((e, t) => {
|
|
596
|
+
const n = u("fs");
|
|
597
|
+
const r = T();
|
|
617
598
|
function i(e) {
|
|
618
599
|
const t = 150;
|
|
619
600
|
const i = Buffer.alloc(t);
|
|
@@ -626,12 +607,12 @@ var P = h((exports, t) => {
|
|
|
626
607
|
return r(i.toString());
|
|
627
608
|
}
|
|
628
609
|
t.exports = i;
|
|
629
|
-
});
|
|
630
|
-
var
|
|
631
|
-
const n =
|
|
632
|
-
const r =
|
|
633
|
-
const i =
|
|
634
|
-
const a =
|
|
610
|
+
}));
|
|
611
|
+
var D = /* @__PURE__ */ l(((e, t) => {
|
|
612
|
+
const n = u("path");
|
|
613
|
+
const r = S();
|
|
614
|
+
const i = C();
|
|
615
|
+
const a = E();
|
|
635
616
|
const o = process.platform === "win32";
|
|
636
617
|
const s = /\.(?:com|exe)$/i;
|
|
637
618
|
const c = /node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;
|
|
@@ -645,7 +626,7 @@ var F = h((exports, t) => {
|
|
|
645
626
|
}
|
|
646
627
|
return e.file;
|
|
647
628
|
}
|
|
648
|
-
function
|
|
629
|
+
function d(e) {
|
|
649
630
|
if (!o) return e;
|
|
650
631
|
const t = l(e);
|
|
651
632
|
const r = !s.test(t);
|
|
@@ -665,7 +646,7 @@ var F = h((exports, t) => {
|
|
|
665
646
|
}
|
|
666
647
|
return e;
|
|
667
648
|
}
|
|
668
|
-
function
|
|
649
|
+
function f(e, t, n) {
|
|
669
650
|
if (t && !Array.isArray(t)) {
|
|
670
651
|
n = t;
|
|
671
652
|
t = null;
|
|
@@ -682,11 +663,11 @@ var F = h((exports, t) => {
|
|
|
682
663
|
args: t
|
|
683
664
|
}
|
|
684
665
|
};
|
|
685
|
-
return n.shell ? r :
|
|
666
|
+
return n.shell ? r : d(r);
|
|
686
667
|
}
|
|
687
|
-
t.exports =
|
|
688
|
-
});
|
|
689
|
-
var
|
|
668
|
+
t.exports = f;
|
|
669
|
+
}));
|
|
670
|
+
var O = /* @__PURE__ */ l(((e, t) => {
|
|
690
671
|
const n = process.platform === "win32";
|
|
691
672
|
function r(e, t) {
|
|
692
673
|
return Object.assign(/* @__PURE__ */ new Error(`${t} ${e.command} ENOENT`), {
|
|
@@ -702,7 +683,7 @@ var I = h((exports, t) => {
|
|
|
702
683
|
const r = e.emit;
|
|
703
684
|
e.emit = function(n, i) {
|
|
704
685
|
if (n === "exit") {
|
|
705
|
-
const n = a(i, t
|
|
686
|
+
const n = a(i, t);
|
|
706
687
|
if (n) return r.call(e, "error", n);
|
|
707
688
|
}
|
|
708
689
|
return r.apply(e, arguments);
|
|
@@ -722,11 +703,11 @@ var I = h((exports, t) => {
|
|
|
722
703
|
verifyENOENTSync: o,
|
|
723
704
|
notFoundError: r
|
|
724
705
|
};
|
|
725
|
-
});
|
|
726
|
-
var
|
|
727
|
-
const n =
|
|
728
|
-
const r =
|
|
729
|
-
const i =
|
|
706
|
+
}));
|
|
707
|
+
var A = (/* @__PURE__ */ l(((e, t) => {
|
|
708
|
+
const n = u("child_process");
|
|
709
|
+
const r = D();
|
|
710
|
+
const i = O();
|
|
730
711
|
function a(e, t, a) {
|
|
731
712
|
const o = r(e, t, a);
|
|
732
713
|
const s = n.spawn(o.command, o.args, o.options);
|
|
@@ -744,8 +725,8 @@ var R = _(h((exports, t) => {
|
|
|
744
725
|
t.exports.sync = o;
|
|
745
726
|
t.exports._parse = r;
|
|
746
727
|
t.exports._enoent = i;
|
|
747
|
-
})()
|
|
748
|
-
var
|
|
728
|
+
})))();
|
|
729
|
+
var j = class extends Error {
|
|
749
730
|
result;
|
|
750
731
|
output;
|
|
751
732
|
get exitCode() {
|
|
@@ -757,18 +738,18 @@ var z = class extends Error {
|
|
|
757
738
|
this.output = t;
|
|
758
739
|
}
|
|
759
740
|
};
|
|
760
|
-
const
|
|
741
|
+
const M = {
|
|
761
742
|
timeout: void 0,
|
|
762
743
|
persist: false
|
|
763
744
|
};
|
|
764
|
-
const
|
|
765
|
-
function
|
|
745
|
+
const N = { windowsHide: true };
|
|
746
|
+
function P(e, t) {
|
|
766
747
|
return {
|
|
767
748
|
command: normalize(e),
|
|
768
749
|
args: t ?? []
|
|
769
750
|
};
|
|
770
751
|
}
|
|
771
|
-
function
|
|
752
|
+
function F(e) {
|
|
772
753
|
const t = new AbortController();
|
|
773
754
|
for (const n of e) {
|
|
774
755
|
if (n.aborted) {
|
|
@@ -782,12 +763,12 @@ function U(e) {
|
|
|
782
763
|
}
|
|
783
764
|
return t.signal;
|
|
784
765
|
}
|
|
785
|
-
async function
|
|
766
|
+
async function I(e) {
|
|
786
767
|
let t = "";
|
|
787
768
|
for await (const n of e) t += n.toString();
|
|
788
769
|
return t;
|
|
789
770
|
}
|
|
790
|
-
var
|
|
771
|
+
var L = class {
|
|
791
772
|
_process;
|
|
792
773
|
_aborted = false;
|
|
793
774
|
_options;
|
|
@@ -807,7 +788,7 @@ var G = class {
|
|
|
807
788
|
}
|
|
808
789
|
constructor(e, t, n) {
|
|
809
790
|
this._options = {
|
|
810
|
-
...
|
|
791
|
+
...M,
|
|
811
792
|
...n
|
|
812
793
|
};
|
|
813
794
|
this._command = e;
|
|
@@ -826,7 +807,7 @@ var G = class {
|
|
|
826
807
|
return this._process?.killed === true;
|
|
827
808
|
}
|
|
828
809
|
pipe(e, t, n) {
|
|
829
|
-
return
|
|
810
|
+
return z(e, t, {
|
|
830
811
|
...n,
|
|
831
812
|
stdin: this
|
|
832
813
|
});
|
|
@@ -837,18 +818,18 @@ var G = class {
|
|
|
837
818
|
const t = [];
|
|
838
819
|
if (this._streamErr) t.push(this._streamErr);
|
|
839
820
|
if (this._streamOut) t.push(this._streamOut);
|
|
840
|
-
const n =
|
|
821
|
+
const n = g(t);
|
|
841
822
|
const r = readline.createInterface({ input: n });
|
|
842
823
|
for await (const e of r) yield e.toString();
|
|
843
824
|
await this._processClosed;
|
|
844
825
|
e.removeAllListeners();
|
|
845
826
|
if (this._thrownError) throw this._thrownError;
|
|
846
|
-
if (this._options?.throwOnError && this.exitCode !== 0 && this.exitCode !== void 0) throw new
|
|
827
|
+
if (this._options?.throwOnError && this.exitCode !== 0 && this.exitCode !== void 0) throw new j(this);
|
|
847
828
|
}
|
|
848
829
|
async _waitForOutput() {
|
|
849
830
|
const e = this._process;
|
|
850
831
|
if (!e) throw new Error("No process was started");
|
|
851
|
-
const [t, n] = await Promise.all([this._streamOut ?
|
|
832
|
+
const [t, n] = await Promise.all([this._streamOut ? I(this._streamOut) : "", this._streamErr ? I(this._streamErr) : ""]);
|
|
852
833
|
await this._processClosed;
|
|
853
834
|
if (this._options?.stdin) await this._options.stdin;
|
|
854
835
|
e.removeAllListeners();
|
|
@@ -858,7 +839,7 @@ var G = class {
|
|
|
858
839
|
stdout: t,
|
|
859
840
|
exitCode: this.exitCode
|
|
860
841
|
};
|
|
861
|
-
if (this._options.throwOnError && this.exitCode !== 0 && this.exitCode !== void 0) throw new
|
|
842
|
+
if (this._options.throwOnError && this.exitCode !== 0 && this.exitCode !== void 0) throw new j(this, r);
|
|
862
843
|
return r;
|
|
863
844
|
}
|
|
864
845
|
then(e, t) {
|
|
@@ -870,7 +851,7 @@ var G = class {
|
|
|
870
851
|
const e = cwd();
|
|
871
852
|
const n = this._options;
|
|
872
853
|
const r = {
|
|
873
|
-
...
|
|
854
|
+
...N,
|
|
874
855
|
...n.nodeOptions
|
|
875
856
|
};
|
|
876
857
|
const i = [];
|
|
@@ -878,10 +859,10 @@ var G = class {
|
|
|
878
859
|
if (n.timeout !== void 0) i.push(AbortSignal.timeout(n.timeout));
|
|
879
860
|
if (n.signal !== void 0) i.push(n.signal);
|
|
880
861
|
if (n.persist === true) r.detached = true;
|
|
881
|
-
if (i.length > 0) r.signal =
|
|
882
|
-
r.env =
|
|
883
|
-
const { command: a, args: s } =
|
|
884
|
-
const c = (0,
|
|
862
|
+
if (i.length > 0) r.signal = F(i);
|
|
863
|
+
r.env = h(e, r.env);
|
|
864
|
+
const { command: a, args: s } = P(this._command, this._args);
|
|
865
|
+
const c = (0, A._parse)(a, s, r);
|
|
885
866
|
const l = spawn(c.command, c.args, c.options);
|
|
886
867
|
if (l.stderr) this._streamErr = l.stderr;
|
|
887
868
|
if (l.stdout) this._streamOut = l.stdout;
|
|
@@ -911,11 +892,11 @@ var G = class {
|
|
|
911
892
|
if (this._resolveClose) this._resolveClose();
|
|
912
893
|
};
|
|
913
894
|
};
|
|
914
|
-
const
|
|
915
|
-
const r = new
|
|
895
|
+
const R = (e, t, n) => {
|
|
896
|
+
const r = new L(e, t, n);
|
|
916
897
|
r.spawn();
|
|
917
898
|
return r;
|
|
918
899
|
};
|
|
919
|
-
const
|
|
900
|
+
const z = R;
|
|
920
901
|
//#endregion
|
|
921
|
-
export { resolveComma as C, toArray as E, promiseWithResolvers as S, slash as T, debounce as _, createLogger as a, noop as b, globalLogger as c, bold as d, dim as f, yellow as g, underline as h, LogLevels as i, prettyFormat as l, red as m,
|
|
902
|
+
export { resolveComma as C, toArray as E, promiseWithResolvers as S, slash as T, debounce as _, createLogger as a, noop as b, globalLogger as c, bold as d, dim as f, yellow as g, underline as h, LogLevels as i, prettyFormat as l, red as m, z as n, generateColor as o, green as p, version as r, getNameLabel as s, R as t, blue as u, importWithError as v, resolveRegex as w, pkgExists as x, matchPattern as y };
|
package/dist/tsdown/run.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { c as globalLogger, f as dim, g as yellow, r as version, t as
|
|
2
|
+
import { c as globalLogger, f as dim, g as yellow, r as version, t as R } from "./main-BR1iuPKy.js";
|
|
3
3
|
import "./node-B3Gdtau1.js";
|
|
4
|
-
import { t as enableDebug } from "./debug-C4FmgzkJ-
|
|
4
|
+
import { t as enableDebug } from "./debug-C4FmgzkJ-58KiZwv5.js";
|
|
5
5
|
import module, { createRequire } from "node:module";
|
|
6
6
|
import process$1 from "node:process";
|
|
7
7
|
import { VERSION } from "@voidzero-dev/vite-plus-core/rolldown";
|
|
@@ -631,13 +631,13 @@ cli.command("[...files]", "Bundle files", {
|
|
|
631
631
|
}).option("-c, --config <filename>", "Use a custom config file").option("--config-loader <loader>", "Config loader to use: auto, native, unrun", { default: "auto" }).option("--no-config", "Disable config file").option("-f, --format <format>", "Bundle format: esm, cjs, iife, umd", { default: "esm" }).option("--clean", "Clean output directory, --no-clean to disable").option("--deps.never-bundle <module>", "Mark dependencies as external").option("--minify", "Minify output").option("--devtools", "Enable devtools integration").option("--debug [feat]", "Show debug logs").option("--target <target>", "Bundle target, e.g \"es2015\", \"esnext\"").option("-l, --logLevel <level>", "Set log level: info, warn, error, silent").option("--fail-on-warn", "Fail on warnings", { default: true }).option("--no-write", "Disable writing files to disk, incompatible with watch mode").option("-d, --out-dir <dir>", "Output directory", { default: "dist" }).option("--treeshake", "Tree-shake bundle", { default: true }).option("--sourcemap", "Generate source map", { default: false }).option("--shims", "Enable cjs and esm shims ", { default: false }).option("--platform <platform>", "Target platform", { default: "node" }).option("--dts", "Generate dts files").option("--publint", "Enable publint", { default: false }).option("--attw", "Enable Are the types wrong integration", { default: false }).option("--unused", "Enable unused dependencies check", { default: false }).option("-w, --watch [path]", "Watch mode").option("--ignore-watch <path>", "Ignore custom paths in watch mode").option("--from-vite [vitest]", "Reuse config from Vite or Vitest").option("--report", "Size report", { default: true }).option("--env.* <value>", "Define compile-time env variables").option("--env-file <file>", "Load environment variables from a file, when used together with --env, variables in --env take precedence").option("--env-prefix <prefix>", "Prefix for env variables to inject into the bundle", { default: "TSDOWN_" }).option("--on-success <command>", "Command to run on success").option("--copy <dir>", "Copy files to output dir").option("--public-dir <dir>", "Alias for --copy, deprecated").option("--tsconfig <tsconfig>", "Set tsconfig path").option("--unbundle", "Unbundle mode").option("--root <dir>", "Root directory of input files").option("--exe", "Bundle as executable").option("-W, --workspace [dir]", "Enable workspace mode").option("-F, --filter <pattern>", "Filter configs (cwd or name), e.g. /pkg-name$/ or pkg-name").option("--exports", "Generate export-related metadata for package.json (experimental)").action(async (input, flags) => {
|
|
632
632
|
globalLogger.level = flags.logLevel || "info";
|
|
633
633
|
globalLogger.info(`tsdown ${dim`v${version}`} powered by rolldown ${dim`v${VERSION}`}`);
|
|
634
|
-
const { build } = await import("./build-
|
|
634
|
+
const { build } = await import("./build-CGB4R_gC-Dyc6Tj-y.js");
|
|
635
635
|
if (input.length > 0) flags.entry = input;
|
|
636
636
|
await build(flags);
|
|
637
637
|
});
|
|
638
638
|
cli.command("create", "[deprecated] Create a tsdown project. Use \"npx create-tsdown\" instead.", { allowUnknownOptions: true }).action(async () => {
|
|
639
639
|
globalLogger.warn(`"tsdown create" is deprecated. Please use "npx create-tsdown" instead.`);
|
|
640
|
-
const { exitCode } = await
|
|
640
|
+
const { exitCode } = await R("npx", [
|
|
641
641
|
"-y",
|
|
642
642
|
"create-tsdown@latest",
|
|
643
643
|
...process$1.argv.slice(3)
|
|
@@ -646,7 +646,7 @@ cli.command("create", "[deprecated] Create a tsdown project. Use \"npx create-ts
|
|
|
646
646
|
});
|
|
647
647
|
cli.command("migrate", "[deprecated] Migrate from tsup to tsdown. Use \"npx tsdown-migrate\" instead.", { allowUnknownOptions: true }).action(async () => {
|
|
648
648
|
globalLogger.warn(`"tsdown migrate" is deprecated. Please use "npx tsdown-migrate" instead.`);
|
|
649
|
-
const { exitCode } = await
|
|
649
|
+
const { exitCode } = await R("npx", [
|
|
650
650
|
"-y",
|
|
651
651
|
"tsdown-migrate@latest",
|
|
652
652
|
...process$1.argv.slice(3)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@voidzero-dev/vite-plus-core",
|
|
3
|
-
"version": "0.1.12
|
|
3
|
+
"version": "0.1.12",
|
|
4
4
|
"description": "The Unified Toolchain for the Web",
|
|
5
5
|
"homepage": "https://viteplus.dev/guide",
|
|
6
6
|
"bugs": {
|
|
@@ -127,14 +127,14 @@
|
|
|
127
127
|
"semver": "^7.7.3",
|
|
128
128
|
"tinyglobby": "^0.2.15",
|
|
129
129
|
"tree-kill": "^1.2.2",
|
|
130
|
-
"tsdown": "^0.21.
|
|
130
|
+
"tsdown": "^0.21.3",
|
|
131
131
|
"rolldown": "1.0.0-rc.9",
|
|
132
|
-
"vite": "npm:@voidzero-dev/vite-plus-core@0.1.12
|
|
132
|
+
"vite": "npm:@voidzero-dev/vite-plus-core@0.1.12"
|
|
133
133
|
},
|
|
134
134
|
"peerDependencies": {
|
|
135
135
|
"@arethetypeswrong/core": "^0.18.1",
|
|
136
|
-
"@tsdown/css": "0.21.
|
|
137
|
-
"@tsdown/exe": "0.21.
|
|
136
|
+
"@tsdown/css": "0.21.3",
|
|
137
|
+
"@tsdown/exe": "0.21.3",
|
|
138
138
|
"@types/node": "^20.19.0 || >=22.12.0",
|
|
139
139
|
"@vitejs/devtools": "^0.0.0-alpha.31",
|
|
140
140
|
"esbuild": "^0.27.0",
|
|
@@ -216,7 +216,7 @@
|
|
|
216
216
|
"bundledVersions": {
|
|
217
217
|
"vite": "8.0.0",
|
|
218
218
|
"rolldown": "1.0.0-rc.9",
|
|
219
|
-
"tsdown": "0.21.
|
|
219
|
+
"tsdown": "0.21.3"
|
|
220
220
|
},
|
|
221
221
|
"scripts": {
|
|
222
222
|
"build": "oxnode -C dev ./build.ts"
|
|
@@ -1,249 +0,0 @@
|
|
|
1
|
-
import util from "node:util";
|
|
2
|
-
import cp$1 from "node:child_process";
|
|
3
|
-
import path from "node:path";
|
|
4
|
-
import fs from "node:fs/promises";
|
|
5
|
-
import os from "node:os";
|
|
6
|
-
import zlib from "node:zlib";
|
|
7
|
-
//#region ../../node_modules/.pnpm/tsdown@0.21.2_@arethetypeswrong+core@0.18.2_@tsdown+css@0.21.2_@tsdown+exe@0.21.2_@type_059aa640a91d945cefc9d8c8db7a9cd0/node_modules/tsdown/dist/index-node-Bpsmc0eX.mjs
|
|
8
|
-
/** @type {import('../index.d.ts').pack} */
|
|
9
|
-
async function pack(dir, opts) {
|
|
10
|
-
const packageManager = opts?.packageManager ?? "npm";
|
|
11
|
-
let command = `${packageManager} pack`;
|
|
12
|
-
if (packageManager === "bun") command = command.replace("bun", "bun pm");
|
|
13
|
-
const packDestination = opts?.destination ?? dir;
|
|
14
|
-
if (opts?.destination) switch (packageManager) {
|
|
15
|
-
case "yarn":
|
|
16
|
-
command += ` --out \"${path.join(packDestination, "package.tgz")}\"`;
|
|
17
|
-
break;
|
|
18
|
-
case "bun":
|
|
19
|
-
command += ` --destination \"${packDestination}\"`;
|
|
20
|
-
break;
|
|
21
|
-
default:
|
|
22
|
-
command += ` --pack-destination \"${packDestination}\"`;
|
|
23
|
-
break;
|
|
24
|
-
}
|
|
25
|
-
if (opts?.ignoreScripts) switch (packageManager) {
|
|
26
|
-
case "pnpm":
|
|
27
|
-
command += " --config.ignore-scripts=true";
|
|
28
|
-
break;
|
|
29
|
-
case "yarn": break;
|
|
30
|
-
default:
|
|
31
|
-
command += " --ignore-scripts";
|
|
32
|
-
break;
|
|
33
|
-
}
|
|
34
|
-
const output = await util.promisify(cp$1.exec)(command, { cwd: dir });
|
|
35
|
-
const tarballFile = await fs.readdir(packDestination).then((files) => {
|
|
36
|
-
return files.find((file) => file.endsWith(".tgz") && output.stdout.includes(file));
|
|
37
|
-
});
|
|
38
|
-
if (!tarballFile) if (output.stdout.startsWith("yarn pack v1")) throw new Error(`Yarn 1 is not supported to pack files. Command output:\n${JSON.stringify(output, null, 2)}`);
|
|
39
|
-
else throw new Error(`Failed to find packed tarball file in ${packDestination}. Command output:\n${JSON.stringify(output, null, 2)}`);
|
|
40
|
-
return path.join(packDestination, tarballFile);
|
|
41
|
-
}
|
|
42
|
-
async function getTempPackDir() {
|
|
43
|
-
const tempDir = os.tmpdir() + path.sep;
|
|
44
|
-
const tempPackDir = await fs.mkdtemp(tempDir + "publint-pack-");
|
|
45
|
-
return await fs.realpath(tempPackDir);
|
|
46
|
-
}
|
|
47
|
-
/** @type {import('../index.d.ts').packAsJson} */
|
|
48
|
-
async function packAsJson(dir, opts) {
|
|
49
|
-
const packageManager = opts?.packageManager ?? "npm";
|
|
50
|
-
if (packageManager === "bun") throw new Error("`packAsJson` is not supported for `bun`");
|
|
51
|
-
let command = `${packageManager} pack --json`;
|
|
52
|
-
const supportsDryRun = packageManager === "npm" || packageManager === "yarn";
|
|
53
|
-
/** @type {string | undefined} */
|
|
54
|
-
let packDestination;
|
|
55
|
-
if (supportsDryRun) command += " --dry-run";
|
|
56
|
-
else {
|
|
57
|
-
packDestination = await getTempPackDir();
|
|
58
|
-
command += ` --pack-destination ${packDestination}`;
|
|
59
|
-
}
|
|
60
|
-
if (opts?.ignoreScripts) switch (packageManager) {
|
|
61
|
-
case "pnpm":
|
|
62
|
-
command += " --config.ignore-scripts=true";
|
|
63
|
-
break;
|
|
64
|
-
case "yarn": break;
|
|
65
|
-
default:
|
|
66
|
-
command += " --ignore-scripts";
|
|
67
|
-
break;
|
|
68
|
-
}
|
|
69
|
-
let { stdout } = await util.promisify(cp$1.exec)(command, { cwd: dir });
|
|
70
|
-
try {
|
|
71
|
-
stdout = stdout.trim();
|
|
72
|
-
if (packageManager === "pnpm") stdout = fixPnpmStdout(stdout);
|
|
73
|
-
else if (packageManager === "yarn") stdout = fixYarnStdout(stdout);
|
|
74
|
-
return JSON.parse(stdout);
|
|
75
|
-
} finally {
|
|
76
|
-
if (!supportsDryRun && packDestination) await fs.rm(packDestination, { recursive: true });
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* @param {string} stdout
|
|
81
|
-
*/
|
|
82
|
-
function fixPnpmStdout(stdout) {
|
|
83
|
-
if (stdout.startsWith("{")) return stdout;
|
|
84
|
-
const usualStartIndex = /\{\s*"name"/.exec(stdout)?.index;
|
|
85
|
-
if (usualStartIndex != null) return stdout.slice(usualStartIndex);
|
|
86
|
-
const firstBraceIndex = stdout.indexOf("{");
|
|
87
|
-
if (firstBraceIndex !== -1) return stdout.slice(firstBraceIndex);
|
|
88
|
-
return stdout;
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* @param {string} stdout
|
|
92
|
-
*/
|
|
93
|
-
function fixYarnStdout(stdout) {
|
|
94
|
-
const lines = stdout.split("\n");
|
|
95
|
-
let fixedStdout = "[";
|
|
96
|
-
for (const line of lines) if (line) fixedStdout += line + ",";
|
|
97
|
-
if (fixedStdout[fixedStdout.length - 1] === ",") fixedStdout = fixedStdout.slice(0, -1);
|
|
98
|
-
fixedStdout += "]";
|
|
99
|
-
return fixedStdout;
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* @param {ReadableStream<Uint8Array>} readableStream
|
|
103
|
-
* @returns {Promise<ArrayBuffer>}
|
|
104
|
-
*/
|
|
105
|
-
async function readableStreamToArrayBuffer(readableStream) {
|
|
106
|
-
return await new Response(readableStream).arrayBuffer();
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* @param {ArrayBuffer} buffer
|
|
110
|
-
* @returns {import('../index.d.ts').TarballFile[]}
|
|
111
|
-
*/
|
|
112
|
-
function parseTar(buffer) {
|
|
113
|
-
const decoder = new TextDecoder();
|
|
114
|
-
/** @type {import('../index.d.ts').TarballFile[]} */
|
|
115
|
-
const files = [];
|
|
116
|
-
let offset = 0;
|
|
117
|
-
while (offset < buffer.byteLength) {
|
|
118
|
-
const type = read(buffer, decoder, offset + 156, 1);
|
|
119
|
-
if (type === "\0") break;
|
|
120
|
-
const size = parseInt(read(buffer, decoder, offset + 124, 12), 8);
|
|
121
|
-
if (type === "0") {
|
|
122
|
-
const name = read(buffer, decoder, offset, 100).split("\0", 1)[0];
|
|
123
|
-
const data = new Uint8Array(buffer, offset + 512, size);
|
|
124
|
-
files.push({
|
|
125
|
-
name,
|
|
126
|
-
data
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
offset += 512 + Math.ceil(size / 512) * 512;
|
|
130
|
-
}
|
|
131
|
-
return files;
|
|
132
|
-
}
|
|
133
|
-
/**
|
|
134
|
-
* @param {ArrayBuffer} buffer
|
|
135
|
-
* @param {TextDecoder} decoder
|
|
136
|
-
* @param {number} offset
|
|
137
|
-
* @param {number} length
|
|
138
|
-
*/
|
|
139
|
-
function read(buffer, decoder, offset, length) {
|
|
140
|
-
const view = new Uint8Array(buffer, offset, length);
|
|
141
|
-
return decoder.decode(view);
|
|
142
|
-
}
|
|
143
|
-
/**
|
|
144
|
-
* @param {import('../index.d.ts').TarballFile[]} files
|
|
145
|
-
*/
|
|
146
|
-
function getFilesRootDir(files) {
|
|
147
|
-
return files.length ? files[0].name.split("/")[0] : "package";
|
|
148
|
-
}
|
|
149
|
-
/** @type {import('../index.d.ts').unpack} */
|
|
150
|
-
async function unpack(tarball) {
|
|
151
|
-
/** @type {ArrayBuffer} */
|
|
152
|
-
let buffer;
|
|
153
|
-
if (tarball instanceof ReadableStream) buffer = await readableStreamToArrayBuffer(tarball.pipeThrough(new DecompressionStream("gzip")));
|
|
154
|
-
else {
|
|
155
|
-
const nodeBuffer = await util.promisify(zlib.gunzip)(tarball);
|
|
156
|
-
buffer = nodeBuffer.buffer.slice(nodeBuffer.byteOffset, nodeBuffer.byteOffset + nodeBuffer.byteLength);
|
|
157
|
-
}
|
|
158
|
-
const files = parseTar(buffer);
|
|
159
|
-
return {
|
|
160
|
-
files,
|
|
161
|
-
rootDir: getFilesRootDir(files)
|
|
162
|
-
};
|
|
163
|
-
}
|
|
164
|
-
/** @type {import('../index.d.ts').packAsList} */
|
|
165
|
-
async function packAsList(dir, opts) {
|
|
166
|
-
const packageManager = opts?.packageManager ?? "npm";
|
|
167
|
-
try {
|
|
168
|
-
return await packAsListWithJson(dir, packageManager, opts?.ignoreScripts);
|
|
169
|
-
} catch {
|
|
170
|
-
return await packAsListWithPack(dir, packageManager, opts?.ignoreScripts);
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
/**
|
|
174
|
-
* NOTE: only exported for tests
|
|
175
|
-
* @internal
|
|
176
|
-
* @param {string} dir
|
|
177
|
-
* @param {NonNullable<import('../index.d.ts').PackAsListOptions['packageManager']>} packageManager
|
|
178
|
-
* @param {import('../index.d.ts').PackAsListOptions['ignoreScripts']} ignoreScripts
|
|
179
|
-
* @returns {Promise<string[]>}
|
|
180
|
-
*/
|
|
181
|
-
async function packAsListWithJson(dir, packageManager, ignoreScripts) {
|
|
182
|
-
const stdoutJson = await packAsJson(dir, {
|
|
183
|
-
packageManager,
|
|
184
|
-
ignoreScripts
|
|
185
|
-
});
|
|
186
|
-
switch (packageManager) {
|
|
187
|
-
case "npm": return parseNpmPackJson(stdoutJson);
|
|
188
|
-
case "yarn": return parseYarnPackJson(stdoutJson);
|
|
189
|
-
case "pnpm": return parsePnpmPackJson(stdoutJson);
|
|
190
|
-
default: return [];
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
/**
|
|
194
|
-
* NOTE: only exported for tests
|
|
195
|
-
* @internal
|
|
196
|
-
* @param {string} dir
|
|
197
|
-
* @param {NonNullable<import('../index.d.ts').PackAsListOptions['packageManager']>} packageManager
|
|
198
|
-
* @param {import('../index.d.ts').PackAsListOptions['ignoreScripts']} ignoreScripts
|
|
199
|
-
* @returns {Promise<string[]>}
|
|
200
|
-
*/
|
|
201
|
-
async function packAsListWithPack(dir, packageManager, ignoreScripts) {
|
|
202
|
-
const destination = await getTempPackDir();
|
|
203
|
-
const tarballPath = await pack(dir, {
|
|
204
|
-
packageManager,
|
|
205
|
-
ignoreScripts,
|
|
206
|
-
destination
|
|
207
|
-
});
|
|
208
|
-
try {
|
|
209
|
-
const nodeBuffer = await fs.readFile(tarballPath);
|
|
210
|
-
const { files, rootDir } = await unpack(nodeBuffer.buffer.slice(nodeBuffer.byteOffset, nodeBuffer.byteOffset + nodeBuffer.byteLength));
|
|
211
|
-
return files.map((file) => file.name.slice(rootDir.length + 1));
|
|
212
|
-
} finally {
|
|
213
|
-
await fs.rm(destination, { recursive: true });
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
/**
|
|
217
|
-
* @param {any} stdoutJson
|
|
218
|
-
* @returns {string[]}
|
|
219
|
-
*/
|
|
220
|
-
function parseNpmPackJson(stdoutJson) {
|
|
221
|
-
return stdoutJson[0].files.map((file) => file.path);
|
|
222
|
-
}
|
|
223
|
-
/**
|
|
224
|
-
* @param {any} stdoutJson
|
|
225
|
-
* @returns {string[]}
|
|
226
|
-
*/
|
|
227
|
-
function parseYarnPackJson(stdoutJson) {
|
|
228
|
-
const files = [];
|
|
229
|
-
for (const value of stdoutJson) if (value.location) files.push(value.location);
|
|
230
|
-
return files;
|
|
231
|
-
}
|
|
232
|
-
/**
|
|
233
|
-
* @param {any} stdoutJson
|
|
234
|
-
* @returns {string[]}
|
|
235
|
-
*/
|
|
236
|
-
function parsePnpmPackJson(stdoutJson) {
|
|
237
|
-
return stdoutJson.files.map((file) => file.path);
|
|
238
|
-
}
|
|
239
|
-
/** @type {import('../index.d.ts').getPackDirectory} */
|
|
240
|
-
async function getPackDirectory(dir, packageManager) {
|
|
241
|
-
if (packageManager === "pnpm") try {
|
|
242
|
-
const pkgJsonPath = path.resolve(dir, "package.json");
|
|
243
|
-
const pkgJsonData = JSON.parse(await fs.readFile(pkgJsonPath, "utf-8"));
|
|
244
|
-
if (pkgJsonData.publishConfig?.directory) return path.resolve(dir, pkgJsonData.publishConfig.directory);
|
|
245
|
-
} catch {}
|
|
246
|
-
return dir;
|
|
247
|
-
}
|
|
248
|
-
//#endregion
|
|
249
|
-
export { getPackDirectory, pack, packAsJson, packAsList, unpack };
|
|
File without changes
|