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

@revealui/setup

v0.2.0

Published

Setup utilities for RevealUI projects - environment, database, and configuration management

Readme

@revealui/setup

Shared setup utilities for RevealUI projects. Provides environment variable management, database initialization, and configuration validation.

Features

  • Environment Setup - Interactive and automated environment variable configuration
  • Secret Generation - Cryptographically secure secret and password generation
  • Validation - Type-safe validation for environment variables
  • Logging - Consistent, colored console output with log levels
  • Reusable - Used by both @revealui/cli and setup scripts

Installation

pnpm add @revealui/setup

Usage

Environment Setup

import { setupEnvironment } from '@revealui/setup/environment'

// Interactive setup with prompts
const result = await setupEnvironment({
  projectRoot: '/path/to/project',
  interactive: true
})

if (result.success) {
  console.log('Environment configured!')
} else {
  console.log('Missing variables:', result.missing)
}

Generate Secrets

import { generateSecret, generatePassword } from '@revealui/setup/environment'

const jwtSecret = generateSecret(32)    // 64-char hex string
const password = generatePassword(16)    // 16-char alphanumeric + special

Validate Environment

import { validateEnv, REQUIRED_ENV_VARS } from '@revealui/setup/validators'

const validation = validateEnv(REQUIRED_ENV_VARS, process.env)

if (!validation.valid) {
  console.log('Missing:', validation.missing)
  console.log('Invalid:', validation.invalid)
}

Logging

import { createLogger } from '@revealui/setup/utils'

const logger = createLogger({
  prefix: 'MyScript',
  level: 'info',
  timestamps: true
})

logger.info('Starting process')
logger.success('Completed!')
logger.error('Failed')
logger.header('Section Title')
logger.divider()
logger.progress(50, 100, 'Processing')

API Reference

Environment

setupEnvironment(options)

Sets up environment variables for a project.

Options:

  • projectRoot: string - Project root directory
  • templatePath?: string - Path to .env.template (default: {projectRoot}/.env.template)
  • outputPath?: string - Output path (default: {projectRoot}/.env.development.local)
  • force?: boolean - Overwrite existing file without prompting
  • generateOnly?: boolean - Only generate secrets, skip prompts
  • interactive?: boolean - Enable interactive prompts (default: true)
  • customVariables?: EnvVariable[] - Custom variable definitions
  • logger?: Logger - Custom logger instance

Returns: Promise<SetupEnvironmentResult>

  • success: boolean - Whether setup completed successfully
  • envPath: string - Path to generated env file
  • missing: string[] - Variables still missing
  • invalid: string[] - Variables with invalid values

generateSecret(length?: number)

Generates cryptographically secure hex string.

generatePassword(length?: number)

Generates random password with alphanumeric + special characters.

updateEnvValue(content, key, value)

Updates or adds an environment variable in file content.

parseEnvContent(content)

Parses environment file content into key-value object.

Validators

validateEnv(required, env)

Validates environment variables against schema.

Parameters:

  • required: EnvVariable[] - Required variable definitions
  • env: Record<string, string> - Environment to validate

Returns: ValidationResult

  • valid: boolean
  • missing: string[]
  • invalid: string[]

validators

Pre-built validators:

  • postgresUrl - PostgreSQL connection string
  • stripeSecretKey - Stripe secret key format
  • stripePublishableKey - Stripe publishable key format
  • url - Valid URL format
  • email - Valid email format
  • minLength(n) - Minimum string length

REQUIRED_ENV_VARS

Default required environment variables for RevealUI:

  • REVEALUI_SECRET - JWT secret (min 32 chars)
  • POSTGRES_URL - Database connection string
  • BLOB_READ_WRITE_TOKEN - Vercel Blob token
  • STRIPE_SECRET_KEY - Stripe secret key
  • NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY - Stripe publishable key

OPTIONAL_ENV_VARS

Optional environment variables (Supabase, Sentry, admin config, etc.)

Utilities

createLogger(options)

Creates a logger instance with configurable options.

Options:

  • level?: 'debug' | 'info' | 'warn' | 'error' | 'silent'
  • prefix?: string - Prefix for all log messages
  • colors?: boolean - Enable colors (auto-detected by default)
  • timestamps?: boolean - Include timestamps

Methods:

  • debug(msg, ...args) - Debug message
  • info(msg, ...args) - Info message
  • warn(msg, ...args) - Warning message
  • error(msg, ...args) - Error message
  • success(msg, ...args) - Success message
  • header(msg) - Formatted header
  • divider() - Visual divider
  • table(data) - Console table
  • group(label) - Start group
  • groupEnd() - End group
  • progress(current, total, label?) - Progress bar

Examples

Complete Setup Flow

import { setupEnvironment, createLogger } from '@revealui/setup'

const logger = createLogger({ prefix: 'Setup' })

logger.header('Project Setup')

const result = await setupEnvironment({
  projectRoot: process.cwd(),
  interactive: true,
  logger
})

if (result.success) {
  logger.success('Environment configured successfully!')
  logger.info(`Config file: ${result.envPath}`)
} else {
  logger.error('Setup failed')
  logger.info('Missing variables:', result.missing.join(', '))
}

Non-Interactive Setup

import { setupEnvironment } from '@revealui/setup'

// Generate secrets only, no prompts
const result = await setupEnvironment({
  projectRoot: '/path/to/project',
  interactive: false,
  generateOnly: true
})

Custom Validation

import { validateEnv, validators, type EnvVariable } from '@revealui/setup/validators'

const customVars: EnvVariable[] = [
  {
    name: 'API_KEY',
    description: 'Third-party API key',
    required: true,
    validator: validators.minLength(20)
  },
  {
    name: 'WEBHOOK_URL',
    description: 'Webhook endpoint',
    required: true,
    validator: validators.url
  }
]

const validation = validateEnv(customVars, process.env)

Package Exports

// Main export
import { setupEnvironment, createLogger } from '@revealui/setup'

// Subpath exports
import { setupEnvironment } from '@revealui/setup/environment'
import { validateEnv } from '@revealui/setup/validators'
import { createLogger } from '@revealui/setup/utils'

Integration

In @revealui/cli

import { setupEnvironment, createLogger } from '@revealui/setup'

const logger = createLogger({ prefix: '@revealui/cli' })

await setupEnvironment({
  projectRoot: projectPath,
  interactive: true,
  logger
})

In Setup Scripts

#!/usr/bin/env tsx
import { setupEnvironment } from '@revealui/setup'

await setupEnvironment({
  projectRoot: process.cwd(),
  force: process.argv.includes('--force')
})

Development

# Build package
pnpm build

# Watch mode
pnpm dev

# Type check
pnpm typecheck

# Run tests
pnpm test

# Coverage
pnpm test:coverage

License

MIT