buncid/README.md

107 lines
3.4 KiB
Markdown
Raw Normal View History

2023-10-29 07:35:26 +00:00
# Simple CI/CD package for any application
2025-01-16 08:01:06 +00:00
NOTE: This package is for Bun runtime
2023-10-29 07:35:26 +00:00
Integrate a simple CI/CD process into your application without the hassle.
_**NOTE:** This package needs `node` installed to work_
## Requirements
2025-01-16 08:01:06 +00:00
- **Node JS Runtime and NPM:** You need to have `NodeJS` and `bun` installed on the target machine for this package to work.
2025-01-16 08:18:45 +00:00
- **`buncid.config.json` file:** This package depends on a configuration file located in the root directory of your application.
2023-10-29 07:35:26 +00:00
## Installation
To install this package globally just run:
```shell
2025-01-16 08:18:45 +00:00
bun install -g buncid
2023-10-29 07:35:26 +00:00
```
To run the package directly run:
```shell
2025-01-16 08:18:45 +00:00
bunx buncid
2023-10-29 07:35:26 +00:00
```
This will download the package and run the binaries directly. After the first run it won't download the package again.
## Usage
To run the package after installing it globally just run:
```shell
2025-01-16 08:18:45 +00:00
buncid
2023-10-29 07:35:26 +00:00
```
2025-01-16 08:18:45 +00:00
Remember you must have a `buncid.config.json` file located in your root directory else this will throw an error.
2023-10-29 07:35:26 +00:00
### Configuration
2025-01-16 08:18:45 +00:00
Your `buncid.config.json` file should look like this:
2023-10-29 07:35:26 +00:00
```json
{
"start": "node index.js",
2025-01-16 08:01:06 +00:00
"preflight": ["bun run test", "bun run build"]
2023-10-29 07:35:26 +00:00
}
```
or
```json
{
"start": "node index.js",
"preflight": "./preflight.sh"
}
```
Your `preflight` parameter can wither be an array of commands, or path to a shell script. This will run before every `start` commands.
Optionally you could include a `redeploy_path` in your config file:
```json
{
"start": "node index.js",
"preflight": "./preflight.sh",
"redeploy_path": "./REDEPLOY"
}
```
This will look for the file named `REDEPLOY` in your rood directory and watch that file. If the file is changed the application will be restarted, ie it will run the `preflight` command(s) and `start` command. If you ommit the `redeploy_path` a file named `REDEPLOY` will be created in your root directory.
You can change the name and path of the `redeploy_path`, just make sure the path is correct and the file name exists in the named path. Example:
```json
{
"start": "node index.js",
"preflight": "./preflight.sh",
"redeploy_path": "./deploy/trigger.txt"
}
```
_NOTE:_ This also works for other languages, example:
```json
{
"start": "python app.py",
"preflight": "./preflight.sh"
}
```
This app just runs whatever command you send it in an isolated child process, the command will be run as if being run in a terminal.
2025-01-16 08:18:45 +00:00
#### All Available options in `buncid.config.json` file
2023-11-01 05:01:17 +00:00
- **`start`**: _string_: The start Command
- **`preflight`**: _string | Array_: Array of commands or shell script file to run before reloading application
2023-11-06 20:06:33 +00:00
- **`postflight`**: _string | Array_: _Optional_: Array of commands or shell script file to run after reloading application
2023-11-01 05:01:17 +00:00
- **`redeploy_path`**: _string_: _Optional_: The path to trigger a redeployment. Default `./REDEPLOY`
2023-11-06 20:06:33 +00:00
- **`port`**: _string | number | (string | number)[]_: _Optional_: A port(or array of ports) to kill if running a server. _NOTE_: it is important to provide this option if running a server else the process may not terminate properly
2023-11-01 05:01:17 +00:00
- **`first_run`**: _boolean_: _Optional_: If the preflight should run on first run. Default `false`.
2023-10-29 07:35:26 +00:00
### Redeployment
For continuos deployment and integration there needs to be a text file located in your project which the application can watch. Any time the content of this file is changed the application will rebuild and rerun your `start` command.