@grafana/create-plugin 6.8.0-canary.2356.20815895884.0 → 6.8.0-canary.2356.20816081919.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/dist/constants.js CHANGED
@@ -30,6 +30,7 @@ const EXTRA_TEMPLATE_VARIABLES = {
30
30
  grafanaImage: "grafana-enterprise"
31
31
  };
32
32
  const DEFAULT_FEATURE_FLAGS = {
33
+ bundleGrafanaUI: false,
33
34
  useExperimentalRspack: false,
34
35
  useExperimentalUpdates: true
35
36
  };
@@ -1,4 +1,4 @@
1
- import { EXTRA_TEMPLATE_VARIABLES, PLUGIN_TYPES, TEMPLATE_PATHS, EXPORT_PATH_PREFIX } from '../constants.js';
1
+ import { DEFAULT_FEATURE_FLAGS, EXTRA_TEMPLATE_VARIABLES, PLUGIN_TYPES, TEMPLATE_PATHS, EXPORT_PATH_PREFIX } from '../constants.js';
2
2
  import { isFile, getExportFileName, filterOutCommonFiles, isFileStartingWith } from './utils.files.js';
3
3
  import { getPackageManagerFromUserAgent, getPackageManagerInstallCmd, getPackageManagerWithFallback } from './utils.packageManager.js';
4
4
  import { normalizeId, renderHandlebarsTemplate } from './utils.handlebars.js';
