@theia/vsx-registry 1.45.1 → 1.46.0-next.72

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.
Files changed (100) hide show
  1. package/README.md +45 -45
  2. package/lib/browser/recommended-extensions/preference-provider-overrides.d.ts +17 -17
  3. package/lib/browser/recommended-extensions/preference-provider-overrides.js +95 -95
  4. package/lib/browser/recommended-extensions/recommended-extensions-json-schema.d.ts +14 -14
  5. package/lib/browser/recommended-extensions/recommended-extensions-json-schema.js +94 -94
  6. package/lib/browser/recommended-extensions/recommended-extensions-preference-contribution.d.ts +11 -11
  7. package/lib/browser/recommended-extensions/recommended-extensions-preference-contribution.js +59 -59
  8. package/lib/browser/vsx-extension-commands.d.ts +14 -13
  9. package/lib/browser/vsx-extension-commands.d.ts.map +1 -1
  10. package/lib/browser/vsx-extension-commands.js +68 -63
  11. package/lib/browser/vsx-extension-commands.js.map +1 -1
  12. package/lib/browser/vsx-extension-editor-manager.d.ts +9 -9
  13. package/lib/browser/vsx-extension-editor-manager.js +49 -49
  14. package/lib/browser/vsx-extension-editor.d.ts +21 -21
  15. package/lib/browser/vsx-extension-editor.js +109 -109
  16. package/lib/browser/vsx-extension.d.ts +146 -143
  17. package/lib/browser/vsx-extension.d.ts.map +1 -1
  18. package/lib/browser/vsx-extension.js +616 -596
  19. package/lib/browser/vsx-extension.js.map +1 -1
  20. package/lib/browser/vsx-extensions-contribution.d.ts +70 -60
  21. package/lib/browser/vsx-extensions-contribution.d.ts.map +1 -1
  22. package/lib/browser/vsx-extensions-contribution.js +375 -344
  23. package/lib/browser/vsx-extensions-contribution.js.map +1 -1
  24. package/lib/browser/vsx-extensions-model.d.ts +75 -72
  25. package/lib/browser/vsx-extensions-model.d.ts.map +1 -1
  26. package/lib/browser/vsx-extensions-model.js +437 -391
  27. package/lib/browser/vsx-extensions-model.js.map +1 -1
  28. package/lib/browser/vsx-extensions-preferences.d.ts +12 -0
  29. package/lib/browser/vsx-extensions-preferences.d.ts.map +1 -0
  30. package/lib/browser/vsx-extensions-preferences.js +47 -0
  31. package/lib/browser/vsx-extensions-preferences.js.map +1 -0
  32. package/lib/browser/vsx-extensions-search-bar.d.ts +22 -14
  33. package/lib/browser/vsx-extensions-search-bar.d.ts.map +1 -1
  34. package/lib/browser/vsx-extensions-search-bar.js +106 -75
  35. package/lib/browser/vsx-extensions-search-bar.js.map +1 -1
  36. package/lib/browser/vsx-extensions-search-model.d.ts +21 -21
  37. package/lib/browser/vsx-extensions-search-model.js +70 -70
  38. package/lib/browser/vsx-extensions-source.d.ts +19 -19
  39. package/lib/browser/vsx-extensions-source.js +102 -102
  40. package/lib/browser/vsx-extensions-view-container.d.ts +49 -49
  41. package/lib/browser/vsx-extensions-view-container.js +179 -179
  42. package/lib/browser/vsx-extensions-widget.d.ts +35 -34
  43. package/lib/browser/vsx-extensions-widget.d.ts.map +1 -1
  44. package/lib/browser/vsx-extensions-widget.js +164 -156
  45. package/lib/browser/vsx-extensions-widget.js.map +1 -1
  46. package/lib/browser/vsx-language-quick-pick-service.d.ts +15 -15
  47. package/lib/browser/vsx-language-quick-pick-service.js +121 -121
  48. package/lib/browser/vsx-registry-frontend-module.d.ts +4 -4
  49. package/lib/browser/vsx-registry-frontend-module.d.ts.map +1 -1
  50. package/lib/browser/vsx-registry-frontend-module.js +99 -97
  51. package/lib/browser/vsx-registry-frontend-module.js.map +1 -1
  52. package/lib/common/index.d.ts +3 -3
  53. package/lib/common/index.js +25 -25
  54. package/lib/common/ovsx-client-provider.d.ts +13 -13
  55. package/lib/common/ovsx-client-provider.js +29 -29
  56. package/lib/common/vsx-environment.d.ts +9 -9
  57. package/lib/common/vsx-environment.js +20 -20
  58. package/lib/common/vsx-extension-uri.d.ts +3 -3
  59. package/lib/common/vsx-extension-uri.js +20 -20
  60. package/lib/common/vsx-registry-common-module.d.ts +3 -3
  61. package/lib/common/vsx-registry-common-module.js +57 -57
  62. package/lib/node/vsx-cli.d.ts +9 -9
  63. package/lib/node/vsx-cli.js +41 -41
  64. package/lib/node/vsx-environment-impl.d.ts +14 -14
  65. package/lib/node/vsx-environment-impl.js +61 -61
  66. package/lib/node/vsx-extension-resolver.d.ts +20 -20
  67. package/lib/node/vsx-extension-resolver.js +154 -154
  68. package/lib/node/vsx-registry-backend-module.d.ts +3 -3
  69. package/lib/node/vsx-registry-backend-module.js +35 -35
  70. package/lib/package.spec.js +25 -25
  71. package/package.json +12 -12
  72. package/src/browser/recommended-extensions/preference-provider-overrides.ts +99 -99
  73. package/src/browser/recommended-extensions/recommended-extensions-json-schema.ts +74 -74
  74. package/src/browser/recommended-extensions/recommended-extensions-preference-contribution.ts +68 -68
  75. package/src/browser/style/extensions.svg +4 -4
  76. package/src/browser/style/index.css +436 -373
  77. package/src/browser/vsx-extension-commands.ts +68 -63
  78. package/src/browser/vsx-extension-editor-manager.ts +42 -42
  79. package/src/browser/vsx-extension-editor.tsx +96 -96
  80. package/src/browser/vsx-extension.tsx +704 -675
  81. package/src/browser/vsx-extensions-contribution.ts +361 -327
  82. package/src/browser/vsx-extensions-model.ts +436 -389
  83. package/src/browser/vsx-extensions-preferences.ts +58 -0
  84. package/src/browser/vsx-extensions-search-bar.tsx +107 -69
  85. package/src/browser/vsx-extensions-search-model.ts +61 -61
  86. package/src/browser/vsx-extensions-source.ts +83 -83
  87. package/src/browser/vsx-extensions-view-container.ts +179 -179
  88. package/src/browser/vsx-extensions-widget.tsx +165 -156
  89. package/src/browser/vsx-language-quick-pick-service.ts +110 -110
  90. package/src/browser/vsx-registry-frontend-module.ts +108 -106
  91. package/src/common/index.ts +19 -19
  92. package/src/common/ovsx-client-provider.ts +35 -35
  93. package/src/common/vsx-environment.ts +27 -27
  94. package/src/common/vsx-extension-uri.ts +20 -20
  95. package/src/common/vsx-registry-common-module.ts +63 -63
  96. package/src/node/vsx-cli.ts +38 -38
  97. package/src/node/vsx-environment-impl.ts +50 -50
  98. package/src/node/vsx-extension-resolver.ts +125 -125
  99. package/src/node/vsx-registry-backend-module.ts +35 -35
  100. package/src/package.spec.ts +29 -29
