Skip to content

Commit 8fadc3a

Browse files
committed
initial commit
0 parents  commit 8fadc3a

File tree

11 files changed

+1539
-0
lines changed

11 files changed

+1539
-0
lines changed

.gitignore

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
node_modules/
2+
dist/
3+
4+
.yarn/*
5+
!.yarn/patches
6+
!.yarn/plugins
7+
!.yarn/releases
8+
!.yarn/sdks
9+
!.yarn/versions
10+
11+
# Swap the comments on the following lines if you wish to use zero-installs
12+
# In that case, don't forget to run `yarn config set enableGlobalCache false`!
13+
# Documentation here: https://yarnpkg.com/features/caching#zero-installs
14+
15+
#!.yarn/cache
16+
.pnp.*

README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Source Academy Plugin Directory
2+
3+
This repository acts as a directory for Conductor plugins officially supported
4+
by Source Academy.
5+
6+
## Plugin definitions
7+
8+
Plugin definitions should follow the `IPluginDefinition` interface.
9+
10+
Plugins consist of a name, an optional description, and a record mapping
11+
execution environment to a URL to the plugin's entrypoint file.
12+
13+
## Adding a new Plugin
14+
15+
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`.
19+
20+
For plugins meant to use Conductor's Module API, create an entry for
21+
`PluginType.MODULE`, and do not create one for `PluginType.RUNNER`.
22+
23+
For plugins meant to use the Source Academy Frontend's API, create an entry for
24+
`PluginType.WEB`.

package.json

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"name": "plugin-directory",
3+
"packageManager": "[email protected]",
4+
"version": "0.0.1",
5+
"description": "This repository acts as a directory for Conductor plugins officially supported by Source Academy.",
6+
"type": "module",
7+
"main": "dist/index.js",
8+
"scripts": {
9+
"build": "rollup -c",
10+
"prepack": "yarn build"
11+
},
12+
"repository": {
13+
"type": "git",
14+
"url": "git+https://github.com/source-academy/plugin-directory.git"
15+
},
16+
"author": "tsammeow",
17+
"license": "ISC",
18+
"files": [
19+
"dist"
20+
],
21+
"bugs": {
22+
"url": "https://github.com/source-academy/plugin-directory/issues"
23+
},
24+
"homepage": "https://github.com/source-academy/plugin-directory#readme",
25+
"devDependencies": {
26+
"@rollup/plugin-node-resolve": "^16.0.0",
27+
"@rollup/plugin-terser": "^0.4.4",
28+
"@rollup/plugin-typescript": "^12.1.2",
29+
"rollup": "^4.34.1",
30+
"tslib": "^2.8.1",
31+
"typescript": "^5.5.3"
32+
}
33+
}

rollup.config.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import nodeResolve from "@rollup/plugin-node-resolve";
2+
import terser from "@rollup/plugin-terser";
3+
import typescript from "@rollup/plugin-typescript";
4+
5+
export default [{
6+
plugins: [nodeResolve(), typescript()],
7+
input: "src/index.ts",
8+
output: {
9+
plugins: [terser({
10+
module: true,
11+
ecma: 2015,
12+
format: {
13+
preserve_annotations: true
14+
}
15+
})],
16+
dir: "dist",
17+
format: "es",
18+
sourcemap: true,
19+
}
20+
}];

src/index.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { soundsPlugin } from "./plugins/sounds";
2+
import type { IPluginDefinition } from "./types/IPluginDefinition";
3+
4+
function toRecord<const P extends IPluginDefinition[]>(plugins: P) {
5+
const pluginRecord: Record<P[number]["name"], IPluginDefinition> = {} as any; // to be populated
6+
for (const plugin of plugins) {
7+
// @ts-expect-error
8+
pluginRecord[plugin.name] = plugin;
9+
}
10+
return pluginRecord;
11+
}
12+
13+
export const plugins = /*#__PURE__*/ toRecord([
14+
soundsPlugin
15+
]);
16+
17+
export { PluginType } from "./types";

src/plugins/sounds.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { IPluginDefinition } from "../types";
2+
3+
export const soundsPlugin = {
4+
name: "sounds",
5+
resolutions: {
6+
// TODO: add sounds plugin resolutions
7+
}
8+
} as const satisfies IPluginDefinition;

src/types/IPluginDefinition.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import type { PluginType } from "./PluginType";
2+
3+
export interface IPluginDefinition {
4+
name: string;
5+
description?: string;
6+
resolutions: Partial<Record<PluginType, string>>;
7+
}

src/types/PluginType.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export enum PluginType {
2+
RUNNER = "runner",
3+
MODULE = "module",
4+
MODULE_LEGACY = "module_legacy",
5+
WEB = "web",
6+
NODE_JS = "nodejs",
7+
}

src/types/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export type { IPluginDefinition } from "./IPluginDefinition";
2+
export { PluginType } from "./PluginType";

tsconfig.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"compilerOptions": {
3+
"strict": true,
4+
"module": "ESNext",
5+
"moduleResolution": "bundler",
6+
"target": "ESNext",
7+
"outDir": "dist",
8+
"declaration": true,
9+
"sourceMap": true
10+
}
11+
}

0 commit comments

Comments
 (0)