@cubejs-infra/post-installer

中文文档
0.2.0发布于 2026/09/21Apache-2.0TypeScriptCommonJS近 30 天下载 50.6万

Resources installer

原始使用文档
文档目录3 节
  1. Downloading plain files (no extraction)
  2. Constraints
  3. Variables

@cubejs-infra/post-installer

Easiest way to download files on post installation step of you npm package.

Usage example

  1. First you need to define resources section under coresponding package.json file of your package.
{
    "resources": {
        "files": [{
            "host": "https://github.com/cube-js/cube/releases/download/v${version}/",
            "path": "native-${platform}-${arch}-${libc}-${libpython_or_fallback}.tar.gz",
        }]
    }
}

Additional

Downloading plain files (no extraction)

By default the downloaded file is extracted into the package directory. Whether a file is an archive is detected automatically from its mime type (resolved from the url via mime-types): application/gzip, application/x-tar and application/zip (.tar.gz, .tgz, .tar, .zip) are extracted, anything else - a .jar, a .node, a bare binary - is downloaded as is.

For a file that is not extracted you must specify dst - a destination path relative to the package directory. Missing directories are created, escaping the package directory is not allowed.

{
    "resources": {
        "files": [{
            "host": "https://repo1.maven.org/maven2/",
            "path": "org/slf4j/slf4j-api/${slf4j_version}/slf4j-api-${slf4j_version}.jar",
            "dst": "lib/slf4j.jar"
        }]
    }
}

dst supports the same variables as host & path.

Detection can be overridden with extract:

{
    "host": "https://example.com/",
    "path": "bundle.tar.gz",
    "extract": false,
    "dst": "vendor/bundle.tar.gz"
}

For archives dst is ignored (they are always extracted into the package directory).

Constraints

Variables and files supports contstraints, you can define it:

  "constraints": {
    "platform": [
      "linux"
    ],
    "arch": [
      "x64"
    ]
  }

Supported types:

  • platform: win32 / darwin / linux / aix / android / freebsd / openbsd / cygwin
  • arch: x64 / arm64
  • platform-arch: linux-x64, etc.

Variables

You can define and use variables in path & host.

{
    "vars": {
      "libpython_or_fallback": {
        "default": "fallback",
        "value": [
          "libpython",
          [
            "3.11",
            "3.10",
            "3.9"
          ]
        ],
        "constraints": {
          "platform": [
            "linux"
          ],
          "arch": [
            "x64"
          ]
        }
      },
      "feature_or_default": {
        "default": "default",
        "value": [
          "env",
          "YOUR_ENV_NAME"
        ]
      }
    },
}

Next you can use this variable in the url via /file/${libpython_or_fallback}.tar.gz

LICENSE

Apache-2.0

版本与发布记录

@cubejs-infra/post-installer 共发布 10 个版本,首次发布于 2023/05/31;过去 12 个月发布了 3 个版本。

版本发布日期距今
0.2.0latest2026/09/211 个月前
0.1.22026/08/182 个月前
0.1.12025/11/2011 个月前
0.1.02024/07/082 年前
0.0.72023/05/313 年前
0.0.62023/05/313 年前

关于 @cubejs-infra/post-installer 的常见问题

@cubejs-infra/post-installer 是什么?

Resources installer

如何安装 @cubejs-infra/post-installer?

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

@cubejs-infra/post-installer 支持 TypeScript 吗?

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

@cubejs-infra/post-installer 支持 ESM 还是 CommonJS?

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

@cubejs-infra/post-installer 需要什么版本的 Node.js?

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

@cubejs-infra/post-installer 可以商用吗?

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

@cubejs-infra/post-installer 的下载量有多少?

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

@cubejs-infra/post-installer 还在维护吗?

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