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

p4client-ts

v0.3.1

Published

Typed TypeScript helpers for the Perforce p4 CLI

Readme

p4-ts

Typed TypeScript helpers for the Perforce p4 CLI.

The published package name is p4client-ts.

  • Run p4 with a testable client abstraction
  • Parse classic tagged output and newline-delimited JSON
  • Query current Perforce environment with sensible fallbacks
  • List and filter workspaces that are relevant to the local machine
  • Provide preview-first Perforce helpers with opt-in mutating sync support
  • Optional Effect-based service API

Scope

This package is intended for inspection, preview-oriented workflows, and explicit sync() operations.

In scope:

  • Inspect current environment and workspace state
  • List relevant workspaces for the current machine
  • Inspect pending changelists and opened files
  • Preview reconcile operations
  • Preview sync operations and apply sync when explicitly requested
  • Read file metadata and depot/local path mappings

Out of scope:

  • submit
  • shelve or unshelve
  • edit, add, delete, or other checkout/open-for-edit commands
  • revert, lock, unlock, move, integrate, or resolve
  • Changelist creation or mutation
  • Client or stream spec mutation
  • Server administration or other server-mutating workflows

Install

npm install p4client-ts

Quick Start

import { P4Client } from "p4client-ts";

const p4 = new P4Client();

const environment = await p4.getEnvironment();
const workspaces = await p4.listWorkspaces();
const pending = await p4.listPendingChangelists();
const opened = await p4.getOpenedFiles({ change: "default" });
const reconcilePreview = await p4.previewReconcile({
  fileSpec: "C:/work/project/..."
});
const syncPreview = await p4.previewSync({
  fileSpec: "//Project/main/..."
});

if (syncPreview.totalCount > 0) {
  const syncResult = await p4.sync({
    fileSpec: "//Project/main/..."
  });
}

const reconcileOperation = p4.watchPreviewReconcile({
  fileSpec: "C:/work/project/..."
});

for await (const event of reconcileOperation.events) {
  if (event.type === "progress") {
    console.log(event.rawLine);
  }
}

const reconcileWithProgress = await reconcileOperation.result;

Documentation

This repository includes a Starlight docs app in ../www with authored guides and generated API docs powered by TypeDoc.

Run the docs site locally from the repo root:

bun run docs:dev

Build the static docs site:

bun run docs:build

Reconcile Progress

previewReconcile() remains the simple buffered API. Use watchPreviewReconcile() when you need incremental progress while still awaiting the final structured reconcile result.

Progress output is best-effort:

  • Perforce progress lines are version-dependent and not treated as a stable schema.
  • The final structured reconcile preview remains the source of truth.
  • When -I progress is unsupported, the watcher retries once without -I and emits a progress-unavailable event.
  • When Perforce completes without any progress lines, the watcher emits progress-unavailable with reason not-emitted.

Effect Service API

For Effect-based codebases, createP4Service returns the same operations as P4Client wrapped in Effect:

import { Effect, Stream } from "effect";
import { createP4Service } from "p4client-ts";

const p4 = createP4Service();

const environment = await Effect.runPromise(p4.getP4Environment());
const workspaces = await Effect.runPromise(p4.listP4Workspaces());
const opened = await Effect.runPromise(p4.getOpenedFiles({ change: "default" }));
const reconcilePreview = await Effect.runPromise(p4.previewReconcile());
const reconcileEvents = await Effect.runPromise(
  p4.streamPreviewReconcile().pipe(Stream.runCollect)
);
const syncPreview = await Effect.runPromise(p4.previewSync({ fileSpec: "//Project/main/..." }));

if (syncPreview.totalCount > 0) {
  await Effect.runPromise(p4.sync({ fileSpec: "//Project/main/..." }));
}

Development

bun install
bun run typecheck
bun run test
bun run test:e2e
bun run build
bun run docs:build

End-to-End Tests

The e2e suite targets a pre-provisioned Perforce fixture workspace seeded from @p4-ts/test-stream.

  • The suite is manual opt-in and skipped unless P4_TS_E2E=1.
  • The harness validates the configured fixture target; it does not provision streams, clients, or submit seed content.
  • Scenario setup may use local p4 edit/add/delete, numbered changelists, sync, and revert, with cleanup returning the workspace to baseline.

Required env vars:

P4_TS_E2E=1
P4_TS_E2E_WORKSPACE_ROOT=/absolute/path/to/workspace
P4_TS_E2E_CLIENT=p4ts_e2e_main
P4_TS_E2E_STREAM=//p4ts/main

Optional env vars:

P4_TS_E2E_USER=p4ts-e2e
P4_TS_E2E_HOST=build-host
P4_TS_E2E_P4PORT=ssl:perforce.example.com:1666
P4_TS_E2E_P4CONFIG=.p4config
P4_TS_E2E_ALLOW_OPENED_SCENARIOS=1
P4_TS_E2E_ALLOW_SYNC_PREVIEW=1

External prerequisite checklist:

  1. Create a dedicated stream matching packages/test-stream/stream-manifest.json.
  2. Create a dedicated client/workspace for that stream.
  3. Seed and submit the contents of packages/test-stream/seed outside the test harness.
  4. Optionally prepare a behind-head workspace state for sync-preview coverage.