@@ -56,6 +56,7 @@ function renderTemplateFromFile(templateFile, data) {
56
56
  function getTemplateData(cliArgs) {
57
57
  const { features } = getConfig();
58
58
  const currentVersion = CURRENT_APP_VERSION;
59
+ const bundleGrafanaUI = features.bundleGrafanaUI ?? DEFAULT_FEATURE_FLAGS.bundleGrafanaUI;
59
60
  const isAppType = (pluginType) => pluginType === PLUGIN_TYPES.app || pluginType === PLUGIN_TYPES.scenes;
60
61
  const isNPM = (packageManagerName) => packageManagerName === "npm";
61
62
  const frontendBundler = features.useExperimentalRspack ? "rspack" : "webpack";
@@ -76,6 +77,7 @@ function getTemplateData(cliArgs) {
76
77
  isAppType: isAppType(cliArgs.pluginType),
77
78
  isNPM: isNPM(packageManagerName),
78
79
  version: currentVersion,
80
+ bundleGrafanaUI,
79
81
  scenesVersion: "^6.10.4",
80
82
  useExperimentalRspack: Boolean(features.useExperimentalRspack),
81
83
  frontendBundler
@@ -96,6 +98,7 @@ function getTemplateData(cliArgs) {
96
98
  isAppType: isAppType(pluginJson.type),
97
99
  isNPM: isNPM(packageManagerName),
98
100
  version: currentVersion,
101
+ bundleGrafanaUI,
99
102
  scenesVersion: "^6.10.4",
100
103
  pluginExecutable: pluginJson.executable,
101
104
  useExperimentalRspack: Boolean(features.useExperimentalRspack),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@grafana/create-plugin",
3
- "version": "6.8.0-canary.2356.20815895884.0",
3
+ "version": "6.8.0-canary.2356.20816081919.0",
4
4
  "repository": {
5
5
  "directory": "packages/create-plugin",
6
6
  "url": "https://github.com/grafana/plugin-tools"
@@ -55,5 +55,5 @@
55
55
  "engines": {
56
56
  "node": ">=20"
57
57
  },
58
- "gitHead": "1aaf622fe62c06dcbbb9552d3e1d2432d3bd07ce"
58
+ "gitHead": "93dbf84ed95b0b6d5104208108651a3abff726d6"
59
59
  }
package/src/constants.ts CHANGED
@@ -49,6 +49,7 @@ export const EXTRA_TEMPLATE_VARIABLES = {
49
49
  };
50
50
 
51
51
  export const DEFAULT_FEATURE_FLAGS = {
52
+ bundleGrafanaUI: false,
52
53
  useExperimentalRspack: false,
53
54
  useExperimentalUpdates: true,
54
55
  };
package/src/types.ts CHANGED
@@ -21,6 +21,7 @@ export type TemplateData = {
21
21
  isAppType: boolean;
22
22
  isNPM: boolean;
23
23
  version: string;
24
+ bundleGrafanaUI: boolean;
24
25
  scenesVersion: string;
25
26
  useExperimentalRspack: boolean;
26
27
  pluginExecutable?: string;
@@ -46,13 +46,13 @@ describe('getConfig', () => {
46
46
 
47
47
  it('should override default feature flags via cli args', async () => {
48
48
  mocks.argv = {
49
- 'feature-flags': 'useExperimentalRspack',
49
+ 'feature-flags': 'bundleGrafanaUI',
50
50
  };
51
51
  const config = getConfig(tmpDir);
52
52
 
53
53
  expect(config).toEqual({
54
54
  version: CURRENT_APP_VERSION,
55
- features: { ...DEFAULT_FEATURE_FLAGS, useExperimentalRspack: true },
55
+ features: { ...DEFAULT_FEATURE_FLAGS, bundleGrafanaUI: true },
56
56
  });
57
57
  });
58
58
  });
@@ -94,7 +94,7 @@ describe('getConfig', () => {
94
94
  const userConfigPath = path.join(tmpDir, '.cprc.json');
95
95
  const userConfig: UserConfig = {
96
96
  features: {
97
- useExperimentalRspack: true,
97
+ bundleGrafanaUI: true,
98
98
  },
99
99
  };
100
100
 
@@ -107,5 +107,27 @@ describe('getConfig', () => {
107
107
  features: userConfig.features,
108
108
  });
109
109
  });
110
+
111
+ it('should give back the correct config when config files exist', async () => {
112
+ const rootConfigPath = path.join(tmpDir, '.config', '.cprc.json');
113
+ const userConfigPath = path.join(tmpDir, '.cprc.json');
114
+ const rootConfig: CreatePluginConfig = {
115
+ version: '1.0.0',
116
+ features: {},
117
+ };
118
+ const userConfig: UserConfig = {
119
+ features: {
120
+ bundleGrafanaUI: false,
121
+ },
122
+ };
123
+
124
+ await fs.mkdir(path.dirname(rootConfigPath), { recursive: true });
125
+ await fs.writeFile(rootConfigPath, JSON.stringify(rootConfig));
126
+ await fs.writeFile(userConfigPath, JSON.stringify(userConfig));
127
+
128
+ const config = getConfig(tmpDir);
129
+
130
+ expect(config).toEqual({ ...rootConfig, ...userConfig });
131
+ });
110
132
  });
111
133
  });
@@ -10,6 +10,7 @@ import { writeFile } from 'node:fs/promises';
10
10
  import { EOL } from 'node:os';
11
11
 
12
12
  export type FeatureFlags = {
13
+ bundleGrafanaUI?: boolean;
13
14
  useExperimentalRspack?: boolean;
14
15
  useExperimentalUpdates?: boolean;
15
16
  };
@@ -1,4 +1,10 @@
1
- import { EXPORT_PATH_PREFIX, EXTRA_TEMPLATE_VARIABLES, PLUGIN_TYPES, TEMPLATE_PATHS } from '../constants.js';
1
+ import {
2
+ DEFAULT_FEATURE_FLAGS,
3
+ EXPORT_PATH_PREFIX,
4
+ EXTRA_TEMPLATE_VARIABLES,
5
+ PLUGIN_TYPES,
6
+ TEMPLATE_PATHS,
7
+ } from '../constants.js';
2
8
  import { GenerateCliArgs, TemplateData } from '../types.js';
3
9
  import { filterOutCommonFiles, isFile, isFileStartingWith } from './utils.files.js';
4
10
  import {
@@ -89,6 +95,7 @@ export function renderTemplateFromFile(templateFile: string, data?: any) {
89
95
  export function getTemplateData(cliArgs?: GenerateCliArgs): TemplateData {
90
96
  const { features } = getConfig();
91
97
  const currentVersion = CURRENT_APP_VERSION;
98
+ const bundleGrafanaUI = features.bundleGrafanaUI ?? DEFAULT_FEATURE_FLAGS.bundleGrafanaUI;
92
99
  const isAppType = (pluginType: string) => pluginType === PLUGIN_TYPES.app || pluginType === PLUGIN_TYPES.scenes;
93
100
  const isNPM = (packageManagerName: string) => packageManagerName === 'npm';
94
101
  const frontendBundler = features.useExperimentalRspack ? 'rspack' : 'webpack';
@@ -113,6 +120,7 @@ export function getTemplateData(cliArgs?: GenerateCliArgs): TemplateData {
113
120
  isAppType: isAppType(cliArgs.pluginType),
114
121
  isNPM: isNPM(packageManagerName),
115
122
  version: currentVersion,
123
+ bundleGrafanaUI,
116
124
  scenesVersion: '^6.10.4',
117
125
  useExperimentalRspack: Boolean(features.useExperimentalRspack),
118
126
  frontendBundler,
@@ -136,6 +144,7 @@ export function getTemplateData(cliArgs?: GenerateCliArgs): TemplateData {
136
144
  isAppType: isAppType(pluginJson.type),
137
145
  isNPM: isNPM(packageManagerName),
138
146
  version: currentVersion,
147
+ bundleGrafanaUI,
139
148
  scenesVersion: '^6.10.4',
140
149
  pluginExecutable: pluginJson.executable,
141
150
  useExperimentalRspack: Boolean(features.useExperimentalRspack),
@@ -1,5 +1,6 @@
1
1
  {
2
2
  "features": {
3
+ "bundleGrafanaUI": {{ bundleGrafanaUI }},
3
4
  "useExperimentalRspack": {{ useExperimentalRspack }}
4
5
  }
5
6
  }