Skip to main content

PUI CLI Documentation

Welcome to the ICE MT UI Platform CLI documentation. This CLI tool provides a comprehensive set of commands for building, testing, and maintaining UI applications and libraries.

Featuresโ€‹

  • ๐Ÿš€ Modern Build Tools - Webpack and Vite integration
  • ๐Ÿงช Testing - Jest and Vitest support with coverage
  • ๐ŸŽจ Linting - ESLint, Prettier, and Stylelint configurations
  • ๐Ÿ“ TypeScript - Full TypeScript support
  • ๐Ÿ“š Storybook - Component development and documentation
  • ๐Ÿ”ง Development Server - Hot module replacement
  • ๐Ÿ“ฆ Library Support - Build both applications and libraries
  • ๐ŸŽฏ Monorepo Support - Workspace version management

Getting Startedโ€‹

This guide will help you get started with @elliemae/pui-cli, a command-line interface tool for building and managing UI applications and libraries.

Prerequisitesโ€‹

Before you begin, ensure you have the following installed:

  • Node.js: Version 20
  • pnpm: Version 8 (recommended package manager)

Installationโ€‹

For New Projectsโ€‹

Install the CLI as a development dependency in your project:

pnpm add -D @elliemae/pui-cli

Quick Startโ€‹

Setting Up a New Applicationโ€‹

  1. Create a package.json if you don't have one:
pnpm init
  1. Install pui-cli:
pnpm add -D @elliemae/pui-cli
  1. Add scripts to your package.json:

For applications:

{
"scripts": {
"start": "pui-cli start",
"start:prod": "pui-cli start -p",
"build": "pui-cli build",
"test": "pui-cli test",
"vitest": "pui-cli vitest",
"test:fix": "pui-cli test -f",
"test:debug": "pui-cli test --debug",
"lint": "pui-cli lint",
"lint:fix": "pui-cli lint --fix",
"lint:staged": "lint-staged",
"tscheck": "pui-cli tscheck --files",
"storybook": "pui-cli storybook",
"storybook:docs": "pui-cli storybook --docs",
"storybook:build": "pui-cli storybook -b",
"gendoc": "pui-cli gendoc"
}
}

For libraries:

{
"scripts": {
"build": "pui-cli pack -p",
"build:dev": "pui-cli pack",
"test": "pui-cli test",
"test:fix": "pui-cli test -f",
"lint": "pui-cli lint",
"lint:fix": "pui-cli lint --fix",
"tscheck": "pui-cli tscheck --files"
}
}
  1. Create a TypeScript configuration (tsconfig.json):

For applications:

{
"extends": "@elliemae/pui-cli/app.tsconfig.json",
"compilerOptions": {
"outDir": "dist/types",
"baseUrl": ".",
"paths": {}
},
"include": [
"app/**/*",
"wdio.config.mjs",
"vitest.config.ts",
"docusaurus.config.ts"
],
"exclude": ["node_modules", "**/*.spec.ts"]
}

For libraries:

{
"extends": "@elliemae/pui-cli/library.tsconfig.json",
"compilerOptions": {
"outDir": "dist/types",
"declarationDir": "dist/types",
"baseUrl": "."
},
"include": ["lib/**/*", "./docusaurus.config.ts"],
"exclude": ["node_modules"]
}
  1. Create your source structure:

For applications:

your-project/
โ”œโ”€โ”€ app/
โ”‚ โ”œโ”€โ”€ index.tsx # Entry point
โ”‚ โ”œโ”€โ”€ route/ # Routes
โ”‚ โ”œโ”€โ”€ view/ # Components
โ”‚ โ”œโ”€โ”€ data/ # Redux slices
โ”‚ โ”œโ”€โ”€ api/ # RTK Query APIs
โ”‚ โ”œโ”€โ”€ sideeffect/ # Redux Sagas
โ”‚ โ”œโ”€โ”€ utils/ # Utilities
โ”‚ โ””โ”€โ”€ app.config.json # App configuration
โ”œโ”€โ”€ public/ # Static assets
โ”œโ”€โ”€ package.json
โ””โ”€โ”€ tsconfig.json

For libraries:

your-project/
โ”œโ”€โ”€ lib/
โ”‚ โ”œโ”€โ”€ index.ts # Entry point
โ”‚ โ”œโ”€โ”€ components/ # Components
โ”‚ โ”œโ”€โ”€ utils/ # Utilities
โ”‚ โ””โ”€โ”€ __tests__/ # Tests
โ”œโ”€โ”€ stories/ # Storybook stories (optional)
โ”œโ”€โ”€ package.json
โ””โ”€โ”€ tsconfig.json

Project Structureโ€‹

Application Structureโ€‹

