Skip to content

Add interactive environment setup script (npm run setup)#25

Open
Codewithpabitra wants to merge 1 commit intoZenYukti:mainfrom
Codewithpabitra:envScripts
Open

Add interactive environment setup script (npm run setup)#25
Codewithpabitra wants to merge 1 commit intoZenYukti:mainfrom
Codewithpabitra:envScripts

Conversation

@Codewithpabitra
Copy link

Description

Adds an interactive environment setup script to simplify initial project configuration. Users can now run npm run setup to generate backend/.env and frontend/.env from existing .env.example files by providing required credentials.

Type of Change

  • 🐛 Bug fix (non-breaking change which fixes an issue)
  • ✨ New feature (non-breaking change which adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • 📚 Documentation update
  • 🧹 Code refactoring (no functional changes)
  • ⚡ Performance improvement
  • ✅ Test improvement
  • 🔧 Build or CI/CD configuration changes

How Has This Been Tested?

  • Ran npm run setup locally on Windows
  • Verified .env files are generated correctly for both frontend and backend
  • Confirmed project runs successfully using npm run dev

Screenshots

N/A (CLI-based change)

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

Additional Information

  • This change improves onboarding and reduces setup friction, especially for Windows users where manual .env copying can be error-prone.

Learning Outcomes

  • Learned how to build a cross-platform interactive CLI script for environment setup using Node.js.

Let me know if any further improvement is needed on this issue. Thank you !

@github-actions
Copy link

github-actions bot commented Feb 6, 2026

ZenYukti Banner

Yay! You're officially a Contributor! 🎉

Huge thanks for opening this Pull Request. Being a contributor to ZenYukti is a big deal, and we’re excited to have you on board.

Next Steps:

  1. A maintainer will review your code soon.
  2. Please ensure you've linked an assigned issue in the description.
  3. Stay tuned for feedback!

@Codewithpabitra
Copy link
Author

@ayushHardeniya If you tell I can Update the documentation as well. Let me know if further work is required on this issue .
Thank you!

@ayushHardeniya ayushHardeniya linked an issue Feb 6, 2026 that may be closed by this pull request
@ayushHardeniya
Copy link
Member

Hi, thank you for the contribution - we appreciate your effort.

Just a small request: please avoid tagging maintainers imediately after opening an issue or PR.
We review items in the queue, nd response times can vary depending on availability. If there’s no update after about 24 hours, you’re welcome to post a gentle reminder.

Thanks for your patience and for contributing to the project.

@Codewithpabitra
Copy link
Author

Okay, didn't aware of, Thank u!

@ayushHardeniya ayushHardeniya added enhancement New feature or request developer-experience Enhances experience of a developer in IDE or while working on project apertre3.0 Apertre 3.0 open source program medium features involving multiple files or logic. labels Feb 13, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds an interactive CLI-based environment setup script to simplify the initial project configuration for OpenMindWell. Users can now run npm run setup to interactively provide credentials and automatically generate .env files for both backend and frontend from their respective .env.example templates. The script uses the inquirer library for an interactive CLI experience and includes validation for Supabase URLs and API keys.

Changes:

  • Added scripts/setup-env.js to create an interactive environment setup workflow
  • Added inquirer dependency for interactive CLI prompts
  • Added "type": "module" to root package.json to enable ES module syntax in the setup script
  • Updated .gitignore to explicitly include generated .env files

Reviewed changes

Copilot reviewed 2 out of 4 changed files in this pull request and generated 7 comments.

File Description
scripts/setup-env.js New interactive setup script that prompts for Supabase and HuggingFace credentials and generates .env files
package.json Added inquirer dependency, "type": "module" configuration, and new "setup" script command
package-lock.json Lockfile updates for inquirer v13.2.2 and all its dependencies
.gitignore Explicitly added backend/.env and frontend/.env to ignored files

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

"concurrently": "^8.2.2"
},
"dependencies": {
"inquirer": "^13.2.2"
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The inquirer package version 13.2.2 requires Node.js >= 23.5.0 || ^22.13.0 || ^21.7.0 || ^20.12.0, but the backend/package.json specifies "engines": {"node": ">=18.0.0"}. This creates a version mismatch where users on Node.js 18 or 19 (which are valid for the backend) won't be able to run npm install successfully at the root level. Consider either downgrading to inquirer version 9 or 10 (which support Node 18+), or explicitly documenting the Node 20.12+ requirement in the root package.json engines field.

Suggested change
"inquirer": "^13.2.2"
"inquirer": "^10.0.0"

Copilot uses AI. Check for mistakes.
frontendEnv
);

console.log("\n🎊Environment setup complete!");
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing space after emoji. Should be "🎊 Environment setup complete!" for consistency with the warning emoji format on line 18.

