@constructive-io/cli 6.1.7 → 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.
@@ -20,8 +20,6 @@ Generator Options:
20
20
  --orm Generate ORM client
21
21
  --output <dir> Output directory (default: codegen)
22
22
  --authorization <token> Authorization header value
23
- --browser-compatible Generate browser-compatible code (default: true)
24
- Set to false for Node.js with localhost DNS fix
25
23
  --dry-run Preview without writing files
26
24
  --verbose Verbose output
27
25
 
@@ -32,34 +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
- // Convert kebab-case CLI args to camelCase for internal use
46
- const camelized = (0, graphql_codegen_1.camelizeArgv)(answers);
47
- // Build db config if schemas or apiNames provided
48
- const db = (camelized.schemas || camelized.apiNames) ? {
49
- schemas: camelized.schemas,
50
- apiNames: camelized.apiNames,
51
- } : undefined;
52
- const result = await (0, graphql_codegen_1.generate)({
53
- endpoint: camelized.endpoint,
54
- schemaFile: camelized.schemaFile,
55
- db,
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,
63
- });
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);
64
51
  (0, graphql_codegen_1.printResult)(result);
65
52
  };
@@ -1,4 +1,4 @@
1
- import { generate, findConfigFile, codegenQuestions, printResult, camelizeArgv, } 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
 
@@ -18,8 +18,6 @@ Generator Options:
18
18
  --orm Generate ORM client
19
19
  --output <dir> Output directory (default: codegen)
20
20
  --authorization <token> Authorization header value
21
- --browser-compatible Generate browser-compatible code (default: true)
22
- Set to false for Node.js with localhost DNS fix
23
21
  --dry-run Preview without writing files
24
22
  --verbose Verbose output
25
23
 
@@ -30,34 +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
- // Convert kebab-case CLI args to camelCase for internal use
44
- const camelized = camelizeArgv(answers);
45
- // Build db config if schemas or apiNames provided
46
- const db = (camelized.schemas || camelized.apiNames) ? {
47
- schemas: camelized.schemas,
48
- apiNames: camelized.apiNames,
49
- } : undefined;
50
- const result = await generate({
51
- endpoint: camelized.endpoint,
52
- schemaFile: camelized.schemaFile,
53
- db,
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,
61
- });
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);
62
49
  printResult(result);
63
50
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@constructive-io/cli",
3
- "version": "6.1.7",
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.1",
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": "013a736cd2b09d465697c58c1b807858129c16b5"
79
+ "gitHead": "048188f6b43ffaa6146e7694b2b0d35d34cb2945"
80
80
  }