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

@adobe/spectrum-diff-core

v1.1.1

Published

Shared core library for Spectrum diff generation tools (tokens, component schemas, etc.)

Readme

Spectrum Diff Core

Shared core library for Spectrum diff generation tools (tokens, component schemas, etc.).

Overview

This package provides the foundational components for creating consistent diff tools across the Spectrum ecosystem. It includes:

  • Core utilities: File import/export, diff operations, type checking
  • CLI framework: Base CLI structure with consistent option handling
  • Template system: Handlebars-based formatting with shared helpers
  • Output handling: File output and console formatting

Installation

pnpm add @adobe/spectrum-diff-core

Usage

Creating a Diff Tool

import { BaseCLI, FileLoader, detailedDiff } from "@adobe/spectrum-diff-core";

class MyDiffTool extends BaseCLI {
  constructor() {
    super({
      toolName: "mydiff",
      dataType: "mydata",
      packagePath: "packages/mydata/src",
      manifestFile: "manifest.json",
    });
  }

  async generateDiff(original, updated) {
    const changes = detailedDiff(original, updated);
    // Add your specific change detection logic here
    return this.processChanges(changes);
  }
}

Using File Loading

import { FileLoader } from "@adobe/spectrum-diff-core";

const loader = new FileLoader();

// Load from remote repository
const remoteData = await loader.loadRemoteFiles(
  ["file1.json", "file2.json"],
  "v1.0.0",
  null,
  "owner/repo",
  "api-key",
  "packages/data/src",
);

// Load from local filesystem
const localData = await loader.loadLocalFiles("packages/data/src", [
  "file1.json",
  "file2.json",
]);

Using Templates

import { HandlebarsFormatter } from "@adobe/spectrum-diff-core";

const formatter = new HandlebarsFormatter({
  template: "cli",
  dataType: "tokens",
});

const output = await formatter.format(diffResult, options);

CLI Framework

The BaseCLI class provides a consistent CLI structure:

mydiff report --old-version v1.0.0 --new-version v1.1.0 --format markdown --output report.md

Common CLI Options:

  • --old-[type]-version / --new-[type]-version (version comparison)
  • --old-[type]-branch / --new-[type]-branch (branch comparison)
  • --local (local file comparison)
  • --format (cli, markdown, handlebars)
  • --template (built-in template names)
  • --output (file output)
  • --debug (debug output)

Template System

Templates are organized by data type:

templates/
├── base/           # Shared templates
│   ├── cli.hbs
│   ├── markdown.hbs
│   └── json.hbs
├── tokens/         # Token-specific templates
└── schemas/        # Schema-specific templates

Available Helpers

  • {{hasKeys obj}} - Check if object has properties
  • {{totalItems result}} - Calculate total number of changes
  • {{capitalize str}} - Capitalize string
  • {{cleanPath path}} - Clean up property paths
  • {{formatDate date}} - Format timestamps
  • {{hilite}}, {{error}}, {{passing}} - Terminal colors
  • {{bold}}, {{dim}}, {{emphasis}} - Text formatting

API Reference

Core

  • detailedDiff(original, updated) - Generate detailed diff
  • isObject(obj), isString(str), etc. - Type checking utilities
  • deepClone(obj) - Deep clone objects
  • getNestedProperty(obj, path) - Safe property access

File Import

  • FileLoader - Main file loading orchestrator
  • RemoteFileFetcher - Handle remote repository fetching
  • LocalFileSystem - Handle local file operations

CLI

  • BaseCLI - Base class for creating CLI tools
  • normalizeOptions(options) - Normalize CLI options
  • determineStrategy(options) - Determine loading strategy

Formatters

  • HandlebarsFormatter - Template-based formatting
  • storeOutput(content, path) - File output utility

Development

# Install dependencies
pnpm install

# Run tests
pnpm test

# Lint code
pnpm lint

# Fix linting issues
pnpm lint:fix

License

Apache-2.0