wizard for deploying bdc (#7183)

* wip

* wip2

* wip eod 820

* wip 822

* text component improvements and misc changes

* aria-label

* targetClusterPage wip

* target cluster page

* target cluster page

* wip 827

* wip deployment profile page

* profile page

* service settings page

* wip 0903

* 0909 wip

* 0910

* 0911

* sql instance and working directory

* notebooks

* docker version on windows

* EULA env var

* 917 updates

* address comments

* use async file access

* fix the summary page display issue for ad auth

* add save json file buttons

* use promise for private methds

* review feedbacks

* refactor

* pass json to notebooks

* fix no tool scenario

* bypass tool check if installed

* update hint text

* update notebooks

* workaround azdata first time use

* comments

* accept eula and some text update

* fix the error in package.json

* promise instead of thenable

* comments

* fix typo
This commit is contained in:
Alan Ren
2019-09-25 10:04:13 -07:00
committed by GitHub
parent 6a6048d40f
commit a0e31fc723
51 changed files with 4137 additions and 855 deletions

View File

@@ -2,37 +2,58 @@
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
import * as fs from 'fs';
import * as vscode from 'vscode';
import * as azdata from 'azdata';
import * as cp from 'child_process';
/**
* Abstract of platform dependencies
*/
export interface IPlatformService {
platform(): string;
copyFile(source: string, target: string): void;
fileExists(file: string): boolean;
storagePath(): string;
copyFile(source: string, target: string): Promise<void>;
fileExists(file: string): Promise<boolean>;
openFile(filePath: string): void;
showErrorMessage(message: string): void;
isNotebookNameUsed(title: string): boolean;
makeDirectory(path: string): Promise<void>;
readTextFile(filePath: string): Promise<string>;
runCommand(command: string, options?: CommandOptions): Promise<string>;
}
export interface CommandOptions {
workingDirectory?: string;
additionalEnvironmentVariables?: NodeJS.ProcessEnv;
}
export class PlatformService implements IPlatformService {
constructor(private _storagePath: string = '') {
}
storagePath(): string {
return this._storagePath;
}
platform(): string {
return process.platform;
}
copyFile(source: string, target: string): void {
// tslint:disable-next-line:no-sync
fs.copyFileSync(source, target);
copyFile(source: string, target: string): Promise<void> {
return fs.promises.copyFile(source, target);
}
fileExists(file: string): boolean {
// tslint:disable-next-line:no-sync
return fs.existsSync(file);
fileExists(file: string): Promise<boolean> {
return fs.promises.access(file).then(() => {
return true;
}).catch(error => {
if (error && error.code === 'ENOENT') {
return false;
}
throw error;
});
}
openFile(filePath: string): void {
@@ -46,4 +67,28 @@ export class PlatformService implements IPlatformService {
isNotebookNameUsed(title: string): boolean {
return (azdata.nb.notebookDocuments.findIndex(doc => doc.isUntitled && doc.fileName === title) > -1);
}
makeDirectory(path: string): Promise<void> {
return fs.promises.mkdir(path);
}
readTextFile(filePath: string): Promise<string> {
return fs.promises.readFile(filePath, 'utf8');
}
runCommand(command: string, options?: CommandOptions): Promise<string> {
return new Promise<string>((resolve, reject) => {
const env = Object.assign({}, process.env, options && options.additionalEnvironmentVariables);
cp.exec(command, {
cwd: options && options.workingDirectory,
env: env
}, (error, stdout, stderror) => {
if (error) {
reject(error);
} else {
resolve(stdout);
}
});
});
}
}