-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Convert bootstrap script to ESM #3904
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "roo-cline": patch | ||
| --- | ||
|
|
||
| Convert bootstrap script to esm | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| #!/usr/bin/env node | ||
|
|
||
| import { spawnSync } from "child_process" | ||
| import { existsSync, writeFileSync } from "fs" | ||
|
|
||
| if (process.env.BOOTSTRAP_IN_PROGRESS) { | ||
| console.log("⏭️ Bootstrap already in progress, continuing with normal installation...") | ||
| process.exit(0) | ||
| } | ||
|
|
||
| // If we're already using pnpm, just exit normally. | ||
| if (process.env.npm_execpath && process.env.npm_execpath.includes("pnpm")) { | ||
| process.exit(0) | ||
| } | ||
|
|
||
| console.log("🚀 Bootstrapping to pnpm...") | ||
|
|
||
| /** | ||
| * Run pnpm install with bootstrap environment variable. | ||
| */ | ||
| function runPnpmInstall(pnpmCommand) { | ||
| return spawnSync(pnpmCommand, ["install"], { | ||
| stdio: "inherit", | ||
| shell: true, | ||
| env: { | ||
| ...process.env, | ||
| BOOTSTRAP_IN_PROGRESS: "1", // Set environment variable to indicate bootstrapping | ||
| }, | ||
| }) | ||
| } | ||
|
|
||
| /** | ||
| * Create a temporary package.json if it doesn't exist. | ||
| */ | ||
| function ensurePackageJson() { | ||
| if (!existsSync("package.json")) { | ||
| console.log("📦 Creating temporary package.json...") | ||
| writeFileSync("package.json", JSON.stringify({ name: "temp", private: true }, null, 2)) | ||
| } | ||
| } | ||
|
|
||
| try { | ||
| // Check if pnpm is installed globally. | ||
| const pnpmCheck = spawnSync("command", ["-v", "pnpm"], { shell: true }) | ||
|
|
||
| let pnpmInstall | ||
|
|
||
| if (pnpmCheck.status === 0) { | ||
| console.log("✨ Found pnpm") | ||
| pnpmInstall = runPnpmInstall("pnpm") | ||
| } else { | ||
| console.log("⚠️ Unable to find pnpm, installing it temporarily...") | ||
| ensurePackageJson() | ||
|
|
||
| console.log("📥 Installing pnpm locally...") | ||
|
|
||
| const npmInstall = spawnSync("npm", ["install", "--no-save", "pnpm"], { | ||
| stdio: "inherit", | ||
| shell: true, | ||
| }) | ||
|
|
||
| if (npmInstall.status !== 0) { | ||
| console.error("❌ Failed to install pnpm locally") | ||
| process.exit(1) | ||
| } | ||
|
|
||
| console.log("🔧 Running pnpm install with local installation...") | ||
| pnpmInstall = runPnpmInstall("node_modules/.bin/pnpm") | ||
| } | ||
|
|
||
| if (pnpmInstall.status !== 0) { | ||
| console.error("❌ pnpm install failed") | ||
| process.exit(pnpmInstall.status) | ||
| } | ||
|
|
||
| console.log("🎉 Bootstrap completed successfully!") | ||
| process.exit(0) | ||
| } catch (error) { | ||
| console.error("💥 Bootstrap failed:", error.message) | ||
| process.exit(1) | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Typo in key:
roo-clineappears to be incorrect. Did you meanroo-cli(orroo-code)?