@adobe/helix-cli

中文文档
14.26.0发布于 2023/09/15Apache-2.0ES Module近 30 天下载 5407

Project Helix CLI

原始使用文档
文档目录8 节
  1. Status
  2. Installation
  3. Quick Start
  4. Starting development
  5. automatically open the browser
  6. setting up a self-signed cert for using https
  7. environment
  8. Testing

Helix/AEM Command Line Interface (hlx or aem)

Status

codecov CircleCI GitHub license GitHub issues LGTM Code Quality Grade: JavaScript

The Helix Command Line Interface allows web developers to create, develop, and deploy digital experiences using Adobe Experience Manager Sites 'Edge Delivery Services' f.k.a 'Project Helix'

Installation

Install hlx or aem as a global command. You need Node 12.11 or newer.

$ npm install -g @adobe/helix-cli

Quick Start

You can interchange hlx and aem in the examples listed below.

$ hlx --help
Usage: hlx <command> [options]

Commands:
  hlx up  Run a Helix development server

Options:
  --version                Show version number                         [boolean]
  --log-file, --logFile    Log file (use "-" for stdout)  [array] [default: "-"]
  --log-level, --logLevel  Log level
        [string] [choices: "silly", "debug", "verbose", "info", "warn", "error"]
                                                               [default: "info"]
  --tls-key, --tlsKey      Path to .key file (for enabling TLS)        [string]
  --tls-cert, --tlsCert    Path to .pem file (for enabling TLS)        [string]
  --help                   Show help                                   [boolean]

use <command> --help to get command specific details.

for more information, find our manual at https://github.com/adobe/helix-cli

Starting development

$ cd <my-cool-project>
$ hlx up

automatically open the browser

The --open argument takes a path, eg --open=/products/, will cause the browser to be openend at the specific location. Disable with --no-open'.

setting up a self-signed cert for using https

  1. create the certificate
$ openssl req -new -newkey rsa:4096 -x509 -sha256 -days 365 -nodes -out server.crt -keyout server.key -subj "/CN=localhost"

this will create 2 files: server.crt and server.key

  1. start hlx with tls support
$ hlx up --tls-cert server.crt --tls-key server.key
    ____              __    ___   v14.21.4
   / __/______ ____  / /__ / (_)__
  / _// __/ _ `/ _ \/  '_// / / _ \
 /_/ /_/  \_,_/_//_/_/\_\/_/_/_//_/

info: Starting Franklin dev server v14.21.4
info: Local Franklin dev server up and running: https://localhost:3000/
  1. (optional) Add arguments to .env file:
$ echo -e "HLX_TLS_CERT=server.crt\nHLX_TLS_KEY=server.key" >> .env

environment

All the command arguments can also be specified via environment variables. the .env file is loaded automatically.

example:

.env

HLX_OPEN=/products
HLX_PORT=8080
HLX_PAGES_URL=https://stage.myproject.com

HTTP Proxy

In order to use a HTTP proxy (eg behind a corporate firewall), you can set the respective environment variables:

NO_PROXY is a list of host names (optionally with a port). If the input URL matches any of the entries in NO_PROXY, then the input URL should be fetched by a direct request (i.e. without a proxy).

Matching follows the following rules:

NO_PROXY=* disables all proxies. Space and commas may be used to separate the entries in the NO_PROXY list. If NO_PROXY does not contain any entries, then proxies are never disabled. If a port is added after the host name, then the ports must match. If the URL does not have an explicit port name, the protocol's default port is used. Generally, the proxy is only disabled if the host name is an exact match for an entry in the NO_PROXY list. The only exceptions are entries that start with a dot or with a wildcard; then the proxy is disabled if the host name ends with the entry. See test.js for examples of what should match and what does not.

*_PROXY The environment variable used for the proxy depends on the protocol of the URL. For example, https://example.com uses the "https" protocol, and therefore the proxy to be used is HTTPS_PROXY (NOT HTTP_PROXY, which is only used for http:-URLs).

If present, ALL_PROXY is used as fallback if there is no other match.

Global

optionvariabledefaultdescription
--log-fileHLX_LOG_FILE-Log file. use - to log to stdout
--log-levelHLX_LOG_LEVELinfoLog level

Up command

optionvariabledefaultdescription
--portHLX_PORT3000Development server port
--addrHLX_ADDR127.0.0.1Development server bind address
--livereloadHLX_LIVERELOADtrueEnable automatic reloading of modified sources in browser.
--no-livereloadHLX_NO_LIVERELOADfalseDisable live-reload.
--openHLX_OPEN/Open a browser window at specified path after server start.
--no-openHLX_NO_OPENfalseDisable automatic opening of browser window.
--tls-keyHLX_TLS_KEYundefinedPath to .key file (for enabling TLS)
--tls-certHLX_TLS_CERTundefinedPath to .pem file (for enabling TLS)

Developing Helix CLI

Testing

You can use npm run check to run the tests and check whether your code adheres to the helix-cli coding style.

版本与发布记录

@adobe/helix-cli 共发布 1,213 个版本,首次发布于 2018/06/06;过去 12 个月发布了 0 个版本。

版本发布日期距今
14.26.0latest2023/09/153 年前
14.25.12023/09/143 年前
14.25.02023/09/063 年前
14.24.172023/09/043 年前
14.24.162023/09/033 年前
14.24.152023/09/013 年前

其他发布通道:lastest → 0.5.3,devel → 0.13.11-pre.5-dev,experimental → 0.13.11-pre.8-test,next → 0.13.15-pre.8。

关于 @adobe/helix-cli 的常见问题

@adobe/helix-cli 是什么?

Project Helix CLI

如何安装 @adobe/helix-cli?

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

@adobe/helix-cli 支持 TypeScript 吗?

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

@adobe/helix-cli 支持 ESM 还是 CommonJS?

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

@adobe/helix-cli 需要什么版本的 Node.js?

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

@adobe/helix-cli 可以商用吗?

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

@adobe/helix-cli 的下载量有多少?

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

@adobe/helix-cli 还在维护吗?

最新版本 14.26.0 发布于 2023/09/15(3 年前);至今共发布 1213 个版本,其中过去 12 个月发布了 0 个;首次发布于 2018/06/06。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。