export async function deploy()

in src/commands/deploy/deploy.ts [33:120]


export async function deploy(actionContext: IActionContext, arg1?: vscode.Uri | SiteTreeItem, arg2?: (vscode.Uri | SiteTreeItem)[], isNewApp: boolean = false): Promise<void> {
    actionContext.telemetry.properties.deployedWithConfigs = 'false';
    let siteConfig: WebSiteManagementModels.SiteConfigResource | undefined;
    let client: SiteClient;
    if (arg1 instanceof SiteTreeItem) {
        client = await arg1.site.createClient(actionContext);
        // we can only get the siteConfig earlier if the entry point was a treeItem
        siteConfig = await client.getSiteConfig();
    }

    const fileExtensions: string | string[] | undefined = await javaUtils.getJavaFileExtensions(siteConfig);

    const deployPaths: IDeployPaths = await getDeployFsPath(actionContext, arg1, fileExtensions);
    const context: IDeployContext = Object.assign(actionContext, deployPaths, { defaultAppSetting: constants.configurationSettings.defaultWebAppToDeploy, isNewApp });

    // because this is workspace dependant, do it before user selects app
    await setPreDeployConfig(context);
    const node: SiteTreeItem = await getDeployNode(context, ext.tree, arg1, arg2, [WebAppTreeItem.contextValue]);
    client = await node.site.createClient(actionContext);

    const correlationId: string = getRandomHexString();
    context.telemetry.properties.correlationId = correlationId;

    // if we already got siteConfig, don't waste time getting it again
    siteConfig = siteConfig ? siteConfig : await client.getSiteConfig();

    if (javaUtils.isJavaRuntime(siteConfig)) {
        await javaUtils.configureJavaSEAppSettings(context, node);
    }

    const isZipDeploy: boolean = siteConfig.scmType !== constants.ScmType.LocalGit && siteConfig !== constants.ScmType.GitHub;
    // only check enableScmDoBuildDuringDeploy if currentWorkspace matches the workspace being deployed as a user can "Browse" to a different project
    if (getWorkspaceSetting<boolean>(constants.configurationSettings.showBuildDuringDeployPrompt, context.effectiveDeployFsPath)) {
        const remoteSettings: WebSiteManagementModels.StringDictionary = await client.listApplicationSettings();
        const hasSCMDoBuildSetting: boolean = !!remoteSettings.properties && 'SCM_DO_BUILD_DURING_DEPLOYMENT' in remoteSettings.properties;
        //check if node is being zipdeployed and that there is no .deployment file
        if (!hasSCMDoBuildSetting && siteConfig.linuxFxVersion && isZipDeploy && !(await pathExists(path.join(context.effectiveDeployFsPath, constants.deploymentFileName)))) {
            const linuxFxVersion: string = siteConfig.linuxFxVersion.toLowerCase();
            if (linuxFxVersion.startsWith(LinuxRuntimes.node)) {
                // if it is node or python, prompt the user (as we can break them)
                await promptScmDoBuildDeploy(context, context.effectiveDeployFsPath, LinuxRuntimes.node);
            } else if (linuxFxVersion.startsWith(LinuxRuntimes.python)) {
                await promptScmDoBuildDeploy(context, context.effectiveDeployFsPath, LinuxRuntimes.python);
            }
        }
    }

    if (getWorkspaceSetting<boolean>('showDeployConfirmation', context.workspaceFolder.uri.fsPath) && !context.isNewApp && isZipDeploy) {
        await showDeployConfirmation(context, node.site, 'appService.Deploy');
    }

    void promptToSaveDeployDefaults(context, node, context.workspaceFolder.uri.fsPath, context.effectiveDeployFsPath);
    await appservice.runPreDeployTask(context, context.originalDeployFsPath, siteConfig.scmType);

    // cancellation moved to after prompts while gathering telemetry
    // cancel the previous detector check from the same web app
    const previousTokenSource: vscode.CancellationTokenSource | undefined = postDeployCancelTokens.get(node.id);
    if (previousTokenSource) {
        previousTokenSource.cancel();
    }

    // only respect the deploySubpath settings for zipdeploys
    const deployPath: string = isZipDeploy ? context.effectiveDeployFsPath : context.originalDeployFsPath;

    if (!isZipDeploy && isPathEqual(context.effectiveDeployFsPath, context.originalDeployFsPath)) {
        const noSubpathWarning: string = localize('ignoreSuppath', 'WARNING: Ignoring deploySubPath "{0}" for non-zip deploy.', getWorkspaceSetting(constants.configurationSettings.deploySubpath));
        ext.outputChannel.appendLog(noSubpathWarning);
    }

    await node.runWithTemporaryDescription(context, localize('deploying', "Deploying..."), async () => {
        try {
            await appservice.deploy(nonNullValue(node).site, <string>deployPath, context);
        } catch (error) {
            if (!actionContext.errorHandling.suppressDisplay
                && failureMoreInfoSurvey(parseError(error), nonNullValue(siteConfig))) {
                actionContext.errorHandling.suppressDisplay = true;
            }
            throw error;
        }
    });

    const tokenSource: vscode.CancellationTokenSource = new vscode.CancellationTokenSource();
    postDeployCancelTokens.set(node.id, tokenSource);

    showDeployCompletedMessage(context, node);

    runPostDeployTask(context, node, correlationId, tokenSource);
}