@theia/dev-container 1.67.0-next.56 → 1.67.0-next.86

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 (82) hide show
  1. package/lib/dev-container-server/dev-container-server.d.ts +2 -0
  2. package/lib/dev-container-server/dev-container-server.d.ts.map +1 -0
  3. package/lib/dev-container-server/dev-container-server.js +48 -0
  4. package/lib/dev-container-server/dev-container-server.js.map +1 -0
  5. package/lib/electron-browser/container-connection-contribution.d.ts +29 -0
  6. package/lib/electron-browser/container-connection-contribution.d.ts.map +1 -0
  7. package/lib/electron-browser/container-connection-contribution.js +156 -0
  8. package/lib/electron-browser/container-connection-contribution.js.map +1 -0
  9. package/lib/electron-browser/container-info-contribution.d.ts +20 -0
  10. package/lib/electron-browser/container-info-contribution.d.ts.map +1 -0
  11. package/lib/electron-browser/container-info-contribution.js +85 -0
  12. package/lib/electron-browser/container-info-contribution.js.map +1 -0
  13. package/lib/electron-browser/container-output-provider.d.ts +8 -0
  14. package/lib/electron-browser/container-output-provider.d.ts.map +1 -0
  15. package/lib/electron-browser/container-output-provider.js +41 -0
  16. package/lib/electron-browser/container-output-provider.js.map +1 -0
  17. package/lib/electron-browser/dev-container-frontend-module.d.ts +4 -0
  18. package/lib/electron-browser/dev-container-frontend-module.d.ts.map +1 -0
  19. package/lib/electron-browser/dev-container-frontend-module.js +42 -0
  20. package/lib/electron-browser/dev-container-frontend-module.js.map +1 -0
  21. package/lib/electron-common/container-output-provider.d.ts +4 -0
  22. package/lib/electron-common/container-output-provider.d.ts.map +1 -0
  23. package/lib/electron-common/container-output-provider.js +18 -0
  24. package/lib/electron-common/container-output-provider.js.map +1 -0
  25. package/lib/electron-common/dev-container-workspaces.d.ts +3 -0
  26. package/lib/electron-common/dev-container-workspaces.d.ts.map +1 -0
  27. package/lib/electron-common/dev-container-workspaces.js +21 -0
  28. package/lib/electron-common/dev-container-workspaces.js.map +1 -0
  29. package/lib/electron-common/remote-container-connection-provider.d.ts +30 -0
  30. package/lib/electron-common/remote-container-connection-provider.d.ts.map +1 -0
  31. package/lib/electron-common/remote-container-connection-provider.js +21 -0
  32. package/lib/electron-common/remote-container-connection-provider.js.map +1 -0
  33. package/lib/electron-node/dev-container-backend-module.d.ts +5 -0
  34. package/lib/electron-node/dev-container-backend-module.d.ts.map +1 -0
  35. package/lib/electron-node/dev-container-backend-module.js +63 -0
  36. package/lib/electron-node/dev-container-backend-module.js.map +1 -0
  37. package/lib/electron-node/dev-container-file-service.d.ts +15 -0
  38. package/lib/electron-node/dev-container-file-service.d.ts.map +1 -0
  39. package/lib/electron-node/dev-container-file-service.js +105 -0
  40. package/lib/electron-node/dev-container-file-service.js.map +1 -0
  41. package/lib/electron-node/dev-container-workspace-handler.d.ts +7 -0
  42. package/lib/electron-node/dev-container-workspace-handler.d.ts.map +1 -0
  43. package/lib/electron-node/dev-container-workspace-handler.js +21 -0
  44. package/lib/electron-node/dev-container-workspace-handler.js.map +1 -0
  45. package/lib/electron-node/devcontainer-contributions/cli-enhancing-creation-contributions.d.ts +17 -0
  46. package/lib/electron-node/devcontainer-contributions/cli-enhancing-creation-contributions.d.ts.map +1 -0
  47. package/lib/electron-node/devcontainer-contributions/cli-enhancing-creation-contributions.js +69 -0
  48. package/lib/electron-node/devcontainer-contributions/cli-enhancing-creation-contributions.js.map +1 -0
  49. package/lib/electron-node/devcontainer-contributions/main-container-creation-contributions.d.ts +41 -0
  50. package/lib/electron-node/devcontainer-contributions/main-container-creation-contributions.d.ts.map +1 -0
  51. package/lib/electron-node/devcontainer-contributions/main-container-creation-contributions.js +209 -0
  52. package/lib/electron-node/devcontainer-contributions/main-container-creation-contributions.js.map +1 -0
  53. package/lib/electron-node/devcontainer-contributions/profile-file-modification-contribution.d.ts +11 -0
  54. package/lib/electron-node/devcontainer-contributions/profile-file-modification-contribution.d.ts.map +1 -0
  55. package/lib/electron-node/devcontainer-contributions/profile-file-modification-contribution.js +37 -0
  56. package/lib/electron-node/devcontainer-contributions/profile-file-modification-contribution.js.map +1 -0
  57. package/lib/electron-node/devcontainer-contributions/variable-resolver-contribution.d.ts +18 -0
  58. package/lib/electron-node/devcontainer-contributions/variable-resolver-contribution.d.ts.map +1 -0
  59. package/lib/electron-node/devcontainer-contributions/variable-resolver-contribution.js +58 -0
  60. package/lib/electron-node/devcontainer-contributions/variable-resolver-contribution.js.map +1 -0
  61. package/lib/electron-node/devcontainer-file.d.ts +354 -0
  62. package/lib/electron-node/devcontainer-file.d.ts.map +1 -0
  63. package/lib/electron-node/devcontainer-file.js +18 -0
  64. package/lib/electron-node/devcontainer-file.js.map +1 -0
  65. package/lib/electron-node/docker-compose/compose-service.d.ts +9 -0
  66. package/lib/electron-node/docker-compose/compose-service.d.ts.map +1 -0
  67. package/lib/electron-node/docker-compose/compose-service.js +73 -0
  68. package/lib/electron-node/docker-compose/compose-service.js.map +1 -0
  69. package/lib/electron-node/docker-container-service.d.ts +32 -0
  70. package/lib/electron-node/docker-container-service.d.ts.map +1 -0
  71. package/lib/electron-node/docker-container-service.js +122 -0
  72. package/lib/electron-node/docker-container-service.js.map +1 -0
  73. package/lib/electron-node/remote-container-connection-provider.d.ts +88 -0
  74. package/lib/electron-node/remote-container-connection-provider.d.ts.map +1 -0
  75. package/lib/electron-node/remote-container-connection-provider.js +345 -0
  76. package/lib/electron-node/remote-container-connection-provider.js.map +1 -0
  77. package/lib/package.spec.d.ts +1 -0
  78. package/lib/package.spec.d.ts.map +1 -0
  79. package/lib/package.spec.js +26 -0
  80. package/lib/package.spec.js.map +1 -0
  81. package/package.json +6 -6
  82. package/src/electron-node/remote-container-connection-provider.ts +7 -4
