# Arc XP PageBuilder (Fusion) CLI

CLI tool for running Arc XP PageBuilder (formerly Fusion) on your local machine.

## Changelog

You can see the [release notes in Arc Learning Center (ALC)](https://docs.arcxp.com/en/what-s-new-in-arc-xp/what-s-new-in-pagebuilder-cli.html).

## Requirements

The following apps/commands are required for the fusion CLI to function properly:

-   [node](https://nodejs.org/en/download/) - This should be the same version of Node your `FUSION_RELEASE` is using (Node.js v20 in Engine 5.x)
-   [npm](https://docs.npmjs.com/getting-started/installing-node) - This should be the default version provided by node (v7 in Node.js 16+)
-   [docker 18+](https://docs.docker.com/install/)
-   [docker-compose](https://docs.docker.com/compose/install/#install-compose)

## Installation

### Global install

```sh
npm install -g @arc-fusion/cli
```

will install a command-line script on your system, globally accessible as `fusion`.

### Local install

```sh
npm install --save-dev @arc-fusion/cli
```

will install a command-line script in your repo, locally accessible as `npx fusion` or `npm run fusion`.

## Getting Started

- [What does the PageBuilder local development stack look like?](https://dev.arcxp.com/pagebuilder-engine/developer-docs/what-does-the-pagebuilder-local-development-stack-look-like/)
- How To Run PageBuilder Engine Locally, Video Tutorials:
  - [Starting from scratch with Hello World example](https://dev.arcxp.com/pagebuilder-engine/developer-docs/how-to-run-pagebuilder-engine-locally-starting-from-scratch-with-hello-world-example/)
  - [Starting with my organization's live bundle and pages](https://dev.arcxp.com/pagebuilder-engine/developer-docs/how-to-run-pagebuilder-engine-locally-starting-with-my-organizations-live-bundle-and-pages/)

## Configuration and Environment Variables

ALC documentation related with configuring PageBuiler CLI:
- [Environment Variables](https://dev.arcxp.com/pagebuilder-engine/developer-docs/environment-variables/)
- [arc.config.json](https://dev.arcxp.com/pagebuilder-engine/developer-docs/arcconfigjson/) (for build options)
- [Local Mocks](https://dev.arcxp.com/pagebuilder-engine/developer-docs/local-mocks/)

## Commands

All commands should be run from within the repository, as `fusion <command>` if installed globally, or `npx fusion <command>` if installed locally.

#### `daemon [--no-admin]`

Run Fusion services in detached mode

#### `down`

Stop and remove containers, networks, images, and volumes

#### `dump`

Export the database into `data/dumps/<timestamp>.tar.gz`

#### `init`

Initialize the directory as a git repo, an npm package, and bootstrap the fusion directory structure

#### `migrate`

Migrate a legacy fusion repository to work with the fusion CLI

#### `rebuild`

Force a webpack rebuild of a running cluster

#### `compile-styles`

Compile styles from Themes Blocks and Components, as well as custom blocks

#### `start [--no-admin]`

Configure a docker-compose cluster to map npm linked modules, then start services.

This is also aliased as `npm start` for convenience.

The start command may also be run with the `--no-admin` flag to run the rendering services without the admin app.

For themes development, there are a few additional flags you can use:

* `-l` or `--links`: Use the local version of blocks for developement. Can optionally take a comma separated string of blocks to link instead of linking all of them (`-l @org/block1,@org/block2`). This requires that you have `THEMES_BLOCKS_REPO` set in your `.env` file and it should be the absolute path to the directory the local blocks repo is in.
* *New for fusion 2.7.4* When linking an unpublished block, you will need to include `@org/block-name@local` in your blocks.json in addition to using the `-l @org/block-name` flag.
* `-f` or `--rebuild`: Rebuild the webpack image and pull the latest version of the blocks.
* `-p` or `--production`: Force the image to use the published blocks. A developer can use any published tag `canary`, `beta`, `stable`, `hotfix`, or `latest`.

#### `stop`

Stop services

#### `verify`

Run webpack on the repo source to ensure it has no compilation errors

* `-f` or `--force`: Verify production build without running validation.
* `-k` or `--keep-artifacts`: Keep verify build artifacts in `.fusion/` after completion.

#### `zip`

* `-f` or `--force`: Skip verifying the bundle.
* `-n` or `--rename`: Change the generated zip file's name.
* `-k` or `--keep-artifacts`: Keep verify build artifacts in `.fusion/` after completion.

Create a zip file that is appropriate for upload into the fusion deployment system