@xyd-js/cli 0.1.0-xyd.10 → 0.1.0-xyd.117

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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 xyd
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,2 @@
1
+
2
+ export { }
package/dist/build.js ADDED
@@ -0,0 +1,5 @@
1
+ // build.ts
2
+ import * as documan from "@xyd-js/documan";
3
+ (async () => {
4
+ await documan.build();
5
+ })();
@@ -0,0 +1 @@
1
+ #!/usr/bin/env node
package/dist/index.js ADDED
@@ -0,0 +1,150 @@
1
+ #!/usr/bin/env node
2
+
3
+ // src/run.ts
4
+ import arg from "arg";
5
+ import semver from "semver";
6
+ import colors from "picocolors";
7
+
8
+ // package.json
9
+ var version = "0.1.0-xyd.117";
10
+
11
+ // src/commands.ts
12
+ import { spawn } from "child_process";
13
+ import { fileURLToPath } from "url";
14
+ import { dirname, join } from "path";
15
+ import * as documan from "@xyd-js/documan";
16
+ async function build(root, options = {}) {
17
+ const __filename = fileURLToPath(import.meta.url);
18
+ const __dirname = dirname(__filename);
19
+ const buildScript = join(__dirname, "..", "dist", "build.js");
20
+ return new Promise((resolve, reject) => {
21
+ const args = process.argv.slice(2);
22
+ const child = spawn("node", [buildScript, ...args], {
23
+ stdio: "inherit",
24
+ // This will show output in stdout
25
+ shell: true,
26
+ env: {
27
+ NODE_ENV: "production",
28
+ ...process.env
29
+ // Pass through all existing environment variables
30
+ }
31
+ });
32
+ child.on("close", (code) => {
33
+ if (code === 0) {
34
+ resolve(void 0);
35
+ } else {
36
+ reject(new Error(`Build process exited with code ${code}`));
37
+ }
38
+ });
39
+ child.on("error", (err) => {
40
+ reject(err);
41
+ });
42
+ });
43
+ }
44
+ async function dev2(root, options = {}) {
45
+ await documan.dev(options);
46
+ await new Promise(() => {
47
+ });
48
+ }
49
+ async function install2(root, options = {}) {
50
+ await documan.install();
51
+ }
52
+
53
+ // src/run.ts
54
+ var helpText = `
55
+ ${colors.blueBright("xyd")}
56
+
57
+ ${colors.underline("Usage")}:
58
+ $ xyd build [${colors.yellowBright("projectDir")}]
59
+ $ xyd start [${colors.yellowBright("projectDir")}]
60
+ $ xyd dev [${colors.yellowBright("projectDir")}]
61
+
62
+ ${colors.underline("Options")}:
63
+ --help, -h Print this help message and exit
64
+ --version, -v Print the CLI version and exit
65
+ --verbose Show debug messages
66
+
67
+ ${colors.underline("Build your project")}:
68
+
69
+ $ xyd build
70
+
71
+ ${colors.underline("Install the xyd framework")}:
72
+
73
+ $ xyd install
74
+
75
+ ${colors.underline("Run your project locally in development")}:
76
+
77
+ $ xyd dev
78
+ `;
79
+ async function run(argv = process.argv.slice(2)) {
80
+ process.env.XYD_CLI = "true";
81
+ const versions = process.versions;
82
+ const MINIMUM_NODE_VERSION = 22;
83
+ if (versions && versions.node && semver.major(versions.node) < MINIMUM_NODE_VERSION) {
84
+ console.warn(
85
+ `\uFE0F\u26A0\uFE0F Oops, Node v${versions.node} detected. xyd requires a Node version greater than ${MINIMUM_NODE_VERSION}.`
86
+ );
87
+ }
88
+ let args = arg(
89
+ {
90
+ "--help": Boolean,
91
+ "-h": "--help",
92
+ "--version": Boolean,
93
+ "-v": "--version",
94
+ "--port": Number,
95
+ "-p": "--port",
96
+ "--logLevel": String,
97
+ "-l": "--logLevel",
98
+ "--verbose": Boolean,
99
+ "--debug": Boolean
100
+ },
101
+ {
102
+ argv
103
+ }
104
+ );
105
+ if (args["--verbose"]) {
106
+ process.env.XYD_VERBOSE = "true";
107
+ } else {
108
+ console.debug = () => {
109
+ };
110
+ }
111
+ let input = args._;
112
+ let flags = Object.entries(args).reduce((acc, [key, value]) => {
113
+ key = key.replace(/^--/, "");
114
+ acc[key] = value;
115
+ return acc;
116
+ }, {});
117
+ if (flags.help) {
118
+ console.log(helpText);
119
+ return;
120
+ }
121
+ if (flags.version) {
122
+ console.log(version);
123
+ return;
124
+ }
125
+ let command = input[0];
126
+ switch (command) {
127
+ case "build":
128
+ await build(input[1], flags);
129
+ break;
130
+ case "install":
131
+ await install2(input[1], flags);
132
+ break;
133
+ case "dev":
134
+ await dev2(input[1], flags);
135
+ break;
136
+ default:
137
+ await dev2(input[0], flags);
138
+ }
139
+ }
140
+
141
+ // index.ts
142
+ run().then(
143
+ () => {
144
+ process.exit(0);
145
+ },
146
+ (error) => {
147
+ if (error) console.error(error);
148
+ process.exit(1);
149
+ }
150
+ );
package/package.json CHANGED
@@ -1,68 +1,30 @@
1
1
  {
2
2
  "name": "@xyd-js/cli",
3
- "version": "0.1.0-xyd.10",
3
+ "version": "0.1.0-xyd.117",
4
4
  "keywords": [],
5
5
  "author": "",
6
6
  "description": "",
7
7
  "type": "module",
8
+ "main": "dist/index.js",
9
+ "bin": {
10
+ "xyd": "dist/index.js"
11
+ },
8
12
  "files": [
9
- ".cli",
10
- "postinstall.js"
13
+ "dist",
14
+ "package.json"
11
15
  ],
12
- "scripts": {
13
- "build": "tsup",
14
- "postinstall": "node postinstall.js"
15
- },
16
16
  "dependencies": {
17
- "@graphql-markdown/core": "^1.12.0",
18
- "@graphql-markdown/graphql": "^1.1.4",
19
- "@graphql-markdown/types": "^1.4.0",
20
- "@react-router/dev": "^7.1.1",
21
- "@react-router/node": "^7.1.1",
22
- "@react-router/serve": "^7.1.1",
23
- "@readme/oas-to-snippet": "^26.0.1",
24
- "@xyd-js/documan-host": "file:.cli",
25
- "@xyd-js/react-router-dev": "7.1.1-xyd.3",
17
+ "picocolors": "^1.1.1",
26
18
  "arg": "^5.0.2",
27
- "codehike": "^1.0.3",
28
19
  "colors": "^1.4.0",
29
- "compression": "^1.7.5",
30
- "express": "^4.21.1",
31
- "get-port": "^7.1.0",
32
- "graphql-config": "^5.1.2",
33
- "gray-matter": "^4.0.3",
34
- "isbot": "^5.1.17",
35
- "js-yaml": "^4.1.0",
36
- "json-schema-ref-parser": "^9.0.9",
37
- "json-to-graphql-query": "^2.3.0",
38
- "lightningcss": "^1.27.0",
39
- "morgan": "^1.10.0",
40
- "oas": "^25.0.3",
41
- "openapi-sampler": "^1.5.1",
42
- "openapi-types": "^12.1.3",
43
- "react": "^18.3.1",
44
- "react-dom": "^18.3.1",
45
- "react-router": "^7.1.1",
46
- "remark": "^15.0.1",
47
- "remark-frontmatter": "^5.0.0",
48
- "remark-gfm": "^4.0.0",
49
- "remark-mdx-frontmatter": "^5.0.0",
50
- "remark-stringify": "^11.0.0",
51
20
  "semver": "^7.6.3",
52
- "source-map-support": "^0.5.21",
53
- "typescript": "^5.6.3",
54
- "unist-builder": "^4.0.0",
55
- "unist-util-visit": "^5.0.0",
56
- "vfile": "^6.0.3",
57
- "vite-tsconfig-paths": "^5.1.4",
58
- "yaml": "^2.6.0"
21
+ "@xyd-js/documan": "0.1.0-xyd.73",
22
+ "@xyd-js/host": "0.1.0-xyd.42"
59
23
  },
60
24
  "devDependencies": {
61
- "@xyd-js/documan": "0.1.0-xyd.15",
62
- "arg": "^5.0.2",
63
- "colors": "^1.4.0",
64
- "semver": "^7.6.3",
65
- "tsup": "^8.3.0",
66
- "vite-tsconfig-paths": "^5.1.4"
25
+ "tsup": "^8.3.0"
26
+ },
27
+ "scripts": {
28
+ "build": "tsup"
67
29
  }
68
- }
30
+ }
package/.cli/app/root.tsx DELETED
@@ -1,23 +0,0 @@
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
- }
@@ -1,5 +0,0 @@
1
- // we export empty routes because rr7 need this file and we load routes via xyd plugins
2
-
3
- export const routes = []
4
-
5
- export default routes
package/.cli/bin.js DELETED
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- import './index.js';