@theia/remote 1.52.0 → 1.53.0-next.55

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 (37) hide show
  1. package/README.md +61 -61
  2. package/lib/electron-node/setup/remote-setup-script-service.js +11 -11
  3. package/package.json +5 -5
  4. package/src/electron-browser/port-forwarding/port-forwading-contribution.ts +33 -33
  5. package/src/electron-browser/port-forwarding/port-forwarding-service.ts +92 -92
  6. package/src/electron-browser/port-forwarding/port-forwarding-widget.tsx +140 -140
  7. package/src/electron-browser/remote-electron-file-dialog-service.ts +47 -47
  8. package/src/electron-browser/remote-frontend-contribution.ts +143 -143
  9. package/src/electron-browser/remote-frontend-module.ts +68 -68
  10. package/src/electron-browser/remote-preferences.ts +62 -62
  11. package/src/electron-browser/remote-registry-contribution.ts +73 -73
  12. package/src/electron-browser/remote-service.ts +31 -31
  13. package/src/electron-browser/remote-ssh-contribution.ts +102 -102
  14. package/src/electron-browser/style/port-forwarding-widget.css +44 -44
  15. package/src/electron-common/remote-port-forwarding-provider.ts +30 -30
  16. package/src/electron-common/remote-ssh-connection-provider.ts +29 -29
  17. package/src/electron-common/remote-status-service.ts +35 -35
  18. package/src/electron-node/backend-remote-service-impl.ts +45 -45
  19. package/src/electron-node/remote-backend-module.ts +87 -87
  20. package/src/electron-node/remote-connection-service.ts +56 -56
  21. package/src/electron-node/remote-connection-socket-provider.ts +34 -34
  22. package/src/electron-node/remote-port-forwarding-provider.ts +66 -66
  23. package/src/electron-node/remote-proxy-server-provider.ts +37 -37
  24. package/src/electron-node/remote-status-service.ts +41 -41
  25. package/src/electron-node/remote-types.ts +64 -64
  26. package/src/electron-node/setup/app-native-dependency-contribution.ts +48 -48
  27. package/src/electron-node/setup/main-copy-contribution.ts +28 -28
  28. package/src/electron-node/setup/remote-copy-contribution.ts +74 -74
  29. package/src/electron-node/setup/remote-copy-service.ts +116 -116
  30. package/src/electron-node/setup/remote-native-dependency-contribution.ts +63 -63
  31. package/src/electron-node/setup/remote-native-dependency-service.ts +111 -111
  32. package/src/electron-node/setup/remote-node-setup-service.ts +123 -123
  33. package/src/electron-node/setup/remote-setup-script-service.ts +146 -146
  34. package/src/electron-node/setup/remote-setup-service.ts +220 -220
  35. package/src/electron-node/ssh/remote-ssh-connection-provider.ts +358 -358
  36. package/src/electron-node/ssh/ssh-identity-file-collector.ts +137 -137
  37. package/src/package.spec.ts +29 -29
