Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
徽霖
Vscode
提交
9dea7369
V
Vscode
项目概览
徽霖
/
Vscode
通知
9
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
Vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
9dea7369
编写于
9月 15, 2016
作者:
J
Joao Moreno
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
process vsix installations from args
上级
3634d3d1
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
75 addition
and
25 deletion
+75
-25
src/vs/code/node/sharedProcessMain.ts
src/vs/code/node/sharedProcessMain.ts
+7
-2
src/vs/platform/environment/node/argv.ts
src/vs/platform/environment/node/argv.ts
+9
-1
src/vs/platform/extensionManagement/common/extensionManagement.ts
...latform/extensionManagement/common/extensionManagement.ts
+13
-2
src/vs/platform/extensionManagement/common/extensionManagementIpc.ts
...form/extensionManagement/common/extensionManagementIpc.ts
+16
-6
src/vs/platform/extensionManagement/node/extensionManagementService.ts
...rm/extensionManagement/node/extensionManagementService.ts
+7
-5
src/vs/workbench/parts/extensions/electron-browser/extensionsWorkbenchService.ts
...extensions/electron-browser/extensionsWorkbenchService.ts
+23
-9
未找到文件。
src/vs/code/node/sharedProcessMain.ts
浏览文件 @
9dea7369
...
...
@@ -103,12 +103,17 @@ function main(server: Server, initData: ISharedProcessInitData): void {
const
instantiationService2
=
instantiationService
.
createChild
(
services
);
instantiationService2
.
invokeFunction
(
accessor
=>
{
const
environmentService
=
accessor
.
get
(
IEnvironmentService
);
const
extensionManagementService
=
accessor
.
get
(
IExtensionManagementService
);
const
channel
=
new
ExtensionManagementChannel
(
extensionManagementService
);
server
.
registerChannel
(
'
extensions
'
,
channel
);
// eventually clean up old extensions
setTimeout
(()
=>
(
extensionManagementService
as
ExtensionManagementService
).
removeDeprecatedExtensions
(),
100
);
// clean up deprecated extensions
(
extensionManagementService
as
ExtensionManagementService
).
removeDeprecatedExtensions
();
// install vsix
environmentService
.
args
[
'
install-vsix
'
]
.
forEach
(
vsix
=>
extensionManagementService
.
install
(
vsix
));
});
});
}
...
...
src/vs/platform/environment/node/argv.ts
浏览文件 @
9dea7369
...
...
@@ -7,6 +7,7 @@ import * as os from 'os';
import
*
as
minimist
from
'
minimist
'
;
import
*
as
assert
from
'
assert
'
;
import
{
firstIndex
}
from
'
vs/base/common/arrays
'
;
import
{
not
}
from
'
vs/base/common/functional
'
;
import
{
localize
}
from
'
vs/nls
'
;
export
interface
ParsedArgs
extends
minimist
.
ParsedArgs
{
...
...
@@ -31,6 +32,7 @@ export interface ParsedArgs extends minimist.ParsedArgs {
'
list-extensions
'
?:
boolean
;
'
install-extension
'
?:
string
|
string
[];
'
uninstall-extension
'
?:
string
|
string
[];
'
install-vsix
'
?:
string
[];
}
const
options
:
minimist
.
Opts
=
{
...
...
@@ -119,7 +121,13 @@ export function parseCLIProcessArgv(processArgv: string[]): ParsedArgs {
* Use this to parse code arguments such as `--verbose --wait`
*/
export
function
parseArgs
(
args
:
string
[]):
ParsedArgs
{
return
minimist
(
args
,
options
)
as
ParsedArgs
;
const
result
=
minimist
(
args
,
options
)
as
ParsedArgs
;
const
isVSIX
=
a
=>
/
\.
vsix$/i
.
test
(
a
);
result
[
'
install-vsix
'
]
=
result
.
_
.
filter
(
isVSIX
);
result
.
_
=
result
.
_
.
filter
(
not
(
isVSIX
));
return
result
;
}
export
const
optionsHelp
:
{
[
name
:
string
]:
string
;
}
=
{
...
...
src/vs/platform/extensionManagement/common/extensionManagement.ts
浏览文件 @
9dea7369
...
...
@@ -180,8 +180,19 @@ export interface IExtensionGalleryService {
getAsset
(
url
:
string
):
TPromise
<
IRequestContext
>
;
}
export
type
InstallExtensionEvent
=
{
id
:
string
;
gallery
?:
IGalleryExtension
;
};
export
type
DidInstallExtensionEvent
=
{
id
:
string
;
local
?:
ILocalExtension
;
error
?:
Error
;
};
export
interface
InstallExtensionEvent
{
id
:
string
;
zipPath
?:
string
;
gallery
?:
IGalleryExtension
;
}
export
interface
DidInstallExtensionEvent
{
id
:
string
;
zipPath
?:
string
;
gallery
?:
IGalleryExtension
;
local
?:
ILocalExtension
;
error
?:
Error
;
}
export
interface
IExtensionManagementService
{
_serviceBrand
:
any
;
...
...
src/vs/platform/extensionManagement/common/extensionManagementIpc.ts
浏览文件 @
9dea7369
...
...
@@ -8,7 +8,7 @@
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
IChannel
,
eventToCall
,
eventFromCall
}
from
'
vs/base/parts/ipc/common/ipc
'
;
import
{
IExtensionManagementService
,
ILocalExtension
,
InstallExtensionEvent
,
DidInstallExtensionEvent
,
IGalleryExtension
}
from
'
./extensionManagement
'
;
import
Event
from
'
vs/base/common/event
'
;
import
Event
,
{
buffer
}
from
'
vs/base/common/event
'
;
export
interface
IExtensionManagementChannel
extends
IChannel
{
call
(
command
:
'
event:onInstallExtension
'
):
TPromise
<
void
>
;
...
...
@@ -24,14 +24,24 @@ export interface IExtensionManagementChannel extends IChannel {
export
class
ExtensionManagementChannel
implements
IExtensionManagementChannel
{
constructor
(
private
service
:
IExtensionManagementService
)
{
}
onInstallExtension
:
Event
<
InstallExtensionEvent
>
;
onDidInstallExtension
:
Event
<
DidInstallExtensionEvent
>
;
onUninstallExtension
:
Event
<
string
>
;
onDidUninstallExtension
:
Event
<
string
>
;
constructor
(
private
service
:
IExtensionManagementService
)
{
this
.
onInstallExtension
=
buffer
(
service
.
onInstallExtension
,
true
);
this
.
onDidInstallExtension
=
buffer
(
service
.
onDidInstallExtension
,
true
);
this
.
onUninstallExtension
=
buffer
(
service
.
onUninstallExtension
,
true
);
this
.
onDidUninstallExtension
=
buffer
(
service
.
onDidUninstallExtension
,
true
);
}
call
(
command
:
string
,
arg
:
any
):
TPromise
<
any
>
{
switch
(
command
)
{
case
'
event:onInstallExtension
'
:
return
eventToCall
(
this
.
service
.
onInstallExtension
);
case
'
event:onDidInstallExtension
'
:
return
eventToCall
(
this
.
service
.
onDidInstallExtension
);
case
'
event:onUninstallExtension
'
:
return
eventToCall
(
this
.
service
.
onUninstallExtension
);
case
'
event:onDidUninstallExtension
'
:
return
eventToCall
(
this
.
service
.
onDidUninstallExtension
);
case
'
event:onInstallExtension
'
:
return
eventToCall
(
this
.
onInstallExtension
);
case
'
event:onDidInstallExtension
'
:
return
eventToCall
(
this
.
onDidInstallExtension
);
case
'
event:onUninstallExtension
'
:
return
eventToCall
(
this
.
onUninstallExtension
);
case
'
event:onDidUninstallExtension
'
:
return
eventToCall
(
this
.
onDidUninstallExtension
);
case
'
install
'
:
return
this
.
service
.
install
(
arg
);
case
'
installFromGallery
'
:
return
this
.
service
.
installFromGallery
(
arg
);
case
'
uninstall
'
:
return
this
.
service
.
uninstall
(
arg
);
...
...
src/vs/platform/extensionManagement/node/extensionManagementService.ts
浏览文件 @
9dea7369
...
...
@@ -91,6 +91,8 @@ export class ExtensionManagementService implements IExtensionManagementService {
}
install
(
zipPath
:
string
):
TPromise
<
void
>
{
zipPath
=
path
.
resolve
(
zipPath
);
return
validate
(
zipPath
).
then
<
void
>
(
manifest
=>
{
const
id
=
getExtensionId
(
manifest
,
manifest
.
version
);
...
...
@@ -99,12 +101,12 @@ export class ExtensionManagementService implements IExtensionManagementService {
return
TPromise
.
wrapError
(
new
Error
(
nls
.
localize
(
'
restartCode
'
,
"
Please restart Code before reinstalling {0}.
"
,
manifest
.
displayName
||
manifest
.
name
)));
}
this
.
_onInstallExtension
.
fire
({
id
});
this
.
_onInstallExtension
.
fire
({
id
,
zipPath
});
return
this
.
installExtension
(
zipPath
,
id
)
.
then
(
local
=>
this
.
_onDidInstallExtension
.
fire
({
id
,
local
}),
error
=>
{
this
.
_onDidInstallExtension
.
fire
({
id
,
error
});
return
TPromise
.
wrapError
(
error
);
}
local
=>
this
.
_onDidInstallExtension
.
fire
({
id
,
zipPath
,
local
}),
error
=>
{
this
.
_onDidInstallExtension
.
fire
({
id
,
zipPath
,
error
});
return
TPromise
.
wrapError
(
error
);
}
);
});
});
...
...
@@ -130,8 +132,8 @@ export class ExtensionManagementService implements IExtensionManagementService {
.
then
(
zipPath
=>
validate
(
zipPath
).
then
(()
=>
zipPath
))
.
then
(
zipPath
=>
this
.
installExtension
(
zipPath
,
id
,
metadata
))
.
then
(
local
=>
this
.
_onDidInstallExtension
.
fire
({
id
,
local
}),
error
=>
{
this
.
_onDidInstallExtension
.
fire
({
id
,
error
});
return
TPromise
.
wrapError
(
error
);
}
local
=>
this
.
_onDidInstallExtension
.
fire
({
id
,
local
,
gallery
:
extension
}),
error
=>
{
this
.
_onDidInstallExtension
.
fire
({
id
,
gallery
:
extension
,
error
});
return
TPromise
.
wrapError
(
error
);
}
);
});
}
...
...
src/vs/workbench/parts/extensions/electron-browser/extensionsWorkbenchService.ts
浏览文件 @
9dea7369
...
...
@@ -18,7 +18,8 @@ import { TPromise } from 'vs/base/common/winjs.base';
import
{
IDisposable
,
dispose
}
from
'
vs/base/common/lifecycle
'
;
import
{
IPager
,
mapPager
,
singlePagePager
}
from
'
vs/base/common/paging
'
;
import
{
ITelemetryService
}
from
'
vs/platform/telemetry/common/telemetry
'
;
import
{
IExtensionManagementService
,
IExtensionGalleryService
,
ILocalExtension
,
IGalleryExtension
,
IQueryOptions
,
IExtensionManifest
}
from
'
vs/platform/extensionManagement/common/extensionManagement
'
;
import
{
IExtensionManagementService
,
IExtensionGalleryService
,
ILocalExtension
,
IGalleryExtension
,
IQueryOptions
,
IExtensionManifest
,
InstallExtensionEvent
,
DidInstallExtensionEvent
}
from
'
vs/platform/extensionManagement/common/extensionManagement
'
;
import
{
getGalleryExtensionTelemetryData
,
getLocalExtensionTelemetryData
}
from
'
vs/platform/extensionManagement/common/extensionTelemetry
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
...
...
@@ -35,6 +36,7 @@ import { UpdateAllAction } from './extensionsActions';
import
{
IFileService
}
from
'
vs/platform/files/common/files
'
;
import
{
IWorkbenchEditorService
}
from
'
vs/workbench/services/editor/common/editorService
'
;
import
{
Content
}
from
'
vs/workbench/parts/extensions/electron-browser/extensionsFileTemplate
'
;
import
{
ReloadWindowAction
}
from
'
vs/workbench/electron-browser/actions
'
;
interface
IExtensionStateProvider
{
(
extension
:
Extension
):
ExtensionState
;
...
...
@@ -268,10 +270,10 @@ export class ExtensionsWorkbenchService implements IExtensionsWorkbenchService {
)
{
this
.
stateProvider
=
ext
=>
this
.
getExtensionState
(
ext
);
this
.
disposables
.
push
(
extensionService
.
onInstallExtension
(({
id
,
gallery
})
=>
this
.
onInstallExtension
(
id
,
gallery
))
);
this
.
disposables
.
push
(
extensionService
.
onDidInstallExtension
(({
id
,
local
,
error
})
=>
this
.
onDidInstallExtension
(
id
,
local
,
error
))
);
this
.
disposables
.
push
(
extensionService
.
onUninstallExtension
(
id
=>
this
.
onUninstallExtension
(
id
))
);
this
.
disposables
.
push
(
extensionService
.
onDidUninstallExtension
(
id
=>
this
.
onDidUninstallExtension
(
id
))
);
extensionService
.
onInstallExtension
(
this
.
onInstallExtension
,
this
,
this
.
disposables
);
extensionService
.
onDidInstallExtension
(
this
.
onDidInstallExtension
,
this
,
this
.
disposables
);
extensionService
.
onUninstallExtension
(
this
.
onUninstallExtension
,
this
,
this
.
disposables
);
extensionService
.
onDidUninstallExtension
(
this
.
onDidUninstallExtension
,
this
,
this
.
disposables
);
this
.
syncDelayer
=
new
ThrottledDelayer
<
void
>
(
ExtensionsWorkbenchService
.
SyncPeriod
);
...
...
@@ -395,7 +397,9 @@ export class ExtensionsWorkbenchService implements IExtensionsWorkbenchService {
return
this
.
extensionService
.
uninstall
(
local
);
}
private
onInstallExtension
(
id
:
string
,
gallery
:
IGalleryExtension
):
void
{
private
onInstallExtension
(
event
:
InstallExtensionEvent
):
void
{
const
{
id
,
gallery
}
=
event
;
if
(
!
gallery
)
{
return
;
}
...
...
@@ -415,12 +419,22 @@ export class ExtensionsWorkbenchService implements IExtensionsWorkbenchService {
this
.
_onChange
.
fire
();
}
private
onDidInstallExtension
(
id
:
string
,
local
:
ILocalExtension
,
error
:
Error
):
void
{
id
=
stripVersion
(
id
)
;
private
onDidInstallExtension
(
event
:
DidInstallExtensionEvent
):
void
{
const
{
local
,
zipPath
,
error
}
=
event
;
const
id
=
stripVersion
(
event
.
id
);
const
installing
=
this
.
installing
.
filter
(
e
=>
e
.
id
===
id
)[
0
];
if
(
!
installing
)
{
if
(
zipPath
)
{
this
.
messageService
.
show
(
Severity
.
Info
,
{
message
:
localize
(
'
successSingle
'
,
"
'{0}' was successfully installed. Restart to enable it.
"
,
id
),
actions
:
[
this
.
instantiationService
.
createInstance
(
ReloadWindowAction
,
ReloadWindowAction
.
ID
,
localize
(
'
reloadNow
'
,
"
Restart Now
"
))]
}
);
}
return
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录