@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,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 '../remote-types';
|
|
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 '../remote-types';
|
|
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,111 +1,111 @@
|
|
|
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 { ContributionProvider, THEIA_VERSION } from '@theia/core';
|
|
18
|
-
import { inject, injectable, named } from '@theia/core/shared/inversify';
|
|
19
|
-
import { RequestContext, RequestService, RequestOptions } from '@theia/core/shared/@theia/request';
|
|
20
|
-
import * as decompress from 'decompress';
|
|
21
|
-
import * as path from 'path';
|
|
22
|
-
import * as fs from 'fs/promises';
|
|
23
|
-
import { DependencyDownload, DirectoryDependencyDownload, RemoteNativeDependencyContribution } from './remote-native-dependency-contribution';
|
|
24
|
-
import { RemotePlatform } from '../remote-types';
|
|
25
|
-
|
|
26
|
-
const decompressTar = require('decompress-tar');
|
|
27
|
-
const decompressTargz = require('decompress-targz');
|
|
28
|
-
const decompressUnzip = require('decompress-unzip');
|
|
29
|
-
|
|
30
|
-
export const DEFAULT_HTTP_OPTIONS = {
|
|
31
|
-
method: 'GET',
|
|
32
|
-
headers: {
|
|
33
|
-
Accept: 'application/octet-stream'
|
|
34
|
-
},
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
export interface NativeDependencyFile {
|
|
38
|
-
path: string;
|
|
39
|
-
target: string;
|
|
40
|
-
mode?: number;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
@injectable()
|
|
44
|
-
export class RemoteNativeDependencyService {
|
|
45
|
-
|
|
46
|
-
@inject(ContributionProvider) @named(RemoteNativeDependencyContribution)
|
|
47
|
-
protected nativeDependencyContributions: ContributionProvider<RemoteNativeDependencyContribution>;
|
|
48
|
-
|
|
49
|
-
@inject(RequestService)
|
|
50
|
-
protected requestService: RequestService;
|
|
51
|
-
|
|
52
|
-
async downloadDependencies(remotePlatform: RemotePlatform, directory: string): Promise<NativeDependencyFile[]> {
|
|
53
|
-
const contributionResults = await Promise.all(this.nativeDependencyContributions.getContributions()
|
|
54
|
-
.map(async contribution => {
|
|
55
|
-
const result = await contribution.download({
|
|
56
|
-
remotePlatform,
|
|
57
|
-
theiaVersion: THEIA_VERSION,
|
|
58
|
-
download: requestInfo => this.downloadDependency(requestInfo)
|
|
59
|
-
});
|
|
60
|
-
const dependency = await this.storeDependency(result, directory);
|
|
61
|
-
return dependency;
|
|
62
|
-
}));
|
|
63
|
-
return contributionResults.flat();
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
protected async downloadDependency(downloadURI: string | RequestOptions): Promise<Buffer> {
|
|
67
|
-
const options = typeof downloadURI === 'string'
|
|
68
|
-
? { url: downloadURI, ...DEFAULT_HTTP_OPTIONS }
|
|
69
|
-
: { ...DEFAULT_HTTP_OPTIONS, ...downloadURI };
|
|
70
|
-
const req = await this.requestService.request(options);
|
|
71
|
-
if (RequestContext.isSuccess(req)) {
|
|
72
|
-
return Buffer.from(req.buffer);
|
|
73
|
-
} else {
|
|
74
|
-
throw new Error('Server error while downloading native dependency from: ' + options.url);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
protected async storeDependency(dependency: DependencyDownload, directory: string): Promise<NativeDependencyFile[]> {
|
|
79
|
-
if (DirectoryDependencyDownload.is(dependency)) {
|
|
80
|
-
const archiveBuffer = dependency.buffer;
|
|
81
|
-
const plugins: unknown[] = [];
|
|
82
|
-
if (dependency.archive === 'tar') {
|
|
83
|
-
plugins.push(decompressTar());
|
|
84
|
-
} else if (dependency.archive === 'tgz') {
|
|
85
|
-
plugins.push(decompressTargz());
|
|
86
|
-
} else if (dependency.archive === 'zip') {
|
|
87
|
-
plugins.push(decompressUnzip());
|
|
88
|
-
}
|
|
89
|
-
const files = await decompress(archiveBuffer, directory, { plugins });
|
|
90
|
-
const result: NativeDependencyFile[] = await Promise.all(files.map(async file => {
|
|
91
|
-
const localPath = path.join(directory, file.path);
|
|
92
|
-
return {
|
|
93
|
-
path: localPath,
|
|
94
|
-
target: file.path,
|
|
95
|
-
mode: file.mode
|
|
96
|
-
};
|
|
97
|
-
}));
|
|
98
|
-
return result;
|
|
99
|
-
} else {
|
|
100
|
-
const fileName = path.basename(dependency.file.path);
|
|
101
|
-
const localPath = path.join(directory, fileName);
|
|
102
|
-
await fs.writeFile(localPath, dependency.buffer);
|
|
103
|
-
return [{
|
|
104
|
-
path: localPath,
|
|
105
|
-
target: dependency.file.path,
|
|
106
|
-
mode: dependency.file.mode
|
|
107
|
-
}];
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
}
|
|
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 { ContributionProvider, THEIA_VERSION } from '@theia/core';
|
|
18
|
+
import { inject, injectable, named } from '@theia/core/shared/inversify';
|
|
19
|
+
import { RequestContext, RequestService, RequestOptions } from '@theia/core/shared/@theia/request';
|
|
20
|
+
import * as decompress from 'decompress';
|
|
21
|
+
import * as path from 'path';
|
|
22
|
+
import * as fs from 'fs/promises';
|
|
23
|
+
import { DependencyDownload, DirectoryDependencyDownload, RemoteNativeDependencyContribution } from './remote-native-dependency-contribution';
|
|
24
|
+
import { RemotePlatform } from '../remote-types';
|
|
25
|
+
|
|
26
|
+
const decompressTar = require('decompress-tar');
|
|
27
|
+
const decompressTargz = require('decompress-targz');
|
|
28
|
+
const decompressUnzip = require('decompress-unzip');
|
|
29
|
+
|
|
30
|
+
export const DEFAULT_HTTP_OPTIONS = {
|
|
31
|
+
method: 'GET',
|
|
32
|
+
headers: {
|
|
33
|
+
Accept: 'application/octet-stream'
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export interface NativeDependencyFile {
|
|
38
|
+
path: string;
|
|
39
|
+
target: string;
|
|
40
|
+
mode?: number;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
@injectable()
|
|
44
|
+
export class RemoteNativeDependencyService {
|
|
45
|
+
|
|
46
|
+
@inject(ContributionProvider) @named(RemoteNativeDependencyContribution)
|
|
47
|
+
protected nativeDependencyContributions: ContributionProvider<RemoteNativeDependencyContribution>;
|
|
48
|
+
|
|
49
|
+
@inject(RequestService)
|
|
50
|
+
protected requestService: RequestService;
|
|
51
|
+
|
|
52
|
+
async downloadDependencies(remotePlatform: RemotePlatform, directory: string): Promise<NativeDependencyFile[]> {
|
|
53
|
+
const contributionResults = await Promise.all(this.nativeDependencyContributions.getContributions()
|
|
54
|
+
.map(async contribution => {
|
|
55
|
+
const result = await contribution.download({
|
|
56
|
+
remotePlatform,
|
|
57
|
+
theiaVersion: THEIA_VERSION,
|
|
58
|
+
download: requestInfo => this.downloadDependency(requestInfo)
|
|
59
|
+
});
|
|
60
|
+
const dependency = await this.storeDependency(result, directory);
|
|
61
|
+
return dependency;
|
|
62
|
+
}));
|
|
63
|
+
return contributionResults.flat();
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
protected async downloadDependency(downloadURI: string | RequestOptions): Promise<Buffer> {
|
|
67
|
+
const options = typeof downloadURI === 'string'
|
|
68
|
+
? { url: downloadURI, ...DEFAULT_HTTP_OPTIONS }
|
|
69
|
+
: { ...DEFAULT_HTTP_OPTIONS, ...downloadURI };
|
|
70
|
+
const req = await this.requestService.request(options);
|
|
71
|
+
if (RequestContext.isSuccess(req)) {
|
|
72
|
+
return Buffer.from(req.buffer);
|
|
73
|
+
} else {
|
|
74
|
+
throw new Error('Server error while downloading native dependency from: ' + options.url);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
protected async storeDependency(dependency: DependencyDownload, directory: string): Promise<NativeDependencyFile[]> {
|
|
79
|
+
if (DirectoryDependencyDownload.is(dependency)) {
|
|
80
|
+
const archiveBuffer = dependency.buffer;
|
|
81
|
+
const plugins: unknown[] = [];
|
|
82
|
+
if (dependency.archive === 'tar') {
|
|
83
|
+
plugins.push(decompressTar());
|
|
84
|
+
} else if (dependency.archive === 'tgz') {
|
|
85
|
+
plugins.push(decompressTargz());
|
|
86
|
+
} else if (dependency.archive === 'zip') {
|
|
87
|
+
plugins.push(decompressUnzip());
|
|
88
|
+
}
|
|
89
|
+
const files = await decompress(archiveBuffer, directory, { plugins });
|
|
90
|
+
const result: NativeDependencyFile[] = await Promise.all(files.map(async file => {
|
|
91
|
+
const localPath = path.join(directory, file.path);
|
|
92
|
+
return {
|
|
93
|
+
path: localPath,
|
|
94
|
+
target: file.path,
|
|
95
|
+
mode: file.mode
|
|
96
|
+
};
|
|
97
|
+
}));
|
|
98
|
+
return result;
|
|
99
|
+
} else {
|
|
100
|
+
const fileName = path.basename(dependency.file.path);
|
|
101
|
+
const localPath = path.join(directory, fileName);
|
|
102
|
+
await fs.writeFile(localPath, dependency.buffer);
|
|
103
|
+
return [{
|
|
104
|
+
path: localPath,
|
|
105
|
+
target: dependency.file.path,
|
|
106
|
+
mode: dependency.file.mode
|
|
107
|
+
}];
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
}
|
|
@@ -1,123 +1,123 @@
|
|
|
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 path from 'path';
|
|
18
|
-
import * as fs from '@theia/core/shared/fs-extra';
|
|
19
|
-
import * as os from 'os';
|
|
20
|
-
|
|
21
|
-
import { inject, injectable } from '@theia/core/shared/inversify';
|
|
22
|
-
import { RequestService } from '@theia/core/shared/@theia/request';
|
|
23
|
-
import { RemoteSetupScriptService } from './remote-setup-script-service';
|
|
24
|
-
import { RemotePlatform } from '../remote-types';
|
|
25
|
-
import { OS } from '@theia/core';
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* The current node version that Theia recommends.
|
|
29
|
-
*
|
|
30
|
-
* Native dependencies are compiled against this version.
|
|
31
|
-
*/
|
|
32
|
-
export const REMOTE_NODE_VERSION = '18.17.0';
|
|
33
|
-
|
|
34
|
-
@injectable()
|
|
35
|
-
export class RemoteNodeSetupService {
|
|
36
|
-
|
|
37
|
-
@inject(RequestService)
|
|
38
|
-
protected readonly requestService: RequestService;
|
|
39
|
-
|
|
40
|
-
@inject(RemoteSetupScriptService)
|
|
41
|
-
protected readonly scriptService: RemoteSetupScriptService;
|
|
42
|
-
|
|
43
|
-
getNodeDirectoryName(platform: RemotePlatform): string {
|
|
44
|
-
return `node-v${REMOTE_NODE_VERSION}-${this.getPlatformName(platform)}-${platform.arch}`;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
protected getPlatformName(platform: RemotePlatform): string {
|
|
48
|
-
let platformId: string;
|
|
49
|
-
if (platform.os === OS.Type.Windows) {
|
|
50
|
-
platformId = 'win';
|
|
51
|
-
} else if (platform.os === OS.Type.OSX) {
|
|
52
|
-
platformId = 'darwin';
|
|
53
|
-
} else {
|
|
54
|
-
platformId = 'linux';
|
|
55
|
-
}
|
|
56
|
-
return platformId;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
protected validatePlatform(platform: RemotePlatform): void {
|
|
60
|
-
if (platform.os === OS.Type.Windows && !platform.arch.match(/^x(64|86)$/)) {
|
|
61
|
-
this.throwPlatformError(platform, 'x64 and x86');
|
|
62
|
-
} else if (platform.os === OS.Type.Linux && !platform.arch.match(/^(x64|armv7l|arm64)$/)) {
|
|
63
|
-
this.throwPlatformError(platform, 'x64, armv7l and arm64');
|
|
64
|
-
} else if (platform.os === OS.Type.OSX && !platform.arch.match(/^(x64|arm64)$/)) {
|
|
65
|
-
this.throwPlatformError(platform, 'x64 and arm64');
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
protected throwPlatformError(platform: RemotePlatform, supportedArch: string): never {
|
|
70
|
-
throw new Error(`Invalid architecture for ${platform.os}: '${platform.arch}'. Only ${supportedArch} are supported.`);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
protected getNodeFileExtension(platform: RemotePlatform): string {
|
|
74
|
-
let fileExtension: string;
|
|
75
|
-
if (platform.os === OS.Type.Windows) {
|
|
76
|
-
fileExtension = 'zip';
|
|
77
|
-
} else if (platform.os === OS.Type.OSX) {
|
|
78
|
-
fileExtension = 'tar.gz';
|
|
79
|
-
} else {
|
|
80
|
-
fileExtension = 'tar.xz';
|
|
81
|
-
}
|
|
82
|
-
return fileExtension;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
getNodeFileName(platform: RemotePlatform): string {
|
|
86
|
-
return `${this.getNodeDirectoryName(platform)}.${this.getNodeFileExtension(platform)}`;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
async downloadNode(platform: RemotePlatform, downloadTemplate?: string): Promise<string> {
|
|
90
|
-
this.validatePlatform(platform);
|
|
91
|
-
const fileName = this.getNodeFileName(platform);
|
|
92
|
-
const tmpdir = os.tmpdir();
|
|
93
|
-
const localPath = path.join(tmpdir, fileName);
|
|
94
|
-
if (!await fs.pathExists(localPath)) {
|
|
95
|
-
const downloadPath = this.getDownloadPath(platform, downloadTemplate);
|
|
96
|
-
const downloadResult = await this.requestService.request({
|
|
97
|
-
url: downloadPath
|
|
98
|
-
});
|
|
99
|
-
await fs.writeFile(localPath, downloadResult.buffer);
|
|
100
|
-
}
|
|
101
|
-
return localPath;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
generateDownloadScript(platform: RemotePlatform, targetPath: string, downloadTemplate?: string): string {
|
|
105
|
-
this.validatePlatform(platform);
|
|
106
|
-
const fileName = this.getNodeFileName(platform);
|
|
107
|
-
const downloadPath = this.getDownloadPath(platform, downloadTemplate);
|
|
108
|
-
const zipPath = this.scriptService.joinPath(platform, targetPath, fileName);
|
|
109
|
-
const download = this.scriptService.downloadFile(platform, downloadPath, zipPath);
|
|
110
|
-
const unzip = this.scriptService.unzip(platform, zipPath, targetPath);
|
|
111
|
-
return this.scriptService.joinScript(platform, download, unzip);
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
protected getDownloadPath(platform: RemotePlatform, downloadTemplate?: string): string {
|
|
115
|
-
const template = downloadTemplate || 'https://nodejs.org/dist/v{version}/node-v{version}-{os}-{arch}.{ext}';
|
|
116
|
-
const downloadPath = template
|
|
117
|
-
.replace(/{version}/g, REMOTE_NODE_VERSION)
|
|
118
|
-
.replace(/{os}/g, this.getPlatformName(platform))
|
|
119
|
-
.replace(/{arch}/g, platform.arch)
|
|
120
|
-
.replace(/{ext}/g, this.getNodeFileExtension(platform));
|
|
121
|
-
return downloadPath;
|
|
122
|
-
}
|
|
123
|
-
}
|
|
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 path from 'path';
|
|
18
|
+
import * as fs from '@theia/core/shared/fs-extra';
|
|
19
|
+
import * as os from 'os';
|
|
20
|
+
|
|
21
|
+
import { inject, injectable } from '@theia/core/shared/inversify';
|
|
22
|
+
import { RequestService } from '@theia/core/shared/@theia/request';
|
|
23
|
+
import { RemoteSetupScriptService } from './remote-setup-script-service';
|
|
24
|
+
import { RemotePlatform } from '../remote-types';
|
|
25
|
+
import { OS } from '@theia/core';
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* The current node version that Theia recommends.
|
|
29
|
+
*
|
|
30
|
+
* Native dependencies are compiled against this version.
|
|
31
|
+
*/
|
|
32
|
+
export const REMOTE_NODE_VERSION = '18.17.0';
|
|
33
|
+
|
|
34
|
+
@injectable()
|
|
35
|
+
export class RemoteNodeSetupService {
|
|
36
|
+
|
|
37
|
+
@inject(RequestService)
|
|
38
|
+
protected readonly requestService: RequestService;
|
|
39
|
+
|
|
40
|
+
@inject(RemoteSetupScriptService)
|
|
41
|
+
protected readonly scriptService: RemoteSetupScriptService;
|
|
42
|
+
|
|
43
|
+
getNodeDirectoryName(platform: RemotePlatform): string {
|
|
44
|
+
return `node-v${REMOTE_NODE_VERSION}-${this.getPlatformName(platform)}-${platform.arch}`;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
protected getPlatformName(platform: RemotePlatform): string {
|
|
48
|
+
let platformId: string;
|
|
49
|
+
if (platform.os === OS.Type.Windows) {
|
|
50
|
+
platformId = 'win';
|
|
51
|
+
} else if (platform.os === OS.Type.OSX) {
|
|
52
|
+
platformId = 'darwin';
|
|
53
|
+
} else {
|
|
54
|
+
platformId = 'linux';
|
|
55
|
+
}
|
|
56
|
+
return platformId;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
protected validatePlatform(platform: RemotePlatform): void {
|
|
60
|
+
if (platform.os === OS.Type.Windows && !platform.arch.match(/^x(64|86)$/)) {
|
|
61
|
+
this.throwPlatformError(platform, 'x64 and x86');
|
|
62
|
+
} else if (platform.os === OS.Type.Linux && !platform.arch.match(/^(x64|armv7l|arm64)$/)) {
|
|
63
|
+
this.throwPlatformError(platform, 'x64, armv7l and arm64');
|
|
64
|
+
} else if (platform.os === OS.Type.OSX && !platform.arch.match(/^(x64|arm64)$/)) {
|
|
65
|
+
this.throwPlatformError(platform, 'x64 and arm64');
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
protected throwPlatformError(platform: RemotePlatform, supportedArch: string): never {
|
|
70
|
+
throw new Error(`Invalid architecture for ${platform.os}: '${platform.arch}'. Only ${supportedArch} are supported.`);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
protected getNodeFileExtension(platform: RemotePlatform): string {
|
|
74
|
+
let fileExtension: string;
|
|
75
|
+
if (platform.os === OS.Type.Windows) {
|
|
76
|
+
fileExtension = 'zip';
|
|
77
|
+
} else if (platform.os === OS.Type.OSX) {
|
|
78
|
+
fileExtension = 'tar.gz';
|
|
79
|
+
} else {
|
|
80
|
+
fileExtension = 'tar.xz';
|
|
81
|
+
}
|
|
82
|
+
return fileExtension;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
getNodeFileName(platform: RemotePlatform): string {
|
|
86
|
+
return `${this.getNodeDirectoryName(platform)}.${this.getNodeFileExtension(platform)}`;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
async downloadNode(platform: RemotePlatform, downloadTemplate?: string): Promise<string> {
|
|
90
|
+
this.validatePlatform(platform);
|
|
91
|
+
const fileName = this.getNodeFileName(platform);
|
|
92
|
+
const tmpdir = os.tmpdir();
|
|
93
|
+
const localPath = path.join(tmpdir, fileName);
|
|
94
|
+
if (!await fs.pathExists(localPath)) {
|
|
95
|
+
const downloadPath = this.getDownloadPath(platform, downloadTemplate);
|
|
96
|
+
const downloadResult = await this.requestService.request({
|
|
97
|
+
url: downloadPath
|
|
98
|
+
});
|
|
99
|
+
await fs.writeFile(localPath, downloadResult.buffer);
|
|
100
|
+
}
|
|
101
|
+
return localPath;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
generateDownloadScript(platform: RemotePlatform, targetPath: string, downloadTemplate?: string): string {
|
|
105
|
+
this.validatePlatform(platform);
|
|
106
|
+
const fileName = this.getNodeFileName(platform);
|
|
107
|
+
const downloadPath = this.getDownloadPath(platform, downloadTemplate);
|
|
108
|
+
const zipPath = this.scriptService.joinPath(platform, targetPath, fileName);
|
|
109
|
+
const download = this.scriptService.downloadFile(platform, downloadPath, zipPath);
|
|
110
|
+
const unzip = this.scriptService.unzip(platform, zipPath, targetPath);
|
|
111
|
+
return this.scriptService.joinScript(platform, download, unzip);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
protected getDownloadPath(platform: RemotePlatform, downloadTemplate?: string): string {
|
|
115
|
+
const template = downloadTemplate || 'https://nodejs.org/dist/v{version}/node-v{version}-{os}-{arch}.{ext}';
|
|
116
|
+
const downloadPath = template
|
|
117
|
+
.replace(/{version}/g, REMOTE_NODE_VERSION)
|
|
118
|
+
.replace(/{os}/g, this.getPlatformName(platform))
|
|
119
|
+
.replace(/{arch}/g, platform.arch)
|
|
120
|
+
.replace(/{ext}/g, this.getNodeFileExtension(platform));
|
|
121
|
+
return downloadPath;
|
|
122
|
+
}
|
|
123
|
+
}
|