aem-cli
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseAEM CLI
AEM CLI
Local development tool for AEM Edge Delivery Services. Three commands: (local dev
server), (import server + UI), (da.live content sync).
aem upaem importaem contentBinary: (primary), (alias from the former package, renamed to
at v15.0.0).
aemhlxhelix-cli@adobe/aem-cliAEM Edge Delivery Services的本地开发工具。包含三个命令:(本地开发服务器)、(导入服务器+界面)、(与da.live的内容同步)。
aem upaem importaem content可执行文件:(主命令)、(原包的别名,在v15.0.0版本时更名为)。
aemhlxhelix-cli@adobe/aem-cli1. Install
1. 安装
Prerequisite: Node.js 12.11 or newer (Node 22 LTS recommended).
[verified]bash
undefined前提条件: Node.js 12.11或更高版本(推荐使用Node 22 LTS)。
[verified]bash
undefinedGlobal install
全局安装
npm install -g @adobe/aem-cli
npm install -g @adobe/aem-cli
One-off via npx (no global install needed)
通过npx一次性使用(无需全局安装)
npx -y @adobe/aem-cli up
**Verify:**
```bash
aem --version # or: hlx --versionnpx -y @adobe/aem-cli up
**验证安装:**
```bash
aem --version # 或:hlx --versionMigrating from the old helix-cli package
从旧版helix-cli包迁移
If fails with , the old package is still
installed and owns the binary. Uninstall it first (npm package scoped under , named
):
npm install -g @adobe/aem-cliFile exists: …/hlx@adobehelix-cli[verified]bash
npm uninstall -g @adobe/helix-cli
npm install -g @adobe/aem-cliThe binary name changes from to ; both work after installation because
ships as an alias.
hlxaemaem-clihlx如果执行时提示,说明旧版包仍在安装中并占用了该可执行文件。请先卸载旧版包(npm包范围为,包名为):
npm install -g @adobe/aem-cliFile exists: …/hlx@adobehelix-cli[verified]bash
npm uninstall -g @adobe/helix-cli
npm install -g @adobe/aem-cli可执行文件名称从变更为;安装完成后两者均可使用,因为附带了作为别名。
hlxaemaem-clihlx2. aem up
— Local Dev Server
aem up2. aem up
—— 本地开发服务器
aem upAgent-standard invocation:
bash
aem up --no-open --forward-browser-logsCheck the server is running:
bash
curl -s -o /dev/null -w "%{http_code}" http://localhost:3000标准调用方式:
bash
aem up --no-open --forward-browser-logs检查服务器是否运行:
bash
curl -s -o /dev/null -w "%{http_code}" http://localhost:3000Expected: 200
预期结果:200
undefinedundefinedKey flags
关键参数
| Flag | What it does |
|---|---|
| Do not open a browser window on startup |
| Forward browser console messages (log, error, warn, info) to the terminal |
| Listen on a different port (default: |
| Bind address; use |
| Origin URL to proxy content from (overrides the project's default pages URL) |
| Serve local HTML files from |
| URL path where |
| Disable automatic browser reload on file changes |
| Stop another AEM CLI instance on the same port before starting (default: true) |
| Path to |
| Path to |
| Allow insecure (self-signed cert) requests to the upstream server |
| Print indexed records for the current page (debugging) |
| Site token for CLI access to the website |
| Proxy all cookies (default: only |
--html-folder[verified]| 参数 | 功能 |
|---|---|
| 启动时不打开浏览器窗口 |
| 将浏览器控制台消息(log、error、warn、info)转发到终端 |
| 使用指定端口监听(默认: |
| 绑定地址;使用 |
| 用于代理内容的源URL(覆盖项目默认的页面URL) |
| 从 |
| |
| 禁用文件变更时的自动浏览器重载 |
| 启动前停止同一端口上的其他AEM CLI实例(默认:true) |
| TLS证书的 |
| TLS密钥的 |
| 允许向上游服务器发送不安全(自签名证书)请求 |
| 打印当前页面的索引记录(用于调试) |
| CLI访问网站的站点令牌 |
| 代理所有Cookie(默认:仅代理 |
--html-folder[verified]Serving import HTML locally (preview-import pattern)
本地提供导入的HTML文件(预览导入模式)
bash
aem up --html-folder drafts --no-open --forward-browser-logsbash
aem up --html-folder drafts --no-open --forward-browser-logsFiles in ./drafts/ are served at /drafts/<name> (no extension needed)
./drafts/目录下的文件会在/drafts/<name>路径下提供(无需扩展名)
---
---3. .env
Configuration
.env3. .env
配置
.envAll options can be persisted in at the project root; loaded automatically.
.env[verified]dotenv
undefined所有选项均可持久化到项目根目录的文件中,会自动加载。
.env[verified]dotenv
undefined.env example
.env示例
AEM_PORT=8080
AEM_PAGES_URL=https://stage.myproject.com
AEM_FORWARD_BROWSER_LOGS=true
AEM_HTML_FOLDER=drafts
AEM_TLS_CERT=server.crt
AEM_TLS_KEY=server.key
AEM_OPEN=/products
See [references/command-reference.md](./references/command-reference.md) for the complete
`AEM_*` environment variable reference with defaults.
---AEM_PORT=8080
AEM_PAGES_URL=https://stage.myproject.com
AEM_FORWARD_BROWSER_LOGS=true
AEM_HTML_FOLDER=drafts
AEM_TLS_CERT=server.crt
AEM_TLS_KEY=server.key
AEM_OPEN=/products
完整的`AEM_*`环境变量参考及默认值,请查看[references/command-reference.md](./references/command-reference.md)。
---4. HTTPS / TLS
4. HTTPS / TLS
Trusted local certificate (recommended — avoids browser warnings)
受信任的本地证书(推荐——避免浏览器警告)
Install ( on macOS, on Windows,
elsewhere), then:
mkcertbrew install mkcertchoco install mkcertgo install filippo.io/mkcert@latestbash
mkcert -install # one-time CA install
mkcert -cert-file server.crt -key-file server.key localhost 127.0.0.1
aem up --tls-cert server.crt --tls-key server.key安装(macOS使用,Windows使用,其他平台使用),然后执行:
mkcertbrew install mkcertchoco install mkcertgo install filippo.io/mkcert@latestbash
mkcert -install # 一次性安装CA证书
mkcert -cert-file server.crt -key-file server.key localhost 127.0.0.1
aem up --tls-cert server.crt --tls-key server.keySelf-signed certificate (no mkcert)
自签名证书(无需mkcert)
bash
openssl req -new -newkey rsa:4096 -x509 -sha256 -days 365 -nodes \
-out server.crt -keyout server.key -subj "/CN=localhost"
aem up --tls-cert server.crt --tls-key server.keybash
openssl req -new -newkey rsa:4096 -x509 -sha256 -days 365 -nodes \
-out server.crt -keyout server.key -subj "/CN=localhost"
aem up --tls-cert server.crt --tls-key server.keyPersisting TLS in .env
在.env中持久化TLS配置
dotenv
AEM_TLS_CERT=server.crt
AEM_TLS_KEY=server.keydotenv
AEM_TLS_CERT=server.crt
AEM_TLS_KEY=server.key5. Corporate Proxy and Certificate Trust
5. 企业代理与证书信任
aem upunable to get local issuer certificatebash
undefined在启用HTTPS拦截的代理环境下,会报错。从浏览器导出企业CA证书或向IT部门获取,然后设置:
aem upunable to get local issuer certificatebash
undefinedmacOS / Linux
macOS / Linux
export NODE_EXTRA_CA_CERTS=/path/to/corporate-ca.crt
aem up
export NODE_EXTRA_CA_CERTS=/path/to/corporate-ca.crt
aem up
Windows
Windows
set NODE_EXTRA_CA_CERTS=./certs/corporate-ca.pem
aem up
`NODE_EXTRA_CA_CERTS` is a Node built-in — set it in the shell profile or CI, not `.env`.
**Proxy env vars:**
| Variable | Purpose |
|---|---|
| `HTTP_PROXY` | Proxy for HTTP requests |
| `HTTPS_PROXY` | Proxy for HTTPS requests |
| `ALL_PROXY` | Fallback for either protocol |
| `NO_PROXY` | Comma-separated hosts to bypass; `*` disables all proxies |
---set NODE_EXTRA_CA_CERTS=./certs/corporate-ca.pem
aem up
`NODE_EXTRA_CA_CERTS`是Node的内置变量——请在shell配置文件或CI中设置,不要在`.env`中设置。
**代理环境变量:**
| 变量 | 用途 |
|---|---|
| `HTTP_PROXY` | HTTP请求的代理 |
| `HTTPS_PROXY` | HTTPS请求的代理 |
| `ALL_PROXY` | 两种协议的备用代理 |
| `NO_PROXY` | 逗号分隔的需绕过代理的主机列表;`*`表示禁用所有代理 |
---6. aem import
— Import Server
aem import6. aem import
—— 导入服务器
aem importLocal import server (default port 3001) serving the helix-importer-ui.
bash
aem import # opens Importer UI in browser at port 3001
aem import --no-open # headless / background start
aem import --port 3002 # different portKey flags:
| Flag | Default | What it does |
|---|---|---|
| | Import server port |
| — | Do not open the browser window |
| | Allow self-signed certs on the proxied site |
| helix-importer-ui repo on GitHub | Custom Importer UI repo |
| | Skip downloading/installing the UI |
| — | JSON file of custom headers for proxy requests |
| — | Cache proxied responses to a local folder |
| | Print request headers to console for debugging |
| — | TLS for the import server itself (see §4) |
Workflow: For writing the transformation script or running the full import
pipeline, use the page-import or generate-import-html skills. This skill covers only
starting and configuring the server.
import.js本地导入服务器(默认端口3001),用于提供helix-importer-ui界面。
bash
aem import # 在浏览器打开端口3001的导入界面
aem import --no-open # 无头/后台启动
aem import --port 3002 # 使用其他端口关键参数:
| 参数 | 默认值 | 功能 |
|---|---|---|
| | 导入服务器端口 |
| — | 不打开浏览器窗口 |
| | 允许代理站点使用自签名证书 |
| GitHub上的helix-importer-ui仓库 | 自定义导入界面仓库 |
| | 跳过下载/安装界面 |
| — | 代理请求的自定义头信息JSON文件 |
| — | 将代理响应缓存到本地目录 |
| | 将请求头打印到控制台用于调试 |
| — | 导入服务器自身的TLS配置(见第4节) |
工作流: 若要编写转换脚本或运行完整的导入流水线,请使用page-import或generate-import-html技能。本技能仅涵盖服务器的启动与配置。
import.js7. aem content
— da.live Content Sync
aem content7. aem content
—— da.live内容同步
aem contentbash
aem content clone [--path /] # auth via browser popup; clones into ./content/
aem content status # show added / modified / deleted files
aem content diff [path] # diff local vs remote
aem content merge [path] # sync remote changes into local files
aem content add <files..> # stage changes (like git add)
aem content commit -m "..." # commit staged changes (like git commit)
aem content push # upload committed changes to da.live
aem content push --force # overwrite remote on conflictAuth token cached at (gitignored); browser OAuth on first use.
.hlx/.da-token.jsonRead the token directly to authenticate curl calls:
bash
TOKEN=$(jq -r .access_token .hlx/.da-token.json)bash
aem content clone [--path /] # 通过浏览器弹窗认证;克隆到./content/目录
aem content status # 显示已添加/修改/删除的文件
aem content diff [path] # 对比本地与远程文件差异
aem content merge [path] # 将远程变更同步到本地文件
aem content add <files..> # 暂存变更(类似git add)
aem content commit -m "..." # 提交暂存的变更(类似git commit)
aem content push # 将提交的变更上传到da.live
aem content push --force # 冲突时覆盖远程内容认证令牌缓存于(已加入git忽略);首次使用时通过浏览器OAuth认证。
.hlx/.da-token.json可直接读取令牌以认证curl请求:
bash
TOKEN=$(jq -r .access_token .hlx/.da-token.json)Known behaviour: binary files
已知特性:二进制文件
aem content push[verified]Verify a binary upload landed:
bash
curl -sI https://content.da.live/<org>/<repo>/path/to/image.png | grep -i "content-type"If it 404s, upload the binary directly via the DA Source API:
bash
TOKEN=$(jq -r .access_token .hlx/.da-token.json)
curl -X POST \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: image/png" \
--data-binary @./image.png \
"https://admin.da.live/source/<org>/<repo>/path/to/image.png"aem content push[verified]验证二进制文件是否上传成功:
bash
curl -sI https://content.da.live/<org>/<repo>/path/to/image.png | grep -i "content-type"如果返回404,请通过DA Source API直接上传二进制文件:
bash
TOKEN=$(jq -r .access_token .hlx/.da-token.json)
curl -X POST \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: image/png" \
--data-binary @./image.png \
"https://admin.da.live/source/<org>/<repo>/path/to/image.png"Known behaviour: pre-upload HTML normalization
已知特性:上传前HTML标准化
Pre-upload normalization strips EDS icon decorations ( etc.).
For byte-faithful EDS HTML, POST directly to the DA Source API:
<span class="icon icon-X">[verified]bash
curl -X POST \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: text/html" \
--data-binary @./page.html \
"https://admin.da.live/source/<org>/<repo>/path/to/page.html"See the da-content skill (platform reference §7) for the DA Source API contract and rate limits.
上传前的标准化处理会移除EDS图标装饰(如等)。 若要实现字节级一致的EDS HTML上传,请直接POST到DA Source API:
<span class="icon icon-X">[verified]bash
curl -X POST \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: text/html" \
--data-binary @./page.html \
"https://admin.da.live/source/<org>/<repo>/path/to/page.html"DA Source API协议及速率限制,请查看da-content技能(平台参考第7节)。
Troubleshooting
故障排查
| Symptom | Cause | Fix |
|---|---|---|
| old | uninstall the old package (see §1) then reinstall |
| Port 3000 is taken | Pass |
| Corporate proxy intercepts TLS | Export corp CA cert → |
| Local HTML file in | Add |
| Wrong origin URL proxied | Pass |
| CLI silently no-ops on binaries | Upload binary via DA Source API (see §7) |
| Pre-upload normalization removes EDS decorations | POST directly to DA Source API for byte-faithful upload |
| Port 3001 in use, or UI download failed | Try |
| 症状 | 原因 | 解决方法 |
|---|---|---|
| 旧版 | 先卸载旧版包(见第1节),然后重新安装 |
| 端口3000被占用 | 使用 |
| 企业代理拦截了TLS | 导出企业CA证书 → 设置 |
| 本地 | 添加 |
| 代理了错误的源URL | 使用 |
| CLI会静默跳过二进制文件 | 通过DA Source API上传二进制文件(见第7节) |
| 上传前的标准化处理移除了EDS装饰 | 直接POST到DA Source API以实现字节级一致的上传 |
| 端口3001被占用,或界面下载失败 | 尝试使用 |
Reference
参考资料
- references/command-reference.md — exhaustive flag +
env-var tables for all commands
AEM_* - Upstream docs: https://www.npmjs.com/package/@adobe/aem-cli — npm page for (the GitHub repo is named
@adobe/aem-clifor historical reasons)helix-cli - Importer UI: the helix-importer-ui (search npm or GitHub for ) — served by
helix-importer-uiaem import
- references/command-reference.md —— 所有命令的详尽参数及环境变量表格
AEM_* - 上游文档:https://www.npmjs.com/package/@adobe/aem-cli —— 的npm页面(GitHub仓库因历史原因仍命名为
@adobe/aem-cli)helix-cli - 导入界面:helix-importer-ui(在npm或GitHub搜索)—— 由
helix-importer-ui提供服务aem import