@@ -0,0 +1,88 @@
1
+ /// <reference types="node" />
2
+ /// <reference types="node" />
3
+ /// <reference types="node" />
4
+ /// <reference types="node" />
5
+ /// <reference types="node" />
6
+ import { ContainerConnectionOptions, ContainerConnectionResult, DevContainerFile, RemoteContainerConnectionProvider } from '../electron-common/remote-container-connection-provider';
7
+ import { RemoteConnection, RemoteExecOptions, RemoteExecResult, RemoteExecTester } from '@theia/remote/lib/electron-node/remote-types';
8
+ import { RemoteSetupResult, RemoteSetupService } from '@theia/remote/lib/electron-node/setup/remote-setup-service';
9
+ import { RemoteConnectionService } from '@theia/remote/lib/electron-node/remote-connection-service';
10
+ import { RemoteProxyServerProvider } from '@theia/remote/lib/electron-node/remote-proxy-server-provider';
11
+ import { Emitter, Event, MessageService, RpcServer, ILogger } from '@theia/core';
12
+ import { Socket } from 'net';
13
+ import * as Docker from 'dockerode';
14
+ import { DockerContainerService } from './docker-container-service';
15
+ import { WriteStream } from 'tty';
16
+ import { DevContainerFileService } from './dev-container-file-service';
17
+ import { ContainerOutputProvider } from '../electron-common/container-output-provider';
18
+ import { DevContainerConfiguration } from './devcontainer-file';
19
+ export declare class DevContainerConnectionProvider implements RemoteContainerConnectionProvider, RpcServer<ContainerOutputProvider> {
20
+ protected readonly remoteConnectionService: RemoteConnectionService;
21
+ protected readonly remoteSetup: RemoteSetupService;
22
+ protected readonly messageService: MessageService;
23
+ protected readonly serverProvider: RemoteProxyServerProvider;
24
+ protected readonly containerService: DockerContainerService;
25
+ protected readonly devContainerFileService: DevContainerFileService;
26
+ protected readonly remoteService: RemoteConnectionService;
27
+ protected readonly logger: ILogger;
28
+ protected outputProvider: ContainerOutputProvider | undefined;
29
+ setClient(client: ContainerOutputProvider): void;
30
+ connectToContainer(options: ContainerConnectionOptions): Promise<ContainerConnectionResult>;
31
+ getDevContainerFiles(workspacePath: string): Promise<DevContainerFile[]>;
32
+ createContainerConnection(container: Docker.Container, docker: Docker, config: DevContainerConfiguration): Promise<RemoteDockerContainerConnection>;
33
+ getCurrentContainerInfo(port: number): Promise<Docker.ContainerInspectInfo | undefined>;
34
+ dispose(): void;
35
+ }
36
+ export interface RemoteContainerConnectionOptions {
37
+ id: string;
38
+ name: string;
39
+ type: string;
40
+ docker: Docker;
41
+ container: Docker.Container;
42
+ config: DevContainerConfiguration;
43
+ logger: ILogger;
44
+ }
45
+ interface ContainerTerminalSession {
46
+ execution: Docker.Exec;
47
+ stdout: WriteStream;
48
+ stderr: WriteStream;
49
+ executeCommand(cmd: string, args?: string[]): Promise<{
50
+ stdout: string;
51
+ stderr: string;
52
+ }>;
53
+ }
54
+ interface ContainerTerminalSession {
55
+ execution: Docker.Exec;
56
+ stdout: WriteStream;
57
+ stderr: WriteStream;
58
+ executeCommand(cmd: string, args?: string[]): Promise<{
59
+ stdout: string;
60
+ stderr: string;
61
+ }>;
62
+ }
63
+ export declare class RemoteDockerContainerConnection implements RemoteConnection {
64
+ id: string;
65
+ name: string;
66
+ type: string;
67
+ localPort: number;
68
+ remotePort: number;
69
+ docker: Docker;
70
+ container: Docker.Container;
71
+ remoteSetupResult: RemoteSetupResult;
72
+ protected readonly logger: ILogger;
73
+ protected config: DevContainerConfiguration;
74
+ protected activeTerminalSession: ContainerTerminalSession | undefined;
75
+ protected readonly onDidDisconnectEmitter: Emitter<void>;
76
+ onDidDisconnect: Event<void>;
77
+ constructor(options: RemoteContainerConnectionOptions);
78
+ forwardOut(socket: Socket, port?: number): Promise<void>;
79
+ exec(cmd: string, args?: string[], options?: RemoteExecOptions): Promise<RemoteExecResult>;
80
+ execPartial(cmd: string, tester: RemoteExecTester, args?: string[], options?: RemoteExecOptions): Promise<RemoteExecResult>;
81
+ getDockerHost(): string;
82
+ copy(localPath: string | Buffer | NodeJS.ReadableStream, remotePath: string): Promise<void>;
83
+ disposeSync(): void;
84
+ dispose(): Promise<void>;
85
+ protected shutdownContainer(sync: boolean): Promise<unknown>;
86
+ }
87
+ export {};
88
+ //# sourceMappingURL=remote-container-connection-provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remote-container-connection-provider.d.ts","sourceRoot":"","sources":["../../src/electron-node/remote-container-connection-provider.ts"],"names":[],"mappings":";;;;;AAiBA,OAAO,EACH,0BAA0B,EAAE,yBAAyB,EACrD,gBAAgB,EAAE,iCAAiC,EACtD,MAAM,yDAAyD,CAAC;AACjE,OAAO,EAAE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MAAM,CAAC,cAAc,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAoBjG,WAAW,IAAI,IAAI;IAKb,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;cAId,iBAAiB,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;CAsBrE"}
@@ -0,0 +1,345 @@
1
+ "use strict";
2
+ // *****************************************************************************
3
+ // Copyright (C) 2024 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
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.RemoteDockerContainerConnection = exports.DevContainerConnectionProvider = void 0;
19
+ const tslib_1 = require("tslib");
20
+ const remote_setup_service_1 = require("@theia/remote/lib/electron-node/setup/remote-setup-service");
21
+ const remote_connection_service_1 = require("@theia/remote/lib/electron-node/remote-connection-service");
22
+ const remote_proxy_server_provider_1 = require("@theia/remote/lib/electron-node/remote-proxy-server-provider");
23
+ const core_1 = require("@theia/core");
24
+ const inversify_1 = require("@theia/core/shared/inversify");
25
+ const Docker = require("dockerode");
26
+ const docker_container_service_1 = require("./docker-container-service");
27
+ const promise_util_1 = require("@theia/core/lib/common/promise-util");
28
+ const stream_1 = require("stream");
29
+ const child_process_1 = require("child_process");
30
+ const dev_container_file_service_1 = require("./dev-container-file-service");
31
+ const compose_service_1 = require("./docker-compose/compose-service");
32
+ let DevContainerConnectionProvider = class DevContainerConnectionProvider {
33
+ setClient(client) {
34
+ this.outputProvider = client;
35
+ }
36
+ async connectToContainer(options) {
37
+ const dockerOptions = {};
38
+ const dockerHost = process.env.DOCKER_HOST;
39
+ try {
40
+ if (dockerHost) {
41
+ const dockerHostURL = new URL(dockerHost);
42
+ if (dockerHostURL.protocol === 'unix:') {
43
+ dockerOptions.socketPath = dockerHostURL.pathname;
44
+ }
45
+ else {
46
+ if (dockerHostURL.protocol === 'http:') {
47
+ dockerOptions.protocol = 'http';
48
+ }
49
+ else if (dockerHostURL.protocol === 'https:') {
50
+ dockerOptions.protocol = 'https';
51
+ }
52
+ else if (dockerHostURL.protocol === 'ssh:') {
53
+ dockerOptions.protocol = 'ssh';
54
+ }
55
+ else {
56
+ dockerOptions.protocol = undefined;
57
+ }
58
+ dockerOptions.port = parseInt(dockerHostURL.port) || undefined;
59
+ dockerOptions.username = dockerHostURL.username || undefined;
60
+ }
61
+ }
62
+ }
63
+ catch (_) {
64
+ this.logger.warn(`Ignoring invalid DOCKER_HOST=${dockerHost}`);
65
+ this.messageService.warn(`Ignoring invalid DOCKER_HOST=${dockerHost}`);
66
+ }
67
+ const dockerConnection = new Docker(dockerOptions);
68
+ const version = await dockerConnection.version()
69
+ .catch(e => {
70
+ console.error('Docker Error:', e);
71
+ this.messageService.error('Docker Error: ' + e.message);
72
+ });
73
+ if (!version) {
74
+ this.messageService.error('Docker Daemon is not running');
75
+ throw new Error('Docker is not running');
76
+ }
77
+ // create container
78
+ const progress = await this.messageService.showProgress({
79
+ text: 'Creating container',
80
+ });
81
+ try {
82
+ const container = await this.containerService.getOrCreateContainer(dockerConnection, options, this.outputProvider);
83
+ const devContainerConfig = await this.devContainerFileService.getConfiguration(options.devcontainerFile);
84
+ // create actual connection
85
+ const report = message => progress.report({ message });
86
+ report('Connecting to remote system...');
87
+ const remote = await this.createContainerConnection(container, dockerConnection, devContainerConfig);
88
+ const result = await this.remoteSetup.setup({
89
+ connection: remote,
90
+ report,
91
+ nodeDownloadTemplate: options.nodeDownloadTemplate
92
+ });
93
+ remote.remoteSetupResult = result;
94
+ const registration = this.remoteConnectionService.register(remote);
95
+ const server = await this.serverProvider.getProxyServer(socket => {
96
+ remote.forwardOut(socket);
97
+ });
98
+ remote.onDidDisconnect(() => {
99
+ server.close();
100
+ registration.dispose();
101
+ });
102
+ const localPort = server.address().port;
103
+ remote.localPort = localPort;
104
+ await this.containerService.postConnect(options.devcontainerFile, remote, this.outputProvider);
105
+ return {
106
+ containerId: container.id,
107
+ workspacePath: (await container.inspect()).Mounts[0].Destination,
108
+ port: localPort.toString(),
109
+ };
110
+ }
111
+ catch (e) {
112
+ this.messageService.error(e.message);
113
+ console.error(e);
114
+ throw e;
115
+ }
116
+ finally {
117
+ progress.cancel();
118
+ }
119
+ }
120
+ getDevContainerFiles(workspacePath) {
121
+ return this.devContainerFileService.getAvailableFiles(workspacePath);
122
+ }
123
+ async createContainerConnection(container, docker, config) {
124
+ var _a;
125
+ return Promise.resolve(new RemoteDockerContainerConnection({
126
+ id: (0, core_1.generateUuid)(),
127
+ name: (_a = config.name) !== null && _a !== void 0 ? _a : 'dev-container',
128
+ type: 'Dev Container',
129
+ docker,
130
+ container,
131
+ config,
132
+ logger: this.logger
133
+ }));
134
+ }
135
+ async getCurrentContainerInfo(port) {
136
+ const connection = this.remoteConnectionService.getConnectionFromPort(port);
137
+ if (!connection || !(connection instanceof RemoteDockerContainerConnection)) {
138
+ return undefined;
139
+ }
140
+ return connection.container.inspect();
141
+ }
142
+ dispose() {
143
+ }
144
+ };
145
+ exports.DevContainerConnectionProvider = DevContainerConnectionProvider;
146
+ tslib_1.__decorate([
147
+ (0, inversify_1.inject)(remote_connection_service_1.RemoteConnectionService),
148
+ tslib_1.__metadata("design:type", remote_connection_service_1.RemoteConnectionService)
149
+ ], DevContainerConnectionProvider.prototype, "remoteConnectionService", void 0);
150
+ tslib_1.__decorate([
151
+ (0, inversify_1.inject)(remote_setup_service_1.RemoteSetupService),
152
+ tslib_1.__metadata("design:type", remote_setup_service_1.RemoteSetupService)
153
+ ], DevContainerConnectionProvider.prototype, "remoteSetup", void 0);
154
+ tslib_1.__decorate([
155
+ (0, inversify_1.inject)(core_1.MessageService),
156
+ tslib_1.__metadata("design:type", core_1.MessageService)
157
+ ], DevContainerConnectionProvider.prototype, "messageService", void 0);
158
+ tslib_1.__decorate([
159
+ (0, inversify_1.inject)(remote_proxy_server_provider_1.RemoteProxyServerProvider),
160
+ tslib_1.__metadata("design:type", remote_proxy_server_provider_1.RemoteProxyServerProvider)
161
+ ], DevContainerConnectionProvider.prototype, "serverProvider", void 0);
162
+ tslib_1.__decorate([
163
+ (0, inversify_1.inject)(docker_container_service_1.DockerContainerService),
164
+ tslib_1.__metadata("design:type", docker_container_service_1.DockerContainerService)
165
+ ], DevContainerConnectionProvider.prototype, "containerService", void 0);
166
+ tslib_1.__decorate([
167
+ (0, inversify_1.inject)(dev_container_file_service_1.DevContainerFileService),
168
+ tslib_1.__metadata("design:type", dev_container_file_service_1.DevContainerFileService)
169
+ ], DevContainerConnectionProvider.prototype, "devContainerFileService", void 0);
170
+ tslib_1.__decorate([
171
+ (0, inversify_1.inject)(remote_connection_service_1.RemoteConnectionService),
172
+ tslib_1.__metadata("design:type", remote_connection_service_1.RemoteConnectionService)
173
+ ], DevContainerConnectionProvider.prototype, "remoteService", void 0);
174
+ tslib_1.__decorate([
175
+ (0, inversify_1.inject)(core_1.ILogger),
176
+ tslib_1.__metadata("design:type", Object)
177
+ ], DevContainerConnectionProvider.prototype, "logger", void 0);
178
+ exports.DevContainerConnectionProvider = DevContainerConnectionProvider = tslib_1.__decorate([
179
+ (0, inversify_1.injectable)()
180
+ ], DevContainerConnectionProvider);
181
+ class RemoteDockerContainerConnection {
182
+ constructor(options) {
183
+ this.onDidDisconnectEmitter = new core_1.Emitter();
184
+ this.onDidDisconnect = this.onDidDisconnectEmitter.event;
185
+ this.id = options.id;
186
+ this.type = options.type;
187
+ this.name = options.name;
188
+ this.docker = options.docker;
189
+ this.container = options.container;
190
+ this.config = options.config;
191
+ this.docker.getEvents({ filters: { container: [this.container.id], event: ['stop'] } }).then(stream => {
192
+ stream.on('data', () => this.onDidDisconnectEmitter.fire());
193
+ });
194
+ this.logger = options.logger;
195
+ }
196
+ async forwardOut(socket, port) {
197
+ const node = `${this.remoteSetupResult.nodeDirectory}/bin/node`;
198
+ const devContainerServer = `${this.remoteSetupResult.applicationDirectory}/backend/dev-container-server.js`;
199
+ try {
200
+ const ttySession = await this.container.exec({
201
+ Cmd: ['sh', '-c', `${node} ${devContainerServer} -target-port=${port !== null && port !== void 0 ? port : this.remotePort}`],
202
+ AttachStdin: true, AttachStdout: true, AttachStderr: true
203
+ });
204
+ const stream = await ttySession.start({ hijack: true, stdin: true });
205
+ socket.pipe(stream);
206
+ ttySession.modem.demuxStream(stream, socket, socket);
207
+ }
208
+ catch (e) {
209
+ console.error(e);
210
+ }
211
+ }
212
+ async exec(cmd, args, options) {
213
+ var _a;
214
+ // return (await this.getOrCreateTerminalSession()).executeCommand(cmd, args);
215
+ const deferred = new promise_util_1.Deferred();
216
+ try {
217
+ // TODO add windows container support
218
+ const execution = await this.container.exec({ Cmd: ['sh', '-c', `${cmd} ${(_a = args === null || args === void 0 ? void 0 : args.join(' ')) !== null && _a !== void 0 ? _a : ''}`], AttachStdout: true, AttachStderr: true });
219
+ let stdoutBuffer = '';
220
+ let stderrBuffer = '';
221
+ const stream = await (execution === null || execution === void 0 ? void 0 : execution.start({}));
222
+ const stdout = new stream_1.PassThrough();
223
+ stdout.on('data', (chunk) => {
224
+ stdoutBuffer += chunk.toString();
225
+ });
226
+ const stderr = new stream_1.PassThrough();
227
+ stderr.on('data', (chunk) => {
228
+ stderrBuffer += chunk.toString();
229
+ });
230
+ execution.modem.demuxStream(stream, stdout, stderr);
231
+ stream === null || stream === void 0 ? void 0 : stream.addListener('close', () => deferred.resolve({ stdout: stdoutBuffer, stderr: stderrBuffer }));
232
+ }
233
+ catch (e) {
234
+ deferred.reject(e);
235
+ }
236
+ return deferred.promise;
237
+ }
238
+ async execPartial(cmd, tester, args, options) {
239
+ var _a;
240
+ const deferred = new promise_util_1.Deferred();
241
+ try {
242
+ // TODO add windows container support
243
+ const execution = await this.container.exec({ Cmd: ['sh', '-c', `${cmd} ${(_a = args === null || args === void 0 ? void 0 : args.join(' ')) !== null && _a !== void 0 ? _a : ''}`], AttachStdout: true, AttachStderr: true });
244
+ let stdoutBuffer = '';
245
+ let stderrBuffer = '';
246
+ const stream = await (execution === null || execution === void 0 ? void 0 : execution.start({}));
247
+ stream.on('close', () => {
248
+ if (deferred.state === 'unresolved') {
249
+ deferred.resolve({ stdout: stdoutBuffer, stderr: stderrBuffer });
250
+ }
251
+ });
252
+ const stdout = new stream_1.PassThrough();
253
+ stdout.on('data', (data) => {
254
+ this.logger.debug('REMOTE STDOUT:', data.toString());
255
+ if (deferred.state === 'unresolved') {
256
+ stdoutBuffer += data.toString();
257
+ if (tester(stdoutBuffer, stderrBuffer)) {
258
+ deferred.resolve({ stdout: stdoutBuffer, stderr: stderrBuffer });
259
+ }
260
+ }
261
+ });
262
+ const stderr = new stream_1.PassThrough();
263
+ stderr.on('data', (data) => {
264
+ this.logger.debug('REMOTE STDERR:', data.toString());
265
+ if (deferred.state === 'unresolved') {
266
+ stderrBuffer += data.toString();
267
+ if (tester(stdoutBuffer, stderrBuffer)) {
268
+ deferred.resolve({ stdout: stdoutBuffer, stderr: stderrBuffer });
269
+ }
270
+ }
271
+ });
272
+ execution.modem.demuxStream(stream, stdout, stderr);
273
+ }
274
+ catch (e) {
275
+ deferred.reject(e);
276
+ }
277
+ return deferred.promise;
278
+ }
279
+ getDockerHost() {
280
+ const dockerHost = process.env.DOCKER_HOST;
281
+ let remoteHost = '';
282
+ try {
283
+ if (dockerHost) {
284
+ const dockerHostURL = new URL(dockerHost);
285
+ if (dockerHostURL.protocol === 'http:' || dockerHostURL.protocol === 'https:') {
286
+ dockerHostURL.protocol = 'tcp:';
287
+ }
288
+ remoteHost = `-H ${dockerHostURL.href} `;
289
+ }
290
+ }
291
+ catch (e) {
292
+ console.error(e);
293
+ }
294
+ return remoteHost;
295
+ }
296
+ async copy(localPath, remotePath) {
297
+ var _a;
298
+ const deferred = new promise_util_1.Deferred();
299
+ const remoteHost = this.getDockerHost();
300
+ const subprocess = (0, child_process_1.exec)(`docker ${remoteHost}cp -a ${localPath.toString()} ${this.container.id}:${remotePath}`);
301
+ let stderr = '';
302
+ (_a = subprocess.stderr) === null || _a === void 0 ? void 0 : _a.on('data', data => {
303
+ stderr += data.toString();
304
+ });
305
+ subprocess.on('close', code => {
306
+ if (code === 0) {
307
+ deferred.resolve();
308
+ }
309
+ else {
310
+ deferred.reject(stderr);
311
+ }
312
+ });
313
+ return deferred.promise;
314
+ }
315
+ disposeSync() {
316
+ // cant use dockerrode here since this needs to happen on one tick
317
+ this.shutdownContainer(true);
318
+ }
319
+ async dispose() {
320
+ await this.shutdownContainer(false);
321
+ }
322
+ async shutdownContainer(sync) {
323
+ var _a;
324
+ const remoteHost = this.getDockerHost();
325
+ const shutdownAction = ((_a = this.config.shutdownAction) !== null && _a !== void 0 ? _a : this.config.dockerComposeFile) ? 'stopCompose' : 'stopContainer';
326
+ if (shutdownAction === 'stopContainer') {
327
+ return sync ? (0, child_process_1.execSync)(`docker ${remoteHost}stop ${this.container.id}`) : this.container.stop();
328
+ }
329
+ else if (shutdownAction === 'stopCompose') {
330
+ const composeFilePath = (0, compose_service_1.resolveComposeFilePath)(this.config);
331
+ return sync ? (0, child_process_1.execSync)(`docker ${remoteHost}compose -f ${composeFilePath} stop`) :
332
+ new Promise((res, rej) => (0, child_process_1.exec)(`docker ${remoteHost}compose -f ${composeFilePath} stop`, err => {
333
+ if (err) {
334
+ console.error(err);
335
+ rej(err);
336
+ }
337
+ else {
338
+ res();
339
+ }
340
+ }));
341
+ }
342
+ }
343
+ }
344
+ exports.RemoteDockerContainerConnection = RemoteDockerContainerConnection;
345
+ //# sourceMappingURL=remote-container-connection-provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remote-container-connection-provider.js","sourceRoot":"","sources":["../../src/electron-node/remote-container-connection-provider.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,yCAAyC;AACzC,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,gFAAgF;AAChF,gFAAgF;;;;AAQhF,qGAAmH;AACnH,yGAAoG;AACpG,+GAAyG;AACzG,sCAA+F;AAE/F,4DAAkE;AAClE,oCAAoC;AACpC,yEAAoE;AACpE,sEAA+D;AAE/D,mCAAqC;AACrC,iDAA+C;AAC/C,6EAAuE;AAGvE,sEAA0E;AAGnE,IAAM,8BAA8B,GAApC,MAAM,8BAA8B;IA4BvC,SAAS,CAAC,MAA+B;QACrC,IAAI,CAAC,cAAc,GAAG,MAAM,CAAC;IACjC,CAAC;IAED,KAAK,CAAC,kBAAkB,CAAC,OAAmC;QACxD,MAAM,aAAa,GAAyB,EAAE,CAAC;QAC/C,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC;QAE3C,IAAI,CAAC;YACD,IAAI,UAAU,EAAE,CAAC;gBACb,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC,UAAU,CAAC,CAAC;gBAE1C,IAAI,aAAa,CAAC,QAAQ,KAAK,OAAO,EAAE,CAAC;oBACrC,aAAa,CAAC,UAAU,GAAG,aAAa,CAAC,QAAQ,CAAC;gBACtD,CAAC;qBAAM,CAAC;oBACJ,IAAI,aAAa,CAAC,QAAQ,KAAK,OAAO,EAAE,CAAC;wBACrC,aAAa,CAAC,QAAQ,GAAG,MAAM,CAAC;oBACpC,CAAC;yBAAM,IAAI,aAAa,CAAC,QAAQ,KAAK,QAAQ,EAAE,CAAC;wBAC7C,aAAa,CAAC,QAAQ,GAAG,OAAO,CAAC;oBACrC,CAAC;yBAAM,IAAI,aAAa,CAAC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C;wBACJ,GAAG,EAAE,CAAC;oBACV,CAAC;gBACL,CAAC,CAAC,CAAC,CAAC;QACZ,CAAC;IAEL,CAAC;CAEJ;AAjMD,0EAiMC"}
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=package.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"package.spec.d.ts","sourceRoot":"","sources":["../src/package.spec.ts"],"names":[],"mappings":""}
@@ -0,0 +1,26 @@
1
+ // *****************************************************************************
2
+ // Copyright (C) 2017 Ericsson 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
+ /* note: this bogus test file is required so that
17
+ we are able to run mocha unit tests on this
18
+ package, without having any actual unit tests in it.
19
+ This way a coverage report will be generated,
20
+ showing 0% coverage, instead of no report.
21
+ This file can be removed once we have real unit
22
+ tests in place. */
23
+ describe('dev-container package', () => {
24
+ it('support code coverage statistics', () => true);
25
+ });
26
+ //# sourceMappingURL=package.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"package.spec.js","sourceRoot":"","sources":["../src/package.spec.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,0CAA0C;AAC1C,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,gFAAgF;AAChF,gFAAgF;AAEhF;;;;;;qBAMqB;AAErB,QAAQ,CAAC,uBAAuB,EAAE,GAAG,EAAE;IAEnC,EAAE,CAAC,kCAAkC,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC;AACvD,CAAC,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@theia/dev-container",
3
- "version": "1.67.0-next.56+d8f18cc386c",
3
+ "version": "1.67.0-next.86+03f92ff1d",
4
4
  "description": "Theia - Editor Preview Extension",
