Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
myhjmzy
code-server
提交
86d70ec7
C
code-server
项目概览
myhjmzy
/
code-server
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
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,发现更多精彩内容 >>
未验证
提交
86d70ec7
编写于
2月 07, 2019
作者:
A
Asher
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add constants file
上级
81f48b8b
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
27 addition
and
20 deletion
+27
-20
packages/server/.gitignore
packages/server/.gitignore
+2
-1
packages/server/package.json
packages/server/package.json
+1
-1
packages/server/src/cli.ts
packages/server/src/cli.ts
+7
-6
packages/server/src/constants.ts
packages/server/src/constants.ts
+3
-0
packages/server/src/fill.ts
packages/server/src/fill.ts
+2
-1
packages/server/src/modules.ts
packages/server/src/modules.ts
+4
-3
packages/server/src/server.ts
packages/server/src/server.ts
+5
-6
packages/server/src/vscode/bootstrapFork.ts
packages/server/src/vscode/bootstrapFork.ts
+3
-2
未找到文件。
packages/server/.gitignore
浏览文件 @
86d70ec7
out
cli*
!cli.ts
build
resources
# This file is generated when the binary is created.
# We want to use the parent tsconfig so we can ignore it.
tsconfig.json
\ No newline at end of file
tsconfig.json
packages/server/package.json
浏览文件 @
86d70ec7
...
...
@@ -8,7 +8,7 @@
"build:webpack"
:
"rm -rf ./out && export CLI=true && ../../node_modules/.bin/webpack --config ./webpack.config.js"
,
"build:nexe"
:
"node scripts/nexe.js"
,
"build:bootstrap-fork"
:
"cd ../vscode && npm run build:bootstrap-fork; mkdir -p ./packages/server/resources; cp ./bin/bootstrap-fork.js ../server/resources/bootstrap-fork.js"
,
"build:default-extensions"
:
"cd ../../lib/vscode && npx gulp vscode-linux-arm && cd ../.. && mkdir -p ./packages/server/resources; cp -r ./lib/VSCode-linux-arm/resources/app/extensions/* ./packages/server/resources/extensions/"
,
"build:default-extensions"
:
"cd ../../lib/vscode && npx gulp vscode-linux-arm && cd ../.. && mkdir -p ./packages/server/resources
/extensions
; cp -r ./lib/VSCode-linux-arm/resources/app/extensions/* ./packages/server/resources/extensions/"
,
"build:web"
:
"cd ../web; rm -rf ./out; NODE_ENV=production npm run build; rm -rf ../server/resources/web; mkdir -p ../server/resources/web; cp -r ./out/* ../server/resources/web"
,
"build"
:
"npm run build:bootstrap-fork && npm run build:webpack && npm run build:nexe"
},
...
...
packages/server/src/cli.ts
浏览文件 @
86d70ec7
...
...
@@ -10,6 +10,7 @@ import { requireModule } from "./vscode/bootstrapFork";
import
{
SharedProcess
,
SharedProcessState
}
from
"
./vscode/sharedProcess
"
;
import
{
setup
as
setupNativeModules
}
from
"
./modules
"
;
import
{
fillFs
}
from
"
./fill
"
;
import
{
isCli
,
serveStatic
,
buildDir
}
from
"
./constants
"
;
export
class
Entry
extends
Command
{
public
static
description
=
"
Start your own self-hosted browser-accessible VS Code
"
;
...
...
@@ -50,7 +51,7 @@ export class Entry extends Command {
logger
.
warn
(
"
Failed to remove extracted dependency.
"
,
field
(
"
dependency
"
,
"
spdlog
"
),
field
(
"
error
"
,
ex
.
message
));
}
if
(
process
.
env
.
CLI
)
{
if
(
isCli
)
{
fillFs
();
}
...
...
@@ -60,7 +61,7 @@ export class Entry extends Command {
Object
.
assign
(
process
.
env
,
JSON
.
parse
(
flags
.
env
));
}
const
builtInExtensionsDir
=
path
.
join
(
process
.
env
.
BUILD_DIR
||
path
.
join
(
__dirname
,
"
..
"
),
"
build/extensions
"
);
const
builtInExtensionsDir
=
path
.
join
(
buildDir
||
path
.
join
(
__dirname
,
"
..
"
),
"
build/extensions
"
);
if
(
flags
[
"
bootstrap-fork
"
])
{
const
modulePath
=
flags
[
"
bootstrap-fork
"
];
if
(
!
modulePath
)
{
...
...
@@ -74,8 +75,8 @@ export class Entry extends Command {
const
dataDir
=
flags
[
"
data-dir
"
]
||
path
.
join
(
os
.
homedir
(),
"
.vscode-remote
"
);
const
workingDir
=
args
[
"
workdir
"
];
if
(
process
.
env
.
BUILD_DIR
&&
process
.
env
.
BUILD_DIR
.
startsWith
(
workingDir
))
{
logger
.
error
(
"
Cannot run binary inside of BUILD_DIR
"
,
field
(
"
build_dir
"
,
process
.
env
.
BUILD_DIR
),
field
(
"
cwd
"
,
process
.
cwd
()));
if
(
buildDir
&&
buildDir
.
startsWith
(
workingDir
))
{
logger
.
error
(
"
Cannot run binary inside of BUILD_DIR
"
,
field
(
"
build_dir
"
,
buildDir
),
field
(
"
cwd
"
,
process
.
cwd
()));
process
.
exit
(
1
);
}
...
...
@@ -114,7 +115,7 @@ export class Entry extends Command {
next
();
});
if
(
(
process
.
env
.
CLI
===
"
false
"
||
!
process
.
env
.
CLI
)
&&
!
process
.
env
.
SERVE_STATIC
)
{
if
(
!
isCli
&&
!
serveStatic
)
{
const
webpackConfig
=
require
(
path
.
join
(
__dirname
,
"
..
"
,
"
..
"
,
"
web
"
,
"
webpack.config.js
"
));
const
compiler
=
require
(
"
webpack
"
)(
webpackConfig
);
app
.
use
(
require
(
"
webpack-dev-middleware
"
)(
compiler
,
{
...
...
@@ -163,6 +164,6 @@ export class Entry extends Command {
}
Entry
.
run
(
undefined
,
{
root
:
process
.
env
.
BUILD_DIR
as
string
||
__dirname
,
root
:
buildDir
||
__dirname
,
//@ts-ignore
}).
catch
(
require
(
"
@oclif/errors/handle
"
));
packages/server/src/constants.ts
0 → 100644
浏览文件 @
86d70ec7
export
const
isCli
=
typeof
process
.
env
.
CLI
!==
"
undefined
"
&&
process
.
env
.
CLI
!==
"
false
"
;
export
const
serveStatic
=
typeof
process
.
env
.
SERVE_STATIC
!==
"
undefined
"
&&
process
.
env
.
SERVE_STATIC
!==
"
false
"
;
export
const
buildDir
=
process
.
env
.
BUILD_DIR
;
packages/server/src/fill.ts
浏览文件 @
86d70ec7
import
*
as
fs
from
"
fs
"
;
import
*
as
util
from
"
util
"
;
import
{
isCli
}
from
"
./constants
"
;
const
oldAccess
=
fs
.
access
;
const
existsWithinBinary
=
(
path
:
fs
.
PathLike
):
Promise
<
boolean
>
=>
{
...
...
@@ -24,7 +25,7 @@ export const fillFs = (): void => {
* For impls
*/
if
(
!
process
.
env
.
CLI
)
{
if
(
!
isCli
)
{
throw
new
Error
(
"
Should not fill FS when not in CLI
"
);
}
...
...
packages/server/src/modules.ts
浏览文件 @
86d70ec7
import
*
as
fs
from
"
fs
"
;
import
*
as
path
from
"
path
"
;
import
{
isCli
,
buildDir
}
from
"
./constants
"
;
declare
var
__non_webpack_require__
:
typeof
require
;
...
...
@@ -7,7 +8,7 @@ declare var __non_webpack_require__: typeof require;
* Handling of native modules within the CLI
*/
export
const
setup
=
(
dataDirectory
:
string
):
void
=>
{
if
(
!
process
.
env
.
CLI
)
{
if
(
!
isCli
)
{
return
;
}
...
...
@@ -20,7 +21,7 @@ export const setup = (dataDirectory: string): void => {
}
const
unpackModule
=
(
moduleName
:
string
):
void
=>
{
const
memFile
=
path
.
join
(
process
.
env
.
BUILD_DIR
!
,
"
build/modules
"
,
moduleName
+
"
.node
"
);
const
memFile
=
path
.
join
(
buildDir
!
,
"
build/modules
"
,
moduleName
+
"
.node
"
);
const
diskFile
=
path
.
join
(
dataDirectory
,
"
modules
"
,
moduleName
+
"
.node
"
);
if
(
!
fs
.
existsSync
(
diskFile
))
{
fs
.
writeFileSync
(
diskFile
,
fs
.
readFileSync
(
memFile
));
...
...
@@ -38,4 +39,4 @@ export const setup = (dataDirectory: string): void => {
return
__non_webpack_require__
(
path
.
join
(
dataDirectory
,
"
modules
"
,
modName
+
"
.node
"
));
};
require
(
"
../../protocol/node_modules/node-pty/lib/index
"
)
as
typeof
import
(
"
../../protocol/node_modules/node-pty/src/index
"
);
};
\ No newline at end of file
};
packages/server/src/server.ts
浏览文件 @
86d70ec7
...
...
@@ -13,6 +13,7 @@ import * as path from "path";
import
*
as
util
from
"
util
"
;
import
*
as
ws
from
"
ws
"
;
import
{
forkModule
}
from
"
./vscode/bootstrapFork
"
;
import
{
isCli
,
buildDir
}
from
"
./constants
"
;
export
const
createApp
=
(
registerMiddleware
?:
(
app
:
express
.
Application
)
=>
void
,
options
?:
ServerOptions
):
{
readonly
express
:
express
.
Application
;
...
...
@@ -69,8 +70,8 @@ export const createApp = (registerMiddleware?: (app: express.Application) => voi
}
:
undefined
);
});
const
baseDir
=
process
.
env
.
BUILD_DIR
||
path
.
join
(
__dirname
,
"
..
"
);
if
(
process
.
env
.
CLI
)
{
const
baseDir
=
buildDir
||
path
.
join
(
__dirname
,
"
..
"
);
if
(
isCli
)
{
app
.
use
(
expressStaticGzip
(
path
.
join
(
baseDir
,
"
build/web
"
)));
}
else
{
app
.
use
(
express
.
static
(
path
.
join
(
baseDir
,
"
resources/web
"
)));
...
...
@@ -84,16 +85,14 @@ export const createApp = (registerMiddleware?: (app: express.Application) => voi
// }
const
exists
=
fs
.
existsSync
(
fullPath
);
if
(
!
exists
)
{
res
.
status
(
404
).
end
();
return
;
return
res
.
status
(
404
).
end
();
}
const
stat
=
await
util
.
promisify
(
fs
.
stat
)(
fullPath
);
if
(
!
stat
.
isFile
())
{
res
.
write
(
"
Resource must be a file.
"
);
res
.
status
(
422
);
res
.
end
();
return
;
return
res
.
end
()
;
}
let
mimeType
=
mime
.
lookup
(
fullPath
);
if
(
mimeType
===
false
)
{
...
...
packages/server/src/vscode/bootstrapFork.ts
浏览文件 @
86d70ec7
...
...
@@ -3,6 +3,7 @@ import * as fs from "fs";
import
*
as
path
from
"
path
"
;
import
*
as
zlib
from
"
zlib
"
;
import
*
as
vm
from
"
vm
"
;
import
{
isCli
}
from
"
../constants
"
;
export
const
requireModule
=
(
modulePath
:
string
,
builtInExtensionsDir
:
string
):
void
=>
{
process
.
env
.
AMD_ENTRYPOINT
=
modulePath
;
...
...
@@ -37,7 +38,7 @@ export const requireModule = (modulePath: string, builtInExtensionsDir: string):
const
readFile
=
(
name
:
string
):
Buffer
=>
{
return
fs
.
readFileSync
(
path
.
join
(
process
.
env
.
BUILD_DIR
as
string
||
path
.
join
(
__dirname
,
"
../..
"
),
"
./build
"
,
name
));
};
if
(
process
.
env
.
CLI
)
{
if
(
isCli
)
{
content
=
zlib
.
gunzipSync
(
readFile
(
"
bootstrap-fork.js.gz
"
));
}
else
{
content
=
readFile
(
"
../resources/bootstrap-fork.js
"
);
...
...
@@ -63,7 +64,7 @@ export const forkModule = (modulePath: string, env?: NodeJS.ProcessEnv): cp.Chil
const
options
:
cp
.
SpawnOptions
=
{
stdio
:
[
null
,
null
,
null
,
"
ipc
"
],
};
if
(
process
.
env
.
CLI
===
"
true
"
)
{
if
(
isCli
)
{
proc
=
cp
.
execFile
(
process
.
execPath
,
args
,
options
);
}
else
{
proc
=
cp
.
spawn
(
process
.
execPath
,
[
"
--require
"
,
"
ts-node/register
"
,
"
--require
"
,
"
tsconfig-paths/register
"
,
process
.
argv
[
1
],
...
args
],
options
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录