@@ -576,9 +576,18 @@ project(":") {
576576 val sandboxPluginDir = layout.projectDirectory
577577 .dir(" .intellijPlatform/sandbox/mpp-idea/${prop(" ideaVersion" )} /plugins/$basePluginArchiveName " )
578578 .asFile
579+ val nodeReplSourceDir = layout.projectDirectory.dir(" ../mpp-ui" ).asFile
580+ val nodeReplRuntimeDir = sandboxPluginDir.resolve(" node-repl" )
581+ val requiredNodeReplSources = listOf (
582+ nodeReplSourceDir.resolve(" bin/autodev-node-repl" ),
583+ nodeReplSourceDir.resolve(" dist/jsMain/typescript/node-repl/server.js" ),
584+ nodeReplSourceDir.resolve(" node-repl.modules.json" ),
585+ nodeReplSourceDir.resolve(" vendor/node" ),
586+ nodeReplSourceDir.resolve(" vendor/node_modules" ),
587+ )
579588
580589 named< org.jetbrains.intellij.platform.gradle.tasks.PrepareSandboxTask > (" prepareSandbox" ) {
581- notCompatibleWithConfigurationCache(" Moves IntelliJ content module jars into the legacy lib layout" )
590+ notCompatibleWithConfigurationCache(" Moves IntelliJ content module jars into the legacy plugin layout" )
582591
583592 // Exclude font files from the plugin distribution
584593 // NotoSansSC-Regular.ttf (~18MB), NotoColorEmoji.ttf (~11MB x2), FiraCode fonts (~1MB)
@@ -648,6 +657,47 @@ project(":") {
648657 }
649658 }
650659
660+ register<Sync >(" syncBundledNodeReplRuntime" ) {
661+ group = " distribution"
662+ description = " Bundles the Node REPL MCP runtime into the IDEA plugin sandbox"
663+ dependsOn(" prepareSandbox" )
664+
665+ into(nodeReplRuntimeDir)
666+ from(nodeReplSourceDir.resolve(" bin" )) {
667+ into(" bin" )
668+ }
669+ from(nodeReplSourceDir.resolve(" dist" )) {
670+ into(" dist" )
671+ }
672+ from(nodeReplSourceDir.resolve(" vendor" )) {
673+ into(" vendor" )
674+ }
675+ from(nodeReplSourceDir.resolve(" node-repl.modules.json" ))
676+
677+ doFirst {
678+ val missingNodeReplSources = requiredNodeReplSources.filterNot { it.exists() }
679+ check(missingNodeReplSources.isEmpty()) {
680+ " Missing Node REPL runtime sources. Run `cd mpp-ui && npm run build:ts && npm run prepare:node-runtime && npm run prepare:node-modules` first.\n " +
681+ missingNodeReplSources.joinToString(" \n " ) { " - ${it.absolutePath} " }
682+ }
683+ }
684+
685+ doLast {
686+ val autodevNodeRepl = nodeReplRuntimeDir.resolve(" bin/autodev-node-repl" )
687+ autodevNodeRepl.setExecutable(true , false )
688+ val nodeReplAlias = nodeReplRuntimeDir.resolve(" bin/node_repl" )
689+ nodeReplAlias.writeText(
690+ """
691+ |#!/usr/bin/env sh
692+ |DIR="${' $' } (CDPATH= cd -- "${' $' } (dirname -- "${' $' } 0")" && pwd)"
693+ |exec "${' $' } DIR/autodev-node-repl" "${' $' } @"
694+ |
695+ """ .trimMargin()
696+ )
697+ nodeReplAlias.setExecutable(true , false )
698+ }
699+ }
700+
651701 // Task to verify no conflicting dependencies are included
652702 register(" verifyNoDuplicateDependencies" ) {
653703 group = " verification"
@@ -704,6 +754,7 @@ project(":") {
704754 // Run verification before build
705755 named(" buildPlugin" ) {
706756 dependsOn(" verifyNoDuplicateDependencies" )
757+ dependsOn(" syncBundledNodeReplRuntime" )
707758 }
708759 }
709760}
0 commit comments