Skip to content

Commit

Permalink
Docs: Update the "Prompts" page (#1042)
Browse files Browse the repository at this point in the history
Co-authored-by: Jack Westbrook <jack.westbrook@gmail.com>
Co-authored-by: Joe Perez <joseph.perez@grafana.com>
  • Loading branch information
3 people authored Aug 28, 2024
1 parent e54ad1a commit 8b23d1b
Show file tree
Hide file tree
Showing 10 changed files with 158 additions and 166 deletions.
5 changes: 1 addition & 4 deletions docusaurus/docs/get-started/get-started.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ Run the following command and answer the prompts:
queryString="current-package-manager"
/>

For help with the prompts, refer to the [Prompts reference](../reference/prompts.md).
For help with the prompts, refer to the [CLI commands](../reference/cli-commands.mdx).

### Open the generated folder structure

Expand Down Expand Up @@ -266,6 +266,3 @@ Congratulations! You've just scaffolded your first plugin which you can now acce
- Learn how to [extend](/how-to-guides) its functionality.
- Review the [plugin examples](https://github.com/grafana/grafana-plugin-examples) to learn about good practices.
- Learn how to [package](/publish-a-plugin/package-a-plugin), [sign](/publish-a-plugin/sign-a-plugin), and [publish](/publish-a-plugin/publish-or-update-a-plugin.md) your plugin to the Grafana [plugin catalog](https://grafana.com/plugins).

## See also
For a complete list of available CLI commands, refer to the [CLI reference](/reference/cli-commands.md).
2 changes: 1 addition & 1 deletion docusaurus/docs/key-concepts/plugin-types-usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Grafana plugin development allows for many options depending on the type of user
- **Data-source plugin** - a connection to a new database or other source of data.
- **App plugin** - an integrated out-of-the-box experience.

Refer to [Get started](../get-started/get-started.mdx) for instructions on how to quickly scaffold [each type](../reference/prompts.md#select-a-plugin-type) of plugin.
Refer to [Get started](../get-started/get-started.mdx) for instructions on how to quickly scaffold [each type](../reference/cli-commands.mdx#select-a-plugin-type) of plugin.

:::note

Expand Down
30 changes: 0 additions & 30 deletions docusaurus/docs/migration-guides/update-create-plugin-versions.mdx

This file was deleted.

61 changes: 0 additions & 61 deletions docusaurus/docs/reference/cli-commands.md

This file was deleted.

139 changes: 139 additions & 0 deletions docusaurus/docs/reference/cli-commands.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
---
id: cli-commands
title: CLI commands
description: Reference for commands available in the create-plugin tool.
keywords:
- grafana
- plugins
- plugin
- create-plugin
- prompts
- commands
sidebar_position: 40
---

import ScaffoldNPM from '@snippets/createplugin-scaffold.npm.md';
import ScaffoldPNPM from '@snippets/createplugin-scaffold.pnpm.md';
import ScaffoldYarn from '@snippets/createplugin-scaffold.yarn.md';
import UpdateNPM from '@snippets/createplugin-update.npm.md';
import UpdatePNPM from '@snippets/createplugin-update.pnpm.md';
import UpdateYarn from '@snippets/createplugin-update.yarn.md';
import UpdateForceNPM from '@snippets/createplugin-update-force.npm.md';
import UpdateForcePNPM from '@snippets/createplugin-update-force.pnpm.md';
import UpdateForceYarn from '@snippets/createplugin-update-force.yarn.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.

<CodeSnippets
snippets={[
{ component: ScaffoldNPM, label: 'npm' },
{ component: ScaffoldPNPM, label: 'pnpm' },
{ component: ScaffoldYarn, label: 'yarn' },
]}
groupId="package-manager"
queryString="current-package-manager"
/>


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](../key-concepts/plugin-types-usage.md).

For more information on how Scenes allows you to create dashboard-like experiences in app plugins, see the [Scenes](https://grafana.com/developers/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.

Backend plugins offer powerful features such as:

- Enable [Grafana Alerting](https://grafana.com/docs/grafana/latest/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 [Backend plugins](../key-concepts/backend-plugins/index.md).

### 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](https://grafana.com/signup/) organization. With the organization name you can [sign](../publish-a-plugin/sign-a-plugin.md) and optionally [publish](../publish-a-plugin/publish-or-update-a-plugin.md) the plugin to the [Grafana plugin catalog](https://grafana.com/grafana/plugins).

### 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:

<CodeSnippets
snippets={[
{ component: UpdateNPM, label: 'npm' },
{ component: UpdatePNPM, label: 'pnpm' },
{ component: UpdateYarn, label: 'yarn' },
]}
groupId="package-manager"
queryString="current-package-manager"
/>

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:

<CodeSnippets
snippets={[
{ component: UpdateForceNPM, label: 'npm' },
{ component: UpdateForcePNPM, label: 'pnpm' },
{ component: UpdateForceYarn, label: 'yarn' },
]}
groupId="package-manager"
queryString="current-package-manager"
/>

70 changes: 0 additions & 70 deletions docusaurus/docs/reference/prompts.md

This file was deleted.

3 changes: 3 additions & 0 deletions docusaurus/docs/snippets/createplugin-update-force.npm.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```shell
npx @grafana/create-plugin@latest update --force
```
3 changes: 3 additions & 0 deletions docusaurus/docs/snippets/createplugin-update-force.pnpm.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```shell
pnpm dlx @grafana/create-plugin@latest update --force
```
3 changes: 3 additions & 0 deletions docusaurus/docs/snippets/createplugin-update-force.yarn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```shell
yarn create @grafana/plugin update --force
```
8 changes: 8 additions & 0 deletions docusaurus/website/docusaurus.config.base.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,14 @@ const plugins = [
from: ['/create-a-plugin/extend-a-plugin/extend-configurations'],
to: '/get-started/set-up-development-environment#extend-configurations',
},
{
from: ['/migration-guides/update-create-plugin-versions'],
to: '/reference/cli-commands/#update-plugin-tooling',
},
{
from: ['/reference/prompts'],
to: '/reference/cli-commands/',
},
],
},
],
Expand Down

0 comments on commit 8b23d1b

Please sign in to comment.