@nx/js
Version:
74 lines (73 loc) • 3.02 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.logTar = void 0;
const tslib_1 = require("tslib");
// Adapted from https://github.com/npm/cli/blob/c736b622b8504b07f5a19f631ade42dd40063269/lib/utils/tar.js
const chalk_1 = tslib_1.__importDefault(require("chalk"));
const columnify_1 = tslib_1.__importDefault(require("columnify"));
const format_bytes_1 = require("./format-bytes");
const logTar = (tarball, opts = {}) => {
// @ts-ignore
const { unicode = true } = opts;
console.log('');
console.log(`${unicode ? '📦 ' : 'package:'} ${tarball.name}@${tarball.version}`);
console.log(chalk_1.default.magenta('=== Tarball Contents ==='));
if (tarball.files.length) {
console.log('');
const columnData = (0, columnify_1.default)(
// Sort for a stable listing: pnpm 11 orders files differently than
// npm and pnpm 10.
[...tarball.files]
.sort((a, b) => (a.path < b.path ? -1 : a.path > b.path ? 1 : 0))
.map((f) => {
const bytes = typeof f.size === 'number' ? (0, format_bytes_1.formatBytes)(f.size, false) : '';
return /^node_modules\//.test(f.path)
? null
: { path: f.path, size: `${bytes}` };
})
.filter((f) => f), {
include: ['size', 'path'],
showHeaders: false,
});
columnData.split('\n').forEach((line) => {
console.log(line);
});
}
if (tarball.bundled.length) {
console.log(chalk_1.default.magenta('=== Bundled Dependencies ==='));
tarball.bundled.forEach((name) => console.log('', name));
}
console.log(chalk_1.default.magenta('=== Tarball Details ==='));
console.log((0, columnify_1.default)([
{ name: 'name:', value: tarball.name },
{ name: 'version:', value: tarball.version },
tarball.filename && { name: 'filename:', value: tarball.filename },
{ name: 'package size:', value: (0, format_bytes_1.formatBytes)(tarball.size) },
{ name: 'unpacked size:', value: (0, format_bytes_1.formatBytes)(tarball.unpackedSize) },
{ name: 'shasum:', value: tarball.shasum },
{
name: 'integrity:',
value: tarball.integrity.toString().slice(0, 20) +
'[...]' +
tarball.integrity.toString().slice(80),
},
tarball.bundled.length && {
name: 'bundled deps:',
value: tarball.bundled.length,
},
tarball.bundled.length && {
name: 'bundled files:',
value: tarball.entryCount - tarball.files.length,
},
tarball.bundled.length && {
name: 'own files:',
value: tarball.files.length,
},
{ name: 'total files:', value: tarball.entryCount },
].filter((x) => x), {
include: ['name', 'value'],
showHeaders: false,
}));
console.log('', '');
};
exports.logTar = logTar;