Skip to content

Commit 22d9e90

Browse files
committed
update via create-plugin
ran ``` npx @grafana/create-plugin@latest update ``` as suggested by https://grafana.com/developers/plugin-tools/migration-guides/update-create-plugin-versions followed by a ``` yarn install ``` But the commands in `pacakge.json` are not fully standard so they had to be adapted to take our local webpack config and execute the `utils/plugin_json_*` scripts. Typescript found one more problem in src/utils.ts which was fixed.
1 parent df8a6cb commit 22d9e90

File tree

10 files changed

+3337
-972
lines changed

10 files changed

+3337
-972
lines changed

.config/.eslintrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* In order to extend the configuration follow the steps in
55
* https://grafana.github.io/plugin-tools/docs/advanced-configuration#extending-the-eslint-config
66
*/
7-
{
7+
{
88
"extends": ["@grafana/eslint-config"],
99
"root": true,
1010
"rules": {

.config/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ A common issue found with the current jest config involves importing an npm pack
6060

6161
```javascript
6262
process.env.TZ = 'UTC';
63-
const { grafanaESModules, nodeModulesToTransform } = require('./jest/utils');
63+
const { grafanaESModules, nodeModulesToTransform } = require('./config/jest/utils');
6464

6565
module.exports = {
6666
// Jest configuration provided by Grafana
@@ -142,7 +142,7 @@ We need to update the `scripts` in the `package.json` to use the extended Webpac
142142

143143
### Configure grafana image to use when running docker
144144

145-
By default `grafana-enterprise` will be used as the docker image for all docker related commands. If you want to override this behaviour simply alter the `docker-compose.yaml` by adding the following build arg `grafana_image`.
145+
By default `grafana-enterprise` will be used as the docker image for all docker related commands. If you want to override this behaviour simply alter the `docker-compose.yaml` by adding the following build arg `grafana_image`.
146146

147147
**Example:**
148148

@@ -161,4 +161,4 @@ services:
161161
162162
In this example we are assigning the environment variable `GRAFANA_IMAGE` to the build arg `grafana_image` with a default value of `grafana`. This will give you the possibility to set the value while running the docker-compose commands which might be convinent in some scenarios.
163163

164-
---
164+
---

.config/jest.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ module.exports = {
2525
'^.+\\.(t|j)sx?$': [
2626
'@swc/jest',
2727
{
28-
sourceMaps: true,
28+
sourceMaps: 'inline',
2929
jsc: {
3030
parser: {
3131
syntax: 'typescript',

.config/jest/utils.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,16 @@ const nodeModulesToTransform = (moduleNames) => `node_modules\/(?!(${moduleNames
1212

1313
// Array of known nested grafana package dependencies that only bundle an ESM version
1414
const grafanaESModules = [
15+
'.pnpm', // Support using pnpm symlinked packages
16+
'@grafana/schema',
1517
'd3',
1618
'd3-color',
1719
'd3-force',
1820
'd3-interpolate',
1921
'd3-scale-chromatic',
2022
'ol',
2123
'react-colorful',
24+
'rxjs',
2225
'uuid',
2326
];
2427

.config/webpack/utils.ts

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,26 @@
11
import { SOURCE_DIR } from './constants';
22
import fs from 'fs';
3-
import glob from 'glob';
3+
import { glob } from 'glob';
4+
import os from 'os';
45
import path from 'path';
6+
import process from 'process';
57
import util from 'util';
68

7-
const globAsync = util.promisify(glob);
9+
export function isWSL() {
10+
if (process.platform !== 'linux') {
11+
return false;
12+
}
13+
14+
if (os.release().toLowerCase().includes('microsoft')) {
15+
return true;
16+
}
17+
18+
try {
19+
return fs.readFileSync('/proc/version', 'utf8').toLowerCase().includes('microsoft');
20+
} catch {
21+
return false;
22+
}
23+
}
824

925
export function getPackageJson() {
1026
return require(path.resolve(process.cwd(), 'package.json'));
@@ -21,12 +37,12 @@ export function hasReadme() {
2137
// Support bundling nested plugins by finding all plugin.json files in src directory
2238
// then checking for a sibling module.[jt]sx? file.
2339
export async function getEntries(): Promise<Record<string, string>> {
24-
const pluginsJson = await globAsync('**/src/**/plugin.json', { absolute: true });
40+
const pluginsJson = await glob('**/src/**/plugin.json', { absolute: true });
2541

2642
const plugins = await Promise.all(
2743
pluginsJson.map((pluginJson) => {
2844
const folder = path.dirname(pluginJson);
29-
return globAsync(`${folder}/module.{ts,tsx,js,jsx}`, { absolute: true });
45+
return glob(`${folder}/module.{ts,tsx,js,jsx}`, { absolute: true });
3046
})
3147
);
3248

0 commit comments

Comments
 (0)