@xyd-js/documan 0.1.0-xyd.18 → 0.1.0-xyd.2
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/build.js +7 -19
- package/dist/build.js.map +1 -1
- package/dist/dev.js +17 -7
- package/dist/dev.js.map +1 -1
- package/dist/index.js +22 -24
- package/dist/index.js.map +1 -1
- package/dist/serve.js +2 -2
- package/dist/serve.js.map +1 -1
- package/host/.react-router/types/app/+types/root.ts +40 -0
- package/host/app/root.tsx +23 -0
- package/host/app/routes.ts +5 -0
- package/host/node_modules/.vite/deps/@mdx-js_mdx.js +81 -0
- package/host/node_modules/.vite/deps/@mdx-js_mdx.js.map +7 -0
- package/host/node_modules/.vite/deps/@mdx-js_rollup.js +4003 -0
- package/host/node_modules/.vite/deps/@mdx-js_rollup.js.map +7 -0
- package/host/node_modules/.vite/deps/@radix-ui_react-icons.js +7531 -0
- package/host/node_modules/.vite/deps/@radix-ui_react-icons.js.map +7 -0
- package/host/node_modules/.vite/deps/@radix-ui_react-tabs.js +917 -0
- package/host/node_modules/.vite/deps/@radix-ui_react-tabs.js.map +7 -0
- package/host/node_modules/.vite/deps/_metadata.json +157 -0
- package/host/node_modules/.vite/deps/chunk-2TUXWMP5.js +46 -0
- package/host/node_modules/.vite/deps/chunk-2TUXWMP5.js.map +7 -0
- package/host/node_modules/.vite/deps/chunk-A76PLWFF.js +23875 -0
- package/host/node_modules/.vite/deps/chunk-A76PLWFF.js.map +7 -0
- package/host/node_modules/.vite/deps/chunk-B2TCFXA3.js +27 -0
- package/host/node_modules/.vite/deps/chunk-B2TCFXA3.js.map +7 -0
- package/host/node_modules/.vite/deps/chunk-CZACBYAQ.js +3461 -0
- package/host/node_modules/.vite/deps/chunk-CZACBYAQ.js.map +7 -0
- package/host/node_modules/.vite/deps/chunk-IVP26VTC.js +21 -0
- package/host/node_modules/.vite/deps/chunk-IVP26VTC.js.map +7 -0
- package/host/node_modules/.vite/deps/chunk-NSHFRFAV.js +894 -0
- package/host/node_modules/.vite/deps/chunk-NSHFRFAV.js.map +7 -0
- package/host/node_modules/.vite/deps/chunk-O6QCC74R.js +205 -0
- package/host/node_modules/.vite/deps/chunk-O6QCC74R.js.map +7 -0
- package/host/node_modules/.vite/deps/chunk-SBIFJFEH.js +894 -0
- package/host/node_modules/.vite/deps/chunk-SBIFJFEH.js.map +7 -0
- package/host/node_modules/.vite/deps/chunk-SURLKOJ2.js +12 -0
- package/host/node_modules/.vite/deps/chunk-SURLKOJ2.js.map +7 -0
- package/host/node_modules/.vite/deps/chunk-VENRSTQF.js +21628 -0
- package/host/node_modules/.vite/deps/chunk-VENRSTQF.js.map +7 -0
- package/host/node_modules/.vite/deps/chunk-XCGROZNW.js +10609 -0
- package/host/node_modules/.vite/deps/chunk-XCGROZNW.js.map +7 -0
- package/host/node_modules/.vite/deps/chunk-ZFDQJWTH.js +928 -0
- package/host/node_modules/.vite/deps/chunk-ZFDQJWTH.js.map +7 -0
- package/host/node_modules/.vite/deps/chunk-ZFOARUJI.js +1906 -0
- package/host/node_modules/.vite/deps/chunk-ZFOARUJI.js.map +7 -0
- package/host/node_modules/.vite/deps/gray-matter.js +3492 -0
- package/host/node_modules/.vite/deps/gray-matter.js.map +7 -0
- package/host/node_modules/.vite/deps/lucide-react.js +34742 -0
- package/host/node_modules/.vite/deps/lucide-react.js.map +7 -0
- package/host/node_modules/.vite/deps/package.json +3 -0
- package/host/node_modules/.vite/deps/react-dom.js +7 -0
- package/host/node_modules/.vite/deps/react-dom.js.map +7 -0
- package/host/node_modules/.vite/deps/react-dom_client.js +39 -0
- package/host/node_modules/.vite/deps/react-dom_client.js.map +7 -0
- package/host/node_modules/.vite/deps/react-router.js +243 -0
- package/host/node_modules/.vite/deps/react-router.js.map +7 -0
- package/host/node_modules/.vite/deps/react-router_dom.js +212 -0
- package/host/node_modules/.vite/deps/react-router_dom.js.map +7 -0
- package/host/node_modules/.vite/deps/react.js +6 -0
- package/host/node_modules/.vite/deps/react.js.map +7 -0
- package/host/node_modules/.vite/deps/react_jsx-dev-runtime.js +913 -0
- package/host/node_modules/.vite/deps/react_jsx-dev-runtime.js.map +7 -0
- package/host/node_modules/.vite/deps/react_jsx-runtime.js +7 -0
- package/host/node_modules/.vite/deps/react_jsx-runtime.js.map +7 -0
- package/host/node_modules/.vite/deps/remark-frontmatter.js +428 -0
- package/host/node_modules/.vite/deps/remark-frontmatter.js.map +7 -0
- package/host/node_modules/.vite/deps/remark-gfm.js +3122 -0
- package/host/node_modules/.vite/deps/remark-gfm.js.map +7 -0
- package/host/node_modules/.vite/deps/remark-mdx-frontmatter.js +10482 -0
- package/host/node_modules/.vite/deps/remark-mdx-frontmatter.js.map +7 -0
- package/host/node_modules/.vite/deps/unist-util-visit.js +14 -0
- package/host/node_modules/.vite/deps/unist-util-visit.js.map +7 -0
- package/host/node_modules/.vite/deps/vfile.js +8 -0
- package/host/node_modules/.vite/deps/vfile.js.map +7 -0
- package/host/package.json +43 -0
- package/host/postcss.config.cjs +5 -0
- package/host/react-router.config.ts +8 -0
- package/host/tsconfig.json +22 -0
- package/host/vite.config.ts +9 -0
- package/package.json +14 -11
- package/src/commands/build.ts +4 -0
- package/src/commands/dev.ts +5 -0
- package/src/commands/serve.ts +5 -0
- package/src/index.ts +7 -0
- package/src/run/build.ts +98 -0
- package/src/run/dev.ts +76 -0
- package/src/run/index.ts +6 -0
- package/src/run/serve.ts +106 -0
- package/tsconfig.json +22 -0
- package/tsup.config.ts +81 -0
package/dist/build.js
CHANGED
|
@@ -2,11 +2,10 @@
|
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import fs from "node:fs";
|
|
4
4
|
import { fileURLToPath } from "node:url";
|
|
5
|
-
import { execSync } from "child_process";
|
|
6
5
|
import { build as viteBuild } from "vite";
|
|
7
6
|
import tsconfigPaths from "vite-tsconfig-paths";
|
|
8
7
|
import { reactRouter } from "@xyd-js/react-router-dev/vite";
|
|
9
|
-
import { vitePlugins as xydContentVitePlugins } from "@xyd-js/content
|
|
8
|
+
import { vitePlugins as xydContentVitePlugins } from "@xyd-js/content";
|
|
10
9
|
import { pluginZero } from "@xyd-js/plugin-zero";
|
|
11
10
|
var __filename = fileURLToPath(import.meta.url);
|
|
12
11
|
var __dirname = path.dirname(__filename);
|
|
@@ -21,30 +20,18 @@ async function build() {
|
|
|
21
20
|
const packageJsonContent = {
|
|
22
21
|
type: "module",
|
|
23
22
|
scripts: {},
|
|
24
|
-
dependencies: {
|
|
25
|
-
// TODO: better
|
|
26
|
-
// "@xyd-js/content": "latest",
|
|
27
|
-
// "@xyd-js/components": "latest",
|
|
28
|
-
// "@xyd-js/framework": "latest",
|
|
29
|
-
// "@xyd-js/theme-poetry": "latest",
|
|
30
|
-
"@xyd-js/content": "workspace:*",
|
|
31
|
-
"@xyd-js/components": "workspace:*",
|
|
32
|
-
"@xyd-js/framework": "workspace:*",
|
|
33
|
-
"@xyd-js/theme-poetry": "workspace:*",
|
|
34
|
-
"@react-router/node": "^7.1.1",
|
|
35
|
-
"isbot": "^5"
|
|
36
|
-
},
|
|
23
|
+
dependencies: {},
|
|
37
24
|
devDependencies: {}
|
|
38
25
|
};
|
|
39
26
|
if (!fs.existsSync(buildDir)) {
|
|
40
27
|
fs.mkdirSync(buildDir, { recursive: true });
|
|
41
28
|
}
|
|
42
29
|
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJsonContent, null, 2), "utf8");
|
|
43
|
-
execSync("pnpm i", { cwd: buildDir, stdio: "inherit" });
|
|
44
30
|
}
|
|
45
31
|
try {
|
|
46
32
|
await viteBuild({
|
|
47
|
-
root:
|
|
33
|
+
root: path.join(__dirname, "../host"),
|
|
34
|
+
// @ts-ignore
|
|
48
35
|
plugins: [
|
|
49
36
|
...xydContentVitePlugins({
|
|
50
37
|
toc: {
|
|
@@ -63,10 +50,11 @@ async function build() {
|
|
|
63
50
|
}
|
|
64
51
|
});
|
|
65
52
|
await viteBuild({
|
|
66
|
-
root:
|
|
53
|
+
root: path.join(__dirname, "../host"),
|
|
67
54
|
build: {
|
|
68
55
|
ssr: true
|
|
69
56
|
},
|
|
57
|
+
// @ts-ignore
|
|
70
58
|
plugins: [
|
|
71
59
|
...xydContentVitePlugins({
|
|
72
60
|
toc: {
|
|
@@ -95,7 +83,7 @@ import path2 from "node:path";
|
|
|
95
83
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
96
84
|
import { createServer, searchForWorkspaceRoot } from "vite";
|
|
97
85
|
import { reactRouter as reactRouter2 } from "@xyd-js/react-router-dev/vite";
|
|
98
|
-
import { vitePlugins as xydContentVitePlugins2 } from "@xyd-js/content
|
|
86
|
+
import { vitePlugins as xydContentVitePlugins2 } from "@xyd-js/content";
|
|
99
87
|
import { pluginZero as pluginZero2 } from "@xyd-js/plugin-zero";
|
|
100
88
|
var __filename2 = fileURLToPath2(import.meta.url);
|
|
101
89
|
var __dirname2 = path2.dirname(__filename2);
|
package/dist/build.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/run/build.ts","../src/run/dev.ts","../src/run/serve.ts","../src/commands/build.ts"],"sourcesContent":["import path from \"node:path\";\nimport fs from \"node:fs\";\nimport {fileURLToPath} from \"node:url\";\nimport {execSync} from 'child_process';\n\nimport {build as viteBuild} from 'vite';\nimport tsconfigPaths from \"vite-tsconfig-paths\";\n\nimport {reactRouter} from \"@xyd-js/react-router-dev/vite\";\n\nimport {vitePlugins as xydContentVitePlugins} from \"@xyd-js/content/vite\"\nimport {pluginZero} from \"@xyd-js/plugin-zero\";\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = path.dirname(__filename);\n\n// Define the main function to run the builds\nexport async function build() {\n const resp = await pluginZero()\n if (!resp) {\n throw new Error(\"PluginZero not found\")\n }\n\n const buildDir = path.join(process.cwd(), \".xyd/build\");\n\n {\n // TODO: probably we should have better mechanism - maybe bundle?\n\n const packageJsonPath = path.join(buildDir, 'package.json');\n\n const packageJsonContent = {\n type: \"module\",\n scripts: {},\n dependencies: { // TODO: better\n // \"@xyd-js/content\": \"latest\",\n // \"@xyd-js/components\": \"latest\",\n // \"@xyd-js/framework\": \"latest\",\n // \"@xyd-js/theme-poetry\": \"latest\",\n\n \"@xyd-js/content\": \"workspace:*\",\n \"@xyd-js/components\": \"workspace:*\",\n \"@xyd-js/framework\": \"workspace:*\",\n \"@xyd-js/theme-poetry\": \"workspace:*\",\n\n \"@react-router/node\": \"^7.1.1\",\n \"isbot\": \"^5\"\n },\n devDependencies: {}\n };\n\n // Ensure the build directory exists\n if (!fs.existsSync(buildDir)) {\n fs.mkdirSync(buildDir, {recursive: true});\n }\n\n // Write the package.json file\n fs.writeFileSync(packageJsonPath, JSON.stringify(packageJsonContent, null, 2), 'utf8');\n\n // Install packages inside buildDir\n // execSync('npm install', {cwd: buildDir, stdio: 'inherit'});\n\n execSync('pnpm i', {cwd: buildDir, stdio: 'inherit'});\n }\n\n try {\n // Build the client-side bundle\n await viteBuild({\n root: process.env.XYD_CLI ? __dirname : process.env.XYD_DOCUMAN_HOST || path.join(__dirname, \"../host\"),\n plugins: [\n ...(xydContentVitePlugins({\n toc: {\n minDepth: 2,\n }\n }) as Plugin[]),\n reactRouter({\n outDir: buildDir,\n routes: resp.routes\n }),\n tsconfigPaths(),\n ...resp.vitePlugins\n ],\n optimizeDeps: {\n include: [\"react/jsx-runtime\"],\n },\n });\n\n // Build the SSR bundle\n await viteBuild({\n root: process.env.XYD_CLI ? __dirname : process.env.XYD_DOCUMAN_HOST || path.join(__dirname, \"../host\"),\n build: {\n ssr: true,\n },\n plugins: [\n ...(xydContentVitePlugins({\n toc: {\n minDepth: 2,\n }\n }) as Plugin[]),\n reactRouter({\n outDir: buildDir,\n routes: resp.routes\n }),\n tsconfigPaths(),\n ...resp.vitePlugins\n ],\n optimizeDeps: {\n include: [\"react/jsx-runtime\"],\n },\n });\n\n console.log('Build completed successfully.'); // TODO: better message\n } catch (error) {\n console.error('Build failed:', error); // TODO: better message\n }\n}\n\n","import path from \"node:path\";\nimport {fileURLToPath} from \"node:url\";\nimport {createServer, searchForWorkspaceRoot} from \"vite\";\n\nimport {reactRouter} from \"@xyd-js/react-router-dev/vite\";\n\nimport {vitePlugins as xydContentVitePlugins} from \"@xyd-js/content/vite\";\nimport {pluginZero} from \"@xyd-js/plugin-zero\";\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = path.dirname(__filename);\n\nconst port = process.env.XYD_PORT ? parseInt(process.env.XYD_PORT) : 5175;\n\nexport async function dev() {\n const respPluginZero = await pluginZero()\n if (!respPluginZero) {\n throw new Error(\"PluginZero not found\")\n }\n\n const allowCwd = searchForWorkspaceRoot(process.cwd())\n\n const preview = await createServer({\n root: process.env.XYD_CLI ? __dirname : process.env.XYD_DOCUMAN_HOST || path.join(__dirname, \"../host\"), // TODO: bundler?\n server: {\n port: port,\n fs: {\n allow: [\n allowCwd,\n process.env.XYD_CLI ? path.join(__dirname, \"../../\") : \"\",\n // path.join(__dirname, \"../node_modules\") // Ensure node_modules from xyd-documan is included\n ]\n }\n },\n build: {\n rollupOptions: {\n // Exclude package `B` from the client-side bundle\n external: [\"@xyd-js/uniform\", \"@xyd-js/uniform/content\", \"@xyd-js/plugin-zero\"],\n },\n },\n ssr: {\n external: [\"@xyd-js/uniform\", \"@xyd-js/uniform/content\", \"@xyd-js/plugin-zero\"],\n },\n optimizeDeps: {\n include: [\"react/jsx-runtime\"],\n },\n plugins: [ // TODO: fix plugin ts\n ...(xydContentVitePlugins({\n toc: {\n minDepth: 2,\n }\n }) as Plugin[]),\n reactRouter({\n routes: respPluginZero.routes\n }),\n ...respPluginZero.vitePlugins\n ],\n });\n\n await preview.listen(port);\n\n preview.printUrls();\n preview.bindCLIShortcuts({print: true});\n\n}","import fs from \"node:fs\";\nimport os from \"node:os\";\nimport path from \"node:path\";\nimport url from \"node:url\";\n\nimport type {ServerBuild} from \"react-router\";\nimport {createRequestHandler} from \"@react-router/express\";\nimport compression from \"compression\";\nimport express from \"express\";\nimport morgan from \"morgan\";\nimport sourceMapSupport from \"source-map-support\";\nimport getPort from \"get-port\";\n\nfunction parseNumber(raw?: string) {\n if (raw === undefined) return undefined;\n let maybe = Number(raw);\n if (Number.isNaN(maybe)) return undefined;\n return maybe;\n}\n\nexport async function serve() {\n process.env.NODE_ENV = process.env.NODE_ENV ?? \"production\";\n\n sourceMapSupport.install({\n retrieveSourceMap: function (source) {\n let match = source.startsWith(\"file://\");\n if (match) {\n let filePath = url.fileURLToPath(source);\n let sourceMapPath = `${filePath}.map`;\n if (fs.existsSync(sourceMapPath)) {\n return {\n url: source,\n map: fs.readFileSync(sourceMapPath, \"utf8\"),\n };\n }\n }\n return null;\n },\n });\n\n let port = parseNumber(process.env.PORT) ?? (await getPort({port: 3000}));\n\n let buildPathArg = path.join(process.cwd(), \".xyd/build/server/index.js\")\n\n if (!buildPathArg) {\n console.error(`\n Usage: react-router-serve <server-build-path> - e.g. react-router-serve build/server/index.js`);\n process.exit(1);\n }\n\n let buildPath = path.resolve(buildPathArg);\n\n let build: ServerBuild = await import(url.pathToFileURL(buildPath).href);\n\n let onListen = () => {\n let address =\n process.env.HOST ||\n Object.values(os.networkInterfaces())\n .flat()\n .find((ip) => String(ip?.family).includes(\"4\") && !ip?.internal)\n ?.address;\n\n if (!address) {\n console.log(`[xyd-serve] http://localhost:${port}`);\n } else {\n console.log(\n `[xyd-serve] http://localhost:${port} (http://${address}:${port})`\n );\n }\n };\n\n build = {\n ...build,\n assetsBuildDirectory: path.join(process.cwd(), \".xyd/build/client\")\n }\n\n let app = express();\n app.disable(\"x-powered-by\");\n app.use(compression());\n app.use(\n path.posix.join(build.publicPath, \"assets\"),\n express.static(path.join(build.assetsBuildDirectory, \"assets\"), {\n immutable: true,\n maxAge: \"1y\",\n })\n );\n app.use(build.publicPath, express.static(build.assetsBuildDirectory));\n app.use(express.static(\"public\", {maxAge: \"1h\"}));\n app.use(morgan(\"tiny\"));\n\n app.all(\n \"*\",\n createRequestHandler({\n build,\n mode: process.env.NODE_ENV,\n })\n );\n\n let server = process.env.HOST\n ? app.listen(port, process.env.HOST, onListen)\n : app.listen(port, onListen);\n\n [\"SIGTERM\", \"SIGINT\"].forEach((signal) => {\n process.once(signal, () => server?.close(console.error));\n });\n}\n","import {build} from \"../\"\n\n// Execute the build function\nawait build();"],"mappings":";AAAA,OAAO,UAAU;AACjB,OAAO,QAAQ;AACf,SAAQ,qBAAoB;AAC5B,SAAQ,gBAAe;AAEvB,SAAQ,SAAS,iBAAgB;AACjC,OAAO,mBAAmB;AAE1B,SAAQ,mBAAkB;AAE1B,SAAQ,eAAe,6BAA4B;AACnD,SAAQ,kBAAiB;AAEzB,IAAM,aAAa,cAAc,YAAY,GAAG;AAChD,IAAM,YAAY,KAAK,QAAQ,UAAU;AAGzC,eAAsB,QAAQ;AAC1B,QAAM,OAAO,MAAM,WAAW;AAC9B,MAAI,CAAC,MAAM;AACP,UAAM,IAAI,MAAM,sBAAsB;AAAA,EAC1C;AAEA,QAAM,WAAW,KAAK,KAAK,QAAQ,IAAI,GAAG,YAAY;AAEtD;AAGI,UAAM,kBAAkB,KAAK,KAAK,UAAU,cAAc;AAE1D,UAAM,qBAAqB;AAAA,MACvB,MAAM;AAAA,MACN,SAAS,CAAC;AAAA,MACV,cAAc;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,QAMV,mBAAmB;AAAA,QACnB,sBAAsB;AAAA,QACtB,qBAAqB;AAAA,QACrB,wBAAwB;AAAA,QAExB,sBAAsB;AAAA,QACtB,SAAS;AAAA,MACb;AAAA,MACA,iBAAiB,CAAC;AAAA,IACtB;AAGA,QAAI,CAAC,GAAG,WAAW,QAAQ,GAAG;AAC1B,SAAG,UAAU,UAAU,EAAC,WAAW,KAAI,CAAC;AAAA,IAC5C;AAGA,OAAG,cAAc,iBAAiB,KAAK,UAAU,oBAAoB,MAAM,CAAC,GAAG,MAAM;AAKrF,aAAS,UAAU,EAAC,KAAK,UAAU,OAAO,UAAS,CAAC;AAAA,EACxD;AAEA,MAAI;AAEA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AU;AAEzC,IAAM,OAAO,QAAQ,IAAI,WAAW,SAAS,QAAQ,IAAI,QAAQ,IAAI;;;ACZrE,OAAOE,SAAQ;AACf,OAAO,QAAQ;AACf,OAAOC,WAAU;AACjB,OAAO,SAAS;AAGhB,SAAQ,4BAA2B;AACnC,OAAO,iBAAiB;AACxB,OAAO,aAAa;AACpB,OAAO,YAAY;AACnB,OAAO,sBAAsB;AAC7B,OAAO,aAAa;;;ACRpB,MAAM,MAAM;","names":["path","fileURLToPath","reactRouter","xydContentVitePlugins","pluginZero","__filename","__dirname","fs","path"]}
|
|
1
|
+
{"version":3,"sources":["../src/run/build.ts","../src/run/dev.ts","../src/run/serve.ts","../src/commands/build.ts"],"sourcesContent":["import path from \"node:path\";\nimport fs from \"node:fs\";\nimport {fileURLToPath} from \"node:url\";\n\nimport {build as viteBuild} from 'vite';\nimport tsconfigPaths from \"vite-tsconfig-paths\";\n\nimport {reactRouter} from \"@xyd-js/react-router-dev/vite\";\n// import { reactRouter } from \"@react-router/dev/vite\";\n\nimport {vitePlugins as xydContentVitePlugins} from \"@xyd-js/content\"\nimport {pluginZero} from \"@xyd-js/plugin-zero\";\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = path.dirname(__filename);\n\n// Define the main function to run the builds\nexport async function build() {\n const resp = await pluginZero()\n if (!resp) {\n throw new Error(\"PluginZero not found\")\n }\n\n const buildDir = path.join(process.cwd(), \".xyd/build\");\n\n {\n const packageJsonPath = path.join(buildDir, 'package.json');\n\n const packageJsonContent = {\n type: \"module\",\n scripts: {},\n dependencies: {},\n devDependencies: {}\n };\n\n // Ensure the build directory exists\n if (!fs.existsSync(buildDir)) {\n fs.mkdirSync(buildDir, {recursive: true});\n }\n\n // Write the package.json file\n fs.writeFileSync(packageJsonPath, JSON.stringify(packageJsonContent, null, 2), 'utf8');\n }\n\n try {\n // Build the client-side bundle\n await viteBuild({\n root: path.join(__dirname, \"../host\"),\n // @ts-ignore\n plugins: [\n ...(xydContentVitePlugins({\n toc: {\n minDepth: 2,\n }\n }) as Plugin[]),\n reactRouter({\n outDir: buildDir,\n routes: resp.routes\n }),\n tsconfigPaths(),\n ...resp.vitePlugins\n ],\n optimizeDeps: {\n include: [\"react/jsx-runtime\"],\n },\n });\n\n // Build the SSR bundle\n await viteBuild({\n root: path.join(__dirname, \"../host\"),\n build: {\n ssr: true,\n },\n // @ts-ignore\n plugins: [\n ...(xydContentVitePlugins({\n toc: {\n minDepth: 2,\n }\n }) as Plugin[]),\n reactRouter({\n outDir: buildDir,\n routes: resp.routes\n }),\n tsconfigPaths(),\n ...resp.vitePlugins\n ],\n optimizeDeps: {\n include: [\"react/jsx-runtime\"],\n },\n });\n\n console.log('Build completed successfully.'); // TODO: better message\n } catch (error) {\n console.error('Build failed:', error); // TODO: better message\n }\n}\n\n","import path from \"node:path\";\nimport {fileURLToPath} from \"node:url\";\nimport {createServer, searchForWorkspaceRoot} from \"vite\";\n\nimport {reactRouter} from \"@xyd-js/react-router-dev/vite\";\n// import { reactRouter } from \"@react-router/dev/vite\";\n\nimport {vitePlugins as xydContentVitePlugins} from \"@xyd-js/content\";\nimport {pluginZero} from \"@xyd-js/plugin-zero\";\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = path.dirname(__filename);\n\nconst port = process.env.XYD_PORT ? parseInt(process.env.XYD_PORT) : 5175;\n\nexport async function dev() {\n const resp = await pluginZero()\n if (!resp) {\n throw new Error(\"PluginZero not found\")\n }\n\n const allowCwd = searchForWorkspaceRoot(process.cwd())\n\n const preview = await createServer({\n // any valid user config options, plus `mode` and `configFile`\n // configFile: path.join(__dirname, \"../src/vite/empty-config.ts\"), // TODO: bundler??\n // configFile: path.join(__dirname, \"../\"), // TODO: bundler??\n // root: path.join(__dirname, \"../\"), // TODO: bundler?\n root: process.env.XYD_DOCUMAN_HOST || path.join(__dirname, \"../host\"), // TODO: bundler?\n server: {\n port: port,\n fs: {\n allow: [\n allowCwd,\n process.env.XYD_CLI ? path.join(__dirname, \"../../\") : \"\",\n // path.join(__dirname, \"../node_modules\") // Ensure node_modules from xyd-documan is included\n ]\n }\n },\n build: {\n rollupOptions: {\n // Exclude package `B` from the client-side bundle\n external: [\"@xyd-js/uniform\", \"@xyd-js/uniform/content\", \"@xyd-js/plugin-zero\"],\n },\n },\n ssr: {\n external: [\"@xyd-js/uniform\", \"@xyd-js/uniform/content\", \"@xyd-js/plugin-zero\"],\n // noExternal: [\n // \"@xyd-js/uniform\",\n // \"@xyd-js/uniform/content\",\n // \"@xyd-js/plugin-zero\"\n // ],\n },\n optimizeDeps: {\n include: [\"react/jsx-runtime\"],\n },\n // @ts-ignore\n plugins: [ // TODO: fix plugin ts\n ...(xydContentVitePlugins({\n toc: {\n minDepth: 2,\n }\n }) as Plugin[]),\n reactRouter({\n routes: resp.routes\n }),\n ...resp.vitePlugins\n ],\n });\n\n await preview.listen(port);\n\n preview.printUrls();\n preview.bindCLIShortcuts({print: true});\n\n}","import fs from \"node:fs\";\nimport os from \"node:os\";\nimport path from \"node:path\";\nimport url from \"node:url\";\n\nimport type {ServerBuild} from \"react-router\";\nimport {createRequestHandler} from \"@react-router/express\";\nimport compression from \"compression\";\nimport express from \"express\";\nimport morgan from \"morgan\";\nimport sourceMapSupport from \"source-map-support\";\nimport getPort from \"get-port\";\n\nfunction parseNumber(raw?: string) {\n if (raw === undefined) return undefined;\n let maybe = Number(raw);\n if (Number.isNaN(maybe)) return undefined;\n return maybe;\n}\n\nexport async function serve() {\n process.env.NODE_ENV = process.env.NODE_ENV ?? \"production\";\n\n sourceMapSupport.install({\n retrieveSourceMap: function (source) {\n let match = source.startsWith(\"file://\");\n if (match) {\n let filePath = url.fileURLToPath(source);\n let sourceMapPath = `${filePath}.map`;\n if (fs.existsSync(sourceMapPath)) {\n return {\n url: source,\n map: fs.readFileSync(sourceMapPath, \"utf8\"),\n };\n }\n }\n return null;\n },\n });\n\n let port = parseNumber(process.env.PORT) ?? (await getPort({port: 3000}));\n\n let buildPathArg = path.join(process.cwd(), \".xyd/build/server/index.js\")\n\n if (!buildPathArg) {\n console.error(`\n Usage: react-router-serve <server-build-path> - e.g. react-router-serve build/server/index.js`);\n process.exit(1);\n }\n\n let buildPath = path.resolve(buildPathArg);\n\n let build: ServerBuild = await import(url.pathToFileURL(buildPath).href);\n\n let onListen = () => {\n let address =\n process.env.HOST ||\n Object.values(os.networkInterfaces())\n .flat()\n .find((ip) => String(ip?.family).includes(\"4\") && !ip?.internal)\n ?.address;\n\n if (!address) {\n console.log(`[xyd-serve] http://localhost:${port}`);\n } else {\n console.log(\n `[xyd-serve] http://localhost:${port} (http://${address}:${port})`\n );\n }\n };\n\n build = {\n ...build,\n assetsBuildDirectory: path.join(process.cwd(), \".xyd/build/client\")\n }\n\n let app = express();\n app.disable(\"x-powered-by\");\n app.use(compression());\n app.use(\n path.posix.join(build.publicPath, \"assets\"),\n express.static(path.join(build.assetsBuildDirectory, \"assets\"), {\n immutable: true,\n maxAge: \"1y\",\n })\n );\n app.use(build.publicPath, express.static(build.assetsBuildDirectory));\n app.use(express.static(\"public\", {maxAge: \"1h\"}));\n app.use(morgan(\"tiny\"));\n\n app.all(\n \"*\",\n createRequestHandler({\n build,\n mode: process.env.NODE_ENV,\n })\n );\n\n let server = process.env.HOST\n ? app.listen(port, process.env.HOST, onListen)\n : app.listen(port, onListen);\n\n [\"SIGTERM\", \"SIGINT\"].forEach((signal) => {\n process.once(signal, () => server?.close(console.error));\n });\n}\n","import {build} from \"../\"\n\n// Execute the build function\nawait build();"],"mappings":";AAAA,OAAO,UAAU;AACjB,OAAO,QAAQ;AACf,SAAQ,qBAAoB;AAE5B,SAAQ,SAAS,iBAAgB;AACjC,OAAO,mBAAmB;AAE1B,SAAQ,mBAAkB;AAG1B,SAAQ,eAAe,6BAA4B;AACnD,SAAQ,kBAAiB;AAEzB,IAAM,aAAa,cAAc,YAAY,GAAG;AAChD,IAAM,YAAY,KAAK,QAAQ,UAAU;AAGzC,eAAsB,QAAQ;AAC1B,QAAM,OAAO,MAAM,W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;AAAA,MACA,cAAc;AAAA,QACV,SAAS,CAAC,mBAAmB;AAAA,MACjC;AAAA,IACJ,CAAC;AAED,YAAQ,IAAI,+BAA+B;AAAA,EAC/C,SAAS,OAAO;AACZ,YAAQ,MAAM,iBAAiB,KAAK;AAAA,EACxC;AACJ;;;AChGA,OAAOA,WAAU;AACjB,SAAQ,iBAAAC,sBAAoB;AAC5B,SAAQ,cAAc,8BAA6B;AAEnD,SAAQ,eAAAC,oBAAkB;AAG1B,SAAQ,eAAeC,8BAA4B;AACnD,SAAQ,cAAAC,mBAAiB;AAEzB,IAAMC,cAAaJ,eAAc,YAAY,GAAG;AAChD,IAAMK,aAAYN,MAAK,QAAQK,WAAU;AAEzC,IAAM,OAAO,QAAQ,IAAI,WAAW,SAAS,QAAQ,IAAI,QAAQ,IAAI;;;ACbrE,OAAOE,SAAQ;AACf,OAAO,QAAQ;AACf,OAAOC,WAAU;AACjB,OAAO,SAAS;AAGhB,SAAQ,4BAA2B;AACnC,OAAO,iBAAiB;AACxB,OAAO,aAAa;AACpB,OAAO,YAAY;AACnB,OAAO,sBAAsB;AAC7B,OAAO,aAAa;;;ACRpB,MAAM,MAAM;","names":["path","fileURLToPath","reactRouter","xydContentVitePlugins","pluginZero","__filename","__dirname","fs","path"]}
|
package/dist/dev.js
CHANGED
|
@@ -5,7 +5,7 @@ import { fileURLToPath } from "node:url";
|
|
|
5
5
|
import { build as viteBuild } from "vite";
|
|
6
6
|
import tsconfigPaths from "vite-tsconfig-paths";
|
|
7
7
|
import { reactRouter } from "@xyd-js/react-router-dev/vite";
|
|
8
|
-
import { vitePlugins as xydContentVitePlugins } from "@xyd-js/content
|
|
8
|
+
import { vitePlugins as xydContentVitePlugins } from "@xyd-js/content";
|
|
9
9
|
import { pluginZero } from "@xyd-js/plugin-zero";
|
|
10
10
|
var __filename = fileURLToPath(import.meta.url);
|
|
11
11
|
var __dirname = path.dirname(__filename);
|
|
@@ -15,19 +15,23 @@ import path2 from "node:path";
|
|
|
15
15
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
16
16
|
import { createServer, searchForWorkspaceRoot } from "vite";
|
|
17
17
|
import { reactRouter as reactRouter2 } from "@xyd-js/react-router-dev/vite";
|
|
18
|
-
import { vitePlugins as xydContentVitePlugins2 } from "@xyd-js/content
|
|
18
|
+
import { vitePlugins as xydContentVitePlugins2 } from "@xyd-js/content";
|
|
19
19
|
import { pluginZero as pluginZero2 } from "@xyd-js/plugin-zero";
|
|
20
20
|
var __filename2 = fileURLToPath2(import.meta.url);
|
|
21
21
|
var __dirname2 = path2.dirname(__filename2);
|
|
22
22
|
var port = process.env.XYD_PORT ? parseInt(process.env.XYD_PORT) : 5175;
|
|
23
23
|
async function dev() {
|
|
24
|
-
const
|
|
25
|
-
if (!
|
|
24
|
+
const resp = await pluginZero2();
|
|
25
|
+
if (!resp) {
|
|
26
26
|
throw new Error("PluginZero not found");
|
|
27
27
|
}
|
|
28
28
|
const allowCwd = searchForWorkspaceRoot(process.cwd());
|
|
29
29
|
const preview = await createServer({
|
|
30
|
-
|
|
30
|
+
// any valid user config options, plus `mode` and `configFile`
|
|
31
|
+
// configFile: path.join(__dirname, "../src/vite/empty-config.ts"), // TODO: bundler??
|
|
32
|
+
// configFile: path.join(__dirname, "../"), // TODO: bundler??
|
|
33
|
+
// root: path.join(__dirname, "../"), // TODO: bundler?
|
|
34
|
+
root: process.env.XYD_DOCUMAN_HOST || path2.join(__dirname2, "../host"),
|
|
31
35
|
// TODO: bundler?
|
|
32
36
|
server: {
|
|
33
37
|
port,
|
|
@@ -47,10 +51,16 @@ async function dev() {
|
|
|
47
51
|
},
|
|
48
52
|
ssr: {
|
|
49
53
|
external: ["@xyd-js/uniform", "@xyd-js/uniform/content", "@xyd-js/plugin-zero"]
|
|
54
|
+
// noExternal: [
|
|
55
|
+
// "@xyd-js/uniform",
|
|
56
|
+
// "@xyd-js/uniform/content",
|
|
57
|
+
// "@xyd-js/plugin-zero"
|
|
58
|
+
// ],
|
|
50
59
|
},
|
|
51
60
|
optimizeDeps: {
|
|
52
61
|
include: ["react/jsx-runtime"]
|
|
53
62
|
},
|
|
63
|
+
// @ts-ignore
|
|
54
64
|
plugins: [
|
|
55
65
|
// TODO: fix plugin ts
|
|
56
66
|
...xydContentVitePlugins2({
|
|
@@ -59,9 +69,9 @@ async function dev() {
|
|
|
59
69
|
}
|
|
60
70
|
}),
|
|
61
71
|
reactRouter2({
|
|
62
|
-
routes:
|
|
72
|
+
routes: resp.routes
|
|
63
73
|
}),
|
|
64
|
-
...
|
|
74
|
+
...resp.vitePlugins
|
|
65
75
|
]
|
|
66
76
|
});
|
|
67
77
|
await preview.listen(port);
|
package/dist/dev.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/run/build.ts","../src/run/dev.ts","../src/run/serve.ts","../src/commands/dev.ts"],"sourcesContent":["import path from \"node:path\";\nimport fs from \"node:fs\";\nimport {fileURLToPath} from \"node:url\";\nimport {execSync} from 'child_process';\n\nimport {build as viteBuild} from 'vite';\nimport tsconfigPaths from \"vite-tsconfig-paths\";\n\nimport {reactRouter} from \"@xyd-js/react-router-dev/vite\";\n\nimport {vitePlugins as xydContentVitePlugins} from \"@xyd-js/content/vite\"\nimport {pluginZero} from \"@xyd-js/plugin-zero\";\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = path.dirname(__filename);\n\n// Define the main function to run the builds\nexport async function build() {\n const resp = await pluginZero()\n if (!resp) {\n throw new Error(\"PluginZero not found\")\n }\n\n const buildDir = path.join(process.cwd(), \".xyd/build\");\n\n {\n // TODO: probably we should have better mechanism - maybe bundle?\n\n const packageJsonPath = path.join(buildDir, 'package.json');\n\n const packageJsonContent = {\n type: \"module\",\n scripts: {},\n dependencies: { // TODO: better\n // \"@xyd-js/content\": \"latest\",\n // \"@xyd-js/components\": \"latest\",\n // \"@xyd-js/framework\": \"latest\",\n // \"@xyd-js/theme-poetry\": \"latest\",\n\n \"@xyd-js/content\": \"workspace:*\",\n \"@xyd-js/components\": \"workspace:*\",\n \"@xyd-js/framework\": \"workspace:*\",\n \"@xyd-js/theme-poetry\": \"workspace:*\",\n\n \"@react-router/node\": \"^7.1.1\",\n \"isbot\": \"^5\"\n },\n devDependencies: {}\n };\n\n // Ensure the build directory exists\n if (!fs.existsSync(buildDir)) {\n fs.mkdirSync(buildDir, {recursive: true});\n }\n\n // Write the package.json file\n fs.writeFileSync(packageJsonPath, JSON.stringify(packageJsonContent, null, 2), 'utf8');\n\n // Install packages inside buildDir\n // execSync('npm install', {cwd: buildDir, stdio: 'inherit'});\n\n execSync('pnpm i', {cwd: buildDir, stdio: 'inherit'});\n }\n\n try {\n // Build the client-side bundle\n await viteBuild({\n root: process.env.XYD_CLI ? __dirname : process.env.XYD_DOCUMAN_HOST || path.join(__dirname, \"../host\"),\n plugins: [\n ...(xydContentVitePlugins({\n toc: {\n minDepth: 2,\n }\n }) as Plugin[]),\n reactRouter({\n outDir: buildDir,\n routes: resp.routes\n }),\n tsconfigPaths(),\n ...resp.vitePlugins\n ],\n optimizeDeps: {\n include: [\"react/jsx-runtime\"],\n },\n });\n\n // Build the SSR bundle\n await viteBuild({\n root: process.env.XYD_CLI ? __dirname : process.env.XYD_DOCUMAN_HOST || path.join(__dirname, \"../host\"),\n build: {\n ssr: true,\n },\n plugins: [\n ...(xydContentVitePlugins({\n toc: {\n minDepth: 2,\n }\n }) as Plugin[]),\n reactRouter({\n outDir: buildDir,\n routes: resp.routes\n }),\n tsconfigPaths(),\n ...resp.vitePlugins\n ],\n optimizeDeps: {\n include: [\"react/jsx-runtime\"],\n },\n });\n\n console.log('Build completed successfully.'); // TODO: better message\n } catch (error) {\n console.error('Build failed:', error); // TODO: better message\n }\n}\n\n","import path from \"node:path\";\nimport {fileURLToPath} from \"node:url\";\nimport {createServer, searchForWorkspaceRoot} from \"vite\";\n\nimport {reactRouter} from \"@xyd-js/react-router-dev/vite\";\n\nimport {vitePlugins as xydContentVitePlugins} from \"@xyd-js/content/vite\";\nimport {pluginZero} from \"@xyd-js/plugin-zero\";\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = path.dirname(__filename);\n\nconst port = process.env.XYD_PORT ? parseInt(process.env.XYD_PORT) : 5175;\n\nexport async function dev() {\n const respPluginZero = await pluginZero()\n if (!respPluginZero) {\n throw new Error(\"PluginZero not found\")\n }\n\n const allowCwd = searchForWorkspaceRoot(process.cwd())\n\n const preview = await createServer({\n root: process.env.XYD_CLI ? __dirname : process.env.XYD_DOCUMAN_HOST || path.join(__dirname, \"../host\"), // TODO: bundler?\n server: {\n port: port,\n fs: {\n allow: [\n allowCwd,\n process.env.XYD_CLI ? path.join(__dirname, \"../../\") : \"\",\n // path.join(__dirname, \"../node_modules\") // Ensure node_modules from xyd-documan is included\n ]\n }\n },\n build: {\n rollupOptions: {\n // Exclude package `B` from the client-side bundle\n external: [\"@xyd-js/uniform\", \"@xyd-js/uniform/content\", \"@xyd-js/plugin-zero\"],\n },\n },\n ssr: {\n external: [\"@xyd-js/uniform\", \"@xyd-js/uniform/content\", \"@xyd-js/plugin-zero\"],\n },\n optimizeDeps: {\n include: [\"react/jsx-runtime\"],\n },\n plugins: [ // TODO: fix plugin ts\n ...(xydContentVitePlugins({\n toc: {\n minDepth: 2,\n }\n }) as Plugin[]),\n reactRouter({\n routes: respPluginZero.routes\n }),\n ...respPluginZero.vitePlugins\n ],\n });\n\n await preview.listen(port);\n\n preview.printUrls();\n preview.bindCLIShortcuts({print: true});\n\n}","import fs from \"node:fs\";\nimport os from \"node:os\";\nimport path from \"node:path\";\nimport url from \"node:url\";\n\nimport type {ServerBuild} from \"react-router\";\nimport {createRequestHandler} from \"@react-router/express\";\nimport compression from \"compression\";\nimport express from \"express\";\nimport morgan from \"morgan\";\nimport sourceMapSupport from \"source-map-support\";\nimport getPort from \"get-port\";\n\nfunction parseNumber(raw?: string) {\n if (raw === undefined) return undefined;\n let maybe = Number(raw);\n if (Number.isNaN(maybe)) return undefined;\n return maybe;\n}\n\nexport async function serve() {\n process.env.NODE_ENV = process.env.NODE_ENV ?? \"production\";\n\n sourceMapSupport.install({\n retrieveSourceMap: function (source) {\n let match = source.startsWith(\"file://\");\n if (match) {\n let filePath = url.fileURLToPath(source);\n let sourceMapPath = `${filePath}.map`;\n if (fs.existsSync(sourceMapPath)) {\n return {\n url: source,\n map: fs.readFileSync(sourceMapPath, \"utf8\"),\n };\n }\n }\n return null;\n },\n });\n\n let port = parseNumber(process.env.PORT) ?? (await getPort({port: 3000}));\n\n let buildPathArg = path.join(process.cwd(), \".xyd/build/server/index.js\")\n\n if (!buildPathArg) {\n console.error(`\n Usage: react-router-serve <server-build-path> - e.g. react-router-serve build/server/index.js`);\n process.exit(1);\n }\n\n let buildPath = path.resolve(buildPathArg);\n\n let build: ServerBuild = await import(url.pathToFileURL(buildPath).href);\n\n let onListen = () => {\n let address =\n process.env.HOST ||\n Object.values(os.networkInterfaces())\n .flat()\n .find((ip) => String(ip?.family).includes(\"4\") && !ip?.internal)\n ?.address;\n\n if (!address) {\n console.log(`[xyd-serve] http://localhost:${port}`);\n } else {\n console.log(\n `[xyd-serve] http://localhost:${port} (http://${address}:${port})`\n );\n }\n };\n\n build = {\n ...build,\n assetsBuildDirectory: path.join(process.cwd(), \".xyd/build/client\")\n }\n\n let app = express();\n app.disable(\"x-powered-by\");\n app.use(compression());\n app.use(\n path.posix.join(build.publicPath, \"assets\"),\n express.static(path.join(build.assetsBuildDirectory, \"assets\"), {\n immutable: true,\n maxAge: \"1y\",\n })\n );\n app.use(build.publicPath, express.static(build.assetsBuildDirectory));\n app.use(express.static(\"public\", {maxAge: \"1h\"}));\n app.use(morgan(\"tiny\"));\n\n app.all(\n \"*\",\n createRequestHandler({\n build,\n mode: process.env.NODE_ENV,\n })\n );\n\n let server = process.env.HOST\n ? app.listen(port, process.env.HOST, onListen)\n : app.listen(port, onListen);\n\n [\"SIGTERM\", \"SIGINT\"].forEach((signal) => {\n process.once(signal, () => server?.close(console.error));\n });\n}\n","import {dev} from \"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AAAA,MACD,UAAU,CAAC,mBAAmB,2BAA2B,qBAAqB;AAAA,IAClF;AAAA,IACA,cAAc;AAAA,MACV,SAAS,CAAC,mBAAmB;AAAA,IACjC;AAAA,IACA,SAAS;AAAA;AAAA,MACL,GAAIH,uBAAsB;AAAA,QACtB,KAAK;AAAA,UACD,UAAU;AAAA,QACd;AAAA,MACJ,CAAC;AAAA,MACDD,aAAY;AAAA,QACR,QAAQ,eAAe;AAAA,MAC3B,CAAC;AAAA,MACD,GAAG,eAAe;AAAA,IACtB;AAAA,EACJ,CAAC;AAED,QAAM,QAAQ,OAAO,IAAI;AAEzB,UAAQ,UAAU;AAClB,UAAQ,iBAAiB,EAAC,OAAO,KAAI,CAAC;AAE1C;;;AChEA,OAAOK,SAAQ;AACf,OAAO,QAAQ;AACf,OAAOC,WAAU;AACjB,OAAO,SAAS;AAGhB,SAAQ,4BAA2B;AACnC,OAAO,iBAAiB;AACxB,OAAO,aAAa;AACpB,OAAO,YAAY;AACnB,OAAO,sBAAsB;AAC7B,OAAO,aAAa;;;ACRpB,MAAM,IAAI;","names":["path","fileURLToPath","reactRouter","xydContentVitePlugins","pluginZero","__filename","__dirname","fs","path"]}
|
|
1
|
+
{"version":3,"sources":["../src/run/build.ts","../src/run/dev.ts","../src/run/serve.ts","../src/commands/dev.ts"],"sourcesContent":["import path from \"node:path\";\nimport fs from \"node:fs\";\nimport {fileURLToPath} from \"node:url\";\n\nimport {build as viteBuild} from 'vite';\nimport tsconfigPaths from \"vite-tsconfig-paths\";\n\nimport {reactRouter} from \"@xyd-js/react-router-dev/vite\";\n// import { reactRouter } from \"@react-router/dev/vite\";\n\nimport {vitePlugins as xydContentVitePlugins} from \"@xyd-js/content\"\nimport {pluginZero} from \"@xyd-js/plugin-zero\";\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = path.dirname(__filename);\n\n// Define the main function to run the builds\nexport async function build() {\n const resp = await pluginZero()\n if (!resp) {\n throw new Error(\"PluginZero not found\")\n }\n\n const buildDir = path.join(process.cwd(), \".xyd/build\");\n\n {\n const packageJsonPath = path.join(buildDir, 'package.json');\n\n const packageJsonContent = {\n type: \"module\",\n scripts: {},\n dependencies: {},\n devDependencies: {}\n };\n\n // Ensure the build directory exists\n if (!fs.existsSync(buildDir)) {\n fs.mkdirSync(buildDir, {recursive: true});\n }\n\n // Write the package.json file\n fs.writeFileSync(packageJsonPath, JSON.stringify(packageJsonContent, null, 2), 'utf8');\n }\n\n try {\n // Build the client-side bundle\n await viteBuild({\n root: path.join(__dirname, \"../host\"),\n // @ts-ignore\n plugins: [\n ...(xydContentVitePlugins({\n toc: {\n minDepth: 2,\n }\n }) as Plugin[]),\n reactRouter({\n outDir: buildDir,\n routes: resp.routes\n }),\n tsconfigPaths(),\n ...resp.vitePlugins\n ],\n optimizeDeps: {\n include: [\"react/jsx-runtime\"],\n },\n });\n\n // Build the SSR bundle\n await viteBuild({\n root: path.join(__dirname, \"../host\"),\n build: {\n ssr: true,\n },\n // @ts-ignore\n plugins: [\n ...(xydContentVitePlugins({\n toc: {\n minDepth: 2,\n }\n }) as Plugin[]),\n reactRouter({\n outDir: buildDir,\n routes: resp.routes\n }),\n tsconfigPaths(),\n ...resp.vitePlugins\n ],\n optimizeDeps: {\n include: [\"react/jsx-runtime\"],\n },\n });\n\n console.log('Build completed successfully.'); // TODO: better message\n } catch (error) {\n console.error('Build failed:', error); // TODO: better message\n }\n}\n\n","import path from \"node:path\";\nimport {fileURLToPath} from \"node:url\";\nimport {createServer, searchForWorkspaceRoot} from \"vite\";\n\nimport {reactRouter} from \"@xyd-js/react-router-dev/vite\";\n// import { reactRouter } from \"@react-router/dev/vite\";\n\nimport {vitePlugins as xydContentVitePlugins} from \"@xyd-js/content\";\nimport {pluginZero} from \"@xyd-js/plugin-zero\";\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = path.dirname(__filename);\n\nconst port = process.env.XYD_PORT ? parseInt(process.env.XYD_PORT) : 5175;\n\nexport async function dev() {\n const resp = await pluginZero()\n if (!resp) {\n throw new Error(\"PluginZero not found\")\n }\n\n const allowCwd = searchForWorkspaceRoot(process.cwd())\n\n const preview = await createServer({\n // any valid user config options, plus `mode` and `configFile`\n // configFile: path.join(__dirname, \"../src/vite/empty-config.ts\"), // TODO: bundler??\n // configFile: path.join(__dirname, \"../\"), // TODO: bundler??\n // root: path.join(__dirname, \"../\"), // TODO: bundler?\n root: process.env.XYD_DOCUMAN_HOST || path.join(__dirname, \"../host\"), // TODO: bundler?\n server: {\n port: port,\n fs: {\n allow: [\n allowCwd,\n process.env.XYD_CLI ? path.join(__dirname, \"../../\") : \"\",\n // path.join(__dirname, \"../node_modules\") // Ensure node_modules from xyd-documan is included\n ]\n }\n },\n build: {\n rollupOptions: {\n // Exclude package `B` from the client-side bundle\n external: [\"@xyd-js/uniform\", \"@xyd-js/uniform/content\", \"@xyd-js/plugin-zero\"],\n },\n },\n ssr: {\n external: [\"@xyd-js/uniform\", \"@xyd-js/uniform/content\", \"@xyd-js/plugin-zero\"],\n // noExternal: [\n // \"@xyd-js/uniform\",\n // \"@xyd-js/uniform/content\",\n // \"@xyd-js/plugin-zero\"\n // ],\n },\n optimizeDeps: {\n include: [\"react/jsx-runtime\"],\n },\n // @ts-ignore\n plugins: [ // TODO: fix plugin ts\n ...(xydContentVitePlugins({\n toc: {\n minDepth: 2,\n }\n }) as Plugin[]),\n reactRouter({\n routes: resp.routes\n }),\n ...resp.vitePlugins\n ],\n });\n\n await preview.listen(port);\n\n preview.printUrls();\n preview.bindCLIShortcuts({print: true});\n\n}","import fs from \"node:fs\";\nimport os from \"node:os\";\nimport path from \"node:path\";\nimport url from \"node:url\";\n\nimport type {ServerBuild} from \"react-router\";\nimport {createRequestHandler} from \"@react-router/express\";\nimport compression from \"compression\";\nimport express from \"express\";\nimport morgan from \"morgan\";\nimport sourceMapSupport from \"source-map-support\";\nimport getPort from \"get-port\";\n\nfunction parseNumber(raw?: string) {\n if (raw === undefined) return undefined;\n let maybe = Number(raw);\n if (Number.isNaN(maybe)) return undefined;\n return maybe;\n}\n\nexport async function serve() {\n process.env.NODE_ENV = process.env.NODE_ENV ?? \"production\";\n\n sourceMapSupport.install({\n retrieveSourceMap: function (source) {\n let match = source.startsWith(\"file://\");\n if (match) {\n let filePath = url.fileURLToPath(source);\n let sourceMapPath = `${filePath}.map`;\n if (fs.existsSync(sourceMapPath)) {\n return {\n url: source,\n map: fs.readFileSync(sourceMapPath, \"utf8\"),\n };\n }\n }\n return null;\n },\n });\n\n let port = parseNumber(process.env.PORT) ?? (await getPort({port: 3000}));\n\n let buildPathArg = path.join(process.cwd(), \".xyd/build/server/index.js\")\n\n if (!buildPathArg) {\n console.error(`\n Usage: react-router-serve <server-build-path> - e.g. react-router-serve build/server/index.js`);\n process.exit(1);\n }\n\n let buildPath = path.resolve(buildPathArg);\n\n let build: ServerBuild = await import(url.pathToFileURL(buildPath).href);\n\n let onListen = () => {\n let address =\n process.env.HOST ||\n Object.values(os.networkInterfaces())\n .flat()\n .find((ip) => String(ip?.family).includes(\"4\") && !ip?.internal)\n ?.address;\n\n if (!address) {\n console.log(`[xyd-serve] http://localhost:${port}`);\n } else {\n console.log(\n `[xyd-serve] http://localhost:${port} (http://${address}:${port})`\n );\n }\n };\n\n build = {\n ...build,\n assetsBuildDirectory: path.join(process.cwd(), \".xyd/build/client\")\n }\n\n let app = express();\n app.disable(\"x-powered-by\");\n app.use(compression());\n app.use(\n path.posix.join(build.publicPath, \"assets\"),\n express.static(path.join(build.assetsBuildDirectory, \"assets\"), {\n immutable: true,\n maxAge: \"1y\",\n })\n );\n app.use(build.publicPath, express.static(build.assetsBuildDirectory));\n app.use(express.static(\"public\", {maxAge: \"1h\"}));\n app.use(morgan(\"tiny\"));\n\n app.all(\n \"*\",\n createRequestHandler({\n build,\n mode: process.env.NODE_ENV,\n })\n );\n\n let server = process.env.HOST\n ? app.listen(port, process.env.HOST, onListen)\n : app.listen(port, onListen);\n\n [\"SIGTERM\", \"SIGINT\"].forEach((signal) => {\n process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MAClF;AAAA,IACJ;AAAA,IACA,KAAK;AAAA,MACD,UAAU,CAAC,mBAAmB,2BAA2B,qBAAqB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAMlF;AAAA,IACA,cAAc;AAAA,MACV,SAAS,CAAC,mBAAmB;AAAA,IACjC;AAAA;AAAA,IAEA,SAAS;AAAA;AAAA,MACL,GAAIH,uBAAsB;AAAA,QACtB,KAAK;AAAA,UACD,UAAU;AAAA,QACd;AAAA,MACJ,CAAC;AAAA,MACDD,aAAY;AAAA,QACR,QAAQ,KAAK;AAAA,MACjB,CAAC;AAAA,MACD,GAAG,KAAK;AAAA,IACZ;AAAA,EACJ,CAAC;AAED,QAAM,QAAQ,OAAO,IAAI;AAEzB,UAAQ,UAAU;AAClB,UAAQ,iBAAiB,EAAC,OAAO,KAAI,CAAC;AAE1C;;;AC3EA,OAAOK,SAAQ;AACf,OAAO,QAAQ;AACf,OAAOC,WAAU;AACjB,OAAO,SAAS;AAGhB,SAAQ,4BAA2B;AACnC,OAAO,iBAAiB;AACxB,OAAO,aAAa;AACpB,OAAO,YAAY;AACnB,OAAO,sBAAsB;AAC7B,OAAO,aAAa;;;ACRpB,MAAM,IAAI;","names":["path","fileURLToPath","reactRouter","xydContentVitePlugins","pluginZero","__filename","__dirname","fs","path"]}
|
package/dist/index.js
CHANGED
|
@@ -2,11 +2,10 @@
|
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import fs from "node:fs";
|
|
4
4
|
import { fileURLToPath } from "node:url";
|
|
5
|
-
import { execSync } from "child_process";
|
|
6
5
|
import { build as viteBuild } from "vite";
|
|
7
6
|
import tsconfigPaths from "vite-tsconfig-paths";
|
|
8
7
|
import { reactRouter } from "@xyd-js/react-router-dev/vite";
|
|
9
|
-
import { vitePlugins as xydContentVitePlugins } from "@xyd-js/content
|
|
8
|
+
import { vitePlugins as xydContentVitePlugins } from "@xyd-js/content";
|
|
10
9
|
import { pluginZero } from "@xyd-js/plugin-zero";
|
|
11
10
|
var __filename = fileURLToPath(import.meta.url);
|
|
12
11
|
var __dirname = path.dirname(__filename);
|
|
@@ -21,30 +20,18 @@ async function build() {
|
|
|
21
20
|
const packageJsonContent = {
|
|
22
21
|
type: "module",
|
|
23
22
|
scripts: {},
|
|
24
|
-
dependencies: {
|
|
25
|
-
// TODO: better
|
|
26
|
-
// "@xyd-js/content": "latest",
|
|
27
|
-
// "@xyd-js/components": "latest",
|
|
28
|
-
// "@xyd-js/framework": "latest",
|
|
29
|
-
// "@xyd-js/theme-poetry": "latest",
|
|
30
|
-
"@xyd-js/content": "workspace:*",
|
|
31
|
-
"@xyd-js/components": "workspace:*",
|
|
32
|
-
"@xyd-js/framework": "workspace:*",
|
|
33
|
-
"@xyd-js/theme-poetry": "workspace:*",
|
|
34
|
-
"@react-router/node": "^7.1.1",
|
|
35
|
-
"isbot": "^5"
|
|
36
|
-
},
|
|
23
|
+
dependencies: {},
|
|
37
24
|
devDependencies: {}
|
|
38
25
|
};
|
|
39
26
|
if (!fs.existsSync(buildDir)) {
|
|
40
27
|
fs.mkdirSync(buildDir, { recursive: true });
|
|
41
28
|
}
|
|
42
29
|
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJsonContent, null, 2), "utf8");
|
|
43
|
-
execSync("pnpm i", { cwd: buildDir, stdio: "inherit" });
|
|
44
30
|
}
|
|
45
31
|
try {
|
|
46
32
|
await viteBuild({
|
|
47
|
-
root:
|
|
33
|
+
root: path.join(__dirname, "../host"),
|
|
34
|
+
// @ts-ignore
|
|
48
35
|
plugins: [
|
|
49
36
|
...xydContentVitePlugins({
|
|
50
37
|
toc: {
|
|
@@ -63,10 +50,11 @@ async function build() {
|
|
|
63
50
|
}
|
|
64
51
|
});
|
|
65
52
|
await viteBuild({
|
|
66
|
-
root:
|
|
53
|
+
root: path.join(__dirname, "../host"),
|
|
67
54
|
build: {
|
|
68
55
|
ssr: true
|
|
69
56
|
},
|
|
57
|
+
// @ts-ignore
|
|
70
58
|
plugins: [
|
|
71
59
|
...xydContentVitePlugins({
|
|
72
60
|
toc: {
|
|
@@ -95,19 +83,23 @@ import path2 from "node:path";
|
|
|
95
83
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
96
84
|
import { createServer, searchForWorkspaceRoot } from "vite";
|
|
97
85
|
import { reactRouter as reactRouter2 } from "@xyd-js/react-router-dev/vite";
|
|
98
|
-
import { vitePlugins as xydContentVitePlugins2 } from "@xyd-js/content
|
|
86
|
+
import { vitePlugins as xydContentVitePlugins2 } from "@xyd-js/content";
|
|
99
87
|
import { pluginZero as pluginZero2 } from "@xyd-js/plugin-zero";
|
|
100
88
|
var __filename2 = fileURLToPath2(import.meta.url);
|
|
101
89
|
var __dirname2 = path2.dirname(__filename2);
|
|
102
90
|
var port = process.env.XYD_PORT ? parseInt(process.env.XYD_PORT) : 5175;
|
|
103
91
|
async function dev() {
|
|
104
|
-
const
|
|
105
|
-
if (!
|
|
92
|
+
const resp = await pluginZero2();
|
|
93
|
+
if (!resp) {
|
|
106
94
|
throw new Error("PluginZero not found");
|
|
107
95
|
}
|
|
108
96
|
const allowCwd = searchForWorkspaceRoot(process.cwd());
|
|
109
97
|
const preview = await createServer({
|
|
110
|
-
|
|
98
|
+
// any valid user config options, plus `mode` and `configFile`
|
|
99
|
+
// configFile: path.join(__dirname, "../src/vite/empty-config.ts"), // TODO: bundler??
|
|
100
|
+
// configFile: path.join(__dirname, "../"), // TODO: bundler??
|
|
101
|
+
// root: path.join(__dirname, "../"), // TODO: bundler?
|
|
102
|
+
root: process.env.XYD_DOCUMAN_HOST || path2.join(__dirname2, "../host"),
|
|
111
103
|
// TODO: bundler?
|
|
112
104
|
server: {
|
|
113
105
|
port,
|
|
@@ -127,10 +119,16 @@ async function dev() {
|
|
|
127
119
|
},
|
|
128
120
|
ssr: {
|
|
129
121
|
external: ["@xyd-js/uniform", "@xyd-js/uniform/content", "@xyd-js/plugin-zero"]
|
|
122
|
+
// noExternal: [
|
|
123
|
+
// "@xyd-js/uniform",
|
|
124
|
+
// "@xyd-js/uniform/content",
|
|
125
|
+
// "@xyd-js/plugin-zero"
|
|
126
|
+
// ],
|
|
130
127
|
},
|
|
131
128
|
optimizeDeps: {
|
|
132
129
|
include: ["react/jsx-runtime"]
|
|
133
130
|
},
|
|
131
|
+
// @ts-ignore
|
|
134
132
|
plugins: [
|
|
135
133
|
// TODO: fix plugin ts
|
|
136
134
|
...xydContentVitePlugins2({
|
|
@@ -139,9 +137,9 @@ async function dev() {
|
|
|
139
137
|
}
|
|
140
138
|
}),
|
|
141
139
|
reactRouter2({
|
|
142
|
-
routes:
|
|
140
|
+
routes: resp.routes
|
|
143
141
|
}),
|
|
144
|
-
...
|
|
142
|
+
...resp.vitePlugins
|
|
145
143
|
]
|
|
146
144
|
});
|
|
147
145
|
await preview.listen(port);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/run/build.ts","../src/run/dev.ts","../src/run/serve.ts"],"sourcesContent":["import path from \"node:path\";\nimport fs from \"node:fs\";\nimport {fileURLToPath} from \"node:url\";\nimport {execSync} from 'child_process';\n\nimport {build as viteBuild} from 'vite';\nimport tsconfigPaths from \"vite-tsconfig-paths\";\n\nimport {reactRouter} from \"@xyd-js/react-router-dev/vite\";\n\nimport {vitePlugins as xydContentVitePlugins} from \"@xyd-js/content/vite\"\nimport {pluginZero} from \"@xyd-js/plugin-zero\";\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = path.dirname(__filename);\n\n// Define the main function to run the builds\nexport async function build() {\n const resp = await pluginZero()\n if (!resp) {\n throw new Error(\"PluginZero not found\")\n }\n\n const buildDir = path.join(process.cwd(), \".xyd/build\");\n\n {\n // TODO: probably we should have better mechanism - maybe bundle?\n\n const packageJsonPath = path.join(buildDir, 'package.json');\n\n const packageJsonContent = {\n type: \"module\",\n scripts: {},\n dependencies: { // TODO: better\n // \"@xyd-js/content\": \"latest\",\n // \"@xyd-js/components\": \"latest\",\n // \"@xyd-js/framework\": \"latest\",\n // \"@xyd-js/theme-poetry\": \"latest\",\n\n \"@xyd-js/content\": \"workspace:*\",\n \"@xyd-js/components\": \"workspace:*\",\n \"@xyd-js/framework\": \"workspace:*\",\n \"@xyd-js/theme-poetry\": \"workspace:*\",\n\n \"@react-router/node\": \"^7.1.1\",\n \"isbot\": \"^5\"\n },\n devDependencies: {}\n };\n\n // Ensure the build directory exists\n if (!fs.existsSync(buildDir)) {\n fs.mkdirSync(buildDir, {recursive: true});\n }\n\n // Write the package.json file\n fs.writeFileSync(packageJsonPath, JSON.stringify(packageJsonContent, null, 2), 'utf8');\n\n // Install packages inside buildDir\n // execSync('npm install', {cwd: buildDir, stdio: 'inherit'});\n\n execSync('pnpm i', {cwd: buildDir, stdio: 'inherit'});\n }\n\n try {\n // Build the client-side bundle\n await viteBuild({\n root: process.env.XYD_CLI ? __dirname : process.env.XYD_DOCUMAN_HOST || path.join(__dirname, \"../host\"),\n plugins: [\n ...(xydContentVitePlugins({\n toc: {\n minDepth: 2,\n }\n }) as Plugin[]),\n reactRouter({\n outDir: buildDir,\n routes: resp.routes\n }),\n tsconfigPaths(),\n ...resp.vitePlugins\n ],\n optimizeDeps: {\n include: [\"react/jsx-runtime\"],\n },\n });\n\n // Build the SSR bundle\n await viteBuild({\n root: process.env.XYD_CLI ? __dirname : process.env.XYD_DOCUMAN_HOST || path.join(__dirname, \"../host\"),\n build: {\n ssr: true,\n },\n plugins: [\n ...(xydContentVitePlugins({\n toc: {\n minDepth: 2,\n }\n }) as Plugin[]),\n reactRouter({\n outDir: buildDir,\n routes: resp.routes\n }),\n tsconfigPaths(),\n ...resp.vitePlugins\n ],\n optimizeDeps: {\n include: [\"react/jsx-runtime\"],\n },\n });\n\n console.log('Build completed successfully.'); // TODO: better message\n } catch (error) {\n console.error('Build failed:', error); // TODO: better message\n }\n}\n\n","import path from \"node:path\";\nimport {fileURLToPath} from \"node:url\";\nimport {createServer, searchForWorkspaceRoot} from \"vite\";\n\nimport {reactRouter} from \"@xyd-js/react-router-dev/vite\";\n\nimport {vitePlugins as xydContentVitePlugins} from \"@xyd-js/content/vite\";\nimport {pluginZero} from \"@xyd-js/plugin-zero\";\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = path.dirname(__filename);\n\nconst port = process.env.XYD_PORT ? parseInt(process.env.XYD_PORT) : 5175;\n\nexport async function dev() {\n const respPluginZero = await pluginZero()\n if (!respPluginZero) {\n throw new Error(\"PluginZero not found\")\n }\n\n const allowCwd = searchForWorkspaceRoot(process.cwd())\n\n const preview = await createServer({\n root: process.env.XYD_CLI ? __dirname : process.env.XYD_DOCUMAN_HOST || path.join(__dirname, \"../host\"), // TODO: bundler?\n server: {\n port: port,\n fs: {\n allow: [\n allowCwd,\n process.env.XYD_CLI ? path.join(__dirname, \"../../\") : \"\",\n // path.join(__dirname, \"../node_modules\") // Ensure node_modules from xyd-documan is included\n ]\n }\n },\n build: {\n rollupOptions: {\n // Exclude package `B` from the client-side bundle\n external: [\"@xyd-js/uniform\", \"@xyd-js/uniform/content\", \"@xyd-js/plugin-zero\"],\n },\n },\n ssr: {\n external: [\"@xyd-js/uniform\", \"@xyd-js/uniform/content\", \"@xyd-js/plugin-zero\"],\n },\n optimizeDeps: {\n include: [\"react/jsx-runtime\"],\n },\n plugins: [ // TODO: fix plugin ts\n ...(xydContentVitePlugins({\n toc: {\n minDepth: 2,\n }\n }) as Plugin[]),\n reactRouter({\n routes: respPluginZero.routes\n }),\n ...respPluginZero.vitePlugins\n ],\n });\n\n await preview.listen(port);\n\n preview.printUrls();\n preview.bindCLIShortcuts({print: true});\n\n}","import fs from \"node:fs\";\nimport os from \"node:os\";\nimport path from \"node:path\";\nimport url from \"node:url\";\n\nimport type {ServerBuild} from \"react-router\";\nimport {createRequestHandler} from \"@react-router/express\";\nimport compression from \"compression\";\nimport express from \"express\";\nimport morgan from \"morgan\";\nimport sourceMapSupport from \"source-map-support\";\nimport getPort from \"get-port\";\n\nfunction parseNumber(raw?: string) {\n if (raw === undefined) return undefined;\n let maybe = Number(raw);\n if (Number.isNaN(maybe)) return undefined;\n return maybe;\n}\n\nexport async function serve() {\n process.env.NODE_ENV = process.env.NODE_ENV ?? \"production\";\n\n sourceMapSupport.install({\n retrieveSourceMap: function (source) {\n let match = source.startsWith(\"file://\");\n if (match) {\n let filePath = url.fileURLToPath(source);\n let sourceMapPath = `${filePath}.map`;\n if (fs.existsSync(sourceMapPath)) {\n return {\n url: source,\n map: fs.readFileSync(sourceMapPath, \"utf8\"),\n };\n }\n }\n return null;\n },\n });\n\n let port = parseNumber(process.env.PORT) ?? (await getPort({port: 3000}));\n\n let buildPathArg = path.join(process.cwd(), \".xyd/build/server/index.js\")\n\n if (!buildPathArg) {\n console.error(`\n Usage: react-router-serve <server-build-path> - e.g. react-router-serve build/server/index.js`);\n process.exit(1);\n }\n\n let buildPath = path.resolve(buildPathArg);\n\n let build: ServerBuild = await import(url.pathToFileURL(buildPath).href);\n\n let onListen = () => {\n let address =\n process.env.HOST ||\n Object.values(os.networkInterfaces())\n .flat()\n .find((ip) => String(ip?.family).includes(\"4\") && !ip?.internal)\n ?.address;\n\n if (!address) {\n console.log(`[xyd-serve] http://localhost:${port}`);\n } else {\n console.log(\n `[xyd-serve] http://localhost:${port} (http://${address}:${port})`\n );\n }\n };\n\n build = {\n ...build,\n assetsBuildDirectory: path.join(process.cwd(), \".xyd/build/client\")\n }\n\n let app = express();\n app.disable(\"x-powered-by\");\n app.use(compression());\n app.use(\n path.posix.join(build.publicPath, \"assets\"),\n express.static(path.join(build.assetsBuildDirectory, \"assets\"), {\n immutable: true,\n maxAge: \"1y\",\n })\n );\n app.use(build.publicPath, express.static(build.assetsBuildDirectory));\n app.use(express.static(\"public\", {maxAge: \"1h\"}));\n app.use(morgan(\"tiny\"));\n\n app.all(\n \"*\",\n createRequestHandler({\n build,\n mode: process.env.NODE_ENV,\n })\n );\n\n let server = process.env.HOST\n ? app.listen(port, process.env.HOST, onListen)\n : app.listen(port, onListen);\n\n [\"SIGTERM\", \"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,IAAIA,KAAI;AAAA,MACnE;AAAA,IACJ;AAAA,EACJ;AAEA,EAAAC,SAAQ;AAAA,IACJ,GAAGA;AAAA,IACH,sBAAsBF,MAAK,KAAK,QAAQ,IAAI,GAAG,mBAAmB;AAAA,EACtE;AAEA,MAAI,MAAM,QAAQ;AAClB,MAAI,QAAQ,cAAc;AAC1B,MAAI,IAAI,YAAY,CAAC;AACrB,MAAI;AAAA,IACAA,MAAK,MAAM,KAAKE,OAAM,YAAY,QAAQ;AAAA,IAC1C,QAAQ,OAAOF,MAAK,KAAKE,OAAM,sBAAsB,QAAQ,GAAG;AAAA,MAC5D,WAAW;AAAA,MACX,QAAQ;AAAA,IACZ,CAAC;AAAA,EACL;AACA,MAAI,IAAIA,OAAM,YAAY,QAAQ,OAAOA,OAAM,oBAAoB,CAAC;AACpE,MAAI,IAAI,QAAQ,OAAO,UAAU,EAAC,QAAQ,KAAI,CAAC,CAAC;AAChD,MAAI,IAAI,OAAO,MAAM,CAAC;AAEtB,MAAI;AAAA,IACA;AAAA,IACA,qBAAqB;AAAA,MACjB,OAAAA;AAAA,MACA,MAAM,QAAQ,IAAI;AAAA,IACtB,CAAC;AAAA,EACL;AAEA,MAAI,SAAS,QAAQ,IAAI,OACnB,IAAI,OAAOD,OAAM,QAAQ,IAAI,MAAM,QAAQ,IAC3C,IAAI,OAAOA,OAAM,QAAQ;AAE/B,GAAC,WAAW,QAAQ,EAAE,QAAQ,CAAC,WAAW;AACtC,YAAQ,KAAK,QAAQ,MAAM,QAAQ,MAAM,QAAQ,KAAK,CAAC;AAAA,EAC3D,CAAC;AACL;","names":["path","fileURLToPath","reactRouter","xydContentVitePlugins","pluginZero","__filename","__dirname","fs","path","port","build"]}
|
|
1
|
+
{"version":3,"sources":["../src/run/build.ts","../src/run/dev.ts","../src/run/serve.ts"],"sourcesContent":["import path from \"node:path\";\nimport fs from \"node:fs\";\nimport {fileURLToPath} from \"node:url\";\n\nimport {build as viteBuild} from 'vite';\nimport tsconfigPaths from \"vite-tsconfig-paths\";\n\nimport {reactRouter} from \"@xyd-js/react-router-dev/vite\";\n// import { reactRouter } from \"@react-router/dev/vite\";\n\nimport {vitePlugins as xydContentVitePlugins} from \"@xyd-js/content\"\nimport {pluginZero} from \"@xyd-js/plugin-zero\";\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = path.dirname(__filename);\n\n// Define the main function to run the builds\nexport async function build() {\n const resp = await pluginZero()\n if (!resp) {\n throw new Error(\"PluginZero not found\")\n }\n\n const buildDir = path.join(process.cwd(), \".xyd/build\");\n\n {\n const packageJsonPath = path.join(buildDir, 'package.json');\n\n const packageJsonContent = {\n type: \"module\",\n scripts: {},\n dependencies: {},\n devDependencies: {}\n };\n\n // Ensure the build directory exists\n if (!fs.existsSync(buildDir)) {\n fs.mkdirSync(buildDir, {recursive: true});\n }\n\n // Write the package.json file\n fs.writeFileSync(packageJsonPath, JSON.stringify(packageJsonContent, null, 2), 'utf8');\n }\n\n try {\n // Build the client-side bundle\n await viteBuild({\n root: path.join(__dirname, \"../host\"),\n // @ts-ignore\n plugins: [\n ...(xydContentVitePlugins({\n toc: {\n minDepth: 2,\n }\n }) as Plugin[]),\n reactRouter({\n outDir: buildDir,\n routes: resp.routes\n }),\n tsconfigPaths(),\n ...resp.vitePlugins\n ],\n optimizeDeps: {\n include: [\"react/jsx-runtime\"],\n },\n });\n\n // Build the SSR bundle\n await viteBuild({\n root: path.join(__dirname, \"../host\"),\n build: {\n ssr: true,\n },\n // @ts-ignore\n plugins: [\n ...(xydContentVitePlugins({\n toc: {\n minDepth: 2,\n }\n }) as Plugin[]),\n reactRouter({\n outDir: buildDir,\n routes: resp.routes\n }),\n tsconfigPaths(),\n ...resp.vitePlugins\n ],\n optimizeDeps: {\n include: [\"react/jsx-runtime\"],\n },\n });\n\n console.log('Build completed successfully.'); // TODO: better message\n } catch (error) {\n console.error('Build failed:', error); // TODO: better message\n }\n}\n\n","import path from \"node:path\";\nimport {fileURLToPath} from \"node:url\";\nimport {createServer, searchForWorkspaceRoot} from \"vite\";\n\nimport {reactRouter} from \"@xyd-js/react-router-dev/vite\";\n// import { reactRouter } from \"@react-router/dev/vite\";\n\nimport {vitePlugins as xydContentVitePlugins} from \"@xyd-js/content\";\nimport {pluginZero} from \"@xyd-js/plugin-zero\";\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = path.dirname(__filename);\n\nconst port = process.env.XYD_PORT ? parseInt(process.env.XYD_PORT) : 5175;\n\nexport async function dev() {\n const resp = await pluginZero()\n if (!resp) {\n throw new Error(\"PluginZero not found\")\n }\n\n const allowCwd = searchForWorkspaceRoot(process.cwd())\n\n const preview = await createServer({\n // any valid user config options, plus `mode` and `configFile`\n // configFile: path.join(__dirname, \"../src/vite/empty-config.ts\"), // TODO: bundler??\n // configFile: path.join(__dirname, \"../\"), // TODO: bundler??\n // root: path.join(__dirname, \"../\"), // TODO: bundler?\n root: process.env.XYD_DOCUMAN_HOST || path.join(__dirname, \"../host\"), // TODO: bundler?\n server: {\n port: port,\n fs: {\n allow: [\n allowCwd,\n process.env.XYD_CLI ? path.join(__dirname, \"../../\") : \"\",\n // path.join(__dirname, \"../node_modules\") // Ensure node_modules from xyd-documan is included\n ]\n }\n },\n build: {\n rollupOptions: {\n // Exclude package `B` from the client-side bundle\n external: [\"@xyd-js/uniform\", \"@xyd-js/uniform/content\", \"@xyd-js/plugin-zero\"],\n },\n },\n ssr: {\n external: [\"@xyd-js/uniform\", \"@xyd-js/uniform/content\", \"@xyd-js/plugin-zero\"],\n // noExternal: [\n // \"@xyd-js/uniform\",\n // \"@xyd-js/uniform/content\",\n // \"@xyd-js/plugin-zero\"\n // ],\n },\n optimizeDeps: {\n include: [\"react/jsx-runtime\"],\n },\n // @ts-ignore\n plugins: [ // TODO: fix plugin ts\n ...(xydContentVitePlugins({\n toc: {\n minDepth: 2,\n }\n }) as Plugin[]),\n reactRouter({\n routes: resp.routes\n }),\n ...resp.vitePlugins\n ],\n });\n\n await preview.listen(port);\n\n preview.printUrls();\n preview.bindCLIShortcuts({print: true});\n\n}","import fs from \"node:fs\";\nimport os from \"node:os\";\nimport path from \"node:path\";\nimport url from \"node:url\";\n\nimport type {ServerBuild} from \"react-router\";\nimport {createRequestHandler} from \"@react-router/express\";\nimport compression from \"compression\";\nimport express from \"express\";\nimport morgan from \"morgan\";\nimport sourceMapSupport from \"source-map-support\";\nimport getPort from \"get-port\";\n\nfunction parseNumber(raw?: string) {\n if (raw === undefined) return undefined;\n let maybe = Number(raw);\n if (Number.isNaN(maybe)) return undefined;\n return maybe;\n}\n\nexport async function serve() {\n process.env.NODE_ENV = process.env.NODE_ENV ?? \"production\";\n\n sourceMapSupport.install({\n retrieveSourceMap: function (source) {\n let match = source.startsWith(\"file://\");\n if (match) {\n let filePath = url.fileURLToPath(source);\n let sourceMapPath = `${filePath}.map`;\n if (fs.existsSync(sourceMapPath)) {\n return {\n url: source,\n map: fs.readFileSync(sourceMapPath, \"utf8\"),\n };\n }\n }\n return null;\n },\n });\n\n let port = parseNumber(process.env.PORT) ?? (await getPort({port: 3000}));\n\n let buildPathArg = path.join(process.cwd(), \".xyd/build/server/index.js\")\n\n if (!buildPathArg) {\n console.error(`\n Usage: react-router-serve <server-build-path> - e.g. react-router-serve build/server/index.js`);\n process.exit(1);\n }\n\n let buildPath = path.resolve(buildPathArg);\n\n let build: ServerBuild = await import(url.pathToFileURL(buildPath).href);\n\n let onListen = () => {\n let address =\n process.env.HOST ||\n Object.values(os.networkInterfaces())\n .flat()\n .find((ip) => String(ip?.family).includes(\"4\") && !ip?.internal)\n ?.address;\n\n if (!address) {\n console.log(`[xyd-serve] http://localhost:${port}`);\n } else {\n console.log(\n `[xyd-serve] http://localhost:${port} (http://${address}:${port})`\n );\n }\n };\n\n build = {\n ...build,\n assetsBuildDirectory: path.join(process.cwd(), \".xyd/build/client\")\n }\n\n let app = express();\n app.disable(\"x-powered-by\");\n app.use(compression());\n app.use(\n path.posix.join(build.publicPath, \"assets\"),\n express.static(path.join(build.assetsBuildDirectory, \"assets\"), {\n immutable: true,\n maxAge: \"1y\",\n })\n );\n app.use(build.publicPath, express.static(build.assetsBuildDirectory));\n app.use(express.static(\"public\", {maxAge: \"1h\"}));\n app.use(morgan(\"tiny\"));\n\n app.all(\n \"*\",\n createRequestHandler({\n build,\n mode: process.env.NODE_ENV,\n })\n );\n\n let server = process.env.HOST\n ? app.listen(port, process.env.HOST, onListen)\n : app.listen(port, onListen);\n\n [\"SIGTERM\", \"SIGINT\"].forEach((signal) => {\n process.once(signal, () => server?.close(console.error));\n });\n}\n"],"mappings":";AAAA,OAAO,UAAU;AACjB,OAAO,QAAQ;AACf,SAAQ,qBAAoB;AAE5B,SAAQ,SAAS,iBAAgB;AACjC,OAAO,mBAAmB;AAE1B,SAAQ,mBAAkB;AAG1B,SAAQ,eAAe,6BAA4B;AACnD,SAAQ,kBAAiB;AAEzB,IAAM,aAAa,cAAc,YAAY,GAAG;AAChD,IAAM,YAAY,KAAK,QAAQ,UAAU;AAGzC,eAAsB,QAAQ;AAC1B,QAAM,OAAO,MAAM,WAAW;AAC9B,MAAI,CAAC,MAAM;AACP,UAAM,IAAI,MAAM,sBAAsB;AAAA,EAC1C;AAEA,QAAM,WAAW,KAAK,KAAK,QAAQ,IAAI,GAAG,YAAY;AAEtD;AACI,UAAM,kBAAkB,KAAK,KAAK,UAAU,cAAc;AAE1D,UAAM,qBAAqB;AAAA,MACvB,MAAM;AAAA,MACN,SAAS,CAAC;AAAA,MACV,cAAc,CAAC;AAAA,MACf,iBAAiB,CAAC;AAAA,IACtB;AAGA,QAAI,CAAC,GAAG,WAAW,QAAQ,GAAG;AAC1B,SAAG,UAAU,UAAU,EAAC,WAAW,KAAI,CAAC;AAAA,IAC5C;AAGA,OAAG,cAAc,iBAAiB,KAAK,UAAU,oBAAoB,MAAM,CAAC,GAAG,MAAM;AAAA,EACzF;AAEA,MAAI;AAEA,UAAM,UAAU;AAAA,MACZ,MAAM,KAAK,KAAK,WAAW,SAAS;AAAA;AAAA,M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Y,OAAO,IAAIA,KAAI;AAAA,MACnE;AAAA,IACJ;AAAA,EACJ;AAEA,EAAAC,SAAQ;AAAA,IACJ,GAAGA;AAAA,IACH,sBAAsBF,MAAK,KAAK,QAAQ,IAAI,GAAG,mBAAmB;AAAA,EACtE;AAEA,MAAI,MAAM,QAAQ;AAClB,MAAI,QAAQ,cAAc;AAC1B,MAAI,IAAI,YAAY,CAAC;AACrB,MAAI;AAAA,IACAA,MAAK,MAAM,KAAKE,OAAM,YAAY,QAAQ;AAAA,IAC1C,QAAQ,OAAOF,MAAK,KAAKE,OAAM,sBAAsB,QAAQ,GAAG;AAAA,MAC5D,WAAW;AAAA,MACX,QAAQ;AAAA,IACZ,CAAC;AAAA,EACL;AACA,MAAI,IAAIA,OAAM,YAAY,QAAQ,OAAOA,OAAM,oBAAoB,CAAC;AACpE,MAAI,IAAI,QAAQ,OAAO,UAAU,EAAC,QAAQ,KAAI,CAAC,CAAC;AAChD,MAAI,IAAI,OAAO,MAAM,CAAC;AAEtB,MAAI;AAAA,IACA;AAAA,IACA,qBAAqB;AAAA,MACjB,OAAAA;AAAA,MACA,MAAM,QAAQ,IAAI;AAAA,IACtB,CAAC;AAAA,EACL;AAEA,MAAI,SAAS,QAAQ,IAAI,OACnB,IAAI,OAAOD,OAAM,QAAQ,IAAI,MAAM,QAAQ,IAC3C,IAAI,OAAOA,OAAM,QAAQ;AAE/B,GAAC,WAAW,QAAQ,EAAE,QAAQ,CAAC,WAAW;AACtC,YAAQ,KAAK,QAAQ,MAAM,QAAQ,MAAM,QAAQ,KAAK,CAAC;AAAA,EAC3D,CAAC;AACL;","names":["path","fileURLToPath","reactRouter","xydContentVitePlugins","pluginZero","__filename","__dirname","fs","path","port","build"]}
|
package/dist/serve.js
CHANGED
|
@@ -5,7 +5,7 @@ import { fileURLToPath } from "node:url";
|
|
|
5
5
|
import { build as viteBuild } from "vite";
|
|
6
6
|
import tsconfigPaths from "vite-tsconfig-paths";
|
|
7
7
|
import { reactRouter } from "@xyd-js/react-router-dev/vite";
|
|
8
|
-
import { vitePlugins as xydContentVitePlugins } from "@xyd-js/content
|
|
8
|
+
import { vitePlugins as xydContentVitePlugins } from "@xyd-js/content";
|
|
9
9
|
import { pluginZero } from "@xyd-js/plugin-zero";
|
|
10
10
|
var __filename = fileURLToPath(import.meta.url);
|
|
11
11
|
var __dirname = path.dirname(__filename);
|
|
@@ -15,7 +15,7 @@ import path2 from "node:path";
|
|
|
15
15
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
16
16
|
import { createServer, searchForWorkspaceRoot } from "vite";
|
|
17
17
|
import { reactRouter as reactRouter2 } from "@xyd-js/react-router-dev/vite";
|
|
18
|
-
import { vitePlugins as xydContentVitePlugins2 } from "@xyd-js/content
|
|
18
|
+
import { vitePlugins as xydContentVitePlugins2 } from "@xyd-js/content";
|
|
19
19
|
import { pluginZero as pluginZero2 } from "@xyd-js/plugin-zero";
|
|
20
20
|
var __filename2 = fileURLToPath2(import.meta.url);
|
|
21
21
|
var __dirname2 = path2.dirname(__filename2);
|
package/dist/serve.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/run/build.ts","../src/run/dev.ts","../src/run/serve.ts","../src/commands/serve.ts"],"sourcesContent":["import path from \"node:path\";\nimport fs from \"node:fs\";\nimport {fileURLToPath} from \"node:url\";\nimport {execSync} from 'child_process';\n\nimport {build as viteBuild} from 'vite';\nimport tsconfigPaths from \"vite-tsconfig-paths\";\n\nimport {reactRouter} from \"@xyd-js/react-router-dev/vite\";\n\nimport {vitePlugins as xydContentVitePlugins} from \"@xyd-js/content/vite\"\nimport {pluginZero} from \"@xyd-js/plugin-zero\";\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = path.dirname(__filename);\n\n// Define the main function to run the builds\nexport async function build() {\n const resp = await pluginZero()\n if (!resp) {\n throw new Error(\"PluginZero not found\")\n }\n\n const buildDir = path.join(process.cwd(), \".xyd/build\");\n\n {\n // TODO: probably we should have better mechanism - maybe bundle?\n\n const packageJsonPath = path.join(buildDir, 'package.json');\n\n const packageJsonContent = {\n type: \"module\",\n scripts: {},\n dependencies: { // TODO: better\n // \"@xyd-js/content\": \"latest\",\n // \"@xyd-js/components\": \"latest\",\n // \"@xyd-js/framework\": \"latest\",\n // \"@xyd-js/theme-poetry\": \"latest\",\n\n \"@xyd-js/content\": \"workspace:*\",\n \"@xyd-js/components\": \"workspace:*\",\n \"@xyd-js/framework\": \"workspace:*\",\n \"@xyd-js/theme-poetry\": \"workspace:*\",\n\n \"@react-router/node\": \"^7.1.1\",\n \"isbot\": \"^5\"\n },\n devDependencies: {}\n };\n\n // Ensure the build directory exists\n if (!fs.existsSync(buildDir)) {\n fs.mkdirSync(buildDir, {recursive: true});\n }\n\n // Write the package.json file\n fs.writeFileSync(packageJsonPath, JSON.stringify(packageJsonContent, null, 2), 'utf8');\n\n // Install packages inside buildDir\n // execSync('npm install', {cwd: buildDir, stdio: 'inherit'});\n\n execSync('pnpm i', {cwd: buildDir, stdio: 'inherit'});\n }\n\n try {\n // Build the client-side bundle\n await viteBuild({\n root: process.env.XYD_CLI ? __dirname : process.env.XYD_DOCUMAN_HOST || path.join(__dirname, \"../host\"),\n plugins: [\n ...(xydContentVitePlugins({\n toc: {\n minDepth: 2,\n }\n }) as Plugin[]),\n reactRouter({\n outDir: buildDir,\n routes: resp.routes\n }),\n tsconfigPaths(),\n ...resp.vitePlugins\n ],\n optimizeDeps: {\n include: [\"react/jsx-runtime\"],\n },\n });\n\n // Build the SSR bundle\n await viteBuild({\n root: process.env.XYD_CLI ? __dirname : process.env.XYD_DOCUMAN_HOST || path.join(__dirname, \"../host\"),\n build: {\n ssr: true,\n },\n plugins: [\n ...(xydContentVitePlugins({\n toc: {\n minDepth: 2,\n }\n }) as Plugin[]),\n reactRouter({\n outDir: buildDir,\n routes: resp.routes\n }),\n tsconfigPaths(),\n ...resp.vitePlugins\n ],\n optimizeDeps: {\n include: [\"react/jsx-runtime\"],\n },\n });\n\n console.log('Build completed successfully.'); // TODO: better message\n } catch (error) {\n console.error('Build failed:', error); // TODO: better message\n }\n}\n\n","import path from \"node:path\";\nimport {fileURLToPath} from \"node:url\";\nimport {createServer, searchForWorkspaceRoot} from \"vite\";\n\nimport {reactRouter} from \"@xyd-js/react-router-dev/vite\";\n\nimport {vitePlugins as xydContentVitePlugins} from \"@xyd-js/content/vite\";\nimport {pluginZero} from \"@xyd-js/plugin-zero\";\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = path.dirname(__filename);\n\nconst port = process.env.XYD_PORT ? parseInt(process.env.XYD_PORT) : 5175;\n\nexport async function dev() {\n const respPluginZero = await pluginZero()\n if (!respPluginZero) {\n throw new Error(\"PluginZero not found\")\n }\n\n const allowCwd = searchForWorkspaceRoot(process.cwd())\n\n const preview = await createServer({\n root: process.env.XYD_CLI ? __dirname : process.env.XYD_DOCUMAN_HOST || path.join(__dirname, \"../host\"), // TODO: bundler?\n server: {\n port: port,\n fs: {\n allow: [\n allowCwd,\n process.env.XYD_CLI ? path.join(__dirname, \"../../\") : \"\",\n // path.join(__dirname, \"../node_modules\") // Ensure node_modules from xyd-documan is included\n ]\n }\n },\n build: {\n rollupOptions: {\n // Exclude package `B` from the client-side bundle\n external: [\"@xyd-js/uniform\", \"@xyd-js/uniform/content\", \"@xyd-js/plugin-zero\"],\n },\n },\n ssr: {\n external: [\"@xyd-js/uniform\", \"@xyd-js/uniform/content\", \"@xyd-js/plugin-zero\"],\n },\n optimizeDeps: {\n include: [\"react/jsx-runtime\"],\n },\n plugins: [ // TODO: fix plugin ts\n ...(xydContentVitePlugins({\n toc: {\n minDepth: 2,\n }\n }) as Plugin[]),\n reactRouter({\n routes: respPluginZero.routes\n }),\n ...respPluginZero.vitePlugins\n ],\n });\n\n await preview.listen(port);\n\n preview.printUrls();\n preview.bindCLIShortcuts({print: true});\n\n}","import fs from \"node:fs\";\nimport os from \"node:os\";\nimport path from \"node:path\";\nimport url from \"node:url\";\n\nimport type {ServerBuild} from \"react-router\";\nimport {createRequestHandler} from \"@react-router/express\";\nimport compression from \"compression\";\nimport express from \"express\";\nimport morgan from \"morgan\";\nimport sourceMapSupport from \"source-map-support\";\nimport getPort from \"get-port\";\n\nfunction parseNumber(raw?: string) {\n if (raw === undefined) return undefined;\n let maybe = Number(raw);\n if (Number.isNaN(maybe)) return undefined;\n return maybe;\n}\n\nexport async function serve() {\n process.env.NODE_ENV = process.env.NODE_ENV ?? \"production\";\n\n sourceMapSupport.install({\n retrieveSourceMap: function (source) {\n let match = source.startsWith(\"file://\");\n if (match) {\n let filePath = url.fileURLToPath(source);\n let sourceMapPath = `${filePath}.map`;\n if (fs.existsSync(sourceMapPath)) {\n return {\n url: source,\n map: fs.readFileSync(sourceMapPath, \"utf8\"),\n };\n }\n }\n return null;\n },\n });\n\n let port = parseNumber(process.env.PORT) ?? (await getPort({port: 3000}));\n\n let buildPathArg = path.join(process.cwd(), \".xyd/build/server/index.js\")\n\n if (!buildPathArg) {\n console.error(`\n Usage: react-router-serve <server-build-path> - e.g. react-router-serve build/server/index.js`);\n process.exit(1);\n }\n\n let buildPath = path.resolve(buildPathArg);\n\n let build: ServerBuild = await import(url.pathToFileURL(buildPath).href);\n\n let onListen = () => {\n let address =\n process.env.HOST ||\n Object.values(os.networkInterfaces())\n .flat()\n .find((ip) => String(ip?.family).includes(\"4\") && !ip?.internal)\n ?.address;\n\n if (!address) {\n console.log(`[xyd-serve] http://localhost:${port}`);\n } else {\n console.log(\n `[xyd-serve] http://localhost:${port} (http://${address}:${port})`\n );\n }\n };\n\n build = {\n ...build,\n assetsBuildDirectory: path.join(process.cwd(), \".xyd/build/client\")\n }\n\n let app = express();\n app.disable(\"x-powered-by\");\n app.use(compression());\n app.use(\n path.posix.join(build.publicPath, \"assets\"),\n express.static(path.join(build.assetsBuildDirectory, \"assets\"), {\n immutable: true,\n maxAge: \"1y\",\n })\n );\n app.use(build.publicPath, express.static(build.assetsBuildDirectory));\n app.use(express.static(\"public\", {maxAge: \"1h\"}));\n app.use(morgan(\"tiny\"));\n\n app.all(\n \"*\",\n createRequestHandler({\n build,\n mode: process.env.NODE_ENV,\n })\n );\n\n let server = process.env.HOST\n ? app.listen(port, process.env.HOST, onListen)\n : app.listen(port, onListen);\n\n [\"SIGTERM\", \"SIGINT\"].forEach((signal) => {\n process.once(signal, () => server?.close(console.error));\n });\n}\n","import {serve} from \"../\"\n\n// Execute the serve function\nawait serve();\n\n"],"mappings":";AAAA,OAAO,UAAU;AACjB,OAAO,QAAQ;AACf,SAAQ,qBAAoB;AAG5B,SAAQ,SAAS,iBAAgB;AACjC,OAAO,mBAAmB;AAE1B,SAAQ,mBAAkB;AAE1B,SAAQ,eAAe,6BAA4B;AACnD,SAAQ,kBAAiB;AAEzB,IAAM,aAAa,cAAc,YAAY,GAAG;AAChD,IAAM,YAAY,KAAK,QAAQ,UAAU;;;ACdzC,OAAOA,WAAU;AACjB,SAAQ,iBAAAC,sBAAoB;AAC5B,SAAQ,cAAc,8BAA6B;AAEnD,SAAQ,eAAAC,oBAAkB;AAE1B,SAAQ,eAAeC,8BAA4B;AACnD,SAAQ,cAAAC,mBAAiB;AAEzB,IAAMC,cAAaJ,eAAc,YAAY,GAAG;AAChD,IAAMK,aAAYN,MAAK,QAAQK,WAAU;AAEzC,IAAM,OAAO,QAAQ,IAAI,WAAW,SAAS,QAAQ,IAAI,QAAQ,IAAI;;;ACZrE,OAAOE,SAAQ;AACf,OAAO,QAAQ;AACf,OAAOC,WAAU;AACjB,OAAO,SAAS;AAGhB,SAAQ,4BAA2B;AACnC,OAAO,iBAAiB;AACxB,OAAO,aAAa;AACpB,OAAO,YAAY;AACnB,OAAO,sBAAsB;AAC7B,OAAO,aAAa;AAEpB,SAAS,YAAY,KAAc;AAC/B,MAAI,QAAQ,OAAW,QAAO;AAC9B,MAAI,QAAQ,OAAO,GAAG;AACtB,MAAI,OAAO,MAAM,KAAK,EAAG,QAAO;AAChC,SAAO;AACX;AAEA,eAAsB,QAAQ;AAC1B,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ACtE;AAEA,MAAI,MAAM,QAAQ;AAClB,MAAI,QAAQ,cAAc;AAC1B,MAAI,IAAI,YAAY,CAAC;AACrB,MAAI;AAAA,IACAA,MAAK,MAAM,KAAKE,OAAM,YAAY,QAAQ;AAAA,IAC1C,QAAQ,OAAOF,MAAK,KAAKE,OAAM,sBAAsB,QAAQ,GAAG;AAAA,MAC5D,WAAW;AAAA,MACX,QAAQ;AAAA,IACZ,CAAC;AAAA,EACL;AACA,MAAI,IAAIA,OAAM,YAAY,QAAQ,OAAOA,OAAM,oBAAoB,CAAC;AACpE,MAAI,IAAI,QAAQ,OAAO,UAAU,EAAC,QAAQ,KAAI,CAAC,CAAC;AAChD,MAAI,IAAI,OAAO,MAAM,CAAC;AAEtB,MAAI;AAAA,IACA;AAAA,IACA,qBAAqB;AAAA,MACjB,OAAAA;AAAA,MACA,MAAM,QAAQ,IAAI;AAAA,IACtB,CAAC;AAAA,EACL;AAEA,MAAI,SAAS,QAAQ,IAAI,OACnB,IAAI,OAAOD,OAAM,QAAQ,IAAI,MAAM,QAAQ,IAC3C,IAAI,OAAOA,OAAM,QAAQ;AAE/B,GAAC,WAAW,QAAQ,EAAE,QAAQ,CAAC,WAAW;AACtC,YAAQ,KAAK,QAAQ,MAAM,QAAQ,MAAM,QAAQ,KAAK,CAAC;AAAA,EAC3D,CAAC;AACL;;;ACtGA,MAAM,MAAM;","names":["path","fileURLToPath","reactRouter","xydContentVitePlugins","pluginZero","__filename","__dirname","fs","path","port","build"]}
|
|
1
|
+
{"version":3,"sources":["../src/run/build.ts","../src/run/dev.ts","../src/run/serve.ts","../src/commands/serve.ts"],"sourcesContent":["import path from \"node:path\";\nimport fs from \"node:fs\";\nimport {fileURLToPath} from \"node:url\";\n\nimport {build as viteBuild} from 'vite';\nimport tsconfigPaths from \"vite-tsconfig-paths\";\n\nimport {reactRouter} from \"@xyd-js/react-router-dev/vite\";\n// import { reactRouter } from \"@react-router/dev/vite\";\n\nimport {vitePlugins as xydContentVitePlugins} from \"@xyd-js/content\"\nimport {pluginZero} from \"@xyd-js/plugin-zero\";\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = path.dirname(__filename);\n\n// Define the main function to run the builds\nexport async function build() {\n const resp = await pluginZero()\n if (!resp) {\n throw new Error(\"PluginZero not found\")\n }\n\n const buildDir = path.join(process.cwd(), \".xyd/build\");\n\n {\n const packageJsonPath = path.join(buildDir, 'package.json');\n\n const packageJsonContent = {\n type: \"module\",\n scripts: {},\n dependencies: {},\n devDependencies: {}\n };\n\n // Ensure the build directory exists\n if (!fs.existsSync(buildDir)) {\n fs.mkdirSync(buildDir, {recursive: true});\n }\n\n // Write the package.json file\n fs.writeFileSync(packageJsonPath, JSON.stringify(packageJsonContent, null, 2), 'utf8');\n }\n\n try {\n // Build the client-side bundle\n await viteBuild({\n root: path.join(__dirname, \"../host\"),\n // @ts-ignore\n plugins: [\n ...(xydContentVitePlugins({\n toc: {\n minDepth: 2,\n }\n }) as Plugin[]),\n reactRouter({\n outDir: buildDir,\n routes: resp.routes\n }),\n tsconfigPaths(),\n ...resp.vitePlugins\n ],\n optimizeDeps: {\n include: [\"react/jsx-runtime\"],\n },\n });\n\n // Build the SSR bundle\n await viteBuild({\n root: path.join(__dirname, \"../host\"),\n build: {\n ssr: true,\n },\n // @ts-ignore\n plugins: [\n ...(xydContentVitePlugins({\n toc: {\n minDepth: 2,\n }\n }) as Plugin[]),\n reactRouter({\n outDir: buildDir,\n routes: resp.routes\n }),\n tsconfigPaths(),\n ...resp.vitePlugins\n ],\n optimizeDeps: {\n include: [\"react/jsx-runtime\"],\n },\n });\n\n console.log('Build completed successfully.'); // TODO: better message\n } catch (error) {\n console.error('Build failed:', error); // TODO: better message\n }\n}\n\n","import path from \"node:path\";\nimport {fileURLToPath} from \"node:url\";\nimport {createServer, searchForWorkspaceRoot} from \"vite\";\n\nimport {reactRouter} from \"@xyd-js/react-router-dev/vite\";\n// import { reactRouter } from \"@react-router/dev/vite\";\n\nimport {vitePlugins as xydContentVitePlugins} from \"@xyd-js/content\";\nimport {pluginZero} from \"@xyd-js/plugin-zero\";\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = path.dirname(__filename);\n\nconst port = process.env.XYD_PORT ? parseInt(process.env.XYD_PORT) : 5175;\n\nexport async function dev() {\n const resp = await pluginZero()\n if (!resp) {\n throw new Error(\"PluginZero not found\")\n }\n\n const allowCwd = searchForWorkspaceRoot(process.cwd())\n\n const preview = await createServer({\n // any valid user config options, plus `mode` and `configFile`\n // configFile: path.join(__dirname, \"../src/vite/empty-config.ts\"), // TODO: bundler??\n // configFile: path.join(__dirname, \"../\"), // TODO: bundler??\n // root: path.join(__dirname, \"../\"), // TODO: bundler?\n root: process.env.XYD_DOCUMAN_HOST || path.join(__dirname, \"../host\"), // TODO: bundler?\n server: {\n port: port,\n fs: {\n allow: [\n allowCwd,\n process.env.XYD_CLI ? path.join(__dirname, \"../../\") : \"\",\n // path.join(__dirname, \"../node_modules\") // Ensure node_modules from xyd-documan is included\n ]\n }\n },\n build: {\n rollupOptions: {\n // Exclude package `B` from the client-side bundle\n external: [\"@xyd-js/uniform\", \"@xyd-js/uniform/content\", \"@xyd-js/plugin-zero\"],\n },\n },\n ssr: {\n external: [\"@xyd-js/uniform\", \"@xyd-js/uniform/content\", \"@xyd-js/plugin-zero\"],\n // noExternal: [\n // \"@xyd-js/uniform\",\n // \"@xyd-js/uniform/content\",\n // \"@xyd-js/plugin-zero\"\n // ],\n },\n optimizeDeps: {\n include: [\"react/jsx-runtime\"],\n },\n // @ts-ignore\n plugins: [ // TODO: fix plugin ts\n ...(xydContentVitePlugins({\n toc: {\n minDepth: 2,\n }\n }) as Plugin[]),\n reactRouter({\n routes: resp.routes\n }),\n ...resp.vitePlugins\n ],\n });\n\n await preview.listen(port);\n\n preview.printUrls();\n preview.bindCLIShortcuts({print: true});\n\n}","import fs from \"node:fs\";\nimport os from \"node:os\";\nimport path from \"node:path\";\nimport url from \"node:url\";\n\nimport type {ServerBuild} from \"react-router\";\nimport {createRequestHandler} from \"@react-router/express\";\nimport compression from \"compression\";\nimport express from \"express\";\nimport morgan from \"morgan\";\nimport sourceMapSupport from \"source-map-support\";\nimport getPort from \"get-port\";\n\nfunction parseNumber(raw?: string) {\n if (raw === undefined) return undefined;\n let maybe = Number(raw);\n if (Number.isNaN(maybe)) return undefined;\n return maybe;\n}\n\nexport async function serve() {\n process.env.NODE_ENV = process.env.NODE_ENV ?? \"production\";\n\n sourceMapSupport.install({\n retrieveSourceMap: function (source) {\n let match = source.startsWith(\"file://\");\n if (match) {\n let filePath = url.fileURLToPath(source);\n let sourceMapPath = `${filePath}.map`;\n if (fs.existsSync(sourceMapPath)) {\n return {\n url: source,\n map: fs.readFileSync(sourceMapPath, \"utf8\"),\n };\n }\n }\n return null;\n },\n });\n\n let port = parseNumber(process.env.PORT) ?? (await getPort({port: 3000}));\n\n let buildPathArg = path.join(process.cwd(), \".xyd/build/server/index.js\")\n\n if (!buildPathArg) {\n console.error(`\n Usage: react-router-serve <server-build-path> - e.g. react-router-serve build/server/index.js`);\n process.exit(1);\n }\n\n let buildPath = path.resolve(buildPathArg);\n\n let build: ServerBuild = await import(url.pathToFileURL(buildPath).href);\n\n let onListen = () => {\n let address =\n process.env.HOST ||\n Object.values(os.networkInterfaces())\n .flat()\n .find((ip) => String(ip?.family).includes(\"4\") && !ip?.internal)\n ?.address;\n\n if (!address) {\n console.log(`[xyd-serve] http://localhost:${port}`);\n } else {\n console.log(\n `[xyd-serve] http://localhost:${port} (http://${address}:${port})`\n );\n }\n };\n\n build = {\n ...build,\n assetsBuildDirectory: path.join(process.cwd(), \".xyd/build/client\")\n }\n\n let app = express();\n app.disable(\"x-powered-by\");\n app.use(compression());\n app.use(\n path.posix.join(build.publicPath, \"assets\"),\n express.static(path.join(build.assetsBuildDirectory, \"assets\"), {\n immutable: true,\n maxAge: \"1y\",\n })\n );\n app.use(build.publicPath, express.static(build.assetsBuildDirectory));\n app.use(express.static(\"public\", {maxAge: \"1h\"}));\n app.use(morgan(\"tiny\"));\n\n app.all(\n \"*\",\n createRequestHandler({\n build,\n mode: process.env.NODE_ENV,\n })\n );\n\n let server = process.env.HOST\n ? app.listen(port, process.env.HOST, onListen)\n : app.listen(port, onListen);\n\n [\"SIGTERM\", \"SIGINT\"].forEach((signal) => {\n process.once(signal, () => server?.close(console.error));\n });\n}\n","import {serve} from \"../\"\n\n// Execute the serve function\nawait serve();\n\n"],"mappings":";AAAA,OAAO,UAAU;AACjB,OAAO,QAAQ;AACf,SAAQ,qBAAoB;AAE5B,SAAQ,SAAS,iBAAgB;AACjC,OAAO,mBAAmB;AAE1B,SAAQ,mBAAkB;AAG1B,SAAQ,eAAe,6BAA4B;AACnD,SAAQ,kBAAiB;AAEzB,IAAM,aAAa,cAAc,YAAY,GAAG;AAChD,IAAM,YAAY,KAAK,QAAQ,UAAU;;;ACdzC,OAAOA,WAAU;AACjB,SAAQ,iBAAAC,sBAAoB;AAC5B,SAAQ,cAAc,8BAA6B;AAEnD,SAAQ,eAAAC,oBAAkB;AAG1B,SAAQ,eAAeC,8BAA4B;AACnD,SAAQ,cAAAC,mBAAiB;AAEzB,IAAMC,cAAaJ,eAAc,YAAY,GAAG;AAChD,IAAMK,aAAYN,MAAK,QAAQK,WAAU;AAEzC,IAAM,OAAO,QAAQ,IAAI,WAAW,SAAS,QAAQ,IAAI,QAAQ,IAAI;;;ACbrE,OAAOE,SAAQ;AACf,OAAO,QAAQ;AACf,OAAOC,WAAU;AACjB,OAAO,SAAS;AAGhB,SAAQ,4BAA2B;AACnC,OAAO,iBAAiB;AACxB,OAAO,aAAa;AACpB,OAAO,YAAY;AACnB,OAAO,sBAAsB;AAC7B,OAAO,aAAa;AAEpB,SAAS,YAAY,KAAc;AAC/B,MAAI,QAAQ,OAAW,QAAO;AAC9B,MAAI,QAAQ,OAAO,GAAG;AACtB,MAAI,OAAO,MAAM,KAAK,EAAG,QAAO;AAChC,SAAO;AACX;AAEA,eAAsB,QAAQ;AAC1B,UAAQ,I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A,MAAI,MAAM,QAAQ;AAClB,MAAI,QAAQ,cAAc;AAC1B,MAAI,IAAI,YAAY,CAAC;AACrB,MAAI;AAAA,IACAA,MAAK,MAAM,KAAKE,OAAM,YAAY,QAAQ;AAAA,IAC1C,QAAQ,OAAOF,MAAK,KAAKE,OAAM,sBAAsB,QAAQ,GAAG;AAAA,MAC5D,WAAW;AAAA,MACX,QAAQ;AAAA,IACZ,CAAC;AAAA,EACL;AACA,MAAI,IAAIA,OAAM,YAAY,QAAQ,OAAOA,OAAM,oBAAoB,CAAC;AACpE,MAAI,IAAI,QAAQ,OAAO,UAAU,EAAC,QAAQ,KAAI,CAAC,CAAC;AAChD,MAAI,IAAI,OAAO,MAAM,CAAC;AAEtB,MAAI;AAAA,IACA;AAAA,IACA,qBAAqB;AAAA,MACjB,OAAAA;AAAA,MACA,MAAM,QAAQ,IAAI;AAAA,IACtB,CAAC;AAAA,EACL;AAEA,MAAI,SAAS,QAAQ,IAAI,OACnB,IAAI,OAAOD,OAAM,QAAQ,IAAI,MAAM,QAAQ,IAC3C,IAAI,OAAOA,OAAM,QAAQ;AAE/B,GAAC,WAAW,QAAQ,EAAE,QAAQ,CAAC,WAAW;AACtC,YAAQ,KAAK,QAAQ,MAAM,QAAQ,MAAM,QAAQ,KAAK,CAAC;AAAA,EAC3D,CAAC;AACL;;;ACtGA,MAAM,MAAM;","names":["path","fileURLToPath","reactRouter","xydContentVitePlugins","pluginZero","__filename","__dirname","fs","path","port","build"]}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// React Router generated types for route:
|
|
2
|
+
// root.tsx
|
|
3
|
+
|
|
4
|
+
import type * as T from "react-router/route-module"
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
type Module = typeof import("../root.js")
|
|
9
|
+
|
|
10
|
+
export type Info = {
|
|
11
|
+
parents: [],
|
|
12
|
+
id: "root"
|
|
13
|
+
file: "root.tsx"
|
|
14
|
+
path: ""
|
|
15
|
+
params: {} & { [key: string]: string | undefined }
|
|
16
|
+
module: Module
|
|
17
|
+
loaderData: T.CreateLoaderData<Module>
|
|
18
|
+
actionData: T.CreateActionData<Module>
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export namespace Route {
|
|
22
|
+
export type LinkDescriptors = T.LinkDescriptors
|
|
23
|
+
export type LinksFunction = () => LinkDescriptors
|
|
24
|
+
|
|
25
|
+
export type MetaArgs = T.CreateMetaArgs<Info>
|
|
26
|
+
export type MetaDescriptors = T.MetaDescriptors
|
|
27
|
+
export type MetaFunction = (args: MetaArgs) => MetaDescriptors
|
|
28
|
+
|
|
29
|
+
export type HeadersArgs = T.HeadersArgs
|
|
30
|
+
export type HeadersFunction = (args: HeadersArgs) => Headers | HeadersInit
|
|
31
|
+
|
|
32
|
+
export type LoaderArgs = T.CreateServerLoaderArgs<Info>
|
|
33
|
+
export type ClientLoaderArgs = T.CreateClientLoaderArgs<Info>
|
|
34
|
+
export type ActionArgs = T.CreateServerActionArgs<Info>
|
|
35
|
+
export type ClientActionArgs = T.CreateClientActionArgs<Info>
|
|
36
|
+
|
|
37
|
+
export type HydrateFallbackProps = T.CreateHydrateFallbackProps<Info>
|
|
38
|
+
export type ComponentProps = T.CreateComponentProps<Info>
|
|
39
|
+
export type ErrorBoundaryProps = T.CreateErrorBoundaryProps<Info>
|
|
40
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Links, Meta, Outlet, Scripts, ScrollRestoration } from "react-router";
|
|
2
|
+
|
|
3
|
+
export function Layout({ children }: { children: React.ReactNode }) {
|
|
4
|
+
return (
|
|
5
|
+
<html lang="en">
|
|
6
|
+
<head>
|
|
7
|
+
<meta charSet="utf-8" />
|
|
8
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
9
|
+
<Meta />
|
|
10
|
+
<Links />
|
|
11
|
+
</head>
|
|
12
|
+
<body>
|
|
13
|
+
{children}
|
|
14
|
+
<ScrollRestoration />
|
|
15
|
+
<Scripts />
|
|
16
|
+
</body>
|
|
17
|
+
</html>
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export default function App() {
|
|
22
|
+
return <Outlet />;
|
|
23
|
+
}
|