@soda-gql/cli 0.8.2 → 0.9.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/dist/index.cjs CHANGED
@@ -33,9 +33,9 @@ let __soda_gql_builder = require("@soda-gql/builder");
33
33
  let __soda_gql_config = require("@soda-gql/config");
34
34
  let __soda_gql_codegen = require("@soda-gql/codegen");
35
35
  let zod = require("zod");
36
+ let node_fs = require("node:fs");
36
37
  let fast_glob = require("fast-glob");
37
38
  fast_glob = __toESM(fast_glob);
38
- let node_fs = require("node:fs");
39
39
 
40
40
  //#region packages/cli/src/errors.ts
41
41
  /**
@@ -436,6 +436,490 @@ const codegenCommand = async (argv) => {
436
436
  });
437
437
  };
438
438
 
439
+ //#endregion
440
+ //#region packages/cli/src/commands/doctor/checks/codegen-freshness.ts
441
+ /**
442
+ * Codegen freshness check.
443
+ * @module
444
+ */
445
+ /**
446
+ * Check if generated code is newer than schema files.
447
+ */
448
+ const checkCodegenFreshness = () => {
449
+ const configPath = (0, __soda_gql_config.findConfigFile)();
450
+ if (!configPath) return {
451
+ name: "Codegen Freshness",
452
+ status: "skip",
453
+ message: "No soda-gql.config.ts found",
454
+ data: { schemas: [] }
455
+ };
456
+ const configResult = (0, __soda_gql_config.loadConfig)(configPath);
457
+ if (configResult.isErr()) return {
458
+ name: "Codegen Freshness",
459
+ status: "skip",
460
+ message: "Could not load config",
461
+ data: { schemas: [] }
462
+ };
463
+ const config = configResult.value;
464
+ const generatedPath = (0, node_path.join)(config.outdir, "index.ts");
465
+ if (!(0, node_fs.existsSync)(generatedPath)) return {
466
+ name: "Codegen Freshness",
467
+ status: "warn",
468
+ message: "Generated code not found - run codegen",
469
+ data: { schemas: [] },
470
+ fix: "Run: soda-gql codegen"
471
+ };
472
+ const generatedMtime = (0, node_fs.statSync)(generatedPath).mtimeMs;
473
+ const schemaResults = [];
474
+ let hasStale = false;
475
+ for (const [name, schemaConfig] of Object.entries(config.schemas)) {
476
+ if (!(0, node_fs.existsSync)(schemaConfig.schema)) continue;
477
+ const schemaMtime = (0, node_fs.statSync)(schemaConfig.schema).mtimeMs;
478
+ const isStale = schemaMtime > generatedMtime;
479
+ if (isStale) hasStale = true;
480
+ schemaResults.push({
481
+ name,
482
+ schemaPath: schemaConfig.schema,
483
+ generatedPath,
484
+ schemaMtime,
485
+ generatedMtime,
486
+ isStale
487
+ });
488
+ }
489
+ if (hasStale) return {
490
+ name: "Codegen Freshness",
491
+ status: "warn",
492
+ message: `Schema modified after codegen: ${schemaResults.filter((s) => s.isStale).map((s) => s.name).join(", ")}`,
493
+ data: { schemas: schemaResults },
494
+ fix: "Run: soda-gql codegen"
495
+ };
496
+ return {
497
+ name: "Codegen Freshness",
498
+ status: "pass",
499
+ message: "Generated code is up to date",
500
+ data: { schemas: schemaResults }
501
+ };
502
+ };
503
+
504
+ //#endregion
505
+ //#region packages/cli/src/commands/doctor/checks/config-validation.ts
506
+ /**
507
+ * Config validation check.
508
+ * @module
509
+ */
510
+ /**
511
+ * Check that config file is valid and referenced files exist.
512
+ */
513
+ const checkConfigValidation = () => {
514
+ const configPath = (0, __soda_gql_config.findConfigFile)();
515
+ if (!configPath) return {
516
+ name: "Config Validation",
517
+ status: "skip",
518
+ message: "No soda-gql.config.ts found",
519
+ data: {
520
+ configPath: null,
521
+ missingFiles: []
522
+ }
523
+ };
524
+ const configResult = (0, __soda_gql_config.loadConfig)(configPath);
525
+ if (configResult.isErr()) return {
526
+ name: "Config Validation",
527
+ status: "fail",
528
+ message: `Config error: ${configResult.error.message}`,
529
+ data: {
530
+ configPath,
531
+ missingFiles: []
532
+ },
533
+ fix: "Check your soda-gql.config.ts for syntax errors"
534
+ };
535
+ const config = configResult.value;
536
+ const missingFiles = [];
537
+ for (const [name, schemaConfig] of Object.entries(config.schemas)) {
538
+ if (!(0, node_fs.existsSync)(schemaConfig.schema)) missingFiles.push(`Schema '${name}': ${schemaConfig.schema}`);
539
+ if (!(0, node_fs.existsSync)(schemaConfig.inject.scalars)) missingFiles.push(`Scalars '${name}': ${schemaConfig.inject.scalars}`);
540
+ if (schemaConfig.inject.adapter && !(0, node_fs.existsSync)(schemaConfig.inject.adapter)) missingFiles.push(`Adapter '${name}': ${schemaConfig.inject.adapter}`);
541
+ }
542
+ if (missingFiles.length > 0) return {
543
+ name: "Config Validation",
544
+ status: "fail",
545
+ message: `${missingFiles.length} referenced file(s) not found`,
546
+ data: {
547
+ configPath,
548
+ missingFiles
549
+ },
550
+ fix: "Create the missing files or update paths in config"
551
+ };
552
+ return {
553
+ name: "Config Validation",
554
+ status: "pass",
555
+ message: "Config loaded successfully",
556
+ data: {
557
+ configPath,
558
+ missingFiles: []
559
+ }
560
+ };
561
+ };
562
+
563
+ //#endregion
564
+ //#region packages/cli/src/commands/doctor/discovery.ts
565
+ /**
566
+ * Package discovery utilities for doctor command.
567
+ * @module
568
+ */
569
+ const SODA_GQL_SCOPE = "@soda-gql";
570
+ /**
571
+ * Find the nearest node_modules directory.
572
+ */
573
+ const findNodeModules = (startDir = process.cwd()) => {
574
+ let currentDir = startDir;
575
+ while (currentDir !== (0, node_path.dirname)(currentDir)) {
576
+ const nodeModulesPath = (0, node_path.join)(currentDir, "node_modules");
577
+ if ((0, node_fs.existsSync)(nodeModulesPath) && (0, node_fs.statSync)(nodeModulesPath).isDirectory()) return nodeModulesPath;
578
+ currentDir = (0, node_path.dirname)(currentDir);
579
+ }
580
+ return null;
581
+ };
582
+ /**
583
+ * Read package.json from a directory.
584
+ */
585
+ const readPackageJson = (dir) => {
586
+ const packageJsonPath = (0, node_path.join)(dir, "package.json");
587
+ try {
588
+ const content = (0, node_fs.readFileSync)(packageJsonPath, "utf-8");
589
+ const pkg = JSON.parse(content);
590
+ if (!pkg.name || !pkg.version) return (0, neverthrow.err)(`Invalid package.json at ${packageJsonPath}`);
591
+ return (0, neverthrow.ok)({
592
+ name: pkg.name,
593
+ version: pkg.version
594
+ });
595
+ } catch {
596
+ return (0, neverthrow.err)(`Failed to read package.json at ${packageJsonPath}`);
597
+ }
598
+ };
599
+ /**
600
+ * Discover @soda-gql packages at a specific node_modules path.
601
+ */
602
+ const discoverAtPath = (nodeModulesPath) => {
603
+ const scopePath = (0, node_path.join)(nodeModulesPath, SODA_GQL_SCOPE);
604
+ if (!(0, node_fs.existsSync)(scopePath)) return [];
605
+ const packages = [];
606
+ try {
607
+ const entries = (0, node_fs.readdirSync)(scopePath, { withFileTypes: true });
608
+ for (const entry of entries) {
609
+ if (!entry.isDirectory()) continue;
610
+ const packageDir = (0, node_path.join)(scopePath, entry.name);
611
+ const result = readPackageJson(packageDir);
612
+ if (result.isOk()) packages.push({
613
+ name: result.value.name,
614
+ version: result.value.version,
615
+ path: packageDir
616
+ });
617
+ }
618
+ } catch {}
619
+ return packages;
620
+ };
621
+ /**
622
+ * Discover all @soda-gql packages including nested node_modules.
623
+ * Uses breadth-first search to avoid deep recursion.
624
+ */
625
+ const discoverAllSodaGqlPackages = (startDir = process.cwd()) => {
626
+ const rootNodeModules = findNodeModules(startDir);
627
+ if (!rootNodeModules) return (0, neverthrow.err)("No node_modules directory found");
628
+ const allPackages = [];
629
+ const visitedPaths = /* @__PURE__ */ new Set();
630
+ const queue = [rootNodeModules];
631
+ while (queue.length > 0) {
632
+ const nodeModulesPath = queue.shift();
633
+ if (!nodeModulesPath) continue;
634
+ let realPath;
635
+ try {
636
+ realPath = (0, node_path.resolve)(nodeModulesPath);
637
+ } catch {
638
+ continue;
639
+ }
640
+ if (visitedPaths.has(realPath)) continue;
641
+ visitedPaths.add(realPath);
642
+ const packages = discoverAtPath(nodeModulesPath);
643
+ allPackages.push(...packages);
644
+ try {
645
+ const entries = (0, node_fs.readdirSync)(nodeModulesPath, { withFileTypes: true });
646
+ for (const entry of entries) {
647
+ if (!entry.isDirectory()) continue;
648
+ if (entry.name.startsWith("@")) {
649
+ const scopeDir = (0, node_path.join)(nodeModulesPath, entry.name);
650
+ try {
651
+ const scopeEntries = (0, node_fs.readdirSync)(scopeDir, { withFileTypes: true });
652
+ for (const scopeEntry of scopeEntries) {
653
+ if (!scopeEntry.isDirectory()) continue;
654
+ const nestedNodeModules = (0, node_path.join)(scopeDir, scopeEntry.name, "node_modules");
655
+ if ((0, node_fs.existsSync)(nestedNodeModules)) queue.push(nestedNodeModules);
656
+ }
657
+ } catch {}
658
+ } else {
659
+ const nestedNodeModules = (0, node_path.join)(nodeModulesPath, entry.name, "node_modules");
660
+ if ((0, node_fs.existsSync)(nestedNodeModules)) queue.push(nestedNodeModules);
661
+ }
662
+ }
663
+ } catch {}
664
+ }
665
+ return (0, neverthrow.ok)(allPackages);
666
+ };
667
+ /**
668
+ * Get the soda-gql CLI version.
669
+ */
670
+ const getCliVersion = () => {
671
+ try {
672
+ const content = (0, node_fs.readFileSync)((0, node_path.join)(__dirname, "..", "..", "..", "package.json"), "utf-8");
673
+ return JSON.parse(content).version ?? "unknown";
674
+ } catch {
675
+ return "unknown";
676
+ }
677
+ };
678
+ /**
679
+ * Get TypeScript version from node_modules.
680
+ */
681
+ const getTypescriptVersion = (startDir = process.cwd()) => {
682
+ const nodeModulesPath = findNodeModules(startDir);
683
+ if (!nodeModulesPath) return null;
684
+ const tsPackageJson = (0, node_path.join)(nodeModulesPath, "typescript", "package.json");
685
+ try {
686
+ const content = (0, node_fs.readFileSync)(tsPackageJson, "utf-8");
687
+ return JSON.parse(content).version ?? null;
688
+ } catch {
689
+ return null;
690
+ }
691
+ };
692
+
693
+ //#endregion
694
+ //#region packages/cli/src/commands/doctor/checks/duplicate-packages.ts
695
+ /**
696
+ * Duplicate packages check.
697
+ * @module
698
+ */
699
+ /**
700
+ * Check for duplicate @soda-gql packages installed at different paths.
701
+ */
702
+ const checkDuplicatePackages = () => {
703
+ const packagesResult = discoverAllSodaGqlPackages();
704
+ if (packagesResult.isErr()) return {
705
+ name: "Duplicate Packages",
706
+ status: "skip",
707
+ message: packagesResult.error,
708
+ data: { duplicates: [] }
709
+ };
710
+ const packages = packagesResult.value;
711
+ const byName = /* @__PURE__ */ new Map();
712
+ for (const pkg of packages) {
713
+ const existing = byName.get(pkg.name) ?? [];
714
+ existing.push(pkg);
715
+ byName.set(pkg.name, existing);
716
+ }
717
+ const duplicates = [];
718
+ for (const [name, instances] of byName) if (instances.length > 1) duplicates.push({
719
+ name,
720
+ instances: instances.map((i) => ({
721
+ path: i.path,
722
+ version: i.version
723
+ }))
724
+ });
725
+ if (duplicates.length === 0) return {
726
+ name: "Duplicate Packages",
727
+ status: "pass",
728
+ message: "No duplicate packages detected",
729
+ data: { duplicates: [] }
730
+ };
731
+ return {
732
+ name: "Duplicate Packages",
733
+ status: "warn",
734
+ message: `Duplicate packages found: ${duplicates.map((d) => d.name).join(", ")}`,
735
+ data: { duplicates },
736
+ fix: "Run: rm -rf node_modules && bun install"
737
+ };
738
+ };
739
+
740
+ //#endregion
741
+ //#region packages/cli/src/commands/doctor/checks/version-consistency.ts
742
+ /**
743
+ * Version consistency check.
744
+ * @module
745
+ */
746
+ /**
747
+ * Check that all @soda-gql packages have consistent versions.
748
+ */
749
+ const checkVersionConsistency = () => {
750
+ const packagesResult = discoverAllSodaGqlPackages();
751
+ if (packagesResult.isErr()) return {
752
+ name: "Version Consistency",
753
+ status: "skip",
754
+ message: packagesResult.error,
755
+ data: {
756
+ packages: [],
757
+ expectedVersion: null
758
+ }
759
+ };
760
+ const packages = packagesResult.value;
761
+ if (packages.length === 0) return {
762
+ name: "Version Consistency",
763
+ status: "skip",
764
+ message: "No @soda-gql packages found",
765
+ data: {
766
+ packages: [],
767
+ expectedVersion: null
768
+ }
769
+ };
770
+ const byName = /* @__PURE__ */ new Map();
771
+ for (const pkg of packages) {
772
+ const existing = byName.get(pkg.name) ?? [];
773
+ existing.push(pkg);
774
+ byName.set(pkg.name, existing);
775
+ }
776
+ const uniquePackages = Array.from(byName.values()).map((instances) => instances[0]).filter((pkg) => pkg !== void 0);
777
+ const versionCounts = /* @__PURE__ */ new Map();
778
+ for (const pkg of uniquePackages) versionCounts.set(pkg.version, (versionCounts.get(pkg.version) ?? 0) + 1);
779
+ let expectedVersion = uniquePackages[0]?.version ?? null;
780
+ let maxCount = 0;
781
+ for (const [version, count] of versionCounts) if (count > maxCount) {
782
+ maxCount = count;
783
+ expectedVersion = version;
784
+ }
785
+ const packageResults = uniquePackages.map((pkg) => ({
786
+ name: pkg.name,
787
+ version: pkg.version,
788
+ path: pkg.path,
789
+ isMismatch: pkg.version !== expectedVersion
790
+ }));
791
+ const mismatches = packageResults.filter((p) => p.isMismatch);
792
+ if (mismatches.length === 0) return {
793
+ name: "Version Consistency",
794
+ status: "pass",
795
+ message: `All ${uniquePackages.length} packages at version ${expectedVersion}`,
796
+ data: {
797
+ packages: packageResults,
798
+ expectedVersion
799
+ }
800
+ };
801
+ return {
802
+ name: "Version Consistency",
803
+ status: "fail",
804
+ message: `Version mismatch: ${mismatches.map((p) => p.name).join(", ")}`,
805
+ data: {
806
+ packages: packageResults,
807
+ expectedVersion
808
+ },
809
+ fix: `Run: bun update ${mismatches.map((p) => p.name).join(" ")}`
810
+ };
811
+ };
812
+
813
+ //#endregion
814
+ //#region packages/cli/src/commands/doctor/output.ts
815
+ const STATUS_SYMBOLS = {
816
+ pass: "✓",
817
+ warn: "!",
818
+ fail: "✗",
819
+ skip: "-"
820
+ };
821
+ /**
822
+ * Type guard to check if data is an object (not null/primitive).
823
+ */
824
+ const isObject = (data) => {
825
+ return typeof data === "object" && data !== null;
826
+ };
827
+ /**
828
+ * Format a single check result for human output.
829
+ */
830
+ const formatCheckResult = (result) => {
831
+ const lines = [];
832
+ const symbol = STATUS_SYMBOLS[result.status];
833
+ lines.push(`${symbol} ${result.message}`);
834
+ if (result.status === "fail" || result.status === "warn") {
835
+ const data = result.data;
836
+ if (isObject(data) && "packages" in data && "expectedVersion" in data) {
837
+ const versionData = data;
838
+ const mismatched = versionData.packages.filter((p) => p.isMismatch);
839
+ for (const pkg of mismatched) lines.push(` ${pkg.name}: ${pkg.version} <- mismatch`);
840
+ if (versionData.expectedVersion && mismatched.length > 0) lines.push(` Expected: ${versionData.expectedVersion}`);
841
+ }
842
+ if (isObject(data) && "duplicates" in data) {
843
+ const dupData = data;
844
+ for (const dup of dupData.duplicates) {
845
+ lines.push(` ${dup.name}:`);
846
+ for (const instance of dup.instances) lines.push(` ${instance.version} at ${instance.path}`);
847
+ }
848
+ }
849
+ if (result.fix) {
850
+ lines.push("");
851
+ lines.push(` Fix: ${result.fix}`);
852
+ }
853
+ }
854
+ return lines;
855
+ };
856
+ /**
857
+ * Format the complete doctor result for human output.
858
+ */
859
+ const formatDoctorResult = (result) => {
860
+ const lines = [];
861
+ lines.push(`soda-gql doctor v${result.version}`);
862
+ lines.push("");
863
+ for (const check of result.checks) {
864
+ lines.push(...formatCheckResult(check));
865
+ lines.push("");
866
+ }
867
+ const passed = result.checks.filter((c) => c.status === "pass").length;
868
+ if (result.issueCount === 0 && result.warningCount === 0) lines.push(`Summary: All ${passed} checks passed`);
869
+ else {
870
+ const parts = [];
871
+ if (result.issueCount > 0) parts.push(`${result.issueCount} issue${result.issueCount > 1 ? "s" : ""}`);
872
+ if (result.warningCount > 0) parts.push(`${result.warningCount} warning${result.warningCount > 1 ? "s" : ""}`);
873
+ lines.push(`Summary: ${parts.join(", ")} found`);
874
+ }
875
+ return lines.join("\n");
876
+ };
877
+
878
+ //#endregion
879
+ //#region packages/cli/src/commands/doctor/index.ts
880
+ /**
881
+ * Doctor command entry point.
882
+ * @module
883
+ */
884
+ const DOCTOR_HELP = `Usage: soda-gql doctor
885
+
886
+ Run diagnostic checks on your soda-gql installation.
887
+
888
+ Checks performed:
889
+ - Version consistency across @soda-gql packages
890
+ - Duplicate package detection
891
+ - Config file validation
892
+ - Codegen freshness (schema vs generated code)
893
+
894
+ Options:
895
+ --help, -h Show this help message
896
+ `;
897
+ const doctorCommand = (argv) => {
898
+ if (argv.includes("--help") || argv.includes("-h")) return (0, neverthrow.ok)({ message: DOCTOR_HELP });
899
+ const version = getCliVersion();
900
+ const tsVersion = getTypescriptVersion();
901
+ const checks = [];
902
+ if (tsVersion) checks.push({
903
+ name: "TypeScript Version",
904
+ status: "pass",
905
+ message: `TypeScript version: ${tsVersion}`
906
+ });
907
+ checks.push(checkVersionConsistency());
908
+ checks.push(checkDuplicatePackages());
909
+ checks.push(checkConfigValidation());
910
+ checks.push(checkCodegenFreshness());
911
+ const result = {
912
+ version,
913
+ checks,
914
+ issueCount: checks.filter((c) => c.status === "fail").length,
915
+ warningCount: checks.filter((c) => c.status === "warn").length
916
+ };
917
+ return (0, neverthrow.ok)({
918
+ message: formatDoctorResult(result),
919
+ data: result
920
+ });
921
+ };
922
+
439
923
  //#endregion
