@graphql-codegen/cli 6.0.0-alpha-20250814123644-9b9c4e7a2ceb01175dafd069cd26047ce20eb406 → 6.0.0-alpha-20250816104654-3cefeabda1bcfa915d43b4515cb86dd2dfb9df5b
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/cjs/codegen.js +12 -3
- package/cjs/init/index.js +1 -3
- package/cjs/init/questions.js +74 -86
- package/esm/codegen.js +12 -3
- package/esm/init/index.js +2 -3
- package/esm/init/questions.js +73 -83
- package/package.json +6 -6
- package/typings/init/questions.d.cts +7 -6
- package/typings/init/questions.d.ts +7 -6
package/cjs/codegen.js
CHANGED
|
@@ -302,8 +302,17 @@ async function executeCodegen(input) {
|
|
|
302
302
|
}, filename, `Generate: ${filename}`, ctx),
|
|
303
303
|
},
|
|
304
304
|
], {
|
|
305
|
-
|
|
305
|
+
/**
|
|
306
|
+
* For each `generates` task, we must do the following in order:
|
|
307
|
+
*
|
|
308
|
+
* 1. Load schema
|
|
309
|
+
* 2. Load documents
|
|
310
|
+
* 3. Generate based on the schema + documents
|
|
311
|
+
*
|
|
312
|
+
* This way, the 3rd step has all the schema and documents loaded in previous steps to work correctly
|
|
313
|
+
*/
|
|
306
314
|
exitOnError: true,
|
|
315
|
+
concurrent: false,
|
|
307
316
|
});
|
|
308
317
|
},
|
|
309
318
|
// It doesn't stop when one of tasks failed, to finish at least some of outputs
|
|
@@ -316,13 +325,13 @@ async function executeCodegen(input) {
|
|
|
316
325
|
], {
|
|
317
326
|
rendererOptions: {
|
|
318
327
|
clearOutput: false,
|
|
319
|
-
|
|
328
|
+
collapseSubtasks: true,
|
|
320
329
|
formatOutput: 'wrap',
|
|
321
330
|
removeEmptyLines: false,
|
|
322
331
|
},
|
|
323
332
|
renderer: config.verbose ? 'verbose' : 'default',
|
|
324
333
|
ctx: { errors: [] },
|
|
325
|
-
|
|
334
|
+
silentRendererCondition: isTest || config.silent,
|
|
326
335
|
exitOnError: true,
|
|
327
336
|
});
|
|
328
337
|
// All the errors throw in `listr2` are collected in context
|
package/cjs/init/index.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.init = init;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const inquirer_1 = tslib_1.__importDefault(require("inquirer"));
|
|
6
4
|
const helpers_js_1 = require("./helpers.js");
|
|
7
5
|
const questions_js_1 = require("./questions.js");
|
|
8
6
|
const targets_js_1 = require("./targets.js");
|
|
@@ -17,7 +15,7 @@ async function init() {
|
|
|
17
15
|
Answer few questions and we will setup everything for you.
|
|
18
16
|
`);
|
|
19
17
|
const possibleTargets = await (0, targets_js_1.guessTargets)();
|
|
20
|
-
const answers = await
|
|
18
|
+
const answers = await (0, questions_js_1.getAnswers)(possibleTargets);
|
|
21
19
|
// define config
|
|
22
20
|
const config = {
|
|
23
21
|
overwrite: true,
|
package/cjs/init/questions.js
CHANGED
|
@@ -1,95 +1,86 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.getAnswers = getAnswers;
|
|
4
4
|
exports.getApplicationTypeChoices = getApplicationTypeChoices;
|
|
5
5
|
exports.getPluginChoices = getPluginChoices;
|
|
6
|
-
|
|
7
|
-
exports.getDocumentsDefaultValue = getDocumentsDefaultValue;
|
|
6
|
+
const prompts_1 = require("@inquirer/prompts");
|
|
8
7
|
const helpers_js_1 = require("./helpers.js");
|
|
9
8
|
const plugins_js_1 = require("./plugins.js");
|
|
10
9
|
const types_js_1 = require("./types.js");
|
|
11
|
-
function
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
name: 'targets',
|
|
10
|
+
async function getAnswers(possibleTargets) {
|
|
11
|
+
try {
|
|
12
|
+
const targetChoices = getApplicationTypeChoices(possibleTargets);
|
|
13
|
+
const targets = await (0, prompts_1.select)({
|
|
16
14
|
message: `What type of application are you building?`,
|
|
17
|
-
choices:
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
type: 'input',
|
|
23
|
-
name: 'schema',
|
|
24
|
-
message: 'Where is your schema?:',
|
|
25
|
-
suffix: (0, helpers_js_1.grey)(' (path or url)'),
|
|
15
|
+
choices: targetChoices,
|
|
16
|
+
default: targetChoices.find(c => c.checked)?.value,
|
|
17
|
+
});
|
|
18
|
+
const schema = await (0, prompts_1.input)({
|
|
19
|
+
message: `Where is your schema?: ${(0, helpers_js_1.grey)('(path or url)')}`,
|
|
26
20
|
default: 'http://localhost:4000', // matches Apollo Server's default
|
|
27
|
-
validate:
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
{
|
|
45
|
-
type: 'checkbox',
|
|
46
|
-
name: 'plugins',
|
|
47
|
-
when: answers => {
|
|
48
|
-
// flatten targets
|
|
49
|
-
// I can't find an API in Inquirer that would do that
|
|
50
|
-
answers.targets = normalizeTargets(answers.targets);
|
|
51
|
-
return !answers.targets.includes(types_js_1.Tags.client);
|
|
52
|
-
},
|
|
53
|
-
message: 'Pick plugins:',
|
|
54
|
-
choices: getPluginChoices,
|
|
55
|
-
validate: ((plugins) => plugins.length > 0),
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
type: 'input',
|
|
59
|
-
name: 'output',
|
|
21
|
+
validate: str => str.length > 0,
|
|
22
|
+
});
|
|
23
|
+
let documents;
|
|
24
|
+
if (targets.includes(types_js_1.Tags.client) || targets.includes(types_js_1.Tags.angular) || targets.includes(types_js_1.Tags.stencil))
|
|
25
|
+
documents = await (0, prompts_1.input)({
|
|
26
|
+
message: 'Where are your operations and fragments?:',
|
|
27
|
+
default: getDocumentsDefaultValue(targets),
|
|
28
|
+
validate: str => str.length > 0,
|
|
29
|
+
});
|
|
30
|
+
let plugins;
|
|
31
|
+
if (!targets.includes(types_js_1.Tags.client)) {
|
|
32
|
+
plugins = await (0, prompts_1.checkbox)({
|
|
33
|
+
message: 'Pick plugins:',
|
|
34
|
+
choices: getPluginChoices(targets),
|
|
35
|
+
validate: plugins => plugins.length > 0,
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
const output = await (0, prompts_1.input)({
|
|
60
39
|
message: 'Where to write the output:',
|
|
61
|
-
default: getOutputDefaultValue,
|
|
62
|
-
validate:
|
|
63
|
-
}
|
|
64
|
-
{
|
|
65
|
-
type: 'confirm',
|
|
66
|
-
name: 'introspection',
|
|
67
|
-
default: false,
|
|
40
|
+
default: getOutputDefaultValue({ targets, plugins }),
|
|
41
|
+
validate: str => str.length > 0,
|
|
42
|
+
});
|
|
43
|
+
const introspection = await (0, prompts_1.confirm)({
|
|
68
44
|
message: 'Do you want to generate an introspection file?',
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
name: 'config',
|
|
45
|
+
default: false,
|
|
46
|
+
});
|
|
47
|
+
const config = await (0, prompts_1.input)({
|
|
73
48
|
message: 'How to name the config file?',
|
|
74
|
-
default:
|
|
75
|
-
answers.targets.includes(types_js_1.Tags.typescript) ||
|
|
76
|
-
answers.targets.includes(types_js_1.Tags.angular)
|
|
49
|
+
default: (() => targets.includes(types_js_1.Tags.client) || targets.includes(types_js_1.Tags.typescript) || targets.includes(types_js_1.Tags.angular)
|
|
77
50
|
? 'codegen.ts'
|
|
78
|
-
: 'codegen.yml',
|
|
79
|
-
validate:
|
|
51
|
+
: 'codegen.yml')(),
|
|
52
|
+
validate: str => {
|
|
80
53
|
const isNotEmpty = str.length > 0;
|
|
81
54
|
const hasCorrectExtension = ['json', 'yml', 'yaml', 'js', 'ts'].some(ext => str.toLocaleLowerCase().endsWith(`.${ext}`));
|
|
82
55
|
return isNotEmpty && hasCorrectExtension;
|
|
83
56
|
},
|
|
84
|
-
}
|
|
85
|
-
{
|
|
86
|
-
type: 'input',
|
|
87
|
-
name: 'script',
|
|
57
|
+
});
|
|
58
|
+
const script = await (0, prompts_1.input)({
|
|
88
59
|
default: 'codegen',
|
|
89
60
|
message: 'What script in package.json should run the codegen?',
|
|
90
61
|
validate: (str) => str.length > 0,
|
|
91
|
-
}
|
|
92
|
-
|
|
62
|
+
});
|
|
63
|
+
return {
|
|
64
|
+
targets,
|
|
65
|
+
schema,
|
|
66
|
+
documents,
|
|
67
|
+
plugins,
|
|
68
|
+
output,
|
|
69
|
+
introspection,
|
|
70
|
+
config,
|
|
71
|
+
script,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
catch (error) {
|
|
75
|
+
if (error instanceof Error && error.name === 'ExitPromptError') {
|
|
76
|
+
// This error because user exited using CMD+C, just exit gracefully or else user would see an ugly error message
|
|
77
|
+
// https://github.com/SBoudrias/Inquirer.js/blob/ee16061a1e3f99a6cc714a3d473f7cd12b06a3f1/packages/prompts/README.md#handling-ctrlc-gracefully
|
|
78
|
+
process.exit();
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
throw error;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
93
84
|
}
|
|
94
85
|
function getApplicationTypeChoices(possibleTargets) {
|
|
95
86
|
function withFlowOrTypescript(tags) {
|
|
@@ -149,40 +140,37 @@ function getApplicationTypeChoices(possibleTargets) {
|
|
|
149
140
|
},
|
|
150
141
|
];
|
|
151
142
|
}
|
|
152
|
-
function getPluginChoices(
|
|
143
|
+
function getPluginChoices(targets) {
|
|
153
144
|
return plugins_js_1.plugins
|
|
154
|
-
.filter(p => p.available(
|
|
145
|
+
.filter(p => p.available(targets))
|
|
155
146
|
.map(p => {
|
|
156
147
|
return {
|
|
157
148
|
name: p.name,
|
|
158
149
|
value: p,
|
|
159
|
-
checked: p.shouldBeSelected(
|
|
150
|
+
checked: p.shouldBeSelected(targets),
|
|
160
151
|
};
|
|
161
152
|
});
|
|
162
153
|
}
|
|
163
|
-
function
|
|
164
|
-
|
|
165
|
-
}
|
|
166
|
-
function getOutputDefaultValue(answers) {
|
|
167
|
-
if (answers.targets.includes(types_js_1.Tags.client)) {
|
|
154
|
+
function getOutputDefaultValue({ targets, plugins }) {
|
|
155
|
+
if (targets.includes(types_js_1.Tags.client)) {
|
|
168
156
|
return 'src/gql/';
|
|
169
157
|
}
|
|
170
|
-
if (
|
|
158
|
+
if (plugins.some(plugin => plugin.defaultExtension === '.tsx')) {
|
|
171
159
|
return 'src/generated/graphql.tsx';
|
|
172
160
|
}
|
|
173
|
-
if (
|
|
161
|
+
if (plugins.some(plugin => plugin.defaultExtension === '.ts')) {
|
|
174
162
|
return 'src/generated/graphql.ts';
|
|
175
163
|
}
|
|
176
164
|
return 'src/generated/graphql.js';
|
|
177
165
|
}
|
|
178
|
-
function getDocumentsDefaultValue(
|
|
179
|
-
if (
|
|
166
|
+
function getDocumentsDefaultValue(targets) {
|
|
167
|
+
if (targets.includes(types_js_1.Tags.vue)) {
|
|
180
168
|
return 'src/**/*.vue';
|
|
181
169
|
}
|
|
182
|
-
if (
|
|
170
|
+
if (targets.includes(types_js_1.Tags.angular)) {
|
|
183
171
|
return 'src/**/*.ts';
|
|
184
172
|
}
|
|
185
|
-
if (
|
|
173
|
+
if (targets.includes(types_js_1.Tags.client)) {
|
|
186
174
|
return 'src/**/*.tsx';
|
|
187
175
|
}
|
|
188
176
|
return 'src/**/*.graphql';
|
package/esm/codegen.js
CHANGED
|
@@ -298,8 +298,17 @@ export async function executeCodegen(input) {
|
|
|
298
298
|
}, filename, `Generate: ${filename}`, ctx),
|
|
299
299
|
},
|
|
300
300
|
], {
|
|
301
|
-
|
|
301
|
+
/**
|
|
302
|
+
* For each `generates` task, we must do the following in order:
|
|
303
|
+
*
|
|
304
|
+
* 1. Load schema
|
|
305
|
+
* 2. Load documents
|
|
306
|
+
* 3. Generate based on the schema + documents
|
|
307
|
+
*
|
|
308
|
+
* This way, the 3rd step has all the schema and documents loaded in previous steps to work correctly
|
|
309
|
+
*/
|
|
302
310
|
exitOnError: true,
|
|
311
|
+
concurrent: false,
|
|
303
312
|
});
|
|
304
313
|
},
|
|
305
314
|
// It doesn't stop when one of tasks failed, to finish at least some of outputs
|
|
@@ -312,13 +321,13 @@ export async function executeCodegen(input) {
|
|
|
312
321
|
], {
|
|
313
322
|
rendererOptions: {
|
|
314
323
|
clearOutput: false,
|
|
315
|
-
|
|
324
|
+
collapseSubtasks: true,
|
|
316
325
|
formatOutput: 'wrap',
|
|
317
326
|
removeEmptyLines: false,
|
|
318
327
|
},
|
|
319
328
|
renderer: config.verbose ? 'verbose' : 'default',
|
|
320
329
|
ctx: { errors: [] },
|
|
321
|
-
|
|
330
|
+
silentRendererCondition: isTest || config.silent,
|
|
322
331
|
exitOnError: true,
|
|
323
332
|
});
|
|
324
333
|
// All the errors throw in `listr2` are collected in context
|
package/esm/init/index.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import inquirer from 'inquirer';
|
|
2
1
|
import { bold, writeConfig, writePackage } from './helpers.js';
|
|
3
|
-
import {
|
|
2
|
+
import { getAnswers } from './questions.js';
|
|
4
3
|
import { guessTargets } from './targets.js';
|
|
5
4
|
import { Tags } from './types.js';
|
|
6
5
|
function log(...msgs) {
|
|
@@ -13,7 +12,7 @@ export async function init() {
|
|
|
13
12
|
Answer few questions and we will setup everything for you.
|
|
14
13
|
`);
|
|
15
14
|
const possibleTargets = await guessTargets();
|
|
16
|
-
const answers = await
|
|
15
|
+
const answers = await getAnswers(possibleTargets);
|
|
17
16
|
// define config
|
|
18
17
|
const config = {
|
|
19
18
|
overwrite: true,
|
package/esm/init/questions.js
CHANGED
|
@@ -1,88 +1,81 @@
|
|
|
1
|
+
import { checkbox, input, select, confirm } from '@inquirer/prompts';
|
|
1
2
|
import { grey } from './helpers.js';
|
|
2
3
|
import { plugins } from './plugins.js';
|
|
3
4
|
import { Tags } from './types.js';
|
|
4
|
-
export function
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
name: 'targets',
|
|
5
|
+
export async function getAnswers(possibleTargets) {
|
|
6
|
+
try {
|
|
7
|
+
const targetChoices = getApplicationTypeChoices(possibleTargets);
|
|
8
|
+
const targets = await select({
|
|
9
9
|
message: `What type of application are you building?`,
|
|
10
|
-
choices:
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
type: 'input',
|
|
16
|
-
name: 'schema',
|
|
17
|
-
message: 'Where is your schema?:',
|
|
18
|
-
suffix: grey(' (path or url)'),
|
|
10
|
+
choices: targetChoices,
|
|
11
|
+
default: targetChoices.find(c => c.checked)?.value,
|
|
12
|
+
});
|
|
13
|
+
const schema = await input({
|
|
14
|
+
message: `Where is your schema?: ${grey('(path or url)')}`,
|
|
19
15
|
default: 'http://localhost:4000', // matches Apollo Server's default
|
|
20
|
-
validate:
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
{
|
|
38
|
-
type: 'checkbox',
|
|
39
|
-
name: 'plugins',
|
|
40
|
-
when: answers => {
|
|
41
|
-
// flatten targets
|
|
42
|
-
// I can't find an API in Inquirer that would do that
|
|
43
|
-
answers.targets = normalizeTargets(answers.targets);
|
|
44
|
-
return !answers.targets.includes(Tags.client);
|
|
45
|
-
},
|
|
46
|
-
message: 'Pick plugins:',
|
|
47
|
-
choices: getPluginChoices,
|
|
48
|
-
validate: ((plugins) => plugins.length > 0),
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
type: 'input',
|
|
52
|
-
name: 'output',
|
|
16
|
+
validate: str => str.length > 0,
|
|
17
|
+
});
|
|
18
|
+
let documents;
|
|
19
|
+
if (targets.includes(Tags.client) || targets.includes(Tags.angular) || targets.includes(Tags.stencil))
|
|
20
|
+
documents = await input({
|
|
21
|
+
message: 'Where are your operations and fragments?:',
|
|
22
|
+
default: getDocumentsDefaultValue(targets),
|
|
23
|
+
validate: str => str.length > 0,
|
|
24
|
+
});
|
|
25
|
+
let plugins;
|
|
26
|
+
if (!targets.includes(Tags.client)) {
|
|
27
|
+
plugins = await checkbox({
|
|
28
|
+
message: 'Pick plugins:',
|
|
29
|
+
choices: getPluginChoices(targets),
|
|
30
|
+
validate: plugins => plugins.length > 0,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
const output = await input({
|
|
53
34
|
message: 'Where to write the output:',
|
|
54
|
-
default: getOutputDefaultValue,
|
|
55
|
-
validate:
|
|
56
|
-
}
|
|
57
|
-
{
|
|
58
|
-
type: 'confirm',
|
|
59
|
-
name: 'introspection',
|
|
60
|
-
default: false,
|
|
35
|
+
default: getOutputDefaultValue({ targets, plugins }),
|
|
36
|
+
validate: str => str.length > 0,
|
|
37
|
+
});
|
|
38
|
+
const introspection = await confirm({
|
|
61
39
|
message: 'Do you want to generate an introspection file?',
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
name: 'config',
|
|
40
|
+
default: false,
|
|
41
|
+
});
|
|
42
|
+
const config = await input({
|
|
66
43
|
message: 'How to name the config file?',
|
|
67
|
-
default:
|
|
68
|
-
answers.targets.includes(Tags.typescript) ||
|
|
69
|
-
answers.targets.includes(Tags.angular)
|
|
44
|
+
default: (() => targets.includes(Tags.client) || targets.includes(Tags.typescript) || targets.includes(Tags.angular)
|
|
70
45
|
? 'codegen.ts'
|
|
71
|
-
: 'codegen.yml',
|
|
72
|
-
validate:
|
|
46
|
+
: 'codegen.yml')(),
|
|
47
|
+
validate: str => {
|
|
73
48
|
const isNotEmpty = str.length > 0;
|
|
74
49
|
const hasCorrectExtension = ['json', 'yml', 'yaml', 'js', 'ts'].some(ext => str.toLocaleLowerCase().endsWith(`.${ext}`));
|
|
75
50
|
return isNotEmpty && hasCorrectExtension;
|
|
76
51
|
},
|
|
77
|
-
}
|
|
78
|
-
{
|
|
79
|
-
type: 'input',
|
|
80
|
-
name: 'script',
|
|
52
|
+
});
|
|
53
|
+
const script = await input({
|
|
81
54
|
default: 'codegen',
|
|
82
55
|
message: 'What script in package.json should run the codegen?',
|
|
83
56
|
validate: (str) => str.length > 0,
|
|
84
|
-
}
|
|
85
|
-
|
|
57
|
+
});
|
|
58
|
+
return {
|
|
59
|
+
targets,
|
|
60
|
+
schema,
|
|
61
|
+
documents,
|
|
62
|
+
plugins,
|
|
63
|
+
output,
|
|
64
|
+
introspection,
|
|
65
|
+
config,
|
|
66
|
+
script,
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
catch (error) {
|
|
70
|
+
if (error instanceof Error && error.name === 'ExitPromptError') {
|
|
71
|
+
// This error because user exited using CMD+C, just exit gracefully or else user would see an ugly error message
|
|
72
|
+
// https://github.com/SBoudrias/Inquirer.js/blob/ee16061a1e3f99a6cc714a3d473f7cd12b06a3f1/packages/prompts/README.md#handling-ctrlc-gracefully
|
|
73
|
+
process.exit();
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
throw error;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
86
79
|
}
|
|
87
80
|
export function getApplicationTypeChoices(possibleTargets) {
|
|
88
81
|
function withFlowOrTypescript(tags) {
|
|
@@ -142,40 +135,37 @@ export function getApplicationTypeChoices(possibleTargets) {
|
|
|
142
135
|
},
|
|
143
136
|
];
|
|
144
137
|
}
|
|
145
|
-
export function getPluginChoices(
|
|
138
|
+
export function getPluginChoices(targets) {
|
|
146
139
|
return plugins
|
|
147
|
-
.filter(p => p.available(
|
|
140
|
+
.filter(p => p.available(targets))
|
|
148
141
|
.map(p => {
|
|
149
142
|
return {
|
|
150
143
|
name: p.name,
|
|
151
144
|
value: p,
|
|
152
|
-
checked: p.shouldBeSelected(
|
|
145
|
+
checked: p.shouldBeSelected(targets),
|
|
153
146
|
};
|
|
154
147
|
});
|
|
155
148
|
}
|
|
156
|
-
function
|
|
157
|
-
|
|
158
|
-
}
|
|
159
|
-
export function getOutputDefaultValue(answers) {
|
|
160
|
-
if (answers.targets.includes(Tags.client)) {
|
|
149
|
+
function getOutputDefaultValue({ targets, plugins }) {
|
|
150
|
+
if (targets.includes(Tags.client)) {
|
|
161
151
|
return 'src/gql/';
|
|
162
152
|
}
|
|
163
|
-
if (
|
|
153
|
+
if (plugins.some(plugin => plugin.defaultExtension === '.tsx')) {
|
|
164
154
|
return 'src/generated/graphql.tsx';
|
|
165
155
|
}
|
|
166
|
-
if (
|
|
156
|
+
if (plugins.some(plugin => plugin.defaultExtension === '.ts')) {
|
|
167
157
|
return 'src/generated/graphql.ts';
|
|
168
158
|
}
|
|
169
159
|
return 'src/generated/graphql.js';
|
|
170
160
|
}
|
|
171
|
-
|
|
172
|
-
if (
|
|
161
|
+
function getDocumentsDefaultValue(targets) {
|
|
162
|
+
if (targets.includes(Tags.vue)) {
|
|
173
163
|
return 'src/**/*.vue';
|
|
174
164
|
}
|
|
175
|
-
if (
|
|
165
|
+
if (targets.includes(Tags.angular)) {
|
|
176
166
|
return 'src/**/*.ts';
|
|
177
167
|
}
|
|
178
|
-
if (
|
|
168
|
+
if (targets.includes(Tags.client)) {
|
|
179
169
|
return 'src/**/*.tsx';
|
|
180
170
|
}
|
|
181
171
|
return 'src/**/*.graphql';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-codegen/cli",
|
|
3
|
-
"version": "6.0.0-alpha-
|
|
3
|
+
"version": "6.0.0-alpha-20250816104654-3cefeabda1bcfa915d43b4515cb86dd2dfb9df5b",
|
|
4
4
|
"peerDependenciesMeta": {
|
|
5
5
|
"@parcel/watcher": {
|
|
6
6
|
"optional": true
|
|
@@ -14,9 +14,9 @@
|
|
|
14
14
|
"@babel/generator": "^7.18.13",
|
|
15
15
|
"@babel/template": "^7.18.10",
|
|
16
16
|
"@babel/types": "^7.18.13",
|
|
17
|
-
"@graphql-codegen/client-preset": "5.0.0-alpha-
|
|
18
|
-
"@graphql-codegen/core": "5.0.0-alpha-
|
|
19
|
-
"@graphql-codegen/plugin-helpers": "6.0.0-alpha-
|
|
17
|
+
"@graphql-codegen/client-preset": "5.0.0-alpha-20250816104654-3cefeabda1bcfa915d43b4515cb86dd2dfb9df5b",
|
|
18
|
+
"@graphql-codegen/core": "5.0.0-alpha-20250816104654-3cefeabda1bcfa915d43b4515cb86dd2dfb9df5b",
|
|
19
|
+
"@graphql-codegen/plugin-helpers": "6.0.0-alpha-20250816104654-3cefeabda1bcfa915d43b4515cb86dd2dfb9df5b",
|
|
20
20
|
"@graphql-tools/apollo-engine-loader": "^8.0.0",
|
|
21
21
|
"@graphql-tools/code-file-loader": "^8.0.0",
|
|
22
22
|
"@graphql-tools/git-loader": "^8.0.0",
|
|
@@ -26,17 +26,17 @@
|
|
|
26
26
|
"@graphql-tools/load": "^8.1.0",
|
|
27
27
|
"@graphql-tools/url-loader": "^8.0.0",
|
|
28
28
|
"@graphql-tools/utils": "^10.0.0",
|
|
29
|
+
"@inquirer/prompts": "^7.8.2",
|
|
29
30
|
"@whatwg-node/fetch": "^0.10.0",
|
|
30
31
|
"chalk": "^4.1.0",
|
|
31
32
|
"cosmiconfig": "^9.0.0",
|
|
32
33
|
"debounce": "^2.0.0",
|
|
33
34
|
"detect-indent": "^6.0.0",
|
|
34
35
|
"graphql-config": "^5.1.1",
|
|
35
|
-
"inquirer": "^8.0.0",
|
|
36
36
|
"is-glob": "^4.0.1",
|
|
37
37
|
"jiti": "^2.3.0",
|
|
38
38
|
"json-to-pretty-yaml": "^1.2.2",
|
|
39
|
-
"listr2": "^
|
|
39
|
+
"listr2": "^9.0.0",
|
|
40
40
|
"log-symbols": "^4.0.0",
|
|
41
41
|
"micromatch": "^4.0.5",
|
|
42
42
|
"shell-quote": "^1.7.3",
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
export declare function getQuestions(possibleTargets: Record<Tags, boolean>): inquirer.QuestionCollection;
|
|
1
|
+
import { type Answers, type PluginOption, Tags } from './types.cjs';
|
|
2
|
+
export declare function getAnswers(possibleTargets: Record<Tags, boolean>): Promise<Answers>;
|
|
4
3
|
export declare function getApplicationTypeChoices(possibleTargets: Record<Tags, boolean>): {
|
|
5
4
|
name: string;
|
|
6
5
|
key: string;
|
|
7
6
|
value: Tags[];
|
|
8
7
|
checked: boolean;
|
|
9
8
|
}[];
|
|
10
|
-
export declare function getPluginChoices(
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
export declare function getPluginChoices(targets: Tags[]): {
|
|
10
|
+
name: string;
|
|
11
|
+
value: PluginOption;
|
|
12
|
+
checked: boolean;
|
|
13
|
+
}[];
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
export declare function getQuestions(possibleTargets: Record<Tags, boolean>): inquirer.QuestionCollection;
|
|
1
|
+
import { type Answers, type PluginOption, Tags } from './types.js';
|
|
2
|
+
export declare function getAnswers(possibleTargets: Record<Tags, boolean>): Promise<Answers>;
|
|
4
3
|
export declare function getApplicationTypeChoices(possibleTargets: Record<Tags, boolean>): {
|
|
5
4
|
name: string;
|
|
6
5
|
key: string;
|
|
7
6
|
value: Tags[];
|
|
8
7
|
checked: boolean;
|
|
9
8
|
}[];
|
|
10
|
-
export declare function getPluginChoices(
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
export declare function getPluginChoices(targets: Tags[]): {
|
|
10
|
+
name: string;
|
|
11
|
+
value: PluginOption;
|
|
12
|
+
checked: boolean;
|
|
13
|
+
}[];
|