Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
myhjmzy
code-server
提交
73d6b776
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,发现更多精彩内容 >>
未验证
提交
73d6b776
编写于
2月 21, 2019
作者:
K
Kyle Carberry
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Externalize spdlog .node module
上级
670003c3
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
38 addition
and
35 deletion
+38
-35
build/tasks.ts
build/tasks.ts
+5
-0
packages/server/scripts/nexe.js
packages/server/scripts/nexe.js
+0
-7
packages/server/src/cli.ts
packages/server/src/cli.ts
+5
-21
packages/server/src/modules.ts
packages/server/src/modules.ts
+3
-0
packages/server/src/vscode/bootstrapFork.ts
packages/server/src/vscode/bootstrapFork.ts
+6
-3
packages/server/src/vscode/sharedProcess.ts
packages/server/src/vscode/sharedProcess.ts
+1
-1
packages/server/webpack.config.js
packages/server/webpack.config.js
+1
-1
packages/vscode/webpack.config.bootstrap.js
packages/vscode/webpack.config.bootstrap.js
+0
-1
scripts/webpack.general.config.js
scripts/webpack.general.config.js
+17
-1
未找到文件。
build/tasks.ts
浏览文件 @
73d6b776
...
...
@@ -82,10 +82,14 @@ const buildServerBinaryCopy = register("build:server:binary:copy", async (runner
const
webOutputPath
=
path
.
join
(
pkgsPath
,
"
web
"
,
"
out
"
);
const
browserAppOutputPath
=
path
.
join
(
pkgsPath
,
"
app
"
,
"
browser
"
,
"
out
"
);
const
nodePtyModule
=
path
.
join
(
pkgsPath
,
"
protocol
"
,
"
node_modules
"
,
"
node-pty
"
,
"
build
"
,
"
Release
"
,
"
pty.node
"
);
const
spdlogModule
=
path
.
join
(
pkgsPath
,
"
server
"
,
"
node_modules
"
,
"
spdlog
"
,
"
build
"
,
"
Release
"
,
"
spdlog.node
"
);
if
(
!
fs
.
existsSync
(
nodePtyModule
))
{
throw
new
Error
(
"
Could not find pty.node. Ensure all packages have been installed
"
);
}
if
(
!
fs
.
existsSync
(
spdlogModule
))
{
throw
new
Error
(
"
Could not find spdlog.node. Ensure all packages have been installed
"
);
}
if
(
!
fs
.
existsSync
(
webOutputPath
))
{
throw
new
Error
(
"
Web bundle must be built
"
);
}
...
...
@@ -114,6 +118,7 @@ const buildServerBinaryCopy = register("build:server:binary:copy", async (runner
cpDir
(
browserAppOutputPath
,
"
unauth
"
,
browserAppOutputPath
);
fse
.
mkdirpSync
(
path
.
join
(
cliBuildPath
,
"
modules
"
));
fse
.
copySync
(
nodePtyModule
,
path
.
join
(
cliBuildPath
,
"
modules
"
,
"
pty.node
"
));
fse
.
copySync
(
spdlogModule
,
path
.
join
(
cliBuildPath
,
"
modules
"
,
"
spdlog.node
"
));
});
const
buildServerBundle
=
register
(
"
build:server:bundle
"
,
async
(
runner
)
=>
{
...
...
packages/server/scripts/nexe.js
浏览文件 @
73d6b776
...
...
@@ -9,13 +9,6 @@ nexe.compile({
input
:
path
.
join
(
__dirname
,
"
../out/cli.js
"
),
output
:
`cli-
${
process
.
env
.
TRAVIS_OS_NAME
||
os
.
platform
()}
`
,
targets
:
[
os
.
platform
()],
native
:
{
spdlog
:
{
additionalFiles
:
[
'
spdlog.node
'
],
},
},
/**
* To include native extensions, do NOT install node_modules for each one. They
* are not required as each extension is built using webpack.
...
...
packages/server/src/cli.ts
浏览文件 @
73d6b776
...
...
@@ -38,28 +38,15 @@ export class Entry extends Command {
}];
public
async
run
():
Promise
<
void
>
{
try
{
/**
* Suuuper janky
* Comes from - https://github.com/nexe/nexe/issues/524
* Seems to cleanup by removing this path immediately
* If any native module is added its assumed this pathname
* will change.
*/
require
(
"
spdlog
"
);
const
nodePath
=
path
.
join
(
process
.
cwd
(),
"
e91a410b
"
);
fs
.
unlinkSync
(
path
.
join
(
nodePath
,
"
spdlog.node
"
));
fs
.
rmdirSync
(
nodePath
);
}
catch
(
ex
)
{
logger
.
warn
(
"
Failed to remove extracted dependency.
"
,
field
(
"
dependency
"
,
"
spdlog
"
),
field
(
"
error
"
,
ex
.
message
));
}
if
(
isCli
)
{
fillFs
();
}
const
{
args
,
flags
}
=
this
.
parse
(
Entry
);
const
dataDir
=
flags
[
"
data-dir
"
]
||
path
.
join
(
os
.
homedir
(),
"
.vscode-remote
"
);
const
workingDir
=
args
[
"
workdir
"
];
setupNativeModules
(
dataDir
);
const
builtInExtensionsDir
=
path
.
join
(
buildDir
||
path
.
join
(
__dirname
,
"
..
"
),
"
build/extensions
"
);
if
(
flags
[
"
bootstrap-fork
"
])
{
const
modulePath
=
flags
[
"
bootstrap-fork
"
];
...
...
@@ -75,7 +62,7 @@ export class Entry extends Command {
process
.
argv
[
i
+
2
]
=
arg
;
});
return
requireModule
(
modulePath
,
builtInExtensionsDir
);
return
requireModule
(
modulePath
,
dataDir
,
builtInExtensionsDir
);
}
if
(
flags
[
"
fork
"
])
{
...
...
@@ -84,9 +71,6 @@ export class Entry extends Command {
return
requireFork
(
modulePath
,
JSON
.
parse
(
flags
.
args
!
),
builtInExtensionsDir
);
}
const
dataDir
=
flags
[
"
data-dir
"
]
||
path
.
join
(
os
.
homedir
(),
"
.vscode-remote
"
);
const
workingDir
=
args
[
"
workdir
"
];
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
);
...
...
@@ -95,7 +79,7 @@ export class Entry extends Command {
if
(
!
fs
.
existsSync
(
dataDir
))
{
fs
.
mkdirSync
(
dataDir
);
}
setupNativeModules
(
dataDir
);
require
(
"
spdlog
"
);
const
logDir
=
path
.
join
(
dataDir
,
"
logs
"
,
new
Date
().
toISOString
().
replace
(
/
[
-:.TZ
]
/g
,
""
));
process
.
env
.
VSCODE_LOGS
=
logDir
;
...
...
packages/server/src/modules.ts
浏览文件 @
73d6b776
...
...
@@ -34,11 +34,14 @@ export const setup = (dataDirectory: string): void => {
* for this is unknown ATM, but this patch works around it.
*/
unpackModule
(
"
pty
"
);
unpackModule
(
"
spdlog
"
);
const
nodePtyUtils
=
require
(
"
../../protocol/node_modules/node-pty/lib/utils
"
)
as
typeof
import
(
"
../../protocol/node_modules/node-pty/src/utils
"
);
// tslint:disable-next-line:no-any
nodePtyUtils
.
loadNative
=
(
modName
:
string
):
any
=>
{
return
__non_webpack_require__
(
path
.
join
(
dataDirectory
,
"
modules
"
,
modName
+
"
.node
"
));
};
// tslint:disable-next-line:no-any
(
<
any
>
global
).
SPDLOG_LOCATION
=
path
.
join
(
dataDirectory
,
"
modules
"
,
"
spdlog.node
"
);
// tslint:disable-next-line:no-unused-expression
require
(
"
../../protocol/node_modules/node-pty/lib/index
"
)
as
typeof
import
(
"
../../protocol/node_modules/node-pty/src/index
"
);
};
packages/server/src/vscode/bootstrapFork.ts
浏览文件 @
73d6b776
...
...
@@ -71,7 +71,7 @@ export const requireFork = (modulePath: string, args: string[], builtInExtension
}
};
export
const
requireModule
=
(
modulePath
:
string
,
builtInExtensionsDir
:
string
):
void
=>
{
export
const
requireModule
=
(
modulePath
:
string
,
dataDir
:
string
,
builtInExtensionsDir
:
string
):
void
=>
{
process
.
env
.
AMD_ENTRYPOINT
=
modulePath
;
const
xml
=
require
(
"
xhr2
"
);
xml
.
XMLHttpRequest
.
prototype
.
_restrictedHeaders
[
"
user-agent
"
]
=
false
;
...
...
@@ -96,7 +96,7 @@ export const requireModule = (modulePath: string, builtInExtensionsDir: string):
*/
// tslint:disable-next-line:no-any
(
<
any
>
cp
).
fork
=
(
modulePath
:
string
,
args
:
ReadonlyArray
<
string
>
=
[],
options
?:
cp
.
ForkOptions
):
cp
.
ChildProcess
=>
{
return
cp
.
spawn
(
process
.
execPath
,
[
"
--fork
"
,
modulePath
,
"
--args
"
,
JSON
.
stringify
(
args
)],
{
return
cp
.
spawn
(
process
.
execPath
,
[
"
--fork
"
,
modulePath
,
"
--args
"
,
JSON
.
stringify
(
args
)
,
"
--data-dir
"
,
dataDir
],
{
...
options
,
stdio
:
[
null
,
null
,
null
,
"
ipc
"
],
});
...
...
@@ -123,7 +123,7 @@ export const requireModule = (modulePath: string, builtInExtensionsDir: string):
* cp.stderr.on("data", (data) => console.log(data.toString("utf8")));
* @param modulePath Path of the VS Code module to load.
*/
export
const
forkModule
=
(
modulePath
:
string
,
args
:
string
[],
options
:
cp
.
ForkOptions
):
cp
.
ChildProcess
=>
{
export
const
forkModule
=
(
modulePath
:
string
,
args
:
string
[],
options
:
cp
.
ForkOptions
,
dataDir
?:
string
):
cp
.
ChildProcess
=>
{
let
proc
:
cp
.
ChildProcess
;
const
forkArgs
=
[
"
--bootstrap-fork
"
,
modulePath
];
if
(
args
)
{
...
...
@@ -134,6 +134,9 @@ export const forkModule = (modulePath: string, args: string[], options: cp.ForkO
delete
options
.
env
.
ELECTRON_RUN_AS_NODE
;
forkArgs
.
push
(
"
--env
"
,
JSON
.
stringify
(
options
.
env
));
}
if
(
dataDir
)
{
forkArgs
.
push
(
"
--data-dir
"
,
dataDir
);
}
const
forkOptions
:
cp
.
ForkOptions
=
{
stdio
:
[
null
,
null
,
null
,
"
ipc
"
],
};
...
...
packages/server/src/vscode/sharedProcess.ts
浏览文件 @
73d6b776
...
...
@@ -84,7 +84,7 @@ export class SharedProcess {
VSCODE_ALLOW_IO
:
"
true
"
,
VSCODE_LOGS
:
process
.
env
.
VSCODE_LOGS
,
},
});
}
,
this
.
userDataDir
);
if
(
this
.
logger
.
level
<=
Level
.
Trace
)
{
this
.
activeProcess
.
stdout
.
on
(
"
data
"
,
(
data
)
=>
{
this
.
logger
.
trace
(()
=>
[
"
stdout
"
,
field
(
"
data
"
,
data
.
toString
())]);
...
...
packages/server/webpack.config.js
浏览文件 @
73d6b776
...
...
@@ -48,7 +48,7 @@ module.exports = merge({
__dirname
:
false
,
setImmediate
:
false
},
externals
:
[
"
spdlog
"
,
"
tslib
"
,
"
trash
"
],
externals
:
[
"
tslib
"
,
"
trash
"
],
entry
:
"
./packages/server/src/cli.ts
"
,
target
:
"
node
"
,
plugins
:
[
...
...
packages/vscode/webpack.config.bootstrap.js
浏览文件 @
73d6b776
...
...
@@ -16,7 +16,6 @@ module.exports = (env) => {
entry
:
path
.
join
(
root
,
"
lib/vscode/src/bootstrap-fork.js
"
),
mode
:
"
development
"
,
target
:
"
node
"
,
externals
:
[
"
spdlog
"
],
output
:
{
chunkFilename
:
"
[name].bundle.js
"
,
path
:
path
.
resolve
(
__dirname
,
"
./bin
"
),
...
...
scripts/webpack.general.config.js
浏览文件 @
73d6b776
...
...
@@ -83,7 +83,23 @@ module.exports = (options = {}) => ({
},
{
test
:
/
\.
wasm$/
,
type
:
"
javascript/auto
"
,
}],
},
{
/**
* Fixes spdlog
*/
test
:
/spdlog
\/
index
\.
js/
,
loader
:
"
string-replace-loader
"
,
options
:
{
multiple
:
[{
// These will be handled by file-loader. We need the location because
// they are parsed as URIs and will throw errors if not fully formed.
// The !! prefix causes it to ignore other loaders (doesn't work).
search
:
"
const spdlog.*;
"
,
replace
:
"
const spdlog = __non_webpack_require__(global.SPDLOG_LOCATION);
"
,
flags
:
"
g
"
,
}],
},
},],
noParse
:
/
\/
test
\/
|
\.
test
\.
jsx
?
|
\.
test
\.
tsx
?
|tsconfig.+
\.
json$/
,
},
resolve
:
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录