@grafana/create-plugin 4.15.0-canary.984.9ef654f.0 → 4.15.0
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 +24 -0
- package/dist/commands/generate/print-success-message.js +1 -1
- package/dist/utils/tests/utils.config.test.js +0 -14
- package/dist/utils/utils.config.js +5 -10
- package/package.json +2 -2
- package/src/commands/generate/print-success-message.ts +1 -1
- package/src/utils/tests/utils.config.test.ts +0 -16
- package/src/utils/utils.config.ts +6 -11
- package/templates/common/.config/Dockerfile +2 -1
- package/templates/common/.config/webpack/publicPath.ts +17 -0
- package/templates/common/.config/webpack/webpack.config.ts +14 -7
- package/templates/common/_package.json +1 -0
- package/templates/common/docker-compose.yaml +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,27 @@
|
|
|
1
|
+
# v4.15.0 (Thu Jul 04 2024)
|
|
2
|
+
|
|
3
|
+
#### 🚀 Enhancement
|
|
4
|
+
|
|
5
|
+
- Create Plugin: Dynamic webpack publicPath [#966](https://github.com/grafana/plugin-tools/pull/966) ([@jackw](https://github.com/jackw))
|
|
6
|
+
|
|
7
|
+
#### Authors: 1
|
|
8
|
+
|
|
9
|
+
- Jack Westbrook ([@jackw](https://github.com/jackw))
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
# v4.14.1 (Thu Jul 04 2024)
|
|
14
|
+
|
|
15
|
+
#### 🐛 Bug Fix
|
|
16
|
+
|
|
17
|
+
- Create Plugin: Fix backend dev env for arm64 hosts [#990](https://github.com/grafana/plugin-tools/pull/990) ([@jackw](https://github.com/jackw))
|
|
18
|
+
|
|
19
|
+
#### Authors: 1
|
|
20
|
+
|
|
21
|
+
- Jack Westbrook ([@jackw](https://github.com/jackw))
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
1
25
|
# v4.14.0 (Mon Jul 01 2024)
|
|
2
26
|
|
|
3
27
|
#### 🚀 Enhancement
|
|
@@ -11,7 +11,7 @@ export function printGenerateSuccessMessage(answers) {
|
|
|
11
11
|
`- \`${packageManagerName} run dev\` to build (and watch) the plugin frontend code.`,
|
|
12
12
|
...(answers.hasBackend
|
|
13
13
|
? [
|
|
14
|
-
'- `mage -v build:
|
|
14
|
+
'- `mage -v build:backend` to build the plugin backend code. Rerun this command every time you edit your backend files.',
|
|
15
15
|
]
|
|
16
16
|
: []),
|
|
17
17
|
'- `docker-compose up` to start a grafana development server.',
|
|
@@ -8,7 +8,6 @@ import { DEFAULT_FEATURE_FLAGS } from '../../constants.js';
|
|
|
8
8
|
const mocks = vi.hoisted(() => {
|
|
9
9
|
return {
|
|
10
10
|
commandName: 'generate',
|
|
11
|
-
argv: {},
|
|
12
11
|
};
|
|
13
12
|
});
|
|
14
13
|
vi.mock('../utils.cli.js', async () => mocks);
|
|
@@ -21,7 +20,6 @@ describe('getConfig', () => {
|
|
|
21
20
|
describe('Command: Generate', () => {
|
|
22
21
|
beforeEach(() => {
|
|
23
22
|
mocks.commandName = 'generate';
|
|
24
|
-
mocks.argv = {};
|
|
25
23
|
});
|
|
26
24
|
it('should give back a default config', async () => {
|
|
27
25
|
const config = getConfig(tmpDir);
|
|
@@ -30,22 +28,10 @@ describe('getConfig', () => {
|
|
|
30
28
|
features: DEFAULT_FEATURE_FLAGS,
|
|
31
29
|
});
|
|
32
30
|
});
|
|
33
|
-
it('should override default feature flags via cli args', async () => {
|
|
34
|
-
mocks.argv = {
|
|
35
|
-
useReactRouterV6: false,
|
|
36
|
-
bundleGrafanaUI: true,
|
|
37
|
-
};
|
|
38
|
-
const config = getConfig(tmpDir);
|
|
39
|
-
expect(config).toEqual({
|
|
40
|
-
version: getVersion(),
|
|
41
|
-
features: { ...DEFAULT_FEATURE_FLAGS, ...mocks.argv },
|
|
42
|
-
});
|
|
43
|
-
});
|
|
44
31
|
});
|
|
45
32
|
describe('Command: Update', () => {
|
|
46
33
|
beforeEach(() => {
|
|
47
34
|
mocks.commandName = 'update';
|
|
48
|
-
mocks.argv = {};
|
|
49
35
|
});
|
|
50
36
|
it('should give back the correct config when there are no config files at all', async () => {
|
|
51
37
|
const config = getConfig();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { getVersion } from './utils.version.js';
|
|
4
|
-
import {
|
|
4
|
+
import { commandName } from './utils.cli.js';
|
|
5
5
|
import { DEFAULT_FEATURE_FLAGS } from '../constants.js';
|
|
6
6
|
export function getConfig(workDir = process.cwd()) {
|
|
7
7
|
const rootConfig = getRootConfig(workDir);
|
|
@@ -58,13 +58,8 @@ function readRCFileSync(path) {
|
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
60
|
function createFeatureFlags(flags) {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}
|
|
66
|
-
else {
|
|
67
|
-
return { ...acc, [flag]: value };
|
|
68
|
-
}
|
|
69
|
-
}, {});
|
|
61
|
+
if (commandName === 'generate') {
|
|
62
|
+
return DEFAULT_FEATURE_FLAGS;
|
|
63
|
+
}
|
|
64
|
+
return flags ?? {};
|
|
70
65
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@grafana/create-plugin",
|
|
3
|
-
"version": "4.15.0
|
|
3
|
+
"version": "4.15.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"directory": "packages/create-plugin",
|
|
6
6
|
"url": "https://github.com/grafana/plugin-tools"
|
|
@@ -87,5 +87,5 @@
|
|
|
87
87
|
"engines": {
|
|
88
88
|
"node": ">=20"
|
|
89
89
|
},
|
|
90
|
-
"gitHead": "
|
|
90
|
+
"gitHead": "10a4a8648f2f2794df271011c3bd062d47e323d6"
|
|
91
91
|
}
|
|
@@ -13,7 +13,7 @@ export function printGenerateSuccessMessage(answers: TemplateData) {
|
|
|
13
13
|
`- \`${packageManagerName} run dev\` to build (and watch) the plugin frontend code.`,
|
|
14
14
|
...(answers.hasBackend
|
|
15
15
|
? [
|
|
16
|
-
'- `mage -v build:
|
|
16
|
+
'- `mage -v build:backend` to build the plugin backend code. Rerun this command every time you edit your backend files.',
|
|
17
17
|
]
|
|
18
18
|
: []),
|
|
19
19
|
'- `docker-compose up` to start a grafana development server.',
|
|
@@ -9,7 +9,6 @@ import { DEFAULT_FEATURE_FLAGS } from '../../constants.js';
|
|
|
9
9
|
const mocks = vi.hoisted(() => {
|
|
10
10
|
return {
|
|
11
11
|
commandName: 'generate',
|
|
12
|
-
argv: {},
|
|
13
12
|
};
|
|
14
13
|
});
|
|
15
14
|
|
|
@@ -26,7 +25,6 @@ describe('getConfig', () => {
|
|
|
26
25
|
describe('Command: Generate', () => {
|
|
27
26
|
beforeEach(() => {
|
|
28
27
|
mocks.commandName = 'generate';
|
|
29
|
-
mocks.argv = {};
|
|
30
28
|
});
|
|
31
29
|
|
|
32
30
|
it('should give back a default config', async () => {
|
|
@@ -37,25 +35,11 @@ describe('getConfig', () => {
|
|
|
37
35
|
features: DEFAULT_FEATURE_FLAGS,
|
|
38
36
|
});
|
|
39
37
|
});
|
|
40
|
-
|
|
41
|
-
it('should override default feature flags via cli args', async () => {
|
|
42
|
-
mocks.argv = {
|
|
43
|
-
useReactRouterV6: false,
|
|
44
|
-
bundleGrafanaUI: true,
|
|
45
|
-
};
|
|
46
|
-
const config = getConfig(tmpDir);
|
|
47
|
-
|
|
48
|
-
expect(config).toEqual({
|
|
49
|
-
version: getVersion(),
|
|
50
|
-
features: { ...DEFAULT_FEATURE_FLAGS, ...mocks.argv },
|
|
51
|
-
});
|
|
52
|
-
});
|
|
53
38
|
});
|
|
54
39
|
|
|
55
40
|
describe('Command: Update', () => {
|
|
56
41
|
beforeEach(() => {
|
|
57
42
|
mocks.commandName = 'update';
|
|
58
|
-
mocks.argv = {};
|
|
59
43
|
});
|
|
60
44
|
|
|
61
45
|
it('should give back the correct config when there are no config files at all', async () => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { getVersion } from './utils.version.js';
|
|
4
|
-
import {
|
|
4
|
+
import { commandName } from './utils.cli.js';
|
|
5
5
|
import { DEFAULT_FEATURE_FLAGS } from '../constants.js';
|
|
6
6
|
|
|
7
7
|
export type FeatureFlags = {
|
|
@@ -83,16 +83,11 @@ function readRCFileSync(path: string): CreatePluginConfig | undefined {
|
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
-
// This function creates feature flags based on the defaults for generate command else flags read from config.
|
|
87
|
-
// In both cases it will override the flags if any cli args with the same name are passed in.
|
|
88
86
|
function createFeatureFlags(flags?: FeatureFlags): FeatureFlags {
|
|
89
|
-
|
|
87
|
+
// Default values for new scaffoldings
|
|
88
|
+
if (commandName === 'generate') {
|
|
89
|
+
return DEFAULT_FEATURE_FLAGS;
|
|
90
|
+
}
|
|
90
91
|
|
|
91
|
-
return
|
|
92
|
-
if (argv.hasOwnProperty(flag)) {
|
|
93
|
-
return { ...acc, [flag]: argv[flag] };
|
|
94
|
-
} else {
|
|
95
|
-
return { ...acc, [flag]: value };
|
|
96
|
-
}
|
|
97
|
-
}, {} as FeatureFlags);
|
|
92
|
+
return flags ?? {};
|
|
98
93
|
}
|
|
@@ -4,10 +4,11 @@ ARG grafana_image=grafana-enterprise
|
|
|
4
4
|
FROM grafana/${grafana_image}:${grafana_version}
|
|
5
5
|
|
|
6
6
|
ARG development=false
|
|
7
|
+
ARG TARGETARCH
|
|
7
8
|
|
|
8
9
|
{{#if hasBackend}}
|
|
9
10
|
ARG GO_VERSION=1.21.6
|
|
10
|
-
ARG GO_ARCH
|
|
11
|
+
ARG GO_ARCH=${TARGETARCH:-amd64}
|
|
11
12
|
{{/if}}
|
|
12
13
|
|
|
13
14
|
ENV DEV "${development}"
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* ⚠️⚠️⚠️ THIS FILE WAS SCAFFOLDED BY `@grafana/create-plugin`. DO NOT EDIT THIS FILE DIRECTLY. ⚠️⚠️⚠️
|
|
3
|
+
*
|
|
4
|
+
* This file dynamically sets the public path at runtime based on the location of the plugin's AMD module.
|
|
5
|
+
* It relies on the magic `module` which is defined by the AMD loader.
|
|
6
|
+
* https://github.com/requirejs/requirejs/wiki/Differences-between-the-simplified-CommonJS-wrapper-and-standard-AMD-define#module
|
|
7
|
+
*
|
|
8
|
+
* We fallback to the plugin root so that older versions of Grafana will continue to load the plugin correctly.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
// @ts-nocheck
|
|
12
|
+
import amdMetaModule from 'amd-module';
|
|
13
|
+
|
|
14
|
+
__webpack_public_path__ =
|
|
15
|
+
amdMetaModule && amdMetaModule.uri
|
|
16
|
+
? amdMetaModule.uri.slice(0, amdMetaModule.uri.lastIndexOf('/') + 1)
|
|
17
|
+
: 'public/plugins/{{ pluginId }}/';
|
|
@@ -36,6 +36,8 @@ const config = async (env): Promise<Configuration> => {
|
|
|
36
36
|
entry: await getEntries(),
|
|
37
37
|
|
|
38
38
|
externals: [
|
|
39
|
+
// Required for dynamic publicPath resolution
|
|
40
|
+
{ 'amd-module': 'module' },
|
|
39
41
|
'lodash',
|
|
40
42
|
'jquery',
|
|
41
43
|
'moment',
|
|
@@ -104,6 +106,17 @@ const config = async (env): Promise<Configuration> => {
|
|
|
104
106
|
},
|
|
105
107
|
},
|
|
106
108
|
},
|
|
109
|
+
{
|
|
110
|
+
test: /src\/(?:.*\/)?module\.tsx?$/,
|
|
111
|
+
use: [
|
|
112
|
+
{
|
|
113
|
+
loader: 'imports-loader',
|
|
114
|
+
options: {
|
|
115
|
+
imports: `side-effects ${path.join(__dirname, 'publicPath.ts')}`,
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
],
|
|
119
|
+
},
|
|
107
120
|
{
|
|
108
121
|
test: /\.css$/,
|
|
109
122
|
use: ['style-loader', 'css-loader'],
|
|
@@ -116,9 +129,6 @@ const config = async (env): Promise<Configuration> => {
|
|
|
116
129
|
test: /\.(png|jpe?g|gif|svg)$/,
|
|
117
130
|
type: 'asset/resource',
|
|
118
131
|
generator: {
|
|
119
|
-
// Keep publicPath relative for host.com/grafana/ deployments
|
|
120
|
-
publicPath: `public/plugins/${pluginJson.id}/img/`,
|
|
121
|
-
outputPath: 'img/',
|
|
122
132
|
filename: Boolean(env.production) ? '[hash][ext]' : '[file]',
|
|
123
133
|
},
|
|
124
134
|
},
|
|
@@ -126,10 +136,7 @@ const config = async (env): Promise<Configuration> => {
|
|
|
126
136
|
test: /\.(woff|woff2|eot|ttf|otf)(\?v=\d+\.\d+\.\d+)?$/,
|
|
127
137
|
type: 'asset/resource',
|
|
128
138
|
generator: {
|
|
129
|
-
|
|
130
|
-
publicPath: `public/plugins/${pluginJson.id}/fonts/`,
|
|
131
|
-
outputPath: 'fonts/',
|
|
132
|
-
filename: Boolean(env.production) ? '[hash][ext]' : '[name][ext]',
|
|
139
|
+
filename: Boolean(env.production) ? '[hash][ext]' : '[file]',
|
|
133
140
|
},
|
|
134
141
|
},
|
|
135
142
|
],
|