Skip to content

Commit 571a75a

Browse files
committed
Support plugin copying for remote feature
1 parent 84fdd75 commit 571a75a

26 files changed

+268
-63
lines changed

packages/core/src/electron-node/hosting/electron-ws-origin-validator.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
import * as http from 'http';
1818
import { inject, injectable } from 'inversify';
19-
import { BackendRemoteService } from '../../node/backend-remote-service';
19+
import { BackendRemoteService } from '../../node/remote/backend-remote-service';
2020
import { WsRequestValidatorContribution } from '../../node/ws-request-validators';
2121

2222
@injectable()

packages/core/src/node/backend-application-module.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ import { bindNodeStopwatch, bindBackendStopwatchServer } from './performance';
4141
import { OSBackendProviderImpl } from './os-backend-provider';
4242
import { BackendRequestFacade } from './request/backend-request-facade';
4343
import { FileSystemLocking, FileSystemLockingImpl } from './filesystem-locking';
44-
import { BackendRemoteService } from './backend-remote-service';
44+
import { BackendRemoteService } from './remote/backend-remote-service';
45+
import { RemoteCliContribution } from './remote/remote-cli-contribution';
4546

4647
decorate(injectable(), ApplicationPackage);
4748

@@ -127,6 +128,7 @@ export const backendApplicationModule = new ContainerModule(bind => {
127128
bind(ProxyCliContribution).toSelf().inSingletonScope();
128129
bind(CliContribution).toService(ProxyCliContribution);
129130

131+
bindContributionProvider(bind, RemoteCliContribution);
130132
bind(BackendRemoteService).toSelf().inSingletonScope();
131133
bind(BackendRequestFacade).toSelf().inSingletonScope();
132134
bind(ConnectionHandler).toDynamicValue(
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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 type { OS } from '../../common/os';
18+
import type { MaybePromise } from '../../common/types';
19+
20+
export interface RemotePlatform {
21+
os: OS.Type
22+
arch: string
23+
}
24+
25+
export interface RemoteCliContext {
26+
platform: RemotePlatform;
27+
directory: string;
28+
}
29+
30+
export const RemoteCliContribution = Symbol('RemoteCliContribution');
31+
32+
export interface RemoteCliContribution {
33+
enhanceArgs(context: RemoteCliContext): MaybePromise<string[]>;
34+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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 { MaybePromise } from '../../common/types';
18+
19+
export const RemoteCopyContribution = Symbol('RemoteCopyContribution');
20+
21+
export interface RemoteCopyContribution {
22+
copy(registry: RemoteCopyRegistry): MaybePromise<void>
23+
}
24+
25+
export interface RemoteCopyOptions {
26+
/**
27+
* The mode that the file should be set to once copied to the remote.
28+
*
29+
* Only relevant for POSIX-like systems
30+
*/
31+
mode?: number;
32+
}
33+
34+
export interface RemoteFile {
35+
path: string
36+
target: string
37+
options?: RemoteCopyOptions;
38+
}
39+
40+
export interface RemoteCopyRegistry {
41+
getFiles(): RemoteFile[];
42+
glob(pattern: string, target?: string): Promise<void>;
43+
file(file: string, target?: string, options?: RemoteCopyOptions): void;
44+
directory(dir: string, target?: string): Promise<void>;
45+
}

packages/plugin-ext/src/common/plugin-protocol.ts

+1
Original file line numberDiff line numberDiff line change
@@ -982,6 +982,7 @@ export interface PluginDeployerHandler {
982982
deployFrontendPlugins(frontendPlugins: PluginDeployerEntry[]): Promise<number | undefined>;
983983
deployBackendPlugins(backendPlugins: PluginDeployerEntry[]): Promise<number | undefined>;
984984

985+
getDeployedPlugins(): Promise<DeployedPlugin[]>;
985986
getDeployedPluginsById(pluginId: string): DeployedPlugin[];
986987

987988
getDeployedPlugin(pluginId: PluginIdentifiers.VersionedId): DeployedPlugin | undefined;

packages/plugin-ext/src/hosted/node/hosted-plugin-deployer-handler.ts

+6
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,12 @@ export class HostedPluginDeployerHandler implements PluginDeployerHandler {
8383
return Array.from(this.deployedBackendPlugins.values());
8484
}
8585

86+
async getDeployedPlugins(): Promise<DeployedPlugin[]> {
87+
await this.frontendPluginsMetadataDeferred.promise;
88+
await this.backendPluginsMetadataDeferred.promise;
89+
return [...this.deployedFrontendPlugins.values(), ...this.deployedBackendPlugins.values()];
90+
}
91+
8692
getDeployedPluginsById(pluginId: string): DeployedPlugin[] {
8793
const matches: DeployedPlugin[] = [];
8894
const handle = (plugins: Iterable<DeployedPlugin>): void => {

packages/plugin-ext/src/main/node/plugin-ext-backend-module.ts

+9
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ import { PluginUninstallationManager } from './plugin-uninstallation-manager';
4242
import { LocalizationServerImpl } from '@theia/core/lib/node/i18n/localization-server';
4343
import { PluginLocalizationServer } from './plugin-localization-server';
4444
import { PluginMgmtCliContribution } from './plugin-mgmt-cli-contribution';
45+
import { PluginRemoteCliContribution } from './plugin-remote-cli-contribution';
46+
import { RemoteCliContribution } from '@theia/core/lib/node/remote/remote-cli-contribution';
47+
import { PluginRemoteCopyContribution } from './plugin-remote-copy-contribution';
48+
import { RemoteCopyContribution } from '@theia/core/lib/node/remote/remote-copy-contribution';
4549

4650
export function bindMainBackend(bind: interfaces.Bind, unbind: interfaces.Unbind, isBound: interfaces.IsBound, rebind: interfaces.Rebind): void {
4751
bind(PluginApiContribution).toSelf().inSingletonScope();
@@ -89,6 +93,11 @@ export function bindMainBackend(bind: interfaces.Bind, unbind: interfaces.Unbind
8993
bind(PluginMgmtCliContribution).toSelf().inSingletonScope();
9094
bind(CliContribution).toService(PluginMgmtCliContribution);
9195

96+
bind(PluginRemoteCliContribution).toSelf().inSingletonScope();
97+
bind(RemoteCliContribution).toService(PluginRemoteCliContribution);
98+
bind(PluginRemoteCopyContribution).toSelf().inSingletonScope();
99+
bind(RemoteCopyContribution).toService(PluginRemoteCopyContribution);
100+
92101
bind(WebviewBackendSecurityWarnings).toSelf().inSingletonScope();
93102
bind(BackendApplicationContribution).toService(WebviewBackendSecurityWarnings);
94103

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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 { MaybePromise } from '@theia/core';
18+
import { RemoteCliContext, RemoteCliContribution } from '@theia/core/lib/node/remote/remote-cli-contribution';
19+
import { inject, injectable } from '@theia/core/shared/inversify';
20+
import { PluginCliContribution } from './plugin-cli-contribution';
21+
22+
@injectable()
23+
export class PluginRemoteCliContribution implements RemoteCliContribution {
24+
25+
@inject(PluginCliContribution)
26+
protected readonly pluginCliContribution: PluginCliContribution;
27+
28+
enhanceArgs(context: RemoteCliContext): MaybePromise<string[]> {
29+
const pluginsFolder = this.pluginCliContribution.localDir();
30+
if (!pluginsFolder) {
31+
return [];
32+
} else {
33+
return ['--plugins=local-dir:./plugins'];
34+
}
35+
}
36+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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 { RemoteCopyContribution, RemoteCopyRegistry } from '@theia/core/lib/node/remote/remote-copy-contribution';
18+
import { inject, injectable } from '@theia/core/shared/inversify';
19+
import { PluginCliContribution } from './plugin-cli-contribution';
20+
import { FileUri } from '@theia/core/lib/common/file-uri';
21+
22+
@injectable()
23+
export class PluginRemoteCopyContribution implements RemoteCopyContribution {
24+
25+
@inject(PluginCliContribution)
26+
protected readonly pluginCliContribution: PluginCliContribution;
27+
28+
async copy(registry: RemoteCopyRegistry): Promise<void> {
29+
const localDir = this.pluginCliContribution.localDir();
30+
if (localDir) {
31+
const fsPath = FileUri.fsPath(localDir);
32+
await registry.directory(fsPath, 'plugins');
33+
}
34+
35+
}
36+
}

packages/plugin-ext/src/main/node/plugin-service.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import { environment } from '@theia/core/shared/@theia/application-package/lib/e
2626
import { WsRequestValidatorContribution } from '@theia/core/lib/node/ws-request-validators';
2727
import { MaybePromise } from '@theia/core/lib/common';
2828
import { ApplicationPackage } from '@theia/core/shared/@theia/application-package';
29-
import { BackendRemoteService } from '@theia/core/lib/node/backend-remote-service';
29+
import { BackendRemoteService } from '@theia/core/lib/node/remote/backend-remote-service';
3030

3131
@injectable()
3232
export class PluginApiContribution implements BackendApplicationContribution, WsRequestValidatorContribution {

packages/remote/src/electron-node/backend-remote-service-impl.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import { CliContribution } from '@theia/core/lib/node';
1818
import { injectable } from '@theia/core/shared/inversify';
1919
import { Arguments, Argv } from '@theia/core/shared/yargs';
20-
import { BackendRemoteService } from '@theia/core/lib/node/backend-remote-service';
20+
import { BackendRemoteService } from '@theia/core/lib/node/remote/backend-remote-service';
2121

2222
export const REMOTE_START = 'remote';
2323

packages/remote/src/electron-node/remote-backend-module.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,14 @@ import { RemoteCopyService } from './setup/remote-copy-service';
2727
import { RemoteSetupService } from './setup/remote-setup-service';
2828
import { RemoteNativeDependencyService } from './setup/remote-native-dependency-service';
2929
import { BackendRemoteServiceImpl } from './backend-remote-service-impl';
30-
import { BackendRemoteService } from '@theia/core/lib/node/backend-remote-service';
30+
import { BackendRemoteService } from '@theia/core/lib/node/remote/backend-remote-service';
3131
import { RemoteNodeSetupService } from './setup/remote-node-setup-service';
3232
import { RemotePosixScriptStrategy, RemoteSetupScriptService, RemoteWindowsScriptStrategy } from './setup/remote-setup-script-service';
3333
import { RemoteStatusService, RemoteStatusServicePath } from '../electron-common/remote-status-service';
3434
import { RemoteStatusServiceImpl } from './remote-status-service';
3535
import { ConnectionHandler, RpcConnectionHandler, bindContributionProvider } from '@theia/core';
36-
import { RemoteCopyContribution, RemoteCopyRegistry } from './setup/remote-copy-contribution';
36+
import { RemoteCopyRegistryImpl } from './setup/remote-copy-contribution';
37+
import { RemoteCopyContribution } from '@theia/core/lib/node/remote/remote-copy-contribution';
3738
import { MainCopyContribution } from './setup/main-copy-contribution';
3839
import { RemoteNativeDependencyContribution } from './setup/remote-native-dependency-contribution';
3940
import { AppNativeDependencyContribution } from './setup/app-native-dependency-contribution';
@@ -68,7 +69,7 @@ export default new ContainerModule((bind, _unbind, _isBound, rebind) => {
6869
bind(RemotePosixScriptStrategy).toSelf().inSingletonScope();
6970
bind(RemoteSetupScriptService).toSelf().inSingletonScope();
7071
bind(RemoteNativeDependencyService).toSelf().inSingletonScope();
71-
bind(RemoteCopyRegistry).toSelf().inSingletonScope();
72+
bind(RemoteCopyRegistryImpl).toSelf().inSingletonScope();
7273
bindContributionProvider(bind, RemoteCopyContribution);
7374
bindContributionProvider(bind, RemoteNativeDependencyContribution);
7475
bind(MainCopyContribution).toSelf().inSingletonScope();

packages/remote/src/electron-node/remote-connection-service.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,18 @@ import { inject, injectable } from '@theia/core/shared/inversify';
1818
import { RemoteConnection } from './remote-types';
1919
import { Disposable } from '@theia/core';
2020
import { RemoteCopyService } from './setup/remote-copy-service';
21-
import { RemoteNativeDependencyService } from './setup/remote-native-dependency-service';
2221
import { BackendApplicationContribution } from '@theia/core/lib/node';
22+
import { RemoteSetupService } from './setup/remote-setup-service';
2323

2424
@injectable()
2525
export class RemoteConnectionService implements BackendApplicationContribution {
2626

2727
@inject(RemoteCopyService)
2828
protected readonly copyService: RemoteCopyService;
2929

30-
@inject(RemoteNativeDependencyService)
31-
protected readonly nativeDependencyService: RemoteNativeDependencyService;
30+
// Workaround for the fact that connection scoped services cannot directly inject these services.
31+
@inject(RemoteSetupService)
32+
protected readonly remoteSetupService: RemoteSetupService;
3233

3334
protected readonly connections = new Map<string, RemoteConnection>();
3435

packages/remote/src/electron-node/remote-types.ts

+1-6
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,9 @@
1414
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
1515
// *****************************************************************************
1616

17-
import { Disposable, Event, OS } from '@theia/core';
17+
import { Disposable, Event } from '@theia/core';
1818
import * as net from 'net';
1919

20-
export interface RemotePlatform {
21-
os: OS.Type
22-
arch: string
23-
}
24-
2520
export type RemoteStatusReport = (message: string) => void;
2621

2722
export interface ExpressLayer {

packages/remote/src/electron-node/setup/app-native-dependency-contribution.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
import { injectable } from '@theia/core/shared/inversify';
1818
import { RemoteNativeDependencyContribution, DownloadOptions, DependencyDownload } from './remote-native-dependency-contribution';
19-
import { RemotePlatform } from '../remote-types';
19+
import { RemotePlatform } from '@theia/core/lib/node/remote/remote-cli-contribution';
2020
import { OS } from '@theia/core';
2121

2222
@injectable()

packages/remote/src/electron-node/setup/main-copy-contribution.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
// *****************************************************************************
1616

1717
import { injectable } from '@theia/core/shared/inversify';
18-
import { RemoteCopyContribution, RemoteCopyRegistry } from './remote-copy-contribution';
18+
import { RemoteCopyContribution, RemoteCopyRegistry } from '@theia/core/lib/node/remote/remote-copy-contribution';
1919

2020
@injectable()
2121
export class MainCopyContribution implements RemoteCopyContribution {

0 commit comments

Comments
 (0)