UNPKG

vlt

Version:
119 lines (116 loc) 3.04 kB
var global = globalThis; import {Buffer} from "node:buffer"; import {setTimeout,clearTimeout,setImmediate,clearImmediate,setInterval,clearInterval} from "node:timers"; import {createRequire as _vlt_createRequire} from "node:module"; var require = _vlt_createRequire(import.meta.filename); import { packTarball } from "./chunk-3UQTYLWM.js"; import { run } from "./chunk-XZF5GYDF.js"; import "./chunk-SLTPNBLH.js"; import "./chunk-YWPMIBJS.js"; import "./chunk-SGEQHKFC.js"; import { prettyBytes } from "./chunk-57IH4XFG.js"; import { commandUsage } from "./chunk-2Y5QRO5N.js"; import "./chunk-6YRWYWZQ.js"; import "./chunk-TJHWNOOA.js"; import "./chunk-264UXZEG.js"; import "./chunk-X4RDKJKD.js"; import "./chunk-BNCOU5ZT.js"; import "./chunk-RV3EHS4P.js"; import "./chunk-AECDW3EJ.js"; // ../../src/cli-sdk/src/commands/pack.ts import { writeFile } from "node:fs/promises"; import { dirname, join } from "node:path"; import assert from "node:assert"; var usage = () => commandUsage({ command: "pack", usage: "", description: `Create a tarball from a package in the current directory or specified folder. The tarball will be saved to the current directory with the name <name>-<version>.tgz.`, options: { "dry-run": { description: "Show what would be packed without creating a tarball" } } }); var views = { human: (r) => { const lines = [ `\u{1F4E6} Package: ${r.id}`, `\u{1F4C4} File: ${r.filename}`, `\u{1F4C1} ${r.files.length} Files`, ...r.files.map((f) => ` - ${f}`), `\u{1F4CA} Package Size: ${prettyBytes(r.size)}`, `\u{1F4C2} Unpacked Size: ${prettyBytes(r.unpackedSize)}` ]; if (r.shasum) lines.push(`\u{1F512} Shasum: ${r.shasum}`); if (r.integrity) lines.push(`\u{1F510} Integrity: ${r.integrity}`); return lines.join("\n"); }, json: (r) => r }; var command = async (conf) => { const manifestPath = conf.options.packageJson.find(); assert(manifestPath, "No package.json found"); const manifestDir = dirname(manifestPath); const manifest = conf.options.packageJson.read(manifestDir); const isDryRun = conf.options["dry-run"]; const runOptions = { cwd: manifestDir, projectRoot: conf.projectRoot, packageJson: conf.options.packageJson, manifest, ignoreMissing: true, ignorePrePost: true }; await run({ ...runOptions, arg0: "prepack" }); await run({ ...runOptions, arg0: "prepare" }); const { name, version, filename, tarballData, unpackedSize, files, integrity, shasum } = await packTarball(manifest, manifestDir, conf); if (!isDryRun) { await writeFile(join(manifestDir, filename), tarballData); } await run({ ...runOptions, arg0: "postpack" }); return { id: `${name}@${version}`, name, version, filename, files, size: tarballData.length, unpackedSize, shasum, integrity }; }; export { command, usage, views }; //# sourceMappingURL=pack-BARZXALT.js.map