Skip to content

Commit 0170952

Browse files
committed
add --download-extensions-locally
1 parent 9f4e94e commit 0170952

File tree

8 files changed

+31
-5
lines changed

8 files changed

+31
-5
lines changed

cli/src/commands/args.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,7 @@ pub enum ExtensionSubcommand {
266266
Uninstall(UninstallExtensionArgs),
267267
/// Update the installed extensions.
268268
Update,
269+
DownloadExtensionsLocally,
269270
}
270271

271272
impl ExtensionSubcommand {
@@ -302,6 +303,9 @@ impl ExtensionSubcommand {
302303
ExtensionSubcommand::Update => {
303304
target.push("--update-extensions".to_string());
304305
}
306+
ExtensionSubcommand::DownloadExtensionsLocally => {
307+
target.push("--download-extensions-locally".to_string());
308+
}
305309
}
306310
}
307311
}

cli/src/tunnels/code_server.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ pub struct CodeServerArgs {
6363
pub install_extensions: Vec<String>,
6464
pub uninstall_extensions: Vec<String>,
6565
pub update_extensions: bool,
66+
pub download_extensions_locally: bool,
6667
pub list_extensions: bool,
6768
pub show_versions: bool,
6869
pub category: Option<String>,
@@ -138,6 +139,9 @@ impl CodeServerArgs {
138139
if self.update_extensions {
139140
args.push(String::from("--update-extensions"));
140141
}
142+
if self.download_extensions_locally {
143+
args.push(String::from("--download-extensions-locally"));
144+
}
141145
if self.list_extensions {
142146
args.push(String::from("--list-extensions"));
143147
if self.show_versions {

src/server-main.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ perf.mark('code/server/start');
2828
// Do a quick parse to determine if a server or the cli needs to be started
2929
const parsedArgs = minimist(process.argv.slice(2), {
3030
boolean: ['start-server', 'list-extensions', 'print-ip-address', 'help', 'version', 'accept-server-license-terms', 'update-extensions'],
31-
string: ['install-extension', 'install-builtin-extension', 'uninstall-extension', 'locate-extension', 'socket-path', 'host', 'port', 'compatibility'],
31+
string: ['install-extension', 'install-builtin-extension', 'uninstall-extension', 'locate-extension', 'socket-path', 'host', 'port', 'compatibility', 'download-extensions-locally'],
3232
alias: { help: 'h', version: 'v' }
3333
});
3434
['host', 'port', 'accept-server-license-terms'].forEach(e => {
@@ -41,7 +41,7 @@ const parsedArgs = minimist(process.argv.slice(2), {
4141
});
4242

4343
const extensionLookupArgs = ['list-extensions', 'locate-extension'];
44-
const extensionInstallArgs = ['install-extension', 'install-builtin-extension', 'uninstall-extension', 'update-extensions'];
44+
const extensionInstallArgs = ['install-extension', 'install-builtin-extension', 'uninstall-extension', 'update-extensions', 'download-extensions-locally'];
4545

4646
const shouldSpawnCli = parsedArgs.help || parsedArgs.version || extensionLookupArgs.some(a => !!parsedArgs[a]) || (extensionInstallArgs.some(a => !!parsedArgs[a]) && !parsedArgs['start-server']);
4747

src/vs/platform/environment/common/argv.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ export interface NativeParsedArgs {
8383
'pre-release'?: boolean;
8484
'install-builtin-extension'?: string[]; // undefined or array of 1 or more
8585
'uninstall-extension'?: string[]; // undefined or array of 1 or more
86+
'download-extensions-locally'?: boolean;
8687
'update-extensions'?: boolean;
8788
'do-not-include-pack-dependencies'?: boolean;
8889
'locate-extension'?: string[]; // undefined or array of 1 or more

src/vs/platform/environment/node/argv.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ export const OPTIONS: OptionDescriptions<Required<NativeParsedArgs>> = {
101101
'install-extension': { type: 'string[]', cat: 'e', args: 'ext-id | path', description: localize('installExtension', "Installs or updates an extension. The argument is either an extension id or a path to a VSIX. The identifier of an extension is '${publisher}.${name}'. Use '--force' argument to update to latest version. To install a specific version provide '@${version}'. For example: 'vscode.csharp@1.2.3'.") },
102102
'pre-release': { type: 'boolean', cat: 'e', description: localize('install prerelease', "Installs the pre-release version of the extension, when using --install-extension") },
103103
'uninstall-extension': { type: 'string[]', cat: 'e', args: 'ext-id', description: localize('uninstallExtension', "Uninstalls an extension.") },
104+
'download-extensions-locally': { type: 'boolean', cat: 'e', description: localize('downloadExtensionsLocally', "When enabled extensions are downloaded locally and installed on remote") },
104105
'update-extensions': { type: 'boolean', cat: 'e', description: localize('updateExtensions', "Update the installed extensions.") },
105106
'enable-proposed-api': { type: 'string[]', allowEmptyValue: true, cat: 'e', args: 'ext-id', description: localize('experimentalApis', "Enables proposed API features for extensions. Can receive one or more extension IDs to enable individually.") },
106107

src/vs/server/node/remoteExtensionsScanner.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,22 @@ export class RemoteExtensionsScannerService implements IRemoteExtensionsScannerS
6060

6161
const extensionsToInstall = environmentService.args['install-extension'];
6262
if (extensionsToInstall) {
63-
_logService.trace('Installing extensions passed via args...');
6463
const installOptions: InstallOptions = {
6564
isMachineScoped: !!environmentService.args['do-not-sync'],
6665
installPreReleaseVersion: !!environmentService.args['pre-release'],
6766
isApplicationScoped: true // extensions installed during server startup are available to all profiles
6867
};
68+
69+
if (!!environmentService.args['download-extensions-locally']) {
70+
_logService.trace('Installing extensions later...');
71+
this._whenExtensionsReady = this._whenBuiltinExtensionsReady
72+
.then(async () => {
73+
return { failed: extensionsToInstall.map(id => ({ id, installOptions })) };
74+
});
75+
return;
76+
}
77+
78+
_logService.trace('Installing extensions passed via args...');
6979
this._whenExtensionsReady = this._whenBuiltinExtensionsReady
7080
.then(() => _extensionManagementCLI.installExtensions(this._asExtensionIdOrVSIX(extensionsToInstall), [], installOptions, !!environmentService.args['force']))
7181
.then(async () => {

src/vs/server/node/server.cli.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ const isSupportedForPipe = (optionId: keyof RemoteParsedArgs) => {
7070
case 'uninstall-extension':
7171
case 'update-extensions':
7272
case 'list-extensions':
73+
case 'download-extensions-locally':
7374
case 'force':
7475
case 'do-not-include-pack-dependencies':
7576
case 'show-versions':
@@ -228,7 +229,7 @@ export async function main(desc: ProductDescription, args: string[]): Promise<vo
228229
}
229230

230231
if (cliCommand) {
231-
if (parsedArgs['install-extension'] !== undefined || parsedArgs['uninstall-extension'] !== undefined || parsedArgs['list-extensions'] || parsedArgs['update-extensions']) {
232+
if (parsedArgs['install-extension'] !== undefined || parsedArgs['uninstall-extension'] !== undefined || parsedArgs['list-extensions'] || parsedArgs['update-extensions'] || parsedArgs['download-extensions-locally']) {
232233
const cmdLine: string[] = [];
233234
parsedArgs['install-extension']?.forEach(id => cmdLine.push('--install-extension', id));
234235
parsedArgs['uninstall-extension']?.forEach(id => cmdLine.push('--uninstall-extension', id));
@@ -242,6 +243,10 @@ export async function main(desc: ProductDescription, args: string[]): Promise<vo
242243
cmdLine.push('--update-extensions');
243244
}
244245

246+
if (parsedArgs['download-extensions-locally']) {
247+
cmdLine.push('--download-extensions-locally');
248+
}
249+
245250
const childProcess = cp.fork(FileAccess.asFileUri('server-main').fsPath, cmdLine, { stdio: 'inherit' });
246251
childProcess.on('error', err => console.log(err));
247252
return;

src/vs/server/node/serverEnvironmentService.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ export const serverOptions: OptionDescriptions<Required<ServerParsedArgs>> = {
6464
'uninstall-extension': OPTIONS['uninstall-extension'],
6565
'list-extensions': OPTIONS['list-extensions'],
6666
'locate-extension': OPTIONS['locate-extension'],
67-
67+
'download-extensions-locally': OPTIONS['download-extensions-locally'],
6868
'show-versions': OPTIONS['show-versions'],
6969
'category': OPTIONS['category'],
7070
'force': OPTIONS['force'],
@@ -189,6 +189,7 @@ export interface ServerParsedArgs {
189189
'update-extensions'?: boolean;
190190
'uninstall-extension'?: string[];
191191
'list-extensions'?: boolean;
192+
'download-extensions-locally'?: boolean;
192193
'locate-extension'?: string[];
193194
'show-versions'?: boolean;
194195
'category'?: string;

0 commit comments

Comments
 (0)