public async install()

in src/server/install.ts [57:118]


  public async install(): Promise<boolean> {
    // Install at the git root of the current workspace.
    const root = await Utils.getWorkspaceGitRoot()
    if (!root) {
      return false
    }

    const installMode = getExtensionSetting(SettingName.SERVER_INSTALL_MODE)
    if (installMode === 'Prompt') {
      // User prompt before proceeding.
      const installSelection: vscode.MessageItem = {title: 'Install BSP'}
      const userSelection =
        await vscode.window.showErrorMessage<vscode.MessageItem>(
          `Do you want to install the Bazel Build Server in ${root}?`,
          installSelection,
          {title: 'Cancel', isCloseAffordance: true}
        )

      if (userSelection?.title !== installSelection.title) {
        this.outputChannel.appendLine(
          `Installation in ${root} declined by user`
        )
        return false
      }
    } else if (installMode !== 'Auto') {
      // Installation is disabled by setting.
      this.outputChannel.appendLine(
        `Installation in ${root} skipped because '${SettingName.SERVER_INSTALL_MODE}' setting is set to ${installMode}`
      )
      return false
    }

    const installConfig = await this.getInstallConfig()
    if (!installConfig) {
      this.outputChannel.appendLine(
        'Installation interrupted: failed to get settings.'
      )
      this.outputChannel.show()
      return false
    }
    this.outputChannel.appendLine(`Installing Bazel BSP server at ${root}`)

    // Coursier install, to avoid dependence on the local environment.
    const coursierPath = await this.downloadCoursier()
    if (coursierPath === undefined) {
      return false
    }

    // Execute the BSP installer within this workspace.
    const exitCode = await this.runInstaller(coursierPath, root, installConfig)
    if (exitCode !== 0) {
      this.outputChannel.appendLine(
        'Bazel BSP installation failed. Please see output above for details.'
      )
      this.outputChannel.show()
      return false
    }

    // Temporary: Patch the python_info file to be compatible with rules_py.
    await this.patchPythonAspect(root)
    return true
  }