Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
f15177d2
V
vscode
项目概览
xxadev
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
f15177d2
编写于
6月 17, 2016
作者:
J
Joao Moreno
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add metadata to local extensions
上级
ec45ebf0
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
26 addition
and
22 deletion
+26
-22
src/vs/platform/extensionManagement/common/extensionManagement.ts
...latform/extensionManagement/common/extensionManagement.ts
+1
-0
src/vs/platform/extensionManagement/node/extensionManagementService.ts
...rm/extensionManagement/node/extensionManagementService.ts
+25
-22
未找到文件。
src/vs/platform/extensionManagement/common/extensionManagement.ts
浏览文件 @
f15177d2
...
...
@@ -46,6 +46,7 @@ export interface IGalleryExtension {
export
interface
IExtension
{
id
:
string
;
manifest
:
IExtensionManifest
;
metadata
:
IGalleryMetadata
;
}
export
const
IExtensionManagementService
=
createDecorator
<
IExtensionManagementService
>
(
'
extensionManagementService
'
);
...
...
src/vs/platform/extensionManagement/node/extensionManagementService.ts
浏览文件 @
f15177d2
...
...
@@ -15,7 +15,7 @@ import { IDisposable, dispose } from 'vs/base/common/lifecycle';
import
{
flatten
}
from
'
vs/base/common/arrays
'
;
import
{
extract
,
buffer
}
from
'
vs/base/node/zip
'
;
import
{
Promise
,
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
IExtensionManagementService
,
IExtension
,
IGalleryExtension
,
IExtensionManifest
,
IGalleryVersion
}
from
'
vs/platform/extensionManagement/common/extensionManagement
'
;
import
{
IExtensionManagementService
,
IExtension
,
IGalleryExtension
,
IExtensionManifest
,
IGalleryVersion
,
IGalleryMetadata
}
from
'
vs/platform/extensionManagement/common/extensionManagement
'
;
import
{
download
,
json
,
IRequestOptions
}
from
'
vs/base/node/request
'
;
import
{
getProxyAgent
}
from
'
vs/base/node/proxy
'
;
import
{
IEnvironmentService
}
from
'
vs/platform/environment/common/environment
'
;
...
...
@@ -28,10 +28,13 @@ import { groupBy, values } from 'vs/base/common/collections';
import
{
isValidExtensionVersion
}
from
'
vs/platform/extensions/node/extensionValidator
'
;
import
pkg
from
'
vs/platform/package
'
;
function
parseManifest
(
raw
:
string
):
TPromise
<
IExtensionManifest
>
{
function
parseManifest
(
raw
:
string
):
TPromise
<
{
manifest
:
IExtensionManifest
;
metadata
:
IGalleryMetadata
;
}
>
{
return
new
Promise
((
c
,
e
)
=>
{
try
{
c
(
JSON
.
parse
(
raw
));
const
manifest
=
JSON
.
parse
(
raw
);
const
metadata
=
manifest
.
__metadata
||
null
;
delete
manifest
.
__metadata
;
c
({
manifest
,
metadata
});
}
catch
(
err
)
{
e
(
new
Error
(
nls
.
localize
(
'
invalidManifest
'
,
"
Extension invalid: package.json is not a JSON file.
"
)));
}
...
...
@@ -41,7 +44,7 @@ function parseManifest(raw: string): TPromise<IExtensionManifest> {
function
validate
(
zipPath
:
string
,
extension
?:
IExtensionManifest
,
version
=
extension
&&
extension
.
version
):
TPromise
<
IExtensionManifest
>
{
return
buffer
(
zipPath
,
'
extension/package.json
'
)
.
then
(
buffer
=>
parseManifest
(
buffer
.
toString
(
'
utf8
'
)))
.
then
(
manifest
=>
{
.
then
(
({
manifest
})
=>
{
if
(
extension
)
{
if
(
extension
.
name
!==
manifest
.
name
)
{
return
Promise
.
wrapError
(
Error
(
nls
.
localize
(
'
invalidName
'
,
"
Extension invalid: manifest name mismatch.
"
)));
...
...
@@ -126,24 +129,18 @@ export class ExtensionManagementService implements IExtensionManagementService {
}
private
installFromGallery
(
extension
:
IGalleryExtension
):
TPromise
<
void
>
{
const
id
=
getExtensionId
(
extension
.
manifest
);
this
.
_onInstallExtension
.
fire
(
id
);
return
this
.
getLastValidExtensionVersion
(
extension
).
then
(
versionInfo
=>
{
const
version
=
versionInfo
.
version
;
const
url
=
versionInfo
.
downloadUrl
;
const
headers
=
versionInfo
.
downloadHeaders
;
const
zipPath
=
path
.
join
(
tmpdir
(),
extension
.
id
);
const
extensionPath
=
path
.
join
(
this
.
extensionsPath
,
getExtensionId
(
extension
.
manifest
,
version
)
);
const
id
=
getExtensionId
(
extension
.
manifest
,
version
);
return
this
.
request
(
url
)
.
then
(
opts
=>
assign
(
opts
,
{
headers
}))
.
then
(
opts
=>
download
(
zipPath
,
opts
))
.
then
(()
=>
validate
(
zipPath
,
extension
.
manifest
,
version
))
.
then
(
manifest
=>
extract
(
zipPath
,
extensionPath
,
{
sourcePath
:
'
extension
'
,
overwrite
:
true
}))
.
then
(()
=>
this
.
_onDidInstallExtension
.
fire
({
id
}))
.
then
<
void
>
(
null
,
error
=>
{
this
.
_onDidInstallExtension
.
fire
({
id
,
error
});
return
TPromise
.
wrapError
(
error
);
});
.
then
(()
=>
this
.
installValidExtension
(
zipPath
,
id
,
extension
.
metadata
));
});
}
...
...
@@ -175,15 +172,21 @@ export class ExtensionManagementService implements IExtensionManagementService {
}
private
installFromZip
(
zipPath
:
string
):
TPromise
<
void
>
{
return
validate
(
zipPath
).
then
(
manifest
=>
{
const
id
=
getExtensionId
(
manifest
);
const
extensionPath
=
path
.
join
(
this
.
extensionsPath
,
id
);
this
.
_onInstallExtension
.
fire
(
id
);
return
extract
(
zipPath
,
extensionPath
,
{
sourcePath
:
'
extension
'
,
overwrite
:
true
})
.
then
(()
=>
this
.
_onDidInstallExtension
.
fire
({
id
}))
.
then
<
void
>
(
null
,
error
=>
{
this
.
_onDidInstallExtension
.
fire
({
id
,
error
});
return
TPromise
.
wrapError
(
error
);
});
});
return
validate
(
zipPath
).
then
(
manifest
=>
this
.
installValidExtension
(
zipPath
,
getExtensionId
(
manifest
)));
}
private
installValidExtension
(
zipPath
:
string
,
id
:
string
,
metadata
:
IGalleryMetadata
=
null
):
TPromise
<
void
>
{
const
extensionPath
=
path
.
join
(
this
.
extensionsPath
,
id
);
const
manifestPath
=
path
.
join
(
extensionPath
,
'
package.json
'
);
this
.
_onInstallExtension
.
fire
(
id
);
return
extract
(
zipPath
,
extensionPath
,
{
sourcePath
:
'
extension
'
,
overwrite
:
true
})
.
then
(()
=>
pfs
.
readFile
(
manifestPath
,
'
utf8
'
))
.
then
(
raw
=>
parseManifest
(
raw
))
.
then
(({
manifest
})
=>
assign
(
manifest
,
{
__metadata
:
metadata
}))
.
then
(
manifest
=>
pfs
.
writeFile
(
manifestPath
,
JSON
.
stringify
(
manifest
,
null
,
'
\t
'
)))
.
then
(()
=>
this
.
_onDidInstallExtension
.
fire
({
id
}))
.
then
<
void
>
(
null
,
error
=>
{
this
.
_onDidInstallExtension
.
fire
({
id
,
error
});
return
TPromise
.
wrapError
(
error
);
});
}
uninstall
(
extension
:
IExtension
):
TPromise
<
void
>
{
...
...
@@ -225,7 +228,7 @@ export class ExtensionManagementService implements IExtensionManagementService {
return
limiter
.
queue
(
()
=>
pfs
.
readFile
(
path
.
join
(
extensionPath
,
'
package.json
'
),
'
utf8
'
)
.
then
(
raw
=>
parseManifest
(
raw
))
.
then
<
IExtension
>
(
manifest
=>
({
id
,
manifest
}))
.
then
(({
manifest
,
metadata
})
=>
({
id
,
manifest
,
metadata
}))
.
then
(
null
,
()
=>
null
)
);
})))
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录