@adobe/aio-lib-env

中文文档
3.0.1发布于 2024/02/08Apache-2.0CommonJS近 30 天下载 8万

Adobe I/O lib for determining dev environment

原始使用文档
文档目录5 节
  1. Installing
  2. Usage
  3. Debug Logs
  4. Contributing
  5. Licensing

Version Downloads/week Node.js CI License Codecov Coverage

Adobe I/O Env Lib

This is a helper library that is to be used in the Adobe I/O CLI and SDKs to determine the environment to run in, whether prod, or stage.

Installing

$ npm install @adobe/aio-lib-env 

Usage

Determining the Environment

const { 
  getCliEnv, /* function */ 
  setCliEnv, /* function */
  SUPPORTED_ENVS, /* array<string> */
  DEFAULT_ENV, /* string */
  PROD_ENV, /* string */
  STAGE_ENV /* string */
} = require('@adobe/aio-lib-env')

// getCliEnv defaults to PROD_ENV if the global config key is not set, or is set to an unknown env
const env = getCliEnv() 
// do something based on the env - switch to prod or stage endpoints, for example

Setting the Environment (.aio)

{
  cli: {
    env: "prod"
  }
}

Setting the Environment (.env)

AIO_CLI_ENV=prod

Setting the Environment (in code)

const { setCliEnv, PROD_ENV, STAGE_ENV } = require('@adobe/aio-lib-env')

setCliEnv(PROD_ENV)
setCliEnv(STAGE_ENV)
setCliEnv('delta-quadrant') // throws Error

Debug Logs

LOG_LEVEL=debug <your_call_here>

Prepend the LOG_LEVEL environment variable and debug value to the call that invokes your function, on the command line. This should output a lot of debug data for your SDK calls.

Contributing

Contributions are welcome! Read the Contributing Guide for more information.

Licensing

This project is licensed under the Apache V2 License. See LICENSE for more information.

版本与发布记录

@adobe/aio-lib-env 共发布 7 个版本,首次发布于 2021/03/10;过去 12 个月发布了 0 个版本。

版本发布日期距今
3.0.1latest2024/02/082 年前
3.0.02024/01/102 年前
2.0.0-pre.2024-01-08.afe0f46enext2024/01/082 年前
2.0.02022/08/194 年前
1.1.0-pre.2022-06-06.9947571f2022/06/064 年前
1.1.02021/04/095 年前

关于 @adobe/aio-lib-env 的常见问题

@adobe/aio-lib-env 是什么?

Adobe I/O lib for determining dev environment

如何安装 @adobe/aio-lib-env?

在项目目录运行 npm install @adobe/aio-lib-env,或使用 pnpm add / yarn add / bun add。

@adobe/aio-lib-env 支持 TypeScript 吗?

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

@adobe/aio-lib-env 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@adobe/aio-lib-env 需要什么版本的 Node.js?

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

@adobe/aio-lib-env 可以商用吗?

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

@adobe/aio-lib-env 的下载量有多少?

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

@adobe/aio-lib-env 还在维护吗?

最新版本 3.0.1 发布于 2024/02/08(2 年前);至今共发布 7 个版本,其中过去 12 个月发布了 0 个;首次发布于 2021/03/10。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。