Skip to content

chore: replace dotenv-mono with dotenv and try to fix env variables#1261

Merged
Crunchyman-ralph merged 2 commits intonextfrom
ralph/chore/fix.env.variables.in.build
Oct 2, 2025
Merged

chore: replace dotenv-mono with dotenv and try to fix env variables#1261
Crunchyman-ralph merged 2 commits intonextfrom
ralph/chore/fix.env.variables.in.build

Conversation

@Crunchyman-ralph
Copy link
Collaborator

@Crunchyman-ralph Crunchyman-ralph commented Oct 1, 2025

What type of PR is this?

  • 🐛 Bug fix
  • ✨ Feature
  • 🔌 Integration
  • 📝 Docs
  • 🧹 Refactor
  • Other:

Description

Related Issues

How to Test This

# Example commands or steps

Expected result:

Contributor Checklist

  • Created changeset: npm run changeset
  • Tests pass: npm test
  • Format check passes: npm run format-check (or npm run format to fix)
  • Addressed CodeRabbit comments (if any)
  • Linked related issues (if any)
  • Manually tested the changes

Changelog Entry


For Maintainers

  • PR title follows conventional commits
  • Target branch correct
  • Labels added
  • Milestone assigned (if applicable)

Summary by CodeRabbit

  • Refactor
    • Environment variables are now auto-loaded at startup; no manual loading required.
    • API base URL now reads from TM_PUBLIC_BASE_DOMAIN (with existing fallback). Update environment config if needed.
  • Chores
    • Updated dotenv to 16.6.1.
    • Removed dotenv-mono from development dependencies.

@changeset-bot
Copy link

changeset-bot bot commented Oct 1, 2025

⚠️ No Changeset found

Latest commit: 5795870

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 1, 2025

Walkthrough

Updates environment handling and dependencies by removing dotenv-mono, adopting a side-effect dotenv/config import, bumping dotenv. Changes mergeConfig return type to UserConfig and switches tm-core storage fallback env var from HAMSTER_API_URL to TM_PUBLIC_BASE_DOMAIN. No public API additions.

Changes

Cohort / File(s) Change summary
Root & package manifests
package.json, packages/build-config/package.json, packages/tm-core/package.json
Updated dotenv to 16.6.1 and removed dotenv-mono from devDependencies.
Env load entry
tsdown.config.ts
Replaced explicit dotenv-mono loading with a side-effect import "dotenv/config"; removed dotenvLoad() usage.
Build-config merge type
packages/build-config/src/tsdown.base.ts
mergeConfig return type changed from Partial<UserConfig> to UserConfig; merged result cast to UserConfig.
tm-core storage fallback
packages/tm-core/src/storage/storage-factory.ts
Switched fallback environment variable for API endpoint resolution from HAMSTER_API_URL to TM_PUBLIC_BASE_DOMAIN.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant Node as Node.js
  participant TSDown as tsdown.config.ts
  participant Dotenv as dotenv/config

  Note over TSDown,Dotenv: Module initialization time
  Node->>TSDown: import tsdown.config.ts
  TSDown->>Dotenv: import "dotenv/config"
  activate Dotenv
  Dotenv-->>Node: load .env into process.env (side-effect)
  deactivate Dotenv
  TSDown-->>Node: continue config setup
Loading
sequenceDiagram
  autonumber
  participant App as tm-core
  participant Store as storage-factory
  participant Config as app config
  participant Env as process.env

  App->>Store: request API base URL
  alt config.apiEndpoint present
    Store->>Config: read apiEndpoint
    Config-->>Store: return value
  else
    Store->>Env: read TM_PUBLIC_BASE_DOMAIN
    Env-->>Store: value or undefined
    alt undefined
      Store-->>Store: use default URL
    end
  end
  Store-->>App: resolved API base URL
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • eyaltoledano

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title succinctly describes the primary change of replacing dotenv-mono with dotenv and references the associated environment variable fixes, which aligns with the modifications across multiple packages.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch ralph/chore/fix.env.variables.in.build

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8ef2a09 and 5795870.

