Skip to content

Reusable lstk components#817

Open
remotesynth wants to merge 2 commits into
mainfrom
DOC-342-reusable-lstk-components
Open

Reusable lstk components#817
remotesynth wants to merge 2 commits into
mainfrom
DOC-342-reusable-lstk-components

Conversation

@remotesynth

Copy link
Copy Markdown
Collaborator

This is an attempt to create the various lstk pages out of reusable components that cover the shared content. We should decide whether this adds too much complexity to solve the reusability problem. The issue is that many sections of the lstk docs contain caveats that make them not entirely reusable. In addition, this requires more complex logic in our middleware due to the fact that TOC headings from imported components don't automatically render in the right sidebar. A concern is that this makes maintainability more complex rather than less because many pieces are not reused or contain logic for a specific emulator.

Here's a summary of changes:

Splits the lstk CLI reference page — previously duplicated near-verbatim across AWS and Azure, and already drifted out of sync between the two — into a shared set of MDX components plus a thin per-emulator page. Also adds the missing Snowflake lstk page.

Shared components (src/components/lstk/)

New reusable .mdx components for content that's genuinely identical across emulators: Installation, QuickStart, Authentication, Configuration, LifecycleCommands (start/stop/restart/status/logs), CommonCommands (volume/login/logout/config/update/completion), GlobalOptionsAndOutput, EnvironmentAndLogging, ShellCompletions, FaqCommon, TroubleshootingCommon. LifecycleCommands takes an emulator prop to gate the two AWS-only bits (snapshot autoload on start, resource listing on status).

Each of the three pages now imports these and adds only what's genuinely specific to that emulator (its own Introduction/Prerequisites text, and commands like aws/terraform/cdk/sam/setup aws/reset for AWS, az/setup azure for Azure).

Pages

  • AWS (src/content/docs/aws/developer-tools/running-localstack/lstk.mdx) and Azure (src/content/docs/azure/developer-tools/lstk.mdx): rewritten to compose from the shared components.
  • Snowflake (new: src/content/docs/snowflake/developer-tools/lstk.mdx): added, plus a new "Developer Tools" sidebar section in astro.config.mjs.

Content accuracy fixes

  • Azure's page had drifted and was missing the "Structured output"/"Exit codes" section that AWS has — now shared, so both stay in sync.
  • Azure no longer documents AWS-only commands (aws, terraform, cdk, sam, setup aws, reset) it never actually had.
  • Snapshots corrected per emulator: Cloud Pods and S3 remotes are AWS-only. Azure has no snapshot/reset support at all (now just a note pointing at lstk start --persist). Snowflake supports snapshot save/load with local files only — no Cloud Pods, no S3 remotes, no list/remove/show (all Cloud-Pod-only), flagged as experimental.
  • Fixed introduction paragraphs on all three pages that overclaimed capabilities (e.g. Azure/Snowflake previously implied Cloud Pod support).
  • Fixed a broken link: the AWS page's license link pointed at #managing-your-license, which doesn't exist on the AWS auth-token page (it does on Azure/Snowflake's) — corrected to #license-assignment.
  • Genericized the MAIN_CONTAINER_NAME container-injected-variable row, previously hardcoded to localstack-aws regardless of emulator.
  • Annotated the global --snapshot/--no-snapshot flags as AWS-only.

Right-hand nav (TOC) fix

Starlight builds its TOC from each page's own compiled headings, so headings coming from an imported .mdx component were invisible to it. Added src/lib/lstk-toc.ts + a hook in src/routeData.ts that parses each lstk page's source (and the shared components it imports), extracts headings with github-slugger (matching Astro's own per-file slugging), and stitches them into starlightRoute.toc.items in document order.

Other

  • Added a scoped exclude to the starlight-links-validator config for same-page #hash links on the lstk page/component files, since that plugin validates each file in isolation and can't see the cross-file composition (the anchors themselves are real and verified via the TOC fix above).
  • Added github-slugger as an explicit dependency.

Testing

Rendered all three pages in-browser; confirmed content, TOC accuracy/ordering, and AWS-only conditional content appear/disappear correctly per emulator. Ran a full npm run build — passes except for ~27 pre-existing broken links in unrelated files (not touched by this change).

**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`.
- **AWS page**: `snapshot` content inlined natively (it's no longer shared with anything, so the component was folded back in and deleted) — kept full Cloud Pods/S3/local support, dropped the inaccurate "also works experimentally on Snowflake/Azure" note.
- **Azure page**: removed `snapshot`/`reset` entirely, added a short note pointing to `--persist` as the only state-retention option, and fixed the Introduction paragraph, which previously claimed Cloud Pod support.
- **Snowflake page**: replaced the shared component with a native `snapshot` section scoped to local files only — no `pod:` refs, no S3 remotes, no `list`/`remove`/`show` (all Cloud-Pod-only) — kept the "experimental" warning since that's specifically about local save/load, and fixed its Introduction paragraph too.
- Annotated the global `--snapshot`/`--no-snapshot` flags as AWS-only in `GlobalOptionsAndOutput.mdx` for consistency.
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