From edbe6e45b22aaafc64524a179b3d6798f497bc61 Mon Sep 17 00:00:00 2001 From: Jesse Wierzbinski Date: Thu, 13 Jun 2024 23:26:20 -1000 Subject: [PATCH] fix: :bug: Fix incorrect docs, make exit code 0 instead of 1 --- docker-compose.yml | 2 +- docs/installation.md | 16 ++++++++-------- drizzle/db.ts | 4 ++-- index.ts | 8 ++++---- packages/config-manager/index.ts | 5 ++++- utils/meilisearch.ts | 2 +- 6 files changed, 20 insertions(+), 17 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 5352b789..c6535641 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -11,7 +11,7 @@ services: command: "cli start --all-threads" networks: - lysand-net - depends-on: + depends_on: - db - redis - meilisearch diff --git a/docs/installation.md b/docs/installation.md index 9771e1e5..38857fa9 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -1,6 +1,6 @@ # Installation -### Requirements +## Requirements - The [Bun Runtime](https://bun.sh), version 1.1.13 or later (usage of the latest version is recommended) - Lysand will work on lower versions than 1.1.13, but only the latest version is supported @@ -13,7 +13,7 @@ > > We will not be offering support to Windows or macOS users. If you are using one of these operating systems, please use a virtual machine or container to run Lysand. -### With Docker/Podman +## With Docker/Podman Docker is the recommended way to run Lysand (podman also works). To run Lysand with Docker, follow these steps: @@ -23,12 +23,12 @@ Docker is the recommended way to run Lysand (podman also works). To run Lysand w curl -o docker-compose.yml https://raw.githubusercontent.com/lysand-org/lysand/main/docker-compose.yml ``` 2. Edit the `docker-compose.yml` file to set up the database connection and other settings -3. Download the `config.toml.example` file from the repository +3. Download the `config.example.toml` file from the repository ```bash -curl -o config.toml.example https://raw.githubusercontent.com/lysand-org/lysand/main/config.toml.example +curl -o config.example/toml https://raw.githubusercontent.com/lysand-org/lysand/main/config/config.example.toml ``` -4. Edit the `config.toml.example` file to set up the database connection and other settings, then place it inside `config/` (create the `config/` directory if it does not exist) +4. Edit the `config.example.toml` file to set up the database connection and other settings, rename it to `config.toml`, then place it inside `config/` (create the `config/` directory if it does not exist) 5. Run the following command to start the server: ```bash @@ -37,7 +37,7 @@ docker-compose up You may need root privileges to run Docker commands. -### From Source +## From Source 1. Clone this repository @@ -68,7 +68,7 @@ bun prod-build You may now start the server with `bun start`. It lives in the `dist/` directory, all the other code can be removed from this point onwards. -### Running the Server +## Running the Server Database migrations are run automatically on startup. @@ -81,7 +81,7 @@ Please see the [CLI documentation](cli.md) for more information on how to use th > > This is possible by following the instructions in [this file](glitch-soc.md). -### Updating the server +## Updating the server Updating the server is as simple as pulling the latest changes from the repository and running `bun prod-build` again. You may need to run `bun install` again if there are new dependencies. diff --git a/drizzle/db.ts b/drizzle/db.ts index 95b683aa..51119b5f 100644 --- a/drizzle/db.ts +++ b/drizzle/db.ts @@ -34,7 +34,7 @@ export const setupDatabase = async ( "Database", "Failed to connect to database. Please check your configuration.", ); - process.exit(1); + process.exit(); } // Migrate the database @@ -52,7 +52,7 @@ export const setupDatabase = async ( "Database", "Failed to migrate database. Please check your configuration.", ); - process.exit(1); + process.exit(); } info && (await logger.log(LogLevel.Info, "Database", "Database migrated")); diff --git a/index.ts b/index.ts index e728ecb7..5ff5d090 100644 --- a/index.ts +++ b/index.ts @@ -73,7 +73,7 @@ if (isEntry) { "Server", chalk.gray(`${privateKey};${publicKey}`), ); - process.exit(1); + process.exit(); } // Try and import the key @@ -104,7 +104,7 @@ if (isEntry) { "Server", "The JWT key could not be imported! You may generate a new one by removing the old one from the config and restarting the server (this will invalidate all current JWTs).", ); - process.exit(1); + process.exit(); } if ( @@ -142,7 +142,7 @@ if (isEntry) { `Generated key: ${chalk.gray(base64)}`, ); - process.exit(1); + process.exit(); } } @@ -245,7 +245,7 @@ if (config.frontend.enabled) { "Server", `Frontend URL is not a valid URL: ${config.frontend.url}`, ); - process.exit(1); + process.exit(); } // Check if frontend is reachable diff --git a/packages/config-manager/index.ts b/packages/config-manager/index.ts index a661d3d9..cf0c02a7 100644 --- a/packages/config-manager/index.ts +++ b/packages/config-manager/index.ts @@ -6,6 +6,7 @@ */ import { loadConfig, watchConfig } from "c12"; +import { fromZodError } from "zod-validation-error"; import { type Config, configValidator } from "./config.type"; const { config } = await watchConfig({ @@ -21,7 +22,9 @@ const { config } = await watchConfig({ const parsed = await configValidator.safeParseAsync(config); if (!parsed.success) { - process.exit(1); + console.error("Invalid config file:"); + console.error(fromZodError(parsed.error).message); + process.exit(); } const exportedConfig = parsed.data; diff --git a/utils/meilisearch.ts b/utils/meilisearch.ts index 8aacc6c1..78d98962 100644 --- a/utils/meilisearch.ts +++ b/utils/meilisearch.ts @@ -44,7 +44,7 @@ export const connectMeili = async (logger: MultiLogManager | LogManager) => { "Meilisearch", "Error while connecting to Meilisearch", ); - process.exit(1); + process.exit(); } };