@templateto/cli
v0.1.1
Published
Create, edit, validate, preview, and publish TemplateTo templates.
Downloads
271
Readme
TemplateTo CLI
@templateto/cli gives people and coding agents a safe, version-controllable way to create and edit TemplateTo templates.
It supports both direct HTML templates and TemplateTo Visual Editor templates. Visual Editor workspaces keep these four files synchronized:
components.jsonstyles.jsonhtml.txtcssContent.css
The CLI refuses to push a Visual Editor workspace when one side has changed since the last successful sync.
Install
npm install --global @templateto/cliNode.js 20 or newer is required.
Maintainer release instructions are in PUBLISHING.md.
Configure
Create an API key in the TemplateTo application, then expose it to the process:
export TEMPLATETO_API_KEY="..."PowerShell:
$env:TEMPLATETO_API_KEY = "..."The default API endpoint is https://api.templateto.com. Set TEMPLATETO_API_URL to target a local or self-hosted API.
The CLI does not persist or print the API key.
Visual Editor workflow
Create a new local bundle:
templateto bundle init invoice --name "Invoice" --mode visualEdit invoice/components.json and invoice/styles.json, then synchronize the render artifacts:
templateto editor sync invoice
templateto bundle validate invoiceCreate a remote draft and preview it:
templateto templates create invoice
templateto templates preview <template-id> --draft --data invoice/exampleJson.json --out invoice.pdfPublishing is deliberately separate:
templateto templates publish <template-id>Edit an existing template
templateto templates pull <template-id> --out invoice
# edit files
templateto editor sync invoice
templateto templates push invoice
templateto templates preview <template-id> --draft --data invoice/exampleJson.jsontemplates push creates or updates a draft. It does not publish it.
Existing TemplateTo archive format
The workspace uses the same files as TemplateTo’s existing export/import zip:
details.json
components.json
styles.json
exampleJson.json
settings.json
html.txt
cssContent.css
blocks/...
fonts/...
theme.css
manifest.jsontemplateto.json is local CLI metadata and is omitted from packed archives.
Supported Visual Editor components
The compiler supports TemplateTo Visual Editor elements, including logic, repeat, content block, computed variable, QR code, barcode, column layout, and table components. Run:
templateto editor typesUnknown custom component types without an explicit tagName fail compilation. This is intentional: a failed sync is safer than silently generating HTML that differs from the visual editor.
Inspect a pulled component tree before structural edits:
templateto editor inspect invoicetemplates push updates the template's core bundle as a draft. It deliberately does not reimport or overwrite referenced content blocks, fonts, or themes. Use templates import when creating a new template from a complete archive. Updating those related resources needs separate API support so it can remain draft-first.
License
MIT
