-
Notifications
You must be signed in to change notification settings - Fork 0
Update create plugin #10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
zoltanbedi
wants to merge
8
commits into
main
Choose a base branch
from
zoltan-chore
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
2b533b8
Update package dependencies, CI workflows, and project configuration
zoltanbedi f9a8062
Update packages
zoltanbedi 73be0b3
Update Docker Compose configuration for Grafana plugin
zoltanbedi 4a75c57
Add signature type
zoltanbedi d01563b
Some more changes
zoltanbedi a5a8df3
Fix e2e and some references
zoltanbedi 0d09cee
Add CODEOWNERS file to define repository ownership
zoltanbedi a8067f4
Run plugin validator in ci cd
zoltanbedi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| { | ||
| "version": "6.4.3" | ||
| } |
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| ARG grafana_version=latest | ||
| ARG grafana_image=grafana-enterprise | ||
|
|
||
| FROM grafana/${grafana_image}:${grafana_version} | ||
|
|
||
| ARG anonymous_auth_enabled=true | ||
| ARG development=false | ||
| ARG TARGETARCH | ||
|
|
||
|
|
||
| ENV DEV "${development}" | ||
|
|
||
| # Make it as simple as possible to access the grafana instance for development purposes | ||
| # Do NOT enable these settings in a public facing / production grafana instance | ||
| ENV GF_AUTH_ANONYMOUS_ORG_ROLE "Admin" | ||
| ENV GF_AUTH_ANONYMOUS_ENABLED "${anonymous_auth_enabled}" | ||
| ENV GF_AUTH_BASIC_ENABLED "false" | ||
| # Set development mode so plugins can be loaded without the need to sign | ||
| ENV GF_DEFAULT_APP_MODE "development" | ||
|
|
||
|
|
||
| LABEL maintainer="Grafana Labs <[email protected]>" | ||
|
|
||
| ENV GF_PATHS_HOME="/usr/share/grafana" | ||
| WORKDIR $GF_PATHS_HOME | ||
|
|
||
| USER root | ||
|
|
||
| # Installing supervisor and inotify-tools | ||
| RUN if [ "${development}" = "true" ]; then \ | ||
| if grep -i -q alpine /etc/issue; then \ | ||
| apk add supervisor inotify-tools git; \ | ||
| elif grep -i -q ubuntu /etc/issue; then \ | ||
| DEBIAN_FRONTEND=noninteractive && \ | ||
| apt-get update && \ | ||
| apt-get install -y supervisor inotify-tools git && \ | ||
| rm -rf /var/lib/apt/lists/*; \ | ||
| else \ | ||
| echo 'ERROR: Unsupported base image' && /bin/false; \ | ||
| fi \ | ||
| fi | ||
|
|
||
| COPY supervisord/supervisord.conf /etc/supervisor.d/supervisord.ini | ||
| COPY supervisord/supervisord.conf /etc/supervisor/conf.d/supervisord.conf | ||
|
|
||
|
|
||
|
|
||
| # Inject livereload script into grafana index.html | ||
| RUN sed -i 's|</body>|<script src="http://localhost:35729/livereload.js"></script></body>|g' /usr/share/grafana/public/views/index.html | ||
|
|
||
|
|
||
| COPY entrypoint.sh /entrypoint.sh | ||
| RUN chmod +x /entrypoint.sh | ||
| ENTRYPOINT ["/entrypoint.sh"] | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,176 @@ | ||
| # Default build configuration by Grafana | ||
|
|
||
| **This is an auto-generated directory and is not intended to be changed! ⚠️** | ||
|
|
||
| The `.config/` directory holds basic configuration for the different tools | ||
| that are used to develop, test and build the project. In order to make it updates easier we ask you to | ||
| not edit files in this folder to extend configuration. | ||
|
|
||
| ## How to extend the basic configs? | ||
|
|
||
| Bear in mind that you are doing it at your own risk, and that extending any of the basic configuration can lead | ||
| to issues around working with the project. | ||
|
|
||
| ### Extending the ESLint config | ||
|
|
||
| Edit the `eslint.config.mjs` file in the project root to extend the ESLint configuration. The following example disables deprecation notices for source files. | ||
|
|
||
| **Example:** | ||
|
|
||
| ```javascript | ||
| import { defineConfig } from 'eslint/config'; | ||
| import baseConfig from './.config/eslint.config.mjs'; | ||
|
|
||
| export default defineConfig([ | ||
| { | ||
| ignores: [ | ||
| //... | ||
| ], | ||
| }, | ||
| ...baseConfig, | ||
| { | ||
| files: ['src/**/*.{ts,tsx}'], | ||
| rules: { | ||
| '@typescript-eslint/no-deprecated': 'off', | ||
| }, | ||
| }, | ||
| ]); | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ### Extending the Prettier config | ||
|
|
||
| Edit the `.prettierrc.js` file in the project root in order to extend the Prettier configuration. | ||
|
|
||
| **Example:** | ||
|
|
||
| ```javascript | ||
| module.exports = { | ||
| // Prettier configuration provided by Grafana scaffolding | ||
| ...require('./.config/.prettierrc.js'), | ||
|
|
||
| semi: false, | ||
| }; | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ### Extending the Jest config | ||
|
|
||
| There are two configuration in the project root that belong to Jest: `jest-setup.js` and `jest.config.js`. | ||
|
|
||
| **`jest-setup.js`:** A file that is run before each test file in the suite is executed. We are using it to | ||
| set up the Jest DOM for the testing library and to apply some polyfills. ([link to Jest docs](https://jestjs.io/docs/configuration#setupfilesafterenv-array)) | ||
|
|
||
| **`jest.config.js`:** The main Jest configuration file that extends the Grafana recommended setup. ([link to Jest docs](https://jestjs.io/docs/configuration)) | ||
|
|
||
| #### ESM errors with Jest | ||
|
|
||
| A common issue with the current jest config involves importing an npm package that only offers an ESM build. These packages cause jest to error with `SyntaxError: Cannot use import statement outside a module`. To work around this, we provide a list of known packages to pass to the `[transformIgnorePatterns](https://jestjs.io/docs/configuration#transformignorepatterns-arraystring)` jest configuration property. If need be, this can be extended in the following way: | ||
|
|
||
| ```javascript | ||
| process.env.TZ = 'UTC'; | ||
| const { grafanaESModules, nodeModulesToTransform } = require('./config/jest/utils'); | ||
|
|
||
| module.exports = { | ||
| // Jest configuration provided by Grafana | ||
| ...require('./.config/jest.config'), | ||
| // Inform jest to only transform specific node_module packages. | ||
| transformIgnorePatterns: [nodeModulesToTransform([...grafanaESModules, 'packageName'])], | ||
| }; | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ### Extending the TypeScript config | ||
|
|
||
| Edit the `tsconfig.json` file in the project root in order to extend the TypeScript configuration. | ||
|
|
||
| **Example:** | ||
|
|
||
| ```json | ||
| { | ||
| "extends": "./.config/tsconfig.json", | ||
| "compilerOptions": { | ||
| "preserveConstEnums": true | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ### Extending the Webpack config | ||
|
|
||
| Follow these steps to extend the basic Webpack configuration that lives under `.config/`: | ||
|
|
||
| #### 1. Create a new Webpack configuration file | ||
|
|
||
| Create a new config file that is going to extend the basic one provided by Grafana. | ||
| It can live in the project root, e.g. `webpack.config.ts`. | ||
|
|
||
| #### 2. Merge the basic config provided by Grafana and your custom setup | ||
|
|
||
| We are going to use [`webpack-merge`](https://github.com/survivejs/webpack-merge) for this. | ||
|
|
||
| ```typescript | ||
| // webpack.config.ts | ||
| import type { Configuration } from 'webpack'; | ||
| import { merge } from 'webpack-merge'; | ||
| import grafanaConfig, { type Env } from './.config/webpack/webpack.config'; | ||
|
|
||
| const config = async (env: Env): Promise<Configuration> => { | ||
| const baseConfig = await grafanaConfig(env); | ||
|
|
||
| return merge(baseConfig, { | ||
| // Add custom config here... | ||
| output: { | ||
| asyncChunks: true, | ||
| }, | ||
| }); | ||
| }; | ||
|
|
||
| export default config; | ||
| ``` | ||
|
|
||
| #### 3. Update the `package.json` to use the new Webpack config | ||
|
|
||
| We need to update the `scripts` in the `package.json` to use the extended Webpack configuration. | ||
|
|
||
| **Update for `build`:** | ||
|
|
||
| ```diff | ||
| -"build": "webpack -c ./.config/webpack/webpack.config.ts --env production", | ||
| +"build": "webpack -c ./webpack.config.ts --env production", | ||
| ``` | ||
|
|
||
| **Update for `dev`:** | ||
|
|
||
| ```diff | ||
| -"dev": "webpack -w -c ./.config/webpack/webpack.config.ts --env development", | ||
| +"dev": "webpack -w -c ./webpack.config.ts --env development", | ||
| ``` | ||
|
|
||
| ### Configure grafana image to use when running docker | ||
|
|
||
| By default, `grafana-enterprise` will be used as the docker image for all docker related commands. If you want to override this behavior, simply alter the `docker-compose.yaml` by adding the following build arg `grafana_image`. | ||
|
|
||
| **Example:** | ||
|
|
||
| ```yaml | ||
| version: '3.7' | ||
|
|
||
| services: | ||
| grafana: | ||
| extends: | ||
| file: .config/docker-compose-base.yaml | ||
| service: grafana | ||
| build: | ||
| args: | ||
| grafana_version: ${GRAFANA_VERSION:-9.1.2} | ||
| grafana_image: ${GRAFANA_IMAGE:-grafana} | ||
| ``` | ||
|
|
||
| In this example, we assign the environment variable `GRAFANA_IMAGE` to the build arg `grafana_image` with a default value of `grafana`. This will allow you to set the value while running the docker compose commands, which might be convenient in some scenarios. | ||
|
|
||
| --- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| import type { Configuration, ExternalItemFunctionData } from 'webpack'; | ||
|
|
||
| type ExternalsType = Configuration['externals']; | ||
|
|
||
| export const externals: ExternalsType = [ | ||
| // Required for dynamic publicPath resolution | ||
| { 'amd-module': 'module' }, | ||
| 'lodash', | ||
| 'jquery', | ||
| 'moment', | ||
| 'slate', | ||
| 'emotion', | ||
| '@emotion/react', | ||
| '@emotion/css', | ||
| 'prismjs', | ||
| 'slate-plain-serializer', | ||
| '@grafana/slate-react', | ||
| 'react', | ||
| 'react-dom', | ||
| 'react-redux', | ||
| 'redux', | ||
| 'rxjs', | ||
| 'i18next', | ||
| 'react-router', | ||
| 'd3', | ||
| 'angular', | ||
| /^@grafana\/ui/i, | ||
| /^@grafana\/runtime/i, | ||
| /^@grafana\/data/i, | ||
|
|
||
| // Mark legacy SDK imports as external if their name starts with the "grafana/" prefix | ||
| ({ request }: ExternalItemFunctionData, callback: (error?: Error, result?: string) => void) => { | ||
| const prefix = 'grafana/'; | ||
| const hasPrefix = (request: string) => request.indexOf(prefix) === 0; | ||
| const stripPrefix = (request: string) => request.slice(prefix.length); | ||
|
|
||
| if (request && hasPrefix(request)) { | ||
| return callback(undefined, stripPrefix(request)); | ||
| } | ||
|
|
||
| callback(); | ||
| }, | ||
| ]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| services: | ||
| grafana: | ||
| user: root | ||
| container_name: 'grafana-business-input' | ||
|
|
||
| build: | ||
| context: . | ||
| args: | ||
| grafana_image: ${GRAFANA_IMAGE:-grafana-enterprise} | ||
| grafana_version: ${GRAFANA_VERSION:-12.3.0} | ||
| development: ${DEVELOPMENT:-false} | ||
| anonymous_auth_enabled: ${ANONYMOUS_AUTH_ENABLED:-true} | ||
| ports: | ||
| - 3000:3000/tcp | ||
| volumes: | ||
| - ../dist:/var/lib/grafana/plugins/marcusolsson-static-datasource | ||
| - ../provisioning:/etc/grafana/provisioning | ||
| - ..:/root/business-input | ||
|
|
||
| environment: | ||
| NODE_ENV: development | ||
| GF_LOG_FILTERS: plugin.marcusolsson-static-datasource:debug | ||
| GF_LOG_LEVEL: debug | ||
| GF_DATAPROXY_LOGGING: 1 | ||
| GF_PLUGINS_ALLOW_LOADING_UNSIGNED_PLUGINS: marcusolsson-static-datasource |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| #!/bin/sh | ||
|
|
||
| if [ "${DEV}" = "false" ]; then | ||
| echo "Starting test mode" | ||
| exec /run.sh | ||
| fi | ||
|
|
||
| echo "Starting development mode" | ||
|
|
||
| if grep -i -q alpine /etc/issue; then | ||
| exec /usr/bin/supervisord -c /etc/supervisord.conf | ||
| elif grep -i -q ubuntu /etc/issue; then | ||
| exec /usr/bin/supervisord -c /etc/supervisor/supervisord.conf | ||
| else | ||
| echo 'ERROR: Unsupported base image' | ||
| exit 1 | ||
| fi | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| /* | ||
| * ⚠️⚠️⚠️ THIS FILE WAS SCAFFOLDED BY `@grafana/create-plugin`. DO NOT EDIT THIS FILE DIRECTLY. ⚠️⚠️⚠️ | ||
| * | ||
| * In order to extend the configuration follow the steps in | ||
| * https://grafana.com/developers/plugin-tools/how-to-guides/extend-configurations#extend-the-eslint-config | ||
| */ | ||
|
|
||
| import { defineConfig } from 'eslint/config'; | ||
| import grafanaConfig from '@grafana/eslint-config/flat.js'; | ||
|
|
||
| export default defineConfig([ | ||
| ...grafanaConfig, | ||
| { | ||
| rules: { | ||
| 'react/prop-types': 'off', | ||
| }, | ||
| }, | ||
| { | ||
| files: ['src/**/*.{ts,tsx}'], | ||
|
|
||
| languageOptions: { | ||
| parserOptions: { | ||
| project: './tsconfig.json', | ||
| }, | ||
| }, | ||
|
|
||
| rules: { | ||
| '@typescript-eslint/no-deprecated': 'warn', | ||
| }, | ||
| }, | ||
| { | ||
| files: ['./tests/**/*'], | ||
|
|
||
| rules: { | ||
| 'react-hooks/rules-of-hooks': 'off', | ||
| }, | ||
| }, | ||
| ]); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.