npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@kube-hive/oci-artifact

v0.0.0

Published

Build valid OCI images from a directory — pure JS, zero runtime dependencies

Downloads

93

Readme

@kube-hive/oci-artifact

Build valid OCI images from a directory. Pure JS, zero runtime dependencies.

The produced images conform to the OCI Image Spec and can be pushed to any OCI-compliant registry and mounted as volumes in Kubernetes via Image Volumes.

Install

npm install @kube-hive/oci-artifact

CLI

oci-artifact <input-dir> <output.tar>

The output is an OCI archive tar that can be pushed with skopeo:

oci-artifact ./my-files ./image.tar
skopeo copy oci-archive:./image.tar docker://registry.example.com/my-image:latest

Library

Quick start

import { buildOCILayout, buildOCIArchive } from '@kube-hive/oci-artifact';

// Write an OCI image layout directory (for use with `skopeo copy oci:./output ...`)
await buildOCILayout({
  inputDir: './my-files',
  outputDir: './oci-output',
});

// Or build an in-memory OCI archive tar
import { writeFile } from 'node:fs/promises';

const archive = await buildOCIArchive({ inputDir: './my-files' });
await writeFile('image.tar', archive);

Options

await buildOCILayout({
  inputDir: './my-files',    // Directory to pack into the image layer
  outputDir: './oci-output', // Where to write the OCI layout
  architecture: 'arm64',     // Default: 'amd64'
  os: 'linux',               // Default: 'linux'
  reproducible: true,        // Default: true — deterministic tar (mtime=0, uid/gid=0)
  annotations: {             // Optional OCI annotations on the manifest
    'org.opencontainers.image.title': 'my-artifact',
  },
});

Lower-level API

Each step in the pipeline is independently accessible:

import {
  collectEntries,
  createTarArchive,
  createLayer,
  createImageConfig,
  createManifest,
  createIndex,
  computeDigest,
} from '@kube-hive/oci-artifact';

// 1. Collect files from a directory
const entries = await collectEntries('./my-files');

// 2. Create an OCI layer (tar + gzip + digest pair)
const layer = await createLayer(entries);
// layer.diffId       — sha256 of uncompressed tar (goes in config.rootfs.diff_ids)
// layer.descriptor   — descriptor with sha256 of compressed blob (goes in manifest.layers)

// 3. Build config, manifest, index
const config = createImageConfig({ diffIds: [layer.diffId] });
const manifest = createManifest({ config: config.descriptor, layers: [layer.descriptor] });
const index = createIndex({ manifests: [manifest.descriptor] });

// 4. Or create a tar archive directly
const tar = createTarArchive([
  { type: 'directory', name: 'etc' },
  { type: 'file', name: 'etc/config.yaml', data: new TextEncoder().encode('key: value') },
]);

How it works

The library implements a POSIX ustar tar writer from scratch using only Node.js builtins (crypto, zlib, fs). The OCI image is built as:

input directory
  -> tar archive (POSIX ustar, reproducible)
    -> gzip compress
      -> layer blob (manifest references compressed digest)
      -> diffId (config references uncompressed digest)
        -> image config JSON
          -> image manifest JSON
            -> image index JSON
              -> OCI layout directory or archive tar

The critical invariant for Kubernetes compatibility: config.rootfs.diff_ids[i] is the SHA-256 of the uncompressed layer tar, while manifest.layers[i].digest is the SHA-256 of the compressed blob. A mismatch causes containerd to reject the image with "mismatched image rootfs and manifest layers".

License

Apache-2.0