Grafana / 插件 Meta 提取器
[尖叫声]
这是一个实验项目,随时可能改变。 它尚未被我们的任何工具使用,并且无法可靠地与我们大多数的应用插件执行模式配合.
@grafana/plugin-meta-extractor 是一种cli工具,可用于从Grafana插件的源代码中提取元信息. 它用于生成不需要人工干预的插件元数据,然后被Grafana应用程序用于理解插件支持或使用的特性或功能.
安装
npm install @grafana/plugin-meta-extractor --save-dev
使用量
用网络包装
该套件暴露出一个可以用来生成基于源代码的每个构建的插件元信息的webpack插件. 插件添加到额外的信息 plugin.json 通过覆盖 generated 财产在JSON.
// webpack.config.ts
// -----------------
import { GrafanaPluginMetaExtractor } from '@grafana/plugin-meta-extractor';
export default {
// ...
plugins: [
new GrafanaPluginMetaExtractor(),
// ...
],
};
在代码中
软件包暴露出提取元数据的方法,以便可以手动使用:
import { extractPluginMeta } from '@grafana/plugin-meta-extractor';
const entryPoint = `${PLUGIN_ROOT}/src/module.ts`;
const pluginMeta = extractPluginMeta(entryPoint);
国 际
通过将二进制调用到一个(module.ts|tsx)文件,包会将所提取的元数据打印出到控制台.
# 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
返回的数据格式
返回的元数据格式如下:
{
extensions: Array<{
type: "link" | "component",
extensionPointId: string,
title: string,
description: string
}>
}
插件支持
这个软件包需要 module.(ts|tsx) 以某种形式加以分析(我们计划今后改进)。 登记延期的方法必须在 module.(ts|tsx),他们需要呼吁 AppPlugin 实例以“链式”方式:
// src/module.ts
export const plugin = new AppPlugin<{}>()
.setRootPage(App)
.configureExtensionLink<PluginExtensionPanelContext>({
// ...
})
.configureExtensionLink<PluginExtensionPanelContext>({
// ...
});
捐款
我们总是感激捐款! 见 捐款额 更多信息.