@grafana/create-plugin 4.14.0 → 4.15.0-canary.984.dbba404.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.
|
@@ -8,6 +8,7 @@ import { DEFAULT_FEATURE_FLAGS } from '../../constants.js';
|
|
|
8
8
|
const mocks = vi.hoisted(() => {
|
|
9
9
|
return {
|
|
10
10
|
commandName: 'generate',
|
|
11
|
+
argv: {},
|
|
11
12
|
};
|
|
12
13
|
});
|
|
13
14
|
vi.mock('../utils.cli.js', async () => mocks);
|
|
@@ -20,6 +21,7 @@ describe('getConfig', () => {
|
|
|
20
21
|
describe('Command: Generate', () => {
|
|
21
22
|
beforeEach(() => {
|
|
22
23
|
mocks.commandName = 'generate';
|
|
24
|
+
mocks.argv = {};
|
|
23
25
|
});
|
|
24
26
|
it('should give back a default config', async () => {
|
|
25
27
|
const config = getConfig(tmpDir);
|
|
@@ -28,6 +30,17 @@ describe('getConfig', () => {
|
|
|
28
30
|
features: DEFAULT_FEATURE_FLAGS,
|
|
29
31
|
});
|
|
30
32
|
});
|
|
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
|
+
});
|
|
31
44
|
});
|
|
32
45
|
describe('Command: Update', () => {
|
|
33
46
|
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 { commandName } from './utils.cli.js';
|
|
4
|
+
import { argv, 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,7 +59,15 @@ function readRCFileSync(path) {
|
|
|
59
59
|
}
|
|
60
60
|
function createFeatureFlags(flags) {
|
|
61
61
|
if (commandName === 'generate') {
|
|
62
|
-
|
|
62
|
+
const flags = Object.entries(DEFAULT_FEATURE_FLAGS).reduce((acc, [flag, value]) => {
|
|
63
|
+
if (argv.hasOwnProperty(flag)) {
|
|
64
|
+
return { ...acc, [flag]: argv[flag] };
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
return { ...acc, [flag]: value };
|
|
68
|
+
}
|
|
69
|
+
}, {});
|
|
70
|
+
return flags;
|
|
63
71
|
}
|
|
64
72
|
return flags ?? {};
|
|
65
73
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@grafana/create-plugin",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.15.0-canary.984.dbba404.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": "dbba404bbb705c8daf675fa82e19a3e197728bd6"
|
|
91
91
|
}
|
|
@@ -9,6 +9,7 @@ import { DEFAULT_FEATURE_FLAGS } from '../../constants.js';
|
|
|
9
9
|
const mocks = vi.hoisted(() => {
|
|
10
10
|
return {
|
|
11
11
|
commandName: 'generate',
|
|
12
|
+
argv: {},
|
|
12
13
|
};
|
|
13
14
|
});
|
|
14
15
|
|
|
@@ -25,6 +26,7 @@ describe('getConfig', () => {
|
|
|
25
26
|
describe('Command: Generate', () => {
|
|
26
27
|
beforeEach(() => {
|
|
27
28
|
mocks.commandName = 'generate';
|
|
29
|
+
mocks.argv = {};
|
|
28
30
|
});
|
|
29
31
|
|
|
30
32
|
it('should give back a default config', async () => {
|
|
@@ -35,6 +37,19 @@ describe('getConfig', () => {
|
|
|
35
37
|
features: DEFAULT_FEATURE_FLAGS,
|
|
36
38
|
});
|
|
37
39
|
});
|
|
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
|
+
});
|
|
38
53
|
});
|
|
39
54
|
|
|
40
55
|
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 { commandName } from './utils.cli.js';
|
|
4
|
+
import { argv, commandName } from './utils.cli.js';
|
|
5
5
|
import { DEFAULT_FEATURE_FLAGS } from '../constants.js';
|
|
6
6
|
|
|
7
7
|
export type FeatureFlags = {
|
|
@@ -84,9 +84,17 @@ function readRCFileSync(path: string): CreatePluginConfig | undefined {
|
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
function createFeatureFlags(flags?: FeatureFlags): FeatureFlags {
|
|
87
|
-
//
|
|
87
|
+
// For new scaffolds override any defaults with args passed in the CLI.
|
|
88
88
|
if (commandName === 'generate') {
|
|
89
|
-
|
|
89
|
+
const flags = Object.entries(DEFAULT_FEATURE_FLAGS).reduce((acc, [flag, value]) => {
|
|
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;
|
|
90
98
|
}
|
|
91
99
|
|
|
92
100
|
return flags ?? {};
|