@depup/graphql-codegen__cli 6.2.1-depup.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/README.md +51 -0
- package/changes.json +90 -0
- package/cjs/bin.js +13 -0
- package/cjs/cli.js +64 -0
- package/cjs/codegen.js +388 -0
- package/cjs/config.js +370 -0
- package/cjs/documentTransforms.js +63 -0
- package/cjs/generate-and-save.js +153 -0
- package/cjs/graphql-config.js +67 -0
- package/cjs/hooks.js +93 -0
- package/cjs/index.js +13 -0
- package/cjs/init/helpers.js +90 -0
- package/cjs/init/index.js +62 -0
- package/cjs/init/plugins.js +136 -0
- package/cjs/init/questions.js +177 -0
- package/cjs/init/targets.js +45 -0
- package/cjs/init/types.js +15 -0
- package/cjs/load.js +102 -0
- package/cjs/package.json +1 -0
- package/cjs/plugins.js +43 -0
- package/cjs/presets.js +50 -0
- package/cjs/utils/abort-controller-polyfill.js +99 -0
- package/cjs/utils/cli-error.js +24 -0
- package/cjs/utils/debugging.js +22 -0
- package/cjs/utils/file-system.js +24 -0
- package/cjs/utils/get-latest-version.js +14 -0
- package/cjs/utils/helpers.js +12 -0
- package/cjs/utils/logger.js +24 -0
- package/cjs/utils/patterns.js +235 -0
- package/cjs/utils/watcher.js +244 -0
- package/esm/bin.js +11 -0
- package/esm/cli.js +37 -0
- package/esm/codegen.js +384 -0
- package/esm/config.js +357 -0
- package/esm/documentTransforms.js +59 -0
- package/esm/generate-and-save.js +149 -0
- package/esm/graphql-config.js +62 -0
- package/esm/hooks.js +89 -0
- package/esm/index.js +7 -0
- package/esm/init/helpers.js +82 -0
- package/esm/init/index.js +59 -0
- package/esm/init/plugins.js +133 -0
- package/esm/init/questions.js +172 -0
- package/esm/init/targets.js +42 -0
- package/esm/init/types.js +12 -0
- package/esm/load.js +97 -0
- package/esm/plugins.js +40 -0
- package/esm/presets.js +47 -0
- package/esm/utils/abort-controller-polyfill.js +96 -0
- package/esm/utils/cli-error.js +20 -0
- package/esm/utils/debugging.js +17 -0
- package/esm/utils/file-system.js +17 -0
- package/esm/utils/get-latest-version.js +11 -0
- package/esm/utils/helpers.js +9 -0
- package/esm/utils/logger.js +18 -0
- package/esm/utils/patterns.js +226 -0
- package/esm/utils/watcher.js +239 -0
- package/package.json +205 -0
- package/typings/bin.d.cts +2 -0
- package/typings/bin.d.ts +2 -0
- package/typings/cli.d.cts +2 -0
- package/typings/cli.d.ts +2 -0
- package/typings/codegen.d.cts +6 -0
- package/typings/codegen.d.ts +6 -0
- package/typings/config.d.cts +152 -0
- package/typings/config.d.ts +152 -0
- package/typings/documentTransforms.d.cts +3 -0
- package/typings/documentTransforms.d.ts +3 -0
- package/typings/generate-and-save.d.cts +10 -0
- package/typings/generate-and-save.d.ts +10 -0
- package/typings/graphql-config.d.cts +3 -0
- package/typings/graphql-config.d.ts +3 -0
- package/typings/hooks.d.cts +11 -0
- package/typings/hooks.d.ts +11 -0
- package/typings/index.d.cts +8 -0
- package/typings/index.d.ts +8 -0
- package/typings/init/helpers.d.cts +10 -0
- package/typings/init/helpers.d.ts +10 -0
- package/typings/init/index.d.cts +1 -0
- package/typings/init/index.d.ts +1 -0
- package/typings/init/plugins.d.cts +2 -0
- package/typings/init/plugins.d.ts +2 -0
- package/typings/init/questions.d.cts +13 -0
- package/typings/init/questions.d.ts +13 -0
- package/typings/init/targets.d.cts +2 -0
- package/typings/init/targets.d.ts +2 -0
- package/typings/init/types.d.cts +30 -0
- package/typings/init/types.d.ts +30 -0
- package/typings/load.d.cts +15 -0
- package/typings/load.d.ts +15 -0
- package/typings/plugins.d.cts +2 -0
- package/typings/plugins.d.ts +2 -0
- package/typings/presets.d.cts +5 -0
- package/typings/presets.d.ts +5 -0
- package/typings/utils/abort-controller-polyfill.d.cts +5 -0
- package/typings/utils/abort-controller-polyfill.d.ts +5 -0
- package/typings/utils/cli-error.d.cts +10 -0
- package/typings/utils/cli-error.d.ts +10 -0
- package/typings/utils/debugging.d.cts +3 -0
- package/typings/utils/debugging.d.ts +3 -0
- package/typings/utils/file-system.d.cts +8 -0
- package/typings/utils/file-system.d.ts +8 -0
- package/typings/utils/get-latest-version.d.cts +6 -0
- package/typings/utils/get-latest-version.d.ts +6 -0
- package/typings/utils/helpers.d.cts +1 -0
- package/typings/utils/helpers.d.ts +1 -0
- package/typings/utils/logger.d.cts +5 -0
- package/typings/utils/logger.d.ts +5 -0
- package/typings/utils/patterns.d.cts +91 -0
- package/typings/utils/patterns.d.ts +91 -0
- package/typings/utils/watcher.d.cts +16 -0
- package/typings/utils/watcher.d.ts +16 -0
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
import { join, isAbsolute, relative, resolve, sep } from 'path';
|
|
2
|
+
import { normalizeOutputParam } from '@graphql-codegen/plugin-helpers';
|
|
3
|
+
import debounce from 'debounce';
|
|
4
|
+
import mm from 'micromatch';
|
|
5
|
+
import logSymbols from 'log-symbols';
|
|
6
|
+
import { executeCodegen } from '../codegen.js';
|
|
7
|
+
import { loadContext } from '../config.js';
|
|
8
|
+
import { lifecycleHooks } from '../hooks.js';
|
|
9
|
+
import { access } from './file-system.js';
|
|
10
|
+
import { debugLog } from './debugging.js';
|
|
11
|
+
import { getLogger } from './logger.js';
|
|
12
|
+
import { allAffirmativePatternsFromPatternSets, makeGlobalPatternSet, makeLocalPatternSet, makeShouldRebuild, } from './patterns.js';
|
|
13
|
+
import { AbortController } from './abort-controller-polyfill.js';
|
|
14
|
+
function log(msg) {
|
|
15
|
+
// double spaces to inline the message with Listr
|
|
16
|
+
getLogger().info(` ${msg}`);
|
|
17
|
+
}
|
|
18
|
+
function emitWatching(watchDir) {
|
|
19
|
+
log(`${logSymbols.info} Watching for changes in ${watchDir}...`);
|
|
20
|
+
}
|
|
21
|
+
export const createWatcher = (initialContext, onNext) => {
|
|
22
|
+
debugLog(`[Watcher] Starting watcher...`);
|
|
23
|
+
let config = initialContext.getConfig();
|
|
24
|
+
const globalPatternSet = makeGlobalPatternSet(initialContext);
|
|
25
|
+
const localPatternSets = Object.keys(config.generates)
|
|
26
|
+
.map(filename => normalizeOutputParam(config.generates[filename]))
|
|
27
|
+
.map(conf => makeLocalPatternSet(conf));
|
|
28
|
+
const allAffirmativePatterns = allAffirmativePatternsFromPatternSets([globalPatternSet, ...localPatternSets]);
|
|
29
|
+
const shouldRebuild = makeShouldRebuild({ globalPatternSet, localPatternSets });
|
|
30
|
+
let watcherSubscription;
|
|
31
|
+
const runWatcher = async (abortSignal) => {
|
|
32
|
+
const watchDirectory = await findHighestCommonDirectory(allAffirmativePatterns);
|
|
33
|
+
// Try to load the parcel watcher, but don't fail if it's not available.
|
|
34
|
+
let parcelWatcher;
|
|
35
|
+
try {
|
|
36
|
+
parcelWatcher = await import('@parcel/watcher');
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
log('Failed to import @parcel/watcher.\n To use watch mode, install https://www.npmjs.com/package/@parcel/watcher.');
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
debugLog(`[Watcher] Parcel watcher loaded...`);
|
|
43
|
+
let isShutdown = false;
|
|
44
|
+
const debouncedExec = debounce(() => {
|
|
45
|
+
if (!isShutdown) {
|
|
46
|
+
executeCodegen(initialContext)
|
|
47
|
+
.then(({ result, error }) => {
|
|
48
|
+
// FIXME: this is a quick fix to stop `onNext` (writeOutput) from
|
|
49
|
+
// removing all files when there is an error.
|
|
50
|
+
//
|
|
51
|
+
// This is because `removeStaleFiles()` will remove files if the
|
|
52
|
+
// generated files are different between runs. And on error, it
|
|
53
|
+
// returns an empty array i.e. will remove all generated files from
|
|
54
|
+
// the previous run
|
|
55
|
+
//
|
|
56
|
+
// This also means we don't have config.allowPartialOutputs in watch mode
|
|
57
|
+
if (error) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
onNext(result);
|
|
61
|
+
}, () => Promise.resolve())
|
|
62
|
+
.then(() => emitWatching(watchDirectory));
|
|
63
|
+
}
|
|
64
|
+
}, 100);
|
|
65
|
+
emitWatching(watchDirectory);
|
|
66
|
+
const ignored = ['**/.git/**'];
|
|
67
|
+
for (const entry of Object.keys(config.generates).map(filename => ({
|
|
68
|
+
filename,
|
|
69
|
+
config: normalizeOutputParam(config.generates[filename]),
|
|
70
|
+
}))) {
|
|
71
|
+
// ParcelWatcher expects relative ignore patterns to be relative from watchDirectory,
|
|
72
|
+
// but we expect filename from config to be relative from cwd, so we need to convert
|
|
73
|
+
const filenameRelativeFromWatchDirectory = relative(watchDirectory, resolve(process.cwd(), entry.filename));
|
|
74
|
+
if (entry.config.preset) {
|
|
75
|
+
const extension = entry.config.presetConfig?.extension;
|
|
76
|
+
if (extension) {
|
|
77
|
+
ignored.push(join(filenameRelativeFromWatchDirectory, '**', '*' + extension));
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
ignored.push(filenameRelativeFromWatchDirectory);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
watcherSubscription = await parcelWatcher.subscribe(watchDirectory, async (_, events) => {
|
|
85
|
+
// it doesn't matter what has changed, need to run whole process anyway
|
|
86
|
+
await Promise.all(
|
|
87
|
+
// NOTE: @parcel/watcher always provides path as an absolute path
|
|
88
|
+
events.map(async ({ type: eventName, path }) => {
|
|
89
|
+
if (!shouldRebuild({ path })) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
lifecycleHooks(config.hooks).onWatchTriggered(eventName, path);
|
|
93
|
+
debugLog(`[Watcher] triggered due to a file ${eventName} event: ${path}`);
|
|
94
|
+
// In ESM require is not defined
|
|
95
|
+
try {
|
|
96
|
+
delete require.cache[path];
|
|
97
|
+
}
|
|
98
|
+
catch { }
|
|
99
|
+
if (eventName === 'update' && config.configFilePath && path === config.configFilePath) {
|
|
100
|
+
log(`${logSymbols.info} Config file has changed, reloading...`);
|
|
101
|
+
const context = await loadContext(config.configFilePath);
|
|
102
|
+
const newParsedConfig = context.getConfig();
|
|
103
|
+
newParsedConfig.watch = config.watch;
|
|
104
|
+
newParsedConfig.silent = config.silent;
|
|
105
|
+
newParsedConfig.overwrite = config.overwrite;
|
|
106
|
+
newParsedConfig.configFilePath = config.configFilePath;
|
|
107
|
+
config = newParsedConfig;
|
|
108
|
+
initialContext.updateConfig(config);
|
|
109
|
+
}
|
|
110
|
+
debouncedExec();
|
|
111
|
+
}));
|
|
112
|
+
}, { ignore: ignored });
|
|
113
|
+
debugLog(`[Watcher] Started`);
|
|
114
|
+
const shutdown = (
|
|
115
|
+
/** Optional callback to execute after shutdown has completed its async tasks */
|
|
116
|
+
afterShutdown) => {
|
|
117
|
+
isShutdown = true;
|
|
118
|
+
debugLog(`[Watcher] Shutting down`);
|
|
119
|
+
log(`Shutting down watch...`);
|
|
120
|
+
const pendingUnsubscribe = watcherSubscription.unsubscribe();
|
|
121
|
+
const pendingBeforeDoneHook = lifecycleHooks(config.hooks).beforeDone();
|
|
122
|
+
if (afterShutdown && typeof afterShutdown === 'function') {
|
|
123
|
+
Promise.allSettled([pendingUnsubscribe, pendingBeforeDoneHook]).then(afterShutdown);
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
abortSignal.addEventListener('abort', () => shutdown(abortSignal.reason));
|
|
127
|
+
process.once('SIGINT', () => shutdown());
|
|
128
|
+
process.once('SIGTERM', () => shutdown());
|
|
129
|
+
};
|
|
130
|
+
// Use an AbortController for shutdown signals
|
|
131
|
+
// NOTE: This will be polyfilled on Node 14 (or any environment without it defined)
|
|
132
|
+
const abortController = new AbortController();
|
|
133
|
+
/**
|
|
134
|
+
* Send shutdown signal and return a promise that only resolves after the
|
|
135
|
+
* runningWatcher has resolved, which only resolved after the shutdown signal has been handled
|
|
136
|
+
*/
|
|
137
|
+
const stopWatching = async function () {
|
|
138
|
+
// stopWatching.afterShutdown is lazily set to resolve pendingShutdown promise
|
|
139
|
+
abortController.abort(stopWatching.afterShutdown);
|
|
140
|
+
// SUBTLE: runningWatcher waits for pendingShutdown before it resolves itself, so
|
|
141
|
+
// by awaiting it here, we are awaiting both the shutdown handler, and runningWatcher itself
|
|
142
|
+
await stopWatching.runningWatcher;
|
|
143
|
+
};
|
|
144
|
+
stopWatching.afterShutdown = () => {
|
|
145
|
+
debugLog('Shutdown watcher before it started');
|
|
146
|
+
};
|
|
147
|
+
stopWatching.runningWatcher = Promise.resolve();
|
|
148
|
+
/** Promise will resolve after the shutdown() handler completes */
|
|
149
|
+
const pendingShutdown = new Promise(afterShutdown => {
|
|
150
|
+
// afterShutdown will be passed to shutdown() handler via abortSignal.reason
|
|
151
|
+
stopWatching.afterShutdown = afterShutdown;
|
|
152
|
+
});
|
|
153
|
+
/**
|
|
154
|
+
* Promise that resolves after the watch server has shutdown, either because
|
|
155
|
+
* stopWatching() was called or there was an error inside it
|
|
156
|
+
*/
|
|
157
|
+
stopWatching.runningWatcher = new Promise((resolve, reject) => {
|
|
158
|
+
executeCodegen(initialContext)
|
|
159
|
+
.then(({ result, error }) => {
|
|
160
|
+
// TODO: this is the initial run, the logic here mimics the above watcher logic.
|
|
161
|
+
// We need to check whether it's ok to deviate between these two.
|
|
162
|
+
if (error) {
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
onNext(result);
|
|
166
|
+
}, () => Promise.resolve())
|
|
167
|
+
.then(() => runWatcher(abortController.signal))
|
|
168
|
+
.catch(err => {
|
|
169
|
+
watcherSubscription.unsubscribe();
|
|
170
|
+
reject(err);
|
|
171
|
+
})
|
|
172
|
+
.then(() => pendingShutdown)
|
|
173
|
+
.finally(() => {
|
|
174
|
+
debugLog('Done watching.');
|
|
175
|
+
resolve();
|
|
176
|
+
});
|
|
177
|
+
});
|
|
178
|
+
return {
|
|
179
|
+
stopWatching,
|
|
180
|
+
runningWatcher: stopWatching.runningWatcher,
|
|
181
|
+
};
|
|
182
|
+
};
|
|
183
|
+
/**
|
|
184
|
+
* Given a list of file paths (each of which may be absolute, or relative from
|
|
185
|
+
* `process.cwd()`), find absolute path of the "highest" common directory,
|
|
186
|
+
* i.e. the directory that contains all the files in the list.
|
|
187
|
+
*
|
|
188
|
+
* @param files List of relative and/or absolute file paths (or micromatch patterns)
|
|
189
|
+
*/
|
|
190
|
+
const findHighestCommonDirectory = async (files) => {
|
|
191
|
+
// Map files to a list of basePaths, where "base" is the result of mm.scan(pathOrPattern)
|
|
192
|
+
// e.g. mm.scan("/**/foo/bar").base -> "/" ; mm.scan("/foo/bar/**/fizz/*.graphql") -> /foo/bar
|
|
193
|
+
const dirPaths = files
|
|
194
|
+
.map(filePath => (isAbsolute(filePath) ? filePath : resolve(filePath)))
|
|
195
|
+
// mm.scan doesn't know how to handle Windows \ path separator
|
|
196
|
+
.map(patterned => patterned.replace(/\\/g, '/'))
|
|
197
|
+
.map(patterned => mm.scan(patterned).base)
|
|
198
|
+
// revert the separators to the platform-supported ones
|
|
199
|
+
.map(base => base.replace(/\//g, sep));
|
|
200
|
+
// Return longest common prefix if it's accessible, otherwise process.cwd()
|
|
201
|
+
return (async (maybeValidPath) => {
|
|
202
|
+
debugLog(`[Watcher] Longest common prefix of all files: ${maybeValidPath}...`);
|
|
203
|
+
try {
|
|
204
|
+
await access(maybeValidPath);
|
|
205
|
+
return maybeValidPath;
|
|
206
|
+
}
|
|
207
|
+
catch {
|
|
208
|
+
log(`[Watcher] Longest common prefix (${maybeValidPath}) is not accessible`);
|
|
209
|
+
log(`[Watcher] Watching current working directory (${process.cwd()}) instead`);
|
|
210
|
+
return process.cwd();
|
|
211
|
+
}
|
|
212
|
+
})(longestCommonPrefix(dirPaths.map(path => path.split(sep))).join(sep));
|
|
213
|
+
};
|
|
214
|
+
/**
|
|
215
|
+
* Find the longest common prefix of an array of paths, where each item in
|
|
216
|
+
* the array an array of path segments which comprise an absolute path when
|
|
217
|
+
* joined together by a path separator
|
|
218
|
+
*
|
|
219
|
+
* Adapted from:
|
|
220
|
+
* https://duncan-mcardle.medium.com/leetcode-problem-14-longest-common-prefix-javascript-3bc6a2f777c4
|
|
221
|
+
*
|
|
222
|
+
* @param splitPaths An array of arrays, where each item is a path split by its separator
|
|
223
|
+
* @returns An array of path segments representing the longest common prefix of splitPaths
|
|
224
|
+
*/
|
|
225
|
+
const longestCommonPrefix = (splitPaths) => {
|
|
226
|
+
// Return early on empty input
|
|
227
|
+
if (!splitPaths.length) {
|
|
228
|
+
return [];
|
|
229
|
+
}
|
|
230
|
+
// Loop through the segments of the first path
|
|
231
|
+
for (let i = 0; i <= splitPaths[0].length; i++) {
|
|
232
|
+
// Check if this path segment is present in the same position of every path
|
|
233
|
+
if (!splitPaths.every(string => string[i] === splitPaths[0][i])) {
|
|
234
|
+
// If not, return the path segments up to and including the previous segment
|
|
235
|
+
return splitPaths[0].slice(0, i);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
return splitPaths[0];
|
|
239
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@depup/graphql-codegen__cli",
|
|
3
|
+
"version": "6.2.1-depup.0",
|
|
4
|
+
"peerDependenciesMeta": {
|
|
5
|
+
"@parcel/watcher": {
|
|
6
|
+
"optional": true
|
|
7
|
+
}
|
|
8
|
+
},
|
|
9
|
+
"peerDependencies": {
|
|
10
|
+
"@parcel/watcher": "^2.1.0",
|
|
11
|
+
"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"
|
|
12
|
+
},
|
|
13
|
+
"dependencies": {
|
|
14
|
+
"@babel/generator": "^7.29.1",
|
|
15
|
+
"@babel/template": "^7.28.6",
|
|
16
|
+
"@babel/types": "^7.29.0",
|
|
17
|
+
"@graphql-codegen/client-preset": "^5.2.4",
|
|
18
|
+
"@graphql-codegen/core": "^5.0.1",
|
|
19
|
+
"@graphql-codegen/plugin-helpers": "^6.2.0",
|
|
20
|
+
"@graphql-tools/apollo-engine-loader": "^8.0.28",
|
|
21
|
+
"@graphql-tools/code-file-loader": "^8.1.28",
|
|
22
|
+
"@graphql-tools/git-loader": "^8.0.32",
|
|
23
|
+
"@graphql-tools/github-loader": "^9.0.6",
|
|
24
|
+
"@graphql-tools/graphql-file-loader": "^8.1.12",
|
|
25
|
+
"@graphql-tools/json-file-loader": "^8.0.26",
|
|
26
|
+
"@graphql-tools/load": "^8.1.8",
|
|
27
|
+
"@graphql-tools/url-loader": "^9.0.6",
|
|
28
|
+
"@graphql-tools/merge": "^9.1.7",
|
|
29
|
+
"@graphql-tools/utils": "^11.0.0",
|
|
30
|
+
"@inquirer/prompts": "^8.3.2",
|
|
31
|
+
"@whatwg-node/fetch": "^0.10.13",
|
|
32
|
+
"chalk": "^5.6.2",
|
|
33
|
+
"cosmiconfig": "^9.0.1",
|
|
34
|
+
"debounce": "^3.0.0",
|
|
35
|
+
"detect-indent": "^7.0.2",
|
|
36
|
+
"graphql-config": "^5.1.6",
|
|
37
|
+
"is-glob": "^4.0.3",
|
|
38
|
+
"jiti": "^2.6.1",
|
|
39
|
+
"json-to-pretty-yaml": "^1.2.2",
|
|
40
|
+
"listr2": "^10.2.1",
|
|
41
|
+
"log-symbols": "^7.0.1",
|
|
42
|
+
"micromatch": "^4.0.8",
|
|
43
|
+
"shell-quote": "^1.8.3",
|
|
44
|
+
"string-env-interpolation": "^1.0.1",
|
|
45
|
+
"ts-log": "^2.2.7",
|
|
46
|
+
"tslib": "^2.8.1",
|
|
47
|
+
"yaml": "^2.8.2",
|
|
48
|
+
"yargs": "^18.0.0"
|
|
49
|
+
},
|
|
50
|
+
"repository": {
|
|
51
|
+
"type": "git",
|
|
52
|
+
"url": "https://github.com/dotansimha/graphql-code-generator.git",
|
|
53
|
+
"directory": "packages/graphql-codegen-cli"
|
|
54
|
+
},
|
|
55
|
+
"homepage": "https://github.com/dotansimha/graphql-code-generator#readme",
|
|
56
|
+
"keywords": [
|
|
57
|
+
"depup",
|
|
58
|
+
"dependency-bumped",
|
|
59
|
+
"updated-deps",
|
|
60
|
+
"@graphql-codegen/cli",
|
|
61
|
+
"gql",
|
|
62
|
+
"generator",
|
|
63
|
+
"code",
|
|
64
|
+
"types",
|
|
65
|
+
"interfaces",
|
|
66
|
+
"graphql",
|
|
67
|
+
"codegen",
|
|
68
|
+
"apollo",
|
|
69
|
+
"node",
|
|
70
|
+
"typescript",
|
|
71
|
+
"ts",
|
|
72
|
+
"flow",
|
|
73
|
+
"d.ts",
|
|
74
|
+
"typings"
|
|
75
|
+
],
|
|
76
|
+
"author": "Dotan Simha <dotansimha@gmail.com>",
|
|
77
|
+
"license": "MIT",
|
|
78
|
+
"engines": {
|
|
79
|
+
"node": ">=16"
|
|
80
|
+
},
|
|
81
|
+
"main": "cjs/index.js",
|
|
82
|
+
"module": "esm/index.js",
|
|
83
|
+
"typings": "typings/index.d.ts",
|
|
84
|
+
"typescript": {
|
|
85
|
+
"definition": "typings/index.d.ts"
|
|
86
|
+
},
|
|
87
|
+
"type": "module",
|
|
88
|
+
"exports": {
|
|
89
|
+
".": {
|
|
90
|
+
"require": {
|
|
91
|
+
"types": "./typings/index.d.cts",
|
|
92
|
+
"default": "./cjs/index.js"
|
|
93
|
+
},
|
|
94
|
+
"import": {
|
|
95
|
+
"types": "./typings/index.d.ts",
|
|
96
|
+
"default": "./esm/index.js"
|
|
97
|
+
},
|
|
98
|
+
"default": {
|
|
99
|
+
"types": "./typings/index.d.ts",
|
|
100
|
+
"default": "./esm/index.js"
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
"./package.json": "./package.json"
|
|
104
|
+
},
|
|
105
|
+
"bin": {
|
|
106
|
+
"gql-gen": "cjs/bin.js",
|
|
107
|
+
"graphql-codegen": "cjs/bin.js",
|
|
108
|
+
"graphql-code-generator": "cjs/bin.js",
|
|
109
|
+
"graphql-codegen-esm": "esm/bin.js"
|
|
110
|
+
},
|
|
111
|
+
"description": "[DepUp] Dependency-bumped version of @graphql-codegen/cli",
|
|
112
|
+
"depup": {
|
|
113
|
+
"changes": {
|
|
114
|
+
"@babel/generator": {
|
|
115
|
+
"from": "^7.18.13",
|
|
116
|
+
"to": "^7.29.1"
|
|
117
|
+
},
|
|
118
|
+
"@babel/template": {
|
|
119
|
+
"from": "^7.18.10",
|
|
120
|
+
"to": "^7.28.6"
|
|
121
|
+
},
|
|
122
|
+
"@babel/types": {
|
|
123
|
+
"from": "^7.18.13",
|
|
124
|
+
"to": "^7.29.0"
|
|
125
|
+
},
|
|
126
|
+
"@graphql-tools/graphql-file-loader": {
|
|
127
|
+
"from": "^8.1.11",
|
|
128
|
+
"to": "^8.1.12"
|
|
129
|
+
},
|
|
130
|
+
"@graphql-tools/merge": {
|
|
131
|
+
"from": "^9.0.6",
|
|
132
|
+
"to": "^9.1.7"
|
|
133
|
+
},
|
|
134
|
+
"@inquirer/prompts": {
|
|
135
|
+
"from": "^7.8.2",
|
|
136
|
+
"to": "^8.3.2"
|
|
137
|
+
},
|
|
138
|
+
"@whatwg-node/fetch": {
|
|
139
|
+
"from": "^0.10.0",
|
|
140
|
+
"to": "^0.10.13"
|
|
141
|
+
},
|
|
142
|
+
"chalk": {
|
|
143
|
+
"from": "^4.1.0",
|
|
144
|
+
"to": "^5.6.2"
|
|
145
|
+
},
|
|
146
|
+
"cosmiconfig": {
|
|
147
|
+
"from": "^9.0.0",
|
|
148
|
+
"to": "^9.0.1"
|
|
149
|
+
},
|
|
150
|
+
"debounce": {
|
|
151
|
+
"from": "^2.0.0",
|
|
152
|
+
"to": "^3.0.0"
|
|
153
|
+
},
|
|
154
|
+
"detect-indent": {
|
|
155
|
+
"from": "^6.0.0",
|
|
156
|
+
"to": "^7.0.2"
|
|
157
|
+
},
|
|
158
|
+
"is-glob": {
|
|
159
|
+
"from": "^4.0.1",
|
|
160
|
+
"to": "^4.0.3"
|
|
161
|
+
},
|
|
162
|
+
"jiti": {
|
|
163
|
+
"from": "^2.3.0",
|
|
164
|
+
"to": "^2.6.1"
|
|
165
|
+
},
|
|
166
|
+
"listr2": {
|
|
167
|
+
"from": "^9.0.0",
|
|
168
|
+
"to": "^10.2.1"
|
|
169
|
+
},
|
|
170
|
+
"log-symbols": {
|
|
171
|
+
"from": "^4.0.0",
|
|
172
|
+
"to": "^7.0.1"
|
|
173
|
+
},
|
|
174
|
+
"micromatch": {
|
|
175
|
+
"from": "^4.0.5",
|
|
176
|
+
"to": "^4.0.8"
|
|
177
|
+
},
|
|
178
|
+
"shell-quote": {
|
|
179
|
+
"from": "^1.7.3",
|
|
180
|
+
"to": "^1.8.3"
|
|
181
|
+
},
|
|
182
|
+
"ts-log": {
|
|
183
|
+
"from": "^2.2.3",
|
|
184
|
+
"to": "^2.2.7"
|
|
185
|
+
},
|
|
186
|
+
"tslib": {
|
|
187
|
+
"from": "^2.4.0",
|
|
188
|
+
"to": "^2.8.1"
|
|
189
|
+
},
|
|
190
|
+
"yaml": {
|
|
191
|
+
"from": "^2.3.1",
|
|
192
|
+
"to": "^2.8.2"
|
|
193
|
+
},
|
|
194
|
+
"yargs": {
|
|
195
|
+
"from": "^17.0.0",
|
|
196
|
+
"to": "^18.0.0"
|
|
197
|
+
}
|
|
198
|
+
},
|
|
199
|
+
"depsUpdated": 21,
|
|
200
|
+
"originalPackage": "@graphql-codegen/cli",
|
|
201
|
+
"originalVersion": "6.2.1",
|
|
202
|
+
"processedAt": "2026-03-17T16:31:36.885Z",
|
|
203
|
+
"smokeTest": "passed"
|
|
204
|
+
}
|
|
205
|
+
}
|
package/typings/bin.d.ts
ADDED
package/typings/cli.d.ts
ADDED
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { Profiler, Types } from '@graphql-codegen/plugin-helpers';
|
|
2
|
+
import { GraphQLSchema } from 'graphql';
|
|
3
|
+
import { GraphQLConfig } from 'graphql-config';
|
|
4
|
+
export type CodegenConfig = Types.Config;
|
|
5
|
+
export type YamlCliFlags = {
|
|
6
|
+
config: string;
|
|
7
|
+
watch: boolean | string | string[];
|
|
8
|
+
require: string[];
|
|
9
|
+
overwrite: boolean;
|
|
10
|
+
project: string;
|
|
11
|
+
silent: boolean;
|
|
12
|
+
errorsOnly: boolean;
|
|
13
|
+
profile: boolean;
|
|
14
|
+
check?: boolean;
|
|
15
|
+
verbose?: boolean;
|
|
16
|
+
debug?: boolean;
|
|
17
|
+
ignoreNoDocuments?: boolean;
|
|
18
|
+
emitLegacyCommonJSImports?: boolean;
|
|
19
|
+
importExtension?: '' | `.${string}`;
|
|
20
|
+
};
|
|
21
|
+
export declare function generateSearchPlaces(moduleName: string): string[];
|
|
22
|
+
export type CodegenConfigLoader = (filepath: string, content: string) => Promise<Types.Config> | Types.Config;
|
|
23
|
+
export interface LoadCodegenConfigOptions {
|
|
24
|
+
/**
|
|
25
|
+
* The path to the config file or directory contains the config file.
|
|
26
|
+
* @default process.cwd()
|
|
27
|
+
*/
|
|
28
|
+
configFilePath?: string;
|
|
29
|
+
/**
|
|
30
|
+
* The name of the config file
|
|
31
|
+
* @default codegen
|
|
32
|
+
*/
|
|
33
|
+
moduleName?: string;
|
|
34
|
+
/**
|
|
35
|
+
* Additional search paths for the config file you want to check
|
|
36
|
+
*/
|
|
37
|
+
searchPlaces?: string[];
|
|
38
|
+
/**
|
|
39
|
+
* @default codegen
|
|
40
|
+
*/
|
|
41
|
+
packageProp?: string;
|
|
42
|
+
/**
|
|
43
|
+
* Overrides or extends the loaders for specific file extensions
|
|
44
|
+
*/
|
|
45
|
+
loaders?: Record<string, CodegenConfigLoader>;
|
|
46
|
+
}
|
|
47
|
+
export interface LoadCodegenConfigResult {
|
|
48
|
+
filepath: string;
|
|
49
|
+
config: Types.Config;
|
|
50
|
+
isEmpty?: boolean;
|
|
51
|
+
}
|
|
52
|
+
export declare function loadCodegenConfig({ configFilePath, moduleName, searchPlaces: additionalSearchPlaces, packageProp, loaders: customLoaders, }: LoadCodegenConfigOptions): Promise<LoadCodegenConfigResult>;
|
|
53
|
+
export declare function loadContext(configFilePath?: string): Promise<CodegenContext> | never;
|
|
54
|
+
export declare function buildOptions(): {
|
|
55
|
+
c: {
|
|
56
|
+
alias: string;
|
|
57
|
+
type: "string";
|
|
58
|
+
describe: string;
|
|
59
|
+
};
|
|
60
|
+
w: {
|
|
61
|
+
alias: string;
|
|
62
|
+
describe: string;
|
|
63
|
+
coerce(watch: any): string | boolean | any[];
|
|
64
|
+
};
|
|
65
|
+
r: {
|
|
66
|
+
alias: string;
|
|
67
|
+
describe: string;
|
|
68
|
+
type: "array";
|
|
69
|
+
default: any[];
|
|
70
|
+
};
|
|
71
|
+
o: {
|
|
72
|
+
alias: string;
|
|
73
|
+
describe: string;
|
|
74
|
+
type: "boolean";
|
|
75
|
+
};
|
|
76
|
+
s: {
|
|
77
|
+
alias: string;
|
|
78
|
+
describe: string;
|
|
79
|
+
type: "boolean";
|
|
80
|
+
};
|
|
81
|
+
e: {
|
|
82
|
+
alias: string;
|
|
83
|
+
describe: string;
|
|
84
|
+
type: "boolean";
|
|
85
|
+
};
|
|
86
|
+
profile: {
|
|
87
|
+
describe: string;
|
|
88
|
+
type: "boolean";
|
|
89
|
+
};
|
|
90
|
+
p: {
|
|
91
|
+
alias: string;
|
|
92
|
+
describe: string;
|
|
93
|
+
type: "string";
|
|
94
|
+
};
|
|
95
|
+
v: {
|
|
96
|
+
alias: string;
|
|
97
|
+
describe: string;
|
|
98
|
+
type: "boolean";
|
|
99
|
+
default: boolean;
|
|
100
|
+
};
|
|
101
|
+
d: {
|
|
102
|
+
alias: string;
|
|
103
|
+
describe: string;
|
|
104
|
+
type: "boolean";
|
|
105
|
+
default: boolean;
|
|
106
|
+
};
|
|
107
|
+
'emit-legacy-common-js-imports': {
|
|
108
|
+
describe: string;
|
|
109
|
+
type: "boolean";
|
|
110
|
+
};
|
|
111
|
+
'import-extension': {
|
|
112
|
+
describe: string;
|
|
113
|
+
type: "string";
|
|
114
|
+
};
|
|
115
|
+
'ignore-no-documents': {
|
|
116
|
+
describe: string;
|
|
117
|
+
type: "boolean";
|
|
118
|
+
};
|
|
119
|
+
};
|
|
120
|
+
export declare function parseArgv(argv?: string[]): YamlCliFlags;
|
|
121
|
+
export declare function createContext(cliFlags?: YamlCliFlags): Promise<CodegenContext>;
|
|
122
|
+
export declare function updateContextWithCliFlags(context: CodegenContext, cliFlags: YamlCliFlags): void;
|
|
123
|
+
export declare class CodegenContext {
|
|
124
|
+
private _config;
|
|
125
|
+
private _graphqlConfig?;
|
|
126
|
+
private config;
|
|
127
|
+
private _project?;
|
|
128
|
+
private _checkMode;
|
|
129
|
+
private _pluginContext;
|
|
130
|
+
cwd: string;
|
|
131
|
+
filepath: string;
|
|
132
|
+
profiler: Profiler;
|
|
133
|
+
profilerOutput?: string;
|
|
134
|
+
checkModeStaleFiles: any[];
|
|
135
|
+
constructor({ config, graphqlConfig, filepath, }: {
|
|
136
|
+
config?: Types.Config;
|
|
137
|
+
graphqlConfig?: GraphQLConfig;
|
|
138
|
+
filepath?: string;
|
|
139
|
+
});
|
|
140
|
+
useProject(name?: string): void;
|
|
141
|
+
getConfig<T>(extraConfig?: T): T & Types.Config;
|
|
142
|
+
updateConfig(config: Partial<Types.Config>): void;
|
|
143
|
+
enableCheckMode(): void;
|
|
144
|
+
get checkMode(): boolean;
|
|
145
|
+
useProfiler(): void;
|
|
146
|
+
getPluginContext(): {
|
|
147
|
+
[key: string]: any;
|
|
148
|
+
};
|
|
149
|
+
loadSchema(pointer: Types.Schema | Types.Schema[]): Promise<GraphQLSchema>;
|
|
150
|
+
loadDocuments(pointer: Types.OperationDocument[]): Promise<Types.DocumentFile[]>;
|
|
151
|
+
}
|
|
152
|
+
export declare function ensureContext(input: CodegenContext | Types.Config): CodegenContext;
|