@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.
Files changed (87) hide show
  1. package/README.md +61 -61
  2. package/lib/electron-browser/remote-electron-file-dialog-service.d.ts +13 -13
  3. package/lib/electron-browser/remote-electron-file-dialog-service.js +57 -57
  4. package/lib/electron-browser/remote-frontend-contribution.d.ts +25 -25
  5. package/lib/electron-browser/remote-frontend-contribution.js +164 -164
  6. package/lib/electron-browser/remote-frontend-module.d.ts +3 -3
  7. package/lib/electron-browser/remote-frontend-module.js +42 -42
  8. package/lib/electron-browser/remote-preferences.d.ts +10 -10
  9. package/lib/electron-browser/remote-preferences.js +48 -48
  10. package/lib/electron-browser/remote-registry-contribution.d.ts +18 -18
  11. package/lib/electron-browser/remote-registry-contribution.js +74 -74
  12. package/lib/electron-browser/remote-service.d.ts +5 -5
  13. package/lib/electron-browser/remote-service.js +37 -37
  14. package/lib/electron-browser/remote-ssh-contribution.d.ts +17 -17
  15. package/lib/electron-browser/remote-ssh-contribution.js +117 -117
  16. package/lib/electron-common/remote-ssh-connection-provider.d.ts +10 -10
  17. package/lib/electron-common/remote-ssh-connection-provider.js +20 -20
  18. package/lib/electron-common/remote-status-service.d.ts +14 -14
  19. package/lib/electron-common/remote-status-service.js +20 -20
  20. package/lib/electron-node/backend-remote-service-impl.d.ts +11 -11
  21. package/lib/electron-node/backend-remote-service-impl.js +50 -50
  22. package/lib/electron-node/remote-backend-module.d.ts +4 -4
  23. package/lib/electron-node/remote-backend-module.js +74 -74
  24. package/lib/electron-node/remote-connection-service.d.ts +14 -14
  25. package/lib/electron-node/remote-connection-service.js +65 -65
  26. package/lib/electron-node/remote-connection-socket-provider.d.ts +8 -8
  27. package/lib/electron-node/remote-connection-socket-provider.js +37 -37
  28. package/lib/electron-node/remote-proxy-server-provider.d.ts +5 -5
  29. package/lib/electron-node/remote-proxy-server-provider.js +43 -43
  30. package/lib/electron-node/remote-status-service.d.ts +6 -6
  31. package/lib/electron-node/remote-status-service.js +54 -54
  32. package/lib/electron-node/remote-types.d.ts +34 -34
  33. package/lib/electron-node/remote-types.js +17 -17
  34. package/lib/electron-node/setup/app-native-dependency-contribution.d.ts +7 -7
  35. package/lib/electron-node/setup/app-native-dependency-contribution.js +57 -57
  36. package/lib/electron-node/setup/main-copy-contribution.d.ts +4 -4
  37. package/lib/electron-node/setup/main-copy-contribution.js +37 -37
  38. package/lib/electron-node/setup/remote-copy-contribution.d.ts +28 -28
  39. package/lib/electron-node/setup/remote-copy-contribution.js +78 -78
  40. package/lib/electron-node/setup/remote-copy-service.d.ts +18 -18
  41. package/lib/electron-node/setup/remote-copy-service.js +126 -126
  42. package/lib/electron-node/setup/remote-native-dependency-contribution.d.ts +34 -34
  43. package/lib/electron-node/setup/remote-native-dependency-contribution.js +34 -34
  44. package/lib/electron-node/setup/remote-native-dependency-service.d.ts +23 -23
  45. package/lib/electron-node/setup/remote-native-dependency-service.js +118 -118
  46. package/lib/electron-node/setup/remote-node-setup-service.d.ts +22 -22
  47. package/lib/electron-node/setup/remote-node-setup-service.js +132 -132
  48. package/lib/electron-node/setup/remote-setup-script-service.d.ts +40 -40
  49. package/lib/electron-node/setup/remote-setup-script-service.js +132 -132
  50. package/lib/electron-node/setup/remote-setup-service.d.ts +28 -28
  51. package/lib/electron-node/setup/remote-setup-service.js +198 -198
  52. package/lib/electron-node/ssh/remote-ssh-connection-provider.d.ts +55 -55
  53. package/lib/electron-node/ssh/remote-ssh-connection-provider.d.ts.map +1 -1
  54. package/lib/electron-node/ssh/remote-ssh-connection-provider.js +344 -342
  55. package/lib/electron-node/ssh/remote-ssh-connection-provider.js.map +1 -1
  56. package/lib/electron-node/ssh/ssh-identity-file-collector.d.ts +12 -12
  57. package/lib/electron-node/ssh/ssh-identity-file-collector.js +131 -131
  58. package/lib/package.spec.js +25 -25
  59. package/package.json +6 -7
  60. package/src/electron-browser/remote-electron-file-dialog-service.ts +47 -47
  61. package/src/electron-browser/remote-frontend-contribution.ts +145 -145
  62. package/src/electron-browser/remote-frontend-module.ts +49 -49
  63. package/src/electron-browser/remote-preferences.ts +62 -62
  64. package/src/electron-browser/remote-registry-contribution.ts +70 -70
  65. package/src/electron-browser/remote-service.ts +31 -31
  66. package/src/electron-browser/remote-ssh-contribution.ts +102 -102
  67. package/src/electron-common/remote-ssh-connection-provider.ts +29 -29
  68. package/src/electron-common/remote-status-service.ts +35 -35
  69. package/src/electron-node/backend-remote-service-impl.ts +45 -45
  70. package/src/electron-node/remote-backend-module.ts +80 -80
  71. package/src/electron-node/remote-connection-service.ts +55 -55
  72. package/src/electron-node/remote-connection-socket-provider.ts +34 -34
  73. package/src/electron-node/remote-proxy-server-provider.ts +37 -37
  74. package/src/electron-node/remote-status-service.ts +41 -41
  75. package/src/electron-node/remote-types.ts +56 -56
  76. package/src/electron-node/setup/app-native-dependency-contribution.ts +48 -48
  77. package/src/electron-node/setup/main-copy-contribution.ts +28 -28
  78. package/src/electron-node/setup/remote-copy-contribution.ts +90 -90
  79. package/src/electron-node/setup/remote-copy-service.ts +114 -114
  80. package/src/electron-node/setup/remote-native-dependency-contribution.ts +63 -63
  81. package/src/electron-node/setup/remote-native-dependency-service.ts +111 -111
  82. package/src/electron-node/setup/remote-node-setup-service.ts +123 -123
  83. package/src/electron-node/setup/remote-setup-script-service.ts +146 -146
  84. package/src/electron-node/setup/remote-setup-service.ts +197 -197
  85. package/src/electron-node/ssh/remote-ssh-connection-provider.ts +358 -356
  86. package/src/electron-node/ssh/ssh-identity-file-collector.ts +137 -137
  87. package/src/package.spec.ts +29 -29
