@graphql-codegen/cli 3.3.2-rc-20230519121941-92ebcf71b → 3.3.2-rc-20230523141319-8e14665fd

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 CHANGED
@@ -8,7 +8,6 @@ const os_1 = require("os");
8
8
  const path_1 = tslib_1.__importDefault(require("path"));
9
9
  const core_1 = require("@graphql-codegen/core");
10
10
  const plugin_helpers_1 = require("@graphql-codegen/plugin-helpers");
11
- const utils_1 = require("@graphql-tools/utils");
12
11
  const graphql_1 = require("graphql");
13
12
  const listr2_1 = require("listr2");
14
13
  const config_js_1 = require("./config.js");
@@ -168,7 +167,7 @@ async function executeCodegen(input) {
168
167
  ? await (0, presets_js_1.getPresetByName)(outputConfig.preset, makeDefaultLoader(context.cwd))
169
168
  : outputConfig.preset
170
169
  : null;
171
- if (preset === null || preset === void 0 ? void 0 : preset.prepareDocuments) {
170
+ if (preset?.prepareDocuments) {
172
171
  outputSpecificDocuments = await preset.prepareDocuments(filename, outputSpecificDocuments);
173
172
  }
174
173
  return subTask.newListr([
@@ -332,7 +331,7 @@ async function executeCodegen(input) {
332
331
  }
333
332
  if (executedContext.errors.length > 0) {
334
333
  const errors = executedContext.errors.map(subErr => subErr.message || subErr.toString());
335
- const newErr = new utils_1.AggregateError(executedContext.errors, String(errors.join('\n\n')));
334
+ const newErr = new AggregateError(executedContext.errors, String(errors.join('\n\n')));
336
335
  // Best-effort to all stack traces for debugging
337
336
  newErr.stack = `${newErr.stack}\n\n${executedContext.errors.map(subErr => subErr.stack).join('\n\n')}`;
338
337
  throw newErr;
package/cjs/config.js CHANGED
@@ -53,9 +53,9 @@ function customLoader(ext) {
53
53
  };
54
54
  }
55
55
  async function loadCodegenConfig({ configFilePath, moduleName, searchPlaces: additionalSearchPlaces, packageProp, loaders: customLoaders, }) {
56
- configFilePath || (configFilePath = process.cwd());
57
- moduleName || (moduleName = 'codegen');
58
- packageProp || (packageProp = moduleName);
56
+ configFilePath ||= process.cwd();
57
+ moduleName ||= 'codegen';
58
+ packageProp ||= moduleName;
59
59
  const cosmi = (0, cosmiconfig_1.cosmiconfig)(moduleName, {
60
60
  searchPlaces: generateSearchPlaces(moduleName).concat(additionalSearchPlaces || []),
61
61
  packageProp,
@@ -60,10 +60,10 @@ async function writePackage(answers, configLocation) {
60
60
  const pkgContent = (0, fs_1.readFileSync)(pkgPath, 'utf8');
61
61
  const pkg = JSON.parse(pkgContent);
62
62
  const { indent } = (0, detect_indent_1.default)(pkgContent);
63
- pkg.scripts || (pkg.scripts = {});
63
+ pkg.scripts ||= {};
64
64
  pkg.scripts[answers.script] = `graphql-codegen --config ${configLocation}`;
65
65
  // plugin
66
- pkg.devDependencies || (pkg.devDependencies = {});
66
+ pkg.devDependencies ||= {};
67
67
  await Promise.all((answers.plugins || []).map(async (plugin) => {
68
68
  pkg.devDependencies[plugin.package] = await (0, get_latest_version_js_1.getLatestVersion)(plugin.package);
69
69
  }));
package/cjs/presets.js CHANGED
@@ -12,10 +12,10 @@ async function getPresetByName(name, loader) {
12
12
  for (const moduleName of possibleNames) {
13
13
  try {
14
14
  const loaded = await loader(moduleName);
15
- if (loaded === null || loaded === void 0 ? void 0 : loaded.preset) {
15
+ if (loaded?.preset) {
16
16
  return loaded.preset;
17
17
  }
18
- if (loaded === null || loaded === void 0 ? void 0 : loaded.default) {
18
+ if (loaded?.default) {
19
19
  return loaded.default;
20
20
  }
21
21
  return loaded;
@@ -1,5 +1,4 @@
1
1
  "use strict";
2
- var _a, _b;
3
2
  Object.defineProperty(exports, "__esModule", { value: true });
4
3
  exports.AbortController = void 0;
5
4
  const events_1 = require("events");
@@ -61,7 +60,7 @@ class AbortSignalPolyfill {
61
60
  return controller.signal;
62
61
  }
63
62
  }
64
- const AbortSignal = (_a = global.AbortSignal) !== null && _a !== void 0 ? _a : AbortSignalPolyfill;
63
+ const AbortSignal = global.AbortSignal ?? AbortSignalPolyfill;
65
64
  class AbortControllerPolyfill {
66
65
  constructor() {
67
66
  (0, debugging_js_1.debugLog)('Using polyfilled AbortController');
@@ -91,5 +90,5 @@ class AbortControllerPolyfill {
91
90
  return 'AbortController';
92
91
  }
93
92
  }
94
- const AbortController = (_b = global.AbortController) !== null && _b !== void 0 ? _b : AbortControllerPolyfill;
93
+ const AbortController = global.AbortController ?? AbortControllerPolyfill;
95
94
  exports.AbortController = AbortController;
@@ -8,7 +8,7 @@ exports.isListrError = isListrError;
8
8
  function cliError(err, exitOnError = true) {
9
9
  let msg;
10
10
  if (err instanceof Error) {
11
- msg = err.message || err.toString();
11
+ msg = err;
12
12
  }
13
13
  else if (typeof err === 'string') {
14
14
  msg = err;
@@ -17,7 +17,7 @@ function setSilentLogger() {
17
17
  }
18
18
  exports.setSilentLogger = setSilentLogger;
19
19
  function useWinstonLogger() {
20
- if (logger === null || logger === void 0 ? void 0 : logger.levels) {
20
+ if (logger?.levels) {
21
21
  return;
22
22
  }
23
23
  logger = console;
@@ -96,11 +96,10 @@ exports.makeShouldRebuild = makeShouldRebuild;
96
96
  * mixed into the pattern set of each local config.
97
97
  */
98
98
  const makeGlobalPatternSet = (initialContext) => {
99
- var _a;
100
99
  const config = initialContext.getConfig();
101
100
  return {
102
101
  watch: (0, exports.sortPatterns)([
103
- ...(typeof config.watch === 'boolean' ? [] : (0, plugin_helpers_1.normalizeInstanceOrArray)((_a = config.watch) !== null && _a !== void 0 ? _a : [])),
102
+ ...(typeof config.watch === 'boolean' ? [] : (0, plugin_helpers_1.normalizeInstanceOrArray)(config.watch ?? [])),
104
103
  (0, path_1.relative)(process.cwd(), initialContext.filepath),
105
104
  ]),
106
105
  schemas: (0, exports.sortPatterns)(makePatternsFromSchemas((0, plugin_helpers_1.normalizeInstanceOrArray)(config.schema))),
@@ -33,7 +33,6 @@ const createWatcher = (initialContext, onNext) => {
33
33
  const shouldRebuild = (0, patterns_js_1.makeShouldRebuild)({ globalPatternSet, localPatternSets });
34
34
  let watcherSubscription;
35
35
  const runWatcher = async (abortSignal) => {
36
- var _a;
37
36
  const watchDirectory = await findHighestCommonDirectory(allAffirmativePatterns);
38
37
  const parcelWatcher = await Promise.resolve().then(() => tslib_1.__importStar(require('@parcel/watcher')));
39
38
  (0, debugging_js_1.debugLog)(`[Watcher] Parcel watcher loaded...`);
@@ -55,7 +54,7 @@ const createWatcher = (initialContext, onNext) => {
55
54
  // but we expect filename from config to be relative from cwd, so we need to convert
56
55
  const filenameRelativeFromWatchDirectory = (0, path_1.relative)(watchDirectory, (0, path_1.resolve)(process.cwd(), entry.filename));
57
56
  if (entry.config.preset) {
58
- const extension = (_a = entry.config.presetConfig) === null || _a === void 0 ? void 0 : _a.extension;
57
+ const extension = entry.config.presetConfig?.extension;
59
58
  if (extension) {
60
59
  ignored.push((0, path_1.join)(filenameRelativeFromWatchDirectory, '**', '*' + extension));
61
60
  }
@@ -177,7 +176,7 @@ const findHighestCommonDirectory = async (files) => {
177
176
  await (0, file_system_js_1.access)(maybeValidPath);
178
177
  return maybeValidPath;
179
178
  }
180
- catch (_a) {
179
+ catch {
181
180
  log(`[Watcher] Longest common prefix (${maybeValidPath}) is not accessible`);
182
181
  log(`[Watcher] Watching current working directory (${process.cwd()}) instead`);
183
182
  return process.cwd();
package/esm/codegen.js CHANGED
@@ -4,7 +4,6 @@ import { cpus } from 'os';
4
4
  import path from 'path';
5
5
  import { codegen } from '@graphql-codegen/core';
6
6
  import { getCachedDocumentNodeFromSchema, normalizeConfig, normalizeInstanceOrArray, normalizeOutputParam, } from '@graphql-codegen/plugin-helpers';
7
- import { AggregateError } from '@graphql-tools/utils';
8
7
  import { GraphQLError } from 'graphql';
9
8
  import { Listr } from 'listr2';
10
9
  import { ensureContext, shouldEmitLegacyCommonJSImports } from './config.js';
@@ -164,7 +163,7 @@ export async function executeCodegen(input) {
164
163
  ? await getPresetByName(outputConfig.preset, makeDefaultLoader(context.cwd))
165
164
  : outputConfig.preset
166
165
  : null;
167
- if (preset === null || preset === void 0 ? void 0 : preset.prepareDocuments) {
166
+ if (preset?.prepareDocuments) {
168
167
  outputSpecificDocuments = await preset.prepareDocuments(filename, outputSpecificDocuments);
169
168
  }
170
169
  return subTask.newListr([
package/esm/config.js CHANGED
@@ -48,9 +48,9 @@ function customLoader(ext) {
48
48
  };
49
49
  }
50
50
  export async function loadCodegenConfig({ configFilePath, moduleName, searchPlaces: additionalSearchPlaces, packageProp, loaders: customLoaders, }) {
51
- configFilePath || (configFilePath = process.cwd());
52
- moduleName || (moduleName = 'codegen');
53
- packageProp || (packageProp = moduleName);
51
+ configFilePath ||= process.cwd();
52
+ moduleName ||= 'codegen';
53
+ packageProp ||= moduleName;
54
54
  const cosmi = cosmiconfig(moduleName, {
55
55
  searchPlaces: generateSearchPlaces(moduleName).concat(additionalSearchPlaces || []),
56
56
  packageProp,
@@ -55,10 +55,10 @@ export async function writePackage(answers, configLocation) {
55
55
  const pkgContent = readFileSync(pkgPath, 'utf8');
56
56
  const pkg = JSON.parse(pkgContent);
57
57
  const { indent } = detectIndent(pkgContent);
58
- pkg.scripts || (pkg.scripts = {});
58
+ pkg.scripts ||= {};
59
59
  pkg.scripts[answers.script] = `graphql-codegen --config ${configLocation}`;
60
60
  // plugin
61
- pkg.devDependencies || (pkg.devDependencies = {});
61
+ pkg.devDependencies ||= {};
62
62
  await Promise.all((answers.plugins || []).map(async (plugin) => {
63
63
  pkg.devDependencies[plugin.package] = await getLatestVersion(plugin.package);
64
64
  }));
package/esm/presets.js CHANGED
@@ -9,10 +9,10 @@ export async function getPresetByName(name, loader) {
9
9
  for (const moduleName of possibleNames) {
10
10
  try {
11
11
  const loaded = await loader(moduleName);
12
- if (loaded === null || loaded === void 0 ? void 0 : loaded.preset) {
12
+ if (loaded?.preset) {
13
13
  return loaded.preset;
14
14
  }
15
- if (loaded === null || loaded === void 0 ? void 0 : loaded.default) {
15
+ if (loaded?.default) {
16
16
  return loaded.default;
17
17
  }
18
18
  return loaded;
@@ -1,4 +1,3 @@
1
- var _a, _b;
2
1
  import { EventEmitter } from 'events';
3
2
  import { debugLog } from './debugging.js';
4
3
  /**
@@ -58,7 +57,7 @@ class AbortSignalPolyfill {
58
57
  return controller.signal;
59
58
  }
60
59
  }
61
- const AbortSignal = (_a = global.AbortSignal) !== null && _a !== void 0 ? _a : AbortSignalPolyfill;
60
+ const AbortSignal = global.AbortSignal ?? AbortSignalPolyfill;
62
61
  class AbortControllerPolyfill {
63
62
  constructor() {
64
63
  debugLog('Using polyfilled AbortController');
@@ -88,5 +87,5 @@ class AbortControllerPolyfill {
88
87
  return 'AbortController';
89
88
  }
90
89
  }
91
- const AbortController = (_b = global.AbortController) !== null && _b !== void 0 ? _b : AbortControllerPolyfill;
90
+ const AbortController = global.AbortController ?? AbortControllerPolyfill;
92
91
  export { AbortController };
@@ -4,7 +4,7 @@ export function isListrError(err) {
4
4
  export function cliError(err, exitOnError = true) {
5
5
  let msg;
6
6
  if (err instanceof Error) {
7
- msg = err.message || err.toString();
7
+ msg = err;
8
8
  }
9
9
  else if (typeof err === 'string') {
10
10
  msg = err;
@@ -11,7 +11,7 @@ export function setSilentLogger() {
11
11
  logger = dummyLogger;
12
12
  }
13
13
  export function useWinstonLogger() {
14
- if (logger === null || logger === void 0 ? void 0 : logger.levels) {
14
+ if (logger?.levels) {
15
15
  return;
16
16
  }
17
17
  logger = console;
@@ -90,11 +90,10 @@ export const makeShouldRebuild = ({ globalPatternSet, localPatternSets, }) => {
90
90
  * mixed into the pattern set of each local config.
91
91
  */
92
92
  export const makeGlobalPatternSet = (initialContext) => {
93
- var _a;
94
93
  const config = initialContext.getConfig();
95
94
  return {
96
95
  watch: sortPatterns([
97
- ...(typeof config.watch === 'boolean' ? [] : normalizeInstanceOrArray((_a = config.watch) !== null && _a !== void 0 ? _a : [])),
96
+ ...(typeof config.watch === 'boolean' ? [] : normalizeInstanceOrArray(config.watch ?? [])),
98
97
  relative(process.cwd(), initialContext.filepath),
99
98
  ]),
100
99
  schemas: sortPatterns(makePatternsFromSchemas(normalizeInstanceOrArray(config.schema))),
@@ -29,7 +29,6 @@ export const createWatcher = (initialContext, onNext) => {
29
29
  const shouldRebuild = makeShouldRebuild({ globalPatternSet, localPatternSets });
30
30
  let watcherSubscription;
31
31
  const runWatcher = async (abortSignal) => {
32
- var _a;
33
32
  const watchDirectory = await findHighestCommonDirectory(allAffirmativePatterns);
34
33
  const parcelWatcher = await import('@parcel/watcher');
35
34
  debugLog(`[Watcher] Parcel watcher loaded...`);
@@ -51,7 +50,7 @@ export const createWatcher = (initialContext, onNext) => {
51
50
  // but we expect filename from config to be relative from cwd, so we need to convert
52
51
  const filenameRelativeFromWatchDirectory = relative(watchDirectory, resolve(process.cwd(), entry.filename));
53
52
  if (entry.config.preset) {
54
- const extension = (_a = entry.config.presetConfig) === null || _a === void 0 ? void 0 : _a.extension;
53
+ const extension = entry.config.presetConfig?.extension;
55
54
  if (extension) {
56
55
  ignored.push(join(filenameRelativeFromWatchDirectory, '**', '*' + extension));
57
56
  }
@@ -172,7 +171,7 @@ const findHighestCommonDirectory = async (files) => {
172
171
  await access(maybeValidPath);
173
172
  return maybeValidPath;
174
173
  }
175
- catch (_a) {
174
+ catch {
176
175
  log(`[Watcher] Longest common prefix (${maybeValidPath}) is not accessible`);
177
176
  log(`[Watcher] Watching current working directory (${process.cwd()}) instead`);
178
177
  return process.cwd();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphql-codegen/cli",
3
- "version": "3.3.2-rc-20230519121941-92ebcf71b",
3
+ "version": "3.3.2-rc-20230523141319-8e14665fd",
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
  },
@@ -8,25 +8,25 @@
8
8
  "@babel/generator": "^7.18.13",
9
9
  "@babel/template": "^7.18.10",
10
10
  "@babel/types": "^7.18.13",
11
- "@graphql-codegen/core": "^3.1.0",
12
- "@graphql-codegen/plugin-helpers": "4.2.1-rc-20230519121941-92ebcf71b",
13
- "@graphql-tools/apollo-engine-loader": "^7.3.6",
14
- "@graphql-tools/code-file-loader": "^7.3.17",
15
- "@graphql-tools/git-loader": "^7.2.13",
16
- "@graphql-tools/github-loader": "^7.3.28",
17
- "@graphql-tools/graphql-file-loader": "^7.5.0",
18
- "@graphql-tools/json-file-loader": "^7.4.1",
19
- "@graphql-tools/load": "^7.8.0",
20
- "@graphql-tools/prisma-loader": "^7.2.69",
21
- "@graphql-tools/url-loader": "^7.17.17",
22
- "@graphql-tools/utils": "^9.0.0",
11
+ "@graphql-codegen/core": "3.1.1-rc-20230523141319-8e14665fd",
12
+ "@graphql-codegen/plugin-helpers": "4.2.1-rc-20230523141319-8e14665fd",
13
+ "@graphql-tools/apollo-engine-loader": "^8.0.0",
14
+ "@graphql-tools/code-file-loader": "^8.0.0",
15
+ "@graphql-tools/git-loader": "^8.0.0",
16
+ "@graphql-tools/github-loader": "^8.0.0",
17
+ "@graphql-tools/graphql-file-loader": "^8.0.0",
18
+ "@graphql-tools/json-file-loader": "^8.0.0",
19
+ "@graphql-tools/load": "^8.0.0",
20
+ "@graphql-tools/prisma-loader": "^8.0.0",
21
+ "@graphql-tools/url-loader": "^8.0.0",
22
+ "@graphql-tools/utils": "^10.0.0",
23
23
  "@parcel/watcher": "^2.1.0",
24
24
  "@whatwg-node/fetch": "^0.8.0",
25
25
  "chalk": "^4.1.0",
26
- "cosmiconfig": "^7.0.0",
26
+ "cosmiconfig": "^8.1.3",
27
27
  "debounce": "^1.2.0",
28
28
  "detect-indent": "^6.0.0",
29
- "graphql-config": "^4.5.0",
29
+ "graphql-config": "^5.0.1",
30
30
  "inquirer": "^8.0.0",
31
31
  "is-glob": "^4.0.1",
32
32
  "jiti": "^1.17.1",