Skip to content

versacomp/fastyoke-cli

Repository files navigation

@fastyoke/cli

Scaffold, build, and publish FastYoke extensions.

Install

npm install -g @fastyoke/cli

Commands

fy init [name]

Scaffolds a new extension project in ./<name>. Omit name to initialize the current directory.

fy init my-extension
cd my-extension
npm install

fy dev

Builds the extension in watch mode. Rebuilds on file changes.

fy dev

fy build

One-shot build to dist/bundle.mjs. Uses esbuild with the FastYoke-required externals (react, react/jsx-runtime, react-dom, @fastyoke/sdk) so the host app supplies them at runtime.

fy build

Templates

fy init supports two templates via --template <kind>:

  • extension (default) — a FastYoke extension built against @fastyoke/sdk, driven by fy dev / fy build / fy publish.
  • nextjs — a standalone Next.js (App Router, TypeScript, Tailwind) consumer app pre-wired against a tenant's public form-submission and signed-URL PDF download endpoints. Driven by npm run dev / npm run build directly; fy lifecycle commands do not wrap it.

fy init <name> --template nextjs quickstart

fy init my-app --template nextjs
cd my-app
cp .env.local.example .env.local      # set FASTYOKE_TENANT_URL
npm install
npm run dev

Visit http://localhost:3000/forms/<token>, where <token> is the public submission token your tenant admin published for the form. The route uses the token (not the form's slug) — keep the token opaque.

Customize:

  • src/app/forms/[token]/page.tsx — server-side schema fetch.
  • src/app/forms/[token]/FormView.tsx — schema-driven renderer.
  • src/lib/form-actions.ts — submit server action.

The starter renderer covers text / email / textarea / checkbox / signature field types. Extend FormView.tsx for the field types your forms use.

fy publish --tenant <url> --token <jwt>

Uploads manifest.json + dist/bundle.mjs to a running FastYoke instance. --token is a tenant admin JWT — the CLI decodes its tenant_id claim to populate the multipart request.

fy publish --tenant https://my-tenant.fastyoke.example.com --token "$FASTYOKE_TOKEN"
Flag Required Description
--tenant <url> yes Base URL of the FastYoke instance, e.g. https://app.fastyoke.example.com
--token <jwt> yes Tenant admin JWT. tenant_id is read from the token's claims.
--manifest <path> no Defaults to ./manifest.json
--bundle <path> no Defaults to ./dist/bundle.mjs

Run fy build before publishing if you've made changes.

Extension shape

fy init produces this layout:

my-extension/
├── package.json     # scripts + devDependencies only; host provides react at runtime
├── tsconfig.json
├── manifest.json    # id, version, components, pages, required_scopes
├── src/
│   └── index.tsx    # default export: { components?, pages? }
└── dist/            # generated by `fy build`
    └── bundle.mjs

The bundle's default export is what the host's <ExtensionProvider> imports and registers. See the examples/hello-fastyoke reference extension in the FastYoke repo for a working example.

About

Scaffold, build, and publish FastYoke extensions.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors