@soda-gql/cli 0.1.0 → 0.3.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 CHANGED
@@ -26,8 +26,7 @@ export default defineConfig({
26
26
  schemas: {
27
27
  default: {
28
28
  schema: "./schema.graphql",
29
- runtimeAdapter: "./src/graphql-system/runtime-adapter.ts",
30
- scalars: "./src/graphql-system/scalars.ts",
29
+ inject: "./src/graphql-system/default.inject.ts",
31
30
  },
32
31
  },
33
32
  });
@@ -48,10 +47,10 @@ This command:
48
47
 
49
48
  #### Scaffold Templates
50
49
 
51
- For first-time setup, generate scalar and runtime adapter templates:
50
+ For first-time setup, generate inject template with scalar and adapter definitions:
52
51
 
53
52
  ```bash
54
- bun run soda-gql codegen --emit-inject-template ./src/graphql-system/inject.ts
53
+ bun run soda-gql codegen --emit-inject-template ./src/graphql-system/default.inject.ts
55
54
  ```
56
55
 
57
56
  ### CLI Options
@@ -59,7 +58,7 @@ bun run soda-gql codegen --emit-inject-template ./src/graphql-system/inject.ts
59
58
  | Option | Description |
60
59
  |--------|-------------|
61
60
  | `--config <path>` | Path to config file (auto-discovered if not specified) |
62
- | `--emit-inject-template <path>` | Generate scaffold templates for scalars and runtime adapter |
61
+ | `--emit-inject-template <path>` | Generate scaffold template for scalars and adapter definitions |
63
62
  | `--format <type>` | Output format: `human` (default) or `json` |
64
63
 
65
64
  ### Config File Discovery
@@ -87,15 +86,14 @@ export default defineConfig({
87
86
  schemas: {
88
87
  default: {
89
88
  schema: "./schema.graphql",
90
- runtimeAdapter: "./src/graphql-system/runtime-adapter.ts",
91
- scalars: "./src/graphql-system/scalars.ts",
89
+ inject: "./src/graphql-system/default.inject.ts",
92
90
  },
93
91
  },
94
92
  });
95
93
  EOF
96
94
 
97
95
  # 3. Generate templates (first-time only)
98
- bun run soda-gql codegen --emit-inject-template ./src/graphql-system/inject.ts
96
+ bun run soda-gql codegen --emit-inject-template ./src/graphql-system/default.inject.ts
99
97
 
100
98
  # 4. Generate GraphQL system
101
99
  bun run soda-gql codegen
package/dist/index.cjs CHANGED
@@ -1,14 +1,44 @@
1
1
  #!/usr/bin/env node
2
+ //#region rolldown:runtime
3
+ var __create = Object.create;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
12
+ key = keys[i];
13
+ if (!__hasOwnProp.call(to, key) && key !== except) {
14
+ __defProp(to, key, {
15
+ get: ((k) => from[k]).bind(null, key),
16
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
17
+ });
18
+ }
19
+ }
20
+ }
21
+ return to;
22
+ };
23
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
24
+ value: mod,
25
+ enumerable: true
26
+ }) : target, mod));
27
+
28
+ //#endregion
2
29
  let node_path = require("node:path");
3
30
  let __soda_gql_codegen = require("@soda-gql/codegen");
4
31
  let __soda_gql_config = require("@soda-gql/config");
5
32
  let neverthrow = require("neverthrow");
6
33
  let zod = require("zod");
34
+ let node_fs_promises = require("node:fs/promises");
35
+ let fast_glob = require("fast-glob");
36
+ fast_glob = __toESM(fast_glob);
37
+ let node_fs = require("node:fs");
7
38
 
8
39
  //#region packages/cli/src/schemas/args.ts
9
40
  const CodegenArgsSchema = zod.z.object({
10
41
  config: zod.z.string().optional(),
11
- format: zod.z.enum(["human", "json"]).optional(),
12
42
  "emit-inject-template": zod.z.string().optional()
13
43
  });
