@soda-gql/cli 0.0.8 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +112 -0
- package/dist/index.cjs +8 -0
- package/package.json +4 -4
package/README.md
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
# @soda-gql/cli
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@soda-gql/cli)
|
|
4
|
+
[](https://opensource.org/licenses/MIT)
|
|
5
|
+
|
|
6
|
+
Command-line interface for soda-gql zero-runtime GraphQL code generation.
|
|
7
|
+
|
|
8
|
+
## Installation
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
bun add -D @soda-gql/cli @soda-gql/config
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Usage
|
|
15
|
+
|
|
16
|
+
### Configuration
|
|
17
|
+
|
|
18
|
+
Create a `soda-gql.config.ts` file in your project root:
|
|
19
|
+
|
|
20
|
+
```typescript
|
|
21
|
+
import { defineConfig } from "@soda-gql/config";
|
|
22
|
+
|
|
23
|
+
export default defineConfig({
|
|
24
|
+
outdir: "./src/graphql-system",
|
|
25
|
+
include: ["./src/**/*.ts"],
|
|
26
|
+
schemas: {
|
|
27
|
+
default: {
|
|
28
|
+
schema: "./schema.graphql",
|
|
29
|
+
runtimeAdapter: "./src/graphql-system/runtime-adapter.ts",
|
|
30
|
+
scalars: "./src/graphql-system/scalars.ts",
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### Commands
|
|
37
|
+
|
|
38
|
+
#### Generate GraphQL System
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
bun run soda-gql codegen
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
This command:
|
|
45
|
+
1. Reads your GraphQL schema
|
|
46
|
+
2. Generates type-safe GraphQL system module
|
|
47
|
+
3. Outputs to the directory specified in `outdir`
|
|
48
|
+
|
|
49
|
+
#### Scaffold Templates
|
|
50
|
+
|
|
51
|
+
For first-time setup, generate scalar and runtime adapter templates:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
bun run soda-gql codegen --emit-inject-template ./src/graphql-system/inject.ts
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### CLI Options
|
|
58
|
+
|
|
59
|
+
| Option | Description |
|
|
60
|
+
|--------|-------------|
|
|
61
|
+
| `--config <path>` | Path to config file (auto-discovered if not specified) |
|
|
62
|
+
| `--emit-inject-template <path>` | Generate scaffold templates for scalars and runtime adapter |
|
|
63
|
+
| `--format <type>` | Output format: `human` (default) or `json` |
|
|
64
|
+
|
|
65
|
+
### Config File Discovery
|
|
66
|
+
|
|
67
|
+
The CLI automatically searches for configuration files in the following order:
|
|
68
|
+
1. `soda-gql.config.ts`
|
|
69
|
+
2. `soda-gql.config.mts`
|
|
70
|
+
3. `soda-gql.config.js`
|
|
71
|
+
4. `soda-gql.config.mjs`
|
|
72
|
+
|
|
73
|
+
## Example Workflow
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
# 1. Install dependencies
|
|
77
|
+
bun add @soda-gql/core @soda-gql/runtime
|
|
78
|
+
bun add -D @soda-gql/cli @soda-gql/config
|
|
79
|
+
|
|
80
|
+
# 2. Create config file
|
|
81
|
+
cat > soda-gql.config.ts << 'EOF'
|
|
82
|
+
import { defineConfig } from "@soda-gql/config";
|
|
83
|
+
|
|
84
|
+
export default defineConfig({
|
|
85
|
+
outdir: "./src/graphql-system",
|
|
86
|
+
include: ["./src/**/*.ts"],
|
|
87
|
+
schemas: {
|
|
88
|
+
default: {
|
|
89
|
+
schema: "./schema.graphql",
|
|
90
|
+
runtimeAdapter: "./src/graphql-system/runtime-adapter.ts",
|
|
91
|
+
scalars: "./src/graphql-system/scalars.ts",
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
});
|
|
95
|
+
EOF
|
|
96
|
+
|
|
97
|
+
# 3. Generate templates (first-time only)
|
|
98
|
+
bun run soda-gql codegen --emit-inject-template ./src/graphql-system/inject.ts
|
|
99
|
+
|
|
100
|
+
# 4. Generate GraphQL system
|
|
101
|
+
bun run soda-gql codegen
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## Related Packages
|
|
105
|
+
|
|
106
|
+
- [@soda-gql/config](../config) - Configuration management
|
|
107
|
+
- [@soda-gql/codegen](../codegen) - Code generation engine
|
|
108
|
+
- [@soda-gql/core](../core) - Core types and utilities
|
|
109
|
+
|
|
110
|
+
## License
|
|
111
|
+
|
|
112
|
+
MIT
|
package/dist/index.cjs
CHANGED
|
@@ -90,10 +90,14 @@ const parseCodegenArgs = (argv) => {
|
|
|
90
90
|
const schemas = {};
|
|
91
91
|
const runtimeAdapters = {};
|
|
92
92
|
const scalars = {};
|
|
93
|
+
const metadataAdapters = {};
|
|
94
|
+
const helpers = {};
|
|
93
95
|
for (const [name, schemaConfig] of Object.entries(config.schemas)) {
|
|
94
96
|
schemas[name] = schemaConfig.schema;
|
|
95
97
|
runtimeAdapters[name] = schemaConfig.runtimeAdapter;
|
|
96
98
|
scalars[name] = schemaConfig.scalars;
|
|
99
|
+
if (schemaConfig.metadataAdapter) metadataAdapters[name] = schemaConfig.metadataAdapter;
|
|
100
|
+
if (schemaConfig.helpers) helpers[name] = schemaConfig.helpers;
|
|
97
101
|
}
|
|
98
102
|
return (0, neverthrow.ok)({
|
|
99
103
|
kind: "multi",
|
|
@@ -102,6 +106,8 @@ const parseCodegenArgs = (argv) => {
|
|
|
102
106
|
format: args.format ?? "human",
|
|
103
107
|
runtimeAdapters,
|
|
104
108
|
scalars,
|
|
109
|
+
metadataAdapters,
|
|
110
|
+
helpers,
|
|
105
111
|
importExtension: config.styles.importExtension
|
|
106
112
|
});
|
|
107
113
|
};
|
|
@@ -144,6 +150,8 @@ const codegenCommand = async (argv) => {
|
|
|
144
150
|
format: command.format,
|
|
145
151
|
runtimeAdapters: Object.fromEntries(Object.entries(command.runtimeAdapters).map(([name, path]) => [name, (0, node_path.resolve)(path)])),
|
|
146
152
|
scalars: Object.fromEntries(Object.entries(command.scalars).map(([name, path]) => [name, (0, node_path.resolve)(path)])),
|
|
153
|
+
metadataAdapters: Object.keys(command.metadataAdapters).length > 0 ? Object.fromEntries(Object.entries(command.metadataAdapters).map(([name, path]) => [name, (0, node_path.resolve)(path)])) : void 0,
|
|
154
|
+
helpers: Object.keys(command.helpers).length > 0 ? Object.fromEntries(Object.entries(command.helpers).map(([name, path]) => [name, (0, node_path.resolve)(path)])) : void 0,
|
|
147
155
|
importExtension: command.importExtension
|
|
148
156
|
});
|
|
149
157
|
if (result.isErr()) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@soda-gql/cli",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"private": false,
|
|
6
6
|
"license": "MIT",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"types": "./dist/index.d.cts",
|
|
21
21
|
"exports": {
|
|
22
22
|
".": {
|
|
23
|
-
"
|
|
23
|
+
"@soda-gql": "./src/index.ts",
|
|
24
24
|
"types": "./dist/index.d.cts",
|
|
25
25
|
"require": "./dist/index.cjs",
|
|
26
26
|
"default": "./dist/index.cjs"
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
"./package.json": "./package.json"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@soda-gql/codegen": "0.0
|
|
32
|
-
"@soda-gql/builder": "0.0
|
|
31
|
+
"@soda-gql/codegen": "0.1.0",
|
|
32
|
+
"@soda-gql/builder": "0.1.0",
|
|
33
33
|
"neverthrow": "^8.1.1",
|
|
34
34
|
"zod": "^4.1.11"
|
|
35
35
|
},
|