@@ -9,6 +9,8 @@ import { GitpodExtensionContext } from 'gitpod-shared';
99import * as util from 'util' ;
1010import * as path from 'path' ;
1111
12+ const MAX_EXTENSIONS = 15 ;
13+
1214export 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