Skip to content

Commit

Permalink
merge work with fe and be topics into get started and sdk pages
Browse files Browse the repository at this point in the history
  • Loading branch information
sympatheticmoose committed Jul 12, 2024
1 parent 9c39436 commit a3b89f2
Show file tree
Hide file tree
Showing 13 changed files with 118 additions and 119 deletions.
2 changes: 1 addition & 1 deletion docusaurus/docs/get-started/folder-structure.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ keywords:
sidebar_position: 60
---

After you [install](./get-started.mdx#step-1-install-the-create-plugin-tool) the `create-plugin` tool and have answered the prompts, your project should look similar to this:
After you [Run](./get-started.mdx#run-the-create-plugin-tool) the `create-plugin` tool and have answered the prompts, your project should look similar to this:

```
myorg-myplugin-datasource/
Expand Down
122 changes: 86 additions & 36 deletions docusaurus/docs/get-started/get-started.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ import ScaffoldYarn from '@snippets/createplugin-scaffold.yarn.md';
import InstallNPM from '@snippets/createplugin-install.npm.md';
import InstallPNPM from '@snippets/createplugin-install.pnpm.md';
import InstallYarn from '@snippets/createplugin-install.yarn.md';
import BuildFEDevNPM from '@snippets/createplugin-build-fe-dev.npm.md';
import BuildFEDevPNPM from '@snippets/createplugin-build-fe-dev.pnpm.md';
import BuildFEDevYarn from '@snippets/createplugin-build-fe-dev.yarn.md';
import BuildFEProdNPM from '@snippets/createplugin-build-fe-prod.npm.md';
import BuildFEProdPNPM from '@snippets/createplugin-build-fe-prod.pnpm.md';
import BuildFEProdYarn from '@snippets/createplugin-build-fe-prod.yarn.md';

# Get started

Expand Down Expand Up @@ -97,7 +103,7 @@ When you first run `@grafana/create-plugin`, choose your package manager: `npm`,

## Scaffold a plugin

### Step 1: Install the `create-plugin` tool
### Run the `create-plugin` tool

Run the following command and answer the prompts:

Expand All @@ -113,19 +119,9 @@ Run the following command and answer the prompts:

For help with the prompts, refer to the [Prompts reference](../reference/prompts.md).

### Step 2: Open the generated folder structure
### Open the generated folder structure

When you've finished installing the tools, open the plugin folder:

<CodeSnippets
snippets={[
{ component: InstallNPM, label: 'npm' },
{ component: InstallPNPM, label: 'pnpm' },
{ component: InstallYarn, label: 'yarn' },
]}
groupId="package-manager"
queryString="current-package-manager"
/>
Open the plugin folder to browse the generated plugin:

The directory name `<orgName>-<pluginName>-<pluginType>` is based on the answers you gave to the prompts. Use the name of the generated folder when prompted. This directory contains the initial project structure to kickstart your plugin development.

Expand Down Expand Up @@ -169,53 +165,107 @@ The file structure should look like this:

For more information about these files, refer to [Folder structure](get-started/folder-structure/).

### Step 3: Run your plugin in Docker
## Build and run your plugin in Docker

With the `create-plugin` tool, you can use a Docker container to simplify the configuration, loading, and development processes. For more information, refer to [Set up development environment](get-started/set-up-development-environment/).

Key CLI commands include:
- Install (`npm i`)
- Build the frontend in development mode (`npm run dev`)
- Build the backend (optional) (`mage -v build:linux`)
- Run the Grafana server (`npm run server`)
Refer to the "Next steps" terminal output following the [scaffolding of a new plugin](#scaffold-a-plugin) to install dependecies, build and run your plugin.

## Frequently used CLI commands

Use the CLI for essential tasks of plugin development, substituting `npm` for `pnpm`, or `yarn` based on your choice of package manager.
Example output:
```
## What's next?
### `mage -v`
Run the following commands to get started:
Builds backend plugin binaries for Linux, Windows and Darwin.
* cd ./orgName-pluginName-app
* npm install to install frontend dependencies.
* npm exec playwright install chromium to install e2e test dependencies.
* npm run dev to build (and watch) the plugin frontend code.
* mage -v build:backend to build the plugin backend code. Rerun this command every time you edit your backend files.
* docker-compose up to start a grafana development server.
* Open http://localhost:3000 in your browser to create a dashboard to begin developing your plugin.
### `npm run build`
Note: We strongly recommend creating a new Git repository by running git init in ./org-pluginname-app before continuing.
Compiles and bundles the project using Webpack in production mode.
* Learn more about Grafana Plugin Development at https://grafana.com/developers/plugin-tools
### `npm run dev`
```

Runs Webpack in watch mode for development, continually monitoring for changes.
### Install dependencies

### `npm run typecheck`
<CodeSnippets
snippets={[
{ component: InstallNPM, label: 'npm' },
{ component: InstallPNPM, label: 'pnpm' },
{ component: InstallYarn, label: 'yarn' },
]}
groupId="package-manager"
queryString="current-package-manager"
/>

Performs a type-checking process on the frontend code using TypeScript.
### Build the frontend

### `npm run server`
To build the plugin in watch mode for development, continually monitoring for changes, run:
<CodeSnippets
snippets={[
{ component: BuildFEDevNPM, label: 'npm' },
{ component: BuildFEDevPNPM, label: 'pnpm' },
{ component: BuildFEDevYarn, label: 'yarn' },
]}
groupId="package-manager"
queryString="current-package-manager"
/>

Launches the [Grafana development server](https://grafana.com/developers/plugin-tools/get-started/set-up-development-environment) using Docker.

### `npm run sign`
To build for production, run:

Signs the Grafana plugin using the latest version of `@grafana/sign-plugin`.
<CodeSnippets
snippets={[
{ component: BuildFEProdNPM, label: 'npm' },
{ component: BuildFEProdPNPM, label: 'pnpm' },
{ component: BuildFEProdYarn, label: 'yarn' },
]}
groupId="package-manager"
queryString="current-package-manager"
/>

:::info
### Build the backend

For a complete list of available CLI commands, refer to the [CLI reference](/reference/cli-commands.md).
If your plugin includes a [backend](../key-concepts/backend-plugins/index.md) component, you can build using mage:

:::
```shell
mage -v build:linux
```

#### Build targets

| Option | Description | Example |
| -------------- | -------------------------------------------- | --------------------- |
| `build:[arch]` | Builds a binary for a specific architecture. | `mage -v build:Linux` |

List all available Mage targets for additional commands:

```bash
mage -l
```

### Run the Grafana server

To launch the Grafana development server using Docker, run:

```shell
docker-compose up --build
```

Congratulations! You've just scaffolded your first plugin which you can now access at [http://localhost:3000](http://localhost:3000).

## Next steps

- Start your plugin journey with one of our [plugin development tutorials](/tutorials/).
- 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).
40 changes: 0 additions & 40 deletions docusaurus/docs/get-started/work-with-backend.md

This file was deleted.

38 changes: 0 additions & 38 deletions docusaurus/docs/get-started/work-with-frontend.mdx

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ Use a contextual logger to automatically include additional key-value pairs atta

:::note

Make sure you are using at least [grafana-plugin-sdk-go v0.186.0](https://github.com/grafana/grafana-plugin-sdk-go/releases/tag/v0.186.0). Refer to [Update the Go SDK](../../get-started/work-with-backend#update-the-go-sdk) for update instructions.
Make sure you are using at least [grafana-plugin-sdk-go v0.186.0](https://github.com/grafana/grafana-plugin-sdk-go/releases/tag/v0.186.0). Refer to [Update the Go SDK](../../key-concepts/backend-plugins/grafana-plugin-sdk-for-go.md#update-the-go-sdk) for update instructions.

:::

Expand Down Expand Up @@ -394,7 +394,7 @@ If tracing is disabled in Grafana, `backend.DefaultTracer()` returns a no-op tra

:::note

Make sure you are using at least [`grafana-plugin-sdk-go v0.157.0`](https://github.com/grafana/grafana-plugin-sdk-go/releases/tag/v0.157.0). Refer to [Update the Go SDK](../../get-started/work-with-backend) for update instructions.
Make sure you are using at least [`grafana-plugin-sdk-go v0.157.0`](https://github.com/grafana/grafana-plugin-sdk-go/releases/tag/v0.157.0). Refer to [Update the Go SDK](../../key-concepts/backend-plugins/grafana-plugin-sdk-for-go.md#update-the-go-sdk) for update instructions.

:::

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@ The Grafana plugin Go SDK is still in development. It is based on the [plugin pr

When we update the plugin SDK, those plugins that use an older version of the SDK should still work with Grafana. However, these older plugins may be unable to use the new features and capabilities we introduce in updated SDK versions.

## Update the Go SDK

To keep the Grafana plugin SDK for Go up to date:

```bash
go get -u github.com/grafana/grafana-plugin-sdk-go
go mod tidy
```

## See also

- [SDK source code](https://github.com/grafana/grafana-plugin-sdk-go)
Expand Down
3 changes: 3 additions & 0 deletions docusaurus/docs/snippets/createplugin-build-fe-dev.npm.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```shell
npm run dev
```
3 changes: 3 additions & 0 deletions docusaurus/docs/snippets/createplugin-build-fe-dev.pnpm.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```shell
pnpm run dev
```
3 changes: 3 additions & 0 deletions docusaurus/docs/snippets/createplugin-build-fe-dev.yarn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```shell
yarn run dev
```
3 changes: 3 additions & 0 deletions docusaurus/docs/snippets/createplugin-build-fe-prod.npm.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```shell
npm run prod
```
3 changes: 3 additions & 0 deletions docusaurus/docs/snippets/createplugin-build-fe-prod.pnpm.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```shell
pnpm run build
```
3 changes: 3 additions & 0 deletions docusaurus/docs/snippets/createplugin-build-fe-prod.yarn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```shell
yarn run build
```
4 changes: 2 additions & 2 deletions docusaurus/website/docusaurus.config.base.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,11 @@ const plugins = [
},
{
from: ['/create-a-plugin/develop-a-plugin/work-with-frontend'],
to: '/get-started/work-with-frontend',
to: '/reference/cli-commands/',
},
{
from: ['/create-a-plugin/develop-a-plugin/work-with-backend'],
to: '/get-started/work-with-backend',
to: '/reference/cli-commands/',
},
{
from: ['/create-a-plugin/develop-a-plugin/set-up-github-workflows'],
Expand Down

0 comments on commit a3b89f2

Please sign in to comment.