add server license and server license terms
parent
eace6a0af1
commit
cd2d059ec0
|
@ -7,6 +7,8 @@
|
|||
"licenseName": "MIT",
|
||||
"licenseUrl": "https://github.com/microsoft/vscode/blob/main/LICENSE.txt",
|
||||
"serverGreeting": [],
|
||||
"serverLicense": [],
|
||||
"serverLicensePrompt": "",
|
||||
"win32DirName": "Microsoft Code OSS",
|
||||
"win32NameVersion": "Microsoft Code OSS",
|
||||
"win32RegValueName": "CodeOSS",
|
||||
|
|
|
@ -120,6 +120,8 @@ export interface IProductConfiguration {
|
|||
readonly showTelemetryOptOut?: boolean;
|
||||
|
||||
readonly serverGreeting: string[];
|
||||
readonly serverLicense?: string[];
|
||||
readonly serverLicensePrompt?: string;
|
||||
|
||||
readonly npsSurveyUrl?: string;
|
||||
readonly cesSurveyUrl?: string;
|
||||
|
|
|
@ -24,7 +24,7 @@ async function start() {
|
|||
|
||||
// Do a quick parse to determine if a server or the cli needs to be started
|
||||
const parsedArgs = minimist(process.argv.slice(2), {
|
||||
boolean: ['start-server', 'list-extensions', 'print-ip-address', 'help', 'version'],
|
||||
boolean: ['start-server', 'list-extensions', 'print-ip-address', 'help', 'version', 'accept-server-license-terms'],
|
||||
string: ['install-extension', 'install-builtin-extension', 'uninstall-extension', 'locate-extension', 'socket-path', 'host', 'port', 'pick-port']
|
||||
});
|
||||
|
||||
|
@ -57,6 +57,21 @@ async function start() {
|
|||
const http = require('http');
|
||||
const os = require('os');
|
||||
|
||||
if (Array.isArray(product.serverLicense) && product.serverLicense.length) {
|
||||
console.log(product.serverLicense.join('\n'));
|
||||
if (product.serverLicensePrompt && parsedArgs['accept-server-license-terms'] !== true) {
|
||||
try {
|
||||
const accept = await prompt(product.serverLicensePrompt);
|
||||
if (!accept) {
|
||||
process.exit();
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
process.exit();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let firstRequest = true;
|
||||
let firstWebSocket = true;
|
||||
|
||||
|
@ -218,4 +233,31 @@ function loadCode() {
|
|||
});
|
||||
}
|
||||
|
||||
const { stdin, stdout } = process;
|
||||
|
||||
/**
|
||||
* @param {string} question
|
||||
* @returns { Promise<boolean> }
|
||||
*/
|
||||
function prompt(question) {
|
||||
return new Promise((resolve, reject) => {
|
||||
stdin.resume();
|
||||
stdout.write(question);
|
||||
|
||||
stdin.on('data', async data => {
|
||||
const str = data.toString().trim().toLowerCase();
|
||||
if (str === '' || str === 'y' || str === 'yes') {
|
||||
resolve(true);
|
||||
} else if (str === 'n' || str === 'no') {
|
||||
resolve(false);
|
||||
} else {
|
||||
process.stdout.write('\nInvalid Response. Answer either yes (y, yes) or no (n, no)\n');
|
||||
resolve(await prompt(question));
|
||||
}
|
||||
stdin.on('error', err => reject(err));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
start();
|
||||
|
|
|
@ -57,6 +57,7 @@ export const serverOptions: OptionDescriptions<ServerParsedArgs> = {
|
|||
|
||||
'help': OPTIONS['help'],
|
||||
'version': OPTIONS['version'],
|
||||
'accept-server-license-terms': { type: 'boolean' },
|
||||
|
||||
_: OPTIONS['_']
|
||||
};
|
||||
|
@ -136,6 +137,8 @@ export interface ServerParsedArgs {
|
|||
help: boolean;
|
||||
version: boolean;
|
||||
|
||||
'accept-server-license-terms': boolean;
|
||||
|
||||
_: string[];
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue