<h1 align="center">Welcome to deploy-cli 👋</h1>
<p>
  <a href="https://www.npmjs.com/package/deploy-cli" target="_blank">
    <img alt="Version" src="https://img.shields.io/npm/v/deploy-cli.svg">
  </a>
  <img src="https://img.shields.io/badge/node-%3E%3D16.0.0-blue.svg" />
  <img src="https://img.shields.io/badge/npm-%3E%3D7.0.0-blue.svg" />
  <a href="https://github.com/kexin8/auto-deploy#readme" target="_blank">
    <img alt="Documentation" src="https://img.shields.io/badge/documentation-yes-brightgreen.svg" />
  </a>
  <a href="https://github.com/kexin8/auto-deploy/graphs/commit-activity" target="_blank">
    <img alt="Maintenance" src="https://img.shields.io/badge/Maintained%3F-yes-green.svg" />
  </a>
  <a href="https://github.com/kexin8/auto-deploy/blob/master/LICENSE" target="_blank">
    <img alt="License: ISC" src="https://img.shields.io/github/license/kexin8/deploy-cli" />
  </a>
</p>

> “Deploy CLI” is a one-click deployment CLI tool that allows users to deploy programs to servers with just one command
> based on their configurations. This tool can help users quickly deploy programs and improve efficiency. You can
> describe
> the features and advantages of this tool in the introduction.

### 🏠 [Homepage](https://github.com/kexin8/auto-deploy#readme) | [中文文档](https://github.com/kexin8/auto-deploy#README_CN.md)

## Prerequisites

> This parameter is applicable only to the yarn method. Other methods are not applicable

- node >=16.0.0
- npm >=7.0.0

## Install

### Yarn(Recommended)

```sh
yarn global add @kexin88/deploy-cli
```

### ~~Npm(Deprecated)~~

> Deprecated: `npm uninstall -g` does not trigger the `preuninstall` event and therefore cannot delete the global binary file.

### Script Install

#### Linux && MacOS

```shell
curl -fsSL https://github.com/kexin8/auto-deploy/releases/download/install/install.sh | sh
```

*China mainland users can use the following command to speed up the download*

```shell
curl -fsSL https://ghproxy.com/https://github.com/kexin8/auto-deploy/releases/download/install/install.sh | sh -s https://ghproxy.com
```

#### Windows (PowerShell)

```powershell
# Optional: Needed to run a remote script the first time
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
irm https://github.com/kexin8/auto-deploy/releases/download/install/install.ps1 | iex
# if you can't access github, you can use proxy
irm https://github.com/kexin8/auto-deploy/releases/download/install/install.ps1 -Proxy '<host>:<ip>' | iex
```

*China mainland users can use the following command to speed up the download*

```powershell
# Optional: Needed to run a remote script the first time
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
irm https://ghproxy.com/https://github.com/kexin8/auto-deploy/releases/download/install/install_ZH-CN.ps1 | iex
```

## Usage

```sh
deploy --version
```

## Commands

### Init Config

Run `deploy init` command to initialize the configuration file.
The configuration file is located in the current directory. The default name is `dyconfig.json`.
If you want to all the configuration file to be named `dyconfig.json`, you can add `-a` parameter.
Detailed configuration file description can be found in [Configuration](#Configuration).
**Example:**

```shell
deploy init
# or
deploy init -a
```

### Deploy Program

Run `deploy` command to deploy program to server.
The configuration file is located in the current directory. The default name is `dyconfig.json`.
**Example:**

```shell
deploy
# or
deploy /path/to/dyconfig.json
```

### More

More commands can be found by running `deploy --help` or `deploy -h` command.

```shell
$ deploy -h
NAME:
   deploy - this is a simple cli app that automates deploy

USAGE:
   deploy [\path\to\config.json]

VERSION:
   v1.3.0-pre

DESCRIPTION:
   This is a simple cli app that automates deploy.
   e.g. This is a common way to perform deploy, according to dyconfig.json in the current path
     deploy
   This is manually specifying the configuration file
     deploy \path\to\config.json

COMMANDS:
   init     
   upgrade  upgrade deploy
   help, h  Shows a list of commands or help for one command

GLOBAL OPTIONS:
   --help, -h     show help
   --version, -v  print the version
```

## Configuration

The configuration file is a json file, which can be generated by running `deploy init` command.

| Field         | Type     | Required | Description                                                                          |
|---------------|----------|----------|--------------------------------------------------------------------------------------|
| address       | string   | true     | The address of the server to be deployed.                                            |
| username      | string   | true     | The username of the server to be deployed.                                           |
| password      | string   | true     | The password of the server to be deployed.                                           |
| srcFile       | string   | true     | The path of the file to be deployed. allow multiple files to be separated by commas. |
| workDir       | string   | false    | The path of the directory to be deployed.                                            |
| changeWorkDir | boolean  | false    | Whether to change the working directory.                                             |
| preCmd        | string[] | false    | The commands to be executed before deployment.                                       |
| postCmd       | string[] | false    | The commands to be executed after deployment.                                        |

**Example:**

```yaml
{
  "address": "127.0.0.1:22",
  "username": "username",
  "password": "password",
  "srcFile": "file1,file2,...",
  "workDir": "/path/to/workDir",
  "changeWorkDir": true,
  "preCmd": [
    "echo 'preCmds'"
  ],
  "postCmd": [
    "echo 'postCmds'"
  ]
}
```

## Author

👤 **kexin8**

* Github: [@kexin8](https://github.com/kexin8)

## 🤝 Contributing

Contributions, issues and feature requests are welcome!<br />Feel free to
check [issues page](https://github.com/kexin8/auto-deploy/issues). You can also take a look at
the [contributing guide](https://github.com/kexin8/auto-deploy/blob/master/CONTRIBUTING.md).

## Show your support

Give a ⭐️ if this project helped you!

## 📝 License

Copyright © 2023 [kexin8](https://github.com/kexin8).<br />
This project is [ISC](https://github.com/kexin8/auto-deploy/blob/master/LICENSE) licensed.

***
_This README was generated with ❤️ by [readme-md-generator](https://github.com/kefranabg/readme-md-generator)_