|
3 | 3 | This repository acts as a directory for Conductor plugins officially supported |
4 | 4 | by Source Academy. |
5 | 5 |
|
| 6 | +## Using this directory |
| 7 | + |
| 8 | +### As a static asset |
| 9 | + |
| 10 | +You may import the `plugins` array directly after installing this repository |
| 11 | +(as `import { plugins } from 'plugin-directory'`). This will cause the array |
| 12 | +to be bundled together at build time. |
| 13 | + |
| 14 | +Caution: when including this repository as a dependency in your `package.json`, |
| 15 | +**be sure to specify a specific commit hash or tag**. |
| 16 | +Failure to do this may cause problems with CI/CD due to lockfile issues when this |
| 17 | +directory is updated. |
| 18 | + |
| 19 | +### Retrieved dynamically |
| 20 | + |
| 21 | +The `plugins` array is available dynamically at |
| 22 | +[`https://source-academy.github.io/plugin-directory/directory.json`](https://source-academy.github.io/plugin-directory/directory.json). |
| 23 | + |
| 24 | +In this case, you probably do not want to bundle the array at build time. You may |
| 25 | +bundle only the utility functions by importing from `'plugin-directory/dist/util'` instead. |
| 26 | + |
| 27 | +You can reconstruct the `pluginMap` using the `generatePluginMap` utility function. |
| 28 | + |
6 | 29 | ## Plugin definitions |
7 | 30 |
|
8 | 31 | Plugin definitions should follow the `IPluginDefinition` interface. |
9 | 32 |
|
10 | | -Plugins consist of a name, an optional description, and a record mapping |
| 33 | +Plugins consist of an ID, a name, an optional description, and a record mapping |
11 | 34 | execution environment to a URL to the plugin's entrypoint file. |
12 | 35 |
|
13 | | -## Adding a new Plugin |
14 | | - |
15 | 36 | To add a new plugin to the plugins directory, define your plugin according to |
16 | | -the interface, and add the definition to the `plugins` array in `src/index.ts`. |
17 | | - |
18 | | -Please export your plugin definitions `as const`. |
| 37 | +the interface, and add the definition to the `plugins` array in `src/plugins.ts`. |
19 | 38 |
|
20 | 39 | For plugins meant to use Conductor's Module API, create an entry for |
21 | 40 | `PluginType.MODULE`, and do not create one for `PluginType.RUNNER`. |
22 | 41 |
|
23 | 42 | For plugins meant to use the Source Academy Frontend's API, create an entry for |
24 | 43 | `PluginType.WEB`. |
| 44 | + |
| 45 | +## Local testing |
| 46 | + |
| 47 | +You may test any changes (e.g. adding your new language) locally by running `yarn start`. |
| 48 | +This starts a development server and compiles the directory in watch mode (recompiling on any changes). |
| 49 | + |
| 50 | +The directory will be available at [`http://localhost:8126/directory.json`](http://localhost:8126/directory.json). |
| 51 | +On the Source Academy frontend, set the feature flag `plugindir.url` to point to this location. |
0 commit comments