@@ -1,38 +1,38 @@
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 { 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
-
28
- configure(conf: Argv<{}>): void {
29
- conf.option('ovsx-router-config', { description: 'JSON configuration file for the OVSX router client', type: 'string' });
30
- }
31
-
32
- async setArguments(args: Record<string, unknown>): Promise<void> {
33
- const { 'ovsx-router-config': ovsxRouterConfig } = args;
34
- if (typeof ovsxRouterConfig === 'string') {
35
- this.ovsxRouterConfig = JSON.parse(await fs.promises.readFile(ovsxRouterConfig, 'utf8'));
36
- }
37
- }
38
- }
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 { 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
+
28
+ configure(conf: Argv<{}>): void {
29
+ conf.option('ovsx-router-config', { description: 'JSON configuration file for the OVSX router client', type: 'string' });
30
+ }
31
+
32
+ async setArguments(args: Record<string, unknown>): Promise<void> {
33
+ const { 'ovsx-router-config': ovsxRouterConfig } = args;
34
+ if (typeof ovsxRouterConfig === 'string') {
35
+ this.ovsxRouterConfig = JSON.parse(await fs.promises.readFile(ovsxRouterConfig, 'utf8'));
36
+ }
37
+ }
38
+ }
@@ -1,50 +1,50 @@
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 getRegistryUri(): Promise<string> {
36
- return this._registryUri.toString(true);
37
- }
38
-
39
- async getRegistryApiUri(): Promise<string> {
40
- return this._registryUri.resolve('api').toString(true);
41
- }
42
-
43
- async getVscodeApiVersion(): Promise<string> {
44
- return this.pluginVscodeCli.vsCodeApiVersionPromise;
45
- }
46
-
47
- async getOvsxRouterConfig(): Promise<OVSXRouterConfig | undefined> {
48
- return this.vsxCli.ovsxRouterConfig;
49
- }
50
- }
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 getRegistryUri(): Promise<string> {
36
+ return this._registryUri.toString(true);
37
+ }
38
+
39
+ async getRegistryApiUri(): Promise<string> {
40
+ return this._registryUri.resolve('api').toString(true);
41
+ }
42
+
43
+ async getVscodeApiVersion(): Promise<string> {
44
+ return this.pluginVscodeCli.vsCodeApiVersionPromise;
45
+ }
46
+
47
+ async getOvsxRouterConfig(): Promise<OVSXRouterConfig | undefined> {
48
+ return this.vsxCli.ovsxRouterConfig;
49
+ }
50
+ }
@@ -1,125 +1,125 @@
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 { OVSXApiFilter, VSXExtensionRaw } 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(OVSXApiFilter) protected vsxApiFilter: OVSXApiFilter;
40
-
41
- accept(pluginId: string): boolean {
42
- return !!VSCodeExtensionUri.toId(new URI(pluginId));
43
- }
44
-
45
- static readonly TEMP_DIR_PREFIX = 'vscode-download';
46
-
47
- async resolve(context: PluginDeployerResolverContext, options?: PluginDeployOptions): Promise<void> {
48
- const id = VSCodeExtensionUri.toId(new URI(context.getOriginId()));
49
- if (!id) {
50
- return;
51
- }
52
- let extension: VSXExtensionRaw | undefined;
53
- const client = await this.clientProvider();
54
- if (options) {
55
- console.log(`[${id}]: trying to resolve version ${options.version}...`);
56
- const { extensions } = await client.query({ extensionId: id, extensionVersion: options.version, includeAllVersions: true });
57
- extension = extensions[0];
58
- } else {
59
- console.log(`[${id}]: trying to resolve latest version...`);
60
- const { extensions } = await client.query({ extensionId: id, includeAllVersions: true });
61
- extension = this.vsxApiFilter.getLatestCompatibleExtension(extensions);
62
- }
63
- if (!extension) {
64
- return;
65
- }
66
- if (extension.error) {
67
- throw new Error(extension.error);
68
- }
69
- const resolvedId = id + '-' + extension.version;
70
- const downloadUrl = extension.files.download;
71
- console.log(`[${id}]: resolved to '${resolvedId}'`);
72
-
73
- if (!options?.ignoreOtherVersions) {
74
- const existingVersion = this.hasSameOrNewerVersion(id, extension);
75
- if (existingVersion) {
76
- console.log(`[${id}]: is already installed with the same or newer version '${existingVersion}'`);
77
- return;
78
- }
79
- }
80
- const downloadDir = await this.getTempDir();
81
- await fs.ensureDir(downloadDir);
82
- const downloadedExtensionPath = path.resolve(downloadDir, path.basename(downloadUrl));
83
- console.log(`[${resolvedId}]: trying to download from "${downloadUrl}"...`, 'to path', downloadDir);
84
- if (!await this.download(downloadUrl, downloadedExtensionPath)) {
85
- console.log(`[${resolvedId}]: not found`);
86
- return;
87
- }
88
- console.log(`[${resolvedId}]: downloaded to ${downloadedExtensionPath}"`);
89
- context.addPlugin(resolvedId, downloadedExtensionPath);
90
- }
91
-
92
- protected async getTempDir(): Promise<string> {
93
- const tempDir = FileUri.fsPath(await this.environment.getTempDirUri(VSXExtensionResolver.TEMP_DIR_PREFIX));
94
- if (!await fs.pathExists(tempDir)) {
95
- await fs.mkdirs(tempDir);
96
- }
97
- return tempDir;
98
- }
99
-
100
- protected hasSameOrNewerVersion(id: string, extension: VSXExtensionRaw): string | undefined {
101
- const existingPlugins = this.pluginDeployerHandler.getDeployedPluginsById(id)
102
- .filter(plugin => !this.uninstallationManager.isUninstalled(PluginIdentifiers.componentsToVersionedId(plugin.metadata.model)));
103
- const sufficientVersion = existingPlugins.find(existingPlugin => {
104
- const existingVersion = semver.clean(existingPlugin.metadata.model.version);
105
- const desiredVersion = semver.clean(extension.version);
106
- if (desiredVersion && existingVersion && semver.gte(existingVersion, desiredVersion)) {
107
- return existingVersion;
108
- }
109
- });
110
- return sufficientVersion?.metadata.model.version;
111
- }
112
-
113
- protected async download(downloadUrl: string, downloadPath: string): Promise<boolean> {
114
- if (await fs.pathExists(downloadPath)) { return true; }
115
- const context = await this.requestService.request({ url: downloadUrl });
116
- if (context.res.statusCode === 404) {
117
- return false;
118
- } else if (context.res.statusCode !== 200) {
119
- throw new Error('Request returned status code: ' + context.res.statusCode);
120
- } else {
121
- await fs.writeFile(downloadPath, context.buffer);
122
- return true;
123
- }
124
- }
125
- }
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 { OVSXApiFilter, VSXExtensionRaw } 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(OVSXApiFilter) protected vsxApiFilter: OVSXApiFilter;
40
+
41
+ accept(pluginId: string): boolean {
42
+ return !!VSCodeExtensionUri.toId(new URI(pluginId));
43
+ }
44
+
45
+ static readonly TEMP_DIR_PREFIX = 'vscode-download';
46
+
47
+ async resolve(context: PluginDeployerResolverContext, options?: PluginDeployOptions): Promise<void> {
48
+ const id = VSCodeExtensionUri.toId(new URI(context.getOriginId()));
49
+ if (!id) {
50
+ return;
51
+ }
52
+ let extension: VSXExtensionRaw | undefined;
53
+ const client = await this.clientProvider();
54
+ if (options) {
55
+ console.log(`[${id}]: trying to resolve version ${options.version}...`);
56
+ const { extensions } = await client.query({ extensionId: id, extensionVersion: options.version, includeAllVersions: true });
57
+ extension = extensions[0];
58
+ } else {
59
+ console.log(`[${id}]: trying to resolve latest version...`);
60
+ const { extensions } = await client.query({ extensionId: id, includeAllVersions: true });
61
+ extension = this.vsxApiFilter.getLatestCompatibleExtension(extensions);
62
+ }
63
+ if (!extension) {
64
+ return;
65
+ }
66
+ if (extension.error) {
67
+ throw new Error(extension.error);
68
+ }
69
+ const resolvedId = id + '-' + extension.version;
70
+ const downloadUrl = extension.files.download;
71
+ console.log(`[${id}]: resolved to '${resolvedId}'`);
72
+
73
+ if (!options?.ignoreOtherVersions) {
74
+ const existingVersion = this.hasSameOrNewerVersion(id, extension);
75
+ if (existingVersion) {
76
+ console.log(`[${id}]: is already installed with the same or newer version '${existingVersion}'`);
77
+ return;
78
+ }
79
+ }
80
+ const downloadDir = await this.getTempDir();
81
+ await fs.ensureDir(downloadDir);
82
+ const downloadedExtensionPath = path.resolve(downloadDir, path.basename(downloadUrl));
83
+ console.log(`[${resolvedId}]: trying to download from "${downloadUrl}"...`, 'to path', downloadDir);
84
+ if (!await this.download(downloadUrl, downloadedExtensionPath)) {
85
+ console.log(`[${resolvedId}]: not found`);
86
+ return;
87
+ }
88
+ console.log(`[${resolvedId}]: downloaded to ${downloadedExtensionPath}"`);
89
+ context.addPlugin(resolvedId, downloadedExtensionPath);
90
+ }
91
+
92
+ protected async getTempDir(): Promise<string> {
93
+ const tempDir = FileUri.fsPath(await this.environment.getTempDirUri(VSXExtensionResolver.TEMP_DIR_PREFIX));
94
+ if (!await fs.pathExists(tempDir)) {
95
+ await fs.mkdirs(tempDir);
96
+ }
97
+ return tempDir;
98
+ }
99
+
100
+ protected hasSameOrNewerVersion(id: string, extension: VSXExtensionRaw): string | undefined {
101
+ const existingPlugins = this.pluginDeployerHandler.getDeployedPluginsById(id)
102
+ .filter(plugin => !this.uninstallationManager.isUninstalled(PluginIdentifiers.componentsToVersionedId(plugin.metadata.model)));
103
+ const sufficientVersion = existingPlugins.find(existingPlugin => {
104
+ const existingVersion = semver.clean(existingPlugin.metadata.model.version);
105
+ const desiredVersion = semver.clean(extension.version);
106
+ if (desiredVersion && existingVersion && semver.gte(existingVersion, desiredVersion)) {
107
+ return existingVersion;
108
+ }
109
+ });
110
+ return sufficientVersion?.metadata.model.version;
111
+ }
112
+
113
+ protected async download(downloadUrl: string, downloadPath: string): Promise<boolean> {
114
+ if (await fs.pathExists(downloadPath)) { return true; }
115
+ const context = await this.requestService.request({ url: downloadUrl });
116
+ if (context.res.statusCode === 404) {
117
+ return false;
118
+ } else if (context.res.statusCode !== 200) {
119
+ throw new Error('Request returned status code: ' + context.res.statusCode);
120
+ } else {
121
+ await fs.writeFile(downloadPath, context.buffer);
122
+ return true;
123
+ }
124
+ }
125
+ }
@@ -1,35 +1,35 @@
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 { ConnectionHandler, JsonRpcConnectionHandler } from '@theia/core';
18
- import { CliContribution } from '@theia/core/lib/node';
19
- import { ContainerModule } from '@theia/core/shared/inversify';
20
- import { PluginDeployerResolver } from '@theia/plugin-ext/lib/common/plugin-protocol';
21
- import { VSXEnvironment, VSX_ENVIRONMENT_PATH } from '../common/vsx-environment';
22
- import { VsxCli } from './vsx-cli';
23
- import { VSXEnvironmentImpl } from './vsx-environment-impl';
24
- import { VSXExtensionResolver } from './vsx-extension-resolver';
25
-
26
- export default new ContainerModule(bind => {
27
- bind(VSXEnvironment).to(VSXEnvironmentImpl).inSingletonScope();
28
- bind(VsxCli).toSelf().inSingletonScope();
29
- bind(CliContribution).toService(VsxCli);
30
- bind(ConnectionHandler)
31
- .toDynamicValue(ctx => new JsonRpcConnectionHandler(VSX_ENVIRONMENT_PATH, () => ctx.container.get(VSXEnvironment)))
32
- .inSingletonScope();
33
- bind(VSXExtensionResolver).toSelf().inSingletonScope();
34
- bind(PluginDeployerResolver).toService(VSXExtensionResolver);
35
- });
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 { ConnectionHandler, JsonRpcConnectionHandler } from '@theia/core';
18
+ import { CliContribution } from '@theia/core/lib/node';
19
+ import { ContainerModule } from '@theia/core/shared/inversify';
20
+ import { PluginDeployerResolver } from '@theia/plugin-ext/lib/common/plugin-protocol';
21
+ import { VSXEnvironment, VSX_ENVIRONMENT_PATH } from '../common/vsx-environment';
22
+ import { VsxCli } from './vsx-cli';
23
+ import { VSXEnvironmentImpl } from './vsx-environment-impl';
24
+ import { VSXExtensionResolver } from './vsx-extension-resolver';
25
+
26
+ export default new ContainerModule(bind => {
27
+ bind(VSXEnvironment).to(VSXEnvironmentImpl).inSingletonScope();
28
+ bind(VsxCli).toSelf().inSingletonScope();
29
+ bind(CliContribution).toService(VsxCli);
30
+ bind(ConnectionHandler)
31
+ .toDynamicValue(ctx => new JsonRpcConnectionHandler(VSX_ENVIRONMENT_PATH, () => ctx.container.get(VSXEnvironment)))
32
+ .inSingletonScope();
33
+ bind(VSXExtensionResolver).toSelf().inSingletonScope();
34
+ bind(PluginDeployerResolver).toService(VSXExtensionResolver);
35
+ });
@@ -1,29 +1,29 @@
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
- /* note: this bogus test file is required so that
18
- we are able to run mocha unit tests on this
19
- package, without having any actual unit tests in it.
20
- This way a coverage report will be generated,
21
- showing 0% coverage, instead of no report.
22
- This file can be removed once we have real unit
23
- tests in place. */
24
-
25
- describe('vsx-registry package', () => {
26
-
27
- it('support code coverage statistics', () => true);
28
-
29
- });
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
+ /* note: this bogus test file is required so that
18
+ we are able to run mocha unit tests on this
19
+ package, without having any actual unit tests in it.
20
+ This way a coverage report will be generated,
21
+ showing 0% coverage, instead of no report.
22
+ This file can be removed once we have real unit
23
+ tests in place. */
24
+
25
+ describe('vsx-registry package', () => {
26
+
27
+ it('support code coverage statistics', () => true);
28
+
29
+ });