@grafana/create-plugin 4.13.0 → 4.14.0-canary.970.e321735.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/commands/update.command.js +2 -3
- package/dist/constants.js +0 -1
- package/dist/utils/utils.templates.js +2 -2
- package/dist/utils/utils.version.js +8 -1
- package/fixtures/test-template/src/plugin.json +1 -1
- package/package.json +2 -2
- package/src/commands/update.command.ts +2 -3
- package/src/constants.ts +0 -2
- package/src/utils/utils.templates.ts +2 -2
- package/src/utils/utils.version.ts +9 -1
- package/templates/app/src/plugin.json +1 -1
- package/templates/backend/src/datasource.ts +1 -1
- package/templates/common/.config/webpack/utils.ts +5 -0
- package/templates/common/.config/webpack/webpack.config.ts +23 -2
- package/templates/common/_package.json +7 -7
- package/templates/common/docker-compose.yaml +1 -1
- package/templates/common/npmrc +1 -0
- package/templates/datasource/src/plugin.json +1 -1
- package/templates/panel/src/plugin.json +1 -1
- package/templates/scenes-app/src/plugin.json +1 -1
|
@@ -3,8 +3,7 @@ import { printRedBox, printBlueBox } from '../utils/utils.console.js';
|
|
|
3
3
|
import { updatePackageJson, updateNpmScripts } from '../utils/utils.npm.js';
|
|
4
4
|
import { isGitDirectory, isGitDirectoryClean } from '../utils/utils.git.js';
|
|
5
5
|
import { isPluginDirectory, updateDotConfigFolder } from '../utils/utils.plugin.js';
|
|
6
|
-
import {
|
|
7
|
-
import { getVersion } from '../utils/utils.version.js';
|
|
6
|
+
import { getVersion, getGrafanaRuntimeVersion } from '../utils/utils.version.js';
|
|
8
7
|
import { getPackageManagerFromUserAgent } from '../utils/utils.packageManager.js';
|
|
9
8
|
export const update = async (argv) => {
|
|
10
9
|
const { packageManagerName } = getPackageManagerFromUserAgent();
|
|
@@ -43,7 +42,7 @@ In case you want to proceed as is please use the ${chalk.bold('--force')} flag.)
|
|
|
43
42
|
});
|
|
44
43
|
printBlueBox({
|
|
45
44
|
title: 'Update successful ✔',
|
|
46
|
-
content: `${chalk.bold('@grafana/* package version:')} ${
|
|
45
|
+
content: `${chalk.bold('@grafana/* package version:')} ${getGrafanaRuntimeVersion()}
|
|
47
46
|
${chalk.bold('@grafana/create-plugin version:')} ${getVersion()}
|
|
48
47
|
|
|
49
48
|
${chalk.bold.underline('Next steps:')}
|
package/dist/constants.js
CHANGED
|
@@ -28,7 +28,6 @@ export var PLUGIN_TYPES;
|
|
|
28
28
|
PLUGIN_TYPES["scenes"] = "scenesapp";
|
|
29
29
|
})(PLUGIN_TYPES || (PLUGIN_TYPES = {}));
|
|
30
30
|
export const EXTRA_TEMPLATE_VARIABLES = {
|
|
31
|
-
grafanaVersion: '10.3.3',
|
|
32
31
|
grafanaImage: 'grafana-enterprise',
|
|
33
32
|
};
|
|
34
33
|
export const DEFAULT_FEATURE_FLAGS = {
|
|
@@ -10,7 +10,7 @@ import { getPluginJson } from './utils.plugin.js';
|
|
|
10
10
|
import { TEMPLATE_PATHS, EXPORT_PATH_PREFIX, EXTRA_TEMPLATE_VARIABLES, PLUGIN_TYPES, DEFAULT_FEATURE_FLAGS, } from '../constants.js';
|
|
11
11
|
import { getPackageManagerInstallCmd, getPackageManagerWithFallback, getPackageManagerFromUserAgent, } from './utils.packageManager.js';
|
|
12
12
|
import { getExportFileName } from '../utils/utils.files.js';
|
|
13
|
-
import { getVersion } from './utils.version.js';
|
|
13
|
+
import { getGrafanaRuntimeVersion, getVersion } from './utils.version.js';
|
|
14
14
|
import { getConfig } from './utils.config.js';
|
|
15
15
|
const debug = createDebug('templates');
|
|
16
16
|
export function getTemplateFiles(pluginType, filter) {
|
|
@@ -58,7 +58,7 @@ export function renderTemplateFromFile(templateFile, data) {
|
|
|
58
58
|
export function getTemplateData(cliArgs) {
|
|
59
59
|
const { features } = getConfig();
|
|
60
60
|
const currentVersion = getVersion();
|
|
61
|
-
const grafanaVersion =
|
|
61
|
+
const grafanaVersion = getGrafanaRuntimeVersion();
|
|
62
62
|
const usePlaywright = features.usePlaywright === true || isFile(path.join(process.cwd(), 'playwright.config.ts'));
|
|
63
63
|
const useCypress = !usePlaywright && semverLt(grafanaVersion, '11.0.0') && fs.existsSync(path.join(process.cwd(), 'cypress'));
|
|
64
64
|
const bundleGrafanaUI = features.bundleGrafanaUI ?? DEFAULT_FEATURE_FLAGS.bundleGrafanaUI;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { readFileSync } from 'node:fs';
|
|
2
|
-
import { resolve } from 'node:path';
|
|
2
|
+
import path, { resolve } from 'node:path';
|
|
3
3
|
import { fileURLToPath } from 'node:url';
|
|
4
|
+
import { TEMPLATE_PATHS } from '../constants.js';
|
|
4
5
|
const __dirname = fileURLToPath(new URL('.', import.meta.url));
|
|
5
6
|
export function getVersion() {
|
|
6
7
|
const packageJsonPath = resolve(__dirname, '..', '..', 'package.json');
|
|
@@ -11,3 +12,9 @@ export function getVersion() {
|
|
|
11
12
|
}
|
|
12
13
|
return version;
|
|
13
14
|
}
|
|
15
|
+
export function getGrafanaRuntimeVersion() {
|
|
16
|
+
const packageJsonPath = path.join(TEMPLATE_PATHS.common, '_package.json');
|
|
17
|
+
const pkg = readFileSync(packageJsonPath, 'utf8');
|
|
18
|
+
const { version } = /\"(@grafana\/runtime)\":\s\"\^(?<version>.*)\"/.exec(pkg)?.groups ?? {};
|
|
19
|
+
return version;
|
|
20
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@grafana/create-plugin",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.14.0-canary.970.e321735.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": "e321735191a4937a1dae824ec38d8e505c5eddbb"
|
|
91
91
|
}
|
|
@@ -4,8 +4,7 @@ import { printRedBox, printBlueBox } from '../utils/utils.console.js';
|
|
|
4
4
|
import { updatePackageJson, updateNpmScripts } from '../utils/utils.npm.js';
|
|
5
5
|
import { isGitDirectory, isGitDirectoryClean } from '../utils/utils.git.js';
|
|
6
6
|
import { isPluginDirectory, updateDotConfigFolder } from '../utils/utils.plugin.js';
|
|
7
|
-
import {
|
|
8
|
-
import { getVersion } from '../utils/utils.version.js';
|
|
7
|
+
import { getVersion, getGrafanaRuntimeVersion } from '../utils/utils.version.js';
|
|
9
8
|
import { getPackageManagerFromUserAgent } from '../utils/utils.packageManager.js';
|
|
10
9
|
|
|
11
10
|
export const update = async (argv: minimist.ParsedArgs) => {
|
|
@@ -57,7 +56,7 @@ In case you want to proceed as is please use the ${chalk.bold('--force')} flag.)
|
|
|
57
56
|
|
|
58
57
|
printBlueBox({
|
|
59
58
|
title: 'Update successful ✔',
|
|
60
|
-
content: `${chalk.bold('@grafana/* package version:')} ${
|
|
59
|
+
content: `${chalk.bold('@grafana/* package version:')} ${getGrafanaRuntimeVersion()}
|
|
61
60
|
${chalk.bold('@grafana/create-plugin version:')} ${getVersion()}
|
|
62
61
|
|
|
63
62
|
${chalk.bold.underline('Next steps:')}
|
package/src/constants.ts
CHANGED
|
@@ -41,9 +41,7 @@ export enum PLUGIN_TYPES {
|
|
|
41
41
|
|
|
42
42
|
// This gets merged into variables coming from user prompts (when scaffolding) or any other dynamic variables,
|
|
43
43
|
// and will be available to use in the templates.
|
|
44
|
-
// Example: "@grafana/ui": "{{ grafanaVersion }}"
|
|
45
44
|
export const EXTRA_TEMPLATE_VARIABLES = {
|
|
46
|
-
grafanaVersion: '10.3.3',
|
|
47
45
|
grafanaImage: 'grafana-enterprise',
|
|
48
46
|
};
|
|
49
47
|
|
|
@@ -21,7 +21,7 @@ import {
|
|
|
21
21
|
getPackageManagerFromUserAgent,
|
|
22
22
|
} from './utils.packageManager.js';
|
|
23
23
|
import { getExportFileName } from '../utils/utils.files.js';
|
|
24
|
-
import { getVersion } from './utils.version.js';
|
|
24
|
+
import { getGrafanaRuntimeVersion, getVersion } from './utils.version.js';
|
|
25
25
|
import { getConfig } from './utils.config.js';
|
|
26
26
|
|
|
27
27
|
const debug = createDebug('templates');
|
|
@@ -96,7 +96,7 @@ export function renderTemplateFromFile(templateFile: string, data?: any) {
|
|
|
96
96
|
export function getTemplateData(cliArgs?: GenerateCliArgs): TemplateData {
|
|
97
97
|
const { features } = getConfig();
|
|
98
98
|
const currentVersion = getVersion();
|
|
99
|
-
const grafanaVersion =
|
|
99
|
+
const grafanaVersion = getGrafanaRuntimeVersion();
|
|
100
100
|
const usePlaywright = features.usePlaywright === true || isFile(path.join(process.cwd(), 'playwright.config.ts'));
|
|
101
101
|
//@grafana/e2e was deprecated in Grafana 11
|
|
102
102
|
const useCypress =
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { readFileSync } from 'node:fs';
|
|
2
|
-
import { resolve } from 'node:path';
|
|
2
|
+
import path, { resolve } from 'node:path';
|
|
3
3
|
import { fileURLToPath } from 'node:url';
|
|
4
|
+
import { TEMPLATE_PATHS } from '../constants.js';
|
|
4
5
|
|
|
5
6
|
const __dirname = fileURLToPath(new URL('.', import.meta.url));
|
|
6
7
|
|
|
@@ -13,3 +14,10 @@ export function getVersion(): string {
|
|
|
13
14
|
}
|
|
14
15
|
return version;
|
|
15
16
|
}
|
|
17
|
+
|
|
18
|
+
export function getGrafanaRuntimeVersion() {
|
|
19
|
+
const packageJsonPath = path.join(TEMPLATE_PATHS.common, '_package.json');
|
|
20
|
+
const pkg = readFileSync(packageJsonPath, 'utf8');
|
|
21
|
+
const { version } = /\"(@grafana\/runtime)\":\s\"\^(?<version>.*)\"/.exec(pkg)?.groups ?? {};
|
|
22
|
+
return version;
|
|
23
|
+
}
|
|
@@ -12,7 +12,7 @@ export class DataSource extends DataSourceWithBackend<MyQuery, MyDataSourceOptio
|
|
|
12
12
|
return DEFAULT_QUERY;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
applyTemplateVariables(query: MyQuery, scopedVars: ScopedVars)
|
|
15
|
+
applyTemplateVariables(query: MyQuery, scopedVars: ScopedVars) {
|
|
16
16
|
return {
|
|
17
17
|
...query,
|
|
18
18
|
queryText: getTemplateSrv().replace(query.queryText, scopedVars),
|
|
@@ -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
|
|
@@ -20,10 +20,10 @@
|
|
|
20
20
|
"license": "Apache-2.0",
|
|
21
21
|
"devDependencies": {
|
|
22
22
|
"@babel/core": "^7.21.4",{{#if useCypress}}
|
|
23
|
-
"@grafana/e2e": "
|
|
24
|
-
"@grafana/e2e-selectors": "
|
|
23
|
+
"@grafana/e2e": "^10.4.0",
|
|
24
|
+
"@grafana/e2e-selectors": "^10.4.0",{{/if}}
|
|
25
25
|
"@grafana/eslint-config": "^7.0.0",{{#if usePlaywright}}
|
|
26
|
-
"@grafana/plugin-e2e": "1.2.0",{{/if}}
|
|
26
|
+
"@grafana/plugin-e2e": "^1.2.0",{{/if}}
|
|
27
27
|
"@grafana/tsconfig": "^1.2.0-rc1",{{#if usePlaywright}}
|
|
28
28
|
"@playwright/test": "^1.41.2",{{/if}}
|
|
29
29
|
"@swc/core": "^1.3.90",
|
|
@@ -63,10 +63,10 @@
|
|
|
63
63
|
},
|
|
64
64
|
"dependencies": {
|
|
65
65
|
"@emotion/css": "11.10.6",
|
|
66
|
-
"@grafana/data": "
|
|
67
|
-
"@grafana/runtime": "
|
|
68
|
-
"@grafana/ui": "
|
|
69
|
-
"@grafana/schema": "
|
|
66
|
+
"@grafana/data": "^10.4.0",
|
|
67
|
+
"@grafana/runtime": "^10.4.0",
|
|
68
|
+
"@grafana/ui": "^10.4.0",
|
|
69
|
+
"@grafana/schema": "^10.4.0",{{#if_eq pluginType "scenesapp"}}
|
|
70
70
|
"@grafana/scenes": "^3.6.0",{{/if_eq}}
|
|
71
71
|
"react": "18.2.0",
|
|
72
72
|
"react-dom": "18.2.0",{{#if isAppType}}
|
|
@@ -8,7 +8,7 @@ services:
|
|
|
8
8
|
context: ./.config
|
|
9
9
|
args:
|
|
10
10
|
grafana_image: ${GRAFANA_IMAGE:-{{~grafanaImage~}} }
|
|
11
|
-
grafana_version: ${GRAFANA_VERSION:-
|
|
11
|
+
grafana_version: ${GRAFANA_VERSION:-10.4.0}
|
|
12
12
|
development: ${DEVELOPMENT:-false}
|
|
13
13
|
ports:
|
|
14
14
|
- 3000:3000/tcp
|
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}}
|