@xyd-js/documan 0.1.0-xyd.3 → 0.1.0-xyd.31
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/LICENSE +21 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +981 -0
- package/dist/index.js.map +1 -0
- package/package.json +24 -22
- package/host/app/root.tsx +0 -23
- package/host/app/routes.ts +0 -5
- package/host/package.json +0 -43
- package/host/postcss.config.cjs +0 -5
- package/host/react-router.config.ts +0 -8
- package/host/tsconfig.json +0 -22
- package/host/vite.config.ts +0 -9
- package/src/commands/build.ts +0 -4
- package/src/commands/dev.ts +0 -5
- package/src/commands/serve.ts +0 -5
- package/src/index.ts +0 -7
- package/src/run/build.ts +0 -98
- package/src/run/dev.ts +0 -76
- package/src/run/index.ts +0 -6
- package/src/run/serve.ts +0 -106
- package/tsconfig.json +0 -22
- package/tsup.config.ts +0 -81
package/src/run/serve.ts
DELETED
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
import fs from "node:fs";
|
|
2
|
-
import os from "node:os";
|
|
3
|
-
import path from "node:path";
|
|
4
|
-
import url from "node:url";
|
|
5
|
-
|
|
6
|
-
import type {ServerBuild} from "react-router";
|
|
7
|
-
import {createRequestHandler} from "@react-router/express";
|
|
8
|
-
import compression from "compression";
|
|
9
|
-
import express from "express";
|
|
10
|
-
import morgan from "morgan";
|
|
11
|
-
import sourceMapSupport from "source-map-support";
|
|
12
|
-
import getPort from "get-port";
|
|
13
|
-
|
|
14
|
-
function parseNumber(raw?: string) {
|
|
15
|
-
if (raw === undefined) return undefined;
|
|
16
|
-
let maybe = Number(raw);
|
|
17
|
-
if (Number.isNaN(maybe)) return undefined;
|
|
18
|
-
return maybe;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export async function serve() {
|
|
22
|
-
process.env.NODE_ENV = process.env.NODE_ENV ?? "production";
|
|
23
|
-
|
|
24
|
-
sourceMapSupport.install({
|
|
25
|
-
retrieveSourceMap: function (source) {
|
|
26
|
-
let match = source.startsWith("file://");
|
|
27
|
-
if (match) {
|
|
28
|
-
let filePath = url.fileURLToPath(source);
|
|
29
|
-
let sourceMapPath = `${filePath}.map`;
|
|
30
|
-
if (fs.existsSync(sourceMapPath)) {
|
|
31
|
-
return {
|
|
32
|
-
url: source,
|
|
33
|
-
map: fs.readFileSync(sourceMapPath, "utf8"),
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
return null;
|
|
38
|
-
},
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
let port = parseNumber(process.env.PORT) ?? (await getPort({port: 3000}));
|
|
42
|
-
|
|
43
|
-
let buildPathArg = path.join(process.cwd(), ".xyd/build/server/index.js")
|
|
44
|
-
|
|
45
|
-
if (!buildPathArg) {
|
|
46
|
-
console.error(`
|
|
47
|
-
Usage: react-router-serve <server-build-path> - e.g. react-router-serve build/server/index.js`);
|
|
48
|
-
process.exit(1);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
let buildPath = path.resolve(buildPathArg);
|
|
52
|
-
|
|
53
|
-
let build: ServerBuild = await import(url.pathToFileURL(buildPath).href);
|
|
54
|
-
|
|
55
|
-
let onListen = () => {
|
|
56
|
-
let address =
|
|
57
|
-
process.env.HOST ||
|
|
58
|
-
Object.values(os.networkInterfaces())
|
|
59
|
-
.flat()
|
|
60
|
-
.find((ip) => String(ip?.family).includes("4") && !ip?.internal)
|
|
61
|
-
?.address;
|
|
62
|
-
|
|
63
|
-
if (!address) {
|
|
64
|
-
console.log(`[xyd-serve] http://localhost:${port}`);
|
|
65
|
-
} else {
|
|
66
|
-
console.log(
|
|
67
|
-
`[xyd-serve] http://localhost:${port} (http://${address}:${port})`
|
|
68
|
-
);
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
build = {
|
|
73
|
-
...build,
|
|
74
|
-
assetsBuildDirectory: path.join(process.cwd(), ".xyd/build/client")
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
let app = express();
|
|
78
|
-
app.disable("x-powered-by");
|
|
79
|
-
app.use(compression());
|
|
80
|
-
app.use(
|
|
81
|
-
path.posix.join(build.publicPath, "assets"),
|
|
82
|
-
express.static(path.join(build.assetsBuildDirectory, "assets"), {
|
|
83
|
-
immutable: true,
|
|
84
|
-
maxAge: "1y",
|
|
85
|
-
})
|
|
86
|
-
);
|
|
87
|
-
app.use(build.publicPath, express.static(build.assetsBuildDirectory));
|
|
88
|
-
app.use(express.static("public", {maxAge: "1h"}));
|
|
89
|
-
app.use(morgan("tiny"));
|
|
90
|
-
|
|
91
|
-
app.all(
|
|
92
|
-
"*",
|
|
93
|
-
createRequestHandler({
|
|
94
|
-
build,
|
|
95
|
-
mode: process.env.NODE_ENV,
|
|
96
|
-
})
|
|
97
|
-
);
|
|
98
|
-
|
|
99
|
-
let server = process.env.HOST
|
|
100
|
-
? app.listen(port, process.env.HOST, onListen)
|
|
101
|
-
: app.listen(port, onListen);
|
|
102
|
-
|
|
103
|
-
["SIGTERM", "SIGINT"].forEach((signal) => {
|
|
104
|
-
process.once(signal, () => server?.close(console.error));
|
|
105
|
-
});
|
|
106
|
-
}
|
package/tsconfig.json
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"module": "esnext",
|
|
4
|
-
"esModuleInterop": true,
|
|
5
|
-
"moduleResolution": "bundler",
|
|
6
|
-
"target": "esnext", // Change this to es2020 or esnext
|
|
7
|
-
"baseUrl": ".",
|
|
8
|
-
"lib": ["dom", "dom.iterable", "esnext"],
|
|
9
|
-
"allowJs": true,
|
|
10
|
-
"skipLibCheck": true,
|
|
11
|
-
"strict": false,
|
|
12
|
-
"noEmit": true,
|
|
13
|
-
"incremental": false,
|
|
14
|
-
"resolveJsonModule": true,
|
|
15
|
-
"isolatedModules": true,
|
|
16
|
-
"jsx": "preserve",
|
|
17
|
-
"plugins": [],
|
|
18
|
-
"strictNullChecks": true
|
|
19
|
-
},
|
|
20
|
-
"include": ["src/**/*.ts", "src/**/*.tsx", "host/**/*.ts", "host/**/*.tsx"],
|
|
21
|
-
"exclude": ["node_modules"]
|
|
22
|
-
}
|
package/tsup.config.ts
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import {defineConfig} from 'tsup';
|
|
2
|
-
import pkg from './package.json';
|
|
3
|
-
|
|
4
|
-
const deps = [
|
|
5
|
-
...Object.keys(pkg.dependencies || {}),
|
|
6
|
-
...Object.keys(pkg.devDependencies || {}),
|
|
7
|
-
].filter((dep) => [
|
|
8
|
-
"@xyd-js/core",
|
|
9
|
-
"@xyd-js/content",
|
|
10
|
-
"@xyd-js/framework",
|
|
11
|
-
"@xyd-js/ui",
|
|
12
|
-
"@xyd-js/openapi",
|
|
13
|
-
"@xyd-js/uniform",
|
|
14
|
-
"@xyd-js/theme-gusto",
|
|
15
|
-
// "@xyd-js/plugin-zero", // TODO: because plugin-zero has react-router dependency
|
|
16
|
-
].indexOf(dep) === -1)
|
|
17
|
-
|
|
18
|
-
export default defineConfig({
|
|
19
|
-
entry: {
|
|
20
|
-
index: 'src/index.ts',
|
|
21
|
-
dev: 'src/commands/dev.ts',
|
|
22
|
-
build: 'src/commands/build.ts',
|
|
23
|
-
serve: 'src/commands/serve.ts',
|
|
24
|
-
},
|
|
25
|
-
dts: {
|
|
26
|
-
entry: {
|
|
27
|
-
index: 'src/index.ts',
|
|
28
|
-
dev: 'src/commands/dev.ts',
|
|
29
|
-
build: 'src/commands/build.ts',
|
|
30
|
-
serve: 'src/commands/serve.ts',
|
|
31
|
-
},
|
|
32
|
-
resolve: true, // Resolve external types
|
|
33
|
-
},
|
|
34
|
-
|
|
35
|
-
format: ["esm"],
|
|
36
|
-
platform: 'node',
|
|
37
|
-
shims: false,
|
|
38
|
-
splitting: false,
|
|
39
|
-
sourcemap: true,
|
|
40
|
-
clean: true,
|
|
41
|
-
bundle: true, // Enable bundling
|
|
42
|
-
external: [
|
|
43
|
-
...deps,
|
|
44
|
-
|
|
45
|
-
// needed by @xyd-js/plugin-zero
|
|
46
|
-
"react-router",
|
|
47
|
-
"@react-router/dev",
|
|
48
|
-
"@react-router/express",
|
|
49
|
-
|
|
50
|
-
"@xyd-js/react-router-dev",
|
|
51
|
-
|
|
52
|
-
"@readme/json-schema-ref-parser",
|
|
53
|
-
"@apidevtools/json-schema-ref-parser",
|
|
54
|
-
//
|
|
55
|
-
|
|
56
|
-
//
|
|
57
|
-
// Externalize Node.js built-in modules
|
|
58
|
-
/^node:.*/,
|
|
59
|
-
'fs',
|
|
60
|
-
'path',
|
|
61
|
-
'url',
|
|
62
|
-
'os',
|
|
63
|
-
'http',
|
|
64
|
-
'https',
|
|
65
|
-
'stream',
|
|
66
|
-
'zlib',
|
|
67
|
-
'util',
|
|
68
|
-
'crypto',
|
|
69
|
-
'tty',
|
|
70
|
-
|
|
71
|
-
// "lightningcss",
|
|
72
|
-
// "vite",
|
|
73
|
-
// "vite-tsconfig-paths",
|
|
74
|
-
// "react-router",
|
|
75
|
-
// "@react-router/serve",
|
|
76
|
-
// "@react-router/dev",
|
|
77
|
-
// "@xydjs/react-router-dev",
|
|
78
|
-
// "@mdx-js/rollup",
|
|
79
|
-
// "@graphql-markdown"
|
|
80
|
-
], // Ensure no dependencies are marked as external
|
|
81
|
-
})
|