@grafana/create-plugin 2.4.0 → 2.5.0-canary.500.3237c5a.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.
@@ -26,9 +26,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
26
26
  var fs_1 = __importDefault(require("fs"));
27
27
  var glob_1 = __importDefault(require("glob"));
28
28
  var path_1 = __importDefault(require("path"));
29
+ var minimist_1 = __importDefault(require("minimist"));
29
30
  var constants_1 = require("../constants");
30
31
  var utils_handlebars_1 = require("../utils/utils.handlebars");
31
32
  var utils_path_1 = require("../utils/utils.path");
33
+ var utils_version_1 = require("../utils/utils.version");
32
34
  var utils_packageManager_1 = require("../utils/utils.packageManager");
33
35
  var print_success_message_1 = require("./generate-actions/print-success-message");
34
36
  var update_go_sdk_and_packages_1 = require("./generate-actions/update-go-sdk-and-packages");
@@ -99,6 +101,8 @@ function default_1(plop) {
99
101
  ],
100
102
  actions: function (_a) {
101
103
  var pluginName = _a.pluginName, orgName = _a.orgName, pluginType = _a.pluginType, hasBackend = _a.hasBackend, hasGithubWorkflows = _a.hasGithubWorkflows, hasGithubLevitateWorkflow = _a.hasGithubLevitateWorkflow;
104
+ var args = process.argv.slice(2);
105
+ var argv = (0, minimist_1.default)(args);
102
106
  var exportPath = (0, utils_path_1.getExportPath)(pluginName, orgName, pluginType);
103
107
  var pluginId = (0, utils_handlebars_1.normalizeId)(pluginName, orgName, pluginType);
104
108
  var _b = (0, utils_packageManager_1.getPackageManagerFromUserAgent)(), packageManagerName = _b.packageManagerName, packageManagerVersion = _b.packageManagerVersion;
@@ -111,6 +115,8 @@ function default_1(plop) {
111
115
  packageManagerVersion: packageManagerVersion,
112
116
  isAppType: isAppType,
113
117
  isNPM: packageManagerName === 'npm',
118
+ createPluginVersion: (0, utils_version_1.getVersion)(),
119
+ shouldBundleGrafanaUI: Boolean(argv['experimental-bundle-grafana-ui']),
114
120
  };
115
121
  var commonActions = getActionsForTemplateFolder({
116
122
  folderPath: constants_1.TEMPLATE_PATHS.common,
@@ -37,12 +37,11 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
37
37
  };
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
39
  exports.version = void 0;
40
- var path_1 = require("path");
41
- var fs_1 = require("fs");
40
+ var utils_version_1 = require("../utils/utils.version");
42
41
  var version = function () { return __awaiter(void 0, void 0, void 0, function () {
43
42
  return __generator(this, function (_a) {
44
43
  try {
45
- console.log(getVersion());
44
+ console.log((0, utils_version_1.getVersion)());
46
45
  }
47
46
  catch (error) {
48
47
  console.error(error);
@@ -52,12 +51,3 @@ var version = function () { return __awaiter(void 0, void 0, void 0, function ()
52
51
  });
53
52
  }); };
54
53
  exports.version = version;
55
- var getVersion = function () {
56
- var packageJsonPath = (0, path_1.resolve)(__dirname, '..', '..', 'package.json');
57
- var pkg = (0, fs_1.readFileSync)(packageJsonPath, 'utf8');
58
- var version = JSON.parse(pkg).version;
59
- if (!version) {
60
- throw "Could not find the version of sign-plugin";
61
- }
62
- return version;
63
- };
@@ -33,7 +33,7 @@ var utils_handlebars_1 = require("./utils.handlebars");
33
33
  var utils_plugin_1 = require("./utils.plugin");
34
34
  var constants_1 = require("../constants");
35
35
  var utils_packageManager_1 = require("./utils.packageManager");
36
- var utils_files_2 = require("../utils/utils.files");
36
+ var utils_version_1 = require("./utils.version");
37
37
  function getTemplateFiles(pluginType, filter) {
38
38
  var commonFiles = glob_1.default.sync("".concat(constants_1.TEMPLATE_PATHS.common, "/**"), { dot: true });
39
39
  var pluginTypeSpecificFiles = glob_1.default.sync("".concat(constants_1.TEMPLATE_PATHS[pluginType], "/**"), { dot: true });
@@ -62,7 +62,7 @@ function compileSingleTemplateFile(pluginType, templateFile, data) {
62
62
  }
63
63
  var rendered = renderTemplateFromFile(templateFile, data);
64
64
  var relativeExportPath = templateFile.replace(constants_1.TEMPLATE_PATHS.common, '').replace(constants_1.TEMPLATE_PATHS[pluginType], '');
65
- var exportPath = path_1.default.join(constants_1.EXPORT_PATH_PREFIX, path_1.default.dirname(relativeExportPath), (0, utils_files_2.getExportFileName)(templateFile));
65
+ var exportPath = path_1.default.join(constants_1.EXPORT_PATH_PREFIX, path_1.default.dirname(relativeExportPath), (0, utils_files_1.getExportFileName)(templateFile));
66
66
  mkdirp_1.default.sync(path_1.default.dirname(exportPath));
67
67
  fs_1.default.writeFileSync(exportPath, rendered);
68
68
  }
@@ -75,6 +75,6 @@ function getTemplateData() {
75
75
  var _a, _b, _c;
76
76
  var pluginJson = (0, utils_plugin_1.getPluginJson)();
77
77
  var _d = (0, utils_packageManager_1.getPackageManagerWithFallback)(), packageManagerName = _d.packageManagerName, packageManagerVersion = _d.packageManagerVersion;
78
- return __assign(__assign({}, constants_1.EXTRA_TEMPLATE_VARIABLES), { pluginId: pluginJson.id, pluginName: pluginJson.name, pluginDescription: (_a = pluginJson.info) === null || _a === void 0 ? void 0 : _a.description, hasBackend: Boolean(pluginJson.backend), orgName: (_c = (_b = pluginJson.info) === null || _b === void 0 ? void 0 : _b.author) === null || _c === void 0 ? void 0 : _c.name, pluginType: pluginJson.type, packageManagerName: packageManagerName, packageManagerVersion: packageManagerVersion });
78
+ return __assign(__assign({}, constants_1.EXTRA_TEMPLATE_VARIABLES), { pluginId: pluginJson.id, pluginName: pluginJson.name, pluginDescription: (_a = pluginJson.info) === null || _a === void 0 ? void 0 : _a.description, hasBackend: Boolean(pluginJson.backend), orgName: (_c = (_b = pluginJson.info) === null || _b === void 0 ? void 0 : _b.author) === null || _c === void 0 ? void 0 : _c.name, pluginType: pluginJson.type, packageManagerName: packageManagerName, packageManagerVersion: packageManagerVersion, createPluginVersion: (0, utils_version_1.getVersion)() });
79
79
  }
80
80
  exports.getTemplateData = getTemplateData;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getVersion = void 0;
4
+ var path_1 = require("path");
5
+ var fs_1 = require("fs");
6
+ var getVersion = function () {
7
+ var packageJsonPath = (0, path_1.resolve)(__dirname, '..', '..', 'package.json');
8
+ var pkg = (0, fs_1.readFileSync)(packageJsonPath, 'utf8');
9
+ var version = JSON.parse(pkg).version;
10
+ if (!version) {
11
+ throw "Could not find the version of create-plugin";
12
+ }
13
+ return version;
14
+ };
15
+ exports.getVersion = getVersion;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@grafana/create-plugin",
3
- "version": "2.4.0",
3
+ "version": "2.5.0-canary.500.3237c5a.0",
4
4
  "main": "index.js",
5
5
  "repository": {
6
6
  "directory": "packages/create-plugin",
@@ -66,5 +66,5 @@
66
66
  "engines": {
67
67
  "node": ">=20"
68
68
  },
69
- "gitHead": "534ad78e12d1fd0c371f7659c3c3084ec31bb3c0"
69
+ "gitHead": "3237c5ae589428f6f5de0418aeda1bb8cf709c67"
70
70
  }
@@ -1,10 +1,12 @@
1
1
  import fs from 'fs';
2
2
  import glob from 'glob';
3
3
  import path from 'path';
4
+ import minimist from 'minimist';
4
5
  import type { ModifyActionConfig, NodePlopAPI } from 'plop';
5
6
  import { EXTRA_TEMPLATE_VARIABLES, IS_DEV, PARTIALS_DIR, PLUGIN_TYPES, TEMPLATE_PATHS } from '../constants';
6
7
  import { ifEq, normalizeId } from '../utils/utils.handlebars';
7
8
  import { getExportPath } from '../utils/utils.path';
9
+ import { getVersion } from '../utils/utils.version';
8
10
  import { getPackageManagerInstallCmd, getPackageManagerFromUserAgent } from '../utils/utils.packageManager';
9
11
  import { printGenerateSuccessMessage } from './generate-actions/print-success-message';
10
12
  import { updateGoSdkAndModules } from './generate-actions/update-go-sdk-and-packages';
@@ -86,6 +88,8 @@ export default function (plop: NodePlopAPI) {
86
88
  hasGithubWorkflows,
87
89
  hasGithubLevitateWorkflow,
88
90
  }: CliArgs) {
91
+ const args = process.argv.slice(2);
92
+ const argv = minimist(args);
89
93
  const exportPath = getExportPath(pluginName, orgName, pluginType);
90
94
  const pluginId = normalizeId(pluginName, orgName, pluginType);
91
95
  // Support the users package manager of choice.
@@ -99,6 +103,8 @@ export default function (plop: NodePlopAPI) {
99
103
  packageManagerVersion,
100
104
  isAppType,
101
105
  isNPM: packageManagerName === 'npm',
106
+ createPluginVersion: getVersion(),
107
+ shouldBundleGrafanaUI: Boolean(argv['experimental-bundle-grafana-ui']),
102
108
  };
103
109
  // Copy over files that are shared between plugins types
104
110
  const commonActions = getActionsForTemplateFolder({
@@ -17,4 +17,6 @@ export type TemplateData = {
17
17
  packageManagerVersion: string;
18
18
  isAppType: boolean;
19
19
  isNPM: boolean;
20
+ createPluginVersion: string;
21
+ shouldBundleGrafanaUI: boolean;
20
22
  };
@@ -1,5 +1,4 @@
1
- import { resolve } from 'path';
2
- import { readFileSync } from 'fs';
1
+ import { getVersion } from '../utils/utils.version';
3
2
 
4
3
  export const version = async () => {
5
4
  try {
@@ -9,13 +8,3 @@ export const version = async () => {
9
8
  process.exit(1);
10
9
  }
11
10
  };
12
-
13
- const getVersion = () => {
14
- const packageJsonPath = resolve(__dirname, '..', '..', 'package.json');
15
- const pkg = readFileSync(packageJsonPath, 'utf8');
16
- const { version } = JSON.parse(pkg);
17
- if (!version) {
18
- throw `Could not find the version of sign-plugin`;
19
- }
20
- return version;
21
- };
@@ -2,12 +2,12 @@ import glob from 'glob';
2
2
  import path from 'path';
3
3
  import fs from 'fs';
4
4
  import mkdirp from 'mkdirp';
5
- import { filterOutCommonFiles, isFile, isFileStartingWith } from './utils.files';
5
+ import { filterOutCommonFiles, getExportFileName, isFile, isFileStartingWith } from './utils.files';
6
6
  import { renderHandlebarsTemplate } from './utils.handlebars';
7
7
  import { getPluginJson } from './utils.plugin';
8
8
  import { TEMPLATE_PATHS, EXPORT_PATH_PREFIX, EXTRA_TEMPLATE_VARIABLES } from '../constants';
9
9
  import { getPackageManagerWithFallback } from './utils.packageManager';
10
- import { getExportFileName } from '../utils/utils.files';
10
+ import { getVersion } from './utils.version';
11
11
 
12
12
  /**
13
13
  *
@@ -77,5 +77,6 @@ export function getTemplateData() {
77
77
  pluginType: pluginJson.type,
78
78
  packageManagerName,
79
79
  packageManagerVersion,
80
+ createPluginVersion: getVersion(),
80
81
  };
81
82
  }
@@ -0,0 +1,12 @@
1
+ import { resolve } from 'path';
2
+ import { readFileSync } from 'fs';
3
+
4
+ export const getVersion = () => {
5
+ const packageJsonPath = resolve(__dirname, '..', '..', 'package.json');
6
+ const pkg = readFileSync(packageJsonPath, 'utf8');
7
+ const { version } = JSON.parse(pkg);
8
+ if (!version) {
9
+ throw `Could not find the version of create-plugin`;
10
+ }
11
+ return version;
12
+ };
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": "{{ createPluginVersion }}",
3
+ "config": {
4
+ "bundleGrafanaUi": "{{ shouldBundleGrafanaUI }}"
5
+ }
6
+ }
@@ -52,10 +52,12 @@ const config = async (env): Promise<Configuration> => {
52
52
  'react-router',
53
53
  'react-router-dom',
54
54
  'd3',
55
- 'angular',
56
- '@grafana/ui',
55
+ 'angular',{{#unless shouldBundleGrafanaUI}}
56
+ '@grafana/ui',{{/unless}}
57
57
  '@grafana/runtime',
58
- '@grafana/data',
58
+ '@grafana/data',{{#if shouldBundleGrafanaUI}}
59
+ 'react-inlinesvg',
60
+ 'i18next',{{/if}}
59
61
 
60
62
  // Mark legacy SDK imports as external if their name starts with the "grafana/" prefix
61
63
  ({ request }, callback) => {
@@ -1 +1 @@
1
- 18
1
+ 20