@grafana/plugin-ui 0.2.1 โ 0.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.
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const node_child_process_1 = require("node:child_process");
|
|
6
|
+
const promises_1 = require("node:fs/promises");
|
|
7
|
+
const node_path_1 = require("node:path");
|
|
8
|
+
const prompts_1 = tslib_1.__importDefault(require("prompts"));
|
|
9
|
+
const read_1 = tslib_1.__importDefault(require("@changesets/read"));
|
|
10
|
+
const write_1 = tslib_1.__importDefault(require("@changesets/write"));
|
|
11
|
+
const changeTypes = {
|
|
12
|
+
feature: { icon: "๐", prefix: "Feature" },
|
|
13
|
+
fix: { icon: "๐", prefix: "Fix" },
|
|
14
|
+
docs: { icon: "๐", prefix: "Documentation" },
|
|
15
|
+
chore: { icon: "โ๏ธ", prefix: "Chore" },
|
|
16
|
+
tests: { icon: "๐งช", prefix: "Tests" },
|
|
17
|
+
refactor: { icon: "โ๏ธ", prefix: "Chore" },
|
|
18
|
+
};
|
|
19
|
+
const dir = process.cwd();
|
|
20
|
+
// First two arguments are `ts-node` and this file name.
|
|
21
|
+
// Actual changeset arguments start from the 3rd item.
|
|
22
|
+
const args = process.argv.slice(2);
|
|
23
|
+
(() => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
24
|
+
if (args[0] === "version") {
|
|
25
|
+
// If this is a version change we only need to update CHANGELOG.md
|
|
26
|
+
yield runChangesetCmd(args);
|
|
27
|
+
updateChangelogFile();
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
const changeSetIdsBefore = (yield (0, read_1.default)(dir)).map((c) => c.id);
|
|
31
|
+
yield runChangesetCmd(args);
|
|
32
|
+
const changeSetsAfter = yield (0, read_1.default)(dir);
|
|
33
|
+
if (changeSetsAfter.length <= changeSetIdsBefore.length) {
|
|
34
|
+
// There are no new changes, no need to continue
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
// Asking what's the change type
|
|
38
|
+
const { changeType } = yield (0, prompts_1.default)({
|
|
39
|
+
name: "changeType",
|
|
40
|
+
type: "select",
|
|
41
|
+
message: "What kind of change have you added?",
|
|
42
|
+
choices: Object.entries(changeTypes).map(([key, { icon }]) => ({
|
|
43
|
+
title: `${icon} ${key}`,
|
|
44
|
+
value: key,
|
|
45
|
+
})),
|
|
46
|
+
});
|
|
47
|
+
const { icon, prefix } = changeTypes[changeType];
|
|
48
|
+
// Adding change type to the changeset summary
|
|
49
|
+
const newChangeset = changeSetsAfter
|
|
50
|
+
.filter((change) => !changeSetIdsBefore.includes(change.id))
|
|
51
|
+
.map((changeset) => (Object.assign(Object.assign({}, changeset), { summary: `${icon} **${prefix}**: ${changeset.summary}` })))[0];
|
|
52
|
+
// Remove the original changeset file
|
|
53
|
+
yield (0, promises_1.rm)((0, node_path_1.join)(dir, ".changeset", `${newChangeset.id}.md`));
|
|
54
|
+
// Write a new changeset file (includes change type), returns the new id
|
|
55
|
+
const id = yield (0, write_1.default)(newChangeset, dir);
|
|
56
|
+
// Rename new file to previous name
|
|
57
|
+
yield (0, promises_1.rename)((0, node_path_1.join)(dir, ".changeset", `${id}.md`), (0, node_path_1.join)(dir, ".changeset", `${newChangeset.id}.md`));
|
|
58
|
+
}))();
|
|
59
|
+
function runChangesetCmd(args) {
|
|
60
|
+
return new Promise((resolve, reject) => {
|
|
61
|
+
const child = (0, node_child_process_1.fork)((0, node_path_1.join)(dir, "node_modules/.bin/changeset"), args);
|
|
62
|
+
child.on("error", reject);
|
|
63
|
+
child.on("close", (exitCode) => {
|
|
64
|
+
if (exitCode === 0) {
|
|
65
|
+
resolve();
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
reject(new Error(`Changeset process exited with exit code ${exitCode}`));
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
function updateChangelogFile() {
|
|
74
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
75
|
+
const filePath = (0, node_path_1.join)(dir, "CHANGELOG.md");
|
|
76
|
+
const content = yield (0, promises_1.readFile)(filePath, { encoding: "utf-8" });
|
|
77
|
+
const today = new Date();
|
|
78
|
+
const date = `0${today.getDate()}`.slice(-2);
|
|
79
|
+
const month = `0${today.getMonth() + 1}`.slice(-2);
|
|
80
|
+
const year = today.getFullYear();
|
|
81
|
+
const formattedDate = `${year}-${month}-${date}`;
|
|
82
|
+
const updatedChangeLog = content
|
|
83
|
+
// Remove unnecessary titles
|
|
84
|
+
.replace(/\s### (Patch|Minor|Major) Changes\s+/gi, "")
|
|
85
|
+
// Add `v` prefix to the version and add date
|
|
86
|
+
.replace(/## (\d+\.\d+.\d+)\s+/, `## v$1 - ${formattedDate}\n\n`);
|
|
87
|
+
yield (0, promises_1.writeFile)(filePath, updatedChangeLog);
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/changeset/index.ts"],"names":[],"mappings":";;;;AAEA,2DAA0C;AAC1C,+CAAmE;AACnE,yCAAiC;AACjC,8DAA8B;AAC9B,oEAA6C;AAC7C,sEAAgD;AAEhD,MAAM,WAAW,GAAG;IAClB,OAAO,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE;IAC1C,GAAG,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE;IAClC,IAAI,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,eAAe,EAAE;IAC7C,KAAK,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE;IACtC,KAA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com:grafana/plugin-ui.git",
|
|
5
5
|
"author": "Grafana Labs",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -12,7 +12,12 @@
|
|
|
12
12
|
"storybook": "start-storybook -p 6006",
|
|
13
13
|
"storybook:build": "build-storybook"
|
|
14
14
|
},
|
|
15
|
+
"bin": {
|
|
16
|
+
"changeset-improved": "./dist/utils/changeset/index.js"
|
|
17
|
+
},
|
|
15
18
|
"dependencies": {
|
|
19
|
+
"@changesets/read": "^0.5.9",
|
|
20
|
+
"@changesets/write": "^0.2.3",
|
|
16
21
|
"@grafana/data": "^8.4.7",
|
|
17
22
|
"@grafana/experimental": "^0.0.2-canary.39",
|
|
18
23
|
"@grafana/runtime": "^8.4.7",
|
|
@@ -25,6 +30,7 @@
|
|
|
25
30
|
"copyfiles": "^2.4.1",
|
|
26
31
|
"lodash": "^4.17.21",
|
|
27
32
|
"memoize-one": "^5.1.1",
|
|
33
|
+
"prompts": "^2.4.2",
|
|
28
34
|
"rc-cascader": "1.0.1",
|
|
29
35
|
"react-awesome-query-builder": "^5.3.1",
|
|
30
36
|
"react-use": "17.3.1",
|
|
@@ -50,6 +56,7 @@
|
|
|
50
56
|
"@testing-library/react": "^11.2.2",
|
|
51
57
|
"@testing-library/user-event": "^12.8.3",
|
|
52
58
|
"@types/lodash": "^4.14.194",
|
|
59
|
+
"@types/prompts": "^2.4.4",
|
|
53
60
|
"@types/react": "17.0.38",
|
|
54
61
|
"@types/semver": "^7.5.0",
|
|
55
62
|
"@types/testing-library__jest-dom": "^5.9.5",
|
|
@@ -58,6 +65,9 @@
|
|
|
58
65
|
"mockdate": "^3.0.2",
|
|
59
66
|
"ts-jest": "^26.4.4"
|
|
60
67
|
},
|
|
68
|
+
"peerDependencies": {
|
|
69
|
+
"@changesets/cli": ">=2.x"
|
|
70
|
+
},
|
|
61
71
|
"files": [
|
|
62
72
|
"dist/**/*",
|
|
63
73
|
"package.json"
|