Skip to content

Commit 460c25c

Browse files
authored
⬆️ Chore: Upgrade go & npm dependencies to latest versions (#75)
1 parent 2fb6eae commit 460c25c

File tree

15 files changed

+1293
-702
lines changed

15 files changed

+1293
-702
lines changed

.config/.cprc.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"version": "4.3.0"
3+
}

.config/.eslintrc

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,22 @@
44
* In order to extend the configuration follow the steps in
55
* https://grafana.com/developers/plugin-tools/create-a-plugin/extend-a-plugin/extend-configurations#extend-the-eslint-config
66
*/
7-
{
7+
{
88
"extends": ["@grafana/eslint-config"],
99
"root": true,
1010
"rules": {
1111
"react/prop-types": "off"
12-
}
12+
},
13+
"overrides": [
14+
{
15+
"plugins": ["deprecation"],
16+
"files": ["src/**/*.{ts,tsx}"],
17+
"rules": {
18+
"deprecation/deprecation": "warn"
19+
},
20+
"parserOptions": {
21+
"project": "./tsconfig.json"
22+
}
23+
}
24+
]
1325
}

.config/.prettierrc.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
*/
66

77
module.exports = {
8-
"endOfLine": "auto",
9-
"printWidth": 120,
10-
"trailingComma": "es5",
11-
"semi": true,
12-
"jsxSingleQuote": false,
13-
"singleQuote": true,
14-
"useTabs": false,
15-
"tabWidth": 2
16-
};
8+
endOfLine: 'auto',
9+
printWidth: 120,
10+
trailingComma: 'es5',
11+
semi: true,
12+
jsxSingleQuote: false,
13+
singleQuote: true,
14+
useTabs: false,
15+
tabWidth: 2,
16+
};

.config/Dockerfile

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ ARG grafana_image=grafana-enterprise
33

44
FROM grafana/${grafana_image}:${grafana_version}
55

6+
ARG GO_VERSION=1.21.6
7+
ARG GO_ARCH=amd64
8+
69
# Make it as simple as possible to access the grafana instance for development purposes
710
# Do NOT enable these settings in a public facing / production grafana instance
811
ENV GF_AUTH_ANONYMOUS_ORG_ROLE "Admin"
@@ -11,6 +14,51 @@ ENV GF_AUTH_BASIC_ENABLED "false"
1114
# Set development mode so plugins can be loaded without the need to sign
1215
ENV GF_DEFAULT_APP_MODE "development"
1316

