-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
137 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,12 @@ | ||
{ | ||
"installation": "Installation", | ||
"commandkit-setup": "CommandKit Setup", | ||
"commandkit.config.js-options": "CommandKit Config Options", | ||
"command-file-setup": "Commands Setup", | ||
"event-file-setup": "Events Setup", | ||
"validation-file-setup": "Validations Setup", | ||
"buttonkit": "Using ButtonKit", | ||
"using-cli": "Using CommandKit CLI", | ||
"using-signals": "Using Signals", | ||
"migrating-from-djs-commander": "Migrating from DJS-Commander" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import { Callout } from 'nextra/components'; | ||
|
||
# commandkit.config.js options | ||
|
||
<Callout type="warning"> | ||
This is currently only available in the [development | ||
version](/docs/installation#development-version) of CommandKit. | ||
</Callout> | ||
|
||
CommandKit CLI can be configured using `commandkit.config` file in the root of your project directory (for example, by `package.json`). You can use either of the following files: | ||
|
||
- `commandkit.js` | ||
- `commandkit.config.js` | ||
- `commandkit.mjs` | ||
- `commandkit.config.mjs` | ||
- `commandkit.cjs` | ||
- `commandkit.config.cjs` | ||
- `commandkit.json` | ||
- `commandkit.config.json` | ||
|
||
Throughout this guide, we'll be using `commandkit.config.mjs` as an example. | ||
|
||
The following is the sample configuration required to run your bot: | ||
|
||
```js title="commandkit.config.mjs" | ||
import { defineConfig } from 'commandkit'; | ||
|
||
export default defineConfig({ | ||
src: 'src', // The source directory of your project. | ||
main: 'index.mjs', // The JavaScript entry point of your project. | ||
}); | ||
``` | ||
|
||
## Options | ||
|
||
### `src`: string | ||
|
||
The source directory of the project. This is where your source code lives. This is a required option. | ||
|
||
### `main`: string | ||
|
||
The JavaScript entry point of your project. This is a required option. | ||
|
||
For example, if your source is structured as `src/index.ts`, you'd need to set this option to `index.mjs`. This is because CommandKit always compiles your source code to esm format. | ||
|
||
### `watch`: boolean | ||
|
||
Whether to watch for file changes or not. This is an optional option. The default value is `true`. | ||
|
||
### `outDir`: string | ||
|
||
The output directory to emit the production build to. This is an optional option. The default value is `dist`. | ||
|
||
### `envExtra`: boolean | ||
|
||
Extra env utilities to load. This allows you to load environment variables in different formats, like `Date`, `JSON`, `Boolean`, etc. This is an optional option. The default value is set to `true`. | ||
|
||
### `nodeOptions`: string[] | ||
|
||
Options to pass to Node.js. This is an optional option. The default value is `[]`. | ||
|
||
### `clearRestartLogs`: boolean | ||
|
||
Whether or not to clear default restart logs. This is an optional option. The default value is `true`. | ||
|
||
#### `minify`: boolean | ||
|
||
Whether or not to minify the production build. This is an optional option. The default value is `false`. | ||
|
||
### `sourcemap`: boolean | 'inline' | ||
|
||
Whether or not to include sourcemaps in the production build. This is an optional option. The default value is `false`. | ||
|
||
### `antiCrash`: boolean | ||
|
||
Whether or not to inject anti-crash script in the production build. This is an optional option. The default value is `true`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { Callout } from 'nextra/components'; | ||
|
||
# Using CommandKit CLI | ||
|
||
<Callout type="warning"> | ||
This is currently only available in the [development | ||
version](/docs/installation#development-version) of CommandKit. | ||
</Callout> | ||
|
||
CommandKit CLI allows you to start and build your bot application. | ||
|
||
To get a list of the available CLI commands, run the following command inside your project directory: | ||
|
||
```sh | ||
npx commandkit --help | ||
``` | ||
|
||
The output should look something like this: | ||
|
||
```sh | ||
Usage: commandkit [options] [command] | ||
|
||
Options: | ||
-h, --help display help for command | ||
|
||
Commands: | ||
dev [options] Start your bot in development mode. | ||
start [options] Start your bot in production mode after running the build command. | ||
build [options] Build your project for production usage. | ||
help [command] display help for command | ||
``` | ||
|
||
<Callout type="info"> | ||
CommandKit does not perform type checking on your code. You need to do that yourself using{' '} | ||
<code>tsc --noEmit</code> command or any other tool of your choice. | ||
</Callout> | ||
|
||
# Available commands | ||
|
||
## Build | ||
|
||
`commandkit build` creates an optimized production build of your bot application. By default, commandkit emits the build to `dist/` directory in your project. It supports typescript out of the box. | ||
|
||
CommandKit also injects anti-crash script in your production build to prevent your bot from crashing due to cases like unhandled promise rejections. Although, it's recommended to handle these cases yourself. You can disable this behavior by setting `antiCrash: false` in your `commandkit.config.js` file. | ||
|
||
## Development | ||
|
||
`commandkit dev` starts your bot in development mode. It supports hot reloading out of the box to automatically restart your bot when you make changes to your code. CommandKit automatically loads your environment variables from `.env` file in your project directory, without you having to worry about it. It also supports typescript out of the box. | ||
|
||
## Production | ||
|
||
`commandkit start` starts your bot in production mode. You need to run `commandkit build` before running this command. This command also loads the environment variables from `.env` file in your project directory. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.