color-name-list 10.17.0 → 10.18.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/package.json +1 -1
- package/scripts/tools/history.js +66 -0
package/package.json
CHANGED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
const child_process = require("child_process");
|
|
2
|
+
const readline = require("readline");
|
|
3
|
+
|
|
4
|
+
function cmd(c) {
|
|
5
|
+
const stdout = child_process.execSync(c);
|
|
6
|
+
return stdout.toString().trim();
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
// Print the list of colors added/removed/changed by date.
|
|
10
|
+
// Pretty inefficient due to the many git commands (optimized for clarity)
|
|
11
|
+
async function main() {
|
|
12
|
+
|
|
13
|
+
// Grab the list of all git commits
|
|
14
|
+
const allCommits = cmd("git log --pretty=format:%h").split("\n").filter(Boolean);
|
|
15
|
+
|
|
16
|
+
// The data, one element for each commit (date)
|
|
17
|
+
const dat = [];
|
|
18
|
+
|
|
19
|
+
for (const commit of allCommits) {
|
|
20
|
+
|
|
21
|
+
// Figure out what changed in that particular commit
|
|
22
|
+
const diff = cmd(`git show ${commit} -- ./src/colornames.csv`)
|
|
23
|
+
.split("\n").filter(Boolean);
|
|
24
|
+
|
|
25
|
+
// Grab the date for said commit
|
|
26
|
+
const dt = cmd(`git show -s ${commit} --format=%ci`);
|
|
27
|
+
|
|
28
|
+
// The list of color modified (indexed by hex value) with "op" (+/-/~)
|
|
29
|
+
const modified = {};
|
|
30
|
+
|
|
31
|
+
for(const line of diff) {
|
|
32
|
+
const res = line.match(/^((?<op>(\+|-)))(?<name>[^,]+),(?<hex>[^,]+)/)
|
|
33
|
+
if(!res) { continue; }
|
|
34
|
+
const name = res.groups?.name;
|
|
35
|
+
const hex = res.groups?.hex;
|
|
36
|
+
var op = res.groups?.op;
|
|
37
|
+
|
|
38
|
+
// If a value already introduced with a different op, then it's
|
|
39
|
+
// a modification
|
|
40
|
+
if(modified[hex] && modified[hex].op !== op) { op = "~" }
|
|
41
|
+
|
|
42
|
+
modified[hex] = { hex, name, op };
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Partition by added/removed/changed
|
|
46
|
+
|
|
47
|
+
const added = Object.values(modified)
|
|
48
|
+
.filter(x => x.op === "+")
|
|
49
|
+
.map(({name, hex}) => ({ name, hex }));
|
|
50
|
+
|
|
51
|
+
const removed = Object.values(modified)
|
|
52
|
+
.filter(x => x.op === "-")
|
|
53
|
+
.map(({name, hex}) => ({ name, hex }));
|
|
54
|
+
|
|
55
|
+
const changed = Object.values(modified)
|
|
56
|
+
.filter(x => x.op === "~")
|
|
57
|
+
.map(({name, hex}) => ({ name, hex }));
|
|
58
|
+
|
|
59
|
+
// Add the day
|
|
60
|
+
dat.push({ date: dt, added, removed, changed });
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
console.log(JSON.stringify(dat));
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
main()
|