14
44
  const BuilderArgsSchema = zod.z.object({
@@ -17,24 +47,12 @@ const BuilderArgsSchema = zod.z.object({
17
47
  out: zod.z.string(),
18
48
  format: zod.z.enum(["human", "json"]).optional().default("human")
19
49
  });
20
-
21
- //#endregion
22
- //#region packages/cli/src/utils/format.ts
23
- const formatters = {
24
- json: (data) => JSON.stringify(data, null, 2),
25
- human: (data) => {
26
- if (typeof data === "string") return data;
27
- if (data instanceof Error) return data.message;
28
- return JSON.stringify(data, null, 2);
29
- }
30
- };
31
- const formatOutput = (data, format = "human") => {
32
- return formatters[format](data);
33
- };
34
- const formatError = (error, format = "human") => {
35
- if (format === "json") return JSON.stringify({ error }, null, 2);
36
- return error instanceof Error ? error.message : String(error);
37
- };
50
+ const FormatArgsSchema = zod.z.object({
51
+ _: zod.z.array(zod.z.string()).optional(),
52
+ config: zod.z.string().optional(),
53
+ check: zod.z.boolean().optional()
54
+ });
55
+ const InitArgsSchema = zod.z.object({ force: zod.z.boolean().optional() });
38
56
 
39
57
  //#endregion
40
58
  //#region packages/cli/src/utils/parse-args.ts
@@ -72,8 +90,7 @@ const parseCodegenArgs = (argv) => {
72
90
  const args = parsed.value;
73
91
  if (args["emit-inject-template"]) return (0, neverthrow.ok)({
74
92
  kind: "emitInjectTemplate",
75
- outPath: args["emit-inject-template"],
76
- format: args.format ?? "human"
93
+ outPath: args["emit-inject-template"]
77
94
  });
78
95
  const configResult = (0, __soda_gql_config.loadConfig)(args.config);
79
96
  if (configResult.isErr()) return (0, neverthrow.err)({
@@ -88,49 +105,60 @@ const parseCodegenArgs = (argv) => {
88
105
  outPath: ""
89
106
  });
90
107
  const schemas = {};
91
- const runtimeAdapters = {};
92
- const scalars = {};
93
- const metadataAdapters = {};
94
- const helpers = {};
95
- for (const [name, schemaConfig] of Object.entries(config.schemas)) {
96
- schemas[name] = schemaConfig.schema;
97
- runtimeAdapters[name] = schemaConfig.runtimeAdapter;
98
- scalars[name] = schemaConfig.scalars;
99
- if (schemaConfig.metadataAdapter) metadataAdapters[name] = schemaConfig.metadataAdapter;
100
- if (schemaConfig.helpers) helpers[name] = schemaConfig.helpers;
101
- }
108
+ for (const [name, schemaConfig] of Object.entries(config.schemas)) schemas[name] = {
109
+ schema: schemaConfig.schema,
110
+ inject: schemaConfig.inject
111
+ };
102
112
  return (0, neverthrow.ok)({
103
- kind: "multi",
113
+ kind: "generate",
104
114
  schemas,
105
115
  outPath: (0, node_path.resolve)(config.outdir, "index.ts"),
106
- format: args.format ?? "human",
107
- runtimeAdapters,
108
- scalars,
109
- metadataAdapters,
110
- helpers,
111
116
  importExtension: config.styles.importExtension
112
117
  });
113
118
  };
114
- const formatMultiSchemaSuccess = (format, success) => {
115
- if (format === "json") return formatOutput(success, "json");
119
+ const formatSuccess$1 = (success) => {
116
120
  const schemaNames = Object.keys(success.schemas).join(", ");
117
- return `Generated ${Object.values(success.schemas).reduce((sum, s) => {
118
- return sum + s.objects;
119
- }, 0)} objects from schemas: ${schemaNames}\n TypeScript: ${success.outPath}\n CommonJS: ${success.cjsPath}`;
121
+ return `Generated ${Object.values(success.schemas).reduce((sum, s) => sum + s.objects, 0)} objects from schemas: ${schemaNames}\n TypeScript: ${success.outPath}\n CommonJS: ${success.cjsPath}`;
120
122
  };
121
- const formatTemplateSuccess = (format, outPath) => {
122
- if (format === "json") return formatOutput({ outPath }, "json");
123
+ const formatTemplateSuccess = (outPath) => {
123
124
  return `Created inject template → ${outPath}`;
124
125
  };
125
- const formatCodegenError = (format, error) => {
126
- if (format === "json") return formatError(error, "json");
127
- return `${error.code}: ${"message" in error ? error.message : "Unknown error"}`;
126
+ const errorHints = {
127
+ SCHEMA_NOT_FOUND: "Verify the schema path in soda-gql.config.ts",
128
+ SCHEMA_INVALID: "Check your GraphQL schema for syntax errors",
129
+ INJECT_MODULE_NOT_FOUND: "Run: soda-gql codegen --emit-inject-template <path>",
130
+ INJECT_MODULE_REQUIRED: "Add inject configuration to your schema in soda-gql.config.ts",
131
+ INJECT_TEMPLATE_EXISTS: "Delete the existing file to regenerate, or use a different path",
132
+ EMIT_FAILED: "Check write permissions and that the output directory exists"
133
+ };
134
+ const formatCodegenError = (error) => {
135
+ const message = "message" in error ? error.message : "Unknown error";
136
+ const hint = errorHints[error.code];
137
+ const hintLine = hint ? `\n Hint: ${hint}` : "";
138
+ return `${error.code}: ${message}${hintLine}`;
128
139
  };
140
+ const CODEGEN_HELP = `Usage: soda-gql codegen [options]
141
+
142
+ Generate graphql-system runtime module from GraphQL schema.
143
+
144
+ Options:
145
+ --config <path> Path to soda-gql.config.ts
146
+ --emit-inject-template <path> Create inject template file
147
+ --help, -h Show this help message
148
+
149
+ Examples:
150
+ soda-gql codegen --config ./soda-gql.config.ts
151
+ soda-gql codegen --emit-inject-template ./src/graphql/scalars.ts
152
+ `;
129
153
  const codegenCommand = async (argv) => {
154
+ if (argv.includes("--help") || argv.includes("-h")) {
155
+ process.stdout.write(CODEGEN_HELP);
156
+ return 0;
157
+ }
130
158
  try {
131
159
  const parsed = parseCodegenArgs(argv);
132
160
  if (parsed.isErr()) {
133
- process.stderr.write(`${formatCodegenError("json", parsed.error)}\n`);
161
+ process.stderr.write(`${formatCodegenError(parsed.error)}\n`);
134
162
  return 1;
135
163
  }
136
164
  const command = parsed.value;
@@ -138,27 +166,31 @@ const codegenCommand = async (argv) => {
138
166
  const outPath = (0, node_path.resolve)(command.outPath);
139
167
  const result$1 = (0, __soda_gql_codegen.writeInjectTemplate)(outPath);
140
168
  if (result$1.isErr()) {
141
- process.stderr.write(`${formatCodegenError(command.format, result$1.error)}\n`);
169
+ process.stderr.write(`${formatCodegenError(result$1.error)}\n`);
142
170
  return 1;
143
171
  }
144
- process.stdout.write(`${formatTemplateSuccess(command.format, outPath)}\n`);
172
+ process.stdout.write(`${formatTemplateSuccess(outPath)}\n`);
145
173
  return 0;
146
174
  }
147
- const result = await (0, __soda_gql_codegen.runMultiSchemaCodegen)({
148
- schemas: Object.fromEntries(Object.entries(command.schemas).map(([name, path]) => [name, (0, node_path.resolve)(path)])),
175
+ const resolvedSchemas = {};
176
+ for (const [name, schemaConfig] of Object.entries(command.schemas)) resolvedSchemas[name] = {
177
+ schema: (0, node_path.resolve)(schemaConfig.schema),
178
+ inject: {
179
+ scalars: (0, node_path.resolve)(schemaConfig.inject.scalars),
180
+ ...schemaConfig.inject.adapter ? { adapter: (0, node_path.resolve)(schemaConfig.inject.adapter) } : {}
181
+ }
182
+ };
183
+ const result = await (0, __soda_gql_codegen.runCodegen)({
184
+ schemas: resolvedSchemas,
149
185
  outPath: (0, node_path.resolve)(command.outPath),
150
- format: command.format,
151
- runtimeAdapters: Object.fromEntries(Object.entries(command.runtimeAdapters).map(([name, path]) => [name, (0, node_path.resolve)(path)])),
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,
186
+ format: "human",
155
187
  importExtension: command.importExtension
156
188
  });
157
189
  if (result.isErr()) {
158
- process.stderr.write(`${formatCodegenError(command.format, result.error)}\n`);
190
+ process.stderr.write(`${formatCodegenError(result.error)}\n`);
159
191
  return 1;
160
192
  }
161
- process.stdout.write(`${formatMultiSchemaSuccess(command.format, result.value)}\n`);
193
+ process.stdout.write(`${formatSuccess$1(result.value)}\n`);
162
194
  return 0;
163
195
  } catch (error) {
164
196
  const unexpectedError = {
@@ -166,11 +198,341 @@ const codegenCommand = async (argv) => {
166
198
  message: error instanceof Error ? error.message : String(error),
167
199
  outPath: ""
168
200
  };
169
- process.stderr.write(`${formatCodegenError("json", unexpectedError)}\n`);
201
+ process.stderr.write(`${formatCodegenError(unexpectedError)}\n`);
170
202
  return 1;
171
203
  }
172
204
  };
173
205
 
206
+ //#endregion
207
+ //#region packages/cli/src/commands/format.ts
208
+ const loadFormatter = async () => {
209
+ try {
210
+ return await import("@soda-gql/formatter");
211
+ } catch {
212
+ return null;
213
+ }
214
+ };
215
+ const formatFormatError = (error) => {
216
+ return `${error.code}: ${error.message}`;
217
+ };
218
+ const formatResult = (result) => {
219
+ if (result.mode === "check") {
220
+ if (result.unformatted.length > 0) {
221
+ const files = result.unformatted.map((f) => ` ${f}`).join("\n");
222
+ return `${result.unformatted.length} file(s) need formatting:\n${files}`;
223
+ }
224
+ return `All ${result.total} file(s) are properly formatted`;
225
+ }
226
+ const parts = [];
227
+ if (result.modified > 0) parts.push(`${result.modified} formatted`);
228
+ if (result.unchanged > 0) parts.push(`${result.unchanged} unchanged`);
229
+ if (result.errors > 0) parts.push(`${result.errors} errors`);
230
+ return `${result.total} file(s) checked: ${parts.join(", ")}`;
231
+ };
232
+ const isGlobPattern = (pattern) => {
233
+ return /[*?[\]{}]/.test(pattern);
234
+ };
235
+ const expandGlobPatterns = async (patterns, excludePatterns = []) => {
236
+ const files = [];
237
+ for (const pattern of patterns) {
238
+ if (!isGlobPattern(pattern)) {
239
+ try {
240
+ await (0, node_fs_promises.access)(pattern);
241
+ files.push(pattern);
242
+ } catch {}
243
+ continue;
244
+ }
245
+ const matches = await (0, fast_glob.default)(pattern, {
246
+ absolute: true,
247
+ ignore: [...excludePatterns]
248
+ });
249
+ files.push(...matches);
250
+ }
251
+ return [...new Set(files)];
252
+ };
253
+ const FORMAT_HELP = `Usage: soda-gql format [patterns...] [options]
254
+
255
+ Format soda-gql field selections by inserting empty comments.
256
+
257
+ Options:
258
+ --config <path> Path to soda-gql.config.ts (auto-detected if omitted)
259
+ --check Check if files need formatting (exit 1 if unformatted)
260
+ --help, -h Show this help message
261
+
262
+ Examples:
263
+ soda-gql format # Use config include/exclude
264
+ soda-gql format "src/**/*.ts" # Override with explicit patterns
265
+ soda-gql format --check # Check mode with config
266
+ `;
267
+ const formatCommand = async (argv) => {
268
+ if (argv.includes("--help") || argv.includes("-h")) {
269
+ process.stdout.write(FORMAT_HELP);
270
+ return 0;
271
+ }
272
+ const parsed = parseArgs([...argv], FormatArgsSchema);
273
+ if (!parsed.isOk()) {
274
+ const error = {
275
+ code: "PARSE_ERROR",
276
+ message: parsed.error
277
+ };
278
+ process.stderr.write(`${formatFormatError(error)}\n`);
279
+ return 1;
280
+ }
281
+ const args = parsed.value;
282
+ const isCheckMode = args.check === true;
283
+ const explicitPatterns = args._ ?? [];
284
+ let targetPatterns;
285
+ let excludePatterns = [];
286
+ if (explicitPatterns.length > 0) targetPatterns = explicitPatterns;
287
+ else {
288
+ const configResult = (0, __soda_gql_config.loadConfig)(args.config);
289
+ if (configResult.isErr()) {
290
+ process.stderr.write(`${formatFormatError({
291
+ code: "NO_PATTERNS",
292
+ message: "No patterns provided and config not found. Usage: soda-gql format [patterns...] [--check]"
293
+ })}\n`);
294
+ return 1;
295
+ }
296
+ targetPatterns = configResult.value.include;
297
+ excludePatterns = configResult.value.exclude;
298
+ }
299
+ const formatter = await loadFormatter();
300
+ if (!formatter) {
301
+ process.stderr.write(`${formatFormatError({
302
+ code: "FORMATTER_NOT_INSTALLED",
303
+ message: "@soda-gql/formatter is not installed. Run: npm install @soda-gql/formatter"
304
+ })}\n`);
305
+ return 1;
306
+ }
307
+ const files = await expandGlobPatterns(targetPatterns, excludePatterns);
308
+ if (files.length === 0) {
309
+ const result$1 = {
310
+ mode: isCheckMode ? "check" : "format",
311
+ total: 0,
312
+ modified: 0,
313
+ unchanged: 0,
314
+ errors: 0,
315
+ unformatted: []
316
+ };
317
+ process.stdout.write(`${formatResult(result$1)}\n`);
318
+ return 0;
319
+ }
320
+ let modified = 0;
321
+ let unchanged = 0;
322
+ let errors = 0;
323
+ const unformatted = [];
324
+ for (const filePath of files) {
325
+ const sourceCode = await (0, node_fs_promises.readFile)(filePath, "utf-8");
326
+ if (isCheckMode) {
327
+ const result$1 = formatter.needsFormat({
328
+ sourceCode,
329
+ filePath
330
+ });
331
+ if (result$1.isErr()) {
332
+ errors++;
333
+ continue;
334
+ }
335
+ if (result$1.value) {
336
+ unformatted.push(filePath);
337
+ modified++;
338
+ } else unchanged++;
339
+ } else {
340
+ const result$1 = formatter.format({
341
+ sourceCode,
342
+ filePath
343
+ });
344
+ if (result$1.isErr()) {
345
+ errors++;
346
+ continue;
347
+ }
348
+ if (result$1.value.modified) {
349
+ await (0, node_fs_promises.writeFile)(filePath, result$1.value.sourceCode, "utf-8");
350
+ modified++;
351
+ } else unchanged++;
352
+ }
353
+ }
354
+ const result = {
355
+ mode: isCheckMode ? "check" : "format",
356
+ total: files.length,
357
+ modified,
358
+ unchanged,
359
+ errors,
360
+ unformatted
361
+ };
362
+ process.stdout.write(`${formatResult(result)}\n`);
363
+ if (isCheckMode && unformatted.length > 0) return 1;
364
+ return errors > 0 ? 1 : 0;
365
+ };
366
+
367
+ //#endregion
368
+ //#region packages/cli/src/templates/config.template.ts
369
+ const getConfigTemplate = () => `\
370
+ import { defineConfig } from "@soda-gql/config";
371
+
372
+ export default defineConfig({
373
+ outdir: "./graphql-system",
374
+ include: ["./src/**/*.ts"],
375
+ schemas: {
376
+ default: {
377
+ schema: "./schema.graphql",
378
+ inject: "./graphql-system/default.inject.ts",
379
+ },
380
+ },
381
+ });
382
+ `;
383
+
384
+ //#endregion
385
+ //#region packages/cli/src/templates/gitignore.template.ts
386
+ const getGitignoreTemplate = () => `\
387
+ /index.ts
388
+ /index.cjs
389
+ `;
390
+
391
+ //#endregion
392
+ //#region packages/cli/src/templates/inject.template.ts
393
+ const getInjectTemplate = () => `\
394
+ import { defineAdapter, defineScalar } from "@soda-gql/core/adapter";
395
+
396
+ export const scalar = {
397
+ ...defineScalar<"ID", string, string>("ID"),
398
+ ...defineScalar<"String", string, string>("String"),
399
+ ...defineScalar<"Int", number, number>("Int"),
400
+ ...defineScalar<"Float", number, number>("Float"),
401
+ ...defineScalar<"Boolean", boolean, boolean>("Boolean"),
402
+ } as const;
403
+
404
+ export const adapter = defineAdapter({
405
+ helpers: {},
406
+ metadata: {
407
+ aggregateFragmentMetadata: (fragments) => fragments.map((m) => m.metadata),
408
+ },
409
+ });
410
+ `;
411
+
412
+ //#endregion
413
+ //#region packages/cli/src/templates/schema.template.ts
414
+ const getSchemaTemplate = () => `\
415
+ type Query {
416
+ hello: String!
417
+ }
418
+ `;
419
+
420
+ //#endregion
421
+ //#region packages/cli/src/commands/init.ts
422
+ const INIT_HELP = `Usage: soda-gql init [options]
423
+
424
+ Initialize a new soda-gql project with starter configuration.
425
+
426
+ Options:
427
+ --force Overwrite existing files
428
+ --help, -h Show this help message
429
+
430
+ Generated files:
431
+ soda-gql.config.ts Configuration file
432
+ schema.graphql Sample GraphQL schema
433
+ graphql-system/default.inject.ts Scalars, helpers, and metadata adapter
434
+ graphql-system/.gitignore Ignore generated files
435
+ `;
436
+ const checkFilesExist = (files, force) => {
437
+ if (force) return (0, neverthrow.ok)(void 0);
438
+ for (const file of files) if ((0, node_fs.existsSync)(file.path)) return (0, neverthrow.err)({
439
+ code: "FILE_EXISTS",
440
+ message: `File already exists: ${file.path}. Use --force to overwrite.`,
441
+ filePath: file.path
442
+ });
443
+ return (0, neverthrow.ok)(void 0);
444
+ };
445
+ const writeFiles = (files) => {
446
+ const createdPaths = [];
447
+ for (const file of files) try {
448
+ (0, node_fs.mkdirSync)((0, node_path.dirname)(file.path), { recursive: true });
449
+ (0, node_fs.writeFileSync)(file.path, file.content);
450
+ createdPaths.push(file.path);
451
+ } catch (error) {
452
+ const message = error instanceof Error ? error.message : String(error);
453
+ return (0, neverthrow.err)({
454
+ code: "WRITE_FAILED",
455
+ message: `Failed to write ${file.description}: ${message}`,
456
+ filePath: file.path
457
+ });
458
+ }
459
+ return (0, neverthrow.ok)({ filesCreated: createdPaths });
460
+ };
461
+ const formatSuccess = (result) => {
462
+ const lines = [
463
+ "soda-gql project initialized successfully!",
464
+ "",
465
+ "Created files:"
466
+ ];
467
+ for (const file of result.filesCreated) lines.push(` ${file}`);
468
+ lines.push("", "Next steps:");
469
+ lines.push(" 1. Edit schema.graphql with your GraphQL types");
470
+ lines.push(" 2. Run: soda-gql codegen");
471
+ lines.push(" 3. Import gql from ./graphql-system");
472
+ return lines.join("\n");
473
+ };
474
+ const formatInitError = (error) => {
475
+ return `${error.code}: ${error.message}`;
476
+ };
477
+ const initCommand = async (argv) => {
478
+ if (argv.includes("--help") || argv.includes("-h")) {
479
+ process.stdout.write(INIT_HELP);
480
+ return 0;
481
+ }
482
+ const parsed = parseArgs([...argv], InitArgsSchema);
483
+ if (!parsed.isOk()) {
484
+ const error = {
485
+ code: "PARSE_ERROR",
486
+ message: parsed.error
487
+ };
488
+ process.stderr.write(`${formatInitError(error)}\n`);
489
+ return 1;
490
+ }
491
+ const force = parsed.value.force === true;
492
+ const cwd = process.cwd();
493
+ const files = [
494
+ {
495
+ path: (0, node_path.resolve)(cwd, "soda-gql.config.ts"),
496
+ content: getConfigTemplate(),
497
+ description: "configuration file"
498
+ },
499
+ {
500
+ path: (0, node_path.resolve)(cwd, "schema.graphql"),
501
+ content: getSchemaTemplate(),
502
+ description: "GraphQL schema"
503
+ },
504
+ {
505
+ path: (0, node_path.resolve)(cwd, "graphql-system/default.inject.ts"),
506
+ content: getInjectTemplate(),
507
+ description: "inject module"
508
+ },
509
+ {
510
+ path: (0, node_path.resolve)(cwd, "graphql-system/.gitignore"),
511
+ content: getGitignoreTemplate(),
512
+ description: "gitignore file"
513
+ }
514
+ ];
515
+ const existsCheck = checkFilesExist(files, force);
516
+ if (existsCheck.isErr()) {
517
+ process.stderr.write(`${formatInitError(existsCheck.error)}\n`);
518
+ return 1;
519
+ }
520
+ const writeResult = writeFiles(files);
521
+ if (writeResult.isErr()) {
522
+ process.stderr.write(`${formatInitError(writeResult.error)}\n`);
523
+ return 1;
524
+ }
525
+ process.stdout.write(`${formatSuccess(writeResult.value)}\n`);
526
+ return 0;
527
+ };
528
+
529
+ //#endregion
530
+ //#region packages/cli/src/utils/format.ts
531
+ const formatError = (error, format = "human") => {
532
+ if (format === "json") return JSON.stringify({ error }, null, 2);
533
+ return error instanceof Error ? error.message : String(error);
534
+ };
535
+
174
536
  //#endregion
175
537
  //#region packages/cli/src/index.ts
176
538
  const dispatch = async (argv) => {
@@ -178,10 +540,14 @@ const dispatch = async (argv) => {
178
540
  if (!command || command === "--help" || command === "-h") {
179
541
  process.stdout.write(`Usage: soda-gql <command> [options]\n`);
180
542
  process.stdout.write(`\nCommands:\n`);
543
+ process.stdout.write(` init Initialize a new soda-gql project\n`);
181
544
  process.stdout.write(` codegen Generate graphql-system runtime module\n`);
545
+ process.stdout.write(` format Format soda-gql field selections\n`);
182
546
  return 0;
183
547
  }
548
+ if (command === "init") return initCommand(rest);
184
549
  if (command === "codegen") return codegenCommand(rest);
550
+ if (command === "format") return formatCommand(rest);
185
551
  process.stderr.write(`Unknown command: ${command}\n`);
186
552
  return 1;
187
553
  };
@@ -197,4 +563,5 @@ dispatch(process.argv.slice(2)).then((exitCode) => {
197
563
  });
198
564
 
199
565
  //#endregion
200
- exports.dispatch = dispatch;
566
+ exports.dispatch = dispatch;
567
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","names":["z","parsed: Record<string, unknown>","positional: string[]","schemas: Record<string, CodegenSchemaConfig>","formatSuccess","errorHints: Record<string, string>","result","resolvedSchemas: Record<string, CodegenSchemaConfig>","unexpectedError: CodegenError","parts: string[]","files: string[]","error: FormatError","targetPatterns: readonly string[]","excludePatterns: readonly string[]","result: FormatResult","result","unformatted: string[]","createdPaths: string[]","error: InitError","files: FileToGenerate[]"],"sources":["../src/schemas/args.ts","../src/utils/parse-args.ts","../src/commands/codegen.ts","../src/commands/format.ts","../src/templates/config.template.ts","../src/templates/gitignore.template.ts","../src/templates/inject.template.ts","../src/templates/schema.template.ts","../src/commands/init.ts","../src/utils/format.ts","../src/index.ts"],"sourcesContent":["import { z } from \"zod\";\n\nexport const CodegenArgsSchema = z.object({\n config: z.string().optional(),\n \"emit-inject-template\": z.string().optional(),\n});\n\nexport const BuilderArgsSchema = z.object({\n mode: z.enum([\"runtime\", \"zero-runtime\"]),\n entry: z.string(),\n out: z.string(),\n format: z.enum([\"human\", \"json\"]).optional().default(\"human\"),\n});\n\nexport const FormatArgsSchema = z.object({\n _: z.array(z.string()).optional(),\n config: z.string().optional(),\n check: z.boolean().optional(),\n});\n\nexport const InitArgsSchema = z.object({\n force: z.boolean().optional(),\n});\n\nexport type CodegenArgs = z.infer<typeof CodegenArgsSchema>;\nexport type BuilderArgs = z.infer<typeof BuilderArgsSchema>;\nexport type FormatArgs = z.infer<typeof FormatArgsSchema>;\nexport type InitArgs = z.infer<typeof InitArgsSchema>;\n","import { err, ok, type Result } from \"neverthrow\";\nimport type { z } from \"zod\";\n\nexport const parseArgs = <T extends z.ZodType>(args: string[], schema: T): Result<z.infer<T>, string> => {\n const parsed: Record<string, unknown> = {};\n const positional: string[] = [];\n\n for (let i = 0; i < args.length; i++) {\n const arg = args[i];\n if (!arg) continue;\n\n if (arg.startsWith(\"--\")) {\n const key = arg.slice(2);\n const nextArg = args[i + 1];\n\n if (!nextArg || nextArg.startsWith(\"--\")) {\n parsed[key] = true;\n } else {\n parsed[key] = nextArg;\n i++;\n }\n } else {\n positional.push(arg);\n }\n }\n\n if (positional.length > 0) {\n parsed._ = positional;\n }\n\n const result = schema.safeParse(parsed);\n if (!result.success) {\n return err(result.error.issues.map((e) => e.message).join(\", \"));\n }\n\n return ok(result.data);\n};\n","import { resolve } from \"node:path\";\nimport type { CodegenError, CodegenSchemaConfig, CodegenSuccess } from \"@soda-gql/codegen\";\nimport { runCodegen, writeInjectTemplate } from \"@soda-gql/codegen\";\nimport { loadConfig } from \"@soda-gql/config\";\nimport { err, ok, type Result } from \"neverthrow\";\nimport { CodegenArgsSchema } from \"../schemas/args\";\nimport { parseArgs } from \"../utils/parse-args\";\n\ntype ParsedCommand =\n | {\n kind: \"emitInjectTemplate\";\n outPath: string;\n }\n | {\n kind: \"generate\";\n schemas: Record<string, CodegenSchemaConfig>;\n outPath: string;\n importExtension: boolean;\n };\n\nconst parseCodegenArgs = (argv: readonly string[]): Result<ParsedCommand, CodegenError> => {\n const parsed = parseArgs([...argv], CodegenArgsSchema);\n\n if (!parsed.isOk()) {\n return err<ParsedCommand, CodegenError>({\n code: \"EMIT_FAILED\",\n message: parsed.error,\n outPath: \"\",\n });\n }\n\n const args = parsed.value;\n\n // Handle emit inject template\n if (args[\"emit-inject-template\"]) {\n return ok<ParsedCommand, CodegenError>({\n kind: \"emitInjectTemplate\",\n outPath: args[\"emit-inject-template\"],\n });\n }\n\n // Load config from @soda-gql/config\n const configResult = loadConfig(args.config);\n if (configResult.isErr()) {\n return err<ParsedCommand, CodegenError>({\n code: \"EMIT_FAILED\",\n message: `Failed to load config: ${configResult.error.message}`,\n outPath: \"\",\n });\n }\n\n const config = configResult.value;\n\n // Check if schemas config exists\n if (!config.schemas || Object.keys(config.schemas).length === 0) {\n return err<ParsedCommand, CodegenError>({\n code: \"EMIT_FAILED\",\n message: \"schemas configuration is required in soda-gql.config.ts\",\n outPath: \"\",\n });\n }\n\n // Build schemas config with resolved paths\n const schemas: Record<string, CodegenSchemaConfig> = {};\n\n for (const [name, schemaConfig] of Object.entries(config.schemas)) {\n schemas[name] = {\n schema: schemaConfig.schema,\n inject: schemaConfig.inject,\n };\n }\n\n // Derive output path from outdir (default to index.ts)\n const outPath = resolve(config.outdir, \"index.ts\");\n\n return ok<ParsedCommand, CodegenError>({\n kind: \"generate\",\n schemas,\n outPath,\n importExtension: config.styles.importExtension,\n });\n};\n\nconst formatSuccess = (success: CodegenSuccess): string => {\n const schemaNames = Object.keys(success.schemas).join(\", \");\n const totalObjects = Object.values(success.schemas).reduce((sum, s) => sum + s.objects, 0);\n return `Generated ${totalObjects} objects from schemas: ${schemaNames}\\n TypeScript: ${success.outPath}\\n CommonJS: ${success.cjsPath}`;\n};\n\nconst formatTemplateSuccess = (outPath: string): string => {\n return `Created inject template → ${outPath}`;\n};\n\nconst errorHints: Record<string, string> = {\n SCHEMA_NOT_FOUND: \"Verify the schema path in soda-gql.config.ts\",\n SCHEMA_INVALID: \"Check your GraphQL schema for syntax errors\",\n INJECT_MODULE_NOT_FOUND: \"Run: soda-gql codegen --emit-inject-template <path>\",\n INJECT_MODULE_REQUIRED: \"Add inject configuration to your schema in soda-gql.config.ts\",\n INJECT_TEMPLATE_EXISTS: \"Delete the existing file to regenerate, or use a different path\",\n EMIT_FAILED: \"Check write permissions and that the output directory exists\",\n};\n\nconst formatCodegenError = (error: CodegenError): string => {\n const message = \"message\" in error ? error.message : \"Unknown error\";\n const hint = errorHints[error.code];\n const hintLine = hint ? `\\n Hint: ${hint}` : \"\";\n return `${error.code}: ${message}${hintLine}`;\n};\n\nconst CODEGEN_HELP = `Usage: soda-gql codegen [options]\n\nGenerate graphql-system runtime module from GraphQL schema.\n\nOptions:\n --config <path> Path to soda-gql.config.ts\n --emit-inject-template <path> Create inject template file\n --help, -h Show this help message\n\nExamples:\n soda-gql codegen --config ./soda-gql.config.ts\n soda-gql codegen --emit-inject-template ./src/graphql/scalars.ts\n`;\n\nexport const codegenCommand = async (argv: readonly string[]): Promise<number> => {\n if (argv.includes(\"--help\") || argv.includes(\"-h\")) {\n process.stdout.write(CODEGEN_HELP);\n return 0;\n }\n\n try {\n const parsed = parseCodegenArgs(argv);\n\n if (parsed.isErr()) {\n process.stderr.write(`${formatCodegenError(parsed.error)}\\n`);\n return 1;\n }\n\n const command = parsed.value;\n\n if (command.kind === \"emitInjectTemplate\") {\n const outPath = resolve(command.outPath);\n const result = writeInjectTemplate(outPath);\n if (result.isErr()) {\n process.stderr.write(`${formatCodegenError(result.error)}\\n`);\n return 1;\n }\n process.stdout.write(`${formatTemplateSuccess(outPath)}\\n`);\n return 0;\n }\n\n // Resolve all paths in schemas config\n const resolvedSchemas: Record<string, CodegenSchemaConfig> = {};\n for (const [name, schemaConfig] of Object.entries(command.schemas)) {\n resolvedSchemas[name] = {\n schema: resolve(schemaConfig.schema),\n inject: {\n scalars: resolve(schemaConfig.inject.scalars),\n ...(schemaConfig.inject.adapter ? { adapter: resolve(schemaConfig.inject.adapter) } : {}),\n },\n };\n }\n\n const result = await runCodegen({\n schemas: resolvedSchemas,\n outPath: resolve(command.outPath),\n format: \"human\",\n importExtension: command.importExtension,\n });\n\n if (result.isErr()) {\n process.stderr.write(`${formatCodegenError(result.error)}\\n`);\n return 1;\n }\n\n process.stdout.write(`${formatSuccess(result.value)}\\n`);\n return 0;\n } catch (error) {\n // Catch unexpected errors and convert to structured format\n const unexpectedError: CodegenError = {\n code: \"EMIT_FAILED\",\n message: error instanceof Error ? error.message : String(error),\n outPath: \"\",\n };\n process.stderr.write(`${formatCodegenError(unexpectedError)}\\n`);\n return 1;\n }\n};\n","import { access, readFile, writeFile } from \"node:fs/promises\";\nimport { loadConfig } from \"@soda-gql/config\";\nimport fg from \"fast-glob\";\nimport { FormatArgsSchema } from \"../schemas/args\";\nimport { parseArgs } from \"../utils/parse-args\";\n\ntype FormatterModule = typeof import(\"@soda-gql/formatter\");\n\nconst loadFormatter = async (): Promise<FormatterModule | null> => {\n try {\n return await import(\"@soda-gql/formatter\");\n } catch {\n return null;\n }\n};\n\ntype FormatError = {\n code: \"PARSE_ERROR\" | \"NO_PATTERNS\" | \"FORMAT_ERROR\" | \"FORMATTER_NOT_INSTALLED\";\n message: string;\n};\n\ntype FormatResult = {\n mode: \"format\" | \"check\";\n total: number;\n modified: number;\n unchanged: number;\n errors: number;\n unformatted: string[];\n};\n\nconst formatFormatError = (error: FormatError): string => {\n return `${error.code}: ${error.message}`;\n};\n\nconst formatResult = (result: FormatResult): string => {\n if (result.mode === \"check\") {\n if (result.unformatted.length > 0) {\n const files = result.unformatted.map((f) => ` ${f}`).join(\"\\n\");\n return `${result.unformatted.length} file(s) need formatting:\\n${files}`;\n }\n return `All ${result.total} file(s) are properly formatted`;\n }\n\n const parts: string[] = [];\n if (result.modified > 0) {\n parts.push(`${result.modified} formatted`);\n }\n if (result.unchanged > 0) {\n parts.push(`${result.unchanged} unchanged`);\n }\n if (result.errors > 0) {\n parts.push(`${result.errors} errors`);\n }\n return `${result.total} file(s) checked: ${parts.join(\", \")}`;\n};\n\nconst isGlobPattern = (pattern: string): boolean => {\n return /[*?[\\]{}]/.test(pattern);\n};\n\nconst expandGlobPatterns = async (patterns: readonly string[], excludePatterns: readonly string[] = []): Promise<string[]> => {\n const files: string[] = [];\n\n for (const pattern of patterns) {\n if (!isGlobPattern(pattern)) {\n // Direct file path - check if it exists\n try {\n await access(pattern);\n files.push(pattern);\n } catch {\n // File doesn't exist, skip it\n }\n continue;\n }\n\n // Glob pattern - use fast-glob with ignore\n const matches = await fg(pattern, {\n absolute: true,\n ignore: [...excludePatterns],\n });\n files.push(...matches);\n }\n\n return [...new Set(files)];\n};\n\nconst FORMAT_HELP = `Usage: soda-gql format [patterns...] [options]\n\nFormat soda-gql field selections by inserting empty comments.\n\nOptions:\n --config <path> Path to soda-gql.config.ts (auto-detected if omitted)\n --check Check if files need formatting (exit 1 if unformatted)\n --help, -h Show this help message\n\nExamples:\n soda-gql format # Use config include/exclude\n soda-gql format \"src/**/*.ts\" # Override with explicit patterns\n soda-gql format --check # Check mode with config\n`;\n\nexport const formatCommand = async (argv: readonly string[]): Promise<number> => {\n if (argv.includes(\"--help\") || argv.includes(\"-h\")) {\n process.stdout.write(FORMAT_HELP);\n return 0;\n }\n\n const parsed = parseArgs([...argv], FormatArgsSchema);\n\n if (!parsed.isOk()) {\n const error: FormatError = {\n code: \"PARSE_ERROR\",\n message: parsed.error,\n };\n process.stderr.write(`${formatFormatError(error)}\\n`);\n return 1;\n }\n\n const args = parsed.value;\n const isCheckMode = args.check === true;\n const explicitPatterns = args._ ?? [];\n\n // Determine patterns: use explicit patterns or load from config\n let targetPatterns: readonly string[];\n let excludePatterns: readonly string[] = [];\n\n if (explicitPatterns.length > 0) {\n targetPatterns = explicitPatterns;\n } else {\n // Try to load patterns from config\n const configResult = loadConfig(args.config);\n if (configResult.isErr()) {\n const error: FormatError = {\n code: \"NO_PATTERNS\",\n message: \"No patterns provided and config not found. Usage: soda-gql format [patterns...] [--check]\",\n };\n process.stderr.write(`${formatFormatError(error)}\\n`);\n return 1;\n }\n targetPatterns = configResult.value.include;\n excludePatterns = configResult.value.exclude;\n }\n\n // Load formatter lazily - it's an optional dependency\n const formatter = await loadFormatter();\n if (!formatter) {\n const error: FormatError = {\n code: \"FORMATTER_NOT_INSTALLED\",\n message: \"@soda-gql/formatter is not installed. Run: npm install @soda-gql/formatter\",\n };\n process.stderr.write(`${formatFormatError(error)}\\n`);\n return 1;\n }\n\n const files = await expandGlobPatterns(targetPatterns, excludePatterns);\n\n if (files.length === 0) {\n const result: FormatResult = {\n mode: isCheckMode ? \"check\" : \"format\",\n total: 0,\n modified: 0,\n unchanged: 0,\n errors: 0,\n unformatted: [],\n };\n process.stdout.write(`${formatResult(result)}\\n`);\n return 0;\n }\n\n let modified = 0;\n let unchanged = 0;\n let errors = 0;\n const unformatted: string[] = [];\n\n for (const filePath of files) {\n const sourceCode = await readFile(filePath, \"utf-8\");\n\n if (isCheckMode) {\n const result = formatter.needsFormat({ sourceCode, filePath });\n if (result.isErr()) {\n errors++;\n continue;\n }\n if (result.value) {\n unformatted.push(filePath);\n modified++;\n } else {\n unchanged++;\n }\n } else {\n const result = formatter.format({ sourceCode, filePath });\n if (result.isErr()) {\n errors++;\n continue;\n }\n if (result.value.modified) {\n await writeFile(filePath, result.value.sourceCode, \"utf-8\");\n modified++;\n } else {\n unchanged++;\n }\n }\n }\n\n const result: FormatResult = {\n mode: isCheckMode ? \"check\" : \"format\",\n total: files.length,\n modified,\n unchanged,\n errors,\n unformatted,\n };\n\n process.stdout.write(`${formatResult(result)}\\n`);\n\n if (isCheckMode && unformatted.length > 0) {\n return 1;\n }\n\n return errors > 0 ? 1 : 0;\n};\n","export const getConfigTemplate = (): string => `\\\nimport { defineConfig } from \"@soda-gql/config\";\n\nexport default defineConfig({\n outdir: \"./graphql-system\",\n include: [\"./src/**/*.ts\"],\n schemas: {\n default: {\n schema: \"./schema.graphql\",\n inject: \"./graphql-system/default.inject.ts\",\n },\n },\n});\n`;\n","export const getGitignoreTemplate = (): string => `\\\n/index.ts\n/index.cjs\n`;\n","export const getInjectTemplate = (): string => `\\\nimport { defineAdapter, defineScalar } from \"@soda-gql/core/adapter\";\n\nexport const scalar = {\n ...defineScalar<\"ID\", string, string>(\"ID\"),\n ...defineScalar<\"String\", string, string>(\"String\"),\n ...defineScalar<\"Int\", number, number>(\"Int\"),\n ...defineScalar<\"Float\", number, number>(\"Float\"),\n ...defineScalar<\"Boolean\", boolean, boolean>(\"Boolean\"),\n} as const;\n\nexport const adapter = defineAdapter({\n helpers: {},\n metadata: {\n aggregateFragmentMetadata: (fragments) => fragments.map((m) => m.metadata),\n },\n});\n`;\n","export const getSchemaTemplate = (): string => `\\\ntype Query {\n hello: String!\n}\n`;\n","import { existsSync, mkdirSync, writeFileSync } from \"node:fs\";\nimport { dirname, resolve } from \"node:path\";\nimport { err, ok, type Result } from \"neverthrow\";\n\nimport { InitArgsSchema } from \"../schemas/args\";\nimport { getConfigTemplate } from \"../templates/config.template\";\nimport { getGitignoreTemplate } from \"../templates/gitignore.template\";\nimport { getInjectTemplate } from \"../templates/inject.template\";\nimport { getSchemaTemplate } from \"../templates/schema.template\";\nimport { parseArgs } from \"../utils/parse-args\";\n\ntype InitErrorCode = \"FILE_EXISTS\" | \"WRITE_FAILED\" | \"PARSE_ERROR\";\n\ntype InitError = {\n readonly code: InitErrorCode;\n readonly message: string;\n readonly filePath?: string;\n};\n\ntype FileToGenerate = {\n readonly path: string;\n readonly content: string;\n readonly description: string;\n};\n\ntype InitSuccess = {\n readonly filesCreated: readonly string[];\n};\n\nconst INIT_HELP = `Usage: soda-gql init [options]\n\nInitialize a new soda-gql project with starter configuration.\n\nOptions:\n --force Overwrite existing files\n --help, -h Show this help message\n\nGenerated files:\n soda-gql.config.ts Configuration file\n schema.graphql Sample GraphQL schema\n graphql-system/default.inject.ts Scalars, helpers, and metadata adapter\n graphql-system/.gitignore Ignore generated files\n`;\n\nconst checkFilesExist = (files: readonly FileToGenerate[], force: boolean): Result<void, InitError> => {\n if (force) {\n return ok(undefined);\n }\n\n for (const file of files) {\n if (existsSync(file.path)) {\n return err({\n code: \"FILE_EXISTS\",\n message: `File already exists: ${file.path}. Use --force to overwrite.`,\n filePath: file.path,\n });\n }\n }\n\n return ok(undefined);\n};\n\nconst writeFiles = (files: readonly FileToGenerate[]): Result<InitSuccess, InitError> => {\n const createdPaths: string[] = [];\n\n for (const file of files) {\n try {\n const dir = dirname(file.path);\n mkdirSync(dir, { recursive: true });\n writeFileSync(file.path, file.content);\n createdPaths.push(file.path);\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n return err({\n code: \"WRITE_FAILED\",\n message: `Failed to write ${file.description}: ${message}`,\n filePath: file.path,\n });\n }\n }\n\n return ok({ filesCreated: createdPaths });\n};\n\nconst formatSuccess = (result: InitSuccess): string => {\n const lines = [\"soda-gql project initialized successfully!\", \"\", \"Created files:\"];\n for (const file of result.filesCreated) {\n lines.push(` ${file}`);\n }\n lines.push(\"\", \"Next steps:\");\n lines.push(\" 1. Edit schema.graphql with your GraphQL types\");\n lines.push(\" 2. Run: soda-gql codegen\");\n lines.push(\" 3. Import gql from ./graphql-system\");\n return lines.join(\"\\n\");\n};\n\nconst formatInitError = (error: InitError): string => {\n return `${error.code}: ${error.message}`;\n};\n\nexport const initCommand = async (argv: readonly string[]): Promise<number> => {\n if (argv.includes(\"--help\") || argv.includes(\"-h\")) {\n process.stdout.write(INIT_HELP);\n return 0;\n }\n\n const parsed = parseArgs([...argv], InitArgsSchema);\n\n if (!parsed.isOk()) {\n const error: InitError = {\n code: \"PARSE_ERROR\",\n message: parsed.error,\n };\n process.stderr.write(`${formatInitError(error)}\\n`);\n return 1;\n }\n\n const args = parsed.value;\n const force = args.force === true;\n const cwd = process.cwd();\n\n const files: FileToGenerate[] = [\n {\n path: resolve(cwd, \"soda-gql.config.ts\"),\n content: getConfigTemplate(),\n description: \"configuration file\",\n },\n {\n path: resolve(cwd, \"schema.graphql\"),\n content: getSchemaTemplate(),\n description: \"GraphQL schema\",\n },\n {\n path: resolve(cwd, \"graphql-system/default.inject.ts\"),\n content: getInjectTemplate(),\n description: \"inject module\",\n },\n {\n path: resolve(cwd, \"graphql-system/.gitignore\"),\n content: getGitignoreTemplate(),\n description: \"gitignore file\",\n },\n ];\n\n const existsCheck = checkFilesExist(files, force);\n if (existsCheck.isErr()) {\n process.stderr.write(`${formatInitError(existsCheck.error)}\\n`);\n return 1;\n }\n\n const writeResult = writeFiles(files);\n if (writeResult.isErr()) {\n process.stderr.write(`${formatInitError(writeResult.error)}\\n`);\n return 1;\n }\n\n process.stdout.write(`${formatSuccess(writeResult.value)}\\n`);\n return 0;\n};\n","export const formatters = {\n json: (data: unknown) => JSON.stringify(data, null, 2),\n human: (data: unknown) => {\n if (typeof data === \"string\") return data;\n if (data instanceof Error) return data.message;\n return JSON.stringify(data, null, 2);\n },\n} as const;\n\nexport type OutputFormat = keyof typeof formatters;\n\nexport const formatOutput = (data: unknown, format: OutputFormat = \"human\"): string => {\n return formatters[format](data);\n};\n\nexport const formatError = (error: unknown, format: OutputFormat = \"human\"): string => {\n if (format === \"json\") {\n return JSON.stringify(\n {\n error: error,\n },\n null,\n 2,\n );\n }\n return error instanceof Error ? error.message : String(error);\n};\n","import { codegenCommand } from \"./commands/codegen\";\nimport { formatCommand } from \"./commands/format\";\nimport { initCommand } from \"./commands/init\";\nimport { formatError } from \"./utils/format\";\n\nconst dispatch = async (argv: readonly string[]): Promise<number> => {\n const [command, ...rest] = argv;\n\n if (!command || command === \"--help\" || command === \"-h\") {\n process.stdout.write(`Usage: soda-gql <command> [options]\\n`);\n process.stdout.write(`\\nCommands:\\n`);\n process.stdout.write(` init Initialize a new soda-gql project\\n`);\n process.stdout.write(` codegen Generate graphql-system runtime module\\n`);\n process.stdout.write(` format Format soda-gql field selections\\n`);\n return 0;\n }\n\n if (command === \"init\") {\n return initCommand(rest);\n }\n\n if (command === \"codegen\") {\n return codegenCommand(rest);\n }\n\n if (command === \"format\") {\n return formatCommand(rest);\n }\n\n process.stderr.write(`Unknown command: ${command}\\n`);\n return 1;\n};\n\n// Run CLI when executed directly\ndispatch(process.argv.slice(2))\n .then((exitCode) => {\n process.exitCode = exitCode;\n })\n .catch((error) => {\n const message = error instanceof Error ? error.message : String(error);\n const unexpectedError = {\n code: \"UNEXPECTED_ERROR\",\n message,\n };\n process.stderr.write(`${formatError(unexpectedError, \"json\")}\\n`);\n process.exitCode = 1;\n });\n\nexport { dispatch };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,MAAa,oBAAoBA,MAAE,OAAO;CACxC,QAAQA,MAAE,QAAQ,CAAC,UAAU;CAC7B,wBAAwBA,MAAE,QAAQ,CAAC,UAAU;CAC9C,CAAC;AAEF,MAAa,oBAAoBA,MAAE,OAAO;CACxC,MAAMA,MAAE,KAAK,CAAC,WAAW,eAAe,CAAC;CACzC,OAAOA,MAAE,QAAQ;CACjB,KAAKA,MAAE,QAAQ;CACf,QAAQA,MAAE,KAAK,CAAC,SAAS,OAAO,CAAC,CAAC,UAAU,CAAC,QAAQ,QAAQ;CAC9D,CAAC;AAEF,MAAa,mBAAmBA,MAAE,OAAO;CACvC,GAAGA,MAAE,MAAMA,MAAE,QAAQ,CAAC,CAAC,UAAU;CACjC,QAAQA,MAAE,QAAQ,CAAC,UAAU;CAC7B,OAAOA,MAAE,SAAS,CAAC,UAAU;CAC9B,CAAC;AAEF,MAAa,iBAAiBA,MAAE,OAAO,EACrC,OAAOA,MAAE,SAAS,CAAC,UAAU,EAC9B,CAAC;;;;ACnBF,MAAa,aAAkC,MAAgB,WAA0C;CACvG,MAAMC,SAAkC,EAAE;CAC1C,MAAMC,aAAuB,EAAE;AAE/B,MAAK,IAAI,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;EACpC,MAAM,MAAM,KAAK;AACjB,MAAI,CAAC,IAAK;AAEV,M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O;;;;;AC9IT,MAAa,eAAe,OAAgB,SAAuB,YAAoB;AACrF,KAAI,WAAW,OACb,QAAO,KAAK,UACV,EACS,OACR,EACD,MACA,EACD;AAEH,QAAO,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM;;;;;ACpB/D,MAAM,WAAW,OAAO,SAA6C;CACnE,MAAM,CAAC,SAAS,GAAG,QAAQ;AAE3B,KAAI,CAAC,WAAW,YAAY,YAAY,YAAY,MAAM;AACxD,UAAQ,OAAO,MAAM,wCAAwC;AAC7D,UAAQ,OAAO,MAAM,gBAAgB;AACrC,UAAQ,OAAO,MAAM,mDAAmD;AACxE,UAAQ,OAAO,MAAM,wDAAwD;AAC7E,UAAQ,OAAO,MAAM,kDAAkD;AACvE,SAAO;;AAGT,KAAI,YAAY,OACd,QAAO,YAAY,KAAK;AAG1B,KAAI,YAAY,UACd,QAAO,eAAe,KAAK;AAG7B,KAAI,YAAY,SACd,QAAO,cAAc,KAAK;AAG5B,SAAQ,OAAO,MAAM,oBAAoB,QAAQ,IAAI;AACrD,QAAO;;AAIT,SAAS,QAAQ,KAAK,MAAM,EAAE,CAAC,CAC5B,MAAM,aAAa;AAClB,SAAQ,WAAW;EACnB,CACD,OAAO,UAAU;CAEhB,MAAM,kBAAkB;EACtB,MAAM;EACN,SAHc,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM;EAIrE;AACD,SAAQ,OAAO,MAAM,GAAG,YAAY,iBAAiB,OAAO,CAAC,IAAI;AACjE,SAAQ,WAAW;EACnB"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.ts"],"sourcesContent":[],"mappings":";cAGM,uCAA4C"}
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.ts"],"sourcesContent":[],"mappings":";cAKM,uCAA4C"}
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "@soda-gql/cli",
3
- "version": "0.1.0",
3
+ "version": "0.3.0",
4
+ "description": "Command-line interface for soda-gql",
4
5
  "type": "module",
5
6
  "private": false,
6
7
  "license": "MIT",
@@ -15,12 +16,31 @@
15
16
  "email": "shota.hatada@whatasoda.me",
16
17
  "url": "https://github.com/whatasoda"
17
18
  },
19
+ "keywords": [
20
+ "graphql",
21
+ "codegen",
22
+ "zero-runtime",
23
+ "typescript",
24
+ "cli"
25
+ ],
26
+ "repository": {
27
+ "type": "git",
28
+ "url": "https://github.com/whatasoda/soda-gql.git",
29
+ "directory": "packages/cli"
30
+ },
31
+ "homepage": "https://github.com/whatasoda/soda-gql#readme",
32
+ "bugs": {
33
+ "url": "https://github.com/whatasoda/soda-gql/issues"
34
+ },
35
+ "engines": {
36
+ "node": ">=18"
37
+ },
18
38
  "main": "./dist/index.cjs",
19
39
  "module": "./dist/index.cjs",
20
40
  "types": "./dist/index.d.cts",
21
41
  "exports": {
22
42
  ".": {
23
- "@soda-gql": "./src/index.ts",
43
+ "@soda-gql": "./@x-index.ts",
24
44
  "types": "./dist/index.d.cts",
25
45
  "require": "./dist/index.cjs",
26
46
  "default": "./dist/index.cjs"
@@ -28,11 +48,15 @@
28
48
  "./package.json": "./package.json"
29
49
  },
30
50
  "dependencies": {
31
- "@soda-gql/codegen": "0.1.0",
32
- "@soda-gql/builder": "0.1.0",
51
+ "@soda-gql/codegen": "0.3.0",
52
+ "@soda-gql/builder": "0.3.0",
53
+ "fast-glob": "^3.3.3",
33
54
  "neverthrow": "^8.1.1",
34
55
  "zod": "^4.1.11"
35
56
  },
36
57
  "devDependencies": {},
37
- "peerDependencies": {}
58
+ "peerDependencies": {},
59
+ "optionalDependencies": {
60
+ "@soda-gql/formatter": "workspace:*"
61
+ }
38
62
  }