@constructive-io/cli 6.1.6 → 6.1.7
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 +25 -9
- package/commands/codegen.js +19 -17
- package/esm/commands/codegen.js +20 -18
- package/package.json +3 -3
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
|
-
#
|
|
65
|
-
cnc codegen --endpoint http://localhost:5555/graphql --
|
|
64
|
+
# Generate React Query hooks from endpoint
|
|
65
|
+
cnc codegen --endpoint http://localhost:5555/graphql --output ./codegen --react-query
|
|
66
66
|
|
|
67
|
-
#
|
|
68
|
-
cnc codegen --
|
|
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
|
-
- `--
|
|
75
|
-
- `--
|
|
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.
|
package/commands/codegen.js
CHANGED
|
@@ -9,20 +9,20 @@ 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
|
-
--
|
|
12
|
+
--schema-file <path> Path to GraphQL schema file
|
|
13
13
|
|
|
14
14
|
Database Options:
|
|
15
15
|
--schemas <list> Comma-separated PostgreSQL schemas
|
|
16
|
-
--
|
|
16
|
+
--api-names <list> Comma-separated API names
|
|
17
17
|
|
|
18
18
|
Generator Options:
|
|
19
|
-
--
|
|
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
|
-
--
|
|
23
|
+
--browser-compatible Generate browser-compatible code (default: true)
|
|
24
24
|
Set to false for Node.js with localhost DNS fix
|
|
25
|
-
--
|
|
25
|
+
--dry-run Preview without writing files
|
|
26
26
|
--verbose Verbose output
|
|
27
27
|
|
|
28
28
|
--help, -h Show this help message
|
|
@@ -42,22 +42,24 @@ exports.default = async (argv, prompter, _options) => {
|
|
|
42
42
|
}
|
|
43
43
|
// No config file - prompt for options using shared questions
|
|
44
44
|
const answers = await prompter.prompt(argv, graphql_codegen_1.codegenQuestions);
|
|
45
|
+
// Convert kebab-case CLI args to camelCase for internal use
|
|
46
|
+
const camelized = (0, graphql_codegen_1.camelizeArgv)(answers);
|
|
45
47
|
// Build db config if schemas or apiNames provided
|
|
46
|
-
const db = (
|
|
47
|
-
schemas:
|
|
48
|
-
apiNames:
|
|
48
|
+
const db = (camelized.schemas || camelized.apiNames) ? {
|
|
49
|
+
schemas: camelized.schemas,
|
|
50
|
+
apiNames: camelized.apiNames,
|
|
49
51
|
} : undefined;
|
|
50
52
|
const result = await (0, graphql_codegen_1.generate)({
|
|
51
|
-
endpoint:
|
|
52
|
-
schemaFile:
|
|
53
|
+
endpoint: camelized.endpoint,
|
|
54
|
+
schemaFile: camelized.schemaFile,
|
|
53
55
|
db,
|
|
54
|
-
output:
|
|
55
|
-
authorization:
|
|
56
|
-
reactQuery:
|
|
57
|
-
orm:
|
|
58
|
-
browserCompatible:
|
|
59
|
-
dryRun:
|
|
60
|
-
verbose:
|
|
56
|
+
output: camelized.output,
|
|
57
|
+
authorization: camelized.authorization,
|
|
58
|
+
reactQuery: camelized.reactQuery,
|
|
59
|
+
orm: camelized.orm,
|
|
60
|
+
browserCompatible: camelized.browserCompatible,
|
|
61
|
+
dryRun: camelized.dryRun,
|
|
62
|
+
verbose: camelized.verbose,
|
|
61
63
|
});
|
|
62
64
|
(0, graphql_codegen_1.printResult)(result);
|
|
63
65
|
};
|
package/esm/commands/codegen.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { generate, findConfigFile, codegenQuestions, printResult, } from '@constructive-io/graphql-codegen';
|
|
1
|
+
import { generate, findConfigFile, codegenQuestions, printResult, camelizeArgv, } from '@constructive-io/graphql-codegen';
|
|
2
2
|
const usage = `
|
|
3
3
|
Constructive GraphQL Codegen:
|
|
4
4
|
|
|
@@ -7,20 +7,20 @@ 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
|
-
--
|
|
10
|
+
--schema-file <path> Path to GraphQL schema file
|
|
11
11
|
|
|
12
12
|
Database Options:
|
|
13
13
|
--schemas <list> Comma-separated PostgreSQL schemas
|
|
14
|
-
--
|
|
14
|
+
--api-names <list> Comma-separated API names
|
|
15
15
|
|
|
16
16
|
Generator Options:
|
|
17
|
-
--
|
|
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
|
-
--
|
|
21
|
+
--browser-compatible Generate browser-compatible code (default: true)
|
|
22
22
|
Set to false for Node.js with localhost DNS fix
|
|
23
|
-
--
|
|
23
|
+
--dry-run Preview without writing files
|
|
24
24
|
--verbose Verbose output
|
|
25
25
|
|
|
26
26
|
--help, -h Show this help message
|
|
@@ -40,22 +40,24 @@ export default async (argv, prompter, _options) => {
|
|
|
40
40
|
}
|
|
41
41
|
// No config file - prompt for options using shared questions
|
|
42
42
|
const answers = await prompter.prompt(argv, codegenQuestions);
|
|
43
|
+
// Convert kebab-case CLI args to camelCase for internal use
|
|
44
|
+
const camelized = camelizeArgv(answers);
|
|
43
45
|
// Build db config if schemas or apiNames provided
|
|
44
|
-
const db = (
|
|
45
|
-
schemas:
|
|
46
|
-
apiNames:
|
|
46
|
+
const db = (camelized.schemas || camelized.apiNames) ? {
|
|
47
|
+
schemas: camelized.schemas,
|
|
48
|
+
apiNames: camelized.apiNames,
|
|
47
49
|
} : undefined;
|
|
48
50
|
const result = await generate({
|
|
49
|
-
endpoint:
|
|
50
|
-
schemaFile:
|
|
51
|
+
endpoint: camelized.endpoint,
|
|
52
|
+
schemaFile: camelized.schemaFile,
|
|
51
53
|
db,
|
|
52
|
-
output:
|
|
53
|
-
authorization:
|
|
54
|
-
reactQuery:
|
|
55
|
-
orm:
|
|
56
|
-
browserCompatible:
|
|
57
|
-
dryRun:
|
|
58
|
-
verbose:
|
|
54
|
+
output: camelized.output,
|
|
55
|
+
authorization: camelized.authorization,
|
|
56
|
+
reactQuery: camelized.reactQuery,
|
|
57
|
+
orm: camelized.orm,
|
|
58
|
+
browserCompatible: camelized.browserCompatible,
|
|
59
|
+
dryRun: camelized.dryRun,
|
|
60
|
+
verbose: camelized.verbose,
|
|
59
61
|
});
|
|
60
62
|
printResult(result);
|
|
61
63
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@constructive-io/cli",
|
|
3
|
-
"version": "6.1.
|
|
3
|
+
"version": "6.1.7",
|
|
4
4
|
"author": "Constructive <developers@constructive.io>",
|
|
5
5
|
"description": "Constructive CLI",
|
|
6
6
|
"main": "index.js",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"ts-node": "^10.9.2"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@constructive-io/graphql-codegen": "^3.2.
|
|
48
|
+
"@constructive-io/graphql-codegen": "^3.2.1",
|
|
49
49
|
"@constructive-io/graphql-env": "^2.9.4",
|
|
50
50
|
"@constructive-io/graphql-explorer": "^3.0.5",
|
|
51
51
|
"@constructive-io/graphql-server": "^3.0.5",
|
|
@@ -76,5 +76,5 @@
|
|
|
76
76
|
"postgres",
|
|
77
77
|
"graphile"
|
|
78
78
|
],
|
|
79
|
-
"gitHead": "
|
|
79
|
+
"gitHead": "013a736cd2b09d465697c58c1b807858129c16b5"
|
|
80
80
|
}
|