@grafana/create-plugin 2.7.0-canary.528.8a2e623.0 → 2.7.0-canary.528.d8ffdeb.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.
@@ -45,24 +45,24 @@ var utils_console_1 = require("../utils/utils.console");
45
45
  var archiver_1 = __importDefault(require("archiver"));
46
46
  var path_1 = __importDefault(require("path"));
47
47
  var packagePlugin = function (argv) { return __awaiter(void 0, void 0, void 0, function () {
48
- var nonInteractive, CWD, DIS_PATH, PLUGIN_JSON, MANIFEST_TXT, confirm_1, pluginJsonContent, pluginId, zipFileName, zipFilePath, confirm_2, _a, error_1;
48
+ var nonInteractive, CWD, DIST_PATH, PLUGIN_JSON_PATH, MANIFEST_TXT_PATH, confirm_1, pluginJsonContent, pluginId, zipFileName, zipFilePath, confirm_2, _a, error_1;
49
49
  return __generator(this, function (_b) {
50
50
  switch (_b.label) {
51
51
  case 0:
52
52
  nonInteractive = argv['non-interactive'];
53
53
  CWD = process.cwd();
54
- DIS_PATH = path_1.default.join(CWD, 'dist');
55
- PLUGIN_JSON = path_1.default.join(DIS_PATH, 'plugin.json');
56
- MANIFEST_TXT = path_1.default.join(DIS_PATH, 'MANIFEST.txt');
57
- if (!fs_1.default.existsSync(DIS_PATH) || !fs_1.default.statSync(DIS_PATH).isDirectory()) {
54
+ DIST_PATH = path_1.default.join(CWD, 'dist');
55
+ PLUGIN_JSON_PATH = path_1.default.join(DIST_PATH, 'plugin.json');
56
+ MANIFEST_TXT_PATH = path_1.default.join(DIST_PATH, 'MANIFEST.txt');
57
+ if (!fs_1.default.existsSync(DIST_PATH) || !fs_1.default.statSync(DIST_PATH).isDirectory()) {
58
58
  (0, utils_console_1.printErrorMessage)("Could not find 'dist' directory. Please build your plugin before running this command. e.g.: `yarn build` or `npm run build`");
59
59
  process.exit(1);
60
60
  }
61
- if (!fs_1.default.existsSync(PLUGIN_JSON)) {
61
+ if (!fs_1.default.existsSync(PLUGIN_JSON_PATH)) {
62
62
  (0, utils_console_1.printErrorMessage)("Could not find 'plugin.json' inside 'dist' directory. Please build your plugin before running this command. e.g.: `yarn build` or `npm run build`");
63
63
  process.exit(1);
64
64
  }
65
- if (!(!fs_1.default.existsSync(MANIFEST_TXT) && !nonInteractive)) return [3, 2];
65
+ if (!(!fs_1.default.existsSync(MANIFEST_TXT_PATH) && !nonInteractive)) return [3, 2];
66
66
  return [4, (0, utils_console_1.confirmPrompt)("Could not find a 'MANIFEST.txt' file inside 'dist' directory. This means that the plugin is not signed. Would you like to continue generating an unsigned archive file?")];
67
67
  case 1:
68
68
  confirm_1 = _b.sent();
@@ -71,8 +71,12 @@ var packagePlugin = function (argv) { return __awaiter(void 0, void 0, void 0, f
71
71
  }
72
72
  _b.label = 2;
73
73
  case 2:
74
- pluginJsonContent = require(PLUGIN_JSON);
74
+ pluginJsonContent = require(PLUGIN_JSON_PATH);
75
75
  pluginId = pluginJsonContent.id;
76
+ if (typeof pluginId !== 'string' || pluginId.length === 0) {
77
+ (0, utils_console_1.printErrorMessage)("Could not find 'id' in 'plugin.json'");
78
+ process.exit(1);
79
+ }
76
80
  zipFileName = "".concat(pluginId, ".zip");
77
81
  zipFilePath = path_1.default.join(CWD, zipFileName);
78
82
  if (!fs_1.default.existsSync(zipFilePath)) return [3, 5];
@@ -99,7 +103,7 @@ var packagePlugin = function (argv) { return __awaiter(void 0, void 0, void 0, f
99
103
  _b.label = 5;
100
104
  case 5:
101
105
  _b.trys.push([5, 7, , 8]);
102
- return [4, zipDistPath(DIS_PATH, zipFilePath, pluginId)];
106
+ return [4, zipDistPath(DIST_PATH, zipFilePath, pluginId)];
103
107
  case 6:
104
108
  _b.sent();
105
109
  (0, utils_console_1.printSuccessMessage)("Successfully created zip archive at ".concat(zipFileName));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@grafana/create-plugin",
3
- "version": "2.7.0-canary.528.8a2e623.0",
3
+ "version": "2.7.0-canary.528.d8ffdeb.0",
4
4
  "main": "index.js",
5
5
  "repository": {
6
6
  "directory": "packages/create-plugin",
@@ -68,5 +68,5 @@
68
68
  "engines": {
69
69
  "node": ">=20"
70
70
  },
71
- "gitHead": "8a2e623b848ed62103eadc61e22593acc4c5718f"
71
+ "gitHead": "d8ffdeb3ab6fb79ab83343a3d17ab03ac2a224fa"
72
72
  }
@@ -8,12 +8,12 @@ export const packagePlugin = async (argv: minimist.ParsedArgs) => {
8
8
  const nonInteractive = argv['non-interactive'];
9
9
 
10
10
  const CWD = process.cwd();
11
- const DIS_PATH = path.join(CWD, 'dist');
12
- const PLUGIN_JSON = path.join(DIS_PATH, 'plugin.json');
13
- const MANIFEST_TXT = path.join(DIS_PATH, 'MANIFEST.txt');
11
+ const DIST_PATH = path.join(CWD, 'dist');
12
+ const PLUGIN_JSON_PATH = path.join(DIST_PATH, 'plugin.json');
13
+ const MANIFEST_TXT_PATH = path.join(DIST_PATH, 'MANIFEST.txt');
14
14
 
15
15
  // validate DIS_PATH exists
16
- if (!fs.existsSync(DIS_PATH) || !fs.statSync(DIS_PATH).isDirectory()) {
16
+ if (!fs.existsSync(DIST_PATH) || !fs.statSync(DIST_PATH).isDirectory()) {
17
17
  printErrorMessage(
18
18
  "Could not find 'dist' directory. Please build your plugin before running this command. e.g.: `yarn build` or `npm run build`"
19
19
  );
@@ -21,7 +21,7 @@ export const packagePlugin = async (argv: minimist.ParsedArgs) => {
21
21
  }
22
22
 
23
23
  // validate PLUGIN_JSON exists
24
- if (!fs.existsSync(PLUGIN_JSON)) {
24
+ if (!fs.existsSync(PLUGIN_JSON_PATH)) {
25
25
  printErrorMessage(
26
26
  "Could not find 'plugin.json' inside 'dist' directory. Please build your plugin before running this command. e.g.: `yarn build` or `npm run build`"
27
27
  );
@@ -29,7 +29,7 @@ export const packagePlugin = async (argv: minimist.ParsedArgs) => {
29
29
  }
30
30
 
31
31
  // if no manifest file, warn user and confirm if wish to continue
32
- if (!fs.existsSync(MANIFEST_TXT) && !nonInteractive) {
32
+ if (!fs.existsSync(MANIFEST_TXT_PATH) && !nonInteractive) {
33
33
  const confirm = await confirmPrompt(
34
34
  `Could not find a 'MANIFEST.txt' file inside 'dist' directory. This means that the plugin is not signed. Would you like to continue generating an unsigned archive file?`
35
35
  );
@@ -38,9 +38,14 @@ export const packagePlugin = async (argv: minimist.ParsedArgs) => {
38
38
  }
39
39
  }
40
40
 
41
- const pluginJsonContent = require(PLUGIN_JSON);
41
+ const pluginJsonContent = require(PLUGIN_JSON_PATH);
42
42
  const pluginId = pluginJsonContent.id;
43
43
 
44
+ if (typeof pluginId !== 'string' || pluginId.length === 0) {
45
+ printErrorMessage(`Could not find 'id' in 'plugin.json'`);
46
+ process.exit(1);
47
+ }
48
+
44
49
  const zipFileName = `${pluginId}.zip`;
45
50
  const zipFilePath = path.join(CWD, zipFileName);
46
51
 
@@ -65,7 +70,7 @@ export const packagePlugin = async (argv: minimist.ParsedArgs) => {
65
70
  }
66
71
 
67
72
  try {
68
- await zipDistPath(DIS_PATH, zipFilePath, pluginId);
73
+ await zipDistPath(DIST_PATH, zipFilePath, pluginId);
69
74
  printSuccessMessage(`Successfully created zip archive at ${zipFileName}`);
70
75
  } catch (error) {
71
76
  printErrorMessage(`Could not create zip file: ${error}`);