3 Commits

Author SHA1 Message Date
hikari 330c4946b8 feat: add table of contents and strip fCC directive syntax
Node.js CI / CI (push) Failing after 17s
Security Scan and Upload / Security & DefectDojo Upload (push) Successful in 2m12s
2026-04-17 13:52:40 -07:00
hikari 99b5cb6935 fix: add puppeteer as dev dependency to resolve postinstall failure 2026-04-17 13:52:37 -07:00
hikari bc3bceded8 chore: replace .npmrc with pnpm-workspace.yaml
Node.js CI / CI (push) Failing after 23s
Security Scan and Upload / Security & DefectDojo Upload (push) Failing after 14m24s
2026-03-02 16:28:46 -08:00
5 changed files with 121 additions and 98 deletions
-25
View File
@@ -1,25 +0,0 @@
# Package Manager Configuration
# Force pnpm usage - breaks npm/yarn intentionally
node-linker=pnpm
# Security: Disable all lifecycle scripts
ignore-scripts=true
enable-pre-post-scripts=false
# Security: Require packages to be 10+ days old before installation
minimum-release-age=14400
# Security: Verify package integrity hashes
verify-store-integrity=true
# Security: Enforce strict trust policies
trust-policy=strict
# Security: Strict peer dependency resolution
strict-peer-dependencies=true
# Performance: Use symlinks for node_modules
symlink=true
# Lockfile: Ensure lockfile is not modified during install
frozen-lockfile=false
+2 -1
View File
@@ -20,10 +20,11 @@
"@nhcarrigan/typescript-config": "4.0.0", "@nhcarrigan/typescript-config": "4.0.0",
"@types/node": "24.7.0", "@types/node": "24.7.0",
"eslint": "9.37.0", "eslint": "9.37.0",
"puppeteer": "24.40.0",
"tsx": "4.20.6", "tsx": "4.20.6",
"typescript": "5.9.3" "typescript": "5.9.3"
}, },
"dependencies": { "dependencies": {
"md-to-pdf": "5.2.5" "md-to-pdf": "5.2.4"
} }
} }
+54 -43
View File
@@ -9,8 +9,8 @@ importers:
.: .:
dependencies: dependencies:
md-to-pdf: md-to-pdf:
specifier: 5.2.5 specifier: 5.2.4
version: 5.2.5(typescript@5.9.3) version: 5.2.4(typescript@5.9.3)
devDependencies: devDependencies:
'@nhcarrigan/eslint-config': '@nhcarrigan/eslint-config':
specifier: 5.2.0 specifier: 5.2.0
@@ -24,6 +24,9 @@ importers:
eslint: eslint:
specifier: 9.37.0 specifier: 9.37.0
version: 9.37.0 version: 9.37.0
puppeteer:
specifier: 24.40.0
version: 24.40.0(typescript@5.9.3)
tsx: tsx:
specifier: 4.20.6 specifier: 4.20.6
version: 4.20.6 version: 4.20.6
@@ -313,8 +316,8 @@ packages:
resolution: {integrity: sha512-fdDH1LSGfZdTH2sxdpVMw31BanV28K/Gry0cVFxaNP77neJSkd82mM8ErPNYs9e+0O7SdHBLTDzDgwUuy18RnQ==} resolution: {integrity: sha512-fdDH1LSGfZdTH2sxdpVMw31BanV28K/Gry0cVFxaNP77neJSkd82mM8ErPNYs9e+0O7SdHBLTDzDgwUuy18RnQ==}
engines: {node: ^12.20.0 || ^14.18.0 || >=16.0.0} engines: {node: ^12.20.0 || ^14.18.0 || >=16.0.0}
'@puppeteer/browsers@2.10.10': '@puppeteer/browsers@2.13.0':
resolution: {integrity: sha512-3ZG500+ZeLql8rE0hjfhkycJjDj0pI/btEh3L9IkWUYcOrgP0xCNRq3HbtbqOPbvDhFaAWD88pDFtlLv8ns8gA==} resolution: {integrity: sha512-46BZJYJjc/WwmKjsvDFykHtXrtomsCIrwYQPOP7VfMJoZY2bsDF9oROBABR3paDjDcmkUye1Pb1BqdcdiipaWA==}
engines: {node: '>=18'} engines: {node: '>=18'}
hasBin: true hasBin: true
@@ -822,6 +825,7 @@ packages:
basic-ftp@5.0.5: basic-ftp@5.0.5:
resolution: {integrity: sha512-4Bcg1P8xhUuqcii/S0Z9wiHIrQVPMermM1any+MX5GeGD7faD3/msQUDGLol9wOcz4/jbg/WJnGqoJF6LiBdtg==} resolution: {integrity: sha512-4Bcg1P8xhUuqcii/S0Z9wiHIrQVPMermM1any+MX5GeGD7faD3/msQUDGLol9wOcz4/jbg/WJnGqoJF6LiBdtg==}
engines: {node: '>=10.0.0'} engines: {node: '>=10.0.0'}
deprecated: Security vulnerability fixed in 5.2.1, please upgrade
binary-extensions@2.3.0: binary-extensions@2.3.0:
resolution: {integrity: sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw==} resolution: {integrity: sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw==}
@@ -900,8 +904,8 @@ packages:
resolution: {integrity: sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==} resolution: {integrity: sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==}
engines: {node: '>= 8.10.0'} engines: {node: '>= 8.10.0'}
chromium-bidi@9.1.0: chromium-bidi@14.0.0:
resolution: {integrity: sha512-rlUzQ4WzIAWdIbY/viPShhZU2n21CxDUgazXVbw4Hu1MwaeUSEksSeM6DqPgpRjCLXRk702AVRxJxoOz0dw4OA==} resolution: {integrity: sha512-9gYlLtS6tStdRWzrtXaTMnqcM4dudNegMXJxkR0I/CXObHalYeYcAMPrL19eroNZHtJ8DQmu1E+ZNOYu/IXMXw==}
peerDependencies: peerDependencies:
devtools-protocol: '*' devtools-protocol: '*'
@@ -1024,8 +1028,8 @@ packages:
resolution: {integrity: sha512-TllpMR/t0M5sqCXfj85i4XaAzxmS5tVA16dqvdkMwGmzI+dXLXnw3J+3Vdv7VKw+ThlTMboK6i9rnZ6Nntj5CQ==} resolution: {integrity: sha512-TllpMR/t0M5sqCXfj85i4XaAzxmS5tVA16dqvdkMwGmzI+dXLXnw3J+3Vdv7VKw+ThlTMboK6i9rnZ6Nntj5CQ==}
engines: {node: '>= 14'} engines: {node: '>= 14'}
devtools-protocol@0.0.1508733: devtools-protocol@0.0.1581282:
resolution: {integrity: sha512-QJ1R5gtck6nDcdM+nlsaJXcelPEI7ZxSMw1ujHpO1c4+9l+Nue5qlebi9xO1Z2MGr92bFOQTW7/rrheh5hHxDg==} resolution: {integrity: sha512-nv7iKtNZQshSW2hKzYNr46nM/Cfh5SEvE2oV0/SEGgc9XupIY5ggf84Cz8eJIkBce7S3bmTAauFD6aysMpnqsQ==}
dir-glob@3.0.1: dir-glob@3.0.1:
resolution: {integrity: sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA==} resolution: {integrity: sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA==}
@@ -1773,8 +1777,8 @@ packages:
resolution: {integrity: sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==} resolution: {integrity: sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==}
engines: {node: '>= 0.4'} engines: {node: '>= 0.4'}
md-to-pdf@5.2.5: md-to-pdf@5.2.4:
resolution: {integrity: sha512-TG8TgDM0PmEwCldR6j/1QP9gBElLL3DSn5ID8P3bEXEl3Y2zHOUSyszHzabWnDNxklRjKbi40ybli8YQJ5Ym5w==} resolution: {integrity: sha512-s6080i4ZSBfvn7qplSVjdqP9eWi9rIWj+t5pucEKnpAHan89VLQuQPhVx06vWIM+6JX2HrJ1wNRFMiwLlS01vg==}
engines: {node: '>=12.0'} engines: {node: '>=12.0'}
hasBin: true hasBin: true
@@ -2024,12 +2028,12 @@ packages:
resolution: {integrity: sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==} resolution: {integrity: sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==}
engines: {node: '>=6'} engines: {node: '>=6'}
puppeteer-core@24.23.0: puppeteer-core@24.40.0:
resolution: {integrity: sha512-yl25C59gb14sOdIiSnJ08XiPP+O2RjuyZmEG+RjYmCXO7au0jcLf7fRiyii96dXGUBW7Zwei/mVKfxMx/POeFw==} resolution: {integrity: sha512-MWL3XbUCfVgGR0gRsidzT6oKJT2QydPLhMITU6HoVWiiv4gkb6gJi3pcdAa8q4HwjBTbqISOWVP4aJiiyUJvag==}
engines: {node: '>=18'} engines: {node: '>=18'}
puppeteer@24.23.0: puppeteer@24.40.0:
resolution: {integrity: sha512-BVR1Lg8sJGKXY79JARdIssFWK2F6e1j+RyuJP66w4CUmpaXjENicmA3nNpUXA8lcTdDjAndtP+oNdni3T/qQqA==} resolution: {integrity: sha512-IxQbDq93XHVVLWHrAkFP7F7iHvb9o0mgfsSIMlhHb+JM+JjM1V4v4MNSQfcRWJopx9dsNOr9adYv0U5fm9BJBQ==}
engines: {node: '>=18'} engines: {node: '>=18'}
hasBin: true hasBin: true
@@ -2151,6 +2155,11 @@ packages:
engines: {node: '>=10'} engines: {node: '>=10'}
hasBin: true hasBin: true
semver@7.7.4:
resolution: {integrity: sha512-vFKC2IEtQnVhpT78h1Yp8wzwrf8CM+MzKMHGJZfBtzhZNycRFnXsHk6E5TxIkkMsgNS7mdX3AGB7x2QM2di4lA==}
engines: {node: '>=10'}
hasBin: true
serve-handler@6.1.6: serve-handler@6.1.6:
resolution: {integrity: sha512-x5RL9Y2p5+Sh3D38Fh9i/iQ5ZK+e4xuXRd/pGbM4D13tgo/MGwbttUk8emytcr1YYzBYs+apnUngBDFYfpjPuQ==} resolution: {integrity: sha512-x5RL9Y2p5+Sh3D38Fh9i/iQ5ZK+e4xuXRd/pGbM4D13tgo/MGwbttUk8emytcr1YYzBYs+apnUngBDFYfpjPuQ==}
@@ -2437,8 +2446,8 @@ packages:
resolution: {integrity: sha512-3KS2b+kL7fsuk/eJZ7EQdnEmQoaho/r6KUef7hxvltNA5DR8NAUM+8wJMbJyZ4G9/7i3v5zPBIMN5aybAh2/Jg==} resolution: {integrity: sha512-3KS2b+kL7fsuk/eJZ7EQdnEmQoaho/r6KUef7hxvltNA5DR8NAUM+8wJMbJyZ4G9/7i3v5zPBIMN5aybAh2/Jg==}
engines: {node: '>= 0.4'} engines: {node: '>= 0.4'}
typed-query-selector@2.12.0: typed-query-selector@2.12.1:
resolution: {integrity: sha512-SbklCd1F0EiZOyPiW192rrHZzZ5sBijB6xM+cpmrwDqObvdtunOHHIk9fCGsoK5JVIYXoyEp4iEdE3upFH3PAg==} resolution: {integrity: sha512-uzR+FzI8qrUEIu96oaeBJmd9E7CFEiQ3goA5qCVgc4s5llSubcfGHq9yUstZx/k4s9dXHVKsE35YWoFyvEqEHA==}
typescript@5.9.3: typescript@5.9.3:
resolution: {integrity: sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==} resolution: {integrity: sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==}
@@ -2537,8 +2546,8 @@ packages:
jsdom: jsdom:
optional: true optional: true
webdriver-bidi-protocol@0.3.6: webdriver-bidi-protocol@0.4.1:
resolution: {integrity: sha512-mlGndEOA9yK9YAbvtxaPTqdi/kaCWYYfwrZvGzcmkr/3lWM+tQj53BxtpVd6qbC6+E5OnHXgCcAhre6AkXzxjA==} resolution: {integrity: sha512-ARrjNjtWRRs2w4Tk7nqrf2gBI0QXWuOmMCx2hU+1jUt6d00MjMxURrhxhGbrsoiZKJrhTSTzbIrc554iKI10qw==}
which-boxed-primitive@1.1.1: which-boxed-primitive@1.1.1:
resolution: {integrity: sha512-TbX3mj8n0odCBFVlY8AxkqcHASw3L60jIuF8jFP78az3C2YhmGvqbHBpAjTRH2/xqYunrJ9g1jSyjCjpoWzIAA==} resolution: {integrity: sha512-TbX3mj8n0odCBFVlY8AxkqcHASw3L60jIuF8jFP78az3C2YhmGvqbHBpAjTRH2/xqYunrJ9g1jSyjCjpoWzIAA==}
@@ -2581,8 +2590,8 @@ packages:
wrappy@1.0.2: wrappy@1.0.2:
resolution: {integrity: sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==} resolution: {integrity: sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==}
ws@8.18.3: ws@8.20.0:
resolution: {integrity: sha512-PEIGCY5tSlUt50cqyMXfCzX+oOPqN0vuGqWzbcJ2xvnkzkq46oOpz7dQaTDBdfICb4N14+GARUDw2XV2N4tvzg==} resolution: {integrity: sha512-sAt8BhgNbzCtgGbt2OxmpuryO63ZoDk/sqaB/znQm94T4fCEsy/yV+7CdC1kJhOU9lboAEU7R3kquuycDoibVA==}
engines: {node: '>=10.0.0'} engines: {node: '>=10.0.0'}
peerDependencies: peerDependencies:
bufferutil: ^4.0.1 bufferutil: ^4.0.1
@@ -2841,13 +2850,13 @@ snapshots:
'@pkgr/core@0.1.2': {} '@pkgr/core@0.1.2': {}
'@puppeteer/browsers@2.10.10': '@puppeteer/browsers@2.13.0':
dependencies: dependencies:
debug: 4.4.3 debug: 4.4.3
extract-zip: 2.0.1 extract-zip: 2.0.1
progress: 2.0.3 progress: 2.0.3
proxy-agent: 6.5.0 proxy-agent: 6.5.0
semver: 7.7.2 semver: 7.7.4
tar-fs: 3.1.1 tar-fs: 3.1.1
yargs: 17.7.2 yargs: 17.7.2
transitivePeerDependencies: transitivePeerDependencies:
@@ -3460,9 +3469,9 @@ snapshots:
optionalDependencies: optionalDependencies:
fsevents: 2.3.3 fsevents: 2.3.3
chromium-bidi@9.1.0(devtools-protocol@0.0.1508733): chromium-bidi@14.0.0(devtools-protocol@0.0.1581282):
dependencies: dependencies:
devtools-protocol: 0.0.1508733 devtools-protocol: 0.0.1581282
mitt: 3.0.1 mitt: 3.0.1
zod: 3.25.76 zod: 3.25.76
@@ -3578,7 +3587,7 @@ snapshots:
escodegen: 2.1.0 escodegen: 2.1.0
esprima: 4.0.1 esprima: 4.0.1
devtools-protocol@0.0.1508733: {} devtools-protocol@0.0.1581282: {}
dir-glob@3.0.1: dir-glob@3.0.1:
dependencies: dependencies:
@@ -4502,7 +4511,7 @@ snapshots:
math-intrinsics@1.1.0: {} math-intrinsics@1.1.0: {}
md-to-pdf@5.2.5(typescript@5.9.3): md-to-pdf@5.2.4(typescript@5.9.3):
dependencies: dependencies:
arg: 5.0.2 arg: 5.0.2
chalk: 4.1.2 chalk: 4.1.2
@@ -4514,7 +4523,7 @@ snapshots:
iconv-lite: 0.6.3 iconv-lite: 0.6.3
listr: 0.14.3 listr: 0.14.3
marked: 4.3.0 marked: 4.3.0
puppeteer: 24.23.0(typescript@5.9.3) puppeteer: 24.40.0(typescript@5.9.3)
semver: 7.7.2 semver: 7.7.2
serve-handler: 6.1.6 serve-handler: 6.1.6
transitivePeerDependencies: transitivePeerDependencies:
@@ -4770,15 +4779,15 @@ snapshots:
punycode@2.3.1: {} punycode@2.3.1: {}
puppeteer-core@24.23.0: puppeteer-core@24.40.0:
dependencies: dependencies:
'@puppeteer/browsers': 2.10.10 '@puppeteer/browsers': 2.13.0
chromium-bidi: 9.1.0(devtools-protocol@0.0.1508733) chromium-bidi: 14.0.0(devtools-protocol@0.0.1581282)
debug: 4.4.3 debug: 4.4.3
devtools-protocol: 0.0.1508733 devtools-protocol: 0.0.1581282
typed-query-selector: 2.12.0 typed-query-selector: 2.12.1
webdriver-bidi-protocol: 0.3.6 webdriver-bidi-protocol: 0.4.1
ws: 8.18.3 ws: 8.20.0
transitivePeerDependencies: transitivePeerDependencies:
- bare-buffer - bare-buffer
- bufferutil - bufferutil
@@ -4786,14 +4795,14 @@ snapshots:
- supports-color - supports-color
- utf-8-validate - utf-8-validate
puppeteer@24.23.0(typescript@5.9.3): puppeteer@24.40.0(typescript@5.9.3):
dependencies: dependencies:
'@puppeteer/browsers': 2.10.10 '@puppeteer/browsers': 2.13.0
chromium-bidi: 9.1.0(devtools-protocol@0.0.1508733) chromium-bidi: 14.0.0(devtools-protocol@0.0.1581282)
cosmiconfig: 9.0.0(typescript@5.9.3) cosmiconfig: 9.0.0(typescript@5.9.3)
devtools-protocol: 0.0.1508733 devtools-protocol: 0.0.1581282
puppeteer-core: 24.23.0 puppeteer-core: 24.40.0
typed-query-selector: 2.12.0 typed-query-selector: 2.12.1
transitivePeerDependencies: transitivePeerDependencies:
- bare-buffer - bare-buffer
- bufferutil - bufferutil
@@ -4948,6 +4957,8 @@ snapshots:
semver@7.7.2: {} semver@7.7.2: {}
semver@7.7.4: {}
serve-handler@6.1.6: serve-handler@6.1.6:
dependencies: dependencies:
bytes: 3.0.0 bytes: 3.0.0
@@ -5301,7 +5312,7 @@ snapshots:
possible-typed-array-names: 1.1.0 possible-typed-array-names: 1.1.0
reflect.getprototypeof: 1.0.10 reflect.getprototypeof: 1.0.10
typed-query-selector@2.12.0: {} typed-query-selector@2.12.1: {}
typescript@5.9.3: {} typescript@5.9.3: {}
@@ -5404,7 +5415,7 @@ snapshots:
- tsx - tsx
- yaml - yaml
webdriver-bidi-protocol@0.3.6: {} webdriver-bidi-protocol@0.4.1: {}
which-boxed-primitive@1.1.1: which-boxed-primitive@1.1.1:
dependencies: dependencies:
@@ -5471,7 +5482,7 @@ snapshots:
wrappy@1.0.2: {} wrappy@1.0.2: {}
ws@8.18.3: {} ws@8.20.0: {}
y18n@5.0.8: {} y18n@5.0.8: {}
+21
View File
@@ -0,0 +1,21 @@
# Security
# Do not execute any scripts of installed packages (project scripts still run)
ignoreDepScripts: true
# Do not automatically run pre/post scripts (e.g. preinstall, postbuild)
enablePrePostScripts: false
# Only allow packages published at least 10 days ago (reduces risk of compromised packages)
minimumReleaseAge: 14400
# Fail if a package's trust level has decreased compared to previous releases
trustPolicy: no-downgrade
# Ignore trust policy for packages published more than 1 year ago (predates provenance signing)
trustPolicyIgnoreAfter: 525960
# Fail if there are missing or invalid peer dependencies
strictPeerDependencies: true
# Prevent transitive dependencies from using exotic sources (git repos, direct tarball URLs)
blockExoticSubdeps: true
# Lockfile
# Allow the lockfile to be updated during install (set to true in CI for stricter reproducibility)
preferFrozenLockfile: false
+44 -29
View File
@@ -4,13 +4,7 @@
* @author Naomi Carrigan * @author Naomi Carrigan
*/ */
import { import { readFile, writeFile, readdir, unlink } from "node:fs/promises";
readFile,
appendFile,
writeFile,
readdir,
unlink,
} from "node:fs/promises";
import { join } from "node:path"; import { join } from "node:path";
import { mdToPdf } from "md-to-pdf"; import { mdToPdf } from "md-to-pdf";
import order from "../data/order.json" assert { type: "json" }; import order from "../data/order.json" assert { type: "json" };
@@ -46,38 +40,59 @@ const sortFiles = (a: string, b: string): number => {
return aIndex - bIndex; return aIndex - bIndex;
}; };
interface FileEntry {
body: string;
title: string;
}
const slugify = (text: string): string => {
return text.
toLowerCase().
replaceAll(/[^\w\s-]/gu, "").
replaceAll(/\s+/gu, "-");
};
const processFile = async(file: string): Promise<FileEntry> => {
const content = await readFile(file, "utf8");
const titleMatch = /^title: (?<title>.*)/mu.exec(content);
const title = titleMatch?.groups?.title ?? "Unknown";
const body = content.
replace(/^---\n[\S\s]*?\n---\n/u, "").
trim().
replace(/^#+ --.*--/u, "").
trim().
replaceAll(/^:::.*$/gmu, "").
trim();
return { body, title };
};
const rollupFiles = async( const rollupFiles = async(
inputDirectory: string, inputDirectory: string,
outputFile: string, outputFile: string,
): Promise<void> => { ): Promise<void> => {
try { try {
console.log("Process started..."); console.log("Process started...");
await writeFile(outputFile, `${starterText}\n`);
console.log("Reading content directory..."); console.log("Reading content directory...");
const unsortedFiles = await readDirectoryRecursively(inputDirectory); const unsortedFiles = await readDirectoryRecursively(inputDirectory);
console.log(unsortedFiles);
const files = unsortedFiles.toSorted(sortFiles); const files = unsortedFiles.toSorted(sortFiles);
console.log("Files found, processing..."); console.log("Files found, processing...");
for (const file of files) { const mdFiles = files.filter((file) => {
if (file === ".gitkeep") { return file.endsWith(".md");
continue; });
} const entries = await Promise.all(
if (file.endsWith(".md")) { mdFiles.map(async(file) => {
const content = await readFile(file, "utf8"); return await processFile(file);
const strippedFrontmatter = content. }),
replace(/^---\n[\S\s]*?\n---\n/, ""). );
trim(); const tocLines = entries.map(({ title }) => {
// Title is in front matter return `- [${title}](#${slugify(title)})`;
const title = /^title: (?<title>.*)/m.exec(content)?.groups?.title; });
const strippedFccHeadings = strippedFrontmatter. const toc = `## Table of Contents\n\n${tocLines.join("\n")}\n\n---`;
replace(/^#+ --.*--/, ""). const sections = entries.map(({ body, title }) => {
trim(); return `---\n\n# ${title}\n\n${body}\n\n`;
await appendFile( });
outputFile,
`---\n\n# ${title ?? "Unknown"}\n${strippedFccHeadings}\n\n`, await writeFile(outputFile, `${starterText}\n${toc}\n\n${sections.join("")}`);
);
}
}
console.log(`Successfully rolled up files into ${outputFile}`); console.log(`Successfully rolled up files into ${outputFile}`);
} catch (error) { } catch (error) {
console.error("Error rolling up files:", error); console.error("Error rolling up files:", error);