func PrepareHost()

in internal/core/startup/prepare.go [52:111]


func PrepareHost(commonCtx commoncontext.Context) PreparedHost {
	prod := product.Product{}
	cloudUploadToken := commonCtx.QodanaToken
	ideDir := ""

	if commonCtx.IsClearCache {
		err := os.RemoveAll(commonCtx.CacheDir)
		if err != nil {
			log.Errorf("Could not clear local Qodana cache: %s", err)
		}
	}
	nuget.WarnIfPrivateFeedDetected(commonCtx.Analyzer, commonCtx.ProjectDir)
	if nuget.IsNugetConfigNeeded() {
		nuget.PrepareNugetConfig(os.Getenv("HOME"))
	}
	if err := os.MkdirAll(commonCtx.CacheDir, os.ModePerm); err != nil {
		log.Fatal("couldn't create a directory ", err.Error())
	}
	if err := os.MkdirAll(commonCtx.ResultsDir, os.ModePerm); err != nil {
		log.Fatal("couldn't create a directory ", err.Error())
	}
	if err := os.MkdirAll(commonCtx.ReportDir, os.ModePerm); err != nil {
		log.Fatal("couldn't create a directory ", err.Error())
	}

	if commonCtx.Analyzer.DownloadDist() {
		linter := commonCtx.Analyzer.GetLinter()
		msg.PrintProcess(
			func(spinner *pterm.SpinnerPrinter) {
				if spinner != nil {
					spinner.ShowTimer = false // We will update interactive spinner
				}
				ideDir = downloadAndInstallIDE(commonCtx.Analyzer, commonCtx.QodanaSystemDir, spinner)
				fixWindowsPlugins(ideDir)
			},
			fmt.Sprintf("Downloading %s", linter.Name),
			fmt.Sprintf("downloading IDE distribution to %s", commonCtx.QodanaSystemDir),
		)
	}

	if commonCtx.Analyzer.IsContainer() {
		qdcontainer.PrepareContainerEnvSettings()
	} else {
		prod, cloudUploadToken = prepareLocalIdeSettingsAndGetQodanaCloudUploadToken(commonCtx, ideDir)
		// in case of container run the token passed directly (ref - core/container.go#getDockerOptions)
		prepareQodanaTokenForNative(cloudUploadToken)
	}

	if tokenloader.IsCloudTokenRequired(commonCtx) {
		cloudUploadToken = tokenloader.ValidateCloudToken(commonCtx, false)
	}
	checkVcsSameAsRepositoryRoot(commonCtx)

	result := PreparedHost{
		IdeDir:            ideDir,
		QodanaUploadToken: cloudUploadToken,
		Prod:              prod,
	}
	return result
}