Skip to content

Give a service its own env, and make services optional - #25

Merged
rhyek merged 1 commit into
mainfrom
chore/service-env-optional-services
Nov 15, 2026
Merged

rhyek merged 1 commit into
mainfrom
chore/service-env-optional-services

Conversation

@rhyek

@rhyek rhyek commented Nov 15, 2026

Copy link
Copy Markdown
Owner

A service takes an env of its own, and services is optional. Releases 0.10.0.

  • services.<name>.env: vars, override, additionalFiles (or the vars callback) and inherits (default true). Inheriting, its vars merge over the config's, override adds, additionalFiles load after the config's; with inherits: false only its own apply. No decrypt: that stays workspace-wide.
  • Resolved once onto the service as envFiles, envOverride and envVars, used by its callbacks, its process, exec/run/resolveEnv() and the .env watcher.
  • A target's process starts from process.env minus the workspace layer the CLI merged in, then takes its own layer, so a service that doesn't inherit gets none of the config's env.
  • The watcher keeps one target per directory and file list, so a file only one service looks for restarts only it; one edit seen by several targets of a directory is one change.
  • services optional: stackctl start with none says so and exits 1; exec, run, show-config work.
  • Docs: a service env section in config/services.md, pointers from the env and commands pages, show-config fields.

Verification

  • pnpm build
  • pnpm lint
  • pnpm test (2607 passed, type tests included)
  • pnpm test:e2e (23 passed)
  • pnpm docs:build (no dead links)
  • node maintenance/scripts/changelog.ts check (releases 0.10.0)
  • The config type check and show-config on example/ and four projects that link stackctl
  • Recordings: affected.ts listed demo, picker, run-screen and getting-started; all skipped, as the example declares no service env and its services resolve the same values.

A service takes an env of its own, with the top level's vars,
override and additionalFiles (or the vars callback) and an inherits
flag, true by default. Inheriting, its vars merge over the config's,
its override adds to the config's, and its additional files load
after the config's, a file named at both levels being an error. With
inherits: false the config's three options don't apply to it. decrypt
stays workspace-wide. defineConfig resolves each service's combined
options once, onto envFiles, envOverride and envVars on the resolved
service, which its callbacks, its process, exec, run and resolveEnv()
use.

Two things had to change for that to hold. A target's process now
starts from process.env with the workspace layer the CLI merged into
it undone, then takes its own layer, since that layer already holds
the config's files and vars when they are its; without this a service
that doesn't inherit got them through process.env anyway. And the
.env watcher keeps one target per directory and file list, so a file
only one service looks for restarts that service alone, with what one
directory's targets report within 50 ms counted as one change.

services is optional: a config may only set the environment of exec
and run. stackctl start says the config declares no services and
exits 1.

The docs gain a service env section, and CHANGELOG.md records 0.10.0.
@rhyek
rhyek merged commit 66356fb into main Nov 15, 2026
5 checks passed
@rhyek
rhyek deleted the chore/service-env-optional-services branch November 15, 2026 07:22
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