@dotcms/create-app

中文文档
26.11.2-3发布于 2026/11/12ES Module近 30 天下载 4803

CLI to scaffold a dotCMS frontend project or start a local dotCMS Docker stack.

原始使用文档
文档目录18 节
  1. Status
  2. Requirements
  3. Which SDK Version Should I Use?
  4. Quick Start
  5. CLI
  6. Behavior by Mode
  7. 1) Cloud mode (existing dotCMS instance)
  8. 2) Local mode ( --local )
  9. 3) Starter-only local mode ( --starter <url> )
  10. The bundled Docker stack
  11. Published ports
  12. Using a different compose file
  13. If dotCMS is already running
  14. Your .env
  15. Examples
  16. Validation Rules
  17. Troubleshooting
  18. Development (this repo)

@dotcms/create-app

CLI to scaffold a dotCMS frontend project or start a local dotCMS Docker stack.

Status

Beta. Behavior and flags may change.

Requirements

  • Node.js 22.22.3+ and npm
  • Git
  • Docker (for --local or --starter)
  • Internet access (downloads templates; pulls Docker images)

Which SDK Version Should I Use?

dotCMS SDKs are published in lockstep with dotCMS itself: every @dotcms/* package ships at the exact same version number as the dotCMS release it was built for (e.g. dotCMS 26.7.14-1 → @dotcms/[email protected], @dotcms/[email protected], and so on).

Simple rule of thumb: use the SDK version that matches your dotCMS instance's version.

You don't have to upgrade the SDK every time dotCMS releases a new version (or vice versa). Most releases don't change anything the SDKs rely on, so an older SDK usually keeps working fine against a newer dotCMS instance. Occasionally, though, a release does include a real breaking change — and if your SDK is older than that point, it will stop working correctly.

You don't need to track this yourself: your dotCMS instance always knows the oldest SDK version it still supports, and the SDK checks itself against it automatically. If you're using an SDK that's too old, you'll see a clear warning in your console telling you to upgrade.

Recommendation: pin your SDKs to the same version as your dotCMS instance, and only bump them when you upgrade dotCMS — or when the console tells you to.

On an LTS release? LTS releases don't currently get their own matching SDK version. Until that's addressed, use the SDK version published for the closest regular release at or before your LTS version.

Want more background on how dotCMS releases and support windows work? See Release & Support Lifecycle.

Quick Start

npx @dotcms/create-app my-app

Global install:

npm install -g @dotcms/create-app
create-dotcms-app my-app

CLI

create-dotcms-app [projectName] [options]
OptionDescription
-f, --framework <framework>Framework: nextjs, astro, angular, angular-ssr
-d, --directory <path>Parent or target directory
--localUse local dotCMS with Docker
--starter <url>Custom starter ZIP URL (local-only; sets CUSTOM_STARTER_URL)
--url <url>dotCMS URL for cloud mode
-u, --username <username>dotCMS username for cloud mode
-p, --password <password>dotCMS password for cloud mode
-V, --versionShow CLI version

Framework aliases:

  • next, next.js -> nextjs
  • ng -> angular
  • angular-server -> angular-ssr

Behavior by Mode

1) Cloud mode (existing dotCMS instance)

Used when you do not pass --local or --starter and choose cloud in prompts.

Flow:

  1. Validates URL, project name, and flags.
  2. Checks dotCMS health at /api/v1/appconfiguration.
  3. Authenticates (up to 3 attempts).
  4. Reads defaultSite from /api/v1/site/defaultSite.
  5. Configures UVE via /api/v1/apps/dotema-config-v2/{siteId}. Optional — if this fails the CLI warns, explains how to finish it by hand, and carries on.
  6. Scaffolds selected frontend and runs npm install.
  7. Writes .env with your host, site ID and token (see Your .env).

2) Local mode (--local)

Flow:

  1. Validates Docker availability.
  2. Checks the ports this stack publishes: 8082, 8443 and 8090. A dotCMS already running on 8082 is not treated as a conflict — see If dotCMS is already running.
  3. Writes the bundled docker-compose.yml into the project directory (see The bundled Docker stack).
  4. Runs docker compose up -d --wait, which blocks until every service reports healthy, streaming progress and elapsed time so a long first pull is never a silent spinner.
  5. Waits for readiness on /dotmgt/readyz, falling back to /api/v1/appconfiguration.
  6. Authenticates with default local credentials ([email protected] / admin).
  7. Reads defaultSite, configures UVE (optional — a failure warns and continues), scaffolds the frontend, runs npm install.
  8. Writes .env with your host, site ID and token (see Your .env).

3) Starter-only local mode (--starter <url>)

--starter implies local mode.

Flow:

  1. Same Docker and port checks as local mode.
  2. Writes the bundled docker-compose.yml.
  3. Rewrites CUSTOM_STARTER_URL in docker-compose.yml.
  4. Also passes CUSTOM_STARTER_URL in compose environment at runtime.
  5. Starts containers and waits for health check.
  6. Skips frontend scaffold and dotCMS frontend settings flow (token, default site lookup, UVE setup).

Use this when your starter is not compatible with the default frontend sample flow.

The bundled Docker stack

--local and --starter write a docker-compose.yml that ships inside this package. It is no longer downloaded from the dotCMS/core repository at run time, so the stack you get is the one this CLI version was tested against, rather than whatever is currently on main.

The stack is db (PostgreSQL), opensearch, and dotcms. dotcms starts only after both dependencies report healthy, and carries restart: unless-stopped, so it no longer races Postgres and exit at startup.

Published ports

PortBindingPurpose
8082all interfacesdotCMS HTTP
8443all interfacesdotCMS HTTPS
8090127.0.0.1 onlydotCMS management endpoints

PostgreSQL and OpenSearch publish no ports — they are reachable only from inside the compose network, so running your own Postgres or OpenSearch on the usual ports does not conflict.

Why 8090 is loopback-only. It serves /dotmgt/livez, /dotmgt/readyz, /dotmgt/health and /dotmgt/metrics, and dotCMS authorizes those purely by the port a request arrives on — there is no credential check and no IP allow-list. Binding it to 0.0.0.0 would expose your instance's health and metrics to everyone on your network. It is bound to 127.0.0.1 deliberately; do not "fix" it to a wildcard.

Using a different compose file

Set DOTCMS_COMPOSE_URL to fetch one from a URL instead of using the bundled file:

DOTCMS_COMPOSE_URL=https://example.com/my-compose.yml npx @dotcms/create-app my-app --local

This is an escape hatch for hotfixes. The file must keep a single-line CUSTOM_STARTER_URL: entry or --starter will fail against it.

If dotCMS is already running

A dotCMS on 8082 from a previous run is not a conflict — the CLI probes it and offers a choice:

⚠  Found a dotCMS already running at http://localhost:8082
   Docker project "my-app" · Up 8 minutes (healthy)

? How would you like to continue?
❯ Use this instance for my project
  Replace it with a clean instance
  Cancel

Replace stops that Docker project and removes its volumes (docker compose -p <project> down -v) before starting fresh. It is offered only when a Compose project owns the port — something started outside Compose is not the CLI's to destroy.

Reuse requires the instance to pass a readiness check and issue a token; anything else on 8082 is still a hard failure.

In a non-interactive run (CI, or no TTY) the CLI auto-reuses and prints a notice. It never replaces without being asked.

Your .env

The CLI writes .env into your project with the values the scaffolded app reads — NEXT_PUBLIC_* for Next.js, PUBLIC_* for Astro. You do not need to copy anything by hand.

An existing .env is never overwritten: the CLI prints the values instead so you can merge them. Angular has no .env — it reads a TypeScript environment object, so the values are printed for you to paste into the environment files.

Examples

Interactive:

npx @dotcms/create-app my-blog

Local + specific framework:

npx @dotcms/create-app my-blog --local --framework nextjs

Starter-only local:

npx @dotcms/create-app my-blog --starter https://repo.example.com/path/starter.zip

Cloud with flags:

npx @dotcms/create-app my-blog \
  --framework angular \
  --url https://demo.dotcms.com \
  --username [email protected] \
  --password admin

Debug errors with stack traces:

DEBUG=1 npx @dotcms/create-app my-blog --local

Validation Rules

  • URLs must include protocol (http:// or https://).
  • Project names are validated for path traversal, invalid characters, reserved Windows names, and length.
  • If local mode is selected (--local or --starter), cloud flags are ignored with a warning.
  • Existing non-empty target directory requires confirmation before cleanup.

Troubleshooting

Docker not available:

  • Install/start Docker Desktop, then retry.

Ports already in use:

  • If it is a dotCMS from a previous run, the CLI offers to reuse or replace it — see If dotCMS is already running.
  • Otherwise, find the owner: lsof -i :8082 (macOS/Linux) or netstat -ano | findstr ":8082" (Windows), then stop it or run docker compose down.

zip END header not found during starter load:

  • Starter URL is reachable but not returning a valid ZIP payload.
  • Verify artifact URL, repository permissions, and response content type/body.

Development (this repo)

Build:

pnpm nx build sdk-create-app --skip-nx-cache

Lint:

pnpm nx lint sdk-create-app

Verify the package ships correctly (asserts the compose asset reaches dist/ and the npm tarball):

pnpm nx verify-package sdk-create-app

Dist output:

  • dist/libs/sdk/create-app/index.js
  • ESM Node CLI bundle with shebang in production build
  • Publishable package includes JavaScript files and README.md only (no type declarations)

版本与发布记录

@dotcms/create-app 共发布 176 个版本,首次发布于 2026/01/07;过去 12 个月发布了 176 个版本。

版本发布日期距今
26.11.2-3latest2026/11/121 天前
26.11.11-12026/11/112 天前
26.11.10-22026/11/112 天前
26.11.9-1-next.3071next2026/11/112 天前
26.11.9-12026/11/094 天前
26.11.6-32026/11/076 天前

关于 @dotcms/create-app 的常见问题

@dotcms/create-app 是什么?

CLI to scaffold a dotCMS frontend project or start a local dotCMS Docker stack.

如何安装 @dotcms/create-app?

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

@dotcms/create-app 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/dotcms__create-app 是否存在。

@dotcms/create-app 支持 ESM 还是 CommonJS?

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

@dotcms/create-app 可以商用吗?

@dotcms/create-app 使用 未声明 许可。package.json 没有声明许可证。没有许可证的代码默认保留全部权利,商用前请联系作者或查看仓库中的 LICENSE 文件。以上为概括,不构成法律意见,请以许可原文为准。

@dotcms/create-app 的下载量有多少?

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

@dotcms/create-app 还在维护吗?

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