@theia/vsx-registry 1.53.0-next.55 → 1.53.0-next.64
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +45 -45
- package/package.json +10 -10
- package/src/browser/recommended-extensions/preference-provider-overrides.ts +99 -99
- package/src/browser/recommended-extensions/recommended-extensions-json-schema.ts +74 -74
- package/src/browser/recommended-extensions/recommended-extensions-preference-contribution.ts +68 -68
- package/src/browser/style/extensions.svg +4 -4
- package/src/browser/style/index.css +436 -436
- package/src/browser/vsx-extension-argument-processor.ts +32 -32
- package/src/browser/vsx-extension-commands.ts +68 -68
- package/src/browser/vsx-extension-editor-manager.ts +42 -42
- package/src/browser/vsx-extension-editor.tsx +96 -96
- package/src/browser/vsx-extension.tsx +710 -710
- package/src/browser/vsx-extensions-contribution.ts +373 -373
- package/src/browser/vsx-extensions-model.ts +456 -456
- package/src/browser/vsx-extensions-preferences.ts +58 -58
- package/src/browser/vsx-extensions-search-bar.tsx +107 -107
- package/src/browser/vsx-extensions-search-model.ts +61 -61
- package/src/browser/vsx-extensions-source.ts +83 -83
- package/src/browser/vsx-extensions-view-container.ts +179 -179
- package/src/browser/vsx-extensions-widget.tsx +165 -165
- package/src/browser/vsx-language-quick-pick-service.ts +112 -112
- package/src/browser/vsx-registry-frontend-module.ts +113 -113
- package/src/common/index.ts +19 -19
- package/src/common/ovsx-client-provider.ts +35 -35
- package/src/common/vsx-environment.ts +28 -28
- package/src/common/vsx-extension-uri.ts +20 -20
- package/src/common/vsx-registry-common-module.ts +85 -85
- package/src/node/vsx-cli-deployer-participant.ts +46 -46
- package/src/node/vsx-cli.ts +55 -55
- package/src/node/vsx-environment-impl.ts +54 -54
- package/src/node/vsx-extension-resolver.ts +134 -134
- package/src/node/vsx-registry-backend-module.ts +38 -38
- package/src/node/vsx-remote-cli.ts +39 -39
- package/src/package.spec.ts +29 -29
|
@@ -1,46 +1,46 @@
|
|
|
1
|
-
// *****************************************************************************
|
|
2
|
-
// Copyright (C) 2024 TypeFox and others.
|
|
3
|
-
//
|
|
4
|
-
// This program and the accompanying materials are made available under the
|
|
5
|
-
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
-
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
-
//
|
|
8
|
-
// This Source Code may also be made available under the following Secondary
|
|
9
|
-
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
-
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
-
// with the GNU Classpath Exception which is available at
|
|
12
|
-
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
-
//
|
|
14
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
-
// *****************************************************************************
|
|
16
|
-
|
|
17
|
-
import { inject, injectable } from '@theia/core/shared/inversify';
|
|
18
|
-
import { PluginDeployerParticipant, PluginDeployerStartContext } from '@theia/plugin-ext';
|
|
19
|
-
import { VsxCli } from './vsx-cli';
|
|
20
|
-
import { VSXExtensionUri } from '../common';
|
|
21
|
-
import * as fs from 'fs';
|
|
22
|
-
import { FileUri } from '@theia/core/lib/node';
|
|
23
|
-
import * as path from 'path';
|
|
24
|
-
|
|
25
|
-
@injectable()
|
|
26
|
-
export class VsxCliDeployerParticipant implements PluginDeployerParticipant {
|
|
27
|
-
|
|
28
|
-
@inject(VsxCli)
|
|
29
|
-
protected readonly vsxCli: VsxCli;
|
|
30
|
-
|
|
31
|
-
async onWillStart(context: PluginDeployerStartContext): Promise<void> {
|
|
32
|
-
const pluginUris = await Promise.all(this.vsxCli.pluginsToInstall.map(async id => {
|
|
33
|
-
try {
|
|
34
|
-
const resolvedPath = path.resolve(id);
|
|
35
|
-
const stat = await fs.promises.stat(resolvedPath);
|
|
36
|
-
if (stat.isFile()) {
|
|
37
|
-
return FileUri.create(resolvedPath).withScheme('local-file').toString();
|
|
38
|
-
}
|
|
39
|
-
} catch (e) {
|
|
40
|
-
// expected if file does not exist
|
|
41
|
-
}
|
|
42
|
-
return VSXExtensionUri.fromVersionedId(id).toString();
|
|
43
|
-
}));
|
|
44
|
-
context.userEntries.push(...pluginUris);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2024 TypeFox and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
import { inject, injectable } from '@theia/core/shared/inversify';
|
|
18
|
+
import { PluginDeployerParticipant, PluginDeployerStartContext } from '@theia/plugin-ext';
|
|
19
|
+
import { VsxCli } from './vsx-cli';
|
|
20
|
+
import { VSXExtensionUri } from '../common';
|
|
21
|
+
import * as fs from 'fs';
|
|
22
|
+
import { FileUri } from '@theia/core/lib/node';
|
|
23
|
+
import * as path from 'path';
|
|
24
|
+
|
|
25
|
+
@injectable()
|
|
26
|
+
export class VsxCliDeployerParticipant implements PluginDeployerParticipant {
|
|
27
|
+
|
|
28
|
+
@inject(VsxCli)
|
|
29
|
+
protected readonly vsxCli: VsxCli;
|
|
30
|
+
|
|
31
|
+
async onWillStart(context: PluginDeployerStartContext): Promise<void> {
|
|
32
|
+
const pluginUris = await Promise.all(this.vsxCli.pluginsToInstall.map(async id => {
|
|
33
|
+
try {
|
|
34
|
+
const resolvedPath = path.resolve(id);
|
|
35
|
+
const stat = await fs.promises.stat(resolvedPath);
|
|
36
|
+
if (stat.isFile()) {
|
|
37
|
+
return FileUri.create(resolvedPath).withScheme('local-file').toString();
|
|
38
|
+
}
|
|
39
|
+
} catch (e) {
|
|
40
|
+
// expected if file does not exist
|
|
41
|
+
}
|
|
42
|
+
return VSXExtensionUri.fromVersionedId(id).toString();
|
|
43
|
+
}));
|
|
44
|
+
context.userEntries.push(...pluginUris);
|
|
45
|
+
}
|
|
46
|
+
}
|
package/src/node/vsx-cli.ts
CHANGED
|
@@ -1,55 +1,55 @@
|
|
|
1
|
-
// *****************************************************************************
|
|
2
|
-
// Copyright (C) 2023 Ericsson and others.
|
|
3
|
-
//
|
|
4
|
-
// This program and the accompanying materials are made available under the
|
|
5
|
-
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
-
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
-
//
|
|
8
|
-
// This Source Code may also be made available under the following Secondary
|
|
9
|
-
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
-
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
-
// with the GNU Classpath Exception which is available at
|
|
12
|
-
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
-
//
|
|
14
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
-
// *****************************************************************************
|
|
16
|
-
|
|
17
|
-
import { CliContribution } from '@theia/core/lib/node';
|
|
18
|
-
import { injectable } from '@theia/core/shared/inversify';
|
|
19
|
-
import { Argv } from '@theia/core/shared/yargs';
|
|
20
|
-
import { OVSX_RATE_LIMIT, OVSXRouterConfig } from '@theia/ovsx-client';
|
|
21
|
-
import * as fs from 'fs';
|
|
22
|
-
|
|
23
|
-
@injectable()
|
|
24
|
-
export class VsxCli implements CliContribution {
|
|
25
|
-
|
|
26
|
-
ovsxRouterConfig: OVSXRouterConfig | undefined;
|
|
27
|
-
ovsxRateLimit: number;
|
|
28
|
-
pluginsToInstall: string[] = [];
|
|
29
|
-
|
|
30
|
-
configure(conf: Argv<{}>): void {
|
|
31
|
-
conf.option('ovsx-router-config', { description: 'JSON configuration file for the OVSX router client', type: 'string' });
|
|
32
|
-
conf.option('ovsx-rate-limit', { description: 'Limits the number of requests to OVSX per second', type: 'number', default: OVSX_RATE_LIMIT });
|
|
33
|
-
conf.option('install-plugin', {
|
|
34
|
-
alias: 'install-extension',
|
|
35
|
-
nargs: 1,
|
|
36
|
-
desc: 'Installs or updates a plugin. Argument is a path to the *.vsix file or a plugin id of the form "publisher.name[@version]"'
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
async setArguments(args: Record<string, unknown>): Promise<void> {
|
|
41
|
-
const { 'ovsx-router-config': ovsxRouterConfig } = args;
|
|
42
|
-
if (typeof ovsxRouterConfig === 'string') {
|
|
43
|
-
this.ovsxRouterConfig = JSON.parse(await fs.promises.readFile(ovsxRouterConfig, 'utf8'));
|
|
44
|
-
}
|
|
45
|
-
let pluginsToInstall = args.installPlugin;
|
|
46
|
-
if (typeof pluginsToInstall === 'string') {
|
|
47
|
-
pluginsToInstall = [pluginsToInstall];
|
|
48
|
-
}
|
|
49
|
-
if (Array.isArray(pluginsToInstall)) {
|
|
50
|
-
this.pluginsToInstall = pluginsToInstall;
|
|
51
|
-
}
|
|
52
|
-
const ovsxRateLimit = args.ovsxRateLimit;
|
|
53
|
-
this.ovsxRateLimit = typeof ovsxRateLimit === 'number' ? ovsxRateLimit : OVSX_RATE_LIMIT;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2023 Ericsson and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
import { CliContribution } from '@theia/core/lib/node';
|
|
18
|
+
import { injectable } from '@theia/core/shared/inversify';
|
|
19
|
+
import { Argv } from '@theia/core/shared/yargs';
|
|
20
|
+
import { OVSX_RATE_LIMIT, OVSXRouterConfig } from '@theia/ovsx-client';
|
|
21
|
+
import * as fs from 'fs';
|
|
22
|
+
|
|
23
|
+
@injectable()
|
|
24
|
+
export class VsxCli implements CliContribution {
|
|
25
|
+
|
|
26
|
+
ovsxRouterConfig: OVSXRouterConfig | undefined;
|
|
27
|
+
ovsxRateLimit: number;
|
|
28
|
+
pluginsToInstall: string[] = [];
|
|
29
|
+
|
|
30
|
+
configure(conf: Argv<{}>): void {
|
|
31
|
+
conf.option('ovsx-router-config', { description: 'JSON configuration file for the OVSX router client', type: 'string' });
|
|
32
|
+
conf.option('ovsx-rate-limit', { description: 'Limits the number of requests to OVSX per second', type: 'number', default: OVSX_RATE_LIMIT });
|
|
33
|
+
conf.option('install-plugin', {
|
|
34
|
+
alias: 'install-extension',
|
|
35
|
+
nargs: 1,
|
|
36
|
+
desc: 'Installs or updates a plugin. Argument is a path to the *.vsix file or a plugin id of the form "publisher.name[@version]"'
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
async setArguments(args: Record<string, unknown>): Promise<void> {
|
|
41
|
+
const { 'ovsx-router-config': ovsxRouterConfig } = args;
|
|
42
|
+
if (typeof ovsxRouterConfig === 'string') {
|
|
43
|
+
this.ovsxRouterConfig = JSON.parse(await fs.promises.readFile(ovsxRouterConfig, 'utf8'));
|
|
44
|
+
}
|
|
45
|
+
let pluginsToInstall = args.installPlugin;
|
|
46
|
+
if (typeof pluginsToInstall === 'string') {
|
|
47
|
+
pluginsToInstall = [pluginsToInstall];
|
|
48
|
+
}
|
|
49
|
+
if (Array.isArray(pluginsToInstall)) {
|
|
50
|
+
this.pluginsToInstall = pluginsToInstall;
|
|
51
|
+
}
|
|
52
|
+
const ovsxRateLimit = args.ovsxRateLimit;
|
|
53
|
+
this.ovsxRateLimit = typeof ovsxRateLimit === 'number' ? ovsxRateLimit : OVSX_RATE_LIMIT;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -1,54 +1,54 @@
|
|
|
1
|
-
// *****************************************************************************
|
|
2
|
-
// Copyright (C) 2020 TypeFox and others.
|
|
3
|
-
//
|
|
4
|
-
// This program and the accompanying materials are made available under the
|
|
5
|
-
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
-
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
-
//
|
|
8
|
-
// This Source Code may also be made available under the following Secondary
|
|
9
|
-
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
-
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
-
// with the GNU Classpath Exception which is available at
|
|
12
|
-
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
-
//
|
|
14
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
-
// *****************************************************************************
|
|
16
|
-
|
|
17
|
-
import URI from '@theia/core/lib/common/uri';
|
|
18
|
-
import { inject, injectable } from '@theia/core/shared/inversify';
|
|
19
|
-
import { OVSXRouterConfig } from '@theia/ovsx-client';
|
|
20
|
-
import { PluginVsCodeCliContribution } from '@theia/plugin-ext-vscode/lib/node/plugin-vscode-cli-contribution';
|
|
21
|
-
import { VSXEnvironment } from '../common/vsx-environment';
|
|
22
|
-
import { VsxCli } from './vsx-cli';
|
|
23
|
-
|
|
24
|
-
@injectable()
|
|
25
|
-
export class VSXEnvironmentImpl implements VSXEnvironment {
|
|
26
|
-
|
|
27
|
-
protected _registryUri = new URI(process.env['VSX_REGISTRY_URL']?.trim() || 'https://open-vsx.org');
|
|
28
|
-
|
|
29
|
-
@inject(PluginVsCodeCliContribution)
|
|
30
|
-
protected readonly pluginVscodeCli: PluginVsCodeCliContribution;
|
|
31
|
-
|
|
32
|
-
@inject(VsxCli)
|
|
33
|
-
protected vsxCli: VsxCli;
|
|
34
|
-
|
|
35
|
-
async getRateLimit(): Promise<number> {
|
|
36
|
-
return this.vsxCli.ovsxRateLimit;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
async getRegistryUri(): Promise<string> {
|
|
40
|
-
return this._registryUri.toString(true);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
async getRegistryApiUri(): Promise<string> {
|
|
44
|
-
return this._registryUri.resolve('api').toString(true);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
async getVscodeApiVersion(): Promise<string> {
|
|
48
|
-
return this.pluginVscodeCli.vsCodeApiVersionPromise;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
async getOvsxRouterConfig(): Promise<OVSXRouterConfig | undefined> {
|
|
52
|
-
return this.vsxCli.ovsxRouterConfig;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2020 TypeFox and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
import URI from '@theia/core/lib/common/uri';
|
|
18
|
+
import { inject, injectable } from '@theia/core/shared/inversify';
|
|
19
|
+
import { OVSXRouterConfig } from '@theia/ovsx-client';
|
|
20
|
+
import { PluginVsCodeCliContribution } from '@theia/plugin-ext-vscode/lib/node/plugin-vscode-cli-contribution';
|
|
21
|
+
import { VSXEnvironment } from '../common/vsx-environment';
|
|
22
|
+
import { VsxCli } from './vsx-cli';
|
|
23
|
+
|
|
24
|
+
@injectable()
|
|
25
|
+
export class VSXEnvironmentImpl implements VSXEnvironment {
|
|
26
|
+
|
|
27
|
+
protected _registryUri = new URI(process.env['VSX_REGISTRY_URL']?.trim() || 'https://open-vsx.org');
|
|
28
|
+
|
|
29
|
+
@inject(PluginVsCodeCliContribution)
|
|
30
|
+
protected readonly pluginVscodeCli: PluginVsCodeCliContribution;
|
|
31
|
+
|
|
32
|
+
@inject(VsxCli)
|
|
33
|
+
protected vsxCli: VsxCli;
|
|
34
|
+
|
|
35
|
+
async getRateLimit(): Promise<number> {
|
|
36
|
+
return this.vsxCli.ovsxRateLimit;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
async getRegistryUri(): Promise<string> {
|
|
40
|
+
return this._registryUri.toString(true);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
async getRegistryApiUri(): Promise<string> {
|
|
44
|
+
return this._registryUri.resolve('api').toString(true);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
async getVscodeApiVersion(): Promise<string> {
|
|
48
|
+
return this.pluginVscodeCli.vsCodeApiVersionPromise;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
async getOvsxRouterConfig(): Promise<OVSXRouterConfig | undefined> {
|
|
52
|
+
return this.vsxCli.ovsxRouterConfig;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -1,134 +1,134 @@
|
|
|
1
|
-
// *****************************************************************************
|
|
2
|
-
// Copyright (C) 2020 TypeFox and others.
|
|
3
|
-
//
|
|
4
|
-
// This program and the accompanying materials are made available under the
|
|
5
|
-
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
-
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
-
//
|
|
8
|
-
// This Source Code may also be made available under the following Secondary
|
|
9
|
-
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
-
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
-
// with the GNU Classpath Exception which is available at
|
|
12
|
-
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
-
//
|
|
14
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
-
// *****************************************************************************
|
|
16
|
-
|
|
17
|
-
import * as path from 'path';
|
|
18
|
-
import * as semver from 'semver';
|
|
19
|
-
import * as fs from '@theia/core/shared/fs-extra';
|
|
20
|
-
import { injectable, inject } from '@theia/core/shared/inversify';
|
|
21
|
-
import URI from '@theia/core/lib/common/uri';
|
|
22
|
-
import { PluginDeployerHandler, PluginDeployerResolver, PluginDeployerResolverContext, PluginDeployOptions, PluginIdentifiers } from '@theia/plugin-ext/lib/common/plugin-protocol';
|
|
23
|
-
import { FileUri } from '@theia/core/lib/node';
|
|
24
|
-
import { VSCodeExtensionUri } from '@theia/plugin-ext-vscode/lib/common/plugin-vscode-uri';
|
|
25
|
-
import { OVSXClientProvider } from '../common/ovsx-client-provider';
|
|
26
|
-
import { OVSXApiFilterProvider, VSXExtensionRaw, VSXTargetPlatform } from '@theia/ovsx-client';
|
|
27
|
-
import { RequestService } from '@theia/core/shared/@theia/request';
|
|
28
|
-
import { PluginVSCodeEnvironment } from '@theia/plugin-ext-vscode/lib/common/plugin-vscode-environment';
|
|
29
|
-
import { PluginUninstallationManager } from '@theia/plugin-ext/lib/main/node/plugin-uninstallation-manager';
|
|
30
|
-
|
|
31
|
-
@injectable()
|
|
32
|
-
export class VSXExtensionResolver implements PluginDeployerResolver {
|
|
33
|
-
|
|
34
|
-
@inject(OVSXClientProvider) protected clientProvider: OVSXClientProvider;
|
|
35
|
-
@inject(PluginDeployerHandler) protected pluginDeployerHandler: PluginDeployerHandler;
|
|
36
|
-
@inject(RequestService) protected requestService: RequestService;
|
|
37
|
-
@inject(PluginVSCodeEnvironment) protected readonly environment: PluginVSCodeEnvironment;
|
|
38
|
-
@inject(PluginUninstallationManager) protected readonly uninstallationManager: PluginUninstallationManager;
|
|
39
|
-
@inject(OVSXApiFilterProvider) protected vsxApiFilter: OVSXApiFilterProvider;
|
|
40
|
-
|
|
41
|
-
accept(pluginId: string): boolean {
|
|
42
|
-
return !!VSCodeExtensionUri.toId(new URI(pluginId));
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
static readonly TEMP_DIR_PREFIX = 'vscode-download';
|
|
46
|
-
static readonly TARGET_PLATFORM = `${process.platform}-${process.arch}` as VSXTargetPlatform;
|
|
47
|
-
|
|
48
|
-
async resolve(context: PluginDeployerResolverContext, options?: PluginDeployOptions): Promise<void> {
|
|
49
|
-
const id = VSCodeExtensionUri.toId(new URI(context.getOriginId()));
|
|
50
|
-
if (!id) {
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
let extension: VSXExtensionRaw | undefined;
|
|
54
|
-
const filter = await this.vsxApiFilter();
|
|
55
|
-
const version = options?.version || id.version;
|
|
56
|
-
if (version) {
|
|
57
|
-
console.log(`[${id.id}]: trying to resolve version ${version}...`);
|
|
58
|
-
extension = await filter.findLatestCompatibleExtension({
|
|
59
|
-
extensionId: id.id,
|
|
60
|
-
extensionVersion: version,
|
|
61
|
-
includeAllVersions: true,
|
|
62
|
-
targetPlatform: VSXExtensionResolver.TARGET_PLATFORM
|
|
63
|
-
});
|
|
64
|
-
} else {
|
|
65
|
-
console.log(`[${id.id}]: trying to resolve latest version...`);
|
|
66
|
-
extension = await filter.findLatestCompatibleExtension({
|
|
67
|
-
extensionId: id.id,
|
|
68
|
-
includeAllVersions: true,
|
|
69
|
-
targetPlatform: VSXExtensionResolver.TARGET_PLATFORM
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
if (!extension) {
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
if (extension.error) {
|
|
76
|
-
throw new Error(extension.error);
|
|
77
|
-
}
|
|
78
|
-
const resolvedId = id.id + '-' + extension.version;
|
|
79
|
-
const downloadUrl = extension.files.download;
|
|
80
|
-
console.log(`[${id.id}]: resolved to '${resolvedId}'`);
|
|
81
|
-
|
|
82
|
-
if (!options?.ignoreOtherVersions) {
|
|
83
|
-
const existingVersion = this.hasSameOrNewerVersion(id.id, extension);
|
|
84
|
-
if (existingVersion) {
|
|
85
|
-
console.log(`[${id.id}]: is already installed with the same or newer version '${existingVersion}'`);
|
|
86
|
-
return;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
const downloadDir = await this.getTempDir();
|
|
90
|
-
await fs.ensureDir(downloadDir);
|
|
91
|
-
const downloadedExtensionPath = path.resolve(downloadDir, path.basename(downloadUrl));
|
|
92
|
-
console.log(`[${resolvedId}]: trying to download from "${downloadUrl}"...`, 'to path', downloadDir);
|
|
93
|
-
if (!await this.download(downloadUrl, downloadedExtensionPath)) {
|
|
94
|
-
console.log(`[${resolvedId}]: not found`);
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
97
|
-
console.log(`[${resolvedId}]: downloaded to ${downloadedExtensionPath}"`);
|
|
98
|
-
context.addPlugin(resolvedId, downloadedExtensionPath);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
protected async getTempDir(): Promise<string> {
|
|
102
|
-
const tempDir = FileUri.fsPath(await this.environment.getTempDirUri(VSXExtensionResolver.TEMP_DIR_PREFIX));
|
|
103
|
-
if (!await fs.pathExists(tempDir)) {
|
|
104
|
-
await fs.mkdirs(tempDir);
|
|
105
|
-
}
|
|
106
|
-
return tempDir;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
protected hasSameOrNewerVersion(id: string, extension: VSXExtensionRaw): string | undefined {
|
|
110
|
-
const existingPlugins = this.pluginDeployerHandler.getDeployedPluginsById(id)
|
|
111
|
-
.filter(plugin => !this.uninstallationManager.isUninstalled(PluginIdentifiers.componentsToVersionedId(plugin.metadata.model)));
|
|
112
|
-
const sufficientVersion = existingPlugins.find(existingPlugin => {
|
|
113
|
-
const existingVersion = semver.clean(existingPlugin.metadata.model.version);
|
|
114
|
-
const desiredVersion = semver.clean(extension.version);
|
|
115
|
-
if (desiredVersion && existingVersion && semver.gte(existingVersion, desiredVersion)) {
|
|
116
|
-
return existingVersion;
|
|
117
|
-
}
|
|
118
|
-
});
|
|
119
|
-
return sufficientVersion?.metadata.model.version;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
protected async download(downloadUrl: string, downloadPath: string): Promise<boolean> {
|
|
123
|
-
if (await fs.pathExists(downloadPath)) { return true; }
|
|
124
|
-
const context = await this.requestService.request({ url: downloadUrl });
|
|
125
|
-
if (context.res.statusCode === 404) {
|
|
126
|
-
return false;
|
|
127
|
-
} else if (context.res.statusCode !== 200) {
|
|
128
|
-
throw new Error('Request returned status code: ' + context.res.statusCode);
|
|
129
|
-
} else {
|
|
130
|
-
await fs.writeFile(downloadPath, context.buffer);
|
|
131
|
-
return true;
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
}
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2020 TypeFox and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
import * as path from 'path';
|
|
18
|
+
import * as semver from 'semver';
|
|
19
|
+
import * as fs from '@theia/core/shared/fs-extra';
|
|
20
|
+
import { injectable, inject } from '@theia/core/shared/inversify';
|
|
21
|
+
import URI from '@theia/core/lib/common/uri';
|
|
22
|
+
import { PluginDeployerHandler, PluginDeployerResolver, PluginDeployerResolverContext, PluginDeployOptions, PluginIdentifiers } from '@theia/plugin-ext/lib/common/plugin-protocol';
|
|
23
|
+
import { FileUri } from '@theia/core/lib/node';
|
|
24
|
+
import { VSCodeExtensionUri } from '@theia/plugin-ext-vscode/lib/common/plugin-vscode-uri';
|
|
25
|
+
import { OVSXClientProvider } from '../common/ovsx-client-provider';
|
|
26
|
+
import { OVSXApiFilterProvider, VSXExtensionRaw, VSXTargetPlatform } from '@theia/ovsx-client';
|
|
27
|
+
import { RequestService } from '@theia/core/shared/@theia/request';
|
|
28
|
+
import { PluginVSCodeEnvironment } from '@theia/plugin-ext-vscode/lib/common/plugin-vscode-environment';
|
|
29
|
+
import { PluginUninstallationManager } from '@theia/plugin-ext/lib/main/node/plugin-uninstallation-manager';
|
|
30
|
+
|
|
31
|
+
@injectable()
|
|
32
|
+
export class VSXExtensionResolver implements PluginDeployerResolver {
|
|
33
|
+
|
|
34
|
+
@inject(OVSXClientProvider) protected clientProvider: OVSXClientProvider;
|
|
35
|
+
@inject(PluginDeployerHandler) protected pluginDeployerHandler: PluginDeployerHandler;
|
|
36
|
+
@inject(RequestService) protected requestService: RequestService;
|
|
37
|
+
@inject(PluginVSCodeEnvironment) protected readonly environment: PluginVSCodeEnvironment;
|
|
38
|
+
@inject(PluginUninstallationManager) protected readonly uninstallationManager: PluginUninstallationManager;
|
|
39
|
+
@inject(OVSXApiFilterProvider) protected vsxApiFilter: OVSXApiFilterProvider;
|
|
40
|
+
|
|
41
|
+
accept(pluginId: string): boolean {
|
|
42
|
+
return !!VSCodeExtensionUri.toId(new URI(pluginId));
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
static readonly TEMP_DIR_PREFIX = 'vscode-download';
|
|
46
|
+
static readonly TARGET_PLATFORM = `${process.platform}-${process.arch}` as VSXTargetPlatform;
|
|
47
|
+
|
|
48
|
+
async resolve(context: PluginDeployerResolverContext, options?: PluginDeployOptions): Promise<void> {
|
|
49
|
+
const id = VSCodeExtensionUri.toId(new URI(context.getOriginId()));
|
|
50
|
+
if (!id) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
let extension: VSXExtensionRaw | undefined;
|
|
54
|
+
const filter = await this.vsxApiFilter();
|
|
55
|
+
const version = options?.version || id.version;
|
|
56
|
+
if (version) {
|
|
57
|
+
console.log(`[${id.id}]: trying to resolve version ${version}...`);
|
|
58
|
+
extension = await filter.findLatestCompatibleExtension({
|
|
59
|
+
extensionId: id.id,
|
|
60
|
+
extensionVersion: version,
|
|
61
|
+
includeAllVersions: true,
|
|
62
|
+
targetPlatform: VSXExtensionResolver.TARGET_PLATFORM
|
|
63
|
+
});
|
|
64
|
+
} else {
|
|
65
|
+
console.log(`[${id.id}]: trying to resolve latest version...`);
|
|
66
|
+
extension = await filter.findLatestCompatibleExtension({
|
|
67
|
+
extensionId: id.id,
|
|
68
|
+
includeAllVersions: true,
|
|
69
|
+
targetPlatform: VSXExtensionResolver.TARGET_PLATFORM
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
if (!extension) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
if (extension.error) {
|
|
76
|
+
throw new Error(extension.error);
|
|
77
|
+
}
|
|
78
|
+
const resolvedId = id.id + '-' + extension.version;
|
|
79
|
+
const downloadUrl = extension.files.download;
|
|
80
|
+
console.log(`[${id.id}]: resolved to '${resolvedId}'`);
|
|
81
|
+
|
|
82
|
+
if (!options?.ignoreOtherVersions) {
|
|
83
|
+
const existingVersion = this.hasSameOrNewerVersion(id.id, extension);
|
|
84
|
+
if (existingVersion) {
|
|
85
|
+
console.log(`[${id.id}]: is already installed with the same or newer version '${existingVersion}'`);
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
const downloadDir = await this.getTempDir();
|
|
90
|
+
await fs.ensureDir(downloadDir);
|
|
91
|
+
const downloadedExtensionPath = path.resolve(downloadDir, path.basename(downloadUrl));
|
|
92
|
+
console.log(`[${resolvedId}]: trying to download from "${downloadUrl}"...`, 'to path', downloadDir);
|
|
93
|
+
if (!await this.download(downloadUrl, downloadedExtensionPath)) {
|
|
94
|
+
console.log(`[${resolvedId}]: not found`);
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
console.log(`[${resolvedId}]: downloaded to ${downloadedExtensionPath}"`);
|
|
98
|
+
context.addPlugin(resolvedId, downloadedExtensionPath);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
protected async getTempDir(): Promise<string> {
|
|
102
|
+
const tempDir = FileUri.fsPath(await this.environment.getTempDirUri(VSXExtensionResolver.TEMP_DIR_PREFIX));
|
|
103
|
+
if (!await fs.pathExists(tempDir)) {
|
|
104
|
+
await fs.mkdirs(tempDir);
|
|
105
|
+
}
|
|
106
|
+
return tempDir;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
protected hasSameOrNewerVersion(id: string, extension: VSXExtensionRaw): string | undefined {
|
|
110
|
+
const existingPlugins = this.pluginDeployerHandler.getDeployedPluginsById(id)
|
|
111
|
+
.filter(plugin => !this.uninstallationManager.isUninstalled(PluginIdentifiers.componentsToVersionedId(plugin.metadata.model)));
|
|
112
|
+
const sufficientVersion = existingPlugins.find(existingPlugin => {
|
|
113
|
+
const existingVersion = semver.clean(existingPlugin.metadata.model.version);
|
|
114
|
+
const desiredVersion = semver.clean(extension.version);
|
|
115
|
+
if (desiredVersion && existingVersion && semver.gte(existingVersion, desiredVersion)) {
|
|
116
|
+
return existingVersion;
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
return sufficientVersion?.metadata.model.version;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
protected async download(downloadUrl: string, downloadPath: string): Promise<boolean> {
|
|
123
|
+
if (await fs.pathExists(downloadPath)) { return true; }
|
|
124
|
+
const context = await this.requestService.request({ url: downloadUrl });
|
|
125
|
+
if (context.res.statusCode === 404) {
|
|
126
|
+
return false;
|
|
127
|
+
} else if (context.res.statusCode !== 200) {
|
|
128
|
+
throw new Error('Request returned status code: ' + context.res.statusCode);
|
|
129
|
+
} else {
|
|
130
|
+
await fs.writeFile(downloadPath, context.buffer);
|
|
131
|
+
return true;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|