-
Notifications
You must be signed in to change notification settings - Fork 2
/
generate-readme.js
89 lines (83 loc) · 3.42 KB
/
generate-readme.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
// Generates the sploits section of the README.md
var fs;
var sploits;
if (!sploits) {
fs = require("fs");
sploits = require("./sploits.json");
}
var lines = [];
var links = [];
sploits.forEach(function (sploit, i) {
lines.push(`## ${sploit.usability}\n`);
lines.push(
`| Cover Art | Details | Exploit |`
);
lines.push(`| --------- | :---------: | ------- |`);
sploit.titles.forEach(function (title, k) {
if (!title.notes) {
title.notes = [];
}
let game = title.title;
let brC = game.indexOf(":");
let brP = game.indexOf("(");
if (brC > -1 && brP > -1) {
if (brC < brP) {
brP = -1; // forget the later (
} else {
brC = -1; // forget the later :
}
}
if (brP > -1) {
game = game.slice(0, brP) + "<br>" + game.slice(brP);
} else if (brC > -1) {
game = game.slice(0, brC + 1) + "<br>" + game.slice(brC + 1);
}
let hack = "";
let complexity = "";
let notes = (title.notes.length && title.notes.join("<br>")) || "N/A";
if (title.hack) {
hack = `<em>"${title.hack}"</em><br> `;
}
if (title.time) {
complexity = `(${title.time}s`;
if (title.buttons) {
complexity += ` and ${title.buttons.length} button${
1 === title.buttons.length ? "" : "s"
})`;
notes += "<br>Buttons: " + (title.buttons.join(", ") || "N/A");
}
}
if (complexity) {
complexity = `<br>${complexity}<br>`;
}
lines.push(
`| ![][box-${i}-${k}] | <br> **${game}** ${complexity} <br> ![][disc-${i}-${k}]<br><strong>${
title.price
}</strong><br>[Amazon](${title.amazon}) \\| [eBay](${
title.ebay
})<br> | ${hack}<br>Github: [${
title.source.name
}][source-${i}-${k}] <br>**Download**: [${title.download.replace(
/https:\/\//,
""
)}][download-${i}-${k}] <br>**Instructions**: [${
title.readme.name
}][readme-${i}-${k}] <br>Demo: [${
title.demo.name
}][demo-${i}-${k}] <br><br>Notes: ${notes} |`
);
links.push(`[box-${i}-${k}]: ${title.case} "Box Art"`);
links.push(`[disc-${i}-${k}]: ${title.disc} "Disc Art"`);
links.push(`[source-${i}-${k}]: ${title.source.link} "Source Code"`);
links.push(`[download-${i}-${k}]: ${title.download} "Download"`);
links.push(`[readme-${i}-${k}]: ${title.readme.link} "Instructions"`);
links.push(`[demo-${i}-${k}]: ${title.demo.link} "YouTube Demo"`);
});
lines.push("");
});
var body = lines.join("\n") + "\n\n" + links.join("\n");
if (fs) {
fs.writeFileSync("./README.sploits.md", body, "utf8");
} else {
console.info(body);
}