@grafana/create-plugin 2.3.0-canary.478.898d286.0 → 2.3.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,50 @@
1
+ # v2.3.0 (Tue Oct 24 2023)
2
+
3
+ #### 🚀 Enhancement
4
+
5
+ - Bump to node 20 [#478](https://github.com/grafana/plugin-tools/pull/478) ([@tolzhabayev](https://github.com/tolzhabayev))
6
+
7
+ #### 🐛 Bug Fix
8
+
9
+ - Create Plugin: Fix wrongly named files when upgrading/migrating [#490](https://github.com/grafana/plugin-tools/pull/490) ([@jackw](https://github.com/jackw))
10
+
11
+ #### Authors: 2
12
+
13
+ - Jack Westbrook ([@jackw](https://github.com/jackw))
14
+ - Timur Olzhabayev ([@tolzhabayev](https://github.com/tolzhabayev))
15
+
16
+ ---
17
+
18
+ # v2.2.2 (Mon Oct 23 2023)
19
+
20
+ #### 🐛 Bug Fix
21
+
22
+ - Create Plugin: Fix migrate and update commands [#487](https://github.com/grafana/plugin-tools/pull/487) ([@jackw](https://github.com/jackw))
23
+
24
+ #### Authors: 1
25
+
26
+ - Jack Westbrook ([@jackw](https://github.com/jackw))
27
+
28
+ ---
29
+
30
+ # v2.2.1 (Fri Oct 20 2023)
31
+
32
+ :tada: This release contains work from a new contributor! :tada:
33
+
34
+ Thank you, Domas ([@domasx2](https://github.com/domasx2)), for all your work!
35
+
36
+ #### 🐛 Bug Fix
37
+
38
+ - Templates/Webpack: Include full path in dev mode image output filename [#388](https://github.com/grafana/plugin-tools/pull/388) ([@domasx2](https://github.com/domasx2))
39
+ - Docs: Fix broken links in package files [#476](https://github.com/grafana/plugin-tools/pull/476) ([@josmperez](https://github.com/josmperez))
40
+
41
+ #### Authors: 2
42
+
43
+ - Domas ([@domasx2](https://github.com/domasx2))
44
+ - Joseph Perez ([@josmperez](https://github.com/josmperez))
45
+
46
+ ---
47
+
1
48
  # v2.2.0 (Tue Oct 17 2023)
2
49
 
3
50
  #### 🚀 Enhancement
@@ -33,6 +33,7 @@ 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
35
  var prettify_files_1 = require("./generate-actions/prettify-files");
36
+ var utils_files_1 = require("../utils/utils.files");
36
37
  function default_1(plop) {
37
38
  plop.setHelper('if_eq', utils_handlebars_1.ifEq);
38
39
  plop.setHelper('normalize_id', utils_handlebars_1.normalizeId);
@@ -185,22 +186,13 @@ function getActionsForTemplateFolder(_a) {
185
186
  if (templateData.packageManagerName !== 'pnpm') {
186
187
  files = files.filter(function (file) { return path_1.default.basename(file) !== 'npmrc'; });
187
188
  }
188
- function getExportFileName(f) {
189
- if (path_1.default.basename(f) === 'gitignore') {
190
- return '.gitignore';
191
- }
192
- if (path_1.default.basename(f) === 'npmrc') {
193
- return '.npmrc';
194
- }
195
- return path_1.default.extname(f) === '.hbs' ? path_1.default.basename(f, '.hbs') : path_1.default.basename(f);
196
- }
197
189
  function getExportPath(f) {
198
190
  return path_1.default.relative(folderPath, path_1.default.dirname(f));
199
191
  }
200
192
  return files.filter(isFile).map(function (f) { return ({
201
193
  type: 'add',
202
194
  templateFile: f,
203
- path: path_1.default.join(exportPath, getExportPath(f), getExportFileName(f)),
195
+ path: path_1.default.join(exportPath, getExportPath(f), (0, utils_files_1.getExportFileName)(f)),
204
196
  force: constants_1.IS_DEV,
205
197
  abortOnFail: false,
206
198
  data: __assign(__assign({}, constants_1.EXTRA_TEMPLATE_VARIABLES), templateData),
@@ -19,7 +19,7 @@ describe('Utils / Templates', function () {
19
19
  expect(templateFiles.length).toBe(0);
20
20
  });
21
21
  test('should be possible to filter for multiple different files', function () {
22
- var templateFiles = (0, utils_templates_1.getTemplateFiles)(constants_1.PLUGIN_TYPES.app, ['.eslintrc', '.prettierrc.js', 'tsconfig.json']);
22
+ var templateFiles = (0, utils_templates_1.getTemplateFiles)(constants_1.PLUGIN_TYPES.app, ['.prettierrc.js', 'cypress.json', 'tsconfig.json']);
23
23
  expect(Array.isArray(templateFiles)).toBe(true);
24
24
  expect(templateFiles.length).toBe(3);
25
25
  });
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.isFileStartingWith = exports.removeFilesInCwd = exports.getOnlyNotExistingInCwd = exports.getOnlyExistingInCwd = exports.readJsonFile = exports.isFile = exports.filterOutCommonFiles = void 0;
6
+ exports.isFileStartingWith = exports.getExportFileName = exports.removeFilesInCwd = exports.getOnlyNotExistingInCwd = exports.getOnlyExistingInCwd = exports.readJsonFile = exports.isFile = exports.filterOutCommonFiles = void 0;
7
7
  var path_1 = __importDefault(require("path"));
8
8
  var fs_1 = __importDefault(require("fs"));
9
9
  var constants_1 = require("../constants");
@@ -52,6 +52,20 @@ function removeFilesInCwd(files) {
52
52
  }
53
53
  }
54
54
  exports.removeFilesInCwd = removeFilesInCwd;
55
+ function getExportFileName(f) {
56
+ var baseName = path_1.default.basename(f);
57
+ if (Object.keys(configFileNamesMap).includes(baseName)) {
58
+ return configFileNamesMap[baseName];
59
+ }
60
+ return path_1.default.extname(f) === '.hbs' ? path_1.default.basename(f, '.hbs') : baseName;
61
+ }
62
+ exports.getExportFileName = getExportFileName;
63
+ var configFileNamesMap = {
64
+ gitignore: '.gitignore',
65
+ npmrc: '.npmrc',
66
+ _eslintrc: '.eslintrc',
67
+ '_package.json': 'package.json',
68
+ };
55
69
  function isFileStartingWith(file, filter) {
56
70
  if (Array.isArray(filter)) {
57
71
  return filter.some(function (f) { return file.startsWith(f); });
@@ -14,7 +14,7 @@ function getPackageJson() {
14
14
  }
15
15
  exports.getPackageJson = getPackageJson;
16
16
  function getLatestPackageJson() {
17
- var packageJsonPath = path_1.default.join(constants_1.TEMPLATE_PATHS.common, 'package.json');
17
+ var packageJsonPath = path_1.default.join(constants_1.TEMPLATE_PATHS.common, '_package.json');
18
18
  var data = (0, utils_templates_1.getTemplateData)();
19
19
  return JSON.parse((0, utils_templates_1.renderTemplateFromFile)(packageJsonPath, data));
20
20
  }
@@ -33,6 +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
37
  function getTemplateFiles(pluginType, filter) {
37
38
  var commonFiles = glob_1.default.sync("".concat(constants_1.TEMPLATE_PATHS.common, "/**"), { dot: true });
38
39
  var pluginTypeSpecificFiles = glob_1.default.sync("".concat(constants_1.TEMPLATE_PATHS[pluginType], "/**"), { dot: true });
@@ -61,7 +62,7 @@ function compileSingleTemplateFile(pluginType, templateFile, data) {
61
62
  }
62
63
  var rendered = renderTemplateFromFile(templateFile, data);
63
64
  var relativeExportPath = templateFile.replace(constants_1.TEMPLATE_PATHS.common, '').replace(constants_1.TEMPLATE_PATHS[pluginType], '');
64
- var exportPath = path_1.default.join(constants_1.EXPORT_PATH_PREFIX, relativeExportPath);
65
+ var exportPath = path_1.default.join(constants_1.EXPORT_PATH_PREFIX, path_1.default.dirname(relativeExportPath), (0, utils_files_2.getExportFileName)(templateFile));
65
66
  mkdirp_1.default.sync(path_1.default.dirname(exportPath));
66
67
  fs_1.default.writeFileSync(exportPath, rendered);
67
68
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@grafana/create-plugin",
3
- "version": "2.3.0-canary.478.898d286.0",
3
+ "version": "2.3.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": "898d2868c88fee97ca13e62d5a0e997741d8da4f"
69
+ "gitHead": "20d8e2c7eef2c091e4fc26a583fe232bec52fd44"
70
70
  }
@@ -10,6 +10,7 @@ import { printGenerateSuccessMessage } from './generate-actions/print-success-me
10
10
  import { updateGoSdkAndModules } from './generate-actions/update-go-sdk-and-packages';
11
11
  import { prettifyFiles } from './generate-actions/prettify-files';
12
12
  import { CliArgs, TemplateData } from './types';
13
+ import { getExportFileName } from '../utils/utils.files';
13
14
 
14
15
  // Plopfile API documentation: https://plopjs.com/documentation/#plopfile-api
15
16
  export default function (plop: NodePlopAPI) {
@@ -236,19 +237,6 @@ function getActionsForTemplateFolder({
236
237
  files = files.filter((file) => path.basename(file) !== 'npmrc');
237
238
  }
238
239
 
239
- function getExportFileName(f: string) {
240
- // yarn and npm packing will not include `.gitignore` files
241
- // so we have to manually rename them to add the dot prefix
242
- if (path.basename(f) === 'gitignore') {
243
- return '.gitignore';
244
- }
245
- if (path.basename(f) === 'npmrc') {
246
- return '.npmrc';
247
- }
248
-
249
- return path.extname(f) === '.hbs' ? path.basename(f, '.hbs') : path.basename(f);
250
- }
251
-
252
240
  function getExportPath(f: string) {
253
241
  return path.relative(folderPath, path.dirname(f));
254
242
  }
@@ -28,7 +28,7 @@ describe('Utils / Templates', () => {
28
28
  });
29
29
 
30
30
  test('should be possible to filter for multiple different files', () => {
31
- const templateFiles = getTemplateFiles(PLUGIN_TYPES.app, ['.eslintrc', '.prettierrc.js', 'tsconfig.json']);
31
+ const templateFiles = getTemplateFiles(PLUGIN_TYPES.app, ['.prettierrc.js', 'cypress.json', 'tsconfig.json']);
32
32
 
33
33
  expect(Array.isArray(templateFiles)).toBe(true);
34
34
  expect(templateFiles.length).toBe(3);
@@ -50,6 +50,26 @@ export function removeFilesInCwd(files: string[]) {
50
50
  }
51
51
  }
52
52
 
53
+ export function getExportFileName(f: string) {
54
+ const baseName = path.basename(f);
55
+
56
+ if (Object.keys(configFileNamesMap).includes(baseName)) {
57
+ return configFileNamesMap[baseName];
58
+ }
59
+
60
+ return path.extname(f) === '.hbs' ? path.basename(f, '.hbs') : baseName;
61
+ }
62
+
63
+ // yarn and npm packing will not include `.gitignore` files
64
+ // so we have to manually rename them to add the dot prefix
65
+ // other config files trip up the tooling in the plugin-tools monorepo
66
+ const configFileNamesMap: Record<string, string> = {
67
+ gitignore: '.gitignore',
68
+ npmrc: '.npmrc',
69
+ _eslintrc: '.eslintrc',
70
+ '_package.json': 'package.json',
71
+ };
72
+
53
73
  /**
54
74
  * Returns TRUE if the file is starting with any of the provided string filters.
55
75
  *
@@ -16,7 +16,7 @@ export function getPackageJson(): PackageJson {
16
16
 
17
17
  // Returns with a package.json that is generated based on the latest templates
18
18
  export function getLatestPackageJson(): PackageJson {
19
- const packageJsonPath = path.join(TEMPLATE_PATHS.common, 'package.json');
19
+ const packageJsonPath = path.join(TEMPLATE_PATHS.common, '_package.json');
20
20
  const data = getTemplateData();
21
21
 
22
22
  return JSON.parse(renderTemplateFromFile(packageJsonPath, data));
@@ -7,6 +7,7 @@ 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
11
 
11
12
  /**
12
13
  *
@@ -52,7 +53,7 @@ export function compileSingleTemplateFile(pluginType: string, templateFile: stri
52
53
 
53
54
  const rendered = renderTemplateFromFile(templateFile, data);
54
55
  const relativeExportPath = templateFile.replace(TEMPLATE_PATHS.common, '').replace(TEMPLATE_PATHS[pluginType], '');
55
- const exportPath = path.join(EXPORT_PATH_PREFIX, relativeExportPath);
56
+ const exportPath = path.join(EXPORT_PATH_PREFIX, path.dirname(relativeExportPath), getExportFileName(templateFile));
56
57
 
57
58
  mkdirp.sync(path.dirname(exportPath));
58
59
  fs.writeFileSync(exportPath, rendered);
@@ -110,7 +110,7 @@ const config = async (env): Promise<Configuration> => {
110
110
  // Keep publicPath relative for host.com/grafana/ deployments
111
111
  publicPath: `public/plugins/${pluginJson.id}/img/`,
112
112
  outputPath: 'img/',
113
- filename: Boolean(env.production) ? '[hash][ext]' : '[name][ext]',
113
+ filename: Boolean(env.production) ? '[hash][ext]' : '[file]',
114
114
  },
115
115
  },
116
116
  {
@@ -30,7 +30,7 @@
30
30
  "@testing-library/react": "^12.1.4",
31
31
  "@types/jest": "^29.5.0",
32
32
  "@types/lodash": "^4.14.194",
33
- "@types/node": "^18.15.11",{{#if isAppType}}
33
+ "@types/node": "^20.8.7",{{#if isAppType}}
34
34
  "@types/react-router-dom": "^5.3.3",{{/if}}
35
35
  "copy-webpack-plugin": "^11.0.0",
36
36
  "css-loader": "^6.7.3",
File without changes