Project commands
Development, validation, database, and deployment commands in the default template's package.json.
This page lists the npm scripts in saavo-default-template/package.json. Unless otherwise noted, run them from the root of your initialized project. Source archives remove the commit command used by template maintainers, so it is not a default command in newly created projects.
This reference was checked against template source version 0.2.14. Run npm run to list the scripts available in your own project. Older templates may differ; adding a script name alone does not install its implementation. Compare with the corresponding template source before using a missing command.
Development and preview
| Command | Purpose |
|---|---|
npm run predev | Generate content collections and the search index; npm runs this automatically before dev |
npm run dev | Generate the search index, then start the Vite development server |
npm run build | Generate the search index and build the analytics script and application in production mode |
npm run build:preview | Generate the search index and build a local preview in local-preview mode |
npm run preview | Run build:preview, then start Vite Preview at 127.0.0.1:4173 |
npm run build:analytics | Build only the analytics script in development mode |
predev is a lifecycle script for npm run dev. npm runs it automatically, so you usually do not need to run it manually.
Code checks and tests
| Command | Purpose |
|---|---|
npm run lint | Generate content collections and run ESLint |
npm run lint:fix | Generate content collections and run ESLint with automatic fixes |
npm run typecheck | Generate content collections and run tsc --noEmit |
npm test | Run application, script, OAuth rate limiting, and Durable Object primitive tests in sequence |
npm run test:app | Generate content collections, then run application tests |
npm run test:scripts | Run only tests for scripts/ |
npm run test:oauth-rate-limit | Run only OAuth rate limiting tests |
npm run test:primitives | Run only Durable Object primitive tests |
npm run test:coverage | Generate content collections, then run application tests with a coverage report |
npm run verify | Run lint, typecheck, all tests, and a production build in sequence |
Run npm run verify to complete all local checks. A successful build does not replace type checking and tests.
Content and type generation
| Command | Purpose |
|---|---|
npm run gen:collections | Regenerate documentation and blog collections from the content directories |
npm run gen:search-index | Generate content collections and the site search index |
npm run cf-typegen | Regenerate worker-configuration.d.ts from the Wrangler configuration and environment variables |
npm run kv:sync:local | Generate content collections and sync documentation and blog content to local MAIN_KV |
npm run kv:sync:remote | Generate content collections and sync documentation and blog content to remote MAIN_KV |
src/libs/documentation/source/.content-collections/ contains generated collections, types, and cache files. It is ignored by Git and excluded from source archives. saavo:init regenerates it; after changing content, you can rebuild it with npm run gen:collections.
Local initialization and checks
| Command | Purpose |
|---|---|
npm run secret:generate | Print a new 256-bit SAAS_SECRET in standard Base64 without modifying environment variable files |
npm run saavo:init | Create or preserve .env, add a missing SAAS_SECRET, then run cf-typegen, gen:collections, db:migrate:local, and doctor in order |
npm run doctor | Check local environment variables, configuration, bindings, resource names, and database directories |
npm run doctor:remote | Use .env.production to check production configuration, the account, and resource IDs. This does not verify that all remote services are available |
Databases
| Command | Purpose |
|---|---|
npm run db:migrate:local | Initialize empty local D1 databases and apply pending local migrations |
npm run db:migrate:remote | Initialize empty remote D1 databases and apply pending remote migrations |
npm run db:reset:local | Delete tables, views, and triggers in both local D1 databases, then run initialization scripts and database migrations |
npm run db:reset:remote | After the full confirmation text is entered, reset both remote D1 databases, then run initialization scripts and database migrations |
Reset commands erase database contents
Both db:reset:local and db:reset:remote delete existing data. The scripts provide no undo operation. Recovery depends on backups or database recovery capabilities prepared and verified beforehand. Do not use reset commands to update production database schemas.
To change a database schema, add a migration file under schema/migrations and run the appropriate db:migrate command. Do not execute schema/db-init.sql or schema/analytics-init.sql directly.
Deployment
| Command | Purpose |
|---|---|
npm run deploy:init | First deployment: check the local project, determine Worker and resource names, create remote resources, deploy the Worker, initialize D1, sync content, and run health checks |
npm run deploy:update | Update an initialized project: check remote configuration, run full verification and database migrations, deploy the Worker, sync content, and run health checks |
npm run domain:set -- https://app.example.com | Check production configuration, update the custom domain in wrangler.jsonc and .env.production, build and deploy, then check the homepage |
Use deploy:init only for the first remote deployment. Once that deployment is complete and all remote resources are configured, use deploy:update for subsequent releases. Setting account_id alone does not mean initialization is complete. If the first deployment fails partway through, inspect the resources and configuration already created, then follow the deployment tutorial. Do not switch commands based on a single field.
deploy:update requires SAAS_SECRET to exist and match exactly in .env and .env.production. Remote migrations run before the new Worker is deployed, so they must remain compatible with the code still running in production.
domain:set only changes the Worker's custom domain and VITE_SITE_URL. Update callback URLs on third-party platforms such as GitHub, Google, and Stripe separately. Turnstile domains and email sending domains also need to be updated on their respective platforms.
domain:set does not run the full verify sequence, database migrations, or KV synchronization. For releases that also change code, schema, or content, use deploy:update.
Stripe Webhook
| Command | Purpose |
|---|---|
npm run webhook:stripe:dev | Read .env, create a webhook destination using test-mode keys, and write back STRIPE_WEBHOOK_SECRET |
npm run webhook:stripe:prod | Read .env.production, create a webhook destination using live-mode keys, and write back STRIPE_WEBHOOK_SECRET |
These commands call Stripe to create remote webhooks, rather than only generating local configuration. The script prompts for the destination URL, event API version, and subscribed events. For development, provide an HTTPS URL that Stripe can reach. A loopback address cannot serve as a remote delivery destination. After production configuration is written back, redeploy the application. After development configuration changes, restart the development server.
Each successful run creates a new webhook destination; it does not update an existing one. Before running it again, check existing destinations to avoid duplicate event delivery.
Versions and releases
| Command | Purpose |
|---|---|
npm run release:tag | Interactively select a version, create an annotated v<version> tag for the current commit, and push only that tag to origin |
npm run release:archive -- <tree-ish> <output-path> | Package the specified Git tree as a reproducible source ZIP archive |
release:tag defaults to the version in package.json. It does not modify files, create a commit, or push the current branch. If you enter a different version, the script warns you but still allows you to continue.
For the template repository’s release workflow, commit all intended changes first and make sure the tag matches the versions in both package.json and package-lock.json. A successful tag push does not mean publication succeeded; check the release workflow result.
release:archive reads files from the Git tree, so uncommitted changes are not included in the archive. The archive excludes package-lock.json and removes the maintainer-only commit script from package.json.
Template repository maintenance command
npm run commit -- "Commit message" exists only in the template source repository's scripts and is removed from released source archives. It stages all changes, prepares the next patch version, creates a commit, and pushes the current branch directly. If no commit message is provided, it prompts for one interactively.