@constructive-io/cli 6.1.7 → 6.2.1
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/commands/codegen.js +17 -30
- package/esm/commands/codegen.js +18 -31
- package/package.json +15 -15
package/commands/codegen.js
CHANGED
|
@@ -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
|
-
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
(0, graphql_codegen_1.
|
|
41
|
-
|
|
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
|
-
|
|
44
|
-
const answers =
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
const
|
|
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
|
};
|
package/esm/commands/codegen.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { generate, findConfigFile, codegenQuestions, printResult,
|
|
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
|
-
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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
|
-
|
|
42
|
-
const answers =
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
const
|
|
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
|
|
3
|
+
"version": "6.2.1",
|
|
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.
|
|
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.
|
|
49
|
-
"@constructive-io/graphql-env": "^2.
|
|
50
|
-
"@constructive-io/graphql-explorer": "^3.
|
|
51
|
-
"@constructive-io/graphql-server": "^3.
|
|
52
|
-
"@constructive-io/knative-job-service": "^1.
|
|
48
|
+
"@constructive-io/graphql-codegen": "^3.3.1",
|
|
49
|
+
"@constructive-io/graphql-env": "^2.10.0",
|
|
50
|
+
"@constructive-io/graphql-explorer": "^3.1.1",
|
|
51
|
+
"@constructive-io/graphql-server": "^3.1.1",
|
|
52
|
+
"@constructive-io/knative-job-service": "^1.1.1",
|
|
53
53
|
"@inquirerer/utils": "^3.2.0",
|
|
54
|
-
"@pgpmjs/core": "^5.
|
|
55
|
-
"@pgpmjs/logger": "^2.
|
|
56
|
-
"@pgpmjs/server-utils": "^3.
|
|
57
|
-
"@pgpmjs/types": "^2.
|
|
54
|
+
"@pgpmjs/core": "^5.2.1",
|
|
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.
|
|
63
|
-
"pg-env": "^1.
|
|
64
|
-
"pgpm": "^3.
|
|
62
|
+
"pg-cache": "^2.1.0",
|
|
63
|
+
"pg-env": "^1.4.0",
|
|
64
|
+
"pgpm": "^3.3.1",
|
|
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": "
|
|
79
|
+
"gitHead": "49049ad3ddd762d35625f657cb42fa0862b829a0"
|
|
80
80
|
}
|