wiki-viewer 2.9.2 → 2.9.3
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/.next/standalone/.next/BUILD_ID +1 -1
- package/.next/standalone/.next/app-path-routes-manifest.json +0 -4
- package/.next/standalone/.next/build-manifest.json +5 -5
- package/.next/standalone/.next/prerender-manifest.json +3 -3
- package/.next/standalone/.next/required-server-files.json +4 -4
- package/.next/standalone/.next/routes-manifest.json +0 -24
- package/.next/standalone/.next/server/app/_global-error/page/build-manifest.json +2 -2
- package/.next/standalone/.next/server/app/_global-error.html +1 -1
- package/.next/standalone/.next/server/app/_global-error.rsc +1 -1
- package/.next/standalone/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_not-found/page/build-manifest.json +2 -2
- package/.next/standalone/.next/server/app/_not-found/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/api/agent/activity/route.js +7 -7
- package/.next/standalone/.next/server/app/api/agent/activity/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/agent/admin/agents/[agentId]/revoke/route.js +5 -5
- package/.next/standalone/.next/server/app/api/agent/admin/agents/[agentId]/revoke/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/agent/admin/agents/route.js +5 -5
- package/.next/standalone/.next/server/app/api/agent/admin/agents/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/agent/admin/registrations/[regId]/approve/route.js +5 -5
- package/.next/standalone/.next/server/app/api/agent/admin/registrations/[regId]/approve/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/agent/admin/registrations/[regId]/deny/route.js +5 -5
- package/.next/standalone/.next/server/app/api/agent/admin/registrations/[regId]/deny/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/agent/admin/registrations/route.js +5 -5
- package/.next/standalone/.next/server/app/api/agent/admin/registrations/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/agent/events/[...path]/route.js +7 -7
- package/.next/standalone/.next/server/app/api/agent/events/[...path]/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/agent/files/[...path]/route.js +9 -9
- package/.next/standalone/.next/server/app/api/agent/files/[...path]/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/agent/fs/file/[...path]/route.js +7 -7
- package/.next/standalone/.next/server/app/api/agent/fs/file/[...path]/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/agent/fs/ls/[[...path]]/route.js +8 -8
- package/.next/standalone/.next/server/app/api/agent/fs/ls/[[...path]]/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/agent/fs/move/route.js +8 -8
- package/.next/standalone/.next/server/app/api/agent/fs/move/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/agent/fs/search/route.js +8 -8
- package/.next/standalone/.next/server/app/api/agent/fs/search/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/agent/internal/span/route.js +8 -8
- package/.next/standalone/.next/server/app/api/agent/internal/span/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/agent/settings/route.js +8 -8
- package/.next/standalone/.next/server/app/api/agent/settings/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/agent/sidecar/[...path]/route.js +8 -8
- package/.next/standalone/.next/server/app/api/agent/sidecar/[...path]/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/app-proxy/[...path]/route.js +10 -2
- package/.next/standalone/.next/server/app/api/app-proxy/[...path]/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/assets/[...path]/route.js +5 -5
- package/.next/standalone/.next/server/app/api/assets/[...path]/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/auth/[...all]/route.js +2 -2
- package/.next/standalone/.next/server/app/api/pdf/save/route.js +8 -8
- package/.next/standalone/.next/server/app/api/pdf/save/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/share/[token]/asset/route.js +3 -2
- package/.next/standalone/.next/server/app/api/share/[token]/asset/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/share/[token]/route.js +8 -7
- package/.next/standalone/.next/server/app/api/share/[token]/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/share/route.js +8 -8
- package/.next/standalone/.next/server/app/api/share/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/system/admins/route.js +5 -5
- package/.next/standalone/.next/server/app/api/system/admins/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/system/api-key/route.js +2 -2
- package/.next/standalone/.next/server/app/api/system/api-key/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/system/auth-config/route.js +3 -3
- package/.next/standalone/.next/server/app/api/system/auth-config/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/system/auth-settings/route.js +5 -5
- package/.next/standalone/.next/server/app/api/system/auth-settings/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/system/browse/route.js +4 -4
- package/.next/standalone/.next/server/app/api/system/browse/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/system/config/route.js +3 -3
- package/.next/standalone/.next/server/app/api/system/config/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/system/pins/route.js +5 -5
- package/.next/standalone/.next/server/app/api/system/pins/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/system/reveal/route.js +4 -4
- package/.next/standalone/.next/server/app/api/system/reveal/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/system/users/route.js +4 -4
- package/.next/standalone/.next/server/app/api/system/users/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/system/workspaces/[id]/branch/route.js +5 -5
- package/.next/standalone/.next/server/app/api/system/workspaces/[id]/branch/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/system/workspaces/[id]/open/route.js +5 -5
- package/.next/standalone/.next/server/app/api/system/workspaces/[id]/open/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/system/workspaces/[id]/refresh/route.js +5 -5
- package/.next/standalone/.next/server/app/api/system/workspaces/[id]/refresh/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/system/workspaces/[id]/route.js +5 -5
- package/.next/standalone/.next/server/app/api/system/workspaces/[id]/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/system/workspaces/route.js +4 -4
- package/.next/standalone/.next/server/app/api/system/workspaces/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/upload/[...path]/route.js +7 -7
- package/.next/standalone/.next/server/app/api/upload/[...path]/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/wiki/app/route.js +9 -9
- package/.next/standalone/.next/server/app/api/wiki/app/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/wiki/backlinks/route.js +7 -7
- package/.next/standalone/.next/server/app/api/wiki/backlinks/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/wiki/content/route.js +10 -10
- package/.next/standalone/.next/server/app/api/wiki/content/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/wiki/download/route.js +9 -9
- package/.next/standalone/.next/server/app/api/wiki/download/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/wiki/folder/route.js +7 -7
- package/.next/standalone/.next/server/app/api/wiki/folder/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/wiki/git-branches/route.js +7 -7
- package/.next/standalone/.next/server/app/api/wiki/git-branches/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/wiki/git-checkout/route.js +6 -6
- package/.next/standalone/.next/server/app/api/wiki/git-checkout/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/wiki/git-diff/route.js +7 -7
- package/.next/standalone/.next/server/app/api/wiki/git-diff/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/wiki/git-file-info/route.js +7 -7
- package/.next/standalone/.next/server/app/api/wiki/git-file-info/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/wiki/git-history/route.js +7 -7
- package/.next/standalone/.next/server/app/api/wiki/git-history/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/wiki/git-pull/route.js +8 -8
- package/.next/standalone/.next/server/app/api/wiki/git-pull/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/wiki/move/route.js +8 -8
- package/.next/standalone/.next/server/app/api/wiki/move/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/wiki/new-file/route.js +8 -8
- package/.next/standalone/.next/server/app/api/wiki/new-file/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/wiki/outlinks/route.js +7 -7
- package/.next/standalone/.next/server/app/api/wiki/outlinks/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/wiki/page/route.js +8 -8
- package/.next/standalone/.next/server/app/api/wiki/page/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/wiki/presence/route.js +7 -7
- package/.next/standalone/.next/server/app/api/wiki/presence/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/wiki/route.js +8 -8
- package/.next/standalone/.next/server/app/api/wiki/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/wiki/search/route.js +8 -8
- package/.next/standalone/.next/server/app/api/wiki/search/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/wiki/slugs/route.js +8 -8
- package/.next/standalone/.next/server/app/api/wiki/slugs/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/wiki/upload/route.js +8 -8
- package/.next/standalone/.next/server/app/api/wiki/upload/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/wiki/watch/route.js +4 -4
- package/.next/standalone/.next/server/app/api/wiki/watch/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/page/build-manifest.json +2 -2
- package/.next/standalone/.next/server/app/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/s/[token]/page/build-manifest.json +2 -2
- package/.next/standalone/.next/server/app/s/[token]/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/s/[token]/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/signin/page/build-manifest.json +2 -2
- package/.next/standalone/.next/server/app/signin/page.js +4 -4
- package/.next/standalone/.next/server/app/signin/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/signin/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app-paths-manifest.json +0 -4
- package/.next/standalone/.next/server/chunks/0p91_next_dist_esm_build_templates_app-route_0ytral2.js +1 -1
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0.xk8gi._.js +3 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__00awqt2._.js +3 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__00sn-o5._.js +16 -0
- package/.next/standalone/.next/server/chunks/{[root-of-the-server]__0mw1brk._.js → [root-of-the-server]__01y-312._.js} +2 -2
- package/.next/standalone/.next/server/chunks/{[root-of-the-server]__12jdw86._.js → [root-of-the-server]__02373p-._.js} +1 -1
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__03_q-~2._.js +3 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__03c09g7._.js +3 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__03prziv._.js +3 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__04vo55d._.js +3 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__04~wbjj._.js +3 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__05tbv~.._.js +16 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__068r9h7._.js +3 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__06jm~o8._.js +3 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__07ox9i8._.js +12 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__088zh92._.js +3 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0_5~w8k._.js +20 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0_g-.kr._.js +20 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0bdxjy5._.js +1 -1
- package/.next/standalone/.next/server/chunks/{[root-of-the-server]__10c4_fo._.js → [root-of-the-server]__0e1kbl7._.js} +1 -1
- package/.next/standalone/.next/server/chunks/{[root-of-the-server]__12v.eva._.js → [root-of-the-server]__0er9oof._.js} +2 -2
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0e~2gkf._.js +3 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0f2frhc._.js +4 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0hgccef._.js +3 -0
- package/.next/standalone/.next/server/chunks/{[root-of-the-server]__0egcl8n._.js → [root-of-the-server]__0j40f60._.js} +2 -2
- package/.next/standalone/.next/server/chunks/{[root-of-the-server]__04mie79._.js → [root-of-the-server]__0k0t_.e._.js} +1 -1
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0k46u9j._.js +3 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0kau~ca._.js +3 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0kuwuwk._.js +3 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0kvxxt~._.js +3 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0l5io1-._.js +3 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0md2vr3._.js +3 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0muj-bp._.js +3 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0nnxcs7._.js +3 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0omny3u._.js +3 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0ou7hai._.js +3 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0r--676._.js +3 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0r55bc0._.js +3 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0rdt~cr._.js +3 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0tizmgc._.js +3 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0vr.qhy._.js +3 -0
- package/.next/standalone/.next/server/chunks/{[root-of-the-server]__0915i_~._.js → [root-of-the-server]__0x.030x._.js} +2 -2
- package/.next/standalone/.next/server/chunks/{[root-of-the-server]__11mhei8._.js → [root-of-the-server]__0xlo2r_._.js} +2 -2
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0yfb5md._.js +3 -0
- package/.next/standalone/.next/server/chunks/{[root-of-the-server]__0a7c~hj._.js → [root-of-the-server]__0z5xk6f._.js} +1 -1
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0~gd460._.js +3 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0~i3blt._.js +3 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__10p-nga._.js +3 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__10zrueo._.js +12 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__11ltgmp._.js +20 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__11zy4x1._.js +6 -6
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__12bl1v6._.js +3 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__12g8s_j._.js +3 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__13h_w~h._.js +4 -0
- package/.next/standalone/.next/server/chunks/_079xuln._.js +1 -1
- package/.next/standalone/.next/server/chunks/_next-internal_server_app_api_system_workspaces_[id]_open_route_actions_1087xu7.js +1 -1
- package/.next/standalone/.next/server/chunks/node_modules__pnpm_0aj5g-w._.js +1 -1
- package/.next/standalone/.next/server/chunks/src_0ks~u~e._.js +1 -1
- package/.next/standalone/.next/server/chunks/src_lib_fs_mounts_ts_0ksy80l._.js +1 -1
- package/.next/standalone/.next/server/chunks/src_lib_workspaces_ts_0qon40u._.js +2 -2
- package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0bt7d39._.js → 0e.4_sonner_dist_index_mjs_0u2em8w._.js} +2 -2
- package/.next/standalone/.next/server/chunks/ssr/{0~w0_katex_dist_katex_mjs_0p7ph25._.js → 0~w0_katex_dist_katex_mjs_018q_uc._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/12y~_mermaid_dist_chunks_mermaid_core_chunk-5ZQYHXKU_mjs_0z1.978._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/12y~_mermaid_dist_chunks_mermaid_core_chunk-KSCS5N6A_mjs_0v4oeem._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__0ybtj28._.js → [root-of-the-server]__02ov~kn._.js} +2 -2
- package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__13k6~ax._.js → [root-of-the-server]__0n5kphk._.js} +2 -2
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0vglc36._.js +3 -0
- package/.next/standalone/.next/server/chunks/ssr/_00pku9f._.js +3 -0
- package/.next/standalone/.next/server/chunks/ssr/_0_.s7b8._.js +3 -0
- package/.next/standalone/.next/server/chunks/ssr/_0oq8kwv._.js +174 -0
- package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_04qqrjr._.js → node_modules__pnpm_0.wgpvp._.js} +2 -2
- package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_09k0q18._.js → node_modules__pnpm_02j0p3a._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0wg48.8._.js → node_modules__pnpm_02yqus6._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_11g2aee._.js → node_modules__pnpm_07bf4mp._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/node_modules__pnpm_0a4su30._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0a-f4gi._.js → node_modules__pnpm_0a~3f2a._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0819uyi._.js → node_modules__pnpm_0bnc0lk._.js} +2 -2
- package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0b3l3b4._.js → node_modules__pnpm_0dm.meu._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0rc4s48._.js → node_modules__pnpm_0ebvpwi._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0jp7ggg._.js → node_modules__pnpm_0f.5boy._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0ha2xsd._.js → node_modules__pnpm_0f9vj0~._.js} +2 -2
- package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0ypcps.._.js → node_modules__pnpm_0f9vuiw._.js} +2 -2
- package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_06usij4._.js → node_modules__pnpm_0fa23-q._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0cuckmp._.js → node_modules__pnpm_0g21lw4._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_09ybwhl._.js → node_modules__pnpm_0kdk2ot._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0wjizot._.js → node_modules__pnpm_0kkbph0._.js} +2 -2
- package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0xp3s_y._.js → node_modules__pnpm_0mv0.4i._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0z~bh__._.js → node_modules__pnpm_0nt22aq._.js} +2 -2
- package/.next/standalone/.next/server/chunks/ssr/node_modules__pnpm_0o~d81.._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0m2hb6k._.js → node_modules__pnpm_0p4w0~q._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_03ciu.l._.js → node_modules__pnpm_0pv3k.9._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_09c3lg3._.js → node_modules__pnpm_0qmqt0m._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0iuzd3o._.js → node_modules__pnpm_0q~maar._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0ldft78._.js → node_modules__pnpm_0s1th-1._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0qhs4r2._.js → node_modules__pnpm_0tdnho_._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0dsnv76._.js → node_modules__pnpm_0w6oo9l._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0eiz-8_._.js → node_modules__pnpm_0x9-_1d._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0gnc95r._.js → node_modules__pnpm_0xq~zku._.js} +2 -2
- package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0~88b7s._.js → node_modules__pnpm_12nfd13._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/src_app_s_[token]_page_tsx_0_fzrmd._.js +1 -1
- package/.next/standalone/.next/server/middleware-build-manifest.js +5 -5
- package/.next/standalone/.next/server/pages/500.html +1 -1
- package/.next/standalone/.next/server/server-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/server-reference-manifest.json +1 -1
- package/.next/standalone/.next/static/chunks/00_12ekhbvhhp.js +1 -0
- package/.next/standalone/.next/static/chunks/01u~45r8icusu.js +1 -0
- package/.next/standalone/.next/static/chunks/0aeii_m.9~9_t.js +1 -0
- package/.next/standalone/.next/static/chunks/0fm2eul-wqh2f.js +1 -0
- package/.next/standalone/.next/static/chunks/{08usk_~k6d0yf.js → 0k31ncl7m_j9q.js} +2 -2
- package/.next/standalone/.next/static/chunks/0n7px0u5.eizf.css +9 -0
- package/.next/standalone/.next/static/chunks/0qs6cl.~q-0tv.js +1 -0
- package/.next/standalone/.next/static/chunks/0wu_n6m9jg8rn.js +1 -0
- package/.next/standalone/.next/static/chunks/0yixq3fhhpk~9.js +172 -0
- package/.next/standalone/.next/static/chunks/{turbopack-0~8fsjmdvb_1i.js → turbopack-1105gjd__15ti.js} +1 -1
- package/.next/standalone/.test-floor +1 -1
- package/.next/standalone/biome.json +70 -0
- package/.next/standalone/node_modules/@vscode/ripgrep-linux-x64/bin/rg +0 -0
- package/.next/standalone/package.json +8 -9
- package/.next/standalone/scripts/format-check.mjs +25 -0
- package/.next/standalone/scripts/test-floor.mjs +86 -37
- package/.next/standalone/server.js +1 -1
- package/README.md +12 -5
- package/bin/cli/config.js +105 -0
- package/bin/cli/prompt.js +36 -0
- package/bin/cli/serve.js +413 -0
- package/bin/cli/service.js +304 -0
- package/bin/cli/update.js +58 -0
- package/bin/cli/wizard.js +134 -0
- package/bin/shared/ssh-target.js +154 -0
- package/bin/wiki-viewer.js +118 -1224
- package/package.json +19 -13
- package/.next/standalone/.next/server/app/api/system/clear-root/route/app-paths-manifest.json +0 -3
- package/.next/standalone/.next/server/app/api/system/clear-root/route/build-manifest.json +0 -9
- package/.next/standalone/.next/server/app/api/system/clear-root/route/server-reference-manifest.json +0 -4
- package/.next/standalone/.next/server/app/api/system/clear-root/route.js +0 -14
- package/.next/standalone/.next/server/app/api/system/clear-root/route.js.map +0 -5
- package/.next/standalone/.next/server/app/api/system/clear-root/route.js.nft.json +0 -1
- package/.next/standalone/.next/server/app/api/system/clear-root/route_client-reference-manifest.js +0 -3
- package/.next/standalone/.next/server/app/api/system/root-status/route/app-paths-manifest.json +0 -3
- package/.next/standalone/.next/server/app/api/system/root-status/route/build-manifest.json +0 -9
- package/.next/standalone/.next/server/app/api/system/root-status/route/server-reference-manifest.json +0 -4
- package/.next/standalone/.next/server/app/api/system/root-status/route.js +0 -14
- package/.next/standalone/.next/server/app/api/system/root-status/route.js.map +0 -5
- package/.next/standalone/.next/server/app/api/system/root-status/route.js.nft.json +0 -1
- package/.next/standalone/.next/server/app/api/system/root-status/route_client-reference-manifest.js +0 -3
- package/.next/standalone/.next/server/app/api/system/set-root/route/app-paths-manifest.json +0 -3
- package/.next/standalone/.next/server/app/api/system/set-root/route/build-manifest.json +0 -9
- package/.next/standalone/.next/server/app/api/system/set-root/route/server-reference-manifest.json +0 -4
- package/.next/standalone/.next/server/app/api/system/set-root/route.js +0 -15
- package/.next/standalone/.next/server/app/api/system/set-root/route.js.map +0 -5
- package/.next/standalone/.next/server/app/api/system/set-root/route.js.nft.json +0 -1
- package/.next/standalone/.next/server/app/api/system/set-root/route_client-reference-manifest.js +0 -3
- package/.next/standalone/.next/server/app/api/wiki/file/route/app-paths-manifest.json +0 -3
- package/.next/standalone/.next/server/app/api/wiki/file/route/build-manifest.json +0 -9
- package/.next/standalone/.next/server/app/api/wiki/file/route/server-reference-manifest.json +0 -4
- package/.next/standalone/.next/server/app/api/wiki/file/route.js +0 -16
- package/.next/standalone/.next/server/app/api/wiki/file/route.js.map +0 -5
- package/.next/standalone/.next/server/app/api/wiki/file/route.js.nft.json +0 -1
- package/.next/standalone/.next/server/app/api/wiki/file/route_client-reference-manifest.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0-3eby~._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0-bd36s._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0._o62m._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0.f~mr1._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0.xsx4e._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__01w5s-4._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__02hiw0n._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__037g~yp._.js +0 -20
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__04yzrn9._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__05dk_5q._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__05nk8xg._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__05wicn_._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__07i72.r._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__086~~78._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__08h0txl._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__09ezcba._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0au~ncj._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0c-49tx._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0di13ue._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0dkxp4y._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0jhwupj._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0ker6~l._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0mkrdf0._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0nzjsw9._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0o0lsmx._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0omc1-s._.js +0 -20
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0os3ej1._.js +0 -16
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0px8._m._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0qe7kxb._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0qe8lje._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0qox302._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0s5ns33._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0s6kt0y._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0t_s2dg._.js +0 -20
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0tchvup._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0tw6h_5._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0wmp13_._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0z8qb~s._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0zy2f8y._.js +0 -12
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0~s~szv._.js +0 -16
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__1024gkd._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__12abg.4._.js +0 -3
- package/.next/standalone/.next/server/chunks/_next-internal_server_app_api_system_clear-root_route_actions_065znew.js +0 -3
- package/.next/standalone/.next/server/chunks/_next-internal_server_app_api_system_root-status_route_actions_0stp57y.js +0 -3
- package/.next/standalone/.next/server/chunks/_next-internal_server_app_api_system_set-root_route_actions_0vxn8ey.js +0 -3
- package/.next/standalone/.next/server/chunks/_next-internal_server_app_api_wiki_file_route_actions_0ytnc0i.js +0 -3
- package/.next/standalone/.next/server/chunks/ssr/0~w0_katex_dist_katex_mjs_12lt4cp._.js +0 -3
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0a3bjyp._.js +0 -3
- package/.next/standalone/.next/server/chunks/ssr/_03xt0rl._.js +0 -158
- package/.next/standalone/.next/server/chunks/ssr/_06rf50_._.js +0 -3
- package/.next/standalone/.next/server/chunks/ssr/_0i3r51-._.js +0 -158
- package/.next/standalone/.next/server/chunks/ssr/_0jdop6l._.js +0 -3
- package/.next/standalone/.next/server/chunks/ssr/_0v4uz-4._.js +0 -19
- package/.next/standalone/.next/server/chunks/ssr/node_modules__pnpm_0.6uh54._.js +0 -3
- package/.next/standalone/.next/server/chunks/ssr/node_modules__pnpm_00o9din._.js +0 -3
- package/.next/standalone/.next/server/chunks/ssr/node_modules__pnpm_02jnz2o._.js +0 -17
- package/.next/standalone/.next/server/chunks/ssr/node_modules__pnpm_03jchtd._.js +0 -3
- package/.next/standalone/.next/server/chunks/ssr/node_modules__pnpm_04xh4re._.js +0 -26
- package/.next/standalone/.next/server/chunks/ssr/node_modules__pnpm_07p8tmd._.js +0 -17
- package/.next/standalone/.next/server/chunks/ssr/node_modules__pnpm_08jqh.4._.js +0 -3
- package/.next/standalone/.next/server/chunks/ssr/node_modules__pnpm_0_up15t._.js +0 -17
- package/.next/standalone/.next/server/chunks/ssr/node_modules__pnpm_0c.b4rt._.js +0 -3
- package/.next/standalone/.next/server/chunks/ssr/node_modules__pnpm_0dr38_k._.js +0 -31
- package/.next/standalone/.next/server/chunks/ssr/node_modules__pnpm_0e-nvo5._.js +0 -45
- package/.next/standalone/.next/server/chunks/ssr/node_modules__pnpm_0e9l2~p._.js +0 -3
- package/.next/standalone/.next/server/chunks/ssr/node_modules__pnpm_0k_8g5d._.js +0 -3
- package/.next/standalone/.next/server/chunks/ssr/node_modules__pnpm_0kli5~f._.js +0 -3
- package/.next/standalone/.next/server/chunks/ssr/node_modules__pnpm_0n-ec__._.js +0 -3
- package/.next/standalone/.next/server/chunks/ssr/node_modules__pnpm_0odzirk._.js +0 -3
- package/.next/standalone/.next/server/chunks/ssr/node_modules__pnpm_0ov9ih8._.js +0 -17
- package/.next/standalone/.next/server/chunks/ssr/node_modules__pnpm_0qb~hug._.js +0 -17
- package/.next/standalone/.next/server/chunks/ssr/node_modules__pnpm_0t24-57._.js +0 -3
- package/.next/standalone/.next/server/chunks/ssr/node_modules__pnpm_0umkew~._.js +0 -17
- package/.next/standalone/.next/server/chunks/ssr/node_modules__pnpm_0w_fkrb._.js +0 -3
- package/.next/standalone/.next/server/chunks/ssr/node_modules__pnpm_0yfe2s1._.js +0 -3
- package/.next/standalone/.next/server/chunks/ssr/node_modules__pnpm_0~ovwm1._.js +0 -3
- package/.next/standalone/.next/server/chunks/ssr/node_modules__pnpm_10-i1v8._.js +0 -3
- package/.next/standalone/.next/server/chunks/ssr/node_modules__pnpm_12dmj0l._.js +0 -3
- package/.next/standalone/.next/server/chunks/ssr/node_modules__pnpm_133w.gx._.js +0 -11
- package/.next/standalone/.next/server/chunks/ssr/node_modules__pnpm_13y5ncy._.js +0 -3
- package/.next/standalone/.next/static/chunks/0-lsw0io13aha.js +0 -1
- package/.next/standalone/.next/static/chunks/01-v2wyaj~5gn.js +0 -1
- package/.next/standalone/.next/static/chunks/03zmegz1kvvod.js +0 -17
- package/.next/standalone/.next/static/chunks/04_l8s7dy454_.js +0 -1
- package/.next/standalone/.next/static/chunks/0a~z4.g.dtxjm.js +0 -156
- package/.next/standalone/.next/static/chunks/0ky8fha87kp0_.js +0 -1
- package/.next/standalone/.next/static/chunks/0nzvnpn.j1~sx.js +0 -1
- package/.next/standalone/.next/static/chunks/0t5bc7buy7sx9.js +0 -156
- package/.next/standalone/.next/static/chunks/0umlolnxs~j3r.js +0 -1
- package/.next/standalone/.next/static/chunks/1012fl5fxholx.js +0 -1
- package/.next/standalone/.next/static/chunks/17isnstdq92js.css +0 -5
- /package/.next/standalone/.next/static/{R2lG97g-a6HpbZZtS4qep → I6ZpQF8Ua7ytNZMW5ZKWH}/_buildManifest.js +0 -0
- /package/.next/standalone/.next/static/{R2lG97g-a6HpbZZtS4qep → I6ZpQF8Ua7ytNZMW5ZKWH}/_clientMiddlewareManifest.js +0 -0
- /package/.next/standalone/.next/static/{R2lG97g-a6HpbZZtS4qep → I6ZpQF8Ua7ytNZMW5ZKWH}/_ssgManifest.js +0 -0
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
import { execFileSync, execSync } from "node:child_process";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import os from "node:os";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
import { existsSync, mkdirSync, rmSync, writeFileSync } from "node:fs";
|
|
6
|
+
import { configPath, logDir, loadConfig, saveConfig, parseEnvFlags } from "./config.js";
|
|
7
|
+
import { computeServerEnv, parseServeArgs } from "./serve.js";
|
|
8
|
+
import { looksLikeSshTarget } from "../shared/ssh-target.js";
|
|
9
|
+
|
|
10
|
+
const selfScript = fileURLToPath(import.meta.url);
|
|
11
|
+
|
|
12
|
+
export const SERVICE_NAME = "wiki-viewer";
|
|
13
|
+
export const LAUNCHD_LABEL = "com.wiki-viewer";
|
|
14
|
+
|
|
15
|
+
export function platform() {
|
|
16
|
+
if (process.platform === "linux") return "linux";
|
|
17
|
+
if (process.platform === "darwin") return "macos";
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function requireSupportedPlatform() {
|
|
22
|
+
const p = platform();
|
|
23
|
+
if (!p) {
|
|
24
|
+
console.error(`Error: service management is only supported on Linux (systemd) and macOS (launchd), not ${process.platform}.`);
|
|
25
|
+
process.exit(1);
|
|
26
|
+
}
|
|
27
|
+
return p;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function run(cmd, args, opts = {}) {
|
|
31
|
+
return execFileSync(cmd, args, { stdio: "inherit", ...opts });
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function runQuiet(cmd, args) {
|
|
35
|
+
try {
|
|
36
|
+
return execFileSync(cmd, args, { stdio: ["ignore", "pipe", "pipe"] }).toString();
|
|
37
|
+
} catch (e) {
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function installSystemd(nodeBin, scriptPath) {
|
|
43
|
+
const unitDir = path.join(os.homedir(), ".config", "systemd", "user");
|
|
44
|
+
mkdirSync(unitDir, { recursive: true });
|
|
45
|
+
const unitPath = path.join(unitDir, `${SERVICE_NAME}.service`);
|
|
46
|
+
|
|
47
|
+
const nodeDir = path.dirname(nodeBin);
|
|
48
|
+
const sysPath = `${nodeDir}:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin`;
|
|
49
|
+
const rgEnv = process.env.WIKI_VIEWER_RG
|
|
50
|
+
? `\nEnvironment=WIKI_VIEWER_RG=${process.env.WIKI_VIEWER_RG}`
|
|
51
|
+
: "";
|
|
52
|
+
const unit = `[Unit]
|
|
53
|
+
Description=wiki-viewer local file viewer
|
|
54
|
+
After=network.target
|
|
55
|
+
|
|
56
|
+
[Service]
|
|
57
|
+
Type=simple
|
|
58
|
+
ExecStart=${nodeBin} ${scriptPath} service run
|
|
59
|
+
Restart=on-failure
|
|
60
|
+
RestartSec=3
|
|
61
|
+
Environment=NODE_ENV=production
|
|
62
|
+
Environment=PATH=${sysPath}${rgEnv}
|
|
63
|
+
|
|
64
|
+
[Install]
|
|
65
|
+
WantedBy=default.target
|
|
66
|
+
`;
|
|
67
|
+
writeFileSync(unitPath, unit);
|
|
68
|
+
console.log(`Wrote unit ${unitPath}`);
|
|
69
|
+
|
|
70
|
+
const user = os.userInfo().username;
|
|
71
|
+
try {
|
|
72
|
+
execFileSync("loginctl", ["enable-linger", user], { stdio: "ignore" });
|
|
73
|
+
console.log(`Enabled linger for ${user} (starts at boot)`);
|
|
74
|
+
} catch {
|
|
75
|
+
console.log(`Note: could not enable linger automatically. For boot persistence run:`);
|
|
76
|
+
console.log(` sudo loginctl enable-linger ${user}`);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
run("systemctl", ["--user", "daemon-reload"]);
|
|
80
|
+
run("systemctl", ["--user", "enable", "--now", `${SERVICE_NAME}.service`]);
|
|
81
|
+
console.log("\nService installed and started.");
|
|
82
|
+
console.log(" Status: wiki-viewer service status");
|
|
83
|
+
console.log(" Logs: wiki-viewer service logs");
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export function installLaunchd(nodeBin, scriptPath) {
|
|
87
|
+
const agentsDir = path.join(os.homedir(), "Library", "LaunchAgents");
|
|
88
|
+
mkdirSync(agentsDir, { recursive: true });
|
|
89
|
+
mkdirSync(logDir, { recursive: true });
|
|
90
|
+
const plistPath = path.join(agentsDir, `${LAUNCHD_LABEL}.plist`);
|
|
91
|
+
const outLog = path.join(logDir, "out.log");
|
|
92
|
+
const errLog = path.join(logDir, "err.log");
|
|
93
|
+
|
|
94
|
+
const plist = `<?xml version="1.0" encoding="UTF-8"?>
|
|
95
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
96
|
+
<plist version="1.0">
|
|
97
|
+
<dict>
|
|
98
|
+
<key>Label</key>
|
|
99
|
+
<string>${LAUNCHD_LABEL}</string>
|
|
100
|
+
<key>ProgramArguments</key>
|
|
101
|
+
<array>
|
|
102
|
+
<string>${nodeBin}</string>
|
|
103
|
+
<string>${scriptPath}</string>
|
|
104
|
+
<string>service</string>
|
|
105
|
+
<string>run</string>
|
|
106
|
+
</array>
|
|
107
|
+
<key>RunAtLoad</key>
|
|
108
|
+
<true/>
|
|
109
|
+
<key>KeepAlive</key>
|
|
110
|
+
<true/>
|
|
111
|
+
<key>StandardOutPath</key>
|
|
112
|
+
<string>${outLog}</string>
|
|
113
|
+
<key>StandardErrorPath</key>
|
|
114
|
+
<string>${errLog}</string>
|
|
115
|
+
</dict>
|
|
116
|
+
</plist>
|
|
117
|
+
`;
|
|
118
|
+
writeFileSync(plistPath, plist);
|
|
119
|
+
console.log(`Wrote plist ${plistPath}`);
|
|
120
|
+
|
|
121
|
+
runQuiet("launchctl", ["unload", plistPath]);
|
|
122
|
+
run("launchctl", ["load", "-w", plistPath]);
|
|
123
|
+
console.log("\nService installed and started.");
|
|
124
|
+
console.log(" Status: wiki-viewer service status");
|
|
125
|
+
console.log(" Logs: wiki-viewer service logs");
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// A persistent service bakes an absolute path to this script into the unit /
|
|
129
|
+
// plist (ExecStart). If we're running from a package-manager scratch cache
|
|
130
|
+
// (`npx wiki-viewer …`, `pnpm dlx …`, or an OS temp dir), that path is deleted
|
|
131
|
+
// the moment the cache is pruned, leaving a service that silently fails on the
|
|
132
|
+
// next reboot. Detect it and refuse, pointing the user at a global install.
|
|
133
|
+
export function ephemeralInstallReason() {
|
|
134
|
+
const p = selfScript;
|
|
135
|
+
const sep = path.sep;
|
|
136
|
+
if (p.includes(`${sep}_npx${sep}`)) return "an npx cache";
|
|
137
|
+
if (p.includes(`${sep}dlx-`)) return "a pnpm/yarn dlx cache";
|
|
138
|
+
const tmp = os.tmpdir();
|
|
139
|
+
if (p === tmp || p.startsWith(tmp + sep)) return "a temporary directory";
|
|
140
|
+
return null;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export function requirePersistentInstall() {
|
|
144
|
+
const reason = ephemeralInstallReason();
|
|
145
|
+
if (!reason) return;
|
|
146
|
+
console.error(`Error: cannot install a service from ${reason}.`);
|
|
147
|
+
console.error(` wiki-viewer is running from ${selfScript},`);
|
|
148
|
+
console.error(` which your package manager will delete. A service pointed there would`);
|
|
149
|
+
console.error(` break after the next cache cleanup or reboot.`);
|
|
150
|
+
console.error(``);
|
|
151
|
+
console.error(` Install it globally first, then install the service:`);
|
|
152
|
+
console.error(` npm install -g ${SERVICE_NAME}`);
|
|
153
|
+
console.error(` ${SERVICE_NAME} service install ...`);
|
|
154
|
+
process.exit(1);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
function fnmRoot() {
|
|
158
|
+
return process.env.FNM_DIR || path.join(os.homedir(), ".local", "share", "fnm");
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
export function resolveServiceNode() {
|
|
162
|
+
const exec = process.execPath;
|
|
163
|
+
const looksFnm = exec.includes("/fnm/") || exec.includes("/.fnm/") || exec.includes("fnm_multishells") || exec.includes("/fnm/node-versions/") || exec.includes("/.local/share/fnm/");
|
|
164
|
+
if (looksFnm) {
|
|
165
|
+
const fnmDefault = path.join(fnmRoot(), "aliases", "default", "bin", "node");
|
|
166
|
+
if (existsSync(fnmDefault)) return fnmDefault;
|
|
167
|
+
}
|
|
168
|
+
return exec;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
export function resolveServiceScript() {
|
|
172
|
+
const script = selfScript;
|
|
173
|
+
const pinned = path.join(fnmRoot(), "node-versions") + path.sep;
|
|
174
|
+
if (!script.startsWith(pinned)) return script;
|
|
175
|
+
const parts = path.relative(path.join(fnmRoot(), "node-versions"), script).split(path.sep);
|
|
176
|
+
if (parts[1] !== "installation") return script;
|
|
177
|
+
const durable = path.join(fnmRoot(), "aliases", "default", ...parts.slice(2));
|
|
178
|
+
return existsSync(durable) ? durable : script;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
export function versionManagedNodeWarning(nodePath) {
|
|
182
|
+
const markers = ["/.nvm/", "/.asdf/", "/.volta/", "/n/versions/", "/fnm_multishells/", "/node-versions/"];
|
|
183
|
+
if (!markers.some((m) => nodePath.includes(m))) return null;
|
|
184
|
+
return (
|
|
185
|
+
`The service will run Node from a version-manager path:\n` +
|
|
186
|
+
` ${nodePath}\n` +
|
|
187
|
+
` If you upgrade or remove that Node version, the service will stop working.\n` +
|
|
188
|
+
` Set a stable default (e.g. \`fnm default <version>\`) or install wiki-viewer\n` +
|
|
189
|
+
` under a system Node, then re-run the install.`
|
|
190
|
+
);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
export function serviceInstall(args) {
|
|
194
|
+
const p = requireSupportedPlatform();
|
|
195
|
+
requirePersistentInstall();
|
|
196
|
+
|
|
197
|
+
const cli = parseServeArgs(args);
|
|
198
|
+
const envFlags = parseEnvFlags(args);
|
|
199
|
+
const existing = loadConfig();
|
|
200
|
+
const mergedEnv = { ...(existing.env ?? {}), ...envFlags };
|
|
201
|
+
const cliIsSsh = cli.rootDir != null && looksLikeSshTarget(cli.rootDir);
|
|
202
|
+
|
|
203
|
+
const cfg = {
|
|
204
|
+
...existing,
|
|
205
|
+
rootDir: cli.rootDir != null
|
|
206
|
+
? (cliIsSsh ? cli.rootDir : path.resolve(cli.rootDir))
|
|
207
|
+
: existing.rootDir ?? null,
|
|
208
|
+
host: cli.userSpecifiedHost ? cli.host : existing.host ?? "localhost",
|
|
209
|
+
port: cli.userSpecifiedPort ? cli.port : existing.port ?? "3000",
|
|
210
|
+
https: cli.useHttps ?? existing.https ?? false,
|
|
211
|
+
};
|
|
212
|
+
|
|
213
|
+
if (cliIsSsh) {
|
|
214
|
+
cfg.ssh = { ...(cli.sshKey ? { key: cli.sshKey } : {}), ...(cli.sshPort ? { port: cli.sshPort } : {}), ...(cli.sshReadOnly ? { readOnly: true } : {}) };
|
|
215
|
+
}
|
|
216
|
+
if (Object.keys(mergedEnv).length) cfg.env = mergedEnv;
|
|
217
|
+
else delete cfg.env;
|
|
218
|
+
if (cliIsSsh && cli.sshPassword) {
|
|
219
|
+
console.log("⚠️ --ssh-password is ignored for services (non-interactive). Use ssh-agent or --ssh-key.\n");
|
|
220
|
+
}
|
|
221
|
+
saveConfig(cfg);
|
|
222
|
+
console.log(`Saved config to ${configPath}`);
|
|
223
|
+
console.log(` dir: ${cfg.rootDir ?? "(choose in browser)"}`);
|
|
224
|
+
console.log(` host: ${cfg.host}`);
|
|
225
|
+
console.log(` port: ${cfg.port}`);
|
|
226
|
+
console.log(` https: ${cfg.https}`);
|
|
227
|
+
if (cfg.env) {
|
|
228
|
+
console.log(` env: ${Object.keys(cfg.env).join(", ")}`);
|
|
229
|
+
}
|
|
230
|
+
console.log("");
|
|
231
|
+
|
|
232
|
+
const { warnings } = computeServerEnv({ host: cfg.host, port: String(cfg.port), useHttps: Boolean(cfg.https), configEnv: cfg.env ?? {} });
|
|
233
|
+
for (const w of warnings) console.log(`\n⚠️ ${w}\n`);
|
|
234
|
+
|
|
235
|
+
const nodeWarning = versionManagedNodeWarning(resolveServiceNode());
|
|
236
|
+
if (nodeWarning) console.log(`⚠️ ${nodeWarning}\n`);
|
|
237
|
+
|
|
238
|
+
const nodeBin = resolveServiceNode();
|
|
239
|
+
const scriptPath = resolveServiceScript();
|
|
240
|
+
if (p === "linux") installSystemd(nodeBin, scriptPath);
|
|
241
|
+
else installLaunchd(nodeBin, scriptPath);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
export function serviceUninstall() {
|
|
245
|
+
const p = requireSupportedPlatform();
|
|
246
|
+
if (p === "linux") {
|
|
247
|
+
runQuiet("systemctl", ["--user", "disable", "--now", `${SERVICE_NAME}.service`]);
|
|
248
|
+
const unitPath = path.join(os.homedir(), ".config", "systemd", "user", `${SERVICE_NAME}.service`);
|
|
249
|
+
if (existsSync(unitPath)) { rmSync(unitPath); console.log(`Removed ${unitPath}`); }
|
|
250
|
+
runQuiet("systemctl", ["--user", "daemon-reload"]);
|
|
251
|
+
} else {
|
|
252
|
+
const plistPath = path.join(os.homedir(), "Library", "LaunchAgents", `${LAUNCHD_LABEL}.plist`);
|
|
253
|
+
runQuiet("launchctl", ["unload", "-w", plistPath]);
|
|
254
|
+
if (existsSync(plistPath)) { rmSync(plistPath); console.log(`Removed ${plistPath}`); }
|
|
255
|
+
}
|
|
256
|
+
console.log("Service uninstalled.");
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
export function serviceStatus() {
|
|
260
|
+
const p = platform();
|
|
261
|
+
if (p === "linux") {
|
|
262
|
+
try { run("systemctl", ["--user", "status", `${SERVICE_NAME}.service`, "--no-pager"]); }
|
|
263
|
+
catch { /* systemctl exits non-zero when inactive; output already shown */ }
|
|
264
|
+
} else if (p === "macos") {
|
|
265
|
+
const out = runQuiet("launchctl", ["list"]);
|
|
266
|
+
if (out) {
|
|
267
|
+
const line = out.split("\n").find((l) => l.includes(LAUNCHD_LABEL));
|
|
268
|
+
console.log(line ? line.trim() : `${LAUNCHD_LABEL}: not loaded`);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
export function serviceLogs() {
|
|
274
|
+
const p = platform();
|
|
275
|
+
if (p === "linux") {
|
|
276
|
+
run("journalctl", ["--user", "-u", `${SERVICE_NAME}.service`, "-n", "100", "-f"]);
|
|
277
|
+
} else if (p === "macos") {
|
|
278
|
+
const outLog = path.join(logDir, "out.log");
|
|
279
|
+
const errLog = path.join(logDir, "err.log");
|
|
280
|
+
run("tail", ["-n", "100", "-f", outLog, errLog]);
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
export function serviceIsInstalled() {
|
|
285
|
+
const p = platform();
|
|
286
|
+
if (p === "linux") {
|
|
287
|
+
return existsSync(path.join(os.homedir(), ".config", "systemd", "user", `${SERVICE_NAME}.service`));
|
|
288
|
+
}
|
|
289
|
+
if (p === "macos") {
|
|
290
|
+
return existsSync(path.join(os.homedir(), "Library", "LaunchAgents", `${LAUNCHD_LABEL}.plist`));
|
|
291
|
+
}
|
|
292
|
+
return false;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
export function serviceRestart() {
|
|
296
|
+
const p = platform();
|
|
297
|
+
if (p === "linux") {
|
|
298
|
+
run("systemctl", ["--user", "restart", `${SERVICE_NAME}.service`]);
|
|
299
|
+
} else if (p === "macos") {
|
|
300
|
+
const plistPath = path.join(os.homedir(), "Library", "LaunchAgents", `${LAUNCHD_LABEL}.plist`);
|
|
301
|
+
runQuiet("launchctl", ["unload", plistPath]);
|
|
302
|
+
run("launchctl", ["load", "-w", plistPath]);
|
|
303
|
+
}
|
|
304
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { execFileSync } from "node:child_process";
|
|
2
|
+
import { fileURLToPath } from "node:url";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import os from "node:os";
|
|
5
|
+
import { readFileSync } from "node:fs";
|
|
6
|
+
import { appRoot } from "./serve.js";
|
|
7
|
+
import { serviceIsInstalled, serviceRestart } from "./service.js";
|
|
8
|
+
|
|
9
|
+
const selfScript = fileURLToPath(import.meta.url);
|
|
10
|
+
|
|
11
|
+
export function detectPackageManager() {
|
|
12
|
+
const ua = process.env.npm_config_user_agent ?? "";
|
|
13
|
+
if (ua.startsWith("pnpm")) return "pnpm";
|
|
14
|
+
if (ua.startsWith("yarn")) return "yarn";
|
|
15
|
+
if (selfScript.includes(`${path.sep}pnpm${path.sep}`)) return "pnpm";
|
|
16
|
+
return "npm";
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function runQuiet(cmd, args) {
|
|
20
|
+
try {
|
|
21
|
+
return execFileSync(cmd, args, { stdio: ["ignore", "pipe", "pipe"] }).toString();
|
|
22
|
+
} catch (e) {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function update() {
|
|
28
|
+
const pkg = JSON.parse(readFileSync(path.join(appRoot, "package.json"), "utf8"));
|
|
29
|
+
const name = pkg.name;
|
|
30
|
+
console.log(`Current ${name}: v${pkg.version}`);
|
|
31
|
+
|
|
32
|
+
const latest = (runQuiet("npm", ["view", `${name}@latest`, "version"]) || "").trim();
|
|
33
|
+
if (latest && latest === pkg.version) {
|
|
34
|
+
console.log(`Already on the latest version (v${latest}). Nothing to do.`);
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
if (latest) console.log(`Latest: v${latest}`);
|
|
38
|
+
|
|
39
|
+
const pm = detectPackageManager();
|
|
40
|
+
const cmd = pm === "pnpm" ? ["pnpm", ["add", "-g", `${name}@latest`, "--prefer-offline"]]
|
|
41
|
+
: pm === "yarn" ? ["yarn", ["global", "add", `${name}@latest`]]
|
|
42
|
+
: ["npm", ["install", "-g", `${name}@latest`, "--prefer-offline"]];
|
|
43
|
+
|
|
44
|
+
console.log(`Updating via ${pm}…`);
|
|
45
|
+
try {
|
|
46
|
+
execFileSync(cmd[0], cmd[1], { stdio: "inherit" });
|
|
47
|
+
} catch {
|
|
48
|
+
console.error(`Error: update failed. Try manually: ${cmd[0]} ${cmd[1].join(" ")}`);
|
|
49
|
+
process.exit(1);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (serviceIsInstalled()) {
|
|
53
|
+
console.log("Restarting service…");
|
|
54
|
+
try { serviceRestart(); console.log("Service restarted."); }
|
|
55
|
+
catch { console.log("Note: could not restart service automatically. Run: wiki-viewer service restart"); }
|
|
56
|
+
}
|
|
57
|
+
console.log("Update complete.");
|
|
58
|
+
}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { existsSync } from "node:fs";
|
|
3
|
+
import { loadConfig, saveConfig, configPath } from "./config.js";
|
|
4
|
+
import { makePrompter } from "./prompt.js";
|
|
5
|
+
import { computeServerEnv, start, resolveRunOptions, isLocalHost } from "./serve.js";
|
|
6
|
+
import {
|
|
7
|
+
platform,
|
|
8
|
+
requirePersistentInstall,
|
|
9
|
+
resolveServiceNode,
|
|
10
|
+
resolveServiceScript,
|
|
11
|
+
versionManagedNodeWarning,
|
|
12
|
+
installSystemd,
|
|
13
|
+
installLaunchd,
|
|
14
|
+
} from "./service.js";
|
|
15
|
+
|
|
16
|
+
const WIZARD_ENV_VARS = [
|
|
17
|
+
{ key: "AUTH_ALLOWED_DOMAIN", hint: "Restrict signup to an email domain, e.g. example.com" },
|
|
18
|
+
{ key: "AUTH_ALLOWED_EMAILS", hint: "Restrict signup to specific emails (comma-separated)" },
|
|
19
|
+
{ key: "GOOGLE_CLIENT_ID", hint: "Google OAuth client ID (enables Google sign-in)" },
|
|
20
|
+
{ key: "GOOGLE_CLIENT_SECRET", hint: "Google OAuth client secret" },
|
|
21
|
+
{ key: "AUTH_DISABLE_PASSWORD", hint: "Set to 1 to allow Google sign-in only (requires Google keys)" },
|
|
22
|
+
{ key: "AUTH_TRUSTED_PROVIDERS", hint: "Auto-link these providers to existing accounts, e.g. google" },
|
|
23
|
+
{ key: "WIKI_OWNER_HOSTS", hint: "Extra hostnames trusted for the AI panel owner cookie" },
|
|
24
|
+
{ key: "AGENT_RATE_LIMIT", hint: "Per-minute agent API rate limit (default 60)" },
|
|
25
|
+
];
|
|
26
|
+
|
|
27
|
+
export async function runWizard() {
|
|
28
|
+
const io = makePrompter();
|
|
29
|
+
const existing = loadConfig();
|
|
30
|
+
|
|
31
|
+
const ask = async (label, def) => {
|
|
32
|
+
const suffix = def ? ` [${def}]` : "";
|
|
33
|
+
const answer = (await io.prompt(`${label}${suffix}: `)).trim();
|
|
34
|
+
return answer || def || "";
|
|
35
|
+
};
|
|
36
|
+
const askYesNo = async (label, defYes) => {
|
|
37
|
+
const def = defYes ? "Y/n" : "y/N";
|
|
38
|
+
const answer = (await io.prompt(`${label} [${def}]: `)).trim().toLowerCase();
|
|
39
|
+
if (!answer) return defYes;
|
|
40
|
+
return answer === "y" || answer === "yes";
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
try {
|
|
44
|
+
console.log("\nwiki-viewer setup\n");
|
|
45
|
+
console.log("Answer a few questions. Press Enter to accept the [default].\n");
|
|
46
|
+
|
|
47
|
+
const dirInput = await ask(
|
|
48
|
+
"Directory to serve (blank = choose later in the browser)",
|
|
49
|
+
existing.rootDir ?? process.cwd(),
|
|
50
|
+
);
|
|
51
|
+
const rootDir = dirInput ? path.resolve(dirInput) : null;
|
|
52
|
+
if (rootDir && !existsSync(rootDir)) {
|
|
53
|
+
console.log(` Note: ${rootDir} does not exist yet; it will be served once created.`);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const host = await ask(
|
|
57
|
+
"Host to bind (localhost for this machine only, 0.0.0.0 for the network)",
|
|
58
|
+
existing.host ?? "localhost",
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
const port = await ask("Port", String(existing.port ?? "3000"));
|
|
62
|
+
|
|
63
|
+
const httpsDefault = existing.https ?? (!isLocalHost(host) && host !== "0.0.0.0");
|
|
64
|
+
const useHttps = await askYesNo(
|
|
65
|
+
"Enable HTTPS? (recommended for any non-localhost access)",
|
|
66
|
+
Boolean(httpsDefault),
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
const env = { ...(existing.env ?? {}) };
|
|
70
|
+
const wantEnv = await askYesNo(
|
|
71
|
+
"\nConfigure app settings now? (OAuth, signup allowlist, rate limit)",
|
|
72
|
+
false,
|
|
73
|
+
);
|
|
74
|
+
if (wantEnv) {
|
|
75
|
+
console.log("Leave blank to skip a setting.\n");
|
|
76
|
+
for (const { key, hint } of WIZARD_ENV_VARS) {
|
|
77
|
+
const cur = env[key];
|
|
78
|
+
const val = await ask(` ${key} — ${hint}`, cur);
|
|
79
|
+
if (val) env[key] = val;
|
|
80
|
+
else delete env[key];
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const cfg = { ...existing, rootDir, host, port, https: useHttps };
|
|
85
|
+
if (Object.keys(env).length) cfg.env = env;
|
|
86
|
+
else delete cfg.env;
|
|
87
|
+
|
|
88
|
+
console.log("\nConfiguration:");
|
|
89
|
+
console.log(` directory : ${rootDir ?? "(choose in browser)"}`);
|
|
90
|
+
console.log(` host : ${host}`);
|
|
91
|
+
console.log(` port : ${port}`);
|
|
92
|
+
console.log(` https : ${useHttps}`);
|
|
93
|
+
if (cfg.env) console.log(` app env : ${Object.keys(cfg.env).join(", ")}`);
|
|
94
|
+
|
|
95
|
+
const { warnings } = computeServerEnv({ host, port: String(port), useHttps, configEnv: cfg.env ?? {} });
|
|
96
|
+
for (const w of warnings) console.log(`\n⚠️ ${w}`);
|
|
97
|
+
|
|
98
|
+
console.log("");
|
|
99
|
+
console.log("What next?");
|
|
100
|
+
console.log(" 1) Install as a service (starts now and on every reboot)");
|
|
101
|
+
console.log(" 2) Run once now (foreground)");
|
|
102
|
+
console.log(" 3) Save config only");
|
|
103
|
+
const choice = (await io.prompt("Choose [1/2/3]: ")).trim() || "1";
|
|
104
|
+
|
|
105
|
+
saveConfig(cfg);
|
|
106
|
+
console.log(`\nSaved ${configPath}`);
|
|
107
|
+
|
|
108
|
+
io.close();
|
|
109
|
+
|
|
110
|
+
if (choice === "1") {
|
|
111
|
+
const p = platform();
|
|
112
|
+
if (!p) {
|
|
113
|
+
console.log("Service install is only supported on Linux and macOS.");
|
|
114
|
+
console.log("Run it yourself with: wiki-viewer service run");
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
requirePersistentInstall();
|
|
118
|
+
const nodeWarning = versionManagedNodeWarning(resolveServiceNode());
|
|
119
|
+
if (nodeWarning) console.log(`\n⚠️ ${nodeWarning}\n`);
|
|
120
|
+
const nodeBin = resolveServiceNode();
|
|
121
|
+
const scriptPath = resolveServiceScript();
|
|
122
|
+
if (p === "linux") installSystemd(nodeBin, scriptPath);
|
|
123
|
+
else installLaunchd(nodeBin, scriptPath);
|
|
124
|
+
} else if (choice === "2") {
|
|
125
|
+
start(resolveRunOptions([]));
|
|
126
|
+
} else {
|
|
127
|
+
console.log("\nStart it any time with:");
|
|
128
|
+
console.log(" wiki-viewer service install # persistent service");
|
|
129
|
+
console.log(" wiki-viewer service run # run from this config");
|
|
130
|
+
}
|
|
131
|
+
} finally {
|
|
132
|
+
io.close();
|
|
133
|
+
}
|
|
134
|
+
}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared SSH target parsing and sshfs argv construction.
|
|
3
|
+
*
|
|
4
|
+
* This module is consumed by both the Node/JS CLI (`bin/wiki-viewer.js`) and
|
|
5
|
+
* the TypeScript server (`src/lib/sshfs.ts`) via direct import, so the logic
|
|
6
|
+
* stays in one place and cannot drift. It exports defensive validators only —
|
|
7
|
+
* it never calls `process.exit`.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { existsSync } from "node:fs";
|
|
11
|
+
|
|
12
|
+
// Defense-in-depth: reject these even though callers never pass fields through
|
|
13
|
+
// a shell.
|
|
14
|
+
export const FORBIDDEN_SSH_CHARS = new RegExp("[;|&$`<>(){}\\n\\r\\0]");
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* @typedef {Object} ParsedSshTarget
|
|
18
|
+
* @property {string} [user]
|
|
19
|
+
* @property {string} host
|
|
20
|
+
* @property {string} remotePath
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* @typedef {"agent" | "keyfile" | "password"} SshAuthMethod
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* @typedef {Object} BuildSshfsOptions
|
|
29
|
+
* @property {ParsedSshTarget} target
|
|
30
|
+
* @property {string} mountpoint
|
|
31
|
+
* @property {number | string} [port]
|
|
32
|
+
* @property {SshAuthMethod} [authMethod]
|
|
33
|
+
* @property {string} [keyPath]
|
|
34
|
+
* @property {string} [password]
|
|
35
|
+
* @property {boolean} [readOnly]
|
|
36
|
+
* @property {string[]} [extraOptions]
|
|
37
|
+
*/
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Heuristic used by the CLI to decide whether a positional argument should be
|
|
41
|
+
* treated as a directory or as an SSH target.
|
|
42
|
+
*
|
|
43
|
+
* @param {string} s
|
|
44
|
+
* @returns {boolean}
|
|
45
|
+
*/
|
|
46
|
+
export function looksLikeSshTarget(s) {
|
|
47
|
+
if (!s || FORBIDDEN_SSH_CHARS.test(s)) return false;
|
|
48
|
+
// [user@]host:/abs/path — host has no slash, remote path is absolute. An
|
|
49
|
+
// existing local path (e.g. a real dir literally named like this) wins.
|
|
50
|
+
return /^([\w.-]+@)?[\w.-]+:\/.+/.test(s) && !existsSync(s);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Parse an SSH target of the form `[user@]host:/abs/path`.
|
|
55
|
+
*
|
|
56
|
+
* @param {string} target
|
|
57
|
+
* @returns {ParsedSshTarget | null}
|
|
58
|
+
*/
|
|
59
|
+
export function parseSshTarget(target) {
|
|
60
|
+
if (!target || FORBIDDEN_SSH_CHARS.test(target)) return null;
|
|
61
|
+
const trimmed = target.trim();
|
|
62
|
+
|
|
63
|
+
const colon = trimmed.indexOf(":");
|
|
64
|
+
if (colon <= 0) return null;
|
|
65
|
+
const hostPart = trimmed.slice(0, colon);
|
|
66
|
+
const remotePath = trimmed.slice(colon + 1);
|
|
67
|
+
|
|
68
|
+
if (!remotePath.startsWith("/")) return null;
|
|
69
|
+
if (remotePath.includes("..")) return null;
|
|
70
|
+
|
|
71
|
+
let user;
|
|
72
|
+
let host = hostPart;
|
|
73
|
+
const at = hostPart.indexOf("@");
|
|
74
|
+
if (at >= 0) {
|
|
75
|
+
user = hostPart.slice(0, at);
|
|
76
|
+
host = hostPart.slice(at + 1);
|
|
77
|
+
if (!user) return null;
|
|
78
|
+
}
|
|
79
|
+
if (!host) return null;
|
|
80
|
+
if (!/^[a-zA-Z0-9.\-]+$/.test(host)) return null;
|
|
81
|
+
if (user && !/^[a-zA-Z0-9._\-]+$/.test(user)) return null;
|
|
82
|
+
|
|
83
|
+
return { user, host, remotePath };
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Validate an explicit private key path.
|
|
88
|
+
*
|
|
89
|
+
* @param {string} keyPath
|
|
90
|
+
* @returns {boolean}
|
|
91
|
+
*/
|
|
92
|
+
export function isValidKeyPath(keyPath) {
|
|
93
|
+
if (!keyPath || FORBIDDEN_SSH_CHARS.test(keyPath)) return false;
|
|
94
|
+
if (keyPath.includes("..")) return false;
|
|
95
|
+
return keyPath.startsWith("/") || keyPath.startsWith("~/");
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Build the sshfs argv (excluding the binary name).
|
|
100
|
+
*
|
|
101
|
+
* @param {BuildSshfsOptions} opts
|
|
102
|
+
* @returns {string[]}
|
|
103
|
+
*/
|
|
104
|
+
export function buildSshfsArgs(opts) {
|
|
105
|
+
const { target, mountpoint, port } = opts;
|
|
106
|
+
const userPart = target.user ? `${target.user}@` : "";
|
|
107
|
+
const args = [`${userPart}${target.host}:${target.remotePath}`, mountpoint];
|
|
108
|
+
|
|
109
|
+
if (
|
|
110
|
+
port &&
|
|
111
|
+
Number.isInteger(Number(port)) &&
|
|
112
|
+
Number(port) > 0 &&
|
|
113
|
+
Number(port) < 65536
|
|
114
|
+
) {
|
|
115
|
+
args.push("-p", String(port));
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// Infer authentication method if the caller did not provide an explicit one.
|
|
119
|
+
/** @type {SshAuthMethod} */
|
|
120
|
+
let authMethod = opts.authMethod ?? "agent";
|
|
121
|
+
if (!opts.authMethod) {
|
|
122
|
+
if (opts.password != null) authMethod = "password";
|
|
123
|
+
else if (opts.keyPath) authMethod = "keyfile";
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
const o = [
|
|
127
|
+
"reconnect",
|
|
128
|
+
"ServerAliveInterval=15",
|
|
129
|
+
"ServerAliveCountMax=3",
|
|
130
|
+
"compression=yes",
|
|
131
|
+
"cache=yes",
|
|
132
|
+
"kernel_cache",
|
|
133
|
+
"StrictHostKeyChecking=accept-new",
|
|
134
|
+
"BatchMode=yes",
|
|
135
|
+
];
|
|
136
|
+
|
|
137
|
+
if (opts.readOnly) o.push("ro");
|
|
138
|
+
if (authMethod === "keyfile" && opts.keyPath) {
|
|
139
|
+
o.push(`IdentityFile=${opts.keyPath}`);
|
|
140
|
+
o.push("IdentitiesOnly=yes");
|
|
141
|
+
}
|
|
142
|
+
if (authMethod === "password") {
|
|
143
|
+
const idx = o.indexOf("BatchMode=yes");
|
|
144
|
+
if (idx >= 0) o.splice(idx, 1);
|
|
145
|
+
o.push("password_stdin");
|
|
146
|
+
o.push("PreferredAuthentications=password,keyboard-interactive");
|
|
147
|
+
o.push("PubkeyAuthentication=no");
|
|
148
|
+
o.push("NumberOfPasswordPrompts=1");
|
|
149
|
+
}
|
|
150
|
+
if (opts.extraOptions) o.push(...opts.extraOptions);
|
|
151
|
+
|
|
152
|
+
args.push("-o", o.join(","));
|
|
153
|
+
return args;
|
|
154
|
+
}
|