Askr
Tooling

Page and Action Generation

Use page and action generation with the current published Askr packages.

  • @askrjs/askr0.0.59

How to use page and action generation

Generate only the published page and action targets, review the created files, then register and test their routes before committing.

  1. Import the published @askrjs/askr entrypoint.
  2. Keep page and action generation configuration next to the component, route, or server composition root that owns it.
  3. Handle pending, unavailable, cancellation, and failure states, then verify the production path.
npx askr add page audit-log
npx askr add action approve-request --route /requests/{id}

git diff -- src
npm run test
npm run build

Add a page

askr add page <name> [--branch app|public] [--cwd <dir>] [--title <title>] [--route <path>] [--force] writes a page component and registers it into the target route branch's _routes.tsx file. --branch defaults to app; pass --branch public for pages that belong in the public route tree. --title and --route let you override the generated title and route path instead of deriving them from the page name, and --force is required to overwrite a page file that already exists at that path.

Add an action

askr add action <name> --route <path> [--cwd <dir>] [--force] generates a declared action and requires an absolute --route path -- there's no default route inference the way there is for pages, since an action's route is part of its contract. Running it against a name that already has generated files fails with an explicit message telling you to pass --force to replace them, rather than silently merging or skipping.

Route option

--route means slightly different things for the two subcommands: for add page it's an optional override of the page's own URL, defaulting to something derived from the name and branch; for add action it's a required, absolute path describing where the action is mounted, since actions don't have an implicit route the way pages do. Get it wrong on the action side and the CLI refuses to generate anything rather than guessing.

Generated file review

Both add page and add action write directly into your route-first structure -- typically src/pages/app/_routes.tsx or src/pages/public/_routes.tsx plus a new page or action file -- so the change shows up as a normal diff you can review before committing. Nothing is generated into a scratch or preview location first. If a target file already exists, the command stops and asks for --force instead of overwriting silently, which keeps accidental regeneration from clobbering hand-edited code.