Enjoying Blockend?

Give us a star on GitHub

Star on GitHub
blockend

Blockend

01 getting started

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 init

You 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 .js for NodeNext, or remove extensions for bundlers
  • Redis in your dependencies
  • A matching import alias from tsconfig.json or jsconfig.json

If detection fails, the CLI asks you to choose a framework.

Prompts

  1. Existing config: keep, overwrite, or regenerate. This prompt only appears when blockend.json exists.
  2. Blocks directory: defaults to src/blocks when src/ exists, otherwise blocks.
  3. Framework: choose one when detection fails. The CLI does not ask when it detects a framework.
  4. 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"
  }
}
FieldMeaning
environmentexpress, fastify, next, or hono.
languagetypescript or javascript. The add command currently requires TypeScript.
packageManagerDetected package manager.
importRewriteStrategyrewrite appends .js; remove strips extensions.
includeRedisSelect Redis variants in interactive adds when a block offers one.
aliases.blocksImport alias used in generated code. Omitted when no alias matches.
paths.blocksDirectory 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-limiter

See Add blocks for variants, dependency installation, and file conflicts. See the CLI reference for every command.

On this page