@jasonshimmy/vite-plugin-cer-app 0.1.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/.github/copilot-instructions.md +130 -0
- package/.github/workflows/publish.yml +206 -0
- package/.nvmrc +1 -0
- package/CHANGELOG.md +10 -0
- package/IMPLEMENTATION_PLAN.md +391 -0
- package/README.md +231 -0
- package/VITE_PLUGIN_FRAMEWORK_PLAN.md +594 -0
- package/commits.txt +3 -0
- package/dist/__tests__/plugin/path-utils.test.d.ts +2 -0
- package/dist/__tests__/plugin/path-utils.test.d.ts.map +1 -0
- package/dist/__tests__/plugin/path-utils.test.js +305 -0
- package/dist/__tests__/plugin/path-utils.test.js.map +1 -0
- package/dist/__tests__/plugin/scanner.test.d.ts +2 -0
- package/dist/__tests__/plugin/scanner.test.d.ts.map +1 -0
- package/dist/__tests__/plugin/scanner.test.js +143 -0
- package/dist/__tests__/plugin/scanner.test.js.map +1 -0
- package/dist/__tests__/plugin/transforms/auto-import.test.d.ts +2 -0
- package/dist/__tests__/plugin/transforms/auto-import.test.d.ts.map +1 -0
- package/dist/__tests__/plugin/transforms/auto-import.test.js +151 -0
- package/dist/__tests__/plugin/transforms/auto-import.test.js.map +1 -0
- package/dist/__tests__/plugin/transforms/head-inject.test.d.ts +2 -0
- package/dist/__tests__/plugin/transforms/head-inject.test.d.ts.map +1 -0
- package/dist/__tests__/plugin/transforms/head-inject.test.js +151 -0
- package/dist/__tests__/plugin/transforms/head-inject.test.js.map +1 -0
- package/dist/__tests__/plugin/virtual/components.test.d.ts +2 -0
- package/dist/__tests__/plugin/virtual/components.test.d.ts.map +1 -0
- package/dist/__tests__/plugin/virtual/components.test.js +47 -0
- package/dist/__tests__/plugin/virtual/components.test.js.map +1 -0
- package/dist/__tests__/plugin/virtual/composables.test.d.ts +2 -0
- package/dist/__tests__/plugin/virtual/composables.test.d.ts.map +1 -0
- package/dist/__tests__/plugin/virtual/composables.test.js +48 -0
- package/dist/__tests__/plugin/virtual/composables.test.js.map +1 -0
- package/dist/__tests__/plugin/virtual/layouts.test.d.ts +2 -0
- package/dist/__tests__/plugin/virtual/layouts.test.d.ts.map +1 -0
- package/dist/__tests__/plugin/virtual/layouts.test.js +59 -0
- package/dist/__tests__/plugin/virtual/layouts.test.js.map +1 -0
- package/dist/__tests__/plugin/virtual/middleware.test.d.ts +2 -0
- package/dist/__tests__/plugin/virtual/middleware.test.d.ts.map +1 -0
- package/dist/__tests__/plugin/virtual/middleware.test.js +58 -0
- package/dist/__tests__/plugin/virtual/middleware.test.js.map +1 -0
- package/dist/__tests__/plugin/virtual/plugins.test.d.ts +2 -0
- package/dist/__tests__/plugin/virtual/plugins.test.d.ts.map +1 -0
- package/dist/__tests__/plugin/virtual/plugins.test.js +73 -0
- package/dist/__tests__/plugin/virtual/plugins.test.js.map +1 -0
- package/dist/__tests__/plugin/virtual/routes.test.d.ts +2 -0
- package/dist/__tests__/plugin/virtual/routes.test.d.ts.map +1 -0
- package/dist/__tests__/plugin/virtual/routes.test.js +167 -0
- package/dist/__tests__/plugin/virtual/routes.test.js.map +1 -0
- package/dist/__tests__/plugin/virtual/server-api.test.d.ts +2 -0
- package/dist/__tests__/plugin/virtual/server-api.test.d.ts.map +1 -0
- package/dist/__tests__/plugin/virtual/server-api.test.js +72 -0
- package/dist/__tests__/plugin/virtual/server-api.test.js.map +1 -0
- package/dist/__tests__/runtime/use-head.test.d.ts +2 -0
- package/dist/__tests__/runtime/use-head.test.d.ts.map +1 -0
- package/dist/__tests__/runtime/use-head.test.js +202 -0
- package/dist/__tests__/runtime/use-head.test.js.map +1 -0
- package/dist/__tests__/runtime/use-page-data.test.d.ts +2 -0
- package/dist/__tests__/runtime/use-page-data.test.d.ts.map +1 -0
- package/dist/__tests__/runtime/use-page-data.test.js +41 -0
- package/dist/__tests__/runtime/use-page-data.test.js.map +1 -0
- package/dist/cli/commands/build.d.ts +3 -0
- package/dist/cli/commands/build.d.ts.map +1 -0
- package/dist/cli/commands/build.js +103 -0
- package/dist/cli/commands/build.js.map +1 -0
- package/dist/cli/commands/dev.d.ts +3 -0
- package/dist/cli/commands/dev.d.ts.map +1 -0
- package/dist/cli/commands/dev.js +92 -0
- package/dist/cli/commands/dev.js.map +1 -0
- package/dist/cli/commands/generate.d.ts +7 -0
- package/dist/cli/commands/generate.d.ts.map +1 -0
- package/dist/cli/commands/generate.js +72 -0
- package/dist/cli/commands/generate.js.map +1 -0
- package/dist/cli/commands/preview.d.ts +3 -0
- package/dist/cli/commands/preview.d.ts.map +1 -0
- package/dist/cli/commands/preview.js +191 -0
- package/dist/cli/commands/preview.js.map +1 -0
- package/dist/cli/create/index.d.ts +3 -0
- package/dist/cli/create/index.d.ts.map +1 -0
- package/dist/cli/create/index.js +184 -0
- package/dist/cli/create/index.js.map +1 -0
- package/dist/cli/index.d.ts +3 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +17 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/plugin/build-ssg.d.ts +12 -0
- package/dist/plugin/build-ssg.d.ts.map +1 -0
- package/dist/plugin/build-ssg.js +212 -0
- package/dist/plugin/build-ssg.js.map +1 -0
- package/dist/plugin/build-ssr.d.ts +10 -0
- package/dist/plugin/build-ssr.d.ts.map +1 -0
- package/dist/plugin/build-ssr.js +139 -0
- package/dist/plugin/build-ssr.js.map +1 -0
- package/dist/plugin/dev-server.d.ts +46 -0
- package/dist/plugin/dev-server.d.ts.map +1 -0
- package/dist/plugin/dev-server.js +194 -0
- package/dist/plugin/dev-server.js.map +1 -0
- package/dist/plugin/dts-generator.d.ts +27 -0
- package/dist/plugin/dts-generator.d.ts.map +1 -0
- package/dist/plugin/dts-generator.js +180 -0
- package/dist/plugin/dts-generator.js.map +1 -0
- package/dist/plugin/index.d.ts +13 -0
- package/dist/plugin/index.d.ts.map +1 -0
- package/dist/plugin/index.js +298 -0
- package/dist/plugin/index.js.map +1 -0
- package/dist/plugin/path-utils.d.ts +57 -0
- package/dist/plugin/path-utils.d.ts.map +1 -0
- package/dist/plugin/path-utils.js +160 -0
- package/dist/plugin/path-utils.js.map +1 -0
- package/dist/plugin/scanner.d.ts +17 -0
- package/dist/plugin/scanner.d.ts.map +1 -0
- package/dist/plugin/scanner.js +54 -0
- package/dist/plugin/scanner.js.map +1 -0
- package/dist/plugin/transforms/auto-import.d.ts +14 -0
- package/dist/plugin/transforms/auto-import.d.ts.map +1 -0
- package/dist/plugin/transforms/auto-import.js +154 -0
- package/dist/plugin/transforms/auto-import.js.map +1 -0
- package/dist/plugin/transforms/head-inject.d.ts +29 -0
- package/dist/plugin/transforms/head-inject.d.ts.map +1 -0
- package/dist/plugin/transforms/head-inject.js +127 -0
- package/dist/plugin/transforms/head-inject.js.map +1 -0
- package/dist/plugin/virtual/components.d.ts +6 -0
- package/dist/plugin/virtual/components.d.ts.map +1 -0
- package/dist/plugin/virtual/components.js +22 -0
- package/dist/plugin/virtual/components.js.map +1 -0
- package/dist/plugin/virtual/composables.d.ts +6 -0
- package/dist/plugin/virtual/composables.d.ts.map +1 -0
- package/dist/plugin/virtual/composables.js +22 -0
- package/dist/plugin/virtual/composables.js.map +1 -0
- package/dist/plugin/virtual/error.d.ts +13 -0
- package/dist/plugin/virtual/error.d.ts.map +1 -0
- package/dist/plugin/virtual/error.js +32 -0
- package/dist/plugin/virtual/error.js.map +1 -0
- package/dist/plugin/virtual/layouts.d.ts +6 -0
- package/dist/plugin/virtual/layouts.d.ts.map +1 -0
- package/dist/plugin/virtual/layouts.js +33 -0
- package/dist/plugin/virtual/layouts.js.map +1 -0
- package/dist/plugin/virtual/loading.d.ts +11 -0
- package/dist/plugin/virtual/loading.d.ts.map +1 -0
- package/dist/plugin/virtual/loading.js +30 -0
- package/dist/plugin/virtual/loading.js.map +1 -0
- package/dist/plugin/virtual/middleware.d.ts +6 -0
- package/dist/plugin/virtual/middleware.d.ts.map +1 -0
- package/dist/plugin/virtual/middleware.js +36 -0
- package/dist/plugin/virtual/middleware.js.map +1 -0
- package/dist/plugin/virtual/plugins.d.ts +6 -0
- package/dist/plugin/virtual/plugins.d.ts.map +1 -0
- package/dist/plugin/virtual/plugins.js +30 -0
- package/dist/plugin/virtual/plugins.js.map +1 -0
- package/dist/plugin/virtual/routes.d.ts +16 -0
- package/dist/plugin/virtual/routes.d.ts.map +1 -0
- package/dist/plugin/virtual/routes.js +131 -0
- package/dist/plugin/virtual/routes.js.map +1 -0
- package/dist/plugin/virtual/server-api.d.ts +6 -0
- package/dist/plugin/virtual/server-api.d.ts.map +1 -0
- package/dist/plugin/virtual/server-api.js +41 -0
- package/dist/plugin/virtual/server-api.js.map +1 -0
- package/dist/plugin/virtual/server-middleware.d.ts +6 -0
- package/dist/plugin/virtual/server-middleware.d.ts.map +1 -0
- package/dist/plugin/virtual/server-middleware.js +36 -0
- package/dist/plugin/virtual/server-middleware.js.map +1 -0
- package/dist/runtime/app-template.d.ts +10 -0
- package/dist/runtime/app-template.d.ts.map +1 -0
- package/dist/runtime/app-template.js +143 -0
- package/dist/runtime/app-template.js.map +1 -0
- package/dist/runtime/composables/index.d.ts +4 -0
- package/dist/runtime/composables/index.d.ts.map +1 -0
- package/dist/runtime/composables/index.js +3 -0
- package/dist/runtime/composables/index.js.map +1 -0
- package/dist/runtime/composables/use-head.d.ts +30 -0
- package/dist/runtime/composables/use-head.d.ts.map +1 -0
- package/dist/runtime/composables/use-head.js +182 -0
- package/dist/runtime/composables/use-head.js.map +1 -0
- package/dist/runtime/composables/use-page-data.d.ts +32 -0
- package/dist/runtime/composables/use-page-data.d.ts.map +1 -0
- package/dist/runtime/composables/use-page-data.js +41 -0
- package/dist/runtime/composables/use-page-data.js.map +1 -0
- package/dist/runtime/entry-client-template.d.ts +8 -0
- package/dist/runtime/entry-client-template.d.ts.map +1 -0
- package/dist/runtime/entry-client-template.js +18 -0
- package/dist/runtime/entry-client-template.js.map +1 -0
- package/dist/runtime/entry-server-template.d.ts +9 -0
- package/dist/runtime/entry-server-template.d.ts.map +1 -0
- package/dist/runtime/entry-server-template.js +72 -0
- package/dist/runtime/entry-server-template.js.map +1 -0
- package/dist/types/api.d.ts +16 -0
- package/dist/types/api.d.ts.map +1 -0
- package/dist/types/api.js +2 -0
- package/dist/types/api.js.map +1 -0
- package/dist/types/config.d.ts +32 -0
- package/dist/types/config.d.ts.map +1 -0
- package/dist/types/config.js +4 -0
- package/dist/types/config.js.map +1 -0
- package/dist/types/index.d.ts +7 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +2 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/middleware.d.ts +6 -0
- package/dist/types/middleware.d.ts.map +1 -0
- package/dist/types/middleware.js +2 -0
- package/dist/types/middleware.js.map +1 -0
- package/dist/types/page.d.ts +21 -0
- package/dist/types/page.d.ts.map +1 -0
- package/dist/types/page.js +2 -0
- package/dist/types/page.js.map +1 -0
- package/dist/types/plugin.d.ts +12 -0
- package/dist/types/plugin.d.ts.map +1 -0
- package/dist/types/plugin.js +2 -0
- package/dist/types/plugin.js.map +1 -0
- package/docs/cli.md +233 -0
- package/docs/components.md +114 -0
- package/docs/composables.md +99 -0
- package/docs/configuration.md +270 -0
- package/docs/data-loading.md +165 -0
- package/docs/getting-started.md +235 -0
- package/docs/head-management.md +206 -0
- package/docs/layouts.md +112 -0
- package/docs/middleware.md +140 -0
- package/docs/plugins.md +138 -0
- package/docs/rendering-modes.md +251 -0
- package/docs/routing.md +180 -0
- package/docs/server-api.md +172 -0
- package/docs/testing.md +462 -0
- package/package.json +75 -0
- package/src/__tests__/plugin/path-utils.test.ts +399 -0
- package/src/__tests__/plugin/scanner.test.ts +172 -0
- package/src/__tests__/plugin/transforms/auto-import.test.ts +229 -0
- package/src/__tests__/plugin/transforms/head-inject.test.ts +178 -0
- package/src/__tests__/plugin/virtual/components.test.ts +56 -0
- package/src/__tests__/plugin/virtual/composables.test.ts +57 -0
- package/src/__tests__/plugin/virtual/layouts.test.ts +70 -0
- package/src/__tests__/plugin/virtual/middleware.test.ts +68 -0
- package/src/__tests__/plugin/virtual/plugins.test.ts +84 -0
- package/src/__tests__/plugin/virtual/routes.test.ts +202 -0
- package/src/__tests__/plugin/virtual/server-api.test.ts +85 -0
- package/src/__tests__/runtime/use-head.test.ts +243 -0
- package/src/__tests__/runtime/use-page-data.test.ts +45 -0
- package/src/cli/commands/build.ts +114 -0
- package/src/cli/commands/dev.ts +101 -0
- package/src/cli/commands/generate.ts +81 -0
- package/src/cli/commands/preview.ts +218 -0
- package/src/cli/create/index.ts +250 -0
- package/src/cli/create/templates/spa/app/app.ts.tpl +74 -0
- package/src/cli/create/templates/spa/app/layouts/default.ts.tpl +15 -0
- package/src/cli/create/templates/spa/app/pages/index.ts.tpl +8 -0
- package/src/cli/create/templates/spa/cer.config.ts.tpl +6 -0
- package/src/cli/create/templates/spa/index.html.tpl +12 -0
- package/src/cli/create/templates/spa/package.json.tpl +18 -0
- package/src/cli/create/templates/ssg/app/app.ts.tpl +74 -0
- package/src/cli/create/templates/ssg/app/layouts/default.ts.tpl +15 -0
- package/src/cli/create/templates/ssg/app/pages/index.ts.tpl +17 -0
- package/src/cli/create/templates/ssg/cer.config.ts.tpl +13 -0
- package/src/cli/create/templates/ssg/index.html.tpl +12 -0
- package/src/cli/create/templates/ssg/package.json.tpl +19 -0
- package/src/cli/create/templates/ssr/app/app.ts.tpl +74 -0
- package/src/cli/create/templates/ssr/app/layouts/default.ts.tpl +15 -0
- package/src/cli/create/templates/ssr/app/pages/index.ts.tpl +8 -0
- package/src/cli/create/templates/ssr/cer.config.ts.tpl +10 -0
- package/src/cli/create/templates/ssr/index.html.tpl +12 -0
- package/src/cli/create/templates/ssr/package.json.tpl +18 -0
- package/src/cli/index.ts +20 -0
- package/src/index.ts +13 -0
- package/src/plugin/build-ssg.ts +259 -0
- package/src/plugin/build-ssr.ts +147 -0
- package/src/plugin/dev-server.ts +266 -0
- package/src/plugin/dts-generator.ts +214 -0
- package/src/plugin/index.ts +330 -0
- package/src/plugin/path-utils.ts +186 -0
- package/src/plugin/scanner.ts +65 -0
- package/src/plugin/transforms/auto-import.ts +190 -0
- package/src/plugin/transforms/head-inject.ts +161 -0
- package/src/plugin/virtual/components.ts +28 -0
- package/src/plugin/virtual/composables.ts +28 -0
- package/src/plugin/virtual/error.ts +34 -0
- package/src/plugin/virtual/layouts.ts +41 -0
- package/src/plugin/virtual/loading.ts +33 -0
- package/src/plugin/virtual/middleware.ts +45 -0
- package/src/plugin/virtual/plugins.ts +36 -0
- package/src/plugin/virtual/routes.ts +147 -0
- package/src/plugin/virtual/server-api.ts +52 -0
- package/src/plugin/virtual/server-middleware.ts +44 -0
- package/src/runtime/app-template.ts +142 -0
- package/src/runtime/composables/index.ts +3 -0
- package/src/runtime/composables/use-head.ts +204 -0
- package/src/runtime/composables/use-page-data.ts +39 -0
- package/src/runtime/entry-client-template.ts +17 -0
- package/src/runtime/entry-server-template.ts +71 -0
- package/src/types/api.ts +19 -0
- package/src/types/config.ts +39 -0
- package/src/types/index.ts +6 -0
- package/src/types/middleware.ts +16 -0
- package/src/types/page.ts +29 -0
- package/src/types/plugin.ts +13 -0
- package/tsconfig.build.json +10 -0
- package/tsconfig.json +19 -0
- package/vitest.config.ts +29 -0
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* create-cer-app scaffold CLI.
|
|
4
|
+
* Usage: create-cer-app [project-name] [--mode spa|ssr|ssg]
|
|
5
|
+
*/
|
|
6
|
+
import { Command } from 'commander';
|
|
7
|
+
import { resolve, join, dirname, basename } from 'pathe';
|
|
8
|
+
import { existsSync } from 'node:fs';
|
|
9
|
+
import { mkdir, readFile, writeFile, readdir, stat } from 'node:fs/promises';
|
|
10
|
+
import { createInterface } from 'node:readline';
|
|
11
|
+
import { fileURLToPath } from 'node:url';
|
|
12
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
13
|
+
const __dirname = dirname(__filename);
|
|
14
|
+
/**
|
|
15
|
+
* Prompts the user for input on stdin.
|
|
16
|
+
*/
|
|
17
|
+
function prompt(question, defaultValue) {
|
|
18
|
+
return new Promise((resolve) => {
|
|
19
|
+
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
20
|
+
const displayQuestion = defaultValue
|
|
21
|
+
? `${question} (${defaultValue}): `
|
|
22
|
+
: `${question}: `;
|
|
23
|
+
rl.question(displayQuestion, (answer) => {
|
|
24
|
+
rl.close();
|
|
25
|
+
resolve(answer.trim() || defaultValue || '');
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Prompts the user to choose a mode from a list.
|
|
31
|
+
*/
|
|
32
|
+
async function promptMode() {
|
|
33
|
+
console.log('Select app mode:');
|
|
34
|
+
console.log(' 1. spa — Single-Page App (client-side rendering)');
|
|
35
|
+
console.log(' 2. ssr — Server-Side Rendering');
|
|
36
|
+
console.log(' 3. ssg — Static Site Generation');
|
|
37
|
+
const answer = await prompt('Mode [1/2/3]', '1');
|
|
38
|
+
const modeMap = {
|
|
39
|
+
'1': 'spa',
|
|
40
|
+
'2': 'ssr',
|
|
41
|
+
'3': 'ssg',
|
|
42
|
+
spa: 'spa',
|
|
43
|
+
ssr: 'ssr',
|
|
44
|
+
ssg: 'ssg',
|
|
45
|
+
};
|
|
46
|
+
return modeMap[answer] ?? 'spa';
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Recursively reads all files from the template directory.
|
|
50
|
+
*/
|
|
51
|
+
async function readTemplateFiles(dir) {
|
|
52
|
+
const files = new Map();
|
|
53
|
+
async function walk(currentDir, prefix) {
|
|
54
|
+
const entries = await readdir(currentDir);
|
|
55
|
+
for (const entry of entries) {
|
|
56
|
+
const fullPath = join(currentDir, entry);
|
|
57
|
+
const relativePath = prefix ? `${prefix}/${entry}` : entry;
|
|
58
|
+
const info = await stat(fullPath);
|
|
59
|
+
if (info.isDirectory()) {
|
|
60
|
+
await walk(fullPath, relativePath);
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
const content = await readFile(fullPath, 'utf-8');
|
|
64
|
+
// Strip .tpl extension from key
|
|
65
|
+
const key = relativePath.endsWith('.tpl') ? relativePath.slice(0, -4) : relativePath;
|
|
66
|
+
files.set(key, content);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
await walk(dir, '');
|
|
71
|
+
return files;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Replaces template tokens in a content string.
|
|
75
|
+
*/
|
|
76
|
+
function applyTokens(content, tokens) {
|
|
77
|
+
let result = content;
|
|
78
|
+
for (const [key, value] of Object.entries(tokens)) {
|
|
79
|
+
result = result.replaceAll(`{{${key}}}`, value);
|
|
80
|
+
}
|
|
81
|
+
return result;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Writes template files to the target directory.
|
|
85
|
+
*/
|
|
86
|
+
async function writeTemplateFiles(files, targetDir, tokens) {
|
|
87
|
+
for (const [relativePath, rawContent] of files) {
|
|
88
|
+
const content = applyTokens(rawContent, tokens);
|
|
89
|
+
const outputPath = join(targetDir, relativePath);
|
|
90
|
+
await mkdir(dirname(outputPath), { recursive: true });
|
|
91
|
+
await writeFile(outputPath, content, 'utf-8');
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Returns the path to the template directory for the given mode.
|
|
96
|
+
* Resolves relative to the compiled dist output.
|
|
97
|
+
*/
|
|
98
|
+
function getTemplateDir(mode) {
|
|
99
|
+
// When running from compiled dist/, templates are in create/templates/
|
|
100
|
+
// This file is at dist/cli/create/index.js, so templates are at dist/cli/create/templates/
|
|
101
|
+
return join(__dirname, 'templates', mode);
|
|
102
|
+
}
|
|
103
|
+
async function main() {
|
|
104
|
+
const program = new Command();
|
|
105
|
+
program
|
|
106
|
+
.name('create-cer-app')
|
|
107
|
+
.description('Scaffold a new CER App project')
|
|
108
|
+
.argument('[project-name]', 'Name of the project to create')
|
|
109
|
+
.option('--mode <mode>', 'App mode: spa, ssr, or ssg')
|
|
110
|
+
.option('--dir <dir>', 'Directory to create the project in (defaults to project name)')
|
|
111
|
+
.action(async (projectNameArg, options) => {
|
|
112
|
+
console.log('\nWelcome to create-cer-app!\n');
|
|
113
|
+
// Gather inputs
|
|
114
|
+
const projectName = projectNameArg ?? (await prompt('Project name', 'my-cer-app'));
|
|
115
|
+
const mode = options?.mode ?? (await promptMode());
|
|
116
|
+
const targetDir = resolve(options?.dir ?? projectName);
|
|
117
|
+
console.log(`\nCreating ${mode.toUpperCase()} project: ${projectName}`);
|
|
118
|
+
console.log(` Directory: ${targetDir}\n`);
|
|
119
|
+
if (existsSync(targetDir)) {
|
|
120
|
+
const overwrite = await prompt(`Directory "${targetDir}" already exists. Overwrite? [y/N]`, 'N');
|
|
121
|
+
if (!overwrite.toLowerCase().startsWith('y')) {
|
|
122
|
+
console.log('Aborted.');
|
|
123
|
+
process.exit(0);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
// Load template files
|
|
127
|
+
const templateDir = getTemplateDir(mode);
|
|
128
|
+
if (!existsSync(templateDir)) {
|
|
129
|
+
// Fallback: generate minimal template inline
|
|
130
|
+
console.warn(`[create-cer-app] Template directory not found at ${templateDir}, using inline template.`);
|
|
131
|
+
await generateInlineTemplate(targetDir, projectName, mode);
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
const files = await readTemplateFiles(templateDir);
|
|
135
|
+
await writeTemplateFiles(files, targetDir, { projectName });
|
|
136
|
+
}
|
|
137
|
+
console.log(`\nProject created! To get started:\n`);
|
|
138
|
+
console.log(` cd ${basename(targetDir)}`);
|
|
139
|
+
console.log(` npm install`);
|
|
140
|
+
console.log(` npm run dev\n`);
|
|
141
|
+
});
|
|
142
|
+
await program.parseAsync(process.argv);
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Generates a minimal project structure inline when templates aren't available.
|
|
146
|
+
*/
|
|
147
|
+
async function generateInlineTemplate(targetDir, projectName, mode) {
|
|
148
|
+
await mkdir(join(targetDir, 'app/pages'), { recursive: true });
|
|
149
|
+
await mkdir(join(targetDir, 'app/layouts'), { recursive: true });
|
|
150
|
+
// package.json
|
|
151
|
+
await writeFile(join(targetDir, 'package.json'), JSON.stringify({
|
|
152
|
+
name: projectName,
|
|
153
|
+
version: '0.1.0',
|
|
154
|
+
type: 'module',
|
|
155
|
+
scripts: {
|
|
156
|
+
dev: 'cer-app dev',
|
|
157
|
+
build: 'cer-app build',
|
|
158
|
+
preview: 'cer-app preview',
|
|
159
|
+
},
|
|
160
|
+
dependencies: {
|
|
161
|
+
'@jasonshimmy/custom-elements-runtime': '^3.1.1',
|
|
162
|
+
},
|
|
163
|
+
devDependencies: {
|
|
164
|
+
vite: '^5.0.0',
|
|
165
|
+
'vite-plugin-cer-app': '^0.1.0',
|
|
166
|
+
typescript: '^5.4.0',
|
|
167
|
+
},
|
|
168
|
+
}, null, 2), 'utf-8');
|
|
169
|
+
// cer.config.ts
|
|
170
|
+
await writeFile(join(targetDir, 'cer.config.ts'), `import { defineConfig } from 'vite-plugin-cer-app'\n\nexport default defineConfig({\n mode: '${mode}',\n autoImports: { components: true, composables: true, directives: true, runtime: true },\n})\n`, 'utf-8');
|
|
171
|
+
// app/app.ts
|
|
172
|
+
await writeFile(join(targetDir, 'app/app.ts'), `import '@jasonshimmy/custom-elements-runtime/css'\nimport 'virtual:cer-components'\nimport routes from 'virtual:cer-routes'\nimport layouts from 'virtual:cer-layouts'\nimport plugins from 'virtual:cer-plugins'\nimport { hasLoading, loadingTag } from 'virtual:cer-loading'\nimport { hasError, errorTag } from 'virtual:cer-error'\nimport { component, ref, useOnConnected, useOnDisconnected, registerBuiltinComponents } from '@jasonshimmy/custom-elements-runtime'\nimport { initRouter } from '@jasonshimmy/custom-elements-runtime/router'\nimport { enableJITCSS } from '@jasonshimmy/custom-elements-runtime/jit-css'\nimport { createDOMJITCSS } from '@jasonshimmy/custom-elements-runtime/dom-jit-css'\n\nregisterBuiltinComponents()\nenableJITCSS()\n\nconst router = initRouter({ routes })\n\nconst isNavigating = ref(false)\nconst currentError = ref(null)\n;(globalThis as any).resetError = () => { currentError.value = null; router.replace(router.getCurrent().path) }\nconst _push = router.push.bind(router)\nconst _replace = router.replace.bind(router)\nrouter.push = async (path) => { isNavigating.value = true; currentError.value = null; try { await _push(path) } catch (err) { currentError.value = err instanceof Error ? err.message : String(err) } finally { isNavigating.value = false } }\nrouter.replace = async (path) => { isNavigating.value = true; currentError.value = null; try { await _replace(path) } catch (err) { currentError.value = err instanceof Error ? err.message : String(err) } finally { isNavigating.value = false } }\n\ncomponent('cer-layout-view', () => {\n const current = ref(router.getCurrent())\n let unsub: (() => void) | undefined\n useOnConnected(() => { unsub = router.subscribe((s: typeof current.value) => { current.value = s }) })\n useOnDisconnected(() => { unsub?.(); unsub = undefined })\n if (currentError.value !== null) {\n if (hasError && errorTag) return { tag: errorTag, props: { attrs: { error: String(currentError.value) } }, children: [] }\n return { tag: 'div', props: { attrs: { style: 'padding:2rem;font-family:monospace' } }, children: [String(currentError.value)] }\n }\n if (isNavigating.value && hasLoading && loadingTag) return { tag: loadingTag, props: {}, children: [] }\n const matched = router.matchRoute(current.value.path)\n const layoutName = (matched?.route as any)?.meta?.layout ?? 'default'\n const layoutTag = (layouts as Record<string, string>)[layoutName]\n const routerView = { tag: 'router-view', props: {}, children: [] }\n return layoutTag ? { tag: layoutTag, props: {}, children: [routerView] } : routerView\n})\n\nfor (const plugin of plugins ?? []) {\n if (plugin && typeof plugin.setup === 'function') {\n await plugin.setup({ router, provide: (key, value) => { (globalThis as any)[key] = value }, config: {} })\n }\n}\n\nif (typeof window !== 'undefined') {\n await router.replace(window.location.pathname + window.location.search + window.location.hash)\n createDOMJITCSS().mount()\n}\n\nexport { router }\n`, 'utf-8');
|
|
173
|
+
// app/pages/index.ts
|
|
174
|
+
await writeFile(join(targetDir, 'app/pages/index.ts'), `component('page-index', () => {\n return html\`\n <div>\n <h1>Welcome to ${projectName}</h1>\n <p>Edit <code>app/pages/index.ts</code> to get started.</p>\n </div>\n \`\n})\n`, 'utf-8');
|
|
175
|
+
// app/layouts/default.ts
|
|
176
|
+
await writeFile(join(targetDir, 'app/layouts/default.ts'), `component('layout-default', () => {\n return html\`\n <header><nav><router-link to="/">Home</router-link></nav></header>\n <main><slot></slot></main>\n <footer><p>Built with CER App</p></footer>\n \`\n})\n`, 'utf-8');
|
|
177
|
+
// index.html
|
|
178
|
+
await writeFile(join(targetDir, 'index.html'), `<!DOCTYPE html>\n<html lang="en">\n <head>\n <meta charset="UTF-8">\n <meta name="viewport" content="width=device-width, initial-scale=1.0">\n <title>${projectName}</title>\n </head>\n <body>\n <cer-layout-view></cer-layout-view>\n <script type="module" src="/app/app.ts"></script>\n </body>\n</html>\n`, 'utf-8');
|
|
179
|
+
}
|
|
180
|
+
main().catch((err) => {
|
|
181
|
+
console.error('[create-cer-app] Fatal error:', err);
|
|
182
|
+
process.exit(1);
|
|
183
|
+
});
|
|
184
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/cli/create/index.ts"],"names":[],"mappings":";AACA;;;GAGG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AACxD,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACpC,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;AAC5E,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAExC,MAAM,UAAU,GAAG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,SAAS,CACb,IAAI,CAAC,SAAS,EAAE,YAAY,CAAC,EAC7B,g8FAAg8F,EACh8F,OAAO,CACR,CAAA;IAED,qBAAqB;IACrB,MAAM,SAAS,CACb,IAAI,CAAC,SAAS,EAAE,oBAAoB,CAAC,EACrC,qFAAqF,WAAW,kGAAkG,EAClM,OAAO,CACR,CAAA;IAED,yBAAyB;IACzB,MAAM,SAAS,CACb,IAAI,CAAC,SAAS,EAAE,wBAAwB,CAAC,EACzC,0NAA0N,EAC1N,OAAO,CACR,CAAA;IAED,aAAa;IACb,MAAM,SAAS,CACb,IAAI,CAAC,SAAS,EAAE,YAAY,CAAC,EAC7B,mKAAmK,WAAW,qJAAqJ,EACnU,OAAO,CACR,CAAA;AACH,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IACnB,OAAO,CAAC,KAAK,CAAC,+BAA+B,EAAE,GAAG,CAAC,CAAA;IACnD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AACjB,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { Command } from 'commander';
|
|
3
|
+
import { devCommand } from './commands/dev.js';
|
|
4
|
+
import { buildCommand } from './commands/build.js';
|
|
5
|
+
import { previewCommand } from './commands/preview.js';
|
|
6
|
+
import { generateCommand } from './commands/generate.js';
|
|
7
|
+
const program = new Command();
|
|
8
|
+
program
|
|
9
|
+
.name('cer-app')
|
|
10
|
+
.description('Nuxt-style meta-framework CLI for @jasonshimmy/custom-elements-runtime')
|
|
11
|
+
.version('0.1.0');
|
|
12
|
+
program.addCommand(devCommand());
|
|
13
|
+
program.addCommand(buildCommand());
|
|
14
|
+
program.addCommand(previewCommand());
|
|
15
|
+
program.addCommand(generateCommand());
|
|
16
|
+
program.parse(process.argv);
|
|
17
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAExD,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAA;AAE7B,OAAO;KACJ,IAAI,CAAC,SAAS,CAAC;KACf,WAAW,CAAC,wEAAwE,CAAC;KACrF,OAAO,CAAC,OAAO,CAAC,CAAA;AAEnB,OAAO,CAAC,UAAU,CAAC,UAAU,EAAE,CAAC,CAAA;AAChC,OAAO,CAAC,UAAU,CAAC,YAAY,EAAE,CAAC,CAAA;AAClC,OAAO,CAAC,UAAU,CAAC,cAAc,EAAE,CAAC,CAAA;AACpC,OAAO,CAAC,UAAU,CAAC,eAAe,EAAE,CAAC,CAAA;AAErC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { cerApp } from './plugin/index.js';
|
|
2
|
+
export { defineConfig } from './types/config.js';
|
|
3
|
+
export type { CerAppConfig, SsgConfig, JitCssConfig, SsrConfig, AutoImportsConfig } from './types/config.js';
|
|
4
|
+
export type { HydrateStrategy, SsgPathsContext, PageSsgConfig, PageMeta, PageLoaderContext, PageLoader } from './types/page.js';
|
|
5
|
+
export type { ApiRequest, ApiResponse, ApiHandler, ApiContext } from './types/api.js';
|
|
6
|
+
export type { AppContext, AppPlugin } from './types/plugin.js';
|
|
7
|
+
export type { NextFunction, RouteMiddleware, ServerMiddleware } from './types/middleware.js';
|
|
8
|
+
export type { ResolvedCerConfig } from './plugin/dev-server.js';
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAGhD,YAAY,EAAE,YAAY,EAAE,SAAS,EAAE,YAAY,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;AAC5G,YAAY,EAAE,eAAe,EAAE,eAAe,EAAE,aAAa,EAAE,QAAQ,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC/H,YAAY,EAAE,UAAU,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AACrF,YAAY,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAC9D,YAAY,EAAE,YAAY,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AAG5F,YAAY,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,qBAAqB;AACrB,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type UserConfig } from 'vite';
|
|
2
|
+
import type { ResolvedCerConfig } from './dev-server.js';
|
|
3
|
+
/**
|
|
4
|
+
* Full SSG build pipeline:
|
|
5
|
+
* 1. Run the SSR dual-build (client + server bundles)
|
|
6
|
+
* 2. Enumerate all paths to generate
|
|
7
|
+
* 3. Render each path using the server bundle
|
|
8
|
+
* 4. Write HTML files to dist/
|
|
9
|
+
* 5. Write ssg-manifest.json
|
|
10
|
+
*/
|
|
11
|
+
export declare function buildSSG(config: ResolvedCerConfig, viteUserConfig?: UserConfig): Promise<void>;
|
|
12
|
+
//# sourceMappingURL=build-ssg.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-ssg.d.ts","sourceRoot":"","sources":["../../src/plugin/build-ssg.ts"],"names":[],"mappings":"AAGA,OAAO,EAAuB,KAAK,UAAU,EAAE,MAAM,MAAM,CAAA;AAC3D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AA+KxD;;;;;;;GAOG;AACH,wBAAsB,QAAQ,CAC5B,MAAM,EAAE,iBAAiB,EACzB,cAAc,GAAE,UAAe,GAC9B,OAAO,CAAC,IAAI,CAAC,CAoEf"}
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import { writeFile, mkdir, readFile } from 'node:fs/promises';
|
|
2
|
+
import { existsSync } from 'node:fs';
|
|
3
|
+
import { join } from 'pathe';
|
|
4
|
+
import { createServer } from 'vite';
|
|
5
|
+
import { buildSSR } from './build-ssr.js';
|
|
6
|
+
import { buildRouteEntry } from './path-utils.js';
|
|
7
|
+
import fg from 'fast-glob';
|
|
8
|
+
/**
|
|
9
|
+
* Collects all static paths to generate.
|
|
10
|
+
* For 'auto' mode: scans app/pages/ and collects only static (non-dynamic) routes
|
|
11
|
+
* plus any dynamic routes that provide ssg.paths().
|
|
12
|
+
* For explicit string[] mode: uses those paths directly.
|
|
13
|
+
*/
|
|
14
|
+
async function collectSsgPaths(config, viteUserConfig) {
|
|
15
|
+
const ssgConfig = config.ssg;
|
|
16
|
+
if (Array.isArray(ssgConfig.routes) && ssgConfig.routes.length > 0) {
|
|
17
|
+
return ssgConfig.routes;
|
|
18
|
+
}
|
|
19
|
+
// Auto-discover paths
|
|
20
|
+
const paths = ['/'];
|
|
21
|
+
if (!existsSync(config.pagesDir))
|
|
22
|
+
return paths;
|
|
23
|
+
const files = await fg('**/*.ts', {
|
|
24
|
+
cwd: config.pagesDir,
|
|
25
|
+
absolute: true,
|
|
26
|
+
onlyFiles: true,
|
|
27
|
+
});
|
|
28
|
+
const staticFiles = [];
|
|
29
|
+
const dynamicFiles = [];
|
|
30
|
+
for (const file of files) {
|
|
31
|
+
const entry = buildRouteEntry(file, config.pagesDir);
|
|
32
|
+
if (!entry.isDynamic && !entry.isCatchAll) {
|
|
33
|
+
staticFiles.push(file);
|
|
34
|
+
if (entry.routePath !== '/') {
|
|
35
|
+
paths.push(entry.routePath);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
else if (entry.isDynamic && !entry.isCatchAll) {
|
|
39
|
+
dynamicFiles.push({ file, entry });
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
if (dynamicFiles.length > 0) {
|
|
43
|
+
// Use a Vite SSR dev server to load page modules with auto-imports applied
|
|
44
|
+
const viteServer = await createServer({
|
|
45
|
+
...viteUserConfig,
|
|
46
|
+
root: config.root,
|
|
47
|
+
server: { middlewareMode: true },
|
|
48
|
+
appType: 'custom',
|
|
49
|
+
logLevel: 'silent',
|
|
50
|
+
});
|
|
51
|
+
try {
|
|
52
|
+
for (const { file, entry } of dynamicFiles) {
|
|
53
|
+
try {
|
|
54
|
+
const pageMod = await viteServer.ssrLoadModule(file);
|
|
55
|
+
const pageMeta = pageMod.meta ?? pageMod.pageMeta;
|
|
56
|
+
if (pageMeta?.ssg?.paths) {
|
|
57
|
+
const pathsResult = await pageMeta.ssg.paths();
|
|
58
|
+
for (const ctx of pathsResult) {
|
|
59
|
+
let resolvedPath = entry.routePath;
|
|
60
|
+
for (const [key, value] of Object.entries(ctx.params)) {
|
|
61
|
+
resolvedPath = resolvedPath.replace(`:${key}`, String(value));
|
|
62
|
+
}
|
|
63
|
+
paths.push(resolvedPath);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
catch {
|
|
68
|
+
console.warn(`[cer-app] Could not enumerate paths for ${file}`);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
finally {
|
|
73
|
+
await viteServer.close();
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return [...new Set(paths)]; // deduplicate
|
|
77
|
+
}
|
|
78
|
+
// Cache the server module across renderPath calls (loaded once per SSG run)
|
|
79
|
+
let _serverMod = null;
|
|
80
|
+
/**
|
|
81
|
+
* Renders a single path using the SSR server bundle and returns the HTML.
|
|
82
|
+
*
|
|
83
|
+
* The server bundle exports `handler` — an Express-style (req, res) middleware
|
|
84
|
+
* produced by createStreamingSSRHandler. We call it with a mock req/res that
|
|
85
|
+
* captures the final HTML string via res.end().
|
|
86
|
+
*/
|
|
87
|
+
async function renderPath(path, serverBundlePath, clientDistDir) {
|
|
88
|
+
// Load server bundle once
|
|
89
|
+
if (!_serverMod) {
|
|
90
|
+
try {
|
|
91
|
+
_serverMod = await import(serverBundlePath);
|
|
92
|
+
}
|
|
93
|
+
catch (err) {
|
|
94
|
+
throw new Error(`Failed to load server bundle at ${serverBundlePath}: ${err}`);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
const handlerFn = (typeof _serverMod['handler'] === 'function' ? _serverMod['handler'] : null) ??
|
|
98
|
+
(typeof _serverMod['default']?.['handler'] === 'function'
|
|
99
|
+
? _serverMod['default']['handler']
|
|
100
|
+
: null);
|
|
101
|
+
if (typeof handlerFn !== 'function') {
|
|
102
|
+
console.warn(`[cer-app] No handler function found in server bundle for path: ${path}`);
|
|
103
|
+
return '';
|
|
104
|
+
}
|
|
105
|
+
// Mock req/res for the Express-style handler
|
|
106
|
+
const mockReq = { url: path, headers: {} };
|
|
107
|
+
const html = await new Promise((resolve, reject) => {
|
|
108
|
+
const mockRes = {
|
|
109
|
+
setHeader: () => { },
|
|
110
|
+
// Intentionally omit write() so the handler uses the non-streaming code path
|
|
111
|
+
end: (body) => resolve(body),
|
|
112
|
+
};
|
|
113
|
+
handlerFn(mockReq, mockRes).catch(reject);
|
|
114
|
+
});
|
|
115
|
+
// Read the client index.html template and inject the server-rendered body
|
|
116
|
+
const templatePath = join(clientDistDir, 'index.html');
|
|
117
|
+
if (!existsSync(templatePath))
|
|
118
|
+
return html;
|
|
119
|
+
const template = await readFile(templatePath, 'utf-8');
|
|
120
|
+
// The handler already emits a full document; just return it as-is
|
|
121
|
+
// If it only emits a fragment we fall back to injecting into the template
|
|
122
|
+
if (html.trimStart().startsWith('<!DOCTYPE') || html.trimStart().startsWith('<html')) {
|
|
123
|
+
return html;
|
|
124
|
+
}
|
|
125
|
+
return template.replace('<div id="app"></div>', `<div id="app">${html}</div>`);
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Writes the rendered HTML to the output directory.
|
|
129
|
+
* path '/' -> dist/index.html
|
|
130
|
+
* path '/about' -> dist/about/index.html
|
|
131
|
+
*/
|
|
132
|
+
async function writeRenderedPath(path, html, distDir) {
|
|
133
|
+
let outputPath;
|
|
134
|
+
if (path === '/') {
|
|
135
|
+
outputPath = join(distDir, 'index.html');
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
// Normalize path and create directory
|
|
139
|
+
const cleanPath = path.replace(/^\//, '').replace(/\/$/, '');
|
|
140
|
+
outputPath = join(distDir, cleanPath, 'index.html');
|
|
141
|
+
}
|
|
142
|
+
await mkdir(join(outputPath, '..'), { recursive: true });
|
|
143
|
+
await writeFile(outputPath, html, 'utf-8');
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Full SSG build pipeline:
|
|
147
|
+
* 1. Run the SSR dual-build (client + server bundles)
|
|
148
|
+
* 2. Enumerate all paths to generate
|
|
149
|
+
* 3. Render each path using the server bundle
|
|
150
|
+
* 4. Write HTML files to dist/
|
|
151
|
+
* 5. Write ssg-manifest.json
|
|
152
|
+
*/
|
|
153
|
+
export async function buildSSG(config, viteUserConfig = {}) {
|
|
154
|
+
const distDir = join(config.root, 'dist');
|
|
155
|
+
const clientDistDir = join(distDir, 'client');
|
|
156
|
+
const serverDistDir = join(distDir, 'server');
|
|
157
|
+
const serverBundlePath = join(serverDistDir, 'server.js');
|
|
158
|
+
console.log('[cer-app] Starting SSG build...');
|
|
159
|
+
// Step 1: Run the SSR build to produce client + server bundles
|
|
160
|
+
await buildSSR(config, viteUserConfig);
|
|
161
|
+
// Step 2: Collect paths to generate
|
|
162
|
+
console.log('[cer-app] Collecting SSG paths...');
|
|
163
|
+
const paths = await collectSsgPaths(config, viteUserConfig);
|
|
164
|
+
console.log(`[cer-app] Found ${paths.length} path(s) to generate:`, paths);
|
|
165
|
+
// Step 3+4: Render and write paths with bounded concurrency.
|
|
166
|
+
// The server bundle uses per-request router instances (initRouter returns the
|
|
167
|
+
// router; the factory passes it to createStreamingSSRHandler as { vnode, router })
|
|
168
|
+
// so concurrent renders are safe — each request carries its own router with its
|
|
169
|
+
// own URL state and never reads from the shared activeRouterProxy singleton.
|
|
170
|
+
const concurrency = config.ssg?.concurrency ?? 4;
|
|
171
|
+
console.log(`[cer-app] Rendering ${paths.length} path(s) with concurrency ${concurrency}...`);
|
|
172
|
+
const generatedPaths = [];
|
|
173
|
+
const errors = [];
|
|
174
|
+
// Process paths in chunks of `concurrency` so we don't overwhelm the process
|
|
175
|
+
// with hundreds of simultaneous renders on very large sites.
|
|
176
|
+
for (let i = 0; i < paths.length; i += concurrency) {
|
|
177
|
+
const chunk = paths.slice(i, i + concurrency);
|
|
178
|
+
const results = await Promise.allSettled(chunk.map(async (path) => {
|
|
179
|
+
console.log(`[cer-app] Generating: ${path}`);
|
|
180
|
+
const html = await renderPath(path, serverBundlePath, clientDistDir);
|
|
181
|
+
await writeRenderedPath(path, html, distDir);
|
|
182
|
+
return path;
|
|
183
|
+
}));
|
|
184
|
+
for (let j = 0; j < results.length; j++) {
|
|
185
|
+
const result = results[j];
|
|
186
|
+
if (result.status === 'fulfilled') {
|
|
187
|
+
generatedPaths.push(result.value);
|
|
188
|
+
}
|
|
189
|
+
else {
|
|
190
|
+
const errorMsg = String(result.reason);
|
|
191
|
+
console.error(`[cer-app] Failed to generate ${chunk[j]}: ${errorMsg}`);
|
|
192
|
+
errors.push({ path: chunk[j], error: errorMsg });
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
// Step 5: Write SSG manifest
|
|
197
|
+
const manifest = {
|
|
198
|
+
generatedAt: new Date().toISOString(),
|
|
199
|
+
paths: generatedPaths,
|
|
200
|
+
errors,
|
|
201
|
+
};
|
|
202
|
+
const manifestPath = join(distDir, 'ssg-manifest.json');
|
|
203
|
+
await mkdir(distDir, { recursive: true });
|
|
204
|
+
await writeFile(manifestPath, JSON.stringify(manifest, null, 2), 'utf-8');
|
|
205
|
+
console.log(`[cer-app] SSG build complete.`);
|
|
206
|
+
console.log(` Generated ${generatedPaths.length} page(s).`);
|
|
207
|
+
if (errors.length > 0) {
|
|
208
|
+
console.warn(` ${errors.length} error(s) — see ${manifestPath} for details.`);
|
|
209
|
+
}
|
|
210
|
+
console.log(` Manifest: ${manifestPath}`);
|
|
211
|
+
}
|
|
212
|
+
//# sourceMappingURL=build-ssg.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-ssg.js","sourceRoot":"","sources":["../../src/plugin/build-ssg.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACpC,OAAO,EAAE,IAAI,EAAE,MAAM,OAAO,CAAA;AAC5B,OAAO,EAAE,YAAY,EAA0B,MAAM,MAAM,CAAA;AAE3D,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AACzC,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CA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6BAA6B;IAC7B,MAAM,QAAQ,GAAgB;QAC5B,WAAW,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;QACrC,KAAK,EAAE,cAAc;QACrB,MAAM;KACP,CAAA;IAED,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,EAAE,mBAAmB,CAAC,CAAA;IACvD,MAAM,KAAK,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;IACzC,MAAM,SAAS,CAAC,YAAY,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,OAAO,CAAC,CAAA;IAEzE,OAAO,CAAC,GAAG,CAAC,+BAA+B,CAAC,CAAA;IAC5C,OAAO,CAAC,GAAG,CAAC,eAAe,cAAc,CAAC,MAAM,WAAW,CAAC,CAAA;IAC5D,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACtB,OAAO,CAAC,IAAI,CAAC,KAAK,MAAM,CAAC,MAAM,mBAAmB,YAAY,eAAe,CAAC,CAAA;IAChF,CAAC;IACD,OAAO,CAAC,GAAG,CAAC,eAAe,YAAY,EAAE,CAAC,CAAA;AAC5C,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type UserConfig } from 'vite';
|
|
2
|
+
import type { ResolvedCerConfig } from './dev-server.js';
|
|
3
|
+
/**
|
|
4
|
+
* Runs the dual (client + server) SSR build using Vite's programmatic API.
|
|
5
|
+
*
|
|
6
|
+
* 1. Client bundle: normal Vite build (outputs to dist/client)
|
|
7
|
+
* 2. Server bundle: SSR build (outputs to dist/server), uses a generated entry
|
|
8
|
+
*/
|
|
9
|
+
export declare function buildSSR(config: ResolvedCerConfig, viteUserConfig?: UserConfig): Promise<void>;
|
|
10
|
+
//# sourceMappingURL=build-ssr.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-ssr.d.ts","sourceRoot":"","sources":["../../src/plugin/build-ssr.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,KAAK,UAAU,EAAE,MAAM,MAAM,CAAA;AAG7C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AAoExD;;;;;GAKG;AACH,wBAAsB,QAAQ,CAC5B,MAAM,EAAE,iBAAiB,EACzB,cAAc,GAAE,UAAe,GAC9B,OAAO,CAAC,IAAI,CAAC,CAkEf"}
|