Skip to content

Commit

Permalink
Install remote extensions in chunks (#20)
Browse files Browse the repository at this point in the history
* Install extensions in chunks

* 🆙 bump version
  • Loading branch information
jeanp413 authored Aug 15, 2024
1 parent 53df269 commit 7795187
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 19 deletions.
2 changes: 1 addition & 1 deletion gitpod-remote/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"displayName": "%displayName%",
"description": "%description%",
"publisher": "gitpod",
"version": "0.0.53",
"version": "0.0.54",
"license": "MIT",
"preview": true,
"icon": "resources/gitpod.png",
Expand Down
52 changes: 34 additions & 18 deletions gitpod-remote/src/remoteExtensionInit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import { GitpodExtensionContext } from 'gitpod-shared';
import * as util from 'util';
import * as path from 'path';

const MAX_EXTENSIONS = 15;

export interface IExtensionIdentifier {
id: string;
uuid?: string;
Expand Down Expand Up @@ -41,16 +43,23 @@ export async function initializeRemoteExtensions(extensions: ISyncExtension[], c
const productJson = await getVSCodeProductJson();
const appName = productJson.applicationName || 'code';
const codeCliPath = path.join(vscode.env.appRoot, 'bin/remote-cli', appName);
const args = extensions.map(e => '--install-extension ' + e.identifier.id).join(' ');

const execEnv = { ...process.env };
delete execEnv['ELECTRON_RUN_AS_NODE']
try {
context.logger.info('Trying to initialize remote extensions:', extensions.map(e => e.identifier.id).join('\n'));
const { stdout, stderr } = await util.promisify(cp.exec)(`${codeCliPath} ${args}`, { env: execEnv });
context.logger.info(`Initialize remote extensions cli commamnd output:\nstdout: ${stdout}\nstderr: ${stderr}`);
} catch (e) {
context.logger.error('Error trying to initialize remote extensions:', e);
delete execEnv['ELECTRON_RUN_AS_NODE'];

context.logger.info('Trying to initialize remote extensions:', extensions.map(e => e.identifier.id).join('\n'));
for (let i = 0; i < extensions.length; i+= MAX_EXTENSIONS) {
const extensionsChunk = extensions.slice(i, i + MAX_EXTENSIONS);
if (!extensionsChunk.length) {
break;
}

try {
const args = extensionsChunk.map(e => '--install-extension ' + e.identifier.id).join(' ');
const { stdout, stderr } = await util.promisify(cp.exec)(`${codeCliPath} ${args}`, { env: execEnv });
context.logger.info(`Initialize remote extensions cli commamnd output:\nstdout: ${stdout}\nstderr: ${stderr}`);
} catch (e) {
context.logger.error('Error trying to initialize remote extensions:', e);
}
}

return true;
Expand Down Expand Up @@ -102,15 +111,22 @@ export async function installInitialExtensions(context: GitpodExtensionContext)
const productJson = await getVSCodeProductJson();
const appName = productJson.applicationName || 'code';
const codeCliPath = path.join(vscode.env.appRoot, 'bin/remote-cli', appName);
const args = extensions.map(e => '--install-extension ' + e.toString()).join(' ');

const execEnv = { ...process.env };
delete execEnv['ELECTRON_RUN_AS_NODE']
try {
context.logger.info('Trying to initialize remote extensions from gitpod.yml:', extensions.map(e => e.toString()).join('\n'));
const { stdout, stderr } = await util.promisify(cp.exec)(`${codeCliPath} ${args}`, { env: execEnv });
context.logger.info(`Initialize remote extensions cli commamnd output:\nstdout: ${stdout}\nstderr: ${stderr}`);
} catch (e) {
context.logger.error('Error trying to initialize remote extensions from gitpod.yml:', e);
delete execEnv['ELECTRON_RUN_AS_NODE'];

context.logger.info('Trying to initialize remote extensions from gitpod.yml:', extensions.map(e => e.toString()).join('\n'));
for (let i = 0; i < extensions.length; i+= MAX_EXTENSIONS) {
const extensionsChunk = extensions.slice(i, i + MAX_EXTENSIONS);
if (!extensionsChunk.length) {
break;
}

try {
const args = extensionsChunk.map(e => '--install-extension ' + e.toString()).join(' ');
const { stdout, stderr } = await util.promisify(cp.exec)(`${codeCliPath} ${args}`, { env: execEnv });
context.logger.info(`Initialize remote extensions cli commamnd output:\nstdout: ${stdout}\nstderr: ${stderr}`);
} catch (e) {
context.logger.error('Error trying to initialize remote extensions from gitpod.yml:', e);
}
}
}

0 comments on commit 7795187

Please sign in to comment.