docmedown 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +69 -20
- package/dist/abnfDiagram-VCTEODGH-CtQBp0Qv.mjs +89 -0
- package/dist/abnfDiagram-VCTEODGH-mccrzlD_.js +1 -0
- package/dist/arc-DgPKXEdT.mjs +82 -0
- package/dist/arc-n7TW7Bis.js +1 -0
- package/dist/architecture-7GRP2DOG-B7myQ46f.js +1 -0
- package/dist/architecture-7GRP2DOG-Cxj1ussQ.mjs +3 -0
- package/dist/architectureDiagram-5GKGNRK7-BdTCu5T3.js +36 -0
- package/dist/architectureDiagram-5GKGNRK7-CkgZa-G1.mjs +4154 -0
- package/dist/array-CApNbSU9.mjs +6 -0
- package/dist/array-DZSRzHA_.js +1 -0
- package/dist/blockDiagram-I7D4REHJ-CSYvpxQw.js +129 -0
- package/dist/blockDiagram-I7D4REHJ-CYngfPD9.mjs +1922 -0
- package/dist/c4Diagram-7LVT6UL2-B-sz5MUK.js +38 -0
- package/dist/c4Diagram-7LVT6UL2-DEzxFf2b.mjs +3010 -0
- package/dist/channel-LgHproiI.mjs +5 -0
- package/dist/channel-yqu0m4cl.js +1 -0
- package/dist/chunk-2E4U76K2-BOyeRQsI.js +1 -0
- package/dist/chunk-2E4U76K2-CoTrgtfg.mjs +348 -0
- package/dist/chunk-2Q5K7J3B-D4EgYPOq.mjs +15 -0
- package/dist/chunk-2Q5K7J3B-DhjCNjaM.js +1 -0
- package/dist/chunk-4HAMMTFA-GFyfmcSO.js +62 -0
- package/dist/chunk-4HAMMTFA-VgWPe1ng.mjs +4188 -0
- package/dist/chunk-5VM5RSS4-GINalzIv.js +15 -0
- package/dist/chunk-5VM5RSS4-TqxtqrwE.mjs +5 -0
- package/dist/chunk-75Z2AOVW-DYouz5MZ.js +2 -0
- package/dist/chunk-75Z2AOVW-Dz0Sko9Y.mjs +1330 -0
- package/dist/chunk-CLGD4ZFX-C5J-e2io.js +1 -0
- package/dist/chunk-CLGD4ZFX-DBkwyMMv.mjs +14 -0
- package/dist/chunk-DU6HZSFF-BEQZSmUu.mjs +3836 -0
- package/dist/chunk-DU6HZSFF-CWc5ewtb.js +127 -0
- package/dist/chunk-F27PBJKO-8jvY_jJK.js +1 -0
- package/dist/chunk-F27PBJKO-DFH3sRZG.mjs +61 -0
- package/dist/chunk-FOHPRMQF-LRqOLsSw.mjs +21456 -0
- package/dist/chunk-FOHPRMQF-tmTlwTeH.js +161 -0
- package/dist/chunk-GMAD6QVW-BZeZ4fdb.mjs +1863 -0
- package/dist/chunk-GMAD6QVW-DEQiTa0c.js +72 -0
- package/dist/chunk-GVQU2GXP-B1D3J05J.mjs +37 -0
- package/dist/chunk-GVQU2GXP-CdJIWN41.js +1 -0
- package/dist/chunk-IMKFNOWR-BmZb9U1f.mjs +2042 -0
- package/dist/chunk-IMKFNOWR-CPJsszGN.js +231 -0
- package/dist/chunk-JWPE2WC7-DIKiF5cm.mjs +8 -0
- package/dist/chunk-JWPE2WC7-p1fYVdYc.js +1 -0
- package/dist/chunk-L3NEJ4N5-TzDiVs78.js +1 -0
- package/dist/chunk-L3NEJ4N5-lal8wUID.mjs +245 -0
- package/dist/chunk-LNGE3PJU-BQX75wkM.js +34 -0
- package/dist/chunk-LNGE3PJU-DJ9JuXV6.mjs +1521 -0
- package/dist/chunk-OSK3NFVY-9AWK88m1.mjs +672 -0
- package/dist/chunk-OSK3NFVY-CHzvVe8m.js +10 -0
- package/dist/chunk-P2QGCYS3-6q3AXPt5.mjs +67 -0
- package/dist/chunk-P2QGCYS3-DKZzpRQW.js +1 -0
- package/dist/chunk-POPQ4Y6H-Dd7J9tx3.mjs +26 -0
- package/dist/chunk-POPQ4Y6H-T5C7wpjf.js +1 -0
- package/dist/chunk-PWAF6VOD-BYG76tEe.mjs +275 -0
- package/dist/chunk-PWAF6VOD-DxZLuCEw.js +1 -0
- package/dist/chunk-SHT3W25Y-B2Wes8jn.mjs +4183 -0
- package/dist/chunk-SHT3W25Y-BQjHSn5K.js +168 -0
- package/dist/chunk-SVP7TREG-BFMd615E.js +88 -0
- package/dist/chunk-SVP7TREG-CynckzeF.mjs +490 -0
- package/dist/chunk-TICWLB2K-BfCuoR1V.mjs +3357 -0
- package/dist/chunk-TICWLB2K-agcyBfUp.js +206 -0
- package/dist/chunk-TLUHSLCS-CUrWaKDG.mjs +59 -0
- package/dist/chunk-TLUHSLCS-Drx_a7am.js +1 -0
- package/dist/chunk-XXDRQBXY-AAk1-Cyg.js +1 -0
- package/dist/chunk-XXDRQBXY-DpR8eYzz.mjs +9 -0
- package/dist/chunk-Y2CYZVJY-CnmLqFtv.js +1 -0
- package/dist/chunk-Y2CYZVJY-i11wjrBe.mjs +12 -0
- package/dist/classDiagram-ZZMXUADV-B7IN9zcX.js +1 -0
- package/dist/classDiagram-ZZMXUADV-tcy6gxSB.mjs +30 -0
- package/dist/classDiagram-v2-VYDZK3BY-B7IN9zcX.js +1 -0
- package/dist/classDiagram-v2-VYDZK3BY-D5wM6Acp.mjs +30 -0
- package/dist/cli.js +719 -532
- package/dist/cose-bilkent-JH36ORCC-DBUPO3qJ.js +1 -0
- package/dist/cose-bilkent-JH36ORCC-Slpx4WIt.mjs +2253 -0
- package/dist/cynefin-OW5HDTMX--QVnfGi1.mjs +3 -0
- package/dist/cynefin-OW5HDTMX-lNKysi7S.js +1 -0
- package/dist/cynefinDiagram-5FMLGOSQ-CsFONYqx.js +62 -0
- package/dist/cynefinDiagram-5FMLGOSQ-DsrxYBcg.mjs +355 -0
- package/dist/cytoscape.esm-C5TvPYYm.mjs +18148 -0
- package/dist/cytoscape.esm-CBmWJr5M.js +321 -0
- package/dist/dagre-CZ6P9L_h.js +1 -0
- package/dist/dagre-GXQ25YYZ-CQszk-7P.js +4 -0
- package/dist/dagre-GXQ25YYZ-ecYByRSn.mjs +425 -0
- package/dist/dagre-J_1oH0eY.mjs +1934 -0
- package/dist/defaultLocale-N-0uLSyg.mjs +198 -0
- package/dist/defaultLocale-ybN1Vtvg.js +1 -0
- package/dist/diagram-S7CK7UJ4-CTMvxX__.js +30 -0
- package/dist/diagram-S7CK7UJ4-DxCghfa-.mjs +301 -0
- package/dist/diagram-UQ7AKVKN-1viEkqlG.js +41 -0
- package/dist/diagram-UQ7AKVKN-BA7Z_oB7.mjs +214 -0
- package/dist/diagram-VSXAHHWV-DgVT19mq.js +3 -0
- package/dist/diagram-VSXAHHWV-Dtqo03M5.mjs +432 -0
- package/dist/diagram-VX7I27RA-CNw0pOX_.js +24 -0
- package/dist/diagram-VX7I27RA-GMPRt8Zh.mjs +527 -0
- package/dist/diagram-Z3DM3KII-C6XdQK_Q.mjs +134 -0
- package/dist/diagram-Z3DM3KII-CPkBr3FT.js +24 -0
- package/dist/dist-CXWJafG_.js +1 -0
- package/dist/dist-DNdLIC8h.mjs +59 -0
- package/dist/docmedown.cjs +125 -44
- package/dist/docmedown.iife.js +3477 -72
- package/dist/docmedown.mjs +10003 -4807
- package/dist/ebnfDiagram-PWID7BFC-CseVsyL3.js +1 -0
- package/dist/ebnfDiagram-PWID7BFC-D_dBDXWC.mjs +100 -0
- package/dist/erDiagram-RLTQ6QDP-DFwfQTRS.js +99 -0
- package/dist/erDiagram-RLTQ6QDP-DP7ddGMH.mjs +1966 -0
- package/dist/eventmodeling-NTZA5JFV-CzxVg0l5.js +1 -0
- package/dist/eventmodeling-NTZA5JFV-Djsy__5n.mjs +3 -0
- package/dist/flowDiagram-HODETNUW-7hSJfI3W.js +1 -0
- package/dist/flowDiagram-HODETNUW-Dqu5Lr19.mjs +17 -0
- package/dist/ganttDiagram-EL5Y4UJY-KNL3tzTD.mjs +3072 -0
- package/dist/ganttDiagram-EL5Y4UJY-aiLqNWgi.js +292 -0
- package/dist/gitGraph-4MIJSDKK-DnElfqX7.js +1 -0
- package/dist/gitGraph-4MIJSDKK-xuKJBT2e.mjs +3 -0
- package/dist/gitGraphDiagram-WWUBYQGX-D4gSo_-e.js +106 -0
- package/dist/gitGraphDiagram-WWUBYQGX-Dooss5fG.mjs +733 -0
- package/dist/graphlib-BaETKKSa.js +1 -0
- package/dist/graphlib-XW-Jr8pF.mjs +1267 -0
- package/dist/info-A6RAGUB7-ClYskpn6.mjs +3 -0
- package/dist/info-A6RAGUB7-DDvvt-fW.js +1 -0
- package/dist/infoDiagram-27XIBGKW-B2-y2mdQ.mjs +20 -0
- package/dist/infoDiagram-27XIBGKW-DYQ9NzfL.js +2 -0
- package/dist/init-BJdqMO10.js +1 -0
- package/dist/init-CsQUQz36.mjs +13 -0
- package/dist/ishikawaDiagram-5VMMS53U-ULIhoYO5.js +70 -0
- package/dist/ishikawaDiagram-5VMMS53U-xAArNh-1.mjs +719 -0
- package/dist/journeyDiagram-3NMN7TZE-BBMYNZRL.js +139 -0
- package/dist/journeyDiagram-3NMN7TZE-BH-uKqP7.mjs +884 -0
- package/dist/kanban-definition-UXKFOSKX-Be49llXr.mjs +976 -0
- package/dist/kanban-definition-UXKFOSKX-CDL5yJkq.js +89 -0
- package/dist/line-BEwhHSLl.js +1 -0
- package/dist/line-CiXRog8O.mjs +34 -0
- package/dist/linear-75tfjrny.js +1 -0
- package/dist/linear-Ncx_RuON.mjs +288 -0
- package/dist/mermaid-parser.core-BBApyu_y.js +6 -0
- package/dist/mermaid-parser.core-BRHibdUE.mjs +638 -0
- package/dist/mindmap-definition-YA3MSWOX-Chy7XP_5.mjs +1006 -0
- package/dist/mindmap-definition-YA3MSWOX-DOda-fkL.js +96 -0
- package/dist/ordinal-B1BNQwUR.mjs +65 -0
- package/dist/ordinal-B9aFWmF9.js +1 -0
- package/dist/packet-AYTQ26CC-CorIy9Ul.js +1 -0
- package/dist/packet-AYTQ26CC-DWH8gXJK.mjs +3 -0
- package/dist/path-CnWkkRiY.mjs +84 -0
- package/dist/path-DIS6ck99.js +1 -0
- package/dist/pegDiagram-XKGWAZYB-Cdw6MeON.js +1 -0
- package/dist/pegDiagram-XKGWAZYB-uNfxRaq1.mjs +94 -0
- package/dist/pie-WAS4IAKB-Cn5eK-5P.mjs +3 -0
- package/dist/pie-WAS4IAKB-D84xrSoY.js +1 -0
- package/dist/pieDiagram-E7YTZNPT-Bd6mvpJw.js +39 -0
- package/dist/pieDiagram-E7YTZNPT-Cczo96a2.mjs +203 -0
- package/dist/quadrantDiagram-AXDQQJYC-BPfgvMsS.js +7 -0
- package/dist/quadrantDiagram-AXDQQJYC-eqRNtVRl.mjs +2001 -0
- package/dist/radar-RG4KPBEZ-DvkxGdO6.mjs +3 -0
- package/dist/radar-RG4KPBEZ-R2sQOLL9.js +1 -0
- package/dist/railroad-74A4TZTK-BOZIf6ts.js +1 -0
- package/dist/railroad-74A4TZTK-CrQzn8Nm.mjs +3 -0
- package/dist/railroad-abnf-HS5TGJTU-BZYetxLz.mjs +3 -0
- package/dist/railroad-abnf-HS5TGJTU-CXU1aC4B.js +1 -0
- package/dist/railroad-ebnf-LZEXJU2U-D29kI3YW.js +1 -0
- package/dist/railroad-ebnf-LZEXJU2U-qgzTOmN6.mjs +3 -0
- package/dist/railroad-peg-WCYAUIDC-Bjs9Ws3P.mjs +3 -0
- package/dist/railroad-peg-WCYAUIDC-CXviP0hz.js +1 -0
- package/dist/railroadDiagram-O6MQD6OU-58kvwt7H.mjs +76 -0
- package/dist/railroadDiagram-O6MQD6OU-CKY3uzTc.js +1 -0
- package/dist/requirementDiagram-BXWQKSXE-0hZ04Q6h.js +84 -0
- package/dist/requirementDiagram-BXWQKSXE-CS673B5n.mjs +2224 -0
- package/dist/rough.esm-ChRLLRha.js +1 -0
- package/dist/rough.esm-DXYGHN3m.mjs +1361 -0
- package/dist/sankeyDiagram-P5KCCOFB-D1D6HfAM.mjs +972 -0
- package/dist/sankeyDiagram-P5KCCOFB-ciJb9Zr8.js +40 -0
- package/dist/sequenceDiagram-WJ2MYXX4-BXEznuI6.js +162 -0
- package/dist/sequenceDiagram-WJ2MYXX4-CI1VT8AG.mjs +4156 -0
- package/dist/sizeCapture-INFHLROL-BihkCH-7.js +1 -0
- package/dist/sizeCapture-INFHLROL-BmxqyOLj.mjs +46 -0
- package/dist/src-B4mN2BMl.js +1 -0
- package/dist/src-D_hsMyeP.mjs +2154 -0
- package/dist/stateDiagram-D77RDMKH-BQrSs72W.mjs +220 -0
- package/dist/stateDiagram-D77RDMKH-D2PtkW2U.js +1 -0
- package/dist/stateDiagram-v2-MP3YSRHH-CCbvNfk-.mjs +30 -0
- package/dist/stateDiagram-v2-MP3YSRHH-Dq1QuPeN.js +1 -0
- package/dist/swimlanes-42K2YHIH-CA316NPm.mjs +4979 -0
- package/dist/swimlanes-42K2YHIH-DlggBCTy.js +1 -0
- package/dist/swimlanesDiagram-VR7AAH4N-BV9PEIoG.js +8 -0
- package/dist/swimlanesDiagram-VR7AAH4N-BfrOCfdf.mjs +31 -0
- package/dist/timeline-definition-24CTP7MA-Bkd8rWNJ.js +120 -0
- package/dist/timeline-definition-24CTP7MA-BvkqNYt1.mjs +1069 -0
- package/dist/treeView-Q6P3EWNA-Aof3Cp1M.mjs +3 -0
- package/dist/treeView-Q6P3EWNA-BTzvdwbb.js +1 -0
- package/dist/treemap-WGGIJYW6-BNXGg99p.mjs +3 -0
- package/dist/treemap-WGGIJYW6-DfR4P2Hh.js +1 -0
- package/dist/types/runtime/app.d.ts +3 -3
- package/dist/types/runtime/components/AppearanceMenu.d.ts +2 -0
- package/dist/types/runtime/components/Builtins.d.ts +3 -3
- package/dist/types/runtime/components/Content.d.ts +1 -1
- package/dist/types/runtime/components/DmdRegistry.d.ts +4 -2
- package/dist/types/runtime/components/Layout.d.ts +1 -1
- package/dist/types/runtime/components/MermaidDiagram.d.ts +16 -0
- package/dist/types/runtime/components/Navbar.d.ts +1 -1
- package/dist/types/runtime/components/OfflineDownloadButton.d.ts +2 -0
- package/dist/types/runtime/components/Sidebar.d.ts +1 -1
- package/dist/types/runtime/components/TableOfContents.d.ts +2 -2
- package/dist/types/runtime/config-schema.d.ts +386 -0
- package/dist/types/runtime/config.d.ts +10 -3
- package/dist/types/runtime/index.d.ts +7 -5
- package/dist/types/runtime/loader/auto-indexer.d.ts +1 -1
- package/dist/types/runtime/loader/local-loader.d.ts +1 -1
- package/dist/types/runtime/loader/remote-github.d.ts +2 -2
- package/dist/types/runtime/loader/remote-gitlab.d.ts +2 -2
- package/dist/types/runtime/markdown/callouts.d.ts +1 -1
- package/dist/types/runtime/markdown/highlighter.d.ts +16 -16
- package/dist/types/runtime/markdown/mermaid.d.ts +82 -1
- package/dist/types/runtime/markdown/parser.d.ts +1 -1
- package/dist/types/runtime/markdown/renderer.d.ts +1 -1
- package/dist/types/runtime/offline-export.d.ts +26 -0
- package/dist/types/runtime/provider/DocProvider.d.ts +5 -5
- package/dist/types/runtime/provider/ThemeProvider.d.ts +13 -6
- package/dist/types/runtime/search/SearchModal.d.ts +2 -2
- package/dist/types/runtime/search/search-index.d.ts +1 -1
- package/dist/types/runtime/types.d.ts +28 -99
- package/dist/vennDiagram-4TSXK5OY-BOUFXjso.js +34 -0
- package/dist/vennDiagram-4TSXK5OY-CeOg3-hU.mjs +1880 -0
- package/dist/wardley-WFR3VGLG-BOYcSLd1.mjs +3 -0
- package/dist/wardley-WFR3VGLG-DWDqJSgm.js +1 -0
- package/dist/wardleyDiagram-VM6X3IG4-BhWgMjFr.js +78 -0
- package/dist/wardleyDiagram-VM6X3IG4-C31KoRmF.mjs +645 -0
- package/dist/xychartDiagram-S5SC5T6Z-1yU8zz6I.js +7 -0
- package/dist/xychartDiagram-S5SC5T6Z-BK7upFom.mjs +2210 -0
- package/package.json +15 -4
- package/schemas/docs.schema.json +166 -0
- package/templates/README.md +4 -4
- package/templates/docs.json +5 -2
- package/templates/getting-started.md +1 -1
- package/templates/guides/custom-components.md +2 -0
- package/templates/index.html +2 -4
package/dist/cli.js
CHANGED
|
@@ -24,34 +24,354 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
24
24
|
));
|
|
25
25
|
|
|
26
26
|
// src/cli/index.ts
|
|
27
|
+
var import_node_fs7 = __toESM(require("fs"));
|
|
28
|
+
var import_node_path7 = __toESM(require("path"));
|
|
27
29
|
var import_commander = require("commander");
|
|
28
|
-
var import_fs7 = __toESM(require("fs"));
|
|
29
|
-
var import_path7 = __toESM(require("path"));
|
|
30
30
|
|
|
31
|
-
//
|
|
32
|
-
var
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
31
|
+
// package.json
|
|
32
|
+
var package_default = {
|
|
33
|
+
name: "docmedown",
|
|
34
|
+
version: "0.1.2",
|
|
35
|
+
description: "The simplest MarkDown documenter yet. CLI & Web Script React SPA documentation engine.",
|
|
36
|
+
main: "./dist/docmedown.cjs",
|
|
37
|
+
module: "./dist/docmedown.mjs",
|
|
38
|
+
types: "./dist/types/runtime/index.d.ts",
|
|
39
|
+
exports: {
|
|
40
|
+
".": {
|
|
41
|
+
types: "./dist/types/runtime/index.d.ts",
|
|
42
|
+
import: "./dist/docmedown.mjs",
|
|
43
|
+
require: "./dist/docmedown.cjs"
|
|
44
|
+
},
|
|
45
|
+
"./iife": "./dist/docmedown.iife.js"
|
|
46
|
+
},
|
|
47
|
+
unpkg: "./dist/docmedown.iife.js",
|
|
48
|
+
jsdelivr: "./dist/docmedown.iife.js",
|
|
49
|
+
bin: {
|
|
50
|
+
docmedown: "bin/docmedown.js",
|
|
51
|
+
dmd: "bin/docmedown.js"
|
|
52
|
+
},
|
|
53
|
+
files: [
|
|
54
|
+
"dist",
|
|
55
|
+
"bin",
|
|
56
|
+
"templates",
|
|
57
|
+
"schemas",
|
|
58
|
+
"README.md",
|
|
59
|
+
"LICENSE"
|
|
60
|
+
],
|
|
61
|
+
scripts: {
|
|
62
|
+
"dev:runtime": "vite build --watch",
|
|
63
|
+
"build:runtime": "vite build",
|
|
64
|
+
"build:cli": "tsup",
|
|
65
|
+
typecheck: "tsc --noEmit",
|
|
66
|
+
lint: "biome check .",
|
|
67
|
+
"lint:fix": "biome check --write .",
|
|
68
|
+
format: "biome format --write .",
|
|
69
|
+
"build:types": "tsc -p tsconfig.runtime.json",
|
|
70
|
+
build: "npm run build:runtime && npm run build:cli && npm run build:types",
|
|
71
|
+
docmedown: "node ./bin/docmedown.js",
|
|
72
|
+
dmd: "node ./bin/docmedown.js",
|
|
73
|
+
"init:docs": "node ./bin/docmedown.js init",
|
|
74
|
+
serve: "node ./bin/docmedown.js serve ./docs",
|
|
75
|
+
dev: "node ./bin/docmedown.js serve ./docs",
|
|
76
|
+
"build:docs": "node ./bin/docmedown.js build ./docs",
|
|
77
|
+
"build:docs:watch": "node ./bin/docmedown.js build ./docs --watch",
|
|
78
|
+
"build:offline": "node ./bin/docmedown.js build ./docs",
|
|
79
|
+
"config:docs": "node ./bin/docmedown.js config ./docs/docs.json",
|
|
80
|
+
test: "npx tsx --test tests/parser.test.ts tests/scanner.test.ts tests/theme-schema.test.ts tests/runtime-integration.test.ts tests/package-smoke.test.ts tests/hosting.test.ts",
|
|
81
|
+
"test:artifacts": "npx tsx --test tests/offline-artifact.test.ts",
|
|
82
|
+
"test:release": "npm run typecheck && npm run lint && npm run test && npm run build && npm run build:docs && npm run test:artifacts && npm pack --dry-run",
|
|
83
|
+
deploy: "node ./scripts/deploy.mjs",
|
|
84
|
+
"deploy:dry-run": "npm run deploy -- --dry-run",
|
|
85
|
+
prepublishOnly: "npm run test:release"
|
|
86
|
+
},
|
|
87
|
+
keywords: [
|
|
88
|
+
"markdown",
|
|
89
|
+
"documentation",
|
|
90
|
+
"docs",
|
|
91
|
+
"docusaurus",
|
|
92
|
+
"docsify",
|
|
93
|
+
"react",
|
|
94
|
+
"spa",
|
|
95
|
+
"cli",
|
|
96
|
+
"offline-docs",
|
|
97
|
+
"github-docs"
|
|
98
|
+
],
|
|
99
|
+
author: "Gabriel M. Silva",
|
|
100
|
+
license: "MIT",
|
|
101
|
+
engines: {
|
|
102
|
+
node: ">=20.19.0"
|
|
103
|
+
},
|
|
104
|
+
repository: {
|
|
105
|
+
type: "git",
|
|
106
|
+
url: "git+https://github.com/gabrielmsilva00/docmedown.git"
|
|
107
|
+
},
|
|
108
|
+
bugs: {
|
|
109
|
+
url: "https://github.com/gabrielmsilva00/docmedown/issues"
|
|
110
|
+
},
|
|
111
|
+
homepage: "https://github.com/gabrielmsilva00/docmedown#readme",
|
|
112
|
+
packageManager: "npm@11.16.0",
|
|
113
|
+
overrides: {
|
|
114
|
+
tsup: {
|
|
115
|
+
esbuild: "0.28.2"
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
dependencies: {
|
|
119
|
+
chalk: "^4.1.2",
|
|
120
|
+
chokidar: "^3.6.0",
|
|
121
|
+
commander: "^12.1.0",
|
|
122
|
+
esbuild: "^0.28.2",
|
|
123
|
+
"gray-matter": "^4.0.3",
|
|
124
|
+
"mime-types": "^2.1.35",
|
|
125
|
+
open: "^10.1.0",
|
|
126
|
+
prompts: "^2.4.2",
|
|
127
|
+
ws: "^8.18.0",
|
|
128
|
+
zod: "^4.4.3"
|
|
129
|
+
},
|
|
130
|
+
devDependencies: {
|
|
131
|
+
"@biomejs/biome": "^2.5.10",
|
|
132
|
+
"@types/node": "^22.5.0",
|
|
133
|
+
"@types/prismjs": "^1.26.6",
|
|
134
|
+
"@types/prompts": "^2.4.9",
|
|
135
|
+
"@types/react": "^18.3.5",
|
|
136
|
+
"@types/react-dom": "^18.3.0",
|
|
137
|
+
"@types/ws": "^8.5.12",
|
|
138
|
+
"@vitejs/plugin-react": "^6.1.0",
|
|
139
|
+
katex: "^0.16.11",
|
|
140
|
+
marked: "^14.1.1",
|
|
141
|
+
mermaid: "^11.17.2",
|
|
142
|
+
minisearch: "^7.1.0",
|
|
143
|
+
prismjs: "^1.29.0",
|
|
144
|
+
react: "^18.3.1",
|
|
145
|
+
"react-dom": "^18.3.1",
|
|
146
|
+
tsup: "^8.2.4",
|
|
147
|
+
tsx: "^4.19.0",
|
|
148
|
+
typescript: "^5.5.4",
|
|
149
|
+
vite: "^8.2.2",
|
|
150
|
+
"vite-plugin-css-injected-by-js": "^5.0.2"
|
|
151
|
+
}
|
|
152
|
+
};
|
|
45
153
|
|
|
46
154
|
// src/cli/commands/build.ts
|
|
47
|
-
var
|
|
48
|
-
var
|
|
155
|
+
var import_node_fs2 = __toESM(require("fs"));
|
|
156
|
+
var import_node_path2 = __toESM(require("path"));
|
|
157
|
+
var import_node_zlib = require("zlib");
|
|
49
158
|
var import_chalk = __toESM(require("chalk"));
|
|
50
159
|
var import_chokidar = __toESM(require("chokidar"));
|
|
160
|
+
var import_esbuild = require("esbuild");
|
|
161
|
+
|
|
162
|
+
// src/runtime/config-schema.ts
|
|
163
|
+
var import_zod = require("zod");
|
|
164
|
+
var nonEmptyString = import_zod.z.string().trim().min(1, "Must not be empty.");
|
|
165
|
+
var themePresetSchema = import_zod.z.enum(["indigo", "emerald", "sunset", "violet", "rose", "slate", "cyberpunk"]);
|
|
166
|
+
var themeFamilySchema = import_zod.z.enum(["atlas", "blueprint", "terminal", "editorial"]);
|
|
167
|
+
var themeDensitySchema = import_zod.z.enum(["comfortable", "compact"]);
|
|
168
|
+
var colorModeSchema = import_zod.z.enum(["light", "dark", "auto"]);
|
|
169
|
+
var socialTypeSchema = import_zod.z.enum(["github", "gitlab", "twitter", "x", "discord", "custom"]);
|
|
170
|
+
var badgeTypeSchema = import_zod.z.enum(["info", "success", "warning", "new"]);
|
|
171
|
+
var navLinkSchema = import_zod.z.object({
|
|
172
|
+
label: nonEmptyString,
|
|
173
|
+
href: nonEmptyString,
|
|
174
|
+
external: import_zod.z.boolean().optional(),
|
|
175
|
+
icon: import_zod.z.string().optional()
|
|
176
|
+
}).strict();
|
|
177
|
+
var socialLinkSchema = import_zod.z.object({
|
|
178
|
+
type: socialTypeSchema,
|
|
179
|
+
url: import_zod.z.string().url("Must be an absolute URL."),
|
|
180
|
+
label: import_zod.z.string().optional(),
|
|
181
|
+
icon: import_zod.z.string().optional()
|
|
182
|
+
}).strict();
|
|
183
|
+
var remoteSourceSchema = import_zod.z.discriminatedUnion("type", [
|
|
184
|
+
import_zod.z.object({
|
|
185
|
+
type: import_zod.z.literal("github"),
|
|
186
|
+
repo: nonEmptyString.regex(/^[^/\s]+\/[^/\s]+$/, "Use the owner/repository format."),
|
|
187
|
+
branch: nonEmptyString.optional(),
|
|
188
|
+
docsDir: import_zod.z.string().optional(),
|
|
189
|
+
token: import_zod.z.string().optional(),
|
|
190
|
+
baseUrl: import_zod.z.string().url("Must be an absolute URL.").optional()
|
|
191
|
+
}).strict(),
|
|
192
|
+
import_zod.z.object({
|
|
193
|
+
type: import_zod.z.literal("gitlab"),
|
|
194
|
+
repo: nonEmptyString.regex(/^[^/\s]+\/[^/\s]+$/, "Use the namespace/repository format."),
|
|
195
|
+
branch: nonEmptyString.optional(),
|
|
196
|
+
docsDir: import_zod.z.string().optional(),
|
|
197
|
+
token: import_zod.z.string().optional(),
|
|
198
|
+
baseUrl: import_zod.z.string().url("Must be an absolute URL.").optional()
|
|
199
|
+
}).strict(),
|
|
200
|
+
import_zod.z.object({
|
|
201
|
+
type: import_zod.z.literal("raw"),
|
|
202
|
+
baseUrl: import_zod.z.string().url("Must be an absolute URL."),
|
|
203
|
+
branch: nonEmptyString.optional(),
|
|
204
|
+
docsDir: import_zod.z.string().optional(),
|
|
205
|
+
token: import_zod.z.string().optional()
|
|
206
|
+
}).strict()
|
|
207
|
+
]);
|
|
208
|
+
var sidebarItemSchema = import_zod.z.lazy(
|
|
209
|
+
() => import_zod.z.object({
|
|
210
|
+
title: import_zod.z.string().optional(),
|
|
211
|
+
path: import_zod.z.string().optional(),
|
|
212
|
+
slug: import_zod.z.string().optional(),
|
|
213
|
+
icon: import_zod.z.string().optional(),
|
|
214
|
+
badge: import_zod.z.string().optional(),
|
|
215
|
+
badgeType: badgeTypeSchema.optional(),
|
|
216
|
+
collapsed: import_zod.z.boolean().optional(),
|
|
217
|
+
children: import_zod.z.array(sidebarItemSchema).optional()
|
|
218
|
+
}).strict()
|
|
219
|
+
);
|
|
220
|
+
var docThemeConfigSchema = import_zod.z.object({
|
|
221
|
+
family: themeFamilySchema.optional(),
|
|
222
|
+
density: themeDensitySchema.optional(),
|
|
223
|
+
/** @deprecated Use `family`. Preserved to migrate existing docs.json files. */
|
|
224
|
+
preset: themePresetSchema.optional(),
|
|
225
|
+
defaultMode: colorModeSchema.optional(),
|
|
226
|
+
accentColor: import_zod.z.string().optional(),
|
|
227
|
+
accentColorDark: import_zod.z.string().optional(),
|
|
228
|
+
fontFamily: import_zod.z.string().optional(),
|
|
229
|
+
codeTheme: import_zod.z.enum(["github", "dracula", "one-dark", "synthwave"]).optional(),
|
|
230
|
+
logo: import_zod.z.object({
|
|
231
|
+
light: import_zod.z.string().optional(),
|
|
232
|
+
dark: import_zod.z.string().optional(),
|
|
233
|
+
alt: import_zod.z.string().optional(),
|
|
234
|
+
text: import_zod.z.string().optional()
|
|
235
|
+
}).strict().optional(),
|
|
236
|
+
favicon: import_zod.z.string().optional()
|
|
237
|
+
}).strict();
|
|
238
|
+
var docSearchConfigSchema = import_zod.z.object({
|
|
239
|
+
enabled: import_zod.z.boolean().optional(),
|
|
240
|
+
placeholder: import_zod.z.string().optional(),
|
|
241
|
+
maxResults: import_zod.z.number().int().positive().max(100).optional()
|
|
242
|
+
}).strict();
|
|
243
|
+
var docConfigSchema = import_zod.z.object({
|
|
244
|
+
$schema: import_zod.z.string().url("Must be an absolute URL.").optional(),
|
|
245
|
+
name: nonEmptyString.optional(),
|
|
246
|
+
tagline: import_zod.z.string().optional(),
|
|
247
|
+
description: import_zod.z.string().optional(),
|
|
248
|
+
version: import_zod.z.string().optional(),
|
|
249
|
+
rootDoc: nonEmptyString.optional(),
|
|
250
|
+
source: remoteSourceSchema.optional(),
|
|
251
|
+
theme: docThemeConfigSchema.optional(),
|
|
252
|
+
nav: import_zod.z.array(navLinkSchema).optional(),
|
|
253
|
+
socials: import_zod.z.array(socialLinkSchema).optional(),
|
|
254
|
+
sidebar: import_zod.z.array(sidebarItemSchema).optional(),
|
|
255
|
+
autoIndex: import_zod.z.object({
|
|
256
|
+
enabled: import_zod.z.boolean().optional(),
|
|
257
|
+
exclude: import_zod.z.array(nonEmptyString).optional(),
|
|
258
|
+
sort: import_zod.z.enum(["alphabetical", "frontmatter", "natural"]).optional(),
|
|
259
|
+
defaultCollapsed: import_zod.z.boolean().optional()
|
|
260
|
+
}).strict().optional(),
|
|
261
|
+
search: docSearchConfigSchema.optional(),
|
|
262
|
+
footer: import_zod.z.object({
|
|
263
|
+
copyright: import_zod.z.string().optional(),
|
|
264
|
+
links: import_zod.z.array(navLinkSchema).optional(),
|
|
265
|
+
showBuiltWith: import_zod.z.boolean().optional()
|
|
266
|
+
}).strict().optional(),
|
|
267
|
+
componentsUrl: import_zod.z.string().optional(),
|
|
268
|
+
editUrl: import_zod.z.string().optional()
|
|
269
|
+
}).strict();
|
|
270
|
+
var normalizedDocConfigSchema = docConfigSchema.extend({
|
|
271
|
+
name: nonEmptyString
|
|
272
|
+
});
|
|
273
|
+
function formatConfigIssues(error) {
|
|
274
|
+
return error.issues.map((issue) => `${issue.path.length > 0 ? issue.path.join(".") : "config"}: ${issue.message}`).join("\n");
|
|
275
|
+
}
|
|
276
|
+
function parseDocConfig(input) {
|
|
277
|
+
const result = docConfigSchema.safeParse(input);
|
|
278
|
+
if (result.success) return result.data;
|
|
279
|
+
throw new Error(`Invalid DocMeDown configuration:
|
|
280
|
+
${formatConfigIssues(result.error)}`);
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
// src/runtime/config.ts
|
|
284
|
+
var LEGACY_PRESET_FAMILIES = {
|
|
285
|
+
indigo: "atlas",
|
|
286
|
+
emerald: "atlas",
|
|
287
|
+
sunset: "editorial",
|
|
288
|
+
violet: "atlas",
|
|
289
|
+
rose: "editorial",
|
|
290
|
+
slate: "blueprint",
|
|
291
|
+
cyberpunk: "terminal"
|
|
292
|
+
};
|
|
293
|
+
var DEFAULT_CONFIG = {
|
|
294
|
+
name: "DocMeDown",
|
|
295
|
+
tagline: "The simplest Markdown documenter yet",
|
|
296
|
+
description: "Instant documentation site powered by DocMeDown",
|
|
297
|
+
version: "1.0.0",
|
|
298
|
+
rootDoc: "README.md",
|
|
299
|
+
theme: {
|
|
300
|
+
family: "atlas",
|
|
301
|
+
density: "comfortable",
|
|
302
|
+
defaultMode: "auto",
|
|
303
|
+
codeTheme: "github"
|
|
304
|
+
},
|
|
305
|
+
autoIndex: {
|
|
306
|
+
enabled: true,
|
|
307
|
+
sort: "natural",
|
|
308
|
+
defaultCollapsed: false,
|
|
309
|
+
exclude: ["node_modules", ".git", ".dmd", "dist", "bin", "package.json", "tsconfig.json"]
|
|
310
|
+
},
|
|
311
|
+
search: {
|
|
312
|
+
enabled: true,
|
|
313
|
+
placeholder: "Search documentation...",
|
|
314
|
+
maxResults: 10
|
|
315
|
+
},
|
|
316
|
+
footer: {
|
|
317
|
+
copyright: `\xA9 ${(/* @__PURE__ */ new Date()).getFullYear()} DocMeDown. All rights reserved.`,
|
|
318
|
+
showBuiltWith: true
|
|
319
|
+
}
|
|
320
|
+
};
|
|
321
|
+
function normalizeConfig(userConfig = {}) {
|
|
322
|
+
const parsedConfig = parseDocConfig(userConfig);
|
|
323
|
+
const legacyPreset = parsedConfig.theme?.preset;
|
|
324
|
+
const family = parsedConfig.theme?.family || (legacyPreset ? LEGACY_PRESET_FAMILIES[legacyPreset] : DEFAULT_CONFIG.theme?.family);
|
|
325
|
+
const { preset: _legacyPreset, ...resolvedTheme } = parsedConfig.theme ?? {};
|
|
326
|
+
void _legacyPreset;
|
|
327
|
+
const mergedConfig = {
|
|
328
|
+
...DEFAULT_CONFIG,
|
|
329
|
+
...parsedConfig,
|
|
330
|
+
theme: {
|
|
331
|
+
...DEFAULT_CONFIG.theme,
|
|
332
|
+
...resolvedTheme,
|
|
333
|
+
family,
|
|
334
|
+
logo: {
|
|
335
|
+
...DEFAULT_CONFIG.theme?.logo,
|
|
336
|
+
...parsedConfig.theme?.logo
|
|
337
|
+
}
|
|
338
|
+
},
|
|
339
|
+
autoIndex: {
|
|
340
|
+
...DEFAULT_CONFIG.autoIndex,
|
|
341
|
+
...parsedConfig.autoIndex
|
|
342
|
+
},
|
|
343
|
+
search: {
|
|
344
|
+
...DEFAULT_CONFIG.search,
|
|
345
|
+
...parsedConfig.search
|
|
346
|
+
},
|
|
347
|
+
footer: {
|
|
348
|
+
...DEFAULT_CONFIG.footer,
|
|
349
|
+
...parsedConfig.footer
|
|
350
|
+
}
|
|
351
|
+
};
|
|
352
|
+
return normalizedDocConfigSchema.parse(mergedConfig);
|
|
353
|
+
}
|
|
354
|
+
function parseDocConfigJson(json, source) {
|
|
355
|
+
try {
|
|
356
|
+
return parseDocConfig(JSON.parse(json));
|
|
357
|
+
} catch (error) {
|
|
358
|
+
throw new Error(`${source}: ${error instanceof Error ? error.message : String(error)}`);
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
// src/runtime/offline-export.ts
|
|
363
|
+
var OFFLINE_FORMAT_VERSION = 1;
|
|
364
|
+
function escapeHtml(value) {
|
|
365
|
+
return value.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
366
|
+
}
|
|
367
|
+
function createCompressedOfflineHtml(encodedGzip, title) {
|
|
368
|
+
const bootstrap = `(async()=>{try{const b=Uint8Array.from(atob(document.getElementById("d").textContent.trim()),c=>c.charCodeAt(0)),s=await new Response(new Blob([b]).stream().pipeThrough(new DecompressionStream("gzip"))).text(),e=JSON.parse(s);if(e.version!==${OFFLINE_FORMAT_VERSION})throw new Error("Unsupported offline format");window.__DOCMEDOWN_OFFLINE__=true;window.__DOCMEDOWN_DATA__=e.data;window.__DOCMEDOWN_CONFIG__=e.data.manifest.config;const u=URL.createObjectURL(new Blob([e.runtime],{type:"text/javascript"})),j=document.createElement("script");j.src=u;j.onload=()=>URL.revokeObjectURL(u);j.onerror=()=>{URL.revokeObjectURL(u);throw new Error("Runtime bootstrap failed")};document.head.appendChild(j)}catch(e){document.getElementById("dmd-app").textContent="Could not open this offline documentation copy: "+e.message}})();`;
|
|
369
|
+
return `<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="icon" href="data:,"><title>${escapeHtml(title)}</title></head><body><div id="dmd-app">Opening offline documentation\u2026</div><script id="d" type="application/octet-stream">${encodedGzip}</script><script>${bootstrap}</script></body></html>`;
|
|
370
|
+
}
|
|
51
371
|
|
|
52
372
|
// src/cli/utils/scanner.ts
|
|
53
|
-
var
|
|
54
|
-
var
|
|
373
|
+
var import_node_fs = __toESM(require("fs"));
|
|
374
|
+
var import_node_path = __toESM(require("path"));
|
|
55
375
|
var import_gray_matter = __toESM(require("gray-matter"));
|
|
56
376
|
|
|
57
377
|
// src/runtime/loader/auto-indexer.ts
|
|
@@ -181,16 +501,16 @@ function extractHeadings(content) {
|
|
|
181
501
|
}
|
|
182
502
|
function scanDirectory(dir, baseDir = dir, excludeList = ["node_modules", ".git", ".dmd", "dist", "bin"], stopAtNestedDocsRoots = true) {
|
|
183
503
|
const results = [];
|
|
184
|
-
if (!
|
|
185
|
-
const entries =
|
|
504
|
+
if (!import_node_fs.default.existsSync(dir)) return results;
|
|
505
|
+
const entries = import_node_fs.default.readdirSync(dir, { withFileTypes: true });
|
|
186
506
|
for (const entry of entries) {
|
|
187
507
|
if (excludeList.includes(entry.name) || entry.name.startsWith(".")) {
|
|
188
508
|
continue;
|
|
189
509
|
}
|
|
190
|
-
const fullPath =
|
|
191
|
-
const relPath =
|
|
510
|
+
const fullPath = import_node_path.default.join(dir, entry.name);
|
|
511
|
+
const relPath = import_node_path.default.relative(baseDir, fullPath).replace(/\\/g, "/");
|
|
192
512
|
if (entry.isDirectory()) {
|
|
193
|
-
const isNestedDocsRoot = stopAtNestedDocsRoots && fullPath !== baseDir &&
|
|
513
|
+
const isNestedDocsRoot = stopAtNestedDocsRoots && fullPath !== baseDir && import_node_fs.default.existsSync(import_node_path.default.join(fullPath, "docs.json"));
|
|
194
514
|
if (!isNestedDocsRoot) {
|
|
195
515
|
results.push(...scanDirectory(fullPath, baseDir, excludeList, stopAtNestedDocsRoots));
|
|
196
516
|
}
|
|
@@ -205,13 +525,13 @@ function generateManifest(docDir, config) {
|
|
|
205
525
|
const docItems = [];
|
|
206
526
|
const frontmatters = {};
|
|
207
527
|
for (const relFile of files) {
|
|
208
|
-
const fullPath =
|
|
209
|
-
const raw =
|
|
528
|
+
const fullPath = import_node_path.default.join(docDir, relFile);
|
|
529
|
+
const raw = import_node_fs.default.readFileSync(fullPath, "utf-8");
|
|
210
530
|
const { data: fm, content } = (0, import_gray_matter.default)(raw);
|
|
211
531
|
const cleanSlug = relFile.replace(/\.(md|mdx)$/i, "");
|
|
212
532
|
const isOverview = cleanSlug.toLowerCase() === "readme" || cleanSlug.toLowerCase() === "index";
|
|
213
533
|
const slug = isOverview ? "README" : cleanSlug;
|
|
214
|
-
const title = fm.title || fm.sidebar_label || formatTitleFromFilename(
|
|
534
|
+
const title = fm.title || fm.sidebar_label || formatTitleFromFilename(import_node_path.default.basename(relFile));
|
|
215
535
|
frontmatters[relFile] = fm;
|
|
216
536
|
const headings = extractHeadings(content);
|
|
217
537
|
const words = content.trim().split(/\s+/).length;
|
|
@@ -225,7 +545,7 @@ function generateManifest(docDir, config) {
|
|
|
225
545
|
headings,
|
|
226
546
|
content,
|
|
227
547
|
readingTimeMinutes,
|
|
228
|
-
lastModified:
|
|
548
|
+
lastModified: import_node_fs.default.statSync(fullPath).mtime.toISOString()
|
|
229
549
|
});
|
|
230
550
|
}
|
|
231
551
|
const tree = buildSidebarTree(files, frontmatters, config.sidebar);
|
|
@@ -238,63 +558,52 @@ function generateManifest(docDir, config) {
|
|
|
238
558
|
};
|
|
239
559
|
}
|
|
240
560
|
|
|
241
|
-
// src/runtime/config.ts
|
|
242
|
-
var DEFAULT_CONFIG = {
|
|
243
|
-
name: "DocMeDown",
|
|
244
|
-
tagline: "The simplest Markdown documenter yet",
|
|
245
|
-
description: "Instant documentation site powered by DocMeDown",
|
|
246
|
-
version: "1.0.0",
|
|
247
|
-
rootDoc: "README.md",
|
|
248
|
-
theme: {
|
|
249
|
-
preset: "indigo",
|
|
250
|
-
defaultMode: "auto",
|
|
251
|
-
codeTheme: "github"
|
|
252
|
-
},
|
|
253
|
-
autoIndex: {
|
|
254
|
-
enabled: true,
|
|
255
|
-
sort: "natural",
|
|
256
|
-
defaultCollapsed: false,
|
|
257
|
-
exclude: ["node_modules", ".git", ".dmd", "dist", "bin", "package.json", "tsconfig.json"]
|
|
258
|
-
},
|
|
259
|
-
search: {
|
|
260
|
-
enabled: true,
|
|
261
|
-
placeholder: "Search documentation...",
|
|
262
|
-
maxResults: 10
|
|
263
|
-
},
|
|
264
|
-
footer: {
|
|
265
|
-
copyright: `\xA9 ${(/* @__PURE__ */ new Date()).getFullYear()} DocMeDown. All rights reserved.`,
|
|
266
|
-
showBuiltWith: true
|
|
267
|
-
}
|
|
268
|
-
};
|
|
269
|
-
|
|
270
561
|
// src/cli/commands/build.ts
|
|
271
562
|
var DEFAULT_OFFLINE_OUTPUT_DIRECTORY = ".dist";
|
|
272
563
|
function getBuildOutputPaths(targetDir, offlineOutDir) {
|
|
273
564
|
return {
|
|
274
565
|
onlineDir: targetDir,
|
|
275
|
-
offlineDir: offlineOutDir ?
|
|
566
|
+
offlineDir: offlineOutDir ? import_node_path2.default.resolve(process.cwd(), offlineOutDir) : import_node_path2.default.join(targetDir, DEFAULT_OFFLINE_OUTPUT_DIRECTORY)
|
|
276
567
|
};
|
|
277
568
|
}
|
|
278
|
-
function
|
|
279
|
-
return Buffer.from(JSON.stringify(
|
|
569
|
+
function encodeCompressedOfflineEnvelope(envelope) {
|
|
570
|
+
return (0, import_node_zlib.gzipSync)(Buffer.from(JSON.stringify(envelope), "utf-8"), { level: 9 }).toString("base64");
|
|
280
571
|
}
|
|
281
|
-
function
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
572
|
+
function bundleCustomComponents(componentsPath) {
|
|
573
|
+
if (!import_node_fs2.default.existsSync(componentsPath)) return void 0;
|
|
574
|
+
try {
|
|
575
|
+
const result = (0, import_esbuild.buildSync)({
|
|
576
|
+
entryPoints: [componentsPath],
|
|
577
|
+
bundle: true,
|
|
578
|
+
format: "esm",
|
|
579
|
+
platform: "browser",
|
|
580
|
+
target: "es2022",
|
|
581
|
+
write: false,
|
|
582
|
+
minify: true,
|
|
583
|
+
legalComments: "none"
|
|
584
|
+
});
|
|
585
|
+
const bundledSource = result.outputFiles[0]?.text;
|
|
586
|
+
if (!bundledSource) {
|
|
587
|
+
throw new Error("esbuild did not produce an output module.");
|
|
588
|
+
}
|
|
589
|
+
return bundledSource;
|
|
590
|
+
} catch (error) {
|
|
591
|
+
throw new Error(
|
|
592
|
+
`Could not bundle custom components from ${componentsPath}: ${error instanceof Error ? error.message : String(error)}`
|
|
593
|
+
);
|
|
594
|
+
}
|
|
286
595
|
}
|
|
287
596
|
var GENERATED_DOC_OUTPUTS = ["_manifest.json", "_docs.js", "docmedown.iife.js"];
|
|
288
597
|
function findNestedDocumentationRoots(targetDir) {
|
|
289
598
|
const roots = [];
|
|
290
599
|
function visit(directory) {
|
|
291
|
-
if (!
|
|
292
|
-
for (const entry of
|
|
600
|
+
if (!import_node_fs2.default.existsSync(directory)) return;
|
|
601
|
+
for (const entry of import_node_fs2.default.readdirSync(directory, { withFileTypes: true })) {
|
|
293
602
|
if (!entry.isDirectory() || entry.name.startsWith(".") || ["node_modules", ".git", "dist", "bin"].includes(entry.name)) {
|
|
294
603
|
continue;
|
|
295
604
|
}
|
|
296
|
-
const fullPath =
|
|
297
|
-
if (
|
|
605
|
+
const fullPath = import_node_path2.default.join(directory, entry.name);
|
|
606
|
+
if (import_node_fs2.default.existsSync(import_node_path2.default.join(fullPath, "docs.json"))) {
|
|
298
607
|
roots.push(fullPath);
|
|
299
608
|
visit(fullPath);
|
|
300
609
|
} else {
|
|
@@ -306,132 +615,113 @@ function findNestedDocumentationRoots(targetDir) {
|
|
|
306
615
|
return roots;
|
|
307
616
|
}
|
|
308
617
|
function shouldWatchDocumentationSource(rootDir, changedPath) {
|
|
309
|
-
const relativePath =
|
|
618
|
+
const relativePath = import_node_path2.default.relative(rootDir, changedPath).replace(/\\/g, "/");
|
|
310
619
|
const firstSegment = relativePath.split("/")[0];
|
|
311
620
|
const isCustomComponentModule = /(^|\/)\.dmd\/(components|index)\.js$/i.test(relativePath);
|
|
312
621
|
return Boolean(relativePath) && !relativePath.startsWith("..") && (!relativePath.startsWith(".") || isCustomComponentModule) && !GENERATED_DOC_OUTPUTS.includes(relativePath) && firstSegment !== "node_modules" && firstSegment !== "dist";
|
|
313
622
|
}
|
|
314
623
|
async function buildCommand(targetDirArg = "./docs", options = {}) {
|
|
315
|
-
const targetDir =
|
|
624
|
+
const targetDir = import_node_path2.default.resolve(process.cwd(), targetDirArg);
|
|
316
625
|
const { onlineDir, offlineDir } = getBuildOutputPaths(targetDir, options.outDir);
|
|
317
626
|
const buildOfflineBundle = options.singleFile !== false;
|
|
318
627
|
console.log(import_chalk.default.bold.magenta("\n\u26A1 DocMeDown Build\n"));
|
|
319
|
-
if (!
|
|
628
|
+
if (!import_node_fs2.default.existsSync(targetDir)) {
|
|
320
629
|
console.error(import_chalk.default.red(`\u2716 Directory not found: ${targetDir}`));
|
|
321
630
|
process.exit(1);
|
|
322
631
|
}
|
|
323
|
-
if (!
|
|
324
|
-
|
|
632
|
+
if (!import_node_fs2.default.existsSync(onlineDir)) {
|
|
633
|
+
import_node_fs2.default.mkdirSync(onlineDir, { recursive: true });
|
|
325
634
|
}
|
|
326
|
-
|
|
327
|
-
|
|
635
|
+
import_node_fs2.default.writeFileSync(import_node_path2.default.join(onlineDir, ".nojekyll"), "", "utf-8");
|
|
636
|
+
if (buildOfflineBundle && !import_node_fs2.default.existsSync(offlineDir)) {
|
|
637
|
+
import_node_fs2.default.mkdirSync(offlineDir, { recursive: true });
|
|
328
638
|
}
|
|
329
|
-
let config =
|
|
330
|
-
const configPath =
|
|
331
|
-
if (
|
|
639
|
+
let config = normalizeConfig();
|
|
640
|
+
const configPath = import_node_path2.default.join(targetDir, "docs.json");
|
|
641
|
+
if (import_node_fs2.default.existsSync(configPath)) {
|
|
332
642
|
try {
|
|
333
|
-
config =
|
|
334
|
-
} catch (
|
|
335
|
-
|
|
643
|
+
config = normalizeConfig(parseDocConfigJson(import_node_fs2.default.readFileSync(configPath, "utf-8"), configPath));
|
|
644
|
+
} catch (error) {
|
|
645
|
+
throw new Error(`Could not validate ${configPath}: ${error instanceof Error ? error.message : String(error)}`);
|
|
336
646
|
}
|
|
337
647
|
}
|
|
338
648
|
console.log(import_chalk.default.cyan(" Indexing documentation pages..."));
|
|
339
649
|
const manifest = generateManifest(targetDir, config);
|
|
340
|
-
const manifestPath =
|
|
341
|
-
|
|
650
|
+
const manifestPath = import_node_path2.default.join(onlineDir, "_manifest.json");
|
|
651
|
+
import_node_fs2.default.writeFileSync(manifestPath, JSON.stringify(manifest, null, 2), "utf-8");
|
|
342
652
|
console.log(import_chalk.default.green(` \u2714 Generated _manifest.json (${manifest.docs.length} pages indexed)`));
|
|
343
653
|
const docsMap = {};
|
|
344
654
|
const files = scanDirectory(targetDir);
|
|
345
655
|
for (const file of files) {
|
|
346
|
-
const full =
|
|
347
|
-
const raw =
|
|
656
|
+
const full = import_node_path2.default.join(targetDir, file);
|
|
657
|
+
const raw = import_node_fs2.default.readFileSync(full, "utf-8");
|
|
348
658
|
const slug = file.replace(/\.(md|mdx)$/i, "");
|
|
349
659
|
const cleanSlug = slug.toLowerCase() === "readme" || slug.toLowerCase() === "index" ? "README" : slug;
|
|
350
660
|
docsMap[cleanSlug] = raw;
|
|
351
661
|
docsMap[file] = raw;
|
|
352
662
|
}
|
|
353
|
-
const componentsPath =
|
|
354
|
-
const componentsSource =
|
|
663
|
+
const componentsPath = import_node_path2.default.join(targetDir, ".dmd", "components.js");
|
|
664
|
+
const componentsSource = bundleCustomComponents(componentsPath);
|
|
355
665
|
const docsJsContent = `window.__DOCMEDOWN_DATA__ = ${JSON.stringify({ manifest, docs: docsMap, componentsSource }, null, 2)};
|
|
356
666
|
`;
|
|
357
|
-
const docsJsPath =
|
|
358
|
-
|
|
667
|
+
const docsJsPath = import_node_path2.default.join(onlineDir, "_docs.js");
|
|
668
|
+
import_node_fs2.default.writeFileSync(docsJsPath, docsJsContent, "utf-8");
|
|
359
669
|
console.log(import_chalk.default.green(` \u2714 Generated _docs.js for offline file:/// double-click usage`));
|
|
360
670
|
if (buildOfflineBundle) {
|
|
361
671
|
console.log(import_chalk.default.cyan("\n Compiling standalone single-file offline index.html..."));
|
|
362
672
|
const candidates2 = [
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
673
|
+
import_node_path2.default.resolve(__dirname, "docmedown.iife.js"),
|
|
674
|
+
import_node_path2.default.resolve(__dirname, "../dist/docmedown.iife.js"),
|
|
675
|
+
import_node_path2.default.resolve(__dirname, "../docmedown.iife.js")
|
|
366
676
|
];
|
|
367
|
-
const distIifePath2 = candidates2.find((p) =>
|
|
677
|
+
const distIifePath2 = candidates2.find((p) => import_node_fs2.default.existsSync(p));
|
|
368
678
|
let bundleJs = "";
|
|
369
679
|
if (distIifePath2) {
|
|
370
|
-
bundleJs =
|
|
680
|
+
bundleJs = import_node_fs2.default.readFileSync(distIifePath2, "utf-8");
|
|
371
681
|
} else {
|
|
372
682
|
console.warn(import_chalk.default.yellow(" \u26A0 Local runtime bundle not found, linking CDN script."));
|
|
373
683
|
}
|
|
374
|
-
const
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
<body>
|
|
384
|
-
<div id="dmd-app"></div>
|
|
385
|
-
<script>
|
|
386
|
-
(function () {
|
|
387
|
-
const encoded = '${offlinePayload}';
|
|
388
|
-
const bytes = Uint8Array.from(atob(encoded), (character) => character.charCodeAt(0));
|
|
389
|
-
const data = JSON.parse(new TextDecoder().decode(bytes));
|
|
390
|
-
window.__DOCMEDOWN_DATA__ = data;
|
|
391
|
-
window.__DOCMEDOWN_CONFIG__ = data.manifest.config;
|
|
392
|
-
if (data.componentsSource) {
|
|
393
|
-
const componentModule = new Blob([data.componentsSource], { type: 'text/javascript' });
|
|
394
|
-
const componentModuleUrl = URL.createObjectURL(componentModule);
|
|
395
|
-
window.__DOCMEDOWN_COMPONENTS_READY__ = import(componentModuleUrl)
|
|
396
|
-
.then((module) => module.default || module)
|
|
397
|
-
.finally(() => URL.revokeObjectURL(componentModuleUrl));
|
|
398
|
-
}
|
|
399
|
-
})();
|
|
400
|
-
</script>
|
|
401
|
-
<script>
|
|
402
|
-
${safeBundleJs}
|
|
403
|
-
</script>
|
|
404
|
-
</body>
|
|
405
|
-
</html>`;
|
|
406
|
-
const singleFilePath = import_path2.default.join(offlineDir, "index.html");
|
|
407
|
-
import_fs2.default.writeFileSync(singleFilePath, singleFileHtml, "utf-8");
|
|
684
|
+
const envelope = {
|
|
685
|
+
version: OFFLINE_FORMAT_VERSION,
|
|
686
|
+
data: { manifest, docs: docsMap, componentsSource },
|
|
687
|
+
runtime: bundleJs
|
|
688
|
+
};
|
|
689
|
+
const encodedEnvelope = encodeCompressedOfflineEnvelope(envelope);
|
|
690
|
+
const singleFileHtml = createCompressedOfflineHtml(encodedEnvelope, config.name || "Documentation");
|
|
691
|
+
const singleFilePath = import_node_path2.default.join(offlineDir, "index.html");
|
|
692
|
+
import_node_fs2.default.writeFileSync(singleFilePath, singleFileHtml, "utf-8");
|
|
408
693
|
console.log(import_chalk.default.bold.green(` \u2714 Built self-contained offline bundle: ${singleFilePath}`));
|
|
694
|
+
console.log(
|
|
695
|
+
import_chalk.default.dim(
|
|
696
|
+
` Compressed ${Buffer.byteLength(JSON.stringify(envelope), "utf-8").toLocaleString()} bytes to ${Buffer.byteLength(singleFileHtml, "utf-8").toLocaleString()} bytes.`
|
|
697
|
+
)
|
|
698
|
+
);
|
|
409
699
|
console.log(import_chalk.default.dim(` You can now double-click index.html to view offline without any server!
|
|
410
700
|
`));
|
|
411
701
|
}
|
|
412
702
|
const candidates = [
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
703
|
+
import_node_path2.default.resolve(__dirname, "docmedown.iife.js"),
|
|
704
|
+
import_node_path2.default.resolve(__dirname, "../dist/docmedown.iife.js"),
|
|
705
|
+
import_node_path2.default.resolve(__dirname, "../docmedown.iife.js")
|
|
416
706
|
];
|
|
417
|
-
const distIifePath = candidates.find((p) =>
|
|
418
|
-
const targetBundlePath =
|
|
707
|
+
const distIifePath = candidates.find((p) => import_node_fs2.default.existsSync(p));
|
|
708
|
+
const targetBundlePath = import_node_path2.default.join(onlineDir, "docmedown.iife.js");
|
|
419
709
|
if (distIifePath) {
|
|
420
|
-
|
|
710
|
+
import_node_fs2.default.copyFileSync(distIifePath, targetBundlePath);
|
|
421
711
|
console.log(import_chalk.default.green(` \u2714 Updated serveable runtime: ${targetBundlePath}`));
|
|
422
712
|
}
|
|
423
713
|
if (options.buildNested !== false) {
|
|
424
714
|
const nestedRoots = findNestedDocumentationRoots(targetDir);
|
|
425
715
|
for (const nestedRoot of nestedRoots) {
|
|
426
716
|
console.log(import_chalk.default.cyan(`
|
|
427
|
-
Building nested documentation site: ${
|
|
717
|
+
Building nested documentation site: ${import_node_path2.default.relative(targetDir, nestedRoot)}...`));
|
|
428
718
|
await buildCommand(nestedRoot, { buildNested: false });
|
|
429
719
|
}
|
|
430
720
|
}
|
|
431
721
|
console.log(import_chalk.default.bold.green("\u2728 Build completed successfully!\n"));
|
|
432
722
|
}
|
|
433
723
|
async function watchBuildCommand(targetDirArg = "./docs", options = {}) {
|
|
434
|
-
const targetDir =
|
|
724
|
+
const targetDir = import_node_path2.default.resolve(process.cwd(), targetDirArg);
|
|
435
725
|
await buildCommand(targetDir, { ...options, watch: false });
|
|
436
726
|
console.log(import_chalk.default.dim(` Watching source files in: ${targetDir}`));
|
|
437
727
|
console.log(import_chalk.default.dim(" Source changes rebuild serveable files and .dist/index.html. Press Ctrl+C to stop.\n"));
|
|
@@ -452,7 +742,7 @@ async function watchBuildCommand(targetDirArg = "./docs", options = {}) {
|
|
|
452
742
|
if (!shouldWatchDocumentationSource(targetDir, changedPath)) return;
|
|
453
743
|
if (rebuildTimeout) clearTimeout(rebuildTimeout);
|
|
454
744
|
rebuildTimeout = setTimeout(async () => {
|
|
455
|
-
const relativePath =
|
|
745
|
+
const relativePath = import_node_path2.default.relative(targetDir, changedPath);
|
|
456
746
|
console.log(import_chalk.default.cyan(`[DocMeDown] Changed: ${relativePath} -> Rebuilding documentation...`));
|
|
457
747
|
try {
|
|
458
748
|
await buildCommand(targetDir, { ...options, watch: false });
|
|
@@ -464,54 +754,211 @@ async function watchBuildCommand(targetDirArg = "./docs", options = {}) {
|
|
|
464
754
|
return new Promise(() => void 0);
|
|
465
755
|
}
|
|
466
756
|
|
|
467
|
-
// src/cli/
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
(
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
};
|
|
488
|
-
ws.onclose = function() {
|
|
489
|
-
setTimeout(connect, 1500);
|
|
490
|
-
};
|
|
757
|
+
// src/cli/commands/config-tui.ts
|
|
758
|
+
var import_node_fs3 = __toESM(require("fs"));
|
|
759
|
+
var import_node_path3 = __toESM(require("path"));
|
|
760
|
+
var import_chalk2 = __toESM(require("chalk"));
|
|
761
|
+
var import_prompts = __toESM(require("prompts"));
|
|
762
|
+
async function configTuiCommand(configPathArg) {
|
|
763
|
+
console.log(import_chalk2.default.bold.magenta("\n\u26A1 DocMeDown - Interactive Configuration Wizard\n"));
|
|
764
|
+
let configPath = "";
|
|
765
|
+
if (configPathArg) {
|
|
766
|
+
configPath = import_node_path3.default.resolve(process.cwd(), configPathArg);
|
|
767
|
+
if (import_node_fs3.default.existsSync(configPath) && import_node_fs3.default.statSync(configPath).isDirectory()) {
|
|
768
|
+
configPath = import_node_path3.default.join(configPath, "docs.json");
|
|
769
|
+
}
|
|
770
|
+
} else {
|
|
771
|
+
const candidates = [
|
|
772
|
+
import_node_path3.default.resolve(process.cwd(), "docs.json"),
|
|
773
|
+
import_node_path3.default.resolve(process.cwd(), "docs/docs.json"),
|
|
774
|
+
import_node_path3.default.resolve(process.cwd(), "dmd.json")
|
|
775
|
+
];
|
|
776
|
+
configPath = candidates.find((p) => import_node_fs3.default.existsSync(p)) || import_node_path3.default.resolve(process.cwd(), "docs/docs.json");
|
|
491
777
|
}
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
778
|
+
let existingConfig = normalizeConfig();
|
|
779
|
+
if (import_node_fs3.default.existsSync(configPath)) {
|
|
780
|
+
try {
|
|
781
|
+
existingConfig = normalizeConfig(parseDocConfigJson(import_node_fs3.default.readFileSync(configPath, "utf-8"), configPath));
|
|
782
|
+
console.log(import_chalk2.default.dim(` Loaded existing configuration from: ${configPath}
|
|
783
|
+
`));
|
|
784
|
+
} catch (error) {
|
|
785
|
+
console.warn(import_chalk2.default.yellow(` \u26A0 ${error instanceof Error ? error.message : String(error)}
|
|
786
|
+
`));
|
|
787
|
+
}
|
|
788
|
+
} else {
|
|
789
|
+
console.log(import_chalk2.default.dim(` Creating new configuration at: ${configPath}
|
|
790
|
+
`));
|
|
791
|
+
}
|
|
792
|
+
const response = await (0, import_prompts.default)([
|
|
793
|
+
{
|
|
794
|
+
type: "text",
|
|
795
|
+
name: "name",
|
|
796
|
+
message: "Project Name:",
|
|
797
|
+
initial: existingConfig.name || "My Project Docs"
|
|
798
|
+
},
|
|
799
|
+
{
|
|
800
|
+
type: "text",
|
|
801
|
+
name: "tagline",
|
|
802
|
+
message: "Tagline / Short description:",
|
|
803
|
+
initial: existingConfig.tagline || "The simplest Markdown documenter yet"
|
|
804
|
+
},
|
|
805
|
+
{
|
|
806
|
+
type: "select",
|
|
807
|
+
name: "family",
|
|
808
|
+
message: "Select Documentation Theme Family:",
|
|
809
|
+
choices: [
|
|
810
|
+
{ title: "Atlas (Editorial technical reference)", value: "atlas" },
|
|
811
|
+
{ title: "Blueprint (Structured and schematic)", value: "blueprint" },
|
|
812
|
+
{ title: "Terminal (Compact operational console)", value: "terminal" },
|
|
813
|
+
{ title: "Editorial (Spacious publication reading)", value: "editorial" }
|
|
814
|
+
],
|
|
815
|
+
initial: ["atlas", "blueprint", "terminal", "editorial"].indexOf(existingConfig.theme?.family || "atlas")
|
|
816
|
+
},
|
|
817
|
+
{
|
|
818
|
+
type: "select",
|
|
819
|
+
name: "defaultMode",
|
|
820
|
+
message: "Default Color Mode:",
|
|
821
|
+
choices: [
|
|
822
|
+
{ title: "Auto (Follows OS system preference)", value: "auto" },
|
|
823
|
+
{ title: "Dark (Default dark theme)", value: "dark" },
|
|
824
|
+
{ title: "Light (Default light theme)", value: "light" }
|
|
825
|
+
],
|
|
826
|
+
initial: ["auto", "dark", "light"].indexOf(existingConfig.theme?.defaultMode || "auto")
|
|
827
|
+
},
|
|
828
|
+
{
|
|
829
|
+
type: "select",
|
|
830
|
+
name: "sourceType",
|
|
831
|
+
message: "Documentation Source Mode:",
|
|
832
|
+
choices: [
|
|
833
|
+
{ title: "Local Markdown Files (hosted together in folder)", value: "local" },
|
|
834
|
+
{ title: "Remote GitHub Repository (live dynamic fetch)", value: "github" },
|
|
835
|
+
{ title: "Remote GitLab Repository (live dynamic fetch)", value: "gitlab" }
|
|
836
|
+
],
|
|
837
|
+
initial: existingConfig.source?.type ? existingConfig.source.type === "github" ? 1 : 2 : 0
|
|
838
|
+
},
|
|
839
|
+
{
|
|
840
|
+
type: (prev) => prev === "github" ? "text" : null,
|
|
841
|
+
name: "githubRepo",
|
|
842
|
+
message: "GitHub Repository (owner/repo):",
|
|
843
|
+
initial: existingConfig.source?.type === "raw" ? "facebook/react" : existingConfig.source?.repo || "facebook/react"
|
|
844
|
+
},
|
|
845
|
+
{
|
|
846
|
+
type: (_prev, values) => values.sourceType === "github" ? "text" : null,
|
|
847
|
+
name: "githubBranch",
|
|
848
|
+
message: "GitHub Branch:",
|
|
849
|
+
initial: existingConfig.source?.branch || "main"
|
|
850
|
+
},
|
|
851
|
+
{
|
|
852
|
+
type: (_prev, values) => values.sourceType === "github" ? "text" : null,
|
|
853
|
+
name: "githubDocsDir",
|
|
854
|
+
message: "GitHub Docs Subfolder (leave empty for root):",
|
|
855
|
+
initial: existingConfig.source?.docsDir || "docs"
|
|
856
|
+
},
|
|
857
|
+
{
|
|
858
|
+
type: "text",
|
|
859
|
+
name: "githubSocial",
|
|
860
|
+
message: "GitHub Repository URL for Navbar link (optional):",
|
|
861
|
+
initial: existingConfig.socials?.find((s) => s.type === "github")?.url || ""
|
|
862
|
+
}
|
|
863
|
+
]);
|
|
864
|
+
if (!response.name) {
|
|
865
|
+
console.log(import_chalk2.default.yellow("\nConfiguration cancelled."));
|
|
866
|
+
return;
|
|
867
|
+
}
|
|
868
|
+
const updatedConfig = normalizeConfig({
|
|
869
|
+
...existingConfig,
|
|
870
|
+
name: response.name,
|
|
871
|
+
tagline: response.tagline,
|
|
872
|
+
theme: {
|
|
873
|
+
...existingConfig.theme,
|
|
874
|
+
family: response.family,
|
|
875
|
+
defaultMode: response.defaultMode
|
|
876
|
+
},
|
|
877
|
+
socials: response.githubSocial ? [{ type: "github", url: response.githubSocial }] : existingConfig.socials
|
|
878
|
+
});
|
|
879
|
+
if (response.sourceType === "github") {
|
|
880
|
+
updatedConfig.source = {
|
|
881
|
+
type: "github",
|
|
882
|
+
repo: response.githubRepo,
|
|
883
|
+
branch: response.githubBranch,
|
|
884
|
+
docsDir: response.githubDocsDir
|
|
885
|
+
};
|
|
886
|
+
} else if (response.sourceType === "local") {
|
|
887
|
+
delete updatedConfig.source;
|
|
888
|
+
}
|
|
889
|
+
const dir = import_node_path3.default.dirname(configPath);
|
|
890
|
+
if (!import_node_fs3.default.existsSync(dir)) {
|
|
891
|
+
import_node_fs3.default.mkdirSync(dir, { recursive: true });
|
|
892
|
+
}
|
|
893
|
+
const validatedConfig = normalizeConfig(updatedConfig);
|
|
894
|
+
import_node_fs3.default.writeFileSync(configPath, JSON.stringify(validatedConfig, null, 2), "utf-8");
|
|
895
|
+
console.log(import_chalk2.default.bold.green(`
|
|
896
|
+
\u2714 Configuration successfully saved to: ${configPath}
|
|
897
|
+
`));
|
|
898
|
+
}
|
|
899
|
+
|
|
900
|
+
// src/cli/commands/init.ts
|
|
901
|
+
var import_node_fs5 = __toESM(require("fs"));
|
|
902
|
+
var import_node_path5 = __toESM(require("path"));
|
|
903
|
+
var import_chalk4 = __toESM(require("chalk"));
|
|
904
|
+
var import_open = __toESM(require("open"));
|
|
905
|
+
var import_prompts2 = __toESM(require("prompts"));
|
|
906
|
+
|
|
907
|
+
// src/cli/utils/server.ts
|
|
908
|
+
var import_node_fs4 = __toESM(require("fs"));
|
|
909
|
+
var import_node_http = __toESM(require("http"));
|
|
910
|
+
var import_node_path4 = __toESM(require("path"));
|
|
911
|
+
var import_chalk3 = __toESM(require("chalk"));
|
|
912
|
+
var import_chokidar2 = __toESM(require("chokidar"));
|
|
913
|
+
var import_mime_types = __toESM(require("mime-types"));
|
|
914
|
+
var import_ws = require("ws");
|
|
915
|
+
function shouldRebuildDocumentation(rootDir, changedPath) {
|
|
916
|
+
return shouldWatchDocumentationSource(rootDir, changedPath);
|
|
917
|
+
}
|
|
918
|
+
function startDevServer(options) {
|
|
919
|
+
const { rootDir, host = "localhost", port: initialPort = 3e3, onSourceChange } = options;
|
|
920
|
+
return new Promise((resolve, reject) => {
|
|
921
|
+
let port = initialPort;
|
|
922
|
+
const liveReloadScript = `
|
|
923
|
+
<script>
|
|
924
|
+
(function() {
|
|
925
|
+
const protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';
|
|
926
|
+
let ws = null;
|
|
927
|
+
function connect() {
|
|
928
|
+
ws = new WebSocket(protocol + '//' + window.location.host + '/__dmd_reload');
|
|
929
|
+
ws.onmessage = function(e) {
|
|
930
|
+
if (e.data === 'reload') {
|
|
931
|
+
console.log('[DocMeDown] File changed, reloading...');
|
|
932
|
+
window.location.reload();
|
|
933
|
+
}
|
|
934
|
+
};
|
|
935
|
+
ws.onclose = function() {
|
|
936
|
+
setTimeout(connect, 1500);
|
|
937
|
+
};
|
|
938
|
+
}
|
|
939
|
+
connect();
|
|
940
|
+
})();
|
|
941
|
+
</script>
|
|
942
|
+
`;
|
|
943
|
+
const server = import_node_http.default.createServer((req, res) => {
|
|
944
|
+
res.setHeader("Access-Control-Allow-Origin", "*");
|
|
945
|
+
res.setHeader("Access-Control-Allow-Methods", "GET, OPTIONS");
|
|
946
|
+
if (req.method === "OPTIONS") {
|
|
947
|
+
res.writeHead(204);
|
|
948
|
+
res.end();
|
|
949
|
+
return;
|
|
950
|
+
}
|
|
951
|
+
let reqPath = decodeURIComponent(req.url?.split("?")[0] || "/");
|
|
952
|
+
if (reqPath === "/" || reqPath === "") {
|
|
953
|
+
reqPath = "/index.html";
|
|
954
|
+
}
|
|
955
|
+
let filePath = import_node_path4.default.join(rootDir, reqPath);
|
|
956
|
+
if (!import_node_fs4.default.existsSync(filePath) || import_node_fs4.default.statSync(filePath).isDirectory()) {
|
|
957
|
+
const potentialIndex = import_node_path4.default.join(rootDir, "index.html");
|
|
958
|
+
if (import_node_fs4.default.existsSync(potentialIndex)) {
|
|
959
|
+
filePath = potentialIndex;
|
|
960
|
+
} else {
|
|
961
|
+
res.writeHead(200, { "Content-Type": "text/html" });
|
|
515
962
|
res.end(`
|
|
516
963
|
<!DOCTYPE html>
|
|
517
964
|
<html>
|
|
@@ -526,37 +973,37 @@ function startDevServer(options) {
|
|
|
526
973
|
return;
|
|
527
974
|
}
|
|
528
975
|
}
|
|
529
|
-
if (reqPath === "/docmedown.iife.js" && !
|
|
976
|
+
if (reqPath === "/docmedown.iife.js" && !import_node_fs4.default.existsSync(filePath)) {
|
|
530
977
|
const bundleCandidates = [
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
978
|
+
import_node_path4.default.resolve(__dirname, "docmedown.iife.js"),
|
|
979
|
+
import_node_path4.default.resolve(__dirname, "../dist/docmedown.iife.js"),
|
|
980
|
+
import_node_path4.default.resolve(__dirname, "../docmedown.iife.js")
|
|
534
981
|
];
|
|
535
|
-
const distFile = bundleCandidates.find((p) =>
|
|
982
|
+
const distFile = bundleCandidates.find((p) => import_node_fs4.default.existsSync(p));
|
|
536
983
|
if (distFile) {
|
|
537
984
|
filePath = distFile;
|
|
538
985
|
}
|
|
539
986
|
}
|
|
540
987
|
try {
|
|
541
|
-
const stat =
|
|
988
|
+
const stat = import_node_fs4.default.statSync(filePath);
|
|
542
989
|
if (stat.isDirectory()) {
|
|
543
|
-
filePath =
|
|
990
|
+
filePath = import_node_path4.default.join(filePath, "index.html");
|
|
544
991
|
}
|
|
545
992
|
const mimeType = import_mime_types.default.lookup(filePath) || "application/octet-stream";
|
|
546
993
|
res.setHeader("Content-Type", mimeType);
|
|
547
994
|
if (mimeType.includes("html")) {
|
|
548
|
-
let content =
|
|
995
|
+
let content = import_node_fs4.default.readFileSync(filePath, "utf-8");
|
|
549
996
|
if (!content.includes("/__dmd_reload")) {
|
|
550
997
|
content = content.replace("</body>", `${liveReloadScript}</body>`);
|
|
551
998
|
}
|
|
552
999
|
res.writeHead(200);
|
|
553
1000
|
res.end(content);
|
|
554
1001
|
} else {
|
|
555
|
-
const stream =
|
|
1002
|
+
const stream = import_node_fs4.default.createReadStream(filePath);
|
|
556
1003
|
res.writeHead(200);
|
|
557
1004
|
stream.pipe(res);
|
|
558
1005
|
}
|
|
559
|
-
} catch (
|
|
1006
|
+
} catch (_err) {
|
|
560
1007
|
res.writeHead(404, { "Content-Type": "text/plain" });
|
|
561
1008
|
res.end("404 Not Found");
|
|
562
1009
|
}
|
|
@@ -590,16 +1037,16 @@ function startDevServer(options) {
|
|
|
590
1037
|
if (!shouldRebuildDocumentation(rootDir, changedPath)) return;
|
|
591
1038
|
if (reloadTimeout) clearTimeout(reloadTimeout);
|
|
592
1039
|
reloadTimeout = setTimeout(async () => {
|
|
593
|
-
const rel =
|
|
1040
|
+
const rel = import_node_path4.default.relative(rootDir, changedPath);
|
|
594
1041
|
try {
|
|
595
1042
|
if (onSourceChange) {
|
|
596
|
-
console.log(
|
|
1043
|
+
console.log(import_chalk3.default.cyan(`[DocMeDown] Changed: ${rel} -> Rebuilding documentation...`));
|
|
597
1044
|
await onSourceChange(event, changedPath);
|
|
598
1045
|
} else {
|
|
599
|
-
console.log(
|
|
1046
|
+
console.log(import_chalk3.default.cyan(`[DocMeDown] Changed: ${rel} -> Reloading preview...`));
|
|
600
1047
|
}
|
|
601
1048
|
} catch (err) {
|
|
602
|
-
console.error(
|
|
1049
|
+
console.error(import_chalk3.default.red(`[DocMeDown] Rebuild failed: ${err.message}`));
|
|
603
1050
|
}
|
|
604
1051
|
clients.forEach((ws) => {
|
|
605
1052
|
if (ws.readyState === import_ws.WebSocket.OPEN) {
|
|
@@ -634,108 +1081,107 @@ function startDevServer(options) {
|
|
|
634
1081
|
}
|
|
635
1082
|
|
|
636
1083
|
// src/cli/commands/init.ts
|
|
637
|
-
var import_open = __toESM(require("open"));
|
|
638
1084
|
async function initCommand(targetDirArg = "./docs", options = {}) {
|
|
639
|
-
const targetDir =
|
|
640
|
-
console.log(
|
|
641
|
-
if (!
|
|
642
|
-
|
|
1085
|
+
const targetDir = import_node_path5.default.resolve(process.cwd(), targetDirArg);
|
|
1086
|
+
console.log(import_chalk4.default.bold.magenta("\n\u26A1 DocMeDown - Instant Documentation Initializer\n"));
|
|
1087
|
+
if (!import_node_fs5.default.existsSync(targetDir)) {
|
|
1088
|
+
import_node_fs5.default.mkdirSync(targetDir, { recursive: true });
|
|
643
1089
|
}
|
|
644
|
-
const templatesDir =
|
|
645
|
-
const fallbackTemplatesDir =
|
|
646
|
-
const activeTemplateDir =
|
|
647
|
-
const indexPath =
|
|
648
|
-
if (!
|
|
649
|
-
const templateHtml =
|
|
650
|
-
|
|
651
|
-
console.log(
|
|
1090
|
+
const templatesDir = import_node_path5.default.resolve(__dirname, "../../templates");
|
|
1091
|
+
const fallbackTemplatesDir = import_node_path5.default.resolve(__dirname, "../templates");
|
|
1092
|
+
const activeTemplateDir = import_node_fs5.default.existsSync(templatesDir) ? templatesDir : fallbackTemplatesDir;
|
|
1093
|
+
const indexPath = import_node_path5.default.join(targetDir, "index.html");
|
|
1094
|
+
if (!import_node_fs5.default.existsSync(indexPath)) {
|
|
1095
|
+
const templateHtml = import_node_fs5.default.readFileSync(import_node_path5.default.join(activeTemplateDir, "index.html"), "utf-8");
|
|
1096
|
+
import_node_fs5.default.writeFileSync(indexPath, templateHtml, "utf-8");
|
|
1097
|
+
console.log(import_chalk4.default.green(" \u2714 Created index.html"));
|
|
652
1098
|
}
|
|
653
|
-
const configPath =
|
|
654
|
-
if (!
|
|
655
|
-
const templateConfig =
|
|
656
|
-
|
|
657
|
-
console.log(
|
|
1099
|
+
const configPath = import_node_path5.default.join(targetDir, "docs.json");
|
|
1100
|
+
if (!import_node_fs5.default.existsSync(configPath)) {
|
|
1101
|
+
const templateConfig = import_node_fs5.default.readFileSync(import_node_path5.default.join(activeTemplateDir, "docs.json"), "utf-8");
|
|
1102
|
+
import_node_fs5.default.writeFileSync(configPath, templateConfig, "utf-8");
|
|
1103
|
+
console.log(import_chalk4.default.green(" \u2714 Created docs.json"));
|
|
658
1104
|
}
|
|
659
|
-
const readmePath =
|
|
660
|
-
if (!
|
|
661
|
-
const templateReadme =
|
|
662
|
-
|
|
663
|
-
console.log(
|
|
1105
|
+
const readmePath = import_node_path5.default.join(targetDir, "README.md");
|
|
1106
|
+
if (!import_node_fs5.default.existsSync(readmePath)) {
|
|
1107
|
+
const templateReadme = import_node_fs5.default.readFileSync(import_node_path5.default.join(activeTemplateDir, "README.md"), "utf-8");
|
|
1108
|
+
import_node_fs5.default.writeFileSync(readmePath, templateReadme, "utf-8");
|
|
1109
|
+
console.log(import_chalk4.default.green(" \u2714 Created README.md"));
|
|
664
1110
|
}
|
|
665
|
-
const gsPath =
|
|
666
|
-
if (!
|
|
667
|
-
const templateGs =
|
|
668
|
-
|
|
669
|
-
console.log(
|
|
1111
|
+
const gsPath = import_node_path5.default.join(targetDir, "getting-started.md");
|
|
1112
|
+
if (!import_node_fs5.default.existsSync(gsPath)) {
|
|
1113
|
+
const templateGs = import_node_fs5.default.readFileSync(import_node_path5.default.join(activeTemplateDir, "getting-started.md"), "utf-8");
|
|
1114
|
+
import_node_fs5.default.writeFileSync(gsPath, templateGs, "utf-8");
|
|
1115
|
+
console.log(import_chalk4.default.green(" \u2714 Created getting-started.md"));
|
|
670
1116
|
}
|
|
671
|
-
const guidesDir =
|
|
672
|
-
if (!
|
|
673
|
-
|
|
1117
|
+
const guidesDir = import_node_path5.default.join(targetDir, "guides");
|
|
1118
|
+
if (!import_node_fs5.default.existsSync(guidesDir)) {
|
|
1119
|
+
import_node_fs5.default.mkdirSync(guidesDir, { recursive: true });
|
|
674
1120
|
}
|
|
675
|
-
const guidePath =
|
|
676
|
-
if (!
|
|
677
|
-
const templateGuide =
|
|
678
|
-
|
|
679
|
-
console.log(
|
|
1121
|
+
const guidePath = import_node_path5.default.join(guidesDir, "custom-components.md");
|
|
1122
|
+
if (!import_node_fs5.default.existsSync(guidePath)) {
|
|
1123
|
+
const templateGuide = import_node_fs5.default.readFileSync(import_node_path5.default.join(activeTemplateDir, "guides/custom-components.md"), "utf-8");
|
|
1124
|
+
import_node_fs5.default.writeFileSync(guidePath, templateGuide, "utf-8");
|
|
1125
|
+
console.log(import_chalk4.default.green(" \u2714 Created guides/custom-components.md"));
|
|
680
1126
|
}
|
|
681
|
-
const dmdDir =
|
|
682
|
-
if (!
|
|
683
|
-
|
|
1127
|
+
const dmdDir = import_node_path5.default.join(targetDir, ".dmd");
|
|
1128
|
+
if (!import_node_fs5.default.existsSync(dmdDir)) {
|
|
1129
|
+
import_node_fs5.default.mkdirSync(dmdDir, { recursive: true });
|
|
684
1130
|
}
|
|
685
|
-
const dmdComponentPath =
|
|
686
|
-
if (!
|
|
687
|
-
const templateDmd =
|
|
688
|
-
|
|
689
|
-
console.log(
|
|
1131
|
+
const dmdComponentPath = import_node_path5.default.join(dmdDir, "components.js");
|
|
1132
|
+
if (!import_node_fs5.default.existsSync(dmdComponentPath)) {
|
|
1133
|
+
const templateDmd = import_node_fs5.default.readFileSync(import_node_path5.default.join(activeTemplateDir, ".dmd/components.js"), "utf-8");
|
|
1134
|
+
import_node_fs5.default.writeFileSync(dmdComponentPath, templateDmd, "utf-8");
|
|
1135
|
+
console.log(import_chalk4.default.green(" \u2714 Created .dmd/components.js"));
|
|
690
1136
|
}
|
|
691
1137
|
await buildCommand(targetDir);
|
|
692
|
-
console.log(
|
|
693
|
-
console.log(
|
|
1138
|
+
console.log(import_chalk4.default.bold.green("\n\u2728 DocMeDown site successfully initialized!\n"));
|
|
1139
|
+
console.log(import_chalk4.default.dim(` Location: ${targetDir}
|
|
694
1140
|
`));
|
|
695
|
-
console.log(
|
|
696
|
-
console.log(
|
|
1141
|
+
console.log(import_chalk4.default.cyan(" To preview your docs:"));
|
|
1142
|
+
console.log(import_chalk4.default.white(` npx docmedown serve ${targetDirArg}
|
|
697
1143
|
`));
|
|
698
|
-
console.log(
|
|
699
|
-
console.log(
|
|
1144
|
+
console.log(import_chalk4.default.cyan(" To customize settings:"));
|
|
1145
|
+
console.log(import_chalk4.default.white(` npx docmedown config ${targetDirArg}/docs.json
|
|
700
1146
|
`));
|
|
701
1147
|
if (options.start !== false && process.stdout.isTTY) {
|
|
702
|
-
const response = await (0,
|
|
1148
|
+
const response = await (0, import_prompts2.default)({
|
|
703
1149
|
type: "confirm",
|
|
704
1150
|
name: "startServer",
|
|
705
1151
|
message: "Would you like to start the local preview server now?",
|
|
706
1152
|
initial: true
|
|
707
1153
|
});
|
|
708
1154
|
if (response.startServer) {
|
|
709
|
-
console.log(
|
|
1155
|
+
console.log(import_chalk4.default.cyan("\n\u{1F680} Starting local live preview server..."));
|
|
710
1156
|
const devServer = await startDevServer({ rootDir: targetDir, port: 3e3 });
|
|
711
1157
|
const url = `http://localhost:${devServer.port}`;
|
|
712
|
-
console.log(
|
|
713
|
-
\u2714 Documentation live at: ${
|
|
1158
|
+
console.log(import_chalk4.default.bold.green(`
|
|
1159
|
+
\u2714 Documentation live at: ${import_chalk4.default.underline(url)}
|
|
714
1160
|
`));
|
|
715
|
-
console.log(
|
|
1161
|
+
console.log(import_chalk4.default.dim(" Press Ctrl+C to stop the server\n"));
|
|
716
1162
|
await (0, import_open.default)(url);
|
|
717
1163
|
}
|
|
718
1164
|
}
|
|
719
1165
|
}
|
|
720
1166
|
|
|
721
1167
|
// src/cli/commands/serve.ts
|
|
722
|
-
var
|
|
723
|
-
var
|
|
724
|
-
var
|
|
1168
|
+
var import_node_fs6 = __toESM(require("fs"));
|
|
1169
|
+
var import_node_path6 = __toESM(require("path"));
|
|
1170
|
+
var import_chalk5 = __toESM(require("chalk"));
|
|
725
1171
|
var import_open2 = __toESM(require("open"));
|
|
726
1172
|
async function serveCommand(targetDirArg = "./docs", options = {}) {
|
|
727
|
-
let targetDir =
|
|
728
|
-
if (!
|
|
729
|
-
if (
|
|
730
|
-
targetDir =
|
|
1173
|
+
let targetDir = import_node_path6.default.resolve(process.cwd(), targetDirArg);
|
|
1174
|
+
if (!import_node_fs6.default.existsSync(targetDir)) {
|
|
1175
|
+
if (import_node_fs6.default.existsSync(import_node_path6.default.resolve(process.cwd(), "docs"))) {
|
|
1176
|
+
targetDir = import_node_path6.default.resolve(process.cwd(), "docs");
|
|
731
1177
|
} else {
|
|
732
1178
|
targetDir = process.cwd();
|
|
733
1179
|
}
|
|
734
1180
|
}
|
|
735
|
-
console.log(
|
|
736
|
-
console.log(
|
|
1181
|
+
console.log(import_chalk5.default.bold.magenta("\n\u26A1 DocMeDown Dev Server\n"));
|
|
1182
|
+
console.log(import_chalk5.default.dim(` Serving directory: ${targetDir}`));
|
|
737
1183
|
try {
|
|
738
|
-
console.log(
|
|
1184
|
+
console.log(import_chalk5.default.dim(" Building serveable and offline documentation artifacts..."));
|
|
739
1185
|
await buildCommand(targetDir);
|
|
740
1186
|
const devServer = await startDevServer({
|
|
741
1187
|
rootDir: targetDir,
|
|
@@ -744,290 +1190,31 @@ async function serveCommand(targetDirArg = "./docs", options = {}) {
|
|
|
744
1190
|
onSourceChange: () => buildCommand(targetDir)
|
|
745
1191
|
});
|
|
746
1192
|
const url = `http://${options.host || "localhost"}:${devServer.port}`;
|
|
747
|
-
console.log(
|
|
1193
|
+
console.log(import_chalk5.default.bold.green(`
|
|
748
1194
|
\u2714 Live Documentation Server running at:`));
|
|
749
|
-
console.log(
|
|
750
|
-
console.log(
|
|
751
|
-
console.log(
|
|
1195
|
+
console.log(import_chalk5.default.bold.cyan(` \u279C Local: ${import_chalk5.default.underline(url)}`));
|
|
1196
|
+
console.log(import_chalk5.default.dim(` \u279C Watch: Source changes rebuild preview and .dist/index.html`));
|
|
1197
|
+
console.log(import_chalk5.default.dim(`
|
|
752
1198
|
Press Ctrl+C to stop.
|
|
753
1199
|
`));
|
|
754
1200
|
if (options.open !== false) {
|
|
755
1201
|
await (0, import_open2.default)(url);
|
|
756
1202
|
}
|
|
757
1203
|
} catch (err) {
|
|
758
|
-
console.error(
|
|
1204
|
+
console.error(import_chalk5.default.red(`
|
|
759
1205
|
\u2716 Error starting server: ${err.message}
|
|
760
1206
|
`));
|
|
761
1207
|
process.exit(1);
|
|
762
1208
|
}
|
|
763
1209
|
}
|
|
764
1210
|
|
|
765
|
-
// src/cli/commands/config-tui.ts
|
|
766
|
-
var import_fs6 = __toESM(require("fs"));
|
|
767
|
-
var import_path6 = __toESM(require("path"));
|
|
768
|
-
var import_chalk5 = __toESM(require("chalk"));
|
|
769
|
-
var import_prompts2 = __toESM(require("prompts"));
|
|
770
|
-
async function configTuiCommand(configPathArg) {
|
|
771
|
-
console.log(import_chalk5.default.bold.magenta("\n\u26A1 DocMeDown - Interactive Configuration Wizard\n"));
|
|
772
|
-
let configPath = "";
|
|
773
|
-
if (configPathArg) {
|
|
774
|
-
configPath = import_path6.default.resolve(process.cwd(), configPathArg);
|
|
775
|
-
if (import_fs6.default.existsSync(configPath) && import_fs6.default.statSync(configPath).isDirectory()) {
|
|
776
|
-
configPath = import_path6.default.join(configPath, "docs.json");
|
|
777
|
-
}
|
|
778
|
-
} else {
|
|
779
|
-
const candidates = [
|
|
780
|
-
import_path6.default.resolve(process.cwd(), "docs.json"),
|
|
781
|
-
import_path6.default.resolve(process.cwd(), "docs/docs.json"),
|
|
782
|
-
import_path6.default.resolve(process.cwd(), "dmd.json")
|
|
783
|
-
];
|
|
784
|
-
configPath = candidates.find((p) => import_fs6.default.existsSync(p)) || import_path6.default.resolve(process.cwd(), "docs/docs.json");
|
|
785
|
-
}
|
|
786
|
-
let existingConfig = DEFAULT_CONFIG;
|
|
787
|
-
if (import_fs6.default.existsSync(configPath)) {
|
|
788
|
-
try {
|
|
789
|
-
existingConfig = { ...DEFAULT_CONFIG, ...JSON.parse(import_fs6.default.readFileSync(configPath, "utf-8")) };
|
|
790
|
-
console.log(import_chalk5.default.dim(` Loaded existing configuration from: ${configPath}
|
|
791
|
-
`));
|
|
792
|
-
} catch {
|
|
793
|
-
console.warn(import_chalk5.default.yellow(` \u26A0 Error reading ${configPath}, starting fresh.
|
|
794
|
-
`));
|
|
795
|
-
}
|
|
796
|
-
} else {
|
|
797
|
-
console.log(import_chalk5.default.dim(` Creating new configuration at: ${configPath}
|
|
798
|
-
`));
|
|
799
|
-
}
|
|
800
|
-
const response = await (0, import_prompts2.default)([
|
|
801
|
-
{
|
|
802
|
-
type: "text",
|
|
803
|
-
name: "name",
|
|
804
|
-
message: "Project Name:",
|
|
805
|
-
initial: existingConfig.name || "My Project Docs"
|
|
806
|
-
},
|
|
807
|
-
{
|
|
808
|
-
type: "text",
|
|
809
|
-
name: "tagline",
|
|
810
|
-
message: "Tagline / Short description:",
|
|
811
|
-
initial: existingConfig.tagline || "The simplest Markdown documenter yet"
|
|
812
|
-
},
|
|
813
|
-
{
|
|
814
|
-
type: "select",
|
|
815
|
-
name: "preset",
|
|
816
|
-
message: "Select Theme Color Palette:",
|
|
817
|
-
choices: [
|
|
818
|
-
{ title: "Indigo (Modern & Clean)", value: "indigo" },
|
|
819
|
-
{ title: "Emerald (Fresh & Tech)", value: "emerald" },
|
|
820
|
-
{ title: "Sunset (Warm Amber)", value: "sunset" },
|
|
821
|
-
{ title: "Violet (Vibrant Purple)", value: "violet" },
|
|
822
|
-
{ title: "Rose (Bold Quartz)", value: "rose" },
|
|
823
|
-
{ title: "Slate (Minimalist Monochrome)", value: "slate" },
|
|
824
|
-
{ title: "Cyberpunk (Neon Glow)", value: "cyberpunk" }
|
|
825
|
-
],
|
|
826
|
-
initial: ["indigo", "emerald", "sunset", "violet", "rose", "slate", "cyberpunk"].indexOf(
|
|
827
|
-
existingConfig.theme?.preset || "indigo"
|
|
828
|
-
)
|
|
829
|
-
},
|
|
830
|
-
{
|
|
831
|
-
type: "select",
|
|
832
|
-
name: "defaultMode",
|
|
833
|
-
message: "Default Color Mode:",
|
|
834
|
-
choices: [
|
|
835
|
-
{ title: "Auto (Follows OS system preference)", value: "auto" },
|
|
836
|
-
{ title: "Dark (Default dark theme)", value: "dark" },
|
|
837
|
-
{ title: "Light (Default light theme)", value: "light" }
|
|
838
|
-
],
|
|
839
|
-
initial: ["auto", "dark", "light"].indexOf(existingConfig.theme?.defaultMode || "auto")
|
|
840
|
-
},
|
|
841
|
-
{
|
|
842
|
-
type: "select",
|
|
843
|
-
name: "sourceType",
|
|
844
|
-
message: "Documentation Source Mode:",
|
|
845
|
-
choices: [
|
|
846
|
-
{ title: "Local Markdown Files (hosted together in folder)", value: "local" },
|
|
847
|
-
{ title: "Remote GitHub Repository (live dynamic fetch)", value: "github" },
|
|
848
|
-
{ title: "Remote GitLab Repository (live dynamic fetch)", value: "gitlab" }
|
|
849
|
-
],
|
|
850
|
-
initial: existingConfig.source?.type ? existingConfig.source.type === "github" ? 1 : 2 : 0
|
|
851
|
-
},
|
|
852
|
-
{
|
|
853
|
-
type: (prev) => prev === "github" ? "text" : null,
|
|
854
|
-
name: "githubRepo",
|
|
855
|
-
message: "GitHub Repository (owner/repo):",
|
|
856
|
-
initial: existingConfig.source?.repo || "facebook/react"
|
|
857
|
-
},
|
|
858
|
-
{
|
|
859
|
-
type: (prev, values) => values.sourceType === "github" ? "text" : null,
|
|
860
|
-
name: "githubBranch",
|
|
861
|
-
message: "GitHub Branch:",
|
|
862
|
-
initial: existingConfig.source?.branch || "main"
|
|
863
|
-
},
|
|
864
|
-
{
|
|
865
|
-
type: (prev, values) => values.sourceType === "github" ? "text" : null,
|
|
866
|
-
name: "githubDocsDir",
|
|
867
|
-
message: "GitHub Docs Subfolder (leave empty for root):",
|
|
868
|
-
initial: existingConfig.source?.docsDir || "docs"
|
|
869
|
-
},
|
|
870
|
-
{
|
|
871
|
-
type: "text",
|
|
872
|
-
name: "githubSocial",
|
|
873
|
-
message: "GitHub Repository URL for Navbar link (optional):",
|
|
874
|
-
initial: existingConfig.socials?.find((s) => s.type === "github")?.url || ""
|
|
875
|
-
}
|
|
876
|
-
]);
|
|
877
|
-
if (!response.name) {
|
|
878
|
-
console.log(import_chalk5.default.yellow("\nConfiguration cancelled."));
|
|
879
|
-
return;
|
|
880
|
-
}
|
|
881
|
-
const updatedConfig = {
|
|
882
|
-
...existingConfig,
|
|
883
|
-
name: response.name,
|
|
884
|
-
tagline: response.tagline,
|
|
885
|
-
theme: {
|
|
886
|
-
...existingConfig.theme,
|
|
887
|
-
preset: response.preset,
|
|
888
|
-
defaultMode: response.defaultMode
|
|
889
|
-
},
|
|
890
|
-
socials: response.githubSocial ? [{ type: "github", url: response.githubSocial }] : existingConfig.socials
|
|
891
|
-
};
|
|
892
|
-
if (response.sourceType === "github") {
|
|
893
|
-
updatedConfig.source = {
|
|
894
|
-
type: "github",
|
|
895
|
-
repo: response.githubRepo,
|
|
896
|
-
branch: response.githubBranch,
|
|
897
|
-
docsDir: response.githubDocsDir
|
|
898
|
-
};
|
|
899
|
-
} else if (response.sourceType === "local") {
|
|
900
|
-
delete updatedConfig.source;
|
|
901
|
-
}
|
|
902
|
-
const dir = import_path6.default.dirname(configPath);
|
|
903
|
-
if (!import_fs6.default.existsSync(dir)) {
|
|
904
|
-
import_fs6.default.mkdirSync(dir, { recursive: true });
|
|
905
|
-
}
|
|
906
|
-
import_fs6.default.writeFileSync(configPath, JSON.stringify(updatedConfig, null, 2), "utf-8");
|
|
907
|
-
console.log(import_chalk5.default.bold.green(`
|
|
908
|
-
\u2714 Configuration successfully saved to: ${configPath}
|
|
909
|
-
`));
|
|
910
|
-
}
|
|
911
|
-
|
|
912
|
-
// package.json
|
|
913
|
-
var package_default = {
|
|
914
|
-
name: "docmedown",
|
|
915
|
-
version: "0.1.0",
|
|
916
|
-
description: "The simplest MarkDown documenter yet. CLI & Web Script React SPA documentation engine.",
|
|
917
|
-
main: "./dist/docmedown.cjs",
|
|
918
|
-
module: "./dist/docmedown.mjs",
|
|
919
|
-
types: "./dist/types/runtime/index.d.ts",
|
|
920
|
-
exports: {
|
|
921
|
-
".": {
|
|
922
|
-
types: "./dist/types/runtime/index.d.ts",
|
|
923
|
-
import: "./dist/docmedown.mjs",
|
|
924
|
-
require: "./dist/docmedown.cjs"
|
|
925
|
-
},
|
|
926
|
-
"./iife": "./dist/docmedown.iife.js"
|
|
927
|
-
},
|
|
928
|
-
unpkg: "./dist/docmedown.iife.js",
|
|
929
|
-
jsdelivr: "./dist/docmedown.iife.js",
|
|
930
|
-
bin: {
|
|
931
|
-
docmedown: "bin/docmedown.js",
|
|
932
|
-
dmd: "bin/docmedown.js"
|
|
933
|
-
},
|
|
934
|
-
files: [
|
|
935
|
-
"dist",
|
|
936
|
-
"bin",
|
|
937
|
-
"templates",
|
|
938
|
-
"README.md",
|
|
939
|
-
"LICENSE"
|
|
940
|
-
],
|
|
941
|
-
scripts: {
|
|
942
|
-
"dev:runtime": "vite build --watch",
|
|
943
|
-
"build:runtime": "vite build",
|
|
944
|
-
"build:cli": "tsup",
|
|
945
|
-
typecheck: "tsc --noEmit",
|
|
946
|
-
"build:types": "tsc -p tsconfig.runtime.json",
|
|
947
|
-
build: "npm run build:runtime && npm run build:cli && npm run build:types",
|
|
948
|
-
docmedown: "node ./bin/docmedown.js",
|
|
949
|
-
dmd: "node ./bin/docmedown.js",
|
|
950
|
-
"init:docs": "node ./bin/docmedown.js init",
|
|
951
|
-
serve: "node ./bin/docmedown.js serve ./docs",
|
|
952
|
-
dev: "node ./bin/docmedown.js serve ./docs",
|
|
953
|
-
"build:docs": "node ./bin/docmedown.js build ./docs",
|
|
954
|
-
"build:docs:watch": "node ./bin/docmedown.js build ./docs --watch",
|
|
955
|
-
"build:offline": "node ./bin/docmedown.js build ./docs",
|
|
956
|
-
"config:docs": "node ./bin/docmedown.js config ./docs/docs.json",
|
|
957
|
-
test: "npx tsx --test tests/parser.test.ts tests/scanner.test.ts tests/runtime-integration.test.ts tests/package-smoke.test.ts",
|
|
958
|
-
"test:release": "npm run typecheck && npm run test && npm run build && npm run build:docs && npm pack --dry-run",
|
|
959
|
-
prepublishOnly: "npm run test:release"
|
|
960
|
-
},
|
|
961
|
-
keywords: [
|
|
962
|
-
"markdown",
|
|
963
|
-
"documentation",
|
|
964
|
-
"docs",
|
|
965
|
-
"docusaurus",
|
|
966
|
-
"docsify",
|
|
967
|
-
"react",
|
|
968
|
-
"spa",
|
|
969
|
-
"cli",
|
|
970
|
-
"offline-docs",
|
|
971
|
-
"github-docs"
|
|
972
|
-
],
|
|
973
|
-
author: "Gabriel M. Silva",
|
|
974
|
-
license: "MIT",
|
|
975
|
-
engines: {
|
|
976
|
-
node: ">=20.19.0"
|
|
977
|
-
},
|
|
978
|
-
repository: {
|
|
979
|
-
type: "git",
|
|
980
|
-
url: "git+https://github.com/gabrielmsilva00/docmedown.git"
|
|
981
|
-
},
|
|
982
|
-
bugs: {
|
|
983
|
-
url: "https://github.com/gabrielmsilva00/docmedown/issues"
|
|
984
|
-
},
|
|
985
|
-
homepage: "https://github.com/gabrielmsilva00/docmedown#readme",
|
|
986
|
-
packageManager: "npm@11.16.0",
|
|
987
|
-
overrides: {
|
|
988
|
-
tsup: {
|
|
989
|
-
esbuild: "0.28.2"
|
|
990
|
-
}
|
|
991
|
-
},
|
|
992
|
-
dependencies: {
|
|
993
|
-
chalk: "^4.1.2",
|
|
994
|
-
chokidar: "^3.6.0",
|
|
995
|
-
commander: "^12.1.0",
|
|
996
|
-
"gray-matter": "^4.0.3",
|
|
997
|
-
"mime-types": "^2.1.35",
|
|
998
|
-
open: "^10.1.0",
|
|
999
|
-
prompts: "^2.4.2",
|
|
1000
|
-
ws: "^8.18.0"
|
|
1001
|
-
},
|
|
1002
|
-
devDependencies: {
|
|
1003
|
-
"@types/node": "^22.5.0",
|
|
1004
|
-
"@types/prismjs": "^1.26.6",
|
|
1005
|
-
"@types/prompts": "^2.4.9",
|
|
1006
|
-
"@types/react": "^18.3.5",
|
|
1007
|
-
"@types/react-dom": "^18.3.0",
|
|
1008
|
-
"@types/ws": "^8.5.12",
|
|
1009
|
-
"@vitejs/plugin-react": "^6.1.0",
|
|
1010
|
-
katex: "^0.16.11",
|
|
1011
|
-
marked: "^14.1.1",
|
|
1012
|
-
minisearch: "^7.1.0",
|
|
1013
|
-
prismjs: "^1.29.0",
|
|
1014
|
-
react: "^18.3.1",
|
|
1015
|
-
"react-dom": "^18.3.1",
|
|
1016
|
-
tsup: "^8.2.4",
|
|
1017
|
-
tsx: "^4.19.0",
|
|
1018
|
-
typescript: "^5.5.4",
|
|
1019
|
-
vite: "^8.2.2",
|
|
1020
|
-
"vite-plugin-css-injected-by-js": "^5.0.2"
|
|
1021
|
-
}
|
|
1022
|
-
};
|
|
1023
|
-
|
|
1024
1211
|
// src/cli/index.ts
|
|
1025
1212
|
var program = new import_commander.Command();
|
|
1026
1213
|
program.name("docmedown").description("DocMeDown - The simplest MarkDown documenter yet. CLI & Web Script React SPA.").version(package_default.version);
|
|
1027
1214
|
program.argument("[dir]", "Documentation directory to initialize or serve", "./docs").option("-p, --port <number>", "Port for local dev server", "3000").option("--no-open", "Do not automatically open the browser").action(async (dir, options) => {
|
|
1028
|
-
const targetDir =
|
|
1029
|
-
const hasIndex =
|
|
1030
|
-
const hasDocs =
|
|
1215
|
+
const targetDir = import_node_path7.default.resolve(process.cwd(), dir);
|
|
1216
|
+
const hasIndex = import_node_fs7.default.existsSync(import_node_path7.default.join(targetDir, "index.html"));
|
|
1217
|
+
const hasDocs = import_node_fs7.default.existsSync(import_node_path7.default.join(targetDir, "README.md")) || import_node_fs7.default.existsSync(import_node_path7.default.join(targetDir, "docs.json"));
|
|
1031
1218
|
if (!hasIndex && !hasDocs) {
|
|
1032
1219
|
await initCommand(dir, { start: options.open });
|
|
1033
1220
|
} else {
|