@jant/core 0.10.0 → 0.11.0
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/bin/commands/db/execute-file.js +1 -1
- package/bin/commands/db/export.js +1 -1
- package/bin/commands/migrate.js +4 -4
- package/bin/commands/posts/rebuild-html.js +1 -1
- package/bin/commands/reset-password.js +1 -1
- package/bin/commands/search/reindex.js +1 -1
- package/bin/commands/setup.js +4 -2
- package/bin/commands/site/export.js +3 -0
- package/bin/commands/site/import.js +178 -91
- package/bin/commands/site/pull-media.js +3 -2
- package/bin/commands/site/snapshot/export.js +3 -1
- package/bin/commands/site/snapshot/import.js +3 -2
- package/bin/commands/start.js +44 -0
- package/bin/commands/telegram/register-webhooks.js +1 -1
- package/bin/commands/uploads/cleanup.js +48 -9
- package/bin/jant.js +39 -4
- package/bin/lib/import-sources.js +151 -0
- package/bin/lib/node-env.js +14 -9
- package/bin/lib/runtime-target.js +1 -1
- package/bin/lib/site-pull-media.js +56 -4
- package/bin/lib/site-snapshot.js +39 -2
- package/bin/lib/sql-export.js +66 -10
- package/dist/{app-DIVtyB4m.js → app-jQI4OPRe.js} +5055 -4448
- package/dist/client/.vite/manifest.json +38 -38
- package/dist/client/_assets/chunks/{create-editor-B-m7X7S5.js → create-editor-5Y49x7h5.js} +2 -2
- package/dist/client/_assets/chunks/{footnote-rail-CmeoVtnU.js → footnote-rail-BJwswtVQ.js} +1 -1
- package/dist/client/_assets/chunks/{settings-paths-C-ZZBTau.js → settings-paths-h6RjIe3C.js} +2 -2
- package/dist/client/_assets/chunks/{slug-format-BcIsNKz-.js → slug-format-Dsi0e9Xn.js} +1 -1
- package/dist/client/_assets/chunks/{slugify-373citbs.js → slugify-DlHLyUHS.js} +1 -1
- package/dist/client/_assets/chunks/sortable-list-DYMcJrlS.js +2 -0
- package/dist/client/_assets/chunks/unsafe-svg-DxrzM_Gb.js +2 -0
- package/dist/client/_assets/client-52vQhZAv.js +296 -0
- package/dist/client/_assets/client-BaqmpPQ-.css +2 -0
- package/dist/client/_assets/{client-auth-BpkkKTsV.js → client-auth-BDcCR6u1.js} +2 -2
- package/dist/client/_assets/client-author-CGVvrNZ8.css +2 -0
- package/dist/client/_assets/{client-compose-C-DXzcFR.js → client-compose-CzEwT5qX.js} +4 -4
- package/dist/client/_assets/{client-manage-BfT7ht4M.js → client-manage-CF7x21L4.js} +37 -37
- package/dist/client/_assets/{client-settings-CGR_nZ78.js → client-settings-DIM44Zqh.js} +2 -2
- package/dist/{url-CKlGzvdN.js → constants-DEgyqWDl.js} +340 -1
- package/dist/index.d.ts +44 -0
- package/dist/index.js +33 -1
- package/dist/node.js +57 -13
- package/package.json +13 -18
- package/src/__tests__/api-docs.test.ts +168 -1
- package/src/__tests__/bin/import-sources.test.ts +85 -0
- package/src/__tests__/bin/uploads-cleanup.test.ts +66 -26
- package/src/__tests__/cli-commands.test.ts +40 -0
- package/src/__tests__/config-docs.test.ts +119 -16
- package/src/__tests__/custom-url-redirects.test.ts +108 -0
- package/src/__tests__/export-collection-custom-urls.test.ts +69 -0
- package/src/__tests__/export-docs.test.ts +113 -41
- package/src/__tests__/export-feed-ids.test.ts +1 -0
- package/src/__tests__/export-format-version.test.ts +88 -0
- package/src/__tests__/export-hugo-build.test.ts +139 -4
- package/src/__tests__/export-import-roundtrip.test.ts +2 -1
- package/src/__tests__/export-service.test.ts +42 -13
- package/src/__tests__/export-smart-collection.test.ts +1 -1
- package/src/__tests__/feed-docs.test.ts +287 -21
- package/src/__tests__/feed-reply-addresses.test.ts +100 -0
- package/src/__tests__/feeds-disabled.test.ts +98 -0
- package/src/__tests__/fixtures/export-format/1.json +76 -0
- package/src/__tests__/fixtures/export-format/2.json +80 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/README.md +130 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/2thjq/_index.md +25 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/2u5e5/_index.md +35 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/41q27/0x4nv/index.md +18 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/41q27/_index.md +44 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/41q27/faqyt/index.md +30 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/41q27/the-potting-mix-guide-i-keep-rereading/index.md +20 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/5kayp/_index.md +23 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/5ynfs/_index.md +31 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/5ynfs/hu597/index.md +21 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/_index.md +5 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/a-night-heron-field-guide-for-my-walk-folder/_index.md +31 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/a-quiet-saturday-after-a-busy-week/_index.md +36 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/archive/_index.md +8 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/are-na-is-the-only-bookmark-pile-i-still-revisit/_index.md +30 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/bought-too-many-lemons-again/_index.md +37 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/city-walks/_index.md +12 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/cleanshot-for-screenshots-ocr-and-screen-recording-on-the-mac/_index.md +33 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/cleanshotmac-shang-de-jie-tu-ocr-lu-ping-gong-ju/_index.md +32 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/co344/_index.md +25 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/collections/_index.md +5 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/current-tea-rotation/_index.md +34 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/derek-sivers-still-writes-the-kind-of-internet-i-want-more-of/_index.md +30 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/desk-but-better/_index.md +25 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/e0kcg/_index.md +22 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/egi3c/_index.md +24 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/evf9j/_index.md +152 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/featured/_index.md +8 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/from-basho/_index.md +25 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/from-epictetus/_index.md +25 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/from-marcus-aurelius/_index.md +25 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/from-seneca/_index.md +26 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/from-thoreau/_index.md +25 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/gkbvv/2cl6d/index.md +18 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/gkbvv/3zqv7/index.md +30 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/gkbvv/5oxsv/index.md +18 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/gkbvv/_index.md +39 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/gwob9/_index.md +25 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/home-cooking/_index.md +12 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/hz729/_index.md +24 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/inaturalist-ai-zi-ran-she-qu/_index.md +44 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/j4v0q/_index.md +35 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/k278t/_index.md +25 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/k4eee/_index.md +22 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/k5vh8/_index.md +32 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/k5vh8/a-reading-log-idea-i-might-steal/index.md +20 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/k5vh8/a83qu/index.md +18 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/k5vh8/from-seneca-5hibo/index.md +21 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/kan-qi-lai-bi-jiao-ku-de-gong-si-men/_index.md +41 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/l2m7y/_index.md +29 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/lan-ya-yao-kong-qi-chuang-shang-yue-du-de-fan-ye-shen-qi/_index.md +57 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/mynoise-for-rainy-afternoons/_index.md +30 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/n09le/_index.md +23 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/ni-fu-jin-de-wei-ji-bai-ke-tiao-mu/_index.md +42 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/nts-archives-are-good-cleaning-music/_index.md +30 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/qgfcu/_index.md +32 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/qgfcu/c91j0/index.md +18 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/qgfcu/qyucy/index.md +18 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/qgfcu/wsgck/index.md +18 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/rain-makes-my-neighborhood-look-better/_index.md +46 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/reading-notes/_index.md +12 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/s4r3e/_index.md +25 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/serious-eats-on-tomato-and-egg-soup/_index.md +30 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/te812/_index.md +44 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/te812/cxiu6/index.md +18 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/te812/t77ms/index.md +18 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/te812/the-soup-trick-i-always-forget/index.md +20 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/telk3/_index.md +30 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/telk3/from-thoreau-pawt2/index.md +21 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/the-five-minute-reset-is-still-the-best-habit-i-have/_index.md +36 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/the-hallway-light-took-12-minutes-and-3-months/_index.md +32 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/the-recurse-center-manual-is-weirdly-calming/_index.md +30 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/tiny-projects/_index.md +12 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/tong-wang-xing-fu-zhi-lu/_index.md +68 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/tou-ma-yan-jiang-ju-le-bu-chu-ti-yan/_index.md +62 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/useful-links/_index.md +12 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/weekend-notes/_index.md +12 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/what-i-actually-use-my-notebook-for/_index.md +52 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/data/jant.toml +124 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/hugo.toml +45 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/_redirects +25 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/40bc6cd1f12e-med_01kn8jtq3penf98tfq4gzmh9g9.png +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01kn8jtx8qenf98tm9ahxr48sw.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01kn8jv0jdenf98tp6qr9zgjjc.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01kn8jv452enf98trbkwrvhvgd.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01kn8jvb16enf98txp7p0pf5ge.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01kn8jve5nenf98tzap11gpxzr.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01kn8jvq58enf98v538w5vsqp4.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01kn8jvsaeenf98v6ct4gjzppc.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01kn8jw26cenf98vc7k0ppz5k8.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m313q1hme4e8cmby77dn66yy.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m313q2w7e4e8cmc20036yh66.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m313q7d2e4e8cmdeqjmyafby.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m313q887e4e8cmdjssych7yh.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167jx2f6ct88pkz45j3ycp-poster.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167jx2f6ct88pkz45j3ycp.mp4 +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167mbdf6ct88pr4ga1b9kf-poster.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167mbdf6ct88pr4ga1b9kf.mp4 +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167nsvf6ct88q1anhz4svb-poster.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167nsvf6ct88q1anhz4svb.mp4 +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167qaxf6ct88qfndwzxx83-poster.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167qaxf6ct88qfndwzxx83.mp4 +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167sm0f6ct88qw5brtsgcw.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167tf8f6ct88r169s51j49.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167vaaf6ct88rbx5ztenwb.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167w51f6ct88rp19pybkw1.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167x0nf6ct88rzajb84tw3.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167xxbf6ct88s5t2300bjk.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167yq5f6ct88s9pjwt5fxg.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167zg4f6ct88sge8jp28ja.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/themes/jant/static/apple-touch-icon.png +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/themes/jant/static/custom.css +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/themes/jant/static/favicon.ico +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/wrangler.jsonc +24 -0
- package/src/__tests__/fixtures/releases/0.10.0/snapshot/db.sql +322 -0
- package/src/__tests__/fixtures/releases/0.10.0/snapshot/meta.json +11 -0
- package/src/__tests__/helpers/app.ts +6 -1
- package/src/__tests__/helpers/export-fixtures.ts +1 -0
- package/src/__tests__/import-refused-aliases.test.ts +98 -0
- package/src/__tests__/import-site-command.test.ts +73 -8
- package/src/__tests__/public-types.test.ts +64 -0
- package/src/__tests__/release-fixtures.test.ts +79 -24
- package/src/__tests__/release-version.test.ts +84 -0
- package/src/__tests__/site-pull-media.test.ts +48 -0
- package/src/__tests__/snapshot-tables.test.ts +37 -0
- package/src/__tests__/sql-export.test.ts +21 -1
- package/src/__tests__/stored-file-headers.test.ts +94 -0
- package/src/__tests__/template-deploy-workflow.test.ts +101 -0
- package/src/__tests__/theme-docs.test.ts +113 -24
- package/src/__tests__/toolchain-versions.test.ts +54 -0
- package/src/__tests__/trailing-slash-redirect.test.ts +61 -0
- package/src/__tests__/vite-config-graph.test.ts +98 -0
- package/src/app.tsx +89 -66
- package/src/client/__tests__/compose-bridge-image-upload.test.ts +1 -0
- package/src/client/__tests__/compose-bridge.test.ts +87 -0
- package/src/client/__tests__/compose-shortcuts.test.ts +4 -4
- package/src/client/__tests__/footnote-rail.test.ts +1 -1
- package/src/client/__tests__/lazy-entries.test.ts +1 -1
- package/src/client/__tests__/media-scroll-hint.test.ts +2 -2
- package/src/client/avatar-upload.ts +10 -10
- package/src/client/components/__tests__/jant-compose-dialog.test.ts +295 -4
- package/src/client/components/__tests__/jant-compose-editor.test.ts +34 -0
- package/src/client/components/__tests__/jant-settings-general.test.ts +0 -32
- package/src/client/components/compose-types.ts +14 -0
- package/src/client/components/jant-compose-dialog.ts +96 -41
- package/src/client/components/jant-compose-editor.ts +21 -4
- package/src/client/components/jant-config-editor.ts +4 -6
- package/src/client/components/jant-media-lightbox.ts +4 -4
- package/src/client/components/jant-settings-general.ts +0 -4
- package/src/client/components/nav-manager-types.ts +6 -5
- package/src/client/compose-bridge.ts +15 -4
- package/src/client/compose-launch.ts +4 -6
- package/src/client/compose-shortcuts.ts +1 -1
- package/src/client/footnote-rail.ts +1 -1
- package/src/client/lazy-entries.ts +1 -1
- package/src/client/media-scroll-hint.ts +2 -2
- package/src/client/tiptap/__tests__/markdown-clipboard.test.ts +55 -0
- package/src/client/tiptap/markdown-clipboard.ts +50 -2
- package/src/client/upload-session.ts +7 -6
- package/src/db/__tests__/backfill-external-redirects.test.ts +59 -0
- package/src/db/__tests__/backfill-featured-discover.test.ts +56 -0
- package/src/db/backfills/0007_restore_external_redirect_scheme.sql +20 -0
- package/src/db/backfills/0008_turn_off_featured_only_discover.sql +11 -0
- package/src/i18n/locales/public/en.po +46 -48
- package/src/i18n/locales/public/en.ts +1 -1
- package/src/i18n/locales/public/zh-Hans.po +45 -46
- package/src/i18n/locales/public/zh-Hans.ts +1 -1
- package/src/i18n/locales/public/zh-Hant.po +45 -46
- package/src/i18n/locales/public/zh-Hant.ts +1 -1
- package/src/i18n/locales/settings/en.po +15 -29
- package/src/i18n/locales/settings/en.ts +1 -1
- package/src/i18n/locales/settings/zh-Hans.po +15 -29
- package/src/i18n/locales/settings/zh-Hans.ts +1 -1
- package/src/i18n/locales/settings/zh-Hant.po +15 -29
- package/src/i18n/locales/settings/zh-Hant.ts +1 -1
- package/src/index.ts +43 -2
- package/src/lib/__tests__/api-settings.test.ts +3 -3
- package/src/lib/__tests__/constants.test.ts +10 -0
- package/src/lib/__tests__/discover.test.ts +8 -9
- package/src/lib/__tests__/env-values.test.ts +125 -0
- package/src/lib/__tests__/feed-path.test.ts +29 -0
- package/src/lib/__tests__/feed.test.ts +50 -22
- package/src/lib/__tests__/filter-dimensions.test.ts +22 -8
- package/src/lib/__tests__/post-list-cursor.test.ts +0 -10
- package/src/lib/__tests__/rate-limit.test.ts +22 -7
- package/src/lib/__tests__/resolve-config.test.ts +5 -3
- package/src/lib/__tests__/schemas.test.ts +72 -23
- package/src/lib/__tests__/slugify.test.ts +9 -0
- package/src/lib/__tests__/startup-config.test.ts +12 -0
- package/src/lib/__tests__/storage-s3.test.ts +214 -0
- package/src/lib/__tests__/theme.test.ts +20 -1
- package/src/lib/__tests__/time.test.ts +56 -0
- package/src/lib/__tests__/timeline.test.ts +46 -0
- package/src/lib/__tests__/url-fetch.test.ts +65 -1
- package/src/lib/__tests__/url.test.ts +60 -1
- package/src/lib/api-nav-items.ts +16 -20
- package/src/lib/api-post-input.ts +34 -1
- package/src/lib/api-posts.ts +125 -23
- package/src/lib/api-public-posts.ts +28 -37
- package/src/lib/api-search.ts +49 -2
- package/src/lib/api-settings.ts +159 -54
- package/src/lib/api-threads.ts +34 -11
- package/src/lib/constants.ts +6 -0
- package/src/lib/discover.ts +7 -23
- package/src/lib/env-values.ts +140 -0
- package/src/lib/env.ts +203 -12
- package/src/lib/feed-path.ts +8 -2
- package/src/lib/feed-policy.ts +110 -7
- package/src/lib/feed.ts +69 -25
- package/src/lib/filter-dimensions.ts +17 -10
- package/src/lib/github-sync-site-config.ts +1 -0
- package/src/lib/hugo-markdown.ts +5 -6
- package/src/lib/navigation.ts +4 -1
- package/src/lib/post-list-cursor.ts +33 -29
- package/src/lib/public-storage.ts +43 -0
- package/src/lib/rate-limit.ts +31 -16
- package/src/lib/render.tsx +5 -0
- package/src/lib/resolve-config.ts +16 -19
- package/src/lib/schemas.ts +248 -180
- package/src/lib/slugify.ts +6 -1
- package/src/lib/sse.ts +1 -1
- package/src/lib/startup-config.ts +20 -1
- package/src/lib/theme.ts +8 -5
- package/src/lib/thread-fold.ts +6 -0
- package/src/lib/thread-query.ts +19 -24
- package/src/lib/time.ts +137 -17
- package/src/lib/timeline.ts +56 -13
- package/src/lib/url-fetch.ts +141 -40
- package/src/lib/url.ts +86 -1
- package/src/middleware/__tests__/auth.test.ts +27 -0
- package/src/middleware/__tests__/cors.test.ts +54 -0
- package/src/middleware/__tests__/cross-origin.test.ts +149 -0
- package/src/middleware/__tests__/public-content-access.test.ts +2 -42
- package/src/middleware/auth.ts +34 -3
- package/src/middleware/cors.ts +4 -4
- package/src/middleware/cross-origin.ts +124 -0
- package/src/middleware/error-handler.ts +7 -0
- package/src/middleware/public-content-access.ts +3 -26
- package/src/middleware/secure-headers.ts +8 -2
- package/src/node/__tests__/cli-migrate.test.ts +2 -2
- package/src/node/__tests__/cli-runtime-target.test.ts +13 -2
- package/src/node/__tests__/cli-site-snapshot.test.ts +57 -0
- package/src/node/__tests__/cli-snapshot-meta.test.ts +11 -1
- package/src/node/__tests__/cli-sql-export.test.ts +25 -1
- package/src/node/__tests__/cli-start.test.ts +66 -0
- package/src/node/__tests__/request-handler.test.ts +37 -0
- package/src/node/__tests__/runtime.test.ts +56 -1
- package/src/node/request-handler.ts +58 -5
- package/src/node/runtime.ts +37 -11
- package/src/preset.css +3 -3
- package/src/routes/__tests__/compose.test.ts +84 -0
- package/src/routes/api/__tests__/collections.test.ts +68 -0
- package/src/routes/api/__tests__/mcp.test.ts +164 -9
- package/src/routes/api/__tests__/media.test.ts +9 -1
- package/src/routes/api/__tests__/nav-items.test.ts +27 -1
- package/src/routes/api/__tests__/posts.test.ts +269 -78
- package/src/routes/api/__tests__/search.test.ts +17 -4
- package/src/routes/api/__tests__/settings.test.ts +119 -85
- package/src/routes/api/__tests__/telegram.test.ts +11 -6
- package/src/routes/api/__tests__/threads.test.ts +11 -0
- package/src/routes/api/__tests__/upload-response.test.ts +48 -0
- package/src/routes/api/__tests__/uploads.test.ts +35 -2
- package/src/routes/api/collections.ts +3 -3
- package/src/routes/api/custom-urls.ts +2 -1
- package/src/routes/api/export.ts +1 -0
- package/src/routes/api/internal/__tests__/post-body-html.test.ts +19 -0
- package/src/routes/api/internal/__tests__/uploads.test.ts +2 -0
- package/src/routes/api/internal/sites.ts +16 -4
- package/src/routes/api/mcp.ts +1 -0
- package/src/routes/api/media.ts +7 -8
- package/src/routes/api/nav-items.ts +2 -1
- package/src/routes/api/posts.ts +18 -24
- package/src/routes/api/public/__tests__/posts.test.ts +15 -0
- package/src/routes/api/public/__tests__/threads-collections.test.ts +12 -45
- package/src/routes/api/public/__tests__/threads.test.ts +41 -9
- package/src/routes/api/public/posts.ts +2 -2
- package/src/routes/api/public/threads.ts +16 -26
- package/src/routes/api/search.ts +7 -41
- package/src/routes/api/settings.ts +32 -28
- package/src/routes/api/smart-collections.ts +6 -1
- package/src/routes/api/threads.ts +25 -26
- package/src/routes/api/upload.ts +6 -21
- package/src/routes/api/uploads.ts +14 -20
- package/src/routes/auth/__tests__/dev.test.ts +16 -13
- package/src/routes/auth/__tests__/hosted-sso.test.ts +51 -0
- package/src/routes/auth/__tests__/setup-auth.test.ts +2 -0
- package/src/routes/auth/__tests__/setup-discover.test.ts +2 -0
- package/src/routes/auth/__tests__/setup-flow.test.ts +32 -0
- package/src/routes/auth/__tests__/setup-rate-limit.test.ts +72 -0
- package/src/routes/auth/__tests__/setup-steps.test.ts +2 -0
- package/src/routes/auth/__tests__/signin.test.ts +167 -2
- package/src/routes/auth/dev.ts +4 -6
- package/src/routes/auth/hosted-sso.ts +9 -6
- package/src/routes/auth/setup.tsx +35 -5
- package/src/routes/auth/signin.tsx +96 -1
- package/src/routes/compose.tsx +47 -47
- package/src/routes/dash/__tests__/settings-avatar.test.ts +59 -4
- package/src/routes/dash/__tests__/settings-demo-locks.test.ts +147 -0
- package/src/routes/dash/custom-urls.tsx +2 -0
- package/src/routes/dash/settings.tsx +79 -32
- package/src/routes/feed/__tests__/feed.test.ts +93 -3
- package/src/routes/feed/__tests__/sitemap.test.ts +42 -0
- package/src/routes/feed/feed.ts +128 -175
- package/src/routes/feed/sitemap.ts +9 -7
- package/src/routes/pages/__tests__/archive-years.test.ts +45 -0
- package/src/routes/pages/__tests__/collection-routing.test.ts +40 -0
- package/src/routes/pages/__tests__/collections.test.ts +3 -0
- package/src/routes/pages/__tests__/language-routing.test.ts +31 -0
- package/src/routes/pages/__tests__/post-page-round-trips.test.ts +34 -2
- package/src/routes/pages/__tests__/search.test.ts +5 -2
- package/src/routes/pages/__tests__/thread-gap.test.ts +207 -0
- package/src/routes/pages/archive.tsx +33 -94
- package/src/routes/pages/brand.tsx +1 -0
- package/src/routes/pages/collection.tsx +13 -84
- package/src/routes/pages/collections.tsx +2 -0
- package/src/routes/pages/featured.tsx +7 -2
- package/src/routes/pages/home.tsx +1 -0
- package/src/routes/pages/latest.tsx +6 -2
- package/src/routes/pages/new.tsx +1 -0
- package/src/routes/pages/page.tsx +73 -47
- package/src/routes/pages/search.tsx +5 -3
- package/src/routes/pages/smart-collection.tsx +11 -70
- package/src/routes/pages/subscribe.tsx +1 -0
- package/src/routes/pages/theme-sample.tsx +1 -0
- package/src/runtime/__tests__/readiness.test.ts +16 -0
- package/src/runtime/cloudflare.ts +2 -3
- package/src/runtime/index.ts +3 -1
- package/src/runtime/node.ts +3 -5
- package/src/runtime/readiness.ts +5 -0
- package/src/services/__tests__/auth.test.ts +115 -0
- package/src/services/__tests__/collection.test.ts +9 -0
- package/src/services/__tests__/github-sync-webhook.test.ts +78 -0
- package/src/services/__tests__/hosted-handoff.test.ts +208 -1
- package/src/services/__tests__/media.test.ts +47 -27
- package/src/services/__tests__/navigation.test.ts +67 -15
- package/src/services/__tests__/post.test.ts +103 -56
- package/src/services/__tests__/search.test.ts +38 -0
- package/src/services/__tests__/settings.test.ts +2 -14
- package/src/services/__tests__/smart-collection.test.ts +2 -2
- package/src/services/__tests__/telegram-ingest.test.ts +113 -0
- package/src/services/__tests__/thread.test.ts +26 -11
- package/src/services/auth.ts +36 -4
- package/src/services/collection.ts +46 -5
- package/src/services/custom-url.ts +11 -4
- package/src/services/export-theme/assets/client-site.css +1 -1
- package/src/services/export-theme/assets/client-site.js +2 -2
- package/src/services/export-theme/layouts/_default/baseof.html +1 -1
- package/src/services/export-theme/layouts/collection/single.html +1 -1
- package/src/services/export-theme/layouts/partials/featured-thread.html +8 -1
- package/src/services/export-theme/layouts/partials/head.html +1 -1
- package/src/services/export-theme/layouts/partials/media-gallery.html +6 -3
- package/src/services/export-theme/layouts/smart_collection/list.html +1 -1
- package/src/services/export-theme/styles/main.css +3 -3
- package/src/services/export.ts +68 -19
- package/src/services/github-sync.ts +10 -10
- package/src/services/hosted-handoff.ts +106 -6
- package/src/services/index.ts +3 -1
- package/src/services/language.ts +33 -0
- package/src/services/mcp.ts +176 -438
- package/src/services/media.ts +69 -21
- package/src/services/navigation.ts +19 -4
- package/src/services/path.ts +45 -3
- package/src/services/post.ts +329 -214
- package/src/services/search.ts +22 -3
- package/src/services/settings.ts +36 -3
- package/src/services/site-admin.ts +1 -0
- package/src/services/smart-collection.ts +10 -3
- package/src/services/telegram.ts +23 -6
- package/src/services/thread.ts +11 -3
- package/src/services/upload-session.ts +14 -15
- package/src/styles/components.css +2 -2
- package/src/styles/site-media.css +2 -2
- package/src/styles/tokens.css +19 -22
- package/src/styles/ui-author.css +73 -94
- package/src/styles/ui.css +62 -62
- package/src/types/app-context.ts +5 -1
- package/src/types/bindings.ts +11 -0
- package/src/types/config.ts +4 -4
- package/src/types/constants.ts +20 -0
- package/src/types/props.ts +34 -8
- package/src/types/views.ts +28 -13
- package/src/ui/color-themes.ts +6 -5
- package/src/ui/dash/settings/GeneralContent.tsx +0 -22
- package/src/ui/dash/settings/__tests__/GeneralContent.test.tsx +0 -21
- package/src/ui/feed/CuratedThreadPreview.tsx +7 -2
- package/src/ui/feed/LinkCard.tsx +1 -2
- package/src/ui/feed/NoteCard.tsx +1 -2
- package/src/ui/feed/QuoteCard.tsx +2 -2
- package/src/ui/feed/ThreadPreview.tsx +6 -6
- package/src/ui/feed/TimelineFeed.tsx +1 -7
- package/src/ui/feed/__tests__/thread-preview.test.ts +123 -10
- package/src/ui/feed/__tests__/timeline-cards.test.ts +18 -1
- package/src/ui/layouts/BaseLayout.tsx +5 -0
- package/src/ui/pages/ArchivePage.tsx +1 -1
- package/src/ui/pages/BrandPage.tsx +1 -1
- package/src/ui/pages/CollectionPage.tsx +0 -1
- package/src/ui/pages/CollectionsPage.tsx +2 -2
- package/src/ui/pages/ComposePage.tsx +1 -1
- package/src/ui/pages/FeaturedPage.tsx +1 -1
- package/src/ui/pages/HomePage.tsx +1 -1
- package/src/ui/pages/PostPage.tsx +1 -1
- package/src/ui/pages/SearchPage.tsx +1 -1
- package/src/ui/pages/SmartCollectionPage.tsx +2 -3
- package/src/ui/pages/SubscribePage.tsx +1 -1
- package/src/ui/pages/ThemeSamplePage.tsx +1 -1
- package/src/ui/shared/MediaGallery.tsx +1 -1
- package/src/vendor/datastar.js +9 -1956
- package/src/vendor/datastar.js.map +4 -4
- package/dist/client/_assets/chunks/sortable-list-BJyd-LXE.js +0 -2
- package/dist/client/_assets/chunks/unsafe-svg-DU_DNMy5.js +0 -2
- package/dist/client/_assets/client-D4AT9Iqr.js +0 -295
- package/dist/client/_assets/client-DRuw7XCt.css +0 -2
- package/dist/client/_assets/client-author-DQ8R-8KR.css +0 -2
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Public machine-readable content access policies.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* This guard runs after configuration has been resolved. It keeps public HTML
|
|
5
|
+
* rendering independent from the optional JSON API. Feeds check their own
|
|
6
|
+
* switch where they are rendered; see `feedsPublished`.
|
|
6
7
|
*/
|
|
7
8
|
|
|
8
9
|
import type { MiddlewareHandler } from "hono";
|
|
9
10
|
import type { Bindings } from "../types.js";
|
|
10
11
|
import type { AppVariables } from "../types/app-context.js";
|
|
11
|
-
import { isRssFeedPath } from "../lib/feed-path.js";
|
|
12
12
|
|
|
13
13
|
type Env = { Bindings: Bindings; Variables: AppVariables };
|
|
14
14
|
|
|
@@ -37,26 +37,3 @@ export function requirePublicApiEnabled(): MiddlewareHandler<Env> {
|
|
|
37
37
|
return c.notFound();
|
|
38
38
|
};
|
|
39
39
|
}
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Return 404 for Atom endpoints when feed publishing is disabled.
|
|
43
|
-
*
|
|
44
|
-
* @returns Hono middleware that leaves non-feed requests unchanged
|
|
45
|
-
* @example
|
|
46
|
-
* ```ts
|
|
47
|
-
* app.use("*", requireRssFeedsEnabled());
|
|
48
|
-
* ```
|
|
49
|
-
*/
|
|
50
|
-
export function requireRssFeedsEnabled(): MiddlewareHandler<Env> {
|
|
51
|
-
return async (c, next) => {
|
|
52
|
-
if (
|
|
53
|
-
(c.req.method !== "GET" && c.req.method !== "HEAD") ||
|
|
54
|
-
c.var.appConfig.rssFeedsEnabled ||
|
|
55
|
-
!isRssFeedPath(new URL(c.req.url).pathname)
|
|
56
|
-
) {
|
|
57
|
-
return next();
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
return c.notFound();
|
|
61
|
-
};
|
|
62
|
-
}
|
|
@@ -15,6 +15,7 @@ import type { Bindings } from "../types.js";
|
|
|
15
15
|
import type { AppVariables } from "../types/app-context.js";
|
|
16
16
|
import { getConfiguredStorageDriver, getEnvString } from "../lib/env.js";
|
|
17
17
|
import { IS_VITE_DEV } from "../lib/build-env.js";
|
|
18
|
+
import { isPublicStoragePath } from "../lib/public-storage.js";
|
|
18
19
|
import {
|
|
19
20
|
buildCspDirectives,
|
|
20
21
|
type ContentSecurityPolicyDirectives,
|
|
@@ -57,7 +58,7 @@ function couldRenderCodeInjection(path: string): boolean {
|
|
|
57
58
|
if (shouldBlockFraming(path)) return false;
|
|
58
59
|
if (path === "/favicon.ico" || path === "/apple-touch-icon.png") return false;
|
|
59
60
|
if (path === "/healthz" || path === "/readyz") return false;
|
|
60
|
-
if (
|
|
61
|
+
if (isPublicStoragePath(path)) return false;
|
|
61
62
|
return true;
|
|
62
63
|
}
|
|
63
64
|
|
|
@@ -135,7 +136,12 @@ function buildSecureHeadersOptions(
|
|
|
135
136
|
});
|
|
136
137
|
|
|
137
138
|
return {
|
|
138
|
-
|
|
139
|
+
// A stored file carries its own, stricter policy (see storedFileHeaders
|
|
140
|
+
// in app.tsx); the page policy would let an uploaded HTML file run
|
|
141
|
+
// scripts from any https origin.
|
|
142
|
+
contentSecurityPolicy: isPublicStoragePath(path)
|
|
143
|
+
? undefined
|
|
144
|
+
: toHonoCspOptions(directives),
|
|
139
145
|
crossOriginResourcePolicy: false,
|
|
140
146
|
crossOriginOpenerPolicy: false,
|
|
141
147
|
originAgentCluster: false,
|
|
@@ -26,12 +26,12 @@ describe("jant migrate", () => {
|
|
|
26
26
|
vi.resetModules();
|
|
27
27
|
});
|
|
28
28
|
|
|
29
|
-
it("keeps the existing DATABASE_URL when --node loads
|
|
29
|
+
it("keeps the existing DATABASE_URL when --node loads the env file", async () => {
|
|
30
30
|
process.env.DATABASE_URL =
|
|
31
31
|
"postgres://shell_user:super-secret@db.example.com:5432/shell_db";
|
|
32
32
|
delete process.env.DATA_DIR;
|
|
33
33
|
process.env.JANT_DEBUG_MIGRATE = "1";
|
|
34
|
-
// This test is about the auto-located
|
|
34
|
+
// This test is about the auto-located env file itself, so it opts back
|
|
35
35
|
// into the search the suite disables in `vitest.config.ts`. `node:fs` is
|
|
36
36
|
// mocked below, so the file it finds is the mock's content, not a real one.
|
|
37
37
|
delete process.env.JANT_ENV_FILE;
|
|
@@ -113,13 +113,24 @@ describe("findNodeEnvPath", () => {
|
|
|
113
113
|
tmpDir = mkdtempSync(join(tmpdir(), "jant-env-path-"));
|
|
114
114
|
});
|
|
115
115
|
|
|
116
|
-
it("finds .env
|
|
117
|
-
const envPath = join(tmpDir, ".env
|
|
116
|
+
it("finds .env in the given directory when JANT_ENV_FILE is unset", () => {
|
|
117
|
+
const envPath = join(tmpDir, ".env");
|
|
118
118
|
writeFileSync(envPath, "DATABASE_URL=file:./jant.sqlite\n");
|
|
119
119
|
|
|
120
120
|
expect(findNodeEnvPath(tmpDir, {})).toBe(envPath);
|
|
121
121
|
});
|
|
122
122
|
|
|
123
|
+
// The Node and Docker docs, the templates, and docker compose all use
|
|
124
|
+
// `.env`; a project-level `.env.node` was a name only the CLI knew.
|
|
125
|
+
it("doesn't read a .env.node in the project directory", () => {
|
|
126
|
+
writeFileSync(
|
|
127
|
+
join(tmpDir, ".env.node"),
|
|
128
|
+
"DATABASE_URL=file:./local.sqlite\n",
|
|
129
|
+
);
|
|
130
|
+
|
|
131
|
+
expect(findNodeEnvPath(tmpDir, {})).not.toBe(join(tmpDir, ".env.node"));
|
|
132
|
+
});
|
|
133
|
+
|
|
123
134
|
it("loads nothing when JANT_ENV_FILE is empty", () => {
|
|
124
135
|
writeFileSync(
|
|
125
136
|
join(tmpDir, ".env.node"),
|
|
@@ -548,6 +548,63 @@ describe("jant site snapshot export/import", () => {
|
|
|
548
548
|
}
|
|
549
549
|
});
|
|
550
550
|
|
|
551
|
+
it("replaces a setting a later version's snapshot carries and this one doesn't list", async () => {
|
|
552
|
+
const root = await mkdtemp(join(tmpdir(), "jant-site-snapshot-upsert-"));
|
|
553
|
+
tempDirs.push(root);
|
|
554
|
+
const targetDbPath = join(root, "target.sqlite");
|
|
555
|
+
const snapshotPath = join(root, "snapshot");
|
|
556
|
+
await migrate({ DATABASE_URL: `file:${targetDbPath}` } as Bindings);
|
|
557
|
+
|
|
558
|
+
const sqlite = new Database(targetDbPath);
|
|
559
|
+
try {
|
|
560
|
+
// DISCOVER isn't among the settings this version's snapshot restores,
|
|
561
|
+
// so `--replace` leaves the target's row in place.
|
|
562
|
+
sqlite.exec(`
|
|
563
|
+
INSERT INTO "site" ("id", "key", "status", "created_at", "updated_at")
|
|
564
|
+
VALUES ('${SNAPSHOT_SITE_ID}', '${SNAPSHOT_SITE_KEY}', 'active', 1, 1);
|
|
565
|
+
INSERT INTO "site_setting" ("site_id", "key", "value", "updated_at")
|
|
566
|
+
VALUES ('${SNAPSHOT_SITE_ID}', 'DISCOVER', 'off', 1);
|
|
567
|
+
`);
|
|
568
|
+
} finally {
|
|
569
|
+
sqlite.close();
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
await mkdir(snapshotPath, { recursive: true });
|
|
573
|
+
await writeFile(
|
|
574
|
+
join(snapshotPath, "meta.json"),
|
|
575
|
+
JSON.stringify({
|
|
576
|
+
format: "jant-site-snapshot",
|
|
577
|
+
version: 2,
|
|
578
|
+
dialect: "sqlite",
|
|
579
|
+
site: { id: SNAPSHOT_SITE_ID, key: SNAPSHOT_SITE_KEY },
|
|
580
|
+
}),
|
|
581
|
+
);
|
|
582
|
+
const { SNAPSHOT_CONFLICT_CLAUSES } =
|
|
583
|
+
await import("../../../bin/lib/site-snapshot.js");
|
|
584
|
+
await writeFile(
|
|
585
|
+
join(snapshotPath, "db.sql"),
|
|
586
|
+
`INSERT INTO "site_setting" ("site_id", "key", "value", "updated_at") VALUES('${SNAPSHOT_SITE_ID}', 'DISCOVER', 'latest', 2) ${SNAPSHOT_CONFLICT_CLAUSES.site_setting};\n`,
|
|
587
|
+
);
|
|
588
|
+
|
|
589
|
+
useLocalSnapshotRuntime(`file:${targetDbPath}`, join(root, "target-media"));
|
|
590
|
+
const { run: runImport } =
|
|
591
|
+
await import("../../../bin/commands/site/snapshot/import.js");
|
|
592
|
+
await runImport(["--path", snapshotPath, "--replace"]);
|
|
593
|
+
|
|
594
|
+
const verifySqlite = new Database(targetDbPath, { readonly: true });
|
|
595
|
+
try {
|
|
596
|
+
expect(
|
|
597
|
+
verifySqlite
|
|
598
|
+
.prepare(
|
|
599
|
+
`SELECT "value" FROM "site_setting" WHERE "site_id" = ? AND "key" = 'DISCOVER'`,
|
|
600
|
+
)
|
|
601
|
+
.get(SNAPSHOT_SITE_ID),
|
|
602
|
+
).toEqual({ value: "latest" });
|
|
603
|
+
} finally {
|
|
604
|
+
verifySqlite.close();
|
|
605
|
+
}
|
|
606
|
+
});
|
|
607
|
+
|
|
551
608
|
it("skips downloading storage objects when --skip-objects is passed", async () => {
|
|
552
609
|
const root = await mkdtemp(
|
|
553
610
|
join(tmpdir(), "jant-site-snapshot-skip-objects-"),
|
|
@@ -117,13 +117,23 @@ describe("assertSnapshotMeta", () => {
|
|
|
117
117
|
).not.toThrow();
|
|
118
118
|
});
|
|
119
119
|
|
|
120
|
-
it("
|
|
120
|
+
it("asks for an upgrade when the snapshot's version is newer", () => {
|
|
121
121
|
expect(() =>
|
|
122
122
|
assertSnapshotMeta({
|
|
123
123
|
format: "jant-site-snapshot",
|
|
124
124
|
version: SNAPSHOT_VERSION + 1,
|
|
125
125
|
site: SITE,
|
|
126
126
|
}),
|
|
127
|
+
).toThrow(/Upgrade @jant\/core, then import again/);
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
it("rejects a snapshot version this Jant never wrote", () => {
|
|
131
|
+
expect(() =>
|
|
132
|
+
assertSnapshotMeta({
|
|
133
|
+
format: "jant-site-snapshot",
|
|
134
|
+
version: 0,
|
|
135
|
+
site: SITE,
|
|
136
|
+
}),
|
|
127
137
|
).toThrow(/Unsupported snapshot version/);
|
|
128
138
|
});
|
|
129
139
|
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { describe, expect, it } from "vitest";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
getTableColumns,
|
|
4
|
+
listExportTables,
|
|
5
|
+
} from "../../../bin/lib/sql-export.js";
|
|
3
6
|
|
|
4
7
|
interface CapturedQueryRunner {
|
|
5
8
|
query: (sql: string) => Promise<Array<Record<string, unknown>>>;
|
|
@@ -47,3 +50,24 @@ describe("getTableColumns", () => {
|
|
|
47
50
|
expect(runner.lastSql).toMatch(/PRAGMA\s+table_xinfo/);
|
|
48
51
|
});
|
|
49
52
|
});
|
|
53
|
+
|
|
54
|
+
describe("listExportTables", () => {
|
|
55
|
+
// D1 keeps a table of its own (`_cf_KV` remotely, `_cf_METADATA` locally)
|
|
56
|
+
// and refuses every read of it, so asking for its columns failed
|
|
57
|
+
// `jant db export --remote` on every Cloudflare site.
|
|
58
|
+
it("leaves out D1's own tables, migration history, and the search index", async () => {
|
|
59
|
+
const runner = createQueryRunner(
|
|
60
|
+
[
|
|
61
|
+
"_cf_KV",
|
|
62
|
+
"_cf_METADATA",
|
|
63
|
+
"d1_migrations",
|
|
64
|
+
"post",
|
|
65
|
+
"post_fts",
|
|
66
|
+
"post_fts_data",
|
|
67
|
+
"site",
|
|
68
|
+
].map((name) => ({ name, sql: `CREATE TABLE "${name}" (id)` })),
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
expect(await listExportTables(runner)).toEqual(["site", "post"]);
|
|
72
|
+
});
|
|
73
|
+
});
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { EventEmitter } from "node:events";
|
|
2
|
+
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
3
|
+
import { closeOnSignal } from "../../../bin/commands/start.js";
|
|
4
|
+
|
|
5
|
+
function fakeProcess() {
|
|
6
|
+
const emitter = new EventEmitter();
|
|
7
|
+
const exit = vi.fn();
|
|
8
|
+
return {
|
|
9
|
+
target: Object.assign(emitter, { exit }) as unknown as Pick<
|
|
10
|
+
typeof process,
|
|
11
|
+
"on" | "exit"
|
|
12
|
+
>,
|
|
13
|
+
emitter,
|
|
14
|
+
exit,
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
describe("jant start", () => {
|
|
19
|
+
afterEach(() => {
|
|
20
|
+
vi.restoreAllMocks();
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
// Docker stops a container with SIGTERM, and node as PID 1 ignores a
|
|
24
|
+
// signal it has no handler for.
|
|
25
|
+
it.each(["SIGTERM", "SIGINT"])(
|
|
26
|
+
"closes the server and exits on %s",
|
|
27
|
+
async (signal) => {
|
|
28
|
+
vi.spyOn(console, "log").mockImplementation(() => {});
|
|
29
|
+
const close = vi.fn(async () => {});
|
|
30
|
+
const { target, emitter, exit } = fakeProcess();
|
|
31
|
+
|
|
32
|
+
closeOnSignal({ close }, target);
|
|
33
|
+
emitter.emit(signal, signal);
|
|
34
|
+
await vi.waitFor(() => expect(exit).toHaveBeenCalledWith(0));
|
|
35
|
+
|
|
36
|
+
expect(close).toHaveBeenCalledTimes(1);
|
|
37
|
+
},
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
it("stops without waiting on a second signal", async () => {
|
|
41
|
+
vi.spyOn(console, "log").mockImplementation(() => {});
|
|
42
|
+
const close = vi.fn(() => new Promise<void>(() => {}));
|
|
43
|
+
const { target, emitter, exit } = fakeProcess();
|
|
44
|
+
|
|
45
|
+
closeOnSignal({ close }, target);
|
|
46
|
+
emitter.emit("SIGTERM", "SIGTERM");
|
|
47
|
+
emitter.emit("SIGINT", "SIGINT");
|
|
48
|
+
|
|
49
|
+
expect(close).toHaveBeenCalledTimes(1);
|
|
50
|
+
expect(exit).toHaveBeenCalledWith(1);
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it("exits with an error when closing fails", async () => {
|
|
54
|
+
vi.spyOn(console, "log").mockImplementation(() => {});
|
|
55
|
+
vi.spyOn(console, "error").mockImplementation(() => {});
|
|
56
|
+
const close = vi.fn(async () => {
|
|
57
|
+
throw new Error("busy");
|
|
58
|
+
});
|
|
59
|
+
const { target, emitter, exit } = fakeProcess();
|
|
60
|
+
|
|
61
|
+
closeOnSignal({ close }, target);
|
|
62
|
+
emitter.emit("SIGTERM", "SIGTERM");
|
|
63
|
+
|
|
64
|
+
await vi.waitFor(() => expect(exit).toHaveBeenCalledWith(1));
|
|
65
|
+
});
|
|
66
|
+
});
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { withClientAddress } from "../request-handler.js";
|
|
3
|
+
|
|
4
|
+
function forged() {
|
|
5
|
+
return new Request("http://blog.example/signin", {
|
|
6
|
+
method: "POST",
|
|
7
|
+
headers: {
|
|
8
|
+
"X-Forwarded-For": "198.51.100.1",
|
|
9
|
+
"CF-Connecting-IP": "198.51.100.2",
|
|
10
|
+
"Content-Type": "application/json",
|
|
11
|
+
},
|
|
12
|
+
body: "{}",
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
describe("withClientAddress", () => {
|
|
17
|
+
it("replaces client-sent address headers with the socket's address", async () => {
|
|
18
|
+
const request = withClientAddress(forged(), "203.0.113.7", false);
|
|
19
|
+
|
|
20
|
+
expect(request.headers.get("x-forwarded-for")).toBe("203.0.113.7");
|
|
21
|
+
expect(request.headers.get("cf-connecting-ip")).toBeNull();
|
|
22
|
+
await expect(request.text()).resolves.toBe("{}");
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it("drops them when the socket's address is unknown", () => {
|
|
26
|
+
const request = withClientAddress(forged(), undefined, false);
|
|
27
|
+
|
|
28
|
+
expect(request.headers.get("x-forwarded-for")).toBeNull();
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it("keeps a trusted proxy's headers", () => {
|
|
32
|
+
const request = withClientAddress(forged(), "10.0.0.2", true);
|
|
33
|
+
|
|
34
|
+
expect(request.headers.get("x-forwarded-for")).toBe("198.51.100.1");
|
|
35
|
+
expect(request.headers.get("cf-connecting-ip")).toBe("198.51.100.2");
|
|
36
|
+
});
|
|
37
|
+
});
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
1
2
|
import { access, mkdir, mkdtemp, rm, writeFile } from "node:fs/promises";
|
|
3
|
+
import { createServer } from "node:net";
|
|
2
4
|
import { tmpdir } from "node:os";
|
|
3
5
|
import { join } from "node:path";
|
|
4
6
|
import { pathToFileURL } from "node:url";
|
|
@@ -11,8 +13,9 @@ import {
|
|
|
11
13
|
resolveNodeDataDir,
|
|
12
14
|
resolveDatabasePath,
|
|
13
15
|
resolvePublicRequestUrl,
|
|
16
|
+
start,
|
|
14
17
|
} from "../runtime.js";
|
|
15
|
-
import type { App } from "../../types/app-context.js";
|
|
18
|
+
import type { App, HonoApp } from "../../types/app-context.js";
|
|
16
19
|
import type { Bindings } from "../../types.js";
|
|
17
20
|
|
|
18
21
|
const tempDirs: string[] = [];
|
|
@@ -419,3 +422,55 @@ describe("migrate", () => {
|
|
|
419
422
|
await access(databasePath);
|
|
420
423
|
});
|
|
421
424
|
});
|
|
425
|
+
|
|
426
|
+
async function freePort(): Promise<number> {
|
|
427
|
+
const server = createServer();
|
|
428
|
+
await new Promise<void>((resolve) => server.listen(0, "127.0.0.1", resolve));
|
|
429
|
+
const address = server.address();
|
|
430
|
+
await new Promise<void>((resolve) => server.close(() => resolve()));
|
|
431
|
+
if (!address || typeof address === "string") {
|
|
432
|
+
throw new Error("Expected a TCP address");
|
|
433
|
+
}
|
|
434
|
+
return address.port;
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
describe("start", () => {
|
|
438
|
+
// A backup copies `jant.sqlite`. Writes made in WAL mode sit in
|
|
439
|
+
// `jant.sqlite-wal` until the last connection closes, so stopping the
|
|
440
|
+
// server has to close the database, not just stop listening.
|
|
441
|
+
it("writes the WAL back into the database file when it closes", async () => {
|
|
442
|
+
const root = await mkdtemp(join(tmpdir(), "jant-node-close-"));
|
|
443
|
+
tempDirs.push(root);
|
|
444
|
+
const databasePath = join(root, "jant.sqlite");
|
|
445
|
+
const env = {
|
|
446
|
+
DATABASE_URL: `file:${databasePath}`,
|
|
447
|
+
HOST: "127.0.0.1",
|
|
448
|
+
PORT: String(await freePort()),
|
|
449
|
+
} as Bindings;
|
|
450
|
+
await migrate(env);
|
|
451
|
+
|
|
452
|
+
const handle = await start(
|
|
453
|
+
env,
|
|
454
|
+
{ fetch: () => new Response("ok") } as unknown as HonoApp,
|
|
455
|
+
{ assetRoot: null },
|
|
456
|
+
);
|
|
457
|
+
|
|
458
|
+
const writer = new Database(databasePath);
|
|
459
|
+
writer.exec("CREATE TABLE close_check (value TEXT)");
|
|
460
|
+
writer.prepare("INSERT INTO close_check (value) VALUES (?)").run("kept");
|
|
461
|
+
writer.close();
|
|
462
|
+
expect(existsSync(`${databasePath}-wal`)).toBe(true);
|
|
463
|
+
|
|
464
|
+
await handle.close();
|
|
465
|
+
|
|
466
|
+
expect(existsSync(`${databasePath}-wal`)).toBe(false);
|
|
467
|
+
const reader = new Database(databasePath, { readonly: true });
|
|
468
|
+
try {
|
|
469
|
+
expect(
|
|
470
|
+
reader.prepare("SELECT value FROM close_check").pluck().get(),
|
|
471
|
+
).toBe("kept");
|
|
472
|
+
} finally {
|
|
473
|
+
reader.close();
|
|
474
|
+
}
|
|
475
|
+
});
|
|
476
|
+
});
|
|
@@ -30,10 +30,11 @@ import {
|
|
|
30
30
|
getSiteResolutionMode,
|
|
31
31
|
shouldTrustProxy,
|
|
32
32
|
} from "../lib/env.js";
|
|
33
|
+
import { getEnvValueIssues } from "../lib/env-values.js";
|
|
33
34
|
import { getHostBasedStartupConfigurationIssues } from "../lib/startup-config.js";
|
|
34
35
|
import { now } from "../lib/time.js";
|
|
35
36
|
import { createSiteService } from "../services/site.js";
|
|
36
|
-
import type {
|
|
37
|
+
import type { HonoApp } from "../types/app-context.js";
|
|
37
38
|
import type { Bindings } from "../types/bindings.js";
|
|
38
39
|
|
|
39
40
|
const DEFAULT_HOST = "127.0.0.1";
|
|
@@ -570,14 +571,55 @@ export async function migrate(
|
|
|
570
571
|
}
|
|
571
572
|
}
|
|
572
573
|
|
|
573
|
-
export type NodeAppResolver =
|
|
574
|
+
export type NodeAppResolver = HonoApp | (() => HonoApp | Promise<HonoApp>);
|
|
575
|
+
|
|
576
|
+
/** What `@hono/node-server` passes alongside each request. */
|
|
577
|
+
export interface NodeConnection {
|
|
578
|
+
incoming?: { socket?: { remoteAddress?: string } };
|
|
579
|
+
}
|
|
574
580
|
|
|
575
581
|
export interface NodeRequestHandler {
|
|
576
582
|
close(): Promise<void>;
|
|
577
|
-
fetch(request: Request): Promise<Response>;
|
|
583
|
+
fetch(request: Request, connection?: NodeConnection): Promise<Response>;
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
/**
|
|
587
|
+
* Pins the client address a request carries to one Jant can vouch for.
|
|
588
|
+
*
|
|
589
|
+
* Without a trusted proxy in front, an `X-Forwarded-For` or
|
|
590
|
+
* `CF-Connecting-IP` header came from the client itself, and a rate limit
|
|
591
|
+
* keyed on it could be dodged by changing it on every request. Both are
|
|
592
|
+
* replaced by the socket's address. Behind a trusted proxy the headers are
|
|
593
|
+
* the proxy's, and stay.
|
|
594
|
+
*
|
|
595
|
+
* @param request - The request as the server received it
|
|
596
|
+
* @param socketAddress - The connecting socket's address, when known
|
|
597
|
+
* @param trustProxy - Whether `TRUST_PROXY` is on
|
|
598
|
+
* @returns The request, with client-address headers only Jant set
|
|
599
|
+
*
|
|
600
|
+
* @example
|
|
601
|
+
* ```ts
|
|
602
|
+
* withClientAddress(request, "203.0.113.7", false).headers.get("x-forwarded-for");
|
|
603
|
+
* // "203.0.113.7"
|
|
604
|
+
* ```
|
|
605
|
+
*/
|
|
606
|
+
export function withClientAddress(
|
|
607
|
+
request: Request,
|
|
608
|
+
socketAddress: string | undefined,
|
|
609
|
+
trustProxy: boolean,
|
|
610
|
+
): Request {
|
|
611
|
+
if (trustProxy) return request;
|
|
612
|
+
const headers = new Headers(request.headers);
|
|
613
|
+
headers.delete("cf-connecting-ip");
|
|
614
|
+
if (socketAddress) {
|
|
615
|
+
headers.set("x-forwarded-for", socketAddress);
|
|
616
|
+
} else {
|
|
617
|
+
headers.delete("x-forwarded-for");
|
|
618
|
+
}
|
|
619
|
+
return new Request(request, { headers });
|
|
578
620
|
}
|
|
579
621
|
|
|
580
|
-
async function resolveApp(app: NodeAppResolver | undefined): Promise<
|
|
622
|
+
async function resolveApp(app: NodeAppResolver | undefined): Promise<HonoApp> {
|
|
581
623
|
if (typeof app === "function") {
|
|
582
624
|
return app();
|
|
583
625
|
}
|
|
@@ -617,6 +659,12 @@ export async function createNodeRequestHandler(options?: {
|
|
|
617
659
|
`Host-based startup configuration is invalid:\n- ${hostBasedStartupIssues.map((issue) => issue.message).join("\n- ")}`,
|
|
618
660
|
);
|
|
619
661
|
}
|
|
662
|
+
const envValueIssues = getEnvValueIssues(env);
|
|
663
|
+
if (envValueIssues.length > 0) {
|
|
664
|
+
throw new Error(
|
|
665
|
+
`Jant can't use these environment values:\n- ${envValueIssues.map((issue) => issue.message).join("\n- ")}`,
|
|
666
|
+
);
|
|
667
|
+
}
|
|
620
668
|
const { bindings: databaseBindings, close } = await createNodeBindings(env);
|
|
621
669
|
const bindings: Bindings = { ...databaseBindings, NODE_STARTED_AT: now() };
|
|
622
670
|
try {
|
|
@@ -633,7 +681,12 @@ export async function createNodeRequestHandler(options?: {
|
|
|
633
681
|
let closed = false;
|
|
634
682
|
|
|
635
683
|
return {
|
|
636
|
-
async fetch(
|
|
684
|
+
async fetch(receivedRequest: Request, connection?: NodeConnection) {
|
|
685
|
+
const request = withClientAddress(
|
|
686
|
+
receivedRequest,
|
|
687
|
+
connection?.incoming?.socket?.remoteAddress,
|
|
688
|
+
shouldTrustProxy(bindings),
|
|
689
|
+
);
|
|
637
690
|
const publicRequestUrl = resolvePublicRequestUrl(request, bindings);
|
|
638
691
|
const preparedRequest =
|
|
639
692
|
publicRequestUrl === request.url
|
package/src/node/runtime.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { serve, type ServerType } from "@hono/node-server";
|
|
2
2
|
import type { AddressInfo } from "node:net";
|
|
3
|
-
import type {
|
|
3
|
+
import type { HonoApp } from "../types/app-context.js";
|
|
4
4
|
import type { Bindings } from "../types/bindings.js";
|
|
5
5
|
import {
|
|
6
6
|
createNodeRequestHandler,
|
|
@@ -29,13 +29,24 @@ export interface NodeServerHandle {
|
|
|
29
29
|
url: string;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
+
/**
|
|
33
|
+
* How long a stop waits for requests in flight before cutting their
|
|
34
|
+
* connections. Docker kills a container ten seconds after asking it to stop,
|
|
35
|
+
* and the database has to be closed before then.
|
|
36
|
+
*/
|
|
37
|
+
const CLOSE_GRACE_MS = 5000;
|
|
38
|
+
|
|
32
39
|
export async function start(
|
|
33
40
|
env: Bindings = process.env as unknown as Bindings,
|
|
34
|
-
app?:
|
|
41
|
+
app?: HonoApp,
|
|
42
|
+
options: { assetRoot?: string | null } = {},
|
|
35
43
|
): Promise<NodeServerHandle> {
|
|
36
44
|
const handler = await createNodeRequestHandler({
|
|
37
45
|
env,
|
|
38
46
|
app: async () => app ?? (await import("../app.js")).createApp(),
|
|
47
|
+
// Undefined finds the built assets; null serves none, for a test that
|
|
48
|
+
// runs before the build.
|
|
49
|
+
assetRoot: options.assetRoot,
|
|
39
50
|
});
|
|
40
51
|
const hostname = resolveHost(env);
|
|
41
52
|
const port = resolvePort(env);
|
|
@@ -57,21 +68,36 @@ export async function start(
|
|
|
57
68
|
resolvePromise({
|
|
58
69
|
server,
|
|
59
70
|
url: `http://${info.address}:${info.port}`,
|
|
71
|
+
// Closing the database is what writes SQLite's WAL back into
|
|
72
|
+
// `jant.sqlite`, so it runs even when the server fails to close.
|
|
60
73
|
async close() {
|
|
61
74
|
if (closed) {
|
|
62
75
|
return;
|
|
63
76
|
}
|
|
64
77
|
closed = true;
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
78
|
+
try {
|
|
79
|
+
await new Promise<void>((resolveClose, rejectClose) => {
|
|
80
|
+
// `close()` drops idle keep-alive connections at once and
|
|
81
|
+
// waits for requests in flight; past the grace period those
|
|
82
|
+
// are cut too.
|
|
83
|
+
const cutConnections = setTimeout(() => {
|
|
84
|
+
if ("closeAllConnections" in server) {
|
|
85
|
+
server.closeAllConnections();
|
|
86
|
+
}
|
|
87
|
+
}, CLOSE_GRACE_MS);
|
|
88
|
+
cutConnections.unref();
|
|
89
|
+
server.close((error?: Error) => {
|
|
90
|
+
clearTimeout(cutConnections);
|
|
91
|
+
if (error) {
|
|
92
|
+
rejectClose(error);
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
resolveClose();
|
|
96
|
+
});
|
|
72
97
|
});
|
|
73
|
-
}
|
|
74
|
-
|
|
98
|
+
} finally {
|
|
99
|
+
await handler.close();
|
|
100
|
+
}
|
|
75
101
|
},
|
|
76
102
|
});
|
|
77
103
|
},
|
package/src/preset.css
CHANGED
|
@@ -505,7 +505,7 @@ html {
|
|
|
505
505
|
* headings inside the body should remain visible, but they should read as
|
|
506
506
|
* sections within the card rather than as peer post titles.
|
|
507
507
|
*/
|
|
508
|
-
[data-post]:not(
|
|
508
|
+
[data-post]:not(.post-detail) [data-post-body].prose {
|
|
509
509
|
:where(h1, h2) {
|
|
510
510
|
font-size: calc(var(--type-content-body) * 1.12);
|
|
511
511
|
font-weight: var(--fw-medium);
|
|
@@ -535,7 +535,7 @@ html {
|
|
|
535
535
|
* Keep these overrides outside cascade layers so they can outrank the base
|
|
536
536
|
* `.prose` variable defaults defined above.
|
|
537
537
|
*/
|
|
538
|
-
|
|
538
|
+
.post-detail .post-detail-body.prose {
|
|
539
539
|
--tw-prose-body: var(--site-reading-body);
|
|
540
540
|
--tw-prose-headings: var(--site-reading-heading);
|
|
541
541
|
--tw-prose-lead: color-mix(
|
|
@@ -608,7 +608,7 @@ html {
|
|
|
608
608
|
max-width: none;
|
|
609
609
|
}
|
|
610
610
|
|
|
611
|
-
|
|
611
|
+
.search-page,
|
|
612
612
|
.site-home-header,
|
|
613
613
|
.post-detail-body,
|
|
614
614
|
.post-body-summary,
|