your-app/
โ”œโ”€โ”€ app/ # Application source code
โ”‚ โ”œโ”€โ”€ index.tsx # Entry point
โ”‚ โ”œโ”€โ”€ route/ # Route definitions
โ”‚ โ”œโ”€โ”€ view/ # UI components
โ”‚ โ”œโ”€โ”€ data/ # Redux slices (state)
โ”‚ โ”œโ”€โ”€ api/ # RTK Query API definitions
โ”‚ โ”œโ”€โ”€ sideeffect/ # Redux Sagas
โ”‚ โ”œโ”€โ”€ utils/ # Utility functions
โ”‚ โ”œโ”€โ”€ tests/ # Test files
โ”‚ โ””โ”€โ”€ app.config.json # App configuration
โ”œโ”€โ”€ public/ # Static assets
โ”œโ”€โ”€ e2e/ # E2E tests (optional)
โ”œโ”€โ”€ docs/ # Docusaurus docs (optional)
โ”œโ”€โ”€ package.json
โ””โ”€โ”€ tsconfig.json

Library Structureโ€‹

your-library/
โ”œโ”€โ”€ lib/ # Library source code
โ”‚ โ”œโ”€โ”€ index.ts # Entry point
โ”‚ โ”œโ”€โ”€ components/ # Components
โ”‚ โ””โ”€โ”€ __tests__/ # Test files
โ”œโ”€โ”€ stories/ # Storybook stories
โ”œโ”€โ”€ package.json
โ””โ”€โ”€ tsconfig.json

Configuration Filesโ€‹

Prettier Configurationโ€‹

Create prettier.config.cjs:

const { prettierConfig } = require('@elliemae/pui-cli');
module.exports = prettierConfig;

Stylelint Configurationโ€‹

Create stylelint.config.cjs:

const { stylelintConfig } = require('@elliemae/pui-cli');
module.exports = stylelintConfig;

Commitlint Configurationโ€‹

Create commitlint.config.cjs:

const { commitlintConfig } = require('@elliemae/pui-cli');
module.exports = commitlintConfig;

Lint-staged Configurationโ€‹

Create lint-staged.config.mjs:

import { lintStagedConfig } from '@elliemae/pui-cli';
export default lintStagedConfig;

Babel Configuration (Optional)โ€‹

Create babel.config.cjs for custom Babel configuration:

const { babelConfig } = require('@elliemae/pui-cli');
module.exports = babelConfig;

Git Hooks Setupโ€‹

To enable pre-commit hooks with Husky:

  1. Install Husky:
pnpm add -D husky
npx husky init
  1. Create .husky/pre-commit:
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx lint-staged
  1. Make it executable:
chmod +x .husky/pre-commit

Additional Configuration Filesโ€‹

Jest Configurationโ€‹

For custom Jest configuration, create jest.config.cjs:

const { jestConfig } = require('@elliemae/pui-cli');
module.exports = jestConfig;

Environment Variablesโ€‹

Create a .env file in your project root for environment-specific configuration:

PORT=3000
NODE_ENV=development

Running Your First Buildโ€‹

Start Development Serverโ€‹

# Start development server
pnpm start

# Start with production mode
pnpm start:prod
# or
pui-cli start -p

This will:

  • Start webpack dev server
  • Enable hot module replacement
  • Serve your application (default: http://localhost:3000)
  • Watch for file changes

Build for Productionโ€‹

# Build application
pnpm build

# Build library
pui-cli pack -p

# Build library for development (no minification)
pui-cli pack

This will:

  • Create an optimized production build
  • Output files to the dist/ or build/ directory
  • Generate source maps
  • Minify and bundle your code
  • For libraries: Generate ESM, CJS, and type declarations

Run Testsโ€‹

# Run Jest tests
pnpm test

# Run tests with auto-fix
pnpm test:fix

# Debug tests
pnpm test:debug

# Watch mode
pnpm test:watch

Linting and Type Checkingโ€‹

# Lint code
pnpm lint

# Auto-fix lint issues
pnpm lint:fix

# Type check
pnpm tscheck

# Lint staged files only
pnpm lint:staged

Storybookโ€‹

# Run Storybook dev server
pnpm storybook

# Run with docs mode
pnpm storybook:docs

# Build static Storybook
pnpm storybook:build

Next Stepsโ€‹

Troubleshootingโ€‹

Common Issuesโ€‹

Port already in use:

# Change the port in your .env file
PORT=3001

Module not found errors:

# Clear node_modules and reinstall
rm -rf node_modules
pnpm install

Build fails with TypeScript errors:

# Run type checking separately to see detailed errors
pnpm tscheck

HTTPS certificate warnings:

If you see "Not Secure" or certificate warnings when using HTTPS in development:

  • See the SSL Certificate Setup Guide for detailed instructions
  • You need to trust the self-signed CA certificate on your system
  • Platform-specific instructions available for macOS, Windows, and Firefox

Getting Helpโ€‹

If you encounter issues:

  1. Review the documentation in the docs/ folder
  2. Reach out to the ui-platform teams channel