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

@uepm/core

v1.0.5

Published

Core utilities for UEPM - shared code for UProject and package.json management

Downloads

1,012

Readme

@uepm/core

Shared utilities for UProject and package.json management used by other UEPM packages.

Installation

This package is typically installed as a dependency of other UEPM packages. You can also install it directly if you need the utilities:

npm install @uepm/core

Usage

UProject Management

import { UProjectManager } from '@uepm/core';

const manager = new UProjectManager();

// Find .uproject file in directory
const projectPath = await manager.findProjectFile('/path/to/project');

// Read and parse .uproject file
const project = await manager.readProject(projectPath);

// Add plugin directory
const updated = manager.addPluginDirectory(project, 'node_modules');

// Write back to file (preserves formatting)
await manager.writeProject(projectPath, updated);

// Check if directory already exists
const hasNodeModules = manager.hasPluginDirectory(project, 'node_modules');

Package.json Management

import { PackageJsonManager } from '@uepm/core';

const manager = new PackageJsonManager();

// Check if package.json exists
const exists = await manager.exists('/path/to/project');

// Create new package.json with UEPM configuration
await manager.create('/path/to/project', 'MyProject');

// Read existing package.json
const packageJson = await manager.read('/path/to/project');

// Write package.json
await manager.write('/path/to/project', packageJson);

Error Handling

import { UEPMError, formatErrorMessage } from '@uepm/core';

try {
  // Some UEPM operation
} catch (error) {
  if (error instanceof UEPMError) {
    const formatted = formatErrorMessage(error.toErrorMessage());
    console.error(formatted);
    process.exit(error.exitCode);
  }
  throw error;
}

API Reference

UProjectManager

Methods

findProjectFile(directory: string): Promise<string>

Finds the first .uproject file in the specified directory.

Parameters:

  • directory - Directory to search in

Returns: Path to the .uproject file

Throws: UEPMError if no .uproject file found

readProject(filePath: string): Promise<UProjectFile>

Reads and parses a .uproject file.

Parameters:

  • filePath - Path to the .uproject file

Returns: Parsed UProject object

Throws: UEPMError if file cannot be read or parsed

writeProject(filePath: string, project: UProjectFile): Promise<void>

Writes a UProject object to file, preserving original formatting.

Parameters:

  • filePath - Path to write to
  • project - UProject object to write

Throws: UEPMError if file cannot be written

addPluginDirectory(project: UProjectFile, directory: string): UProjectFile

Adds a directory to the AdditionalPluginDirectories array.

Parameters:

  • project - UProject object to modify
  • directory - Directory to add

Returns: Modified UProject object (does not mutate original)

hasPluginDirectory(project: UProjectFile, directory: string): boolean

Checks if a directory exists in AdditionalPluginDirectories.

Parameters:

  • project - UProject object to check
  • directory - Directory to look for

Returns: True if directory exists

PackageJsonManager

Methods

exists(directory: string): Promise<boolean>

Checks if package.json exists in the directory.

Parameters:

  • directory - Directory to check

Returns: True if package.json exists

create(directory: string, projectName: string): Promise<void>

Creates a new package.json with UEPM configuration.

Parameters:

  • directory - Directory to create package.json in
  • projectName - Name for the project

Throws: UEPMError if file cannot be created

read(directory: string): Promise<PackageJson>

Reads and parses package.json from directory.

Parameters:

  • directory - Directory containing package.json

Returns: Parsed PackageJson object

Throws: UEPMError if file cannot be read or parsed

write(directory: string, packageJson: PackageJson): Promise<void>

Writes PackageJson object to file.

Parameters:

  • directory - Directory to write to
  • packageJson - PackageJson object to write

Throws: UEPMError if file cannot be written

Type Definitions

UProjectFile

interface UProjectFile {
  FileVersion?: number;
  EngineAssociation?: string;
  Category?: string;
  Description?: string;
  Modules?: Module[];
  Plugins?: PluginReference[];
  AdditionalPluginDirectories?: string[];
  TargetPlatforms?: string[];
  [key: string]: any; // Allow additional fields
}

PackageJson

interface PackageJson {
  name?: string;
  version?: string;
  description?: string;
  main?: string;
  scripts?: Record<string, string>;
  dependencies?: Record<string, string>;
  devDependencies?: Record<string, string>;
  peerDependencies?: Record<string, string>;
  keywords?: string[];
  author?: string;
  license?: string;
  private?: boolean;
  [key: string]: any; // Allow additional fields
}

UEPMError

class UEPMError extends Error {
  code: string;
  exitCode: number;
  details?: string;
  suggestion?: string;
  
  constructor(
    message: string,
    code: string,
    exitCode: number = 1,
    details?: string,
    suggestion?: string
  );
  
  toErrorMessage(): ErrorMessage;
}

ErrorMessage

interface ErrorMessage {
  level: 'error' | 'warning' | 'info';
  code: string;
  message: string;
  details?: string;
  suggestion?: string;
}

Error Codes

The core package defines standard error codes used throughout UEPM:

| Code | Description | Exit Code | |------|-------------|-----------| | UPROJECT_NOT_FOUND | No .uproject file found | 3 | | UPROJECT_INVALID_JSON | Invalid JSON in .uproject | 4 | | UPROJECT_READ_ERROR | Cannot read .uproject file | 3 | | UPROJECT_WRITE_ERROR | Cannot write .uproject file | 3 | | PACKAGE_JSON_INVALID | Invalid package.json | 4 | | PACKAGE_JSON_READ_ERROR | Cannot read package.json | 3 | | PACKAGE_JSON_WRITE_ERROR | Cannot write package.json | 3 | | PERMISSION_DENIED | File permission error | 4 |

Validation

The core package includes validation utilities:

UProject Validation

import { validateUProject } from '@uepm/core';

const isValid = validateUProject(projectData);

Validates that a UProject object has:

  • Valid JSON structure
  • Recognized fields and types
  • Proper array structures for Modules, Plugins, etc.

Package.json Validation

import { validatePackageJson } from '@uepm/core';

const isValid = validatePackageJson(packageData);

Validates that a package.json object has:

  • Valid semver version strings
  • Proper dependency structures
  • Required fields for NPM packages

Testing Utilities

The core package provides test generators for property-based testing:

import { 
  uprojectArbitrary, 
  packageJsonArbitrary, 
  engineVersionArbitrary 
} from '@uepm/core/test-generators';

// Generate random valid UProject files
const uprojectGen = uprojectArbitrary();

// Generate random valid package.json files
const packageGen = packageJsonArbitrary();

// Generate random engine version strings
const versionGen = engineVersionArbitrary();

Requirements

  • Node.js >= 18.0.0
  • File system access for reading/writing project files

Related Packages

License

MIT