Skip to content

Commit 6397b55

Browse files
Merge pull request #3 from Zoo-Code-Org/feature/managed-node-runtime-3k1xawiz11eht
[Feat] Download managed Node.js runtime on first launch
2 parents 02c7c33 + 754bcbc commit 6397b55

3 files changed

Lines changed: 377 additions & 5 deletions

File tree

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ The plugin targets IntelliJ Platform build **233** (JetBrains 2023.3) or newer.
8181
- A supported JetBrains IDE based on IntelliJ Platform build 233 or newer
8282
- Android Studio 2026.1.4 or newer when using Android Studio; install a preview build until this version reaches the stable channel
8383
- A JCEF-enabled IDE runtime, which Zoo Code requires to render its interface
84-
- Node.js **20.6.0 or newer** available on your `PATH`
84+
85+
On first launch the plugin automatically downloads a pinned, platform-specific Node.js runtime from [nodejs.org](https://nodejs.org) (checksum-verified) and uses it to run the extension host, so no local Node.js installation is required. If the download is unavailable, the plugin falls back to a bundled Node.js or a Node.js **20.6.0 or newer** found on your `PATH`.
8586

8687
### Building from source
8788

@@ -229,8 +230,8 @@ The JetBrains plugin communicates with the Extension Host using RPC over Unix-do
229230

230231
### Plugin does not load
231232

232-
- Confirm Node.js 20.6.0 or newer is installed with `node --version`.
233-
- Make sure Node.js is available on the IDE process `PATH`.
233+
- On first launch, watch the IDE progress panel for the "Downloading Node.js runtime" task; the plugin needs network access to `nodejs.org` unless a suitable Node.js is already installed.
234+
- If you use a local Node.js instead (for example through a version manager), confirm it is 20.6.0 or newer with `node --version` and available on the IDE process `PATH`.
234235
- Restart the IDE after installing the plugin.
235236
- Review the JetBrains IDE log for Zoo Code or Extension Host errors.
236237
- See [Known Issues](docs/KNOWN_ISSUES.md).

jetbrains_plugin/src/main/kotlin/org/zoocode/jetbrains/core/ExtensionProcessManager.kt

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,24 @@ class ExtensionProcessManager : Disposable {
292292
* Find Node.js executable
293293
*/
294294
private fun findNodeExecutable(): String? {
295-
// First check built-in Node.js
295+
// First check the managed Node.js runtime downloaded by the plugin
296+
NodeRuntimeManager.findManagedNodeExecutable()?.let {
297+
LOG.info("Using managed Node.js runtime: $it")
298+
return it
299+
}
300+
301+
// Download the managed runtime on first launch (shows progress), unless it failed recently
302+
val shouldAttemptDownload = !NodeRuntimeManager.hasRecentDownloadFailure()
303+
if (shouldAttemptDownload) {
304+
NodeRuntimeManager.getOrDownloadNodeExecutable()?.let {
305+
LOG.info("Downloaded managed Node.js runtime: $it")
306+
return it
307+
}
308+
} else {
309+
LOG.info("Skipping managed Node.js runtime download: previous attempt failed recently")
310+
}
311+
312+
// Then check built-in Node.js
296313
val resourcesPath = PluginResourceUtil.getResourcePath(PLUGIN_ID, NODE_MODULES_PATH)
297314
if (resourcesPath != null) {
298315
val resourceDir = File(resourcesPath)
@@ -310,7 +327,14 @@ class ExtensionProcessManager : Disposable {
310327
}
311328

312329
// Then check system path
313-
return findExecutableInPath("node")
330+
findExecutableInPath("node")?.let { return it }
331+
332+
// Last resort: retry the managed download even if it failed recently,
333+
// since no other Node.js executable is available
334+
if (!shouldAttemptDownload) {
335+
return NodeRuntimeManager.getOrDownloadNodeExecutable()
336+
}
337+
return null
314338
}
315339

316340
/**

0 commit comments

Comments
 (0)