@grafana/create-plugin 2.2.0-canary.455.9637001.0 โ†’ 2.2.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 CHANGED
@@ -1,3 +1,39 @@
1
+ # v2.2.0 (Tue Oct 17 2023)
2
+
3
+ #### ๐Ÿš€ Enhancement
4
+
5
+ - Create Plugin: Make sure scaffolded code is prettified [#461](https://github.com/grafana/plugin-tools/pull/461) ([@jackw](https://github.com/jackw))
6
+
7
+ #### Authors: 1
8
+
9
+ - Jack Westbrook ([@jackw](https://github.com/jackw))
10
+
11
+ ---
12
+
13
+ # v2.1.2 (Mon Oct 16 2023)
14
+
15
+ #### ๐Ÿ› Bug Fix
16
+
17
+ - Create Plugin: Prevent conflicting webpack runtimes [#464](https://github.com/grafana/plugin-tools/pull/464) ([@jackw](https://github.com/jackw))
18
+
19
+ #### Authors: 1
20
+
21
+ - Jack Westbrook ([@jackw](https://github.com/jackw))
22
+
23
+ ---
24
+
25
+ # v2.1.1 (Fri Oct 13 2023)
26
+
27
+ #### ๐Ÿ› Bug Fix
28
+
29
+ - Create Plugin: Format code under templates/common [#451](https://github.com/grafana/plugin-tools/pull/451) ([@zoltanbedi](https://github.com/zoltanbedi))
30
+
31
+ #### Authors: 1
32
+
33
+ - Zoltรกn Bedi ([@zoltanbedi](https://github.com/zoltanbedi))
34
+
35
+ ---
36
+
1
37
  # v2.1.0 (Fri Oct 13 2023)
2
38
 
3
39
  :tada: This release contains work from a new contributor! :tada:
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ var __importDefault = (this && this.__importDefault) || function (mod) {
39
+ return (mod && mod.__esModule) ? mod : { "default": mod };
40
+ };
41
+ Object.defineProperty(exports, "__esModule", { value: true });
42
+ exports.prettifyFiles = void 0;
43
+ var node_child_process_1 = require("node:child_process");
44
+ var node_util_1 = require("node:util");
45
+ var fs_1 = __importDefault(require("fs"));
46
+ var utils_path_1 = require("../../utils/utils.path");
47
+ var exec = (0, node_util_1.promisify)(node_child_process_1.exec);
48
+ function prettifyFiles(_a) {
49
+ var pluginName = _a.pluginName, orgName = _a.orgName, pluginType = _a.pluginType;
50
+ return __awaiter(this, void 0, void 0, function () {
51
+ var exportPath, command, error_1;
52
+ return __generator(this, function (_b) {
53
+ switch (_b.label) {
54
+ case 0:
55
+ exportPath = (0, utils_path_1.getExportPath)(pluginName, orgName, pluginType);
56
+ if (!fs_1.default.existsSync(exportPath)) {
57
+ return [2, ''];
58
+ }
59
+ _b.label = 1;
60
+ case 1:
61
+ _b.trys.push([1, 3, , 4]);
62
+ command = 'npx -y prettier@2 . --write';
63
+ return [4, exec(command, { cwd: exportPath })];
64
+ case 2:
65
+ _b.sent();
66
+ return [3, 4];
67
+ case 3:
68
+ error_1 = _b.sent();
69
+ throw new Error('There was a problem running prettier on the plugin files. Please run `npx -y prettier@2 . --write` manually in your plugin directory.');
70
+ case 4: return [2, 'Successfully ran prettier against new plugin.'];
71
+ }
72
+ });
73
+ });
74
+ }
75
+ exports.prettifyFiles = prettifyFiles;
@@ -32,10 +32,12 @@ var utils_path_1 = require("../utils/utils.path");
32
32
  var utils_packageManager_1 = require("../utils/utils.packageManager");
33
33
  var print_success_message_1 = require("./generate-actions/print-success-message");
34
34
  var update_go_sdk_and_packages_1 = require("./generate-actions/update-go-sdk-and-packages");
35
+ var prettify_files_1 = require("./generate-actions/prettify-files");
35
36
  function default_1(plop) {
36
37
  plop.setHelper('if_eq', utils_handlebars_1.ifEq);
37
38
  plop.setHelper('normalize_id', utils_handlebars_1.normalizeId);
38
39
  plop.setActionType('printSuccessMessage', print_success_message_1.printGenerateSuccessMessage);
40
+ plop.setActionType('prettifyFiles', prettify_files_1.prettifyFiles);
39
41
  plop.setActionType('updateGoSdkAndModules', update_go_sdk_and_packages_1.updateGoSdkAndModules);
40
42
  plop.setGenerator('create-plugin', {
41
43
  description: 'used to scaffold a grafana plugin',
@@ -107,7 +109,7 @@ function default_1(plop) {
107
109
  packageManagerInstallCmd: packageManagerInstallCmd,
108
110
  packageManagerVersion: packageManagerVersion,
109
111
  isAppType: isAppType,
110
- isNPM: packageManagerName === 'npm'
112
+ isNPM: packageManagerName === 'npm',
111
113
  };
112
114
  var commonActions = getActionsForTemplateFolder({
113
115
  folderPath: constants_1.TEMPLATE_PATHS.common,
@@ -150,6 +152,7 @@ function default_1(plop) {
150
152
  {
151
153
  type: 'updateGoSdkAndModules',
152
154
  },
155
+ { type: 'prettifyFiles' },
153
156
  {
154
157
  type: 'printSuccessMessage',
155
158
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@grafana/create-plugin",
3
- "version": "2.2.0-canary.455.9637001.0",
3
+ "version": "2.2.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": ">=18"
68
68
  },
69
- "gitHead": "9637001847838dfc4e26a67f84382309ff9c88f9"
69
+ "gitHead": "67123c677a1ecc23d0d83249b353bd2e467779e4"
70
70
  }
@@ -0,0 +1,25 @@
1
+ import { exec as nodeExec } from 'node:child_process';
2
+ import { promisify } from 'node:util';
3
+ import fs from 'fs';
4
+ import { getExportPath } from '../../utils/utils.path';
5
+ import { CliArgs } from '../types';
6
+
7
+ const exec = promisify(nodeExec);
8
+
9
+ export async function prettifyFiles({ pluginName, orgName, pluginType }: CliArgs) {
10
+ const exportPath = getExportPath(pluginName, orgName, pluginType);
11
+
12
+ if (!fs.existsSync(exportPath)) {
13
+ return '';
14
+ }
15
+
16
+ try {
17
+ let command = 'npx -y prettier@2 . --write';
18
+ await exec(command, { cwd: exportPath });
19
+ } catch (error) {
20
+ throw new Error(
21
+ 'There was a problem running prettier on the plugin files. Please run `npx -y prettier@2 . --write` manually in your plugin directory.'
22
+ );
23
+ }
24
+ return 'Successfully ran prettier against new plugin.';
25
+ }
@@ -8,6 +8,7 @@ import { getExportPath } from '../utils/utils.path';
8
8
  import { getPackageManagerInstallCmd, getPackageManagerFromUserAgent } from '../utils/utils.packageManager';
9
9
  import { printGenerateSuccessMessage } from './generate-actions/print-success-message';
10
10
  import { updateGoSdkAndModules } from './generate-actions/update-go-sdk-and-packages';
11
+ import { prettifyFiles } from './generate-actions/prettify-files';
11
12
  import { CliArgs, TemplateData } from './types';
12
13
 
13
14
  // Plopfile API documentation: https://plopjs.com/documentation/#plopfile-api
@@ -16,6 +17,7 @@ export default function (plop: NodePlopAPI) {
16
17
  plop.setHelper('normalize_id', normalizeId);
17
18
 
18
19
  plop.setActionType('printSuccessMessage', printGenerateSuccessMessage);
20
+ plop.setActionType('prettifyFiles', prettifyFiles);
19
21
  plop.setActionType('updateGoSdkAndModules', updateGoSdkAndModules);
20
22
 
21
23
  plop.setGenerator('create-plugin', {
@@ -95,7 +97,7 @@ export default function (plop: NodePlopAPI) {
95
97
  packageManagerInstallCmd,
96
98
  packageManagerVersion,
97
99
  isAppType,
98
- isNPM: packageManagerName === 'npm'
100
+ isNPM: packageManagerName === 'npm',
99
101
  };
100
102
  // Copy over files that are shared between plugins types
101
103
  const commonActions = getActionsForTemplateFolder({
@@ -159,6 +161,7 @@ export default function (plop: NodePlopAPI) {
159
161
  {
160
162
  type: 'updateGoSdkAndModules',
161
163
  },
164
+ { type: 'prettifyFiles' },
162
165
  {
163
166
  type: 'printSuccessMessage',
164
167
  },
@@ -4,7 +4,7 @@
4
4
  * In order to extend the configuration follow the steps in
5
5
  * https://grafana.com/developers/plugin-tools/create-a-plugin/extend-a-plugin/extend-configurations#extend-the-eslint-config
6
6
  */
7
- {
7
+ {
8
8
  "extends": ["@grafana/eslint-config"],
9
9
  "root": true,
10
10
  "rules": {
@@ -5,12 +5,12 @@
5
5
  */
6
6
 
7
7
  module.exports = {
8
- "endOfLine": "auto",
9
- "printWidth": 120,
10
- "trailingComma": "es5",
11
- "semi": true,
12
- "jsxSingleQuote": false,
13
- "singleQuote": true,
14
- "useTabs": false,
15
- "tabWidth": 2
16
- };
8
+ endOfLine: 'auto',
9
+ printWidth: 120,
10
+ trailingComma: 'es5',
11
+ semi: true,
12
+ jsxSingleQuote: false,
13
+ singleQuote: true,
14
+ useTabs: false,
15
+ tabWidth: 2,
16
+ };
@@ -4,7 +4,7 @@
4
4
  * In order to extend the configuration follow the steps in
5
5
  * https://grafana.com/developers/plugin-tools/create-a-plugin/extend-a-plugin/extend-configurations#extend-the-typescript-config
6
6
  */
7
- {
7
+ {
8
8
  "compilerOptions": {
9
9
  "alwaysStrict": true,
10
10
  "declaration": false,
@@ -2,11 +2,9 @@ import fs from 'fs';
2
2
  import process from 'process';
3
3
  import os from 'os';
4
4
  import path from 'path';
5
- import util from 'util';
6
5
  import { glob } from 'glob';
7
6
  import { SOURCE_DIR } from './constants';
8
7
 
9
-
10
8
  export function isWSL() {
11
9
  if (process.platform !== 'linux') {
12
10
  return false;
@@ -21,7 +19,7 @@ export function isWSL() {
21
19
  } catch {
22
20
  return false;
23
21
  }
24
- }
22
+ }
25
23
 
26
24
  export function getPackageJson() {
27
25
  return require(path.resolve(process.cwd(), 'package.json'));
@@ -40,7 +38,8 @@ export function hasReadme() {
40
38
  export async function getEntries(): Promise<Record<string, string>> {
41
39
  const pluginsJson = await glob('**/src/**/plugin.json', { absolute: true });
42
40
 
43
- const plugins = await Promise.all(pluginsJson.map((pluginJson) => {
41
+ const plugins = await Promise.all(
42
+ pluginsJson.map((pluginJson) => {
44
43
  const folder = path.dirname(pluginJson);
45
44
  return glob(`${folder}/module.{ts,tsx,js,jsx}`, { absolute: true });
46
45
  })
@@ -97,7 +97,7 @@ const config = async (env): Promise<Configuration> => {
97
97
  },
98
98
  {
99
99
  test: /\.css$/,
100
- use: ["style-loader", "css-loader"]
100
+ use: ['style-loader', 'css-loader'],
101
101
  },
102
102
  {
103
103
  test: /\.s[ac]ss$/,
@@ -136,6 +136,7 @@ const config = async (env): Promise<Configuration> => {
136
136
  },
137
137
  path: path.resolve(process.cwd(), DIST_DIR),
138
138
  publicPath: `public/plugins/${pluginJson.id}/`,
139
+ uniqueName: pluginJson.id,
139
140
  },
140
141
 
141
142
  plugins: [
@@ -207,7 +208,6 @@ const config = async (env): Promise<Configuration> => {
207
208
  }
208
209
 
209
210
  return baseConfig;
210
-
211
211
  };
212
212
 
213
213
  export default config;
@@ -1,3 +1,3 @@
1
1
  {
2
2
  "extends": "./.config/.eslintrc"
3
- }
3
+ }
@@ -1 +1 @@
1
- 16
1
+ 18
@@ -1,4 +1,4 @@
1
1
  module.exports = {
2
2
  // Prettier configuration provided by Grafana scaffolding
3
- ...require("./.config/.prettierrc.js")
4
- };
3
+ ...require('./.config/.prettierrc.js'),
4
+ };
@@ -2,4 +2,4 @@
2
2
 
3
3
  ## 1.0.0 (Unreleased)
4
4
 
5
- Initial release.
5
+ Initial release.
@@ -27,7 +27,7 @@
27
27
  "@swc/helpers": "^0.5.0",
28
28
  "@swc/jest": "^0.2.26",
29
29
  "@testing-library/jest-dom": "^5.16.5",
30
- "@testing-library/react": "14.0.0",
30
+ "@testing-library/react": "^12.1.4",
31
31
  "@types/jest": "^29.5.0",
32
32
  "@types/lodash": "^4.14.194",
33
33
  "@types/node": "^18.15.11",{{#if isAppType}}
@@ -57,15 +57,15 @@
57
57
  "node": ">=18"
58
58
  },
59
59
  "dependencies": {
60
- "@emotion/css": "11.10.6",
60
+ "@emotion/css": "^11.1.3",
61
61
  "@grafana/data": "{{ grafanaVersion }}",
62
62
  "@grafana/runtime": "{{ grafanaVersion }}",
63
63
  "@grafana/ui": "{{ grafanaVersion }}",{{#if_eq pluginType "scenesapp"}}
64
64
  "@grafana/schema": "{{ grafanaVersion }}",
65
65
  "@grafana/scenes": "0.27.0",{{/if_eq}}
66
- "react": "18.2.0",
67
- "react-dom": "18.2.0",{{#if isAppType}}
68
- "react-router-dom": "5.3.3",
66
+ "react": "17.0.2",
67
+ "react-dom": "17.0.2",{{#if isAppType}}
68
+ "react-router-dom": "^5.2.0",
69
69
  "rxjs": "7.8.0",{{/if}}
70
70
  "tslib": "2.5.3"
71
71
  },
@@ -1,3 +1,3 @@
1
1
  {
2
2
  "extends": "./.config/tsconfig.json"
3
- }
3
+ }