@constructive-io/cli 6.1.6 → 6.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -61,24 +61,40 @@ cnc explorer --origin http://localhost:3000
61
61
  Generate TypeScript types, operations, and SDK from a GraphQL schema or endpoint.
62
62
 
63
63
  ```bash
64
- # From endpoint
65
- cnc codegen --endpoint http://localhost:5555/graphql --out ./codegen
64
+ # Generate React Query hooks from endpoint
65
+ cnc codegen --endpoint http://localhost:5555/graphql --output ./codegen --react-query
66
66
 
67
- # From database
68
- cnc codegen --database constructive_db --out ./codegen --verbose
67
+ # Generate ORM client from endpoint
68
+ cnc codegen --endpoint http://localhost:5555/graphql --output ./codegen --orm
69
+
70
+ # Generate both React Query hooks and ORM client
71
+ cnc codegen --endpoint http://localhost:5555/graphql --output ./codegen --react-query --orm
72
+
73
+ # From schema file
74
+ cnc codegen --schema-file ./schema.graphql --output ./codegen --react-query
75
+
76
+ # From database with schemas
77
+ cnc codegen --schemas public,app_public --output ./codegen --react-query
78
+
79
+ # From database with API names
80
+ cnc codegen --api-names my_api --output ./codegen --orm
69
81
  ```
70
82
 
71
83
  **Options:**
72
84
 
85
+ - `--config <path>` - Path to config file
73
86
  - `--endpoint <url>` - GraphQL endpoint URL
74
- - `--auth <token>` - Authorization header value (e.g., "Bearer 123")
75
- - `--out <dir>` - Output directory (default: graphql/codegen/dist)
87
+ - `--schema-file <path>` - Path to GraphQL schema file
88
+ - `--schemas <list>` - Comma-separated PostgreSQL schemas
89
+ - `--api-names <list>` - Comma-separated API names
90
+ - `--react-query` - Generate React Query hooks
91
+ - `--orm` - Generate ORM client
92
+ - `--output <dir>` - Output directory (default: ./codegen)
93
+ - `--authorization <token>` - Authorization header value
94
+ - `--browser-compatible` - Generate browser-compatible code (default: true)
76
95
  - `--dry-run` - Preview without writing files
77
96
  - `--verbose` - Verbose output
78
97
 
79
- - `--database <name>` - Database override for DB mode (defaults to PGDATABASE)
80
- - `--schemas <list>` - Comma-separated schemas (required unless using --endpoint)
81
-
82
98
  ### `cnc get-graphql-schema`
83
99
 
84
100
  Fetch or build GraphQL schema SDL.
@@ -9,20 +9,18 @@ Constructive GraphQL Codegen:
9
9
  Source Options (choose one):
10
10
  --config <path> Path to graphql-codegen config file
11
11
  --endpoint <url> GraphQL endpoint URL
12
- --schemaFile <path> Path to GraphQL schema file
12
+ --schema-file <path> Path to GraphQL schema file
13
13
 
14
14
  Database Options:
15
15
  --schemas <list> Comma-separated PostgreSQL schemas
16
- --apiNames <list> Comma-separated API names
16
+ --api-names <list> Comma-separated API names
17
17
 
18
18
  Generator Options:
19
- --reactQuery Generate React Query hooks (default)
19
+ --react-query Generate React Query hooks (default)
20
20
  --orm Generate ORM client
21
21
  --output <dir> Output directory (default: codegen)
22
22
  --authorization <token> Authorization header value
23
- --browserCompatible Generate browser-compatible code (default: true)
24
- Set to false for Node.js with localhost DNS fix
25
- --dryRun Preview without writing files
23
+ --dry-run Preview without writing files
26
24
  --verbose Verbose output
27
25
 
28
26
  --help, -h Show this help message
@@ -32,32 +30,23 @@ exports.default = async (argv, prompter, _options) => {
32
30
  console.log(usage);
33
31
  process.exit(0);
34
32
  }