@@ -1,199 +1,199 @@
1
- "use strict";
2
- // *****************************************************************************
3
- // Copyright (C) 2023 TypeFox and others.
4
- //
5
- // This program and the accompanying materials are made available under the
6
- // terms of the Eclipse Public License v. 2.0 which is available at
7
- // http://www.eclipse.org/legal/epl-2.0.
8
- //
9
- // This Source Code may also be made available under the following Secondary
10
- // Licenses when the conditions for such availability set forth in the Eclipse
11
- // Public License v. 2.0 are satisfied: GNU General Public License, version 2
12
- // with the GNU Classpath Exception which is available at
13
- // https://www.gnu.org/software/classpath/license.html.
14
- //
15
- // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
16
- // *****************************************************************************
17
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
18
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
19
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
20
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
21
- return c > 3 && r && Object.defineProperty(target, key, r), r;
22
- };
23
- var __metadata = (this && this.__metadata) || function (k, v) {
24
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
25
- };
26
- Object.defineProperty(exports, "__esModule", { value: true });
27
- exports.RemoteSetupService = void 0;
28
- const inversify_1 = require("@theia/core/shared/inversify");
29
- const application_package_1 = require("@theia/core/shared/@theia/application-package");
30
- const remote_copy_service_1 = require("./remote-copy-service");
31
- const remote_native_dependency_service_1 = require("./remote-native-dependency-service");
32
- const core_1 = require("@theia/core");
33
- const remote_node_setup_service_1 = require("./remote-node-setup-service");
34
- const remote_setup_script_service_1 = require("./remote-setup-script-service");
35
- let RemoteSetupService = class RemoteSetupService {
36
- async setup(options) {
37
- const { connection, report, nodeDownloadTemplate } = options;
38
- report('Identifying remote system...');
39
- // 1. Identify remote platform
40
- const platform = await this.detectRemotePlatform(connection);
41
- // 2. Setup home directory
42
- const remoteHome = await this.getRemoteHomeDirectory(connection, platform);
43
- const applicationDirectory = this.scriptService.joinPath(platform, remoteHome, `.${this.getRemoteAppName()}`);
44
- await this.mkdirRemote(connection, platform, applicationDirectory);
45
- // 3. Download+copy node for that platform
46
- const nodeFileName = this.nodeSetupService.getNodeFileName(platform);
47
- const nodeDirName = this.nodeSetupService.getNodeDirectoryName(platform);
48
- const remoteNodeDirectory = this.scriptService.joinPath(platform, applicationDirectory, nodeDirName);
49
- const nodeDirExists = await this.dirExistsRemote(connection, remoteNodeDirectory);
50
- if (!nodeDirExists) {
51
- report('Downloading and installing Node.js on remote...');
52
- // Download the binaries locally and move it via SSH
53
- const nodeArchive = await this.nodeSetupService.downloadNode(platform, nodeDownloadTemplate);
54
- const remoteNodeZip = this.scriptService.joinPath(platform, applicationDirectory, nodeFileName);
55
- await connection.copy(nodeArchive, remoteNodeZip);
56
- await this.unzipRemote(connection, platform, remoteNodeZip, applicationDirectory);
57
- }
58
- // 4. Copy backend to remote system
59
- const libDir = this.scriptService.joinPath(platform, applicationDirectory, 'lib');
60
- const libDirExists = await this.dirExistsRemote(connection, libDir);
61
- if (!libDirExists) {
62
- report('Installing application on remote...');
63
- const applicationZipFile = this.scriptService.joinPath(platform, applicationDirectory, `${this.getRemoteAppName()}.tar`);
64
- await this.copyService.copyToRemote(connection, platform, applicationZipFile);
65
- await this.unzipRemote(connection, platform, applicationZipFile, applicationDirectory);
66
- }
67
- // 5. start remote backend
68
- report('Starting application on remote...');
69
- const port = await this.startApplication(connection, platform, applicationDirectory, remoteNodeDirectory);
70
- connection.remotePort = port;
71
- }
72
- async startApplication(connection, platform, remotePath, nodeDir) {
73
- const nodeExecutable = this.scriptService.joinPath(platform, nodeDir, ...(platform.os === core_1.OS.Type.Windows ? ['node.exe'] : ['bin', 'node']));
74
- const mainJsFile = this.scriptService.joinPath(platform, remotePath, 'lib', 'backend', 'main.js');
75
- const localAddressRegex = /listening on http:\/\/127.0.0.1:(\d+)/;
76
- let prefix = '';
77
- if (platform.os === core_1.OS.Type.Windows) {
78
- // We might to switch to PowerShell beforehand on Windows
79
- prefix = this.scriptService.exec(platform) + ' ';
80
- }
81
- // Change to the remote application path and start a node process with the copied main.js file
82
- // This way, our current working directory is set as expected
83
- const result = await connection.execPartial(`${prefix}cd "${remotePath}";${nodeExecutable}`, stdout => localAddressRegex.test(stdout), [mainJsFile, '--hostname=127.0.0.1', '--port=0', '--remote']);
84
- const match = localAddressRegex.exec(result.stdout);
85
- if (!match) {
86
- throw new Error('Could not start remote system: ' + result.stdout);
87
- }
88
- else {
89
- return Number(match[1]);
90
- }
91
- }
92
- async detectRemotePlatform(connection) {
93
- const osResult = await connection.exec('uname -s');
94
- let os;
95
- if (osResult.stderr) {
96
- // Only Windows systems return an error stream here
97
- os = core_1.OS.Type.Windows;
98
- }
99
- else if (osResult.stdout) {
100
- if (osResult.stdout.includes('windows32') || osResult.stdout.includes('MINGW64')) {
101
- os = core_1.OS.Type.Windows;
102
- }
103
- else if (osResult.stdout.includes('Linux')) {
104
- os = core_1.OS.Type.Linux;
105
- }
106
- else if (osResult.stdout.includes('Darwin')) {
107
- os = core_1.OS.Type.OSX;
108
- }
109
- }
110
- if (!os) {
111
- throw new Error('Failed to identify remote system: ' + osResult.stdout + '\n' + osResult.stderr);
112
- }
113
- let arch;
114
- if (os === core_1.OS.Type.Windows) {
115
- const wmicResult = await connection.exec('wmic OS get OSArchitecture');
116
- if (wmicResult.stdout.includes('64-bit')) {
117
- arch = 'x64';
118
- }
119
- else if (wmicResult.stdout.includes('32-bit')) {
120
- arch = 'x86';
121
- }
122
- }
123
- else {
124
- const archResult = (await connection.exec('uname -m')).stdout;
125
- if (archResult.includes('x86_64')) {
126
- arch = 'x64';
127
- }
128
- else if (archResult.match(/i\d83/)) { // i386, i483, i683
129
- arch = 'x86';
130
- }
131
- else {
132
- arch = archResult.trim();
133
- }
134
- }
135
- if (!arch) {
136
- throw new Error('Could not identify remote system architecture');
137
- }
138
- return {
139
- os,
140
- arch
141
- };
142
- }
143
- async getRemoteHomeDirectory(connection, platform) {
144
- const result = await connection.exec(this.scriptService.home(platform));
145
- return result.stdout.trim();
146
- }
147
- getRemoteAppName() {
148
- const appName = this.applicationPackage.pck.name || 'theia';
149
- const appVersion = this.applicationPackage.pck.version || core_1.THEIA_VERSION;
150
- return `${this.cleanupDirectoryName(`${appName}-${appVersion}`)}-remote`;
151
- }
152
- cleanupDirectoryName(name) {
153
- return name.replace(/[@<>:"\\|?*]/g, '').replace(/\//g, '-');
154
- }
155
- async mkdirRemote(connection, platform, remotePath) {
156
- const result = await connection.exec(this.scriptService.mkdir(platform, remotePath));
157
- if (result.stderr) {
158
- throw new Error('Failed to create directory: ' + result.stderr);
159
- }
160
- }
161
- async dirExistsRemote(connection, remotePath) {
162
- const cdResult = await connection.exec(`cd "${remotePath}"`);
163
- return !Boolean(cdResult.stderr);
164
- }
165
- async unzipRemote(connection, platform, remoteFile, remoteDirectory) {
166
- const result = await connection.exec(this.scriptService.unzip(platform, remoteFile, remoteDirectory));
167
- if (result.stderr) {
168
- throw new Error('Failed to unzip: ' + result.stderr);
169
- }
170
- }
171
- async executeScriptRemote(connection, platform, script) {
172
- return connection.exec(this.scriptService.exec(platform), [script]);
173
- }
174
- };
175
- __decorate([
176
- (0, inversify_1.inject)(remote_copy_service_1.RemoteCopyService),
177
- __metadata("design:type", remote_copy_service_1.RemoteCopyService)
178
- ], RemoteSetupService.prototype, "copyService", void 0);
179
- __decorate([
180
- (0, inversify_1.inject)(remote_native_dependency_service_1.RemoteNativeDependencyService),
181
- __metadata("design:type", remote_native_dependency_service_1.RemoteNativeDependencyService)
182
- ], RemoteSetupService.prototype, "nativeDependencyService", void 0);
183
- __decorate([
184
- (0, inversify_1.inject)(remote_node_setup_service_1.RemoteNodeSetupService),
185
- __metadata("design:type", remote_node_setup_service_1.RemoteNodeSetupService)
186
- ], RemoteSetupService.prototype, "nodeSetupService", void 0);
187
- __decorate([
188
- (0, inversify_1.inject)(remote_setup_script_service_1.RemoteSetupScriptService),
189
- __metadata("design:type", remote_setup_script_service_1.RemoteSetupScriptService)
190
- ], RemoteSetupService.prototype, "scriptService", void 0);
191
- __decorate([
192
- (0, inversify_1.inject)(application_package_1.ApplicationPackage),
193
- __metadata("design:type", application_package_1.ApplicationPackage)
194
- ], RemoteSetupService.prototype, "applicationPackage", void 0);
195
- RemoteSetupService = __decorate([
196
- (0, inversify_1.injectable)()
197
- ], RemoteSetupService);
198
- exports.RemoteSetupService = RemoteSetupService;
1
+ "use strict";
2
+ // *****************************************************************************
3
+ // Copyright (C) 2023 TypeFox and others.
4
+ //
5
+ // This program and the accompanying materials are made available under the
6
+ // terms of the Eclipse Public License v. 2.0 which is available at
7
+ // http://www.eclipse.org/legal/epl-2.0.
8
+ //
9
+ // This Source Code may also be made available under the following Secondary
10
+ // Licenses when the conditions for such availability set forth in the Eclipse
11
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
12
+ // with the GNU Classpath Exception which is available at
13
+ // https://www.gnu.org/software/classpath/license.html.
14
+ //
15
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
16
+ // *****************************************************************************
17
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
18
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
19
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
20
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
21
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
22
+ };
23
+ var __metadata = (this && this.__metadata) || function (k, v) {
24
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
25
+ };
26
+ Object.defineProperty(exports, "__esModule", { value: true });
27
+ exports.RemoteSetupService = void 0;
28
+ const inversify_1 = require("@theia/core/shared/inversify");
29
+ const application_package_1 = require("@theia/core/shared/@theia/application-package");
30
+ const remote_copy_service_1 = require("./remote-copy-service");
31
+ const remote_native_dependency_service_1 = require("./remote-native-dependency-service");
32
+ const core_1 = require("@theia/core");
33
+ const remote_node_setup_service_1 = require("./remote-node-setup-service");
34
+ const remote_setup_script_service_1 = require("./remote-setup-script-service");
35
+ let RemoteSetupService = class RemoteSetupService {
36
+ async setup(options) {
37
+ const { connection, report, nodeDownloadTemplate } = options;
38
+ report('Identifying remote system...');
39
+ // 1. Identify remote platform
40
+ const platform = await this.detectRemotePlatform(connection);
41
+ // 2. Setup home directory
42
+ const remoteHome = await this.getRemoteHomeDirectory(connection, platform);
43
+ const applicationDirectory = this.scriptService.joinPath(platform, remoteHome, `.${this.getRemoteAppName()}`);
44
+ await this.mkdirRemote(connection, platform, applicationDirectory);
45
+ // 3. Download+copy node for that platform
46
+ const nodeFileName = this.nodeSetupService.getNodeFileName(platform);
47
+ const nodeDirName = this.nodeSetupService.getNodeDirectoryName(platform);
48
+ const remoteNodeDirectory = this.scriptService.joinPath(platform, applicationDirectory, nodeDirName);
49
+ const nodeDirExists = await this.dirExistsRemote(connection, remoteNodeDirectory);
50
+ if (!nodeDirExists) {
51
+ report('Downloading and installing Node.js on remote...');
52
+ // Download the binaries locally and move it via SSH
53
+ const nodeArchive = await this.nodeSetupService.downloadNode(platform, nodeDownloadTemplate);
54
+ const remoteNodeZip = this.scriptService.joinPath(platform, applicationDirectory, nodeFileName);
55
+ await connection.copy(nodeArchive, remoteNodeZip);
56
+ await this.unzipRemote(connection, platform, remoteNodeZip, applicationDirectory);
57
+ }
58
+ // 4. Copy backend to remote system
59
+ const libDir = this.scriptService.joinPath(platform, applicationDirectory, 'lib');
60
+ const libDirExists = await this.dirExistsRemote(connection, libDir);
61
+ if (!libDirExists) {
62
+ report('Installing application on remote...');
63
+ const applicationZipFile = this.scriptService.joinPath(platform, applicationDirectory, `${this.getRemoteAppName()}.tar`);
64
+ await this.copyService.copyToRemote(connection, platform, applicationZipFile);
65
+ await this.unzipRemote(connection, platform, applicationZipFile, applicationDirectory);
66
+ }
67
+ // 5. start remote backend
68
+ report('Starting application on remote...');
69
+ const port = await this.startApplication(connection, platform, applicationDirectory, remoteNodeDirectory);
70
+ connection.remotePort = port;
71
+ }
72
+ async startApplication(connection, platform, remotePath, nodeDir) {
73
+ const nodeExecutable = this.scriptService.joinPath(platform, nodeDir, ...(platform.os === core_1.OS.Type.Windows ? ['node.exe'] : ['bin', 'node']));
74
+ const mainJsFile = this.scriptService.joinPath(platform, remotePath, 'lib', 'backend', 'main.js');
75
+ const localAddressRegex = /listening on http:\/\/127.0.0.1:(\d+)/;
76
+ let prefix = '';
77
+ if (platform.os === core_1.OS.Type.Windows) {
78
+ // We might to switch to PowerShell beforehand on Windows
79
+ prefix = this.scriptService.exec(platform) + ' ';
80
+ }
81
+ // Change to the remote application path and start a node process with the copied main.js file
82
+ // This way, our current working directory is set as expected
83
+ const result = await connection.execPartial(`${prefix}cd "${remotePath}";${nodeExecutable}`, stdout => localAddressRegex.test(stdout), [mainJsFile, '--hostname=127.0.0.1', '--port=0', '--remote']);
84
+ const match = localAddressRegex.exec(result.stdout);
85
+ if (!match) {
86
+ throw new Error('Could not start remote system: ' + result.stdout);
87
+ }
88
+ else {
89
+ return Number(match[1]);
90
+ }
91
+ }
92
+ async detectRemotePlatform(connection) {
93
+ const osResult = await connection.exec('uname -s');
94
+ let os;
95
+ if (osResult.stderr) {
96
+ // Only Windows systems return an error stream here
97
+ os = core_1.OS.Type.Windows;
98
+ }
99
+ else if (osResult.stdout) {
100
+ if (osResult.stdout.includes('windows32') || osResult.stdout.includes('MINGW64')) {
101
+ os = core_1.OS.Type.Windows;
102
+ }
103
+ else if (osResult.stdout.includes('Linux')) {
104
+ os = core_1.OS.Type.Linux;
105
+ }
106
+ else if (osResult.stdout.includes('Darwin')) {
107
+ os = core_1.OS.Type.OSX;
108
+ }
109
+ }
110
+ if (!os) {
111
+ throw new Error('Failed to identify remote system: ' + osResult.stdout + '\n' + osResult.stderr);
112
+ }
113
+ let arch;
114
+ if (os === core_1.OS.Type.Windows) {
115
+ const wmicResult = await connection.exec('wmic OS get OSArchitecture');
116
+ if (wmicResult.stdout.includes('64-bit')) {
117
+ arch = 'x64';
118
+ }
119
+ else if (wmicResult.stdout.includes('32-bit')) {
120
+ arch = 'x86';
121
+ }
122
+ }
123
+ else {
124
+ const archResult = (await connection.exec('uname -m')).stdout;
125
+ if (archResult.includes('x86_64')) {
126
+ arch = 'x64';
127
+ }
128
+ else if (archResult.match(/i\d83/)) { // i386, i483, i683
129
+ arch = 'x86';
130
+ }
131
+ else {
132
+ arch = archResult.trim();
133
+ }
134
+ }
135
+ if (!arch) {
136
+ throw new Error('Could not identify remote system architecture');
137
+ }
138
+ return {
139
+ os,
140
+ arch
141
+ };
142
+ }
143
+ async getRemoteHomeDirectory(connection, platform) {
144
+ const result = await connection.exec(this.scriptService.home(platform));
145
+ return result.stdout.trim();
146
+ }
147
+ getRemoteAppName() {
148
+ const appName = this.applicationPackage.pck.name || 'theia';
149
+ const appVersion = this.applicationPackage.pck.version || core_1.THEIA_VERSION;
150
+ return `${this.cleanupDirectoryName(`${appName}-${appVersion}`)}-remote`;
151
+ }
152
+ cleanupDirectoryName(name) {
153
+ return name.replace(/[@<>:"\\|?*]/g, '').replace(/\//g, '-');
154
+ }
155
+ async mkdirRemote(connection, platform, remotePath) {
156
+ const result = await connection.exec(this.scriptService.mkdir(platform, remotePath));
157
+ if (result.stderr) {
158
+ throw new Error('Failed to create directory: ' + result.stderr);
159
+ }
160
+ }
161
+ async dirExistsRemote(connection, remotePath) {
162
+ const cdResult = await connection.exec(`cd "${remotePath}"`);
163
+ return !Boolean(cdResult.stderr);
164
+ }
165
+ async unzipRemote(connection, platform, remoteFile, remoteDirectory) {
166
+ const result = await connection.exec(this.scriptService.unzip(platform, remoteFile, remoteDirectory));
167
+ if (result.stderr) {
168
+ throw new Error('Failed to unzip: ' + result.stderr);
169
+ }
170
+ }
171
+ async executeScriptRemote(connection, platform, script) {
172
+ return connection.exec(this.scriptService.exec(platform), [script]);
173
+ }
174
+ };
175
+ __decorate([
176
+ (0, inversify_1.inject)(remote_copy_service_1.RemoteCopyService),
177
+ __metadata("design:type", remote_copy_service_1.RemoteCopyService)
178
+ ], RemoteSetupService.prototype, "copyService", void 0);
179
+ __decorate([
180
+ (0, inversify_1.inject)(remote_native_dependency_service_1.RemoteNativeDependencyService),
181
+ __metadata("design:type", remote_native_dependency_service_1.RemoteNativeDependencyService)
182
+ ], RemoteSetupService.prototype, "nativeDependencyService", void 0);
183
+ __decorate([
184
+ (0, inversify_1.inject)(remote_node_setup_service_1.RemoteNodeSetupService),
185
+ __metadata("design:type", remote_node_setup_service_1.RemoteNodeSetupService)
186
+ ], RemoteSetupService.prototype, "nodeSetupService", void 0);
187
+ __decorate([
188
+ (0, inversify_1.inject)(remote_setup_script_service_1.RemoteSetupScriptService),
189
+ __metadata("design:type", remote_setup_script_service_1.RemoteSetupScriptService)
190
+ ], RemoteSetupService.prototype, "scriptService", void 0);
191
+ __decorate([
192
+ (0, inversify_1.inject)(application_package_1.ApplicationPackage),
193
+ __metadata("design:type", application_package_1.ApplicationPackage)
194
+ ], RemoteSetupService.prototype, "applicationPackage", void 0);
195
+ RemoteSetupService = __decorate([
196
+ (0, inversify_1.injectable)()
197
+ ], RemoteSetupService);
198
+ exports.RemoteSetupService = RemoteSetupService;
199
199
  //# sourceMappingURL=remote-setup-service.js.map
@@ -1,56 +1,56 @@
1
- /// <reference types="node" />
2
- import * as ssh2 from 'ssh2';
3
- import * as net from 'net';
4
- import SftpClient = require('ssh2-sftp-client');
5
- import { Event, MessageService, QuickInputService } from '@theia/core';
6
- import { RemoteSSHConnectionProvider, RemoteSSHConnectionProviderOptions } from '../../electron-common/remote-ssh-connection-provider';
7
- import { RemoteConnectionService } from '../remote-connection-service';
8
- import { RemoteProxyServerProvider } from '../remote-proxy-server-provider';
9
- import { RemoteConnection, RemoteExecOptions, RemoteExecResult, RemoteExecTester } from '../remote-types';
10
- import { SSHIdentityFileCollector, SSHKey } from './ssh-identity-file-collector';
11
- import { RemoteSetupService } from '../setup/remote-setup-service';
12
- export declare class RemoteSSHConnectionProviderImpl implements RemoteSSHConnectionProvider {
13
- protected readonly remoteConnectionService: RemoteConnectionService;
14
- protected readonly serverProvider: RemoteProxyServerProvider;
15
- protected readonly identityFileCollector: SSHIdentityFileCollector;
16
- protected readonly remoteSetup: RemoteSetupService;
17
- protected readonly quickInputService: QuickInputService;
18
- protected readonly messageService: MessageService;
19
- protected passwordRetryCount: number;
20
- protected passphraseRetryCount: number;
21
- establishConnection(options: RemoteSSHConnectionProviderOptions): Promise<string>;
22
- establishSSHConnection(host: string, user: string): Promise<RemoteSSHConnection>;
23
- /**
24
- * Sometimes, ssh2.exec will not execute and retrieve any data right after the `ready` event fired.
25
- * In this method, we just perform `echo hello` in a loop to ensure that the connection is really ready.
26
- * See also https://github.com/mscdex/ssh2/issues/48
27
- */
28
- protected testConnection(connection: RemoteSSHConnection): Promise<void>;
29
- protected getAuthHandler(user: string, host: string, identityKeys: SSHKey[]): ssh2.AuthHandlerMiddleware;
30
- }
31
- export interface RemoteSSHConnectionOptions {
32
- id: string;
33
- name: string;
34
- type: string;
35
- client: ssh2.Client;
36
- }
37
- export declare class RemoteSSHConnection implements RemoteConnection {
38
- id: string;
39
- name: string;
40
- type: string;
41
- client: ssh2.Client;
42
- localPort: number;
43
- remotePort: number;
44
- private sftpClientPromise;
45
- private readonly onDidDisconnectEmitter;
46
- get onDidDisconnect(): Event<void>;
47
- constructor(options: RemoteSSHConnectionOptions);
48
- protected setupSftpClient(): Promise<SftpClient>;
49
- forwardOut(socket: net.Socket): void;
50
- copy(localPath: string, remotePath: string): Promise<void>;
51
- exec(cmd: string, args?: string[], options?: RemoteExecOptions): Promise<RemoteExecResult>;
52
- execPartial(cmd: string, tester: RemoteExecTester, args?: string[], options?: RemoteExecOptions): Promise<RemoteExecResult>;
53
- protected buildCmd(cmd: string, args?: string[]): string;
54
- dispose(): void;
55
- }
1
+ /// <reference types="node" />
2
+ import * as ssh2 from 'ssh2';
3
+ import * as net from 'net';
4
+ import SftpClient = require('ssh2-sftp-client');
5
+ import { Event, MessageService, QuickInputService } from '@theia/core';
6
+ import { RemoteSSHConnectionProvider, RemoteSSHConnectionProviderOptions } from '../../electron-common/remote-ssh-connection-provider';
7
+ import { RemoteConnectionService } from '../remote-connection-service';
8
+ import { RemoteProxyServerProvider } from '../remote-proxy-server-provider';
9
+ import { RemoteConnection, RemoteExecOptions, RemoteExecResult, RemoteExecTester } from '../remote-types';
10
+ import { SSHIdentityFileCollector, SSHKey } from './ssh-identity-file-collector';
11
+ import { RemoteSetupService } from '../setup/remote-setup-service';
12
+ export declare class RemoteSSHConnectionProviderImpl implements RemoteSSHConnectionProvider {
13
+ protected readonly remoteConnectionService: RemoteConnectionService;
14
+ protected readonly serverProvider: RemoteProxyServerProvider;
15
+ protected readonly identityFileCollector: SSHIdentityFileCollector;
16
+ protected readonly remoteSetup: RemoteSetupService;
17
+ protected readonly quickInputService: QuickInputService;
18
+ protected readonly messageService: MessageService;
19
+ protected passwordRetryCount: number;
20
+ protected passphraseRetryCount: number;
21
+ establishConnection(options: RemoteSSHConnectionProviderOptions): Promise<string>;
22
+ establishSSHConnection(host: string, user: string): Promise<RemoteSSHConnection>;
23
+ /**
24
+ * Sometimes, ssh2.exec will not execute and retrieve any data right after the `ready` event fired.
25
+ * In this method, we just perform `echo hello` in a loop to ensure that the connection is really ready.
26
+ * See also https://github.com/mscdex/ssh2/issues/48
27
+ */
28
+ protected testConnection(connection: RemoteSSHConnection): Promise<void>;
29
+ protected getAuthHandler(user: string, host: string, identityKeys: SSHKey[]): ssh2.AuthHandlerMiddleware;
30
+ }
31
+ export interface RemoteSSHConnectionOptions {
32
+ id: string;
33
+ name: string;
34
+ type: string;
35
+ client: ssh2.Client;
36
+ }
37
+ export declare class RemoteSSHConnection implements RemoteConnection {
38
+ id: string;
39
+ name: string;
40
+ type: string;
41
+ client: ssh2.Client;
42
+ localPort: number;
43
+ remotePort: number;
44
+ private sftpClientPromise;
45
+ private readonly onDidDisconnectEmitter;
46
+ get onDidDisconnect(): Event<void>;
47
+ constructor(options: RemoteSSHConnectionOptions);
48
+ protected setupSftpClient(): Promise<SftpClient>;
49
+ forwardOut(socket: net.Socket): void;
50
+ copy(localPath: string, remotePath: string): Promise<void>;
51
+ exec(cmd: string, args?: string[], options?: RemoteExecOptions): Promise<RemoteExecResult>;
52
+ execPartial(cmd: string, tester: RemoteExecTester, args?: string[], options?: RemoteExecOptions): Promise<RemoteExecResult>;
53
+ protected buildCmd(cmd: string, args?: string[]): string;
54
+ dispose(): void;
55
+ }
56
56
  //# sourceMappingURL=remote-ssh-connection-provider.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"remote-ssh-connection-provider.d.ts","sourceRoot":"","sources":["../../../src/electron-node/ssh/remote-ssh-connection-provider.ts"],"names":[],"mappings":";AAgBA,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAE3B,OAAO,UAAU,GAAG,QAAQ,kBAAkB,CAAC,CAAC;AAChD,OAAO,EAAW,KAAK,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEhF,OAAO,EAAE,2BAA2B,EAAE,kCAAkC,EAAE,MAAM,sDAAsD,CAAC;AACvI,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAAE,yBAAyB,EAAE,MAAM,iCAAiC,CAAC;AAC5E,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,gBAAgB,EAAsB,MAAM,iBAAiB,CAAC;AAE9H,OAAO,EAAE,wBAAwB,EAAE,MAAM,EAAE,MAAM,+BAA+B,CAAC;AACjF,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAGnE,qBACa,+BAAgC,YAAW,2BAA2B;IAG/E,SAAS,CAAC,QAAQ,CAAC,uBAAuB,EAAE,uBAAuB,CAAC;IAGpE,SAAS,CAAC,QAAQ,CAAC,cAAc,EAAE,yBAAyB,CAAC;IAG7D,SAAS,CAAC,QAAQ,CAAC,qBAAqB,EAAE,w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