@voidzero-dev/vite-plus-core 0.0.0-0bfcc90f.20260209-0731
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/LICENSE +41 -0
- package/dist/pluginutils/filter/composable-filters.d.ts +90 -0
- package/dist/pluginutils/filter/composable-filters.js +256 -0
- package/dist/pluginutils/filter/filter-vite-plugins.d.ts +28 -0
- package/dist/pluginutils/filter/filter-vite-plugins.js +75 -0
- package/dist/pluginutils/filter/index.d.ts +3 -0
- package/dist/pluginutils/filter/index.js +3 -0
- package/dist/pluginutils/filter/simple-filters.d.ts +71 -0
- package/dist/pluginutils/filter/simple-filters.js +70 -0
- package/dist/pluginutils/index.d.ts +1 -0
- package/dist/pluginutils/index.js +1 -0
- package/dist/pluginutils/utils.d.ts +2 -0
- package/dist/pluginutils/utils.js +17 -0
- package/dist/rolldown/cli-setup.d.mts +1 -0
- package/dist/rolldown/cli-setup.mjs +17 -0
- package/dist/rolldown/cli.d.mts +1 -0
- package/dist/rolldown/cli.mjs +608 -0
- package/dist/rolldown/config.d.mts +7 -0
- package/dist/rolldown/config.mjs +10 -0
- package/dist/rolldown/experimental-index.d.mts +194 -0
- package/dist/rolldown/experimental-index.mjs +291 -0
- package/dist/rolldown/experimental-runtime-types.d.ts +98 -0
- package/dist/rolldown/filter-index.d.mts +197 -0
- package/dist/rolldown/filter-index.mjs +369 -0
- package/dist/rolldown/get-log-filter.d.mts +7 -0
- package/dist/rolldown/get-log-filter.mjs +47 -0
- package/dist/rolldown/index.d.mts +4 -0
- package/dist/rolldown/index.mjs +57 -0
- package/dist/rolldown/parallel-plugin-worker.d.mts +1 -0
- package/dist/rolldown/parallel-plugin-worker.mjs +32 -0
- package/dist/rolldown/parallel-plugin.d.mts +14 -0
- package/dist/rolldown/parallel-plugin.mjs +7 -0
- package/dist/rolldown/parse-ast-index.d.mts +8 -0
- package/dist/rolldown/parse-ast-index.mjs +47 -0
- package/dist/rolldown/plugins-index.d.mts +30 -0
- package/dist/rolldown/plugins-index.mjs +40 -0
- package/dist/rolldown/shared/binding-D-XMzSaG.d.mts +1665 -0
- package/dist/rolldown/shared/binding-DuOSzYPt.mjs +587 -0
- package/dist/rolldown/shared/bindingify-input-options-Bu6nUTgS.mjs +2257 -0
- package/dist/rolldown/shared/constructors-DZVRHTli.mjs +61 -0
- package/dist/rolldown/shared/constructors-KD7LvxpN.d.mts +28 -0
- package/dist/rolldown/shared/define-config-BVG4QvnP.mjs +7 -0
- package/dist/rolldown/shared/define-config-U4pj0ZDn.d.mts +3616 -0
- package/dist/rolldown/shared/load-config-O1K_tT_z.mjs +114 -0
- package/dist/rolldown/shared/logging-CE90D8JR.d.mts +50 -0
- package/dist/rolldown/shared/logs-NH298mHo.mjs +183 -0
- package/dist/rolldown/shared/misc-CCZIsXVO.mjs +22 -0
- package/dist/rolldown/shared/normalize-string-or-regex-DeZqg15i.mjs +61 -0
- package/dist/rolldown/shared/parse-DLraxqjd.mjs +56 -0
- package/dist/rolldown/shared/prompt-DeISmFRp.mjs +847 -0
- package/dist/rolldown/shared/rolldown-O0UKbTKf.mjs +42 -0
- package/dist/rolldown/shared/rolldown-build-BIs7C4B_.mjs +3354 -0
- package/dist/rolldown/shared/watch-DQXGaDjx.mjs +379 -0
- package/dist/tsdown/build-l5WhXg4M-BBPqZr0m.js +4933 -0
- package/dist/tsdown/chunk-CdeBBKNj.js +44 -0
- package/dist/tsdown/debug-Cb_Nqpo4-BueIRvg1.js +18 -0
- package/dist/tsdown/detect-CCATtVj7-B86m8IqW.js +165 -0
- package/dist/tsdown/dist-BUOkzr_P.js +201 -0
- package/dist/tsdown/dist-BVMGwPdF.js +32363 -0
- package/dist/tsdown/dist-dc0X0G6b.js +742 -0
- package/dist/tsdown/filename-7rlgePeo.js +31 -0
- package/dist/tsdown/index-node-BjDys8jy--sqPE5mM.js +251 -0
- package/dist/tsdown/index-types.d.ts +2163 -0
- package/dist/tsdown/index.js +14 -0
- package/dist/tsdown/main-d9yZSQqW.js +926 -0
- package/dist/tsdown/node-Cb5OsnKg.js +271 -0
- package/dist/tsdown/npm_cjs_chunk_chunk.cjs +11 -0
- package/dist/tsdown/npm_cjs_chunk_range.cjs +484 -0
- package/dist/tsdown/npm_cjs_chunk_semver.cjs +362 -0
- package/dist/tsdown/npm_entry_picomatch.cjs +1676 -0
- package/dist/tsdown/npm_entry_semver_functions_coerce.cjs +52 -0
- package/dist/tsdown/npm_entry_semver_functions_satisfies.cjs +23 -0
- package/dist/tsdown/npm_entry_semver_ranges_min-version.cjs +48 -0
- package/dist/tsdown/npm_entry_tree-kill.cjs +103 -0
- package/dist/tsdown/resolver-j7HY1N36-CIu_7LX6.js +20 -0
- package/dist/tsdown/run.js +537 -0
- package/dist/tsdown/tsc-context-BNYuT3cE.js +25 -0
- package/dist/tsdown/tsc-reo6aLWc.js +423 -0
- package/dist/vite/client/client.mjs +1140 -0
- package/dist/vite/client/env.mjs +19 -0
- package/dist/vite/client.d.ts +279 -0
- package/dist/vite/misc/false.d.ts +2 -0
- package/dist/vite/misc/false.js +1 -0
- package/dist/vite/misc/true.d.ts +2 -0
- package/dist/vite/misc/true.js +1 -0
- package/dist/vite/node/chunks/build2.js +5538 -0
- package/dist/vite/node/chunks/chunk.js +45 -0
- package/dist/vite/node/chunks/dist.js +6758 -0
- package/dist/vite/node/chunks/dist2.js +6651 -0
- package/dist/vite/node/chunks/fetchableEnvironments.js +41395 -0
- package/dist/vite/node/chunks/lib.js +377 -0
- package/dist/vite/node/chunks/logger.js +332 -0
- package/dist/vite/node/chunks/moduleRunnerTransport.d.ts +96 -0
- package/dist/vite/node/chunks/postcss-import.js +479 -0
- package/dist/vite/node/cli.js +699 -0
- package/dist/vite/node/index.d.ts +3807 -0
- package/dist/vite/node/index.js +15 -0
- package/dist/vite/node/internal.d.ts +2 -0
- package/dist/vite/node/internal.js +3 -0
- package/dist/vite/node/module-runner.d.ts +311 -0
- package/dist/vite/node/module-runner.js +1159 -0
- package/dist/vite/types/customEvent.d.ts +52 -0
- package/dist/vite/types/hmrPayload.d.ts +80 -0
- package/dist/vite/types/hot.d.ts +39 -0
- package/dist/vite/types/import-meta.d.ts +5 -0
- package/dist/vite/types/importGlob.d.ts +89 -0
- package/dist/vite/types/importMeta.d.ts +30 -0
- package/dist/vite/types/internal/cssPreprocessorOptions.d.ts +44 -0
- package/dist/vite/types/internal/esbuildOptions.d.ts +28 -0
- package/dist/vite/types/internal/lightningcssOptions.d.ts +18 -0
- package/dist/vite/types/internal/rollupTypeCompat.d.ts +24 -0
- package/dist/vite/types/internal/terserOptions.d.ts +11 -0
- package/dist/vite/types/metadata.d.ts +47 -0
- package/package.json +204 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { RUNTIME_MODULE_ID } from "@voidzero-dev/vite-plus-core/rolldown";
|
|
2
|
+
import { exactRegex } from "@voidzero-dev/vite-plus-core/rolldown/filter";
|
|
3
|
+
|
|
4
|
+
//#region ../../node_modules/.pnpm/rolldown-plugin-dts@0.22.1_@typescript+native-preview@7.0.0-dev.20260122.2_oxc-resolver_d2e4a246ecba2d40b4415d1b79df8dc9/node_modules/rolldown-plugin-dts/dist/filename.mjs
|
|
5
|
+
const RE_JS = /\.([cm]?)jsx?$/;
|
|
6
|
+
const RE_TS = /\.([cm]?)tsx?$/;
|
|
7
|
+
const RE_DTS = /\.d\.([cm]?)ts$/;
|
|
8
|
+
const RE_DTS_MAP = /\.d\.([cm]?)ts\.map$/;
|
|
9
|
+
const RE_NODE_MODULES = /[\\/]node_modules[\\/]/;
|
|
10
|
+
const RE_CSS = /\.css$/;
|
|
11
|
+
const RE_VUE = /\.vue$/;
|
|
12
|
+
const RE_JSON = /\.json$/;
|
|
13
|
+
const RE_ROLLDOWN_RUNTIME = exactRegex(RUNTIME_MODULE_ID);
|
|
14
|
+
function filename_js_to_dts(id) {
|
|
15
|
+
return id.replace(RE_JS, ".d.$1ts");
|
|
16
|
+
}
|
|
17
|
+
function filename_to_dts(id) {
|
|
18
|
+
return id.replace(RE_VUE, ".vue.ts").replace(RE_TS, ".d.$1ts").replace(RE_JS, ".d.$1ts").replace(RE_JSON, ".json.d.ts");
|
|
19
|
+
}
|
|
20
|
+
function filename_dts_to(id, ext) {
|
|
21
|
+
return id.replace(RE_DTS, `.$1${ext}`);
|
|
22
|
+
}
|
|
23
|
+
function resolveTemplateFn(fn, chunk) {
|
|
24
|
+
return typeof fn === "function" ? fn(chunk) : fn;
|
|
25
|
+
}
|
|
26
|
+
function replaceTemplateName(template, name) {
|
|
27
|
+
return template.replaceAll("[name]", name);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
//#endregion
|
|
31
|
+
export { RE_JSON as a, RE_TS as c, filename_js_to_dts as d, filename_to_dts as f, RE_JS as i, RE_VUE as l, resolveTemplateFn as m, RE_DTS as n, RE_NODE_MODULES as o, replaceTemplateName as p, RE_DTS_MAP as r, RE_ROLLDOWN_RUNTIME as s, RE_CSS as t, filename_dts_to as u };
|
|
@@ -0,0 +1,251 @@
|
|
|
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 zlib from "node:zlib";
|
|
6
|
+
import os from "node:os";
|
|
7
|
+
|
|
8
|
+
//#region ../../node_modules/.pnpm/tsdown@0.20.2_@arethetypeswrong+core@0.18.2_@typescript+native-preview@7.0.0-dev.202601_11c6934cad7d4cedf7999249d5905a1c/node_modules/tsdown/dist/index-node-BjDys8jy.mjs
|
|
9
|
+
/** @type {import('../index.d.ts').pack} */
|
|
10
|
+
async function pack(dir, opts) {
|
|
11
|
+
const packageManager = opts?.packageManager ?? "npm";
|
|
12
|
+
let command = `${packageManager} pack`;
|
|
13
|
+
if (packageManager === "bun") command = command.replace("bun", "bun pm");
|
|
14
|
+
const packDestination = opts?.destination ?? dir;
|
|
15
|
+
if (opts?.destination) switch (packageManager) {
|
|
16
|
+
case "yarn":
|
|
17
|
+
command += ` --out \"${path.join(packDestination, "package.tgz")}\"`;
|
|
18
|
+
break;
|
|
19
|
+
case "bun":
|
|
20
|
+
command += ` --destination \"${packDestination}\"`;
|
|
21
|
+
break;
|
|
22
|
+
default:
|
|
23
|
+
command += ` --pack-destination \"${packDestination}\"`;
|
|
24
|
+
break;
|
|
25
|
+
}
|
|
26
|
+
if (opts?.ignoreScripts) switch (packageManager) {
|
|
27
|
+
case "pnpm":
|
|
28
|
+
command += " --config.ignore-scripts=true";
|
|
29
|
+
break;
|
|
30
|
+
case "yarn": break;
|
|
31
|
+
default:
|
|
32
|
+
command += " --ignore-scripts";
|
|
33
|
+
break;
|
|
34
|
+
}
|
|
35
|
+
const output = await util.promisify(cp$1.exec)(command, { cwd: dir });
|
|
36
|
+
const tarballFile = await fs.readdir(packDestination).then((files) => {
|
|
37
|
+
return files.find((file) => file.endsWith(".tgz") && output.stdout.includes(file));
|
|
38
|
+
});
|
|
39
|
+
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)}`);
|
|
40
|
+
else throw new Error(`Failed to find packed tarball file in ${packDestination}. Command output:\n${JSON.stringify(output, null, 2)}`);
|
|
41
|
+
return path.join(packDestination, tarballFile);
|
|
42
|
+
}
|
|
43
|
+
async function getTempPackDir() {
|
|
44
|
+
const tempDir = os.tmpdir() + path.sep;
|
|
45
|
+
const tempPackDir = await fs.mkdtemp(tempDir + "publint-pack-");
|
|
46
|
+
return await fs.realpath(tempPackDir);
|
|
47
|
+
}
|
|
48
|
+
/** @type {import('../index.d.ts').packAsJson} */
|
|
49
|
+
async function packAsJson(dir, opts) {
|
|
50
|
+
const packageManager = opts?.packageManager ?? "npm";
|
|
51
|
+
if (packageManager === "bun") throw new Error("`packAsJson` is not supported for `bun`");
|
|
52
|
+
let command = `${packageManager} pack --json`;
|
|
53
|
+
const supportsDryRun = packageManager === "npm" || packageManager === "yarn";
|
|
54
|
+
/** @type {string | undefined} */
|
|
55
|
+
let packDestination;
|
|
56
|
+
if (supportsDryRun) command += " --dry-run";
|
|
57
|
+
else {
|
|
58
|
+
packDestination = await getTempPackDir();
|
|
59
|
+
command += ` --pack-destination ${packDestination}`;
|
|
60
|
+
}
|
|
61
|
+
if (opts?.ignoreScripts) switch (packageManager) {
|
|
62
|
+
case "pnpm":
|
|
63
|
+
command += " --config.ignore-scripts=true";
|
|
64
|
+
break;
|
|
65
|
+
case "yarn": break;
|
|
66
|
+
default:
|
|
67
|
+
command += " --ignore-scripts";
|
|
68
|
+
break;
|
|
69
|
+
}
|
|
70
|
+
let { stdout } = await util.promisify(cp$1.exec)(command, { cwd: dir });
|
|
71
|
+
try {
|
|
72
|
+
stdout = stdout.trim();
|
|
73
|
+
if (packageManager === "pnpm") stdout = fixPnpmStdout(stdout);
|
|
74
|
+
else if (packageManager === "yarn") stdout = fixYarnStdout(stdout);
|
|
75
|
+
return JSON.parse(stdout);
|
|
76
|
+
} finally {
|
|
77
|
+
if (!supportsDryRun && packDestination) await fs.rm(packDestination, { recursive: true });
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* @param {string} stdout
|
|
82
|
+
*/
|
|
83
|
+
function fixPnpmStdout(stdout) {
|
|
84
|
+
if (stdout.startsWith("{")) return stdout;
|
|
85
|
+
const usualStartIndex = /\{\s*"name"/.exec(stdout)?.index;
|
|
86
|
+
if (usualStartIndex != null) return stdout.slice(usualStartIndex);
|
|
87
|
+
const firstBraceIndex = stdout.indexOf("{");
|
|
88
|
+
if (firstBraceIndex !== -1) return stdout.slice(firstBraceIndex);
|
|
89
|
+
return stdout;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* @param {string} stdout
|
|
93
|
+
*/
|
|
94
|
+
function fixYarnStdout(stdout) {
|
|
95
|
+
const lines = stdout.split("\n");
|
|
96
|
+
let fixedStdout = "[";
|
|
97
|
+
for (const line of lines) if (line) fixedStdout += line + ",";
|
|
98
|
+
if (fixedStdout[fixedStdout.length - 1] === ",") fixedStdout = fixedStdout.slice(0, -1);
|
|
99
|
+
fixedStdout += "]";
|
|
100
|
+
return fixedStdout;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* @param {ReadableStream<Uint8Array>} readableStream
|
|
104
|
+
* @returns {Promise<ArrayBuffer>}
|
|
105
|
+
*/
|
|
106
|
+
async function readableStreamToArrayBuffer(readableStream) {
|
|
107
|
+
return await new Response(readableStream).arrayBuffer();
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* @param {ArrayBuffer} buffer
|
|
111
|
+
* @returns {import('../index.d.ts').TarballFile[]}
|
|
112
|
+
*/
|
|
113
|
+
function parseTar(buffer) {
|
|
114
|
+
const decoder = new TextDecoder();
|
|
115
|
+
/** @type {import('../index.d.ts').TarballFile[]} */
|
|
116
|
+
const files = [];
|
|
117
|
+
let offset = 0;
|
|
118
|
+
while (offset < buffer.byteLength) {
|
|
119
|
+
const type = read(buffer, decoder, offset + 156, 1);
|
|
120
|
+
if (type === "\0") break;
|
|
121
|
+
const size = parseInt(read(buffer, decoder, offset + 124, 12), 8);
|
|
122
|
+
if (type === "0") {
|
|
123
|
+
const name = read(buffer, decoder, offset, 100).split("\0", 1)[0];
|
|
124
|
+
const data = new Uint8Array(buffer, offset + 512, size);
|
|
125
|
+
files.push({
|
|
126
|
+
name,
|
|
127
|
+
data
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
offset += 512 + Math.ceil(size / 512) * 512;
|
|
131
|
+
}
|
|
132
|
+
return files;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* @param {ArrayBuffer} buffer
|
|
136
|
+
* @param {TextDecoder} decoder
|
|
137
|
+
* @param {number} offset
|
|
138
|
+
* @param {number} length
|
|
139
|
+
*/
|
|
140
|
+
function read(buffer, decoder, offset, length) {
|
|
141
|
+
const view = new Uint8Array(buffer, offset, length);
|
|
142
|
+
return decoder.decode(view);
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* @param {import('../index.d.ts').TarballFile[]} files
|
|
146
|
+
*/
|
|
147
|
+
function getFilesRootDir(files) {
|
|
148
|
+
return files.length ? files[0].name.split("/")[0] : "package";
|
|
149
|
+
}
|
|
150
|
+
/** @type {import('../index.d.ts').unpack} */
|
|
151
|
+
async function unpack(tarball) {
|
|
152
|
+
/** @type {ArrayBuffer} */
|
|
153
|
+
let buffer;
|
|
154
|
+
if (tarball instanceof ReadableStream) buffer = await readableStreamToArrayBuffer(tarball.pipeThrough(new DecompressionStream("gzip")));
|
|
155
|
+
else {
|
|
156
|
+
const nodeBuffer = await util.promisify(zlib.gunzip)(tarball);
|
|
157
|
+
buffer = nodeBuffer.buffer.slice(nodeBuffer.byteOffset, nodeBuffer.byteOffset + nodeBuffer.byteLength);
|
|
158
|
+
}
|
|
159
|
+
const files = parseTar(buffer);
|
|
160
|
+
return {
|
|
161
|
+
files,
|
|
162
|
+
rootDir: getFilesRootDir(files)
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
/** @type {import('../index.d.ts').packAsList} */
|
|
166
|
+
async function packAsList(dir, opts) {
|
|
167
|
+
const packageManager = opts?.packageManager ?? "npm";
|
|
168
|
+
try {
|
|
169
|
+
return await packAsListWithJson(dir, packageManager, opts?.ignoreScripts);
|
|
170
|
+
} catch {
|
|
171
|
+
return await packAsListWithPack(dir, packageManager, opts?.ignoreScripts);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* NOTE: only exported for tests
|
|
176
|
+
* @internal
|
|
177
|
+
* @param {string} dir
|
|
178
|
+
* @param {NonNullable<import('../index.d.ts').PackAsListOptions['packageManager']>} packageManager
|
|
179
|
+
* @param {import('../index.d.ts').PackAsListOptions['ignoreScripts']} ignoreScripts
|
|
180
|
+
* @returns {Promise<string[]>}
|
|
181
|
+
*/
|
|
182
|
+
async function packAsListWithJson(dir, packageManager, ignoreScripts) {
|
|
183
|
+
const stdoutJson = await packAsJson(dir, {
|
|
184
|
+
packageManager,
|
|
185
|
+
ignoreScripts
|
|
186
|
+
});
|
|
187
|
+
switch (packageManager) {
|
|
188
|
+
case "npm": return parseNpmPackJson(stdoutJson);
|
|
189
|
+
case "yarn": return parseYarnPackJson(stdoutJson);
|
|
190
|
+
case "pnpm": return parsePnpmPackJson(stdoutJson);
|
|
191
|
+
default: return [];
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* NOTE: only exported for tests
|
|
196
|
+
* @internal
|
|
197
|
+
* @param {string} dir
|
|
198
|
+
* @param {NonNullable<import('../index.d.ts').PackAsListOptions['packageManager']>} packageManager
|
|
199
|
+
* @param {import('../index.d.ts').PackAsListOptions['ignoreScripts']} ignoreScripts
|
|
200
|
+
* @returns {Promise<string[]>}
|
|
201
|
+
*/
|
|
202
|
+
async function packAsListWithPack(dir, packageManager, ignoreScripts) {
|
|
203
|
+
const destination = await getTempPackDir();
|
|
204
|
+
const tarballPath = await pack(dir, {
|
|
205
|
+
packageManager,
|
|
206
|
+
ignoreScripts,
|
|
207
|
+
destination
|
|
208
|
+
});
|
|
209
|
+
try {
|
|
210
|
+
const nodeBuffer = await fs.readFile(tarballPath);
|
|
211
|
+
const { files, rootDir } = await unpack(nodeBuffer.buffer.slice(nodeBuffer.byteOffset, nodeBuffer.byteOffset + nodeBuffer.byteLength));
|
|
212
|
+
return files.map((file) => file.name.slice(rootDir.length + 1));
|
|
213
|
+
} finally {
|
|
214
|
+
await fs.rm(destination, { recursive: true });
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* @param {any} stdoutJson
|
|
219
|
+
* @returns {string[]}
|
|
220
|
+
*/
|
|
221
|
+
function parseNpmPackJson(stdoutJson) {
|
|
222
|
+
return stdoutJson[0].files.map((file) => file.path);
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* @param {any} stdoutJson
|
|
226
|
+
* @returns {string[]}
|
|
227
|
+
*/
|
|
228
|
+
function parseYarnPackJson(stdoutJson) {
|
|
229
|
+
const files = [];
|
|
230
|
+
for (const value of stdoutJson) if (value.location) files.push(value.location);
|
|
231
|
+
return files;
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* @param {any} stdoutJson
|
|
235
|
+
* @returns {string[]}
|
|
236
|
+
*/
|
|
237
|
+
function parsePnpmPackJson(stdoutJson) {
|
|
238
|
+
return stdoutJson.files.map((file) => file.path);
|
|
239
|
+
}
|
|
240
|
+
/** @type {import('../index.d.ts').getPackDirectory} */
|
|
241
|
+
async function getPackDirectory(dir, packageManager) {
|
|
242
|
+
if (packageManager === "pnpm") try {
|
|
243
|
+
const pkgJsonPath = path.resolve(dir, "package.json");
|
|
244
|
+
const pkgJsonData = JSON.parse(await fs.readFile(pkgJsonPath, "utf-8"));
|
|
245
|
+
if (pkgJsonData.publishConfig?.directory) return path.resolve(dir, pkgJsonData.publishConfig.directory);
|
|
246
|
+
} catch {}
|
|
247
|
+
return dir;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
//#endregion
|
|
251
|
+
export { getPackDirectory, pack, packAsJson, packAsList, unpack };
|