Skip to content

Add environment variables using Belt CLI#78

Open
rakeshpetit wants to merge 5 commits into
mainfrom
add-env-variable-support
Open

Add environment variables using Belt CLI#78
rakeshpetit wants to merge 5 commits into
mainfrom
add-env-variable-support

Conversation

@rakeshpetit

@rakeshpetit rakeshpetit commented May 22, 2026

Copy link
Copy Markdown
Contributor

In this PR, we add a new belt add env CLI command that sets up environment variable management in an Expo project using the EXPO_PUBLIC_ mechanism.

What the command does

  • Installs dotenv as a dev dependency.
  • Copies template files: .env.example, .env.test, jest.setup.env.js, and src/config/index.ts.
  • Creates .env from .env.example if it doesn't already exist.
  • Patches src/util/api/api.ts to replace the hardcoded GitHub API URL with EXPO_PUBLIC_API_BASE_URL.
  • Patches jest.config.js to load jest.setup.env.js via setupFiles.

Refactoring existing notifications code

Reusable utilities were extracted as part of this work and applied to both env and notifications:

  • src/util/patchFile.ts - generic read/search/replace/write function to patch existing project files.
  • src/util/confirmToProceed.ts - interactive intro prompt shared across commands.
  • handleCommitError moved to be used in multiple commands.

Both env and notifications command now have:

  • Improved error handling using a try/catch with spinner.fail(error.message) so the terminal doesn't hang on errors.
  • Multi-line user facing strings extracted to named constants for better readability of the code

@rakeshpetit rakeshpetit force-pushed the add-env-variable-support branch from 0eb08b9 to 19e8dc0 Compare June 5, 2026 09:01
@rakeshpetit rakeshpetit changed the title add support for environment variables using Belt CLI add environment variables using Belt CLI Jun 5, 2026
@rakeshpetit rakeshpetit marked this pull request as ready for review June 5, 2026 09:43
@rakeshpetit rakeshpetit requested a review from codeofdiego as a code owner June 5, 2026 09:43
@rakeshpetit rakeshpetit changed the title add environment variables using Belt CLI Add environment variables using Belt CLI Jun 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant