@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
|
@@ -10,17 +10,22 @@
|
|
|
10
10
|
* now collide with. These checks fail on each of those.
|
|
11
11
|
*
|
|
12
12
|
* Environment variables outside `CONFIG_FIELDS` are classified here, so a new
|
|
13
|
-
* one added to `Bindings` has to be documented or declared internal
|
|
13
|
+
* one added to `Bindings` has to be documented or declared internal, and a
|
|
14
|
+
* variable the code reads has to be in `Bindings` to be classified at all.
|
|
15
|
+
* Both language versions of the reference are held to the same lists, and to
|
|
16
|
+
* the four defaults `docs/compatibility.md` freezes.
|
|
14
17
|
*/
|
|
15
18
|
|
|
16
|
-
import { readFileSync } from "node:fs";
|
|
17
|
-
import { join, resolve } from "node:path";
|
|
19
|
+
import { readdirSync, readFileSync } from "node:fs";
|
|
20
|
+
import { join, relative, resolve } from "node:path";
|
|
18
21
|
import { describe, expect, it } from "vitest";
|
|
19
22
|
import {
|
|
20
23
|
editableSettingKeys,
|
|
21
|
-
|
|
24
|
+
appearanceSettingKeys,
|
|
25
|
+
languageSettingKeys,
|
|
22
26
|
} from "../lib/api-settings.js";
|
|
23
27
|
import { RESERVED_PATHS } from "../lib/constants.js";
|
|
28
|
+
import { ENV_RULES, getCorsOrigins } from "../lib/env.js";
|
|
24
29
|
import { CONFIG_FIELDS } from "../types/config.js";
|
|
25
30
|
|
|
26
31
|
const CORE_DIR = resolve(import.meta.dirname, "../..");
|
|
@@ -36,13 +41,21 @@ const PUBLIC_ENV_OUTSIDE_CONFIG_FIELDS = [
|
|
|
36
41
|
"DATABASE_URL",
|
|
37
42
|
"DATA_DIR",
|
|
38
43
|
"DISCOVER_PING_URL",
|
|
44
|
+
"GITHUB_APP_ID",
|
|
45
|
+
"GITHUB_APP_PRIVATE_KEY",
|
|
46
|
+
"GITHUB_APP_SLUG",
|
|
47
|
+
"GITHUB_APP_WEBHOOK_SECRET",
|
|
39
48
|
"HOST",
|
|
40
49
|
"INTERNAL_ADMIN_TOKEN",
|
|
50
|
+
// Read by the CLI and `jant start`, not the server.
|
|
51
|
+
"JANT_ENV_FILE",
|
|
41
52
|
"LOCAL_PUBLIC_URL",
|
|
42
53
|
"LOCAL_STORAGE_PATH",
|
|
43
54
|
"PORT",
|
|
44
|
-
"
|
|
55
|
+
"RATE_LIMIT_ENABLED",
|
|
45
56
|
"RATE_LIMIT_SEARCH_PER_MIN",
|
|
57
|
+
"TELEGRAM_BOT_TOKENS",
|
|
58
|
+
"TELEGRAM_WEBHOOK_SECRET",
|
|
46
59
|
"TRUST_PROXY",
|
|
47
60
|
];
|
|
48
61
|
|
|
@@ -96,6 +109,51 @@ function readReservedPaths(markdown: string): string[] {
|
|
|
96
109
|
.filter(Boolean);
|
|
97
110
|
}
|
|
98
111
|
|
|
112
|
+
/**
|
|
113
|
+
* Every environment variable a source file names through the env readers:
|
|
114
|
+
* `getEnvString(env, "NAME")`, `readEnvBoolean(env, "NAME")`, and the like.
|
|
115
|
+
*/
|
|
116
|
+
function readEnvReads(): Map<string, string> {
|
|
117
|
+
const reads = new Map<string, string>();
|
|
118
|
+
const walk = (dir: string) => {
|
|
119
|
+
for (const entry of readdirSync(dir, { withFileTypes: true })) {
|
|
120
|
+
const path = join(dir, entry.name);
|
|
121
|
+
if (entry.isDirectory()) {
|
|
122
|
+
if (entry.name !== "__tests__") walk(path);
|
|
123
|
+
continue;
|
|
124
|
+
}
|
|
125
|
+
if (!/\.tsx?$/.test(entry.name)) continue;
|
|
126
|
+
const source = readFileSync(path, "utf8");
|
|
127
|
+
for (const match of source.matchAll(
|
|
128
|
+
/\b(?:getEnvString|readEnvBoolean|readEnvInteger|readEnvEnum)\([^,()]+,\s*"([A-Z][A-Z0-9_]+)"/g,
|
|
129
|
+
)) {
|
|
130
|
+
if (match[1]) reads.set(match[1], relative(CORE_DIR, path));
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
walk(join(CORE_DIR, "src"));
|
|
135
|
+
return reads;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Defaults `docs/compatibility.md` freezes until a major release: each decides
|
|
140
|
+
* what a covered address answers.
|
|
141
|
+
*/
|
|
142
|
+
const FROZEN_DEFAULTS = {
|
|
143
|
+
PUBLIC_API_ENABLED: "true",
|
|
144
|
+
MAIN_RSS_FEED: "featured",
|
|
145
|
+
RSS_FEEDS_ENABLED: "true",
|
|
146
|
+
CORS_ORIGINS: "*",
|
|
147
|
+
} as const;
|
|
148
|
+
|
|
149
|
+
/** The default a configuration doc's table gives a variable, e.g. `` `true` ``. */
|
|
150
|
+
function readTableDefault(markdown: string, key: string): string | undefined {
|
|
151
|
+
const row = markdown.match(
|
|
152
|
+
new RegExp(`^\\| \`${key}\`\\s*\\| \`([^\`]*)\`\\s*\\|`, "m"),
|
|
153
|
+
);
|
|
154
|
+
return row?.[1];
|
|
155
|
+
}
|
|
156
|
+
|
|
99
157
|
const configKeys = Object.keys(CONFIG_FIELDS);
|
|
100
158
|
const publicConfigKeys = Object.entries(CONFIG_FIELDS)
|
|
101
159
|
.filter(([, field]) => !("internal" in field && field.internal))
|
|
@@ -111,15 +169,59 @@ describe("configuration docs", () => {
|
|
|
111
169
|
expect(readBindingKeys().filter((key) => !known.has(key))).toEqual([]);
|
|
112
170
|
});
|
|
113
171
|
|
|
114
|
-
it("
|
|
115
|
-
const
|
|
116
|
-
const
|
|
117
|
-
.filter((key) => !
|
|
118
|
-
.
|
|
119
|
-
|
|
172
|
+
it("declares in Bindings every variable the code reads", () => {
|
|
173
|
+
const bindings = new Set(readBindingKeys());
|
|
174
|
+
const undeclared = [...readEnvReads()]
|
|
175
|
+
.filter(([key]) => !bindings.has(key))
|
|
176
|
+
.map(([key, file]) => `${key} (${file})`);
|
|
177
|
+
const unruled = Object.keys(ENV_RULES).filter((key) => !bindings.has(key));
|
|
178
|
+
expect([...undeclared, ...unruled]).toEqual([]);
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
it("keeps the frozen defaults", () => {
|
|
182
|
+
expect(CONFIG_FIELDS.PUBLIC_API_ENABLED.defaultValue).toBe(
|
|
183
|
+
FROZEN_DEFAULTS.PUBLIC_API_ENABLED,
|
|
184
|
+
);
|
|
185
|
+
expect(CONFIG_FIELDS.MAIN_RSS_FEED.defaultValue).toBe(
|
|
186
|
+
FROZEN_DEFAULTS.MAIN_RSS_FEED,
|
|
187
|
+
);
|
|
188
|
+
expect(CONFIG_FIELDS.RSS_FEEDS_ENABLED.defaultValue).toBe(
|
|
189
|
+
FROZEN_DEFAULTS.RSS_FEEDS_ENABLED,
|
|
190
|
+
);
|
|
191
|
+
expect(getCorsOrigins({})).toBe(FROZEN_DEFAULTS.CORS_ORIGINS);
|
|
120
192
|
});
|
|
121
193
|
|
|
122
194
|
for (const path of CONFIGURATION_DOCS) {
|
|
195
|
+
it(`${path} mentions every public variable and setting`, () => {
|
|
196
|
+
const markdown = readRepoFile(path);
|
|
197
|
+
const missing = [...publicConfigKeys, ...PUBLIC_ENV_OUTSIDE_CONFIG_FIELDS]
|
|
198
|
+
.filter((key) => !new RegExp(`\\b${key}\\b`).test(markdown))
|
|
199
|
+
.sort();
|
|
200
|
+
expect(missing).toEqual([]);
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
it(`${path} gives the frozen defaults`, () => {
|
|
204
|
+
const markdown = readRepoFile(path);
|
|
205
|
+
for (const [key, value] of Object.entries(FROZEN_DEFAULTS)) {
|
|
206
|
+
expect(readTableDefault(markdown, key), key).toBe(value);
|
|
207
|
+
}
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
it(`${path} lists exactly the settings the Settings pages edit`, () => {
|
|
211
|
+
const section =
|
|
212
|
+
readRepoFile(path)
|
|
213
|
+
.split(/^## /m)
|
|
214
|
+
.find((part) =>
|
|
215
|
+
/^(Settings page options|Settings 页面设置)\n/.test(part),
|
|
216
|
+
) ?? "";
|
|
217
|
+
const table = section.split(/^### /m)[0] ?? "";
|
|
218
|
+
// DISCOVER is set on the General page but kept out of the Config Editor,
|
|
219
|
+
// so "never chosen" can stay distinct from "off".
|
|
220
|
+
expect(readTableKeys(table).sort()).toEqual(
|
|
221
|
+
[...editableSettingKeys, "DISCOVER"].sort(),
|
|
222
|
+
);
|
|
223
|
+
});
|
|
224
|
+
|
|
123
225
|
it(`${path} lists no variable the code doesn't read`, () => {
|
|
124
226
|
const known = new Set([
|
|
125
227
|
...configKeys,
|
|
@@ -149,14 +251,15 @@ describe("configuration docs", () => {
|
|
|
149
251
|
);
|
|
150
252
|
});
|
|
151
253
|
|
|
152
|
-
it
|
|
254
|
+
it.each([
|
|
255
|
+
["Appearance setting keys", appearanceSettingKeys],
|
|
256
|
+
["Restore the site's languages", languageSettingKeys],
|
|
257
|
+
] as const)("lists exactly the %s in API.md", (heading, keys) => {
|
|
153
258
|
const markdown = readRepoFile("docs/API.md");
|
|
154
259
|
const section =
|
|
155
260
|
markdown
|
|
156
261
|
.split(/^### /m)
|
|
157
|
-
.find((part) => part.startsWith(
|
|
158
|
-
expect(readTableKeys(section).sort()).toEqual(
|
|
159
|
-
[...importableInternalSettingKeys].sort(),
|
|
160
|
-
);
|
|
262
|
+
.find((part) => part.startsWith(`${heading}\n`)) ?? "";
|
|
263
|
+
expect(readTableKeys(section).sort()).toEqual([...keys].sort());
|
|
161
264
|
});
|
|
162
265
|
});
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A custom URL that redirects sends the reader where the author said.
|
|
3
|
+
*
|
|
4
|
+
* The target went through the path normalizer, which lowercased it, dropped
|
|
5
|
+
* its query string's case, and folded `//`, and the redirect then put a `/`
|
|
6
|
+
* in front: `https://Example.com/Page` came out as `/https:/example.com/page`,
|
|
7
|
+
* and `/archive?format=Note` lost its `Note`.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { describe, expect, it } from "vitest";
|
|
11
|
+
import { createApp } from "../app.js";
|
|
12
|
+
import type { Database } from "../db/index.js";
|
|
13
|
+
import { createServices } from "../services/index.js";
|
|
14
|
+
import type { Bindings } from "../types.js";
|
|
15
|
+
import { createTestDatabase, DEFAULT_TEST_SITE_ID } from "./helpers/db.js";
|
|
16
|
+
|
|
17
|
+
const executionCtx = {
|
|
18
|
+
waitUntil() {},
|
|
19
|
+
passThroughOnException() {},
|
|
20
|
+
props: {},
|
|
21
|
+
} as unknown as Parameters<ReturnType<typeof createApp>["fetch"]>[2];
|
|
22
|
+
|
|
23
|
+
async function createSite() {
|
|
24
|
+
const { db, sqlite } = createTestDatabase();
|
|
25
|
+
const services = createServices(
|
|
26
|
+
db as unknown as Database,
|
|
27
|
+
{ query: async () => [] } as unknown as Parameters<
|
|
28
|
+
typeof createServices
|
|
29
|
+
>[1],
|
|
30
|
+
DEFAULT_TEST_SITE_ID,
|
|
31
|
+
{ slugIdLength: 5 },
|
|
32
|
+
);
|
|
33
|
+
await services.settings.completeOnboarding();
|
|
34
|
+
const app = createApp();
|
|
35
|
+
const get = (path: string) =>
|
|
36
|
+
app.fetch(
|
|
37
|
+
new Request(`https://blog.example${path}`, { redirect: "manual" }),
|
|
38
|
+
{
|
|
39
|
+
SITE_ORIGIN: "https://blog.example",
|
|
40
|
+
AUTH_SECRET: "x".repeat(40),
|
|
41
|
+
NODE_SQLITE: sqlite,
|
|
42
|
+
} as unknown as Bindings,
|
|
43
|
+
executionCtx,
|
|
44
|
+
);
|
|
45
|
+
return { services, get };
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
describe("custom URL redirects", () => {
|
|
49
|
+
it("sends a reader to an address on another site as given", async () => {
|
|
50
|
+
const { services, get } = await createSite();
|
|
51
|
+
const created = await services.customUrls.create({
|
|
52
|
+
path: "/elsewhere",
|
|
53
|
+
targetType: "redirect",
|
|
54
|
+
toPath: "https://Example.com/Some/Page?ref=Jant",
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
const res = await get("/elsewhere");
|
|
58
|
+
expect(res.status).toBe(301);
|
|
59
|
+
expect(res.headers.get("location")).toBe(
|
|
60
|
+
"https://example.com/Some/Page?ref=Jant",
|
|
61
|
+
);
|
|
62
|
+
expect(created.toPath).toBe("https://example.com/Some/Page?ref=Jant");
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it("keeps the query string of a target on the site", async () => {
|
|
66
|
+
const { services, get } = await createSite();
|
|
67
|
+
await services.customUrls.create({
|
|
68
|
+
path: "/notes-only",
|
|
69
|
+
targetType: "redirect",
|
|
70
|
+
toPath: "/Archive/?format=Note",
|
|
71
|
+
redirectType: 302,
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
const res = await get("/notes-only");
|
|
75
|
+
expect(res.status).toBe(302);
|
|
76
|
+
expect(res.headers.get("location")).toBe("/archive?format=Note");
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
// A link someone shared with `?page=2` still lands on page 2. A target
|
|
80
|
+
// with a query string of its own, or one off the site, keeps what the
|
|
81
|
+
// author set.
|
|
82
|
+
it("carries the reader's query string to a target on the site without one", async () => {
|
|
83
|
+
const { services, get } = await createSite();
|
|
84
|
+
await services.customUrls.create({
|
|
85
|
+
path: "/old-archive",
|
|
86
|
+
targetType: "redirect",
|
|
87
|
+
toPath: "/archive",
|
|
88
|
+
});
|
|
89
|
+
await services.customUrls.create({
|
|
90
|
+
path: "/notes-only",
|
|
91
|
+
targetType: "redirect",
|
|
92
|
+
toPath: "/archive?format=note",
|
|
93
|
+
});
|
|
94
|
+
await services.customUrls.create({
|
|
95
|
+
path: "/elsewhere",
|
|
96
|
+
targetType: "redirect",
|
|
97
|
+
toPath: "https://example.com/page",
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
const location = async (path: string) =>
|
|
101
|
+
(await get(path)).headers.get("location");
|
|
102
|
+
expect(await location("/old-archive?page=2")).toBe("/archive?page=2");
|
|
103
|
+
expect(await location("/notes-only?page=2")).toBe("/archive?format=note");
|
|
104
|
+
expect(await location("/elsewhere?page=2")).toBe(
|
|
105
|
+
"https://example.com/page",
|
|
106
|
+
);
|
|
107
|
+
});
|
|
108
|
+
});
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A custom URL that names a Collection travels with the export: the
|
|
3
|
+
* Collection's page lists it under `aliases`, and `jant site import`
|
|
4
|
+
* registers it again. It used to stay behind, so the address answered 404 on
|
|
5
|
+
* the imported site.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { mkdir, mkdtemp, rm, writeFile } from "node:fs/promises";
|
|
9
|
+
import { tmpdir } from "node:os";
|
|
10
|
+
import { dirname, join } from "node:path";
|
|
11
|
+
import Database from "better-sqlite3";
|
|
12
|
+
import { afterEach, describe, expect, it } from "vitest";
|
|
13
|
+
import { parseFrontMatter } from "../lib/hugo-markdown.js";
|
|
14
|
+
import { createExportService } from "../services/export.js";
|
|
15
|
+
import { createTestApp } from "./helpers/app.js";
|
|
16
|
+
import { makeSiteConfig } from "./helpers/export-fixtures.js";
|
|
17
|
+
import {
|
|
18
|
+
importSiteExportIntoTempSite,
|
|
19
|
+
type SiteExportImportResult,
|
|
20
|
+
} from "./helpers/site-export-import.js";
|
|
21
|
+
|
|
22
|
+
describe("collection custom URLs in a site export", () => {
|
|
23
|
+
const cleanups: Array<() => Promise<void> | void> = [];
|
|
24
|
+
|
|
25
|
+
afterEach(async () => {
|
|
26
|
+
for (const cleanup of cleanups.splice(0)) await cleanup();
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it("exports them on the Collection's page and imports them again", async () => {
|
|
30
|
+
const { services } = createTestApp();
|
|
31
|
+
const collection = await services.collections.create({
|
|
32
|
+
title: "Ideas",
|
|
33
|
+
slug: "ideas",
|
|
34
|
+
});
|
|
35
|
+
await services.customUrls.create({
|
|
36
|
+
path: "/thoughts",
|
|
37
|
+
targetType: "collection",
|
|
38
|
+
targetId: collection.id,
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
const files = await createExportService(services, makeSiteConfig(), {
|
|
42
|
+
bundleMedia: false,
|
|
43
|
+
}).generateHugoFiles();
|
|
44
|
+
const page = files.find((file) => file.path === "content/ideas/_index.md");
|
|
45
|
+
const { frontMatter } = await parseFrontMatter(String(page?.content));
|
|
46
|
+
expect(frontMatter.aliases).toEqual(["/thoughts"]);
|
|
47
|
+
|
|
48
|
+
const dir = await mkdtemp(join(tmpdir(), "jant-collection-urls-"));
|
|
49
|
+
cleanups.push(() => rm(dir, { recursive: true, force: true }));
|
|
50
|
+
for (const file of files) {
|
|
51
|
+
const path = join(dir, file.path);
|
|
52
|
+
await mkdir(dirname(path), { recursive: true });
|
|
53
|
+
await writeFile(path, file.content);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const result: SiteExportImportResult = importSiteExportIntoTempSite(dir);
|
|
57
|
+
cleanups.push(() => result.cleanup());
|
|
58
|
+
expect(result.status, result.output).toBe(0);
|
|
59
|
+
|
|
60
|
+
const sqlite = new Database(result.databasePath, { readonly: true });
|
|
61
|
+
cleanups.push(() => sqlite.close());
|
|
62
|
+
const row = sqlite
|
|
63
|
+
.prepare(
|
|
64
|
+
"SELECT collection_id FROM path_registry WHERE path = 'thoughts'",
|
|
65
|
+
)
|
|
66
|
+
.get() as { collection_id: string | null } | undefined;
|
|
67
|
+
expect(row?.collection_id).toBeTruthy();
|
|
68
|
+
}, 120_000);
|
|
69
|
+
});
|
|
@@ -20,32 +20,38 @@ import { parseFrontMatter } from "../lib/hugo-markdown.js";
|
|
|
20
20
|
import type { StorageDriver } from "../lib/storage.js";
|
|
21
21
|
|
|
22
22
|
const CORE_DIR = resolve(import.meta.dirname, "../..");
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
);
|
|
28
|
-
const start = doc.indexOf("### File reference\n");
|
|
23
|
+
|
|
24
|
+
/** The "File reference" section of one language's export page. */
|
|
25
|
+
function readReference(docPath: string, heading: string): string {
|
|
26
|
+
const doc = readFileSync(resolve(CORE_DIR, "../..", docPath), "utf8");
|
|
27
|
+
const start = doc.indexOf(`${heading}\n`);
|
|
29
28
|
const end = doc.indexOf("\n### ", start + 1);
|
|
30
29
|
return doc.slice(start, end);
|
|
31
|
-
}
|
|
32
|
-
const EXPORTER = readFileSync(
|
|
33
|
-
resolve(CORE_DIR, "src/services/export.ts"),
|
|
34
|
-
"utf8",
|
|
35
|
-
);
|
|
30
|
+
}
|
|
36
31
|
|
|
37
|
-
/** Every backticked name in
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
(match) => match[1]!,
|
|
47
|
-
),
|
|
32
|
+
/** Every backticked field name in a reference's table rows, prose left out. */
|
|
33
|
+
function tableNames(reference: string): Set<string> {
|
|
34
|
+
return new Set(
|
|
35
|
+
reference
|
|
36
|
+
.split("\n")
|
|
37
|
+
.filter((line) => line.startsWith("| `"))
|
|
38
|
+
.flatMap((line) =>
|
|
39
|
+
[...line.matchAll(/`([a-z][a-z_]*)`/g)].map((match) => match[1]!),
|
|
40
|
+
),
|
|
48
41
|
);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const REFERENCE = readReference(
|
|
45
|
+
"docs/export-and-import.md",
|
|
46
|
+
"### File reference",
|
|
47
|
+
);
|
|
48
|
+
const REFERENCE_ZH = readReference(
|
|
49
|
+
"docs/zh-Hans/export-and-import.md",
|
|
50
|
+
"### 文件字段一览",
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
/** Every field the tables name, in either column: the documented fields. */
|
|
54
|
+
const documented = tableNames(REFERENCE);
|
|
49
55
|
|
|
50
56
|
function memoryStorage(): StorageDriver {
|
|
51
57
|
const files = new Map<string, Uint8Array>();
|
|
@@ -89,7 +95,7 @@ async function exportRichSite() {
|
|
|
89
95
|
description: "Thinking",
|
|
90
96
|
sortOrder: "oldest",
|
|
91
97
|
});
|
|
92
|
-
await services.smartCollections.create({
|
|
98
|
+
const shelf = await services.smartCollections.create({
|
|
93
99
|
slug: "quote-shelf",
|
|
94
100
|
title: "Quotes",
|
|
95
101
|
description: "Kept",
|
|
@@ -150,6 +156,17 @@ async function exportRichSite() {
|
|
|
150
156
|
width: 16,
|
|
151
157
|
height: 9,
|
|
152
158
|
});
|
|
159
|
+
await storage.put("media/site/a.m4a", new Uint8Array([1]));
|
|
160
|
+
await services.media.create({
|
|
161
|
+
filename: "a.m4a",
|
|
162
|
+
originalName: "a.m4a",
|
|
163
|
+
mimeType: "audio/mp4",
|
|
164
|
+
size: 1,
|
|
165
|
+
storageKey: "media/site/a.m4a",
|
|
166
|
+
postId: root.id,
|
|
167
|
+
durationSeconds: 3,
|
|
168
|
+
waveform: "[0,0.5,1]",
|
|
169
|
+
});
|
|
153
170
|
await services.posts.create({
|
|
154
171
|
format: "link",
|
|
155
172
|
title: "A link",
|
|
@@ -193,6 +210,10 @@ async function exportRichSite() {
|
|
|
193
210
|
collectionId: ideas.id,
|
|
194
211
|
});
|
|
195
212
|
await services.navItems.create({ type: "page", postId: page.id });
|
|
213
|
+
await services.navItems.create({
|
|
214
|
+
type: "smart_collection",
|
|
215
|
+
smartCollectionId: shelf.id,
|
|
216
|
+
});
|
|
196
217
|
await services.collections.createDirectoryItem({
|
|
197
218
|
type: "divider",
|
|
198
219
|
label: "More",
|
|
@@ -212,6 +233,7 @@ async function exportRichSite() {
|
|
|
212
233
|
additionalLanguages: ["zh-Hans"],
|
|
213
234
|
siteFooter: "Made by **me**",
|
|
214
235
|
siteAvatarUrl: "https://example.com/avatar.png",
|
|
236
|
+
faviconVersion: "202609280000",
|
|
215
237
|
}),
|
|
216
238
|
{ storage },
|
|
217
239
|
).generateHugoFiles();
|
|
@@ -232,22 +254,63 @@ function keysOf(value: unknown, into: Set<string>): Set<string> {
|
|
|
232
254
|
return into;
|
|
233
255
|
}
|
|
234
256
|
|
|
257
|
+
/** Every front-matter field and data key a rich site's export writes. */
|
|
258
|
+
async function writtenKeys(): Promise<Set<string>> {
|
|
259
|
+
const written = new Set<string>();
|
|
260
|
+
for (const file of await exportRichSite()) {
|
|
261
|
+
if (isStoredExportFile(file)) continue;
|
|
262
|
+
const content =
|
|
263
|
+
typeof file.content === "string"
|
|
264
|
+
? file.content
|
|
265
|
+
: new TextDecoder().decode(file.content);
|
|
266
|
+
if (file.path.startsWith("content/") && file.path.endsWith(".md")) {
|
|
267
|
+
keysOf((await parseFrontMatter(content)).frontMatter, written);
|
|
268
|
+
} else if (file.path === "data/jant.toml") {
|
|
269
|
+
const { parse } = await import("smol-toml");
|
|
270
|
+
keysOf(parse(content), written);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
return written;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* Documented names the rich site doesn't produce. Each is written only under
|
|
278
|
+
* a condition the fixture doesn't meet, or names a value rather than a key.
|
|
279
|
+
*/
|
|
280
|
+
const NOT_IN_FIXTURE = new Set([
|
|
281
|
+
// Values named in a field's notes, not keys.
|
|
282
|
+
"post",
|
|
283
|
+
"note",
|
|
284
|
+
"link",
|
|
285
|
+
"quote",
|
|
286
|
+
"published",
|
|
287
|
+
"draft",
|
|
288
|
+
"public",
|
|
289
|
+
"latest_hidden",
|
|
290
|
+
"private",
|
|
291
|
+
"image",
|
|
292
|
+
"video",
|
|
293
|
+
"audio",
|
|
294
|
+
"text",
|
|
295
|
+
"document",
|
|
296
|
+
"collection",
|
|
297
|
+
"smart_collection",
|
|
298
|
+
"newest",
|
|
299
|
+
"oldest",
|
|
300
|
+
"rating_desc",
|
|
301
|
+
"list",
|
|
302
|
+
"grid",
|
|
303
|
+
"render",
|
|
304
|
+
"true",
|
|
305
|
+
"static",
|
|
306
|
+
// Written only for a custom URL of the retired archive kind, which can
|
|
307
|
+
// no longer be created.
|
|
308
|
+
"archive_query",
|
|
309
|
+
]);
|
|
310
|
+
|
|
235
311
|
describe("export file reference", () => {
|
|
236
312
|
it("lists every field and data key the export writes", async () => {
|
|
237
|
-
const written =
|
|
238
|
-
for (const file of await exportRichSite()) {
|
|
239
|
-
if (isStoredExportFile(file)) continue;
|
|
240
|
-
const content =
|
|
241
|
-
typeof file.content === "string"
|
|
242
|
-
? file.content
|
|
243
|
-
: new TextDecoder().decode(file.content);
|
|
244
|
-
if (file.path.startsWith("content/") && file.path.endsWith(".md")) {
|
|
245
|
-
keysOf((await parseFrontMatter(content)).frontMatter, written);
|
|
246
|
-
} else if (file.path === "data/jant.toml") {
|
|
247
|
-
const { parse } = await import("smol-toml");
|
|
248
|
-
keysOf(parse(content), written);
|
|
249
|
-
}
|
|
250
|
-
}
|
|
313
|
+
const written = await writtenKeys();
|
|
251
314
|
|
|
252
315
|
expect(written.size).toBeGreaterThan(60);
|
|
253
316
|
expect([...written].filter((key) => !documented.has(key)).sort()).toEqual(
|
|
@@ -255,10 +318,19 @@ describe("export file reference", () => {
|
|
|
255
318
|
);
|
|
256
319
|
});
|
|
257
320
|
|
|
258
|
-
it("lists only fields the
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
321
|
+
it("lists only fields the export still writes", async () => {
|
|
322
|
+
const written = await writtenKeys();
|
|
323
|
+
|
|
324
|
+
expect(
|
|
325
|
+
[...documented]
|
|
326
|
+
.filter((name) => !written.has(name) && !NOT_IN_FIXTURE.has(name))
|
|
327
|
+
.sort(),
|
|
328
|
+
).toEqual([]);
|
|
329
|
+
});
|
|
330
|
+
|
|
331
|
+
it("names the same fields in the Chinese reference", () => {
|
|
332
|
+
expect([...tableNames(REFERENCE_ZH)].sort()).toEqual(
|
|
333
|
+
[...documented].sort(),
|
|
262
334
|
);
|
|
263
335
|
});
|
|
264
336
|
});
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The export's format version moves whenever what `site import` reads does.
|
|
3
|
+
*
|
|
4
|
+
* `site import` refuses an export whose `data/jant.toml` carries a format
|
|
5
|
+
* version newer than it reads, and imports anything up to it. That only
|
|
6
|
+
* protects anyone if the version rises when the import starts reading
|
|
7
|
+
* something new: an older Jant given a newer export otherwise imports it,
|
|
8
|
+
* drops the field it has never heard of, and says nothing. The version stayed
|
|
9
|
+
* at 1 while fields came and went.
|
|
10
|
+
*
|
|
11
|
+
* docs/export-and-import.md's File reference lists every field the export
|
|
12
|
+
* writes (export-docs.test.ts holds it to the exporter), and marks the ones
|
|
13
|
+
* `site import` doesn't read "Theme only". The fields it reads are frozen here
|
|
14
|
+
* per format version, in `fixtures/export-format/<version>.json`. Adding one,
|
|
15
|
+
* dropping one, or starting to read a theme-only one fails this until
|
|
16
|
+
* `SITE_EXPORT_FORMAT_VERSION` is raised and the next fixture written.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import { existsSync, readdirSync, readFileSync } from "node:fs";
|
|
20
|
+
import { join, resolve } from "node:path";
|
|
21
|
+
import { describe, expect, it } from "vitest";
|
|
22
|
+
import { SITE_EXPORT_FORMAT_VERSION } from "../services/export.js";
|
|
23
|
+
|
|
24
|
+
const CORE_DIR = resolve(import.meta.dirname, "../..");
|
|
25
|
+
const FIXTURES = join(import.meta.dirname, "fixtures/export-format");
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Fields the File reference says `site import` reads, as `table: field`.
|
|
29
|
+
* A table is named by the caption above it, up to its colon.
|
|
30
|
+
*/
|
|
31
|
+
function importedFields(): string[] {
|
|
32
|
+
const doc = readFileSync(
|
|
33
|
+
resolve(CORE_DIR, "../../docs/export-and-import.md"),
|
|
34
|
+
"utf8",
|
|
35
|
+
);
|
|
36
|
+
const start = doc.indexOf("### File reference\n");
|
|
37
|
+
const section = doc.slice(start, doc.indexOf("\n### ", start + 1));
|
|
38
|
+
|
|
39
|
+
const fields: string[] = [];
|
|
40
|
+
let caption = "";
|
|
41
|
+
for (const line of section.split("\n")) {
|
|
42
|
+
if (line && !line.startsWith("|") && !line.startsWith("#")) {
|
|
43
|
+
caption = line.split(":")[0]!.replace(/`/g, "").trim();
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
if (!line.startsWith("| `")) continue;
|
|
47
|
+
const [, names = "", ...rest] = line.split("|");
|
|
48
|
+
const notes = rest.at(-2)?.trim() ?? "";
|
|
49
|
+
if (/^Theme only\b/.test(notes)) continue;
|
|
50
|
+
for (const [, name] of names.matchAll(/`([a-z][a-z_]*)`/g)) {
|
|
51
|
+
fields.push(`${caption}: ${name}`);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return [...new Set(fields)].sort();
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function fixtureVersions(): number[] {
|
|
58
|
+
return readdirSync(FIXTURES)
|
|
59
|
+
.map((name) => /^(\d+)\.json$/.exec(name)?.[1])
|
|
60
|
+
.filter((version): version is string => version !== undefined)
|
|
61
|
+
.map(Number)
|
|
62
|
+
.sort((a, b) => a - b);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
describe("export format version", () => {
|
|
66
|
+
it("has a frozen field list for every version, the current one last", () => {
|
|
67
|
+
const versions = fixtureVersions();
|
|
68
|
+
expect(versions.at(-1)).toBe(SITE_EXPORT_FORMAT_VERSION);
|
|
69
|
+
expect(versions).toEqual(
|
|
70
|
+
Array.from({ length: versions.length }, (_, i) => i + 1),
|
|
71
|
+
);
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it("changes when the fields site import reads change", () => {
|
|
75
|
+
const fixture = join(FIXTURES, `${SITE_EXPORT_FORMAT_VERSION}.json`);
|
|
76
|
+
expect(existsSync(fixture)).toBe(true);
|
|
77
|
+
const frozen = JSON.parse(readFileSync(fixture, "utf8")) as string[];
|
|
78
|
+
const current = importedFields();
|
|
79
|
+
|
|
80
|
+
expect(current.length).toBeGreaterThan(40);
|
|
81
|
+
expect(
|
|
82
|
+
current,
|
|
83
|
+
`site import now reads a different set of fields than format version ${SITE_EXPORT_FORMAT_VERSION} froze. ` +
|
|
84
|
+
`Raise SITE_EXPORT_FORMAT_VERSION and SUPPORTED_SITE_EXPORT_VERSION to ${SITE_EXPORT_FORMAT_VERSION + 1} ` +
|
|
85
|
+
`and write fixtures/export-format/${SITE_EXPORT_FORMAT_VERSION + 1}.json with this list. Never edit an existing one.`,
|
|
86
|
+
).toEqual(frozen);
|
|
87
|
+
});
|
|
88
|
+
});
|