@haatlabs-core/cli

中文文档
0.18.5发布于 2026/11/14Apache-2.0TypeScriptES Module近 30 天下载 4879

haatlabs: create a new app (Shopify, web or browser extension) and keep its shared files in step.

原始使用文档
文档目录7 节
  1. Install
  2. In a project
  3. memory in platform.json
  4. memory.cache
  5. The name
  6. A new project
  7. A browser extension of an app

@haatlabs-core/cli

haatlabs: writes a project's managed files from @haatlabs-core/templates, and makes new projects.

Install

pnpm add @haatlabs-core/cli --save-dev

or, to make a new app: npx @haatlabs-core/cli create <name> --domain <domain>.

In a project

Each project has @haatlabs-core/cli as a devDependency, at its platform version, and a platform.json that says what the templates need to know (name, domain, port series, apps, CSP lists, memory limits, shared services, and the paths it keeps as its own in unmanaged).

make sync          # pnpm exec haatlabs sync
make sync-check    # pnpm exec haatlabs sync --check
  • sync writes every managed file and records what it wrote in .platform/managed.json. It refuses to overwrite a file edited since, naming it, and writes nothing then: change the template in the platform, or list the path in unmanaged. --force overwrites. It removes a file the templates no longer produce.
  • sync --check fails when a managed file differs from what the templates would write.
  • pnpm-workspace.yaml is managed only between # platform:begin and # platform:end; the project's own lines go after the block.
  • After moving to a new platform version by hand: pnpm install, then make sync. The upgrade pull requests the platform's release opens have done both.

memory in platform.json

The stack's container limits and the Node processes' memory and concurrency, all optional except as defaulted. A small host might say:

"memory": { "api": "320m", "redis": "48m", "redisMaxMemory": "32mb", "nodeHeapMb": 128, "workerConcurrency": 2 }
  • api (default 512m) and redis (default 256m): the containers' memory limits. workerMemory (default 1g) is the worker's.
  • redisMaxMemory (default 128mb): Redis's own maxmemory, which must be below the redis limit (the copy Redis makes of itself while it rewrites its file needs the room). The schema only refuses a value at or above the limit; leaving real headroom for that copy is the project's job.
  • nodeHeapMb: a Node heap cap (--max-old-space-size) for the api and the worker, so Node throws before Docker kills the container. It must be below the api limit and workerMemory. Unset, Node keeps its own default.
  • workerConcurrency: the worker's WORKER_CONCURRENCY, which wins over the env file's.

Without memory, nothing changes. A refused value fails sync with the field named.

memory.cache

"memory": { …, "cache": {} }

A Redis of the environment's own for caches (maxMemory 8mb in a limit of 16m by default): allkeys-lru, nothing on disk, never the queues' Redis. The api and worker get CACHE_REDIS_URL=redis://cache:6379. maxMemory must be below limit.

The name

Lowercase letters and digits, single hyphens between them, starting with a letter, 2 to 31 characters (haatlabs-api). Postgres identifiers, Prometheus metrics and variable names take it with underscores (nameSnake: haatlabs_api, HAATLABS_API_…); everything else keeps the hyphen.

A new project

npx @haatlabs-core/cli create <name> --domain <domain> [--kind shopify|web] \
  [--infra standalone|haatlabs] [--port-series <1-9>] [--into <directory>] [--no-install] [--no-git]
  • --kind shopify (the default): the api, worker, dashboard, the embedded Shopify app, the administrators' dashboard, billing and plans. --kind web: the same without Shopify (email sign-in, organizations, Stripe and Razorpay plans).
  • --infra standalone (the default): the app brings its own Postgres, Redis and Caddy (HTTPS) and deploys to any Debian or Ubuntu server; it owns every file, LICENSE and NOTICE (Apache-2.0) included, and needs no token. --infra haatlabs: one of our own apps, on Haatlabs' hosts, with the managed files haatlabs sync keeps in step; it prints what to add to the edge, the database and GitHub.

--port-series (required with --infra haatlabs; 1 for a standalone app) picks the ports: <series>X00 for the api and <series>X01 for the worker (X: 1 prod, 2 staging, 3 dev, 4 local); 4, 5 and 6 are taken by our own apps.

A browser extension of an app

npx @haatlabs-core/cli create <name> --kind extension --app-domain <domain> [--app-name <name>]

A side panel for Chrome and Edge on @haatlabs-core/extension-ui and @haatlabs-core/extension-kit, signed in through the app's own connect page (https://app.<domain>/connect/extension, which hands the key over as <app-name>.connected; the app's name is the project's without -extension by default) and calling its API (https://api.<domain>). make key gives its id for the app's CONNECTABLE_EXTENSION_IDS; make extension-zip writes the Chrome Web Store (and Edge Add-ons) upload. Firefox's web pages cannot hand a key to an extension, so this sign-in is for Chrome and Edge; an app with its own OAuth server can sign an extension in on Firefox with the kit's startOAuthPkce.

版本与发布记录

@haatlabs-core/cli 共发布 27 个版本,首次发布于 2026/10/23;过去 12 个月发布了 27 个版本。

版本发布日期距今
0.18.5latest2026/11/143 天前
0.18.42026/11/134 天前
0.18.32026/11/134 天前
0.18.22026/11/134 天前
0.18.12026/11/134 天前
0.18.02026/11/134 天前

关于 @haatlabs-core/cli 的常见问题

@haatlabs-core/cli 是什么?

haatlabs: create a new app (Shopify, web or browser extension) and keep its shared files in step.

如何安装 @haatlabs-core/cli?

在项目目录运行 npm install @haatlabs-core/cli,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 haatlabs,可以用 npx haatlabs 直接运行。

@haatlabs-core/cli 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@haatlabs-core/cli 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@haatlabs-core/cli 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=24。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@haatlabs-core/cli 可以商用吗?

@haatlabs-core/cli 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@haatlabs-core/cli 的下载量有多少?

根据 npm 官方下载统计,@haatlabs-core/cli 在 2026/10/17 – 2026/11/15 这 30 天内被下载 4,879 次,日均约 163 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@haatlabs-core/cli 还在维护吗?

最新版本 0.18.5 发布于 2026/11/14(3 天前);至今共发布 27 个版本,其中过去 12 个月发布了 27 个;首次发布于 2026/10/23。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。