diff --git a/.mocharc.json b/.mocharc.json deleted file mode 100644 index fa25f20..0000000 --- a/.mocharc.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "require": [ - "ts-node/register" - ], - "watch-extensions": [ - "ts" - ], - "recursive": true, - "reporter": "spec", - "timeout": 60000, - "node-option": [ - "loader=ts-node/esm", - "experimental-specifier-resolution=node" - ] -} diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index da748c7..3836e4c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,113 +1,63 @@ - - # Contributing -Hey, thanks for your interest in contributing to Dokploy CLI! We appreciate your help and taking your time to contribute. - - -Before you start, please first discuss the feature/bug you want to add with the owners and comunity via github issues. - -We have a few guidelines to follow when contributing to this project: - -- [Commit Convention](#commit-convention) -- [Setup](#setup) -- [Development](#development) -- [Build](#build) -- [Pull Request](#pull-request) - -## Commit Convention - -Before you craete a Pull Request, please make sure your commit message follows the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) specification. - -### Commit Message Format -``` -[optional scope]: - -[optional body] - -[optional footer(s)] -``` - -#### Type -Must be one of the following: - -* **feat**: A new feature -* **fix**: A bug fix -* **docs**: Documentation only changes -* **style**: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc) -* **refactor**: A code change that neither fixes a bug nor adds a feature -* **perf**: A code change that improves performance -* **test**: Adding missing tests or correcting existing tests -* **build**: Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm) -* **ci**: Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs) -* **chore**: Other changes that don't modify `src` or `test` files -* **revert**: Reverts a previous commit - -Example: -``` -feat: add new feature -``` - - +Thanks for your interest in contributing to Dokploy CLI! +Before you start, please discuss the feature/bug via [GitHub issues](https://github.com/Dokploy/cli/issues). ## Setup -Before you start, please make the clone based on the `main` branch. - ```bash git clone https://github.com/Dokploy/cli.git cd cli pnpm install ``` +Create a `.env` file with your credentials: + +```env +DOKPLOY_URL="https://your-server.dokploy.com" +DOKPLOY_API_KEY="YOUR_API_KEY" +``` + ## Development -First step is to authenticate, you can connect to a dokploy localhost or a remote dokploy server. - -Authenticate - ```bash -./bin/dev.js authenticate -``` +# Run in dev mode +pnpm run dev -- project all -Let's take the example to create a new command for application called `start`. +# Regenerate commands from OpenAPI spec +pnpm run generate -You can use the generators from OCLIF to create a new command. - -```bash -oclif generate command application:start -``` - -To run the command, you can use the following command: - -```bash -./bin/dev.js application:start or ./bin/dev.js start -``` - -## Build - -```bash +# Build pnpm run build + +# Lint & format +pnpm run lint ``` -## Publish +### Updating commands -```bash -pnpm run publish +Commands in `src/generated/commands.ts` are auto-generated from `openapi.json`. Never edit that file manually. To update: + +1. Replace `openapi.json` with the latest spec from the [Dokploy repo](https://github.com/Dokploy/dokploy) +2. Run `pnpm run generate` + +## Commit convention + +Follow [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/): + +``` +feat: add new feature +fix: resolve bug +docs: update readme +chore: bump version ``` +## Pull requests -## Pull Request - -- The `main` branch is the source of truth and should always reflect the latest stable release. -- Create a new branch for each feature or bug fix. -- Make sure to add tests for your changes. -- Make sure to update the documentation for any changes Go to the [docs.dokploy.com](https://docs.dokploy.com) website to see the changes. -- When creating a pull request, please provide a clear and concise description of the changes made. -- If you include a video or screenshot, would be awesome so we can see the changes in action. -- If your pull request fixes an open issue, please reference the issue in the pull request description. -- Once your pull request is merged, you will be automatically added as a contributor to the project. +- Branch from `main` +- Provide a clear description of your changes +- Reference any related issues +- Include a screenshot/video if applicable Thank you for your contribution! - diff --git a/readme.md b/readme.md index d4cc848..886366f 100644 --- a/readme.md +++ b/readme.md @@ -1,131 +1,144 @@ # Dokploy CLI - - -Dokploy CLI is a powerful and versatile command-line tool designed to remotely manage your Dokploy server. It simplifies the process of creating, deploying, and managing applications and databases. - - - -## Table of Contents - -- [Installation](#installation) -- [Usage](#usage) -- [Commands](#commands) - - [Authentication](#authentication) - - [Project Management](#project-management) - - [Application Management](#application-management) - - [Environment Management](#environment-management) - - [Database Management](#database-management) -- [Contributing](#contributing) -- [Support](#support) -- [License](#license) +Dokploy CLI is a command-line tool to manage your Dokploy server remotely. It provides **449 commands** auto-generated from the Dokploy OpenAPI spec, covering every API endpoint. ## Installation -```sh-session -$ npm install -g @dokploy/cli +```bash +npm install -g @dokploy/cli ``` +## Authentication + +### Option 1: Using the `auth` command + +```bash +dokploy auth -u https://panel.dokploy.com -t YOUR_API_KEY +``` + +### Option 2: Environment variables + +```bash +export DOKPLOY_URL="https://panel.dokploy.com" +export DOKPLOY_API_KEY="YOUR_API_KEY" +``` + +### Option 3: `.env` file + +Create a `.env` file in your working directory: + +```env +DOKPLOY_URL="https://panel.dokploy.com" +DOKPLOY_API_KEY="YOUR_API_KEY" +``` + +The CLI loads it automatically. Shell environment variables take priority over the `.env` file. + ## Usage -```sh-session -$ dokploy COMMAND -running command... - -$ dokploy --version -dokploy/0.0.0 darwin-arm64 node-v18.18.0 - -$ dokploy --help [COMMAND] -USAGE - $ dokploy COMMAND -... +```bash +dokploy [options] ``` -## Commands +### Examples -### Authentication +```bash +# List all projects +dokploy project all -- `dokploy authenticate`: Authenticate with the Dokploy server. -- `dokploy verify`: Verify current authentication. +# Get a specific project +dokploy project one --projectId abc123 -### Project Management +# Create an application +dokploy application create --name "my-app" --environmentId env123 -- `dokploy project:create`: Create a new project. -- `dokploy project:info`: Get information about an existing project. -- `dokploy project:list`: List all projects. +# Deploy an application +dokploy application deploy --applicationId app123 -### Environment Management +# Create a postgres database +dokploy postgres create --name "my-db" --environmentId env123 -- `dokploy environment:create`: Create a new environment. -- `dokploy environment:delete`: Delete an existing environment. +# Stop a database +dokploy postgres stop --postgresId pg123 -### Application Management - -- `dokploy app:create`: Create a new application. -- `dokploy app:delete`: Delete an existing application. -- `dokploy app:deploy`: Deploy an application. -- `dokploy app:stop`: Stop a running application. - -### Enviroment Management - -- `dokploy env pull `: Pull environment variables from Dokploy in a . -- `dokploy env push `: Push environment variables to Dokploy from a . - -### Database Management - -Dokploy supports various types of databases: - -#### MariaDB - -- `dokploy database:mariadb:create` -- `dokploy database:mariadb:delete` -- `dokploy database:mariadb:deploy` -- `dokploy database:mariadb:stop` - -#### MongoDB - -- `dokploy database:mongo:create` -- `dokploy database:mongo:delete` -- `dokploy database:mongo:deploy` -- `dokploy database:mongo:stop` - -#### MySQL - -- `dokploy database:mysql:create` -- `dokploy database:mysql:delete` -- `dokploy database:mysql:deploy` -- `dokploy database:mysql:stop` - -#### PostgreSQL - -- `dokploy database:postgres:create` -- `dokploy database:postgres:delete` -- `dokploy database:postgres:deploy` -- `dokploy database:postgres:stop` - -#### Redis - -- `dokploy database:redis:create` -- `dokploy database:redis:delete` -- `dokploy database:redis:deploy` -- `dokploy database:redis:stop` - -For more information about a specific command, use: - -```sh-session -$ dokploy [COMMAND] --help +# Get raw JSON output +dokploy project all --json ``` +### Getting help + +```bash +# List all groups +dokploy --help + +# List actions in a group +dokploy application --help + +# See options for a specific action +dokploy application deploy --help +``` + +## Available command groups + +| Group | Commands | Group | Commands | +|---|---|---|---| +| `admin` | 1 | `notification` | 38 | +| `ai` | 9 | `organization` | 10 | +| `application` | 29 | `patch` | 12 | +| `backup` | 11 | `port` | 4 | +| `bitbucket` | 7 | `postgres` | 14 | +| `certificates` | 4 | `preview-deployment` | 4 | +| `cluster` | 4 | `project` | 8 | +| `compose` | 28 | `redirects` | 4 | +| `deployment` | 8 | `redis` | 14 | +| `destination` | 6 | `registry` | 7 | +| `docker` | 7 | `rollback` | 2 | +| `domain` | 9 | `schedule` | 6 | +| `environment` | 7 | `security` | 4 | +| `gitea` | 8 | `server` | 16 | +| `github` | 6 | `settings` | 49 | +| `gitlab` | 7 | `ssh-key` | 6 | +| `git-provider` | 2 | `sso` | 10 | +| `license-key` | 6 | `stripe` | 7 | +| `mariadb` | 14 | `swarm` | 3 | +| `mongo` | 14 | `user` | 18 | +| `mounts` | 6 | `volume-backups` | 6 | +| `mysql` | 14 | | | + +## Development + +```bash +# Install dependencies +pnpm install + +# Run in dev mode +pnpm run dev -- project all + +# Regenerate commands from OpenAPI spec +pnpm run generate + +# Build +pnpm run build + +# Lint & format +pnpm run lint +``` + +### Updating commands + +Commands are auto-generated from `openapi.json`. To update: + +1. Replace `openapi.json` with the latest spec from the [Dokploy repo](https://github.com/Dokploy/dokploy) +2. Run `pnpm run generate` +3. Build with `pnpm run build` + ## Contributing If you want to contribute to Dokploy CLI, please check out our [Contributing Guide](https://github.com/Dokploy/cli/blob/main/CONTRIBUTING.md). ## Support -If you encounter any issues or have any questions, please [open an issue](https://github.com/yourusername/dokploy/issues) in our GitHub repository. +If you encounter any issues or have any questions, please [open an issue](https://github.com/Dokploy/cli/issues) in our GitHub repository. ## License diff --git a/src/index.ts b/src/index.ts index 3a4e010..3e6b1c5 100644 --- a/src/index.ts +++ b/src/index.ts @@ -22,7 +22,9 @@ program registerAuthCommand(program); registerGeneratedCommands(program); -program.parseAsync(process.argv).catch((err) => { +const argv = process.argv.filter((arg) => arg !== "--"); + +program.parseAsync(argv).catch((err) => { console.error(chalk.red(err.message)); process.exit(1); });