@theia/remote 1.45.0 → 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.
- package/README.md +61 -61
- package/lib/electron-browser/remote-electron-file-dialog-service.d.ts +13 -13
- package/lib/electron-browser/remote-electron-file-dialog-service.js +57 -57
- package/lib/electron-browser/remote-frontend-contribution.d.ts +25 -25
- package/lib/electron-browser/remote-frontend-contribution.js +164 -164
- package/lib/electron-browser/remote-frontend-module.d.ts +3 -3
- package/lib/electron-browser/remote-frontend-module.js +42 -42
- package/lib/electron-browser/remote-preferences.d.ts +10 -10
- package/lib/electron-browser/remote-preferences.js +48 -48
- package/lib/electron-browser/remote-registry-contribution.d.ts +18 -18
- package/lib/electron-browser/remote-registry-contribution.js +74 -74
- package/lib/electron-browser/remote-service.d.ts +5 -5
- package/lib/electron-browser/remote-service.js +37 -37
- package/lib/electron-browser/remote-ssh-contribution.d.ts +17 -17
- package/lib/electron-browser/remote-ssh-contribution.js +117 -117
- package/lib/electron-common/remote-ssh-connection-provider.d.ts +10 -10
- package/lib/electron-common/remote-ssh-connection-provider.js +20 -20
- package/lib/electron-common/remote-status-service.d.ts +14 -14
- package/lib/electron-common/remote-status-service.js +20 -20
- package/lib/electron-node/backend-remote-service-impl.d.ts +11 -11
- package/lib/electron-node/backend-remote-service-impl.js +50 -50
- package/lib/electron-node/remote-backend-module.d.ts +4 -4
- package/lib/electron-node/remote-backend-module.js +74 -74
- package/lib/electron-node/remote-connection-service.d.ts +14 -14
- package/lib/electron-node/remote-connection-service.js +65 -65
- package/lib/electron-node/remote-connection-socket-provider.d.ts +8 -8
- package/lib/electron-node/remote-connection-socket-provider.js +37 -37
- package/lib/electron-node/remote-proxy-server-provider.d.ts +5 -5
- package/lib/electron-node/remote-proxy-server-provider.js +43 -43
- package/lib/electron-node/remote-status-service.d.ts +6 -6
- package/lib/electron-node/remote-status-service.js +54 -54
- package/lib/electron-node/remote-types.d.ts +34 -34
- package/lib/electron-node/remote-types.js +17 -17
- package/lib/electron-node/setup/app-native-dependency-contribution.d.ts +7 -7
- package/lib/electron-node/setup/app-native-dependency-contribution.js +57 -57
- package/lib/electron-node/setup/main-copy-contribution.d.ts +4 -4
- package/lib/electron-node/setup/main-copy-contribution.js +37 -37
- package/lib/electron-node/setup/remote-copy-contribution.d.ts +28 -28
- package/lib/electron-node/setup/remote-copy-contribution.js +78 -78
- package/lib/electron-node/setup/remote-copy-service.d.ts +18 -18
- package/lib/electron-node/setup/remote-copy-service.js +126 -126
- package/lib/electron-node/setup/remote-native-dependency-contribution.d.ts +34 -34
- package/lib/electron-node/setup/remote-native-dependency-contribution.js +34 -34
- package/lib/electron-node/setup/remote-native-dependency-service.d.ts +23 -23
- package/lib/electron-node/setup/remote-native-dependency-service.js +118 -118
- package/lib/electron-node/setup/remote-node-setup-service.d.ts +22 -22
- package/lib/electron-node/setup/remote-node-setup-service.js +132 -132
- package/lib/electron-node/setup/remote-setup-script-service.d.ts +40 -40
- package/lib/electron-node/setup/remote-setup-script-service.js +132 -132
- package/lib/electron-node/setup/remote-setup-service.d.ts +28 -28
- package/lib/electron-node/setup/remote-setup-service.js +198 -198
- package/lib/electron-node/ssh/remote-ssh-connection-provider.d.ts +55 -55
- package/lib/electron-node/ssh/remote-ssh-connection-provider.d.ts.map +1 -1
- package/lib/electron-node/ssh/remote-ssh-connection-provider.js +344 -342
- package/lib/electron-node/ssh/remote-ssh-connection-provider.js.map +1 -1
- package/lib/electron-node/ssh/ssh-identity-file-collector.d.ts +12 -12
- package/lib/electron-node/ssh/ssh-identity-file-collector.js +131 -131
- package/lib/package.spec.js +25 -25
- package/package.json +6 -7
- package/src/electron-browser/remote-electron-file-dialog-service.ts +47 -47
- package/src/electron-browser/remote-frontend-contribution.ts +145 -145
- package/src/electron-browser/remote-frontend-module.ts +49 -49
- package/src/electron-browser/remote-preferences.ts +62 -62
- package/src/electron-browser/remote-registry-contribution.ts +70 -70
- package/src/electron-browser/remote-service.ts +31 -31
- package/src/electron-browser/remote-ssh-contribution.ts +102 -102
- package/src/electron-common/remote-ssh-connection-provider.ts +29 -29
- package/src/electron-common/remote-status-service.ts +35 -35
- package/src/electron-node/backend-remote-service-impl.ts +45 -45
- package/src/electron-node/remote-backend-module.ts +80 -80
- package/src/electron-node/remote-connection-service.ts +55 -55
- package/src/electron-node/remote-connection-socket-provider.ts +34 -34
- package/src/electron-node/remote-proxy-server-provider.ts +37 -37
- package/src/electron-node/remote-status-service.ts +41 -41
- package/src/electron-node/remote-types.ts +56 -56
- package/src/electron-node/setup/app-native-dependency-contribution.ts +48 -48
- package/src/electron-node/setup/main-copy-contribution.ts +28 -28
- package/src/electron-node/setup/remote-copy-contribution.ts +90 -90
- package/src/electron-node/setup/remote-copy-service.ts +114 -114
- package/src/electron-node/setup/remote-native-dependency-contribution.ts +63 -63
- package/src/electron-node/setup/remote-native-dependency-service.ts +111 -111
- package/src/electron-node/setup/remote-node-setup-service.ts +123 -123
- package/src/electron-node/setup/remote-setup-script-service.ts +146 -146
- package/src/electron-node/setup/remote-setup-service.ts +197 -197
- package/src/electron-node/ssh/remote-ssh-connection-provider.ts +358 -356
- package/src/electron-node/ssh/ssh-identity-file-collector.ts +137 -137
- package/src/package.spec.ts +29 -29
|
@@ -1,48 +1,48 @@
|
|
|
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 { injectable } from '@theia/core/shared/inversify';
|
|
18
|
-
import { RemoteNativeDependencyContribution, DownloadOptions, DependencyDownload } from './remote-native-dependency-contribution';
|
|
19
|
-
import { RemotePlatform } from '../remote-types';
|
|
20
|
-
import { OS } from '@theia/core';
|
|
21
|
-
|
|
22
|
-
@injectable()
|
|
23
|
-
export class AppNativeDependencyContribution implements RemoteNativeDependencyContribution {
|
|
24
|
-
|
|
25
|
-
appDownloadUrlBase = 'https://github.com/eclipse-theia/theia/releases/download';
|
|
26
|
-
|
|
27
|
-
protected getDefaultURLForFile(remotePlatform: RemotePlatform, theiaVersion: string): string {
|
|
28
|
-
if (remotePlatform.arch !== 'x64') {
|
|
29
|
-
throw new Error(`Unsupported remote architecture '${remotePlatform.arch}'. Remote support is only available for x64 architectures.`);
|
|
30
|
-
}
|
|
31
|
-
let platform: string;
|
|
32
|
-
if (remotePlatform.os === OS.Type.Windows) {
|
|
33
|
-
platform = 'win32';
|
|
34
|
-
} else if (remotePlatform.os === OS.Type.OSX) {
|
|
35
|
-
platform = 'darwin';
|
|
36
|
-
} else {
|
|
37
|
-
platform = 'linux';
|
|
38
|
-
}
|
|
39
|
-
return `${this.appDownloadUrlBase}/v${theiaVersion}/native-dependencies-${platform}-${remotePlatform.arch}.zip`;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
async download(options: DownloadOptions): Promise<DependencyDownload> {
|
|
43
|
-
return {
|
|
44
|
-
buffer: await options.download(this.getDefaultURLForFile(options.remotePlatform, options.theiaVersion)),
|
|
45
|
-
archive: 'zip'
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
}
|
|
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 { injectable } from '@theia/core/shared/inversify';
|
|
18
|
+
import { RemoteNativeDependencyContribution, DownloadOptions, DependencyDownload } from './remote-native-dependency-contribution';
|
|
19
|
+
import { RemotePlatform } from '../remote-types';
|
|
20
|
+
import { OS } from '@theia/core';
|
|
21
|
+
|
|
22
|
+
@injectable()
|
|
23
|
+
export class AppNativeDependencyContribution implements RemoteNativeDependencyContribution {
|
|
24
|
+
|
|
25
|
+
appDownloadUrlBase = 'https://github.com/eclipse-theia/theia/releases/download';
|
|
26
|
+
|
|
27
|
+
protected getDefaultURLForFile(remotePlatform: RemotePlatform, theiaVersion: string): string {
|
|
28
|
+
if (remotePlatform.arch !== 'x64') {
|
|
29
|
+
throw new Error(`Unsupported remote architecture '${remotePlatform.arch}'. Remote support is only available for x64 architectures.`);
|
|
30
|
+
}
|
|
31
|
+
let platform: string;
|
|
32
|
+
if (remotePlatform.os === OS.Type.Windows) {
|
|
33
|
+
platform = 'win32';
|
|
34
|
+
} else if (remotePlatform.os === OS.Type.OSX) {
|
|
35
|
+
platform = 'darwin';
|
|
36
|
+
} else {
|
|
37
|
+
platform = 'linux';
|
|
38
|
+
}
|
|
39
|
+
return `${this.appDownloadUrlBase}/v${theiaVersion}/native-dependencies-${platform}-${remotePlatform.arch}.zip`;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
async download(options: DownloadOptions): Promise<DependencyDownload> {
|
|
43
|
+
return {
|
|
44
|
+
buffer: await options.download(this.getDefaultURLForFile(options.remotePlatform, options.theiaVersion)),
|
|
45
|
+
archive: 'zip'
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -1,28 +1,28 @@
|
|
|
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 { injectable } from '@theia/core/shared/inversify';
|
|
18
|
-
import { RemoteCopyContribution, RemoteCopyRegistry } from './remote-copy-contribution';
|
|
19
|
-
|
|
20
|
-
@injectable()
|
|
21
|
-
export class MainCopyContribution implements RemoteCopyContribution {
|
|
22
|
-
async copy(registry: RemoteCopyRegistry): Promise<void> {
|
|
23
|
-
registry.file('package.json');
|
|
24
|
-
await registry.glob('lib/backend/**/*.js');
|
|
25
|
-
await registry.directory('lib/frontend');
|
|
26
|
-
await registry.directory('lib/webview');
|
|
27
|
-
}
|
|
28
|
-
}
|
|
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 { injectable } from '@theia/core/shared/inversify';
|
|
18
|
+
import { RemoteCopyContribution, RemoteCopyRegistry } from './remote-copy-contribution';
|
|
19
|
+
|
|
20
|
+
@injectable()
|
|
21
|
+
export class MainCopyContribution implements RemoteCopyContribution {
|
|
22
|
+
async copy(registry: RemoteCopyRegistry): Promise<void> {
|
|
23
|
+
registry.file('package.json');
|
|
24
|
+
await registry.glob('lib/backend/**/*.js');
|
|
25
|
+
await registry.directory('lib/frontend');
|
|
26
|
+
await registry.directory('lib/webview');
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -1,90 +1,90 @@
|
|
|
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 { glob as globCallback } from 'glob';
|
|
20
|
-
import { promisify } from 'util';
|
|
21
|
-
import * as path from 'path';
|
|
22
|
-
import { MaybePromise } from '@theia/core';
|
|
23
|
-
|
|
24
|
-
const promiseGlob = promisify(globCallback);
|
|
25
|
-
|
|
26
|
-
export const RemoteCopyContribution = Symbol('RemoteCopyContribution');
|
|
27
|
-
|
|
28
|
-
export interface RemoteCopyContribution {
|
|
29
|
-
copy(registry: RemoteCopyRegistry): MaybePromise<void>
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export interface RemoteCopyOptions {
|
|
33
|
-
/**
|
|
34
|
-
* The mode that the file should be set to once copied to the remote.
|
|
35
|
-
*
|
|
36
|
-
* Only relevant for POSIX-like systems
|
|
37
|
-
*/
|
|
38
|
-
mode?: number;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export interface RemoteFile {
|
|
42
|
-
path: string
|
|
43
|
-
target: string
|
|
44
|
-
options?: RemoteCopyOptions;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
@injectable()
|
|
48
|
-
export class RemoteCopyRegistry {
|
|
49
|
-
|
|
50
|
-
@inject(ApplicationPackage)
|
|
51
|
-
protected readonly applicationPackage: ApplicationPackage;
|
|
52
|
-
|
|
53
|
-
protected readonly files: RemoteFile[] = [];
|
|
54
|
-
|
|
55
|
-
getFiles(): RemoteFile[] {
|
|
56
|
-
return this.files.slice();
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
async glob(pattern: string, target?: string): Promise<void> {
|
|
60
|
-
const projectPath = this.applicationPackage.projectPath;
|
|
61
|
-
const globResult = await promiseGlob(pattern, {
|
|
62
|
-
cwd: projectPath
|
|
63
|
-
});
|
|
64
|
-
const relativeFiles = globResult.map(file => path.relative(projectPath, file));
|
|
65
|
-
for (const file of relativeFiles) {
|
|
66
|
-
const targetFile = this.withTarget(file, target);
|
|
67
|
-
this.files.push({
|
|
68
|
-
path: file,
|
|
69
|
-
target: targetFile
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
file(file: string, target?: string, options?: RemoteCopyOptions): void {
|
|
75
|
-
const targetFile = this.withTarget(file, target);
|
|
76
|
-
this.files.push({
|
|
77
|
-
path: file,
|
|
78
|
-
target: targetFile,
|
|
79
|
-
options
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
async directory(dir: string, target?: string): Promise<void> {
|
|
84
|
-
return this.glob(dir + '/**', target);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
protected withTarget(file: string, target?: string): string {
|
|
88
|
-
return target ? path.join(target, file) : file;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
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 { glob as globCallback } from 'glob';
|
|
20
|
+
import { promisify } from 'util';
|
|
21
|
+
import * as path from 'path';
|
|
22
|
+
import { MaybePromise } from '@theia/core';
|
|
23
|
+
|
|
24
|
+
const promiseGlob = promisify(globCallback);
|
|
25
|
+
|
|
26
|
+
export const RemoteCopyContribution = Symbol('RemoteCopyContribution');
|
|
27
|
+
|
|
28
|
+
export interface RemoteCopyContribution {
|
|
29
|
+
copy(registry: RemoteCopyRegistry): MaybePromise<void>
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface RemoteCopyOptions {
|
|
33
|
+
/**
|
|
34
|
+
* The mode that the file should be set to once copied to the remote.
|
|
35
|
+
*
|
|
36
|
+
* Only relevant for POSIX-like systems
|
|
37
|
+
*/
|
|
38
|
+
mode?: number;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface RemoteFile {
|
|
42
|
+
path: string
|
|
43
|
+
target: string
|
|
44
|
+
options?: RemoteCopyOptions;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
@injectable()
|
|
48
|
+
export class RemoteCopyRegistry {
|
|
49
|
+
|
|
50
|
+
@inject(ApplicationPackage)
|
|
51
|
+
protected readonly applicationPackage: ApplicationPackage;
|
|
52
|
+
|
|
53
|
+
protected readonly files: RemoteFile[] = [];
|
|
54
|
+
|
|
55
|
+
getFiles(): RemoteFile[] {
|
|
56
|
+
return this.files.slice();
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
async glob(pattern: string, target?: string): Promise<void> {
|
|
60
|
+
const projectPath = this.applicationPackage.projectPath;
|
|
61
|
+
const globResult = await promiseGlob(pattern, {
|
|
62
|
+
cwd: projectPath
|
|
63
|
+
});
|
|
64
|
+
const relativeFiles = globResult.map(file => path.relative(projectPath, file));
|
|
65
|
+
for (const file of relativeFiles) {
|
|
66
|
+
const targetFile = this.withTarget(file, target);
|
|
67
|
+
this.files.push({
|
|
68
|
+
path: file,
|
|
69
|
+
target: targetFile
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
file(file: string, target?: string, options?: RemoteCopyOptions): void {
|
|
75
|
+
const targetFile = this.withTarget(file, target);
|
|
76
|
+
this.files.push({
|
|
77
|
+
path: file,
|
|
78
|
+
target: targetFile,
|
|
79
|
+
options
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
async directory(dir: string, target?: string): Promise<void> {
|
|
84
|
+
return this.glob(dir + '/**', target);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
protected withTarget(file: string, target?: string): string {
|
|
88
|
+
return target ? path.join(target, file) : file;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
@@ -1,114 +1,114 @@
|
|
|
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, RemotePlatform } from '../remote-types';
|
|
24
|
-
import { RemoteNativeDependencyService } from './remote-native-dependency-service';
|
|
25
|
-
import { ContributionProvider } from '@theia/core';
|
|
26
|
-
import { RemoteCopyContribution, RemoteCopyRegistry, RemoteFile } from './remote-copy-contribution';
|
|
27
|
-
|
|
28
|
-
@injectable()
|
|
29
|
-
export class RemoteCopyService {
|
|
30
|
-
|
|
31
|
-
@inject(ApplicationPackage)
|
|
32
|
-
protected readonly applicationPackage: ApplicationPackage;
|
|
33
|
-
|
|
34
|
-
@inject(RemoteCopyRegistry)
|
|
35
|
-
protected readonly copyRegistry: RemoteCopyRegistry;
|
|
36
|
-
|
|
37
|
-
@inject(RemoteNativeDependencyService)
|
|
38
|
-
protected readonly nativeDependencyService: RemoteNativeDependencyService;
|
|
39
|
-
|
|
40
|
-
@inject(ContributionProvider) @named(RemoteCopyContribution)
|
|
41
|
-
protected readonly copyContributions: ContributionProvider<RemoteCopyContribution>;
|
|
42
|
-
|
|
43
|
-
protected initialized = false;
|
|
44
|
-
|
|
45
|
-
async copyToRemote(remote: RemoteConnection, remotePlatform: RemotePlatform, destination: string): Promise<void> {
|
|
46
|
-
const zipName = path.basename(destination);
|
|
47
|
-
const projectPath = this.applicationPackage.projectPath;
|
|
48
|
-
const tempDir = await this.getTempDir();
|
|
49
|
-
const zipPath = path.join(tempDir, zipName);
|
|
50
|
-
const files = await this.getFiles(remotePlatform, tempDir);
|
|
51
|
-
// We stream to a file here and then copy it because it is faster
|
|
52
|
-
// Copying files via sftp is 4x times faster compared to readable streams
|
|
53
|
-
const stream = fs.createWriteStream(zipPath);
|
|
54
|
-
const archive = archiver('tar', {
|
|
55
|
-
gzip: true
|
|
56
|
-
});
|
|
57
|
-
archive.pipe(stream);
|
|
58
|
-
for (const file of files) {
|
|
59
|
-
const filePath = path.isAbsolute(file.path)
|
|
60
|
-
? file.path
|
|
61
|
-
: path.join(projectPath, file.path);
|
|
62
|
-
|
|
63
|
-
archive.file(filePath, {
|
|
64
|
-
name: file.target,
|
|
65
|
-
mode: file.options?.mode
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
await archive.finalize();
|
|
69
|
-
await remote.copy(zipPath, destination);
|
|
70
|
-
await fs.promises.rm(tempDir, {
|
|
71
|
-
recursive: true,
|
|
72
|
-
force: true
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
protected async getFiles(remotePlatform: RemotePlatform, tempDir: string): Promise<RemoteFile[]> {
|
|
77
|
-
const [localFiles, nativeDependencies] = await Promise.all([
|
|
78
|
-
this.loadCopyContributions(),
|
|
79
|
-
this.loadNativeDependencies(remotePlatform, tempDir)
|
|
80
|
-
]);
|
|
81
|
-
return [...localFiles, ...nativeDependencies];
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
protected async loadCopyContributions(): Promise<RemoteFile[]> {
|
|
85
|
-
if (this.initialized) {
|
|
86
|
-
return this.copyRegistry.getFiles();
|
|
87
|
-
}
|
|
88
|
-
await Promise.all(this.copyContributions.getContributions()
|
|
89
|
-
.map(copyContribution => copyContribution.copy(this.copyRegistry)));
|
|
90
|
-
this.initialized = true;
|
|
91
|
-
return this.copyRegistry.getFiles();
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
protected async loadNativeDependencies(remotePlatform: RemotePlatform, tempDir: string): Promise<RemoteFile[]> {
|
|
95
|
-
const dependencyFiles = await this.nativeDependencyService.downloadDependencies(remotePlatform, tempDir);
|
|
96
|
-
return dependencyFiles.map(file => ({
|
|
97
|
-
path: file.path,
|
|
98
|
-
target: file.target,
|
|
99
|
-
options: {
|
|
100
|
-
mode: file.mode
|
|
101
|
-
}
|
|
102
|
-
}));
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
protected async getTempDir(): Promise<string> {
|
|
106
|
-
const dir = path.join(os.tmpdir(), 'theia-remote-');
|
|
107
|
-
const tempDir = await fs.promises.mkdtemp(dir);
|
|
108
|
-
return tempDir;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
protected async getRemoteDownloadLocation(): Promise<string | undefined> {
|
|
112
|
-
return undefined;
|
|
113
|
-
}
|
|
114
|
-
}
|
|
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, RemotePlatform } from '../remote-types';
|
|
24
|
+
import { RemoteNativeDependencyService } from './remote-native-dependency-service';
|
|
25
|
+
import { ContributionProvider } from '@theia/core';
|
|
26
|
+
import { RemoteCopyContribution, RemoteCopyRegistry, RemoteFile } from './remote-copy-contribution';
|
|
27
|
+
|
|
28
|
+
@injectable()
|
|
29
|
+
export class RemoteCopyService {
|
|
30
|
+
|
|
31
|
+
@inject(ApplicationPackage)
|
|
32
|
+
protected readonly applicationPackage: ApplicationPackage;
|
|
33
|
+
|
|
34
|
+
@inject(RemoteCopyRegistry)
|
|
35
|
+
protected readonly copyRegistry: RemoteCopyRegistry;
|
|
36
|
+
|
|
37
|
+
@inject(RemoteNativeDependencyService)
|
|
38
|
+
protected readonly nativeDependencyService: RemoteNativeDependencyService;
|
|
39
|
+
|
|
40
|
+
@inject(ContributionProvider) @named(RemoteCopyContribution)
|
|
41
|
+
protected readonly copyContributions: ContributionProvider<RemoteCopyContribution>;
|
|
42
|
+
|
|
43
|
+
protected initialized = false;
|
|
44
|
+
|
|
45
|
+
async copyToRemote(remote: RemoteConnection, remotePlatform: RemotePlatform, destination: string): Promise<void> {
|
|
46
|
+
const zipName = path.basename(destination);
|
|
47
|
+
const projectPath = this.applicationPackage.projectPath;
|
|
48
|
+
const tempDir = await this.getTempDir();
|
|
49
|
+
const zipPath = path.join(tempDir, zipName);
|
|
50
|
+
const files = await this.getFiles(remotePlatform, tempDir);
|
|
51
|
+
// We stream to a file here and then copy it because it is faster
|
|
52
|
+
// Copying files via sftp is 4x times faster compared to readable streams
|
|
53
|
+
const stream = fs.createWriteStream(zipPath);
|
|
54
|
+
const archive = archiver('tar', {
|
|
55
|
+
gzip: true
|
|
56
|
+
});
|
|
57
|
+
archive.pipe(stream);
|
|
58
|
+
for (const file of files) {
|
|
59
|
+
const filePath = path.isAbsolute(file.path)
|
|
60
|
+
? file.path
|
|
61
|
+
: path.join(projectPath, file.path);
|
|
62
|
+
|
|
63
|
+
archive.file(filePath, {
|
|
64
|
+
name: file.target,
|
|
65
|
+
mode: file.options?.mode
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
await archive.finalize();
|
|
69
|
+
await remote.copy(zipPath, destination);
|
|
70
|
+
await fs.promises.rm(tempDir, {
|
|
71
|
+
recursive: true,
|
|
72
|
+
force: true
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
protected async getFiles(remotePlatform: RemotePlatform, tempDir: string): Promise<RemoteFile[]> {
|
|
77
|
+
const [localFiles, nativeDependencies] = await Promise.all([
|
|
78
|
+
this.loadCopyContributions(),
|
|
79
|
+
this.loadNativeDependencies(remotePlatform, tempDir)
|
|
80
|
+
]);
|
|
81
|
+
return [...localFiles, ...nativeDependencies];
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
protected async loadCopyContributions(): Promise<RemoteFile[]> {
|
|
85
|
+
if (this.initialized) {
|
|
86
|
+
return this.copyRegistry.getFiles();
|
|
87
|
+
}
|
|
88
|
+
await Promise.all(this.copyContributions.getContributions()
|
|
89
|
+
.map(copyContribution => copyContribution.copy(this.copyRegistry)));
|
|
90
|
+
this.initialized = true;
|
|
91
|
+
return this.copyRegistry.getFiles();
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
protected async loadNativeDependencies(remotePlatform: RemotePlatform, tempDir: string): Promise<RemoteFile[]> {
|
|
95
|
+
const dependencyFiles = await this.nativeDependencyService.downloadDependencies(remotePlatform, tempDir);
|
|
96
|
+
return dependencyFiles.map(file => ({
|
|
97
|
+
path: file.path,
|
|
98
|
+
target: file.target,
|
|
99
|
+
options: {
|
|
100
|
+
mode: file.mode
|
|
101
|
+
}
|
|
102
|
+
}));
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
protected async getTempDir(): Promise<string> {
|
|
106
|
+
const dir = path.join(os.tmpdir(), 'theia-remote-');
|
|
107
|
+
const tempDir = await fs.promises.mkdtemp(dir);
|
|
108
|
+
return tempDir;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
protected async getRemoteDownloadLocation(): Promise<string | undefined> {
|
|
112
|
+
return undefined;
|
|
113
|
+
}
|
|
114
|
+
}
|