feat(create): add --list flag to print available templates#1247
Draft
DaveHanns wants to merge 1 commit into
Draft
feat(create): add --list flag to print available templates#1247DaveHanns wants to merge 1 commit into
DaveHanns wants to merge 1 commit into
Conversation
Today, discovering template ids requires either visiting the
actor-templates GitHub repo or running `apify create` with its
interactive picker, which fails in non-TTY / agent contexts. There is
no non-interactive discovery path.
Add a `--list` flag to `apify create` that fetches the existing manifest
(via `@apify/actor-templates`, which is already a dependency and already
imported for the interactive picker) and prints one line per template
in the form `<id>\t<language>\t<description>`. When combined with the
existing `--json` support (opted in via `enableJsonFlag`), the command
emits a machine-parseable JSON object with `templates: [{id, label,
category, description}, ...]`. The list path returns early before any
actor-name validation or filesystem work, so it can be invoked from any
directory without side effects.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a
--listflag toapify createso template ids can be discovered non-interactively (agent contexts, CI, non-TTY shells) without visiting theactor-templatesGitHub repo or hitting the interactive picker. Combined with--json, the output is machine-parseable.Addresses finding F34 — no non-interactive discovery path exists today for
apify create --template <id>, which is the only way to invoke the command from an agent.What changes
src/commands/create.tslist: Flags.boolean(...)flag (nochar;--listonly, to avoid clashing with common short-flag conventions).static override enableJsonFlag = trueso the framework's built-in--jsonsupport is available on this command.static examples(apify create --listandapify create --list --json).run(), after the manifest fetch is kicked off but before any actor-name validation or filesystem mkdir. Reuses the samefetchManifest()mechanism the interactive picker already uses — no new dependency, no new HTTP client, no new fetch URL. Fields exposed:id(mapped fromTemplate.name, matching what--templateaccepts),label,category(language),description.<id>\t<language>\t<description>) so it pipes cleanly throughawk/cut.No existing behavior changes —
apify createwithout--listis identical to before.Test plan
pnpm exec tsc --noEmit -p .passes (verified locally).pnpm exec oxlint --type-aware src/commands/create.tspasses (verified locally).apify create --listin a non-TTY shell prints tab-separated<id>\t<language>\t<description>lines and exits 0 without creating a directory.apify create --list --jsonprints a{"templates": [...]}JSON object withid,label,category,descriptionfields and exits 0.apify create my-actor --template <id-from-list> --skip-dependency-installstill works (no regression on the create path).apify createwith no args still triggers the interactive picker (no regression on interactive path).Notes for reviewers
id: t.name(rather thanTemplate.id) matches the string that--templateaccepts today;getTemplateDefinitionlooks up byt.name === maybeTemplateName. Exposing anything else would be confusing.