Files
azuredatastudio/extensions/resource-deployment/src/utils.ts
Arvind Ranasaria 678bbe3142 Custom Summary Page for NotebookWizard and notebook Cell with wizard variables (#10297)
* save not yet tested work

* Merge from master.

* Screeens Shared for Feeedback

* Code complete

* remove unneeded changes

* remove unnecessary comma

* remov wss

* remove dead code

* PR feedback

* checkpoint fixes

* PR & minor fixes

* minor fix for feature of  resourceType options being optional.

* reverting experimental change

* separating out changes for future featurework.

* revert unneeded change

* review feedback fixes

* review feedback

* rename InputFieldComponent to InputComponent

* working version of custom summary page

* add option to align items in a flex- container.

* changes to support labelColor

* save work , still pending issue with labelCSSStyles

* Summary page and setting variabless in notebook.

* minor fixes.

* pr feedbck

* fix formatting issues

* pr feedback

* pr feedback

* pr feedback

* fixing docs

* summary page value setting fix

* rename children of RowInfo to items

* rename a method

* rename summary_text to evaluated_text

* rename properties of fieldInfo

* revert inadvertent change

* rename linked_texttext to hyperlinked_text and removing linking facility from readonly_text

* pr feedback

* fix setting tools variables in env and notebook

* removing saving of originalValues for EvaluatedText

* await on launchNotebookWithEdits

* await on launchNotebookWithContent

* merge RadioOptions & Options into 1

* merge ReadOnlyText, links  & evaluatedText

* Samples for new generic wizard features

* fix comment

* fix assertions

* return type and comment for getClusterContext

* fix inadvertent change

* increase minimum required azdata version

* remove unneeded environment variable settings

* not leaking passwords in notebooks
2020-06-01 11:14:59 -07:00

48 lines
2.1 KiB
TypeScript

/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as path from 'path';
import { ToolsInstallPath } from './constants';
import { ITool, NoteBookEnvironmentVariablePrefix } from './interfaces';
export function getErrorMessage(error: any): string {
return (error instanceof Error)
? (typeof error.message === 'string' ? error.message : '')
: typeof error === 'string' ? error : `${JSON.stringify(error, undefined, '\t')}`;
}
export function getDateTimeString(): string {
return new Date().toISOString().slice(0, 19).replace(/[^0-9]/g, ''); // Take the date time information and only leaving the numbers
}
export function getRuntimeBinaryPathEnvironmentVariableName(toolName: string): string {
return `${NoteBookEnvironmentVariablePrefix}${toolName.toUpperCase().replace(/ |-/g, '_')}`;
}
export function setEnvironmentVariablesForInstallPaths(tools: ITool[], env: NodeJS.ProcessEnv = process.env): void {
// Use Set class to make sure the collection only contains unique values.
let installationPaths: Set<string> = new Set<string>();
tools.forEach(t => {
if (t.installationPathOrAdditionalInformation) {
// construct an env variable name with NoteBookEnvironmentVariablePrefix prefix
// and tool.name as suffix, making sure of using all uppercase characters and only _ as separator
const envVarName = getRuntimeBinaryPathEnvironmentVariableName(t.name);
env[envVarName] = t.installationPathOrAdditionalInformation;
installationPaths.add(path.dirname(t.installationPathOrAdditionalInformation));
}
});
if (installationPaths.size > 0) {
const envVarToolsInstallationPath: string = [...installationPaths.values()].join(path.delimiter);
env[ToolsInstallPath] = envVarToolsInstallationPath;
}
}
export function assert(condition: boolean, message?: string): asserts condition {
if (!condition) {
throw new Error(message);
}
}