Skip to content

Commit 87f01e0

Browse files
committed
Creating reusable components for lstk docs
**Built:** - 12 shared components in [src/components/lstk/](src/components/lstk/) covering Installation, QuickStart, Authentication, Configuration, LifecycleCommands, SnapshotCommands, CommonCommands, GlobalOptionsAndOutput, EnvironmentAndLogging, ShellCompletions, FaqCommon, and TroubleshootingCommon. - Rewrote the [AWS](src/content/docs/aws/developer-tools/running-localstack/lstk.mdx) and [Azure](src/content/docs/azure/developer-tools/lstk.mdx) pages to import them, keeping only what's native to each emulator. - Added the new [Snowflake page](src/content/docs/snowflake/developer-tools/lstk.mdx) plus a "Developer Tools" sidebar section in [astro.config.mjs](astro.config.mjs). - [src/lib/lstk-toc.ts](src/lib/lstk-toc.ts) + a hook in [src/routeData.ts](src/routeData.ts) that stitches shared-component headings into the right-hand nav automatically — verified all three pages now show a complete, correctly-ordered TOC. - Added a scoped `exclude` to `starlight-links-validator` in `astro.config.mjs` for same-page hash links on these files, since that plugin checks each file in isolation and can't see the cross-file composition. **Bugs fixed along the way** (all things you flagged wanting checked): - Azure's page no longer shows AWS-only commands (`aws`, `terraform`, `cdk`, `sam`, `setup aws`, `reset`) or the AWS-only "save/restore state" FAQ item. - Azure regained the "Structured output"/"Exit codes" section it had silently drifted out of sync on. - Fixed a broken volume-mounts example (AWS page linked to Snowflake-specific docs). - Fixed a real broken link: the Prerequisites section linked to `#managing-your-license` on the AWS auth-token page, but that page's heading is actually "License assignment" — fixed to `#license-assignment`. - `MAIN_CONTAINER_NAME`'s default value was hardcoded as `localstack-aws` in shared docs; genericized to reflect the configured emulator type. **Verified:** rendered all three pages in-browser, confirmed content and TOC accuracy, confirmed AWS-only content correctly appears/disappears via the `emulator` prop, and ran a full `npm run build`.
1 parent 96b21c8 commit 87f01e0

20 files changed

Lines changed: 1559 additions & 2598 deletions