5
5
  "dependencies": {
6
- "@theia/core": "1.67.0-next.56+d8f18cc386c",
7
- "@theia/output": "1.67.0-next.56+d8f18cc386c",
8
- "@theia/remote": "1.67.0-next.56+d8f18cc386c",
9
- "@theia/workspace": "1.67.0-next.56+d8f18cc386c",
6
+ "@theia/core": "1.67.0-next.86+03f92ff1d",
7
+ "@theia/output": "1.67.0-next.86+03f92ff1d",
8
+ "@theia/remote": "1.67.0-next.86+03f92ff1d",
9
+ "@theia/workspace": "1.67.0-next.86+03f92ff1d",
10
10
  "dockerode": "^4.0.2",
11
11
  "jsonc-parser": "^2.2.0",
12
12
  "uuid": "^8.0.0"
@@ -51,5 +51,5 @@
51
51
  "nyc": {
52
52
  "extends": "../../configs/nyc.json"
53
53
  },
54
- "gitHead": "d8f18cc386c45a736cd193d42eab02c8f64c6b10"
54
+ "gitHead": "03f92ff1d97dcb199de39b48e60a53535de22808"
55
55
  }
@@ -25,7 +25,7 @@ import { RemoteConnectionService } from '@theia/remote/lib/electron-node/remote-
25
25
  import { RemoteProxyServerProvider } from '@theia/remote/lib/electron-node/remote-proxy-server-provider';
