@grafana/create-plugin 2.7.0-canary.528.42bb84a.0 → 2.7.0-canary.528.8a2e623.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,53 +45,43 @@ 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,
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
switch (_c.label) {
|
|
48
|
+
var nonInteractive, CWD, DIS_PATH, PLUGIN_JSON, MANIFEST_TXT, confirm_1, pluginJsonContent, pluginId, zipFileName, zipFilePath, confirm_2, _a, error_1;
|
|
49
|
+
return __generator(this, function (_b) {
|
|
50
|
+
switch (_b.label) {
|
|
52
51
|
case 0:
|
|
53
52
|
nonInteractive = argv['non-interactive'];
|
|
54
53
|
CWD = process.cwd();
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
if (!fs_1.default.existsSync(
|
|
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()) {
|
|
59
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`");
|
|
60
59
|
process.exit(1);
|
|
61
60
|
}
|
|
62
|
-
if (!fs_1.default.existsSync(
|
|
61
|
+
if (!fs_1.default.existsSync(PLUGIN_JSON)) {
|
|
63
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`");
|
|
64
63
|
process.exit(1);
|
|
65
64
|
}
|
|
66
|
-
if (!(!fs_1.default.existsSync(
|
|
65
|
+
if (!(!fs_1.default.existsSync(MANIFEST_TXT) && !nonInteractive)) return [3, 2];
|
|
67
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?")];
|
|
68
67
|
case 1:
|
|
69
|
-
confirm_1 =
|
|
68
|
+
confirm_1 = _b.sent();
|
|
70
69
|
if (!confirm_1) {
|
|
71
70
|
process.exit(1);
|
|
72
71
|
}
|
|
73
|
-
|
|
72
|
+
_b.label = 2;
|
|
74
73
|
case 2:
|
|
75
|
-
pluginJsonContent = require(
|
|
74
|
+
pluginJsonContent = require(PLUGIN_JSON);
|
|
76
75
|
pluginId = pluginJsonContent.id;
|
|
77
|
-
|
|
78
|
-
if (typeof pluginId !== 'string' || pluginId.length === 0) {
|
|
79
|
-
(0, utils_console_1.printErrorMessage)("Could not find 'id' in 'plugin.json'");
|
|
80
|
-
process.exit(1);
|
|
81
|
-
}
|
|
82
|
-
if (typeof pluginVersion !== 'string' || pluginVersion.length === 0) {
|
|
83
|
-
(0, utils_console_1.printErrorMessage)("Could not find 'version' in 'plugin.json'");
|
|
84
|
-
process.exit(1);
|
|
85
|
-
}
|
|
86
|
-
zipFileName = "".concat(pluginId, "-").concat(pluginVersion, ".zip");
|
|
76
|
+
zipFileName = "".concat(pluginId, ".zip");
|
|
87
77
|
zipFilePath = path_1.default.join(CWD, zipFileName);
|
|
88
78
|
if (!fs_1.default.existsSync(zipFilePath)) return [3, 5];
|
|
89
79
|
_a = nonInteractive;
|
|
90
80
|
if (_a) return [3, 4];
|
|
91
81
|
return [4, (0, utils_console_1.confirmPrompt)("A zip file with the name '".concat(zipFileName, "' already exists. Do you want to continue and overwrite it?"))];
|
|
92
82
|
case 3:
|
|
93
|
-
_a = (
|
|
94
|
-
|
|
83
|
+
_a = (_b.sent());
|
|
84
|
+
_b.label = 4;
|
|
95
85
|
case 4:
|
|
96
86
|
confirm_2 = _a;
|
|
97
87
|
if (confirm_2) {
|
|
@@ -106,16 +96,16 @@ var packagePlugin = function (argv) { return __awaiter(void 0, void 0, void 0, f
|
|
|
106
96
|
else {
|
|
107
97
|
process.exit(1);
|
|
108
98
|
}
|
|
109
|
-
|
|
99
|
+
_b.label = 5;
|
|
110
100
|
case 5:
|
|
111
|
-
|
|
112
|
-
return [4, zipDistPath(
|
|
101
|
+
_b.trys.push([5, 7, , 8]);
|
|
102
|
+
return [4, zipDistPath(DIS_PATH, zipFilePath, pluginId)];
|
|
113
103
|
case 6:
|
|
114
|
-
|
|
104
|
+
_b.sent();
|
|
115
105
|
(0, utils_console_1.printSuccessMessage)("Successfully created zip archive at ".concat(zipFileName));
|
|
116
106
|
return [3, 8];
|
|
117
107
|
case 7:
|
|
118
|
-
error_1 =
|
|
108
|
+
error_1 = _b.sent();
|
|
119
109
|
(0, utils_console_1.printErrorMessage)("Could not create zip file: ".concat(error_1));
|
|
120
110
|
return [3, 8];
|
|
121
111
|
case 8: return [2];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@grafana/create-plugin",
|
|
3
|
-
"version": "2.7.0-canary.528.
|
|
3
|
+
"version": "2.7.0-canary.528.8a2e623.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": "
|
|
71
|
+
"gitHead": "8a2e623b848ed62103eadc61e22593acc4c5718f"
|
|
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
|
|
12
|
-
const
|
|
13
|
-
const
|
|
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');
|
|
14
14
|
|
|
15
15
|
// validate DIS_PATH exists
|
|
16
|
-
if (!fs.existsSync(
|
|
16
|
+
if (!fs.existsSync(DIS_PATH) || !fs.statSync(DIS_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(
|
|
24
|
+
if (!fs.existsSync(PLUGIN_JSON)) {
|
|
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(
|
|
32
|
+
if (!fs.existsSync(MANIFEST_TXT) && !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,21 +38,10 @@ export const packagePlugin = async (argv: minimist.ParsedArgs) => {
|
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
const pluginJsonContent = require(
|
|
41
|
+
const pluginJsonContent = require(PLUGIN_JSON);
|
|
42
42
|
const pluginId = pluginJsonContent.id;
|
|
43
|
-
const pluginVersion = pluginJsonContent.info?.version;
|
|
44
43
|
|
|
45
|
-
|
|
46
|
-
printErrorMessage(`Could not find 'id' in 'plugin.json'`);
|
|
47
|
-
process.exit(1);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
if (typeof pluginVersion !== 'string' || pluginVersion.length === 0) {
|
|
51
|
-
printErrorMessage(`Could not find 'version' in 'plugin.json'`);
|
|
52
|
-
process.exit(1);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
const zipFileName = `${pluginId}-${pluginVersion}.zip`;
|
|
44
|
+
const zipFileName = `${pluginId}.zip`;
|
|
56
45
|
const zipFilePath = path.join(CWD, zipFileName);
|
|
57
46
|
|
|
58
47
|
// if zip file already exists, warn user and confirm if wish to continue
|
|
@@ -76,7 +65,7 @@ export const packagePlugin = async (argv: minimist.ParsedArgs) => {
|
|
|
76
65
|
}
|
|
77
66
|
|
|
78
67
|
try {
|
|
79
|
-
await zipDistPath(
|
|
68
|
+
await zipDistPath(DIS_PATH, zipFilePath, pluginId);
|
|
80
69
|
printSuccessMessage(`Successfully created zip archive at ${zipFileName}`);
|
|
81
70
|
} catch (error) {
|
|
82
71
|
printErrorMessage(`Could not create zip file: ${error}`);
|