@jant/core 0.7.0 → 0.8.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/assets/prepare.js +3 -3
- package/bin/commands/db/export.js +115 -2
- package/bin/commands/deploy.js +11 -3
- package/bin/commands/{search-reindex.js → search/reindex.js} +5 -5
- package/bin/commands/setup.js +136 -0
- package/bin/commands/site/export.js +117 -68
- package/bin/commands/site/import.js +3074 -2
- package/bin/commands/site/pull-media.js +2 -6
- package/bin/commands/site/snapshot/export.js +18 -60
- package/bin/commands/site/snapshot/import.js +24 -23
- package/bin/commands/telegram/register-webhooks.js +48 -23
- package/bin/jant.js +16 -11
- package/bin/lib/command-registry.js +120 -0
- package/bin/lib/d1-query.js +87 -2
- package/bin/lib/hugo-markdown.js +4 -0
- package/bin/lib/migration-artifacts.js +19 -0
- package/bin/lib/renamed-arguments.js +56 -0
- package/bin/lib/site-pull-media.js +21 -28
- package/bin/lib/site-selection.js +10 -1
- package/bin/lib/site-snapshot.js +421 -4
- package/bin/lib/sql-export.js +68 -5
- package/bin/lib/wrangler-cli.js +9 -0
- package/bin/lib/zip-archive.js +187 -0
- package/dist/{app-K_Aa1MMn.js → app-CFsmRVJN.js} +8629 -697
- package/dist/client/.vite/manifest.json +20 -20
- package/dist/client/_assets/chunks/{create-editor-CD3FhrOB.js → create-editor-B-m7X7S5.js} +50 -46
- package/dist/client/_assets/chunks/{sortable-list-CgaL2jCs.js → sortable-list-BJyd-LXE.js} +1 -1
- package/dist/client/_assets/chunks/{unsafe-svg-0QCkP0vZ.js → unsafe-svg-BkscJx69.js} +2 -2
- package/dist/client/_assets/{client-GiYENVw8.css → client-BCumu1-D.css} +1 -1
- package/dist/client/_assets/{client-VnFxJN7G.js → client-DTLBOHqD.js} +1 -1
- package/dist/client/_assets/{client-auth-k8gJ6QJj.js → client-auth-D6Ix6SmE.js} +1 -1
- package/dist/client/_assets/{client-compose-B_kDtWkW.js → client-compose-D6rExKVK.js} +1 -1
- package/dist/client/_assets/{client-manage-M90aSTOk.js → client-manage-sVOkqVbH.js} +1 -1
- package/dist/client/_assets/{client-settings-DfYs9n1F.js → client-settings-CGR_nZ78.js} +7 -7
- package/dist/index.js +2 -3
- package/dist/node.js +8 -5
- package/dist/url-CKlGzvdN.js +428 -0
- package/package.json +13 -7
- package/src/__tests__/cli-commands.test.ts +144 -0
- package/src/__tests__/config-docs.test.ts +148 -0
- package/src/__tests__/dev-scripts.test.ts +203 -0
- package/src/__tests__/export-collection-order.test.ts +276 -0
- package/src/__tests__/export-feed-ids.test.ts +184 -0
- package/src/__tests__/export-feed-order.test.ts +294 -0
- package/src/__tests__/export-hugo-build.test.ts +130 -0
- package/src/__tests__/export-import-roundtrip.test.ts +95 -1
- package/src/__tests__/export-service.test.ts +611 -28
- package/src/__tests__/export-smart-collection.test.ts +329 -0
- package/src/__tests__/feed-docs.test.ts +36 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/README.md +89 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/41q27/0x4nv/index.md +16 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/41q27/_index.md +41 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/41q27/faqyt/index.md +28 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/41q27/the-potting-mix-guide-i-keep-rereading/index.md +18 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/_index.md +4 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/a-night-heron-field-guide-for-my-walk-folder/_index.md +27 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/a-quiet-saturday-after-a-busy-week/_index.md +32 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/archive/_index.md +7 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/are-na-is-the-only-bookmark-pile-i-still-revisit/_index.md +27 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/bought-too-many-lemons-again/_index.md +34 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/city-walks/_index.md +11 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/collections/_index.md +4 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/current-tea-rotation/_index.md +31 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/derek-sivers-still-writes-the-kind-of-internet-i-want-more-of/_index.md +27 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/desk-but-better/_index.md +22 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/e0kcg/_index.md +19 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/featured/_index.md +7 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/from-basho/_index.md +22 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/from-epictetus/_index.md +22 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/from-marcus-aurelius/_index.md +22 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/from-seneca/_index.md +22 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/from-thoreau/_index.md +22 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/gkbvv/2cl6d/index.md +16 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/gkbvv/3zqv7/index.md +28 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/gkbvv/5oxsv/index.md +16 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/gkbvv/_index.md +36 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/home-cooking/_index.md +11 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/k5vh8/_index.md +29 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/k5vh8/a-reading-log-idea-i-might-steal/index.md +18 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/k5vh8/a83qu/index.md +16 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/k5vh8/from-seneca-5hibo/index.md +19 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/mynoise-for-rainy-afternoons/_index.md +27 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/nts-archives-are-good-cleaning-music/_index.md +27 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/qgfcu/_index.md +29 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/qgfcu/c91j0/index.md +16 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/qgfcu/qyucy/index.md +16 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/qgfcu/wsgck/index.md +16 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/rain-makes-my-neighborhood-look-better/_index.md +43 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/reading-notes/_index.md +11 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/serious-eats-on-tomato-and-egg-soup/_index.md +27 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/te812/_index.md +41 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/te812/cxiu6/index.md +16 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/te812/t77ms/index.md +16 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/te812/the-soup-trick-i-always-forget/index.md +18 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/telk3/_index.md +27 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/telk3/from-thoreau-pawt2/index.md +17 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/the-five-minute-reset-is-still-the-best-habit-i-have/_index.md +32 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/the-hallway-light-took-12-minutes-and-3-months/_index.md +29 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/the-recurse-center-manual-is-weirdly-calming/_index.md +27 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/tiny-projects/_index.md +11 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/useful-links/_index.md +11 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/weekend-notes/_index.md +11 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/what-i-actually-use-my-notebook-for/_index.md +49 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/data/jant.toml +119 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/hugo.toml +43 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/static/media/021801c20ab3-med_01kn8jw26cenf98vc7k0ppz5k8.webp +0 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/static/media/0f868ce9ac84-med_01kn8jtx8qenf98tm9ahxr48sw.webp +0 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/static/media/50c2ad911bad-med_01kn8jvb16enf98txp7p0pf5ge.webp +0 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/static/media/7a91f0960491-med_01kn8jvq58enf98v538w5vsqp4.webp +0 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/static/media/8714116d3c8e-med_01kn8jve5nenf98tzap11gpxzr.webp +0 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/static/media/8a0b4277443f-med_01kn8jv0jdenf98tp6qr9zgjjc.webp +0 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/static/media/a7d1c8a1afd9-med_01kn8jv452enf98trbkwrvhvgd.webp +0 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/static/media/e25570b405f5-med_01kn8jvsaeenf98v6ct4gjzppc.webp +0 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/static/media/e89ea4eabf01-med_01kn8jtq3penf98tfq4gzmh9g9.png +0 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/themes/jant/static/apple-touch-icon.png +0 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/themes/jant/static/custom.css +0 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/themes/jant/static/favicon.ico +0 -0
- package/src/__tests__/fixtures/releases/0.7.0/snapshot/db.sql +218 -0
- package/src/__tests__/fixtures/releases/0.7.0/snapshot/meta.json +9 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/README.md +89 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/41q27/0x4nv/index.md +16 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/41q27/_index.md +41 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/41q27/faqyt/index.md +28 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/41q27/the-potting-mix-guide-i-keep-rereading/index.md +18 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/_index.md +4 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/a-night-heron-field-guide-for-my-walk-folder/_index.md +27 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/a-quiet-saturday-after-a-busy-week/_index.md +32 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/archive/_index.md +7 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/are-na-is-the-only-bookmark-pile-i-still-revisit/_index.md +27 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/bought-too-many-lemons-again/_index.md +34 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/city-walks/_index.md +11 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/collections/_index.md +4 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/current-tea-rotation/_index.md +31 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/derek-sivers-still-writes-the-kind-of-internet-i-want-more-of/_index.md +27 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/desk-but-better/_index.md +22 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/e0kcg/_index.md +19 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/featured/_index.md +7 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/from-basho/_index.md +22 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/from-epictetus/_index.md +22 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/from-marcus-aurelius/_index.md +22 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/from-seneca/_index.md +22 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/from-thoreau/_index.md +22 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/gkbvv/2cl6d/index.md +16 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/gkbvv/3zqv7/index.md +28 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/gkbvv/5oxsv/index.md +16 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/gkbvv/_index.md +36 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/home-cooking/_index.md +11 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/k5vh8/_index.md +29 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/k5vh8/a-reading-log-idea-i-might-steal/index.md +18 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/k5vh8/a83qu/index.md +16 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/k5vh8/from-seneca-5hibo/index.md +19 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/mynoise-for-rainy-afternoons/_index.md +27 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/nts-archives-are-good-cleaning-music/_index.md +27 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/qgfcu/_index.md +29 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/qgfcu/c91j0/index.md +16 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/qgfcu/qyucy/index.md +16 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/qgfcu/wsgck/index.md +16 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/rain-makes-my-neighborhood-look-better/_index.md +43 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/reading-notes/_index.md +11 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/serious-eats-on-tomato-and-egg-soup/_index.md +27 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/te812/_index.md +41 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/te812/cxiu6/index.md +16 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/te812/t77ms/index.md +16 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/te812/the-soup-trick-i-always-forget/index.md +18 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/telk3/_index.md +27 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/telk3/from-thoreau-pawt2/index.md +17 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/the-five-minute-reset-is-still-the-best-habit-i-have/_index.md +32 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/the-hallway-light-took-12-minutes-and-3-months/_index.md +29 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/the-recurse-center-manual-is-weirdly-calming/_index.md +27 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/tiny-projects/_index.md +11 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/useful-links/_index.md +11 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/weekend-notes/_index.md +11 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/what-i-actually-use-my-notebook-for/_index.md +49 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/data/jant.toml +119 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/hugo.toml +43 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/static/media/021801c20ab3-med_01kn8jw26cenf98vc7k0ppz5k8.webp +0 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/static/media/0f868ce9ac84-med_01kn8jtx8qenf98tm9ahxr48sw.webp +0 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/static/media/50c2ad911bad-med_01kn8jvb16enf98txp7p0pf5ge.webp +0 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/static/media/7a91f0960491-med_01kn8jvq58enf98v538w5vsqp4.webp +0 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/static/media/8714116d3c8e-med_01kn8jve5nenf98tzap11gpxzr.webp +0 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/static/media/8a0b4277443f-med_01kn8jv0jdenf98tp6qr9zgjjc.webp +0 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/static/media/a7d1c8a1afd9-med_01kn8jv452enf98trbkwrvhvgd.webp +0 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/static/media/e25570b405f5-med_01kn8jvsaeenf98v6ct4gjzppc.webp +0 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/static/media/e89ea4eabf01-med_01kn8jtq3penf98tfq4gzmh9g9.png +0 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/themes/jant/static/apple-touch-icon.png +0 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/themes/jant/static/custom.css +0 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/themes/jant/static/favicon.ico +0 -0
- package/src/__tests__/fixtures/releases/0.7.1/snapshot/db.sql +322 -0
- package/src/__tests__/fixtures/releases/0.7.1/snapshot/meta.json +9 -0
- package/src/__tests__/helpers/hugo-site.ts +146 -0
- package/src/__tests__/helpers/site-export-import.ts +97 -0
- package/src/__tests__/import-site-command.test.ts +514 -2
- package/src/__tests__/mise-config.test.ts +75 -4
- package/src/__tests__/node-dev-tasks.test.ts +264 -0
- package/src/__tests__/release-fixtures.test.ts +132 -0
- package/src/__tests__/site-export-canonical-import.test.ts +113 -0
- package/src/__tests__/snapshot-canonical-replay.test.ts +179 -0
- package/src/__tests__/snapshot-settings.test.ts +97 -0
- package/src/__tests__/snapshot-tables.test.ts +219 -0
- package/src/__tests__/sql-export.test.ts +173 -0
- package/src/__tests__/theme-docs.test.ts +109 -0
- package/src/__tests__/zip-archive.test.ts +106 -0
- package/src/app.tsx +16 -11
- package/src/client/components/__tests__/jant-settings-avatar.test.ts +1 -1
- package/src/client/components/__tests__/jant-settings-general.test.ts +21 -1
- package/src/client/components/jant-repo-picker-types.ts +6 -1
- package/src/client/components/jant-repo-picker.ts +4 -7
- package/src/client/components/jant-settings-general.ts +17 -12
- package/src/client/tiptap/__tests__/list-editing.test.ts +224 -86
- package/src/client/tiptap/__tests__/mark-exit.test.ts +1 -2
- package/src/client/tiptap/__tests__/markdown-clipboard.test.ts +26 -0
- package/src/client/tiptap/extensions.ts +0 -3
- package/src/client/tiptap/structural-keymap.ts +158 -47
- package/src/db/__tests__/d1-query.test.ts +56 -1
- package/src/db/rehearsal-fixtures/pg-demo-current.json +55 -0
- package/src/db/rehearsal-fixtures/pg-demo-current.sql +431 -0
- package/src/i18n/locales/public/en.po +0 -2
- package/src/i18n/locales/public/zh-Hans.po +0 -2
- package/src/i18n/locales/public/zh-Hant.po +0 -2
- package/src/i18n/locales/settings/en.po +8 -8
- package/src/i18n/locales/settings/en.ts +1 -1
- package/src/i18n/locales/settings/zh-Hans.po +8 -8
- package/src/i18n/locales/settings/zh-Hans.ts +1 -1
- package/src/i18n/locales/settings/zh-Hant.po +8 -8
- package/src/i18n/locales/settings/zh-Hant.ts +1 -1
- package/src/index.ts +6 -77
- package/src/lib/__tests__/github-sync-repo-name.test.ts +40 -0
- package/src/lib/__tests__/image.test.ts +27 -1
- package/src/lib/__tests__/markdown-to-tiptap.test.ts +105 -0
- package/src/lib/__tests__/markdown.test.ts +10 -0
- package/src/lib/__tests__/resolve-config.test.ts +67 -0
- package/src/lib/__tests__/schemas.test.ts +27 -1
- package/src/lib/__tests__/timeline.test.ts +87 -0
- package/src/lib/__tests__/tiptap-to-markdown.test.ts +172 -4
- package/src/lib/__tests__/view.test.ts +0 -46
- package/src/lib/discover.ts +3 -1
- package/src/lib/feed.ts +0 -6
- package/src/lib/github-sync-repo-name.ts +45 -0
- package/src/lib/hugo-markdown.ts +46 -0
- package/src/lib/image.ts +17 -4
- package/src/lib/markdown-manager.ts +392 -2
- package/src/lib/post-body-html.ts +11 -4
- package/src/lib/resolve-config.ts +58 -1
- package/src/lib/schemas.ts +50 -5
- package/src/lib/thread-fold.ts +3 -3
- package/src/lib/timeline.ts +1 -1
- package/src/lib/tiptap-to-markdown.ts +13 -7
- package/src/lib/url.ts +20 -0
- package/src/lib/view.ts +2 -29
- package/src/node/__tests__/cli-export.test.ts +2 -2
- package/src/node/__tests__/cli-setup.test.ts +163 -0
- package/src/node/__tests__/cli-site-snapshot.test.ts +73 -0
- package/src/node/__tests__/cli-site-token-env.test.ts +4 -1
- package/src/node/__tests__/cli-snapshot-meta.test.ts +84 -0
- package/src/node/__tests__/runtime.test.ts +38 -0
- package/src/node/index.ts +2 -0
- package/src/node/request-handler.ts +3 -1
- package/src/routes/api/__tests__/posts.test.ts +24 -0
- package/src/routes/api/__tests__/upload.test.ts +34 -0
- package/src/routes/api/export.ts +3 -3
- package/src/routes/api/internal/search-reindex.ts +1 -1
- package/src/routes/api/internal/sites.ts +0 -1
- package/src/routes/api/posts.ts +2 -0
- package/src/routes/api/public/posts.ts +21 -1
- package/src/routes/api/upload.ts +10 -3
- package/src/routes/compose.tsx +4 -0
- package/src/routes/dash/__tests__/github-sync-app.test.ts +365 -0
- package/src/routes/dash/settings.tsx +212 -70
- package/src/routes/pages/__tests__/post-page-round-trips.test.ts +211 -0
- package/src/routes/pages/__tests__/thread-order.test.ts +179 -0
- package/src/routes/pages/archive.tsx +17 -11
- package/src/routes/pages/featured.tsx +11 -5
- package/src/routes/pages/page.tsx +53 -31
- package/src/routes/pages/search.tsx +4 -2
- package/src/runtime/__tests__/readiness.test.ts +23 -0
- package/src/runtime/node.ts +49 -0
- package/src/runtime/readiness.ts +15 -0
- package/src/services/__tests__/bootstrap-setup-instance.test.ts +230 -0
- package/src/services/__tests__/custom-url.test.ts +34 -0
- package/src/services/__tests__/github-app-installations.test.ts +153 -0
- package/src/services/__tests__/github-sync-push.test.ts +46 -0
- package/src/services/__tests__/media.test.ts +31 -271
- package/src/services/__tests__/path.test.ts +56 -0
- package/src/services/__tests__/post-timeline.test.ts +127 -0
- package/src/services/__tests__/post.test.ts +74 -0
- package/src/services/bootstrap.ts +263 -44
- package/src/services/custom-url.ts +2 -2
- package/src/services/export-theme/layouts/_default/alias.html +27 -1
- package/src/services/export-theme/layouts/_default/list.html +2 -63
- package/src/services/export-theme/layouts/_default/rss.xml +27 -38
- package/src/services/export-theme/layouts/collections/list.html +3 -3
- package/src/services/export-theme/layouts/featured/list.html +1 -4
- package/src/services/export-theme/layouts/index.html +40 -26
- package/src/services/export-theme/layouts/partials/collection-members.html +100 -0
- package/src/services/export-theme/layouts/partials/collection-threads.html +33 -0
- package/src/services/export-theme/layouts/partials/featured-members.html +35 -0
- package/src/services/export-theme/layouts/partials/featured-thread.html +1 -1
- package/src/services/export-theme/layouts/partials/footer.html +1 -1
- package/src/services/export-theme/layouts/partials/head.html +1 -1
- package/src/services/export-theme/layouts/partials/header.html +5 -3
- package/src/services/export-theme/layouts/partials/jant-data.html +23 -0
- package/src/services/export-theme/layouts/partials/latest-members.html +48 -0
- package/src/services/export-theme/layouts/partials/smart-collection-members.html +129 -0
- package/src/services/export-theme/layouts/partials/thread-preview.html +1 -1
- package/src/services/export-theme/layouts/post/list.html +1 -1
- package/src/services/export-theme/layouts/smart_collection/list.html +24 -0
- package/src/services/export-theme/styles/main.css +0 -1
- package/src/services/export-theme/theme.toml +1 -1
- package/src/services/export.ts +630 -73
- package/src/services/github-app-installations.ts +171 -4
- package/src/services/github-sync.ts +69 -15
- package/src/services/mcp.ts +19 -1
- package/src/services/media.ts +9 -220
- package/src/services/path.ts +34 -1
- package/src/services/post.ts +214 -39
- package/src/services/site-admin.ts +3 -7
- package/src/services/site.ts +83 -31
- package/src/styles/ui.css +7 -119
- package/src/types/app-context.ts +16 -0
- package/src/types/bindings.ts +5 -0
- package/src/types/operations.ts +10 -0
- package/src/ui/dash/settings/GeneralContent.tsx +10 -8
- package/bin/commands/export.js +0 -118
- package/bin/commands/import-site.js +0 -2561
- package/bin/commands/migrate-text-attachments.js +0 -181
- package/dist/github-sync-BPAvT999.js +0 -7709
- package/src/client/multipart-upload.ts +0 -206
- package/src/client/tiptap/exitable-marks.ts +0 -73
- package/src/routes/api/__tests__/upload-multipart.test.ts +0 -739
- package/src/routes/api/internal/text-attachments.ts +0 -60
- package/src/routes/api/upload-multipart.ts +0 -366
package/src/lib/url.ts
CHANGED
|
@@ -486,6 +486,26 @@ export function toPublicPath(path: string, sitePathPrefix = ""): string {
|
|
|
486
486
|
return `${sitePathPrefix}${normalizedPath}`;
|
|
487
487
|
}
|
|
488
488
|
|
|
489
|
+
/**
|
|
490
|
+
* The internal path a Post is served at: its oldest custom path when it has
|
|
491
|
+
* one, else its slug.
|
|
492
|
+
*
|
|
493
|
+
* This is the Post's permalink before the site path prefix, and so the `<id>`
|
|
494
|
+
* of its Atom entry. The Hugo export writes that `<id>` into front matter so
|
|
495
|
+
* an exported feed keeps it, which is why the rule lives here rather than
|
|
496
|
+
* inside `toPostView`.
|
|
497
|
+
*
|
|
498
|
+
* @param slug - The Post's current slug
|
|
499
|
+
* @param aliasPath - Its oldest custom path, `paths.getPostAliases()`'s first
|
|
500
|
+
* @returns Internal path rooted at `/`
|
|
501
|
+
* @example
|
|
502
|
+
* getPostPath("xta29"); // "/xta29"
|
|
503
|
+
* getPostPath("links-4", "/blog/links/4"); // "/blog/links/4"
|
|
504
|
+
*/
|
|
505
|
+
export function getPostPath(slug: string, aliasPath?: string): string {
|
|
506
|
+
return aliasPath ?? `/${slug}`;
|
|
507
|
+
}
|
|
508
|
+
|
|
489
509
|
/**
|
|
490
510
|
* Convert an app-local href to its public path while leaving external URLs
|
|
491
511
|
* unchanged.
|
package/src/lib/view.ts
CHANGED
|
@@ -47,7 +47,7 @@ import {
|
|
|
47
47
|
} from "./summary.js";
|
|
48
48
|
import { renderTiptapDocumentAroundBoundary } from "./tiptap-render.js";
|
|
49
49
|
import { highlightText } from "./search-snippet.js";
|
|
50
|
-
import { isFullUrl, toPublicPath, toSameSitePath } from "./url.js";
|
|
50
|
+
import { getPostPath, isFullUrl, toPublicPath, toSameSitePath } from "./url.js";
|
|
51
51
|
|
|
52
52
|
// =============================================================================
|
|
53
53
|
// Media Context
|
|
@@ -260,7 +260,7 @@ export function toPostView(
|
|
|
260
260
|
): PostView {
|
|
261
261
|
const id = post.id;
|
|
262
262
|
const permalink = toPublicPath(
|
|
263
|
-
|
|
263
|
+
getPostPath(post.slug, aliasPath),
|
|
264
264
|
ctx.sitePathPrefix,
|
|
265
265
|
);
|
|
266
266
|
const timeZone = ctx.timeZone ?? "UTC";
|
|
@@ -724,35 +724,8 @@ export function toSearchResultViews(
|
|
|
724
724
|
// Archive Group Conversions
|
|
725
725
|
// =============================================================================
|
|
726
726
|
|
|
727
|
-
/**
|
|
728
|
-
* Converts a grouped post map to typed ArchiveGroup[].
|
|
729
|
-
*/
|
|
730
|
-
export function toArchiveGroups(
|
|
731
|
-
grouped: Map<string, Post[]>,
|
|
732
|
-
ctx: MediaContext,
|
|
733
|
-
aliasMap?: Map<string, string>,
|
|
734
|
-
): ArchiveGroup[] {
|
|
735
|
-
const groups: ArchiveGroup[] = [];
|
|
736
|
-
for (const [yearMonth, posts] of grouped) {
|
|
737
|
-
const [year, month] = yearMonth.split("-");
|
|
738
|
-
if (!year || !month) continue;
|
|
739
|
-
|
|
740
|
-
const label = formatYearMonthLabel(yearMonth);
|
|
741
|
-
if (!label) continue;
|
|
742
|
-
|
|
743
|
-
groups.push({
|
|
744
|
-
year,
|
|
745
|
-
month,
|
|
746
|
-
label,
|
|
747
|
-
posts: toPostViewsFromPosts(posts, ctx, undefined, aliasMap),
|
|
748
|
-
});
|
|
749
|
-
}
|
|
750
|
-
return groups;
|
|
751
|
-
}
|
|
752
|
-
|
|
753
727
|
/**
|
|
754
728
|
* Converts a grouped PostWithMedia map to typed ArchiveGroup[].
|
|
755
|
-
* Unlike toArchiveGroups, this preserves media attachments on each post.
|
|
756
729
|
*
|
|
757
730
|
* @param grouped - Map of "YYYY-MM" keys to PostWithMedia arrays
|
|
758
731
|
* @param ctx - Media context for URL computation
|
|
@@ -3,11 +3,11 @@ import { tmpdir } from "node:os";
|
|
|
3
3
|
import { join } from "node:path";
|
|
4
4
|
import Database from "better-sqlite3";
|
|
5
5
|
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
6
|
-
import { run } from "../../../bin/commands/export.js";
|
|
6
|
+
import { run } from "../../../bin/commands/db/export.js";
|
|
7
7
|
import { migrate } from "../runtime.js";
|
|
8
8
|
import type { Bindings } from "../../types.js";
|
|
9
9
|
|
|
10
|
-
describe("jant export", () => {
|
|
10
|
+
describe("jant db export", () => {
|
|
11
11
|
const tempDirs: string[] = [];
|
|
12
12
|
const originalEnv = process.env.DATABASE_URL;
|
|
13
13
|
const siteId = "sit_01jpyz1h3v4m7s2k8r5c9t0qbd";
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { mkdtemp, rm } from "node:fs/promises";
|
|
2
|
+
import { tmpdir } from "node:os";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import { Readable } from "node:stream";
|
|
5
|
+
import Database from "better-sqlite3";
|
|
6
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
7
|
+
import { run } from "../../../bin/commands/setup.js";
|
|
8
|
+
import { verifyPassword } from "../../lib/password.js";
|
|
9
|
+
import type { Bindings } from "../../types.js";
|
|
10
|
+
import { migrate } from "../runtime.js";
|
|
11
|
+
|
|
12
|
+
const SITE_ID = "sit_01kn8jq3t4famtyg9hjd074ckr";
|
|
13
|
+
const ENV_KEYS = [
|
|
14
|
+
"DATABASE_URL",
|
|
15
|
+
"DATA_DIR",
|
|
16
|
+
"SITE_ORIGIN",
|
|
17
|
+
"SITE_RESOLUTION_MODE",
|
|
18
|
+
] as const;
|
|
19
|
+
|
|
20
|
+
function pipe(text: string) {
|
|
21
|
+
return { stdin: Readable.from([text]) };
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
describe("jant setup", () => {
|
|
25
|
+
const originalEnv = Object.fromEntries(
|
|
26
|
+
ENV_KEYS.map((key) => [key, process.env[key]]),
|
|
27
|
+
);
|
|
28
|
+
let root: string;
|
|
29
|
+
let databasePath: string;
|
|
30
|
+
|
|
31
|
+
beforeEach(async () => {
|
|
32
|
+
for (const key of ENV_KEYS) delete process.env[key];
|
|
33
|
+
root = await mkdtemp(join(tmpdir(), "jant-setup-"));
|
|
34
|
+
databasePath = join(root, "jant.sqlite");
|
|
35
|
+
await migrate({ DATABASE_URL: `file:${databasePath}` } as Bindings);
|
|
36
|
+
process.env.DATABASE_URL = `file:${databasePath}`;
|
|
37
|
+
vi.spyOn(console, "log").mockImplementation(() => {});
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
afterEach(async () => {
|
|
41
|
+
for (const [key, value] of Object.entries(originalEnv)) {
|
|
42
|
+
if (value === undefined) delete process.env[key];
|
|
43
|
+
else process.env[key] = value;
|
|
44
|
+
}
|
|
45
|
+
await rm(root, { recursive: true, force: true });
|
|
46
|
+
vi.restoreAllMocks();
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
function readDatabase<T>(read: (sqlite: Database.Database) => T): T {
|
|
50
|
+
const sqlite = new Database(databasePath, { readonly: true });
|
|
51
|
+
try {
|
|
52
|
+
return read(sqlite);
|
|
53
|
+
} finally {
|
|
54
|
+
sqlite.close();
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
it("sets up the install with the piped password", async () => {
|
|
59
|
+
process.env.SITE_ORIGIN = "https://notes.example.com";
|
|
60
|
+
|
|
61
|
+
const result = await run(
|
|
62
|
+
[
|
|
63
|
+
"--email",
|
|
64
|
+
"Owner@Example.com",
|
|
65
|
+
"--password-stdin",
|
|
66
|
+
"--site-id",
|
|
67
|
+
SITE_ID,
|
|
68
|
+
"--site-name",
|
|
69
|
+
"Field Notes",
|
|
70
|
+
],
|
|
71
|
+
// `echo` ends the password with a line break that is not part of it.
|
|
72
|
+
pipe("correct horse\n"),
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
expect(result).toEqual({ outcome: "created", siteId: SITE_ID });
|
|
76
|
+
expect(console.log).toHaveBeenCalledWith(`Set up site ${SITE_ID}.`);
|
|
77
|
+
|
|
78
|
+
const stored = readDatabase((sqlite) => ({
|
|
79
|
+
email: sqlite.prepare('SELECT email FROM "user"').pluck().get(),
|
|
80
|
+
hash: sqlite.prepare('SELECT password FROM "account"').pluck().get(),
|
|
81
|
+
host: sqlite.prepare('SELECT host FROM "site_domain"').pluck().get(),
|
|
82
|
+
status: sqlite
|
|
83
|
+
.prepare(
|
|
84
|
+
`SELECT value FROM "site_setting" WHERE "key" = 'ONBOARDING_STATUS'`,
|
|
85
|
+
)
|
|
86
|
+
.pluck()
|
|
87
|
+
.get(),
|
|
88
|
+
}));
|
|
89
|
+
expect(stored).toMatchObject({
|
|
90
|
+
email: "owner@example.com",
|
|
91
|
+
host: "notes.example.com",
|
|
92
|
+
status: "completed",
|
|
93
|
+
});
|
|
94
|
+
expect(
|
|
95
|
+
await verifyPassword({
|
|
96
|
+
hash: String(stored.hash),
|
|
97
|
+
password: "correct horse",
|
|
98
|
+
}),
|
|
99
|
+
).toBe(true);
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
it("changes nothing when run again", async () => {
|
|
103
|
+
const args = ["--email", "owner@example.com", "--password-stdin"];
|
|
104
|
+
const first = await run(args, pipe("correct horse"));
|
|
105
|
+
const second = await run(args, pipe("a different password"));
|
|
106
|
+
|
|
107
|
+
expect(second).toEqual({
|
|
108
|
+
outcome: "already-set-up",
|
|
109
|
+
siteId: first.siteId,
|
|
110
|
+
});
|
|
111
|
+
expect(console.log).toHaveBeenLastCalledWith(
|
|
112
|
+
`Site ${first.siteId} was already set up. Nothing changed.`,
|
|
113
|
+
);
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
it("refuses a password passed any way but standard input", async () => {
|
|
117
|
+
await expect(
|
|
118
|
+
run(["--email", "owner@example.com"], pipe("correct horse")),
|
|
119
|
+
).rejects.toThrow("Pass --password-stdin");
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
it("refuses to wait on a terminal for the password", async () => {
|
|
123
|
+
const stdin = Object.assign(Readable.from([]), { isTTY: true });
|
|
124
|
+
|
|
125
|
+
await expect(
|
|
126
|
+
run(["--email", "owner@example.com", "--password-stdin"], { stdin }),
|
|
127
|
+
).rejects.toThrow("reads the password from a pipe");
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
it("rejects answers the setup screens would reject", async () => {
|
|
131
|
+
const args = ["--email", "owner@example.com", "--password-stdin"];
|
|
132
|
+
|
|
133
|
+
await expect(run(args, pipe("short"))).rejects.toThrow(
|
|
134
|
+
"Password must be at least 8 characters",
|
|
135
|
+
);
|
|
136
|
+
await expect(
|
|
137
|
+
run(
|
|
138
|
+
[...args, "--site-id", "pst_01kn8jq3t4famtyg9hjd074ckr"],
|
|
139
|
+
pipe("correct horse"),
|
|
140
|
+
),
|
|
141
|
+
).rejects.toThrow("Invalid ID");
|
|
142
|
+
await expect(
|
|
143
|
+
run([...args, "--time-zone", "Mars/Olympus"], pipe("correct horse")),
|
|
144
|
+
).rejects.toThrow("Choose a valid time zone.");
|
|
145
|
+
|
|
146
|
+
expect(
|
|
147
|
+
readDatabase((sqlite) =>
|
|
148
|
+
sqlite.prepare('SELECT COUNT(*) FROM "user"').pluck().get(),
|
|
149
|
+
),
|
|
150
|
+
).toBe(0);
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
it("refuses to run without a Node database", async () => {
|
|
154
|
+
delete process.env.DATABASE_URL;
|
|
155
|
+
|
|
156
|
+
await expect(
|
|
157
|
+
run(
|
|
158
|
+
["--email", "owner@example.com", "--password-stdin"],
|
|
159
|
+
pipe("correct horse"),
|
|
160
|
+
),
|
|
161
|
+
).rejects.toThrow("jant setup runs against a Node database");
|
|
162
|
+
});
|
|
163
|
+
});
|
|
@@ -4,6 +4,10 @@ import { tmpdir } from "node:os";
|
|
|
4
4
|
import { join } from "node:path";
|
|
5
5
|
import Database from "better-sqlite3";
|
|
6
6
|
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
7
|
+
import {
|
|
8
|
+
listInstalledSchemaTags,
|
|
9
|
+
readInstalledJantVersion,
|
|
10
|
+
} from "../../../bin/lib/site-snapshot.js";
|
|
7
11
|
import { createLocalDriver } from "../../lib/storage.js";
|
|
8
12
|
import { migrate } from "../runtime.js";
|
|
9
13
|
import type { Bindings } from "../../types.js";
|
|
@@ -244,6 +248,8 @@ describe("jant site snapshot export/import", () => {
|
|
|
244
248
|
format: "jant-site-snapshot",
|
|
245
249
|
version: 2,
|
|
246
250
|
dialect: "sqlite",
|
|
251
|
+
jant: readInstalledJantVersion(),
|
|
252
|
+
schema: listInstalledSchemaTags("sqlite").at(-1),
|
|
247
253
|
site: { id: SNAPSHOT_SITE_ID, key: SNAPSHOT_SITE_KEY },
|
|
248
254
|
});
|
|
249
255
|
expect(existsSync(join(snapshotPath, "storage-manifest.json"))).toBe(false);
|
|
@@ -780,6 +786,73 @@ describe("jant site snapshot export/import", () => {
|
|
|
780
786
|
expect(await targetStorage.get(SNAPSHOT_MEDIA_KEY)).not.toBeNull();
|
|
781
787
|
});
|
|
782
788
|
|
|
789
|
+
// The snapshot was exported where the bytes lived in R2; this import puts
|
|
790
|
+
// them in local storage. Rows left saying `r2` would look for R2_PUBLIC_URL,
|
|
791
|
+
// miss the avatar's existing row on replacement, and never purge their trash.
|
|
792
|
+
it("records imported media under the storage the import wrote it to", async () => {
|
|
793
|
+
const root = await mkdtemp(join(tmpdir(), "jant-site-snapshot-provider-"));
|
|
794
|
+
tempDirs.push(root);
|
|
795
|
+
|
|
796
|
+
const targetDbPath = join(root, "target.sqlite");
|
|
797
|
+
const targetStoragePath = join(root, "target-media");
|
|
798
|
+
const snapshotPath = join(root, "snapshot");
|
|
799
|
+
|
|
800
|
+
await migrate({ DATABASE_URL: `file:${targetDbPath}` } as Bindings);
|
|
801
|
+
const targetSqlite = new Database(targetDbPath);
|
|
802
|
+
try {
|
|
803
|
+
targetSqlite.exec(`
|
|
804
|
+
INSERT INTO "site" ("id", "key", "status", "created_at", "updated_at")
|
|
805
|
+
VALUES ('${SNAPSHOT_SITE_ID}', '${SNAPSHOT_SITE_KEY}', 'active', 1774009000, 1774009000);
|
|
806
|
+
`);
|
|
807
|
+
} finally {
|
|
808
|
+
targetSqlite.close();
|
|
809
|
+
}
|
|
810
|
+
|
|
811
|
+
await mkdir(
|
|
812
|
+
join(snapshotPath, "objects", "media", SNAPSHOT_SITE_ID, "files"),
|
|
813
|
+
{
|
|
814
|
+
recursive: true,
|
|
815
|
+
},
|
|
816
|
+
);
|
|
817
|
+
await writeFile(join(snapshotPath, "objects", SNAPSHOT_MEDIA_KEY), "png");
|
|
818
|
+
await writeFile(
|
|
819
|
+
join(snapshotPath, "meta.json"),
|
|
820
|
+
JSON.stringify({
|
|
821
|
+
format: "jant-site-snapshot",
|
|
822
|
+
version: 2,
|
|
823
|
+
dialect: "sqlite",
|
|
824
|
+
site: { id: SNAPSHOT_SITE_ID, key: SNAPSHOT_SITE_KEY },
|
|
825
|
+
}),
|
|
826
|
+
);
|
|
827
|
+
await writeFile(
|
|
828
|
+
join(snapshotPath, "db.sql"),
|
|
829
|
+
`INSERT INTO "media" ("id", "site_id", "post_id", "filename", "original_name", "mime_type", "size", "storage_key", "provider", "position", "media_kind", "created_at", "updated_at") VALUES('${SNAPSHOT_MEDIA_ID}', '${SNAPSHOT_SITE_ID}', NULL, '${SNAPSHOT_MEDIA_ID}.png', 'sample.png', 'image/png', 3, '${SNAPSHOT_MEDIA_KEY}', 'r2', 'a0', 'image', 1774009200, 1774009200);\n`,
|
|
830
|
+
);
|
|
831
|
+
|
|
832
|
+
useLocalSnapshotRuntime(`file:${targetDbPath}`, targetStoragePath);
|
|
833
|
+
vi.spyOn(console, "log").mockImplementation(() => {});
|
|
834
|
+
const { run: runImport } =
|
|
835
|
+
await import("../../../bin/commands/site/snapshot/import.js");
|
|
836
|
+
await runImport(["--path", snapshotPath, "--replace"]);
|
|
837
|
+
|
|
838
|
+
const verifySqlite = new Database(targetDbPath, { readonly: true });
|
|
839
|
+
try {
|
|
840
|
+
expect(
|
|
841
|
+
verifySqlite
|
|
842
|
+
.prepare(`SELECT "provider" FROM "media" WHERE "id" = ?`)
|
|
843
|
+
.pluck()
|
|
844
|
+
.get(SNAPSHOT_MEDIA_ID),
|
|
845
|
+
).toBe("local");
|
|
846
|
+
} finally {
|
|
847
|
+
verifySqlite.close();
|
|
848
|
+
}
|
|
849
|
+
expect(
|
|
850
|
+
await createLocalDriver({ rootPath: targetStoragePath }).get(
|
|
851
|
+
SNAPSHOT_MEDIA_KEY,
|
|
852
|
+
),
|
|
853
|
+
).not.toBeNull();
|
|
854
|
+
});
|
|
855
|
+
|
|
783
856
|
it("requires --replace for snapshot import", async () => {
|
|
784
857
|
const root = await mkdtemp(join(tmpdir(), "jant-site-snapshot-replace-"));
|
|
785
858
|
tempDirs.push(root);
|
|
@@ -2,7 +2,7 @@ import { mkdtemp, readFile, rm } from "node:fs/promises";
|
|
|
2
2
|
import { tmpdir } from "node:os";
|
|
3
3
|
import { join } from "node:path";
|
|
4
4
|
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
5
|
-
import { run as runImportSite } from "../../../bin/commands/import
|
|
5
|
+
import { run as runImportSite } from "../../../bin/commands/site/import.js";
|
|
6
6
|
import { run as runSiteExport } from "../../../bin/commands/site/export.js";
|
|
7
7
|
import {
|
|
8
8
|
CLI_API_TOKEN_ENV_VAR,
|
|
@@ -65,6 +65,7 @@ describe("site CLI token env", () => {
|
|
|
65
65
|
vi.spyOn(console, "log").mockImplementation(() => {});
|
|
66
66
|
|
|
67
67
|
await runSiteExport([
|
|
68
|
+
"--url",
|
|
68
69
|
"https://example.com",
|
|
69
70
|
"--output",
|
|
70
71
|
outputPath,
|
|
@@ -94,6 +95,7 @@ describe("site CLI token env", () => {
|
|
|
94
95
|
|
|
95
96
|
await expect(
|
|
96
97
|
runImportSite([
|
|
98
|
+
"--url",
|
|
97
99
|
"https://example.com",
|
|
98
100
|
"--path",
|
|
99
101
|
"/definitely-missing-jant-import-source",
|
|
@@ -119,6 +121,7 @@ describe("site CLI token env", () => {
|
|
|
119
121
|
|
|
120
122
|
await expect(
|
|
121
123
|
runImportSite([
|
|
124
|
+
"--url",
|
|
122
125
|
"https://example.com",
|
|
123
126
|
"--path",
|
|
124
127
|
"/definitely-missing-jant-import-source",
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { readFileSync } from "node:fs";
|
|
2
3
|
import {
|
|
3
4
|
assertSnapshotDialectMatches,
|
|
4
5
|
assertSnapshotMeta,
|
|
6
|
+
assertSnapshotSchemaInstalled,
|
|
7
|
+
listInstalledSchemaTags,
|
|
8
|
+
buildMediaProviderSql,
|
|
5
9
|
buildSnapshotMeta,
|
|
6
10
|
getSnapshotDialect,
|
|
7
11
|
SNAPSHOT_VERSION,
|
|
@@ -31,6 +35,67 @@ describe("buildSnapshotMeta", () => {
|
|
|
31
35
|
});
|
|
32
36
|
});
|
|
33
37
|
|
|
38
|
+
describe("snapshot schema", () => {
|
|
39
|
+
const packageVersion = JSON.parse(
|
|
40
|
+
readFileSync(new URL("../../../package.json", import.meta.url), "utf8"),
|
|
41
|
+
).version;
|
|
42
|
+
|
|
43
|
+
it("records the writing version and its last migration per dialect", () => {
|
|
44
|
+
for (const dialect of ["sqlite", "pg"] as const) {
|
|
45
|
+
const meta = buildSnapshotMeta(SITE, { dialect });
|
|
46
|
+
expect(meta.jant).toBe(packageVersion);
|
|
47
|
+
expect(meta.schema).toBe(listInstalledSchemaTags(dialect).at(-1));
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it("accepts a snapshot whose schema the installed package ships", () => {
|
|
52
|
+
const meta = buildSnapshotMeta(SITE, { dialect: "pg" });
|
|
53
|
+
expect(() => assertSnapshotSchemaInstalled(meta)).not.toThrow();
|
|
54
|
+
const older = {
|
|
55
|
+
...meta,
|
|
56
|
+
schema: listInstalledSchemaTags("pg")[0],
|
|
57
|
+
};
|
|
58
|
+
expect(() => assertSnapshotSchemaInstalled(older)).not.toThrow();
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it("accepts a snapshot from before the schema was recorded", () => {
|
|
62
|
+
const {
|
|
63
|
+
schema: _schema,
|
|
64
|
+
jant: _jant,
|
|
65
|
+
...legacy
|
|
66
|
+
} = buildSnapshotMeta(SITE, { dialect: "sqlite" });
|
|
67
|
+
expect(() => assertSnapshotSchemaInstalled(legacy)).not.toThrow();
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it("refuses a snapshot from a newer schema, naming the fix", () => {
|
|
71
|
+
const meta = {
|
|
72
|
+
...buildSnapshotMeta(SITE, { dialect: "sqlite" }),
|
|
73
|
+
jant: "9.0.0",
|
|
74
|
+
schema: "9999_later_change",
|
|
75
|
+
};
|
|
76
|
+
expect(() => assertSnapshotSchemaInstalled(meta)).toThrow(
|
|
77
|
+
/Jant 9\.0\.0.*9999_later_change.*Upgrade @jant\/core/,
|
|
78
|
+
);
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
it("checks a snapshot against its own dialect's migrations", () => {
|
|
82
|
+
const sqliteTag = listInstalledSchemaTags("sqlite").at(-1);
|
|
83
|
+
const pgTags = listInstalledSchemaTags("pg");
|
|
84
|
+
expect(pgTags).not.toContain(sqliteTag);
|
|
85
|
+
const meta = {
|
|
86
|
+
...buildSnapshotMeta(SITE, { dialect: "pg" }),
|
|
87
|
+
schema: sqliteTag,
|
|
88
|
+
};
|
|
89
|
+
expect(() => assertSnapshotSchemaInstalled(meta)).toThrow();
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
it("rejects a non-string jant or schema field", () => {
|
|
93
|
+
expect(() =>
|
|
94
|
+
assertSnapshotMeta({ ...buildSnapshotMeta(SITE), schema: 34 }),
|
|
95
|
+
).toThrow(/schema must be a string/);
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
|
|
34
99
|
describe("assertSnapshotMeta", () => {
|
|
35
100
|
it("accepts a known dialect", () => {
|
|
36
101
|
expect(() =>
|
|
@@ -183,3 +248,22 @@ describe("assertSnapshotDialectMatches", () => {
|
|
|
183
248
|
expect(() => assertSnapshotDialectMatches({}, "pg")).not.toThrow();
|
|
184
249
|
});
|
|
185
250
|
});
|
|
251
|
+
|
|
252
|
+
describe("buildMediaProviderSql", () => {
|
|
253
|
+
it("records the site's media under the given storage driver", () => {
|
|
254
|
+
expect(buildMediaProviderSql("sit_o'brien", "s3")).toBe(
|
|
255
|
+
`UPDATE "media" SET "provider" = 's3' WHERE "site_id" = 'sit_o''brien';`,
|
|
256
|
+
);
|
|
257
|
+
});
|
|
258
|
+
|
|
259
|
+
// The value is written into SQL and read back as where the bytes live, so
|
|
260
|
+
// anything but a real driver is refused rather than quoted.
|
|
261
|
+
it("refuses anything that is not a storage driver", () => {
|
|
262
|
+
expect(() => buildMediaProviderSql("sit_test", "gcs")).toThrow(
|
|
263
|
+
'Snapshot import cannot record media under storage driver "gcs".',
|
|
264
|
+
);
|
|
265
|
+
expect(() => buildMediaProviderSql("sit_test", "s3' OR '1")).toThrow(
|
|
266
|
+
"cannot record media under storage driver",
|
|
267
|
+
);
|
|
268
|
+
});
|
|
269
|
+
});
|
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
resolveDatabasePath,
|
|
13
13
|
resolvePublicRequestUrl,
|
|
14
14
|
} from "../runtime.js";
|
|
15
|
+
import type { App } from "../../types/app-context.js";
|
|
15
16
|
import type { Bindings } from "../../types.js";
|
|
16
17
|
|
|
17
18
|
const tempDirs: string[] = [];
|
|
@@ -204,6 +205,43 @@ describe("resolveNodeAssetRoot", () => {
|
|
|
204
205
|
).rejects.toThrow("single-site mode found multiple sites in the database:");
|
|
205
206
|
});
|
|
206
207
|
|
|
208
|
+
// A deploy check tells a container that just started from one a rollback
|
|
209
|
+
// left running by this stamp, so it has to be the handler's start and not a
|
|
210
|
+
// time taken per request.
|
|
211
|
+
it("stamps the bindings with when the handler started serving", async () => {
|
|
212
|
+
const root = await mkdtemp(join(tmpdir(), "jant-node-started-at-"));
|
|
213
|
+
tempDirs.push(root);
|
|
214
|
+
const databasePath = join(root, "data", "jant.sqlite");
|
|
215
|
+
await migrate({ DATABASE_URL: `file:${databasePath}` } as Bindings);
|
|
216
|
+
|
|
217
|
+
const before = Math.floor(Date.now() / 1000);
|
|
218
|
+
const handler = await createNodeRequestHandler({
|
|
219
|
+
assetRoot: null,
|
|
220
|
+
env: { DATABASE_URL: `file:${databasePath}` } as Bindings,
|
|
221
|
+
app: {
|
|
222
|
+
fetch: (_request: Request, env: Bindings) =>
|
|
223
|
+
Response.json({ startedAt: env.NODE_STARTED_AT }),
|
|
224
|
+
} as unknown as App,
|
|
225
|
+
});
|
|
226
|
+
const after = Math.floor(Date.now() / 1000);
|
|
227
|
+
|
|
228
|
+
try {
|
|
229
|
+
const read = async () =>
|
|
230
|
+
(
|
|
231
|
+
(await (
|
|
232
|
+
await handler.fetch(new Request("http://127.0.0.1:3000/readyz"))
|
|
233
|
+
).json()) as { startedAt: number }
|
|
234
|
+
).startedAt;
|
|
235
|
+
const first = await read();
|
|
236
|
+
|
|
237
|
+
expect(first).toBeGreaterThanOrEqual(before);
|
|
238
|
+
expect(first).toBeLessThanOrEqual(after);
|
|
239
|
+
expect(await read()).toBe(first);
|
|
240
|
+
} finally {
|
|
241
|
+
await handler.close();
|
|
242
|
+
}
|
|
243
|
+
});
|
|
244
|
+
|
|
207
245
|
// The single-site readiness check blames SITE_RESOLUTION_MODE for extra
|
|
208
246
|
// sites, which on a hosted database are just its tenants.
|
|
209
247
|
it("starts in host-based mode when the database holds several sites", async () => {
|
package/src/node/index.ts
CHANGED
|
@@ -6,10 +6,12 @@ export { createNodeRequestHandler } from "./request-handler.js";
|
|
|
6
6
|
export {
|
|
7
7
|
createNodeCliRuntime,
|
|
8
8
|
createNodeRequestRuntime,
|
|
9
|
+
setUpNodeInstance,
|
|
9
10
|
} from "../runtime/node.js";
|
|
10
11
|
export type { CliSiteSelector } from "../runtime/site.js";
|
|
11
12
|
export { createExportService } from "../services/export.js";
|
|
12
13
|
export { createStorageDriver } from "../lib/storage.js";
|
|
14
|
+
export { getConfiguredStorageDriver } from "../lib/env.js";
|
|
13
15
|
export { resolveConfig } from "../lib/resolve-config.js";
|
|
14
16
|
export { buildThemeStyle } from "../lib/theme.js";
|
|
15
17
|
export { BUILTIN_COLOR_THEMES } from "../ui/color-themes.js";
|
|
@@ -31,6 +31,7 @@ import {
|
|
|
31
31
|
shouldTrustProxy,
|
|
32
32
|
} from "../lib/env.js";
|
|
33
33
|
import { getHostBasedStartupConfigurationIssues } from "../lib/startup-config.js";
|
|
34
|
+
import { now } from "../lib/time.js";
|
|
34
35
|
import { createSiteService } from "../services/site.js";
|
|
35
36
|
import type { App } from "../types/app-context.js";
|
|
36
37
|
import type { Bindings } from "../types/bindings.js";
|
|
@@ -616,7 +617,8 @@ export async function createNodeRequestHandler(options?: {
|
|
|
616
617
|
`Host-based startup configuration is invalid:\n- ${hostBasedStartupIssues.map((issue) => issue.message).join("\n- ")}`,
|
|
617
618
|
);
|
|
618
619
|
}
|
|
619
|
-
const { bindings, close } = await createNodeBindings(env);
|
|
620
|
+
const { bindings: databaseBindings, close } = await createNodeBindings(env);
|
|
621
|
+
const bindings: Bindings = { ...databaseBindings, NODE_STARTED_AT: now() };
|
|
620
622
|
try {
|
|
621
623
|
await assertNodeSiteResolutionReady(bindings);
|
|
622
624
|
|
|
@@ -449,6 +449,30 @@ describe("Posts API Routes", () => {
|
|
|
449
449
|
expect(body.attachments).toEqual([]);
|
|
450
450
|
});
|
|
451
451
|
|
|
452
|
+
it("keeps the creation and edit times a restore sends", async () => {
|
|
453
|
+
const { app } = createTestApp({ authenticated: true });
|
|
454
|
+
app.route("/api/posts", postsApiRoutes);
|
|
455
|
+
|
|
456
|
+
const res = await app.request("/api/posts", {
|
|
457
|
+
method: "POST",
|
|
458
|
+
headers: { "Content-Type": "application/json" },
|
|
459
|
+
body: JSON.stringify({
|
|
460
|
+
format: "note",
|
|
461
|
+
bodyMarkdown: "Moved from another site",
|
|
462
|
+
publishedAt: 1700000500,
|
|
463
|
+
createdAt: 1700000000,
|
|
464
|
+
updatedAt: 1700009000,
|
|
465
|
+
}),
|
|
466
|
+
});
|
|
467
|
+
|
|
468
|
+
expect(res.status).toBe(201);
|
|
469
|
+
expect(await res.json()).toMatchObject({
|
|
470
|
+
publishedAt: 1700000500,
|
|
471
|
+
createdAt: 1700000000,
|
|
472
|
+
updatedAt: 1700009000,
|
|
473
|
+
});
|
|
474
|
+
});
|
|
475
|
+
|
|
452
476
|
it("creates a post with bodyMarkdown", async () => {
|
|
453
477
|
const { app } = createTestApp({ authenticated: true });
|
|
454
478
|
app.route("/api/posts", postsApiRoutes);
|
|
@@ -46,6 +46,40 @@ describe("Upload API Routes", () => {
|
|
|
46
46
|
});
|
|
47
47
|
});
|
|
48
48
|
|
|
49
|
+
it("pages the media list with nextCursor", async () => {
|
|
50
|
+
const { app, services } = createTestApp({ authenticated: true });
|
|
51
|
+
app.route("/api/upload", uploadApiRoutes);
|
|
52
|
+
|
|
53
|
+
for (const name of ["a", "b", "c"]) {
|
|
54
|
+
await services.media.create({
|
|
55
|
+
filename: `${name}.webp`,
|
|
56
|
+
originalName: `${name}.webp`,
|
|
57
|
+
mimeType: "image/webp",
|
|
58
|
+
size: 1024,
|
|
59
|
+
storageKey: `media/${name}.webp`,
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const seen: string[] = [];
|
|
64
|
+
let cursor: string | null = null;
|
|
65
|
+
for (let page = 0; page < 4; page += 1) {
|
|
66
|
+
const res = await app.request(
|
|
67
|
+
`/api/upload?limit=2${cursor ? `&cursor=${cursor}` : ""}`,
|
|
68
|
+
);
|
|
69
|
+
expect(res.status).toBe(200);
|
|
70
|
+
const body = (await res.json()) as {
|
|
71
|
+
media: { filename: string }[];
|
|
72
|
+
nextCursor: string | null;
|
|
73
|
+
};
|
|
74
|
+
seen.push(...body.media.map((media) => media.filename));
|
|
75
|
+
cursor = body.nextCursor;
|
|
76
|
+
if (!cursor) break;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
expect(seen.sort()).toEqual(["a.webp", "b.webp", "c.webp"]);
|
|
80
|
+
expect(cursor).toBeNull();
|
|
81
|
+
});
|
|
82
|
+
|
|
49
83
|
it("returns a single media item", async () => {
|
|
50
84
|
const { app, services } = createTestApp({ authenticated: true });
|
|
51
85
|
app.route("/api/upload", uploadApiRoutes);
|
package/src/routes/api/export.ts
CHANGED
|
@@ -57,12 +57,12 @@ exportApiRoutes.post("/hugo", requireAuthApi(), async (c) => {
|
|
|
57
57
|
storage: c.var.storage,
|
|
58
58
|
},
|
|
59
59
|
);
|
|
60
|
-
|
|
61
|
-
|
|
60
|
+
// Streamed: stored media is read as the archive goes out, so the response
|
|
61
|
+
// starts at once and memory stays flat whatever the site's size.
|
|
62
|
+
return new Response(await exportService.generateHugoSite(), {
|
|
62
63
|
headers: {
|
|
63
64
|
"Content-Type": "application/zip",
|
|
64
65
|
"Content-Disposition": 'attachment; filename="jant-export.zip"',
|
|
65
|
-
"Content-Length": String(zip.byteLength),
|
|
66
66
|
},
|
|
67
67
|
});
|
|
68
68
|
});
|
|
@@ -20,7 +20,7 @@ export const internalSearchReindexRoutes = new Hono<Env>();
|
|
|
20
20
|
* `body_text` changes.
|
|
21
21
|
*
|
|
22
22
|
* Idempotent. Callers loop with the returned `nextCursor` until `done: true`.
|
|
23
|
-
* Used by the `jant search
|
|
23
|
+
* Used by the `jant search reindex` CLI to backfill search indexes for
|
|
24
24
|
* existing posts after changes to the text extraction logic (e.g. including
|
|
25
25
|
* link mark hrefs so inline URLs become searchable).
|
|
26
26
|
*/
|
|
@@ -240,7 +240,6 @@ internalSitesRoutes.get(
|
|
|
240
240
|
return new Response(archive.zip, {
|
|
241
241
|
headers: {
|
|
242
242
|
"Content-Disposition": `attachment; filename="${archive.filename}"`,
|
|
243
|
-
"Content-Length": String(archive.zip.byteLength),
|
|
244
243
|
"Content-Type": "application/zip",
|
|
245
244
|
},
|
|
246
245
|
});
|