Skip to content

feat: add env init command that copies from template placeholders#516

Open
zimeg wants to merge 2 commits intomainfrom
zimeg-feat-env-init
Open

feat: add env init command that copies from template placeholders#516
zimeg wants to merge 2 commits intomainfrom
zimeg-feat-env-init

Conversation

@zimeg
Copy link
Copy Markdown
Member

@zimeg zimeg commented Apr 30, 2026

Changelog

A new env init command copies a template placeholder ".env.sample" or ".env.example" file to the ".env" file of a project.

Summary

This PR adds the env init command that copies from template placeholders 🌲

Preview

Included are expected cases and common edges to encounter! 🔬 ✨

⚡ Bolt Frameworks

  1. An existing placeholder file is used for the new ".env" file
  2. An existing ".env" file is not overwritten
  3. A missing placeholder file notes to use "env set" command
bolt

🥀 ROSI Features

  1. Deployed apps recommend the "env set" command
  2. Local development requires selection and saves to project file
rosi

Testing

Checkout the changes of this branch and experiment with either a Bolt or Deno app:

$ slack create asdf
$ cd asdf
$ slack install     # Required for Deno - Optional for Bolt
$ cat .env.sample   # Inspect values upcoming
$ slack env init
$ cat .env
$ slack env init    # Reattempt the initilization

Notes

Some follow up remains proposed to improve this but is left out of scope for this PR 🏁

  • Prompting for values included in placeholders might be a meaningful improvement to avoid unexpected values. We might find the following format interesting toward this but without much exploration right now:
# COMMENTED_VARIABLE=       # Not prompted
UNCOMMENTED_VARIABLE=       # Prompted
SET_VARIABLE=debug_example  # Not prompted
  • Including this command as part of project init ought make setup a breeze it's been said 😉

Requirements

@zimeg zimeg added this to the Next Release milestone Apr 30, 2026
@zimeg zimeg self-assigned this Apr 30, 2026
@zimeg zimeg requested a review from a team as a code owner April 30, 2026 04:32
@zimeg zimeg added enhancement M-T: A feature request for new functionality changelog Use on updates to be included in the release notes semver:minor Use on pull requests to describe the release version increment labels Apr 30, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 30, 2026

Codecov Report

❌ Patch coverage is 89.71963% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 71.38%. Comparing base (783ac1a) to head (5f997fb).

Files with missing lines Patch % Lines
internal/slackdotenv/slackdotenv.go 68.18% 5 Missing and 2 partials ⚠️
cmd/env/init.go 95.06% 3 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #516      +/-   ##
==========================================
+ Coverage   71.25%   71.38%   +0.13%     
==========================================
  Files         222      223       +1     
  Lines       18682    18789     +107     
==========================================
+ Hits        13311    13413     +102     
- Misses       4190     4195       +5     
  Partials     1181     1181              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Member

@mwbrooks mwbrooks left a comment

Choose a reason for hiding this comment

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

🙇🏻 Thanks a bunch for opening this PR! 🎉 I'm excited to see this one landing.

🧠 Could we swap "template placeholders" for "template file" or ".env template file"? "Placeholder" tends to imply a variable or token that gets substituted, which is a bit ambiguous here. Since we're copying the file verbatim, ".env template file" is more precise and the common convention in the wild from a little Claude research.

Comment thread cmd/env/env.go
}, "\n"),
Example: style.ExampleCommandsf([]style.ExampleCommand{
{
Meaning: "Initialize environment variables from template placeholders",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

suggestion: Minor suggestion to clarify that we're initializing from a file (plus it's shorter, haha).

Suggested change
Meaning: "Initialize environment variables from template placeholders",
Meaning: "Initialize environment variables from a template file",

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog Use on updates to be included in the release notes enhancement M-T: A feature request for new functionality semver:minor Use on pull requests to describe the release version increment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants