@grafana/create-plugin 0.5.2-canary.145.f69fd70.0 → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/package.json +2 -2
- package/templates/backend/pkg/plugin/datasource.go +6 -2
- package/templates/common/.config/README.md +4 -25
- package/templates/common/.config/jest.config.js +3 -6
- package/templates/common/.config/{jest/mocks → mocks}/react-inlinesvg.tsx +0 -0
- package/templates/common/package.json +17 -17
- package/templates/common/.config/jest/utils.ts +0 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
# v0.5.2 (Thu Nov 17 2022)
|
|
2
|
+
|
|
3
|
+
#### 🐛 Bug Fix
|
|
4
|
+
|
|
5
|
+
- Create-Plugin: Bump dependencies to support node 18 [#144](https://github.com/grafana/plugin-tools/pull/144) ([@jackw](https://github.com/jackw))
|
|
6
|
+
- Create-Plugin: Backend template: Switch from Info to Debug level [#146](https://github.com/grafana/plugin-tools/pull/146) ([@xnyo](https://github.com/xnyo))
|
|
7
|
+
|
|
8
|
+
#### Authors: 2
|
|
9
|
+
|
|
10
|
+
- Giuseppe Guerra ([@xnyo](https://github.com/xnyo))
|
|
11
|
+
- Jack Westbrook ([@jackw](https://github.com/jackw))
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
1
15
|
# v0.5.1 (Mon Nov 14 2022)
|
|
2
16
|
|
|
3
17
|
#### 🐛 Bug Fix
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@grafana/create-plugin",
|
|
3
|
-
"version": "0.5.2
|
|
3
|
+
"version": "0.5.2",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"repository": {
|
|
6
6
|
"directory": "packages/create-plugin",
|
|
@@ -59,5 +59,5 @@
|
|
|
59
59
|
"engines": {
|
|
60
60
|
"node": ">=16"
|
|
61
61
|
},
|
|
62
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "33c2b874ddfd16530302004a8089162f04d12c4d"
|
|
63
63
|
}
|
|
@@ -44,7 +44,9 @@ func (d *Datasource) Dispose() {
|
|
|
44
44
|
// The QueryDataResponse contains a map of RefID to the response for each query, and each response
|
|
45
45
|
// contains Frames ([]*Frame).
|
|
46
46
|
func (d *Datasource) QueryData(ctx context.Context, req *backend.QueryDataRequest) (*backend.QueryDataResponse, error) {
|
|
47
|
-
|
|
47
|
+
// when logging at a non-Debug level, make sure you don't include sensitive information in the message
|
|
48
|
+
// (like the *backend.QueryDataRequest)
|
|
49
|
+
log.DefaultLogger.Debug("QueryData called", "numQueries", len(req.Queries))
|
|
48
50
|
|
|
49
51
|
// create response struct
|
|
50
52
|
response := backend.NewQueryDataResponse()
|
|
@@ -94,7 +96,9 @@ func (d *Datasource) query(_ context.Context, pCtx backend.PluginContext, query
|
|
|
94
96
|
// datasource configuration page which allows users to verify that
|
|
95
97
|
// a datasource is working as expected.
|
|
96
98
|
func (d *Datasource) CheckHealth(_ context.Context, req *backend.CheckHealthRequest) (*backend.CheckHealthResult, error) {
|
|
97
|
-
|
|
99
|
+
// when logging at a non-Debug level, make sure you don't include sensitive information in the message
|
|
100
|
+
// (like the *backend.QueryDataRequest)
|
|
101
|
+
log.DefaultLogger.Debug("CheckHealth called")
|
|
98
102
|
|
|
99
103
|
var status = backend.HealthStatusOk
|
|
100
104
|
var message = "Data source is working"
|
|
@@ -16,12 +16,11 @@ to issues around working with the project.
|
|
|
16
16
|
Edit the `.eslintrc` file in the project root in order to extend the ESLint configuration.
|
|
17
17
|
|
|
18
18
|
**Example:**
|
|
19
|
-
|
|
20
19
|
```json
|
|
21
20
|
{
|
|
22
21
|
"extends": "./.config/.eslintrc",
|
|
23
22
|
"rules": {
|
|
24
|
-
|
|
23
|
+
"react/prop-types": "off"
|
|
25
24
|
}
|
|
26
25
|
}
|
|
27
26
|
```
|
|
@@ -33,11 +32,10 @@ Edit the `.eslintrc` file in the project root in order to extend the ESLint conf
|
|
|
33
32
|
Edit the `.prettierrc.js` file in the project root in order to extend the Prettier configuration.
|
|
34
33
|
|
|
35
34
|
**Example:**
|
|
36
|
-
|
|
37
35
|
```javascript
|
|
38
36
|
module.exports = {
|
|
39
37
|
// Prettier configuration provided by Grafana scaffolding
|
|
40
|
-
...require(
|
|
38
|
+
...require("./.config/.prettierrc.js"),
|
|
41
39
|
|
|
42
40
|
semi: false,
|
|
43
41
|
};
|
|
@@ -52,23 +50,7 @@ There are two configuration in the project root that belong to Jest: `jest-setup
|
|
|
52
50
|
**`jest-setup.js`:** A file that is run before each test file in the suite is executed. We are using it to
|
|
53
51
|
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))
|
|
54
52
|
|
|
55
|
-
**`jest.config.js`:** The main Jest configuration file that
|
|
56
|
-
|
|
57
|
-
#### ESM errors with Jest
|
|
58
|
-
|
|
59
|
-
A common issue found with the current jest config involves importing an npm package which 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:
|
|
60
|
-
|
|
61
|
-
```javascript
|
|
62
|
-
process.env.TZ = 'UTC';
|
|
63
|
-
const { grafanaESModules, nodeModulesToTransform } = require('./jest/utils');
|
|
64
|
-
|
|
65
|
-
module.exports = {
|
|
66
|
-
// Jest configuration provided by Grafana
|
|
67
|
-
...require('./.config/jest.config'),
|
|
68
|
-
// Inform jest to only transform specific node_module packages.
|
|
69
|
-
transformIgnorePatterns: [nodeModulesToTransform([...grafanaESModules, 'packageName'])],
|
|
70
|
-
};
|
|
71
|
-
```
|
|
53
|
+
**`jest.config.js`:** The main Jest configuration file that is extending our basic Grafana-tailored setup. ([link to Jest docs](https://jestjs.io/docs/configuration))
|
|
72
54
|
|
|
73
55
|
---
|
|
74
56
|
|
|
@@ -77,7 +59,6 @@ module.exports = {
|
|
|
77
59
|
Edit the `tsconfig.json` file in the project root in order to extend the TypeScript configuration.
|
|
78
60
|
|
|
79
61
|
**Example:**
|
|
80
|
-
|
|
81
62
|
```json
|
|
82
63
|
{
|
|
83
64
|
"extends": "./.config/tsconfig.json",
|
|
@@ -99,7 +80,6 @@ Create a new config file that is going to extend the basic one provided by Grafa
|
|
|
99
80
|
It can live in the project root, e.g. `webpack.config.ts`.
|
|
100
81
|
|
|
101
82
|
#### 2. Merge the basic config provided by Grafana and your custom setup
|
|
102
|
-
|
|
103
83
|
We are going to use [`webpack-merge`](https://github.com/survivejs/webpack-merge) for this.
|
|
104
84
|
|
|
105
85
|
```typescript
|
|
@@ -120,6 +100,7 @@ const config = async (env): Promise<Configuration> => {
|
|
|
120
100
|
};
|
|
121
101
|
|
|
122
102
|
export default config;
|
|
103
|
+
|
|
123
104
|
```
|
|
124
105
|
|
|
125
106
|
#### 3. Update the `package.json` to use the new Webpack config
|
|
@@ -127,14 +108,12 @@ export default config;
|
|
|
127
108
|
We need to update the `scripts` in the `package.json` to use the extended Webpack configuration.
|
|
128
109
|
|
|
129
110
|
**Update for `build`:**
|
|
130
|
-
|
|
131
111
|
```diff
|
|
132
112
|
-"build": "webpack -c ./.config/webpack/webpack.config.ts --env production",
|
|
133
113
|
+"build": "webpack -c ./webpack.config.ts --env production",
|
|
134
114
|
```
|
|
135
115
|
|
|
136
116
|
**Update for `dev`:**
|
|
137
|
-
|
|
138
117
|
```diff
|
|
139
118
|
-"dev": "webpack -w -c ./.config/webpack/webpack.config.ts --env development",
|
|
140
119
|
+"dev": "webpack -w -c ./webpack.config.ts --env development",
|
|
@@ -5,12 +5,11 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
const path = require('path');
|
|
8
|
-
const { grafanaESModules, nodeModulesToTransform } = require('./jest/utils');
|
|
9
8
|
|
|
10
9
|
module.exports = {
|
|
11
10
|
moduleNameMapper: {
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
"\\.(css|scss|sass)$": "identity-obj-proxy",
|
|
12
|
+
"react-inlinesvg": path.resolve(__dirname, "mocks", "react-inlinesvg.tsx"),
|
|
14
13
|
},
|
|
15
14
|
modulePaths: ['<rootDir>/src'],
|
|
16
15
|
setupFilesAfterEnv: ['<rootDir>/jest-setup.js'],
|
|
@@ -36,7 +35,5 @@ module.exports = {
|
|
|
36
35
|
},
|
|
37
36
|
],
|
|
38
37
|
},
|
|
39
|
-
|
|
40
|
-
// ES module without it being transformed first. ./config/README.md#esm-errors-with-jest
|
|
41
|
-
transformIgnorePatterns: [nodeModulesToTransform(grafanaESModules)],
|
|
38
|
+
transformIgnorePatterns: [],
|
|
42
39
|
};
|
|
File without changes
|
|
@@ -20,40 +20,40 @@
|
|
|
20
20
|
"@babel/core": "^7.16.7",
|
|
21
21
|
"@grafana/e2e": "{{ grafanaVersion }}",
|
|
22
22
|
"@grafana/e2e-selectors": "{{ grafanaVersion }}",
|
|
23
|
-
"@grafana/eslint-config": "^
|
|
23
|
+
"@grafana/eslint-config": "^5.1.0",
|
|
24
24
|
"@grafana/tsconfig": "^1.2.0-rc1",
|
|
25
25
|
"@swc/core": "^1.2.144",
|
|
26
|
-
"@swc/helpers": "^0.
|
|
26
|
+
"@swc/helpers": "^0.4.12",
|
|
27
27
|
"@swc/jest": "^0.2.20",
|
|
28
28
|
"@testing-library/jest-dom": "^5.16.2",
|
|
29
|
-
"@testing-library/react": "^
|
|
29
|
+
"@testing-library/react": "^13.4.0",
|
|
30
30
|
"@types/glob": "^8.0.0",
|
|
31
|
-
"@types/jest": "^
|
|
32
|
-
"@types/lodash": "
|
|
31
|
+
"@types/jest": "^29.2.2",
|
|
32
|
+
"@types/lodash": "^4.14.188",{{#if_eq pluginType "app"}}
|
|
33
33
|
"@types/react-router-dom": "^5.3.3",{{/if_eq}}
|
|
34
|
-
"@types/node": "^
|
|
35
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
36
|
-
"@typescript-eslint/parser": "^
|
|
37
|
-
"copy-webpack-plugin": "^
|
|
38
|
-
"css-loader": "6.7.1",
|
|
39
|
-
"eslint": "
|
|
34
|
+
"@types/node": "^18.11.9",
|
|
35
|
+
"@typescript-eslint/eslint-plugin": "^5.42.1",
|
|
36
|
+
"@typescript-eslint/parser": "^5.42.1",
|
|
37
|
+
"copy-webpack-plugin": "^11.0.0",
|
|
38
|
+
"css-loader": "^6.7.1",
|
|
39
|
+
"eslint": "8.26.0",
|
|
40
40
|
"eslint-config-prettier": "^8.3.0",
|
|
41
|
-
"eslint-plugin-jsdoc": "^
|
|
41
|
+
"eslint-plugin-jsdoc": "^39.6.2",
|
|
42
42
|
"eslint-plugin-prettier": "^4.0.0",
|
|
43
43
|
"eslint-plugin-react": "^7.26.1",
|
|
44
44
|
"eslint-plugin-react-hooks": "^4.2.0",
|
|
45
45
|
"eslint-webpack-plugin": "^3.1.1",
|
|
46
|
+
"fork-ts-checker-webpack-plugin": "^7.2.0",
|
|
46
47
|
"glob": "^8.0.3",
|
|
47
48
|
"identity-obj-proxy": "3.0.0",
|
|
48
49
|
"jest": "27.5.0",
|
|
49
|
-
"fork-ts-checker-webpack-plugin": "^7.2.0",
|
|
50
50
|
"prettier": "^2.5.0",
|
|
51
51
|
"replace-in-file-webpack-plugin": "^1.0.6",
|
|
52
|
-
"sass": "1.
|
|
53
|
-
"sass-loader": "13.
|
|
52
|
+
"sass": "1.56.1",
|
|
53
|
+
"sass-loader": "13.2.0",
|
|
54
54
|
"style-loader": "3.3.1",
|
|
55
|
-
"swc-loader": "^0.
|
|
56
|
-
"tsconfig-paths": "^
|
|
55
|
+
"swc-loader": "^0.2.3",
|
|
56
|
+
"tsconfig-paths": "^4.1.0",
|
|
57
57
|
"ts-node": "^10.5.0",
|
|
58
58
|
"typescript": "^4.4.0",
|
|
59
59
|
"webpack": "^5.69.1",
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* nodeModulesToTransform
|
|
3
|
-
* This utility function is useful in combination with jest `transformIgnorePatterns` config
|
|
4
|
-
* to transform specific packages (e.g.ES modules) in a projects node_modules folder.
|
|
5
|
-
*/
|
|
6
|
-
export const nodeModulesToTransform = (moduleNames: string[]) => `node_modules\/(?!(${moduleNames.join('|')})\/)`;
|
|
7
|
-
|
|
8
|
-
// Array of known nested grafana package dependencies that only bundle an ESM version
|
|
9
|
-
export const grafanaESModules = ['ol', 'react-colorful'];
|