@@ -86,7 +86,7 @@ export class PluginAPI {
8686 */
8787 public mount ( r : express . Router ) : void {
8888 for ( const [ , p ] of this . plugins ) {
89- r . use ( `/${ p . name } ` , p . router ( ) )
89+ r . use ( `/${ p . routerPath } ` , p . router ( ) )
9090 }
9191 }
9292
@@ -154,7 +154,7 @@ export class PluginAPI {
154154 this . plugins . set ( p . name , p )
155155 } catch ( err ) {
156156 if ( err . code !== "ENOENT" ) {
157- this . logger . warn ( `failed to load plugin: ${ err . message } ` )
157+ this . logger . warn ( `failed to load plugin: ${ err . stack } ` )
158158 }
159159 }
160160 }
@@ -170,17 +170,24 @@ export class PluginAPI {
170170 const logger = this . logger . named ( packageJSON . name )
171171 logger . debug ( "loading plugin" , field ( "plugin_dir" , dir ) , field ( "package_json" , packageJSON ) )
172172
173+ if ( ! packageJSON . name ) {
174+ throw new Error ( "plugin package.json missing name" )
175+ }
176+ if ( ! packageJSON . version ) {
177+ throw new Error ( "plugin package.json missing version" )
178+ }
179+ if ( ! packageJSON . engines || ! packageJSON . engines [ "code-server" ] ) {
180+ throw new Error ( `plugin package.json missing code-server range like:
181+ "engines": {
182+ "code-server": "^3.6.0"
183+ }
184+ ` )
185+ }
173186 if ( ! semver . satisfies ( version , packageJSON . engines [ "code-server" ] ) ) {
174187 throw new Error (
175188 `plugin range ${ q ( packageJSON . engines [ "code-server" ] ) } incompatible` + ` with code-server version ${ version } ` ,
176189 )
177190 }
178- if ( ! packageJSON . name ) {
179- throw new Error ( "plugin missing name" )
180- }
181- if ( ! packageJSON . version ) {
182- throw new Error ( "plugin missing version" )
183- }
184191
185192 const p = {
186193 name : packageJSON . name ,
@@ -198,6 +205,9 @@ export class PluginAPI {
198205 if ( ! p . routerPath ) {
199206 throw new Error ( "plugin missing router path" )
200207 }
208+ if ( ! p . routerPath . startsWith ( "/" ) || p . routerPath . length < 2 ) {
209+ throw new Error ( `plugin router path ${ q ( p . routerPath ) } : invalid` )
210+ }
201211 if ( ! p . homepageURL ) {
202212 throw new Error ( "plugin missing homepage" )
203213 }
0 commit comments