import { access , ensureDir } from "fs-extra" ; import { isAbsolute , resolve } from "path" ; import { window , workspace , WorkspaceFolder } from "vscode" ; import IEnvironment from "./IEnvironment" ; export default class VSCEnvironment implements IEnvironment { private workspaceConfiguration = workspace . getConfiguration ( "azurite" ) ; public blobHost ( ) { return this . workspaceConfiguration . get < string > ( "blobHost" ) ; } public blobPort ( ) { return this . workspaceConfiguration . get < number > ( "blobPort" ) ; } public queueHost ( ) { return this . workspaceConfiguration . get < string > ( "queueHost" ) ; } public queuePort ( ) { return this . workspaceConfiguration . get < number > ( "queuePort" ) ; } public tableHost ( ) { return this . workspaceConfiguration . get < string > ( "tableHost" ) ; } public tablePort ( ) { return this . workspaceConfiguration . get < number > ( "tablePort" ) ; } public async location ( ) { let location = this . workspaceConfiguration . get < string > ( "location" ) ; if ( location === undefined || location === "" || ! isAbsolute ( location ) ) { if ( workspace . workspaceFolders === undefined || workspace . workspaceFolders . length === 0 ) { throw Error ( `Invalid workspace location for Azurite. Please open a folder in Visual Studio Code, or provide a valid workspace folder path for Azurite in Visual Studio Code setting "azurite.location"` ) ; } let folder ; if ( workspace . workspaceFolders . length > 1 ) { folder = await window . showWorkspaceFolderPick ( { placeHolder : "Select the working directory you wish to use as Azurite workspace location" } ) ; if ( folder === undefined ) { throw Error ( `Invalid workspace location for Azurite. Please select a folder in Visual Studio Code, or provide a valid workspace folder path for Azurite in Visual Studio Code setting "azurite.location"` ) ; } } else { folder = workspace . workspaceFolders [ 0 ] ; } location = resolve ( folder . uri . fsPath , location ?? '' ) ; } await ensureDir ( location ) ; await access ( location ) ; return location ; } public silent ( ) { return this . workspaceConfiguration . get < boolean > ( "silent" ) || false ; } public loose ( ) { return this . workspaceConfiguration . get < boolean > ( "loose" ) || false ; } public skipApiVersionCheck ( ) { return ( this . workspaceConfiguration . get < boolean > ( "skipApiVersionCheck" ) || false ) ; } public async debug ( ) { return this . workspaceConfiguration . get < boolean > ( "debug" ) || false ; } public cert ( ) { return this . workspaceConfiguration . get < string > ( "cert" ) ; } public key ( ) { return this . workspaceConfiguration . get < string > ( "key" ) ; } public pwd ( ) { return this . workspaceConfiguration . get < string > ( "pwd" ) ; } public oauth ( ) { return this . workspaceConfiguration . get < string > ( "oauth" ) ; } public disableProductStyleUrl ( ) { return ( this . workspaceConfiguration . get < boolean > ( "disableProductStyleUrl" ) || false ) ; } }