@graphql-codegen/cli 2.6.2 → 2.6.3

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.
Files changed (4) hide show
  1. package/bin.js +12 -15
  2. package/index.js +12 -15
  3. package/index.mjs +12 -15
  4. package/package.json +2 -8
package/bin.js CHANGED
@@ -61,7 +61,6 @@ const debounce = _interopDefault(require('debounce'));
61
61
  const mkdirp = _interopDefault(require('mkdirp'));
62
62
  const inquirer = _interopDefault(require('inquirer'));
63
63
  const detectIndent = _interopDefault(require('detect-indent'));
64
- const getLatestVersion = _interopDefault(require('latest-version'));
65
64
 
66
65
  let logger;
67
66
  function getLogger() {
@@ -109,7 +108,7 @@ const DEFAULT_HOOKS = {
109
108
  function normalizeHooks(_hooks) {
110
109
  const keys = Object.keys({
111
110
  ...DEFAULT_HOOKS,
112
- ...(_hooks || {}),
111
+ ..._hooks,
113
112
  });
114
113
  return keys.reduce((prev, hookName) => {
115
114
  if (typeof _hooks[hookName] === 'string') {
@@ -118,21 +117,19 @@ function normalizeHooks(_hooks) {
118
117
  [hookName]: [_hooks[hookName]],
119
118
  };
120
119
  }
121
- else if (typeof _hooks[hookName] === 'function') {
120
+ if (typeof _hooks[hookName] === 'function') {
122
121
  return {
123
122
  ...prev,
124
123
  [hookName]: [_hooks[hookName]],
125
124
  };
126
125
  }
127
- else if (Array.isArray(_hooks[hookName])) {
126
+ if (Array.isArray(_hooks[hookName])) {
128
127
  return {
129
128
  ...prev,
130
129
  [hookName]: _hooks[hookName],
131
130
  };
132
131
  }
133
- else {
134
- return prev;
135
- }
132
+ return prev;
136
133
  }, {});
137
134
  }
138
135
  function execShellCommand(cmd) {
@@ -388,7 +385,7 @@ async function getPresetByName(name, loader) {
388
385
  if (loaded && loaded.preset) {
389
386
  return loaded.preset;
390
387
  }
391
- else if (loaded && loaded.default) {
388
+ if (loaded && loaded.default) {
392
389
  return loaded.default;
393
390
  }
394
391
  return loaded;
@@ -1039,8 +1036,8 @@ async function executeCodegen(input) {
1039
1036
  const outputSchemaAst = await context.loadSchema(schemaPointerMap);
1040
1037
  const outputSchema = pluginHelpers.getCachedDocumentNodeFromSchema(outputSchemaAst);
1041
1038
  return {
1042
- outputSchemaAst: outputSchemaAst,
1043
- outputSchema: outputSchema,
1039
+ outputSchemaAst,
1040
+ outputSchema,
1044
1041
  };
1045
1042
  });
1046
1043
  outputSchemaAst = await result.outputSchemaAst;
@@ -1057,7 +1054,7 @@ async function executeCodegen(input) {
1057
1054
  return cache('documents', hash, async () => {
1058
1055
  const documents = await context.loadDocuments(docs);
1059
1056
  return {
1060
- documents: documents,
1057
+ documents,
1061
1058
  };
1062
1059
  });
1063
1060
  }));
@@ -1425,6 +1422,8 @@ async function writeConfig(answers, config) {
1425
1422
  }
1426
1423
  // Updates package.json (script and plugins as dependencies)
1427
1424
  async function writePackage(answers, configLocation) {
1425
+ // dynamic import because latest-version is pure ESM
1426
+ const getLatestVersion = (await new Promise(function (resolve) { resolve(_interopNamespace(require('latest-version'))); })).default;
1428
1427
  // script
1429
1428
  const pkgPath = path.resolve(process.cwd(), 'package.json');
1430
1429
  const pkgContent = fs.readFileSync(pkgPath, {
@@ -1762,12 +1761,10 @@ function getOutputDefaultValue(answers) {
1762
1761
  if (answers.plugins.some(plugin => plugin.defaultExtension === '.tsx')) {
1763
1762
  return 'src/generated/graphql.tsx';
1764
1763
  }
1765
- else if (answers.plugins.some(plugin => plugin.defaultExtension === '.ts')) {
1764
+ if (answers.plugins.some(plugin => plugin.defaultExtension === '.ts')) {
1766
1765
  return 'src/generated/graphql.ts';
1767
1766
  }
1768
- else {
1769
- return 'src/generated/graphql.js';
1770
- }
1767
+ return 'src/generated/graphql.js';
1771
1768
  }
1772
1769
 
1773
1770
  async function guessTargets() {
package/index.js CHANGED
@@ -62,7 +62,6 @@ const debounce = _interopDefault(require('debounce'));
62
62
  const mkdirp = _interopDefault(require('mkdirp'));
63
63
  const inquirer = _interopDefault(require('inquirer'));
64
64
  const detectIndent = _interopDefault(require('detect-indent'));
65
- const getLatestVersion = _interopDefault(require('latest-version'));
66
65
 
67
66
  /**
68
67
  Indent each line in a string.
@@ -306,7 +305,7 @@ async function getPresetByName(name, loader) {
306
305
  if (loaded && loaded.preset) {
307
306
  return loaded.preset;
308
307
  }
309
- else if (loaded && loaded.default) {
308
+ if (loaded && loaded.default) {
310
309
  return loaded.default;
311
310
  }
312
311
  return loaded;
@@ -957,8 +956,8 @@ async function executeCodegen(input) {
957
956
  const outputSchemaAst = await context.loadSchema(schemaPointerMap);
958
957
  const outputSchema = pluginHelpers.getCachedDocumentNodeFromSchema(outputSchemaAst);
959
958
  return {
960
- outputSchemaAst: outputSchemaAst,
961
- outputSchema: outputSchema,
959
+ outputSchemaAst,
960
+ outputSchema,
962
961
  };
963
962
  });
964
963
  outputSchemaAst = await result.outputSchemaAst;
@@ -975,7 +974,7 @@ async function executeCodegen(input) {
975
974
  return cache('documents', hash, async () => {
976
975
  const documents = await context.loadDocuments(docs);
977
976
  return {
978
- documents: documents,
977
+ documents,
979
978
  };
980
979
  });
981
980
  }));
@@ -1098,7 +1097,7 @@ const DEFAULT_HOOKS = {
1098
1097
  function normalizeHooks(_hooks) {
1099
1098
  const keys = Object.keys({
1100
1099
  ...DEFAULT_HOOKS,
1101
- ...(_hooks || {}),
1100
+ ..._hooks,
1102
1101
  });
1103
1102
  return keys.reduce((prev, hookName) => {
1104
1103
  if (typeof _hooks[hookName] === 'string') {
@@ -1107,21 +1106,19 @@ function normalizeHooks(_hooks) {
1107
1106
  [hookName]: [_hooks[hookName]],
1108
1107
  };
1109
1108
  }
1110
- else if (typeof _hooks[hookName] === 'function') {
1109
+ if (typeof _hooks[hookName] === 'function') {
1111
1110
  return {
1112
1111
  ...prev,
1113
1112
  [hookName]: [_hooks[hookName]],
1114
1113
  };
1115
1114
  }
1116
- else if (Array.isArray(_hooks[hookName])) {
1115
+ if (Array.isArray(_hooks[hookName])) {
1117
1116
  return {
1118
1117
  ...prev,
1119
1118
  [hookName]: _hooks[hookName],
1120
1119
  };
1121
1120
  }
1122
- else {
1123
- return prev;
1124
- }
1121
+ return prev;
1125
1122
  }, {});
1126
1123
  }
1127
1124
  function execShellCommand(cmd) {
@@ -1426,6 +1423,8 @@ async function writeConfig(answers, config) {
1426
1423
  }
1427
1424
  // Updates package.json (script and plugins as dependencies)
1428
1425
  async function writePackage(answers, configLocation) {
1426
+ // dynamic import because latest-version is pure ESM
1427
+ const getLatestVersion = (await new Promise(function (resolve) { resolve(_interopNamespace(require('latest-version'))); })).default;
1429
1428
  // script
1430
1429
  const pkgPath = path.resolve(process.cwd(), 'package.json');
1431
1430
  const pkgContent = fs.readFileSync(pkgPath, {
@@ -1763,12 +1762,10 @@ function getOutputDefaultValue(answers) {
1763
1762
  if (answers.plugins.some(plugin => plugin.defaultExtension === '.tsx')) {
1764
1763
  return 'src/generated/graphql.tsx';
1765
1764
  }
1766
- else if (answers.plugins.some(plugin => plugin.defaultExtension === '.ts')) {
1765
+ if (answers.plugins.some(plugin => plugin.defaultExtension === '.ts')) {
1767
1766
  return 'src/generated/graphql.ts';
1768
1767
  }
1769
- else {
1770
- return 'src/generated/graphql.js';
1771
- }
1768
+ return 'src/generated/graphql.js';
1772
1769
  }
1773
1770
 
1774
1771
  async function guessTargets() {
package/index.mjs CHANGED
@@ -35,7 +35,6 @@ import debounce from 'debounce';
35
35
  import mkdirp from 'mkdirp';
36
36
  import inquirer from 'inquirer';
37
37
  import detectIndent from 'detect-indent';
38
- import getLatestVersion from 'latest-version';
39
38
 
40
39
  /**
41
40
  Indent each line in a string.
@@ -279,7 +278,7 @@ async function getPresetByName(name, loader) {
279
278
  if (loaded && loaded.preset) {
280
279
  return loaded.preset;
281
280
  }
282
- else if (loaded && loaded.default) {
281
+ if (loaded && loaded.default) {
283
282
  return loaded.default;
284
283
  }
285
284
  return loaded;
@@ -930,8 +929,8 @@ async function executeCodegen(input) {
930
929
  const outputSchemaAst = await context.loadSchema(schemaPointerMap);
931
930
  const outputSchema = getCachedDocumentNodeFromSchema(outputSchemaAst);
932
931
  return {
933
- outputSchemaAst: outputSchemaAst,
934
- outputSchema: outputSchema,
932
+ outputSchemaAst,
933
+ outputSchema,
935
934
  };
936
935
  });
937
936
  outputSchemaAst = await result.outputSchemaAst;
@@ -948,7 +947,7 @@ async function executeCodegen(input) {
948
947
  return cache('documents', hash, async () => {
949
948
  const documents = await context.loadDocuments(docs);
950
949
  return {
951
- documents: documents,
950
+ documents,
952
951
  };
953
952
  });
954
953
  }));
@@ -1071,7 +1070,7 @@ const DEFAULT_HOOKS = {
1071
1070
  function normalizeHooks(_hooks) {
1072
1071
  const keys = Object.keys({
1073
1072
  ...DEFAULT_HOOKS,
1074
- ...(_hooks || {}),
1073
+ ..._hooks,
1075
1074
  });
1076
1075
  return keys.reduce((prev, hookName) => {
1077
1076
  if (typeof _hooks[hookName] === 'string') {
@@ -1080,21 +1079,19 @@ function normalizeHooks(_hooks) {
1080
1079
  [hookName]: [_hooks[hookName]],
1081
1080
  };
1082
1081
  }
1083
- else if (typeof _hooks[hookName] === 'function') {
1082
+ if (typeof _hooks[hookName] === 'function') {
1084
1083
  return {
1085
1084
  ...prev,
1086
1085
  [hookName]: [_hooks[hookName]],
1087
1086
  };
1088
1087
  }
1089
- else if (Array.isArray(_hooks[hookName])) {
1088
+ if (Array.isArray(_hooks[hookName])) {
1090
1089
  return {
1091
1090
  ...prev,
1092
1091
  [hookName]: _hooks[hookName],
1093
1092
  };
1094
1093
  }
1095
- else {
1096
- return prev;
1097
- }
1094
+ return prev;
1098
1095
  }, {});
1099
1096
  }
1100
1097
  function execShellCommand(cmd) {
@@ -1399,6 +1396,8 @@ async function writeConfig(answers, config) {
1399
1396
  }
1400
1397
  // Updates package.json (script and plugins as dependencies)
1401
1398
  async function writePackage(answers, configLocation) {
1399
+ // dynamic import because latest-version is pure ESM
1400
+ const getLatestVersion = (await import('latest-version')).default;
1402
1401
  // script
1403
1402
  const pkgPath = resolve(process.cwd(), 'package.json');
1404
1403
  const pkgContent = readFileSync(pkgPath, {
@@ -1736,12 +1735,10 @@ function getOutputDefaultValue(answers) {
1736
1735
  if (answers.plugins.some(plugin => plugin.defaultExtension === '.tsx')) {
1737
1736
  return 'src/generated/graphql.tsx';
1738
1737
  }
1739
- else if (answers.plugins.some(plugin => plugin.defaultExtension === '.ts')) {
1738
+ if (answers.plugins.some(plugin => plugin.defaultExtension === '.ts')) {
1740
1739
  return 'src/generated/graphql.ts';
1741
1740
  }
1742
- else {
1743
- return 'src/generated/graphql.js';
1744
- }
1741
+ return 'src/generated/graphql.js';
1745
1742
  }
1746
1743
 
1747
1744
  async function guessTargets() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphql-codegen/cli",
3
- "version": "2.6.2",
3
+ "version": "2.6.3",
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
  },
@@ -24,24 +24,18 @@
24
24
  "common-tags": "^1.8.0",
25
25
  "cosmiconfig": "^7.0.0",
26
26
  "debounce": "^1.2.0",
27
- "dependency-graph": "^0.11.0",
28
27
  "detect-indent": "^6.0.0",
29
- "glob": "^7.1.6",
30
- "globby": "^11.0.4",
31
28
  "graphql-config": "^4.1.0",
32
29
  "inquirer": "^8.0.0",
33
30
  "is-glob": "^4.0.1",
34
31
  "json-to-pretty-yaml": "^1.2.2",
35
- "latest-version": "5.1.0",
32
+ "latest-version": "^6.0.0",
36
33
  "listr": "^0.14.3",
37
34
  "listr-update-renderer": "^0.5.0",
38
35
  "log-symbols": "^4.0.0",
39
- "minimatch": "^4.0.0",
40
36
  "mkdirp": "^1.0.4",
41
37
  "string-env-interpolation": "^1.0.1",
42
38
  "ts-log": "^2.2.3",
43
- "tslib": "~2.3.0",
44
- "valid-url": "^1.0.9",
45
39
  "wrap-ansi": "^7.0.0",
46
40
  "yaml": "^1.10.0",
47
41
  "yargs": "^17.0.0"