Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ib caido dev cli #33

Merged
merged 2 commits into from
Jan 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .vitepress/sidebars/guides.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ export const guidesSidebar: DefaultTheme.SidebarItem[] = [
text: "Getting Started",
link: "/guides/",
},
{
text: "Configuring your Package",
link: "/guides/config",
},
],
},
{
Expand Down
8 changes: 6 additions & 2 deletions .vitepress/sidebars/reference.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,17 @@ export const referenceSidebar: DefaultTheme.SidebarItem[] = [
text: "Files",
items: [
{
text: "manifest.json",
link: "/reference/manifest.md",
text: "caido.config.ts",
link: "/reference/config.md",
},
{
text: "plugin_packages.json",
link: "/reference/plugin_packages.md",
},
{
text: "manifest.json",
link: "/reference/manifest.md",
},
],
},
];
91 changes: 91 additions & 0 deletions src/guides/config.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# Configuring your Package

Caido packages are configured using the `caido.config.ts` file. This file is located in the root of your plugin's directory.
This file is used by the `caido-dev` CLI to build your plugin into a `plugin_package.zip` file.

If you've created a new package with `pnpm create @caido-community/plugin`, the `caido.config.ts` file will be created for you.

Here's what a typical `caido.config.ts` file looks like:

```ts
import { defineConfig } from "@caido-community/dev";

export default defineConfig({
id: "my-plugin",
name: "My Plugin",
description: "A plugin for Caido",
version: "0.0.0",
author: {
name: "Caido Labs Inc.",
email: "[email protected]",
url: "https://caido.io"
},
plugins: [
{
kind: "frontend",
id: "my-frontend",
name: "My Frontend",
root: "packages/my-frontend",
backend: {
id: "my-backend"
}
},
{
kind: "backend",
id: "my-backend",
name: "My Backend",
root: "packages/my-backend",
}
]
});
```

You can find more information about the `caido.config.ts` file in the [Config Reference](/reference/config) page.

## Updating Package Details

Most plugins will only need to update the `id`, `name`, `description`, `author`, and `version` fields.

### ID

The `id` field is a unique identifier used to identify your plugin in Caido. This must be a string that is unique across all plugins.

### Name

The `name` field is the name of your plugin. This is the name that will be displayed when a user installs your plugin.

Keep your names concise, and avoid using the term "Caido" in the name. (e.g. "Auth Tester" instead of "Caido Auth Tester")

### Description

The `description` field is a short description of your plugin. This will be displayed when a user installs your plugin.

### Author

The `author` field is an object comprised of a `name`, `email`, and `url`.

- `name` is the name of the author.
- `email` is a contact email address for the author.
- `url` is a URL that links to the author's website.

### Version

The `version` field is a string that represents the version of your plugin using [Semantic Versioning](https://semver.org/).

When creating a new release of your plugin, you should increment this version number.

## Updating Plugin Details

Packages are comprised of one or more plugins that may need to be configured differently. You can find more information about plugins in the [Plugin Architecture](/concepts/essentials/package) page.

These options usually don't need to be updated, but you can if needed.

### Frontend Plugins

For frontend plugins, `caido-dev` uses [Vite](https://vitejs.dev/) to build your plugin. This means you can specify additional Vite options in your `caido.config.ts` file.

If you created your package with `pnpm create @caido-community/plugin`, the `caido.config.ts` file will be created with a default set of Vite options. We suggest you start with these options, and then update them if needed.

### Backend Plugins

For backend plugins, `caido-dev` uses [tsup](https://tsup.egoist.dev/) to build your plugin. The `tsup` options are not currently configurable.
2 changes: 1 addition & 1 deletion src/guides/distribution/repository.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ Now that your repository and key-pair are ready, it’s time to create a release
1. [Create a Github Action Secret](https://docs.github.com/en/actions/security-for-github-actions/security-guides/using-secrets-in-github-actions#creating-secrets-for-a-repository) called `PRIVATE_KEY` with the content of the private key generated in [step 3](#3-generate-a-key-pair).
1. Go to the `Actions` tab of your repository and trigger the `Release` workflow.

This will create a release with the version specified in your project's [manifest.json](/reference/manifest) file.
This will create a release with the version specified in your project's [caido.config.ts](/guides/config#version) file.

<img width="800" alt="Store release Github Workflow" src="/_images/store_release.png" center/>

Expand Down
73 changes: 73 additions & 0 deletions src/reference/config.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# caido.config.ts

The `caido.config.ts` file is used to configure your package.

```ts
import { defineConfig } from "@caido-community/dev";

export default defineConfig({
id: "my-plugin",
name: "My Plugin",
description: "A plugin for Caido",
version: "0.0.0",
author: {
name: "Caido Labs Inc.",
email: "[email protected]",
url: "https://caido.io"
},
plugins: [
{
kind: "frontend",
id: "my-frontend",
name: "My Frontend",
root: "packages/my-frontend",
backend: {
id: "my-backend"
}
},
{
kind: "backend",
id: "my-backend",
name: "My Backend",
root: "packages/my-backend",
}
]
});
```

## Global Options

| Option | Type | Required | Description |
| --- | --- | --- | --- |
| id | `string` | Yes | Must be unique and must only consist of lowercase letters, numbers, hyphens and underscores (the order of which must satisfy the regex: `^[a-z]+(?:[_-][a-z0-9]+)*$`). |
| name | `string` | Yes | The name of your plugin. This is the name that will be displayed when a user installs your plugin. |
| description | `string` | Yes | The description of your plugin. This is the description that will be displayed when a user installs your plugin. |
| version | `string` | Yes | Represents the version of your plugin using [Semantic Versioning](https://semver.org/). |

## Author Options

| Option | Type | Required | Description |
| --- | --- | --- | --- |
| name | `string` | Yes | The name of the author of your plugin. |
| email | `string` | No | The email of the author of your plugin. |
| url | `string` | No | The URL of the author of your plugin. |

## Frontend Plugin Options

| Option | Type | Required | Description |
| --- | --- | --- | --- |
| kind | `"frontend"` | Yes | The kind of plugin. |
| id | `string` | Yes | The id of the plugin. |
| name | `string` | No | The name of the plugin. Defaults to the id. |
| root | `string` | Yes | The root directory of the frontend plugin. (e.g. `packages/my-frontend`) |
| backend.id | `string` | Yes | The id of the backend plugin that this frontend plugin is associated with. |
| vite | [`ViteConfig`](https://vite.dev/config/) | No | Additional Vite configuration for the frontend plugin. |

## Backend Plugin Options

| Option | Type | Required | Description |
| --- | --- | --- | --- |
| kind | `"backend"` | Yes | The kind of plugin. |
| id | `string` | Yes | The id of the plugin. |
| name | `string` | No | The name of the plugin. Defaults to the id. |
| root | `string` | Yes | The root directory of the backend plugin. (e.g. `packages/my-backend`) |
2 changes: 2 additions & 0 deletions src/reference/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@ If you need a refresher on how a function works, or whether a certain feature is

## Files

- **[caido.config.ts](./config.md)** - caido.config.ts field definitions
- **[plugin_packages.json](./plugin_packages.md)** - plugin_packages.json field definitions
- **[manifest.json](./manifest.md)** - Manifest.json field definitions
Loading