26
26
  import { Emitter, Event, generateUuid, MessageService, RpcServer, ILogger } from '@theia/core';
27
27
  import { Socket } from 'net';
28
- import { inject, injectable, named } from '@theia/core/shared/inversify';
28
+ import { inject, injectable } from '@theia/core/shared/inversify';
29
29
  import * as Docker from 'dockerode';
30
30
  import { DockerContainerService } from './docker-container-service';
31
31
  import { Deferred } from '@theia/core/lib/common/promise-util';
@@ -170,6 +170,7 @@ export class DevContainerConnectionProvider implements RemoteContainerConnection
170
170
  docker,
171
171
  container,
172
172
  config,
173
+ logger: this.logger
173
174
  }));
174
175
  }
175
176
 
@@ -194,6 +195,7 @@ export interface RemoteContainerConnectionOptions {
194
195
  docker: Docker;
195
196
  container: Docker.Container;
196
197
  config: DevContainerConfiguration;
198
+ logger: ILogger;
197
199
  }
198
200
 
199
201
  interface ContainerTerminalSession {
@@ -212,9 +214,6 @@ interface ContainerTerminalSession {
212
214
 
213
215
  export class RemoteDockerContainerConnection implements RemoteConnection {
214
216
 
215
- @inject(ILogger) @named('dev-container')
216
- protected readonly logger: ILogger;
217
-
218
217
  id: string;
219
218
  name: string;
220
219
  type: string;
@@ -226,6 +225,8 @@ export class RemoteDockerContainerConnection implements RemoteConnection {
226
225
 
227
226
  remoteSetupResult: RemoteSetupResult;
228
227
 
228
+ protected readonly logger: ILogger;
229
+
229
230
  protected config: DevContainerConfiguration;
230
231
 
231
232
  protected activeTerminalSession: ContainerTerminalSession | undefined;
@@ -246,6 +247,8 @@ export class RemoteDockerContainerConnection implements RemoteConnection {
246
247
  this.docker.getEvents({ filters: { container: [this.container.id], event: ['stop'] } }).then(stream => {
247
248
  stream.on('data', () => this.onDidDisconnectEmitter.fire());
248
249
  });
250
+
251
+ this.logger = options.logger;
249
252
  }
250
253
 
251
254
  async forwardOut(socket: Socket, port?: number): Promise<void> {