Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
gzupanda
code-server
提交
82e8a00a
C
code-server
项目概览
gzupanda
/
code-server
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
code-server
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
82e8a00a
编写于
10月 30, 2020
作者:
A
Anmol Sethi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix CI
上级
bea185b8
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
48 addition
and
45 deletion
+48
-45
src/node/plugin.ts
src/node/plugin.ts
+15
-17
test/plugin.test.ts
test/plugin.test.ts
+17
-14
test/test-plugin/src/index.ts
test/test-plugin/src/index.ts
+9
-7
test/test-plugin/tsconfig.json
test/test-plugin/tsconfig.json
+7
-7
未找到文件。
src/node/plugin.ts
浏览文件 @
82e8a00a
import
*
as
path
from
"
path
"
import
{
Logger
,
field
}
from
"
@coder/logger
"
import
*
as
util
from
"
./util
"
import
*
as
express
from
"
express
"
import
*
as
pluginapi
from
"
../../typings/plugin
"
import
*
as
fs
from
"
fs
"
import
*
as
fs
from
"
fs
"
import
*
as
path
from
"
path
"
import
*
as
semver
from
"
semver
"
import
*
as
semver
from
"
semver
"
import
*
as
pluginapi
from
"
../../typings/plugin
"
import
{
version
}
from
"
./constants
"
import
{
version
}
from
"
./constants
"
import
*
as
util
from
"
./util
"
const
fsp
=
fs
.
promises
const
fsp
=
fs
.
promises
import
{
Logger
,
field
}
from
"
@coder/logger
"
import
*
as
express
from
"
express
"
// These fields are populated from the plugin's package.json.
// These fields are populated from the plugin's package.json.
interface
Plugin
extends
pluginapi
.
Plugin
{
interface
Plugin
extends
pluginapi
.
Plugin
{
...
@@ -34,7 +34,7 @@ export class PluginAPI {
...
@@ -34,7 +34,7 @@ export class PluginAPI {
*/
*/
private
readonly
csPlugin
=
""
,
private
readonly
csPlugin
=
""
,
private
readonly
csPluginPath
=
`
${
path
.
join
(
util
.
paths
.
data
,
"
plugins
"
)}
:/usr/share/code-server/plugins`
,
private
readonly
csPluginPath
=
`
${
path
.
join
(
util
.
paths
.
data
,
"
plugins
"
)}
:/usr/share/code-server/plugins`
,
){
)
{
this
.
logger
=
logger
.
named
(
"
pluginapi
"
)
this
.
logger
=
logger
.
named
(
"
pluginapi
"
)
}
}
...
@@ -44,7 +44,7 @@ export class PluginAPI {
...
@@ -44,7 +44,7 @@ export class PluginAPI {
*/
*/
public
async
applications
():
Promise
<
Application
[]
>
{
public
async
applications
():
Promise
<
Application
[]
>
{
const
apps
=
new
Array
<
Application
>
()
const
apps
=
new
Array
<
Application
>
()
for
(
le
t
p
of
this
.
plugins
)
{
for
(
cons
t
p
of
this
.
plugins
)
{
const
pluginApps
=
await
p
.
applications
()
const
pluginApps
=
await
p
.
applications
()
// TODO prevent duplicates
// TODO prevent duplicates
...
@@ -62,7 +62,7 @@ export class PluginAPI {
...
@@ -62,7 +62,7 @@ export class PluginAPI {
* mount mounts all plugin routers onto r.
* mount mounts all plugin routers onto r.
*/
*/
public
mount
(
r
:
express
.
Router
):
void
{
public
mount
(
r
:
express
.
Router
):
void
{
for
(
le
t
p
of
this
.
plugins
)
{
for
(
cons
t
p
of
this
.
plugins
)
{
r
.
use
(
`/
${
p
.
name
}
`
,
p
.
router
())
r
.
use
(
`/
${
p
.
name
}
`
,
p
.
router
())
}
}
}
}
...
@@ -75,14 +75,14 @@ export class PluginAPI {
...
@@ -75,14 +75,14 @@ export class PluginAPI {
// Built-in plugins.
// Built-in plugins.
await
this
.
_loadPlugins
(
path
.
join
(
__dirname
,
"
../../plugins
"
))
await
this
.
_loadPlugins
(
path
.
join
(
__dirname
,
"
../../plugins
"
))
for
(
le
t
dir
of
this
.
csPluginPath
.
split
(
"
:
"
))
{
for
(
cons
t
dir
of
this
.
csPluginPath
.
split
(
"
:
"
))
{
if
(
!
dir
)
{
if
(
!
dir
)
{
continue
continue
}
}
await
this
.
_loadPlugins
(
dir
)
await
this
.
_loadPlugins
(
dir
)
}
}
for
(
le
t
dir
of
this
.
csPlugin
.
split
(
"
:
"
))
{
for
(
cons
t
dir
of
this
.
csPlugin
.
split
(
"
:
"
))
{
if
(
!
dir
)
{
if
(
!
dir
)
{
continue
continue
}
}
...
@@ -93,7 +93,7 @@ export class PluginAPI {
...
@@ -93,7 +93,7 @@ export class PluginAPI {
private
async
_loadPlugins
(
dir
:
string
):
Promise
<
void
>
{
private
async
_loadPlugins
(
dir
:
string
):
Promise
<
void
>
{
try
{
try
{
const
entries
=
await
fsp
.
readdir
(
dir
,
{
withFileTypes
:
true
})
const
entries
=
await
fsp
.
readdir
(
dir
,
{
withFileTypes
:
true
})
for
(
le
t
ent
of
entries
)
{
for
(
cons
t
ent
of
entries
)
{
if
(
!
ent
.
isDirectory
())
{
if
(
!
ent
.
isDirectory
())
{
continue
continue
}
}
...
@@ -124,14 +124,12 @@ export class PluginAPI {
...
@@ -124,14 +124,12 @@ export class PluginAPI {
private
_loadPlugin
(
dir
:
string
,
packageJSON
:
PackageJSON
):
Plugin
{
private
_loadPlugin
(
dir
:
string
,
packageJSON
:
PackageJSON
):
Plugin
{
const
logger
=
this
.
logger
.
named
(
packageJSON
.
name
)
const
logger
=
this
.
logger
.
named
(
packageJSON
.
name
)
logger
.
debug
(
"
loading plugin
"
,
logger
.
debug
(
"
loading plugin
"
,
field
(
"
plugin_dir
"
,
dir
),
field
(
"
package_json
"
,
packageJSON
))
field
(
"
plugin_dir
"
,
dir
),
field
(
"
package_json
"
,
packageJSON
),
)
if
(
!
semver
.
satisfies
(
version
,
packageJSON
.
engines
[
"
code-server
"
]))
{
if
(
!
semver
.
satisfies
(
version
,
packageJSON
.
engines
[
"
code-server
"
]))
{
throw
new
Error
(
`plugin range
${
q
(
packageJSON
.
engines
[
"
code-server
"
])}
incompatible`
+
throw
new
Error
(
` with code-server version
${
version
}
`
)
`plugin range
${
q
(
packageJSON
.
engines
[
"
code-server
"
])}
incompatible`
+
` with code-server version
${
version
}
`
,
)
}
}
if
(
!
packageJSON
.
name
)
{
if
(
!
packageJSON
.
name
)
{
throw
new
Error
(
"
plugin missing name
"
)
throw
new
Error
(
"
plugin missing name
"
)
...
...
test/plugin.test.ts
浏览文件 @
82e8a00a
import
{
describe
}
from
"
mocha
"
import
{
PluginAPI
}
from
"
../src/node/plugin
"
import
{
logger
}
from
"
@coder/logger
"
import
{
logger
}
from
"
@coder/logger
"
import
*
as
path
from
"
path
"
import
*
as
assert
from
"
assert
"
import
*
as
assert
from
"
assert
"
import
{
describe
}
from
"
mocha
"
import
*
as
path
from
"
path
"
import
{
PluginAPI
}
from
"
../src/node/plugin
"
/**
/**
* Use $LOG_LEVEL=debug to see debug logs.
* Use $LOG_LEVEL=debug to see debug logs.
...
@@ -15,7 +15,8 @@ describe("plugin", () => {
...
@@ -15,7 +15,8 @@ describe("plugin", () => {
// We remove the function fields from the application's plugins.
// We remove the function fields from the application's plugins.
const
apps
=
JSON
.
parse
(
JSON
.
stringify
(
await
papi
.
applications
()))
const
apps
=
JSON
.
parse
(
JSON
.
stringify
(
await
papi
.
applications
()))
assert
.
deepEqual
([
assert
.
deepEqual
(
[
{
{
name
:
"
goland
"
,
name
:
"
goland
"
,
version
:
"
4.0.0
"
,
version
:
"
4.0.0
"
,
...
@@ -26,6 +27,8 @@ describe("plugin", () => {
...
@@ -26,6 +27,8 @@ describe("plugin", () => {
description
:
"
Fake plugin for testing code-server's plugin API
"
,
description
:
"
Fake plugin for testing code-server's plugin API
"
,
},
},
},
},
],
apps
)
],
apps
,
)
})
})
})
})
test/test-plugin/src/index.ts
浏览文件 @
82e8a00a
import
*
as
pluginapi
from
"
../../../typings/plugin
"
import
*
as
express
from
"
express
"
import
*
as
express
from
"
express
"
import
*
as
path
from
"
path
"
;
import
*
as
path
from
"
path
"
import
*
as
pluginapi
from
"
../../../typings/plugin
"
export
function
init
(
config
:
pluginapi
.
PluginConfig
)
{
export
function
init
(
config
:
pluginapi
.
PluginConfig
)
{
config
.
logger
.
debug
(
"
test-plugin loaded!
"
)
config
.
logger
.
debug
(
"
test-plugin loaded!
"
)
...
@@ -15,9 +15,11 @@ export function router(): express.Router {
...
@@ -15,9 +15,11 @@ export function router(): express.Router {
}
}
export
function
applications
():
pluginapi
.
Application
[]
{
export
function
applications
():
pluginapi
.
Application
[]
{
return
[{
return
[
{
name
:
"
goland
"
,
name
:
"
goland
"
,
version
:
"
4.0.0
"
,
version
:
"
4.0.0
"
,
iconPath
:
"
icon.svg
"
,
iconPath
:
"
icon.svg
"
,
}]
},
]
}
}
test/test-plugin/tsconfig.json
浏览文件 @
82e8a00a
...
@@ -4,8 +4,8 @@
...
@@ -4,8 +4,8 @@
/*
Basic
Options
*/
/*
Basic
Options
*/
//
"incremental"
:
true
,
/*
Enable
incremental
compilation
*/
//
"incremental"
:
true
,
/*
Enable
incremental
compilation
*/
"target"
:
"es5"
,
/*
Specify
ECMAScript
target
version:
'ES
3
'
(default)
,
'ES
5
'
,
'ES
2015
'
,
'ES
2016
'
,
'ES
2017
'
,
'ES
2018
'
,
'ES
2019
'
,
'ES
2020
'
,
or
'ESNEXT'.
*/
"target"
:
"es5"
/*
Specify
ECMAScript
target
version:
'ES
3
'
(default)
,
'ES
5
'
,
'ES
2015
'
,
'ES
2016
'
,
'ES
2017
'
,
'ES
2018
'
,
'ES
2019
'
,
'ES
2020
'
,
or
'ESNEXT'.
*/
,
"module"
:
"commonjs"
,
/*
Specify
module
code
generation:
'none'
,
'commonjs'
,
'amd'
,
'system'
,
'umd'
,
'es
2015
'
,
'es
2020
'
,
or
'ESNext'.
*/
"module"
:
"commonjs"
/*
Specify
module
code
generation:
'none'
,
'commonjs'
,
'amd'
,
'system'
,
'umd'
,
'es
2015
'
,
'es
2020
'
,
or
'ESNext'.
*/
,
//
"lib"
:
[],
/*
Specify
library
files
to
be
included
in
the
compilation.
*/
//
"lib"
:
[],
/*
Specify
library
files
to
be
included
in
the
compilation.
*/
//
"allowJs"
:
true
,
/*
Allow
javascript
files
to
be
compiled.
*/
//
"allowJs"
:
true
,
/*
Allow
javascript
files
to
be
compiled.
*/
//
"checkJs"
:
true
,
/*
Report
errors
in
.js
files.
*/
//
"checkJs"
:
true
,
/*
Report
errors
in
.js
files.
*/
...
@@ -14,7 +14,7 @@
...
@@ -14,7 +14,7 @@
//
"declarationMap"
:
true
,
/*
Generates
a
sourcemap
for
each
corresponding
'.d.ts'
file.
*/
//
"declarationMap"
:
true
,
/*
Generates
a
sourcemap
for
each
corresponding
'.d.ts'
file.
*/
//
"sourceMap"
:
true
,
/*
Generates
corresponding
'.map'
file.
*/
//
"sourceMap"
:
true
,
/*
Generates
corresponding
'.map'
file.
*/
//
"outFile"
:
"./"
,
/*
Concatenate
and
emit
output
to
single
file.
*/
//
"outFile"
:
"./"
,
/*
Concatenate
and
emit
output
to
single
file.
*/
"outDir"
:
"./out"
,
/*
Redirect
output
structure
to
the
directory.
*/
"outDir"
:
"./out"
/*
Redirect
output
structure
to
the
directory.
*/
,
//
"rootDir"
:
"./"
,
/*
Specify
the
root
directory
of
input
files.
Use
to
control
the
output
directory
structure
with
--outDir.
*/
//
"rootDir"
:
"./"
,
/*
Specify
the
root
directory
of
input
files.
Use
to
control
the
output
directory
structure
with
--outDir.
*/
//
"composite"
:
true
,
/*
Enable
project
compilation
*/
//
"composite"
:
true
,
/*
Enable
project
compilation
*/
//
"tsBuildInfoFile"
:
"./"
,
/*
Specify
file
to
store
incremental
compilation
information
*/
//
"tsBuildInfoFile"
:
"./"
,
/*
Specify
file
to
store
incremental
compilation
information
*/
...
@@ -25,7 +25,7 @@
...
@@ -25,7 +25,7 @@
//
"isolatedModules"
:
true
,
/*
Transpile
each
file
as
a
separate
module
(similar
to
'ts.transpileModule').
*/
//
"isolatedModules"
:
true
,
/*
Transpile
each
file
as
a
separate
module
(similar
to
'ts.transpileModule').
*/
/*
Strict
Type-Checking
Options
*/
/*
Strict
Type-Checking
Options
*/
"strict"
:
true
,
/*
Enable
all
strict
type-checking
options.
*/
"strict"
:
true
/*
Enable
all
strict
type-checking
options.
*/
,
//
"noImplicitAny"
:
true
,
/*
Raise
error
on
expressions
and
declarations
with
an
implied
'any'
type.
*/
//
"noImplicitAny"
:
true
,
/*
Raise
error
on
expressions
and
declarations
with
an
implied
'any'
type.
*/
//
"strictNullChecks"
:
true
,
/*
Enable
strict
null
checks.
*/
//
"strictNullChecks"
:
true
,
/*
Enable
strict
null
checks.
*/
//
"strictFunctionTypes"
:
true
,
/*
Enable
strict
checking
of
function
types.
*/
//
"strictFunctionTypes"
:
true
,
/*
Enable
strict
checking
of
function
types.
*/
...
@@ -48,7 +48,7 @@
...
@@ -48,7 +48,7 @@
//
"typeRoots"
:
[],
/*
List
of
folders
to
include
type
definitions
from.
*/
//
"typeRoots"
:
[],
/*
List
of
folders
to
include
type
definitions
from.
*/
//
"types"
:
[],
/*
Type
declaration
files
to
be
included
in
compilation.
*/
//
"types"
:
[],
/*
Type
declaration
files
to
be
included
in
compilation.
*/
//
"allowSyntheticDefaultImports"
:
true
,
/*
Allow
default
imports
from
modules
with
no
default
export.
This
does
not
affect
code
emit
,
just
typechecking.
*/
//
"allowSyntheticDefaultImports"
:
true
,
/*
Allow
default
imports
from
modules
with
no
default
export.
This
does
not
affect
code
emit
,
just
typechecking.
*/
"esModuleInterop"
:
true
,
/*
Enables
emit
interoperability
between
CommonJS
and
ES
Modules
via
creation
of
namespace
objects
for
all
imports.
Implies
'allowSyntheticDefaultImports'.
*/
"esModuleInterop"
:
true
/*
Enables
emit
interoperability
between
CommonJS
and
ES
Modules
via
creation
of
namespace
objects
for
all
imports.
Implies
'allowSyntheticDefaultImports'.
*/
,
//
"preserveSymlinks"
:
true
,
/*
Do
not
resolve
the
real
path
of
symlinks.
*/
//
"preserveSymlinks"
:
true
,
/*
Do
not
resolve
the
real
path
of
symlinks.
*/
//
"allowUmdGlobalAccess"
:
true
,
/*
Allow
accessing
UMD
globals
from
modules.
*/
//
"allowUmdGlobalAccess"
:
true
,
/*
Allow
accessing
UMD
globals
from
modules.
*/
...
@@ -63,7 +63,7 @@
...
@@ -63,7 +63,7 @@
//
"emitDecoratorMetadata"
:
true
,
/*
Enables
experimental
support
for
emitting
type
metadata
for
decorators.
*/
//
"emitDecoratorMetadata"
:
true
,
/*
Enables
experimental
support
for
emitting
type
metadata
for
decorators.
*/
/*
Advanced
Options
*/
/*
Advanced
Options
*/
"skipLibCheck"
:
true
,
/*
Skip
type
checking
of
declaration
files.
*/
"skipLibCheck"
:
true
/*
Skip
type
checking
of
declaration
files.
*/
,
"forceConsistentCasingInFileNames"
:
true
/*
Disallow
inconsistently-cased
references
to
the
same
file.
*/
"forceConsistentCasingInFileNames"
:
true
/*
Disallow
inconsistently-cased
references
to
the
same
file.
*/
}
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录