Standardize repo .env loading for local scripts #275

Closed
opened 2026-06-04 20:20:04 +00:00 by steve · 0 comments
Owner

Problem

Only pnpm docker:ci-check reads repo-root .env, and only for turbo remote-cache keys. Other local scripts require inline exports (e.g. FORGEJO_TOKEN=... pnpm release:desktop:local). .env.example documents turbo cache vars only.

Goal

Every local script entry point that reads developer-facing env vars should bootstrap repo-root .env before parsing config, with shell exports taking precedence. Document all supported vars in .env.example and spec.

Scope

  • scripts/load-repo-env.mjs: add applyRepoEnv
  • Tier A root scripts: release, forgejo, verify-release-assets, publish-official-plugin-assets, publish-lapis-ci-image, run-lapis-ci-check, run-agent-smoke
  • Tier B package scripts: dev, notarize, run-electron-builder, capture-media, run-smoke (desktop + workspace)
  • Harmonize FORGEJO_* fallbacks in publish-official-plugin-assets
  • Expand .env.example and update monorepo-scripts + release docs

Non-goals

  • CI-only vars, tea CLI auth, build-time commit injection, Vite runtime app env

Acceptance Criteria

  • Every Tier A/B entry point calls applyRepoEnv before reading env-dependent config
  • .env.example lists every developer-facing var with purpose and consuming command(s)
  • Shell-exported vars override .env file values
  • publish-official-plugin-assets accepts FORGEJO_SERVER_URL / FORGEJO_REPOSITORY in addition to GITHUB_*
  • Spec documents the .env contract; make spec-lint passes

Implementation Notes

Use applyRepoEnv(repoRoot) which merges parsed .env into process.env only for undefined keys.

Suggested Files or Specs To Inspect

  • scripts/load-repo-env.mjs
  • .env.example
  • spec/src/80-maintenance/monorepo-scripts.md

Validation Commands

pnpm check:all
make spec-lint
  • #274 (turbo cache .env.example precedent)

Follow-up Tasks

Implementation Summary

Added applyRepoEnv() to load-repo-env.mjs and wired repo-root .env bootstrap into release, registry, CI image, docker:ci-check, smoke, dev, notarize, electron-builder, and capture-media entry points. Expanded .env.example with documented vars; harmonized FORGEJO_* fallbacks in publish-official-plugin-assets; updated monorepo-scripts and release docs. Validated with pnpm check:all and make spec-lint.

## Problem Only `pnpm docker:ci-check` reads repo-root `.env`, and only for turbo remote-cache keys. Other local scripts require inline exports (e.g. `FORGEJO_TOKEN=... pnpm release:desktop:local`). `.env.example` documents turbo cache vars only. ## Goal Every local script entry point that reads developer-facing env vars should bootstrap repo-root `.env` before parsing config, with shell exports taking precedence. Document all supported vars in `.env.example` and spec. ## Scope - `scripts/load-repo-env.mjs`: add `applyRepoEnv` - Tier A root scripts: release, forgejo, verify-release-assets, publish-official-plugin-assets, publish-lapis-ci-image, run-lapis-ci-check, run-agent-smoke - Tier B package scripts: dev, notarize, run-electron-builder, capture-media, run-smoke (desktop + workspace) - Harmonize `FORGEJO_*` fallbacks in publish-official-plugin-assets - Expand `.env.example` and update monorepo-scripts + release docs ## Non-goals - CI-only vars, tea CLI auth, build-time commit injection, Vite runtime app env ## Acceptance Criteria - Every Tier A/B entry point calls `applyRepoEnv` before reading env-dependent config - `.env.example` lists every developer-facing var with purpose and consuming command(s) - Shell-exported vars override `.env` file values - `publish-official-plugin-assets` accepts `FORGEJO_SERVER_URL` / `FORGEJO_REPOSITORY` in addition to `GITHUB_*` - Spec documents the `.env` contract; `make spec-lint` passes ## Implementation Notes Use `applyRepoEnv(repoRoot)` which merges parsed `.env` into `process.env` only for undefined keys. ## Suggested Files or Specs To Inspect - `scripts/load-repo-env.mjs` - `.env.example` - `spec/src/80-maintenance/monorepo-scripts.md` ## Validation Commands ```bash pnpm check:all make spec-lint ``` ## Related Issues - #274 (turbo cache `.env.example` precedent) ## Follow-up Tasks ## Implementation Summary Added applyRepoEnv() to load-repo-env.mjs and wired repo-root .env bootstrap into release, registry, CI image, docker:ci-check, smoke, dev, notarize, electron-builder, and capture-media entry points. Expanded .env.example with documented vars; harmonized FORGEJO_* fallbacks in publish-official-plugin-assets; updated monorepo-scripts and release docs. Validated with pnpm check:all and make spec-lint. <!-- backlog:task_id=TASK-TEST-ENV-001 source_spec=spec/src/80-maintenance/monorepo-scripts.md -->
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
lapis-notes/lapis#275
No description provided.