-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.ts
97 lines (82 loc) · 2.75 KB
/
main.ts
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
90
91
92
93
94
95
96
97
import { DebugReport } from "./classes/DebugReport.js"
import { emitResourcePacks, generateStats } from "./builder.js"
import fixes from "./fixes.js"
import {
MinecraftVersionBranch,
MinecraftVersionSpecifier,
fetchVersionsSummary,
} from "./helpers/minecraftHelpers.js"
import { MinecraftVersionRange } from "./classes/minecraftVersions.js"
export async function printStats(limitToLatest?: MinecraftVersionBranch) {
const versions: MinecraftVersionSpecifier = limitToLatest
? {
type: "latest",
branch: limitToLatest,
}
: targetVersions
const stats = await generateStats(fixes, {
version: versions,
})
const { bugReports, translationKeys } = stats.count
const versionString = limitToLatest
? `the latest ${limitToLatest}`
: `all versions`
console.log(`Statistics for ${versionString}:`)
console.log(` Fixed bugs: ${bugReports}`)
console.log(` Translation keys: ${translationKeys}`)
}
export async function buildPack() {
return await emitResourcePacks(fixes, {
targetVersions,
targetLanguages,
clearDirectory: true,
packVersion: commandLineArg,
// If no version was specified, just name the zip after the MC version it targets:
filename: commandLineArg
? undefined
: (minecraftVersion) => `${minecraftVersion}.zip`,
})
}
function getStatsFilter(): MinecraftVersionBranch | undefined {
if (process.argv[3] === "--latest-snapshot") return "snapshot"
if (process.argv[3] === "--latest-release") return "release"
return undefined
}
export const packDescription =
"Fixes issues with text labels.\nSource: §9§nbit.ly/CapsFix"
export const debugReport = new DebugReport()
console.log("Fetching Minecraft version information...")
export const versionsSummary = await fetchVersionsSummary()
export const cache = new Map<string, any>()
const commandLineArg = process.argv[2]
const targetVersions = new MinecraftVersionRange({
include: [
// new MinecraftVersionRange({ only: "1.19.2" }),
// new MinecraftVersionRange({ only: "1.19.3" }),
// new MinecraftVersionRange({ only: "1.19.4" }),
// new MinecraftVersionRange({ only: "1.20" }),
new MinecraftVersionRange({ only: "1.20.5" }),
new MinecraftVersionRange({ only: "1.20.6" }),
],
})
const targetLanguages = ["en_us", "en_gb"]
try {
commandLineArg === "--stats"
? await printStats(getStatsFilter())
: await buildPack()
} catch (error) {
console.error(error)
debugger
} finally {
// Save the debug report
const now = new Date()
const date = now.toISOString().slice(0, 10)
const time = now.toLocaleTimeString("en-US", {
hour: "2-digit",
minute: "2-digit",
second: "2-digit",
hour12: false,
})
debugReport.end()
await debugReport.exportToFile("debug", `${date} ${time}.json`)
}