Skip to content

Latest commit

 

History

History
109 lines (73 loc) · 4.31 KB

File metadata and controls

109 lines (73 loc) · 4.31 KB
id cli-commands
title CLI commands to create plugins
description Commands available in the create-plugin tool.
keywords
grafana
plugins
plugin
create-plugin
prompts
commands
sidebar_position 40

import ScaffoldNPM from '@shared/createplugin-scaffold.md'; import UpdateNPM from '@shared/createplugin-update.md'; import UpdateForceNPM from '@shared/createplugin-update-force.md';

CLI commands

Below you can find the available commands in @grafana/create-plugin.

create-plugin

Use the create-plugin command to scaffold your plugin.

When running the create-plugin command, the following prompts appear:

Select a plugin type

? Select a plugin type …
❯ App (add custom pages, UI extensions and bundle other plugins)
  Data source (query data from a custom source)
  Panel (add a visualization for data or a widget)
  App with Scenes (create dynamic dashboards in app pages)

To learn more about the various types of plugins, refer to Grafana plugin types and usage.

For more information on how Scenes allows you to create dashboard-like experiences in app plugins, see the Scenes documentation.

Add a backend to support server-side functionality? (y/N)

If you are creating an app or a data source plugin, you will be asked whether to additionally add a backend component.

Plugin backend components offer powerful features such as:

  • Enable Grafana Alerting for data sources.
  • Connect to non-HTTP services to which a browser normally can’t connect. For example, SQL database servers.
  • Keep state between users. For example, query caching for data sources.
  • Use custom authentication methods and/or authorization checks that aren’t supported in Grafana.
  • Use a custom data source request proxy.

To learn more, refer to plugin backend components.

Enter a name for your plugin

Give your plugin a name which helps identify its purpose.

Enter your organization name (usually your Grafana Cloud org)

Enter the name of your organization. This must be your Grafana Cloud organization. With the organization name you can sign and optionally publish the plugin to the Grafana plugin catalog.

Bypass prompts

You can bypass all the preceding prompts by using create-plugin CLI arguments. To scaffold a plugin with the CLI arguments, pass them to the create-plugin command like so:

npx @grafana/create-plugin \
  --plugin-type="app" \
  --plugin-name="myPlugin" \
  --org-name="myorg" \
  --backend

You can scaffold plugins using CLI arguments to get started faster. Using arguments also allows you to run the tool in a non-interactive environment such as CI or to scaffold plugins with other tooling.

Refer to the following table for the full list of prompt bypass options:

Prompt Equivalent Argument Name Values
Plugin type --plugin-type one of app, datasource, panel or scenesapp
Backend --backend / --no-backend boolean
Name --plugin-name string
Organization --org-name string

update

To update an existing plugin to use the latest version of the create-plugin tool, run the following command from your plugin's root directory:

This command updates the following:

  • /.config - configuration files for building a plugin
  • NPM dependencies - dependencies (mostly used for supporting latest Grafana versions and build updates)
  • NPM scripts - any updates in build-related scripts

update --force

By default, the update command will stop if there are any uncommitted changes in the repository. If you want to force the update, you can use the --force flag: