Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
aa2cfa2
typings/plugin.d.ts: Create
nhooyr Oct 30, 2020
481df70
ci/dev/test.sh: Pass through args
nhooyr Oct 30, 2020
e08a55d
src/node/plugin.ts: Implement new plugin API
nhooyr Oct 30, 2020
bea185b
plugin: Add basic loading test
nhooyr Oct 30, 2020
82e8a00
Fix CI
nhooyr Oct 30, 2020
30d2962
src/node/plugin.ts: Warn on duplicate plugin and only load first
nhooyr Oct 30, 2020
ef97100
plugin.test.ts: Make it clear iconPath is a path
nhooyr Oct 30, 2020
f4d7f00
plugin.ts: Fixes for @wbobeirne
nhooyr Nov 3, 2020
75e52a3
plugin.ts: Fixes for @code-asher
nhooyr Nov 3, 2020
8d3a772
plugin.d.ts: Document plugin priority correctly
nhooyr Nov 3, 2020
6638daf
plugin.d.ts: Add explicit path field and adjust types to reflect
nhooyr Nov 3, 2020
fed545e
plugin.d.ts -> pluginapi.d.ts
nhooyr Nov 3, 2020
afff86a
plugin.ts: Adjust to implement pluginapi.d.ts correctly
nhooyr Nov 4, 2020
e03bbe3
routes/apps.ts: Implement /api/applications endpoint
nhooyr Nov 4, 2020
139a28e
plugin.ts: Describe private counterpart functions
nhooyr Nov 4, 2020
6870948
plugin.ts: Make application endpoint paths absolute
nhooyr Nov 4, 2020
2a13d00
plugin.ts: Add homepageURL to plugin and application
nhooyr Nov 4, 2020
af73b96
routes/apps.ts: Add example output
nhooyr Nov 4, 2020
706bc23
plugin: Fixes for CI
nhooyr Nov 4, 2020
8a8159c
plugin: More review fixes
nhooyr Nov 5, 2020
14f408a
plugin: Plugin modules now export a single top level identifier
nhooyr Nov 5, 2020
9453f89
plugin.ts: Fix usage of routerPath in mount
nhooyr Nov 5, 2020
197a09f
plugin: Test endpoints via supertest
nhooyr Nov 6, 2020
9d39c53
plugin: Give test-plugin some html to test overlay
nhooyr Nov 6, 2020
277211c
plugin: Make init and applications callbacks optional
nhooyr Nov 6, 2020
fe399ff
Fix formatting
nhooyr Nov 6, 2020
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
Prev Previous commit
Next Next commit
plugin: Plugin modules now export a single top level identifier
Makes typing much easier. Addresse's Will's last comment.
  • Loading branch information
nhooyr committed Nov 6, 2020
commit 14f408a837cbdd301545d4241da4e6ecd90857cb
7 changes: 6 additions & 1 deletion src/node/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,11 +189,16 @@ export class PluginAPI {
)
}

const pluginModule = require(dir)
if (!pluginModule.plugin) {
throw new Error("plugin module does not export a plugin")
}

const p = {
name: packageJSON.name,
version: packageJSON.version,
modulePath: dir,
...require(dir),
...pluginModule.plugin,
} as Plugin

if (!p.displayName) {
Expand Down
52 changes: 27 additions & 25 deletions test/test-plugin/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,35 @@ import * as express from "express"
import * as fspath from "path"
import * as pluginapi from "../../../typings/pluginapi"

export const displayName = "Test Plugin"
export const routerPath = "/test-plugin"
export const homepageURL = "https://example.com"
export const description = "Plugin used in code-server tests."
export const plugin: pluginapi.Plugin = {
displayName: "Test Plugin",
routerPath: "/test-plugin",
homepageURL: "https://example.com",
description: "Plugin used in code-server tests.",

export function init(config: pluginapi.PluginConfig) {
config.logger.debug("test-plugin loaded!")
}
init: (config) => {
config.logger.debug("test-plugin loaded!")
},

export function router(): express.Router {
const r = express.Router()
r.get("/goland/icon.svg", (req, res) => {
res.sendFile(fspath.resolve(__dirname, "../public/icon.svg"))
})
return r
}
router: () => {
const r = express.Router()
r.get("/goland/icon.svg", (req, res) => {
res.sendFile(fspath.resolve(__dirname, "../public/icon.svg"))
})
return r
},

export function applications(): pluginapi.Application[] {
return [
{
name: "Test App",
version: "4.0.0",
iconPath: "/icon.svg",
path: "/test-app",
applications: () => {
return [
{
name: "Test App",
version: "4.0.0",
iconPath: "/icon.svg",
path: "/test-app",

description: "This app does XYZ.",
homepageURL: "https://example.com",
},
]
description: "This app does XYZ.",
homepageURL: "https://example.com",
},
]
},
}
5 changes: 3 additions & 2 deletions typings/pluginapi.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ import * as express from "express"
/**
* Plugins
*
* Plugins are just node modules.
* Plugins are just node modules that contain a top level export "plugin" that implements
* the Plugin interface.
*
* 1. code-server uses $CS_PLUGIN to find plugins.
*
Expand Down Expand Up @@ -78,7 +79,7 @@ import * as express from "express"
*/

/**
* Your plugin module must implement this interface.
* Your plugin module must have a top level export "plugin" that implements this interface.
*
* The plugin's router will be mounted at <code-sever-root>/<plugin-path>
*/
Expand Down