35
- // Auto-detect config file if not provided
36
- const config = argv.config || (0, graphql_codegen_1.findConfigFile)();
37
- if (config) {
38
- // If config file exists, just run generate with it (config file handles everything)
39
- const result = await (0, graphql_codegen_1.generate)({});
40
- (0, graphql_codegen_1.printResult)(result);
41
- return;
33
+ const hasSourceFlags = Boolean(argv.endpoint || argv['schema-file'] || argv.schemas || argv['api-names']);
34
+ const configPath = argv.config ||
35
+ (!hasSourceFlags ? (0, graphql_codegen_1.findConfigFile)() : undefined);
36
+ let fileConfig = {};
37
+ if (configPath) {
38
+ const loaded = await (0, graphql_codegen_1.loadConfigFile)(configPath);
39
+ if (!loaded.success) {
40
+ console.error('x', loaded.error);
41
+ process.exit(1);
42
+ }
43
+ fileConfig = loaded.config;
42
44
  }
43
- // No config file - prompt for options using shared questions
44
- const answers = await prompter.prompt(argv, graphql_codegen_1.codegenQuestions);
45
- // Build db config if schemas or apiNames provided
46
- const db = (answers.schemas || answers.apiNames) ? {
47
- schemas: answers.schemas,
48
- apiNames: answers.apiNames,
49
- } : undefined;
50
- const result = await (0, graphql_codegen_1.generate)({
51
- endpoint: answers.endpoint,
52
- schemaFile: answers.schemaFile,
53
- db,
54
- output: answers.output,
55
- authorization: answers.authorization,
56
- reactQuery: answers.reactQuery,
57
- orm: answers.orm,
58
- browserCompatible: answers.browserCompatible,
59
- dryRun: answers.dryRun,
60
- verbose: answers.verbose,
61
- });
45
+ const seeded = (0, graphql_codegen_1.seedArgvFromConfig)(argv, fileConfig);
46
+ const answers = (0, graphql_codegen_1.hasResolvedCodegenSource)(seeded)
47
+ ? seeded
48
+ : await prompter.prompt(seeded, graphql_codegen_1.codegenQuestions);
49
+ const options = (0, graphql_codegen_1.buildGenerateOptions)(answers, fileConfig);
50
+ const result = await (0, graphql_codegen_1.generate)(options);
62
51
  (0, graphql_codegen_1.printResult)(result);
63
52
  };
