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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@packlet/gpr

v0.2.2

Published

A lightweight utility for preparing package variants compatible with GitHub Packages (GPR). It focuses on deterministic, local, and CI-friendly workflows

Downloads

48

Readme

📦️ @packlet/gpr

TypeScript Bun NodeJS license

Lightweight tooling for preparing packages for distribution through GitHub Packages (GPR).

@packlet/gpr streamlines the creation of GPR-compatible package variants by generating deterministic staging directories and .tgz artifacts suitable for CI environments. It focuses on predictable behavior, minimal configuration, and compatibility with both standalone usage and the broader packlet toolchain.

This utility produces ready-to-publish artifacts but does not perform publishing. Publishing should be handled explicitly in your CI or release workflow.

Features

  • Generates a staged package in a dedicated directory (default: .gpr/).
  • Applies a scoped package name suitable for GitHub Packages.
  • Copies compiled output from dist/ into the staging area.
  • Optionally includes README.md and LICENSE.
  • Produces reproducible .tgz artifacts (default: .artifacts/).
  • Provides deterministic rules for deriving GPR package names.
  • Supports both CLI and programmatic usage.

Installation

# npm
npm install -D @packlet/gpr

# pnpm
pnpm add -D @packlet/gpr

# bun
bun add -D @packlet/gpr

CLI Usage

If you use the packlet CLI:

packlet gpr [options]

Or invoke directly via an npm script:

{
  "scripts": {
    "gpr": "node -e \"require('@packlet/gpr').awakenGpr({ rootDir: '.' })\""
  }
}

CLI Options

| Option | Description | Default | | -------------------- | --------------------------------- | ---------------------------------- | | --root <path> | Project root directory | Current directory | | --gpr-dir <path> | Staging directory | .gpr | | --artifacts <path> | Output directory for .tgz files | .artifacts | | --dist <path> | Build directory | dist | | --scope <scope> | Package scope | GPR_SCOPE or nazahex | | --registry <url> | Registry URL | GPR_REGISTRY or GitHub Packages | | --name <name> | Override staged package name | From packlet.gprName if provided | | --include-readme | Include README.md | true | | --include-license | Include LICENSE | true | | --json | Print artifact manifest to stdout | false | | --manifest <file> | Write artifact manifest to a file | — |

Output Structure

  • Staging directory: .gpr/ Contains the staged package.json, dist/, and optional documentation files.

  • Artifact directory: .artifacts/ Contains generated .tgz files for the staged package.

Environment Variables

| Variable | Description | Example | | --------------------- | --------------------- | ----------------------------- | | GPR_SCOPE | Default package scope | acme | | GPR_REGISTRY | Registry URL | https://npm.pkg.github.com/ | | GPR_INCLUDE_README | Include README.md | true | | GPR_INCLUDE_LICENSE | Include LICENSE | true | | GPR_NAME | Override package name | @acme/pkg |

Directory-related variables supported by @packlet/core are also recognized: PACKLET_DIST_DIR, PACKLET_ARTIFACTS_DIR, PACKLET_GPR_DIR.

Package.json Configuration

@packlet/gpr can be configured through a packlet block:

{
  "packlet": {
    "gpr": true,
    "gprName": "packlet-core"
  }
}

Rules:

  • Unscoped gprName values are automatically scoped using --scope or GPR_SCOPE.
  • Fully scoped names are used as-is.
  • Invalid values are ignored with a warning.

Precedence: CLI flags > Environment variables > package.json.packlet > defaults.

Programmatic API

import { awakenGpr } from "@packlet/gpr"

const result = awakenGpr({
  rootDir: "/path/to/project",
  scope: "acme",
  includeReadme: true
})

console.log(result.scopedName)
console.log(result.version)
console.log(result.gprDir)
console.log(result.artifactsDir)

Options

interface AwakenGprOptions {
  rootDir?: string
  gprDir?: string
  artifactsDir?: string
  distDir?: string
  scope?: string
  registry?: string
  nameOverride?: string
}

Naming Behavior

@packlet/gpr derives a valid GPR package name using the following priority:

  1. Explicit overrides

    • CLI --name
    • GPR_NAME
    • packlet.gprName
  2. Project metadata package.json.name, with any existing scope removed.

  3. Scope application If the selected name is unscoped, the configured scope is applied:

    @<scope>/<name>

CI Example (GitHub Actions)

name: Build and Pack

on:
  push:
    branches: [main]

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: 18

      - name: Install dependencies
        run: bun install

      - name: Build
        run: bun run build

      - name: Prepare GPR package
        run: npx packlet gpr --root . --scope your-org

      - name: Upload artifacts
        uses: actions/upload-artifact@v4
        with:
          name: gpr-artifacts
          path: .artifacts

Publishing

Publishing should occur in a separate step using a token with packages:write permission:

npm publish <artifact.tgz> --registry https://npm.pkg.github.com/

Troubleshooting

  • dist/ missing Ensure a build has been performed.

  • Artifacts not generated Review the output of npm pack for naming issues.

  • Unexpected package name Override via --name or GPR_NAME.

  • Manifest not found in CI Use --json or --manifest <file> to emit the artifact manifest.

License

MIT © KazViz