@grafana/create-plugin 2.5.1 → 2.7.0-canary.528.42bb84a.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 +21 -0
- package/README.md +8 -0
- package/dist/bin/run.js +1 -0
- package/dist/commands/index.js +1 -0
- package/dist/commands/package.command.js +140 -0
- package/dist/utils/utils.console.js +9 -1
- package/fixtures/test-template/src/plugin.json +1 -1
- package/package.json +4 -2
- package/src/bin/run.ts +2 -1
- package/src/commands/index.ts +1 -0
- package/src/commands/package.command.ts +103 -0
- package/src/utils/utils.console.ts +8 -0
- package/templates/app/src/plugin.json +1 -1
- package/templates/datasource/src/plugin.json +1 -1
- package/templates/github/ci/.github/workflows/ci.yml +1 -1
- package/templates/github/ci/.github/workflows/release.yml +6 -7
- package/templates/panel/src/plugin.json +1 -1
- package/templates/scenes-app/src/plugin.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,24 @@
|
|
|
1
|
+
# v2.6.0 (Tue Nov 07 2023)
|
|
2
|
+
|
|
3
|
+
:tada: This release contains work from a new contributor! :tada:
|
|
4
|
+
|
|
5
|
+
Thank you, Joan López de la Franca Beltran ([@joanlopez](https://github.com/joanlopez)), for all your work!
|
|
6
|
+
|
|
7
|
+
#### 🚀 Enhancement
|
|
8
|
+
|
|
9
|
+
- update to use sha1sum and minor workflow updates [#503](https://github.com/grafana/plugin-tools/pull/503) ([@briangann](https://github.com/briangann))
|
|
10
|
+
|
|
11
|
+
#### 🐛 Bug Fix
|
|
12
|
+
|
|
13
|
+
- Create Plugin: Replace 'master' with 'main' on ref [#507](https://github.com/grafana/plugin-tools/pull/507) ([@joanlopez](https://github.com/joanlopez))
|
|
14
|
+
|
|
15
|
+
#### Authors: 2
|
|
16
|
+
|
|
17
|
+
- Brian Gann ([@briangann](https://github.com/briangann))
|
|
18
|
+
- Joan López de la Franca Beltran ([@joanlopez](https://github.com/joanlopez))
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
1
22
|
# v2.5.1 (Thu Nov 02 2023)
|
|
2
23
|
|
|
3
24
|
#### 🐛 Bug Fix
|
package/README.md
CHANGED
|
@@ -95,6 +95,14 @@ For more information see [here](https://grafana.com/developers/plugin-tools/migr
|
|
|
95
95
|
|
|
96
96
|
---
|
|
97
97
|
|
|
98
|
+
## Package your plugin
|
|
99
|
+
|
|
100
|
+
You can use the `package` command to [package](https://grafana.com/developers/plugin-tools/publish-a-plugin/package-a-plugin) your plugin automatically.
|
|
101
|
+
|
|
102
|
+
1. Build your plugin: e.g. `npm run build` or `yarn build` and `mage` if your plugin has a backend.
|
|
103
|
+
2. [Sign your plugin](https://grafana.com/developers/plugin-tools/publish-a-plugin/sign-a-plugin).
|
|
104
|
+
3. Run `npx @grafana/create-plugin@latest package` to package your plugin. A zip file with your plugin will be created.
|
|
105
|
+
|
|
98
106
|
## Customizing or extending the basic configs
|
|
99
107
|
|
|
100
108
|
You can read more about customizing or extending the basic configuration [here](https://grafana.com/developers/plugin-tools/create-a-plugin/extend-a-plugin/extend-configurations)
|
package/dist/bin/run.js
CHANGED
package/dist/commands/index.js
CHANGED
|
@@ -18,3 +18,4 @@ __exportStar(require("./generate.command"), exports);
|
|
|
18
18
|
__exportStar(require("./update.command"), exports);
|
|
19
19
|
__exportStar(require("./migrate.command"), exports);
|
|
20
20
|
__exportStar(require("./version.command"), exports);
|
|
21
|
+
__exportStar(require("./package.command"), exports);
|
|
@@ -0,0 +1,140 @@
|
|
|
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.packagePlugin = void 0;
|
|
43
|
+
var fs_1 = __importDefault(require("fs"));
|
|
44
|
+
var utils_console_1 = require("../utils/utils.console");
|
|
45
|
+
var archiver_1 = __importDefault(require("archiver"));
|
|
46
|
+
var path_1 = __importDefault(require("path"));
|
|
47
|
+
var packagePlugin = function (argv) { return __awaiter(void 0, void 0, void 0, function () {
|
|
48
|
+
var nonInteractive, CWD, DIST_PATH, PLUGIN_JSON_PATH, MANIFEST_TXT_PATH, confirm_1, pluginJsonContent, pluginId, pluginVersion, zipFileName, zipFilePath, confirm_2, _a, error_1;
|
|
49
|
+
var _b;
|
|
50
|
+
return __generator(this, function (_c) {
|
|
51
|
+
switch (_c.label) {
|
|
52
|
+
case 0:
|
|
53
|
+
nonInteractive = argv['non-interactive'];
|
|
54
|
+
CWD = process.cwd();
|
|
55
|
+
DIST_PATH = path_1.default.join(CWD, 'dist');
|
|
56
|
+
PLUGIN_JSON_PATH = path_1.default.join(DIST_PATH, 'plugin.json');
|
|
57
|
+
MANIFEST_TXT_PATH = path_1.default.join(DIST_PATH, 'MANIFEST.txt');
|
|
58
|
+
if (!fs_1.default.existsSync(DIST_PATH) || !fs_1.default.statSync(DIST_PATH).isDirectory()) {
|
|
59
|
+
(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
|
+
process.exit(1);
|
|
61
|
+
}
|
|
62
|
+
if (!fs_1.default.existsSync(PLUGIN_JSON_PATH)) {
|
|
63
|
+
(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
|
+
process.exit(1);
|
|
65
|
+
}
|
|
66
|
+
if (!(!fs_1.default.existsSync(MANIFEST_TXT_PATH) && !nonInteractive)) return [3, 2];
|
|
67
|
+
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
|
+
case 1:
|
|
69
|
+
confirm_1 = _c.sent();
|
|
70
|
+
if (!confirm_1) {
|
|
71
|
+
process.exit(1);
|
|
72
|
+
}
|
|
73
|
+
_c.label = 2;
|
|
74
|
+
case 2:
|
|
75
|
+
pluginJsonContent = require(PLUGIN_JSON_PATH);
|
|
76
|
+
pluginId = pluginJsonContent.id;
|
|
77
|
+
pluginVersion = (_b = pluginJsonContent.info) === null || _b === void 0 ? void 0 : _b.version;
|
|
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");
|
|
87
|
+
zipFilePath = path_1.default.join(CWD, zipFileName);
|
|
88
|
+
if (!fs_1.default.existsSync(zipFilePath)) return [3, 5];
|
|
89
|
+
_a = nonInteractive;
|
|
90
|
+
if (_a) return [3, 4];
|
|
91
|
+
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
|
+
case 3:
|
|
93
|
+
_a = (_c.sent());
|
|
94
|
+
_c.label = 4;
|
|
95
|
+
case 4:
|
|
96
|
+
confirm_2 = _a;
|
|
97
|
+
if (confirm_2) {
|
|
98
|
+
try {
|
|
99
|
+
fs_1.default.unlinkSync(zipFilePath);
|
|
100
|
+
}
|
|
101
|
+
catch (error) {
|
|
102
|
+
(0, utils_console_1.printErrorMessage)("Could not delete existing zip file: ".concat(error));
|
|
103
|
+
process.exit(1);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
process.exit(1);
|
|
108
|
+
}
|
|
109
|
+
_c.label = 5;
|
|
110
|
+
case 5:
|
|
111
|
+
_c.trys.push([5, 7, , 8]);
|
|
112
|
+
return [4, zipDistPath(DIST_PATH, zipFilePath, pluginId)];
|
|
113
|
+
case 6:
|
|
114
|
+
_c.sent();
|
|
115
|
+
(0, utils_console_1.printSuccessMessage)("Successfully created zip archive at ".concat(zipFileName));
|
|
116
|
+
return [3, 8];
|
|
117
|
+
case 7:
|
|
118
|
+
error_1 = _c.sent();
|
|
119
|
+
(0, utils_console_1.printErrorMessage)("Could not create zip file: ".concat(error_1));
|
|
120
|
+
return [3, 8];
|
|
121
|
+
case 8: return [2];
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
}); };
|
|
125
|
+
exports.packagePlugin = packagePlugin;
|
|
126
|
+
function zipDistPath(path, destination, pathName) {
|
|
127
|
+
return new Promise(function (resolve, reject) {
|
|
128
|
+
var output = fs_1.default.createWriteStream(destination);
|
|
129
|
+
var archive = (0, archiver_1.default)('zip', { zlib: { level: 9 } });
|
|
130
|
+
output.on('close', function () {
|
|
131
|
+
resolve(destination);
|
|
132
|
+
});
|
|
133
|
+
archive.on('error', function (err) {
|
|
134
|
+
reject(err);
|
|
135
|
+
});
|
|
136
|
+
archive.pipe(output);
|
|
137
|
+
archive.directory(path, pathName);
|
|
138
|
+
archive.finalize();
|
|
139
|
+
});
|
|
140
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.selectPrompt = exports.confirmPrompt = exports.printSuccessMessage = exports.printMessage = exports.displayArrayAsList = exports.displayAsMarkdown = void 0;
|
|
3
|
+
exports.selectPrompt = exports.confirmPrompt = exports.printErrorMessage = exports.printWarningMessage = exports.printSuccessMessage = exports.printMessage = exports.displayArrayAsList = exports.displayAsMarkdown = void 0;
|
|
4
4
|
var marked = require('marked').marked;
|
|
5
5
|
var TerminalRenderer = require('marked-terminal');
|
|
6
6
|
var _a = require('enquirer'), Confirm = _a.Confirm, Select = _a.Select;
|
|
@@ -23,6 +23,14 @@ function printSuccessMessage(msg) {
|
|
|
23
23
|
console.log(displayAsMarkdown("\n\u2714 ".concat(msg)));
|
|
24
24
|
}
|
|
25
25
|
exports.printSuccessMessage = printSuccessMessage;
|
|
26
|
+
function printWarningMessage(msg) {
|
|
27
|
+
console.log(displayAsMarkdown("\n\u26A0 ".concat(msg)));
|
|
28
|
+
}
|
|
29
|
+
exports.printWarningMessage = printWarningMessage;
|
|
30
|
+
function printErrorMessage(msg) {
|
|
31
|
+
console.log(displayAsMarkdown("\n\u274C ".concat(msg)));
|
|
32
|
+
}
|
|
33
|
+
exports.printErrorMessage = printErrorMessage;
|
|
26
34
|
function confirmPrompt(message) {
|
|
27
35
|
var prompt = new Confirm({
|
|
28
36
|
name: 'question',
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"$schema": "https://raw.githubusercontent.com/grafana/grafana/
|
|
2
|
+
"$schema": "https://raw.githubusercontent.com/grafana/grafana/main/docs/sources/developers/plugins/plugin.schema.json",
|
|
3
3
|
"type": "app",
|
|
4
4
|
"name": "{{ titleCase pluginName }}",
|
|
5
5
|
"id": "{{ normalize_id pluginName orgName 'app' }}",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@grafana/create-plugin",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.7.0-canary.528.42bb84a.0",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"repository": {
|
|
6
6
|
"directory": "packages/create-plugin",
|
|
@@ -38,6 +38,7 @@
|
|
|
38
38
|
"@types/mkdirp": "^1.0.2",
|
|
39
39
|
"@types/semver": "^7.3.9",
|
|
40
40
|
"@types/which": "^2.0.2",
|
|
41
|
+
"archiver": "^6.0.1",
|
|
41
42
|
"enquirer": "^2.3.6",
|
|
42
43
|
"find-up": "^5.0.0",
|
|
43
44
|
"glob": "^7.1.7",
|
|
@@ -49,6 +50,7 @@
|
|
|
49
50
|
"which": "^3.0.0"
|
|
50
51
|
},
|
|
51
52
|
"devDependencies": {
|
|
53
|
+
"@types/archiver": "^6.0.1",
|
|
52
54
|
"@types/glob": "^7.0.0",
|
|
53
55
|
"eslint-plugin-react": "^7.26.1",
|
|
54
56
|
"eslint-plugin-react-hooks": "^4.2.0"
|
|
@@ -66,5 +68,5 @@
|
|
|
66
68
|
"engines": {
|
|
67
69
|
"node": ">=20"
|
|
68
70
|
},
|
|
69
|
-
"gitHead": "
|
|
71
|
+
"gitHead": "42bb84a873db6c1e34f9e3b200d59ffe6f55f495"
|
|
70
72
|
}
|
package/src/bin/run.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
import minimist from 'minimist';
|
|
4
|
-
import { generate, update, migrate, version } from '../commands';
|
|
4
|
+
import { generate, update, migrate, version, packagePlugin } from '../commands';
|
|
5
5
|
import { isUnsupportedPlatform } from '../utils/utils.os';
|
|
6
6
|
|
|
7
7
|
// Exit early if operating system isn't supported.
|
|
@@ -18,6 +18,7 @@ const commands: Record<string, (argv: minimist.ParsedArgs) => void> = {
|
|
|
18
18
|
migrate,
|
|
19
19
|
generate,
|
|
20
20
|
update,
|
|
21
|
+
package: packagePlugin,
|
|
21
22
|
version,
|
|
22
23
|
};
|
|
23
24
|
const command = commands[argv._[0]] || commands.generate;
|
package/src/commands/index.ts
CHANGED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import minimist from 'minimist';
|
|
2
|
+
import fs from 'fs';
|
|
3
|
+
import { confirmPrompt, printErrorMessage, printSuccessMessage } from '../utils/utils.console';
|
|
4
|
+
import archiver from 'archiver';
|
|
5
|
+
import path from 'path';
|
|
6
|
+
|
|
7
|
+
export const packagePlugin = async (argv: minimist.ParsedArgs) => {
|
|
8
|
+
const nonInteractive = argv['non-interactive'];
|
|
9
|
+
|
|
10
|
+
const CWD = process.cwd();
|
|
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
|
+
|
|
15
|
+
// validate DIS_PATH exists
|
|
16
|
+
if (!fs.existsSync(DIST_PATH) || !fs.statSync(DIST_PATH).isDirectory()) {
|
|
17
|
+
printErrorMessage(
|
|
18
|
+
"Could not find 'dist' directory. Please build your plugin before running this command. e.g.: `yarn build` or `npm run build`"
|
|
19
|
+
);
|
|
20
|
+
process.exit(1);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// validate PLUGIN_JSON exists
|
|
24
|
+
if (!fs.existsSync(PLUGIN_JSON_PATH)) {
|
|
25
|
+
printErrorMessage(
|
|
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
|
+
);
|
|
28
|
+
process.exit(1);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// if no manifest file, warn user and confirm if wish to continue
|
|
32
|
+
if (!fs.existsSync(MANIFEST_TXT_PATH) && !nonInteractive) {
|
|
33
|
+
const confirm = await confirmPrompt(
|
|
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
|
+
);
|
|
36
|
+
if (!confirm) {
|
|
37
|
+
process.exit(1);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const pluginJsonContent = require(PLUGIN_JSON_PATH);
|
|
42
|
+
const pluginId = pluginJsonContent.id;
|
|
43
|
+
const pluginVersion = pluginJsonContent.info?.version;
|
|
44
|
+
|
|
45
|
+
if (typeof pluginId !== 'string' || pluginId.length === 0) {
|
|
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`;
|
|
56
|
+
const zipFilePath = path.join(CWD, zipFileName);
|
|
57
|
+
|
|
58
|
+
// if zip file already exists, warn user and confirm if wish to continue
|
|
59
|
+
if (fs.existsSync(zipFilePath)) {
|
|
60
|
+
const confirm =
|
|
61
|
+
nonInteractive ||
|
|
62
|
+
(await confirmPrompt(
|
|
63
|
+
`A zip file with the name '${zipFileName}' already exists. Do you want to continue and overwrite it?`
|
|
64
|
+
));
|
|
65
|
+
|
|
66
|
+
if (confirm) {
|
|
67
|
+
try {
|
|
68
|
+
fs.unlinkSync(zipFilePath);
|
|
69
|
+
} catch (error) {
|
|
70
|
+
printErrorMessage(`Could not delete existing zip file: ${error}`);
|
|
71
|
+
process.exit(1);
|
|
72
|
+
}
|
|
73
|
+
} else {
|
|
74
|
+
process.exit(1);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
try {
|
|
79
|
+
await zipDistPath(DIST_PATH, zipFilePath, pluginId);
|
|
80
|
+
printSuccessMessage(`Successfully created zip archive at ${zipFileName}`);
|
|
81
|
+
} catch (error) {
|
|
82
|
+
printErrorMessage(`Could not create zip file: ${error}`);
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
function zipDistPath(path: string, destination: string, pathName: string): Promise<string> {
|
|
87
|
+
return new Promise((resolve, reject) => {
|
|
88
|
+
const output = fs.createWriteStream(destination);
|
|
89
|
+
const archive = archiver('zip', { zlib: { level: 9 } });
|
|
90
|
+
|
|
91
|
+
output.on('close', () => {
|
|
92
|
+
resolve(destination);
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
archive.on('error', (err) => {
|
|
96
|
+
reject(err);
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
archive.pipe(output);
|
|
100
|
+
archive.directory(path, pathName);
|
|
101
|
+
archive.finalize();
|
|
102
|
+
});
|
|
103
|
+
}
|
|
@@ -22,6 +22,14 @@ export function printSuccessMessage(msg: string) {
|
|
|
22
22
|
console.log(displayAsMarkdown(`\n✔ ${msg}`));
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
+
export function printWarningMessage(msg: string) {
|
|
26
|
+
console.log(displayAsMarkdown(`\n⚠ ${msg}`));
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function printErrorMessage(msg: string) {
|
|
30
|
+
console.log(displayAsMarkdown(`\n❌ ${msg}`));
|
|
31
|
+
}
|
|
32
|
+
|
|
25
33
|
export function confirmPrompt(message: string): Promise<boolean> {
|
|
26
34
|
const prompt = new Confirm({
|
|
27
35
|
name: 'question',
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"$schema": "https://raw.githubusercontent.com/grafana/grafana/
|
|
2
|
+
"$schema": "https://raw.githubusercontent.com/grafana/grafana/main/docs/sources/developers/plugins/plugin.schema.json",
|
|
3
3
|
"type": "app",
|
|
4
4
|
"name": "{{ titleCase pluginName }}",
|
|
5
5
|
"id": "{{ normalize_id pluginName orgName 'app' }}",{{#if hasBackend}}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"$schema": "https://raw.githubusercontent.com/grafana/grafana/
|
|
2
|
+
"$schema": "https://raw.githubusercontent.com/grafana/grafana/main/docs/sources/developers/plugins/plugin.schema.json",
|
|
3
3
|
"type": "datasource",
|
|
4
4
|
"name": "{{ titleCase pluginName }}",
|
|
5
5
|
"id": "{{ normalize_id pluginName orgName 'datasource' }}",
|
|
@@ -29,7 +29,7 @@ jobs:
|
|
|
29
29
|
- name: Setup Go environment
|
|
30
30
|
uses: actions/setup-go@v3
|
|
31
31
|
with:
|
|
32
|
-
go-version: '1.
|
|
32
|
+
go-version: '1.21'
|
|
33
33
|
|
|
34
34
|
- name: Install dependencies
|
|
35
35
|
run: {{ packageManagerInstallCmd }}
|
|
@@ -78,13 +78,13 @@ jobs:
|
|
|
78
78
|
export GRAFANA_PLUGIN_VERSION=$(cat dist/plugin.json | jq -r .info.version)
|
|
79
79
|
export GRAFANA_PLUGIN_TYPE=$(cat dist/plugin.json | jq -r .type)
|
|
80
80
|
export GRAFANA_PLUGIN_ARTIFACT=${GRAFANA_PLUGIN_ID}-${GRAFANA_PLUGIN_VERSION}.zip
|
|
81
|
-
export
|
|
81
|
+
export GRAFANA_PLUGIN_ARTIFACT_SHA1SUM=${GRAFANA_PLUGIN_ARTIFACT}.sha1
|
|
82
82
|
|
|
83
83
|
echo "plugin-id=${GRAFANA_PLUGIN_ID}" >> $GITHUB_OUTPUT
|
|
84
84
|
echo "plugin-version=${GRAFANA_PLUGIN_VERSION}" >> $GITHUB_OUTPUT
|
|
85
85
|
echo "plugin-type=${GRAFANA_PLUGIN_TYPE}" >> $GITHUB_OUTPUT
|
|
86
86
|
echo "archive=${GRAFANA_PLUGIN_ARTIFACT}" >> $GITHUB_OUTPUT
|
|
87
|
-
echo "archive-
|
|
87
|
+
echo "archive-sha1sum=${GRAFANA_PLUGIN_ARTIFACT_SHA1SUM}" >> $GITHUB_OUTPUT
|
|
88
88
|
|
|
89
89
|
echo "github-tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
|
|
90
90
|
|
|
@@ -102,8 +102,7 @@ jobs:
|
|
|
102
102
|
run: |
|
|
103
103
|
mv dist $\{{ steps.metadata.outputs.plugin-id }}
|
|
104
104
|
zip $\{{ steps.metadata.outputs.archive }} $\{{ steps.metadata.outputs.plugin-id }} -r
|
|
105
|
-
|
|
106
|
-
echo "checksum=$(cat ./$\{{ steps.metadata.outputs.archive-checksum }} | cut -d' ' -f1)" >> $GITHUB_OUTPUT
|
|
105
|
+
sha1sum $\{{ steps.metadata.outputs.archive }} | cut -f1 -d' ' > $\{{ steps.metadata.outputs.archive-sha1sum }}
|
|
107
106
|
|
|
108
107
|
- name: Validate plugin
|
|
109
108
|
run: |
|
|
@@ -120,7 +119,7 @@ jobs:
|
|
|
120
119
|
generate_release_notes: true
|
|
121
120
|
files: |
|
|
122
121
|
./$\{{ steps.metadata.outputs.archive }}
|
|
123
|
-
./$\{{ steps.metadata.outputs.archive-
|
|
122
|
+
./$\{{ steps.metadata.outputs.archive-sha1sum }}
|
|
124
123
|
body: |
|
|
125
124
|
**This Github draft release has been created for your plugin.**
|
|
126
125
|
|
|
@@ -134,6 +133,6 @@ jobs:
|
|
|
134
133
|
- Click the **Submit Plugin** button
|
|
135
134
|
- Fill in the Plugin Submission form:
|
|
136
135
|
- Paste this [.zip asset link](https://github.com/$\{{ github.repository }}/releases/download/v$\{{ steps.metadata.outputs.plugin-version }}/$\{{ steps.metadata.outputs.archive }}) in the Plugin URL field
|
|
137
|
-
- Paste this [.zip.
|
|
136
|
+
- Paste this [.zip.sha1 link](https://github.com/${{ github.repository }}/releases/download/v${{ steps.metadata.outputs.plugin-version }}/${{ steps.metadata.outputs.archive-sha1sum }}) in the SHA1 field
|
|
138
137
|
|
|
139
138
|
Once done please remove these instructions and publish this release.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"$schema": "https://raw.githubusercontent.com/grafana/grafana/
|
|
2
|
+
"$schema": "https://raw.githubusercontent.com/grafana/grafana/main/docs/sources/developers/plugins/plugin.schema.json",
|
|
3
3
|
"type": "panel",
|
|
4
4
|
"name": "{{ titleCase pluginName }}",
|
|
5
5
|
"id": "{{ normalize_id pluginName orgName 'panel' }}",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"$schema": "https://raw.githubusercontent.com/grafana/grafana/
|
|
2
|
+
"$schema": "https://raw.githubusercontent.com/grafana/grafana/main/docs/sources/developers/plugins/plugin.schema.json",
|
|
3
3
|
"type": "app",
|
|
4
4
|
"name": "{{ titleCase pluginName }}",
|
|
5
5
|
"id": "{{ normalize_id pluginName orgName 'app' }}",{{#if hasBackend}}
|