# @grafana/plugin-meta-extractor 中文文档

规范地址：https://npmcn.com/package/%40grafana/plugin-meta-extractor/

版本：0\.13\.0
npm 元数据更新时间：2026-07-21T17:56:57.233Z
中文译文更新时间：2026-11-17T03:23:25.215Z
软件包许可：Apache-2\.0

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40grafana/plugin-meta-extractor
原文对照：https://npmcn.com/package/%40grafana/plugin-meta-extractor/?lang=original
项目主页：https://github.com/grafana/plugin-tools#readme
源码仓库：https://github.com/grafana/plugin-tools

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：61.3 kB，34 个文件
- 模块格式：CommonJS
- TypeScript 类型：包内自带
- 运行依赖：2 个
- 首次发布：2024-04-24T08:52:57.439Z
- 最新版本发布：2026-05-29T08:29:35.494Z
- 近 30 天下载量：7967（2026-10-17 至 2026-11-15，npm 官方下载统计）
- 已发布版本数：245（近 12 个月 43 个）

## 中文简介

从 Grafana 插件源代码中提取元信息 .

## 安装

```sh
npm install @grafana/plugin-meta-extractor
```

也可以使用：`pnpm add @grafana/plugin-meta-extractor`、`yarn add @grafana/plugin-meta-extractor`、`bun add @grafana/plugin-meta-extractor`

## README

# Grafana / 插件 Meta 提取器

> \[尖叫声\]  
> 这是一个实验项目,随时可能改变。 它尚未被我们的任何工具使用,并且无法可靠地与我们大多数的应用插件执行模式配合.

`@grafana/plugin-meta-extractor` 是一种cli工具,可用于从Grafana插件的源代码中提取元信息. 它用于生成不需要人工干预的插件元数据,然后被Grafana应用程序用于理解插件支持或使用的特性或功能.

## 安装

```
npm install @grafana/plugin-meta-extractor --save-dev
```

## 使用量

#### 用网络包装

该套件暴露出一个可以用来生成基于源代码的每个构建的插件元信息的webpack插件. 插件添加到额外的信息 `plugin.json` 通过覆盖 `generated` 财产在JSON.

```ts
// webpack.config.ts
// -----------------

import { GrafanaPluginMetaExtractor } from '@grafana/plugin-meta-extractor';

export default {
  // ...
  plugins: [
    new GrafanaPluginMetaExtractor(),
    // ...
  ],
};
```

#### 在代码中

软件包暴露出提取元数据的方法,以便可以手动使用:

```ts
import { extractPluginMeta } from '@grafana/plugin-meta-extractor';

const entryPoint = `${PLUGIN_ROOT}/src/module.ts`;
const pluginMeta = extractPluginMeta(entryPoint);
```

#### 国 际

通过将二进制调用到一个(module.ts|tsx)文件,包会将所提取的元数据打印出到控制台.

```bash
# Run local build
./dist/bin/run.js ~/my-grafana-plugin/src/module.ts

# Run latest remote version
npx @grafana/plugin-meta-extractor ~/my-grafana-plugin/src/module.ts
```

## 返回的数据格式

返回的元数据格式如下:

```ts
{
  extensions: Array<{
    type: "link" | "component",
    extensionPointId: string,
    title: string,
    description: string
  }>
}
```

## 插件支持

这个软件包需要 `module.(ts|tsx)` 以某种形式加以分析(我们计划今后改进)。 登记延期的方法必须在 `module.(ts|tsx)`,他们需要呼吁 `AppPlugin` 实例以“链式”方式:

```ts
// src/module.ts
export const plugin = new AppPlugin<{}>()
  .setRootPage(App)
  .configureExtensionLink<PluginExtensionPanelContext>({
    // ...
  })
  .configureExtensionLink<PluginExtensionPanelContext>({
    // ...
  });
```

* * *

## 捐款

我们总是感激捐款! 见 [捐款额](https://npmcn.com/package/CONTRIBUTING.md) 更多信息.

## 常见问题

### @grafana/plugin-meta-extractor 是什么？

从 Grafana 插件源代码中提取元信息 \.

### 如何安装 @grafana/plugin-meta-extractor？

在项目目录运行 npm install @grafana/plugin-meta-extractor，或使用 pnpm add / yarn add / bun add。它还提供命令行工具 plugin-meta-extractor，可以用 npx plugin-meta-extractor 直接运行。

### @grafana/plugin-meta-extractor 支持 TypeScript 吗？

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

### @grafana/plugin-meta-extractor 支持 ESM 还是 CommonJS？

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

### @grafana/plugin-meta-extractor 可以商用吗？

@grafana/plugin-meta-extractor 使用 Apache-2\.0 许可。宽松许可：允许商业使用、修改和再分发，并附带明确的专利授权；分发时需保留许可与 NOTICE 文件，修改过的文件要注明改动。以上为概括，不构成法律意见，请以许可原文为准。

### @grafana/plugin-meta-extractor 的下载量有多少？

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

### @grafana/plugin-meta-extractor 还在维护吗？

最新版本 0\.13\.0 发布于 2026/05/29（5 个月前）；至今共发布 245 个版本，其中过去 12 个月发布了 43 个；首次发布于 2024/04/24。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

