@jasonshimmy/vite-plugin-cer-app 0.23.2 → 0.25.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/dist/cli/adapters/netlify.js +4 -2
- package/dist/cli/adapters/netlify.js.map +1 -1
- package/dist/cli/checks/lighthouse.d.ts +26 -0
- package/dist/cli/checks/lighthouse.d.ts.map +1 -0
- package/dist/cli/checks/lighthouse.js +121 -0
- package/dist/cli/checks/lighthouse.js.map +1 -0
- package/dist/cli/checks/links.d.ts +12 -0
- package/dist/cli/checks/links.d.ts.map +1 -0
- package/dist/cli/checks/links.js +89 -0
- package/dist/cli/checks/links.js.map +1 -0
- package/dist/cli/checks/performance.d.ts +17 -0
- package/dist/cli/checks/performance.d.ts.map +1 -0
- package/dist/cli/checks/performance.js +61 -0
- package/dist/cli/checks/performance.js.map +1 -0
- package/dist/cli/commands/check.d.ts +3 -0
- package/dist/cli/commands/check.d.ts.map +1 -0
- package/dist/cli/commands/check.js +85 -0
- package/dist/cli/commands/check.js.map +1 -0
- package/dist/cli/commands/preview.d.ts.map +1 -1
- package/dist/cli/commands/preview.js +4 -2
- package/dist/cli/commands/preview.js.map +1 -1
- package/dist/cli/create/index.d.ts +11 -1
- package/dist/cli/create/index.d.ts.map +1 -1
- package/dist/cli/create/index.js +135 -65
- package/dist/cli/create/index.js.map +1 -1
- package/dist/cli/create/templates/spa/package.json.tpl +5 -3
- package/dist/cli/create/templates/ssg/cer.config.ts.tpl +2 -0
- package/dist/cli/create/templates/ssg/package.json.tpl +5 -3
- package/dist/cli/create/templates/ssr/package.json.tpl +5 -3
- package/dist/cli/index.js +2 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/plugin/build-ssg.d.ts +22 -6
- package/dist/plugin/build-ssg.d.ts.map +1 -1
- package/dist/plugin/build-ssg.js +226 -17
- package/dist/plugin/build-ssg.js.map +1 -1
- package/dist/plugin/content/index.d.ts +1 -1
- package/dist/plugin/content/index.d.ts.map +1 -1
- package/dist/plugin/content/index.js +8 -8
- package/dist/plugin/content/index.js.map +1 -1
- package/dist/plugin/content/parser.d.ts +3 -3
- package/dist/plugin/content/parser.d.ts.map +1 -1
- package/dist/plugin/content/parser.js +103 -24
- package/dist/plugin/content/parser.js.map +1 -1
- package/dist/plugin/dev-server.d.ts +4 -1
- package/dist/plugin/dev-server.d.ts.map +1 -1
- package/dist/plugin/dev-server.js.map +1 -1
- package/dist/plugin/dts-generator.d.ts.map +1 -1
- package/dist/plugin/dts-generator.js +50 -8
- package/dist/plugin/dts-generator.js.map +1 -1
- package/dist/plugin/generated-dir.d.ts +2 -0
- package/dist/plugin/generated-dir.d.ts.map +1 -1
- package/dist/plugin/generated-dir.js +17 -6
- package/dist/plugin/generated-dir.js.map +1 -1
- package/dist/plugin/html-post-process.d.ts +7 -0
- package/dist/plugin/html-post-process.d.ts.map +1 -1
- package/dist/plugin/html-post-process.js +26 -0
- package/dist/plugin/html-post-process.js.map +1 -1
- package/dist/plugin/index.d.ts.map +1 -1
- package/dist/plugin/index.js +60 -13
- package/dist/plugin/index.js.map +1 -1
- package/dist/plugin/transforms/auto-import.d.ts.map +1 -1
- package/dist/plugin/transforms/auto-import.js +7 -0
- package/dist/plugin/transforms/auto-import.js.map +1 -1
- package/dist/plugin/transforms/prune-runtime-css.d.ts +8 -0
- package/dist/plugin/transforms/prune-runtime-css.d.ts.map +1 -0
- package/dist/plugin/transforms/prune-runtime-css.js +40 -0
- package/dist/plugin/transforms/prune-runtime-css.js.map +1 -0
- package/dist/runtime/app-template.d.ts +1 -1
- package/dist/runtime/app-template.d.ts.map +1 -1
- package/dist/runtime/app-template.js +206 -36
- package/dist/runtime/app-template.js.map +1 -1
- package/dist/runtime/composables/index.d.ts +4 -0
- package/dist/runtime/composables/index.d.ts.map +1 -1
- package/dist/runtime/composables/index.js +2 -0
- package/dist/runtime/composables/index.js.map +1 -1
- package/dist/runtime/composables/use-active-headings.d.ts +24 -0
- package/dist/runtime/composables/use-active-headings.d.ts.map +1 -0
- package/dist/runtime/composables/use-active-headings.js +112 -0
- package/dist/runtime/composables/use-active-headings.js.map +1 -0
- package/dist/runtime/composables/use-content-page.d.ts +45 -0
- package/dist/runtime/composables/use-content-page.d.ts.map +1 -0
- package/dist/runtime/composables/use-content-page.js +181 -0
- package/dist/runtime/composables/use-content-page.js.map +1 -0
- package/dist/runtime/composables/use-content-search.d.ts.map +1 -1
- package/dist/runtime/composables/use-content-search.js +1 -5
- package/dist/runtime/composables/use-content-search.js.map +1 -1
- package/dist/runtime/composables/use-fetch.d.ts +2 -1
- package/dist/runtime/composables/use-fetch.d.ts.map +1 -1
- package/dist/runtime/composables/use-fetch.js +112 -43
- package/dist/runtime/composables/use-fetch.js.map +1 -1
- package/dist/runtime/composables/use-route.d.ts.map +1 -1
- package/dist/runtime/composables/use-route.js +39 -11
- package/dist/runtime/composables/use-route.js.map +1 -1
- package/dist/runtime/content/client.js +2 -2
- package/dist/runtime/content/client.js.map +1 -1
- package/dist/runtime/entry-server-template.d.ts +16 -1
- package/dist/runtime/entry-server-template.d.ts.map +1 -1
- package/dist/runtime/entry-server-template.js +120 -13
- package/dist/runtime/entry-server-template.js.map +1 -1
- package/dist/types/config.d.ts +45 -4
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/config.js.map +1 -1
- package/dist/types/content.d.ts +18 -1
- package/dist/types/content.d.ts.map +1 -1
- package/dist/types/middleware.d.ts +2 -2
- package/dist/types/middleware.d.ts.map +1 -1
- package/package.json +22 -19
- package/.github/copilot-instructions.md +0 -169
- package/.github/workflows/publish.yml +0 -257
- package/.nvmrc +0 -1
- package/CHANGELOG.md +0 -236
- package/CLAUDE.md +0 -113
- package/commits.txt +0 -1
- package/cypress.config.ts +0 -16
- package/docs/authentication.md +0 -285
- package/docs/cli.md +0 -324
- package/docs/components.md +0 -237
- package/docs/composables.md +0 -907
- package/docs/configuration.md +0 -696
- package/docs/content.md +0 -570
- package/docs/data-loading.md +0 -336
- package/docs/getting-started.md +0 -237
- package/docs/head-management.md +0 -212
- package/docs/i18n.md +0 -159
- package/docs/layouts.md +0 -224
- package/docs/middleware.md +0 -234
- package/docs/plugins.md +0 -170
- package/docs/rendering-modes.md +0 -377
- package/docs/routing.md +0 -485
- package/docs/server-api.md +0 -253
- package/docs/testing.md +0 -455
- package/docs/use-fetch.md +0 -183
- package/e2e/cypress/e2e/api.cy.ts +0 -123
- package/e2e/cypress/e2e/async-component.cy.ts +0 -27
- package/e2e/cypress/e2e/component-splitting.cy.ts +0 -50
- package/e2e/cypress/e2e/content.cy.ts +0 -425
- package/e2e/cypress/e2e/cookie.cy.ts +0 -85
- package/e2e/cypress/e2e/data.cy.ts +0 -158
- package/e2e/cypress/e2e/error-boundary.cy.ts +0 -88
- package/e2e/cypress/e2e/fouc.cy.ts +0 -254
- package/e2e/cypress/e2e/group-meta.cy.ts +0 -36
- package/e2e/cypress/e2e/head.cy.ts +0 -89
- package/e2e/cypress/e2e/i18n.cy.ts +0 -79
- package/e2e/cypress/e2e/interactive.cy.ts +0 -137
- package/e2e/cypress/e2e/isr-nested-runtime.cy.ts +0 -102
- package/e2e/cypress/e2e/jit-css-custom-colors.cy.ts +0 -43
- package/e2e/cypress/e2e/middleware-chain.cy.ts +0 -89
- package/e2e/cypress/e2e/middleware-status.cy.ts +0 -30
- package/e2e/cypress/e2e/middleware.cy.ts +0 -45
- package/e2e/cypress/e2e/navigate.cy.ts +0 -39
- package/e2e/cypress/e2e/observability.cy.ts +0 -77
- package/e2e/cypress/e2e/per-route-error.cy.ts +0 -42
- package/e2e/cypress/e2e/per-route-render.cy.ts +0 -70
- package/e2e/cypress/e2e/preview-hardening.cy.ts +0 -88
- package/e2e/cypress/e2e/routes.cy.ts +0 -128
- package/e2e/cypress/e2e/seo-meta.cy.ts +0 -108
- package/e2e/cypress/e2e/server-middleware.cy.ts +0 -46
- package/e2e/cypress/e2e/session-rotation.cy.ts +0 -25
- package/e2e/cypress/e2e/session.cy.ts +0 -73
- package/e2e/cypress/e2e/ssr-render-error.cy.ts +0 -68
- package/e2e/cypress/e2e/synthetic-404.cy.ts +0 -45
- package/e2e/cypress/e2e/use-page-data.cy.ts +0 -122
- package/e2e/cypress/e2e/use-state.cy.ts +0 -138
- package/e2e/cypress/support/commands.ts +0 -120
- package/e2e/cypress/support/e2e.ts +0 -10
- package/e2e/cypress/tsconfig.json +0 -14
- package/e2e/kitchen-sink/app/components/ks-badge.ts +0 -8
- package/e2e/kitchen-sink/app/composables/useKsCounter.ts +0 -9
- package/e2e/kitchen-sink/app/error.ts +0 -18
- package/e2e/kitchen-sink/app/layouts/admin.ts +0 -13
- package/e2e/kitchen-sink/app/layouts/default.ts +0 -25
- package/e2e/kitchen-sink/app/layouts/group.ts +0 -9
- package/e2e/kitchen-sink/app/layouts/minimal.ts +0 -7
- package/e2e/kitchen-sink/app/loading.ts +0 -9
- package/e2e/kitchen-sink/app/middleware/auth.ts +0 -9
- package/e2e/kitchen-sink/app/middleware/custom-log.ts +0 -4
- package/e2e/kitchen-sink/app/middleware/group-auth.ts +0 -7
- package/e2e/kitchen-sink/app/middleware/logger.ts +0 -14
- package/e2e/kitchen-sink/app/pages/(auth)/login.ts +0 -13
- package/e2e/kitchen-sink/app/pages/(auth)/protected.ts +0 -16
- package/e2e/kitchen-sink/app/pages/404.ts +0 -9
- package/e2e/kitchen-sink/app/pages/about.ts +0 -17
- package/e2e/kitchen-sink/app/pages/admin/_layout.ts +0 -1
- package/e2e/kitchen-sink/app/pages/admin/dashboard.ts +0 -11
- package/e2e/kitchen-sink/app/pages/async-component-error-test.ts +0 -18
- package/e2e/kitchen-sink/app/pages/async-component-test.ts +0 -18
- package/e2e/kitchen-sink/app/pages/blog/[slug].ts +0 -59
- package/e2e/kitchen-sink/app/pages/blog/index.ts +0 -51
- package/e2e/kitchen-sink/app/pages/content-blog.ts +0 -37
- package/e2e/kitchen-sink/app/pages/content-doc.ts +0 -42
- package/e2e/kitchen-sink/app/pages/content-fallback.ts +0 -36
- package/e2e/kitchen-sink/app/pages/content-guides.ts +0 -35
- package/e2e/kitchen-sink/app/pages/content-index.ts +0 -39
- package/e2e/kitchen-sink/app/pages/content-search.ts +0 -36
- package/e2e/kitchen-sink/app/pages/cookie-test.ts +0 -22
- package/e2e/kitchen-sink/app/pages/counter.ts +0 -17
- package/e2e/kitchen-sink/app/pages/group-auth-blocked.ts +0 -9
- package/e2e/kitchen-sink/app/pages/group-meta-test/_layout.ts +0 -6
- package/e2e/kitchen-sink/app/pages/group-meta-test/custom-mw.ts +0 -14
- package/e2e/kitchen-sink/app/pages/group-meta-test/page.ts +0 -9
- package/e2e/kitchen-sink/app/pages/group-meta-test/protected.ts +0 -8
- package/e2e/kitchen-sink/app/pages/head.ts +0 -20
- package/e2e/kitchen-sink/app/pages/i18n-test.ts +0 -14
- package/e2e/kitchen-sink/app/pages/index.ts +0 -27
- package/e2e/kitchen-sink/app/pages/isr-test.ts +0 -17
- package/e2e/kitchen-sink/app/pages/items/[id].ts +0 -20
- package/e2e/kitchen-sink/app/pages/jit-css-custom-colors-test.ts +0 -14
- package/e2e/kitchen-sink/app/pages/loader-error-test.ts +0 -13
- package/e2e/kitchen-sink/app/pages/loader-props-test.ts +0 -19
- package/e2e/kitchen-sink/app/pages/loader-response-error-test.ts +0 -13
- package/e2e/kitchen-sink/app/pages/middleware-chain-test.ts +0 -12
- package/e2e/kitchen-sink/app/pages/middleware-status-test.ts +0 -9
- package/e2e/kitchen-sink/app/pages/navigate-test.ts +0 -16
- package/e2e/kitchen-sink/app/pages/observability-test.ts +0 -25
- package/e2e/kitchen-sink/app/pages/per-route-error-test.error.ts +0 -13
- package/e2e/kitchen-sink/app/pages/per-route-error-test.ts +0 -15
- package/e2e/kitchen-sink/app/pages/plugin-dsd-test.ts +0 -10
- package/e2e/kitchen-sink/app/pages/render-error-test.ts +0 -12
- package/e2e/kitchen-sink/app/pages/render-server-test.ts +0 -12
- package/e2e/kitchen-sink/app/pages/render-spa-test.ts +0 -12
- package/e2e/kitchen-sink/app/pages/route-info.ts +0 -14
- package/e2e/kitchen-sink/app/pages/seo-test.ts +0 -23
- package/e2e/kitchen-sink/app/pages/session-rotation-test.ts +0 -25
- package/e2e/kitchen-sink/app/pages/use-state-test.ts +0 -37
- package/e2e/kitchen-sink/app/plugins/01.setup.ts +0 -7
- package/e2e/kitchen-sink/app/plugins/02.ks-plugin-components.ts +0 -27
- package/e2e/kitchen-sink/cer-auto-imports.d.ts +0 -51
- package/e2e/kitchen-sink/cer-env.d.ts +0 -35
- package/e2e/kitchen-sink/cer-tsconfig.json +0 -30
- package/e2e/kitchen-sink/cer.config.ts +0 -43
- package/e2e/kitchen-sink/content/01.guides/01.index.md +0 -8
- package/e2e/kitchen-sink/content/01.guides/02.intro.md +0 -8
- package/e2e/kitchen-sink/content/01.guides/10.advanced.md +0 -8
- package/e2e/kitchen-sink/content/blog/2026-04-01-hello.md +0 -26
- package/e2e/kitchen-sink/content/blog/2026-04-02-draft.md +0 -10
- package/e2e/kitchen-sink/content/blog/index.md +0 -8
- package/e2e/kitchen-sink/content/blog/no-frontmatter.md +0 -7
- package/e2e/kitchen-sink/content/docs/getting-started.md +0 -48
- package/e2e/kitchen-sink/content/index.md +0 -16
- package/e2e/kitchen-sink/server/api/echo.ts +0 -12
- package/e2e/kitchen-sink/server/api/health.ts +0 -3
- package/e2e/kitchen-sink/server/api/posts/[slug].ts +0 -11
- package/e2e/kitchen-sink/server/api/posts/index.ts +0 -5
- package/e2e/kitchen-sink/server/api/session.ts +0 -23
- package/e2e/kitchen-sink/server/data/posts.ts +0 -21
- package/e2e/kitchen-sink/server/middleware/01-headers.ts +0 -6
- package/e2e/kitchen-sink/server/middleware/02-status-test.ts +0 -10
- package/e2e/kitchen-sink/tsconfig.json +0 -3
- package/e2e/scripts/clean.mjs +0 -14
- package/eslint.config.ts +0 -22
- package/src/__tests__/cli/adapters/cloudflare-worker.integration.test.ts +0 -132
- package/src/__tests__/cli/adapters/cloudflare.test.ts +0 -332
- package/src/__tests__/cli/adapters/netlify-bridge.integration.test.ts +0 -139
- package/src/__tests__/cli/adapters/netlify.test.ts +0 -286
- package/src/__tests__/cli/adapters/vercel-launcher.integration.test.ts +0 -129
- package/src/__tests__/cli/adapters/vercel.test.ts +0 -263
- package/src/__tests__/cli/preview-hardening.test.ts +0 -265
- package/src/__tests__/cli/preview-isr.test.ts +0 -320
- package/src/__tests__/index.test.ts +0 -21
- package/src/__tests__/plugin/app-template.test.ts +0 -166
- package/src/__tests__/plugin/build-ssg-render.test.ts +0 -155
- package/src/__tests__/plugin/build-ssg.test.ts +0 -598
- package/src/__tests__/plugin/build-ssr.test.ts +0 -192
- package/src/__tests__/plugin/cer-app-plugin.test.ts +0 -552
- package/src/__tests__/plugin/content/emitter.test.ts +0 -117
- package/src/__tests__/plugin/content/loader.test.ts +0 -154
- package/src/__tests__/plugin/content/parser.test.ts +0 -381
- package/src/__tests__/plugin/content/path-utils.test.ts +0 -69
- package/src/__tests__/plugin/content/search.test.ts +0 -119
- package/src/__tests__/plugin/dev-server.test.ts +0 -813
- package/src/__tests__/plugin/dts-generator.test.ts +0 -394
- package/src/__tests__/plugin/entry-server-template.test.ts +0 -385
- package/src/__tests__/plugin/generated-dir.test.ts +0 -144
- package/src/__tests__/plugin/html-post-process.test.ts +0 -146
- package/src/__tests__/plugin/path-utils.test.ts +0 -411
- package/src/__tests__/plugin/resolve-config.test.ts +0 -233
- package/src/__tests__/plugin/scanner.test.ts +0 -186
- package/src/__tests__/plugin/transforms/auto-import.test.ts +0 -510
- package/src/__tests__/plugin/transforms/head-inject.test.ts +0 -178
- package/src/__tests__/plugin/virtual/composables.test.ts +0 -57
- package/src/__tests__/plugin/virtual/content-components.test.ts +0 -66
- package/src/__tests__/plugin/virtual/error.test.ts +0 -71
- package/src/__tests__/plugin/virtual/layouts.test.ts +0 -70
- package/src/__tests__/plugin/virtual/loading.test.ts +0 -72
- package/src/__tests__/plugin/virtual/middleware.test.ts +0 -83
- package/src/__tests__/plugin/virtual/plugins.test.ts +0 -129
- package/src/__tests__/plugin/virtual/routes.test.ts +0 -884
- package/src/__tests__/plugin/virtual/server-api.test.ts +0 -164
- package/src/__tests__/plugin/virtual/server-middleware.test.ts +0 -102
- package/src/__tests__/runtime/app-template.test.ts +0 -208
- package/src/__tests__/runtime/define-middleware.test.ts +0 -64
- package/src/__tests__/runtime/define-server-middleware.test.ts +0 -54
- package/src/__tests__/runtime/entry-client-template.test.ts +0 -61
- package/src/__tests__/runtime/isr-handler.test.ts +0 -338
- package/src/__tests__/runtime/oauth/handler.test.ts +0 -358
- package/src/__tests__/runtime/oauth/providers.test.ts +0 -47
- package/src/__tests__/runtime/oauth-index.test.ts +0 -43
- package/src/__tests__/runtime/use-auth.test.ts +0 -169
- package/src/__tests__/runtime/use-content-search-composable.test.ts +0 -405
- package/src/__tests__/runtime/use-content-search.test.ts +0 -163
- package/src/__tests__/runtime/use-content.test.ts +0 -226
- package/src/__tests__/runtime/use-cookie.test.ts +0 -277
- package/src/__tests__/runtime/use-fetch-component.test.ts +0 -214
- package/src/__tests__/runtime/use-fetch.test.ts +0 -377
- package/src/__tests__/runtime/use-head.test.ts +0 -311
- package/src/__tests__/runtime/use-inject-client.test.ts +0 -67
- package/src/__tests__/runtime/use-inject.test.ts +0 -66
- package/src/__tests__/runtime/use-locale.test.ts +0 -152
- package/src/__tests__/runtime/use-navigate.test.ts +0 -121
- package/src/__tests__/runtime/use-page-data.test.ts +0 -298
- package/src/__tests__/runtime/use-route.test.ts +0 -156
- package/src/__tests__/runtime/use-runtime-config.test.ts +0 -182
- package/src/__tests__/runtime/use-seo-meta.test.ts +0 -109
- package/src/__tests__/runtime/use-session.test.ts +0 -320
- package/src/__tests__/runtime/use-state.test.ts +0 -340
- package/src/__tests__/types/config.test.ts +0 -18
- package/src/cli/adapters/cloudflare.ts +0 -335
- package/src/cli/adapters/netlify.ts +0 -326
- package/src/cli/adapters/vercel.ts +0 -311
- package/src/cli/commands/adapt.ts +0 -84
- package/src/cli/commands/build.ts +0 -165
- package/src/cli/commands/dev.ts +0 -125
- package/src/cli/commands/generate.ts +0 -91
- package/src/cli/commands/preview-isr.ts +0 -172
- package/src/cli/commands/preview.ts +0 -523
- package/src/cli/create/index.ts +0 -275
- package/src/cli/create/templates/shared/.gitignore.tpl +0 -25
- package/src/cli/create/templates/shared/app/layouts/default.ts.tpl +0 -15
- package/src/cli/create/templates/shared/app/pages/index.ts.tpl +0 -8
- package/src/cli/create/templates/shared/index.html.tpl +0 -12
- package/src/cli/create/templates/shared/tsconfig.json.tpl +0 -6
- package/src/cli/create/templates/spa/cer.config.ts.tpl +0 -6
- package/src/cli/create/templates/spa/package.json.tpl +0 -18
- package/src/cli/create/templates/ssg/cer.config.ts.tpl +0 -10
- package/src/cli/create/templates/ssg/package.json.tpl +0 -19
- package/src/cli/create/templates/ssr/cer.config.ts.tpl +0 -6
- package/src/cli/create/templates/ssr/package.json.tpl +0 -18
- package/src/cli/index.ts +0 -22
- package/src/index.ts +0 -20
- package/src/plugin/build-ssg.ts +0 -403
- package/src/plugin/build-ssr.ts +0 -134
- package/src/plugin/content/emitter.ts +0 -50
- package/src/plugin/content/index.ts +0 -233
- package/src/plugin/content/parser.ts +0 -259
- package/src/plugin/content/path-utils.ts +0 -55
- package/src/plugin/content/scanner.ts +0 -26
- package/src/plugin/content/search.ts +0 -28
- package/src/plugin/dev-server.ts +0 -379
- package/src/plugin/dts-generator.ts +0 -273
- package/src/plugin/generated-dir.ts +0 -121
- package/src/plugin/html-post-process.ts +0 -96
- package/src/plugin/index.ts +0 -584
- package/src/plugin/path-utils.ts +0 -186
- package/src/plugin/scanner.ts +0 -65
- package/src/plugin/transforms/auto-import.ts +0 -206
- package/src/plugin/transforms/head-inject.ts +0 -161
- package/src/plugin/virtual/composables.ts +0 -28
- package/src/plugin/virtual/content-components.ts +0 -83
- package/src/plugin/virtual/error.ts +0 -34
- package/src/plugin/virtual/layouts.ts +0 -41
- package/src/plugin/virtual/loading.ts +0 -32
- package/src/plugin/virtual/middleware.ts +0 -45
- package/src/plugin/virtual/plugins.ts +0 -46
- package/src/plugin/virtual/routes.ts +0 -514
- package/src/plugin/virtual/server-api.ts +0 -85
- package/src/plugin/virtual/server-middleware.ts +0 -44
- package/src/runtime/app-template.ts +0 -377
- package/src/runtime/composables/define-middleware.ts +0 -17
- package/src/runtime/composables/define-server-middleware.ts +0 -18
- package/src/runtime/composables/index.ts +0 -27
- package/src/runtime/composables/use-auth.ts +0 -125
- package/src/runtime/composables/use-content-search.ts +0 -205
- package/src/runtime/composables/use-content.ts +0 -146
- package/src/runtime/composables/use-cookie.ts +0 -135
- package/src/runtime/composables/use-fetch.ts +0 -438
- package/src/runtime/composables/use-head.ts +0 -234
- package/src/runtime/composables/use-inject.ts +0 -49
- package/src/runtime/composables/use-locale.ts +0 -109
- package/src/runtime/composables/use-navigate.ts +0 -58
- package/src/runtime/composables/use-page-data.ts +0 -93
- package/src/runtime/composables/use-route.ts +0 -71
- package/src/runtime/composables/use-runtime-config.ts +0 -123
- package/src/runtime/composables/use-seo-meta.ts +0 -80
- package/src/runtime/composables/use-session.ts +0 -186
- package/src/runtime/composables/use-state.ts +0 -92
- package/src/runtime/content/client.ts +0 -168
- package/src/runtime/entry-client-template.ts +0 -39
- package/src/runtime/entry-server-template.ts +0 -493
- package/src/runtime/isr-handler.ts +0 -184
- package/src/runtime/oauth/handler.ts +0 -407
- package/src/runtime/oauth/index.ts +0 -49
- package/src/runtime/oauth/providers.ts +0 -38
- package/src/types/api.ts +0 -40
- package/src/types/config.ts +0 -379
- package/src/types/content.ts +0 -66
- package/src/types/index.ts +0 -7
- package/src/types/middleware.ts +0 -63
- package/src/types/page.ts +0 -117
- package/src/types/plugin.ts +0 -34
- package/tsconfig.build.json +0 -10
- package/tsconfig.json +0 -19
- package/vitest.config.ts +0 -33
|
@@ -1,598 +0,0 @@
|
|
|
1
|
-
import { vi, describe, it, expect, beforeEach } from 'vitest'
|
|
2
|
-
|
|
3
|
-
vi.mock('node:fs', () => ({ existsSync: vi.fn().mockReturnValue(false) }))
|
|
4
|
-
vi.mock('node:fs/promises', () => ({
|
|
5
|
-
writeFile: vi.fn().mockResolvedValue(undefined),
|
|
6
|
-
mkdir: vi.fn().mockResolvedValue(undefined),
|
|
7
|
-
readFile: vi.fn().mockResolvedValue(''),
|
|
8
|
-
}))
|
|
9
|
-
vi.mock('fast-glob', () => ({ default: vi.fn().mockResolvedValue([]) }))
|
|
10
|
-
vi.mock('vite', () => ({
|
|
11
|
-
build: vi.fn().mockResolvedValue(undefined),
|
|
12
|
-
createServer: vi.fn(),
|
|
13
|
-
}))
|
|
14
|
-
vi.mock('../../plugin/build-ssr.js', () => ({ buildSSR: vi.fn().mockResolvedValue(undefined) }))
|
|
15
|
-
vi.mock('../../plugin/path-utils.js', () => ({ buildRouteEntry: vi.fn() }))
|
|
16
|
-
|
|
17
|
-
import { existsSync } from 'node:fs'
|
|
18
|
-
import { writeFile, mkdir, readFile } from 'node:fs/promises'
|
|
19
|
-
import fg from 'fast-glob'
|
|
20
|
-
import { createServer } from 'vite'
|
|
21
|
-
import { buildSSR } from '../../plugin/build-ssr.js'
|
|
22
|
-
import { buildRouteEntry } from '../../plugin/path-utils.js'
|
|
23
|
-
import { buildSSG, writeRenderedPath } from '../../plugin/build-ssg.js'
|
|
24
|
-
import type { ResolvedCerConfig } from '../../plugin/dev-server.js'
|
|
25
|
-
|
|
26
|
-
function makeConfig(overrides: Partial<ResolvedCerConfig> = {}): ResolvedCerConfig {
|
|
27
|
-
return {
|
|
28
|
-
root: '/project',
|
|
29
|
-
srcDir: '/project/app',
|
|
30
|
-
pagesDir: '/project/app/pages',
|
|
31
|
-
mode: 'ssg',
|
|
32
|
-
ssg: { concurrency: 4 },
|
|
33
|
-
...overrides,
|
|
34
|
-
} as unknown as ResolvedCerConfig
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
beforeEach(() => {
|
|
38
|
-
vi.mocked(buildSSR).mockClear()
|
|
39
|
-
vi.mocked(writeFile).mockClear()
|
|
40
|
-
vi.mocked(mkdir).mockClear()
|
|
41
|
-
vi.mocked(fg).mockClear()
|
|
42
|
-
vi.mocked(readFile).mockClear()
|
|
43
|
-
vi.mocked(existsSync).mockReturnValue(false)
|
|
44
|
-
vi.mocked(fg).mockResolvedValue([])
|
|
45
|
-
vi.mocked(readFile).mockResolvedValue('')
|
|
46
|
-
vi.mocked(buildRouteEntry).mockReset()
|
|
47
|
-
})
|
|
48
|
-
|
|
49
|
-
describe('buildSSG — buildSSR delegation', () => {
|
|
50
|
-
it('calls buildSSR as step 1', async () => {
|
|
51
|
-
await buildSSG(makeConfig())
|
|
52
|
-
expect(buildSSR).toHaveBeenCalledTimes(1)
|
|
53
|
-
})
|
|
54
|
-
|
|
55
|
-
it('passes the config to buildSSR', async () => {
|
|
56
|
-
const config = makeConfig()
|
|
57
|
-
await buildSSG(config)
|
|
58
|
-
expect(vi.mocked(buildSSR).mock.calls[0][0]).toBe(config)
|
|
59
|
-
})
|
|
60
|
-
})
|
|
61
|
-
|
|
62
|
-
describe('buildSSG — ssg-manifest.json', () => {
|
|
63
|
-
it('writes ssg-manifest.json to the dist directory', async () => {
|
|
64
|
-
await buildSSG(makeConfig())
|
|
65
|
-
const manifestCall = vi.mocked(writeFile).mock.calls.find(([path]) =>
|
|
66
|
-
String(path).includes('ssg-manifest.json'),
|
|
67
|
-
)
|
|
68
|
-
expect(manifestCall).toBeDefined()
|
|
69
|
-
expect(String(manifestCall![0])).toContain('/project/dist/ssg-manifest.json')
|
|
70
|
-
})
|
|
71
|
-
|
|
72
|
-
it('manifest JSON contains generatedAt field', async () => {
|
|
73
|
-
await buildSSG(makeConfig())
|
|
74
|
-
const manifestCall = vi.mocked(writeFile).mock.calls.find(([p]) =>
|
|
75
|
-
String(p).includes('ssg-manifest.json'),
|
|
76
|
-
)
|
|
77
|
-
const manifest = JSON.parse(String(manifestCall![1]))
|
|
78
|
-
expect(manifest).toHaveProperty('generatedAt')
|
|
79
|
-
expect(typeof manifest.generatedAt).toBe('string')
|
|
80
|
-
})
|
|
81
|
-
|
|
82
|
-
it('manifest JSON contains paths array', async () => {
|
|
83
|
-
await buildSSG(makeConfig())
|
|
84
|
-
const manifestCall = vi.mocked(writeFile).mock.calls.find(([p]) =>
|
|
85
|
-
String(p).includes('ssg-manifest.json'),
|
|
86
|
-
)
|
|
87
|
-
const manifest = JSON.parse(String(manifestCall![1]))
|
|
88
|
-
expect(manifest).toHaveProperty('paths')
|
|
89
|
-
expect(Array.isArray(manifest.paths)).toBe(true)
|
|
90
|
-
})
|
|
91
|
-
|
|
92
|
-
it('manifest JSON contains errors array', async () => {
|
|
93
|
-
await buildSSG(makeConfig())
|
|
94
|
-
const manifestCall = vi.mocked(writeFile).mock.calls.find(([p]) =>
|
|
95
|
-
String(p).includes('ssg-manifest.json'),
|
|
96
|
-
)
|
|
97
|
-
const manifest = JSON.parse(String(manifestCall![1]))
|
|
98
|
-
expect(manifest).toHaveProperty('errors')
|
|
99
|
-
expect(Array.isArray(manifest.errors)).toBe(true)
|
|
100
|
-
})
|
|
101
|
-
|
|
102
|
-
it('records render errors in manifest (missing server bundle)', async () => {
|
|
103
|
-
const config = makeConfig({ ssg: { routes: ['/about'], concurrency: 1 } } as Partial<ResolvedCerConfig>)
|
|
104
|
-
await buildSSG(config)
|
|
105
|
-
const manifestCall = vi.mocked(writeFile).mock.calls.find(([p]) =>
|
|
106
|
-
String(p).includes('ssg-manifest.json'),
|
|
107
|
-
)
|
|
108
|
-
const manifest = JSON.parse(String(manifestCall![1]))
|
|
109
|
-
// paths + errors together must cover every route we attempted to render
|
|
110
|
-
expect(manifest.paths.length + manifest.errors.length).toBe(1)
|
|
111
|
-
})
|
|
112
|
-
|
|
113
|
-
it('error entries have path and error fields', async () => {
|
|
114
|
-
const config = makeConfig({ ssg: { routes: ['/fail'], concurrency: 1 } } as Partial<ResolvedCerConfig>)
|
|
115
|
-
await buildSSG(config)
|
|
116
|
-
const manifestCall = vi.mocked(writeFile).mock.calls.find(([p]) =>
|
|
117
|
-
String(p).includes('ssg-manifest.json'),
|
|
118
|
-
)
|
|
119
|
-
const manifest = JSON.parse(String(manifestCall![1]))
|
|
120
|
-
if (manifest.errors.length > 0) {
|
|
121
|
-
expect(manifest.errors[0]).toHaveProperty('path')
|
|
122
|
-
expect(manifest.errors[0]).toHaveProperty('error')
|
|
123
|
-
}
|
|
124
|
-
})
|
|
125
|
-
})
|
|
126
|
-
|
|
127
|
-
describe('buildSSG — path collection', () => {
|
|
128
|
-
it('uses ssg.routes when explicitly provided (skips auto-discovery)', async () => {
|
|
129
|
-
const config = makeConfig({
|
|
130
|
-
ssg: { routes: ['/a', '/b'], concurrency: 1 },
|
|
131
|
-
} as Partial<ResolvedCerConfig>)
|
|
132
|
-
await buildSSG(config)
|
|
133
|
-
// fast-glob should NOT have been called — routes are explicit
|
|
134
|
-
expect(fg).not.toHaveBeenCalled()
|
|
135
|
-
})
|
|
136
|
-
|
|
137
|
-
it('calls fg when pagesDir exists and no explicit routes', async () => {
|
|
138
|
-
vi.mocked(existsSync).mockReturnValue(true)
|
|
139
|
-
await buildSSG(makeConfig())
|
|
140
|
-
// fg is called once for page discovery
|
|
141
|
-
expect(fg).toHaveBeenCalledTimes(1)
|
|
142
|
-
})
|
|
143
|
-
|
|
144
|
-
it('skips Vite dev server when all discovered pages are static', async () => {
|
|
145
|
-
vi.mocked(existsSync).mockReturnValue(true)
|
|
146
|
-
vi.mocked(fg).mockResolvedValue([
|
|
147
|
-
'/project/app/pages/index.ts',
|
|
148
|
-
'/project/app/pages/about.ts',
|
|
149
|
-
])
|
|
150
|
-
vi.mocked(buildRouteEntry)
|
|
151
|
-
.mockReturnValueOnce({ routePath: '/', isDynamic: false, isCatchAll: false } as ReturnType<typeof buildRouteEntry>)
|
|
152
|
-
.mockReturnValueOnce({ routePath: '/about', isDynamic: false, isCatchAll: false } as ReturnType<typeof buildRouteEntry>)
|
|
153
|
-
|
|
154
|
-
await buildSSG(makeConfig())
|
|
155
|
-
|
|
156
|
-
expect(createServer).not.toHaveBeenCalled()
|
|
157
|
-
})
|
|
158
|
-
|
|
159
|
-
it('spawns Vite dev server for dynamic pages', async () => {
|
|
160
|
-
vi.mocked(existsSync).mockReturnValue(true)
|
|
161
|
-
vi.mocked(fg).mockResolvedValue(['/project/app/pages/[slug].ts'])
|
|
162
|
-
vi.mocked(buildRouteEntry).mockReturnValueOnce({
|
|
163
|
-
routePath: '/:slug',
|
|
164
|
-
isDynamic: true,
|
|
165
|
-
isCatchAll: false,
|
|
166
|
-
} as ReturnType<typeof buildRouteEntry>)
|
|
167
|
-
|
|
168
|
-
const closeFn = vi.fn().mockResolvedValue(undefined)
|
|
169
|
-
vi.mocked(createServer).mockResolvedValue({
|
|
170
|
-
ssrLoadModule: vi.fn().mockResolvedValue({}),
|
|
171
|
-
close: closeFn,
|
|
172
|
-
} as unknown as Awaited<ReturnType<typeof createServer>>)
|
|
173
|
-
|
|
174
|
-
await buildSSG(makeConfig())
|
|
175
|
-
|
|
176
|
-
expect(createServer).toHaveBeenCalledTimes(1)
|
|
177
|
-
expect(closeFn).toHaveBeenCalledTimes(1)
|
|
178
|
-
})
|
|
179
|
-
|
|
180
|
-
it('closes Vite dev server even when ssrLoadModule throws', async () => {
|
|
181
|
-
vi.mocked(existsSync).mockReturnValue(true)
|
|
182
|
-
vi.mocked(fg).mockResolvedValue(['/project/app/pages/[slug].ts'])
|
|
183
|
-
vi.mocked(buildRouteEntry).mockReturnValueOnce({
|
|
184
|
-
routePath: '/:slug',
|
|
185
|
-
isDynamic: true,
|
|
186
|
-
isCatchAll: false,
|
|
187
|
-
} as ReturnType<typeof buildRouteEntry>)
|
|
188
|
-
|
|
189
|
-
const closeFn = vi.fn().mockResolvedValue(undefined)
|
|
190
|
-
vi.mocked(createServer).mockResolvedValue({
|
|
191
|
-
ssrLoadModule: vi.fn().mockRejectedValue(new Error('load failed')),
|
|
192
|
-
close: closeFn,
|
|
193
|
-
} as unknown as Awaited<ReturnType<typeof createServer>>)
|
|
194
|
-
|
|
195
|
-
await buildSSG(makeConfig())
|
|
196
|
-
|
|
197
|
-
expect(closeFn).toHaveBeenCalledTimes(1)
|
|
198
|
-
})
|
|
199
|
-
|
|
200
|
-
it('expands dynamic ssg.paths into concrete URL paths', async () => {
|
|
201
|
-
vi.mocked(existsSync).mockReturnValue(true)
|
|
202
|
-
vi.mocked(fg).mockResolvedValue(['/project/app/pages/[id].ts'])
|
|
203
|
-
vi.mocked(buildRouteEntry).mockReturnValueOnce({
|
|
204
|
-
routePath: '/:id',
|
|
205
|
-
isDynamic: true,
|
|
206
|
-
isCatchAll: false,
|
|
207
|
-
} as ReturnType<typeof buildRouteEntry>)
|
|
208
|
-
|
|
209
|
-
const ssgPathsFn = vi.fn().mockResolvedValue([
|
|
210
|
-
{ params: { id: '1' } },
|
|
211
|
-
{ params: { id: '2' } },
|
|
212
|
-
])
|
|
213
|
-
const closeFn = vi.fn().mockResolvedValue(undefined)
|
|
214
|
-
vi.mocked(createServer).mockResolvedValue({
|
|
215
|
-
ssrLoadModule: vi.fn().mockResolvedValue({ meta: { ssg: { paths: ssgPathsFn } } }),
|
|
216
|
-
close: closeFn,
|
|
217
|
-
} as unknown as Awaited<ReturnType<typeof createServer>>)
|
|
218
|
-
|
|
219
|
-
const config = makeConfig({ ssg: { concurrency: 1 } } as Partial<ResolvedCerConfig>)
|
|
220
|
-
await buildSSG(config)
|
|
221
|
-
|
|
222
|
-
// The manifest should attempt to render '/', '/1', '/2' (3 paths total)
|
|
223
|
-
const manifestCall = vi.mocked(writeFile).mock.calls.find(([p]) =>
|
|
224
|
-
String(p).includes('ssg-manifest.json'),
|
|
225
|
-
)
|
|
226
|
-
const manifest = JSON.parse(String(manifestCall![1]))
|
|
227
|
-
expect(manifest.paths.length + manifest.errors.length).toBe(3)
|
|
228
|
-
})
|
|
229
|
-
|
|
230
|
-
it('skips catch-all pages without explicit paths or content queries when auto-discovering paths', async () => {
|
|
231
|
-
vi.mocked(existsSync).mockReturnValue(true)
|
|
232
|
-
vi.mocked(fg).mockResolvedValue(['/project/app/pages/[...all].ts'])
|
|
233
|
-
vi.mocked(readFile).mockResolvedValue('')
|
|
234
|
-
vi.mocked(buildRouteEntry).mockReturnValueOnce({
|
|
235
|
-
routePath: '/:all*',
|
|
236
|
-
isDynamic: true,
|
|
237
|
-
isCatchAll: true,
|
|
238
|
-
} as ReturnType<typeof buildRouteEntry>)
|
|
239
|
-
|
|
240
|
-
const closeFn = vi.fn().mockResolvedValue(undefined)
|
|
241
|
-
vi.mocked(createServer).mockResolvedValue({
|
|
242
|
-
ssrLoadModule: vi.fn().mockResolvedValue({}),
|
|
243
|
-
close: closeFn,
|
|
244
|
-
} as unknown as Awaited<ReturnType<typeof createServer>>)
|
|
245
|
-
|
|
246
|
-
await buildSSG(makeConfig())
|
|
247
|
-
|
|
248
|
-
// Only '/' (always added) should be attempted
|
|
249
|
-
const manifestCall = vi.mocked(writeFile).mock.calls.find(([p]) =>
|
|
250
|
-
String(p).includes('ssg-manifest.json'),
|
|
251
|
-
)
|
|
252
|
-
const manifest = JSON.parse(String(manifestCall![1]))
|
|
253
|
-
expect(manifest.paths.length + manifest.errors.length).toBe(1)
|
|
254
|
-
})
|
|
255
|
-
|
|
256
|
-
it('auto-expands content-backed catch-all pages from the content store', async () => {
|
|
257
|
-
vi.mocked(existsSync).mockReturnValue(true)
|
|
258
|
-
vi.mocked(fg).mockResolvedValue(['/project/app/pages/[...all].ts'])
|
|
259
|
-
vi.mocked(readFile).mockResolvedValue('export const loader = async () => queryContent().find()')
|
|
260
|
-
vi.mocked(buildRouteEntry).mockReturnValueOnce({
|
|
261
|
-
routePath: '/:all*',
|
|
262
|
-
isDynamic: true,
|
|
263
|
-
isCatchAll: true,
|
|
264
|
-
} as ReturnType<typeof buildRouteEntry>)
|
|
265
|
-
|
|
266
|
-
;(globalThis as Record<string, unknown>).__CER_CONTENT_STORE__ = [
|
|
267
|
-
{ _path: '/music/effects/pro-co/rat' },
|
|
268
|
-
{ _path: '/music/effects/boss/ds-1' },
|
|
269
|
-
]
|
|
270
|
-
|
|
271
|
-
const closeFn = vi.fn().mockResolvedValue(undefined)
|
|
272
|
-
vi.mocked(createServer).mockResolvedValue({
|
|
273
|
-
ssrLoadModule: vi.fn().mockResolvedValue({}),
|
|
274
|
-
close: closeFn,
|
|
275
|
-
} as unknown as Awaited<ReturnType<typeof createServer>>)
|
|
276
|
-
|
|
277
|
-
await buildSSG(makeConfig({ ssg: { concurrency: 1 } } as Partial<ResolvedCerConfig>))
|
|
278
|
-
|
|
279
|
-
const manifestCall = vi.mocked(writeFile).mock.calls.find(([p]) =>
|
|
280
|
-
String(p).includes('ssg-manifest.json'),
|
|
281
|
-
)
|
|
282
|
-
const manifest = JSON.parse(String(manifestCall![1]))
|
|
283
|
-
expect(manifest.paths.length + manifest.errors.length).toBe(3)
|
|
284
|
-
|
|
285
|
-
delete (globalThis as Record<string, unknown>).__CER_CONTENT_STORE__
|
|
286
|
-
})
|
|
287
|
-
|
|
288
|
-
it('filters auto-expanded content paths by nested catch-all prefix', async () => {
|
|
289
|
-
vi.mocked(existsSync).mockReturnValue(true)
|
|
290
|
-
vi.mocked(fg).mockResolvedValue(['/project/app/pages/docs/[...all].ts'])
|
|
291
|
-
vi.mocked(readFile).mockResolvedValue('queryContent()')
|
|
292
|
-
vi.mocked(buildRouteEntry).mockReturnValueOnce({
|
|
293
|
-
routePath: '/docs/:all*',
|
|
294
|
-
isDynamic: true,
|
|
295
|
-
isCatchAll: true,
|
|
296
|
-
} as ReturnType<typeof buildRouteEntry>)
|
|
297
|
-
|
|
298
|
-
;(globalThis as Record<string, unknown>).__CER_CONTENT_STORE__ = [
|
|
299
|
-
{ _path: '/docs/getting-started' },
|
|
300
|
-
{ _path: '/docs/api/config' },
|
|
301
|
-
{ _path: '/blog/hello' },
|
|
302
|
-
]
|
|
303
|
-
|
|
304
|
-
const closeFn = vi.fn().mockResolvedValue(undefined)
|
|
305
|
-
vi.mocked(createServer).mockResolvedValue({
|
|
306
|
-
ssrLoadModule: vi.fn().mockResolvedValue({}),
|
|
307
|
-
close: closeFn,
|
|
308
|
-
} as unknown as Awaited<ReturnType<typeof createServer>>)
|
|
309
|
-
|
|
310
|
-
await buildSSG(makeConfig({ ssg: { concurrency: 1 } } as Partial<ResolvedCerConfig>))
|
|
311
|
-
|
|
312
|
-
const manifestCall = vi.mocked(writeFile).mock.calls.find(([p]) =>
|
|
313
|
-
String(p).includes('ssg-manifest.json'),
|
|
314
|
-
)
|
|
315
|
-
const manifest = JSON.parse(String(manifestCall![1]))
|
|
316
|
-
expect(manifest.paths.length + manifest.errors.length).toBe(3)
|
|
317
|
-
|
|
318
|
-
delete (globalThis as Record<string, unknown>).__CER_CONTENT_STORE__
|
|
319
|
-
})
|
|
320
|
-
|
|
321
|
-
it('expands catch-all ssg.paths into concrete URL paths', async () => {
|
|
322
|
-
vi.mocked(existsSync).mockReturnValue(true)
|
|
323
|
-
vi.mocked(fg).mockResolvedValue(['/project/app/pages/[...all].ts'])
|
|
324
|
-
vi.mocked(readFile).mockResolvedValue('')
|
|
325
|
-
vi.mocked(buildRouteEntry).mockReturnValueOnce({
|
|
326
|
-
routePath: '/:all*',
|
|
327
|
-
isDynamic: true,
|
|
328
|
-
isCatchAll: true,
|
|
329
|
-
} as ReturnType<typeof buildRouteEntry>)
|
|
330
|
-
|
|
331
|
-
const closeFn = vi.fn().mockResolvedValue(undefined)
|
|
332
|
-
vi.mocked(createServer).mockResolvedValue({
|
|
333
|
-
ssrLoadModule: vi.fn().mockResolvedValue({
|
|
334
|
-
meta: {
|
|
335
|
-
ssg: {
|
|
336
|
-
paths: async () => [
|
|
337
|
-
{ params: { all: 'music/effects/pro-co/rat' } },
|
|
338
|
-
{ params: { all: 'music/effects/boss/ds-1' } },
|
|
339
|
-
],
|
|
340
|
-
},
|
|
341
|
-
},
|
|
342
|
-
}),
|
|
343
|
-
close: closeFn,
|
|
344
|
-
} as unknown as Awaited<ReturnType<typeof createServer>>)
|
|
345
|
-
|
|
346
|
-
await buildSSG(makeConfig({ ssg: { concurrency: 1 } } as Partial<ResolvedCerConfig>))
|
|
347
|
-
|
|
348
|
-
const manifestCall = vi.mocked(writeFile).mock.calls.find(([p]) =>
|
|
349
|
-
String(p).includes('ssg-manifest.json'),
|
|
350
|
-
)
|
|
351
|
-
const manifest = JSON.parse(String(manifestCall![1]))
|
|
352
|
-
expect(manifest.paths.length + manifest.errors.length).toBe(3)
|
|
353
|
-
expect(manifest.errors.map((entry: { path: string }) => entry.path)).toEqual([
|
|
354
|
-
'/',
|
|
355
|
-
'/music/effects/pro-co/rat',
|
|
356
|
-
'/music/effects/boss/ds-1',
|
|
357
|
-
])
|
|
358
|
-
})
|
|
359
|
-
|
|
360
|
-
it('deduplicates collected paths', async () => {
|
|
361
|
-
vi.mocked(existsSync).mockReturnValue(true)
|
|
362
|
-
vi.mocked(fg).mockResolvedValue([
|
|
363
|
-
'/project/app/pages/index.ts',
|
|
364
|
-
'/project/app/pages/home.ts',
|
|
365
|
-
])
|
|
366
|
-
// Both resolve to '/' — should deduplicate to a single path
|
|
367
|
-
vi.mocked(buildRouteEntry)
|
|
368
|
-
.mockReturnValueOnce({ routePath: '/', isDynamic: false, isCatchAll: false } as ReturnType<typeof buildRouteEntry>)
|
|
369
|
-
.mockReturnValueOnce({ routePath: '/', isDynamic: false, isCatchAll: false } as ReturnType<typeof buildRouteEntry>)
|
|
370
|
-
|
|
371
|
-
await buildSSG(makeConfig({ ssg: { concurrency: 1 } } as Partial<ResolvedCerConfig>))
|
|
372
|
-
|
|
373
|
-
const manifestCall = vi.mocked(writeFile).mock.calls.find(([p]) =>
|
|
374
|
-
String(p).includes('ssg-manifest.json'),
|
|
375
|
-
)
|
|
376
|
-
const manifest = JSON.parse(String(manifestCall![1]))
|
|
377
|
-
expect(manifest.paths.length + manifest.errors.length).toBe(1)
|
|
378
|
-
})
|
|
379
|
-
})
|
|
380
|
-
|
|
381
|
-
// ─── render: 'server' / 'spa' skip ───────────────────────────────────────────
|
|
382
|
-
|
|
383
|
-
describe('buildSSG — render strategy skip (static pages)', () => {
|
|
384
|
-
it('skips static page with render: server', async () => {
|
|
385
|
-
vi.mocked(existsSync).mockReturnValue(true)
|
|
386
|
-
vi.mocked(fg).mockResolvedValue(['/project/app/pages/dashboard.ts'])
|
|
387
|
-
vi.mocked(readFile).mockResolvedValue("export const meta = { render: 'server' }")
|
|
388
|
-
vi.mocked(buildRouteEntry).mockReturnValueOnce({
|
|
389
|
-
routePath: '/dashboard',
|
|
390
|
-
isDynamic: false,
|
|
391
|
-
isCatchAll: false,
|
|
392
|
-
} as ReturnType<typeof buildRouteEntry>)
|
|
393
|
-
|
|
394
|
-
const config = makeConfig({ ssg: { concurrency: 1 } } as Partial<ResolvedCerConfig>)
|
|
395
|
-
await buildSSG(config)
|
|
396
|
-
|
|
397
|
-
// buildRouteEntry should never be called — page is skipped before it
|
|
398
|
-
expect(buildRouteEntry).not.toHaveBeenCalled()
|
|
399
|
-
})
|
|
400
|
-
|
|
401
|
-
it('skips static page with render: spa', async () => {
|
|
402
|
-
vi.mocked(existsSync).mockReturnValue(true)
|
|
403
|
-
vi.mocked(fg).mockResolvedValue(['/project/app/pages/profile.ts'])
|
|
404
|
-
vi.mocked(readFile).mockResolvedValue("export const meta = { render: 'spa' }")
|
|
405
|
-
vi.mocked(buildRouteEntry).mockReturnValueOnce({
|
|
406
|
-
routePath: '/profile',
|
|
407
|
-
isDynamic: false,
|
|
408
|
-
isCatchAll: false,
|
|
409
|
-
} as ReturnType<typeof buildRouteEntry>)
|
|
410
|
-
|
|
411
|
-
const config = makeConfig({ ssg: { concurrency: 1 } } as Partial<ResolvedCerConfig>)
|
|
412
|
-
await buildSSG(config)
|
|
413
|
-
|
|
414
|
-
expect(buildRouteEntry).not.toHaveBeenCalled()
|
|
415
|
-
})
|
|
416
|
-
|
|
417
|
-
it('does not skip static page with render: static', async () => {
|
|
418
|
-
vi.mocked(existsSync).mockReturnValue(true)
|
|
419
|
-
vi.mocked(fg).mockResolvedValue(['/project/app/pages/legal.ts'])
|
|
420
|
-
vi.mocked(readFile).mockResolvedValue("export const meta = { render: 'static' }")
|
|
421
|
-
vi.mocked(buildRouteEntry).mockReturnValueOnce({
|
|
422
|
-
routePath: '/legal',
|
|
423
|
-
isDynamic: false,
|
|
424
|
-
isCatchAll: false,
|
|
425
|
-
} as ReturnType<typeof buildRouteEntry>)
|
|
426
|
-
|
|
427
|
-
await buildSSG(makeConfig())
|
|
428
|
-
|
|
429
|
-
expect(buildRouteEntry).toHaveBeenCalledTimes(1)
|
|
430
|
-
})
|
|
431
|
-
|
|
432
|
-
it('does not skip static page with no render meta', async () => {
|
|
433
|
-
vi.mocked(existsSync).mockReturnValue(true)
|
|
434
|
-
vi.mocked(fg).mockResolvedValue(['/project/app/pages/about.ts'])
|
|
435
|
-
vi.mocked(readFile).mockResolvedValue("component('page-about', () => html`<h1>About</h1>`)")
|
|
436
|
-
vi.mocked(buildRouteEntry).mockReturnValueOnce({
|
|
437
|
-
routePath: '/about',
|
|
438
|
-
isDynamic: false,
|
|
439
|
-
isCatchAll: false,
|
|
440
|
-
} as ReturnType<typeof buildRouteEntry>)
|
|
441
|
-
|
|
442
|
-
await buildSSG(makeConfig())
|
|
443
|
-
|
|
444
|
-
expect(buildRouteEntry).toHaveBeenCalledTimes(1)
|
|
445
|
-
})
|
|
446
|
-
})
|
|
447
|
-
|
|
448
|
-
describe('buildSSG — render strategy skip (dynamic pages)', () => {
|
|
449
|
-
it('skips dynamic page with render: server from ssrLoadModule', async () => {
|
|
450
|
-
vi.mocked(existsSync).mockReturnValue(true)
|
|
451
|
-
vi.mocked(fg).mockResolvedValue(['/project/app/pages/[slug].ts'])
|
|
452
|
-
vi.mocked(readFile).mockResolvedValue('')
|
|
453
|
-
vi.mocked(buildRouteEntry).mockReturnValueOnce({
|
|
454
|
-
routePath: '/:slug',
|
|
455
|
-
isDynamic: true,
|
|
456
|
-
isCatchAll: false,
|
|
457
|
-
} as ReturnType<typeof buildRouteEntry>)
|
|
458
|
-
|
|
459
|
-
const closeFn = vi.fn().mockResolvedValue(undefined)
|
|
460
|
-
vi.mocked(createServer).mockResolvedValue({
|
|
461
|
-
ssrLoadModule: vi.fn().mockResolvedValue({ meta: { render: 'server' } }),
|
|
462
|
-
close: closeFn,
|
|
463
|
-
} as unknown as Awaited<ReturnType<typeof createServer>>)
|
|
464
|
-
|
|
465
|
-
const config = makeConfig({ ssg: { concurrency: 1 } } as Partial<ResolvedCerConfig>)
|
|
466
|
-
await buildSSG(config)
|
|
467
|
-
|
|
468
|
-
// Only '/' (always added) — the dynamic route was skipped
|
|
469
|
-
const manifestCall = vi.mocked(writeFile).mock.calls.find(([p]) =>
|
|
470
|
-
String(p).includes('ssg-manifest.json'),
|
|
471
|
-
)
|
|
472
|
-
const manifest = JSON.parse(String(manifestCall![1]))
|
|
473
|
-
expect(manifest.paths.length + manifest.errors.length).toBe(1)
|
|
474
|
-
})
|
|
475
|
-
|
|
476
|
-
it('skips dynamic page with render: spa from ssrLoadModule', async () => {
|
|
477
|
-
vi.mocked(existsSync).mockReturnValue(true)
|
|
478
|
-
vi.mocked(fg).mockResolvedValue(['/project/app/pages/[id].ts'])
|
|
479
|
-
vi.mocked(readFile).mockResolvedValue('')
|
|
480
|
-
vi.mocked(buildRouteEntry).mockReturnValueOnce({
|
|
481
|
-
routePath: '/:id',
|
|
482
|
-
isDynamic: true,
|
|
483
|
-
isCatchAll: false,
|
|
484
|
-
} as ReturnType<typeof buildRouteEntry>)
|
|
485
|
-
|
|
486
|
-
const closeFn = vi.fn().mockResolvedValue(undefined)
|
|
487
|
-
vi.mocked(createServer).mockResolvedValue({
|
|
488
|
-
ssrLoadModule: vi.fn().mockResolvedValue({ meta: { render: 'spa' } }),
|
|
489
|
-
close: closeFn,
|
|
490
|
-
} as unknown as Awaited<ReturnType<typeof createServer>>)
|
|
491
|
-
|
|
492
|
-
const config = makeConfig({ ssg: { concurrency: 1 } } as Partial<ResolvedCerConfig>)
|
|
493
|
-
await buildSSG(config)
|
|
494
|
-
|
|
495
|
-
const manifestCall = vi.mocked(writeFile).mock.calls.find(([p]) =>
|
|
496
|
-
String(p).includes('ssg-manifest.json'),
|
|
497
|
-
)
|
|
498
|
-
const manifest = JSON.parse(String(manifestCall![1]))
|
|
499
|
-
expect(manifest.paths.length + manifest.errors.length).toBe(1)
|
|
500
|
-
})
|
|
501
|
-
})
|
|
502
|
-
|
|
503
|
-
// ─── writeRenderedPath ────────────────────────────────────────────────────────
|
|
504
|
-
|
|
505
|
-
describe('writeRenderedPath', () => {
|
|
506
|
-
beforeEach(() => {
|
|
507
|
-
vi.mocked(writeFile).mockClear()
|
|
508
|
-
vi.mocked(mkdir).mockClear()
|
|
509
|
-
})
|
|
510
|
-
|
|
511
|
-
it('writes root path to dist/index.html', async () => {
|
|
512
|
-
await writeRenderedPath('/', '<html>home</html>', '/project/dist')
|
|
513
|
-
const [writePath] = vi.mocked(writeFile).mock.calls[0]
|
|
514
|
-
expect(String(writePath)).toMatch(/dist\/index\.html$/)
|
|
515
|
-
})
|
|
516
|
-
|
|
517
|
-
it('writes /about to dist/about/index.html', async () => {
|
|
518
|
-
await writeRenderedPath('/about', '<html>about</html>', '/project/dist')
|
|
519
|
-
const [writePath] = vi.mocked(writeFile).mock.calls[0]
|
|
520
|
-
expect(String(writePath)).toMatch(/dist\/about\/index\.html$/)
|
|
521
|
-
})
|
|
522
|
-
|
|
523
|
-
it('writes nested path to correct subdirectory', async () => {
|
|
524
|
-
await writeRenderedPath('/blog/first-post', '<html>post</html>', '/project/dist')
|
|
525
|
-
const [writePath] = vi.mocked(writeFile).mock.calls[0]
|
|
526
|
-
expect(String(writePath)).toMatch(/dist\/blog\/first-post\/index\.html$/)
|
|
527
|
-
})
|
|
528
|
-
|
|
529
|
-
it('writes the provided html content', async () => {
|
|
530
|
-
const html = '<html><body>Hello</body></html>'
|
|
531
|
-
await writeRenderedPath('/page', html, '/project/dist')
|
|
532
|
-
const [, content] = vi.mocked(writeFile).mock.calls[0]
|
|
533
|
-
expect(content).toBe(html)
|
|
534
|
-
})
|
|
535
|
-
|
|
536
|
-
it('creates the output directory before writing', async () => {
|
|
537
|
-
await writeRenderedPath('/nested/deep', '<html/>', '/project/dist')
|
|
538
|
-
expect(mkdir).toHaveBeenCalledWith(expect.stringContaining('nested/deep'), { recursive: true })
|
|
539
|
-
})
|
|
540
|
-
|
|
541
|
-
it('strips leading and trailing slashes from path', async () => {
|
|
542
|
-
await writeRenderedPath('/trailing/', '<html/>', '/project/dist')
|
|
543
|
-
const [writePath] = vi.mocked(writeFile).mock.calls[0]
|
|
544
|
-
expect(String(writePath)).toMatch(/trailing\/index\.html$/)
|
|
545
|
-
expect(String(writePath)).not.toMatch(/\/\//)
|
|
546
|
-
})
|
|
547
|
-
})
|
|
548
|
-
|
|
549
|
-
// ─── i18n locale path expansion ───────────────────────────────────────────────
|
|
550
|
-
|
|
551
|
-
describe('buildSSG — i18n locale path expansion', () => {
|
|
552
|
-
function makeI18nConfig(strategy: 'prefix' | 'prefix_except_default' | 'no_prefix') {
|
|
553
|
-
return makeConfig({
|
|
554
|
-
i18n: { locales: ['en', 'fr'], defaultLocale: 'en', strategy },
|
|
555
|
-
ssg: { routes: ['/about'], concurrency: 1 },
|
|
556
|
-
} as Partial<ResolvedCerConfig>)
|
|
557
|
-
}
|
|
558
|
-
|
|
559
|
-
it('prefix_except_default: expands /about to /about and /fr/about', async () => {
|
|
560
|
-
await buildSSG(makeI18nConfig('prefix_except_default'))
|
|
561
|
-
const manifestCall = vi.mocked(writeFile).mock.calls.find(([p]) =>
|
|
562
|
-
String(p).includes('ssg-manifest.json'),
|
|
563
|
-
)
|
|
564
|
-
const manifest = JSON.parse(String(manifestCall![1]))
|
|
565
|
-
const total = manifest.paths.length + manifest.errors.length
|
|
566
|
-
expect(total).toBe(2) // /about + /fr/about
|
|
567
|
-
})
|
|
568
|
-
|
|
569
|
-
it('prefix: expands /about to /en/about and /fr/about', async () => {
|
|
570
|
-
await buildSSG(makeI18nConfig('prefix'))
|
|
571
|
-
const manifestCall = vi.mocked(writeFile).mock.calls.find(([p]) =>
|
|
572
|
-
String(p).includes('ssg-manifest.json'),
|
|
573
|
-
)
|
|
574
|
-
const manifest = JSON.parse(String(manifestCall![1]))
|
|
575
|
-
const total = manifest.paths.length + manifest.errors.length
|
|
576
|
-
expect(total).toBe(2) // /en/about + /fr/about
|
|
577
|
-
})
|
|
578
|
-
|
|
579
|
-
it('no_prefix: does not expand paths', async () => {
|
|
580
|
-
await buildSSG(makeI18nConfig('no_prefix'))
|
|
581
|
-
const manifestCall = vi.mocked(writeFile).mock.calls.find(([p]) =>
|
|
582
|
-
String(p).includes('ssg-manifest.json'),
|
|
583
|
-
)
|
|
584
|
-
const manifest = JSON.parse(String(manifestCall![1]))
|
|
585
|
-
const total = manifest.paths.length + manifest.errors.length
|
|
586
|
-
expect(total).toBe(1) // /about only
|
|
587
|
-
})
|
|
588
|
-
|
|
589
|
-
it('no i18n config: behaves as before (no expansion)', async () => {
|
|
590
|
-
const config = makeConfig({ ssg: { routes: ['/about'], concurrency: 1 } } as Partial<ResolvedCerConfig>)
|
|
591
|
-
await buildSSG(config)
|
|
592
|
-
const manifestCall = vi.mocked(writeFile).mock.calls.find(([p]) =>
|
|
593
|
-
String(p).includes('ssg-manifest.json'),
|
|
594
|
-
)
|
|
595
|
-
const manifest = JSON.parse(String(manifestCall![1]))
|
|
596
|
-
expect(manifest.paths.length + manifest.errors.length).toBe(1)
|
|
597
|
-
})
|
|
598
|
-
})
|