CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-lerna--log-packed

Log the result of npm pack --json with formatted tarball details and contents

Pending
Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

SecuritybySnyk

Pending

The risk profile of this skill

Overview
Eval results
Files

index.mddocs/

@lerna/log-packed

@lerna/log-packed is a Node.js utility that formats and displays the JSON output from npm pack --json in a human-readable format. It presents tarball information including file listings with sizes, bundled dependencies, and comprehensive package details using formatted columns and Unicode emojis when supported.

Package Information

  • Package Name: @lerna/log-packed
  • Package Type: npm
  • Language: JavaScript
  • Installation: npm install @lerna/log-packed
  • Node.js Support: ^14.15.0 || >=16.0.0

Core Imports

const { logPacked } = require("@lerna/log-packed");

For ES modules (requires bundler or loader):

import { logPacked } from "@lerna/log-packed";

Basic Usage

const execa = require("execa");
const { logPacked } = require("@lerna/log-packed");

// Get npm pack output and format it
execa("npm", ["pack", "--json"]).then(result => {
  const tarballs = JSON.parse(result.stdout);
  tarballs.forEach(logPacked);
});

Capabilities

Package Logging

Formats and logs npm pack JSON output to console with structured, human-readable information.

/**
 * Logs formatted npm pack JSON result with tarball details, file contents, and bundled dependencies
 * @param {TarballInfo} tarball - Tarball object from npm pack --json output
 */
function logPacked(tarball);

Usage Examples:

const { logPacked } = require("@lerna/log-packed");

// Complete tarball info
logPacked({
  name: "my-package",
  version: "1.0.0",
  size: 223,
  unpackedSize: 396,
  shasum: "8f339308bfabffcddd89e379ab76c8fbbc5c429a",
  integrity: "sha512-s+D+5+Kovk2mi2Jg+P6egJ6ZBKzMOdRaWAL5S+a4dWnRa6taym9EeEwpwx5ASF1wbLb0Tduv2XqcwFATxxUGVw==",
  filename: "my-package-1.0.0.tgz",
  files: [
    { path: "package.json", size: 396, mode: 420 },
    { path: "index.js", size: 1024, mode: 420 }
  ],
  entryCount: 2,
  bundled: ["dependency1", "dependency2"]
});

// Minimal tarball info (gracefully handles missing fields)
logPacked({
  name: "simple-package",
  version: "2.0.0",
  filename: "simple-package-2.0.0.tgz"
});

The function outputs structured information in up to four sections:

  1. Package Header: Package name and version with emoji (📦) if Unicode is supported
  2. Tarball Contents: File listings with sizes (if files present)
  3. Bundled Dependencies: List of bundled dependency names (if present)
  4. Tarball Details: Comprehensive package metadata in formatted columns

Types

/**
 * Tarball information object from npm pack --json output
 */
interface TarballInfo {
  /** Package name (required) */
  name: string;
  /** Package version (required) */
  version: string;
  /** Array of file objects with path and size properties */
  files?: FileInfo[];
  /** Array of bundled dependency names */
  bundled?: string[];
  /** Tarball filename */
  filename?: string;
  /** Package size in bytes */
  size?: number;
  /** Unpacked size in bytes */
  unpackedSize?: number;
  /** SHA sum hash */
  shasum?: string;
  /** Integrity hash */
  integrity?: string;
  /** Total number of entries in tarball */
  entryCount?: number;
}

/**
 * File information within a tarball
 */
interface FileInfo {
  /** File path within the package */
  path: string;
  /** File size in bytes */
  size: number;
  /** File mode/permissions */
  mode?: number;
}

Dependencies

The package uses the following external libraries:

  • byte-size (^7.0.0): For formatting file sizes into human-readable format
  • columnify (^1.6.0): For creating formatted columns in console output
  • has-unicode (^2.0.1): For detecting Unicode support to show emoji decorations
  • npmlog (^6.0.2): For structured logging output to console

Error Handling

The logPacked function is designed to handle incomplete tarball objects gracefully:

  • Missing optional fields are safely ignored using conditional checks
  • No explicit error throwing for malformed input
  • Continues execution even with minimal required fields (name, version)

Output Format

The function produces structured console output with:

  1. Package Header: 📦 package-name@version (or package: package-name@version without Unicode)
  2. Tarball Contents Section: File listings with byte-formatted sizes (if files array present)
  3. Bundled Dependencies Section: List of dependency names (if bundled array present)
  4. Tarball Details Section: Key-value pairs in formatted columns showing package metadata

Example output:

📦 my-package@1.0.0
=== Tarball Contents ===
396B package.json
1kB  index.js
=== Bundled Dependencies ===
dependency1
dependency2
=== Tarball Details ===
name:          my-package
version:       1.0.0
filename:      my-package-1.0.0.tgz
package size:  223 B
unpacked size: 396 B
shasum:        8f339308bfabffcddd89e379ab76c8fbbc5c429a
integrity:     sha512-s+d+5+kovk2mi[...]XqcwFATxxUGVw==
bundled deps:  2
bundled files: 0
own files:     2
total files:   2

docs

index.md

tile.json