@constructive-io/graphql-codegen 2.32.0 → 3.0.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 +429 -1691
- package/cli/index.d.ts +5 -2
- package/cli/index.js +98 -581
- package/cli/shared.d.ts +35 -0
- package/cli/shared.js +106 -0
- package/{esm/cli → core}/codegen/barrel.d.ts +1 -1
- package/{cli → core}/codegen/barrel.js +1 -4
- package/{esm/cli → core}/codegen/index.d.ts +15 -5
- package/{cli → core}/codegen/index.js +44 -24
- package/{cli → core}/codegen/invalidation.d.ts +2 -2
- package/{esm/cli → core}/codegen/mutation-keys.d.ts +2 -2
- package/{cli → core}/codegen/orm/client-generator.js +2 -3
- package/{esm/cli → core}/codegen/orm/index.d.ts +9 -2
- package/{cli → core}/codegen/orm/index.js +3 -2
- package/{cli → core}/codegen/query-keys.d.ts +2 -2
- package/core/codegen/shared/index.d.ts +39 -0
- package/core/codegen/shared/index.js +118 -0
- package/core/config/index.d.ts +5 -0
- package/core/config/index.js +13 -0
- package/core/config/loader.d.ts +18 -0
- package/{cli/commands/init.js → core/config/loader.js} +7 -94
- package/core/config/resolver.d.ts +46 -0
- package/core/config/resolver.js +104 -0
- package/core/database/index.d.ts +43 -0
- package/core/database/index.js +85 -0
- package/core/generate.d.ts +22 -0
- package/core/generate.js +192 -0
- package/core/index.d.ts +13 -1
- package/core/index.js +22 -2
- package/{cli → core}/introspect/fetch-schema.js +58 -9
- package/core/introspect/source/api-schemas.d.ts +44 -0
- package/core/introspect/source/api-schemas.js +122 -0
- package/core/introspect/source/database.d.ts +32 -0
- package/core/introspect/source/database.js +91 -0
- package/core/introspect/source/index.d.ts +112 -0
- package/core/introspect/source/index.js +173 -0
- package/core/introspect/source/pgpm-module.d.ts +83 -0
- package/core/introspect/source/pgpm-module.js +200 -0
- package/core/output/index.d.ts +4 -0
- package/core/output/index.js +9 -0
- package/core/output/writer.d.ts +38 -0
- package/core/output/writer.js +156 -0
- package/{cli/commands/shared.d.ts → core/pipeline/index.d.ts} +5 -3
- package/{cli/commands/shared.js → core/pipeline/index.js} +4 -0
- package/{cli → core}/watch/orchestrator.d.ts +25 -3
- package/{cli → core}/watch/orchestrator.js +35 -27
- package/{cli → core}/watch/types.d.ts +1 -1
- package/esm/cli/index.d.ts +5 -2
- package/esm/cli/index.js +97 -547
- package/esm/cli/shared.d.ts +35 -0
- package/esm/cli/shared.js +101 -0
- package/{cli → esm/core}/codegen/barrel.d.ts +1 -1
- package/esm/{cli → core}/codegen/barrel.js +1 -4
- package/{cli → esm/core}/codegen/index.d.ts +15 -5
- package/esm/{cli → core}/codegen/index.js +44 -24
- package/esm/{cli → core}/codegen/invalidation.d.ts +2 -2
- package/{cli → esm/core}/codegen/mutation-keys.d.ts +2 -2
- package/esm/{cli → core}/codegen/orm/client-generator.js +2 -3
- package/{cli → esm/core}/codegen/orm/index.d.ts +9 -2
- package/esm/{cli → core}/codegen/orm/index.js +3 -2
- package/esm/{cli → core}/codegen/query-keys.d.ts +2 -2
- package/esm/core/codegen/shared/index.d.ts +39 -0
- package/esm/core/codegen/shared/index.js +79 -0
- package/esm/core/config/index.d.ts +5 -0
- package/esm/core/config/index.js +5 -0
- package/esm/core/config/loader.d.ts +18 -0
- package/esm/core/config/loader.js +71 -0
- package/esm/core/config/resolver.d.ts +46 -0
- package/esm/core/config/resolver.js +100 -0
- package/esm/core/database/index.d.ts +43 -0
- package/esm/core/database/index.js +48 -0
- package/esm/core/generate.d.ts +22 -0
- package/esm/core/generate.js +186 -0
- package/esm/core/index.d.ts +13 -1
- package/esm/core/index.js +20 -1
- package/esm/{cli → core}/introspect/fetch-schema.js +55 -9
- package/esm/core/introspect/source/api-schemas.d.ts +44 -0
- package/esm/core/introspect/source/api-schemas.js +117 -0
- package/esm/core/introspect/source/database.d.ts +32 -0
- package/esm/core/introspect/source/database.js +87 -0
- package/esm/core/introspect/source/index.d.ts +112 -0
- package/esm/core/introspect/source/index.js +154 -0
- package/esm/core/introspect/source/pgpm-module.d.ts +83 -0
- package/esm/core/introspect/source/pgpm-module.js +194 -0
- package/esm/core/output/index.d.ts +4 -0
- package/esm/core/output/index.js +4 -0
- package/esm/core/output/writer.d.ts +38 -0
- package/esm/core/output/writer.js +119 -0
- package/esm/{cli/commands/shared.d.ts → core/pipeline/index.d.ts} +5 -3
- package/esm/{cli/commands/shared.js → core/pipeline/index.js} +1 -0
- package/esm/{cli → core}/watch/orchestrator.d.ts +25 -3
- package/esm/{cli → core}/watch/orchestrator.js +35 -27
- package/esm/{cli → core}/watch/types.d.ts +1 -1
- package/esm/index.d.ts +8 -3
- package/esm/index.js +9 -3
- package/esm/types/config.d.ts +101 -138
- package/esm/types/config.js +8 -35
- package/esm/types/index.d.ts +2 -2
- package/esm/types/index.js +1 -1
- package/index.d.ts +8 -3
- package/index.js +18 -8
- package/package.json +18 -11
- package/types/config.d.ts +101 -138
- package/types/config.js +9 -38
- package/types/index.d.ts +2 -2
- package/types/index.js +3 -3
- package/cli/commands/generate-orm.d.ts +0 -53
- package/cli/commands/generate-orm.js +0 -292
- package/cli/commands/generate.d.ts +0 -66
- package/cli/commands/generate.js +0 -431
- package/cli/commands/index.d.ts +0 -9
- package/cli/commands/index.js +0 -14
- package/cli/commands/init.d.ts +0 -35
- package/cli/introspect/source/index.d.ts +0 -48
- package/cli/introspect/source/index.js +0 -72
- package/esm/cli/commands/generate-orm.d.ts +0 -53
- package/esm/cli/commands/generate-orm.js +0 -289
- package/esm/cli/commands/generate.d.ts +0 -66
- package/esm/cli/commands/generate.js +0 -393
- package/esm/cli/commands/index.d.ts +0 -9
- package/esm/cli/commands/index.js +0 -6
- package/esm/cli/commands/init.d.ts +0 -35
- package/esm/cli/commands/init.js +0 -158
- package/esm/cli/introspect/source/index.d.ts +0 -48
- package/esm/cli/introspect/source/index.js +0 -54
- /package/{cli → core}/codegen/babel-ast.d.ts +0 -0
- /package/{cli → core}/codegen/babel-ast.js +0 -0
- /package/{cli → core}/codegen/client.d.ts +0 -0
- /package/{cli → core}/codegen/client.js +0 -0
- /package/{cli → core}/codegen/custom-mutations.d.ts +0 -0
- /package/{cli → core}/codegen/custom-mutations.js +0 -0
- /package/{cli → core}/codegen/custom-queries.d.ts +0 -0
- /package/{cli → core}/codegen/custom-queries.js +0 -0
- /package/{cli → core}/codegen/gql-ast.d.ts +0 -0
- /package/{cli → core}/codegen/gql-ast.js +0 -0
- /package/{cli → core}/codegen/invalidation.js +0 -0
- /package/{cli → core}/codegen/mutation-keys.js +0 -0
- /package/{cli → core}/codegen/mutations.d.ts +0 -0
- /package/{cli → core}/codegen/mutations.js +0 -0
- /package/{cli → core}/codegen/orm/barrel.d.ts +0 -0
- /package/{cli → core}/codegen/orm/barrel.js +0 -0
- /package/{cli → core}/codegen/orm/client-generator.d.ts +0 -0
- /package/{cli → core}/codegen/orm/client.d.ts +0 -0
- /package/{cli → core}/codegen/orm/client.js +0 -0
- /package/{cli → core}/codegen/orm/custom-ops-generator.d.ts +0 -0
- /package/{cli → core}/codegen/orm/custom-ops-generator.js +0 -0
- /package/{cli → core}/codegen/orm/input-types-generator.d.ts +0 -0
- /package/{cli → core}/codegen/orm/input-types-generator.js +0 -0
- /package/{cli → core}/codegen/orm/model-generator.d.ts +0 -0
- /package/{cli → core}/codegen/orm/model-generator.js +0 -0
- /package/{cli → core}/codegen/orm/query-builder.d.ts +0 -0
- /package/{cli → core}/codegen/orm/query-builder.js +0 -0
- /package/{cli → core}/codegen/orm/query-builder.ts +0 -0
- /package/{cli → core}/codegen/orm/select-types.d.ts +0 -0
- /package/{cli → core}/codegen/orm/select-types.js +0 -0
- /package/{cli → core}/codegen/queries.d.ts +0 -0
- /package/{cli → core}/codegen/queries.js +0 -0
- /package/{cli → core}/codegen/query-keys.js +0 -0
- /package/{cli → core}/codegen/scalars.d.ts +0 -0
- /package/{cli → core}/codegen/scalars.js +0 -0
- /package/{cli → core}/codegen/schema-gql-ast.d.ts +0 -0
- /package/{cli → core}/codegen/schema-gql-ast.js +0 -0
- /package/{cli → core}/codegen/schema-types-generator.d.ts +0 -0
- /package/{cli → core}/codegen/schema-types-generator.js +0 -0
- /package/{cli → core}/codegen/type-resolver.d.ts +0 -0
- /package/{cli → core}/codegen/type-resolver.js +0 -0
- /package/{cli → core}/codegen/types.d.ts +0 -0
- /package/{cli → core}/codegen/types.js +0 -0
- /package/{cli → core}/codegen/utils.d.ts +0 -0
- /package/{cli → core}/codegen/utils.js +0 -0
- /package/{cli → core}/introspect/fetch-schema.d.ts +0 -0
- /package/{cli → core}/introspect/index.d.ts +0 -0
- /package/{cli → core}/introspect/index.js +0 -0
- /package/{cli → core}/introspect/infer-tables.d.ts +0 -0
- /package/{cli → core}/introspect/infer-tables.js +0 -0
- /package/{cli → core}/introspect/schema-query.d.ts +0 -0
- /package/{cli → core}/introspect/schema-query.js +0 -0
- /package/{cli → core}/introspect/source/endpoint.d.ts +0 -0
- /package/{cli → core}/introspect/source/endpoint.js +0 -0
- /package/{cli → core}/introspect/source/file.d.ts +0 -0
- /package/{cli → core}/introspect/source/file.js +0 -0
- /package/{cli → core}/introspect/source/types.d.ts +0 -0
- /package/{cli → core}/introspect/source/types.js +0 -0
- /package/{cli → core}/introspect/transform-schema.d.ts +0 -0
- /package/{cli → core}/introspect/transform-schema.js +0 -0
- /package/{cli → core}/introspect/transform.d.ts +0 -0
- /package/{cli → core}/introspect/transform.js +0 -0
- /package/{cli → core}/watch/cache.d.ts +0 -0
- /package/{cli → core}/watch/cache.js +0 -0
- /package/{cli → core}/watch/debounce.d.ts +0 -0
- /package/{cli → core}/watch/debounce.js +0 -0
- /package/{cli → core}/watch/hash.d.ts +0 -0
- /package/{cli → core}/watch/hash.js +0 -0
- /package/{cli → core}/watch/index.d.ts +0 -0
- /package/{cli → core}/watch/index.js +0 -0
- /package/{cli → core}/watch/poller.d.ts +0 -0
- /package/{cli → core}/watch/poller.js +0 -0
- /package/{cli → core}/watch/types.js +0 -0
- /package/esm/{cli → core}/codegen/babel-ast.d.ts +0 -0
- /package/esm/{cli → core}/codegen/babel-ast.js +0 -0
- /package/esm/{cli → core}/codegen/client.d.ts +0 -0
- /package/esm/{cli → core}/codegen/client.js +0 -0
- /package/esm/{cli → core}/codegen/custom-mutations.d.ts +0 -0
- /package/esm/{cli → core}/codegen/custom-mutations.js +0 -0
- /package/esm/{cli → core}/codegen/custom-queries.d.ts +0 -0
- /package/esm/{cli → core}/codegen/custom-queries.js +0 -0
- /package/esm/{cli → core}/codegen/gql-ast.d.ts +0 -0
- /package/esm/{cli → core}/codegen/gql-ast.js +0 -0
- /package/esm/{cli → core}/codegen/invalidation.js +0 -0
- /package/esm/{cli → core}/codegen/mutation-keys.js +0 -0
- /package/esm/{cli → core}/codegen/mutations.d.ts +0 -0
- /package/esm/{cli → core}/codegen/mutations.js +0 -0
- /package/esm/{cli → core}/codegen/orm/barrel.d.ts +0 -0
- /package/esm/{cli → core}/codegen/orm/barrel.js +0 -0
- /package/esm/{cli → core}/codegen/orm/client-generator.d.ts +0 -0
- /package/esm/{cli → core}/codegen/orm/client.d.ts +0 -0
- /package/esm/{cli → core}/codegen/orm/client.js +0 -0
- /package/esm/{cli → core}/codegen/orm/custom-ops-generator.d.ts +0 -0
- /package/esm/{cli → core}/codegen/orm/custom-ops-generator.js +0 -0
- /package/esm/{cli → core}/codegen/orm/input-types-generator.d.ts +0 -0
- /package/esm/{cli → core}/codegen/orm/input-types-generator.js +0 -0
- /package/esm/{cli → core}/codegen/orm/model-generator.d.ts +0 -0
- /package/esm/{cli → core}/codegen/orm/model-generator.js +0 -0
- /package/esm/{cli → core}/codegen/orm/query-builder.d.ts +0 -0
- /package/esm/{cli → core}/codegen/orm/query-builder.js +0 -0
- /package/esm/{cli → core}/codegen/orm/select-types.d.ts +0 -0
- /package/esm/{cli → core}/codegen/orm/select-types.js +0 -0
- /package/esm/{cli → core}/codegen/queries.d.ts +0 -0
- /package/esm/{cli → core}/codegen/queries.js +0 -0
- /package/esm/{cli → core}/codegen/query-keys.js +0 -0
- /package/esm/{cli → core}/codegen/scalars.d.ts +0 -0
- /package/esm/{cli → core}/codegen/scalars.js +0 -0
- /package/esm/{cli → core}/codegen/schema-gql-ast.d.ts +0 -0
- /package/esm/{cli → core}/codegen/schema-gql-ast.js +0 -0
- /package/esm/{cli → core}/codegen/schema-types-generator.d.ts +0 -0
- /package/esm/{cli → core}/codegen/schema-types-generator.js +0 -0
- /package/esm/{cli → core}/codegen/type-resolver.d.ts +0 -0
- /package/esm/{cli → core}/codegen/type-resolver.js +0 -0
- /package/esm/{cli → core}/codegen/types.d.ts +0 -0
- /package/esm/{cli → core}/codegen/types.js +0 -0
- /package/esm/{cli → core}/codegen/utils.d.ts +0 -0
- /package/esm/{cli → core}/codegen/utils.js +0 -0
- /package/esm/{cli → core}/introspect/fetch-schema.d.ts +0 -0
- /package/esm/{cli → core}/introspect/index.d.ts +0 -0
- /package/esm/{cli → core}/introspect/index.js +0 -0
- /package/esm/{cli → core}/introspect/infer-tables.d.ts +0 -0
- /package/esm/{cli → core}/introspect/infer-tables.js +0 -0
- /package/esm/{cli → core}/introspect/schema-query.d.ts +0 -0
- /package/esm/{cli → core}/introspect/schema-query.js +0 -0
- /package/esm/{cli → core}/introspect/source/endpoint.d.ts +0 -0
- /package/esm/{cli → core}/introspect/source/endpoint.js +0 -0
- /package/esm/{cli → core}/introspect/source/file.d.ts +0 -0
- /package/esm/{cli → core}/introspect/source/file.js +0 -0
- /package/esm/{cli → core}/introspect/source/types.d.ts +0 -0
- /package/esm/{cli → core}/introspect/source/types.js +0 -0
- /package/esm/{cli → core}/introspect/transform-schema.d.ts +0 -0
- /package/esm/{cli → core}/introspect/transform-schema.js +0 -0
- /package/esm/{cli → core}/introspect/transform.d.ts +0 -0
- /package/esm/{cli → core}/introspect/transform.js +0 -0
- /package/esm/{cli → core}/watch/cache.d.ts +0 -0
- /package/esm/{cli → core}/watch/cache.js +0 -0
- /package/esm/{cli → core}/watch/debounce.d.ts +0 -0
- /package/esm/{cli → core}/watch/debounce.js +0 -0
- /package/esm/{cli → core}/watch/hash.d.ts +0 -0
- /package/esm/{cli → core}/watch/hash.js +0 -0
- /package/esm/{cli → core}/watch/index.d.ts +0 -0
- /package/esm/{cli → core}/watch/index.js +0 -0
- /package/esm/{cli → core}/watch/poller.d.ts +0 -0
- /package/esm/{cli → core}/watch/poller.js +0 -0
- /package/esm/{cli → core}/watch/types.js +0 -0
package/esm/cli/index.js
CHANGED
|
@@ -1,587 +1,137 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/**
|
|
3
3
|
* CLI entry point for graphql-codegen
|
|
4
|
+
*
|
|
5
|
+
* This is a thin wrapper around the core generate() function.
|
|
6
|
+
* All business logic is in the core modules.
|
|
4
7
|
*/
|
|
5
|
-
import { CLI,
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const usageText = `
|
|
12
|
-
graphql-codegen - CLI for generating GraphQL SDK from PostGraphile endpoints or schema files
|
|
8
|
+
import { CLI, getPackageJson } from 'inquirerer';
|
|
9
|
+
import { generate } from '../core/generate';
|
|
10
|
+
import { findConfigFile, loadConfigFile } from '../core/config';
|
|
11
|
+
import { codegenQuestions, printResult } from './shared';
|
|
12
|
+
const usage = `
|
|
13
|
+
graphql-codegen - GraphQL SDK generator for Constructive databases
|
|
13
14
|
|
|
14
15
|
Usage:
|
|
15
|
-
graphql-codegen
|
|
16
|
+
graphql-codegen [options]
|
|
16
17
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
introspect Introspect a GraphQL endpoint or schema file and print table info
|
|
18
|
+
Source Options (choose one):
|
|
19
|
+
-c, --config <path> Path to config file
|
|
20
|
+
-e, --endpoint <url> GraphQL endpoint URL
|
|
21
|
+
-s, --schema-file <path> Path to GraphQL schema file
|
|
22
22
|
|
|
23
|
-
Options:
|
|
24
|
-
--
|
|
25
|
-
--
|
|
23
|
+
Database Options:
|
|
24
|
+
--schemas <list> Comma-separated PostgreSQL schemas
|
|
25
|
+
--api-names <list> Comma-separated API names (mutually exclusive with --schemas)
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
Options:
|
|
36
|
-
--directory, -d <dir> Target directory for the config file (default: .)
|
|
37
|
-
--force, -f Force overwrite existing config
|
|
38
|
-
--endpoint, -e <url> GraphQL endpoint URL to pre-populate
|
|
39
|
-
--output, -o <dir> Output directory to pre-populate (default: ./generated)
|
|
40
|
-
--help, -h Show this help message
|
|
41
|
-
`;
|
|
42
|
-
const generateUsageText = `
|
|
43
|
-
graphql-codegen generate - Generate SDK from GraphQL endpoint or schema file
|
|
44
|
-
|
|
45
|
-
Usage:
|
|
46
|
-
graphql-codegen generate [options]
|
|
47
|
-
|
|
48
|
-
Options:
|
|
49
|
-
--config, -c <path> Path to config file
|
|
50
|
-
--target, -t <name> Target name in config file
|
|
51
|
-
--endpoint, -e <url> GraphQL endpoint URL (overrides config)
|
|
52
|
-
--schema, -s <path> Path to GraphQL schema file (.graphql)
|
|
53
|
-
--output, -o <dir> Output directory (overrides config)
|
|
54
|
-
--authorization, -a <header> Authorization header value
|
|
55
|
-
--verbose, -v Verbose output
|
|
56
|
-
--dry-run Dry run - show what would be generated without writing files
|
|
57
|
-
--watch, -w Watch mode - poll endpoint for schema changes (in-memory)
|
|
58
|
-
--poll-interval <ms> Polling interval in milliseconds (default: 3000)
|
|
59
|
-
--debounce <ms> Debounce delay before regenerating (default: 800)
|
|
60
|
-
--touch <file> File to touch on schema change
|
|
61
|
-
--no-clear Do not clear terminal on regeneration
|
|
62
|
-
--help, -h Show this help message
|
|
63
|
-
`;
|
|
64
|
-
const generateOrmUsageText = `
|
|
65
|
-
graphql-codegen generate-orm - Generate Prisma-like ORM client from GraphQL endpoint or schema file
|
|
66
|
-
|
|
67
|
-
Usage:
|
|
68
|
-
graphql-codegen generate-orm [options]
|
|
69
|
-
|
|
70
|
-
Options:
|
|
71
|
-
--config, -c <path> Path to config file
|
|
72
|
-
--target, -t <name> Target name in config file
|
|
73
|
-
--endpoint, -e <url> GraphQL endpoint URL (overrides config)
|
|
74
|
-
--schema, -s <path> Path to GraphQL schema file (.graphql)
|
|
75
|
-
--output, -o <dir> Output directory (overrides config)
|
|
76
|
-
--authorization, -a <header> Authorization header value
|
|
77
|
-
--verbose, -v Verbose output
|
|
78
|
-
--dry-run Dry run - show what would be generated without writing files
|
|
79
|
-
--skip-custom-operations Skip custom operations (only generate table CRUD)
|
|
80
|
-
--watch, -w Watch mode - poll endpoint for schema changes (in-memory)
|
|
81
|
-
--poll-interval <ms> Polling interval in milliseconds (default: 3000)
|
|
82
|
-
--debounce <ms> Debounce delay before regenerating (default: 800)
|
|
83
|
-
--touch <file> File to touch on schema change
|
|
84
|
-
--no-clear Do not clear terminal on regeneration
|
|
85
|
-
--help, -h Show this help message
|
|
86
|
-
`;
|
|
87
|
-
const introspectUsageText = `
|
|
88
|
-
graphql-codegen introspect - Introspect a GraphQL endpoint or schema file and print table info
|
|
89
|
-
|
|
90
|
-
Usage:
|
|
91
|
-
graphql-codegen introspect [options]
|
|
27
|
+
Generator Options:
|
|
28
|
+
--react-query Generate React Query hooks
|
|
29
|
+
--orm Generate ORM client
|
|
30
|
+
-o, --output <dir> Output directory
|
|
31
|
+
-t, --target <name> Target name (for multi-target configs)
|
|
32
|
+
-a, --authorization <token> Authorization header value
|
|
33
|
+
--dry-run Preview without writing files
|
|
34
|
+
-v, --verbose Show detailed output
|
|
92
35
|
|
|
93
|
-
|
|
94
|
-
--
|
|
95
|
-
--schema, -s <path> Path to GraphQL schema file (.graphql)
|
|
96
|
-
--authorization, -a <header> Authorization header value
|
|
97
|
-
--json Output as JSON
|
|
98
|
-
--help, -h Show this help message
|
|
36
|
+
-h, --help Show this help message
|
|
37
|
+
--version Show version number
|
|
99
38
|
`;
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
*/
|
|
105
|
-
function formatDuration(ms) {
|
|
106
|
-
if (ms < 1000) {
|
|
107
|
-
return `${Math.round(ms)}ms`;
|
|
108
|
-
}
|
|
109
|
-
return `${(ms / 1000).toFixed(2)}s`;
|
|
110
|
-
}
|
|
111
|
-
/**
|
|
112
|
-
* Load configuration for watch mode, merging CLI options with config file
|
|
113
|
-
*/
|
|
114
|
-
async function loadWatchConfig(options) {
|
|
115
|
-
let configPath = options.config;
|
|
116
|
-
if (!configPath) {
|
|
117
|
-
configPath = findConfigFile() ?? undefined;
|
|
118
|
-
}
|
|
119
|
-
let baseConfig = {};
|
|
120
|
-
if (configPath) {
|
|
121
|
-
const loadResult = await loadConfigFile(configPath);
|
|
122
|
-
if (!loadResult.success) {
|
|
123
|
-
console.error('x', loadResult.error);
|
|
124
|
-
return null;
|
|
125
|
-
}
|
|
126
|
-
baseConfig = loadResult.config;
|
|
127
|
-
}
|
|
128
|
-
if (isMultiConfig(baseConfig)) {
|
|
129
|
-
if (!options.target) {
|
|
130
|
-
console.error('x Watch mode requires --target when using multiple targets.');
|
|
131
|
-
return null;
|
|
132
|
-
}
|
|
133
|
-
if (!baseConfig.targets[options.target]) {
|
|
134
|
-
console.error(`x Target "${options.target}" not found in config file.`);
|
|
135
|
-
return null;
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
else if (options.target) {
|
|
139
|
-
console.error('x Config file does not define targets. Remove --target.');
|
|
140
|
-
return null;
|
|
141
|
-
}
|
|
142
|
-
const sourceOverrides = {};
|
|
143
|
-
if (options.endpoint) {
|
|
144
|
-
sourceOverrides.endpoint = options.endpoint;
|
|
145
|
-
sourceOverrides.schema = undefined;
|
|
146
|
-
}
|
|
147
|
-
const watchOverrides = {
|
|
148
|
-
watch: {
|
|
149
|
-
...(options.pollInterval !== undefined && {
|
|
150
|
-
pollInterval: options.pollInterval,
|
|
151
|
-
}),
|
|
152
|
-
...(options.debounce !== undefined && { debounce: options.debounce }),
|
|
153
|
-
...(options.touch !== undefined && { touchFile: options.touch }),
|
|
154
|
-
...(options.clear !== undefined && { clearScreen: options.clear }),
|
|
155
|
-
},
|
|
156
|
-
};
|
|
157
|
-
let mergedTarget;
|
|
158
|
-
if (isMultiConfig(baseConfig)) {
|
|
159
|
-
const defaults = baseConfig.defaults ?? {};
|
|
160
|
-
const targetConfig = baseConfig.targets[options.target];
|
|
161
|
-
mergedTarget = mergeConfig(defaults, targetConfig);
|
|
162
|
-
}
|
|
163
|
-
else {
|
|
164
|
-
mergedTarget = baseConfig;
|
|
165
|
-
}
|
|
166
|
-
mergedTarget = mergeConfig(mergedTarget, sourceOverrides);
|
|
167
|
-
mergedTarget = mergeConfig(mergedTarget, watchOverrides);
|
|
168
|
-
if (!mergedTarget.endpoint) {
|
|
169
|
-
console.error('x No endpoint specified. Watch mode only supports live endpoints.');
|
|
170
|
-
return null;
|
|
171
|
-
}
|
|
172
|
-
if (mergedTarget.schema) {
|
|
173
|
-
console.error('x Watch mode is only supported with an endpoint, not schema.');
|
|
174
|
-
return null;
|
|
175
|
-
}
|
|
176
|
-
return resolveConfig(mergedTarget);
|
|
177
|
-
}
|
|
178
|
-
/**
|
|
179
|
-
* Init command handler
|
|
180
|
-
*/
|
|
181
|
-
async function handleInit(argv) {
|
|
182
|
-
if (argv.help || argv.h) {
|
|
183
|
-
console.log(initUsageText);
|
|
184
|
-
process.exit(0);
|
|
185
|
-
}
|
|
186
|
-
const startTime = performance.now();
|
|
187
|
-
const result = await initCommand({
|
|
188
|
-
directory: argv.directory || argv.d || '.',
|
|
189
|
-
force: !!(argv.force || argv.f),
|
|
190
|
-
endpoint: argv.endpoint || argv.e,
|
|
191
|
-
output: argv.output || argv.o || './generated',
|
|
192
|
-
});
|
|
193
|
-
const duration = formatDuration(performance.now() - startTime);
|
|
194
|
-
if (result.success) {
|
|
195
|
-
console.log('[ok]', result.message, `(${duration})`);
|
|
196
|
-
}
|
|
197
|
-
else {
|
|
198
|
-
console.error('x', result.message, `(${duration})`);
|
|
199
|
-
process.exit(1);
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
/**
|
|
203
|
-
* Generate command handler
|
|
204
|
-
*/
|
|
205
|
-
async function handleGenerate(argv) {
|
|
206
|
-
if (argv.help || argv.h) {
|
|
207
|
-
console.log(generateUsageText);
|
|
39
|
+
export const commands = async (argv, prompter, _options) => {
|
|
40
|
+
if (argv.version) {
|
|
41
|
+
const pkg = getPackageJson(__dirname);
|
|
42
|
+
console.log(pkg.version);
|
|
208
43
|
process.exit(0);
|
|
209
44
|
}
|
|
210
|
-
const startTime = performance.now();
|
|
211
|
-
const config = argv.config || argv.c;
|
|
212
|
-
const target = argv.target || argv.t;
|
|
213
|
-
const endpoint = argv.endpoint || argv.e;
|
|
214
|
-
const schema = argv.schema || argv.s;
|
|
215
|
-
const output = argv.output || argv.o;
|
|
216
|
-
const authorization = argv.authorization || argv.a;
|
|
217
|
-
const verbose = !!(argv.verbose || argv.v);
|
|
218
|
-
const dryRun = !!(argv['dry-run'] || argv.dryRun);
|
|
219
|
-
const watch = !!(argv.watch || argv.w);
|
|
220
|
-
const pollInterval = argv['poll-interval'] !== undefined
|
|
221
|
-
? parseInt(argv['poll-interval'], 10)
|
|
222
|
-
: undefined;
|
|
223
|
-
const debounce = argv.debounce !== undefined
|
|
224
|
-
? parseInt(argv.debounce, 10)
|
|
225
|
-
: undefined;
|
|
226
|
-
const touch = argv.touch;
|
|
227
|
-
const clear = argv.clear !== false;
|
|
228
|
-
if (endpoint && schema) {
|
|
229
|
-
console.error('x Cannot use both --endpoint and --schema. Choose one source.');
|
|
230
|
-
process.exit(1);
|
|
231
|
-
}
|
|
232
|
-
if (watch) {
|
|
233
|
-
if (schema) {
|
|
234
|
-
console.error('x Watch mode is only supported with --endpoint, not --schema.');
|
|
235
|
-
process.exit(1);
|
|
236
|
-
}
|
|
237
|
-
const watchConfig = await loadWatchConfig({
|
|
238
|
-
config,
|
|
239
|
-
target,
|
|
240
|
-
endpoint,
|
|
241
|
-
output,
|
|
242
|
-
pollInterval,
|
|
243
|
-
debounce,
|
|
244
|
-
touch,
|
|
245
|
-
clear,
|
|
246
|
-
});
|
|
247
|
-
if (!watchConfig) {
|
|
248
|
-
process.exit(1);
|
|
249
|
-
}
|
|
250
|
-
await startWatch({
|
|
251
|
-
config: watchConfig,
|
|
252
|
-
generatorType: 'generate',
|
|
253
|
-
verbose,
|
|
254
|
-
authorization,
|
|
255
|
-
configPath: config,
|
|
256
|
-
target,
|
|
257
|
-
outputDir: output,
|
|
258
|
-
});
|
|
259
|
-
return;
|
|
260
|
-
}
|
|
261
|
-
const result = await generateReactQuery({
|
|
262
|
-
config,
|
|
263
|
-
target,
|
|
264
|
-
endpoint,
|
|
265
|
-
schema,
|
|
266
|
-
output,
|
|
267
|
-
authorization,
|
|
268
|
-
verbose,
|
|
269
|
-
dryRun,
|
|
270
|
-
});
|
|
271
|
-
const duration = formatDuration(performance.now() - startTime);
|
|
272
|
-
const targetResults = result.targets ?? [];
|
|
273
|
-
const hasNamedTargets = targetResults.length > 0 &&
|
|
274
|
-
(targetResults.length > 1 || targetResults[0]?.name !== 'default');
|
|
275
|
-
if (hasNamedTargets) {
|
|
276
|
-
console.log(result.success ? '[ok]' : 'x', result.message);
|
|
277
|
-
targetResults.forEach((t) => {
|
|
278
|
-
const status = t.success ? '[ok]' : 'x';
|
|
279
|
-
console.log(`\n${status} ${t.message}`);
|
|
280
|
-
if (t.tables && t.tables.length > 0) {
|
|
281
|
-
console.log(' Tables:');
|
|
282
|
-
t.tables.forEach((table) => console.log(` - ${table}`));
|
|
283
|
-
}
|
|
284
|
-
if (t.filesWritten && t.filesWritten.length > 0) {
|
|
285
|
-
console.log(' Files written:');
|
|
286
|
-
t.filesWritten.forEach((file) => console.log(` - ${file}`));
|
|
287
|
-
}
|
|
288
|
-
if (!t.success && t.errors) {
|
|
289
|
-
t.errors.forEach((error) => console.error(` - ${error}`));
|
|
290
|
-
}
|
|
291
|
-
});
|
|
292
|
-
if (!result.success) {
|
|
293
|
-
process.exit(1);
|
|
294
|
-
}
|
|
295
|
-
return;
|
|
296
|
-
}
|
|
297
|
-
if (result.success) {
|
|
298
|
-
console.log('[ok]', result.message, `(${duration})`);
|
|
299
|
-
if (result.tables && result.tables.length > 0) {
|
|
300
|
-
console.log('\nTables:');
|
|
301
|
-
result.tables.forEach((t) => console.log(` - ${t}`));
|
|
302
|
-
}
|
|
303
|
-
if (result.filesWritten && result.filesWritten.length > 0) {
|
|
304
|
-
console.log('\nFiles written:');
|
|
305
|
-
result.filesWritten.forEach((f) => console.log(` - ${f}`));
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
else {
|
|
309
|
-
console.error('x', result.message, `(${duration})`);
|
|
310
|
-
if (result.errors) {
|
|
311
|
-
result.errors.forEach((e) => console.error(' -', e));
|
|
312
|
-
}
|
|
313
|
-
process.exit(1);
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
/**
|
|
317
|
-
* Generate ORM command handler
|
|
318
|
-
*/
|
|
319
|
-
async function handleGenerateOrm(argv) {
|
|
320
45
|
if (argv.help || argv.h) {
|
|
321
|
-
console.log(
|
|
46
|
+
console.log(usage);
|
|
322
47
|
process.exit(0);
|
|
323
48
|
}
|
|
324
|
-
const
|
|
325
|
-
const
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
const verbose = !!(argv.verbose || argv.v);
|
|
332
|
-
const dryRun = !!(argv['dry-run'] || argv.dryRun);
|
|
333
|
-
const skipCustomOperations = !!(argv['skip-custom-operations'] || argv.skipCustomOperations);
|
|
334
|
-
const watch = !!(argv.watch || argv.w);
|
|
335
|
-
const pollInterval = argv['poll-interval'] !== undefined
|
|
336
|
-
? parseInt(argv['poll-interval'], 10)
|
|
337
|
-
: undefined;
|
|
338
|
-
const debounce = argv.debounce !== undefined
|
|
339
|
-
? parseInt(argv.debounce, 10)
|
|
340
|
-
: undefined;
|
|
341
|
-
const touch = argv.touch;
|
|
342
|
-
const clear = argv.clear !== false;
|
|
343
|
-
if (endpoint && schema) {
|
|
344
|
-
console.error('x Cannot use both --endpoint and --schema. Choose one source.');
|
|
345
|
-
process.exit(1);
|
|
346
|
-
}
|
|
347
|
-
if (watch) {
|
|
348
|
-
if (schema) {
|
|
349
|
-
console.error('x Watch mode is only supported with --endpoint, not --schema.');
|
|
350
|
-
process.exit(1);
|
|
351
|
-
}
|
|
352
|
-
const watchConfig = await loadWatchConfig({
|
|
353
|
-
config,
|
|
354
|
-
target,
|
|
355
|
-
endpoint,
|
|
356
|
-
output,
|
|
357
|
-
pollInterval,
|
|
358
|
-
debounce,
|
|
359
|
-
touch,
|
|
360
|
-
clear,
|
|
361
|
-
});
|
|
362
|
-
if (!watchConfig) {
|
|
49
|
+
const configPath = (argv.config || argv.c || findConfigFile());
|
|
50
|
+
const targetName = (argv.target || argv.t);
|
|
51
|
+
// If config file exists, load and run
|
|
52
|
+
if (configPath) {
|
|
53
|
+
const loaded = await loadConfigFile(configPath);
|
|
54
|
+
if (!loaded.success) {
|
|
55
|
+
console.error('x', loaded.error);
|
|
363
56
|
process.exit(1);
|
|
364
57
|
}
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
return;
|
|
376
|
-
}
|
|
377
|
-
const result = await generateOrm({
|
|
378
|
-
config,
|
|
379
|
-
target,
|
|
380
|
-
endpoint,
|
|
381
|
-
schema,
|
|
382
|
-
output,
|
|
383
|
-
authorization,
|
|
384
|
-
verbose,
|
|
385
|
-
dryRun,
|
|
386
|
-
skipCustomOperations,
|
|
387
|
-
});
|
|
388
|
-
const duration = formatDuration(performance.now() - startTime);
|
|
389
|
-
const targetResults = result.targets ?? [];
|
|
390
|
-
const hasNamedTargets = targetResults.length > 0 &&
|
|
391
|
-
(targetResults.length > 1 || targetResults[0]?.name !== 'default');
|
|
392
|
-
if (hasNamedTargets) {
|
|
393
|
-
console.log(result.success ? '[ok]' : 'x', result.message);
|
|
394
|
-
targetResults.forEach((t) => {
|
|
395
|
-
const status = t.success ? '[ok]' : 'x';
|
|
396
|
-
console.log(`\n${status} ${t.message}`);
|
|
397
|
-
if (t.tables && t.tables.length > 0) {
|
|
398
|
-
console.log(' Tables:');
|
|
399
|
-
t.tables.forEach((table) => console.log(` - ${table}`));
|
|
58
|
+
const config = loaded.config;
|
|
59
|
+
// Check if it's a multi-target config (no source fields at top level)
|
|
60
|
+
const isMulti = !('endpoint' in config || 'schemaFile' in config || 'db' in config);
|
|
61
|
+
if (isMulti) {
|
|
62
|
+
// Multi-target: simple for loop over targets
|
|
63
|
+
const targets = config;
|
|
64
|
+
const names = targetName ? [targetName] : Object.keys(targets);
|
|
65
|
+
if (targetName && !targets[targetName]) {
|
|
66
|
+
console.error('x', `Target "${targetName}" not found. Available: ${Object.keys(targets).join(', ')}`);
|
|
67
|
+
process.exit(1);
|
|
400
68
|
}
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
69
|
+
let hasError = false;
|
|
70
|
+
for (const name of names) {
|
|
71
|
+
console.log(`\n[${name}]`);
|
|
72
|
+
const result = await generate(targets[name]);
|
|
73
|
+
printResult(result);
|
|
74
|
+
if (!result.success)
|
|
75
|
+
hasError = true;
|
|
404
76
|
}
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
t.errors.forEach((error) => console.error(` - ${error}`));
|
|
415
|
-
}
|
|
416
|
-
});
|
|
417
|
-
if (!result.success) {
|
|
77
|
+
prompter.close();
|
|
78
|
+
if (hasError)
|
|
79
|
+
process.exit(1);
|
|
80
|
+
return argv;
|
|
81
|
+
}
|
|
82
|
+
// Single config
|
|
83
|
+
const result = await generate(config);
|
|
84
|
+
printResult(result);
|
|
85
|
+
if (!result.success)
|
|
418
86
|
process.exit(1);
|
|
419
|
-
}
|
|
420
|
-
return;
|
|
421
|
-
}
|
|
422
|
-
if (result.success) {
|
|
423
|
-
console.log('[ok]', result.message, `(${duration})`);
|
|
424
|
-
if (result.tables && result.tables.length > 0) {
|
|
425
|
-
console.log('\nTables:');
|
|
426
|
-
result.tables.forEach((t) => console.log(` - ${t}`));
|
|
427
|
-
}
|
|
428
|
-
if (result.customQueries && result.customQueries.length > 0) {
|
|
429
|
-
console.log('\nCustom Queries:');
|
|
430
|
-
result.customQueries.forEach((q) => console.log(` - ${q}`));
|
|
431
|
-
}
|
|
432
|
-
if (result.customMutations && result.customMutations.length > 0) {
|
|
433
|
-
console.log('\nCustom Mutations:');
|
|
434
|
-
result.customMutations.forEach((m) => console.log(` - ${m}`));
|
|
435
|
-
}
|
|
436
|
-
if (result.filesWritten && result.filesWritten.length > 0) {
|
|
437
|
-
console.log('\nFiles written:');
|
|
438
|
-
result.filesWritten.forEach((f) => console.log(` - ${f}`));
|
|
439
|
-
}
|
|
440
|
-
}
|
|
441
|
-
else {
|
|
442
|
-
console.error('x', result.message, `(${duration})`);
|
|
443
|
-
if (result.errors) {
|
|
444
|
-
result.errors.forEach((e) => console.error(' -', e));
|
|
445
|
-
}
|
|
446
|
-
process.exit(1);
|
|
447
|
-
}
|
|
448
|
-
}
|
|
449
|
-
/**
|
|
450
|
-
* Introspect command handler
|
|
451
|
-
*/
|
|
452
|
-
async function handleIntrospect(argv) {
|
|
453
|
-
if (argv.help || argv.h) {
|
|
454
|
-
console.log(introspectUsageText);
|
|
455
|
-
process.exit(0);
|
|
456
|
-
}
|
|
457
|
-
const startTime = performance.now();
|
|
458
|
-
const endpoint = argv.endpoint || argv.e;
|
|
459
|
-
const schema = argv.schema || argv.s;
|
|
460
|
-
const authorization = argv.authorization || argv.a;
|
|
461
|
-
const json = !!argv.json;
|
|
462
|
-
if (!endpoint && !schema) {
|
|
463
|
-
console.error('x Either --endpoint or --schema must be provided.');
|
|
464
|
-
process.exit(1);
|
|
465
|
-
}
|
|
466
|
-
if (endpoint && schema) {
|
|
467
|
-
console.error('x Cannot use both --endpoint and --schema. Choose one source.');
|
|
468
|
-
process.exit(1);
|
|
469
|
-
}
|
|
470
|
-
const { createSchemaSource } = await import('./introspect/source');
|
|
471
|
-
const { inferTablesFromIntrospection } = await import('./introspect/infer-tables');
|
|
472
|
-
try {
|
|
473
|
-
const source = createSchemaSource({
|
|
474
|
-
endpoint,
|
|
475
|
-
schema,
|
|
476
|
-
authorization,
|
|
477
|
-
});
|
|
478
|
-
console.log('Fetching schema from', source.describe(), '...');
|
|
479
|
-
const { introspection } = await source.fetch();
|
|
480
|
-
const tables = inferTablesFromIntrospection(introspection);
|
|
481
|
-
const duration = formatDuration(performance.now() - startTime);
|
|
482
|
-
if (json) {
|
|
483
|
-
console.log(JSON.stringify(tables, null, 2));
|
|
484
|
-
}
|
|
485
|
-
else {
|
|
486
|
-
console.log(`\n[ok] Found ${tables.length} tables (${duration}):\n`);
|
|
487
|
-
tables.forEach((table) => {
|
|
488
|
-
const fieldCount = table.fields.length;
|
|
489
|
-
const relationCount = table.relations.belongsTo.length +
|
|
490
|
-
table.relations.hasOne.length +
|
|
491
|
-
table.relations.hasMany.length +
|
|
492
|
-
table.relations.manyToMany.length;
|
|
493
|
-
console.log(` ${table.name} (${fieldCount} fields, ${relationCount} relations)`);
|
|
494
|
-
});
|
|
495
|
-
}
|
|
496
|
-
}
|
|
497
|
-
catch (err) {
|
|
498
|
-
const duration = formatDuration(performance.now() - startTime);
|
|
499
|
-
console.error('x Failed to introspect schema:', err instanceof Error ? err.message : err, `(${duration})`);
|
|
500
|
-
process.exit(1);
|
|
501
|
-
}
|
|
502
|
-
}
|
|
503
|
-
const createCommandMap = () => {
|
|
504
|
-
return {
|
|
505
|
-
init: handleInit,
|
|
506
|
-
generate: handleGenerate,
|
|
507
|
-
'generate-orm': handleGenerateOrm,
|
|
508
|
-
introspect: handleIntrospect,
|
|
509
|
-
};
|
|
510
|
-
};
|
|
511
|
-
export const commands = async (argv, prompter, _options) => {
|
|
512
|
-
if (argv.version || argv.v) {
|
|
513
|
-
const pkg = getPackageJson(__dirname);
|
|
514
|
-
console.log(pkg.version);
|
|
515
|
-
process.exit(0);
|
|
516
|
-
}
|
|
517
|
-
const { first: command, newArgv } = extractFirst(argv);
|
|
518
|
-
if ((argv.help || argv.h) && !command) {
|
|
519
|
-
console.log(usageText);
|
|
520
|
-
process.exit(0);
|
|
521
|
-
}
|
|
522
|
-
if (command === 'help') {
|
|
523
|
-
console.log(usageText);
|
|
524
|
-
process.exit(0);
|
|
525
|
-
}
|
|
526
|
-
const commandMap = createCommandMap();
|
|
527
|
-
if (!command) {
|
|
528
|
-
const answer = await prompter.prompt(argv, [
|
|
529
|
-
{
|
|
530
|
-
type: 'autocomplete',
|
|
531
|
-
name: 'command',
|
|
532
|
-
message: 'What do you want to do?',
|
|
533
|
-
options: Object.keys(commandMap),
|
|
534
|
-
},
|
|
535
|
-
]);
|
|
536
|
-
const selectedCommand = answer.command;
|
|
537
|
-
const commandFn = commandMap[selectedCommand];
|
|
538
|
-
if (commandFn) {
|
|
539
|
-
await commandFn(newArgv);
|
|
540
|
-
}
|
|
541
87
|
prompter.close();
|
|
542
88
|
return argv;
|
|
543
89
|
}
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
90
|
+
// No config file - prompt for options using shared questions
|
|
91
|
+
const answers = await prompter.prompt(argv, codegenQuestions);
|
|
92
|
+
// Build db config if schemas or apiNames provided
|
|
93
|
+
const db = (answers.schemas || answers.apiNames) ? {
|
|
94
|
+
schemas: answers.schemas,
|
|
95
|
+
apiNames: answers.apiNames,
|
|
96
|
+
} : undefined;
|
|
97
|
+
const result = await generate({
|
|
98
|
+
endpoint: answers.endpoint,
|
|
99
|
+
schemaFile: answers.schemaFile,
|
|
100
|
+
db,
|
|
101
|
+
output: answers.output,
|
|
102
|
+
authorization: answers.authorization,
|
|
103
|
+
reactQuery: answers.reactQuery,
|
|
104
|
+
orm: answers.orm,
|
|
105
|
+
dryRun: answers.dryRun,
|
|
106
|
+
verbose: answers.verbose,
|
|
107
|
+
});
|
|
108
|
+
printResult(result);
|
|
550
109
|
prompter.close();
|
|
551
110
|
return argv;
|
|
552
111
|
};
|
|
553
112
|
export const options = {
|
|
554
113
|
minimistOpts: {
|
|
555
114
|
alias: {
|
|
556
|
-
v: 'version',
|
|
557
115
|
h: 'help',
|
|
558
116
|
c: 'config',
|
|
559
|
-
t: 'target',
|
|
560
117
|
e: 'endpoint',
|
|
561
|
-
s: 'schema',
|
|
118
|
+
s: 'schema-file',
|
|
562
119
|
o: 'output',
|
|
120
|
+
t: 'target',
|
|
563
121
|
a: 'authorization',
|
|
564
|
-
|
|
565
|
-
f: 'force',
|
|
566
|
-
w: 'watch',
|
|
567
|
-
},
|
|
568
|
-
boolean: ['help', 'version', 'force', 'verbose', 'dry-run', 'watch', 'json', 'skip-custom-operations', 'clear'],
|
|
569
|
-
string: ['config', 'target', 'endpoint', 'schema', 'output', 'authorization', 'directory', 'touch', 'poll-interval', 'debounce'],
|
|
570
|
-
default: {
|
|
571
|
-
clear: true,
|
|
122
|
+
v: 'verbose',
|
|
572
123
|
},
|
|
124
|
+
boolean: [
|
|
125
|
+
'help', 'version', 'verbose', 'dry-run', 'react-query', 'orm', 'keep-db',
|
|
126
|
+
],
|
|
127
|
+
string: [
|
|
128
|
+
'config', 'endpoint', 'schema-file', 'output', 'target', 'authorization',
|
|
129
|
+
'pgpm-module-path', 'pgpm-workspace-path', 'pgpm-module-name',
|
|
130
|
+
'schemas', 'api-names',
|
|
131
|
+
],
|
|
573
132
|
},
|
|
574
133
|
};
|
|
575
134
|
if (require.main === module) {
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
console.log(pkg.version);
|
|
579
|
-
process.exit(0);
|
|
580
|
-
}
|
|
581
|
-
const app = new CLI(commands, options);
|
|
582
|
-
app.run().then(() => {
|
|
583
|
-
}).catch((error) => {
|
|
584
|
-
console.error('Unexpected error:', error);
|
|
585
|
-
process.exit(1);
|
|
586
|
-
});
|
|
135
|
+
const cli = new CLI(commands, options);
|
|
136
|
+
cli.run();
|
|
587
137
|
}
|