@raystack/chronicle 0.1.0-canary.729744c → 0.1.0-canary.847a058
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/index.js +205 -530
- package/package.json +13 -9
- package/src/cli/commands/build.ts +30 -63
- package/src/cli/commands/dev.ts +24 -13
- package/src/cli/commands/init.ts +38 -123
- package/src/cli/commands/serve.ts +35 -50
- package/src/cli/commands/start.ts +20 -16
- package/src/cli/index.ts +14 -14
- package/src/cli/utils/config.ts +25 -26
- package/src/cli/utils/index.ts +3 -2
- package/src/cli/utils/resolve.ts +7 -3
- package/src/cli/utils/scaffold.ts +14 -16
- package/src/components/mdx/code.tsx +1 -10
- package/src/components/mdx/details.module.css +24 -1
- package/src/components/mdx/details.tsx +3 -2
- package/src/components/mdx/image.tsx +5 -20
- package/src/components/mdx/index.tsx +3 -3
- package/src/components/mdx/link.tsx +24 -20
- package/src/components/ui/breadcrumbs.tsx +8 -42
- package/src/components/ui/footer.tsx +2 -3
- package/src/components/ui/search.tsx +116 -71
- package/src/lib/api-routes.ts +6 -8
- package/src/lib/config.ts +31 -29
- package/src/lib/get-llm-text.ts +10 -0
- package/src/lib/head.tsx +26 -22
- package/src/lib/openapi.ts +8 -8
- package/src/lib/page-context.tsx +80 -58
- package/src/lib/source.ts +123 -116
- package/src/pages/ApiLayout.tsx +22 -18
- package/src/pages/ApiPage.tsx +32 -27
- package/src/pages/DocsLayout.tsx +7 -7
- package/src/pages/DocsPage.tsx +11 -11
- package/src/pages/NotFound.tsx +11 -4
- package/src/server/App.tsx +35 -27
- package/src/server/api/apis-proxy.ts +69 -0
- package/src/server/api/health.ts +5 -0
- package/src/server/api/page/[...slug].ts +26 -0
- package/src/server/api/search.ts +170 -0
- package/src/server/api/specs.ts +9 -0
- package/src/server/build-search-index.ts +117 -0
- package/src/server/entry-client.tsx +60 -58
- package/src/server/entry-server.tsx +104 -35
- package/src/server/routes/llms.txt.ts +61 -0
- package/src/server/routes/og.tsx +75 -0
- package/src/server/routes/robots.txt.ts +11 -0
- package/src/server/routes/sitemap.xml.ts +40 -0
- package/src/server/utils/safe-path.ts +17 -0
- package/src/server/vite-config.ts +80 -49
- package/src/themes/default/Layout.tsx +78 -47
- package/src/themes/default/Page.module.css +0 -55
- package/src/themes/default/Page.tsx +9 -11
- package/src/themes/default/Toc.tsx +25 -39
- package/src/themes/default/index.ts +7 -9
- package/src/themes/paper/ChapterNav.tsx +63 -43
- package/src/themes/paper/Layout.module.css +1 -1
- package/src/themes/paper/Layout.tsx +24 -12
- package/src/themes/paper/Page.module.css +16 -4
- package/src/themes/paper/Page.tsx +56 -62
- package/src/themes/paper/ReadingProgress.tsx +160 -139
- package/src/themes/paper/index.ts +5 -5
- package/src/themes/registry.ts +7 -7
- package/src/types/content.ts +5 -21
- package/src/types/globals.d.ts +4 -0
- package/src/types/theme.ts +4 -3
- package/src/cli/__tests__/config.test.ts +0 -25
- package/src/cli/__tests__/scaffold.test.ts +0 -10
- package/src/pages/__tests__/head.test.tsx +0 -57
- package/src/server/__tests__/entry-server.test.tsx +0 -35
- package/src/server/__tests__/handlers.test.ts +0 -77
- package/src/server/__tests__/og.test.ts +0 -23
- package/src/server/__tests__/router.test.ts +0 -72
- package/src/server/__tests__/vite-config.test.ts +0 -25
- package/src/server/adapters/vercel.ts +0 -133
- package/src/server/dev.ts +0 -156
- package/src/server/entry-prod.ts +0 -97
- package/src/server/entry-vercel.ts +0 -26
- package/src/server/handlers/apis-proxy.ts +0 -52
- package/src/server/handlers/health.ts +0 -3
- package/src/server/handlers/llms.ts +0 -58
- package/src/server/handlers/og.ts +0 -87
- package/src/server/handlers/robots.ts +0 -11
- package/src/server/handlers/search.ts +0 -140
- package/src/server/handlers/sitemap.ts +0 -39
- package/src/server/handlers/specs.ts +0 -9
- package/src/server/index.html +0 -12
- package/src/server/prod.ts +0 -18
- package/src/server/request-handler.ts +0 -63
- package/src/server/router.ts +0 -42
- package/src/themes/default/font.ts +0 -4
package/dist/cli/index.js
CHANGED
|
@@ -16,55 +16,105 @@ var __export = (target, all) => {
|
|
|
16
16
|
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
17
17
|
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
18
18
|
|
|
19
|
+
// src/lib/remark-unused-directives.ts
|
|
20
|
+
import { visit } from "unist-util-visit";
|
|
21
|
+
var remarkUnusedDirectives = () => {
|
|
22
|
+
return (tree) => {
|
|
23
|
+
visit(tree, ["textDirective"], (node) => {
|
|
24
|
+
const directive = node;
|
|
25
|
+
if (!directive.data) {
|
|
26
|
+
const hasAttributes = directive.attributes && Object.keys(directive.attributes).length > 0;
|
|
27
|
+
const hasChildren = directive.children && directive.children.length > 0;
|
|
28
|
+
if (!hasAttributes && !hasChildren) {
|
|
29
|
+
const name = directive.name;
|
|
30
|
+
if (!name)
|
|
31
|
+
return;
|
|
32
|
+
Object.keys(directive).forEach((key) => delete directive[key]);
|
|
33
|
+
directive.type = "text";
|
|
34
|
+
directive.value = `:${name}`;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
}, remark_unused_directives_default;
|
|
40
|
+
var init_remark_unused_directives = __esm(() => {
|
|
41
|
+
remark_unused_directives_default = remarkUnusedDirectives;
|
|
42
|
+
});
|
|
43
|
+
|
|
19
44
|
// src/server/vite-config.ts
|
|
20
45
|
var exports_vite_config = {};
|
|
21
46
|
__export(exports_vite_config, {
|
|
22
47
|
createViteConfig: () => createViteConfig
|
|
23
48
|
});
|
|
24
|
-
import path5 from "path";
|
|
25
49
|
import react from "@vitejs/plugin-react";
|
|
26
|
-
import
|
|
50
|
+
import { remarkDirectiveAdmonition, remarkMdxMermaid } from "fumadocs-core/mdx-plugins";
|
|
51
|
+
import { defineConfig as defineFumadocsConfig } from "fumadocs-mdx/config";
|
|
52
|
+
import mdx from "fumadocs-mdx/vite";
|
|
53
|
+
import { nitro } from "nitro/vite";
|
|
54
|
+
import path4 from "node:path";
|
|
27
55
|
import remarkDirective from "remark-directive";
|
|
28
|
-
import remarkGfm from "remark-gfm";
|
|
29
|
-
import remarkFrontmatter from "remark-frontmatter";
|
|
30
|
-
import remarkMdxFrontmatter from "remark-mdx-frontmatter";
|
|
31
|
-
import rehypeShiki from "@shikijs/rehype";
|
|
32
56
|
async function createViteConfig(options) {
|
|
33
|
-
const {
|
|
57
|
+
const { packageRoot, projectRoot, contentDir, preset } = options;
|
|
34
58
|
return {
|
|
35
|
-
root,
|
|
59
|
+
root: packageRoot,
|
|
36
60
|
configFile: false,
|
|
61
|
+
plugins: [
|
|
62
|
+
nitro({
|
|
63
|
+
serverDir: path4.resolve(packageRoot, "src/server"),
|
|
64
|
+
...preset && { preset }
|
|
65
|
+
}),
|
|
66
|
+
mdx({
|
|
67
|
+
default: defineFumadocsConfig({
|
|
68
|
+
mdxOptions: {
|
|
69
|
+
remarkPlugins: [
|
|
70
|
+
remarkDirective,
|
|
71
|
+
[remarkDirectiveAdmonition, {
|
|
72
|
+
tags: {
|
|
73
|
+
CalloutContainer: "Callout",
|
|
74
|
+
CalloutTitle: "CalloutTitle",
|
|
75
|
+
CalloutDescription: "CalloutDescription"
|
|
76
|
+
},
|
|
77
|
+
types: {
|
|
78
|
+
note: "accent",
|
|
79
|
+
tip: "accent",
|
|
80
|
+
info: "accent",
|
|
81
|
+
warn: "attention",
|
|
82
|
+
warning: "attention",
|
|
83
|
+
danger: "alert",
|
|
84
|
+
caution: "alert",
|
|
85
|
+
success: "success"
|
|
86
|
+
}
|
|
87
|
+
}],
|
|
88
|
+
remark_unused_directives_default,
|
|
89
|
+
remarkMdxMermaid
|
|
90
|
+
]
|
|
91
|
+
}
|
|
92
|
+
})
|
|
93
|
+
}, { index: false }),
|
|
94
|
+
react()
|
|
95
|
+
],
|
|
37
96
|
resolve: {
|
|
38
97
|
alias: {
|
|
39
|
-
"@":
|
|
40
|
-
"@content": contentDir
|
|
98
|
+
"@": path4.resolve(packageRoot, "src")
|
|
41
99
|
},
|
|
42
|
-
|
|
100
|
+
conditions: ["module-sync", "import", "node"],
|
|
101
|
+
dedupe: [
|
|
102
|
+
"react",
|
|
103
|
+
"react-dom",
|
|
104
|
+
"react/jsx-runtime",
|
|
105
|
+
"react/jsx-dev-runtime",
|
|
106
|
+
"react-router"
|
|
107
|
+
]
|
|
43
108
|
},
|
|
44
109
|
server: {
|
|
45
110
|
fs: {
|
|
46
|
-
allow: [
|
|
111
|
+
allow: [packageRoot, projectRoot, contentDir]
|
|
47
112
|
}
|
|
48
113
|
},
|
|
49
|
-
plugins: [
|
|
50
|
-
mdx({
|
|
51
|
-
remarkPlugins: [
|
|
52
|
-
remarkFrontmatter,
|
|
53
|
-
remarkMdxFrontmatter,
|
|
54
|
-
remarkGfm,
|
|
55
|
-
remarkDirective
|
|
56
|
-
],
|
|
57
|
-
rehypePlugins: [
|
|
58
|
-
[rehypeShiki, { themes: { light: "github-light", dark: "github-dark" }, defaultColor: false }]
|
|
59
|
-
],
|
|
60
|
-
mdExtensions: [".md"],
|
|
61
|
-
mdxExtensions: [".mdx"]
|
|
62
|
-
}),
|
|
63
|
-
react()
|
|
64
|
-
],
|
|
65
114
|
define: {
|
|
66
|
-
|
|
67
|
-
|
|
115
|
+
__CHRONICLE_CONTENT_DIR__: JSON.stringify(contentDir),
|
|
116
|
+
__CHRONICLE_PROJECT_ROOT__: JSON.stringify(projectRoot),
|
|
117
|
+
__CHRONICLE_PACKAGE_ROOT__: JSON.stringify(packageRoot)
|
|
68
118
|
},
|
|
69
119
|
css: {
|
|
70
120
|
modules: {
|
|
@@ -72,348 +122,109 @@ async function createViteConfig(options) {
|
|
|
72
122
|
}
|
|
73
123
|
},
|
|
74
124
|
ssr: {
|
|
75
|
-
noExternal: ["@raystack/apsara"]
|
|
125
|
+
noExternal: ["@raystack/apsara", "dayjs", "fumadocs-core"]
|
|
76
126
|
},
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
var init_vite_config = () => {};
|
|
87
|
-
|
|
88
|
-
// src/server/dev.ts
|
|
89
|
-
var exports_dev = {};
|
|
90
|
-
__export(exports_dev, {
|
|
91
|
-
startDevServer: () => startDevServer
|
|
92
|
-
});
|
|
93
|
-
import { createServer as createViteServer } from "vite";
|
|
94
|
-
import { createServer } from "http";
|
|
95
|
-
import fsPromises from "fs/promises";
|
|
96
|
-
import { createReadStream } from "fs";
|
|
97
|
-
import path6 from "path";
|
|
98
|
-
import chalk3 from "chalk";
|
|
99
|
-
async function startDevServer(options) {
|
|
100
|
-
const { port, root, contentDir } = options;
|
|
101
|
-
const viteConfig = await createViteConfig({ root, contentDir, isDev: true });
|
|
102
|
-
const vite = await createViteServer({
|
|
103
|
-
...viteConfig,
|
|
104
|
-
server: { middlewareMode: true },
|
|
105
|
-
appType: "custom"
|
|
106
|
-
});
|
|
107
|
-
const templatePath = path6.resolve(root, "src/server/index.html");
|
|
108
|
-
const server = createServer(async (req, res) => {
|
|
109
|
-
const url = req.url || "/";
|
|
110
|
-
try {
|
|
111
|
-
if (url.startsWith("/@") || url.startsWith("/__vite") || url.startsWith("/node_modules/")) {
|
|
112
|
-
vite.middlewares(req, res, () => {
|
|
113
|
-
res.statusCode = 404;
|
|
114
|
-
res.end();
|
|
115
|
-
});
|
|
116
|
-
return;
|
|
117
|
-
}
|
|
118
|
-
const contentFile = path6.join(contentDir, decodeURIComponent(url.split("?")[0]));
|
|
119
|
-
if (!url.endsWith(".md") && !url.endsWith(".mdx")) {
|
|
120
|
-
try {
|
|
121
|
-
const stat = await fsPromises.stat(contentFile);
|
|
122
|
-
if (stat.isFile()) {
|
|
123
|
-
const ext = path6.extname(contentFile).toLowerCase();
|
|
124
|
-
const mimeTypes = {
|
|
125
|
-
".png": "image/png",
|
|
126
|
-
".jpg": "image/jpeg",
|
|
127
|
-
".jpeg": "image/jpeg",
|
|
128
|
-
".gif": "image/gif",
|
|
129
|
-
".svg": "image/svg+xml",
|
|
130
|
-
".webp": "image/webp",
|
|
131
|
-
".ico": "image/x-icon",
|
|
132
|
-
".pdf": "application/pdf",
|
|
133
|
-
".json": "application/json",
|
|
134
|
-
".yaml": "text/yaml",
|
|
135
|
-
".yml": "text/yaml",
|
|
136
|
-
".txt": "text/plain"
|
|
137
|
-
};
|
|
138
|
-
res.setHeader("Content-Type", mimeTypes[ext] || "application/octet-stream");
|
|
139
|
-
createReadStream(contentFile).pipe(res);
|
|
140
|
-
return;
|
|
127
|
+
environments: {
|
|
128
|
+
client: {
|
|
129
|
+
build: {
|
|
130
|
+
rollupOptions: {
|
|
131
|
+
input: path4.resolve(packageRoot, "src/server/entry-client.tsx")
|
|
141
132
|
}
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
if (/\.(js|ts|tsx|css|map)(\?|$)/.test(url)) {
|
|
145
|
-
vite.middlewares(req, res, () => {
|
|
146
|
-
res.statusCode = 404;
|
|
147
|
-
res.end();
|
|
148
|
-
});
|
|
149
|
-
return;
|
|
150
|
-
}
|
|
151
|
-
const { matchRoute } = await vite.ssrLoadModule(path6.resolve(root, "src/server/router.ts"));
|
|
152
|
-
const routeHandler = matchRoute(new URL(url, `http://localhost:${port}`).href);
|
|
153
|
-
if (routeHandler) {
|
|
154
|
-
const request = new Request(new URL(url, `http://localhost:${port}`));
|
|
155
|
-
const response = await routeHandler(request);
|
|
156
|
-
res.statusCode = response.status;
|
|
157
|
-
response.headers.forEach((value, key) => res.setHeader(key, value));
|
|
158
|
-
const body = await response.text();
|
|
159
|
-
res.end(body);
|
|
160
|
-
return;
|
|
161
|
-
}
|
|
162
|
-
const pathname = new URL(url, `http://localhost:${port}`).pathname;
|
|
163
|
-
const slug = pathname === "/" ? [] : pathname.slice(1).split("/").filter(Boolean);
|
|
164
|
-
const source = await vite.ssrLoadModule(path6.resolve(root, "src/lib/source.ts"));
|
|
165
|
-
const { mdxComponents } = await vite.ssrLoadModule(path6.resolve(root, "src/components/mdx/index.tsx"));
|
|
166
|
-
const { loadConfig } = await vite.ssrLoadModule(path6.resolve(root, "src/lib/config.ts"));
|
|
167
|
-
const config = loadConfig();
|
|
168
|
-
const { loadApiSpecs } = await vite.ssrLoadModule(path6.resolve(root, "src/lib/openapi.ts"));
|
|
169
|
-
const apiSpecs = config.api?.length ? loadApiSpecs(config.api) : [];
|
|
170
|
-
const [tree, sourcePage] = await Promise.all([
|
|
171
|
-
source.buildPageTree(),
|
|
172
|
-
source.getPage(slug)
|
|
173
|
-
]);
|
|
174
|
-
let pageData = null;
|
|
175
|
-
let embeddedData = { config, tree, slug, frontmatter: null, filePath: null };
|
|
176
|
-
if (sourcePage) {
|
|
177
|
-
const component = await source.loadPageComponent(sourcePage);
|
|
178
|
-
const React = await import("react");
|
|
179
|
-
const MDXBody = component;
|
|
180
|
-
pageData = {
|
|
181
|
-
slug,
|
|
182
|
-
frontmatter: sourcePage.frontmatter,
|
|
183
|
-
content: MDXBody ? React.createElement(MDXBody, { components: mdxComponents }) : null
|
|
184
|
-
};
|
|
185
|
-
embeddedData.frontmatter = sourcePage.frontmatter;
|
|
186
|
-
embeddedData.filePath = sourcePage.filePath;
|
|
133
|
+
}
|
|
187
134
|
}
|
|
188
|
-
let template = await fsPromises.readFile(templatePath, "utf-8");
|
|
189
|
-
template = await vite.transformIndexHtml(url, template);
|
|
190
|
-
const dataScript = `<script>window.__PAGE_DATA__ = ${JSON.stringify(embeddedData)}</script>`;
|
|
191
|
-
template = template.replace("<!--head-outlet-->", `<!--head-outlet-->${dataScript}`);
|
|
192
|
-
const { render } = await vite.ssrLoadModule(path6.resolve(root, "src/server/entry-server.tsx"));
|
|
193
|
-
const html = render(url, { config, tree, page: pageData, apiSpecs });
|
|
194
|
-
const finalHtml = template.replace("<!--ssr-outlet-->", html);
|
|
195
|
-
res.setHeader("Content-Type", "text/html");
|
|
196
|
-
res.statusCode = 200;
|
|
197
|
-
res.end(finalHtml);
|
|
198
|
-
} catch (e) {
|
|
199
|
-
vite.ssrFixStacktrace(e);
|
|
200
|
-
console.error(e);
|
|
201
|
-
res.statusCode = 500;
|
|
202
|
-
res.end(e.message);
|
|
203
135
|
}
|
|
204
|
-
});
|
|
205
|
-
server.listen(port, () => {
|
|
206
|
-
console.log(chalk3.cyan(`
|
|
207
|
-
Chronicle dev server running at:`));
|
|
208
|
-
console.log(chalk3.green(` http://localhost:${port}
|
|
209
|
-
`));
|
|
210
|
-
});
|
|
211
|
-
const shutdown = () => {
|
|
212
|
-
vite.close();
|
|
213
|
-
server.close();
|
|
214
|
-
process.exit(0);
|
|
215
136
|
};
|
|
216
|
-
process.on("SIGINT", shutdown);
|
|
217
|
-
process.on("SIGTERM", shutdown);
|
|
218
|
-
return { server, vite };
|
|
219
137
|
}
|
|
220
|
-
var
|
|
221
|
-
|
|
138
|
+
var init_vite_config = __esm(() => {
|
|
139
|
+
init_remark_unused_directives();
|
|
222
140
|
});
|
|
223
141
|
|
|
224
|
-
// src/server/adapters/vercel.ts
|
|
225
|
-
var exports_vercel = {};
|
|
226
|
-
__export(exports_vercel, {
|
|
227
|
-
buildVercelOutput: () => buildVercelOutput
|
|
228
|
-
});
|
|
229
|
-
import path7 from "path";
|
|
230
|
-
import fs3 from "fs/promises";
|
|
231
|
-
import { existsSync } from "fs";
|
|
232
|
-
import chalk5 from "chalk";
|
|
233
|
-
async function buildVercelOutput(options) {
|
|
234
|
-
const { distDir, contentDir, projectRoot } = options;
|
|
235
|
-
const outputDir = path7.resolve(projectRoot, ".vercel/output");
|
|
236
|
-
console.log(chalk5.gray("Generating Vercel output..."));
|
|
237
|
-
await fs3.rm(outputDir, { recursive: true, force: true });
|
|
238
|
-
const staticDir = path7.resolve(outputDir, "static");
|
|
239
|
-
const funcDir = path7.resolve(outputDir, "functions/index.func");
|
|
240
|
-
await fs3.mkdir(staticDir, { recursive: true });
|
|
241
|
-
await fs3.mkdir(funcDir, { recursive: true });
|
|
242
|
-
const clientDir = path7.resolve(distDir, "client");
|
|
243
|
-
await copyDir(clientDir, staticDir);
|
|
244
|
-
console.log(chalk5.gray(" Copied client assets to static/"));
|
|
245
|
-
if (existsSync(contentDir)) {
|
|
246
|
-
await copyContentAssets(contentDir, staticDir);
|
|
247
|
-
console.log(chalk5.gray(" Copied content assets to static/"));
|
|
248
|
-
}
|
|
249
|
-
const serverDir = path7.resolve(distDir, "server");
|
|
250
|
-
await copyDir(serverDir, funcDir);
|
|
251
|
-
console.log(chalk5.gray(" Copied server bundle to functions/"));
|
|
252
|
-
const templateSrc = path7.resolve(clientDir, "src/server/index.html");
|
|
253
|
-
await fs3.copyFile(templateSrc, path7.resolve(funcDir, "index.html"));
|
|
254
|
-
await fs3.writeFile(path7.resolve(funcDir, "package.json"), JSON.stringify({ type: "module" }, null, 2));
|
|
255
|
-
await fs3.writeFile(path7.resolve(funcDir, ".vc-config.json"), JSON.stringify({
|
|
256
|
-
runtime: "nodejs24.x",
|
|
257
|
-
handler: "entry-vercel.js",
|
|
258
|
-
launcherType: "Nodejs"
|
|
259
|
-
}, null, 2));
|
|
260
|
-
await fs3.writeFile(path7.resolve(outputDir, "config.json"), JSON.stringify({
|
|
261
|
-
version: 3,
|
|
262
|
-
routes: [
|
|
263
|
-
{ handle: "filesystem" },
|
|
264
|
-
{ src: "/(.*)", dest: "/index" }
|
|
265
|
-
]
|
|
266
|
-
}, null, 2));
|
|
267
|
-
console.log(chalk5.green("Vercel output generated →"), outputDir);
|
|
268
|
-
}
|
|
269
|
-
async function copyDir(src, dest) {
|
|
270
|
-
await fs3.mkdir(dest, { recursive: true });
|
|
271
|
-
const entries = await fs3.readdir(src, { withFileTypes: true });
|
|
272
|
-
for (const entry of entries) {
|
|
273
|
-
const srcPath = path7.join(src, entry.name);
|
|
274
|
-
const destPath = path7.join(dest, entry.name);
|
|
275
|
-
if (entry.isDirectory()) {
|
|
276
|
-
await copyDir(srcPath, destPath);
|
|
277
|
-
} else {
|
|
278
|
-
await fs3.copyFile(srcPath, destPath);
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
async function copyContentAssets(contentDir, staticDir) {
|
|
283
|
-
const entries = await fs3.readdir(contentDir, { withFileTypes: true });
|
|
284
|
-
for (const entry of entries) {
|
|
285
|
-
const srcPath = path7.join(contentDir, entry.name);
|
|
286
|
-
if (entry.isDirectory()) {
|
|
287
|
-
const destSubDir = path7.join(staticDir, entry.name);
|
|
288
|
-
await copyContentAssetsRecursive(srcPath, destSubDir);
|
|
289
|
-
} else {
|
|
290
|
-
const ext = path7.extname(entry.name).toLowerCase();
|
|
291
|
-
if (CONTENT_EXTENSIONS.has(ext)) {
|
|
292
|
-
await fs3.copyFile(srcPath, path7.join(staticDir, entry.name));
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
async function copyContentAssetsRecursive(srcDir, destDir) {
|
|
298
|
-
const entries = await fs3.readdir(srcDir, { withFileTypes: true });
|
|
299
|
-
for (const entry of entries) {
|
|
300
|
-
const srcPath = path7.join(srcDir, entry.name);
|
|
301
|
-
if (entry.isDirectory()) {
|
|
302
|
-
await copyContentAssetsRecursive(srcPath, path7.join(destDir, entry.name));
|
|
303
|
-
} else {
|
|
304
|
-
const ext = path7.extname(entry.name).toLowerCase();
|
|
305
|
-
if (CONTENT_EXTENSIONS.has(ext)) {
|
|
306
|
-
await fs3.mkdir(destDir, { recursive: true });
|
|
307
|
-
await fs3.copyFile(srcPath, path7.join(destDir, entry.name));
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
var CONTENT_EXTENSIONS;
|
|
313
|
-
var init_vercel = __esm(() => {
|
|
314
|
-
CONTENT_EXTENSIONS = new Set([
|
|
315
|
-
".png",
|
|
316
|
-
".jpg",
|
|
317
|
-
".jpeg",
|
|
318
|
-
".gif",
|
|
319
|
-
".svg",
|
|
320
|
-
".webp",
|
|
321
|
-
".ico",
|
|
322
|
-
".pdf",
|
|
323
|
-
".json",
|
|
324
|
-
".yaml",
|
|
325
|
-
".yml",
|
|
326
|
-
".txt"
|
|
327
|
-
]);
|
|
328
|
-
});
|
|
329
|
-
|
|
330
|
-
// src/server/prod.ts
|
|
331
|
-
var exports_prod = {};
|
|
332
|
-
__export(exports_prod, {
|
|
333
|
-
startProdServer: () => startProdServer
|
|
334
|
-
});
|
|
335
|
-
import path9 from "path";
|
|
336
|
-
import chalk7 from "chalk";
|
|
337
|
-
async function startProdServer(options) {
|
|
338
|
-
const { port, distDir } = options;
|
|
339
|
-
const serverEntry = path9.resolve(distDir, "server/entry-prod.js");
|
|
340
|
-
const { startServer } = await import(serverEntry);
|
|
341
|
-
console.log(chalk7.cyan("Starting production server..."));
|
|
342
|
-
return startServer({ port, distDir });
|
|
343
|
-
}
|
|
344
|
-
var init_prod = () => {};
|
|
345
|
-
|
|
346
142
|
// src/cli/index.ts
|
|
347
143
|
import { Command as Command6 } from "commander";
|
|
348
144
|
|
|
349
|
-
// src/cli/commands/
|
|
145
|
+
// src/cli/commands/build.ts
|
|
146
|
+
import chalk2 from "chalk";
|
|
350
147
|
import { Command } from "commander";
|
|
351
|
-
import { execSync } from "child_process";
|
|
352
|
-
import fs2 from "fs";
|
|
353
|
-
import path3 from "path";
|
|
354
|
-
import chalk from "chalk";
|
|
355
|
-
import { stringify } from "yaml";
|
|
356
148
|
|
|
357
|
-
// src/cli/utils/
|
|
358
|
-
import
|
|
359
|
-
import
|
|
149
|
+
// src/cli/utils/config.ts
|
|
150
|
+
import path from "node:path";
|
|
151
|
+
import chalk from "chalk";
|
|
152
|
+
import { parse } from "yaml";
|
|
153
|
+
function resolveContentDir(contentFlag) {
|
|
154
|
+
if (contentFlag)
|
|
155
|
+
return path.resolve(contentFlag);
|
|
156
|
+
return path.resolve("content");
|
|
157
|
+
}
|
|
360
158
|
|
|
361
159
|
// src/cli/utils/resolve.ts
|
|
362
|
-
import
|
|
160
|
+
import path2 from "path";
|
|
363
161
|
import { fileURLToPath } from "url";
|
|
364
|
-
var PACKAGE_ROOT =
|
|
162
|
+
var PACKAGE_ROOT = path2.resolve(path2.dirname(fileURLToPath(import.meta.url)), "..", "..");
|
|
365
163
|
|
|
366
164
|
// src/cli/utils/scaffold.ts
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
const
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
}
|
|
380
|
-
function getChronicleVersion() {
|
|
381
|
-
const pkgPath = path2.join(PACKAGE_ROOT, "package.json");
|
|
382
|
-
const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf-8"));
|
|
383
|
-
return pkg.version;
|
|
165
|
+
import fs from "node:fs/promises";
|
|
166
|
+
import path3 from "node:path";
|
|
167
|
+
async function linkContent(contentDir) {
|
|
168
|
+
const linkPath = path3.join(PACKAGE_ROOT, ".content");
|
|
169
|
+
const target = path3.resolve(contentDir);
|
|
170
|
+
try {
|
|
171
|
+
const existing = await fs.readlink(linkPath);
|
|
172
|
+
if (existing === target)
|
|
173
|
+
return;
|
|
174
|
+
await fs.unlink(linkPath);
|
|
175
|
+
} catch {}
|
|
176
|
+
await fs.symlink(target, linkPath);
|
|
384
177
|
}
|
|
385
178
|
|
|
179
|
+
// src/cli/commands/build.ts
|
|
180
|
+
var buildCommand = new Command("build").description("Build for production").option("-c, --content <path>", "Content directory").option("--preset <preset>", "Deploy preset (vercel, cloudflare, node-server)").action(async (options) => {
|
|
181
|
+
const contentDir = resolveContentDir(options.content);
|
|
182
|
+
await linkContent(contentDir);
|
|
183
|
+
console.log(chalk2.cyan("Building for production..."));
|
|
184
|
+
const { createBuilder } = await import("vite");
|
|
185
|
+
const { createViteConfig: createViteConfig2 } = await Promise.resolve().then(() => (init_vite_config(), exports_vite_config));
|
|
186
|
+
const config = await createViteConfig2({
|
|
187
|
+
packageRoot: PACKAGE_ROOT,
|
|
188
|
+
projectRoot: process.cwd(),
|
|
189
|
+
contentDir,
|
|
190
|
+
preset: options.preset
|
|
191
|
+
});
|
|
192
|
+
const builder = await createBuilder({ ...config, builder: {} });
|
|
193
|
+
await builder.buildApp();
|
|
194
|
+
console.log(chalk2.green("Build complete"));
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
// src/cli/commands/dev.ts
|
|
198
|
+
import chalk3 from "chalk";
|
|
199
|
+
import { Command as Command2 } from "commander";
|
|
200
|
+
var devCommand = new Command2("dev").description("Start development server").option("-p, --port <port>", "Port number", "3000").option("-c, --content <path>", "Content directory").action(async (options) => {
|
|
201
|
+
const contentDir = resolveContentDir(options.content);
|
|
202
|
+
const port = parseInt(options.port, 10);
|
|
203
|
+
await linkContent(contentDir);
|
|
204
|
+
console.log(chalk3.cyan("Starting dev server..."));
|
|
205
|
+
const { createServer } = await import("vite");
|
|
206
|
+
const { createViteConfig: createViteConfig2 } = await Promise.resolve().then(() => (init_vite_config(), exports_vite_config));
|
|
207
|
+
const config = await createViteConfig2({ packageRoot: PACKAGE_ROOT, projectRoot: process.cwd(), contentDir });
|
|
208
|
+
const server = await createServer({
|
|
209
|
+
...config,
|
|
210
|
+
server: { ...config.server, port }
|
|
211
|
+
});
|
|
212
|
+
await server.listen();
|
|
213
|
+
server.printUrls();
|
|
214
|
+
});
|
|
215
|
+
|
|
386
216
|
// src/cli/commands/init.ts
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
private: true,
|
|
399
|
-
type: "module",
|
|
400
|
-
scripts: {
|
|
401
|
-
dev: "chronicle dev",
|
|
402
|
-
build: "chronicle build",
|
|
403
|
-
start: "chronicle start"
|
|
404
|
-
},
|
|
405
|
-
dependencies: {
|
|
406
|
-
"@raystack/chronicle": `^${getChronicleVersion()}`
|
|
407
|
-
},
|
|
408
|
-
devDependencies: {
|
|
409
|
-
"@raystack/tools-config": "0.56.0",
|
|
410
|
-
"openapi-types": "^12.1.3",
|
|
411
|
-
typescript: "5.9.3",
|
|
412
|
-
"@types/react": "^19.2.10",
|
|
413
|
-
"@types/node": "^25.1.0"
|
|
414
|
-
}
|
|
415
|
-
};
|
|
416
|
-
}
|
|
217
|
+
import fs2 from "node:fs";
|
|
218
|
+
import path5 from "node:path";
|
|
219
|
+
import chalk4 from "chalk";
|
|
220
|
+
import { Command as Command3 } from "commander";
|
|
221
|
+
import { stringify } from "yaml";
|
|
222
|
+
var defaultConfig = {
|
|
223
|
+
title: "My Documentation",
|
|
224
|
+
description: "Documentation powered by Chronicle",
|
|
225
|
+
theme: { name: "default" },
|
|
226
|
+
search: { enabled: true, placeholder: "Search documentation..." }
|
|
227
|
+
};
|
|
417
228
|
var sampleMdx = `---
|
|
418
229
|
title: Welcome
|
|
419
230
|
description: Getting started with your documentation
|
|
@@ -424,74 +235,28 @@ order: 1
|
|
|
424
235
|
|
|
425
236
|
This is your documentation home page.
|
|
426
237
|
`;
|
|
427
|
-
var initCommand = new
|
|
238
|
+
var initCommand = new Command3("init").description("Initialize a new Chronicle project").option("-c, --content <path>", "Content directory name", "content").action((options) => {
|
|
428
239
|
const projectDir = process.cwd();
|
|
429
|
-
const
|
|
430
|
-
const contentDir = path3.join(projectDir, options.content);
|
|
240
|
+
const contentDir = path5.join(projectDir, options.content);
|
|
431
241
|
if (!fs2.existsSync(contentDir)) {
|
|
432
242
|
fs2.mkdirSync(contentDir, { recursive: true });
|
|
433
|
-
console.log(
|
|
243
|
+
console.log(chalk4.green("✓"), "Created", contentDir);
|
|
434
244
|
}
|
|
435
|
-
const
|
|
436
|
-
if (!fs2.existsSync(packageJsonPath)) {
|
|
437
|
-
fs2.writeFileSync(packageJsonPath, JSON.stringify(createPackageJson(dirName), null, 2) + `
|
|
438
|
-
`);
|
|
439
|
-
console.log(chalk.green("✓"), "Created", packageJsonPath);
|
|
440
|
-
} else {
|
|
441
|
-
const existing = JSON.parse(fs2.readFileSync(packageJsonPath, "utf-8"));
|
|
442
|
-
const template = createPackageJson(dirName);
|
|
443
|
-
let updated = false;
|
|
444
|
-
if (existing.type !== "module") {
|
|
445
|
-
existing.type = "module";
|
|
446
|
-
updated = true;
|
|
447
|
-
}
|
|
448
|
-
if (!existing.scripts)
|
|
449
|
-
existing.scripts = {};
|
|
450
|
-
for (const [key, value] of Object.entries(template.scripts)) {
|
|
451
|
-
if (!existing.scripts[key]) {
|
|
452
|
-
existing.scripts[key] = value;
|
|
453
|
-
updated = true;
|
|
454
|
-
}
|
|
455
|
-
}
|
|
456
|
-
if (!existing.dependencies)
|
|
457
|
-
existing.dependencies = {};
|
|
458
|
-
for (const [key, value] of Object.entries(template.dependencies)) {
|
|
459
|
-
if (!existing.dependencies[key]) {
|
|
460
|
-
existing.dependencies[key] = value;
|
|
461
|
-
updated = true;
|
|
462
|
-
}
|
|
463
|
-
}
|
|
464
|
-
if (!existing.devDependencies)
|
|
465
|
-
existing.devDependencies = {};
|
|
466
|
-
for (const [key, value] of Object.entries(template.devDependencies)) {
|
|
467
|
-
if (!existing.devDependencies[key]) {
|
|
468
|
-
existing.devDependencies[key] = value;
|
|
469
|
-
updated = true;
|
|
470
|
-
}
|
|
471
|
-
}
|
|
472
|
-
if (updated) {
|
|
473
|
-
fs2.writeFileSync(packageJsonPath, JSON.stringify(existing, null, 2) + `
|
|
474
|
-
`);
|
|
475
|
-
console.log(chalk.green("✓"), "Updated", packageJsonPath);
|
|
476
|
-
} else {
|
|
477
|
-
console.log(chalk.yellow("⚠"), packageJsonPath, "already has all required entries");
|
|
478
|
-
}
|
|
479
|
-
}
|
|
480
|
-
const configPath = path3.join(projectDir, "chronicle.yaml");
|
|
245
|
+
const configPath = path5.join(projectDir, "chronicle.yaml");
|
|
481
246
|
if (!fs2.existsSync(configPath)) {
|
|
482
|
-
fs2.writeFileSync(configPath, stringify(
|
|
483
|
-
console.log(
|
|
247
|
+
fs2.writeFileSync(configPath, stringify(defaultConfig));
|
|
248
|
+
console.log(chalk4.green("✓"), "Created", configPath);
|
|
484
249
|
} else {
|
|
485
|
-
console.log(
|
|
250
|
+
console.log(chalk4.yellow("⚠"), configPath, "already exists");
|
|
486
251
|
}
|
|
487
252
|
const contentFiles = fs2.readdirSync(contentDir);
|
|
488
253
|
if (contentFiles.length === 0) {
|
|
489
|
-
const indexPath =
|
|
254
|
+
const indexPath = path5.join(contentDir, "index.mdx");
|
|
490
255
|
fs2.writeFileSync(indexPath, sampleMdx);
|
|
491
|
-
console.log(
|
|
256
|
+
console.log(chalk4.green("✓"), "Created", indexPath);
|
|
492
257
|
}
|
|
493
|
-
const gitignorePath =
|
|
494
|
-
const gitignoreEntries = ["node_modules", "dist"];
|
|
258
|
+
const gitignorePath = path5.join(projectDir, ".gitignore");
|
|
259
|
+
const gitignoreEntries = ["node_modules", "dist", ".output"];
|
|
495
260
|
if (fs2.existsSync(gitignorePath)) {
|
|
496
261
|
const existing = fs2.readFileSync(gitignorePath, "utf-8");
|
|
497
262
|
const missing = gitignoreEntries.filter((e) => !existing.includes(e));
|
|
@@ -500,151 +265,61 @@ var initCommand = new Command("init").description("Initialize a new Chronicle pr
|
|
|
500
265
|
${missing.join(`
|
|
501
266
|
`)}
|
|
502
267
|
`);
|
|
503
|
-
console.log(
|
|
268
|
+
console.log(chalk4.green("✓"), "Added", missing.join(", "), "to .gitignore");
|
|
504
269
|
}
|
|
505
270
|
} else {
|
|
506
271
|
fs2.writeFileSync(gitignorePath, `${gitignoreEntries.join(`
|
|
507
272
|
`)}
|
|
508
273
|
`);
|
|
509
|
-
console.log(
|
|
274
|
+
console.log(chalk4.green("✓"), "Created .gitignore");
|
|
510
275
|
}
|
|
511
|
-
|
|
512
|
-
console.log(chalk.cyan(`
|
|
513
|
-
Installing dependencies with ${pm}...`));
|
|
514
|
-
execSync(`${pm} install`, { cwd: projectDir, stdio: "inherit" });
|
|
515
|
-
const runCmd = pm === "npm" ? "npx" : pm === "bun" ? "bunx" : `${pm} dlx`;
|
|
516
|
-
console.log(chalk.green(`
|
|
276
|
+
console.log(chalk4.green(`
|
|
517
277
|
✓ Chronicle initialized!`));
|
|
518
278
|
console.log(`
|
|
519
|
-
Run`,
|
|
279
|
+
Run`, chalk4.cyan("chronicle dev"), "to start development server");
|
|
520
280
|
});
|
|
521
281
|
|
|
522
|
-
// src/cli/commands/
|
|
523
|
-
import
|
|
524
|
-
import
|
|
525
|
-
|
|
526
|
-
// src/cli/utils/config.ts
|
|
527
|
-
import path4 from "path";
|
|
528
|
-
import { parse } from "yaml";
|
|
529
|
-
import chalk2 from "chalk";
|
|
530
|
-
function resolveContentDir(contentFlag) {
|
|
531
|
-
if (contentFlag)
|
|
532
|
-
return path4.resolve(contentFlag);
|
|
533
|
-
if (process.env.CHRONICLE_CONTENT_DIR)
|
|
534
|
-
return path4.resolve(process.env.CHRONICLE_CONTENT_DIR);
|
|
535
|
-
return path4.resolve("content");
|
|
536
|
-
}
|
|
537
|
-
|
|
538
|
-
// src/cli/commands/dev.ts
|
|
539
|
-
var devCommand = new Command2("dev").description("Start development server").option("-p, --port <port>", "Port number", "3000").option("-c, --content <path>", "Content directory").action(async (options) => {
|
|
282
|
+
// src/cli/commands/serve.ts
|
|
283
|
+
import chalk5 from "chalk";
|
|
284
|
+
import { Command as Command4 } from "commander";
|
|
285
|
+
var serveCommand = new Command4("serve").description("Build and start production server").option("-p, --port <port>", "Port number", "3000").option("-c, --content <path>", "Content directory").option("--preset <preset>", "Deploy preset (vercel, cloudflare, node-server)").action(async (options) => {
|
|
540
286
|
const contentDir = resolveContentDir(options.content);
|
|
541
287
|
const port = parseInt(options.port, 10);
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
console.log(chalk4.cyan("Starting dev server..."));
|
|
545
|
-
const { startDevServer: startDevServer2 } = await Promise.resolve().then(() => (init_dev(), exports_dev));
|
|
546
|
-
await startDevServer2({ port, root: PACKAGE_ROOT, contentDir });
|
|
547
|
-
});
|
|
548
|
-
|
|
549
|
-
// src/cli/commands/build.ts
|
|
550
|
-
import { Command as Command3 } from "commander";
|
|
551
|
-
import path8 from "path";
|
|
552
|
-
import chalk6 from "chalk";
|
|
553
|
-
var buildCommand = new Command3("build").description("Build for production").option("-c, --content <path>", "Content directory").option("-o, --outDir <path>", "Output directory", "dist").option("--adapter <adapter>", "Deploy adapter (vercel)").action(async (options) => {
|
|
554
|
-
const contentDir = resolveContentDir(options.content);
|
|
555
|
-
const outDir = path8.resolve(options.outDir);
|
|
556
|
-
process.env.CHRONICLE_PROJECT_ROOT = process.cwd();
|
|
557
|
-
process.env.CHRONICLE_CONTENT_DIR = contentDir;
|
|
558
|
-
console.log(chalk6.cyan("Building for production..."));
|
|
559
|
-
const { build } = await import("vite");
|
|
288
|
+
await linkContent(contentDir);
|
|
289
|
+
const { build, preview } = await import("vite");
|
|
560
290
|
const { createViteConfig: createViteConfig2 } = await Promise.resolve().then(() => (init_vite_config(), exports_vite_config));
|
|
561
|
-
const
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
outDir: path8.join(outDir, "client"),
|
|
567
|
-
ssrManifest: true,
|
|
568
|
-
rolldownOptions: {
|
|
569
|
-
input: path8.resolve(PACKAGE_ROOT, "src/server/index.html")
|
|
570
|
-
}
|
|
571
|
-
}
|
|
291
|
+
const config = await createViteConfig2({
|
|
292
|
+
packageRoot: PACKAGE_ROOT,
|
|
293
|
+
projectRoot: process.cwd(),
|
|
294
|
+
contentDir,
|
|
295
|
+
preset: options.preset
|
|
572
296
|
});
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
},
|
|
580
|
-
build: {
|
|
581
|
-
outDir: path8.join(outDir, "server"),
|
|
582
|
-
ssr: serverEntry
|
|
583
|
-
}
|
|
297
|
+
console.log(chalk5.cyan("Building for production..."));
|
|
298
|
+
await build(config);
|
|
299
|
+
console.log(chalk5.cyan("Starting production server..."));
|
|
300
|
+
const server = await preview({
|
|
301
|
+
...config,
|
|
302
|
+
preview: { port }
|
|
584
303
|
});
|
|
585
|
-
|
|
586
|
-
if (options.adapter === "vercel") {
|
|
587
|
-
const { buildVercelOutput: buildVercelOutput2 } = await Promise.resolve().then(() => (init_vercel(), exports_vercel));
|
|
588
|
-
await buildVercelOutput2({
|
|
589
|
-
distDir: outDir,
|
|
590
|
-
contentDir,
|
|
591
|
-
projectRoot: process.cwd()
|
|
592
|
-
});
|
|
593
|
-
}
|
|
304
|
+
server.printUrls();
|
|
594
305
|
});
|
|
595
306
|
|
|
596
307
|
// src/cli/commands/start.ts
|
|
597
|
-
import
|
|
598
|
-
import path10 from "path";
|
|
599
|
-
import chalk8 from "chalk";
|
|
600
|
-
var startCommand = new Command4("start").description("Start production server").option("-p, --port <port>", "Port number", "3000").option("-c, --content <path>", "Content directory").option("-d, --dist <path>", "Dist directory", "dist").action(async (options) => {
|
|
601
|
-
const contentDir = resolveContentDir(options.content);
|
|
602
|
-
const port = parseInt(options.port, 10);
|
|
603
|
-
const distDir = path10.resolve(options.dist);
|
|
604
|
-
process.env.CHRONICLE_PROJECT_ROOT = process.cwd();
|
|
605
|
-
process.env.CHRONICLE_CONTENT_DIR = contentDir;
|
|
606
|
-
console.log(chalk8.cyan("Starting production server..."));
|
|
607
|
-
const { startProdServer: startProdServer2 } = await Promise.resolve().then(() => (init_prod(), exports_prod));
|
|
608
|
-
await startProdServer2({ port, root: PACKAGE_ROOT, distDir });
|
|
609
|
-
});
|
|
610
|
-
|
|
611
|
-
// src/cli/commands/serve.ts
|
|
308
|
+
import chalk6 from "chalk";
|
|
612
309
|
import { Command as Command5 } from "commander";
|
|
613
|
-
|
|
614
|
-
import chalk9 from "chalk";
|
|
615
|
-
var serveCommand = new Command5("serve").description("Build and start production server").option("-p, --port <port>", "Port number", "3000").option("-c, --content <path>", "Content directory").option("-o, --outDir <path>", "Output directory", "dist").action(async (options) => {
|
|
310
|
+
var startCommand = new Command5("start").description("Start production server").option("-p, --port <port>", "Port number", "3000").option("-c, --content <path>", "Content directory").action(async (options) => {
|
|
616
311
|
const contentDir = resolveContentDir(options.content);
|
|
617
312
|
const port = parseInt(options.port, 10);
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
console.log(chalk9.cyan("Building for production..."));
|
|
622
|
-
const { build } = await import("vite");
|
|
313
|
+
await linkContent(contentDir);
|
|
314
|
+
console.log(chalk6.cyan("Starting production server..."));
|
|
315
|
+
const { preview } = await import("vite");
|
|
623
316
|
const { createViteConfig: createViteConfig2 } = await Promise.resolve().then(() => (init_vite_config(), exports_vite_config));
|
|
624
|
-
const
|
|
625
|
-
await
|
|
626
|
-
...
|
|
627
|
-
|
|
628
|
-
outDir: path11.join(outDir, "client"),
|
|
629
|
-
ssrManifest: true,
|
|
630
|
-
rolldownOptions: {
|
|
631
|
-
input: path11.resolve(PACKAGE_ROOT, "src/server/index.html")
|
|
632
|
-
}
|
|
633
|
-
}
|
|
634
|
-
});
|
|
635
|
-
await build({
|
|
636
|
-
...baseConfig,
|
|
637
|
-
ssr: {
|
|
638
|
-
noExternal: true
|
|
639
|
-
},
|
|
640
|
-
build: {
|
|
641
|
-
outDir: path11.join(outDir, "server"),
|
|
642
|
-
ssr: path11.resolve(PACKAGE_ROOT, "src/server/entry-prod.ts")
|
|
643
|
-
}
|
|
317
|
+
const config = await createViteConfig2({ packageRoot: PACKAGE_ROOT, projectRoot: process.cwd(), contentDir });
|
|
318
|
+
const server = await preview({
|
|
319
|
+
...config,
|
|
320
|
+
preview: { port }
|
|
644
321
|
});
|
|
645
|
-
|
|
646
|
-
const { startProdServer: startProdServer2 } = await Promise.resolve().then(() => (init_prod(), exports_prod));
|
|
647
|
-
await startProdServer2({ port, root: PACKAGE_ROOT, distDir: outDir });
|
|
322
|
+
server.printUrls();
|
|
648
323
|
});
|
|
649
324
|
|
|
650
325
|
// src/cli/index.ts
|