Skip to content

Commit 3fdff69

Browse files
authored
Merge pull request #11 from rhyek/faster-startup-env-decrypt
Start commands sooner, and make decrypting .env values opt-in
2 parents 94decdc + c868189 commit 3fdff69

104 files changed

Lines changed: 3113 additions & 1388 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.claude/rules/project-wording.md‎

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ paths:
55
- "docs/.vitepress/config.ts"
66
- "packages/stackctl/package.json"
77
- "packages/stackctl/src/cli.ts"
8-
- "docs/public/logo.svg"
8+
- "logo/**"
99
---
1010

1111
# How stackctl describes itself — one wording and one icon, everywhere, in lockstep
@@ -51,21 +51,32 @@ Where each one lives:
5151

5252
## The icon
5353

54-
`docs/public/logo.svg` is the icon: a prompt in front of three log lines, the middle one yellow,
55-
on a dark rounded tile. Everything else is made from it, so a change to it is a change to all of
56-
them, in the same change:
54+
`logo/` holds the icon and everything made from it. `logo/logo.svg` is the icon: a prompt in
55+
front of three log lines, the middle one yellow, on a dark rounded tile. `logo/logo-small.svg` is
56+
the same icon for small sizes, with the three lines as thick as the prompt's stroke. Everything
57+
else is made from one of the two, so a change to the icon is a change to both and to all of
58+
these, in the same change:
5759

5860
| Place | File | Wired in |
5961
| --------------------------------------- | ---------------------------------- | ------------------------------------------ |
60-
| The browser tab | `logo.svg`, and `favicon-32.png` | `head` in `docs/.vitepress/config.ts` |
61-
| An iPhone's home screen | `apple-touch-icon.png` (180 px, square: iOS rounds it) | `head` |
62-
| The site's nav bar | `logo.svg` | `themeConfig.logo` |
62+
| The browser tab | `logo-small.svg`, and `site/favicon-32.png` | `head` in `docs/.vitepress/config.ts` |
63+
| An iPhone's home screen | `site/apple-touch-icon.png` (180 px, square: iOS rounds it) | `head` |
64+
| The site's nav bar | `logo-small.svg` | `themeConfig.logo` |
6365
| The home page, beside the headline | `logo.svg` | `hero.image` in `docs/index.md` |
64-
| A link's preview (Slack, X, …) | `og-image.png` (512 px, square corners: Slack rounds it) | `og:image` in `head` |
66+
| A link's preview (Slack, X, …) | `site/og-image.png` (512 px, square corners: Slack rounds it) | `og:image` in `head` |
67+
| `stackctl.config.*` in VS Code's icon themes | `icon-themes/vscode/<theme id>/` (from `logo-small.svg`) | upstream, by pull request ([its README](../../logo/icon-themes/README.md)) |
6568

