@grafana/create-plugin 4.14.0-canary.984.f879305.0 → 4.14.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 +12 -0
- package/dist/utils/tests/utils.config.test.js +0 -13
- package/dist/utils/utils.config.js +2 -10
- package/package.json +2 -2
- package/src/utils/tests/utils.config.test.ts +0 -15
- package/src/utils/utils.config.ts +3 -11
- package/templates/common/.config/webpack/utils.ts +5 -0
- package/templates/common/.config/webpack/webpack.config.ts +23 -2
- package/templates/common/npmrc +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
# v4.14.0 (Mon Jul 01 2024)
|
|
2
|
+
|
|
3
|
+
#### 🚀 Enhancement
|
|
4
|
+
|
|
5
|
+
- Create-Plugin: Add version comment to bundled Javascript [#970](https://github.com/grafana/plugin-tools/pull/970) ([@jackw](https://github.com/jackw))
|
|
6
|
+
|
|
7
|
+
#### Authors: 1
|
|
8
|
+
|
|
9
|
+
- Jack Westbrook ([@jackw](https://github.com/jackw))
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
1
13
|
# v4.12.0 (Tue Jun 11 2024)
|
|
2
14
|
|
|
3
15
|
#### 🚀 Enhancement
|
|
@@ -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,17 +28,6 @@ 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, useReactRouterV6: false, bundleGrafanaUI: true },
|
|
42
|
-
});
|
|
43
|
-
});
|
|
44
31
|
});
|
|
45
32
|
describe('Command: Update', () => {
|
|
46
33
|
beforeEach(() => {
|
|
@@ -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);
|
|
@@ -59,15 +59,7 @@ function readRCFileSync(path) {
|
|
|
59
59
|
}
|
|
60
60
|
function createFeatureFlags(flags) {
|
|
61
61
|
if (commandName === 'generate') {
|
|
62
|
-
|
|
63
|
-
if (argv.hasOwnProperty(flag)) {
|
|
64
|
-
return { ...acc, [flag]: argv[flag] };
|
|
65
|
-
}
|
|
66
|
-
else {
|
|
67
|
-
return { ...acc, [flag]: value };
|
|
68
|
-
}
|
|
69
|
-
}, {});
|
|
70
|
-
return flags;
|
|
62
|
+
return DEFAULT_FEATURE_FLAGS;
|
|
71
63
|
}
|
|
72
64
|
return flags ?? {};
|
|
73
65
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@grafana/create-plugin",
|
|
3
|
-
"version": "4.14.0
|
|
3
|
+
"version": "4.14.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": "732bf7759cc0b6b2b696b9ca4451a9a65a6b732e"
|
|
91
91
|
}
|
|
@@ -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,19 +35,6 @@ 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, useReactRouterV6: false, bundleGrafanaUI: true },
|
|
51
|
-
});
|
|
52
|
-
});
|
|
53
38
|
});
|
|
54
39
|
|
|
55
40
|
describe('Command: Update', () => {
|
|
@@ -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 = {
|
|
@@ -84,17 +84,9 @@ function readRCFileSync(path: string): CreatePluginConfig | undefined {
|
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
function createFeatureFlags(flags?: FeatureFlags): FeatureFlags {
|
|
87
|
-
//
|
|
87
|
+
// Default values for new scaffoldings
|
|
88
88
|
if (commandName === 'generate') {
|
|
89
|
-
|
|
90
|
-
if (argv.hasOwnProperty(flag)) {
|
|
91
|
-
return { ...acc, [flag]: argv[flag] };
|
|
92
|
-
} else {
|
|
93
|
-
return { ...acc, [flag]: value };
|
|
94
|
-
}
|
|
95
|
-
}, {} as FeatureFlags);
|
|
96
|
-
|
|
97
|
-
return flags;
|
|
89
|
+
return DEFAULT_FEATURE_FLAGS;
|
|
98
90
|
}
|
|
99
91
|
|
|
100
92
|
return flags ?? {};
|
|
@@ -29,6 +29,11 @@ export function getPluginJson() {
|
|
|
29
29
|
return require(path.resolve(process.cwd(), `${SOURCE_DIR}/plugin.json`));
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
+
export function getCPConfigVersion() {
|
|
33
|
+
const cprcJson = path.resolve(__dirname, '../', '.cprc.json');
|
|
34
|
+
return fs.existsSync(cprcJson) ? require(cprcJson).version : { version: 'unknown' };
|
|
35
|
+
}
|
|
36
|
+
|
|
32
37
|
export function hasReadme() {
|
|
33
38
|
return fs.existsSync(path.resolve(process.cwd(), SOURCE_DIR, 'README.md'));
|
|
34
39
|
}
|
|
@@ -11,12 +11,14 @@ import ForkTsCheckerWebpackPlugin from 'fork-ts-checker-webpack-plugin';
|
|
|
11
11
|
import LiveReloadPlugin from 'webpack-livereload-plugin';
|
|
12
12
|
import path from 'path';
|
|
13
13
|
import ReplaceInFileWebpackPlugin from 'replace-in-file-webpack-plugin';
|
|
14
|
-
import
|
|
14
|
+
import TerserPlugin from 'terser-webpack-plugin';
|
|
15
|
+
import { type Configuration, BannerPlugin } from 'webpack';
|
|
15
16
|
|
|
16
|
-
import { getPackageJson, getPluginJson, hasReadme, getEntries, isWSL } from './utils';
|
|
17
|
+
import { getPackageJson, getPluginJson, hasReadme, getEntries, isWSL, getCPConfigVersion } from './utils';
|
|
17
18
|
import { SOURCE_DIR, DIST_DIR } from './constants';
|
|
18
19
|
|
|
19
20
|
const pluginJson = getPluginJson();
|
|
21
|
+
const cpVersion = getCPConfigVersion();
|
|
20
22
|
|
|
21
23
|
const config = async (env): Promise<Configuration> => {
|
|
22
24
|
const baseConfig: Configuration = {
|
|
@@ -133,6 +135,19 @@ const config = async (env): Promise<Configuration> => {
|
|
|
133
135
|
],
|
|
134
136
|
},
|
|
135
137
|
|
|
138
|
+
optimization: {
|
|
139
|
+
minimize: Boolean(env.production),
|
|
140
|
+
minimizer: [
|
|
141
|
+
new TerserPlugin({
|
|
142
|
+
terserOptions: {
|
|
143
|
+
format: {
|
|
144
|
+
comments: (_, { type, value }) => type === 'comment2' && value.trim().startsWith('[create-plugin]'),
|
|
145
|
+
},
|
|
146
|
+
},
|
|
147
|
+
}),
|
|
148
|
+
],
|
|
149
|
+
},
|
|
150
|
+
|
|
136
151
|
output: {
|
|
137
152
|
clean: {
|
|
138
153
|
keep: new RegExp(`(.*?_(amd64|arm(64)?)(.exe)?|go_plugin_build_manifest)`),
|
|
@@ -147,6 +162,12 @@ const config = async (env): Promise<Configuration> => {
|
|
|
147
162
|
},
|
|
148
163
|
|
|
149
164
|
plugins: [
|
|
165
|
+
// Insert create plugin version information into the bundle
|
|
166
|
+
new BannerPlugin({
|
|
167
|
+
banner: "/* [create-plugin] version: " + cpVersion + " */",
|
|
168
|
+
raw: true,
|
|
169
|
+
entryOnly: true,
|
|
170
|
+
}),
|
|
150
171
|
new CopyWebpackPlugin({
|
|
151
172
|
patterns: [
|
|
152
173
|
// If src/README.md exists use it; otherwise the root README
|
package/templates/common/npmrc
CHANGED
|
@@ -9,6 +9,7 @@ public-hoist-pattern[]="*prettier*"
|
|
|
9
9
|
|
|
10
10
|
# Hoist all types packages to the root for better TS support
|
|
11
11
|
public-hoist-pattern[]="@types/*"
|
|
12
|
+
public-hoist-pattern[]="*terser-webpack-plugin*"
|
|
12
13
|
{{#unless usePlaywright}}
|
|
13
14
|
# @grafana/e2e expects cypress to exist in the root of the node_modules directory
|
|
14
15
|
public-hoist-pattern[]="*cypress*"{{/unless}}
|