mirror of https://git.tuxpa.in/a/code-server.git
plugin.ts: Make application endpoint paths absolute
This commit is contained in:
parent
139a28e0ea
commit
687094802e
|
@ -60,6 +60,8 @@ export class PluginAPI {
|
|||
// Add plugin key to each app.
|
||||
apps.push(
|
||||
...pluginApps.map((app) => {
|
||||
app = {...app, path: path.join(p.routerPath, app.path || "")}
|
||||
app = {...app, iconPath: path.join(app.path || "", app.iconPath)}
|
||||
return {
|
||||
...app,
|
||||
plugin: {
|
||||
|
@ -69,7 +71,7 @@ export class PluginAPI {
|
|||
|
||||
displayName: p.displayName,
|
||||
description: p.description,
|
||||
path: p.path,
|
||||
routerPath: p.routerPath,
|
||||
},
|
||||
}
|
||||
}),
|
||||
|
@ -192,8 +194,8 @@ export class PluginAPI {
|
|||
if (!p.description) {
|
||||
throw new Error("plugin missing description")
|
||||
}
|
||||
if (!p.path) {
|
||||
throw new Error("plugin missing path")
|
||||
if (!p.routerPath) {
|
||||
throw new Error("plugin missing router path")
|
||||
}
|
||||
|
||||
p.init({
|
||||
|
|
|
@ -21,7 +21,8 @@ describe("plugin", () => {
|
|||
version: "4.0.0",
|
||||
|
||||
description: "This app does XYZ.",
|
||||
iconPath: "/icon.svg",
|
||||
iconPath: "/test-plugin/test-app/icon.svg",
|
||||
path: "/test-plugin/test-app",
|
||||
|
||||
plugin: {
|
||||
name: "test-plugin",
|
||||
|
@ -30,7 +31,7 @@ describe("plugin", () => {
|
|||
|
||||
displayName: "Test Plugin",
|
||||
description: "Plugin used in code-server tests.",
|
||||
path: "/test-plugin",
|
||||
routerPath: "/test-plugin",
|
||||
},
|
||||
},
|
||||
],
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
out/index.js: src/index.ts
|
||||
yarn build
|
||||
# Typescript always emits, even on errors.
|
||||
yarn build || rm out/index.js
|
||||
|
||||
node_modules: package.json yarn.lock
|
||||
yarn
|
||||
|
|
|
@ -3,7 +3,7 @@ import * as fspath from "path"
|
|||
import * as pluginapi from "../../../typings/pluginapi"
|
||||
|
||||
export const displayName = "Test Plugin"
|
||||
export const path = "/test-plugin"
|
||||
export const routerPath = "/test-plugin"
|
||||
export const description = "Plugin used in code-server tests."
|
||||
|
||||
export function init(config: pluginapi.PluginConfig) {
|
||||
|
@ -24,6 +24,7 @@ export function applications(): pluginapi.Application[] {
|
|||
name: "Test App",
|
||||
version: "4.0.0",
|
||||
iconPath: "/icon.svg",
|
||||
path: "/test-app",
|
||||
|
||||
description: "This app does XYZ.",
|
||||
},
|
||||
|
|
|
@ -45,7 +45,9 @@ import * as express from "express"
|
|||
*
|
||||
* There is also a /api/applications endpoint to allow programmatic access to all
|
||||
* available applications. It could be used to create a custom application dashboard
|
||||
* for example.
|
||||
* for example. An important difference with the API is that all application paths
|
||||
* will be absolute (i.e have the plugin path prepended) so that they may be used
|
||||
* directly.
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -60,30 +62,30 @@ export interface Plugin {
|
|||
*
|
||||
* Fetched from package.json.
|
||||
*/
|
||||
name?: string
|
||||
readonly name?: string
|
||||
|
||||
/**
|
||||
* The version for the plugin in the overlay.
|
||||
*
|
||||
* Fetched from package.json.
|
||||
*/
|
||||
version?: string
|
||||
readonly version?: string
|
||||
|
||||
/**
|
||||
* Name used in the overlay.
|
||||
*/
|
||||
displayName: string
|
||||
readonly displayName: string
|
||||
|
||||
/**
|
||||
* Used in overlay.
|
||||
* Should be a full sentence describing the plugin.
|
||||
*/
|
||||
description: string
|
||||
readonly description: string
|
||||
|
||||
/**
|
||||
* The path at which the plugin router is to be registered.
|
||||
*/
|
||||
path: string
|
||||
readonly routerPath: string
|
||||
|
||||
/**
|
||||
* init is called so that the plugin may initialize itself with the config.
|
||||
|
|
Loading…
Reference in New Issue