-
Notifications
You must be signed in to change notification settings - Fork 0
feature/add-gradle-init #178
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,35 @@ | ||||||||||||||||||||||||||||||||
| import { spawn } from "child_process"; | ||||||||||||||||||||||||||||||||
| import * as fs from "fs"; | ||||||||||||||||||||||||||||||||
| import * as path from "path"; | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||
| * Pre-warms the Gradle daemon in the background after cloning a repository. | ||||||||||||||||||||||||||||||||
| * This avoids the ~3s daemon initialization overhead on the first build. | ||||||||||||||||||||||||||||||||
| * | ||||||||||||||||||||||||||||||||
| * Silently skips if: | ||||||||||||||||||||||||||||||||
| * - Running on Windows (not a supported environment) | ||||||||||||||||||||||||||||||||
| * - The project does not contain a `gradlew` file (not a Gradle project) | ||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||
| export function warmupGradleDaemon(projectPath: string): void { | ||||||||||||||||||||||||||||||||
| if (process.platform === "win32") { | ||||||||||||||||||||||||||||||||
| return; | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| const gradlewPath = path.join(projectPath, "gradlew"); | ||||||||||||||||||||||||||||||||
| if (!fs.existsSync(gradlewPath)) { | ||||||||||||||||||||||||||||||||
| return; | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||||
| fs.chmodSync(gradlewPath, 0o755); | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| const child = spawn("./gradlew", ["--daemon"], { | ||||||||||||||||||||||||||||||||
| cwd: projectPath, | ||||||||||||||||||||||||||||||||
| detached: true, | ||||||||||||||||||||||||||||||||
| stdio: "ignore", | ||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||
| child.unref(); | ||||||||||||||||||||||||||||||||
|
Comment on lines
+26
to
+31
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: cat -n src/participation/gradle.service.ts | head -50Repository: EduIDE/scorpio Length of output: 1234 Handle detached spawn failures on the child
Suggested fix const child = spawn("./gradlew", ["--daemon"], {
cwd: projectPath,
detached: true,
stdio: "ignore",
});
+ child.on("error", (error) => {
+ console.warn(`Gradle daemon warmup failed: ${error.message}`);
+ });
child.unref();📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||
| } catch (error: any) { | ||||||||||||||||||||||||||||||||
| console.warn(`Gradle daemon warmup failed: ${error.message}`); | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't auto-execute repository-controlled
gradlewduring clone.Because
src/participation/cloning.service.ts:53-57invokes this immediately after cloning, this executes code from the freshly cloned repository before the user has opened or trusted it.gradlewand the wrapper configuration are part of the repo, so a compromised template or participation repository turns this into unintended code execution. Gate this behind explicit opt-in/trust, or defer warmup until the first user-initiated Gradle command.🤖 Prompt for AI Agents