File tree Expand file tree Collapse file tree 5 files changed +20
-13
lines changed Expand file tree Collapse file tree 5 files changed +20
-13
lines changed Original file line number Diff line number Diff line change @@ -60,6 +60,8 @@ export class PluginAPI {
60
60
// Add plugin key to each app.
61
61
apps . push (
62
62
...pluginApps . map ( ( app ) => {
63
+ app = { ...app , path : path . join ( p . routerPath , app . path || "" ) }
64
+ app = { ...app , iconPath : path . join ( app . path || "" , app . iconPath ) }
63
65
return {
64
66
...app ,
65
67
plugin : {
@@ -69,7 +71,7 @@ export class PluginAPI {
69
71
70
72
displayName : p . displayName ,
71
73
description : p . description ,
72
- path : p . path ,
74
+ routerPath : p . routerPath ,
73
75
} ,
74
76
}
75
77
} ) ,
@@ -192,8 +194,8 @@ export class PluginAPI {
192
194
if ( ! p . description ) {
193
195
throw new Error ( "plugin missing description" )
194
196
}
195
- if ( ! p . path ) {
196
- throw new Error ( "plugin missing path" )
197
+ if ( ! p . routerPath ) {
198
+ throw new Error ( "plugin missing router path" )
197
199
}
198
200
199
201
p . init ( {
Original file line number Diff line number Diff line change @@ -21,7 +21,8 @@ describe("plugin", () => {
21
21
version : "4.0.0" ,
22
22
23
23
description : "This app does XYZ." ,
24
- iconPath : "/icon.svg" ,
24
+ iconPath : "/test-plugin/test-app/icon.svg" ,
25
+ path : "/test-plugin/test-app" ,
25
26
26
27
plugin : {
27
28
name : "test-plugin" ,
@@ -30,7 +31,7 @@ describe("plugin", () => {
30
31
31
32
displayName : "Test Plugin" ,
32
33
description : "Plugin used in code-server tests." ,
33
- path : "/test-plugin" ,
34
+ routerPath : "/test-plugin" ,
34
35
} ,
35
36
} ,
36
37
] ,
Original file line number Diff line number Diff line change 1
1
out/index.js : src/index.ts
2
- yarn build
2
+ # Typescript always emits, even on errors.
3
+ yarn build || rm out/index.js
3
4
4
5
node_modules : package.json yarn.lock
5
6
yarn
Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ import * as fspath from "path"
3
3
import * as pluginapi from "../../../typings/pluginapi"
4
4
5
5
export const displayName = "Test Plugin"
6
- export const path = "/test-plugin"
6
+ export const routerPath = "/test-plugin"
7
7
export const description = "Plugin used in code-server tests."
8
8
9
9
export function init ( config : pluginapi . PluginConfig ) {
@@ -24,6 +24,7 @@ export function applications(): pluginapi.Application[] {
24
24
name : "Test App" ,
25
25
version : "4.0.0" ,
26
26
iconPath : "/icon.svg" ,
27
+ path : "/test-app" ,
27
28
28
29
description : "This app does XYZ." ,
29
30
} ,
Original file line number Diff line number Diff line change @@ -45,7 +45,9 @@ import * as express from "express"
45
45
*
46
46
* There is also a /api/applications endpoint to allow programmatic access to all
47
47
* available applications. It could be used to create a custom application dashboard
48
- * for example.
48
+ * for example. An important difference with the API is that all application paths
49
+ * will be absolute (i.e have the plugin path prepended) so that they may be used
50
+ * directly.
49
51
*/
50
52
51
53
/**
@@ -60,30 +62,30 @@ export interface Plugin {
60
62
*
61
63
* Fetched from package.json.
62
64
*/
63
- name ?: string
65
+ readonly name ?: string
64
66
65
67
/**
66
68
* The version for the plugin in the overlay.
67
69
*
68
70
* Fetched from package.json.
69
71
*/
70
- version ?: string
72
+ readonly version ?: string
71
73
72
74
/**
73
75
* Name used in the overlay.
74
76
*/
75
- displayName : string
77
+ readonly displayName : string
76
78
77
79
/**
78
80
* Used in overlay.
79
81
* Should be a full sentence describing the plugin.
80
82
*/
81
- description : string
83
+ readonly description : string
82
84
83
85
/**
84
86
* The path at which the plugin router is to be registered.
85
87
*/
86
- path : string
88
+ readonly routerPath : string
87
89
88
90
/**
89
91
* init is called so that the plugin may initialize itself with the config.
You can’t perform that action at this time.
0 commit comments