import * as fse from 'fs-extra' ; import * as path from 'path' ; import * as semver from 'semver' ; import { TaskDefinition } from 'vscode' ; import { extensionsCsprojFileName , extInstallTaskName , func , hostStartCommand , ProjectLanguage } from '../../../constants' ; import { getLocalFuncCoreToolsVersion } from '../../../funcCoreTools/getLocalFuncCoreToolsVersion' ; import { FuncVersion } from '../../../FuncVersion' ; import { getFuncWatchProblemMatcher } from '../../../vsCodeConfig/settings' ; import { IProjectWizardContext } from '../../createNewProject/IProjectWizardContext' ; import { InitVSCodeStepBase } from './InitVSCodeStepBase' ; /**
 * Base class for all projects based on a simple script (i.e. JavaScript, C# Script, Bash, etc.) that don't require compilation
 */ export class ScriptInitVSCodeStep extends InitVSCodeStepBase { protected useFuncExtensionsInstall : boolean = false ; protected getTasks ( language ) { return [ { type : func , command : hostStartCommand , problemMatcher : getFuncWatchProblemMatcher ( language ) , dependsOn : this . useFuncExtensionsInstall ? extInstallTaskName : undefined , isBackground : true } ] ; } protected async executeCore ( context ) { try { const extensionsCsprojPath = path . join ( context . projectPath , extensionsCsprojFileName ) ; if ( await fse . pathExists ( extensionsCsprojPath ) ) { this . useFuncExtensionsInstall = true ; context . telemetry . properties . hasExtensionsCsproj = 'true' ; } else if ( context . version === FuncVersion . v2 ) { const currentVersion = await getLocalFuncCoreToolsVersion ( context , context . workspacePath ) ; this . useFuncExtensionsInstall = ! ! currentVersion && semver . lte ( currentVersion , '2.5.553' ) ; } } catch { } if ( this . useFuncExtensionsInstall ) { this . settings . push ( { prefix : 'files' , key : 'exclude' , value : { obj : true , bin : true } } ) ; if ( ! this . preDeployTask ) { this . preDeployTask = extInstallTaskName ; } } this . setDeploySubpath ( context , '.' ) ; } }