14-
# Inject livereload script into grafana index.html
17+
18+
LABEL maintainer="Grafana Labs <[email protected]>"
19+
20+
ENV GF_PATHS_HOME="/usr/share/grafana"
21+
WORKDIR $GF_PATHS_HOME
22+
1523
USER root
16-
RUN sed -i 's/<\/body><\/html>/<script src=\"http:\/\/localhost:35729\/livereload.js\"><\/script><\/body><\/html>/g' /usr/share/grafana/public/views/index.html
24+
25+
26+
# Installing supervisor and inotify-tools
27+
RUN if grep -i -q alpine /etc/issue; then \
28+
apk add supervisor inotify-tools git; \
29+
elif grep -i -q ubuntu /etc/issue; then \
30+
DEBIAN_FRONTEND=noninteractive && \
31+
apt-get update && \
32+
apt-get install -y supervisor inotify-tools git && \
33+
rm -rf /var/lib/apt/lists/*; \
34+
else \
35+
echo 'ERROR: Unsupported base image' && /bin/false; \
36+
fi
37+
38+
COPY supervisord/supervisord.conf /etc/supervisor.d/supervisord.ini
39+
COPY supervisord/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
40+
41+
42+
# Installing Go
43+
RUN curl -O -L https://golang.org/dl/go${GO_VERSION}.linux-${GO_ARCH}.tar.gz && \
44+
rm -rf /usr/local/go && \
45+
tar -C /usr/local -xzf go${GO_VERSION}.linux-${GO_ARCH}.tar.gz && \
46+
echo "export PATH=$PATH:/usr/local/go/bin:~/go/bin" >> ~/.bashrc && \
47+
rm -f go${GO_VERSION}.linux-${GO_ARCH}.tar.gz
48+
49+
# Installing delve for debugging
50+
RUN /usr/local/go/bin/go install github.com/go-delve/delve/cmd/dlv@latest
51+
52+
# Installing mage for plugin (re)building
53+
RUN git clone https://github.com/magefile/mage; \
54+
cd mage; \
55+
export PATH=$PATH:/usr/local/go/bin; \
56+
go run bootstrap.go
57+
58+
# Inject livereload script into grafana index.html
59+
RUN sed -i 's|</body>|<script src="http://localhost:35729/livereload.js"></script></body>|g' /usr/share/grafana/public/views/index.html
60+
61+
62+
COPY entrypoint.sh /entrypoint.sh
63+
RUN chmod +x /entrypoint.sh
64+
ENTRYPOINT ["/entrypoint.sh"]

.config/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ set up the Jest DOM for the testing library and to apply some polyfills. ([link
5656

5757
#### ESM errors with Jest
5858

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:
59+
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:
6060

6161
```javascript
6262
process.env.TZ = 'UTC';
@@ -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 behavior, simply alter the `docker-compose.yaml` by adding the following build arg `grafana_image`.
146146

147147
**Example:**
148148

@@ -159,6 +159,6 @@ services:
159159
grafana_image: ${GRAFANA_IMAGE:-grafana}
160160
```
161161
162-
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.
162+
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.
163163

164164
---

.config/entrypoint.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/sh
2+
3+
if grep -i -q alpine /etc/issue; then
4+
exec /usr/bin/supervisord -c /etc/supervisord.conf
5+
elif grep -i -q ubuntu /etc/issue; then
6+
exec /usr/bin/supervisord -c /etc/supervisor/supervisord.conf
7+
else
8+
echo 'ERROR: Unsupported base image'
9+
exit 1
10+
fi

.config/supervisord/supervisord.conf

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
[supervisord]
2+
nodaemon=true
3+
user=root
4+
5+
[program:grafana]
6+
user=root
7+
directory=/var/lib/grafana
8+
command=/run.sh
9+
stdout_logfile=/dev/fd/1
10+
stdout_logfile_maxbytes=0
11+
redirect_stderr=true
12+
killasgroup=true
13+
stopasgroup=true
14+
autostart=true
15+
16+
[program:delve]
17+
user=root
18+
command=/bin/bash -c 'pid=""; while [ -z "$pid" ]; do pid=$(pgrep -f gpx_databricks); done; /root/go/bin/dlv attach --api-version=2 --headless --continue --accept-multiclient --listen=:2345 $pid'
19+
stdout_logfile=/dev/fd/1
20+
stdout_logfile_maxbytes=0
21+
redirect_stderr=true
22+
killasgroup=false
23+
stopasgroup=false
24+
autostart=true
25+
autorestart=true
26+
27+
[program:build-watcher]
28+
user=root
29+
command=/bin/bash -c 'while inotifywait -e modify,create,delete -r /var/lib/grafana/plugins/mullerpeter-databricks-datasource; do echo "Change detected, restarting delve...";supervisorctl restart delve; done'
30+
stdout_logfile=/dev/fd/1
31+
stdout_logfile_maxbytes=0
32+
redirect_stderr=true
33+
killasgroup=true
34+
stopasgroup=true
35+
autostart=true
36+
37+
[program:mage-watcher]
38+
user=root
39+
environment=PATH="/usr/local/go/bin:/root/go/bin:%(ENV_PATH)s"
40+
directory=/root/mullerpeter-databricks-datasource
41+
command=/bin/bash -c 'git config --global --add safe.directory /root/mullerpeter-databricks-datasource && mage -v watch'
42+
stdout_logfile=/dev/fd/1
43+
stdout_logfile_maxbytes=0
44+
redirect_stderr=true
45+
killasgroup=true
46+
stopasgroup=true
47+
autostart=true

.config/tsconfig.json

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.com/developers/plugin-tools/create-a-plugin/extend-a-plugin/extend-configurations#extend-the-typescript-config
66
*/
7-
{
7+
{
88
"compilerOptions": {
99
"alwaysStrict": true,
1010
"declaration": false,

.config/webpack/utils.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@ import fs from 'fs';
22
import process from 'process';
33
import os from 'os';
44
import path from 'path';
5-
import util from 'util';
65
import { glob } from 'glob';
76
import { SOURCE_DIR } from './constants';
87

9-
108
export function isWSL() {
119
if (process.platform !== 'linux') {
1210
return false;
@@ -21,7 +19,7 @@ export function isWSL() {
2119
} catch {
2220
return false;
2321
}
24-
}
22+
}
2523

2624
export function getPackageJson() {
2725
return require(path.resolve(process.cwd(), 'package.json'));
@@ -40,7 +38,8 @@ export function hasReadme() {
4038
export async function getEntries(): Promise<Record<string, string>> {
4139
const pluginsJson = await glob('**/src/**/plugin.json', { absolute: true });
4240

43-
const plugins = await Promise.all(pluginsJson.map((pluginJson) => {
41+
const plugins = await Promise.all(
42+
pluginsJson.map((pluginJson) => {
4443
const folder = path.dirname(pluginJson);
4544
return glob(`${folder}/module.{ts,tsx,js,jsx}`, { absolute: true });
4645
})

.config/webpack/webpack.config.ts

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ const config = async (env): Promise<Configuration> => {
8282
loader: 'swc-loader',
8383
options: {
8484
jsc: {
85-
baseUrl: './src',
85+
baseUrl: path.resolve(__dirname, 'src'),
8686
target: 'es2015',
8787
loose: false,
8888
parser: {
@@ -97,7 +97,7 @@ const config = async (env): Promise<Configuration> => {
9797
},
9898
{
9999
test: /\.css$/,
100-
use: ["style-loader", "css-loader"]
100+
use: ['style-loader', 'css-loader'],
101101
},
102102
{
103103
test: /\.s[ac]ss$/,
@@ -110,7 +110,7 @@ const config = async (env): Promise<Configuration> => {
110110
// Keep publicPath relative for host.com/grafana/ deployments
111111
publicPath: `public/plugins/${pluginJson.id}/img/`,
112112
outputPath: 'img/',
113-
filename: Boolean(env.production) ? '[hash][ext]' : '[name][ext]',
113+
filename: Boolean(env.production) ? '[hash][ext]' : '[file]',
114114
},
115115
},
116116
{
@@ -135,7 +135,8 @@ const config = async (env): Promise<Configuration> => {
135135
type: 'amd',
136136
},
137137
path: path.resolve(process.cwd(), DIST_DIR),
138-
publicPath: '/',
138+
publicPath: `public/plugins/${pluginJson.id}/`,
139+
uniqueName: pluginJson.id,
139140
},
140141

141142
plugins: [
@@ -154,6 +155,7 @@ const config = async (env): Promise<Configuration> => {
154155
{ from: 'img/**/*', to: '.', noErrorOnMissing: true }, // Optional
155156
{ from: 'libs/**/*', to: '.', noErrorOnMissing: true }, // Optional
156157
{ from: 'static/**/*', to: '.', noErrorOnMissing: true }, // Optional
158+
{ from: '**/query_help.md', to: '.', noErrorOnMissing: true }, // Optional
157159
],
158160
}),
159161
// Replace certain template-variables in the README and plugin.json
@@ -177,18 +179,22 @@ const config = async (env): Promise<Configuration> => {
177179
],
178180
},
179181
]),
180-
new ForkTsCheckerWebpackPlugin({
181-
async: Boolean(env.development),
182-
issue: {
183-
include: [{ file: '**/*.{ts,tsx}' }],
184-
},
185-
typescript: { configFile: path.join(process.cwd(), 'tsconfig.json') },
186-
}),
187-
new ESLintPlugin({
188-
extensions: ['.ts', '.tsx'],
189-
lintDirtyModulesOnly: Boolean(env.development), // don't lint on start, only lint changed files
190-
}),
191-
...(env.development ? [new LiveReloadPlugin()] : []),
182+
...(env.development
183+
? [
184+
new LiveReloadPlugin(),
185+
new ForkTsCheckerWebpackPlugin({
186+
async: Boolean(env.development),
187+
issue: {
188+
include: [{ file: '**/*.{ts,tsx}' }],
189+
},
190+
typescript: { configFile: path.join(process.cwd(), 'tsconfig.json') },
191+
}),
192+
new ESLintPlugin({
193+
extensions: ['.ts', '.tsx'],
194+
lintDirtyModulesOnly: Boolean(env.development), // don't lint on start, only lint changed files
195+
}),
196+
]
197+
: []),
192198
],
193199

194200
resolve: {
@@ -197,17 +203,16 @@ const config = async (env): Promise<Configuration> => {
197203
modules: [path.resolve(process.cwd(), 'src'), 'node_modules'],
198204
unsafeCache: true,
199205
},
200-
}
206+
};
201207

202-
if(isWSL()) {
208+
if (isWSL()) {
203209
baseConfig.watchOptions = {
204210
poll: 3000,
205211
ignored: /node_modules/,
206-
}}
207-
212+
};
213+
}
208214

209215
return baseConfig;
210-
211216
};
212217

213218
export default config;

CHANGELOG.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
# Changelog
22

3-
## 1.2.3
3+
## 1.2.4
4+
5+
- Chore: Upgrade go & npm dependencies to latest versions
6+
- Refactor: SetConnMaxIdleTime to 6 hours on Databricks Connection Refresh
7+
8+
---
9+
10+
### 1.2.3
411

512
- Bugfix: Reintroduce Connection Refresh on Invalid SessionHandle error
613

0 commit comments

Comments
 (0)