440
924
  //#region packages/cli/src/commands/format.ts
441
925
  const loadFormatter = async () => {
@@ -830,6 +1314,7 @@ Commands:
830
1314
  codegen Generate graphql-system runtime module
831
1315
  format Format soda-gql field selections
832
1316
  artifact Manage soda-gql artifacts
1317
+ doctor Run diagnostic checks
833
1318
 
834
1319
  Run 'soda-gql <command> --help' for more information on a specific command.
835
1320
  `;
@@ -861,6 +1346,17 @@ const dispatch = async (argv) => {
861
1346
  return (0, neverthrow.err)(result.error);
862
1347
  }
863
1348
  if (command === "artifact") return artifactCommand(rest);
1349
+ if (command === "doctor") {
1350
+ const result = doctorCommand(rest);
1351
+ if (result.isOk()) {
1352
+ const exitCode = result.value.data?.issueCount ? 1 : 0;
1353
+ return (0, neverthrow.ok)({
1354
+ ...result.value,
1355
+ exitCode
1356
+ });
1357
+ }
1358
+ return result;
1359
+ }
864
1360
  return (0, neverthrow.err)(cliErrors.unknownCommand(command));
865
1361
  };
866
1362
  const main = async () => {
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["args: BuildArgs","formatSuccess","lines: string[]","meta: BuilderArtifactMeta | undefined","artifactWithMeta: BuilderArtifact","data: BuildData","data","args: ValidateArgs","formatSuccess","lines: string[]","z","parsed: Record<string, unknown>","positional: string[]","schemas: Record<string, CodegenSchemaConfig>","formatSuccess","result","resolvedSchemas: Record<string, CodegenSchemaConfig>","parts: string[]","files: string[]","targetPatterns: readonly string[]","excludePatterns: readonly string[]","data: FormatData","data","unformatted: string[]","createdPaths: string[]","files: FileToGenerate[]","cliErrorHints: Partial<Record<CliErrorCode, string>>","codegenErrorHints: Record<string, string>","configErrorHints: Record<string, string>","artifactErrorHints: Record<string, string>","lines: string[]"],"sources":["../src/errors.ts","../src/commands/artifact/build.ts","../src/commands/artifact/validate.ts","../src/commands/artifact/index.ts","../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":["/**\n * Unified CLI error types and constructors.\n * @module\n */\n\nimport type { ArtifactLoadError, BuilderError } from \"@soda-gql/builder\";\nimport type { CodegenError } from \"@soda-gql/codegen\";\nimport type { ConfigError } from \"@soda-gql/config\";\nimport { err, type Result } from \"neverthrow\";\n\n/**\n * CLI-specific error codes.\n */\nexport type CliErrorCode =\n // Argument parsing errors\n | \"CLI_ARGS_INVALID\"\n | \"CLI_UNKNOWN_COMMAND\"\n | \"CLI_UNKNOWN_SUBCOMMAND\"\n // File operation errors\n | \"CLI_FILE_EXISTS\"\n | \"CLI_FILE_NOT_FOUND\"\n | \"CLI_WRITE_FAILED\"\n | \"CLI_READ_FAILED\"\n // Format command specific\n | \"CLI_NO_PATTERNS\"\n | \"CLI_FORMATTER_NOT_INSTALLED\"\n | \"CLI_PARSE_ERROR\"\n | \"CLI_FORMAT_ERROR\"\n // Unexpected errors\n | \"CLI_UNEXPECTED\";\n\n/**\n * Unified CLI error discriminated union.\n * Wraps external errors (codegen, builder, config) and defines CLI-specific errors.\n */\nexport type CliError =\n // Wrapped external errors (preserve original structure)\n | { readonly category: \"codegen\"; readonly error: CodegenError }\n | { readonly category: \"builder\"; readonly error: BuilderError }\n | { readonly category: \"artifact\"; readonly error: ArtifactLoadError }\n | { readonly category: \"config\"; readonly error: ConfigError }\n // CLI-specific errors\n | {\n readonly category: \"cli\";\n readonly code: \"CLI_ARGS_INVALID\";\n readonly message: string;\n readonly command: string;\n }\n | {\n readonly category: \"cli\";\n readonly code: \"CLI_UNKNOWN_COMMAND\";\n readonly message: string;\n readonly command: string;\n }\n | {\n readonly category: \"cli\";\n readonly code: \"CLI_UNKNOWN_SUBCOMMAND\";\n readonly message: string;\n readonly parent: string;\n readonly subcommand: string;\n }\n | {\n readonly category: \"cli\";\n readonly code: \"CLI_FILE_EXISTS\";\n readonly message: string;\n readonly filePath: string;\n }\n | {\n readonly category: \"cli\";\n readonly code: \"CLI_FILE_NOT_FOUND\";\n readonly message: string;\n readonly filePath: string;\n }\n | {\n readonly category: \"cli\";\n readonly code: \"CLI_WRITE_FAILED\";\n readonly message: string;\n readonly filePath: string;\n readonly cause?: unknown;\n }\n | {\n readonly category: \"cli\";\n readonly code: \"CLI_READ_FAILED\";\n readonly message: string;\n readonly filePath: string;\n readonly cause?: unknown;\n }\n | {\n readonly category: \"cli\";\n readonly code: \"CLI_NO_PATTERNS\";\n readonly message: string;\n }\n | {\n readonly category: \"cli\";\n readonly code: \"CLI_FORMATTER_NOT_INSTALLED\";\n readonly message: string;\n }\n | {\n readonly category: \"cli\";\n readonly code: \"CLI_PARSE_ERROR\";\n readonly message: string;\n readonly filePath?: string;\n }\n | {\n readonly category: \"cli\";\n readonly code: \"CLI_FORMAT_ERROR\";\n readonly message: string;\n readonly filePath?: string;\n }\n | {\n readonly category: \"cli\";\n readonly code: \"CLI_UNEXPECTED\";\n readonly message: string;\n readonly cause?: unknown;\n };\n\n/**\n * Result type for CLI operations.\n */\nexport type CliResult<T> = Result<T, CliError>;\n\n// Extract CLI-specific error types for type-safe constructors\ntype CliArgsInvalidError = Extract<CliError, { code: \"CLI_ARGS_INVALID\" }>;\ntype CliUnknownCommandError = Extract<CliError, { code: \"CLI_UNKNOWN_COMMAND\" }>;\ntype CliUnknownSubcommandError = Extract<CliError, { code: \"CLI_UNKNOWN_SUBCOMMAND\" }>;\ntype CliFileExistsError = Extract<CliError, { code: \"CLI_FILE_EXISTS\" }>;\ntype CliFileNotFoundError = Extract<CliError, { code: \"CLI_FILE_NOT_FOUND\" }>;\ntype CliWriteFailedError = Extract<CliError, { code: \"CLI_WRITE_FAILED\" }>;\ntype CliReadFailedError = Extract<CliError, { code: \"CLI_READ_FAILED\" }>;\ntype CliNoPatternsError = Extract<CliError, { code: \"CLI_NO_PATTERNS\" }>;\ntype CliFormatterNotInstalledError = Extract<CliError, { code: \"CLI_FORMATTER_NOT_INSTALLED\" }>;\ntype CliParseErrorError = Extract<CliError, { code: \"CLI_PARSE_ERROR\" }>;\ntype CliFormatErrorError = Extract<CliError, { code: \"CLI_FORMAT_ERROR\" }>;\ntype CliUnexpectedError = Extract<CliError, { code: \"CLI_UNEXPECTED\" }>;\ntype CliCodegenError = Extract<CliError, { category: \"codegen\" }>;\ntype CliBuilderError = Extract<CliError, { category: \"builder\" }>;\ntype CliArtifactError = Extract<CliError, { category: \"artifact\" }>;\ntype CliConfigError = Extract<CliError, { category: \"config\" }>;\n\n/**\n * Error constructor helpers for concise error creation.\n * Each function returns a specific error type for better type inference.\n */\nexport const cliErrors = {\n argsInvalid: (command: string, message: string): CliArgsInvalidError => ({\n category: \"cli\",\n code: \"CLI_ARGS_INVALID\",\n message,\n command,\n }),\n\n unknownCommand: (command: string): CliUnknownCommandError => ({\n category: \"cli\",\n code: \"CLI_UNKNOWN_COMMAND\",\n message: `Unknown command: ${command}`,\n command,\n }),\n\n unknownSubcommand: (parent: string, subcommand: string): CliUnknownSubcommandError => ({\n category: \"cli\",\n code: \"CLI_UNKNOWN_SUBCOMMAND\",\n message: `Unknown subcommand: ${subcommand}`,\n parent,\n subcommand,\n }),\n\n fileExists: (filePath: string, message?: string): CliFileExistsError => ({\n category: \"cli\",\n code: \"CLI_FILE_EXISTS\",\n message: message ?? `File already exists: ${filePath}. Use --force to overwrite.`,\n filePath,\n }),\n\n fileNotFound: (filePath: string, message?: string): CliFileNotFoundError => ({\n category: \"cli\",\n code: \"CLI_FILE_NOT_FOUND\",\n message: message ?? `File not found: ${filePath}`,\n filePath,\n }),\n\n writeFailed: (filePath: string, message?: string, cause?: unknown): CliWriteFailedError => ({\n category: \"cli\",\n code: \"CLI_WRITE_FAILED\",\n message: message ?? `Failed to write file: ${filePath}`,\n filePath,\n cause,\n }),\n\n readFailed: (filePath: string, message?: string, cause?: unknown): CliReadFailedError => ({\n category: \"cli\",\n code: \"CLI_READ_FAILED\",\n message: message ?? `Failed to read file: ${filePath}`,\n filePath,\n cause,\n }),\n\n noPatterns: (message?: string): CliNoPatternsError => ({\n category: \"cli\",\n code: \"CLI_NO_PATTERNS\",\n message: message ?? \"No patterns provided and config not found. Usage: soda-gql format [patterns...] [--check]\",\n }),\n\n formatterNotInstalled: (message?: string): CliFormatterNotInstalledError => ({\n category: \"cli\",\n code: \"CLI_FORMATTER_NOT_INSTALLED\",\n message: message ?? \"@soda-gql/formatter is not installed. Run: bun add @soda-gql/formatter\",\n }),\n\n parseError: (message: string, filePath?: string): CliParseErrorError => ({\n category: \"cli\",\n code: \"CLI_PARSE_ERROR\",\n message,\n filePath,\n }),\n\n formatError: (message: string, filePath?: string): CliFormatErrorError => ({\n category: \"cli\",\n code: \"CLI_FORMAT_ERROR\",\n message,\n filePath,\n }),\n\n unexpected: (message: string, cause?: unknown): CliUnexpectedError => ({\n category: \"cli\",\n code: \"CLI_UNEXPECTED\",\n message,\n cause,\n }),\n\n // Wrappers for external errors\n fromCodegen: (error: CodegenError): CliCodegenError => ({\n category: \"codegen\",\n error,\n }),\n\n fromBuilder: (error: BuilderError): CliBuilderError => ({\n category: \"builder\",\n error,\n }),\n\n fromArtifact: (error: ArtifactLoadError): CliArtifactError => ({\n category: \"artifact\",\n error,\n }),\n\n fromConfig: (error: ConfigError): CliConfigError => ({\n category: \"config\",\n error,\n }),\n} as const;\n\n/**\n * Convenience helper to create an err Result from CliError.\n */\nexport const cliErr = <T = never>(error: CliError): CliResult<T> => err(error);\n\n/**\n * Type guard to check if error is a CLI-specific error.\n */\nexport const isCliError = (error: CliError): error is CliError & { category: \"cli\" } => {\n return error.category === \"cli\";\n};\n\n/**\n * Extract error code from any CliError variant.\n */\nexport const getErrorCode = (error: CliError): string => {\n if (error.category === \"cli\") {\n return error.code;\n }\n // codegen, builder, artifact, config all have error.code\n return error.error.code;\n};\n\n/**\n * Extract error message from any CliError variant.\n */\nexport const getErrorMessage = (error: CliError): string => {\n if (error.category === \"cli\") {\n return error.message;\n }\n return error.error.message;\n};\n","import { mkdir, writeFile } from \"node:fs/promises\";\nimport { dirname, resolve } from \"node:path\";\nimport type { BuilderArtifact, BuilderArtifactMeta } from \"@soda-gql/builder\";\nimport { createBuilderService } from \"@soda-gql/builder\";\nimport { loadConfig } from \"@soda-gql/config\";\nimport { err, ok } from \"neverthrow\";\nimport { cliErrors } from \"../../errors\";\nimport type { CommandResult, CommandSuccess } from \"../../types\";\n\nconst BUILD_HELP = `Usage: soda-gql artifact build [options]\n\nBuild and validate soda-gql artifacts.\n\nOptions:\n --config <path> Path to soda-gql.config.ts\n --output, -o Output file path (default: ./soda-gql-artifact.json)\n --version, -v Custom version string for the artifact (default: package version)\n --dry-run Validate only, don't write output\n --help, -h Show this help message\n\nExamples:\n soda-gql artifact build\n soda-gql artifact build --output ./dist/artifact.json\n soda-gql artifact build --version \"1.0.0\"\n soda-gql artifact build --dry-run\n soda-gql artifact build --config ./soda-gql.config.ts\n`;\n\ntype BuildArgs = {\n configPath?: string;\n outputPath: string;\n version?: string;\n dryRun: boolean;\n help: boolean;\n};\n\nconst DEFAULT_OUTPUT_PATH = \"./soda-gql-artifact.json\";\n\n/**\n * Parse build command arguments.\n */\nconst parseBuildArgs = (argv: readonly string[]): BuildArgs => {\n const args: BuildArgs = {\n configPath: undefined,\n outputPath: DEFAULT_OUTPUT_PATH,\n version: undefined,\n dryRun: false,\n help: false,\n };\n\n for (let i = 0; i < argv.length; i++) {\n const arg = argv[i];\n if (arg === \"--config\" || arg === \"-c\") {\n args.configPath = argv[++i];\n } else if (arg === \"--output\" || arg === \"-o\") {\n args.outputPath = argv[++i] ?? DEFAULT_OUTPUT_PATH;\n } else if (arg === \"--version\" || arg === \"-v\") {\n args.version = argv[++i];\n } else if (arg === \"--dry-run\") {\n args.dryRun = true;\n } else if (arg === \"--help\" || arg === \"-h\") {\n args.help = true;\n }\n }\n\n return args;\n};\n\ntype BuildData = {\n artifact: BuilderArtifact;\n outputPath?: string;\n dryRun: boolean;\n};\n\nconst formatSuccess = (data: BuildData): string => {\n const { artifact, outputPath, dryRun } = data;\n const fragmentCount = Object.values(artifact.elements).filter((e) => e.type === \"fragment\").length;\n const operationCount = Object.values(artifact.elements).filter((e) => e.type === \"operation\").length;\n\n const lines: string[] = [];\n if (dryRun) {\n lines.push(`Validation passed: ${fragmentCount} fragments, ${operationCount} operations`);\n } else {\n lines.push(`Build complete: ${fragmentCount} fragments, ${operationCount} operations`);\n }\n\n if (artifact.meta?.version) {\n lines.push(` Version: ${artifact.meta.version}`);\n }\n\n if (outputPath && !dryRun) {\n lines.push(`Artifact written to: ${outputPath}`);\n }\n\n return lines.join(\"\\n\");\n};\n\ntype BuildCommandResult = CommandResult<CommandSuccess & { data?: BuildData }>;\n\n/**\n * Build command - builds and validates soda-gql artifacts.\n */\nexport const buildCommand = async (argv: readonly string[]): Promise<BuildCommandResult> => {\n const args = parseBuildArgs(argv);\n\n if (args.help) {\n return ok({ message: BUILD_HELP });\n }\n\n // Load config\n const configResult = loadConfig(args.configPath);\n if (configResult.isErr()) {\n return err(cliErrors.fromConfig(configResult.error));\n }\n\n const config = configResult.value;\n\n // Create builder service and build\n const service = createBuilderService({ config });\n const buildResult = await service.buildAsync();\n\n if (buildResult.isErr()) {\n return err(cliErrors.fromBuilder(buildResult.error));\n }\n\n const artifact = buildResult.value;\n\n // Create artifact with metadata (only if version is specified)\n const meta: BuilderArtifactMeta | undefined = args.version\n ? {\n version: args.version,\n createdAt: new Date().toISOString(),\n }\n : undefined;\n const artifactWithMeta: BuilderArtifact = {\n ...(meta ? { meta } : {}),\n ...artifact,\n };\n\n if (args.dryRun) {\n const data: BuildData = { artifact: artifactWithMeta, dryRun: true };\n return ok({ message: formatSuccess(data), data });\n }\n\n // Write artifact to output file\n const outputPath = resolve(process.cwd(), args.outputPath);\n const outputDir = dirname(outputPath);\n try {\n await mkdir(outputDir, { recursive: true });\n await writeFile(outputPath, JSON.stringify(artifactWithMeta, null, 2));\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n return err(cliErrors.writeFailed(outputPath, `Failed to write artifact: ${message}`, error));\n }\n\n const data: BuildData = { artifact: artifactWithMeta, outputPath, dryRun: false };\n return ok({ message: formatSuccess(data), data });\n};\n","import { resolve } from \"node:path\";\nimport type { BuilderArtifact } from \"@soda-gql/builder\";\nimport { loadArtifact } from \"@soda-gql/builder\";\nimport { err, ok } from \"neverthrow\";\nimport { cliErrors } from \"../../errors\";\nimport type { CommandResult, CommandSuccess } from \"../../types\";\n\nconst VALIDATE_HELP = `Usage: soda-gql artifact validate [options] <path>\n\nValidate a pre-built soda-gql artifact file.\n\nArguments:\n <path> Path to artifact JSON file\n\nOptions:\n --help, -h Show this help message\n\nExamples:\n soda-gql artifact validate ./soda-gql-artifact.json\n soda-gql artifact validate ./dist/artifact.json\n`;\n\ntype ValidateArgs = {\n artifactPath?: string;\n help: boolean;\n};\n\n/**\n * Parse validate command arguments.\n */\nconst parseValidateArgs = (argv: readonly string[]): ValidateArgs => {\n const args: ValidateArgs = {\n artifactPath: undefined,\n help: false,\n };\n\n for (const arg of argv) {\n if (arg === \"--help\" || arg === \"-h\") {\n args.help = true;\n } else if (!arg.startsWith(\"-\")) {\n args.artifactPath = arg;\n }\n }\n\n return args;\n};\n\nconst formatSuccess = (artifact: BuilderArtifact): string => {\n const fragmentCount = Object.values(artifact.elements).filter((e) => e.type === \"fragment\").length;\n const operationCount = Object.values(artifact.elements).filter((e) => e.type === \"operation\").length;\n const lines: string[] = [`Artifact valid: ${fragmentCount} fragments, ${operationCount} operations`];\n\n if (artifact.meta) {\n lines.push(` Version: ${artifact.meta.version}`);\n lines.push(` Created: ${artifact.meta.createdAt}`);\n } else {\n lines.push(` (No metadata - legacy artifact format)`);\n }\n\n return lines.join(\"\\n\");\n};\n\ntype ValidateCommandResult = CommandResult<CommandSuccess & { data?: BuilderArtifact }>;\n\n/**\n * Validate command - validates a pre-built artifact file.\n */\nexport const validateCommand = async (argv: readonly string[]): Promise<ValidateCommandResult> => {\n const args = parseValidateArgs(argv);\n\n if (args.help) {\n return ok({ message: VALIDATE_HELP });\n }\n\n if (!args.artifactPath) {\n return err(cliErrors.argsInvalid(\"artifact validate\", \"Missing artifact path argument\"));\n }\n\n const artifactPath = resolve(process.cwd(), args.artifactPath);\n const result = await loadArtifact(artifactPath);\n\n if (result.isErr()) {\n return err(cliErrors.fromArtifact(result.error));\n }\n\n return ok({ message: formatSuccess(result.value), data: result.value });\n};\n","import { err, ok } from \"neverthrow\";\nimport { cliErrors } from \"../../errors\";\nimport type { CommandResult, CommandSuccess } from \"../../types\";\nimport { buildCommand } from \"./build\";\nimport { validateCommand } from \"./validate\";\n\nconst ARTIFACT_HELP = `Usage: soda-gql artifact <subcommand> [options]\n\nManage soda-gql artifacts.\n\nSubcommands:\n build Build artifacts (validate definitions)\n validate Validate a pre-built artifact file\n\nRun 'soda-gql artifact <subcommand> --help' for more information.\n`;\n\ntype ArtifactCommandResult = CommandResult<CommandSuccess>;\n\n/**\n * Dispatcher for artifact subcommands.\n */\nexport const artifactCommand = async (argv: readonly string[]): Promise<ArtifactCommandResult> => {\n const [subcommand, ...rest] = argv;\n\n if (!subcommand || subcommand === \"--help\" || subcommand === \"-h\") {\n return ok({ message: ARTIFACT_HELP });\n }\n\n if (subcommand === \"build\") {\n return buildCommand(rest);\n }\n\n if (subcommand === \"validate\") {\n return validateCommand(rest);\n }\n\n return err(cliErrors.unknownSubcommand(\"artifact\", subcommand));\n};\n","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 { CodegenSchemaConfig, CodegenSuccess } from \"@soda-gql/codegen\";\nimport { runCodegen, writeInjectTemplate } from \"@soda-gql/codegen\";\nimport { loadConfig } from \"@soda-gql/config\";\nimport { err, ok } from \"neverthrow\";\nimport { type CliResult, cliErrors } from \"../errors\";\nimport { CodegenArgsSchema } from \"../schemas/args\";\nimport type { CommandResult, CommandSuccess } from \"../types\";\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[]): CliResult<ParsedCommand> => {\n const parsed = parseArgs([...argv], CodegenArgsSchema);\n\n if (!parsed.isOk()) {\n return err(cliErrors.argsInvalid(\"codegen\", parsed.error));\n }\n\n const args = parsed.value;\n\n // Handle emit inject template\n if (args[\"emit-inject-template\"]) {\n return ok({\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(cliErrors.fromConfig(configResult.error));\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(cliErrors.argsInvalid(\"codegen\", \"schemas configuration is required in soda-gql.config.ts\"));\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 defaultInputDepth: schemaConfig.defaultInputDepth,\n inputDepthOverrides: schemaConfig.inputDepthOverrides,\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({\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 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\ntype CodegenCommandResult = CommandResult<CommandSuccess & { data?: CodegenSuccess }>;\n\nexport const codegenCommand = async (argv: readonly string[]): Promise<CodegenCommandResult> => {\n if (argv.includes(\"--help\") || argv.includes(\"-h\")) {\n return ok({ message: CODEGEN_HELP });\n }\n\n const parsed = parseCodegenArgs(argv);\n\n if (parsed.isErr()) {\n return err(parsed.error);\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 return err(cliErrors.fromCodegen(result.error));\n }\n return ok({ message: formatTemplateSuccess(outPath) });\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 defaultInputDepth: schemaConfig.defaultInputDepth,\n inputDepthOverrides: schemaConfig.inputDepthOverrides,\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 return err(cliErrors.fromCodegen(result.error));\n }\n\n return ok({ message: formatSuccess(result.value), data: result.value });\n};\n","import { access, readFile, writeFile } from \"node:fs/promises\";\nimport { loadConfig } from \"@soda-gql/config\";\nimport fg from \"fast-glob\";\nimport { err, ok } from \"neverthrow\";\nimport { cliErrors } from \"../errors\";\nimport { FormatArgsSchema } from \"../schemas/args\";\nimport type { CommandResult, CommandSuccess } from \"../types\";\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 FormatData = {\n mode: \"format\" | \"check\";\n total: number;\n modified: number;\n unchanged: number;\n errors: number;\n unformatted: string[];\n hasFormattingIssues: boolean;\n};\n\nconst formatResultMessage = (data: FormatData): string => {\n if (data.mode === \"check\") {\n if (data.unformatted.length > 0) {\n const files = data.unformatted.map((f) => ` ${f}`).join(\"\\n\");\n return `${data.unformatted.length} file(s) need formatting:\\n${files}`;\n }\n return `All ${data.total} file(s) are properly formatted`;\n }\n\n const parts: string[] = [];\n if (data.modified > 0) {\n parts.push(`${data.modified} formatted`);\n }\n if (data.unchanged > 0) {\n parts.push(`${data.unchanged} unchanged`);\n }\n if (data.errors > 0) {\n parts.push(`${data.errors} errors`);\n }\n return `${data.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\ntype FormatCommandResult = CommandResult<CommandSuccess & { data?: FormatData }>;\n\nexport const formatCommand = async (argv: readonly string[]): Promise<FormatCommandResult> => {\n if (argv.includes(\"--help\") || argv.includes(\"-h\")) {\n return ok({ message: FORMAT_HELP });\n }\n\n const parsed = parseArgs([...argv], FormatArgsSchema);\n\n if (!parsed.isOk()) {\n return err(cliErrors.argsInvalid(\"format\", parsed.error));\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 return err(cliErrors.noPatterns());\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 return err(cliErrors.formatterNotInstalled());\n }\n\n const files = await expandGlobPatterns(targetPatterns, excludePatterns);\n\n if (files.length === 0) {\n const data: FormatData = {\n mode: isCheckMode ? \"check\" : \"format\",\n total: 0,\n modified: 0,\n unchanged: 0,\n errors: 0,\n unformatted: [],\n hasFormattingIssues: false,\n };\n return ok({ message: formatResultMessage(data), data });\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 data: FormatData = {\n mode: isCheckMode ? \"check\" : \"format\",\n total: files.length,\n modified,\n unchanged,\n errors,\n unformatted,\n hasFormattingIssues: (isCheckMode && unformatted.length > 0) || errors > 0,\n };\n\n return ok({ message: formatResultMessage(data), data });\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 { type CliError, cliErrors } from \"../errors\";\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 type { CommandResult, CommandSuccess } from \"../types\";\nimport { parseArgs } from \"../utils/parse-args\";\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, CliError> => {\n if (force) {\n return ok(undefined);\n }\n\n for (const file of files) {\n if (existsSync(file.path)) {\n return err(cliErrors.fileExists(file.path));\n }\n }\n\n return ok(undefined);\n};\n\nconst writeFiles = (files: readonly FileToGenerate[]): Result<InitSuccess, CliError> => {\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(cliErrors.writeFailed(file.path, `Failed to write ${file.description}: ${message}`, error));\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\ntype InitCommandResult = CommandResult<CommandSuccess & { data?: InitSuccess }>;\n\nexport const initCommand = async (argv: readonly string[]): Promise<InitCommandResult> => {\n if (argv.includes(\"--help\") || argv.includes(\"-h\")) {\n return ok({ message: INIT_HELP });\n }\n\n const parsed = parseArgs([...argv], InitArgsSchema);\n\n if (!parsed.isOk()) {\n return err(cliErrors.argsInvalid(\"init\", parsed.error));\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 return err(existsCheck.error);\n }\n\n const writeResult = writeFiles(files);\n if (writeResult.isErr()) {\n return err(writeResult.error);\n }\n\n return ok({ message: formatSuccess(writeResult.value), data: writeResult.value });\n};\n","import { formatBuilderErrorForCLI } from \"@soda-gql/builder\";\nimport type { CliError, CliErrorCode } from \"../errors\";\nimport type { OutputFormat } from \"../types\";\n\nexport type { OutputFormat } from \"../types\";\n\n/**\n * CLI-specific error hints to help users fix issues.\n */\nconst cliErrorHints: Partial<Record<CliErrorCode, string>> = {\n CLI_ARGS_INVALID: \"Check command usage with --help\",\n CLI_UNKNOWN_COMMAND: \"Run 'soda-gql --help' for available commands\",\n CLI_UNKNOWN_SUBCOMMAND: \"Run the parent command with --help for available subcommands\",\n CLI_FILE_EXISTS: \"Use --force flag to overwrite existing files\",\n CLI_FILE_NOT_FOUND: \"Verify the file path exists\",\n CLI_WRITE_FAILED: \"Check write permissions and disk space\",\n CLI_READ_FAILED: \"Check file permissions and verify the file is not locked\",\n CLI_NO_PATTERNS: \"Provide file patterns or create soda-gql.config.ts\",\n CLI_FORMATTER_NOT_INSTALLED: \"Install with: bun add @soda-gql/formatter\",\n CLI_PARSE_ERROR: \"Check the file for syntax errors\",\n CLI_FORMAT_ERROR: \"Verify the file contains valid soda-gql code\",\n CLI_UNEXPECTED: \"This is an unexpected error. Please report at https://github.com/soda-gql/soda-gql/issues\",\n};\n\n/**\n * Codegen-specific error hints.\n */\nconst codegenErrorHints: 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 INJECT_TEMPLATE_FAILED: \"Check write permissions for the output path\",\n};\n\n/**\n * Config-specific error hints.\n */\nconst configErrorHints: Record<string, string> = {\n CONFIG_NOT_FOUND: \"Create a soda-gql.config.ts file in your project root\",\n CONFIG_LOAD_FAILED: \"Check your configuration file for syntax errors\",\n CONFIG_VALIDATION_FAILED: \"Verify your configuration matches the expected schema\",\n CONFIG_INVALID_PATH: \"Verify the path in your configuration exists\",\n};\n\n/**\n * Artifact-specific error hints.\n */\nconst artifactErrorHints: Record<string, string> = {\n ARTIFACT_NOT_FOUND: \"Verify the artifact file path exists\",\n ARTIFACT_PARSE_ERROR: \"Check that the artifact file is valid JSON\",\n ARTIFACT_VALIDATION_ERROR: \"Verify the artifact was built with a compatible version of soda-gql\",\n};\n\n/**\n * Get hint for any error type.\n */\nconst getErrorHint = (error: CliError): string | undefined => {\n if (error.category === \"cli\") {\n return cliErrorHints[error.code];\n }\n if (error.category === \"codegen\") {\n return codegenErrorHints[error.error.code];\n }\n if (error.category === \"config\") {\n return configErrorHints[error.error.code];\n }\n if (error.category === \"artifact\") {\n return artifactErrorHints[error.error.code];\n }\n // Builder errors use their own hints via formatBuilderErrorForCLI\n return undefined;\n};\n\n/**\n * Format CliError to human-readable string with hints.\n */\nexport const formatCliErrorHuman = (error: CliError): string => {\n // Delegate to builder's formatter for builder errors\n if (error.category === \"builder\") {\n return formatBuilderErrorForCLI(error.error);\n }\n\n const lines: string[] = [];\n\n if (error.category === \"codegen\") {\n const codegenError = error.error;\n lines.push(`Error [${codegenError.code}]: ${codegenError.message}`);\n\n // Add context based on error type\n if (\"schemaPath\" in codegenError) {\n lines.push(` Schema: ${codegenError.schemaPath}`);\n }\n if (\"outPath\" in codegenError && codegenError.outPath) {\n lines.push(` Output: ${codegenError.outPath}`);\n }\n if (\"injectPath\" in codegenError) {\n lines.push(` Inject: ${codegenError.injectPath}`);\n }\n } else if (error.category === \"config\") {\n const configError = error.error;\n lines.push(`Error [${configError.code}]: ${configError.message}`);\n if (configError.filePath) {\n lines.push(` Config: ${configError.filePath}`);\n }\n } else if (error.category === \"artifact\") {\n const artifactError = error.error;\n lines.push(`Error [${artifactError.code}]: ${artifactError.message}`);\n if (artifactError.filePath) {\n lines.push(` Artifact: ${artifactError.filePath}`);\n }\n } else {\n // CLI errors\n lines.push(`Error [${error.code}]: ${error.message}`);\n\n if (\"filePath\" in error && error.filePath) {\n lines.push(` File: ${error.filePath}`);\n }\n if (\"command\" in error && error.code !== \"CLI_UNKNOWN_COMMAND\") {\n lines.push(` Command: ${error.command}`);\n }\n if (\"parent\" in error) {\n lines.push(` Parent: ${error.parent}`);\n }\n }\n\n const hint = getErrorHint(error);\n if (hint) {\n lines.push(\"\");\n lines.push(` Hint: ${hint}`);\n }\n\n return lines.join(\"\\n\");\n};\n\n/**\n * Format CliError to JSON string.\n */\nexport const formatCliErrorJson = (error: CliError): string => {\n if (error.category === \"cli\") {\n const { category: _category, ...rest } = error;\n return JSON.stringify({ error: rest }, null, 2);\n }\n return JSON.stringify({ error: error.error }, null, 2);\n};\n\n/**\n * Format CliError with output format preference.\n */\nexport const formatCliError = (error: CliError, format: OutputFormat = \"human\"): string => {\n return format === \"json\" ? formatCliErrorJson(error) : formatCliErrorHuman(error);\n};\n\n// ---- Legacy formatters (kept for backward compatibility) ----\n\nexport 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 const formatOutput = (data: unknown, format: OutputFormat = \"human\"): string => {\n return formatters[format](data);\n};\n\n/**\n * @deprecated Use formatCliError instead for CliError types.\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 { err, ok } from \"neverthrow\";\nimport { artifactCommand } from \"./commands/artifact\";\nimport { codegenCommand } from \"./commands/codegen\";\nimport { formatCommand } from \"./commands/format\";\nimport { initCommand } from \"./commands/init\";\nimport { cliErrors } from \"./errors\";\nimport type { CommandResult, CommandSuccess, OutputFormat } from \"./types\";\nimport { formatCliError } from \"./utils/format\";\n\nconst MAIN_HELP = `Usage: soda-gql <command> [options]\n\nCommands:\n init Initialize a new soda-gql project\n codegen Generate graphql-system runtime module\n format Format soda-gql field selections\n artifact Manage soda-gql artifacts\n\nRun 'soda-gql <command> --help' for more information on a specific command.\n`;\n\n/**\n * Parse output format from argv.\n * Returns \"json\" if --format=json or --json flag is present, otherwise \"human\".\n */\nconst getOutputFormat = (argv: readonly string[]): OutputFormat => {\n for (const arg of argv) {\n if (arg === \"--format=json\" || arg === \"--json\") {\n return \"json\";\n }\n if (arg === \"--format=human\") {\n return \"human\";\n }\n }\n return \"human\";\n};\n\ntype DispatchResult = CommandResult<CommandSuccess & { exitCode?: number }>;\n\nconst dispatch = async (argv: readonly string[]): Promise<DispatchResult> => {\n const [command, ...rest] = argv;\n\n if (!command || command === \"--help\" || command === \"-h\") {\n return ok({ message: MAIN_HELP });\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 const result = await formatCommand(rest);\n if (result.isOk()) {\n // Format command uses exit 1 for unformatted files in check mode or errors\n const exitCode = result.value.data?.hasFormattingIssues ? 1 : 0;\n return ok({ ...result.value, exitCode });\n }\n return err(result.error);\n }\n\n if (command === \"artifact\") {\n return artifactCommand(rest);\n }\n\n return err(cliErrors.unknownCommand(command));\n};\n\n// Run CLI when executed directly\nconst main = async () => {\n const argv = process.argv.slice(2);\n const format = getOutputFormat(argv);\n\n const result = await dispatch(argv);\n\n if (result.isOk()) {\n process.stdout.write(`${result.value.message}\\n`);\n process.exitCode = result.value.exitCode ?? 0;\n } else {\n process.stderr.write(`${formatCliError(result.error, format)}\\n`);\n process.exitCode = 1;\n }\n};\n\nmain().catch((error) => {\n const unexpectedError = cliErrors.unexpected(error instanceof Error ? error.message : String(error), error);\n const format = getOutputFormat(process.argv.slice(2));\n process.stderr.write(`${formatCliError(unexpectedError, format)}\\n`);\n process.exitCode = 1;\n});\n\nexport { dispatch };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+IA,MAAa,YAAY;CACvB,cAAc,SAAiB,aAA0C;EACvE,UAAU;EACV,MAAM;EACN;EACA;EACD;CAED,iBAAiB,aAA6C;EAC5D,UAAU;EACV,MAAM;EACN,SAAS,oBAAoB;EAC7B;EACD;CAED,oBAAoB,QAAgB,gBAAmD;EACrF,UAAU;EACV,MAAM;EACN,SAAS,uBAAuB;EAChC;EACA;EACD;CAED,aAAa,UAAkB,aAA0C;EACvE,UAAU;EACV,MAAM;EACN,SAAS,WAAW,wBAAwB,SAAS;EACrD;EACD;CAED,eAAe,UAAkB,aAA4C;EAC3E,UAAU;EACV,MAAM;EACN,SAAS,WAAW,mBAAmB;EACvC;EACD;CAED,cAAc,UAAkB,SAAkB,WAA0C;EAC1F,UAAU;EACV,MAAM;EACN,SAAS,WAAW,yBAAyB;EAC7C;EACA;EACD;CAED,aAAa,UAAkB,SAAkB,WAAyC;EACxF,UAAU;EACV,MAAM;EACN,SAAS,WAAW,wBA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W,YAAY,YAAY,YAAY,KAClD,2BAAU,EAAE,SAAS,WAAW,CAAC;AAGnC,KAAI,YAAY,OACd,QAAO,YAAY,KAAK;AAG1B,KAAI,YAAY,UACd,QAAO,eAAe,KAAK;AAG7B,KAAI,YAAY,UAAU;EACxB,MAAM,SAAS,MAAM,cAAc,KAAK;AACxC,MAAI,OAAO,MAAM,EAAE;GAEjB,MAAM,WAAW,OAAO,MAAM,MAAM,sBAAsB,IAAI;AAC9D,6BAAU;IAAE,GAAG,OAAO;IAAO;IAAU,CAAC;;AAE1C,6BAAW,OAAO,MAAM;;AAG1B,KAAI,YAAY,WACd,QAAO,gBAAgB,KAAK;AAG9B,4BAAW,UAAU,eAAe,QAAQ,CAAC;;AAI/C,MAAM,OAAO,YAAY;CACvB,MAAM,OAAO,QAAQ,KAAK,MAAM,EAAE;CAClC,MAAM,SAAS,gBAAgB,KAAK;CAEpC,MAAM,SAAS,MAAM,SAAS,KAAK;AAEnC,KAAI,OAAO,MAAM,EAAE;AACjB,UAAQ,OAAO,MAAM,GAAG,OAAO,MAAM,QAAQ,IAAI;AACjD,UAAQ,WAAW,OAAO,MAAM,YAAY;QACvC;AACL,UAAQ,OAAO,MAAM,GAAG,eAAe,OAAO,OAAO,OAAO,CAAC,IAAI;AACjE,UAAQ,WAAW;;;AAIvB,MAAM,CAAC,OAAO,UAAU;CACtB,MAAM,kBAAkB,UAAU,WAAW,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM,EAAE,MAAM;CAC3G,MAAM,SAAS,gBAAgB,QAAQ,KAAK,MAAM,EAAE,CAAC;AACrD,SAAQ,OAAO,MAAM,GAAG,eAAe,iBAAiB,OAAO,CAAC,IAAI;AACpE,SAAQ,WAAW;EACnB"}
1
+ {"version":3,"file":"index.cjs","names":["args: BuildArgs","formatSuccess","lines: string[]","meta: BuilderArtifactMeta | undefined","artifactWithMeta: BuilderArtifact","data: BuildData","data","args: ValidateArgs","formatSuccess","lines: string[]","z","parsed: Record<string, unknown>","positional: string[]","schemas: Record<string, CodegenSchemaConfig>","formatSuccess","result","resolvedSchemas: Record<string, CodegenSchemaConfig>","schemaResults: CodegenFreshnessData[\"schemas\"][number][]","missingFiles: string[]","packages: DiscoveredPackage[]","allPackages: DiscoveredPackage[]","queue: string[]","realPath: string","duplicates: DuplicatePackageData[\"duplicates\"][number][]","STATUS_SYMBOLS: Record<CheckStatus, string>","lines: string[]","parts: string[]","checks: CheckResult[]","result: DoctorResult","parts: string[]","files: string[]","targetPatterns: readonly string[]","excludePatterns: readonly string[]","data: FormatData","data","unformatted: string[]","createdPaths: string[]","files: FileToGenerate[]","cliErrorHints: Partial<Record<CliErrorCode, string>>","codegenErrorHints: Record<string, string>","configErrorHints: Record<string, string>","artifactErrorHints: Record<string, string>","lines: string[]"],"sources":["../src/errors.ts","../src/commands/artifact/build.ts","../src/commands/artifact/validate.ts","../src/commands/artifact/index.ts","../src/schemas/args.ts","../src/utils/parse-args.ts","../src/commands/codegen.ts","../src/commands/doctor/checks/codegen-freshness.ts","../src/commands/doctor/checks/config-validation.ts","../src/commands/doctor/discovery.ts","../src/commands/doctor/checks/duplicate-packages.ts","../src/commands/doctor/checks/version-consistency.ts","../src/commands/doctor/output.ts","../src/commands/doctor/index.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":["/**\n * Unified CLI error types and constructors.\n * @module\n */\n\nimport type { ArtifactLoadError, BuilderError } from \"@soda-gql/builder\";\nimport type { CodegenError } from \"@soda-gql/codegen\";\nimport type { ConfigError } from \"@soda-gql/config\";\nimport { err, type Result } from \"neverthrow\";\n\n/**\n * CLI-specific error codes.\n */\nexport type CliErrorCode =\n // Argument parsing errors\n | \"CLI_ARGS_INVALID\"\n | \"CLI_UNKNOWN_COMMAND\"\n | \"CLI_UNKNOWN_SUBCOMMAND\"\n // File operation errors\n | \"CLI_FILE_EXISTS\"\n | \"CLI_FILE_NOT_FOUND\"\n | \"CLI_WRITE_FAILED\"\n | \"CLI_READ_FAILED\"\n // Format command specific\n | \"CLI_NO_PATTERNS\"\n | \"CLI_FORMATTER_NOT_INSTALLED\"\n | \"CLI_PARSE_ERROR\"\n | \"CLI_FORMAT_ERROR\"\n // Unexpected errors\n | \"CLI_UNEXPECTED\";\n\n/**\n * Unified CLI error discriminated union.\n * Wraps external errors (codegen, builder, config) and defines CLI-specific errors.\n */\nexport type CliError =\n // Wrapped external errors (preserve original structure)\n | { readonly category: \"codegen\"; readonly error: CodegenError }\n | { readonly category: \"builder\"; readonly error: BuilderError }\n | { readonly category: \"artifact\"; readonly error: ArtifactLoadError }\n | { readonly category: \"config\"; readonly error: ConfigError }\n // CLI-specific errors\n | {\n readonly category: \"cli\";\n readonly code: \"CLI_ARGS_INVALID\";\n readonly message: string;\n readonly command: string;\n }\n | {\n readonly category: \"cli\";\n readonly code: \"CLI_UNKNOWN_COMMAND\";\n readonly message: string;\n readonly command: string;\n }\n | {\n readonly category: \"cli\";\n readonly code: \"CLI_UNKNOWN_SUBCOMMAND\";\n readonly message: string;\n readonly parent: string;\n readonly subcommand: string;\n }\n | {\n readonly category: \"cli\";\n readonly code: \"CLI_FILE_EXISTS\";\n readonly message: string;\n readonly filePath: string;\n }\n | {\n readonly category: \"cli\";\n readonly code: \"CLI_FILE_NOT_FOUND\";\n readonly message: string;\n readonly filePath: string;\n }\n | {\n readonly category: \"cli\";\n readonly code: \"CLI_WRITE_FAILED\";\n readonly message: string;\n readonly filePath: string;\n readonly cause?: unknown;\n }\n | {\n readonly category: \"cli\";\n readonly code: \"CLI_READ_FAILED\";\n readonly message: string;\n readonly filePath: string;\n readonly cause?: unknown;\n }\n | {\n readonly category: \"cli\";\n readonly code: \"CLI_NO_PATTERNS\";\n readonly message: string;\n }\n | {\n readonly category: \"cli\";\n readonly code: \"CLI_FORMATTER_NOT_INSTALLED\";\n readonly message: string;\n }\n | {\n readonly category: \"cli\";\n readonly code: \"CLI_PARSE_ERROR\";\n readonly message: string;\n readonly filePath?: string;\n }\n | {\n readonly category: \"cli\";\n readonly code: \"CLI_FORMAT_ERROR\";\n readonly message: string;\n readonly filePath?: string;\n }\n | {\n readonly category: \"cli\";\n readonly code: \"CLI_UNEXPECTED\";\n readonly message: string;\n readonly cause?: unknown;\n };\n\n/**\n * Result type for CLI operations.\n */\nexport type CliResult<T> = Result<T, CliError>;\n\n// Extract CLI-specific error types for type-safe constructors\ntype CliArgsInvalidError = Extract<CliError, { code: \"CLI_ARGS_INVALID\" }>;\ntype CliUnknownCommandError = Extract<CliError, { code: \"CLI_UNKNOWN_COMMAND\" }>;\ntype CliUnknownSubcommandError = Extract<CliError, { code: \"CLI_UNKNOWN_SUBCOMMAND\" }>;\ntype CliFileExistsError = Extract<CliError, { code: \"CLI_FILE_EXISTS\" }>;\ntype CliFileNotFoundError = Extract<CliError, { code: \"CLI_FILE_NOT_FOUND\" }>;\ntype CliWriteFailedError = Extract<CliError, { code: \"CLI_WRITE_FAILED\" }>;\ntype CliReadFailedError = Extract<CliError, { code: \"CLI_READ_FAILED\" }>;\ntype CliNoPatternsError = Extract<CliError, { code: \"CLI_NO_PATTERNS\" }>;\ntype CliFormatterNotInstalledError = Extract<CliError, { code: \"CLI_FORMATTER_NOT_INSTALLED\" }>;\ntype CliParseErrorError = Extract<CliError, { code: \"CLI_PARSE_ERROR\" }>;\ntype CliFormatErrorError = Extract<CliError, { code: \"CLI_FORMAT_ERROR\" }>;\ntype CliUnexpectedError = Extract<CliError, { code: \"CLI_UNEXPECTED\" }>;\ntype CliCodegenError = Extract<CliError, { category: \"codegen\" }>;\ntype CliBuilderError = Extract<CliError, { category: \"builder\" }>;\ntype CliArtifactError = Extract<CliError, { category: \"artifact\" }>;\ntype CliConfigError = Extract<CliError, { category: \"config\" }>;\n\n/**\n * Error constructor helpers for concise error creation.\n * Each function returns a specific error type for better type inference.\n */\nexport const cliErrors = {\n argsInvalid: (command: string, message: string): CliArgsInvalidError => ({\n category: \"cli\",\n code: \"CLI_ARGS_INVALID\",\n message,\n command,\n }),\n\n unknownCommand: (command: string): CliUnknownCommandError => ({\n category: \"cli\",\n code: \"CLI_UNKNOWN_COMMAND\",\n message: `Unknown command: ${command}`,\n command,\n }),\n\n unknownSubcommand: (parent: string, subcommand: string): CliUnknownSubcommandError => ({\n category: \"cli\",\n code: \"CLI_UNKNOWN_SUBCOMMAND\",\n message: `Unknown subcommand: ${subcommand}`,\n parent,\n subcommand,\n }),\n\n fileExists: (filePath: string, message?: string): CliFileExistsError => ({\n category: \"cli\",\n code: \"CLI_FILE_EXISTS\",\n message: message ?? `File already exists: ${filePath}. Use --force to overwrite.`,\n filePath,\n }),\n\n fileNotFound: (filePath: string, message?: string): CliFileNotFoundError => ({\n category: \"cli\",\n code: \"CLI_FILE_NOT_FOUND\",\n message: message ?? `File not found: ${filePath}`,\n filePath,\n }),\n\n writeFailed: (filePath: string, message?: string, cause?: unknown): CliWriteFailedError => ({\n category: \"cli\",\n code: \"CLI_WRITE_FAILED\",\n message: message ?? `Failed to write file: ${filePath}`,\n filePath,\n cause,\n }),\n\n readFailed: (filePath: string, message?: string, cause?: unknown): CliReadFailedError => ({\n category: \"cli\",\n code: \"CLI_READ_FAILED\",\n message: message ?? `Failed to read file: ${filePath}`,\n filePath,\n cause,\n }),\n\n noPatterns: (message?: string): CliNoPatternsError => ({\n category: \"cli\",\n code: \"CLI_NO_PATTERNS\",\n message: message ?? \"No patterns provided and config not found. Usage: soda-gql format [patterns...] [--check]\",\n }),\n\n formatterNotInstalled: (message?: string): CliFormatterNotInstalledError => ({\n category: \"cli\",\n code: \"CLI_FORMATTER_NOT_INSTALLED\",\n message: message ?? \"@soda-gql/formatter is not installed. Run: bun add @soda-gql/formatter\",\n }),\n\n parseError: (message: string, filePath?: string): CliParseErrorError => ({\n category: \"cli\",\n code: \"CLI_PARSE_ERROR\",\n message,\n filePath,\n }),\n\n formatError: (message: string, filePath?: string): CliFormatErrorError => ({\n category: \"cli\",\n code: \"CLI_FORMAT_ERROR\",\n message,\n filePath,\n }),\n\n unexpected: (message: string, cause?: unknown): CliUnexpectedError => ({\n category: \"cli\",\n code: \"CLI_UNEXPECTED\",\n message,\n cause,\n }),\n\n // Wrappers for external errors\n fromCodegen: (error: CodegenError): CliCodegenError => ({\n category: \"codegen\",\n error,\n }),\n\n fromBuilder: (error: BuilderError): CliBuilderError => ({\n category: \"builder\",\n error,\n }),\n\n fromArtifact: (error: ArtifactLoadError): CliArtifactError => ({\n category: \"artifact\",\n error,\n }),\n\n fromConfig: (error: ConfigError): CliConfigError => ({\n category: \"config\",\n error,\n }),\n} as const;\n\n/**\n * Convenience helper to create an err Result from CliError.\n */\nexport const cliErr = <T = never>(error: CliError): CliResult<T> => err(error);\n\n/**\n * Type guard to check if error is a CLI-specific error.\n */\nexport const isCliError = (error: CliError): error is CliError & { category: \"cli\" } => {\n return error.category === \"cli\";\n};\n\n/**\n * Extract error code from any CliError variant.\n */\nexport const getErrorCode = (error: CliError): string => {\n if (error.category === \"cli\") {\n return error.code;\n }\n // codegen, builder, artifact, config all have error.code\n return error.error.code;\n};\n\n/**\n * Extract error message from any CliError variant.\n */\nexport const getErrorMessage = (error: CliError): string => {\n if (error.category === \"cli\") {\n return error.message;\n }\n return error.error.message;\n};\n","import { mkdir, writeFile } from \"node:fs/promises\";\nimport { dirname, resolve } from \"node:path\";\nimport type { BuilderArtifact, BuilderArtifactMeta } from \"@soda-gql/builder\";\nimport { createBuilderService } from \"@soda-gql/builder\";\nimport { loadConfig } from \"@soda-gql/config\";\nimport { err, ok } from \"neverthrow\";\nimport { cliErrors } from \"../../errors\";\nimport type { CommandResult, CommandSuccess } from \"../../types\";\n\nconst BUILD_HELP = `Usage: soda-gql artifact build [options]\n\nBuild and validate soda-gql artifacts.\n\nOptions:\n --config <path> Path to soda-gql.config.ts\n --output, -o Output file path (default: ./soda-gql-artifact.json)\n --version, -v Custom version string for the artifact (default: package version)\n --dry-run Validate only, don't write output\n --help, -h Show this help message\n\nExamples:\n soda-gql artifact build\n soda-gql artifact build --output ./dist/artifact.json\n soda-gql artifact build --version \"1.0.0\"\n soda-gql artifact build --dry-run\n soda-gql artifact build --config ./soda-gql.config.ts\n`;\n\ntype BuildArgs = {\n configPath?: string;\n outputPath: string;\n version?: string;\n dryRun: boolean;\n help: boolean;\n};\n\nconst DEFAULT_OUTPUT_PATH = \"./soda-gql-artifact.json\";\n\n/**\n * Parse build command arguments.\n */\nconst parseBuildArgs = (argv: readonly string[]): BuildArgs => {\n const args: BuildArgs = {\n configPath: undefined,\n outputPath: DEFAULT_OUTPUT_PATH,\n version: undefined,\n dryRun: false,\n help: false,\n };\n\n for (let i = 0; i < argv.length; i++) {\n const arg = argv[i];\n if (arg === \"--config\" || arg === \"-c\") {\n args.configPath = argv[++i];\n } else if (arg === \"--output\" || arg === \"-o\") {\n args.outputPath = argv[++i] ?? DEFAULT_OUTPUT_PATH;\n } else if (arg === \"--version\" || arg === \"-v\") {\n args.version = argv[++i];\n } else if (arg === \"--dry-run\") {\n args.dryRun = true;\n } else if (arg === \"--help\" || arg === \"-h\") {\n args.help = true;\n }\n }\n\n return args;\n};\n\ntype BuildData = {\n artifact: BuilderArtifact;\n outputPath?: string;\n dryRun: boolean;\n};\n\nconst formatSuccess = (data: BuildData): string => {\n const { artifact, outputPath, dryRun } = data;\n const fragmentCount = Object.values(artifact.elements).filter((e) => e.type === \"fragment\").length;\n const operationCount = Object.values(artifact.elements).filter((e) => e.type === \"operation\").length;\n\n const lines: string[] = [];\n if (dryRun) {\n lines.push(`Validation passed: ${fragmentCount} fragments, ${operationCount} operations`);\n } else {\n lines.push(`Build complete: ${fragmentCount} fragments, ${operationCount} operations`);\n }\n\n if (artifact.meta?.version) {\n lines.push(` Version: ${artifact.meta.version}`);\n }\n\n if (outputPath && !dryRun) {\n lines.push(`Artifact written to: ${outputPath}`);\n }\n\n return lines.join(\"\\n\");\n};\n\ntype BuildCommandResult = CommandResult<CommandSuccess & { data?: BuildData }>;\n\n/**\n * Build command - builds and validates soda-gql artifacts.\n */\nexport const buildCommand = async (argv: readonly string[]): Promise<BuildCommandResult> => {\n const args = parseBuildArgs(argv);\n\n if (args.help) {\n return ok({ message: BUILD_HELP });\n }\n\n // Load config\n const configResult = loadConfig(args.configPath);\n if (configResult.isErr()) {\n return err(cliErrors.fromConfig(configResult.error));\n }\n\n const config = configResult.value;\n\n // Create builder service and build\n const service = createBuilderService({ config });\n const buildResult = await service.buildAsync();\n\n if (buildResult.isErr()) {\n return err(cliErrors.fromBuilder(buildResult.error));\n }\n\n const artifact = buildResult.value;\n\n // Create artifact with metadata (only if version is specified)\n const meta: BuilderArtifactMeta | undefined = args.version\n ? {\n version: args.version,\n createdAt: new Date().toISOString(),\n }\n : undefined;\n const artifactWithMeta: BuilderArtifact = {\n ...(meta ? { meta } : {}),\n ...artifact,\n };\n\n if (args.dryRun) {\n const data: BuildData = { artifact: artifactWithMeta, dryRun: true };\n return ok({ message: formatSuccess(data), data });\n }\n\n // Write artifact to output file\n const outputPath = resolve(process.cwd(), args.outputPath);\n const outputDir = dirname(outputPath);\n try {\n await mkdir(outputDir, { recursive: true });\n await writeFile(outputPath, JSON.stringify(artifactWithMeta, null, 2));\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n return err(cliErrors.writeFailed(outputPath, `Failed to write artifact: ${message}`, error));\n }\n\n const data: BuildData = { artifact: artifactWithMeta, outputPath, dryRun: false };\n return ok({ message: formatSuccess(data), data });\n};\n","import { resolve } from \"node:path\";\nimport type { BuilderArtifact } from \"@soda-gql/builder\";\nimport { loadArtifact } from \"@soda-gql/builder\";\nimport { err, ok } from \"neverthrow\";\nimport { cliErrors } from \"../../errors\";\nimport type { CommandResult, CommandSuccess } from \"../../types\";\n\nconst VALIDATE_HELP = `Usage: soda-gql artifact validate [options] <path>\n\nValidate a pre-built soda-gql artifact file.\n\nArguments:\n <path> Path to artifact JSON file\n\nOptions:\n --help, -h Show this help message\n\nExamples:\n soda-gql artifact validate ./soda-gql-artifact.json\n soda-gql artifact validate ./dist/artifact.json\n`;\n\ntype ValidateArgs = {\n artifactPath?: string;\n help: boolean;\n};\n\n/**\n * Parse validate command arguments.\n */\nconst parseValidateArgs = (argv: readonly string[]): ValidateArgs => {\n const args: ValidateArgs = {\n artifactPath: undefined,\n help: false,\n };\n\n for (const arg of argv) {\n if (arg === \"--help\" || arg === \"-h\") {\n args.help = true;\n } else if (!arg.startsWith(\"-\")) {\n args.artifactPath = arg;\n }\n }\n\n return args;\n};\n\nconst formatSuccess = (artifact: BuilderArtifact): string => {\n const fragmentCount = Object.values(artifact.elements).filter((e) => e.type === \"fragment\").length;\n const operationCount = Object.values(artifact.elements).filter((e) => e.type === \"operation\").length;\n const lines: string[] = [`Artifact valid: ${fragmentCount} fragments, ${operationCount} operations`];\n\n if (artifact.meta) {\n lines.push(` Version: ${artifact.meta.version}`);\n lines.push(` Created: ${artifact.meta.createdAt}`);\n } else {\n lines.push(` (No metadata - legacy artifact format)`);\n }\n\n return lines.join(\"\\n\");\n};\n\ntype ValidateCommandResult = CommandResult<CommandSuccess & { data?: BuilderArtifact }>;\n\n/**\n * Validate command - validates a pre-built artifact file.\n */\nexport const validateCommand = async (argv: readonly string[]): Promise<ValidateCommandResult> => {\n const args = parseValidateArgs(argv);\n\n if (args.help) {\n return ok({ message: VALIDATE_HELP });\n }\n\n if (!args.artifactPath) {\n return err(cliErrors.argsInvalid(\"artifact validate\", \"Missing artifact path argument\"));\n }\n\n const artifactPath = resolve(process.cwd(), args.artifactPath);\n const result = await loadArtifact(artifactPath);\n\n if (result.isErr()) {\n return err(cliErrors.fromArtifact(result.error));\n }\n\n return ok({ message: formatSuccess(result.value), data: result.value });\n};\n","import { err, ok } from \"neverthrow\";\nimport { cliErrors } from \"../../errors\";\nimport type { CommandResult, CommandSuccess } from \"../../types\";\nimport { buildCommand } from \"./build\";\nimport { validateCommand } from \"./validate\";\n\nconst ARTIFACT_HELP = `Usage: soda-gql artifact <subcommand> [options]\n\nManage soda-gql artifacts.\n\nSubcommands:\n build Build artifacts (validate definitions)\n validate Validate a pre-built artifact file\n\nRun 'soda-gql artifact <subcommand> --help' for more information.\n`;\n\ntype ArtifactCommandResult = CommandResult<CommandSuccess>;\n\n/**\n * Dispatcher for artifact subcommands.\n */\nexport const artifactCommand = async (argv: readonly string[]): Promise<ArtifactCommandResult> => {\n const [subcommand, ...rest] = argv;\n\n if (!subcommand || subcommand === \"--help\" || subcommand === \"-h\") {\n return ok({ message: ARTIFACT_HELP });\n }\n\n if (subcommand === \"build\") {\n return buildCommand(rest);\n }\n\n if (subcommand === \"validate\") {\n return validateCommand(rest);\n }\n\n return err(cliErrors.unknownSubcommand(\"artifact\", subcommand));\n};\n","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 { CodegenSchemaConfig, CodegenSuccess } from \"@soda-gql/codegen\";\nimport { runCodegen, writeInjectTemplate } from \"@soda-gql/codegen\";\nimport { loadConfig } from \"@soda-gql/config\";\nimport { err, ok } from \"neverthrow\";\nimport { type CliResult, cliErrors } from \"../errors\";\nimport { CodegenArgsSchema } from \"../schemas/args\";\nimport type { CommandResult, CommandSuccess } from \"../types\";\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[]): CliResult<ParsedCommand> => {\n const parsed = parseArgs([...argv], CodegenArgsSchema);\n\n if (!parsed.isOk()) {\n return err(cliErrors.argsInvalid(\"codegen\", parsed.error));\n }\n\n const args = parsed.value;\n\n // Handle emit inject template\n if (args[\"emit-inject-template\"]) {\n return ok({\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(cliErrors.fromConfig(configResult.error));\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(cliErrors.argsInvalid(\"codegen\", \"schemas configuration is required in soda-gql.config.ts\"));\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 defaultInputDepth: schemaConfig.defaultInputDepth,\n inputDepthOverrides: schemaConfig.inputDepthOverrides,\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({\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 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\ntype CodegenCommandResult = CommandResult<CommandSuccess & { data?: CodegenSuccess }>;\n\nexport const codegenCommand = async (argv: readonly string[]): Promise<CodegenCommandResult> => {\n if (argv.includes(\"--help\") || argv.includes(\"-h\")) {\n return ok({ message: CODEGEN_HELP });\n }\n\n const parsed = parseCodegenArgs(argv);\n\n if (parsed.isErr()) {\n return err(parsed.error);\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 return err(cliErrors.fromCodegen(result.error));\n }\n return ok({ message: formatTemplateSuccess(outPath) });\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 defaultInputDepth: schemaConfig.defaultInputDepth,\n inputDepthOverrides: schemaConfig.inputDepthOverrides,\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 return err(cliErrors.fromCodegen(result.error));\n }\n\n return ok({ message: formatSuccess(result.value), data: result.value });\n};\n","/**\n * Codegen freshness check.\n * @module\n */\n\nimport { existsSync, statSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { findConfigFile, loadConfig } from \"@soda-gql/config\";\nimport type { CheckResult, CodegenFreshnessData } from \"../types\";\n\n/**\n * Check if generated code is newer than schema files.\n */\nexport const checkCodegenFreshness = (): CheckResult<CodegenFreshnessData> => {\n const configPath = findConfigFile();\n\n if (!configPath) {\n return {\n name: \"Codegen Freshness\",\n status: \"skip\",\n message: \"No soda-gql.config.ts found\",\n data: { schemas: [] },\n };\n }\n\n const configResult = loadConfig(configPath);\n\n if (configResult.isErr()) {\n return {\n name: \"Codegen Freshness\",\n status: \"skip\",\n message: \"Could not load config\",\n data: { schemas: [] },\n };\n }\n\n const config = configResult.value;\n const generatedPath = join(config.outdir, \"index.ts\");\n\n if (!existsSync(generatedPath)) {\n return {\n name: \"Codegen Freshness\",\n status: \"warn\",\n message: \"Generated code not found - run codegen\",\n data: { schemas: [] },\n fix: \"Run: soda-gql codegen\",\n };\n }\n\n const generatedStat = statSync(generatedPath);\n const generatedMtime = generatedStat.mtimeMs;\n\n const schemaResults: CodegenFreshnessData[\"schemas\"][number][] = [];\n let hasStale = false;\n\n for (const [name, schemaConfig] of Object.entries(config.schemas)) {\n if (!existsSync(schemaConfig.schema)) {\n continue; // Handled by config validation check\n }\n\n const schemaStat = statSync(schemaConfig.schema);\n const schemaMtime = schemaStat.mtimeMs;\n const isStale = schemaMtime > generatedMtime;\n\n if (isStale) hasStale = true;\n\n schemaResults.push({\n name,\n schemaPath: schemaConfig.schema,\n generatedPath,\n schemaMtime,\n generatedMtime,\n isStale,\n });\n }\n\n if (hasStale) {\n const staleSchemas = schemaResults.filter((s) => s.isStale);\n return {\n name: \"Codegen Freshness\",\n status: \"warn\",\n message: `Schema modified after codegen: ${staleSchemas.map((s) => s.name).join(\", \")}`,\n data: { schemas: schemaResults },\n fix: \"Run: soda-gql codegen\",\n };\n }\n\n return {\n name: \"Codegen Freshness\",\n status: \"pass\",\n message: \"Generated code is up to date\",\n data: { schemas: schemaResults },\n };\n};\n","/**\n * Config validation check.\n * @module\n */\n\nimport { existsSync } from \"node:fs\";\nimport { findConfigFile, loadConfig } from \"@soda-gql/config\";\nimport type { CheckResult, ConfigValidationData } from \"../types\";\n\n/**\n * Check that config file is valid and referenced files exist.\n */\nexport const checkConfigValidation = (): CheckResult<ConfigValidationData> => {\n const configPath = findConfigFile();\n\n if (!configPath) {\n return {\n name: \"Config Validation\",\n status: \"skip\",\n message: \"No soda-gql.config.ts found\",\n data: { configPath: null, missingFiles: [] },\n };\n }\n\n const configResult = loadConfig(configPath);\n\n if (configResult.isErr()) {\n return {\n name: \"Config Validation\",\n status: \"fail\",\n message: `Config error: ${configResult.error.message}`,\n data: { configPath, missingFiles: [] },\n fix: \"Check your soda-gql.config.ts for syntax errors\",\n };\n }\n\n const config = configResult.value;\n const missingFiles: string[] = [];\n\n // Check schema files exist\n for (const [name, schemaConfig] of Object.entries(config.schemas)) {\n if (!existsSync(schemaConfig.schema)) {\n missingFiles.push(`Schema '${name}': ${schemaConfig.schema}`);\n }\n if (!existsSync(schemaConfig.inject.scalars)) {\n missingFiles.push(`Scalars '${name}': ${schemaConfig.inject.scalars}`);\n }\n if (schemaConfig.inject.adapter && !existsSync(schemaConfig.inject.adapter)) {\n missingFiles.push(`Adapter '${name}': ${schemaConfig.inject.adapter}`);\n }\n }\n\n if (missingFiles.length > 0) {\n return {\n name: \"Config Validation\",\n status: \"fail\",\n message: `${missingFiles.length} referenced file(s) not found`,\n data: { configPath, missingFiles },\n fix: \"Create the missing files or update paths in config\",\n };\n }\n\n return {\n name: \"Config Validation\",\n status: \"pass\",\n message: \"Config loaded successfully\",\n data: { configPath, missingFiles: [] },\n };\n};\n","/**\n * Package discovery utilities for doctor command.\n * @module\n */\n\nimport { existsSync, readdirSync, readFileSync, statSync } from \"node:fs\";\nimport { dirname, join, resolve } from \"node:path\";\nimport { err, ok, type Result } from \"neverthrow\";\nimport type { DiscoveredPackage } from \"./types\";\n\nconst SODA_GQL_SCOPE = \"@soda-gql\";\n\n/**\n * Find the nearest node_modules directory.\n */\nexport const findNodeModules = (startDir: string = process.cwd()): string | null => {\n let currentDir = startDir;\n while (currentDir !== dirname(currentDir)) {\n const nodeModulesPath = join(currentDir, \"node_modules\");\n if (existsSync(nodeModulesPath) && statSync(nodeModulesPath).isDirectory()) {\n return nodeModulesPath;\n }\n currentDir = dirname(currentDir);\n }\n return null;\n};\n\n/**\n * Read package.json from a directory.\n */\nconst readPackageJson = (dir: string): Result<{ name: string; version: string }, string> => {\n const packageJsonPath = join(dir, \"package.json\");\n try {\n const content = readFileSync(packageJsonPath, \"utf-8\");\n const pkg = JSON.parse(content) as { name?: string; version?: string };\n if (!pkg.name || !pkg.version) {\n return err(`Invalid package.json at ${packageJsonPath}`);\n }\n return ok({ name: pkg.name, version: pkg.version });\n } catch {\n return err(`Failed to read package.json at ${packageJsonPath}`);\n }\n};\n\n/**\n * Discover @soda-gql packages at a specific node_modules path.\n */\nconst discoverAtPath = (nodeModulesPath: string): DiscoveredPackage[] => {\n const scopePath = join(nodeModulesPath, SODA_GQL_SCOPE);\n if (!existsSync(scopePath)) {\n return [];\n }\n\n const packages: DiscoveredPackage[] = [];\n\n try {\n const entries = readdirSync(scopePath, { withFileTypes: true });\n\n for (const entry of entries) {\n if (!entry.isDirectory()) continue;\n\n const packageDir = join(scopePath, entry.name);\n const result = readPackageJson(packageDir);\n\n if (result.isOk()) {\n packages.push({\n name: result.value.name,\n version: result.value.version,\n path: packageDir,\n });\n }\n }\n } catch {\n // Ignore read errors\n }\n\n return packages;\n};\n\n/**\n * Discover all @soda-gql packages including nested node_modules.\n * Uses breadth-first search to avoid deep recursion.\n */\nexport const discoverAllSodaGqlPackages = (startDir: string = process.cwd()): Result<DiscoveredPackage[], string> => {\n const rootNodeModules = findNodeModules(startDir);\n if (!rootNodeModules) {\n return err(\"No node_modules directory found\");\n }\n\n const allPackages: DiscoveredPackage[] = [];\n const visitedPaths = new Set<string>();\n const queue: string[] = [rootNodeModules];\n\n while (queue.length > 0) {\n const nodeModulesPath = queue.shift();\n if (!nodeModulesPath) continue;\n\n // Resolve to handle symlinks\n let realPath: string;\n try {\n realPath = resolve(nodeModulesPath);\n } catch {\n continue;\n }\n\n if (visitedPaths.has(realPath)) continue;\n visitedPaths.add(realPath);\n\n // Discover packages at this level\n const packages = discoverAtPath(nodeModulesPath);\n allPackages.push(...packages);\n\n // Look for nested node_modules\n try {\n const entries = readdirSync(nodeModulesPath, { withFileTypes: true });\n\n for (const entry of entries) {\n if (!entry.isDirectory()) continue;\n\n // Check scoped packages\n if (entry.name.startsWith(\"@\")) {\n const scopeDir = join(nodeModulesPath, entry.name);\n try {\n const scopeEntries = readdirSync(scopeDir, { withFileTypes: true });\n\n for (const scopeEntry of scopeEntries) {\n if (!scopeEntry.isDirectory()) continue;\n const nestedNodeModules = join(scopeDir, scopeEntry.name, \"node_modules\");\n if (existsSync(nestedNodeModules)) {\n queue.push(nestedNodeModules);\n }\n }\n } catch {\n // Ignore read errors\n }\n } else {\n // Check regular packages\n const nestedNodeModules = join(nodeModulesPath, entry.name, \"node_modules\");\n if (existsSync(nestedNodeModules)) {\n queue.push(nestedNodeModules);\n }\n }\n }\n } catch {\n // Ignore read errors\n }\n }\n\n return ok(allPackages);\n};\n\n/**\n * Get the soda-gql CLI version.\n */\nexport const getCliVersion = (): string => {\n try {\n // Navigate from this file (commands/doctor/discovery.ts) to package.json\n // Path: discovery.ts -> doctor/ -> commands/ -> src/ -> cli/package.json\n const cliPackageJsonPath = join(import.meta.dirname, \"..\", \"..\", \"..\", \"package.json\");\n const content = readFileSync(cliPackageJsonPath, \"utf-8\");\n const pkg = JSON.parse(content) as { version?: string };\n return pkg.version ?? \"unknown\";\n } catch {\n return \"unknown\";\n }\n};\n\n/**\n * Get TypeScript version from node_modules.\n */\nexport const getTypescriptVersion = (startDir: string = process.cwd()): string | null => {\n const nodeModulesPath = findNodeModules(startDir);\n if (!nodeModulesPath) return null;\n\n const tsPackageJson = join(nodeModulesPath, \"typescript\", \"package.json\");\n try {\n const content = readFileSync(tsPackageJson, \"utf-8\");\n const pkg = JSON.parse(content) as { version?: string };\n return pkg.version ?? null;\n } catch {\n return null;\n }\n};\n","/**\n * Duplicate packages check.\n * @module\n */\n\nimport { discoverAllSodaGqlPackages } from \"../discovery\";\nimport type { CheckResult, DuplicatePackageData } from \"../types\";\n\n/**\n * Check for duplicate @soda-gql packages installed at different paths.\n */\nexport const checkDuplicatePackages = (): CheckResult<DuplicatePackageData> => {\n const packagesResult = discoverAllSodaGqlPackages();\n\n if (packagesResult.isErr()) {\n return {\n name: \"Duplicate Packages\",\n status: \"skip\",\n message: packagesResult.error,\n data: { duplicates: [] },\n };\n }\n\n const packages = packagesResult.value;\n\n // Group by package name\n const byName = new Map<string, typeof packages>();\n for (const pkg of packages) {\n const existing = byName.get(pkg.name) ?? [];\n existing.push(pkg);\n byName.set(pkg.name, existing);\n }\n\n // Find duplicates (same name, multiple paths)\n const duplicates: DuplicatePackageData[\"duplicates\"][number][] = [];\n for (const [name, instances] of byName) {\n if (instances.length > 1) {\n duplicates.push({\n name,\n instances: instances.map((i) => ({\n path: i.path,\n version: i.version,\n })),\n });\n }\n }\n\n if (duplicates.length === 0) {\n return {\n name: \"Duplicate Packages\",\n status: \"pass\",\n message: \"No duplicate packages detected\",\n data: { duplicates: [] },\n };\n }\n\n const duplicateNames = duplicates.map((d) => d.name).join(\", \");\n return {\n name: \"Duplicate Packages\",\n status: \"warn\",\n message: `Duplicate packages found: ${duplicateNames}`,\n data: { duplicates },\n fix: \"Run: rm -rf node_modules && bun install\",\n };\n};\n","/**\n * Version consistency check.\n * @module\n */\n\nimport { discoverAllSodaGqlPackages } from \"../discovery\";\nimport type { CheckResult, VersionConsistencyData } from \"../types\";\n\n/**\n * Check that all @soda-gql packages have consistent versions.\n */\nexport const checkVersionConsistency = (): CheckResult<VersionConsistencyData> => {\n const packagesResult = discoverAllSodaGqlPackages();\n\n if (packagesResult.isErr()) {\n return {\n name: \"Version Consistency\",\n status: \"skip\",\n message: packagesResult.error,\n data: { packages: [], expectedVersion: null },\n };\n }\n\n const packages = packagesResult.value;\n\n if (packages.length === 0) {\n return {\n name: \"Version Consistency\",\n status: \"skip\",\n message: \"No @soda-gql packages found\",\n data: { packages: [], expectedVersion: null },\n };\n }\n\n // Group by package name (to handle duplicates separately)\n const byName = new Map<string, typeof packages>();\n for (const pkg of packages) {\n const existing = byName.get(pkg.name) ?? [];\n existing.push(pkg);\n byName.set(pkg.name, existing);\n }\n\n // Get unique packages (first instance of each)\n const uniquePackages = Array.from(byName.values())\n .map((instances) => instances[0])\n .filter((pkg): pkg is (typeof packages)[number] => pkg !== undefined);\n\n // Determine expected version (most common version)\n const versionCounts = new Map<string, number>();\n for (const pkg of uniquePackages) {\n versionCounts.set(pkg.version, (versionCounts.get(pkg.version) ?? 0) + 1);\n }\n\n let expectedVersion = uniquePackages[0]?.version ?? null;\n let maxCount = 0;\n for (const [version, count] of versionCounts) {\n if (count > maxCount) {\n maxCount = count;\n expectedVersion = version;\n }\n }\n\n // Find mismatches\n const packageResults = uniquePackages.map((pkg) => ({\n name: pkg.name,\n version: pkg.version,\n path: pkg.path,\n isMismatch: pkg.version !== expectedVersion,\n }));\n\n const mismatches = packageResults.filter((p) => p.isMismatch);\n\n if (mismatches.length === 0) {\n return {\n name: \"Version Consistency\",\n status: \"pass\",\n message: `All ${uniquePackages.length} packages at version ${expectedVersion}`,\n data: { packages: packageResults, expectedVersion },\n };\n }\n\n const mismatchNames = mismatches.map((p) => p.name).join(\", \");\n return {\n name: \"Version Consistency\",\n status: \"fail\",\n message: `Version mismatch: ${mismatchNames}`,\n data: { packages: packageResults, expectedVersion },\n fix: `Run: bun update ${mismatches.map((p) => p.name).join(\" \")}`,\n };\n};\n","/**\n * Doctor command output formatting.\n * @module\n */\n\nimport type { CheckResult, CheckStatus, DoctorResult, DuplicatePackageData, VersionConsistencyData } from \"./types\";\n\nconst STATUS_SYMBOLS: Record<CheckStatus, string> = {\n pass: \"\\u2713\", // checkmark\n warn: \"!\",\n fail: \"\\u2717\", // X\n skip: \"-\",\n};\n\n/**\n * Type guard to check if data is an object (not null/primitive).\n */\nconst isObject = (data: unknown): data is Record<string, unknown> => {\n return typeof data === \"object\" && data !== null;\n};\n\n/**\n * Format a single check result for human output.\n */\nconst formatCheckResult = (result: CheckResult): string[] => {\n const lines: string[] = [];\n const symbol = STATUS_SYMBOLS[result.status];\n\n lines.push(`${symbol} ${result.message}`);\n\n // Add detailed data for failures/warnings\n if (result.status === \"fail\" || result.status === \"warn\") {\n const data = result.data;\n\n // Version consistency details\n if (isObject(data) && \"packages\" in data && \"expectedVersion\" in data) {\n const versionData = data as VersionConsistencyData;\n const mismatched = versionData.packages.filter((p) => p.isMismatch);\n for (const pkg of mismatched) {\n lines.push(` ${pkg.name}: ${pkg.version} <- mismatch`);\n }\n if (versionData.expectedVersion && mismatched.length > 0) {\n lines.push(` Expected: ${versionData.expectedVersion}`);\n }\n }\n\n // Duplicate packages details\n if (isObject(data) && \"duplicates\" in data) {\n const dupData = data as DuplicatePackageData;\n for (const dup of dupData.duplicates) {\n lines.push(` ${dup.name}:`);\n for (const instance of dup.instances) {\n lines.push(` ${instance.version} at ${instance.path}`);\n }\n }\n }\n\n // Fix suggestion\n if (result.fix) {\n lines.push(\"\");\n lines.push(` Fix: ${result.fix}`);\n }\n }\n\n return lines;\n};\n\n/**\n * Format the complete doctor result for human output.\n */\nexport const formatDoctorResult = (result: DoctorResult): string => {\n const lines: string[] = [];\n\n lines.push(`soda-gql doctor v${result.version}`);\n lines.push(\"\");\n\n for (const check of result.checks) {\n lines.push(...formatCheckResult(check));\n lines.push(\"\");\n }\n\n // Summary\n const passed = result.checks.filter((c) => c.status === \"pass\").length;\n\n if (result.issueCount === 0 && result.warningCount === 0) {\n lines.push(`Summary: All ${passed} checks passed`);\n } else {\n const parts: string[] = [];\n if (result.issueCount > 0) {\n parts.push(`${result.issueCount} issue${result.issueCount > 1 ? \"s\" : \"\"}`);\n }\n if (result.warningCount > 0) {\n parts.push(`${result.warningCount} warning${result.warningCount > 1 ? \"s\" : \"\"}`);\n }\n lines.push(`Summary: ${parts.join(\", \")} found`);\n }\n\n return lines.join(\"\\n\");\n};\n","/**\n * Doctor command entry point.\n * @module\n */\n\nimport { ok } from \"neverthrow\";\nimport type { CommandResult, CommandSuccess } from \"../../types\";\nimport { checkCodegenFreshness } from \"./checks/codegen-freshness\";\nimport { checkConfigValidation } from \"./checks/config-validation\";\nimport { checkDuplicatePackages } from \"./checks/duplicate-packages\";\nimport { checkVersionConsistency } from \"./checks/version-consistency\";\nimport { getCliVersion, getTypescriptVersion } from \"./discovery\";\nimport { formatDoctorResult } from \"./output\";\nimport type { CheckResult, DoctorResult } from \"./types\";\n\nconst DOCTOR_HELP = `Usage: soda-gql doctor\n\nRun diagnostic checks on your soda-gql installation.\n\nChecks performed:\n - Version consistency across @soda-gql packages\n - Duplicate package detection\n - Config file validation\n - Codegen freshness (schema vs generated code)\n\nOptions:\n --help, -h Show this help message\n`;\n\ntype DoctorCommandResult = CommandResult<CommandSuccess & { data?: DoctorResult }>;\n\nexport const doctorCommand = (argv: readonly string[]): DoctorCommandResult => {\n if (argv.includes(\"--help\") || argv.includes(\"-h\")) {\n return ok({ message: DOCTOR_HELP });\n }\n\n const version = getCliVersion();\n const tsVersion = getTypescriptVersion();\n\n // Run all checks\n const checks: CheckResult[] = [];\n\n // Add TypeScript version as informational\n if (tsVersion) {\n checks.push({\n name: \"TypeScript Version\",\n status: \"pass\",\n message: `TypeScript version: ${tsVersion}`,\n });\n }\n\n // Phase 1 checks\n checks.push(checkVersionConsistency());\n checks.push(checkDuplicatePackages());\n\n // Phase 2 checks\n checks.push(checkConfigValidation());\n checks.push(checkCodegenFreshness());\n\n // Calculate summary\n const issueCount = checks.filter((c) => c.status === \"fail\").length;\n const warningCount = checks.filter((c) => c.status === \"warn\").length;\n\n const result: DoctorResult = {\n version,\n checks,\n issueCount,\n warningCount,\n };\n\n const message = formatDoctorResult(result);\n\n return ok({ message, data: result });\n};\n","import { access, readFile, writeFile } from \"node:fs/promises\";\nimport { loadConfig } from \"@soda-gql/config\";\nimport fg from \"fast-glob\";\nimport { err, ok } from \"neverthrow\";\nimport { cliErrors } from \"../errors\";\nimport { FormatArgsSchema } from \"../schemas/args\";\nimport type { CommandResult, CommandSuccess } from \"../types\";\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 FormatData = {\n mode: \"format\" | \"check\";\n total: number;\n modified: number;\n unchanged: number;\n errors: number;\n unformatted: string[];\n hasFormattingIssues: boolean;\n};\n\nconst formatResultMessage = (data: FormatData): string => {\n if (data.mode === \"check\") {\n if (data.unformatted.length > 0) {\n const files = data.unformatted.map((f) => ` ${f}`).join(\"\\n\");\n return `${data.unformatted.length} file(s) need formatting:\\n${files}`;\n }\n return `All ${data.total} file(s) are properly formatted`;\n }\n\n const parts: string[] = [];\n if (data.modified > 0) {\n parts.push(`${data.modified} formatted`);\n }\n if (data.unchanged > 0) {\n parts.push(`${data.unchanged} unchanged`);\n }\n if (data.errors > 0) {\n parts.push(`${data.errors} errors`);\n }\n return `${data.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\ntype FormatCommandResult = CommandResult<CommandSuccess & { data?: FormatData }>;\n\nexport const formatCommand = async (argv: readonly string[]): Promise<FormatCommandResult> => {\n if (argv.includes(\"--help\") || argv.includes(\"-h\")) {\n return ok({ message: FORMAT_HELP });\n }\n\n const parsed = parseArgs([...argv], FormatArgsSchema);\n\n if (!parsed.isOk()) {\n return err(cliErrors.argsInvalid(\"format\", parsed.error));\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 return err(cliErrors.noPatterns());\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 return err(cliErrors.formatterNotInstalled());\n }\n\n const files = await expandGlobPatterns(targetPatterns, excludePatterns);\n\n if (files.length === 0) {\n const data: FormatData = {\n mode: isCheckMode ? \"check\" : \"format\",\n total: 0,\n modified: 0,\n unchanged: 0,\n errors: 0,\n unformatted: [],\n hasFormattingIssues: false,\n };\n return ok({ message: formatResultMessage(data), data });\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 data: FormatData = {\n mode: isCheckMode ? \"check\" : \"format\",\n total: files.length,\n modified,\n unchanged,\n errors,\n unformatted,\n hasFormattingIssues: (isCheckMode && unformatted.length > 0) || errors > 0,\n };\n\n return ok({ message: formatResultMessage(data), data });\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 { type CliError, cliErrors } from \"../errors\";\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 type { CommandResult, CommandSuccess } from \"../types\";\nimport { parseArgs } from \"../utils/parse-args\";\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, CliError> => {\n if (force) {\n return ok(undefined);\n }\n\n for (const file of files) {\n if (existsSync(file.path)) {\n return err(cliErrors.fileExists(file.path));\n }\n }\n\n return ok(undefined);\n};\n\nconst writeFiles = (files: readonly FileToGenerate[]): Result<InitSuccess, CliError> => {\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(cliErrors.writeFailed(file.path, `Failed to write ${file.description}: ${message}`, error));\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\ntype InitCommandResult = CommandResult<CommandSuccess & { data?: InitSuccess }>;\n\nexport const initCommand = async (argv: readonly string[]): Promise<InitCommandResult> => {\n if (argv.includes(\"--help\") || argv.includes(\"-h\")) {\n return ok({ message: INIT_HELP });\n }\n\n const parsed = parseArgs([...argv], InitArgsSchema);\n\n if (!parsed.isOk()) {\n return err(cliErrors.argsInvalid(\"init\", parsed.error));\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 return err(existsCheck.error);\n }\n\n const writeResult = writeFiles(files);\n if (writeResult.isErr()) {\n return err(writeResult.error);\n }\n\n return ok({ message: formatSuccess(writeResult.value), data: writeResult.value });\n};\n","import { formatBuilderErrorForCLI } from \"@soda-gql/builder\";\nimport type { CliError, CliErrorCode } from \"../errors\";\nimport type { OutputFormat } from \"../types\";\n\nexport type { OutputFormat } from \"../types\";\n\n/**\n * CLI-specific error hints to help users fix issues.\n */\nconst cliErrorHints: Partial<Record<CliErrorCode, string>> = {\n CLI_ARGS_INVALID: \"Check command usage with --help\",\n CLI_UNKNOWN_COMMAND: \"Run 'soda-gql --help' for available commands\",\n CLI_UNKNOWN_SUBCOMMAND: \"Run the parent command with --help for available subcommands\",\n CLI_FILE_EXISTS: \"Use --force flag to overwrite existing files\",\n CLI_FILE_NOT_FOUND: \"Verify the file path exists\",\n CLI_WRITE_FAILED: \"Check write permissions and disk space\",\n CLI_READ_FAILED: \"Check file permissions and verify the file is not locked\",\n CLI_NO_PATTERNS: \"Provide file patterns or create soda-gql.config.ts\",\n CLI_FORMATTER_NOT_INSTALLED: \"Install with: bun add @soda-gql/formatter\",\n CLI_PARSE_ERROR: \"Check the file for syntax errors\",\n CLI_FORMAT_ERROR: \"Verify the file contains valid soda-gql code\",\n CLI_UNEXPECTED: \"This is an unexpected error. Please report at https://github.com/soda-gql/soda-gql/issues\",\n};\n\n/**\n * Codegen-specific error hints.\n */\nconst codegenErrorHints: 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 INJECT_TEMPLATE_FAILED: \"Check write permissions for the output path\",\n};\n\n/**\n * Config-specific error hints.\n */\nconst configErrorHints: Record<string, string> = {\n CONFIG_NOT_FOUND: \"Create a soda-gql.config.ts file in your project root\",\n CONFIG_LOAD_FAILED: \"Check your configuration file for syntax errors\",\n CONFIG_VALIDATION_FAILED: \"Verify your configuration matches the expected schema\",\n CONFIG_INVALID_PATH: \"Verify the path in your configuration exists\",\n};\n\n/**\n * Artifact-specific error hints.\n */\nconst artifactErrorHints: Record<string, string> = {\n ARTIFACT_NOT_FOUND: \"Verify the artifact file path exists\",\n ARTIFACT_PARSE_ERROR: \"Check that the artifact file is valid JSON\",\n ARTIFACT_VALIDATION_ERROR: \"Verify the artifact was built with a compatible version of soda-gql\",\n};\n\n/**\n * Get hint for any error type.\n */\nconst getErrorHint = (error: CliError): string | undefined => {\n if (error.category === \"cli\") {\n return cliErrorHints[error.code];\n }\n if (error.category === \"codegen\") {\n return codegenErrorHints[error.error.code];\n }\n if (error.category === \"config\") {\n return configErrorHints[error.error.code];\n }\n if (error.category === \"artifact\") {\n return artifactErrorHints[error.error.code];\n }\n // Builder errors use their own hints via formatBuilderErrorForCLI\n return undefined;\n};\n\n/**\n * Format CliError to human-readable string with hints.\n */\nexport const formatCliErrorHuman = (error: CliError): string => {\n // Delegate to builder's formatter for builder errors\n if (error.category === \"builder\") {\n return formatBuilderErrorForCLI(error.error);\n }\n\n const lines: string[] = [];\n\n if (error.category === \"codegen\") {\n const codegenError = error.error;\n lines.push(`Error [${codegenError.code}]: ${codegenError.message}`);\n\n // Add context based on error type\n if (\"schemaPath\" in codegenError) {\n lines.push(` Schema: ${codegenError.schemaPath}`);\n }\n if (\"outPath\" in codegenError && codegenError.outPath) {\n lines.push(` Output: ${codegenError.outPath}`);\n }\n if (\"injectPath\" in codegenError) {\n lines.push(` Inject: ${codegenError.injectPath}`);\n }\n } else if (error.category === \"config\") {\n const configError = error.error;\n lines.push(`Error [${configError.code}]: ${configError.message}`);\n if (configError.filePath) {\n lines.push(` Config: ${configError.filePath}`);\n }\n } else if (error.category === \"artifact\") {\n const artifactError = error.error;\n lines.push(`Error [${artifactError.code}]: ${artifactError.message}`);\n if (artifactError.filePath) {\n lines.push(` Artifact: ${artifactError.filePath}`);\n }\n } else {\n // CLI errors\n lines.push(`Error [${error.code}]: ${error.message}`);\n\n if (\"filePath\" in error && error.filePath) {\n lines.push(` File: ${error.filePath}`);\n }\n if (\"command\" in error && error.code !== \"CLI_UNKNOWN_COMMAND\") {\n lines.push(` Command: ${error.command}`);\n }\n if (\"parent\" in error) {\n lines.push(` Parent: ${error.parent}`);\n }\n }\n\n const hint = getErrorHint(error);\n if (hint) {\n lines.push(\"\");\n lines.push(` Hint: ${hint}`);\n }\n\n return lines.join(\"\\n\");\n};\n\n/**\n * Format CliError to JSON string.\n */\nexport const formatCliErrorJson = (error: CliError): string => {\n if (error.category === \"cli\") {\n const { category: _category, ...rest } = error;\n return JSON.stringify({ error: rest }, null, 2);\n }\n return JSON.stringify({ error: error.error }, null, 2);\n};\n\n/**\n * Format CliError with output format preference.\n */\nexport const formatCliError = (error: CliError, format: OutputFormat = \"human\"): string => {\n return format === \"json\" ? formatCliErrorJson(error) : formatCliErrorHuman(error);\n};\n\n// ---- Legacy formatters (kept for backward compatibility) ----\n\nexport 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 const formatOutput = (data: unknown, format: OutputFormat = \"human\"): string => {\n return formatters[format](data);\n};\n\n/**\n * @deprecated Use formatCliError instead for CliError types.\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 { err, ok } from \"neverthrow\";\nimport { artifactCommand } from \"./commands/artifact\";\nimport { codegenCommand } from \"./commands/codegen\";\nimport { doctorCommand } from \"./commands/doctor\";\nimport { formatCommand } from \"./commands/format\";\nimport { initCommand } from \"./commands/init\";\nimport { cliErrors } from \"./errors\";\nimport type { CommandResult, CommandSuccess, OutputFormat } from \"./types\";\nimport { formatCliError } from \"./utils/format\";\n\nconst MAIN_HELP = `Usage: soda-gql <command> [options]\n\nCommands:\n init Initialize a new soda-gql project\n codegen Generate graphql-system runtime module\n format Format soda-gql field selections\n artifact Manage soda-gql artifacts\n doctor Run diagnostic checks\n\nRun 'soda-gql <command> --help' for more information on a specific command.\n`;\n\n/**\n * Parse output format from argv.\n * Returns \"json\" if --format=json or --json flag is present, otherwise \"human\".\n */\nconst getOutputFormat = (argv: readonly string[]): OutputFormat => {\n for (const arg of argv) {\n if (arg === \"--format=json\" || arg === \"--json\") {\n return \"json\";\n }\n if (arg === \"--format=human\") {\n return \"human\";\n }\n }\n return \"human\";\n};\n\ntype DispatchResult = CommandResult<CommandSuccess & { exitCode?: number }>;\n\nconst dispatch = async (argv: readonly string[]): Promise<DispatchResult> => {\n const [command, ...rest] = argv;\n\n if (!command || command === \"--help\" || command === \"-h\") {\n return ok({ message: MAIN_HELP });\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 const result = await formatCommand(rest);\n if (result.isOk()) {\n // Format command uses exit 1 for unformatted files in check mode or errors\n const exitCode = result.value.data?.hasFormattingIssues ? 1 : 0;\n return ok({ ...result.value, exitCode });\n }\n return err(result.error);\n }\n\n if (command === \"artifact\") {\n return artifactCommand(rest);\n }\n\n if (command === \"doctor\") {\n const result = doctorCommand(rest);\n if (result.isOk()) {\n // Doctor uses exit 1 if issues found\n const exitCode = result.value.data?.issueCount ? 1 : 0;\n return ok({ ...result.value, exitCode });\n }\n return result;\n }\n\n return err(cliErrors.unknownCommand(command));\n};\n\n// Run CLI when executed directly\nconst main = async () => {\n const argv = process.argv.slice(2);\n const format = getOutputFormat(argv);\n\n const result = await dispatch(argv);\n\n if (result.isOk()) {\n process.stdout.write(`${result.value.message}\\n`);\n process.exitCode = result.value.exitCode ?? 0;\n } else {\n process.stderr.write(`${formatCliError(result.error, format)}\\n`);\n process.exitCode = 1;\n }\n};\n\nmain().catch((error) => {\n const unexpectedError = cliErrors.unexpected(error instanceof Error ? error.message : String(error), error);\n const format = getOutputFormat(process.argv.slice(2));\n process.stderr.write(`${formatCliError(unexpectedError, format)}\\n`);\n process.exitCode = 1;\n});\n\nexport { dispatch };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+IA,MAAa,YAAY;CACvB,cAAc,SAAiB,aAA0C;EACvE,UAAU;EACV,MAAM;EACN;EACA;EACD;CAED,iBAAiB,aAA6C;EAC5D,UAAU;EACV,MAAM;EACN,SAAS,oBAAoB;EAC7B;EACD;CAED,oBAAoB,QAAgB,gBAAmD;EACrF,UAAU;EACV,MAAM;EACN,SAAS,uBAAuB;EAChC;EACA;EACD;CAED,aAAa,UAAkB,aAA0C;EACvE,UAAU;EACV,MAAM;EACN,SAAS,WAAW,wBAAwB,SAAS;EACrD;EACD;CAED,eAAe,UAAkB,aAA4C;EAC3E,UAAU;EACV,MAAM;EACN,SAAS,WAAW,mBAAmB;EACvC;EACD;CAED,cAAc,UAAkB,SAAkB,WAA0C;EAC1F,UAAU;EACV,MAAM;EACN,SAAS,WAAW,yBAAyB;EAC7C;EACA;EACD;CAED,aAAa,UAAkB,SAAkB,WAAyC;EACxF,UAAU;EACV,MAAM;EACN,SAAS,WAAW,wBAAwB;EAC5C;EACA;EACD;CAED,aAAa,aAA0C;EACrD,UAAU;EACV,MAAM;EACN,SAAS,WAAW;EACrB;CAED,wBAAwB,aAAqD;EAC3E,UAAU;EACV,MAAM;EACN,SAAS,WAAW;EACrB;CAED,aAAa,SAAiB,cAA2C;EACvE,UAAU;EACV,MAAM;EACN;EACA;EACD;CAED,cAAc,SAAiB,cAA4C;EACzE,UAAU;EACV,MAAM;EACN;EACA;EACD;CAED,aAAa,SAAiB,WAAyC;EACrE,UAAU;EACV,MAAM;EACN;EACA;EACD;CAGD,cAAc,WAA0C;EACtD,UAAU;EACV;EACD;CAED,cAAc,WAA0C;EACtD,UAAU;EACV;EACD;CAED,eAAe,WAAgD;EAC7D,UAAU;EACV;EACD;CAED,aAAa,WAAwC;EACnD,UAAU;EACV;EACD;CACF;;;;AChPD,MAAM,aAAa;;;;;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,MAAM,kBAAkB,UAAU,WAAW,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM,EAAE,MAAM;CAC3G,MAAM,SAAS,gBAAgB,QAAQ,KAAK,MAAM,EAAE,CAAC;AACrD,SAAQ,OAAO,MAAM,GAAG,eAAe,iBAAiB,OAAO,CAAC,IAAI;AACpE,SAAQ,WAAW;EACnB"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","names":[],"sources":["../src/errors.ts","../src/types.ts","../src/index.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;ACWA,CAAA,CAAA;AAA8B,IAAA,CDwBlB,QAAA,CAAA,CAAA,CCxBkB;EAAyB,QAAA,CAAA,QAAA,CAAA,CAAA,CAAA,OAAA,CAAA;EAAG,QAAA,CAAA,KAAA,CAAA,CD0BN,YC1BM;CAAV,CAAA,CAAA,CAAA;EAAM,QAAA,CAAA,QAAA,CAAA,CAAA,CAAA,OAAA,CAAA;EAK1C,QAAA,CAAA,KAAA,CAAA,CDsBwC,YCtB1B;;;kBDuB2B;AEjCsB,CAAA,CAAA,CAAA,CA8BtE;EAEC,QAAA,CAAA,QA8BL,CAAA,CAAA,CAAA,MAAA,CA9ByD;kBFEP;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AALnD,CAAA,CAAA;;;AAIqD,IAAA,CC5BzC,aD4ByC,CAAA,CAAA,CAAA,CAAA,CC5BvB,cD4BuB,CAAA,CAAA,CAAA,CC5BL,MD4BK,CC5BE,CD4BF,CAAA,CC5BK,QD4BL,CAAA;;;;KCvBzC,cAAA,CAAA,CAAA;;AALZ,CAAA;;;KCyBK,cAAA,CAAA,CAAA,CAAiB,cAAc;;;cAE9B,uCAA4C,QAAQ"}
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../src/errors.ts","../src/types.ts","../src/index.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;ACWA,CAAA,CAAA;AAA8B,IAAA,CDwBlB,QAAA,CAAA,CAAA,CCxBkB;EAAyB,QAAA,CAAA,QAAA,CAAA,CAAA,CAAA,OAAA,CAAA;EAAG,QAAA,CAAA,KAAA,CAAA,CD0BN,YC1BM;CAAV,CAAA,CAAA,CAAA;EAAM,QAAA,CAAA,QAAA,CAAA,CAAA,CAAA,OAAA,CAAA;EAK1C,QAAA,CAAA,KAAA,CAAA,CDsBwC,YCtB1B;;;kBDuB2B;AEhCsB,CAAA,CAAA,CAAA,CA+BtE;EAEC,QAAA,CAAA,QAwCL,CAAA,CAAA,CAAA,MAAA,CAxCyD;kBFAP;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AALnD,CAAA,CAAA;;;AAIqD,IAAA,CC5BzC,aD4ByC,CAAA,CAAA,CAAA,CAAA,CC5BvB,cD4BuB,CAAA,CAAA,CAAA,CC5BL,MD4BK,CC5BE,CD4BF,CAAA,CC5BK,QD4BL,CAAA;;;;KCvBzC,cAAA,CAAA,CAAA;;AALZ,CAAA;;;KC2BK,cAAA,CAAA,CAAA,CAAiB,cAAc;;;cAE9B,uCAA4C,QAAQ"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@soda-gql/cli",
3
- "version": "0.8.2",
3
+ "version": "0.9.0",
4
4
  "description": "Command-line interface for soda-gql",
5
5
  "type": "module",
6
6
  "private": false,
@@ -48,8 +48,8 @@
48
48
  "./package.json": "./package.json"
49
49
  },
50
50
  "dependencies": {
51
- "@soda-gql/codegen": "~0.8.0",
52
- "@soda-gql/builder": "~0.8.0",
51
+ "@soda-gql/codegen": "~0.9.0",
52
+ "@soda-gql/builder": "~0.9.0",
53
53
  "fast-glob": "^3.3.3",
54
54
  "neverthrow": "^8.1.1",
55
55
  "zod": "^4.1.11"
@@ -57,6 +57,6 @@
57
57
  "devDependencies": {},
58
58
  "peerDependencies": {},
59
59
  "optionalDependencies": {
60
- "@soda-gql/formatter": "~0.8.0"
60
+ "@soda-gql/formatter": "~0.9.0"
61
61
  }
62
62
  }