@@ -1,4 +1,4 @@
1
- import { generate, findConfigFile, codegenQuestions, printResult, } from '@constructive-io/graphql-codegen';
1
+ import { generate, findConfigFile, loadConfigFile, codegenQuestions, printResult, buildGenerateOptions, seedArgvFromConfig, hasResolvedCodegenSource, } from '@constructive-io/graphql-codegen';
2
2
  const usage = `
3
3
  Constructive GraphQL Codegen:
4
4
 
@@ -7,20 +7,18 @@ Constructive GraphQL Codegen:
7
7
  Source Options (choose one):
8
8
  --config <path> Path to graphql-codegen config file
9
9
  --endpoint <url> GraphQL endpoint URL
10
- --schemaFile <path> Path to GraphQL schema file
10
+ --schema-file <path> Path to GraphQL schema file
11
11
 
12
12
  Database Options:
13
13
  --schemas <list> Comma-separated PostgreSQL schemas
14
- --apiNames <list> Comma-separated API names
14
+ --api-names <list> Comma-separated API names
15
15
 
16
16
  Generator Options:
17
- --reactQuery Generate React Query hooks (default)
17
+ --react-query Generate React Query hooks (default)
18
18
  --orm Generate ORM client
19
19
  --output <dir> Output directory (default: codegen)
20
20
  --authorization <token> Authorization header value
21
- --browserCompatible Generate browser-compatible code (default: true)
22
- Set to false for Node.js with localhost DNS fix
23
- --dryRun Preview without writing files
21
+ --dry-run Preview without writing files
24
22
  --verbose Verbose output
25
23
 
26
24
  --help, -h Show this help message
@@ -30,32 +28,23 @@ export default async (argv, prompter, _options) => {
30
28
  console.log(usage);
31
29
  process.exit(0);
32
30
  }
33
- // Auto-detect config file if not provided
34
- const config = argv.config || findConfigFile();
35
- if (config) {
36
- // If config file exists, just run generate with it (config file handles everything)
37
- const result = await generate({});
38
- printResult(result);
39
- return;
31
+ const hasSourceFlags = Boolean(argv.endpoint || argv['schema-file'] || argv.schemas || argv['api-names']);
32
+ const configPath = argv.config ||
33
+ (!hasSourceFlags ? findConfigFile() : undefined);
34
+ let fileConfig = {};
35
+ if (configPath) {
36
+ const loaded = await loadConfigFile(configPath);
37
+ if (!loaded.success) {
38
+ console.error('x', loaded.error);
39
+ process.exit(1);
40
+ }
41
+ fileConfig = loaded.config;
40
42
  }
41
- // No config file - prompt for options using shared questions
42
- const answers = await prompter.prompt(argv, codegenQuestions);
43
- // Build db config if schemas or apiNames provided
44
- const db = (answers.schemas || answers.apiNames) ? {
45
- schemas: answers.schemas,
46
- apiNames: answers.apiNames,
47
- } : undefined;
48
- const result = await generate({
49
- endpoint: answers.endpoint,
50
- schemaFile: answers.schemaFile,
51
- db,
52
- output: answers.output,
53
- authorization: answers.authorization,
54
- reactQuery: answers.reactQuery,
55
- orm: answers.orm,
56
- browserCompatible: answers.browserCompatible,
57
- dryRun: answers.dryRun,
58
- verbose: answers.verbose,
59
- });
43
+ const seeded = seedArgvFromConfig(argv, fileConfig);
44
+ const answers = hasResolvedCodegenSource(seeded)
45
+ ? seeded
46
+ : await prompter.prompt(seeded, codegenQuestions);
47
+ const options = buildGenerateOptions(answers, fileConfig);
48
+ const result = await generate(options);
60
49
  printResult(result);
61
50
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@constructive-io/cli",
3
- "version": "6.1.6",
3
+ "version": "6.2.0",
4
4
  "author": "Constructive <developers@constructive.io>",
5
5
  "description": "Constructive CLI",
6
6
  "main": "index.js",
@@ -40,28 +40,28 @@
40
40
  "@types/pg": "^8.16.0",
41
41
  "@types/shelljs": "^0.8.16",
42
42
  "glob": "^13.0.0",
43
- "makage": "^0.1.10",
43
+ "makage": "^0.1.12",
44
44
  "pg": "^8.17.1",
45
45
  "ts-node": "^10.9.2"
46
46
  },
47
47
  "dependencies": {
48
- "@constructive-io/graphql-codegen": "^3.2.0",
49
- "@constructive-io/graphql-env": "^2.9.4",
50
- "@constructive-io/graphql-explorer": "^3.0.5",
51
- "@constructive-io/graphql-server": "^3.0.5",
52
- "@constructive-io/knative-job-service": "^1.0.6",
48
+ "@constructive-io/graphql-codegen": "^3.3.0",
49
+ "@constructive-io/graphql-env": "^2.10.0",
50
+ "@constructive-io/graphql-explorer": "^3.1.0",
51
+ "@constructive-io/graphql-server": "^3.1.0",
52
+ "@constructive-io/knative-job-service": "^1.1.0",
53
53
  "@inquirerer/utils": "^3.2.0",
54
- "@pgpmjs/core": "^5.1.1",
55
- "@pgpmjs/logger": "^2.0.0",
56
- "@pgpmjs/server-utils": "^3.0.0",
57
- "@pgpmjs/types": "^2.15.0",
54
+ "@pgpmjs/core": "^5.2.0",
55
+ "@pgpmjs/logger": "^2.1.0",
56
+ "@pgpmjs/server-utils": "^3.1.0",
57
+ "@pgpmjs/types": "^2.16.0",
58
58
  "appstash": "^0.3.0",
59
59
  "find-and-require-package-json": "^0.9.0",
60
60
  "inquirerer": "^4.5.0",
61
61
  "js-yaml": "^4.1.0",
62
- "pg-cache": "^2.0.0",
63
- "pg-env": "^1.3.0",
64
- "pgpm": "^3.2.1",
62
+ "pg-cache": "^2.1.0",
63
+ "pg-env": "^1.4.0",
64
+ "pgpm": "^3.3.0",
65
65
  "shelljs": "^0.10.0",
66
66
  "yanse": "^0.2.0"
67
67
  },
@@ -76,5 +76,5 @@
76
76
  "postgres",
77
77
  "graphile"
78
78
  ],
79
- "gitHead": "6c33cfe4fcc43de961a33603989ffb8adbaecc09"
79
+ "gitHead": "048188f6b43ffaa6146e7694b2b0d35d34cb2945"
80
80
  }