parent
5621d993e4
commit
279c4d048a
3 changed files with 21 additions and 16 deletions
|
@ -9,6 +9,7 @@ import * as os from 'os';
|
||||||
import * as cp from 'child_process';
|
import * as cp from 'child_process';
|
||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
|
import * as readline from 'readline';
|
||||||
|
|
||||||
import { localize } from 'vs/nls';
|
import { localize } from 'vs/nls';
|
||||||
import { ILaunchChannel } from 'vs/code/electron-main/launch';
|
import { ILaunchChannel } from 'vs/code/electron-main/launch';
|
||||||
|
@ -16,8 +17,6 @@ import { TPromise } from 'vs/base/common/winjs.base';
|
||||||
import product from 'vs/platform/node/product';
|
import product from 'vs/platform/node/product';
|
||||||
import { IRequestService } from 'vs/platform/request/node/request';
|
import { IRequestService } from 'vs/platform/request/node/request';
|
||||||
import { IRequestContext } from 'vs/base/node/request';
|
import { IRequestContext } from 'vs/base/node/request';
|
||||||
import { IChoiceService } from 'vs/platform/message/common/message';
|
|
||||||
import Severity from 'vs/base/common/severity';
|
|
||||||
|
|
||||||
interface PostResult {
|
interface PostResult {
|
||||||
readonly blob_id: string;
|
readonly blob_id: string;
|
||||||
|
@ -36,8 +35,7 @@ class Endpoint {
|
||||||
|
|
||||||
export async function uploadLogs(
|
export async function uploadLogs(
|
||||||
channel: ILaunchChannel,
|
channel: ILaunchChannel,
|
||||||
requestService: IRequestService,
|
requestService: IRequestService
|
||||||
choiceService: IChoiceService
|
|
||||||
): TPromise<any> {
|
): TPromise<any> {
|
||||||
const endpoint = Endpoint.getFromProduct();
|
const endpoint = Endpoint.getFromProduct();
|
||||||
if (!endpoint) {
|
if (!endpoint) {
|
||||||
|
@ -47,7 +45,7 @@ export async function uploadLogs(
|
||||||
|
|
||||||
const logsPath = await channel.call('get-logs-path', null);
|
const logsPath = await channel.call('get-logs-path', null);
|
||||||
|
|
||||||
if (await promptUserToConfirmLogUpload(logsPath, choiceService)) {
|
if (await promptUserToConfirmLogUpload(logsPath)) {
|
||||||
console.log(localize('beginUploading', 'Uploading...'));
|
console.log(localize('beginUploading', 'Uploading...'));
|
||||||
const outZip = await zipLogs(logsPath);
|
const outZip = await zipLogs(logsPath);
|
||||||
const result = await postLogs(endpoint, outZip, requestService);
|
const result = await postLogs(endpoint, outZip, requestService);
|
||||||
|
@ -59,17 +57,23 @@ export async function uploadLogs(
|
||||||
|
|
||||||
async function promptUserToConfirmLogUpload(
|
async function promptUserToConfirmLogUpload(
|
||||||
logsPath: string,
|
logsPath: string,
|
||||||
choiceService: IChoiceService
|
|
||||||
): Promise<boolean> {
|
): Promise<boolean> {
|
||||||
const message = localize('logUploadPromptHeader', 'Upload session logs to secure endpoint?')
|
const message = localize('logUploadPromptHeader', 'Upload session logs to secure endpoint?')
|
||||||
+ '\n\n' + localize('logUploadPromptBody', 'Please review your log files here: \'{0}\'', logsPath)
|
+ '\n\n' + localize('logUploadPromptBody', 'Please review your log files here: \'{0}\'', logsPath)
|
||||||
+ '\n\n' + localize('logUploadPromptBodyDetails', 'Logs may contain personal information such as full paths and file contents.')
|
+ '\n\n' + localize('logUploadPromptBodyDetails', 'Logs may contain personal information such as full paths and file contents.')
|
||||||
+ '\n\n';
|
+ '\n\n' + localize('logUploadPromptKey', 'I have reviewed my logs (enter \'y\' to confirm upload)');
|
||||||
const choice = await choiceService.choose(Severity.Info, message, [
|
|
||||||
localize('logUploadPromptKey', 'I have reviewed my logs. Proceed with upload...'),
|
const rl = readline.createInterface({
|
||||||
localize('logUploadPromptCancel', 'Cancel'),
|
input: process.stdin,
|
||||||
], 1);
|
output: process.stdout
|
||||||
return choice === 0;
|
});
|
||||||
|
|
||||||
|
return new TPromise<boolean>(resolve =>
|
||||||
|
rl.question(message,
|
||||||
|
(answer: string) => {
|
||||||
|
rl.close();
|
||||||
|
resolve(answer && answer.trim()[0].toLowerCase() === 'y');
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
async function postLogs(
|
async function postLogs(
|
||||||
|
|
|
@ -109,7 +109,6 @@ function setupIPC(accessor: ServicesAccessor): TPromise<Server> {
|
||||||
const logService = accessor.get(ILogService);
|
const logService = accessor.get(ILogService);
|
||||||
const environmentService = accessor.get(IEnvironmentService);
|
const environmentService = accessor.get(IEnvironmentService);
|
||||||
const requestService = accessor.get(IRequestService);
|
const requestService = accessor.get(IRequestService);
|
||||||
const choiceService = accessor.get(IChoiceService);
|
|
||||||
|
|
||||||
function allowSetForegroundWindow(service: LaunchChannelClient): TPromise<void> {
|
function allowSetForegroundWindow(service: LaunchChannelClient): TPromise<void> {
|
||||||
let promise = TPromise.wrap<void>(void 0);
|
let promise = TPromise.wrap<void>(void 0);
|
||||||
|
@ -203,7 +202,7 @@ function setupIPC(accessor: ServicesAccessor): TPromise<Server> {
|
||||||
|
|
||||||
// Log uploader
|
// Log uploader
|
||||||
if (environmentService.args['upload-logs']) {
|
if (environmentService.args['upload-logs']) {
|
||||||
return uploadLogs(channel, requestService, choiceService)
|
return uploadLogs(channel, requestService)
|
||||||
.then(() => TPromise.wrapError(new ExpectedError()));
|
.then(() => TPromise.wrapError(new ExpectedError()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -123,7 +123,7 @@ export async function main(argv: string[]): TPromise<any> {
|
||||||
|
|
||||||
const processCallbacks: ((child: ChildProcess) => Thenable<any>)[] = [];
|
const processCallbacks: ((child: ChildProcess) => Thenable<any>)[] = [];
|
||||||
|
|
||||||
const verbose = args.verbose || args.status;
|
const verbose = args.verbose || args.status || args['upload-logs'];
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
env['ELECTRON_ENABLE_LOGGING'] = '1';
|
env['ELECTRON_ENABLE_LOGGING'] = '1';
|
||||||
|
|
||||||
|
@ -311,7 +311,9 @@ export async function main(argv: string[]): TPromise<any> {
|
||||||
env
|
env
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!verbose) {
|
if (args['upload-logs']) {
|
||||||
|
options['stdio'] = [process.stdin, 'pipe', 'pipe'];
|
||||||
|
} else if (!verbose) {
|
||||||
options['stdio'] = 'ignore';
|
options['stdio'] = 'ignore';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue