@graphql-codegen/cli 3.3.2-alpha-20230522172441-e282e8469 → 3.3.2-alpha-20230522233947-904521c12
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 +3 -2
- package/cjs/config.js +3 -3
- package/cjs/init/helpers.js +2 -2
- package/cjs/presets.js +2 -2
- package/cjs/utils/abort-controller-polyfill.js +3 -2
- package/cjs/utils/cli-error.js +1 -1
- package/cjs/utils/logger.js +1 -1
- package/cjs/utils/patterns.js +2 -1
- package/cjs/utils/watcher.js +3 -2
- package/esm/codegen.js +2 -1
- package/esm/config.js +3 -3
- package/esm/init/helpers.js +2 -2
- package/esm/presets.js +2 -2
- package/esm/utils/abort-controller-polyfill.js +3 -2
- package/esm/utils/cli-error.js +1 -1
- package/esm/utils/logger.js +1 -1
- package/esm/utils/patterns.js +2 -1
- package/esm/utils/watcher.js +3 -2
- package/package.json +15 -15
package/cjs/codegen.js
CHANGED
|
@@ -8,6 +8,7 @@ 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");
|
|
11
12
|
const graphql_1 = require("graphql");
|
|
12
13
|
const listr2_1 = require("listr2");
|
|
13
14
|
const config_js_1 = require("./config.js");
|
|
@@ -167,7 +168,7 @@ async function executeCodegen(input) {
|
|
|
167
168
|
? await (0, presets_js_1.getPresetByName)(outputConfig.preset, makeDefaultLoader(context.cwd))
|
|
168
169
|
: outputConfig.preset
|
|
169
170
|
: null;
|
|
170
|
-
if (preset
|
|
171
|
+
if (preset === null || preset === void 0 ? void 0 : preset.prepareDocuments) {
|
|
171
172
|
outputSpecificDocuments = await preset.prepareDocuments(filename, outputSpecificDocuments);
|
|
172
173
|
}
|
|
173
174
|
return subTask.newListr([
|
|
@@ -331,7 +332,7 @@ async function executeCodegen(input) {
|
|
|
331
332
|
}
|
|
332
333
|
if (executedContext.errors.length > 0) {
|
|
333
334
|
const errors = executedContext.errors.map(subErr => subErr.message || subErr.toString());
|
|
334
|
-
const newErr = new AggregateError(executedContext.errors, String(errors.join('\n\n')));
|
|
335
|
+
const newErr = new utils_1.AggregateError(executedContext.errors, String(errors.join('\n\n')));
|
|
335
336
|
// Best-effort to all stack traces for debugging
|
|
336
337
|
newErr.stack = `${newErr.stack}\n\n${executedContext.errors.map(subErr => subErr.stack).join('\n\n')}`;
|
|
337
338
|
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
|
|
57
|
-
moduleName
|
|
58
|
-
packageProp
|
|
56
|
+
configFilePath || (configFilePath = process.cwd());
|
|
57
|
+
moduleName || (moduleName = 'codegen');
|
|
58
|
+
packageProp || (packageProp = moduleName);
|
|
59
59
|
const cosmi = (0, cosmiconfig_1.cosmiconfig)(moduleName, {
|
|
60
60
|
searchPlaces: generateSearchPlaces(moduleName).concat(additionalSearchPlaces || []),
|
|
61
61
|
packageProp,
|
package/cjs/init/helpers.js
CHANGED
|
@@ -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
|
|
63
|
+
pkg.scripts || (pkg.scripts = {});
|
|
64
64
|
pkg.scripts[answers.script] = `graphql-codegen --config ${configLocation}`;
|
|
65
65
|
// plugin
|
|
66
|
-
pkg.devDependencies
|
|
66
|
+
pkg.devDependencies || (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
|
|
15
|
+
if (loaded === null || loaded === void 0 ? void 0 : loaded.preset) {
|
|
16
16
|
return loaded.preset;
|
|
17
17
|
}
|
|
18
|
-
if (loaded
|
|
18
|
+
if (loaded === null || loaded === void 0 ? void 0 : loaded.default) {
|
|
19
19
|
return loaded.default;
|
|
20
20
|
}
|
|
21
21
|
return loaded;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var _a, _b;
|
|
2
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
4
|
exports.AbortController = void 0;
|
|
4
5
|
const events_1 = require("events");
|
|
@@ -60,7 +61,7 @@ class AbortSignalPolyfill {
|
|
|
60
61
|
return controller.signal;
|
|
61
62
|
}
|
|
62
63
|
}
|
|
63
|
-
const AbortSignal = global.AbortSignal
|
|
64
|
+
const AbortSignal = (_a = global.AbortSignal) !== null && _a !== void 0 ? _a : AbortSignalPolyfill;
|
|
64
65
|
class AbortControllerPolyfill {
|
|
65
66
|
constructor() {
|
|
66
67
|
(0, debugging_js_1.debugLog)('Using polyfilled AbortController');
|
|
@@ -90,5 +91,5 @@ class AbortControllerPolyfill {
|
|
|
90
91
|
return 'AbortController';
|
|
91
92
|
}
|
|
92
93
|
}
|
|
93
|
-
const AbortController = global.AbortController
|
|
94
|
+
const AbortController = (_b = global.AbortController) !== null && _b !== void 0 ? _b : AbortControllerPolyfill;
|
|
94
95
|
exports.AbortController = AbortController;
|
package/cjs/utils/cli-error.js
CHANGED
package/cjs/utils/logger.js
CHANGED
package/cjs/utils/patterns.js
CHANGED
|
@@ -96,10 +96,11 @@ exports.makeShouldRebuild = makeShouldRebuild;
|
|
|
96
96
|
* mixed into the pattern set of each local config.
|
|
97
97
|
*/
|
|
98
98
|
const makeGlobalPatternSet = (initialContext) => {
|
|
99
|
+
var _a;
|
|
99
100
|
const config = initialContext.getConfig();
|
|
100
101
|
return {
|
|
101
102
|
watch: (0, exports.sortPatterns)([
|
|
102
|
-
...(typeof config.watch === 'boolean' ? [] : (0, plugin_helpers_1.normalizeInstanceOrArray)(config.watch
|
|
103
|
+
...(typeof config.watch === 'boolean' ? [] : (0, plugin_helpers_1.normalizeInstanceOrArray)((_a = config.watch) !== null && _a !== void 0 ? _a : [])),
|
|
103
104
|
(0, path_1.relative)(process.cwd(), initialContext.filepath),
|
|
104
105
|
]),
|
|
105
106
|
schemas: (0, exports.sortPatterns)(makePatternsFromSchemas((0, plugin_helpers_1.normalizeInstanceOrArray)(config.schema))),
|
package/cjs/utils/watcher.js
CHANGED
|
@@ -33,6 +33,7 @@ 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;
|
|
36
37
|
const watchDirectory = await findHighestCommonDirectory(allAffirmativePatterns);
|
|
37
38
|
const parcelWatcher = await Promise.resolve().then(() => tslib_1.__importStar(require('@parcel/watcher')));
|
|
38
39
|
(0, debugging_js_1.debugLog)(`[Watcher] Parcel watcher loaded...`);
|
|
@@ -54,7 +55,7 @@ const createWatcher = (initialContext, onNext) => {
|
|
|
54
55
|
// but we expect filename from config to be relative from cwd, so we need to convert
|
|
55
56
|
const filenameRelativeFromWatchDirectory = (0, path_1.relative)(watchDirectory, (0, path_1.resolve)(process.cwd(), entry.filename));
|
|
56
57
|
if (entry.config.preset) {
|
|
57
|
-
const extension = entry.config.presetConfig
|
|
58
|
+
const extension = (_a = entry.config.presetConfig) === null || _a === void 0 ? void 0 : _a.extension;
|
|
58
59
|
if (extension) {
|
|
59
60
|
ignored.push((0, path_1.join)(filenameRelativeFromWatchDirectory, '**', '*' + extension));
|
|
60
61
|
}
|
|
@@ -176,7 +177,7 @@ const findHighestCommonDirectory = async (files) => {
|
|
|
176
177
|
await (0, file_system_js_1.access)(maybeValidPath);
|
|
177
178
|
return maybeValidPath;
|
|
178
179
|
}
|
|
179
|
-
catch {
|
|
180
|
+
catch (_a) {
|
|
180
181
|
log(`[Watcher] Longest common prefix (${maybeValidPath}) is not accessible`);
|
|
181
182
|
log(`[Watcher] Watching current working directory (${process.cwd()}) instead`);
|
|
182
183
|
return process.cwd();
|
package/esm/codegen.js
CHANGED
|
@@ -4,6 +4,7 @@ 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';
|
|
7
8
|
import { GraphQLError } from 'graphql';
|
|
8
9
|
import { Listr } from 'listr2';
|
|
9
10
|
import { ensureContext, shouldEmitLegacyCommonJSImports } from './config.js';
|
|
@@ -163,7 +164,7 @@ export async function executeCodegen(input) {
|
|
|
163
164
|
? await getPresetByName(outputConfig.preset, makeDefaultLoader(context.cwd))
|
|
164
165
|
: outputConfig.preset
|
|
165
166
|
: null;
|
|
166
|
-
if (preset
|
|
167
|
+
if (preset === null || preset === void 0 ? void 0 : preset.prepareDocuments) {
|
|
167
168
|
outputSpecificDocuments = await preset.prepareDocuments(filename, outputSpecificDocuments);
|
|
168
169
|
}
|
|
169
170
|
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
|
|
52
|
-
moduleName
|
|
53
|
-
packageProp
|
|
51
|
+
configFilePath || (configFilePath = process.cwd());
|
|
52
|
+
moduleName || (moduleName = 'codegen');
|
|
53
|
+
packageProp || (packageProp = moduleName);
|
|
54
54
|
const cosmi = cosmiconfig(moduleName, {
|
|
55
55
|
searchPlaces: generateSearchPlaces(moduleName).concat(additionalSearchPlaces || []),
|
|
56
56
|
packageProp,
|
package/esm/init/helpers.js
CHANGED
|
@@ -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
|
|
58
|
+
pkg.scripts || (pkg.scripts = {});
|
|
59
59
|
pkg.scripts[answers.script] = `graphql-codegen --config ${configLocation}`;
|
|
60
60
|
// plugin
|
|
61
|
-
pkg.devDependencies
|
|
61
|
+
pkg.devDependencies || (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
|
|
12
|
+
if (loaded === null || loaded === void 0 ? void 0 : loaded.preset) {
|
|
13
13
|
return loaded.preset;
|
|
14
14
|
}
|
|
15
|
-
if (loaded
|
|
15
|
+
if (loaded === null || loaded === void 0 ? void 0 : loaded.default) {
|
|
16
16
|
return loaded.default;
|
|
17
17
|
}
|
|
18
18
|
return loaded;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
var _a, _b;
|
|
1
2
|
import { EventEmitter } from 'events';
|
|
2
3
|
import { debugLog } from './debugging.js';
|
|
3
4
|
/**
|
|
@@ -57,7 +58,7 @@ class AbortSignalPolyfill {
|
|
|
57
58
|
return controller.signal;
|
|
58
59
|
}
|
|
59
60
|
}
|
|
60
|
-
const AbortSignal = global.AbortSignal
|
|
61
|
+
const AbortSignal = (_a = global.AbortSignal) !== null && _a !== void 0 ? _a : AbortSignalPolyfill;
|
|
61
62
|
class AbortControllerPolyfill {
|
|
62
63
|
constructor() {
|
|
63
64
|
debugLog('Using polyfilled AbortController');
|
|
@@ -87,5 +88,5 @@ class AbortControllerPolyfill {
|
|
|
87
88
|
return 'AbortController';
|
|
88
89
|
}
|
|
89
90
|
}
|
|
90
|
-
const AbortController = global.AbortController
|
|
91
|
+
const AbortController = (_b = global.AbortController) !== null && _b !== void 0 ? _b : AbortControllerPolyfill;
|
|
91
92
|
export { AbortController };
|
package/esm/utils/cli-error.js
CHANGED
package/esm/utils/logger.js
CHANGED
package/esm/utils/patterns.js
CHANGED
|
@@ -90,10 +90,11 @@ 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;
|
|
93
94
|
const config = initialContext.getConfig();
|
|
94
95
|
return {
|
|
95
96
|
watch: sortPatterns([
|
|
96
|
-
...(typeof config.watch === 'boolean' ? [] : normalizeInstanceOrArray(config.watch
|
|
97
|
+
...(typeof config.watch === 'boolean' ? [] : normalizeInstanceOrArray((_a = config.watch) !== null && _a !== void 0 ? _a : [])),
|
|
97
98
|
relative(process.cwd(), initialContext.filepath),
|
|
98
99
|
]),
|
|
99
100
|
schemas: sortPatterns(makePatternsFromSchemas(normalizeInstanceOrArray(config.schema))),
|
package/esm/utils/watcher.js
CHANGED
|
@@ -29,6 +29,7 @@ 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;
|
|
32
33
|
const watchDirectory = await findHighestCommonDirectory(allAffirmativePatterns);
|
|
33
34
|
const parcelWatcher = await import('@parcel/watcher');
|
|
34
35
|
debugLog(`[Watcher] Parcel watcher loaded...`);
|
|
@@ -50,7 +51,7 @@ export const createWatcher = (initialContext, onNext) => {
|
|
|
50
51
|
// but we expect filename from config to be relative from cwd, so we need to convert
|
|
51
52
|
const filenameRelativeFromWatchDirectory = relative(watchDirectory, resolve(process.cwd(), entry.filename));
|
|
52
53
|
if (entry.config.preset) {
|
|
53
|
-
const extension = entry.config.presetConfig
|
|
54
|
+
const extension = (_a = entry.config.presetConfig) === null || _a === void 0 ? void 0 : _a.extension;
|
|
54
55
|
if (extension) {
|
|
55
56
|
ignored.push(join(filenameRelativeFromWatchDirectory, '**', '*' + extension));
|
|
56
57
|
}
|
|
@@ -171,7 +172,7 @@ const findHighestCommonDirectory = async (files) => {
|
|
|
171
172
|
await access(maybeValidPath);
|
|
172
173
|
return maybeValidPath;
|
|
173
174
|
}
|
|
174
|
-
catch {
|
|
175
|
+
catch (_a) {
|
|
175
176
|
log(`[Watcher] Longest common prefix (${maybeValidPath}) is not accessible`);
|
|
176
177
|
log(`[Watcher] Watching current working directory (${process.cwd()}) instead`);
|
|
177
178
|
return process.cwd();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-codegen/cli",
|
|
3
|
-
"version": "3.3.2-alpha-
|
|
3
|
+
"version": "3.3.2-alpha-20230522233947-904521c12",
|
|
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.
|
|
12
|
-
"@graphql-codegen/plugin-helpers": "4.2.1-alpha-
|
|
13
|
-
"@graphql-tools/apollo-engine-loader": "^
|
|
14
|
-
"@graphql-tools/code-file-loader": "^
|
|
15
|
-
"@graphql-tools/git-loader": "^
|
|
16
|
-
"@graphql-tools/github-loader": "^
|
|
17
|
-
"@graphql-tools/graphql-file-loader": "^
|
|
18
|
-
"@graphql-tools/json-file-loader": "^
|
|
19
|
-
"@graphql-tools/load": "^8.0
|
|
20
|
-
"@graphql-tools/prisma-loader": "^
|
|
21
|
-
"@graphql-tools/url-loader": "^
|
|
22
|
-
"@graphql-tools/utils": "^
|
|
11
|
+
"@graphql-codegen/core": "^3.1.0",
|
|
12
|
+
"@graphql-codegen/plugin-helpers": "4.2.1-alpha-20230522233947-904521c12",
|
|
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",
|
|
23
23
|
"@parcel/watcher": "^2.1.0",
|
|
24
24
|
"@whatwg-node/fetch": "^0.8.0",
|
|
25
25
|
"chalk": "^4.1.0",
|
|
26
|
-
"cosmiconfig": "^
|
|
26
|
+
"cosmiconfig": "^7.0.0",
|
|
27
27
|
"debounce": "^1.2.0",
|
|
28
28
|
"detect-indent": "^6.0.0",
|
|
29
|
-
"graphql-config": "^5.0
|
|
29
|
+
"graphql-config": "^4.5.0",
|
|
30
30
|
"inquirer": "^8.0.0",
|
|
31
31
|
"is-glob": "^4.0.1",
|
|
32
32
|
"jiti": "^1.17.1",
|