-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.ts
140 lines (130 loc) · 5.03 KB
/
build.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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
import { FileContents } from "@javarome/fileutil"
import { CLI, PeopleDirectoryStepOptions, RR0Build, TimeServiceOptions } from "@rr0/cms"
import { glob } from "glob"
interface RR0BuildArgs {
/**
* Configuration file
*/
config?: string
/**
* If the search index must be regenerated or not.
* For ex: "pages,sources"
*/
reindex?: string[]
/**
* Comma-separated list of file patterns to parse as contents.
*/
contents?: string[]
/**
* Comma-separated list of file patterns to copy to out dir.
*/
copies?: string[]
/**
* Comma-separated list of file patterns to books to generate TOCs for.
*/
books?: string
/**
* Force re-generation even if file has not changed.
*/
force?: string
}
console.time("ssg")
let args = new CLI().getArgs<RR0BuildArgs>()
const configFile = args.config
if (configFile) {
args = JSON.parse(FileContents.read(configFile).contents)
}
const cliContents = args.contents
console.debug("contents", cliContents)
const mandatoryRoots = ["people/*.html", "science/crypto/ufo/enquete/dossier/*.html"]
const contentRoots = cliContents
? cliContents.concat(mandatoryRoots)
: [
"croyance/**/*.html",
"index.html", "404.html", "googlebe03dcf00678bb7c.html", "Contact.html", "Copyright.html", "preambule.html", "FAQ.html", "Referencement.html",
"time/**/*.html",
"book/**/*.html",
"droit/**/*.html",
"org/**/*.html",
"people/**/*.html",
"place/**/*.html",
"politique/**/*.html",
"science/**/*.html",
"tech/**/*.html",
"udb/*.html",
"js/**/*.html"
]
const copiesArg = args.copies
const copies = copiesArg ? copiesArg : [
"favicon.ico", "manifest.json", "opensearch.xml", "apple-touch-icon.png", "apple-touch-icon_400x400.png", "screenshot1.jpg",
"rr0.css", "map.css", "diagram.css", "print.css", "figure.css", "section.css", "table.css", "nav.css",
// "**/*.png", "**/*.jpg", "**/*.gif", "**/*.webp", "!out/**/*",
"**/*.cmmn", "**/*.bpmn",
"tech/info/soft/reseau/protocole/index.js", "tech/info/soft/reseau/protocole/ports.json", "tech/info/soft/reseau/protocole/index.css",
"tech/info/soft/data/doc/index.js", "tech/info/soft/data/doc/index.json", "tech/info/soft/data/doc/index.css",
"people/index.js", "people/index.css", "people/witness/index.css",
"search/SearchComponent.mjs", "search/index.json", "search/search.css",
"source/index.css", "note/index.css",
"link.css", "quote.css",
"time/DualRangeComponent.mjs",
"index/index.js", "lang/form.js", "lang/form.css", "lang/speech.js", "lang/speech.css",
"croyance/divin/theisme/mono/livre/islam/coran/index.js"
]
const outDir = "out"
const googleMapsApiKey = process.env.GOOGLE_MAPS_API_KEY
if (!googleMapsApiKey) {
throw Error("GOOGLE_MAPS_API_KEY is required")
}
const timeOptions: TimeServiceOptions = {
root: "time",
files: []
}
const timeFormat: Intl.DateTimeFormatOptions = {
year: "numeric",
month: "long",
day: "numeric",
weekday: "long",
hour: "2-digit",
minute: "2-digit"
}
async function getTimeFiles(): Promise<string[]> {
const minusYearFiles = await glob("time/-?/?/?/?/index.html")
const year1Files = await glob("time/?/index.html")
const year2Files = await glob("time/?/?/index.html")
const year3Files = await glob("time/?/?/?/index.html")
const year4Files = await glob("time/?/?/?/?/index.html")
const monthFiles = await glob("time/?/?/?/?/??/index.html")
const dayFiles = await glob("time/?/?/?/?/??/??/index.html")
return year1Files.concat(year2Files).concat(year3Files).concat(year4Files).concat(
minusYearFiles).concat(monthFiles).concat(dayFiles).sort()
}
const directoryPages = [
"people/index.html", "people/witness/index.html", "people/militaires.html", "people/scientifiques.html", "people/astronomes.html", "people/politicians.html", "people/dirigeants.html", "people/pilotes.html", "people/contactes.html", "people/ufologues.html", "tech/info/Personnes.html", "people/Contributeurs.html"
]
getTimeFiles().then(async (timeFiles) => {
const sourceRegistryFileName = "source/index.json"
const directoryOptions: PeopleDirectoryStepOptions = {
root: "people/index.html",
scientists: "people/scientifiques.html",
ufologists: "people/ufologues.html",
ufoWitnesses: "people/witness/index.html",
astronomers: "people/astronomes.html",
contactees: "people/contactes.html",
pilots: "people/pilotes.html",
military: "people/militaires.html",
softwareEngineers: "tech/info/Personnes.html",
politicians: "people/politicians.html",
rulers: "people/dirigeants.html"
}
const siteBaseUrl = "https://rr0.org/"
const mail = "[email protected]"
const build = new RR0Build({
contentRoots, copies, outDir, locale: "fr", googleMapsApiKey, mail, timeOptions,
siteBaseUrl, timeFormat, timeFiles, directoryPages,
ufoCaseDirectoryFile: "science/crypto/ufo/enquete/dossier/index.html",
ufoCasesExclusions: ["science/crypto/ufo/enquete/dossier/canular"], sourceRegistryFileName,
directoryExcluded: ["people/Astronomers_fichiers", "people/witness", "people/author"],
directoryOptions
})
await build.run(args)
})