66-
- **The PNGs are renders of the SVG.** Re-render all three when it changes, at their sizes, from
67-
a browser (headless Chrome with a transparent background; the touch icon and the preview from
68-
the SVG with the tile's corners squared).
69+
- **The site serves them through links.** VitePress only serves files from `docs/public/`, so
70+
each file the site uses has a relative symlink there, under the name its URL uses
71+
(`docs/public/logo.svg` → `../../logo/logo.svg`). A new file the site needs gets one too.
72+
`docs.yaml` deploys on a change to `logo/` as well as `docs/`.
73+
- **The PNGs are renders of the SVGs.** Re-render all three when either changes, at their sizes,
74+
from a browser (headless Chrome with a transparent background): `favicon-32.png` from
75+
`logo-small.svg`; the touch icon and the preview from `logo.svg` with the tile's corners
76+
squared.
77+
- **The icon themes' SVGs are written from `logo-small.svg`** by
78+
`node maintenance/scripts/icon-themes.ts`. Run it when that changes; a theme that already
79+
carries the icon then needs a pull request of its own.
6980
- **Every URL to them carries a hash of the file** (`versioned()` in the site config), so a
7081
changed icon is a new URL and no browser or CDN keeps the old one. Reference a public file
7182
through it, never by its bare path.

‎.github/workflows/docs.yaml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ on:
88
branches: [main]
99
paths:
1010
- 'docs/**'
11+
- 'logo/**'
1112
- 'package.json'
1213
- 'pnpm-lock.yaml'
1314
- '.github/workflows/docs.yaml'

‎CHANGELOG.md‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,28 @@
11
# Changelog
22

3+
## 0.6.0
4+
5+
### Features
6+
7+
- **`env.decrypt` decrypts `.env` values encrypted with dotenvx**, so a file of secrets can be
8+
committed. See [docs/config/env.md](docs/config/env.md#envdecrypt).
9+
10+
### Fixes
11+
12+
- **`sctl exec` or `sctl run` in a dev script no longer logs twice, records an event or keeps a process running.**
13+
See [docs/guide/commands.md](docs/guide/commands.md#output-and-exit-code).
14+
- **Every command that reads the config starts about 65 ms sooner**, and `sctl exec` and
15+
`sctl run` about 110 ms sooner.
16+
- **An infra callback's `exec` says why a command couldn't start**, a missing `cwd` included.
17+
- **stackctl installs 19 fewer packages.**
18+
19+
### Breaking changes
20+
21+
- **`stackctl` no longer exports `z`**: for a `logs.formatter` that validates with zod, add `zod`
22+
to your own dependencies and import `z` from it.
23+
- **An `.env` value encrypted with dotenvx stays encrypted unless `env.decrypt` is set**: add
24+
`env: { decrypt: true }` to `stackctl.config.ts`.
25+
326
## 0.5.1
427

528
### Fixes

‎CLAUDE.md‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ Monorepo for the published `stackctl` npm package.
66
- `example/` — a self-contained example monorepo that consumes the package via
77
`stackctl: link:../packages/stackctl` (see `example/package.json`).
88
- `maintenance/` — the project's own notes and tooling. See [Maintenance](#maintenance).
9+
- `logo/` — the icon, its renders for the site and its files for VS Code's icon themes. The site
10+
serves its files through symlinks in `docs/public/`; see
11+
[`.claude/rules/project-wording.md`](.claude/rules/project-wording.md#the-icon).
912

1013
## No worktrees — work in the main checkout
1114

@@ -170,6 +173,7 @@ with neither the package nor the site.
170173
| `maintenance/scripts/format-docs-snippets.ts` | Keeps the docs' `ts` snippets within 75 columns (`pnpm format`, `pnpm lint`). |
171174
| `maintenance/scripts/changelog.ts` | Reads the release state out of `CHANGELOG.md`, for CI and `release.yaml`. |
172175
| `maintenance/scripts/check-source-maps.ts` | Checks that the built source maps point into `src/`, in CI. |
176+
| `maintenance/scripts/icon-themes.ts` | Writes `logo/icon-themes/` from `logo/logo-small.svg`. |
173177

174178
- **A note goes in `maintenance/docs/`, a script in `maintenance/scripts/`**, and each gets a
175179
row here. A script runs from the repo root, as `node maintenance/scripts/<name>.ts`.
@@ -200,7 +204,7 @@ instead — `expectTypeOf(ctx.port).toEqualTypeOf<number>()`, or
200204
things that are genuinely "this must not compile" (an unknown field, a bad `waitFor` name), and
201205
when you write one, confirm it fails for the intended reason.
202206

203-
A config field lives in two places: its Zod schema in `config-schema.ts`, which validates, and its
207+
A config field lives in two places: its valibot schema in `config-schema.ts`, which validates, and its
204208
type in `config.ts` (`ServiceConfigInput` / `DefineConfigOptions`), which carries its JSDoc. The
205209
schema holds no docs. `config.test-d.ts` compares the two, so `pnpm test:types` fails until a new
206210
or changed field agrees in both. Declare each field directly on those object types, not through

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ during development. You describe your services once, in a small typed config fil
77
starts the ones you pick and the services they need, brings up their infrastructure, loads
88
their environment, and shows it all in one place.
99

10-
![stackctl's terminal UI running the example monorepo](https://raw.githubusercontent.com/rhyek/stackctl/main/docs/public/demo-1794521101.gif)
10+
![stackctl's terminal UI running the example monorepo](https://raw.githubusercontent.com/rhyek/stackctl/main/docs/public/demo-1794549316.gif)
1111

1212
**Documentation: [stackctl.dev](https://stackctl.dev)**
1313

‎docs/.vitepress/config.ts‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,11 @@ export default defineConfig({
3333
// Contributor internals and working notes live in docs/ too, but aren't part of the site.
3434
srcExclude: ['architecture/**', 'superpowers/**'],
3535
sitemap: { hostname: site },
36-
// The icon (docs/public/logo.svg) in the browser tab, with a PNG for browsers that don't take
37-
// an SVG one, and the square one iOS rounds for a home-screen bookmark.
36+
// The icon at its small size (logo/logo-small.svg, linked into docs/public/) in the browser
37+
// tab, with a PNG for browsers that don't take an SVG one, and the square one iOS rounds for a
38+
// home-screen bookmark.
3839
head: [
39-
['link', { rel: 'icon', href: versioned('/logo.svg'), type: 'image/svg+xml' }],
40+
['link', { rel: 'icon', href: versioned('/logo-small.svg'), type: 'image/svg+xml' }],
4041
[
4142
'link',
4243
{ rel: 'icon', href: versioned('/favicon-32.png'), type: 'image/png', sizes: '32x32' },
@@ -108,7 +109,7 @@ export default defineConfig({
108109
},
109110

110111
themeConfig: {
111-
logo: { src: versioned('/logo.svg'), alt: '' },
112+
logo: { src: versioned('/logo-small.svg'), alt: '' },
112113
nav: [
113114
{ text: 'Guide', link: '/guide/getting-started', activeMatch: '^/guide/' },
114115
{ text: 'Config', link: '/config/config-file', activeMatch: '^/config/' },

‎docs/config/env.md‎

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
description: The env option of stackctl.config.ts - env.vars for variables set in the config, env.override to let files win over the shell, and env.additionalFiles for extra .env files.
2+
description: The env option of stackctl.config.ts - env.vars for variables set in the config, env.override to let files win over the shell, env.additionalFiles for extra .env files, and env.decrypt for values encrypted with dotenvx.
33
---
44

55
# Environment
@@ -29,6 +29,7 @@ export default defineConfig({
2929
| [`vars`](#envvars) | Sets variables from the config itself. |
3030
| [`override`](#envoverride) | Names variables where a file wins over the shell. |
3131
| [`additionalFiles`](#envadditionalfiles) | Loads extra `.env` files among stackctl's own. |
32+
| [`decrypt`](#envdecrypt) | Decrypts values encrypted with dotenvx. |
3233

3334
## `env.vars`
3435

@@ -152,3 +153,27 @@ API_PORT=21051
152153

153154
`.env.development.local` couldn't hold them: it loads after `.env.development`, too late for
154155
the references there.
156+
157+
## `env.decrypt`
158+
159+
- **Type:** `boolean` (default `false`)
160+
161+
Decrypts the values [encrypted with dotenvx](https://github.com/dotenvx/dotenvx#encryption),
162+
so a `.env` file of secrets can be committed.
163+
164+
```ts
165+
env: { decrypt: true },
166+
```
167+
168+
```sh
169+
# .env.development (committed), after `dotenvx encrypt -f .env.development`
170+
DOTENV_PUBLIC_KEY_DEVELOPMENT="03f8…"
171+
DATABASE_URL="encrypted:BDqD…"
172+
```
173+
174+
- **The private keys** come from `.env.keys` at the workspace root, which stays out of git,
175+
and from any `DOTENV_PRIVATE_KEY*` variable stackctl is started with, which is how CI gets
176+
one.
177+
- **A value with no key to decrypt it** stays as written, and stackctl prints which one.
178+
- **Editing `.env.keys` restarts every service**, as a workspace `.env` file does.
179+
- **Without it, `encrypted:…` is an ordinary string**, passed on as written.

‎docs/config/infra.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,8 @@ anything is removed, and a failing `beforeStart` before anything is started.
216216

217217
- **`cwd`** is relative to the workspace root, the default.
218218
- **A non-zero exit rejects**, failing the service, unless you pass `reject: false`.
219+
- **A command that can't start** (not installed, or a `cwd` that doesn't exist) exits 127, and
220+
the service's output says why.
219221
- **Their environment is `envs`**: the workspace-scope variables and `STACKCTL_MODE`. A
220222
variable from one service's own `.env` file isn't there. Pass it with `env`.
221223
- **Use them for anything a callback runs or prints.** A child process you spawn yourself with

‎docs/config/logs.md‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,5 +113,3 @@ worker: {
113113
filter matching any of them shows the whole block.
114114
- **Don't print a time.** stackctl stamps each line itself.
115115
- **A formatter that throws** falls back to the raw line.
116-
117-
`z` (zod) is re-exported from `stackctl`, for a formatter that validates the shape of a line.

‎docs/guide/commands.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ in a pipeline. The exit code is the command's own.
5959
- **Each call writes a [log file](./logs.md#log-files)**: the command and its directory, every
6060
line that was piped, and how it ended and how long it took. Output that went to a terminal
6161
isn't in it.
62+
- **Inside a command stackctl runs**, such as a dev script `sctl exec -- node --watch
63+
src/main.ts`, a menu command, or another `exec` or `run`, they only set up the environment,
64+
then become the command: no stackctl process stays between them. The outer command keeps
65+
the log and the [event](../reference/events.md), so nothing is recorded twice.
6266

6367
## From a script
6468

0 commit comments

Comments
 (0)