import { DialogResponses , IActionContext } from 'vscode-azureextensionui' ; import { initProjectForVSCode } from '../commands/initProjectForVSCode/initProjectForVSCode' ; import { funcVersionSetting , ProjectLanguage , projectLanguageSetting } from '../constants' ; import { FuncVersion , tryParseFuncVersion } from '../FuncVersion' ; import { localize } from '../localize' ; import { nonNullOrEmptyValue } from '../utils/nonNull' ; import { getWorkspaceSetting } from './settings' ; /**
 * Simpler function than `verifyVSCodeConfigOnActivate` to be used right before an operation that requires the project to be initialized for VS Code
 */ export async function verifyInitForVSCode ( context , fsPath , language ? , version ? ) { language = language || getWorkspaceSetting ( projectLanguageSetting , fsPath ) ; version = tryParseFuncVersion ( version || getWorkspaceSetting ( funcVersionSetting , fsPath ) ) ; if ( ! language || ! version ) { const message = localize ( 'initFolder' , 'Initialize project for use with VS Code?' ) ; await context . ui . showWarningMessage ( message , { modal : true , stepName : 'initProject' } , DialogResponses . yes ) ; await initProjectForVSCode ( context , fsPath ) ; language = nonNullOrEmptyValue ( getWorkspaceSetting ( projectLanguageSetting , fsPath ) , projectLanguageSetting ) ; version = nonNullOrEmptyValue ( tryParseFuncVersion ( getWorkspaceSetting ( funcVersionSetting , fsPath ) ) , funcVersionSetting ) ; } return [ < ProjectLanguage > language , < FuncVersion > version ] ; }