From 70cbef1a254c9205f205d0692459a138b88fc4cb Mon Sep 17 00:00:00 2001 From: Martin Helmich Date: Wed, 29 Jul 2026 09:43:37 +0200 Subject: [PATCH 01/13] feat(stack): add support for container templates Add `mw stack create`, which creates a container stack either empty or from a container template via the create-stack API's `templateConfig`. Template user inputs can be supplied non-interactively with repeatable `--input name=value` flags; required inputs without a value or default are prompted for interactively. Also: - add `mw stack list-templates` to discover available templates and IDs - show the originating template in `mw stack list` (`templateId`) - make `mw stack rm` work for any stack (template or not) by using the dedicated delete-stack API instead of the previous "empty the default stack" workaround - deprecate `mw stack deploy --from-template` in favour of `mw stack create --from-template` Closes #2048 Co-Authored-By: Claude Opus 4.8 --- docs/stack.md | 135 ++++++++++++++++ src/commands/stack/create.tsx | 144 ++++++++++++++++++ src/commands/stack/delete.ts | 29 ++-- src/commands/stack/deploy.tsx | 7 + src/commands/stack/list-templates.ts | 52 +++++++ src/commands/stack/list.ts | 6 + .../resources/stack/template-inputs.test.ts | 95 ++++++++++++ src/lib/resources/stack/template-inputs.ts | 69 +++++++++ 8 files changed, 523 insertions(+), 14 deletions(-) create mode 100644 src/commands/stack/create.tsx create mode 100644 src/commands/stack/list-templates.ts create mode 100644 src/lib/resources/stack/template-inputs.test.ts create mode 100644 src/lib/resources/stack/template-inputs.ts diff --git a/docs/stack.md b/docs/stack.md index af18d3b14..69572a54f 100644 --- a/docs/stack.md +++ b/docs/stack.md @@ -3,16 +3,86 @@ Manage container stacks +* [`mw stack create`](#mw-stack-create) * [`mw stack delete [STACK-ID]`](#mw-stack-delete-stack-id) * [`mw stack deploy`](#mw-stack-deploy) * [`mw stack list`](#mw-stack-list) +* [`mw stack list-templates`](#mw-stack-list-templates) * [`mw stack ls`](#mw-stack-ls) * [`mw stack ps`](#mw-stack-ps) * [`mw stack rm [STACK-ID]`](#mw-stack-rm-stack-id) * [`mw stack set-update-schedule STACK-ID SCHEDULE`](#mw-stack-set-update-schedule-stack-id-schedule) +* [`mw stack templates`](#mw-stack-templates) * [`mw stack unset-update-schedule STACK-ID`](#mw-stack-unset-update-schedule-stack-id) * [`mw stack up`](#mw-stack-up) +## `mw stack create` + +Create a new container stack + +``` +USAGE + $ mw stack create -d [--token ] [-p ] [-q] [--input ... --from-template ] + [-c] + +FLAGS + -c, --update-context update the CLI context to use the newly created stack + -d, --description= (required) description of the stack + -p, --project-id= ID or short ID of a project; this flag is optional if a default project is set in the + context + -q, --quiet suppress process output and only display a machine-readable summary + --from-template= ID of a container template to create the stack from + --input=... user input for a template, in 'name=value' format + +AUTHENTICATION FLAGS + --token= API token to use for authentication (overrides environment and config file). NOTE: watch out that + tokens passed via this flag might be logged in your shell history. + +DESCRIPTION + Create a new container stack + + Creates a new, empty container stack, or a stack based on a container template. + + When --from-template is given, the referenced template may define user inputs. + These can be supplied non-interactively with one or more --input flags in + 'name=value' format; any required inputs that are neither provided nor have a + default value are prompted for interactively. + + Use "mw stack list-templates" to discover available templates and + their IDs. + +EXAMPLES + Create an empty stack + + $ mw stack create --description "my stack" + + Create a stack from a template, providing user inputs + + $ mw stack create --description "my n8n" --from-template --input DOMAIN=example.com --input \ + ADMIN_EMAIL=admin@example.com + +FLAG DESCRIPTIONS + -p, --project-id= ID or short ID of a project; this flag is optional if a default project is set in the context + + May contain a short ID or a full ID of a project; you can also use the "mw context set --project-id=" command + to persistently set a default project for all commands that accept this flag. + + -q, --quiet suppress process output and only display a machine-readable summary + + This flag controls if you want to see the process output or only a summary. When using mw non-interactively (e.g. in + scripts), you can use this flag to easily get the IDs of created resources for further processing. + + --from-template= ID of a container template to create the stack from + + When set, the stack is created from the given container template. Omit this flag to create an empty stack. + + --input=... user input for a template, in 'name=value' format + + May be repeated to provide multiple inputs. Only applicable together with --from-template. Required inputs that are + not provided (and have no default) are prompted for interactively. +``` + + ## `mw stack delete [STACK-ID]` Delete a container stack @@ -90,6 +160,8 @@ FLAG DESCRIPTIONS --from-template= deploy from a GitHub template (e.g., mittwald/n8n) + DEPRECATED: use "mw stack create --from-template" instead. This flag uses an older, GitHub-based template mechanism. + Fetch and deploy a stack from a GitHub template repository. Template names are automatically converted to repository names by prefixing "stack-template-" to the name part. @@ -144,6 +216,37 @@ FLAG DESCRIPTIONS ``` +## `mw stack list-templates` + +List container templates that stacks can be created from. + +``` +USAGE + $ mw stack list-templates -o txt|json|yaml|csv|tsv [--token ] [-x] [--no-header] [--no-truncate] + [--no-relative-dates] [--csv-separator ,|;] + +FLAGS + -o, --output=