@grafana/sign-plugin 1.0.2 → 1.0.3
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 +12 -0
- package/CONTRIBUTING.md +4 -4
- package/dist/utils/manifest.js +3 -3
- package/dist/utils/request.js +89 -0
- package/package.json +2 -3
- package/src/utils/manifest.ts +3 -3
- package/src/utils/request.ts +51 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
# v1.0.3 (Mon Jul 10 2023)
|
|
2
|
+
|
|
3
|
+
#### 🐛 Bug Fix
|
|
4
|
+
|
|
5
|
+
- Chore: Remove axios as a dependency for sign-plugin [#292](https://github.com/grafana/plugin-tools/pull/292) ([@academo](https://github.com/academo))
|
|
6
|
+
|
|
7
|
+
#### Authors: 1
|
|
8
|
+
|
|
9
|
+
- Esteban Beltran ([@academo](https://github.com/academo))
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
1
13
|
# v1.0.1 (Fri Mar 03 2023)
|
|
2
14
|
|
|
3
15
|
#### 🐛 Bug Fix
|
package/CONTRIBUTING.md
CHANGED
|
@@ -7,14 +7,14 @@ The following guidelines help you on how to start with the codebase and how to s
|
|
|
7
7
|
|
|
8
8
|
### Prerequisites
|
|
9
9
|
|
|
10
|
-
You need to have `npm`
|
|
10
|
+
You need to have `npm` installed.
|
|
11
11
|
|
|
12
12
|
### Installing
|
|
13
13
|
|
|
14
14
|
```bash
|
|
15
15
|
git clone git@github.com:grafana/plugin-tools.git
|
|
16
16
|
cd plugin-tools
|
|
17
|
-
|
|
17
|
+
npm install
|
|
18
18
|
```
|
|
19
19
|
|
|
20
20
|
## Overview
|
|
@@ -36,11 +36,11 @@ There are a collection of [commands](#commmands) to assist with developing `sign
|
|
|
36
36
|
Below are the main commands used for developing `sign-plugin`. They can be run by either `yarn workspace @grafana/sign-plugin run <name_of_command>` or navigating to `packages/sign-plugin` and running the command directly as detailed below.
|
|
37
37
|
|
|
38
38
|
```shell
|
|
39
|
-
|
|
39
|
+
npm build # used to build @grafana/sign-plugin
|
|
40
40
|
```
|
|
41
41
|
|
|
42
42
|
```shell
|
|
43
|
-
|
|
43
|
+
npm dev # watches for changes to files and rebuilds @grafana/sign-plugin automatically
|
|
44
44
|
```
|
|
45
45
|
|
|
46
46
|
### Conventions
|
package/dist/utils/manifest.js
CHANGED
|
@@ -79,7 +79,7 @@ var crypto_1 = __importDefault(require("crypto"));
|
|
|
79
79
|
var promises_1 = __importDefault(require("fs/promises"));
|
|
80
80
|
var fs_1 = require("fs");
|
|
81
81
|
var path_1 = __importDefault(require("path"));
|
|
82
|
-
var
|
|
82
|
+
var request_1 = require("./request");
|
|
83
83
|
var MANIFEST_FILE = 'MANIFEST.txt';
|
|
84
84
|
function walk(dir, baseDir) {
|
|
85
85
|
return __asyncGenerator(this, arguments, function walk_1() {
|
|
@@ -225,8 +225,8 @@ function signManifest(manifest) {
|
|
|
225
225
|
_c.label = 1;
|
|
226
226
|
case 1:
|
|
227
227
|
_c.trys.push([1, 3, , 4]);
|
|
228
|
-
return [4,
|
|
229
|
-
|
|
228
|
+
return [4, (0, request_1.postData)(url, manifest, {
|
|
229
|
+
Authorization: 'Bearer ' + GRAFANA_API_KEY
|
|
230
230
|
})];
|
|
231
231
|
case 2:
|
|
232
232
|
info = _c.sent();
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
+
function step(op) {
|
|
27
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
+
while (_) try {
|
|
29
|
+
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;
|
|
30
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
+
switch (op[0]) {
|
|
32
|
+
case 0: case 1: t = op; break;
|
|
33
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
+
default:
|
|
37
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
+
if (t[2]) _.ops.pop();
|
|
42
|
+
_.trys.pop(); continue;
|
|
43
|
+
}
|
|
44
|
+
op = body.call(thisArg, _);
|
|
45
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
50
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
51
|
+
};
|
|
52
|
+
exports.__esModule = true;
|
|
53
|
+
exports.postData = void 0;
|
|
54
|
+
var https_1 = __importDefault(require("https"));
|
|
55
|
+
var url_1 = require("url");
|
|
56
|
+
function postData(urlString, data, headers) {
|
|
57
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
58
|
+
return __generator(this, function (_a) {
|
|
59
|
+
return [2, new Promise(function (resolve, reject) {
|
|
60
|
+
var url = new url_1.URL(urlString);
|
|
61
|
+
var postData = JSON.stringify(data);
|
|
62
|
+
var options = {
|
|
63
|
+
hostname: url.hostname,
|
|
64
|
+
port: url.port || 443,
|
|
65
|
+
path: url.pathname,
|
|
66
|
+
method: 'POST',
|
|
67
|
+
headers: __assign(__assign({}, headers), { 'Content-Type': 'application/json' })
|
|
68
|
+
};
|
|
69
|
+
var req = https_1["default"].request(options, function (res) {
|
|
70
|
+
var chunks = [];
|
|
71
|
+
res.on('data', function (chunk) { return chunks.push(chunk); });
|
|
72
|
+
res.on('end', function () {
|
|
73
|
+
var _a;
|
|
74
|
+
var results = Buffer.concat(chunks);
|
|
75
|
+
resolve({
|
|
76
|
+
data: results.toString(),
|
|
77
|
+
status: (_a = res.statusCode) !== null && _a !== void 0 ? _a : 200
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
res.on('error', reject);
|
|
81
|
+
});
|
|
82
|
+
req.on('error', reject);
|
|
83
|
+
req.write(postData);
|
|
84
|
+
req.end();
|
|
85
|
+
})];
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
exports.postData = postData;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@grafana/sign-plugin",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"repository": {
|
|
6
6
|
"directory": "packages/sign-plugin",
|
|
@@ -23,7 +23,6 @@
|
|
|
23
23
|
"typecheck": "tsc --noEmit"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"axios": "^1.1.3",
|
|
27
26
|
"minimist": "^1.2.2"
|
|
28
27
|
},
|
|
29
28
|
"devDependencies": {
|
|
@@ -41,5 +40,5 @@
|
|
|
41
40
|
"engines": {
|
|
42
41
|
"node": ">=16"
|
|
43
42
|
},
|
|
44
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "45b14f317e18f7f76655292c01d853e5b991cb36"
|
|
45
44
|
}
|
package/src/utils/manifest.ts
CHANGED
|
@@ -2,7 +2,7 @@ import crypto from 'crypto';
|
|
|
2
2
|
import fs from 'fs/promises';
|
|
3
3
|
import { readFileSync, writeFileSync } from 'fs';
|
|
4
4
|
import path from 'path';
|
|
5
|
-
import
|
|
5
|
+
import { postData } from './request';
|
|
6
6
|
|
|
7
7
|
const MANIFEST_FILE = 'MANIFEST.txt';
|
|
8
8
|
|
|
@@ -86,8 +86,8 @@ export async function signManifest(manifest: ManifestInfo): Promise<string> {
|
|
|
86
86
|
const url = GRAFANA_COM_URL + '/plugins/ci/sign';
|
|
87
87
|
|
|
88
88
|
try {
|
|
89
|
-
const info = await
|
|
90
|
-
|
|
89
|
+
const info = await postData(url, manifest, {
|
|
90
|
+
Authorization: 'Bearer ' + GRAFANA_API_KEY,
|
|
91
91
|
});
|
|
92
92
|
if (info.status !== 200) {
|
|
93
93
|
console.error('Error: ', info);
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import https, { RequestOptions } from 'https';
|
|
2
|
+
import { URL } from 'url';
|
|
3
|
+
|
|
4
|
+
interface Headers {
|
|
5
|
+
Authorization: string;
|
|
6
|
+
[header: string]: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
interface Response<R> {
|
|
10
|
+
data: R;
|
|
11
|
+
status: number;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export async function postData(urlString: string, data: unknown, headers: Headers): Promise<Response<string>> {
|
|
15
|
+
return new Promise<Response<string>>((resolve, reject) => {
|
|
16
|
+
const url = new URL(urlString);
|
|
17
|
+
const postData = JSON.stringify(data);
|
|
18
|
+
|
|
19
|
+
const options: RequestOptions = {
|
|
20
|
+
hostname: url.hostname,
|
|
21
|
+
port: url.port || 443,
|
|
22
|
+
path: url.pathname,
|
|
23
|
+
method: 'POST',
|
|
24
|
+
headers: {
|
|
25
|
+
...headers,
|
|
26
|
+
'Content-Type': 'application/json',
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const req = https.request(options, (res) => {
|
|
31
|
+
const chunks: Buffer[] = [];
|
|
32
|
+
|
|
33
|
+
res.on('data', (chunk: Buffer) => chunks.push(chunk));
|
|
34
|
+
|
|
35
|
+
res.on('end', () => {
|
|
36
|
+
const results = Buffer.concat(chunks);
|
|
37
|
+
resolve({
|
|
38
|
+
data: results.toString(),
|
|
39
|
+
status: res.statusCode ?? 200,
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
res.on('error', reject);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
req.on('error', reject);
|
|
47
|
+
|
|
48
|
+
req.write(postData);
|
|
49
|
+
req.end();
|
|
50
|
+
});
|
|
51
|
+
}
|