# hapify-cli

> Command Line Interface for Hapify

Latest version **0.7.2** (published 2020-11-04) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install hapify-cli
pnpm add hapify-cli
yarn add hapify-cli
bun add hapify-cli
```

Provides the command `hpf`.

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 0.7.2 |
| Published | 2020-11-04 |
| First published | 2019-03-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=9 |
| Dependencies | 26 |
| Unpacked size | 14.5 MB |
| Known vulnerabilities | 0 (+33 in 4 direct dependencies) |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Edouard Demotes-Mainard |
| Maintainers | tractr |
| Keywords | hapify, cli |

## Links

- npm: https://www.npmjs.com/package/hapify-cli
- Repository: https://github.com/hapify/cli
- Homepage: https://www.hapify.io
- Issues: https://github.com/hapify/cli/issues
- npm.io page: https://npm.io/package/hapify-cli

## Dependencies (26)

- [ws](https://npm.io/package/ws.md) ^7.3.1
- [joi](https://npm.io/package/joi.md) ^17.3.0
- [md5](https://npm.io/package/md5.md) ^2.3.0
- [vm2](https://npm.io/package/vm2.md) ^3.9.2
- [case](https://npm.io/package/case.md) ^1.6.3
- [open](https://npm.io/package/open.md) ^7.3.0
- [axios](https://npm.io/package/axios.md) ^0.21.0
- [chalk](https://npm.io/package/chalk.md) ^4.1.0
- [jszip](https://npm.io/package/jszip.md) ^3.5.0
- [mkdirp](https://npm.io/package/mkdirp.md) ^1.0.4
- [rimraf](https://npm.io/package/rimraf.md) ^3.0.2
- [typedi](https://npm.io/package/typedi.md) ^0.8.0
- [pkg-dir](https://npm.io/package/pkg-dir.md) ^5.0.0
- [inquirer](https://npm.io/package/inquirer.md) ^7.3.3
- [commander](https://npm.io/package/commander.md) ^6.2.0
- [hapify-vm](https://npm.io/package/hapify-vm.md) github:hapify/vm#v0.3.2
- [@hapi/hapi](https://npm.io/package/@hapi/hapi.md) ^20.0.1
- [@hapi/hoek](https://npm.io/package/@hapi/hoek.md) ^9.1.0
- [simple-git](https://npm.io/package/simple-git.md) ^2.21.0
- [@hapi/inert](https://npm.io/package/@hapi/inert.md) ^6.0.3
- [detect-port](https://npm.io/package/detect-port.md) ^1.2.3
- [querystring](https://npm.io/package/querystring.md) ^0.2.0
- [jsonwebtoken](https://npm.io/package/jsonwebtoken.md) ^8.5.1
- [randomstring](https://npm.io/package/randomstring.md) ^1.1.5
- [hapify-generator](https://npm.io/package/hapify-generator.md) github:hapify/generator#v0.5.3
- [reflect-metadata](https://npm.io/package/reflect-metadata.md) ^0.1.12

## Alternatives

- [@salesforce/cli](https://npm.io/package/@salesforce/cli.md) — 389.7K weekly downloads
- [@mintlify/cli](https://npm.io/package/@mintlify/cli.md) — 208.9K weekly downloads
- [@grafana/e2e-selectors](https://npm.io/package/@grafana/e2e-selectors.md) — 128.7K weekly downloads
- [mintlify](https://npm.io/package/mintlify.md) — 112.0K weekly downloads
- [@intlayer/cli](https://npm.io/package/@intlayer/cli.md) — 22.8K weekly downloads

## Recent versions

- 0.7.2 (latest) — 2020-11-04
- 0.7.1 — 2020-11-04
- 0.7.0 — 2020-11-03
- 0.6.0 — 2020-08-03
- 0.5.6 — 2019-11-15
- 0.5.5 — 2019-11-15
- 0.5.4 — 2019-10-25
- 0.5.3 — 2019-06-18
- 0.5.2 — 2019-06-18
- 0.5.1 — 2019-05-28
- 0.5.0 — 2019-05-03
- 0.4.5 — 2019-03-20
- 0.4.4 — 2019-03-20
- 0.4.3 — 2019-03-13
- 0.4.2 — 2019-03-11
- … 2 more at https://npm.io/package/hapify-cli/versions

## README

# Hapify CLI

## Description

Hapify is a code generation tool based on relational data models.
It uses a dedicated templating language.
It exposes a web-based console for models definition and templates writing.

## Usage

### Installation

You need to install this package globally to have the `hpf` command:

```bash
npm install -g hapify-cli
```

To check the installed version, run `hpf --version`.

### Global options

-   `-V`, `--version`: output the version number
-   `--debug`: enable debug mode
-   `-d <path>`, `--dir <path>`: change the working directory. This path can be absolute or relative to the current path
-   `-k <secret>`, `--key <secret>`: force usage of an API key rather than the one defined in global config. If you want to define your api key permanently, you should use command `hpf key`)
-   `-h`, `--help`: show help

### Commands

#### Set global configuration

```bash
hpf config [options]
```

This command stores your one (or more) global configuration in `~/.hapify/config.json`.
If the file does not exists, it will be automatically created.

_Available configuration_

-   `hpf config --apiKey <secret>`: define the API key to use for every commands. This is equivalent to `hpf key <key>`.
-   `hpf config --apiUrl <url>`: override default api url.

#### Set global API key

```bash
hpf key <key>
```

This command is an alias of `hpf config --apiKey <secret>`.

#### List visible channels

```bash
hpf list
```

Alias: `hpf ls`

This command displays what is visible for the CLI from this directory.
It shows the list of channels and the list of models used by those channels.

The CLI looks for `hapify.json` files to auto-detect channels.
It recurses over sub-directories. Default depth is `2`.
To modify this value, use the `depth` option.

```bash
hpf list --depth 3
```

_Note:_
You are not supposed to run the CLI with different models sets.
If this is the case, the first found set will be used.

#### Generate the code

```bash
hpf generate
```

Alias: `hpf g`

This command generates all found channels from theirs templates and models.
To define the depth to look for channels, use this option: `--depth <n>`. Default is `2`.

```bash
hpf generate --depth 3
```

#### Export the code

```bash
hpf export
```

Alias: `hpf x`

This command generates the channel from its templates and its models.
Then it saves the generated files in a zip file.
To run this command you must be in the channel directory, next to the `hapify.json` file.

By default, the zip file has the channel's name, ie the folder name.
Example: `angular-admin/angular-admin.zip`.
You can define a custom path with this option: `-o, --output <path>`.

```bash
hpf export -o /path/to/file.zip
```

#### Import the models

```bash
hpf import
```

Alias: `hpf m`

Use this command to import pre-defined models from the Cloud database (called presets).
This command displays the list of available presets of models.
Press space bar to select a preset to import and enter to confirm.

_Import presets from ids_

Alternatively, you can import presets from their Ids (visible in [Hapify Hub](https://hub.hapify.io/))

```bash
hpf import --preset ab123 --preset bd456
```

#### Clone a boilerplate and start a new project

```bash
hpf new
```

Alias: `hpf n`

This command let you clone and configure a boilerplate.
It will prompt a form to:

-   select a boilerpalte
-   select or create the project to use
-   select models to import

_Options_

-   `-p <id>`, `--project <id>`: The project to use (if already existing)
-   `-b <slug>`, `--boilerplate <slug>`: The slug name of the boilerplate to clone
-   `--boilerplate-id <id>`: The id of the boilerplate to clone
-   `--boilerplate-url <url>`: The git URL of the boilerplate to clone
-   `--preset [id]`: Ids of presets to preload in the project
-   `--no-presets`: Do not prompt for presets
-   `--project-name <name>`: The project's name to create
-   `--project-desc <description>`: The project's description to create (name must be defined)

To browse available boilerplates, please visit [hub.hapify.io](https://hub.hapify.io).

#### Initialize a new channel

```bash
hpf init
```

Alias: `hpf i`

This command creates a new Hapify files structure in the current directory.
It creates a file `hapify.json` and a folder `hapify` containing a template `models/model/hello.js.hpf`.
It will prompt a form to select or create a project.

_Options_

-   `-p <id>`, `--project <id>`: The project to use (if already created)
-   `--channel-name <name>`: The name of the channel to init
-   `--channel-desc <description>`: The description of the channel to init
-   `--channel-logo <url>`: The URL of the logo of the channel to init
-   `--project-name <name>`: The project's name to create
-   `--project-desc <description>`: The project's description to create (name must be defined)

#### Define project to use in a channel

```bash
hpf use
```

Alias: `hpf u`

Change the project used by one or more existing channels.
It changes the project's id in file `hapify.json` for each found channels.
It will prompt a form to select or create the project to use.

_Options_

-   `-p <id>`, `--project <id>`: The project to use (if already created)
-   `--project-name <name>`: The project's name to create
-   `--project-desc <description>`: The project's description to create

#### Patch source code with new models

During the development process, you may want to add, edit or remove some models.
To automatically apply the difference between two generation to your working branch, use this command.

This command uses `git format-patch` and `git am`.

```bash
hpf patch
```

This will prompt a form to let you choose the source branch and commits then destination branch.

#### Start the console

Run this command to edit models and templates.

```bash
hpf serve
```

This will start a server that hosts a web-based console for models and templates edition.

_Options_

-   `-p <n>`, `--port <n>`: the required port number (default between 4800 and 4820)
-   `-H <hostname>`, `--hostname <hostname>`: the required hostname (default: localhost)
-   `--no-open`: do not open a new tab in the browser to show the console
-   `--depth <n>`: depth to recursively look for channels (default: 2)

---
_Source: https://npm.io/package/hapify-cli · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