📒 Files selected for processing (1)
  • packages/tm-core/src/storage/storage-factory.ts (2 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-09-02T21:51:41.383Z
Learnt from: Crunchyman-ralph
PR: eyaltoledano/claude-task-master#1178
File: packages/tm-core/src/auth/config.ts:0-0
Timestamp: 2025-09-02T21:51:41.383Z
Learning: In packages/tm-core/src/auth/config.ts, the BASE_DOMAIN configuration intentionally does not include runtime environment variable fallbacks like TM_BASE_DOMAIN or HAMSTER_BASE_URL. The maintainers prefer to keep these capabilities "hush hush" and undocumented, using only the build-time TM_PUBLIC_BASE_DOMAIN and the default value.

Applied to files:

  • packages/tm-core/src/storage/storage-factory.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Test
🔇 Additional comments (1)
packages/tm-core/src/storage/storage-factory.ts (1)

78-89: LGTM! Environment variable standardization.

The fallback chain now uses TM_PUBLIC_BASE_DOMAIN consistently, improving configuration clarity.


Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2ea4bb6 and 8ef2a09.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (6)
  • package.json (1 hunks)
  • packages/build-config/package.json (0 hunks)
  • packages/build-config/src/tsdown.base.ts (1 hunks)
  • packages/tm-core/package.json (0 hunks)
  • packages/tm-core/src/storage/storage-factory.ts (1 hunks)
  • tsdown.config.ts (1 hunks)
💤 Files with no reviewable changes (2)
  • packages/build-config/package.json
  • packages/tm-core/package.json
🧰 Additional context used
📓 Path-based instructions (1)
package.json

📄 CodeRabbit inference engine (.cursor/rules/test_workflow.mdc)

Add and update test scripts in package.json to include test, test:watch, test:coverage, test:unit, test:integration, test:e2e, and test:ci

Files:

  • package.json
🧠 Learnings (1)
📚 Learning: 2025-09-02T21:51:41.383Z
Learnt from: Crunchyman-ralph
PR: eyaltoledano/claude-task-master#1178
File: packages/tm-core/src/auth/config.ts:0-0
Timestamp: 2025-09-02T21:51:41.383Z
Learning: In packages/tm-core/src/auth/config.ts, the BASE_DOMAIN configuration intentionally does not include runtime environment variable fallbacks like TM_BASE_DOMAIN or HAMSTER_BASE_URL. The maintainers prefer to keep these capabilities "hush hush" and undocumented, using only the build-time TM_PUBLIC_BASE_DOMAIN and the default value.

Applied to files:

  • packages/tm-core/src/storage/storage-factory.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Test
🔇 Additional comments (3)
package.json (2)

20-28: Test scripts are properly configured.

All required test scripts are present: test, test:watch, test:coverage, test:unit, test:integration, test:e2e, and test:ci.

As per coding guidelines.


84-84: Consider explicitly configuring dotenv quiet behavior.

Version 16.6.1 defaults to quiet: true (suppressing informational logs), but version 17.0.0+ defaults to quiet: false. For consistent behavior across future upgrades, consider explicitly setting the quiet option when calling dotenv.config().

In tsdown.config.ts, update the import to explicitly configure dotenv:

-import 'dotenv/config';
+import dotenv from 'dotenv';
+dotenv.config({ quiet: true }); // or false, based on your preference

Based on learnings.

Likely an incorrect or invalid review comment.

tsdown.config.ts (1)

3-3: Side-effect import pattern is appropriate.

Using import 'dotenv/config' ensures environment variables are loaded at module initialization, before getBuildTimeEnvs() reads them. This is the recommended pattern for build-time environment variable injection.

@Crunchyman-ralph Crunchyman-ralph merged commit 604b94b into next Oct 2, 2025
8 checks passed
@coderabbitai coderabbitai bot mentioned this pull request Oct 4, 2025
16 tasks
sfc-gh-dflippo pushed a commit to sfc-gh-dflippo/task-master-ai that referenced this pull request Dec 4, 2025
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