Skip to content

Commit 7795187

Browse files
authored
Install remote extensions in chunks (#20)
* Install extensions in chunks * 🆙 bump version
1 parent 53df269 commit 7795187

File tree

2 files changed

+35
-19
lines changed

2 files changed

+35
-19
lines changed

gitpod-remote/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"displayName": "%displayName%",
44
"description": "%description%",
55
"publisher": "gitpod",
6-
"version": "0.0.53",
6+
"version": "0.0.54",
77
"license": "MIT",
88
"preview": true,
99
"icon": "resources/gitpod.png",

gitpod-remote/src/remoteExtensionInit.ts

+34-18
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import { GitpodExtensionContext } from 'gitpod-shared';
99
import * as util from 'util';
1010
import * as path from 'path';
1111

12+
const MAX_EXTENSIONS = 15;
13+
1214
export interface IExtensionIdentifier {
1315
id: string;
1416
uuid?: string;
@@ -41,16 +43,23 @@ export async function initializeRemoteExtensions(extensions: ISyncExtension[], c
4143
const productJson = await getVSCodeProductJson();
4244
const appName = productJson.applicationName || 'code';
4345
const codeCliPath = path.join(vscode.env.appRoot, 'bin/remote-cli', appName);
44-
const args = extensions.map(e => '--install-extension ' + e.identifier.id).join(' ');
45-
4646
const execEnv = { ...process.env };
47-
delete execEnv['ELECTRON_RUN_AS_NODE']
48-
try {
49-
context.logger.info('Trying to initialize remote extensions:', extensions.map(e => e.identifier.id).join('\n'));
50-
const { stdout, stderr } = await util.promisify(cp.exec)(`${codeCliPath} ${args}`, { env: execEnv });
51-
context.logger.info(`Initialize remote extensions cli commamnd output:\nstdout: ${stdout}\nstderr: ${stderr}`);
52-
} catch (e) {
53-
context.logger.error('Error trying to initialize remote extensions:', e);
47+
delete execEnv['ELECTRON_RUN_AS_NODE'];
48+
49+
context.logger.info('Trying to initialize remote extensions:', extensions.map(e => e.identifier.id).join('\n'));
50+
for (let i = 0; i < extensions.length; i+= MAX_EXTENSIONS) {
51+
const extensionsChunk = extensions.slice(i, i + MAX_EXTENSIONS);
52+
if (!extensionsChunk.length) {
53+
break;
54+
}
55+
56+
try {
57+
const args = extensionsChunk.map(e => '--install-extension ' + e.identifier.id).join(' ');
58+
const { stdout, stderr } = await util.promisify(cp.exec)(`${codeCliPath} ${args}`, { env: execEnv });
59+
context.logger.info(`Initialize remote extensions cli commamnd output:\nstdout: ${stdout}\nstderr: ${stderr}`);
60+
} catch (e) {
61+
context.logger.error('Error trying to initialize remote extensions:', e);
62+
}
5463
}
5564

5665
return true;
@@ -102,15 +111,22 @@ export async function installInitialExtensions(context: GitpodExtensionContext)
102111
const productJson = await getVSCodeProductJson();
103112
const appName = productJson.applicationName || 'code';
104113
const codeCliPath = path.join(vscode.env.appRoot, 'bin/remote-cli', appName);
105-
const args = extensions.map(e => '--install-extension ' + e.toString()).join(' ');
106-
107114
const execEnv = { ...process.env };
108-
delete execEnv['ELECTRON_RUN_AS_NODE']
109-
try {
110-
context.logger.info('Trying to initialize remote extensions from gitpod.yml:', extensions.map(e => e.toString()).join('\n'));
111-
const { stdout, stderr } = await util.promisify(cp.exec)(`${codeCliPath} ${args}`, { env: execEnv });
112-
context.logger.info(`Initialize remote extensions cli commamnd output:\nstdout: ${stdout}\nstderr: ${stderr}`);
113-
} catch (e) {
114-
context.logger.error('Error trying to initialize remote extensions from gitpod.yml:', e);
115+
delete execEnv['ELECTRON_RUN_AS_NODE'];
116+
117+
context.logger.info('Trying to initialize remote extensions from gitpod.yml:', extensions.map(e => e.toString()).join('\n'));
118+
for (let i = 0; i < extensions.length; i+= MAX_EXTENSIONS) {
119+
const extensionsChunk = extensions.slice(i, i + MAX_EXTENSIONS);
120+
if (!extensionsChunk.length) {
121+
break;
122+
}
123+
124+
try {
125+
const args = extensionsChunk.map(e => '--install-extension ' + e.toString()).join(' ');
126+
const { stdout, stderr } = await util.promisify(cp.exec)(`${codeCliPath} ${args}`, { env: execEnv });
127+
context.logger.info(`Initialize remote extensions cli commamnd output:\nstdout: ${stdout}\nstderr: ${stderr}`);
128+
} catch (e) {
129+
context.logger.error('Error trying to initialize remote extensions from gitpod.yml:', e);
130+
}
115131
}
116132
}

0 commit comments

Comments
 (0)