@graphql-codegen/cli 2.7.0-alpha-929a21bcb.0 → 2.7.0-alpha-8c5d97899.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/bin.js +11 -15
- package/bin.mjs +1869 -0
- package/index.js +11 -15
- package/index.mjs +11 -15
- package/package.json +6 -5
package/bin.js
CHANGED
|
@@ -109,7 +109,7 @@ const DEFAULT_HOOKS = {
|
|
|
109
109
|
function normalizeHooks(_hooks) {
|
|
110
110
|
const keys = Object.keys({
|
|
111
111
|
...DEFAULT_HOOKS,
|
|
112
|
-
...
|
|
112
|
+
..._hooks,
|
|
113
113
|
});
|
|
114
114
|
return keys.reduce((prev, hookName) => {
|
|
115
115
|
if (typeof _hooks[hookName] === 'string') {
|
|
@@ -118,21 +118,19 @@ function normalizeHooks(_hooks) {
|
|
|
118
118
|
[hookName]: [_hooks[hookName]],
|
|
119
119
|
};
|
|
120
120
|
}
|
|
121
|
-
|
|
121
|
+
if (typeof _hooks[hookName] === 'function') {
|
|
122
122
|
return {
|
|
123
123
|
...prev,
|
|
124
124
|
[hookName]: [_hooks[hookName]],
|
|
125
125
|
};
|
|
126
126
|
}
|
|
127
|
-
|
|
127
|
+
if (Array.isArray(_hooks[hookName])) {
|
|
128
128
|
return {
|
|
129
129
|
...prev,
|
|
130
130
|
[hookName]: _hooks[hookName],
|
|
131
131
|
};
|
|
132
132
|
}
|
|
133
|
-
|
|
134
|
-
return prev;
|
|
135
|
-
}
|
|
133
|
+
return prev;
|
|
136
134
|
}, {});
|
|
137
135
|
}
|
|
138
136
|
function execShellCommand(cmd) {
|
|
@@ -388,7 +386,7 @@ async function getPresetByName(name, loader) {
|
|
|
388
386
|
if (loaded && loaded.preset) {
|
|
389
387
|
return loaded.preset;
|
|
390
388
|
}
|
|
391
|
-
|
|
389
|
+
if (loaded && loaded.default) {
|
|
392
390
|
return loaded.default;
|
|
393
391
|
}
|
|
394
392
|
return loaded;
|
|
@@ -694,7 +692,7 @@ function buildOptions() {
|
|
|
694
692
|
};
|
|
695
693
|
}
|
|
696
694
|
function parseArgv(argv = process.argv) {
|
|
697
|
-
return yargs.options(buildOptions()).parse(
|
|
695
|
+
return yargs(argv).options(buildOptions()).parse();
|
|
698
696
|
}
|
|
699
697
|
async function createContext(cliFlags = parseArgv(process.argv)) {
|
|
700
698
|
if (cliFlags.require && cliFlags.require.length > 0) {
|
|
@@ -1039,8 +1037,8 @@ async function executeCodegen(input) {
|
|
|
1039
1037
|
const outputSchemaAst = await context.loadSchema(schemaPointerMap);
|
|
1040
1038
|
const outputSchema = pluginHelpers.getCachedDocumentNodeFromSchema(outputSchemaAst);
|
|
1041
1039
|
return {
|
|
1042
|
-
outputSchemaAst
|
|
1043
|
-
outputSchema
|
|
1040
|
+
outputSchemaAst,
|
|
1041
|
+
outputSchema,
|
|
1044
1042
|
};
|
|
1045
1043
|
});
|
|
1046
1044
|
outputSchemaAst = await result.outputSchemaAst;
|
|
@@ -1057,7 +1055,7 @@ async function executeCodegen(input) {
|
|
|
1057
1055
|
return cache('documents', hash, async () => {
|
|
1058
1056
|
const documents = await context.loadDocuments(docs);
|
|
1059
1057
|
return {
|
|
1060
|
-
documents
|
|
1058
|
+
documents,
|
|
1061
1059
|
};
|
|
1062
1060
|
});
|
|
1063
1061
|
}));
|
|
@@ -1762,12 +1760,10 @@ function getOutputDefaultValue(answers) {
|
|
|
1762
1760
|
if (answers.plugins.some(plugin => plugin.defaultExtension === '.tsx')) {
|
|
1763
1761
|
return 'src/generated/graphql.tsx';
|
|
1764
1762
|
}
|
|
1765
|
-
|
|
1763
|
+
if (answers.plugins.some(plugin => plugin.defaultExtension === '.ts')) {
|
|
1766
1764
|
return 'src/generated/graphql.ts';
|
|
1767
1765
|
}
|
|
1768
|
-
|
|
1769
|
-
return 'src/generated/graphql.js';
|
|
1770
|
-
}
|
|
1766
|
+
return 'src/generated/graphql.js';
|
|
1771
1767
|
}
|
|
1772
1768
|
|
|
1773
1769
|
async function guessTargets() {
|