@@ -21,14 +21,18 @@ import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskId
2121import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskNotificationEvent
2222import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskNotificationListener
2323import com.intellij.openapi.externalSystem.service.project.ExternalSystemProjectResolver
24+ import com.intellij.openapi.progress.coroutineToIndicator
2425import com.intellij.openapi.progress.runBlockingCancellable
2526import dev.elide.intellij.Constants
27+ import dev.elide.intellij.cli.ElideCommandLine
28+ import dev.elide.intellij.cli.install
2629import dev.elide.intellij.manifests.ElideManifestService
2730import dev.elide.intellij.project.model.ElideProjectModel
2831import dev.elide.intellij.service.ElideDistributionResolver
2932import dev.elide.intellij.settings.ElideExecutionSettings
3033import org.jetbrains.annotations.PropertyKey
3134import java.nio.file.Path
35+ import kotlinx.coroutines.launch
3236import kotlin.io.path.Path
3337import kotlin.io.path.notExists
3438import elide.tooling.lockfile.LockfileLoader
@@ -65,6 +69,9 @@ class ElideProjectResolver : ExternalSystemProjectResolver<ElideExecutionSetting
6569 listener : ExternalSystemTaskNotificationListener
6670 ): DataNode <ProjectData >? {
6771 return runBlockingCancellable {
72+ coroutineToIndicator {
73+
74+ }
6875 LOG .debug(" Resolving project at '$projectPath '" )
6976
7077 val projectModel = runCatching {
@@ -82,14 +89,35 @@ class ElideProjectResolver : ExternalSystemProjectResolver<ElideExecutionSetting
8289 listener.onStep(id, progressMessage(" resolve.steps.parse" ))
8390 val manifest = ElideManifestService ().parse(manifestPath)
8491
85- // call the CLI in case the lockfile is outdated
86- listener.onStep(id, progressMessage(" resolve.steps.refresh" ))
87-
8892 // configure the project
8993 listener.onStep(id, progressMessage(" resolve.steps.configure" ))
9094 val loader = buildProjectLoader(projectRoot, settings)
9195 val project = ElideProjectInfo (projectRoot, manifest, null ).load(loader)
9296
97+ // call the CLI in case the lockfile is outdated
98+ listener.onStep(id, progressMessage(" resolve.steps.refresh" ))
99+ val elideHome = settings?.elideHome ? : ElideDistributionResolver .defaultDistributionPath()
100+ val cli = ElideCommandLine .at(elideHome, projectRoot)
101+
102+ val exitCode = cli.install(
103+ withSources = settings?.downloadSources ? : true ,
104+ withDocs = settings?.downloadDocs ? : true ,
105+ ) { process ->
106+ // pass process output on to the IDE
107+ launch {
108+ process.inputStream.bufferedReader().forEachLine {
109+ listener.onTaskOutput(id, " $it \n " , true )
110+ }
111+ }
112+ launch {
113+ process.errorStream.bufferedReader().forEachLine {
114+ listener.onTaskOutput(id, " $it \n " , false )
115+ }
116+ }
117+ }
118+
119+ if (exitCode != 0 ) error(" Command 'elide install' failed with exit code $exitCode " )
120+
93121 // build the project model from the manifest and lockfile
94122 listener.onStep(id, progressMessage(" resolve.steps.buildModel" ))
95123 ElideProjectModel .buildProjectModel(projectRoot, project)
0 commit comments