Suggested change
console.log("\n🎊Environment setup complete!");
console.log("\n🎊 Environment setup complete!");

Copilot uses AI. Check for mistakes.
Comment on lines +78 to +131
let backendEnv = readTemplate(
resolvePath("backend/.env.example")
);

backendEnv = replaceValue(
backendEnv,
"SUPABASE_URL",
answers.SUPABASE_URL
);

backendEnv = replaceValue(
backendEnv,
"SUPABASE_ANON_KEY",
answers.SUPABASE_ANON_KEY
);

backendEnv = replaceValue(
backendEnv,
"SUPABASE_SERVICE_ROLE_KEY",
answers.SUPABASE_SERVICE_ROLE_KEY
);

backendEnv = replaceValue(
backendEnv,
"HUGGINGFACE_API_TOKEN",
answers.HUGGINGFACE_API_TOKEN || ""
);

writeEnv(
resolvePath("backend/.env"),
backendEnv
);

// frontend
let frontendEnv = readTemplate(
resolvePath("frontend/.env.example")
);

frontendEnv = replaceValue(
frontendEnv,
"VITE_SUPABASE_URL",
answers.SUPABASE_URL
);

frontendEnv = replaceValue(
frontendEnv,
"VITE_SUPABASE_ANON_KEY",
answers.SUPABASE_ANON_KEY
);

writeEnv(
resolvePath("frontend/.env"),
frontendEnv
);
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The script doesn't handle or copy other required environment variables from the .env.example files. For backend, it's missing FRONTEND_URL, PORT, RATE_LIMIT_WINDOW_MS, and RATE_LIMIT_MAX_REQUESTS. For frontend, it's missing VITE_API_BASE_URL and VITE_WS_URL. Users will need to manually add these after running the script, which defeats the purpose of automated setup. Consider either prompting for these values or preserving all non-sensitive defaults from the .env.example files when generating the .env files.

Copilot uses AI. Check for mistakes.
Comment on lines +57 to +66
validate: (v) =>
v.length > 40 ? true : "Key looks too short",
},
{
type: "input",
name: "SUPABASE_SERVICE_ROLE_KEY",
message: "Supabase Service Role Key:",
filter: (v) => v.trim(),
validate: (v) =>
v.length > 40 ? true : "Key looks too short",
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The validation for Supabase keys (length > 40) is too simplistic and may give users a false sense of security. Valid Supabase JWT tokens are typically 200+ characters long. Consider either removing this validation (since invalid keys will fail at runtime anyway) or making it more strict (e.g., length > 100) to catch obvious mistakes while avoiding false positives.

Copilot uses AI. Check for mistakes.
Comment on lines +27 to +28
const replaceValue = (env, key, value) => {
const regex = new RegExp(`^${key}=.*$`, "m");
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The regex replacement doesn't escape special regex characters in the key parameter. If a key contains regex special characters like dots, brackets, or dollar signs, the regex could fail or behave unexpectedly. While current environment variable names don't contain such characters, this could cause issues if the template format changes. Consider escaping the key using a utility like key.replace(/[.*+?^${}()|[]\]/g, '\$&') before creating the regex.

Suggested change
const replaceValue = (env, key, value) => {
const regex = new RegExp(`^${key}=.*$`, "m");
const escapeRegex = (str) => str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
const replaceValue = (env, key, value) => {
const escapedKey = escapeRegex(key);
const regex = new RegExp(`^${escapedKey}=.*$`, "m");

Copilot uses AI. Check for mistakes.
Comment on lines 27 to 32
"concurrently": "^8.2.2"
},
"dependencies": {
"inquirer": "^13.2.2"
}
}
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding inquirer as a production dependency rather than a devDependency may not be ideal since it's only used during setup/development, not at runtime. Consider moving it to devDependencies to keep the production installation leaner.

Suggested change
"concurrently": "^8.2.2"
},
"dependencies": {
"inquirer": "^13.2.2"
}
}
"concurrently": "^8.2.2",
"inquirer": "^13.2.2"
},
"dependencies": {}
}

Copilot uses AI. Check for mistakes.

(async () => {
try {
console.log("\nOpenMindWell environment setup\n");
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The console message refers to "OpenMindWell" but based on the PR description and title, this PR was submitted for "ZenYukti". This inconsistency could be confusing for users running the setup script. The project is named "OpenMindWell" according to the package.json and README.md, so this appears to be correct, but the PR description references ZenYukti as if that's the project name.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

apertre3.0 Apertre 3.0 open source program developer-experience Enhances experience of a developer in IDE or while working on project enhancement New feature or request medium features involving multiple files or logic.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

make setup easier with an interactive script

2 participants

Comments