@codecov/astro-plugin

中文文档
2.0.1发布于 2026/04/15MITTypeScriptESM + CJS近 30 天下载 7722

正式的 Codecov Astro 插件

中文使用文档
文档目录6 节
  1. 安装
  2. 公共 Repo 示例 - GitHub 动作
  3. 公共 Repo 示例 - 非 GitHub 动作
  4. 私人 Repo 示例
  5. OIDC 配置示例
  6. 更多信息

Codecov by Sentry logo

代码Astro插件

一个为Codecov提供捆绑分析支持的Astro集成.

[注] 插件不支持代码覆盖, 请见 our 文档 今天就开始报道!

安装

使用 npm :

npx astro add @codecov/astro-plugin

使用线条 :

yarn astro add @codecov/astro-plugin

使用 pnpm :

pnpm astro add @codecov/astro-plugin

公共 Repo 示例 - GitHub 动作

此配置将自动将捆绑分析上传到 Codecov 用于公共寄存器. 当内部的 PR 创建时, 它会使用在您的秘密中设置的 Codecov 令牌, 如果运行从一个被预留的 PR 中, 它会自动使用无令牌设置 。 对于不使用 GitHub 动作的设置,请参见以下 实例。关于私人储存库,请参见: 实例。 。 。 .

// astro.config.mjs
import { defineConfig } from "astro/config";
import { codecovAstroPlugin } from "@codecov/astro-plugin";

// https://astro.build/config
export default defineConfig({
  // other config settings
  integrations: [
    // place this after all other integrations
    codecovAstroPlugin({
      enableBundleAnalysis: true,
      bundleName: "example-astro-bundle",
      uploadToken: process.env.CODECOV_TOKEN,
      gitService: "github",
    }),
  ],
});

公共 Repo 示例 - 非 GitHub 动作

此设置适用于没有使用 GitHub 动作的公有寄存器, 此配置将自动上传捆绑分析到 Codecov 。 您需要配置类似于 GitHub 动作示例的功能, 然而您需要提供分支覆盖, 并确保它能通过正确的分支名称, 并使用包括分叉所有者在内的分叉 . fork-owner:branch。 。 。 .

// astro.config.mjs
import { defineConfig } from "astro/config";
import { codecovAstroPlugin } from "@codecov/astro-plugin";

// https://astro.build/config
export default defineConfig({
  // other config settings
  integrations: [
    // place this after all other integrations
    codecovAstroPlugin({
      enableBundleAnalysis: true,
      bundleName: "example-astro-bundle",
      uploadToken: process.env.CODECOV_TOKEN,
      gitService: "github",
      uploadOverrides: {
        branch: "<branch value>",
      },
    }),
  ],
});

私人 Repo 示例

这是私人寄存器使用插件的必要方式 。 此配置将自动上传捆绑分析到 Codecov.

此配置将自动将捆绑分析上传到 Codecov 用于公共寄存器. 当内部的 PR 创建时, 它会使用在您的秘密中设置的 Codecov 令牌, 如果运行从一个被预留的 PR 中, 它会自动使用无令牌设置 。 对于不使用 GitHub 动作的设置,请参见以下 实例。关于私人储存库,请参见: 实例。 。 。 .

// astro.config.mjs
import { defineConfig } from "astro/config";
import { codecovAstroPlugin } from "@codecov/astro-plugin";

// https://astro.build/config
export default defineConfig({
  // other config settings
  integrations: [
    // place this after all other integrations
    codecovAstroPlugin({
      enableBundleAnalysis: true,
      bundleName: "example-astro-bundle",
      uploadToken: process.env.CODECOV_TOKEN,
    }),
  ],
});

OIDC 配置示例

用户 启用 OpenID 连接( OIDC),设置 uploadToken 没有必要。 您可以使用 OIDC 与 oidc 配置如下.

// astro.config.mjs
import { defineConfig } from "astro/config";
import { codecovAstroPlugin } from "@codecov/astro-plugin";

// https://astro.build/config
export default defineConfig({
  // other config settings
  integrations: [
    // place this after all other integrations
    codecovAstroPlugin({
      enableBundleAnalysis: true,
      bundleName: "example-astro-bundle",
      oidc: {
        useGitHubOIDC: true,
      },
    }),
  ],
});

更多信息

版本与发布记录

@codecov/astro-plugin 共发布 7 个版本,首次发布于 2024/12/10;过去 12 个月发布了 2 个版本。

版本发布日期距今
2.0.1latest2026/04/156 个月前
2.0.02026/04/156 个月前
1.9.12025/05/201.5 年前
1.9.02025/02/111.7 年前
1.8.02025/01/201.8 年前
1.7.02024/12/311.9 年前

关于 @codecov/astro-plugin 的常见问题

@codecov/astro-plugin 是什么?

正式的 Codecov Astro 插件

如何安装 @codecov/astro-plugin?

在项目目录运行 npm install @codecov/astro-plugin,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:astro(4.x || 5.x)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@codecov/astro-plugin 支持 TypeScript 吗?

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

@codecov/astro-plugin 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@codecov/astro-plugin 需要什么版本的 Node.js?

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

@codecov/astro-plugin 可以商用吗?

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

@codecov/astro-plugin 的下载量有多少?

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

@codecov/astro-plugin 还在维护吗?

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