astro.config.mjs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,18 @@ export default defineConfig({
365365
errorOnRelativeLinks: true,
366366
errorOnLocalLinks: false, // Allow localhost links in tutorials (they're instructional)
367367
errorOnInvalidHashes: true,
368+
// The lstk pages and their shared components (src/components/lstk/) compose a single
369+
// page out of multiple .mdx files, so same-page "#hash" links often point at a heading
370+
// defined in a different file than the one linking to it. The validator checks each
371+
// file in isolation and can't see that composition, so skip hash checks there; the
372+
// headings themselves (and their slugs) are still real and verified via the lstk pages'
373+
// right-hand nav (see src/routeData.ts).
374+
exclude: ({ file, link }) =>
375+
link.startsWith('#') &&
376+
(file.includes('/components/lstk/') ||
377+
/\/content\/docs\/(aws\/developer-tools\/running-localstack|azure\/developer-tools|snowflake\/developer-tools)\/lstk\.mdx$/.test(
378+
file
379+
)),
368380
}),
369381
starlightUtils({
370382
multiSidebar: {
@@ -808,6 +820,13 @@ export default defineConfig({
808820
{ autogenerate: { directory: '/snowflake/capabilities' } },
809821
],
810822
},
823+
{
824+
label: 'Developer Tools',
825+
collapsed: true,
826+
items: [
827+
{ autogenerate: { directory: '/snowflake/developer-tools' } },
828+
],
829+
},
811830
{
812831
label: 'Tooling',
813832
collapsed: true,

package-lock.json

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
"astro": "^7.0.2",
2929
"class-variance-authority": "^0.7.1",
3030
"clsx": "^2.1.1",
31+
"github-slugger": "^2.0.0",
3132
"lucide-react": "^0.509.0",
3233
"react": "^19.1.0",
3334
"react-dom": "^19.1.0",
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
## Authentication
2+
3+
`lstk` resolves your auth token in the following order:
4+
5+
1. **System keyring**: a token stored by a previous `lstk login`.
6+
2. **`LOCALSTACK_AUTH_TOKEN` environment variable**: used only when the keyring has no token.
7+
3. **Browser login**: triggered automatically in interactive mode when neither of the above provides a token.
8+
9+
:::caution
10+
The keyring token takes precedence over `LOCALSTACK_AUTH_TOKEN`.
11+
If you set or change the environment variable but a keyring token already exists, the environment variable is ignored.
12+
Run `lstk logout` to clear the stored keyring token first.
13+
:::
14+
15+
### Logging in
16+
17+
```bash
18+
lstk login
19+
```
20+
21+
Opens a browser window for authentication and stores the resulting token in your system keyring.
22+
This command requires an interactive terminal.
23+
See the [`login`](#login) command for the full flow and the endpoints it uses.
24+
25+
### Logging out
26+
27+
```bash
28+
lstk logout
29+
```
30+
31+
Removes the stored credentials from the system keyring and the file-based fallback, and clears the cached license.
32+
`logout` cannot clear a token supplied via `LOCALSTACK_AUTH_TOKEN`; if you authenticated that way, unset the variable instead.
33+
See the [`logout`](#logout) command for the full behavior.
34+
35+
### File-based token storage
36+
37+
On systems where the system keyring is unavailable, `lstk` automatically falls back to storing the token in a file (`<config-dir>/auth-token`, mode `0600`).
38+
You can force file-based storage by setting:
39+
40+
```bash
41+
export LSTK_KEYRING=file
42+
```
Lines changed: 221 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,221 @@
1+
### `volume`
2+
3+
Manage the emulator volume: the host directory that holds persistent state such as certificates, downloaded tools, and persistence data.
4+
5+
```bash
6+
lstk volume path
7+
lstk volume clear [options]
8+
```
9+
10+
#### `volume path`
11+
12+
Prints the resolved volume directory for every emulator in your config, one per line.
13+
With the default config (a single `aws` emulator) it prints one path.
14+
Each path is the container's configured `volume` value, or the default OS cache location if `volume` is unset (`~/Library/Caches/lstk/volume/localstack-aws` on macOS, `~/.cache/lstk/volume/localstack-aws` on Linux).
15+
16+
```bash
17+
# Print the volume directory for each configured emulator
18+
lstk volume path
19+
```
20+
21+
#### `volume clear`
22+
23+
Removes all data from the emulator volume directory, resetting cached state.
24+
It operates on all configured emulators by default, or a single one with `--type`.
25+
Before clearing, it lists each target as `<emulator>: <path> (<size>)`.
26+
27+
| Option | Description |
28+
|:----------------|:------------------------------------------|
29+
| `--force` | Skip the confirmation prompt |
30+
| `--type <type>` | Clear only the emulator of this type |
31+
32+
```bash
33+
# Clear all configured emulator volumes (prompts for confirmation)
34+
lstk volume clear
35+
36+
# Clear only the AWS emulator volume
37+
lstk volume clear --type aws
38+
39+
# Skip the confirmation prompt
40+
lstk volume clear --force
41+
42+
# Clear without prompting in a non-interactive environment
43+
lstk volume clear --type snowflake --force
44+
```
45+
46+
In an interactive terminal, `lstk volume clear` prompts `Clear volume data? This cannot be undone` before deleting anything; choosing **NO** or pressing Ctrl+C cancels with no changes.
47+
In non-interactive mode, `--force` is required, otherwise the command fails with `volume clear requires confirmation; use --force to skip in non-interactive mode`.
48+
49+
:::caution
50+
If the volume contains files owned by `root` (created by Docker), clearing fails with a permission error.
51+
Re-run with elevated privileges:
52+
53+
```bash
54+
sudo lstk volume clear
55+
```
56+
:::
57+
58+
### `login`
59+
60+
Authenticate with LocalStack via a browser-based device authorization flow and store the resulting credential in your system keyring.
61+
This command requires an interactive terminal.
62+
63+
```bash
64+
lstk login
65+
```
66+
67+
`lstk` opens your default browser to the LocalStack Web Application, shows a one-time code, and waits for you to approve the request.
68+
If the browser cannot open automatically, `lstk` prints the URL to visit manually.
69+
On success it stores the **license token** returned by the platform (not the raw browser bearer token).
70+
71+
If you are already authenticated — either `LOCALSTACK_AUTH_TOKEN` is set or a token already exists in storage — `login` prints `You're already logged in` and exits without starting a new flow.
72+
73+
In non-interactive mode (piped output, CI, or `--non-interactive`), `login` fails with `login requires an interactive terminal`.
74+
The `--config <path>` flag selects which `config.toml` is loaded, which affects `keyring`, `web_app_url`, and `api_endpoint` resolution.
75+
76+
:::note
77+
If you approve the request in the browser only *after* pressing a key in the terminal, `lstk` reports `auth request not confirmed - please complete the authentication in your browser`.
78+
Re-run `lstk login` and approve in the browser before continuing.
79+
:::
80+
81+
The credential is written to the system keyring (service `lstk`, key `lstk.auth-token`).
82+
When the keyring is unavailable — or `LSTK_KEYRING=file` is set — `lstk` stores it in a file at `<config-dir>/auth-token` (mode `0600`) instead.
83+
84+
Endpoints used by the flow can be overridden via config or environment:
85+
86+
| Config key | Env var | Default | Description |
87+
|:---------------|:---------------------|:---------------------------------|:-----------------------------------------------------------------------------|
88+
| `keyring` | `LSTK_KEYRING` | (system keyring) | Set to `file` to force file-based token storage instead of the OS keyring. |
89+
| `web_app_url` | `LSTK_WEB_APP_URL` | `https://app.localstack.cloud` | Base URL used to build the browser authorization link. |
90+
| `api_endpoint` | `LSTK_API_ENDPOINT` | `https://api.localstack.cloud` | LocalStack platform API endpoint used for the device flow and license token. |
91+
92+
```bash
93+
# Force file-based token storage during login
94+
LSTK_KEYRING=file lstk login
95+
96+
# Use a specific config file
97+
lstk --config ./.lstk/config.toml login
98+
```
99+
100+
### `logout`
101+
102+
Remove stored authentication credentials.
103+
104+
```bash
105+
lstk logout
106+
lstk logout --non-interactive
107+
```
108+
109+
`logout` deletes the auth token from your system keyring (falling back to the file-based token at `<config-dir>/auth-token` when the keyring is unavailable or `LSTK_KEYRING=file` is set) and removes the cached license file.
110+
On success it prints `Logged out successfully`.
111+
112+
The outcome depends on how you are authenticated:
113+
114+
| Situation | Behavior |
115+
|:----------|:---------|
116+
| A token is stored (from `lstk login`) | The token is deleted from the keyring and file fallback, the cached license is removed, and `lstk` prints `Logged out successfully`. |
117+
| No stored token, but `LOCALSTACK_AUTH_TOKEN` is set | Nothing is deleted. `lstk` prints a note that you are authenticated via the environment variable and to unset it to log out. |
118+
| No stored token and no `LOCALSTACK_AUTH_TOKEN` | `lstk` prints `Not currently logged in` and exits successfully. |
119+
120+
:::note
121+
`logout` never clears the `LOCALSTACK_AUTH_TOKEN` environment variable, and it does not stop running emulators.
122+
If a LocalStack emulator is still running after logout, `lstk` prints a note reminding you it is running in the background; run `lstk stop` to stop it.
123+
:::
124+
125+
### `config`
126+
127+
Manage CLI configuration.
128+
`config` has no behavior of its own; run it with a subcommand.
129+
130+
#### `config path`
131+
132+
Print the resolved path to the active `config.toml`.
133+
134+
```bash
135+
lstk config path
136+
```
137+
138+
This subcommand is read-only: it never creates or initializes a config file.
139+
If `--config <path>` is set, it prints that path verbatim.
140+
Otherwise it prints the already-loaded config path, the first existing config in the search order, or the path where a config would be created on first run.
141+
142+
### `update`
143+
144+
Check for and apply updates to the `lstk` CLI itself.
145+
`lstk` auto-detects how it was installed (Homebrew, npm, or direct binary) and updates using that same method.
146+
Development builds (version `dev`) are skipped, and updates are checked against the latest [GitHub release](https://github.com/localstack/lstk/releases/latest).
147+
148+
```bash
149+
lstk update [options]
150+
```
151+
152+
| Option | Description |
153+
|:--------------------|:---------------------------------------------------------------|
154+
| `--check` | Check for updates without installing them |
155+
| `--non-interactive` | Use plain output instead of the TUI (update logic unchanged) |
156+
| `--json` | Emit the result as a JSON envelope (see [Structured output](#structured-output)). With `--check`, `data` reports `currentVersion`/`latestVersion`/`updateAvailable`; after an applied update, `updatedVersion`/`updated`/`method`. |
157+
158+
Examples:
159+
160+
```bash
161+
# Check for updates without installing
162+
lstk update --check
163+
164+
# Update to the latest version
165+
lstk update
166+
167+
# Update with plain (non-TUI) output
168+
lstk update --non-interactive
169+
```
170+
171+
By install method:
172+
173+
- **Homebrew** (binary under a `Caskroom` path): runs `brew upgrade localstack/tap/lstk`.
174+
- **npm** (binary under `node_modules`): runs `npm install -g @localstack/lstk@latest`.
175+
- **Binary** (anything else): downloads the release asset for your OS/arch from GitHub, extracts it, and replaces the running executable in place.
176+
177+
With `--check`, `lstk` only reports whether a newer version is available and exits without downloading or installing anything.
178+
179+
:::note
180+
Set `LSTK_GITHUB_TOKEN` to send an authenticated GitHub request and avoid API rate limits during update checks.
181+
It is optional; updates also work unauthenticated.
182+
:::
183+
184+
#### Update notification on start
185+
186+
Separately from `lstk update`, `lstk` checks for a newer version when you run `lstk start` (the default command), using a short timeout that fails silently if GitHub is unreachable.
187+
188+
In an interactive terminal, when an update is available `lstk` prints the new version and a release-notes link, then prompts:
189+
190+
```text
191+
Update lstk to latest version?
192+
> Update now [U]
193+
Remind me next time [R]
194+
Skip this version [S]
195+
```
196+
197+
- **Update now [U]**: downloads and applies the update, then asks you to re-run your command.
198+
- **Remind me next time [R]**: does nothing; you are reminded on the next run.
199+
- **Skip this version [S]**: records the version in `config.toml` so you are not prompted about it again.
200+
201+
In non-interactive mode the notification is not a prompt — `lstk` emits a single note (`Update available: <current> → <latest> (run lstk update)`) and continues.
202+
203+
When you choose **Skip this version**, `lstk` writes the skipped version under a `[cli]` table:
204+
205+
```toml
206+
[cli]
207+
update_skipped_version = "0.5.0"
208+
```
209+
210+
While this value matches the latest available version, the start-time update notification for that version is suppressed.
211+
This key is managed automatically and is not intended to be edited by hand.
212+
213+
### `completion`
214+
215+
Generate shell completion scripts.
216+
217+
```bash
218+
lstk completion [bash|zsh|fish|powershell]
219+
```
220+
221+
See [Shell completions](#shell-completions) for setup instructions.

0 commit comments

Comments
 (0)