This commit is contained in:
parent
aa7a0187db
commit
cb66797214
6 changed files with 271 additions and 14 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,2 +1,3 @@
|
|||
build/
|
||||
node_modules/
|
||||
build.js/
|
||||
|
|
|
@ -10,7 +10,8 @@ pipeline:
|
|||
|
||||
- pnpm set registry http://npm.proxy.coso
|
||||
- pnpm install
|
||||
- node compilar.js
|
||||
- pnpm check
|
||||
- pnpm build
|
||||
|
||||
- apk add rsync openssh-client-default
|
||||
|
||||
|
|
|
@ -9,12 +9,16 @@ const execFile = promisify(execFileCallback);
|
|||
const reader = new commonmark.Parser({ smart: true });
|
||||
const writer = new commonmark.HtmlRenderer({ safe: false, smart: true });
|
||||
|
||||
const config = {
|
||||
interface Config {
|
||||
sourcePath: string;
|
||||
buildPath: string;
|
||||
}
|
||||
const config: Config = {
|
||||
sourcePath: ".",
|
||||
buildPath: "build",
|
||||
};
|
||||
|
||||
function head(title, outputName) {
|
||||
function head(title: string, outputName: string) {
|
||||
// TODO: deshardcodear og:url
|
||||
return `<!doctype html>
|
||||
<meta charset=utf-8>
|
||||
|
@ -30,7 +34,7 @@ function head(title, outputName) {
|
|||
`;
|
||||
}
|
||||
|
||||
function header(title, sourceCodePath, linkConexiones = false) {
|
||||
function header(title: string, sourceCodePath: string, linkConexiones = false) {
|
||||
return (
|
||||
`<a href=.>☚ Volver al inicio</a>` +
|
||||
`<header>
|
||||
|
@ -46,7 +50,7 @@ function header(title, sourceCodePath, linkConexiones = false) {
|
|||
}
|
||||
const wikilinkExp = /\[\[(.+?)\]\]/giu;
|
||||
|
||||
async function scanForConnections(sourcePath) {
|
||||
async function scanForConnections(sourcePath: string) {
|
||||
const dir = await opendir(sourcePath);
|
||||
let connections = [];
|
||||
for await (const entry of dir) {
|
||||
|
@ -62,7 +66,7 @@ async function scanForConnections(sourcePath) {
|
|||
return connections;
|
||||
}
|
||||
|
||||
function hackilyTransformHtml(html) {
|
||||
function hackilyTransformHtml(html: string) {
|
||||
return html
|
||||
.replaceAll("<a h", '<a rel="noopener noreferrer" h')
|
||||
.replaceAll(wikilinkExp, `<a href="$1.html">$1</a>`);
|
||||
|
@ -73,7 +77,7 @@ const connections = await scanForConnections(config.sourcePath);
|
|||
await mkdir(config.buildPath, { recursive: true });
|
||||
|
||||
const dir = await opendir(config.sourcePath);
|
||||
let pageList = [];
|
||||
let pageList: string[] = [];
|
||||
let promises = [];
|
||||
for await (const entry of dir) {
|
||||
if (!entry.isFile()) continue;
|
||||
|
@ -83,7 +87,7 @@ await Promise.all(promises);
|
|||
|
||||
await compilePageList(config, pageList);
|
||||
|
||||
async function compileFile(name) {
|
||||
async function compileFile(name: string) {
|
||||
const extension = extname(name);
|
||||
if (
|
||||
[".js", ".md", ".css", ".png", ".jpg", ".mp4", ".svg", ".html"].includes(
|
||||
|
@ -100,7 +104,7 @@ async function compileFile(name) {
|
|||
else if (extension === ".gen") await compileExecutable(config, name);
|
||||
}
|
||||
|
||||
async function compilePageList(config, pageList) {
|
||||
async function compilePageList(config: Config, pageList: string[]) {
|
||||
const name = "Lista de páginas";
|
||||
const outputPath = join(config.buildPath, name + ".html");
|
||||
const html =
|
||||
|
@ -114,7 +118,7 @@ async function compilePageList(config, pageList) {
|
|||
`;
|
||||
await writeFile(outputPath, html);
|
||||
}
|
||||
async function compileMarkdown(config, sourceFileName) {
|
||||
async function compileMarkdown(config: Config, sourceFileName: string) {
|
||||
const name = basename(sourceFileName, ".md");
|
||||
const markdown = await readFile(
|
||||
join(config.sourcePath, sourceFileName),
|
||||
|
@ -149,7 +153,7 @@ async function compileMarkdown(config, sourceFileName) {
|
|||
await writeFile(outputPath, html);
|
||||
}
|
||||
|
||||
async function compileExecutable(config, sourceFileName) {
|
||||
async function compileExecutable(config: Config, sourceFileName: string) {
|
||||
const name = basename(sourceFileName, ".gen");
|
||||
|
||||
const { stdout, stderr } = await execFile(
|
||||
|
@ -170,7 +174,7 @@ async function compileExecutable(config, sourceFileName) {
|
|||
// Markdown utils
|
||||
// ==============================================
|
||||
|
||||
function renderMarkdown(markdown) {
|
||||
function renderMarkdown(markdown: string) {
|
||||
const parsed = reader.parse(markdown);
|
||||
return writer.render(parsed);
|
||||
}
|
|
@ -5,14 +5,18 @@
|
|||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
"build-ts": "esbuild compilar.ts --target=node18 --outdir=build.js --sourcemap",
|
||||
"build": "pnpm build-ts && node build.js/compilar.js",
|
||||
"check": "tsc --noEmit"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"devDependencies": {
|
||||
"@types/commonmark": "^0.27.5",
|
||||
"@types/node": "^18.11.17"
|
||||
"@types/node": "^18.11.17",
|
||||
"esbuild": "^0.16.10",
|
||||
"typescript": "^4.9.4"
|
||||
},
|
||||
"dependencies": {
|
||||
"commonmark": "^0.30.0"
|
||||
|
|
238
pnpm-lock.yaml
238
pnpm-lock.yaml
|
@ -4,6 +4,8 @@ specifiers:
|
|||
'@types/commonmark': ^0.27.5
|
||||
'@types/node': ^18.11.17
|
||||
commonmark: ^0.30.0
|
||||
esbuild: ^0.16.10
|
||||
typescript: ^4.9.4
|
||||
|
||||
dependencies:
|
||||
commonmark: 0.30.0
|
||||
|
@ -11,9 +13,209 @@ dependencies:
|
|||
devDependencies:
|
||||
'@types/commonmark': 0.27.5
|
||||
'@types/node': 18.11.17
|
||||
esbuild: 0.16.10
|
||||
typescript: 4.9.4
|
||||
|
||||
packages:
|
||||
|
||||
/@esbuild/android-arm/0.16.10:
|
||||
resolution: {integrity: sha512-RmJjQTRrO6VwUWDrzTBLmV4OJZTarYsiepLGlF2rYTVB701hSorPywPGvP6d8HCuuRibyXa5JX4s3jN2kHEtjQ==}
|
||||
engines: {node: '>=12'}
|
||||
cpu: [arm]
|
||||
os: [android]
|
||||
requiresBuild: true
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/android-arm64/0.16.10:
|
||||
resolution: {integrity: sha512-47Y+NwVKTldTlDhSgJHZ/RpvBQMUDG7eKihqaF/u6g7s0ZPz4J1vy8A3rwnnUOF2CuDn7w7Gj/QcMoWz3U3SJw==}
|
||||
engines: {node: '>=12'}
|
||||
cpu: [arm64]
|
||||
os: [android]
|
||||
requiresBuild: true
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/android-x64/0.16.10:
|
||||
resolution: {integrity: sha512-C4PfnrBMcuAcOurQzpF1tTtZz94IXO5JmICJJ3NFJRHbXXsQUg9RFG45KvydKqtFfBaFLCHpduUkUfXwIvGnRg==}
|
||||
engines: {node: '>=12'}
|
||||
cpu: [x64]
|
||||
os: [android]
|
||||
requiresBuild: true
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/darwin-arm64/0.16.10:
|
||||
resolution: {integrity: sha512-bH/bpFwldyOKdi9HSLCLhhKeVgRYr9KblchwXgY2NeUHBB/BzTUHtUSBgGBmpydB1/4E37m+ggXXfSrnD7/E7g==}
|
||||
engines: {node: '>=12'}
|
||||
cpu: [arm64]
|
||||
os: [darwin]
|
||||
requiresBuild: true
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/darwin-x64/0.16.10:
|
||||
resolution: {integrity: sha512-OXt7ijoLuy+AjDSKQWu+KdDFMBbdeaL6wtgMKtDUXKWHiAMKHan5+R1QAG6HD4+K0nnOvEJXKHeA9QhXNAjOTQ==}
|
||||
engines: {node: '>=12'}
|
||||
cpu: [x64]
|
||||
os: [darwin]
|
||||
requiresBuild: true
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/freebsd-arm64/0.16.10:
|
||||
resolution: {integrity: sha512-shSQX/3GHuspE3Uxtq5kcFG/zqC+VuMnJkqV7LczO41cIe6CQaXHD3QdMLA4ziRq/m0vZo7JdterlgbmgNIAlQ==}
|
||||
engines: {node: '>=12'}
|
||||
cpu: [arm64]
|
||||
os: [freebsd]
|
||||
requiresBuild: true
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/freebsd-x64/0.16.10:
|
||||
resolution: {integrity: sha512-5YVc1zdeaJGASijZmTzSO4h6uKzsQGG3pkjI6fuXvolhm3hVRhZwnHJkforaZLmzvNv5Tb7a3QL2FAVmrgySIA==}
|
||||
engines: {node: '>=12'}
|
||||
cpu: [x64]
|
||||
os: [freebsd]
|
||||
requiresBuild: true
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/linux-arm/0.16.10:
|
||||
resolution: {integrity: sha512-c360287ZWI2miBnvIj23bPyVctgzeMT2kQKR+x94pVqIN44h3GF8VMEs1SFPH1UgyDr3yBbx3vowDS1SVhyVhA==}
|
||||
engines: {node: '>=12'}
|
||||
cpu: [arm]
|
||||
os: [linux]
|
||||
requiresBuild: true
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/linux-arm64/0.16.10:
|
||||
resolution: {integrity: sha512-2aqeNVxIaRfPcIaMZIFoblLh588sWyCbmj1HHCCs9WmeNWm+EIN0SmvsmPvTa/TsNZFKnxTcvkX2eszTcCqIrA==}
|
||||
engines: {node: '>=12'}
|
||||
cpu: [arm64]
|
||||
os: [linux]
|
||||
requiresBuild: true
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/linux-ia32/0.16.10:
|
||||
resolution: {integrity: sha512-sqMIEWeyrLGU7J5RB5fTkLRIFwsgsQ7ieWXlDLEmC2HblPYGb3AucD7inw2OrKFpRPKsec1l+lssiM3+NV5aOw==}
|
||||
engines: {node: '>=12'}
|
||||
cpu: [ia32]
|
||||
os: [linux]
|
||||
requiresBuild: true
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/linux-loong64/0.16.10:
|
||||
resolution: {integrity: sha512-O7Pd5hLEtTg37NC73pfhUOGTjx/+aXu5YoSq3ahCxcN7Bcr2F47mv+kG5t840thnsEzrv0oB70+LJu3gUgchvg==}
|
||||
engines: {node: '>=12'}
|
||||
cpu: [loong64]
|
||||
os: [linux]
|
||||
requiresBuild: true
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/linux-mips64el/0.16.10:
|
||||
resolution: {integrity: sha512-FN8mZOH7531iPHM0kaFhAOqqNHoAb6r/YHW2ZIxNi0a85UBi2DO4Vuyn7t1p4UN8a4LoAnLOT1PqNgHkgBJgbA==}
|
||||
engines: {node: '>=12'}
|
||||
cpu: [mips64el]
|
||||
os: [linux]
|
||||
requiresBuild: true
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/linux-ppc64/0.16.10:
|
||||
resolution: {integrity: sha512-Dg9RiqdvHOAWnOKIOTsIx8dFX9EDlY2IbPEY7YFzchrCiTZmMkD7jWA9UdZbNUygPjdmQBVPRCrLydReFlX9yg==}
|
||||
engines: {node: '>=12'}
|
||||
cpu: [ppc64]
|
||||
os: [linux]
|
||||
requiresBuild: true
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/linux-riscv64/0.16.10:
|
||||
resolution: {integrity: sha512-XMqtpjwzbmlar0BJIxmzu/RZ7EWlfVfH68Vadrva0Wj5UKOdKvqskuev2jY2oPV3aoQUyXwnMbMrFmloO2GfAw==}
|
||||
engines: {node: '>=12'}
|
||||
cpu: [riscv64]
|
||||
os: [linux]
|
||||
requiresBuild: true
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/linux-s390x/0.16.10:
|
||||
resolution: {integrity: sha512-fu7XtnoeRNFMx8DjK3gPWpFBDM2u5ba+FYwg27SjMJwKvJr4bDyKz5c+FLXLUSSAkMAt/UL+cUbEbra+rYtUgw==}
|
||||
engines: {node: '>=12'}
|
||||
cpu: [s390x]
|
||||
os: [linux]
|
||||
requiresBuild: true
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/linux-x64/0.16.10:
|
||||
resolution: {integrity: sha512-61lcjVC/RldNNMUzQQdyCWjCxp9YLEQgIxErxU9XluX7juBdGKb0pvddS0vPNuCvotRbzijZ1pzII+26haWzbA==}
|
||||
engines: {node: '>=12'}
|
||||
cpu: [x64]
|
||||
os: [linux]
|
||||
requiresBuild: true
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/netbsd-x64/0.16.10:
|
||||
resolution: {integrity: sha512-JeZXCX3viSA9j4HqSoygjssdqYdfHd6yCFWyfSekLbz4Ef+D2EjvsN02ZQPwYl5a5gg/ehdHgegHhlfOFP0HCA==}
|
||||
engines: {node: '>=12'}
|
||||
cpu: [x64]
|
||||
os: [netbsd]
|
||||
requiresBuild: true
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/openbsd-x64/0.16.10:
|
||||
resolution: {integrity: sha512-3qpxQKuEVIIg8SebpXsp82OBrqjPV/OwNWmG+TnZDr3VGyChNnGMHccC1xkbxCHDQNnnXjxhMQNyHmdFJbmbRA==}
|
||||
engines: {node: '>=12'}
|
||||
cpu: [x64]
|
||||
os: [openbsd]
|
||||
requiresBuild: true
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/sunos-x64/0.16.10:
|
||||
resolution: {integrity: sha512-z+q0xZ+et/7etz7WoMyXTHZ1rB8PMSNp/FOqURLJLOPb3GWJ2aj4oCqFCjPwEbW1rsT7JPpxeH/DwGAWk/I1Bg==}
|
||||
engines: {node: '>=12'}
|
||||
cpu: [x64]
|
||||
os: [sunos]
|
||||
requiresBuild: true
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/win32-arm64/0.16.10:
|
||||
resolution: {integrity: sha512-+YYu5sbQ9npkNT9Dec+tn1F/kjg6SMgr6bfi/6FpXYZvCRfu2YFPZGb+3x8K30s8eRxFpoG4sGhiSUkr1xbHEw==}
|
||||
engines: {node: '>=12'}
|
||||
cpu: [arm64]
|
||||
os: [win32]
|
||||
requiresBuild: true
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/win32-ia32/0.16.10:
|
||||
resolution: {integrity: sha512-Aw7Fupk7XNehR1ftHGYwUteyJ2q+em/aE+fVU3YMTBN2V5A7Z4aVCSV+SvCp9HIIHZavPFBpbdP3VfjQpdf6Xg==}
|
||||
engines: {node: '>=12'}
|
||||
cpu: [ia32]
|
||||
os: [win32]
|
||||
requiresBuild: true
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/win32-x64/0.16.10:
|
||||
resolution: {integrity: sha512-qddWullt3sC1EIpfHvCRBq3H4g3L86DZpD6n8k2XFjFVyp01D++uNbN1hT/JRsHxTbyyemZcpwL5aRlJwc/zFw==}
|
||||
engines: {node: '>=12'}
|
||||
cpu: [x64]
|
||||
os: [win32]
|
||||
requiresBuild: true
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@types/commonmark/0.27.5:
|
||||
resolution: {integrity: sha512-vIqgmHyLsc8Or3EWLz6QkhI8/v61FNeH0yxRupA7VqSbA2eFMoHHJAhZSHudplAV89wqg1CKSmShE016ziRXuw==}
|
||||
dev: true
|
||||
|
@ -36,6 +238,36 @@ packages:
|
|||
resolution: {integrity: sha512-MyoZ0jgnLvB2X3Lg5HqpFmn1kybDiIfEQmKzTb5apr51Rb+T3KdmMiqa70T+bhGnyv7bQ6WMj2QMHpGMmlrUYQ==}
|
||||
dev: false
|
||||
|
||||
/esbuild/0.16.10:
|
||||
resolution: {integrity: sha512-z5dIViHoVnw2l+NCJ3zj5behdXjYvXne9gL18OOivCadXDUhyDkeSvEtLcGVAJW2fNmh33TDUpsi704XYlDodw==}
|
||||
engines: {node: '>=12'}
|
||||
hasBin: true
|
||||
requiresBuild: true
|
||||
optionalDependencies:
|
||||
'@esbuild/android-arm': 0.16.10
|
||||
'@esbuild/android-arm64': 0.16.10
|
||||
'@esbuild/android-x64': 0.16.10
|
||||
'@esbuild/darwin-arm64': 0.16.10
|
||||
'@esbuild/darwin-x64': 0.16.10
|
||||
'@esbuild/freebsd-arm64': 0.16.10
|
||||
'@esbuild/freebsd-x64': 0.16.10
|
||||
'@esbuild/linux-arm': 0.16.10
|
||||
'@esbuild/linux-arm64': 0.16.10
|
||||
'@esbuild/linux-ia32': 0.16.10
|
||||
'@esbuild/linux-loong64': 0.16.10
|
||||
'@esbuild/linux-mips64el': 0.16.10
|
||||
'@esbuild/linux-ppc64': 0.16.10
|
||||
'@esbuild/linux-riscv64': 0.16.10
|
||||
'@esbuild/linux-s390x': 0.16.10
|
||||
'@esbuild/linux-x64': 0.16.10
|
||||
'@esbuild/netbsd-x64': 0.16.10
|
||||
'@esbuild/openbsd-x64': 0.16.10
|
||||
'@esbuild/sunos-x64': 0.16.10
|
||||
'@esbuild/win32-arm64': 0.16.10
|
||||
'@esbuild/win32-ia32': 0.16.10
|
||||
'@esbuild/win32-x64': 0.16.10
|
||||
dev: true
|
||||
|
||||
/mdurl/1.0.1:
|
||||
resolution: {integrity: sha512-/sKlQJCBYVY9Ers9hqzKou4H6V5UWc/M59TH2dvkt+84itfnq7uFOMLpOiOS4ujvHP4etln18fmIxA5R5fll0g==}
|
||||
dev: false
|
||||
|
@ -47,3 +279,9 @@ packages:
|
|||
/string.prototype.repeat/0.2.0:
|
||||
resolution: {integrity: sha512-1BH+X+1hSthZFW+X+JaUkjkkUPwIlLEMJBLANN3hOob3RhEk5snLWNECDnYbgn/m5c5JV7Ersu1Yubaf+05cIA==}
|
||||
dev: false
|
||||
|
||||
/typescript/4.9.4:
|
||||
resolution: {integrity: sha512-Uz+dTXYzxXXbsFpM86Wh3dKCxrQqUcVMxwU54orwlJjOpO3ao8L7j5lH+dWfTwgCwIuM9GQ2kvVotzYJMXTBZg==}
|
||||
engines: {node: '>=4.2.0'}
|
||||
hasBin: true
|
||||
dev: true
|
||||
|
|
9
tsconfig.json
Normal file
9
tsconfig.json
Normal file
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"target": "es2022",
|
||||
"module": "es2022",
|
||||
"moduleResolution": "node",
|
||||
"esModuleInterop": true,
|
||||
"strict": true
|
||||
}
|
||||
}
|
Reference in a new issue