@expo/plugin-warn-if-update-available

中文文档
2.5.1发布于 2023/08/17MITTypeScriptCommonJS近 30 天下载 703.4万

warns if there is a newer version of CLI released

原始使用文档

@oclif/plugin-warn-if-update-available

warns if there is a newer version of CLI released

Version CircleCI Appveyor CI Downloads/week License

What is this?

This plugin shows a warning message if a user is running an out of date CLI.

screenshot

How it works

This checks the version against the npm registry asynchronously in a forked process, at most once per 7 days. It then saves a version file to the cache directory that will enable the warning. The upside of this method is that it won't block a user while they're using your CLI—the downside is that it will only display after running a command that fetches the new version.

Installation

Add the plugin to your project with yarn add @oclif/plugin-warn-if-update-available, then add it to the package.json of the oclif CLI:

{
  "name": "mycli",
  "version": "0.0.0",
  // ...
  "oclif": {
    "plugins": ["@oclif/plugin-help", "@oclif/plugin-warn-if-update-available"]
  }
}

Configuration

In package.json, set oclif['warn-if-update-available'] to an object with any of the following configuration properties:

  • timeoutInDays - Duration between update checks. Defaults to 60.
  • message - Customize update message.
  • registry - URL of registry. Defaults to the public npm registry: https://registry.npmjs.org
  • authorization - Authorization header value for registries that require auth.

Example configuration

{
  "oclif": {
    "plugins": [
      "@oclif/plugin-warn-if-update-available"
    ],
    "warn-if-update-available": {
      "timeoutInDays": 7,
      "message": "<%= config.name %> update available from <%= chalk.greenBright(config.version) %> to <%= chalk.greenBright(latest) %>.",
      "registry": "https://my.example.com/module/registry",
      "authorization": "Basic <SOME READ ONLY AUTH TOKEN>"
    }
  }
}

版本与发布记录

@expo/plugin-warn-if-update-available 共发布 10 个版本,首次发布于 2020/12/12;过去 12 个月发布了 0 个版本。

版本发布日期距今
2.5.1latest2023/08/173 年前
2.5.02023/01/103 年前
2.4.02022/10/264 年前
2.3.02022/05/274 年前
2.2.02022/05/124 年前
2.1.02022/02/044 年前

关于 @expo/plugin-warn-if-update-available 的常见问题

@expo/plugin-warn-if-update-available 是什么?

warns if there is a newer version of CLI released

如何安装 @expo/plugin-warn-if-update-available?

在项目目录运行 npm install @expo/plugin-warn-if-update-available,或使用 pnpm add / yarn add / bun add。

@expo/plugin-warn-if-update-available 支持 TypeScript 吗?

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

@expo/plugin-warn-if-update-available 支持 ESM 还是 CommonJS?

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

@expo/plugin-warn-if-update-available 需要什么版本的 Node.js?

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

@expo/plugin-warn-if-update-available 可以商用吗?

@expo/plugin-warn-if-update-available 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@expo/plugin-warn-if-update-available 的下载量有多少?

根据 npm 官方下载统计,@expo/plugin-warn-if-update-available 在 2026/10/14 – 2026/11/12 这 30 天内被下载 7,034,009 次,日均约 234,467 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@expo/plugin-warn-if-update-available 还在维护吗?

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