npm package: @foxpage/foxpage-cli
Description: foxpage cli
Author: melody-yangjie
Latest version: 3.0.2

# @foxpage/foxpage-cli

a `CLI` tool for [foxpage](https://github.com/foxpage)

## 🖥 Environment Support

[![Minimum node.js version](https://img.shields.io/badge/node-%3E%3D12.14.1-brightgreen)](https://img.shields.io/badge/node-%3E%3D12.14.1-brightgreen)
[![typescript version](https://img.shields.io/badge/typescript-%3E%3D4.0.0-brightgreen)](https://img.shields.io/badge/typescript-%3E%3D4.0.0-brightgreen)
[![yarn](https://img.shields.io/badge/yarn-1.22.5-blue)](https://img.shields.io/badge/yarn-1.22.5-blue)

## ⌨️ Usage

The root level command is `foxpage`:

```sh
# see version
foxpage -v

# get help
foxpage -h

# init foxpage config
foxpage --init
```

The CLI provides two main commands:

- `create`: Create new projects or packages
- `build`: Build resources for projects or packages

### foxpage create

Create new projects or packages. Supports two targets:

1. Create a project:

```sh
foxpage create project [options]

Options:
  --name <targetName>    target name
  --component           create component project
  --plugin             create plugin project
  --server             create server project
  --repo <repository>  project git repository
  --uri <uri>         custom template repository URI (e.g., https://github.com/user/custom-template)
  # or
  --zip-uri <zipUri>  custom template zip download URI (e.g., https://github.com/user/custom-template/archive/refs/heads/main.zip)
```

The default template repositories:

- Component project: [foxpage-component-boilerplate](https://github.com/foxpage/foxpage-component-boilerplate)
- Plugin project: [foxpage-plugin-boilerplate](https://github.com/foxpage/foxpage-plugin-boilerplate)

2. Create a package:

```sh
foxpage create package [options]

Options:
  --name <targetName>         target name
  --templates <templateDir>   templates dir location
  --template <templateDir>    template dir location
  --format                   format code after create
  --out-dir <directory>      out dir for new created package (default: "packages")
```

Examples:

```sh
# Create a component project
foxpage create project --component --name my-component-project

# Create a component project with custom template (using repository URI)
foxpage create project --component --name my-component-project \
  --uri https://github.com/user/custom-template

# Create a component project with custom template (using zip download)
foxpage create project --component --name my-component-project \
  --zip-uri https://github.com/user/custom-template/archive/refs/heads/main.zip

# Create a plugin project
foxpage create project --plugin --name my-plugin-project

# Create a plugin project with custom template (using repository URI)
foxpage create project --plugin --name my-plugin-project \
  --uri https://github.com/user/custom-plugin-template

# Create a plugin project with custom template (using zip download)
foxpage create project --plugin --name my-plugin-project \
  --zip-uri https://github.com/user/custom-plugin-template/archive/refs/heads/main.zip

# Create a package
foxpage create package --name my-package --format
```

### foxpage build

Build resources for projects or packages:

```sh
foxpage build [options]

Options:
  --foxpage                   Build for foxpage
  --foxpage-root             Build foxpage in root
  --umd                      Build umd
  --umd-root                 Build umd in root
  --cjs                      Build cjs
  --cjs-root                 Build cjs in root
  --lib                      Build lib(cjs) for npm
  --es-module                Build es(es-module) for npm
  --schema-md                Build schema.md to describe the api of component
  --clean                    Clean dist directory (default: true)
  --no-clean                Set --clean to false
  --output <o>              Output path
  --assets-hash             Build files in assets using the WebPack Contenthash parameter
  --debug                   Debug: some temp file or data will be retained
  --packages <pattern...>   Packages need to build (default: ["packages/*"])
  --root-cache             Cache <root>/dist directory for all package (default: true)
  --no-root-cache          Set --root-cache to false
  --npm-client <npmClient> Executable used to run scripts (npm, yarn, ...) (default: "npm")
  --max-concurrency <n>    Limit the max number of concurrently running processes
  --concurrency <n>        Number of concurrently pending subprocess
  --modes <modes>         Build modes (comma separated):
                          - foxpage: "production,debug,node,editor"
                          - umd: "umd_prod,umd_dev"
                          - cjs: "cjs_prod,cjs_dev"
  --ignore-modes <modes>  Ignore specific build modes (comma separated)
  --manifest              Generate manifest.json (used with --file-hash)
  --file-hash            Build all files using the WebPack Contenthash parameter
  --progress-plugin      Use webpack.ProgressPlugin when webpack build
  --analyze              Use webpack-bundle-analyzer (only for --umd, --cjs, --foxpage)
  --css-in-js           Use style loader to include style in js file (only for --foxpage --umd)
  --generate-foxpage-json Generate foxpage.json file (default: true)
  --no-generate-foxpage-json Disable generate foxpage.json file
  --zip-fox             Automatically compress build resources (only for --foxpage)
  --no-zip-fox          Disable zip-fox
  --zip-fox-output <o>  Output path for zip-fox
  --babel-options <o>   Custom babel cli options (only for --es/lib)
  --ts-declaration      Generate typescript declaration (*.d.ts) (only for --es/lib)
  --no-ts-declaration   Disable ts-declaration
  --css-style          Build style from index.(less/scss) to index.css (only for --es/lib)
  --remove-style-import Remove style import for all ".js" file (only for --es/lib)
  --import-index-css   Add "import './index.css'" in root index.js (only for --es/lib)
  --remove-console     Remove console in final result (default: true)
  --no-remove-console  Keep console
```

Build output directories:

- `/dist`: Resources for Foxpage platform registration
- `/es`: ES Module format resources for NPM
- `/lib`: CommonJS format resources for NPM

Examples:

```sh
# Build a component with foxpage format
foxpage build --foxpage

# Build a component in root directory
foxpage build --foxpage-root

# Build a component with all formats and styles
foxpage build --foxpage --lib --es-module --css-style --ts-declaration

# Build with specific modes
foxpage build --foxpage --modes production,debug

# Build with custom concurrency
foxpage build --foxpage-root --concurrency 4 --max-concurrency 8
```