Initialize Blockend
Create blockend.json so the CLI knows your framework, blocks directory, and import style.
The init command creates blockend.json in your project root. The CLI uses this file to filter compatible blocks and place their files correctly.
Run it from the project root:
pnpm dlx blockend-cli initYou normally run init once. If the file already exists, the CLI asks whether to keep it, overwrite it, or delete and regenerate it.
What init detects
- Framework: Express, Fastify, Next.js, or Hono
- Language: TypeScript or JavaScript
- Package manager: npm, pnpm, yarn, or bun
- Import rewrite strategy: append
.jsfor NodeNext, or remove extensions for bundlers - Redis in your dependencies
- A matching import alias from
tsconfig.jsonorjsconfig.json
If detection fails, the CLI asks you to choose a framework.
Prompts
- Existing config: keep, overwrite, or regenerate. This prompt only appears when
blockend.jsonexists. - Blocks directory: defaults to
src/blockswhensrc/exists, otherwiseblocks. - Framework: choose one when detection fails. The CLI does not ask when it detects a framework.
- Redis: enable Redis-backed variants when Redis is detected.
The import alias is derived from your tsconfig.json or jsconfig.json path mappings without a prompt. If none match, the CLI omits aliases.blocks.
init does not install a block. It only writes the config file.
Generated config
{
"$schema": "https://blockend.noorulhassan.com/schema.json",
"environment": "express",
"language": "typescript",
"packageManager": "pnpm",
"importRewriteStrategy": "remove",
"includeRedis": false,
"aliases": {
"blocks": "@/blocks"
},
"paths": {
"blocks": "./src/blocks"
}
}| Field | Meaning |
|---|---|
environment | express, fastify, next, or hono. |
language | typescript or javascript. The add command currently requires TypeScript. |
packageManager | Detected package manager. |
importRewriteStrategy | rewrite appends .js; remove strips extensions. |
includeRedis | Select Redis variants in interactive adds when a block offers one. |
aliases.blocks | Import alias used in generated code. Omitted when no alias matches. |
paths.blocks | Directory where blocks are written. |
The installed array is added later by the add command. It is not part of a fresh config.
Non-interactive setup
pnpm dlx blockend-cli init --yes--yes accepts detected defaults and does not prompt. If blockend.json already exists, it overwrites the file. If no framework is detected, it uses Express. Run init --yes only when overwriting the config is safe.
For machine-readable output:
pnpm dlx blockend-cli init --json--json changes the output format but still shows prompts. Combine it with --yes for a non-interactive run.
Example output
✔ Project scanned.
Framework detected: express
Import alias: @/blocks
Import strategy: Bundler / Extensionless
✔ Configuration saved.
Blockend initialized! Run: npx blockend add <block>Next steps
pnpm dlx blockend-cli add rate-limiterSee Add blocks for variants, dependency installation, and file conflicts. See the CLI reference for every command.