import * as path from 'path' ; import { TestActionContext , TestInput } from 'vscode-azureextensiondev' ; import { createNewProjectInternal , getRandomHexString , hiddenStacksSetting , ProjectLanguage } from '../../extension.bundle' ; import * as api from '../../src/vscode-azurefunctions.api' ; import { testFolderPath } from '../global.test' ; import { runWithFuncSetting } from '../runWithSetting' ; import { IValidateProjectOptions , validateProject } from './validateProject' ; export interface ICreateProjectTestOptions extends IValidateProjectOptions { isHiddenLanguage ? : boolean ; inputs ? : ( string | TestInput | RegExp ) [ ] ; projectPath ? : string ; } export async function createAndValidateProject ( context , options ) { const inputs = options . inputs ? [ ... options . inputs ] : [ ] ; const language = options . language ; const projectPath = options . projectPath || path . join ( testFolderPath , getRandomHexString ( ) , language + 'Project' ) ; if ( ! options . isHiddenLanguage ) { inputs . unshift ( options . displayLanguage || language ) ; } inputs . unshift ( projectPath ) ; inputs . unshift ( '$(file-directory) Browse...' ) ; if ( language !== ProjectLanguage . Java ) { inputs . push ( /skip for now/i ) ; } await runWithFuncSetting ( hiddenStacksSetting , true , async ( ) => { await context . ui . runWithInputs ( inputs , async ( ) => { await createNewProjectInternal ( context , { language : options . isHiddenLanguage ? < api . ProjectLanguage > language : undefined , version : options . version , suppressOpenFolder : true } ) ; } ) ; } ) ; await validateProject ( projectPath , options ) ; }