@graphql-codegen/cli 2.5.0-alpha-c9cbc7d69.0 → 2.5.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 +43 -26
- package/index.js +44 -26
- package/index.mjs +44 -27
- package/package.json +3 -3
- package/utils/cli-error.d.ts +10 -0
package/bin.js
CHANGED
|
@@ -28,6 +28,7 @@ const path = require('path');
|
|
|
28
28
|
const path__default = _interopDefault(path);
|
|
29
29
|
const pluginHelpers = require('@graphql-codegen/plugin-helpers');
|
|
30
30
|
const core = require('@graphql-codegen/core');
|
|
31
|
+
const utils = require('@graphql-tools/utils');
|
|
31
32
|
const chalk = _interopDefault(require('chalk'));
|
|
32
33
|
const logSymbols = _interopDefault(require('log-symbols'));
|
|
33
34
|
const ansiEscapes = _interopDefault(require('ansi-escapes'));
|
|
@@ -55,7 +56,6 @@ const fs__default = _interopDefault(fs);
|
|
|
55
56
|
const Listr = _interopDefault(require('listr'));
|
|
56
57
|
const isGlob = _interopDefault(require('is-glob'));
|
|
57
58
|
const debounce = _interopDefault(require('debounce'));
|
|
58
|
-
const utils = require('@graphql-tools/utils');
|
|
59
59
|
const mkdirp = _interopDefault(require('mkdirp'));
|
|
60
60
|
const crypto = require('crypto');
|
|
61
61
|
const inquirer = _interopDefault(require('inquirer'));
|
|
@@ -796,6 +796,33 @@ function ensureContext(input) {
|
|
|
796
796
|
return input instanceof CodegenContext ? input : new CodegenContext({ config: input });
|
|
797
797
|
}
|
|
798
798
|
|
|
799
|
+
const isBrowser = typeof window !== 'undefined' && typeof window.document !== 'undefined';
|
|
800
|
+
const isNode = typeof process !== 'undefined' && process.versions != null && process.versions.node != null;
|
|
801
|
+
|
|
802
|
+
function isListrError(err) {
|
|
803
|
+
return err.name === 'ListrError' && Array.isArray(err.errors) && err.errors.length > 0;
|
|
804
|
+
}
|
|
805
|
+
function cliError(err, exitOnError = true) {
|
|
806
|
+
let msg;
|
|
807
|
+
if (err instanceof Error) {
|
|
808
|
+
msg = err.message || err.toString();
|
|
809
|
+
}
|
|
810
|
+
else if (typeof err === 'string') {
|
|
811
|
+
msg = err;
|
|
812
|
+
}
|
|
813
|
+
else {
|
|
814
|
+
msg = JSON.stringify(err);
|
|
815
|
+
}
|
|
816
|
+
// eslint-disable-next-line no-console
|
|
817
|
+
console.error(msg);
|
|
818
|
+
if (exitOnError && isNode) {
|
|
819
|
+
process.exit(1);
|
|
820
|
+
}
|
|
821
|
+
else if (exitOnError && isBrowser) {
|
|
822
|
+
throw err;
|
|
823
|
+
}
|
|
824
|
+
}
|
|
825
|
+
|
|
799
826
|
const makeDefaultLoader = (from) => {
|
|
800
827
|
if (fs__default.statSync(from).isDirectory()) {
|
|
801
828
|
from = path__default.join(from, '__fake.js');
|
|
@@ -1086,7 +1113,21 @@ async function executeCodegen(input) {
|
|
|
1086
1113
|
});
|
|
1087
1114
|
},
|
|
1088
1115
|
});
|
|
1089
|
-
|
|
1116
|
+
try {
|
|
1117
|
+
await listr.run();
|
|
1118
|
+
}
|
|
1119
|
+
catch (err) {
|
|
1120
|
+
if (isListrError(err)) {
|
|
1121
|
+
const allErrs = err.errors.map(subErr => pluginHelpers.isDetailedError(subErr)
|
|
1122
|
+
? `${subErr.message} for "${subErr.source}"${subErr.details}`
|
|
1123
|
+
: subErr.message || subErr.toString());
|
|
1124
|
+
const newErr = new utils.AggregateError(err.errors, `${err.message} ${allErrs.join('\n\n')}`);
|
|
1125
|
+
// Best-effort to all stack traces for debugging
|
|
1126
|
+
newErr.stack = `${newErr.stack}\n\n${err.errors.map(subErr => subErr.stack).join('\n\n')}`;
|
|
1127
|
+
throw newErr;
|
|
1128
|
+
}
|
|
1129
|
+
throw err;
|
|
1130
|
+
}
|
|
1090
1131
|
return result;
|
|
1091
1132
|
}
|
|
1092
1133
|
|
|
@@ -1808,30 +1849,6 @@ async function ensureGraphQlPackage() {
|
|
|
1808
1849
|
}
|
|
1809
1850
|
}
|
|
1810
1851
|
|
|
1811
|
-
const isBrowser = typeof window !== 'undefined' && typeof window.document !== 'undefined';
|
|
1812
|
-
const isNode = typeof process !== 'undefined' && process.versions != null && process.versions.node != null;
|
|
1813
|
-
|
|
1814
|
-
function cliError(err, exitOnError = true) {
|
|
1815
|
-
let msg;
|
|
1816
|
-
if (err instanceof Error) {
|
|
1817
|
-
msg = err.message || err.toString();
|
|
1818
|
-
}
|
|
1819
|
-
else if (typeof err === 'string') {
|
|
1820
|
-
msg = err;
|
|
1821
|
-
}
|
|
1822
|
-
else {
|
|
1823
|
-
msg = JSON.stringify(err);
|
|
1824
|
-
}
|
|
1825
|
-
// eslint-disable-next-line no-console
|
|
1826
|
-
console.error(msg);
|
|
1827
|
-
if (exitOnError && isNode) {
|
|
1828
|
-
process.exit(1);
|
|
1829
|
-
}
|
|
1830
|
-
else if (exitOnError && isBrowser) {
|
|
1831
|
-
throw err;
|
|
1832
|
-
}
|
|
1833
|
-
}
|
|
1834
|
-
|
|
1835
1852
|
const [, , cmd] = process.argv;
|
|
1836
1853
|
runCli(cmd)
|
|
1837
1854
|
.then(() => {
|
package/index.js
CHANGED
|
@@ -25,6 +25,7 @@ function _interopNamespace(e) {
|
|
|
25
25
|
|
|
26
26
|
const pluginHelpers = require('@graphql-codegen/plugin-helpers');
|
|
27
27
|
const core = require('@graphql-codegen/core');
|
|
28
|
+
const utils = require('@graphql-tools/utils');
|
|
28
29
|
const chalk = _interopDefault(require('chalk'));
|
|
29
30
|
const logSymbols = _interopDefault(require('log-symbols'));
|
|
30
31
|
const ansiEscapes = _interopDefault(require('ansi-escapes'));
|
|
@@ -56,7 +57,6 @@ const Listr = _interopDefault(require('listr'));
|
|
|
56
57
|
const child_process = require('child_process');
|
|
57
58
|
const isGlob = _interopDefault(require('is-glob'));
|
|
58
59
|
const debounce = _interopDefault(require('debounce'));
|
|
59
|
-
const utils = require('@graphql-tools/utils');
|
|
60
60
|
const mkdirp = _interopDefault(require('mkdirp'));
|
|
61
61
|
const crypto = require('crypto');
|
|
62
62
|
const inquirer = _interopDefault(require('inquirer'));
|
|
@@ -714,6 +714,33 @@ function ensureContext(input) {
|
|
|
714
714
|
return input instanceof CodegenContext ? input : new CodegenContext({ config: input });
|
|
715
715
|
}
|
|
716
716
|
|
|
717
|
+
const isBrowser = typeof window !== 'undefined' && typeof window.document !== 'undefined';
|
|
718
|
+
const isNode = typeof process !== 'undefined' && process.versions != null && process.versions.node != null;
|
|
719
|
+
|
|
720
|
+
function isListrError(err) {
|
|
721
|
+
return err.name === 'ListrError' && Array.isArray(err.errors) && err.errors.length > 0;
|
|
722
|
+
}
|
|
723
|
+
function cliError(err, exitOnError = true) {
|
|
724
|
+
let msg;
|
|
725
|
+
if (err instanceof Error) {
|
|
726
|
+
msg = err.message || err.toString();
|
|
727
|
+
}
|
|
728
|
+
else if (typeof err === 'string') {
|
|
729
|
+
msg = err;
|
|
730
|
+
}
|
|
731
|
+
else {
|
|
732
|
+
msg = JSON.stringify(err);
|
|
733
|
+
}
|
|
734
|
+
// eslint-disable-next-line no-console
|
|
735
|
+
console.error(msg);
|
|
736
|
+
if (exitOnError && isNode) {
|
|
737
|
+
process.exit(1);
|
|
738
|
+
}
|
|
739
|
+
else if (exitOnError && isBrowser) {
|
|
740
|
+
throw err;
|
|
741
|
+
}
|
|
742
|
+
}
|
|
743
|
+
|
|
717
744
|
const makeDefaultLoader = (from) => {
|
|
718
745
|
if (fs__default.statSync(from).isDirectory()) {
|
|
719
746
|
from = path__default.join(from, '__fake.js');
|
|
@@ -1004,7 +1031,21 @@ async function executeCodegen(input) {
|
|
|
1004
1031
|
});
|
|
1005
1032
|
},
|
|
1006
1033
|
});
|
|
1007
|
-
|
|
1034
|
+
try {
|
|
1035
|
+
await listr.run();
|
|
1036
|
+
}
|
|
1037
|
+
catch (err) {
|
|
1038
|
+
if (isListrError(err)) {
|
|
1039
|
+
const allErrs = err.errors.map(subErr => pluginHelpers.isDetailedError(subErr)
|
|
1040
|
+
? `${subErr.message} for "${subErr.source}"${subErr.details}`
|
|
1041
|
+
: subErr.message || subErr.toString());
|
|
1042
|
+
const newErr = new utils.AggregateError(err.errors, `${err.message} ${allErrs.join('\n\n')}`);
|
|
1043
|
+
// Best-effort to all stack traces for debugging
|
|
1044
|
+
newErr.stack = `${newErr.stack}\n\n${err.errors.map(subErr => subErr.stack).join('\n\n')}`;
|
|
1045
|
+
throw newErr;
|
|
1046
|
+
}
|
|
1047
|
+
throw err;
|
|
1048
|
+
}
|
|
1008
1049
|
return result;
|
|
1009
1050
|
}
|
|
1010
1051
|
|
|
@@ -1780,30 +1821,6 @@ function addIntrospection(config) {
|
|
|
1780
1821
|
};
|
|
1781
1822
|
}
|
|
1782
1823
|
|
|
1783
|
-
const isBrowser = typeof window !== 'undefined' && typeof window.document !== 'undefined';
|
|
1784
|
-
const isNode = typeof process !== 'undefined' && process.versions != null && process.versions.node != null;
|
|
1785
|
-
|
|
1786
|
-
function cliError(err, exitOnError = true) {
|
|
1787
|
-
let msg;
|
|
1788
|
-
if (err instanceof Error) {
|
|
1789
|
-
msg = err.message || err.toString();
|
|
1790
|
-
}
|
|
1791
|
-
else if (typeof err === 'string') {
|
|
1792
|
-
msg = err;
|
|
1793
|
-
}
|
|
1794
|
-
else {
|
|
1795
|
-
msg = JSON.stringify(err);
|
|
1796
|
-
}
|
|
1797
|
-
// eslint-disable-next-line no-console
|
|
1798
|
-
console.error(msg);
|
|
1799
|
-
if (exitOnError && isNode) {
|
|
1800
|
-
process.exit(1);
|
|
1801
|
-
}
|
|
1802
|
-
else if (exitOnError && isBrowser) {
|
|
1803
|
-
throw err;
|
|
1804
|
-
}
|
|
1805
|
-
}
|
|
1806
|
-
|
|
1807
1824
|
async function runCli(cmd) {
|
|
1808
1825
|
await ensureGraphQlPackage();
|
|
1809
1826
|
switch (cmd) {
|
|
@@ -1845,6 +1862,7 @@ exports.findAndLoadGraphQLConfig = findAndLoadGraphQLConfig;
|
|
|
1845
1862
|
exports.generate = generate;
|
|
1846
1863
|
exports.generateSearchPlaces = generateSearchPlaces;
|
|
1847
1864
|
exports.init = init;
|
|
1865
|
+
exports.isListrError = isListrError;
|
|
1848
1866
|
exports.loadCodegenConfig = loadCodegenConfig;
|
|
1849
1867
|
exports.loadContext = loadContext;
|
|
1850
1868
|
exports.parseArgv = parseArgv;
|
package/index.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { isDetailedError, DetailedError, createNoopProfiler, createProfiler, normalizeInstanceOrArray, normalizeConfig, normalizeOutputParam, getCachedDocumentNodeFromSchema } from '@graphql-codegen/plugin-helpers';
|
|
2
2
|
import { codegen } from '@graphql-codegen/core';
|
|
3
|
+
import { AggregateError, isValidPath } from '@graphql-tools/utils';
|
|
3
4
|
import chalk from 'chalk';
|
|
4
5
|
import logSymbols from 'log-symbols';
|
|
5
6
|
import ansiEscapes from 'ansi-escapes';
|
|
@@ -29,7 +30,6 @@ import Listr from 'listr';
|
|
|
29
30
|
import { exec } from 'child_process';
|
|
30
31
|
import isGlob from 'is-glob';
|
|
31
32
|
import debounce from 'debounce';
|
|
32
|
-
import { isValidPath } from '@graphql-tools/utils';
|
|
33
33
|
import mkdirp from 'mkdirp';
|
|
34
34
|
import { createHash } from 'crypto';
|
|
35
35
|
import inquirer from 'inquirer';
|
|
@@ -687,6 +687,33 @@ function ensureContext(input) {
|
|
|
687
687
|
return input instanceof CodegenContext ? input : new CodegenContext({ config: input });
|
|
688
688
|
}
|
|
689
689
|
|
|
690
|
+
const isBrowser = typeof window !== 'undefined' && typeof window.document !== 'undefined';
|
|
691
|
+
const isNode = typeof process !== 'undefined' && process.versions != null && process.versions.node != null;
|
|
692
|
+
|
|
693
|
+
function isListrError(err) {
|
|
694
|
+
return err.name === 'ListrError' && Array.isArray(err.errors) && err.errors.length > 0;
|
|
695
|
+
}
|
|
696
|
+
function cliError(err, exitOnError = true) {
|
|
697
|
+
let msg;
|
|
698
|
+
if (err instanceof Error) {
|
|
699
|
+
msg = err.message || err.toString();
|
|
700
|
+
}
|
|
701
|
+
else if (typeof err === 'string') {
|
|
702
|
+
msg = err;
|
|
703
|
+
}
|
|
704
|
+
else {
|
|
705
|
+
msg = JSON.stringify(err);
|
|
706
|
+
}
|
|
707
|
+
// eslint-disable-next-line no-console
|
|
708
|
+
console.error(msg);
|
|
709
|
+
if (exitOnError && isNode) {
|
|
710
|
+
process.exit(1);
|
|
711
|
+
}
|
|
712
|
+
else if (exitOnError && isBrowser) {
|
|
713
|
+
throw err;
|
|
714
|
+
}
|
|
715
|
+
}
|
|
716
|
+
|
|
690
717
|
const makeDefaultLoader = (from) => {
|
|
691
718
|
if (fs.statSync(from).isDirectory()) {
|
|
692
719
|
from = path.join(from, '__fake.js');
|
|
@@ -977,7 +1004,21 @@ async function executeCodegen(input) {
|
|
|
977
1004
|
});
|
|
978
1005
|
},
|
|
979
1006
|
});
|
|
980
|
-
|
|
1007
|
+
try {
|
|
1008
|
+
await listr.run();
|
|
1009
|
+
}
|
|
1010
|
+
catch (err) {
|
|
1011
|
+
if (isListrError(err)) {
|
|
1012
|
+
const allErrs = err.errors.map(subErr => isDetailedError(subErr)
|
|
1013
|
+
? `${subErr.message} for "${subErr.source}"${subErr.details}`
|
|
1014
|
+
: subErr.message || subErr.toString());
|
|
1015
|
+
const newErr = new AggregateError(err.errors, `${err.message} ${allErrs.join('\n\n')}`);
|
|
1016
|
+
// Best-effort to all stack traces for debugging
|
|
1017
|
+
newErr.stack = `${newErr.stack}\n\n${err.errors.map(subErr => subErr.stack).join('\n\n')}`;
|
|
1018
|
+
throw newErr;
|
|
1019
|
+
}
|
|
1020
|
+
throw err;
|
|
1021
|
+
}
|
|
981
1022
|
return result;
|
|
982
1023
|
}
|
|
983
1024
|
|
|
@@ -1753,30 +1794,6 @@ function addIntrospection(config) {
|
|
|
1753
1794
|
};
|
|
1754
1795
|
}
|
|
1755
1796
|
|
|
1756
|
-
const isBrowser = typeof window !== 'undefined' && typeof window.document !== 'undefined';
|
|
1757
|
-
const isNode = typeof process !== 'undefined' && process.versions != null && process.versions.node != null;
|
|
1758
|
-
|
|
1759
|
-
function cliError(err, exitOnError = true) {
|
|
1760
|
-
let msg;
|
|
1761
|
-
if (err instanceof Error) {
|
|
1762
|
-
msg = err.message || err.toString();
|
|
1763
|
-
}
|
|
1764
|
-
else if (typeof err === 'string') {
|
|
1765
|
-
msg = err;
|
|
1766
|
-
}
|
|
1767
|
-
else {
|
|
1768
|
-
msg = JSON.stringify(err);
|
|
1769
|
-
}
|
|
1770
|
-
// eslint-disable-next-line no-console
|
|
1771
|
-
console.error(msg);
|
|
1772
|
-
if (exitOnError && isNode) {
|
|
1773
|
-
process.exit(1);
|
|
1774
|
-
}
|
|
1775
|
-
else if (exitOnError && isBrowser) {
|
|
1776
|
-
throw err;
|
|
1777
|
-
}
|
|
1778
|
-
}
|
|
1779
|
-
|
|
1780
1797
|
async function runCli(cmd) {
|
|
1781
1798
|
await ensureGraphQlPackage();
|
|
1782
1799
|
switch (cmd) {
|
|
@@ -1806,4 +1823,4 @@ async function ensureGraphQlPackage() {
|
|
|
1806
1823
|
}
|
|
1807
1824
|
}
|
|
1808
1825
|
|
|
1809
|
-
export { CodegenContext, CodegenExtension, buildOptions, cliError, createContext, ensureContext, ensureGraphQlPackage, executeCodegen, findAndLoadGraphQLConfig, generate, generateSearchPlaces, init, loadCodegenConfig, loadContext, parseArgv, runCli, updateContextWithCliFlags };
|
|
1826
|
+
export { CodegenContext, CodegenExtension, buildOptions, cliError, createContext, ensureContext, ensureGraphQlPackage, executeCodegen, findAndLoadGraphQLConfig, generate, generateSearchPlaces, init, isListrError, loadCodegenConfig, loadContext, parseArgv, runCli, updateContextWithCliFlags };
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-codegen/cli",
|
|
3
|
-
"version": "2.5.0
|
|
3
|
+
"version": "2.5.0",
|
|
4
4
|
"peerDependencies": {
|
|
5
5
|
"graphql": "^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0"
|
|
6
6
|
},
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@graphql-codegen/core": "2.5.0
|
|
9
|
-
"@graphql-codegen/plugin-helpers": "2.4.0
|
|
8
|
+
"@graphql-codegen/core": "2.5.0",
|
|
9
|
+
"@graphql-codegen/plugin-helpers": "^2.4.0",
|
|
10
10
|
"@graphql-tools/apollo-engine-loader": "^7.0.5",
|
|
11
11
|
"@graphql-tools/code-file-loader": "^7.0.6",
|
|
12
12
|
"@graphql-tools/git-loader": "^7.0.5",
|
package/utils/cli-error.d.ts
CHANGED
|
@@ -1 +1,11 @@
|
|
|
1
|
+
import { DetailedError } from '@graphql-codegen/plugin-helpers';
|
|
2
|
+
declare type CompositeError = Error | DetailedError;
|
|
3
|
+
declare type ListrError = Error & {
|
|
4
|
+
errors: CompositeError[];
|
|
5
|
+
};
|
|
6
|
+
export declare function isListrError(err: Error & {
|
|
7
|
+
name?: unknown;
|
|
8
|
+
errors?: unknown;
|
|
9
|
+
}): err is ListrError;
|
|
1
10
|
export declare function cliError(err: any, exitOnError?: boolean): void;
|
|
11
|
+
export {};
|