npm package: @scom/cli
Description: CLI for building and testing SCOM packages
Latest version: 0.1.14

# @scom/cli

Command line interface for building, testing, and developing Secure Compute (SCOM) packages and applications.

## Overview

The `@scom/cli` is a development toolkit that streamlines the creation, building, testing, and deployment of SCOM components and applications. It provides scaffolding, bundling, development servers, and testing capabilities in a unified command-line interface.

## Installation

### Global Installation (Recommended)

```bash
npm install -g @scom/cli
```

### Local Installation

```bash
npm install @scom/cli --save-dev
```

## Commands

### `init` - Project Initialization

Create new SCOM projects from templates:

```bash
# Create a new React TypeScript application
npx @scom/cli init app my-app
cd my-app

# Initialize in current directory
npx @scom/cli init app .

# Create a React widget
npx @scom/cli init widget my-widget
```

**Options:**
- `app <project-name>`: Creates a React TypeScript application
- `widget <widget-name>`: Creates a React widget component

### `bundle` - Build and Bundle

Bundle SCOM packages for production:

```bash
# Bundle the current project
npx @scom/cli bundle
```

Uses the integrated `@scom/bundler` to create optimized production builds with proper module resolution and dependency management.

### `serve` - Development Server

Start a development server for testing and previewing:

```bash
# Serve current directory
npx @scom/cli serve

# Serve specific directory
npx @scom/cli serve dist

# Serve with custom port
npx @scom/cli serve dist --port 8080

# Serve with assets mapping
npx @scom/cli serve examples --port 8080 --map /lib/amd-loader.js:./src/lib/amd-loader.js
```

**Features:**
- Live reloading during development
- Custom port configuration
- File mapping for development overrides
- Static file serving

### `dev` - Development Mode

Start development server with auto-rebuild capabilities:

```bash
# Start development mode
npx @scom/cli dev

# Custom port and host
npx @scom/cli dev --port 8080 --host localhost

# Auto-open browser
npx @scom/cli dev --open

# Silent mode (suppress output)
npx @scom/cli dev --silent
```

**Features:**
- Automatic rebuilding on file changes
- Hot module replacement
- Browser auto-opening
- Development optimizations

### `test` - Testing

Run tests using the integrated `@scom/test` framework:

```bash
# Run all tests in current directory
npx @scom/cli test

# Run tests in specific directory
npx @scom/cli test tests

# Run tests in custom directory
npx @scom/cli test my-test-folder
```

**Features:**
- Jest-compatible testing environment
- React component testing support
- TypeScript support
- Browser and Node.js test environments

### `publish` - Package Publishing

Publish packages to npm with automatic dependency resolution:

```bash
# Publish with default npm settings
npx @scom/cli publish

# Publish with specific npm tag
npx @scom/cli publish --tag beta

# Preview changes without publishing (dry-run)
npx @scom/cli publish --simulate
npx @scom/cli publish --dry-run
```

**Features:**
- Automatically replaces `file:` dependencies with actual versions
- Supports npm publish options and tags
- Dry-run mode for testing
- Automatic backup and restore of package.json

## Project Templates

### App Template

Creates a full React TypeScript application with:
- Modern React setup with TypeScript
- Development and production configurations
- Testing environment pre-configured
- SCOM component integration ready
- Build and deployment scripts

### Widget Template

Creates a reusable React widget component with:
- Component scaffolding
- TypeScript definitions
- Testing setup
- Build configuration for widget distribution
- Example usage and documentation

## Dependencies

The CLI integrates several SCOM tools:
- **@scom/bundler**: Advanced bundling and module resolution
- **@scom/serve**: Development server with live reloading
- **@scom/test**: Testing framework for components and applications
- **TypeScript**: Full TypeScript support
- **React**: React and ReactDOM for component development

## Usage Examples

### Creating a New Application

```bash
# Create and setup a new app
npx @scom/cli init app my-secure-app
cd my-secure-app

# Start development
npx @scom/cli dev --open

# Run tests
npx @scom/cli test

# Build for production
npx @scom/cli bundle
```

### Developing Components

```bash
# Create a widget
npx @scom/cli init widget my-widget
cd my-widget

# Start development with live reload
npx @scom/cli serve src --port 3000

# Test the component
npx @scom/cli test

# Bundle for distribution
npx @scom/cli bundle
```

### Development Workflow

```bash
# Start development server
npx @scom/cli dev --port 8080

# In another terminal, run tests in watch mode
npx @scom/cli test --watch

# Build when ready for production
npx @scom/cli bundle
```

## Configuration

The CLI respects standard configuration files:
- `package.json`: Project metadata and dependencies
- `tsconfig.json`: TypeScript configuration
- `scconfig.json`: SCOM-specific configuration
- `.gitignore`: Version control exclusions

## Integration with SCOM Ecosystem

The CLI is designed to work seamlessly with:
- **@scom/core**: Provides runtime dependencies
- **@scom/bundler**: Advanced module bundling
- **@scom/serve**: Development server capabilities
- **@scom/test**: Comprehensive testing framework

## Binary Installation

When installed, the CLI provides the `scom-cli` binary globally:

```bash
which scom-cli
# /usr/local/bin/@scom/cli (or equivalent)
```

## Help

Get help for any command:

```bash
npx @scom/cli --help
npx @scom/cli init --help
npx @scom/cli serve --help
```