@@ -1,74 +1,74 @@
1
- // *****************************************************************************
2
- // Copyright (C) 2023 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 { ApplicationPackage } from '@theia/core/shared/@theia/application-package';
18
- import { inject, injectable } from '@theia/core/shared/inversify';
19
- import { RemoteCopyRegistry, RemoteFile, RemoteCopyOptions } from '@theia/core/lib/node/remote/remote-copy-contribution';
20
- import { glob as globCallback } from 'glob';
21
- import { promisify } from 'util';
22
- import * as path from 'path';
23
-
24
- const promiseGlob = promisify(globCallback);
25
-
26
- @injectable()
27
- export class RemoteCopyRegistryImpl implements RemoteCopyRegistry {
28
-
29
- @inject(ApplicationPackage)
30
- protected readonly applicationPackage: ApplicationPackage;
31
-
32
- protected readonly files: RemoteFile[] = [];
33
-
34
- getFiles(): RemoteFile[] {
35
- return this.files.slice();
36
- }
37
-
38
- async glob(pattern: string, target?: string): Promise<void> {
39
- return this.doGlob(pattern, this.applicationPackage.projectPath, target);
40
- }
41
-
42
- async doGlob(pattern: string, cwd: string, target?: string): Promise<void> {
43
- const projectPath = this.applicationPackage.projectPath;
44
- const globResult = await promiseGlob(pattern, { cwd, nodir: true });
45
- for (const file of globResult) {
46
- const targetFile = this.withTarget(file, target);
47
- this.files.push({
48
- path: path.relative(projectPath, path.resolve(cwd, file)),
49
- target: targetFile
50
- });
51
- }
52
- }
53
-
54
- file(file: string, target?: string, options?: RemoteCopyOptions): void {
55
- const targetFile = this.withTarget(file, target);
56
- this.files.push({
57
- path: file,
58
- target: targetFile,
59
- options
60
- });
61
- }
62
-
63
- async directory(dir: string, target?: string): Promise<void> {
64
- let absoluteDir = dir;
65
- if (!path.isAbsolute(absoluteDir)) {
66
- absoluteDir = path.join(this.applicationPackage.projectPath, dir);
67
- }
68
- return this.doGlob('**/*', absoluteDir, target ?? dir);
69
- }
70
-
71
- protected withTarget(file: string, target?: string): string {
72
- return target ? path.join(target, file) : file;
73
- }
74
- }
1
+ // *****************************************************************************
2
+ // Copyright (C) 2023 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 { ApplicationPackage } from '@theia/core/shared/@theia/application-package';
18
+ import { inject, injectable } from '@theia/core/shared/inversify';
19
+ import { RemoteCopyRegistry, RemoteFile, RemoteCopyOptions } from '@theia/core/lib/node/remote/remote-copy-contribution';
20
+ import { glob as globCallback } from 'glob';
21
+ import { promisify } from 'util';
22
+ import * as path from 'path';
23
+
24
+ const promiseGlob = promisify(globCallback);
25
+
26
+ @injectable()
27
+ export class RemoteCopyRegistryImpl implements RemoteCopyRegistry {
28
+
29
+ @inject(ApplicationPackage)
30
+ protected readonly applicationPackage: ApplicationPackage;
31
+
32
+ protected readonly files: RemoteFile[] = [];
33
+
34
+ getFiles(): RemoteFile[] {
35
+ return this.files.slice();
36
+ }
37
+
38
+ async glob(pattern: string, target?: string): Promise<void> {
39
+ return this.doGlob(pattern, this.applicationPackage.projectPath, target);
40
+ }
41
+
42
+ async doGlob(pattern: string, cwd: string, target?: string): Promise<void> {
43
+ const projectPath = this.applicationPackage.projectPath;
44
+ const globResult = await promiseGlob(pattern, { cwd, nodir: true });
45
+ for (const file of globResult) {
46
+ const targetFile = this.withTarget(file, target);
47
+ this.files.push({
48
+ path: path.relative(projectPath, path.resolve(cwd, file)),
49
+ target: targetFile
50
+ });
51
+ }
52
+ }
53
+
54
+ file(file: string, target?: string, options?: RemoteCopyOptions): void {
55
+ const targetFile = this.withTarget(file, target);
56
+ this.files.push({
57
+ path: file,
58
+ target: targetFile,
59
+ options
60
+ });
61
+ }
62
+
63
+ async directory(dir: string, target?: string): Promise<void> {
64
+ let absoluteDir = dir;
65
+ if (!path.isAbsolute(absoluteDir)) {
66
+ absoluteDir = path.join(this.applicationPackage.projectPath, dir);
67
+ }
68
+ return this.doGlob('**/*', absoluteDir, target ?? dir);
69
+ }
70
+
71
+ protected withTarget(file: string, target?: string): string {
72
+ return target ? path.join(target, file) : file;
73
+ }
74
+ }
@@ -1,116 +1,116 @@
1
- // *****************************************************************************
2
- // Copyright (C) 2023 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 archiver from 'archiver';
18
- import * as path from 'path';
19
- import * as fs from 'fs';
20
- import * as os from 'os';
21
- import { ApplicationPackage } from '@theia/core/shared/@theia/application-package';
22
- import { inject, injectable, named } from '@theia/core/shared/inversify';
23
- import { RemoteConnection } from '../remote-types';
24
- import { RemotePlatform } from '@theia/core/lib/node/remote/remote-cli-contribution';
25
- import { RemoteNativeDependencyService } from './remote-native-dependency-service';
26
- import { ContributionProvider } from '@theia/core';
27
- import { RemoteCopyRegistryImpl } from './remote-copy-contribution';
28
- import { RemoteCopyContribution, RemoteFile } from '@theia/core/lib/node/remote/remote-copy-contribution';
29
-
30
- @injectable()
31
- export class RemoteCopyService {
32
-
33
- @inject(ApplicationPackage)
34
- protected readonly applicationPackage: ApplicationPackage;
35
-
36
- @inject(RemoteCopyRegistryImpl)
37
- protected readonly copyRegistry: RemoteCopyRegistryImpl;
38
-
39
- @inject(RemoteNativeDependencyService)
40
- protected readonly nativeDependencyService: RemoteNativeDependencyService;
41
-
42
- @inject(ContributionProvider) @named(RemoteCopyContribution)
43
- protected readonly copyContributions: ContributionProvider<RemoteCopyContribution>;
44
-
45
- protected initialized = false;
46
-
47
- async copyToRemote(remote: RemoteConnection, remotePlatform: RemotePlatform, destination: string): Promise<void> {
48
- const zipName = path.basename(destination);
49
- const projectPath = this.applicationPackage.projectPath;
50
- const tempDir = await this.getTempDir();
51
- const zipPath = path.join(tempDir, zipName);
52
- const files = await this.getFiles(remotePlatform, tempDir);
53
- // We stream to a file here and then copy it because it is faster
54
- // Copying files via sftp is 4x times faster compared to readable streams
55
- const stream = fs.createWriteStream(zipPath);
56
- const archive = archiver('tar', {
57
- gzip: true
58
- });
59
- archive.pipe(stream);
60
- for (const file of files) {
61
- const filePath = path.isAbsolute(file.path)
62
- ? file.path
63
- : path.join(projectPath, file.path);
64
-
65
- archive.file(filePath, {
66
- name: file.target,
67
- mode: file.options?.mode
68
- });
69
- }
70
- await archive.finalize();
71
- await remote.copy(zipPath, destination);
72
- await fs.promises.rm(tempDir, {
73
- recursive: true,
74
- force: true
75
- });
76
- }
77
-
78
- protected async getFiles(remotePlatform: RemotePlatform, tempDir: string): Promise<RemoteFile[]> {
79
- const [localFiles, nativeDependencies] = await Promise.all([
80
- this.loadCopyContributions(),
81
- this.loadNativeDependencies(remotePlatform, tempDir)
82
- ]);
83
- return [...localFiles, ...nativeDependencies];
84
- }
85
-
86
- protected async loadCopyContributions(): Promise<RemoteFile[]> {
87
- if (this.initialized) {
88
- return this.copyRegistry.getFiles();
89
- }
90
- await Promise.all(this.copyContributions.getContributions()
91
- .map(copyContribution => copyContribution.copy(this.copyRegistry)));
92
- this.initialized = true;
93
- return this.copyRegistry.getFiles();
94
- }
95
-
96
- protected async loadNativeDependencies(remotePlatform: RemotePlatform, tempDir: string): Promise<RemoteFile[]> {
97
- const dependencyFiles = await this.nativeDependencyService.downloadDependencies(remotePlatform, tempDir);
98
- return dependencyFiles.map(file => ({
99
- path: file.path,
100
- target: file.target,
101
- options: {
102
- mode: file.mode
103
- }
104
- }));
105
- }
106
-
107
- protected async getTempDir(): Promise<string> {
108
- const dir = path.join(os.tmpdir(), 'theia-remote-');
109
- const tempDir = await fs.promises.mkdtemp(dir);
110
- return tempDir;
111
- }
112
-
113
- protected async getRemoteDownloadLocation(): Promise<string | undefined> {
114
- return undefined;
115
- }
116
- }
1
+ // *****************************************************************************
2
+ // Copyright (C) 2023 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 archiver from 'archiver';
18
+ import * as path from 'path';
19
+ import * as fs from 'fs';
20
+ import * as os from 'os';
21
+ import { ApplicationPackage } from '@theia/core/shared/@theia/application-package';
22
+ import { inject, injectable, named } from '@theia/core/shared/inversify';
23
+ import { RemoteConnection } from '../remote-types';
24
+ import { RemotePlatform } from '@theia/core/lib/node/remote/remote-cli-contribution';
25
+ import { RemoteNativeDependencyService } from './remote-native-dependency-service';
26
+ import { ContributionProvider } from '@theia/core';
27
+ import { RemoteCopyRegistryImpl } from './remote-copy-contribution';
28
+ import { RemoteCopyContribution, RemoteFile } from '@theia/core/lib/node/remote/remote-copy-contribution';
29
+
30
+ @injectable()
31
+ export class RemoteCopyService {
32
+
33
+ @inject(ApplicationPackage)
34
+ protected readonly applicationPackage: ApplicationPackage;
35
+
36
+ @inject(RemoteCopyRegistryImpl)
37
+ protected readonly copyRegistry: RemoteCopyRegistryImpl;
38
+
39
+ @inject(RemoteNativeDependencyService)
40
+ protected readonly nativeDependencyService: RemoteNativeDependencyService;
41
+
42
+ @inject(ContributionProvider) @named(RemoteCopyContribution)
43
+ protected readonly copyContributions: ContributionProvider<RemoteCopyContribution>;
44
+
45
+ protected initialized = false;
46
+
47
+ async copyToRemote(remote: RemoteConnection, remotePlatform: RemotePlatform, destination: string): Promise<void> {
48
+ const zipName = path.basename(destination);
49
+ const projectPath = this.applicationPackage.projectPath;
50
+ const tempDir = await this.getTempDir();
51
+ const zipPath = path.join(tempDir, zipName);
52
+ const files = await this.getFiles(remotePlatform, tempDir);
53
+ // We stream to a file here and then copy it because it is faster
54
+ // Copying files via sftp is 4x times faster compared to readable streams
55
+ const stream = fs.createWriteStream(zipPath);
56
+ const archive = archiver('tar', {
57
+ gzip: true
58
+ });
59
+ archive.pipe(stream);
60
+ for (const file of files) {
61
+ const filePath = path.isAbsolute(file.path)
62
+ ? file.path
63
+ : path.join(projectPath, file.path);
64
+
65
+ archive.file(filePath, {
66
+ name: file.target,
67
+ mode: file.options?.mode
68
+ });
69
+ }
70
+ await archive.finalize();
71
+ await remote.copy(zipPath, destination);
72
+ await fs.promises.rm(tempDir, {
73
+ recursive: true,
74
+ force: true
75
+ });
76
+ }
77
+
78
+ protected async getFiles(remotePlatform: RemotePlatform, tempDir: string): Promise<RemoteFile[]> {
79
+ const [localFiles, nativeDependencies] = await Promise.all([
80
+ this.loadCopyContributions(),
81
+ this.loadNativeDependencies(remotePlatform, tempDir)
82
+ ]);
83
+ return [...localFiles, ...nativeDependencies];
84
+ }
85
+
86
+ protected async loadCopyContributions(): Promise<RemoteFile[]> {
87
+ if (this.initialized) {
88
+ return this.copyRegistry.getFiles();
89
+ }
90
+ await Promise.all(this.copyContributions.getContributions()
91
+ .map(copyContribution => copyContribution.copy(this.copyRegistry)));
92
+ this.initialized = true;
93
+ return this.copyRegistry.getFiles();
94
+ }
95
+
96
+ protected async loadNativeDependencies(remotePlatform: RemotePlatform, tempDir: string): Promise<RemoteFile[]> {
97
+ const dependencyFiles = await this.nativeDependencyService.downloadDependencies(remotePlatform, tempDir);
98
+ return dependencyFiles.map(file => ({
99
+ path: file.path,
100
+ target: file.target,
101
+ options: {
102
+ mode: file.mode
103
+ }
104
+ }));
105
+ }
106
+
107
+ protected async getTempDir(): Promise<string> {
108
+ const dir = path.join(os.tmpdir(), 'theia-remote-');
109
+ const tempDir = await fs.promises.mkdtemp(dir);
110
+ return tempDir;
111
+ }
112
+
113
+ protected async getRemoteDownloadLocation(): Promise<string | undefined> {
114
+ return undefined;
115
+ }
116
+ }
@@ -1,63 +1,63 @@
1
- // *****************************************************************************
2
- // Copyright (C) 2023 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 { isObject } from '@theia/core';
18
- import { RequestOptions } from '@theia/core/shared/@theia/request';
19
- import { RemotePlatform } from '@theia/core/lib/node/remote/remote-cli-contribution';
20
-
21
- export interface FileDependencyResult {
22
- path: string;
23
- mode?: number;
24
- }
25
-
26
- export type DependencyDownload = FileDependencyDownload | DirectoryDependencyDownload;
27
-
28
- export interface FileDependencyDownload {
29
- file: FileDependencyResult
30
- buffer: Buffer
31
- }
32
-
33
- export namespace FileDependencyResult {
34
- export function is(item: unknown): item is FileDependencyDownload {
35
- return isObject(item) && 'buffer' in item && 'file' in item;
36
- }
37
- }
38
-
39
- export interface DirectoryDependencyDownload {
40
- archive: 'tar' | 'zip' | 'tgz'
41
- buffer: Buffer
42
- }
43
-
44
- export namespace DirectoryDependencyDownload {
45
- export function is(item: unknown): item is DirectoryDependencyDownload {
46
- return isObject(item) && 'buffer' in item && 'archive' in item;
47
- }
48
- }
49
-
50
- export interface DownloadOptions {
51
- remotePlatform: RemotePlatform
52
- theiaVersion: string;
53
- download: (requestInfo: string | RequestOptions) => Promise<Buffer>
54
- }
55
-
56
- export const RemoteNativeDependencyContribution = Symbol('RemoteNativeDependencyContribution');
57
-
58
- /**
59
- * contribution used for downloading prebuild native dependency when connecting to a remote machine with a different system
60
- */
61
- export interface RemoteNativeDependencyContribution {
62
- download(options: DownloadOptions): Promise<DependencyDownload>;
63
- }
1
+ // *****************************************************************************
2
+ // Copyright (C) 2023 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 { isObject } from '@theia/core';
18
+ import { RequestOptions } from '@theia/core/shared/@theia/request';
19
+ import { RemotePlatform } from '@theia/core/lib/node/remote/remote-cli-contribution';
20
+
21
+ export interface FileDependencyResult {
22
+ path: string;
23
+ mode?: number;
24
+ }
25
+
26
+ export type DependencyDownload = FileDependencyDownload | DirectoryDependencyDownload;
27
+
28
+ export interface FileDependencyDownload {
29
+ file: FileDependencyResult
30
+ buffer: Buffer
31
+ }
32
+
33
+ export namespace FileDependencyResult {
34
+ export function is(item: unknown): item is FileDependencyDownload {
35
+ return isObject(item) && 'buffer' in item && 'file' in item;
36
+ }
37
+ }
38
+
39
+ export interface DirectoryDependencyDownload {
40
+ archive: 'tar' | 'zip' | 'tgz'
41
+ buffer: Buffer
42
+ }
43
+
44
+ export namespace DirectoryDependencyDownload {
45
+ export function is(item: unknown): item is DirectoryDependencyDownload {
46
+ return isObject(item) && 'buffer' in item && 'archive' in item;
47
+ }
48
+ }
49
+
50
+ export interface DownloadOptions {
51
+ remotePlatform: RemotePlatform
52
+ theiaVersion: string;
53
+ download: (requestInfo: string | RequestOptions) => Promise<Buffer>
54
+ }
55
+
56
+ export const RemoteNativeDependencyContribution = Symbol('RemoteNativeDependencyContribution');
57
+
58
+ /**
59
+ * contribution used for downloading prebuild native dependency when connecting to a remote machine with a different system
60
+ */
61
+ export interface RemoteNativeDependencyContribution {
62
+ download(options: DownloadOptions): Promise<DependencyDownload>;
63
+ }