@depup/graphql-codegen__cli 7.2.0-depup.9 → 7.3.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 +18 -17
- package/changes.json +20 -16
- package/cjs/config.js +0 -5
- package/cjs/generate-and-save.js +40 -15
- package/cjs/utils/watcher.js +23 -7
- package/cjs/version.js +1 -1
- package/esm/config.js +0 -5
- package/esm/generate-and-save.js +40 -15
- package/esm/utils/watcher.js +23 -7
- package/esm/version.js +1 -1
- package/package.json +39 -35
- package/typings/config.d.cts +0 -1
- package/typings/config.d.ts +0 -1
- package/typings/utils/watcher.d.cts +7 -1
- package/typings/utils/watcher.d.ts +7 -1
package/README.md
CHANGED
|
@@ -13,10 +13,10 @@ npm install @depup/graphql-codegen__cli
|
|
|
13
13
|
|
|
14
14
|
| Field | Value |
|
|
15
15
|
|-------|-------|
|
|
16
|
-
| Original | [@graphql-codegen/cli](https://www.npmjs.com/package/@graphql-codegen/cli) @ 7.
|
|
17
|
-
| Processed | 2026-
|
|
16
|
+
| Original | [@graphql-codegen/cli](https://www.npmjs.com/package/@graphql-codegen/cli) @ 7.3.1 |
|
|
17
|
+
| Processed | 2026-08-23 |
|
|
18
18
|
| Smoke test | passed |
|
|
19
|
-
| Deps updated |
|
|
19
|
+
| Deps updated | 28 |
|
|
20
20
|
|
|
21
21
|
## Dependency Changes
|
|
22
22
|
|
|
@@ -25,20 +25,20 @@ npm install @depup/graphql-codegen__cli
|
|
|
25
25
|
| @babel/generator | ^7.18.13 | ^8.0.0 |
|
|
26
26
|
| @babel/template | ^7.18.10 | ^8.0.0 |
|
|
27
27
|
| @babel/types | ^7.18.13 | ^8.0.4 |
|
|
28
|
-
| @graphql-tools/apollo-engine-loader | ^8.0.28 | ^8.0.
|
|
29
|
-
| @graphql-tools/code-file-loader | ^8.1.28 | ^8.1.
|
|
30
|
-
| @graphql-tools/git-loader | ^8.0.32 | ^8.0.
|
|
31
|
-
| @graphql-tools/github-loader | ^9.0.6 | ^9.1.
|
|
32
|
-
| @graphql-tools/graphql-file-loader | ^8.1.11 | ^8.1.
|
|
33
|
-
| @graphql-tools/json-file-loader | ^8.0.26 | ^8.0.
|
|
34
|
-
| @graphql-tools/load | ^8.1.8 | ^8.1.
|
|
35
|
-
| @graphql-tools/merge | ^9.0.6 | ^9.2.
|
|
36
|
-
| @graphql-tools/url-loader | ^9.0.6 | ^9.1.
|
|
37
|
-
| @graphql-tools/utils | ^11.2.0 | ^
|
|
38
|
-
| @inquirer/prompts | ^8.3.2 | ^8.
|
|
28
|
+
| @graphql-tools/apollo-engine-loader | ^8.0.28 | ^8.0.35 |
|
|
29
|
+
| @graphql-tools/code-file-loader | ^8.1.28 | ^8.1.37 |
|
|
30
|
+
| @graphql-tools/git-loader | ^8.0.32 | ^8.0.41 |
|
|
31
|
+
| @graphql-tools/github-loader | ^9.0.6 | ^9.1.7 |
|
|
32
|
+
| @graphql-tools/graphql-file-loader | ^8.1.11 | ^8.1.19 |
|
|
33
|
+
| @graphql-tools/json-file-loader | ^8.0.26 | ^8.0.33 |
|
|
34
|
+
| @graphql-tools/load | ^8.1.8 | ^8.1.16 |
|
|
35
|
+
| @graphql-tools/merge | ^9.0.6 | ^9.2.3 |
|
|
36
|
+
| @graphql-tools/url-loader | ^9.0.6 | ^9.1.7 |
|
|
37
|
+
| @graphql-tools/utils | ^11.2.0 | ^12.0.0 |
|
|
38
|
+
| @inquirer/prompts | ^8.3.2 | ^8.6.0 |
|
|
39
39
|
| @whatwg-node/fetch | ^0.10.0 | ^0.10.13 |
|
|
40
|
-
| chalk | ^5.6.0 | ^
|
|
41
|
-
| cosmiconfig | ^9.0.0 | ^
|
|
40
|
+
| chalk | ^5.6.0 | ^6.0.0 |
|
|
41
|
+
| cosmiconfig | ^9.0.0 | ^10.0.0 |
|
|
42
42
|
| detect-indent | ^7.0.0 | ^7.0.2 |
|
|
43
43
|
| is-glob | ^4.0.1 | ^4.0.3 |
|
|
44
44
|
| jiti | ^2.3.0 | ^2.7.0 |
|
|
@@ -46,9 +46,10 @@ npm install @depup/graphql-codegen__cli
|
|
|
46
46
|
| log-symbols | ^7.0.0 | ^7.0.1 |
|
|
47
47
|
| micromatch | ^4.0.5 | ^4.0.8 |
|
|
48
48
|
| shell-quote | ^1.7.3 | ^1.10.0 |
|
|
49
|
-
| ts-log | ^3.0.0 | ^3.0.
|
|
49
|
+
| ts-log | ^3.0.0 | ^3.0.3 |
|
|
50
50
|
| tslib | ^2.4.0 | ^2.8.1 |
|
|
51
51
|
| yaml | ^2.3.1 | ^2.9.0 |
|
|
52
|
+
| yargs | ^18.0.0 | ^18.1.0 |
|
|
52
53
|
|
|
53
54
|
---
|
|
54
55
|
|
package/changes.json
CHANGED
|
@@ -14,47 +14,47 @@
|
|
|
14
14
|
},
|
|
15
15
|
"@graphql-tools/apollo-engine-loader": {
|
|
16
16
|
"from": "^8.0.28",
|
|
17
|
-
"to": "^8.0.
|
|
17
|
+
"to": "^8.0.35"
|
|
18
18
|
},
|
|
19
19
|
"@graphql-tools/code-file-loader": {
|
|
20
20
|
"from": "^8.1.28",
|
|
21
|
-
"to": "^8.1.
|
|
21
|
+
"to": "^8.1.37"
|
|
22
22
|
},
|
|
23
23
|
"@graphql-tools/git-loader": {
|
|
24
24
|
"from": "^8.0.32",
|
|
25
|
-
"to": "^8.0.
|
|
25
|
+
"to": "^8.0.41"
|
|
26
26
|
},
|
|
27
27
|
"@graphql-tools/github-loader": {
|
|
28
28
|
"from": "^9.0.6",
|
|
29
|
-
"to": "^9.1.
|
|
29
|
+
"to": "^9.1.7"
|
|
30
30
|
},
|
|
31
31
|
"@graphql-tools/graphql-file-loader": {
|
|
32
32
|
"from": "^8.1.11",
|
|
33
|
-
"to": "^8.1.
|
|
33
|
+
"to": "^8.1.19"
|
|
34
34
|
},
|
|
35
35
|
"@graphql-tools/json-file-loader": {
|
|
36
36
|
"from": "^8.0.26",
|
|
37
|
-
"to": "^8.0.
|
|
37
|
+
"to": "^8.0.33"
|
|
38
38
|
},
|
|
39
39
|
"@graphql-tools/load": {
|
|
40
40
|
"from": "^8.1.8",
|
|
41
|
-
"to": "^8.1.
|
|
41
|
+
"to": "^8.1.16"
|
|
42
42
|
},
|
|
43
43
|
"@graphql-tools/merge": {
|
|
44
44
|
"from": "^9.0.6",
|
|
45
|
-
"to": "^9.2.
|
|
45
|
+
"to": "^9.2.3"
|
|
46
46
|
},
|
|
47
47
|
"@graphql-tools/url-loader": {
|
|
48
48
|
"from": "^9.0.6",
|
|
49
|
-
"to": "^9.1.
|
|
49
|
+
"to": "^9.1.7"
|
|
50
50
|
},
|
|
51
51
|
"@graphql-tools/utils": {
|
|
52
52
|
"from": "^11.2.0",
|
|
53
|
-
"to": "^
|
|
53
|
+
"to": "^12.0.0"
|
|
54
54
|
},
|
|
55
55
|
"@inquirer/prompts": {
|
|
56
56
|
"from": "^8.3.2",
|
|
57
|
-
"to": "^8.
|
|
57
|
+
"to": "^8.6.0"
|
|
58
58
|
},
|
|
59
59
|
"@whatwg-node/fetch": {
|
|
60
60
|
"from": "^0.10.0",
|
|
@@ -62,11 +62,11 @@
|
|
|
62
62
|
},
|
|
63
63
|
"chalk": {
|
|
64
64
|
"from": "^5.6.0",
|
|
65
|
-
"to": "^
|
|
65
|
+
"to": "^6.0.0"
|
|
66
66
|
},
|
|
67
67
|
"cosmiconfig": {
|
|
68
68
|
"from": "^9.0.0",
|
|
69
|
-
"to": "^
|
|
69
|
+
"to": "^10.0.0"
|
|
70
70
|
},
|
|
71
71
|
"detect-indent": {
|
|
72
72
|
"from": "^7.0.0",
|
|
@@ -98,7 +98,7 @@
|
|
|
98
98
|
},
|
|
99
99
|
"ts-log": {
|
|
100
100
|
"from": "^3.0.0",
|
|
101
|
-
"to": "^3.0.
|
|
101
|
+
"to": "^3.0.3"
|
|
102
102
|
},
|
|
103
103
|
"tslib": {
|
|
104
104
|
"from": "^2.4.0",
|
|
@@ -107,8 +107,12 @@
|
|
|
107
107
|
"yaml": {
|
|
108
108
|
"from": "^2.3.1",
|
|
109
109
|
"to": "^2.9.0"
|
|
110
|
+
},
|
|
111
|
+
"yargs": {
|
|
112
|
+
"from": "^18.0.0",
|
|
113
|
+
"to": "^18.1.0"
|
|
110
114
|
}
|
|
111
115
|
},
|
|
112
|
-
"timestamp": "2026-
|
|
113
|
-
"totalUpdated":
|
|
116
|
+
"timestamp": "2026-08-23T16:05:30.633Z",
|
|
117
|
+
"totalUpdated": 28
|
|
114
118
|
}
|
package/cjs/config.js
CHANGED
|
@@ -263,7 +263,6 @@ class CodegenContext {
|
|
|
263
263
|
cwd;
|
|
264
264
|
filepath;
|
|
265
265
|
profiler;
|
|
266
|
-
profilerOutput;
|
|
267
266
|
checkModeStaleFiles = [];
|
|
268
267
|
constructor({ config, graphqlConfig, filepath, }) {
|
|
269
268
|
this._config = config;
|
|
@@ -317,10 +316,6 @@ class CodegenContext {
|
|
|
317
316
|
}
|
|
318
317
|
useProfiler() {
|
|
319
318
|
this.profiler = (0, plugin_helpers_1.createProfiler)();
|
|
320
|
-
const now = new Date(); // 2011-10-05T14:48:00.000Z
|
|
321
|
-
const datetime = now.toISOString().split('.')[0]; // 2011-10-05T14:48:00
|
|
322
|
-
const datetimeNormalized = datetime.replace(/-|:/g, ''); // 20111005T144800
|
|
323
|
-
this.profilerOutput = `codegen-${datetimeNormalized}.json`;
|
|
324
319
|
}
|
|
325
320
|
getPluginContext() {
|
|
326
321
|
return this._pluginContext;
|
package/cjs/generate-and-save.js
CHANGED
|
@@ -23,7 +23,7 @@ async function generate(input, saveToFile = true) {
|
|
|
23
23
|
// find stale files from previous build which are not present in current build
|
|
24
24
|
const staleFilenames = previouslyGeneratedFilenames.filter(f => !filenames.includes(f));
|
|
25
25
|
for (const filename of staleFilenames) {
|
|
26
|
-
if (
|
|
26
|
+
if (normalizeOverwriteConfig(config, filename).removeStaleFiles) {
|
|
27
27
|
(0, file_system_js_1.unlinkFile)(filename, err => {
|
|
28
28
|
const prettyFilename = filename.replace(`${input.cwd || process.cwd()}/`, '');
|
|
29
29
|
if (err) {
|
|
@@ -55,7 +55,7 @@ async function generate(input, saveToFile = true) {
|
|
|
55
55
|
if (previousHash) {
|
|
56
56
|
recentOutputHash.set(result.filename, previousHash);
|
|
57
57
|
}
|
|
58
|
-
if (!
|
|
58
|
+
if (!normalizeOverwriteConfig(config, result.filename).updateExistingFiles && exists) {
|
|
59
59
|
return;
|
|
60
60
|
}
|
|
61
61
|
let content = result.content || '';
|
|
@@ -98,9 +98,20 @@ async function generate(input, saveToFile = true) {
|
|
|
98
98
|
await context.profiler.run(() => (0, hooks_js_1.lifecycleHooks)(config.hooks).afterAllFileWrite(generationResult.map(r => r.filename)), 'Lifecycle: afterAllFileWrite');
|
|
99
99
|
return generationResult;
|
|
100
100
|
}
|
|
101
|
+
// Flush the collected profiler events to disk, then reset the profiler so the
|
|
102
|
+
// next run produces its own trace under a fresh filename. No-op when profiling
|
|
103
|
+
// is disabled (the noop profiler has no `outputName`).
|
|
104
|
+
async function writeProfilerOutput() {
|
|
105
|
+
const { profiler } = context;
|
|
106
|
+
if (!profiler.outputName) {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
await (0, file_system_js_1.writeFile)((0, path_1.join)(context.cwd, profiler.outputName), JSON.stringify(profiler.collect()));
|
|
110
|
+
profiler.clear();
|
|
111
|
+
}
|
|
101
112
|
// watch mode
|
|
102
113
|
if (config.watch) {
|
|
103
|
-
return (0, watcher_js_1.createWatcher)(context, writeOutput).runningWatcher;
|
|
114
|
+
return (0, watcher_js_1.createWatcher)(context, writeOutput, writeProfilerOutput).runningWatcher;
|
|
104
115
|
}
|
|
105
116
|
const { result: outputFiles, error } = await context.profiler.run(() => (0, codegen_js_1.executeCodegen)(context), 'executeCodegen');
|
|
106
117
|
if (error) {
|
|
@@ -118,22 +129,36 @@ async function generate(input, saveToFile = true) {
|
|
|
118
129
|
}
|
|
119
130
|
await context.profiler.run(() => writeOutput(outputFiles), 'writeOutput');
|
|
120
131
|
await context.profiler.run(() => (0, hooks_js_1.lifecycleHooks)(config.hooks).beforeDone(), 'Lifecycle: beforeDone');
|
|
121
|
-
|
|
122
|
-
await (0, file_system_js_1.writeFile)((0, path_1.join)(context.cwd, context.profilerOutput), JSON.stringify(context.profiler.collect()));
|
|
123
|
-
}
|
|
132
|
+
await writeProfilerOutput();
|
|
124
133
|
return outputFiles;
|
|
125
134
|
}
|
|
126
|
-
function
|
|
127
|
-
const
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
(
|
|
131
|
-
|
|
135
|
+
function normalizeOverwriteConfig(config, outputPath) {
|
|
136
|
+
const overwrite = (function getOverwriteOption() {
|
|
137
|
+
const { overwrite: result = true } = config;
|
|
138
|
+
const outputConfig = config.generates[outputPath];
|
|
139
|
+
if (!outputConfig) {
|
|
140
|
+
(0, debugging_js_1.debugLog)(`Couldn't find a config of ${outputPath}`);
|
|
141
|
+
return result;
|
|
142
|
+
}
|
|
143
|
+
if (isConfiguredOutput(outputConfig) && outputConfig.overwrite !== undefined) {
|
|
144
|
+
return outputConfig.overwrite;
|
|
145
|
+
}
|
|
146
|
+
return result;
|
|
147
|
+
})();
|
|
148
|
+
if (overwrite === true) {
|
|
149
|
+
return {
|
|
150
|
+
removeStaleFiles: true,
|
|
151
|
+
updateExistingFiles: true,
|
|
152
|
+
};
|
|
132
153
|
}
|
|
133
|
-
if (
|
|
134
|
-
return
|
|
154
|
+
if (overwrite === false) {
|
|
155
|
+
return {
|
|
156
|
+
removeStaleFiles: false,
|
|
157
|
+
updateExistingFiles: false,
|
|
158
|
+
};
|
|
135
159
|
}
|
|
136
|
-
|
|
160
|
+
const { removeStaleFiles = true, updateExistingFiles = true } = overwrite;
|
|
161
|
+
return { removeStaleFiles, updateExistingFiles };
|
|
137
162
|
}
|
|
138
163
|
function isConfiguredOutput(output) {
|
|
139
164
|
return typeof output.plugins !== 'undefined';
|
package/cjs/utils/watcher.js
CHANGED
|
@@ -21,7 +21,13 @@ function log(msg) {
|
|
|
21
21
|
function emitWatching(watchDir) {
|
|
22
22
|
log(`${log_symbols_1.default.info} Watching for changes in ${watchDir}...`);
|
|
23
23
|
}
|
|
24
|
-
const createWatcher = (initialContext, onNext
|
|
24
|
+
const createWatcher = (initialContext, onNext,
|
|
25
|
+
/**
|
|
26
|
+
* Called after a successful run (initial build or rebuild) once `onNext` has
|
|
27
|
+
* finished. Used to flush profiler output per run; a no-op when profiling is
|
|
28
|
+
* disabled.
|
|
29
|
+
*/
|
|
30
|
+
afterRun = () => Promise.resolve()) => {
|
|
25
31
|
(0, debugging_js_1.debugLog)(`[Watcher] Starting watcher...`);
|
|
26
32
|
let config = initialContext.getConfig();
|
|
27
33
|
const globalPatternSet = (0, patterns_js_1.makeGlobalPatternSet)(initialContext);
|
|
@@ -52,8 +58,9 @@ const createWatcher = (initialContext, onNext) => {
|
|
|
52
58
|
let isShutdown = false;
|
|
53
59
|
const debouncedExec = (0, debounce_1.default)(() => {
|
|
54
60
|
if (!isShutdown) {
|
|
55
|
-
|
|
56
|
-
.
|
|
61
|
+
initialContext.profiler
|
|
62
|
+
.run(() => (0, codegen_js_1.executeCodegen)(initialContext), 'executeCodegen')
|
|
63
|
+
.then(async ({ result, error }) => {
|
|
57
64
|
// FIXME: this is a quick fix to stop `onNext` (writeOutput) from
|
|
58
65
|
// removing all files when there is an error.
|
|
59
66
|
//
|
|
@@ -64,9 +71,13 @@ const createWatcher = (initialContext, onNext) => {
|
|
|
64
71
|
//
|
|
65
72
|
// This also means we don't have config.allowPartialOutputs in watch mode
|
|
66
73
|
if (error) {
|
|
74
|
+
// Discard this failed run's profiler events so they don't leak
|
|
75
|
+
// into the next successful run's trace.
|
|
76
|
+
initialContext.profiler.clear();
|
|
67
77
|
return;
|
|
68
78
|
}
|
|
69
|
-
onNext(result);
|
|
79
|
+
await onNext(result);
|
|
80
|
+
await afterRun();
|
|
70
81
|
}, () => Promise.resolve())
|
|
71
82
|
.then(() => emitWatching(watchDirectory));
|
|
72
83
|
}
|
|
@@ -164,14 +175,19 @@ const createWatcher = (initialContext, onNext) => {
|
|
|
164
175
|
* stopWatching() was called or there was an error inside it
|
|
165
176
|
*/
|
|
166
177
|
stopWatching.runningWatcher = new Promise((resolve, reject) => {
|
|
167
|
-
|
|
168
|
-
.
|
|
178
|
+
initialContext.profiler
|
|
179
|
+
.run(() => (0, codegen_js_1.executeCodegen)(initialContext), 'executeCodegen')
|
|
180
|
+
.then(async ({ result, error }) => {
|
|
169
181
|
// TODO: this is the initial run, the logic here mimics the above watcher logic.
|
|
170
182
|
// We need to check whether it's ok to deviate between these two.
|
|
171
183
|
if (error) {
|
|
184
|
+
// Discard this failed run's profiler events so they don't leak
|
|
185
|
+
// into the next successful run's trace.
|
|
186
|
+
initialContext.profiler.clear();
|
|
172
187
|
return;
|
|
173
188
|
}
|
|
174
|
-
onNext(result);
|
|
189
|
+
await onNext(result);
|
|
190
|
+
await afterRun();
|
|
175
191
|
}, () => Promise.resolve())
|
|
176
192
|
.then(() => runWatcher(abortController.signal))
|
|
177
193
|
.catch(err => {
|
package/cjs/version.js
CHANGED
package/esm/config.js
CHANGED
|
@@ -251,7 +251,6 @@ export class CodegenContext {
|
|
|
251
251
|
cwd;
|
|
252
252
|
filepath;
|
|
253
253
|
profiler;
|
|
254
|
-
profilerOutput;
|
|
255
254
|
checkModeStaleFiles = [];
|
|
256
255
|
constructor({ config, graphqlConfig, filepath, }) {
|
|
257
256
|
this._config = config;
|
|
@@ -305,10 +304,6 @@ export class CodegenContext {
|
|
|
305
304
|
}
|
|
306
305
|
useProfiler() {
|
|
307
306
|
this.profiler = createProfiler();
|
|
308
|
-
const now = new Date(); // 2011-10-05T14:48:00.000Z
|
|
309
|
-
const datetime = now.toISOString().split('.')[0]; // 2011-10-05T14:48:00
|
|
310
|
-
const datetimeNormalized = datetime.replace(/-|:/g, ''); // 20111005T144800
|
|
311
|
-
this.profilerOutput = `codegen-${datetimeNormalized}.json`;
|
|
312
307
|
}
|
|
313
308
|
getPluginContext() {
|
|
314
309
|
return this._pluginContext;
|
package/esm/generate-and-save.js
CHANGED
|
@@ -19,7 +19,7 @@ export async function generate(input, saveToFile = true) {
|
|
|
19
19
|
// find stale files from previous build which are not present in current build
|
|
20
20
|
const staleFilenames = previouslyGeneratedFilenames.filter(f => !filenames.includes(f));
|
|
21
21
|
for (const filename of staleFilenames) {
|
|
22
|
-
if (
|
|
22
|
+
if (normalizeOverwriteConfig(config, filename).removeStaleFiles) {
|
|
23
23
|
unlinkFile(filename, err => {
|
|
24
24
|
const prettyFilename = filename.replace(`${input.cwd || process.cwd()}/`, '');
|
|
25
25
|
if (err) {
|
|
@@ -51,7 +51,7 @@ export async function generate(input, saveToFile = true) {
|
|
|
51
51
|
if (previousHash) {
|
|
52
52
|
recentOutputHash.set(result.filename, previousHash);
|
|
53
53
|
}
|
|
54
|
-
if (!
|
|
54
|
+
if (!normalizeOverwriteConfig(config, result.filename).updateExistingFiles && exists) {
|
|
55
55
|
return;
|
|
56
56
|
}
|
|
57
57
|
let content = result.content || '';
|
|
@@ -94,9 +94,20 @@ export async function generate(input, saveToFile = true) {
|
|
|
94
94
|
await context.profiler.run(() => lifecycleHooks(config.hooks).afterAllFileWrite(generationResult.map(r => r.filename)), 'Lifecycle: afterAllFileWrite');
|
|
95
95
|
return generationResult;
|
|
96
96
|
}
|
|
97
|
+
// Flush the collected profiler events to disk, then reset the profiler so the
|
|
98
|
+
// next run produces its own trace under a fresh filename. No-op when profiling
|
|
99
|
+
// is disabled (the noop profiler has no `outputName`).
|
|
100
|
+
async function writeProfilerOutput() {
|
|
101
|
+
const { profiler } = context;
|
|
102
|
+
if (!profiler.outputName) {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
await writeFile(join(context.cwd, profiler.outputName), JSON.stringify(profiler.collect()));
|
|
106
|
+
profiler.clear();
|
|
107
|
+
}
|
|
97
108
|
// watch mode
|
|
98
109
|
if (config.watch) {
|
|
99
|
-
return createWatcher(context, writeOutput).runningWatcher;
|
|
110
|
+
return createWatcher(context, writeOutput, writeProfilerOutput).runningWatcher;
|
|
100
111
|
}
|
|
101
112
|
const { result: outputFiles, error } = await context.profiler.run(() => executeCodegen(context), 'executeCodegen');
|
|
102
113
|
if (error) {
|
|
@@ -114,22 +125,36 @@ export async function generate(input, saveToFile = true) {
|
|
|
114
125
|
}
|
|
115
126
|
await context.profiler.run(() => writeOutput(outputFiles), 'writeOutput');
|
|
116
127
|
await context.profiler.run(() => lifecycleHooks(config.hooks).beforeDone(), 'Lifecycle: beforeDone');
|
|
117
|
-
|
|
118
|
-
await writeFile(join(context.cwd, context.profilerOutput), JSON.stringify(context.profiler.collect()));
|
|
119
|
-
}
|
|
128
|
+
await writeProfilerOutput();
|
|
120
129
|
return outputFiles;
|
|
121
130
|
}
|
|
122
|
-
function
|
|
123
|
-
const
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
131
|
+
function normalizeOverwriteConfig(config, outputPath) {
|
|
132
|
+
const overwrite = (function getOverwriteOption() {
|
|
133
|
+
const { overwrite: result = true } = config;
|
|
134
|
+
const outputConfig = config.generates[outputPath];
|
|
135
|
+
if (!outputConfig) {
|
|
136
|
+
debugLog(`Couldn't find a config of ${outputPath}`);
|
|
137
|
+
return result;
|
|
138
|
+
}
|
|
139
|
+
if (isConfiguredOutput(outputConfig) && outputConfig.overwrite !== undefined) {
|
|
140
|
+
return outputConfig.overwrite;
|
|
141
|
+
}
|
|
142
|
+
return result;
|
|
143
|
+
})();
|
|
144
|
+
if (overwrite === true) {
|
|
145
|
+
return {
|
|
146
|
+
removeStaleFiles: true,
|
|
147
|
+
updateExistingFiles: true,
|
|
148
|
+
};
|
|
128
149
|
}
|
|
129
|
-
if (
|
|
130
|
-
return
|
|
150
|
+
if (overwrite === false) {
|
|
151
|
+
return {
|
|
152
|
+
removeStaleFiles: false,
|
|
153
|
+
updateExistingFiles: false,
|
|
154
|
+
};
|
|
131
155
|
}
|
|
132
|
-
|
|
156
|
+
const { removeStaleFiles = true, updateExistingFiles = true } = overwrite;
|
|
157
|
+
return { removeStaleFiles, updateExistingFiles };
|
|
133
158
|
}
|
|
134
159
|
function isConfiguredOutput(output) {
|
|
135
160
|
return typeof output.plugins !== 'undefined';
|
package/esm/utils/watcher.js
CHANGED
|
@@ -17,7 +17,13 @@ function log(msg) {
|
|
|
17
17
|
function emitWatching(watchDir) {
|
|
18
18
|
log(`${logSymbols.info} Watching for changes in ${watchDir}...`);
|
|
19
19
|
}
|
|
20
|
-
export const createWatcher = (initialContext, onNext
|
|
20
|
+
export const createWatcher = (initialContext, onNext,
|
|
21
|
+
/**
|
|
22
|
+
* Called after a successful run (initial build or rebuild) once `onNext` has
|
|
23
|
+
* finished. Used to flush profiler output per run; a no-op when profiling is
|
|
24
|
+
* disabled.
|
|
25
|
+
*/
|
|
26
|
+
afterRun = () => Promise.resolve()) => {
|
|
21
27
|
debugLog(`[Watcher] Starting watcher...`);
|
|
22
28
|
let config = initialContext.getConfig();
|
|
23
29
|
const globalPatternSet = makeGlobalPatternSet(initialContext);
|
|
@@ -48,8 +54,9 @@ export const createWatcher = (initialContext, onNext) => {
|
|
|
48
54
|
let isShutdown = false;
|
|
49
55
|
const debouncedExec = debounce(() => {
|
|
50
56
|
if (!isShutdown) {
|
|
51
|
-
|
|
52
|
-
.
|
|
57
|
+
initialContext.profiler
|
|
58
|
+
.run(() => executeCodegen(initialContext), 'executeCodegen')
|
|
59
|
+
.then(async ({ result, error }) => {
|
|
53
60
|
// FIXME: this is a quick fix to stop `onNext` (writeOutput) from
|
|
54
61
|
// removing all files when there is an error.
|
|
55
62
|
//
|
|
@@ -60,9 +67,13 @@ export const createWatcher = (initialContext, onNext) => {
|
|
|
60
67
|
//
|
|
61
68
|
// This also means we don't have config.allowPartialOutputs in watch mode
|
|
62
69
|
if (error) {
|
|
70
|
+
// Discard this failed run's profiler events so they don't leak
|
|
71
|
+
// into the next successful run's trace.
|
|
72
|
+
initialContext.profiler.clear();
|
|
63
73
|
return;
|
|
64
74
|
}
|
|
65
|
-
onNext(result);
|
|
75
|
+
await onNext(result);
|
|
76
|
+
await afterRun();
|
|
66
77
|
}, () => Promise.resolve())
|
|
67
78
|
.then(() => emitWatching(watchDirectory));
|
|
68
79
|
}
|
|
@@ -160,14 +171,19 @@ export const createWatcher = (initialContext, onNext) => {
|
|
|
160
171
|
* stopWatching() was called or there was an error inside it
|
|
161
172
|
*/
|
|
162
173
|
stopWatching.runningWatcher = new Promise((resolve, reject) => {
|
|
163
|
-
|
|
164
|
-
.
|
|
174
|
+
initialContext.profiler
|
|
175
|
+
.run(() => executeCodegen(initialContext), 'executeCodegen')
|
|
176
|
+
.then(async ({ result, error }) => {
|
|
165
177
|
// TODO: this is the initial run, the logic here mimics the above watcher logic.
|
|
166
178
|
// We need to check whether it's ok to deviate between these two.
|
|
167
179
|
if (error) {
|
|
180
|
+
// Discard this failed run's profiler events so they don't leak
|
|
181
|
+
// into the next successful run's trace.
|
|
182
|
+
initialContext.profiler.clear();
|
|
168
183
|
return;
|
|
169
184
|
}
|
|
170
|
-
onNext(result);
|
|
185
|
+
await onNext(result);
|
|
186
|
+
await afterRun();
|
|
171
187
|
}, () => Promise.resolve())
|
|
172
188
|
.then(() => runWatcher(abortController.signal))
|
|
173
189
|
.catch(err => {
|
package/esm/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '7.
|
|
1
|
+
export const version = '7.3.1';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@depup/graphql-codegen__cli",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.3.1-depup.0",
|
|
4
4
|
"peerDependenciesMeta": {
|
|
5
5
|
"@parcel/watcher": {
|
|
6
6
|
"optional": true
|
|
@@ -14,20 +14,20 @@
|
|
|
14
14
|
"@babel/generator": "^8.0.0",
|
|
15
15
|
"@babel/template": "^8.0.0",
|
|
16
16
|
"@babel/types": "^8.0.4",
|
|
17
|
-
"@graphql-tools/apollo-engine-loader": "^8.0.
|
|
18
|
-
"@graphql-tools/code-file-loader": "^8.1.
|
|
19
|
-
"@graphql-tools/git-loader": "^8.0.
|
|
20
|
-
"@graphql-tools/github-loader": "^9.1.
|
|
21
|
-
"@graphql-tools/graphql-file-loader": "^8.1.
|
|
22
|
-
"@graphql-tools/json-file-loader": "^8.0.
|
|
23
|
-
"@graphql-tools/load": "^8.1.
|
|
24
|
-
"@graphql-tools/merge": "^9.2.
|
|
25
|
-
"@graphql-tools/url-loader": "^9.1.
|
|
26
|
-
"@graphql-tools/utils": "^
|
|
27
|
-
"@inquirer/prompts": "^8.
|
|
17
|
+
"@graphql-tools/apollo-engine-loader": "^8.0.35",
|
|
18
|
+
"@graphql-tools/code-file-loader": "^8.1.37",
|
|
19
|
+
"@graphql-tools/git-loader": "^8.0.41",
|
|
20
|
+
"@graphql-tools/github-loader": "^9.1.7",
|
|
21
|
+
"@graphql-tools/graphql-file-loader": "^8.1.19",
|
|
22
|
+
"@graphql-tools/json-file-loader": "^8.0.33",
|
|
23
|
+
"@graphql-tools/load": "^8.1.16",
|
|
24
|
+
"@graphql-tools/merge": "^9.2.3",
|
|
25
|
+
"@graphql-tools/url-loader": "^9.1.7",
|
|
26
|
+
"@graphql-tools/utils": "^12.0.0",
|
|
27
|
+
"@inquirer/prompts": "^8.6.0",
|
|
28
28
|
"@whatwg-node/fetch": "^0.10.13",
|
|
29
|
-
"chalk": "^
|
|
30
|
-
"cosmiconfig": "^
|
|
29
|
+
"chalk": "^6.0.0",
|
|
30
|
+
"cosmiconfig": "^10.0.0",
|
|
31
31
|
"debounce": "^3.0.0",
|
|
32
32
|
"detect-indent": "^7.0.2",
|
|
33
33
|
"graphql-config": "^5.1.6",
|
|
@@ -39,13 +39,13 @@
|
|
|
39
39
|
"micromatch": "^4.0.8",
|
|
40
40
|
"shell-quote": "^1.10.0",
|
|
41
41
|
"string-env-interpolation": "^1.0.1",
|
|
42
|
-
"ts-log": "^3.0.
|
|
42
|
+
"ts-log": "^3.0.3",
|
|
43
43
|
"tslib": "^2.8.1",
|
|
44
44
|
"yaml": "^2.9.0",
|
|
45
|
-
"yargs": "^18.
|
|
46
|
-
"@graphql-codegen/client-preset": "^6.1.
|
|
45
|
+
"yargs": "^18.1.0",
|
|
46
|
+
"@graphql-codegen/client-preset": "^6.1.3",
|
|
47
47
|
"@graphql-codegen/core": "^6.2.0",
|
|
48
|
-
"@graphql-codegen/plugin-helpers": "^7.1
|
|
48
|
+
"@graphql-codegen/plugin-helpers": "^7.2.1"
|
|
49
49
|
},
|
|
50
50
|
"repository": {
|
|
51
51
|
"type": "git",
|
|
@@ -128,47 +128,47 @@
|
|
|
128
128
|
},
|
|
129
129
|
"@graphql-tools/apollo-engine-loader": {
|
|
130
130
|
"from": "^8.0.28",
|
|
131
|
-
"to": "^8.0.
|
|
131
|
+
"to": "^8.0.35"
|
|
132
132
|
},
|
|
133
133
|
"@graphql-tools/code-file-loader": {
|
|
134
134
|
"from": "^8.1.28",
|
|
135
|
-
"to": "^8.1.
|
|
135
|
+
"to": "^8.1.37"
|
|
136
136
|
},
|
|
137
137
|
"@graphql-tools/git-loader": {
|
|
138
138
|
"from": "^8.0.32",
|
|
139
|
-
"to": "^8.0.
|
|
139
|
+
"to": "^8.0.41"
|
|
140
140
|
},
|
|
141
141
|
"@graphql-tools/github-loader": {
|
|
142
142
|
"from": "^9.0.6",
|
|
143
|
-
"to": "^9.1.
|
|
143
|
+
"to": "^9.1.7"
|
|
144
144
|
},
|
|
145
145
|
"@graphql-tools/graphql-file-loader": {
|
|
146
146
|
"from": "^8.1.11",
|
|
147
|
-
"to": "^8.1.
|
|
147
|
+
"to": "^8.1.19"
|
|
148
148
|
},
|
|
149
149
|
"@graphql-tools/json-file-loader": {
|
|
150
150
|
"from": "^8.0.26",
|
|
151
|
-
"to": "^8.0.
|
|
151
|
+
"to": "^8.0.33"
|
|
152
152
|
},
|
|
153
153
|
"@graphql-tools/load": {
|
|
154
154
|
"from": "^8.1.8",
|
|
155
|
-
"to": "^8.1.
|
|
155
|
+
"to": "^8.1.16"
|
|
156
156
|
},
|
|
157
157
|
"@graphql-tools/merge": {
|
|
158
158
|
"from": "^9.0.6",
|
|
159
|
-
"to": "^9.2.
|
|
159
|
+
"to": "^9.2.3"
|
|
160
160
|
},
|
|
161
161
|
"@graphql-tools/url-loader": {
|
|
162
162
|
"from": "^9.0.6",
|
|
163
|
-
"to": "^9.1.
|
|
163
|
+
"to": "^9.1.7"
|
|
164
164
|
},
|
|
165
165
|
"@graphql-tools/utils": {
|
|
166
166
|
"from": "^11.2.0",
|
|
167
|
-
"to": "^
|
|
167
|
+
"to": "^12.0.0"
|
|
168
168
|
},
|
|
169
169
|
"@inquirer/prompts": {
|
|
170
170
|
"from": "^8.3.2",
|
|
171
|
-
"to": "^8.
|
|
171
|
+
"to": "^8.6.0"
|
|
172
172
|
},
|
|
173
173
|
"@whatwg-node/fetch": {
|
|
174
174
|
"from": "^0.10.0",
|
|
@@ -176,11 +176,11 @@
|
|
|
176
176
|
},
|
|
177
177
|
"chalk": {
|
|
178
178
|
"from": "^5.6.0",
|
|
179
|
-
"to": "^
|
|
179
|
+
"to": "^6.0.0"
|
|
180
180
|
},
|
|
181
181
|
"cosmiconfig": {
|
|
182
182
|
"from": "^9.0.0",
|
|
183
|
-
"to": "^
|
|
183
|
+
"to": "^10.0.0"
|
|
184
184
|
},
|
|
185
185
|
"detect-indent": {
|
|
186
186
|
"from": "^7.0.0",
|
|
@@ -212,7 +212,7 @@
|
|
|
212
212
|
},
|
|
213
213
|
"ts-log": {
|
|
214
214
|
"from": "^3.0.0",
|
|
215
|
-
"to": "^3.0.
|
|
215
|
+
"to": "^3.0.3"
|
|
216
216
|
},
|
|
217
217
|
"tslib": {
|
|
218
218
|
"from": "^2.4.0",
|
|
@@ -221,12 +221,16 @@
|
|
|
221
221
|
"yaml": {
|
|
222
222
|
"from": "^2.3.1",
|
|
223
223
|
"to": "^2.9.0"
|
|
224
|
+
},
|
|
225
|
+
"yargs": {
|
|
226
|
+
"from": "^18.0.0",
|
|
227
|
+
"to": "^18.1.0"
|
|
224
228
|
}
|
|
225
229
|
},
|
|
226
|
-
"depsUpdated":
|
|
230
|
+
"depsUpdated": 28,
|
|
227
231
|
"originalPackage": "@graphql-codegen/cli",
|
|
228
|
-
"originalVersion": "7.
|
|
229
|
-
"processedAt": "2026-
|
|
232
|
+
"originalVersion": "7.3.1",
|
|
233
|
+
"processedAt": "2026-08-23T16:05:44.949Z",
|
|
230
234
|
"smokeTest": "passed"
|
|
231
235
|
}
|
|
232
236
|
}
|
package/typings/config.d.cts
CHANGED
package/typings/config.d.ts
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { Types } from '@graphql-codegen/plugin-helpers';
|
|
2
2
|
import { CodegenContext } from '../config.cjs';
|
|
3
|
-
export declare const createWatcher: (initialContext: CodegenContext, onNext: (result: Types.FileOutput[]) => Promise<Types.FileOutput[]
|
|
3
|
+
export declare const createWatcher: (initialContext: CodegenContext, onNext: (result: Types.FileOutput[]) => Promise<Types.FileOutput[]>,
|
|
4
|
+
/**
|
|
5
|
+
* Called after a successful run (initial build or rebuild) once `onNext` has
|
|
6
|
+
* finished. Used to flush profiler output per run; a no-op when profiling is
|
|
7
|
+
* disabled.
|
|
8
|
+
*/
|
|
9
|
+
afterRun?: () => Promise<void>) => {
|
|
4
10
|
/**
|
|
5
11
|
* Call this function to stop the running watch server
|
|
6
12
|
*
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { Types } from '@graphql-codegen/plugin-helpers';
|
|
2
2
|
import { CodegenContext } from '../config.js';
|
|
3
|
-
export declare const createWatcher: (initialContext: CodegenContext, onNext: (result: Types.FileOutput[]) => Promise<Types.FileOutput[]
|
|
3
|
+
export declare const createWatcher: (initialContext: CodegenContext, onNext: (result: Types.FileOutput[]) => Promise<Types.FileOutput[]>,
|
|
4
|
+
/**
|
|
5
|
+
* Called after a successful run (initial build or rebuild) once `onNext` has
|
|
6
|
+
* finished. Used to flush profiler output per run; a no-op when profiling is
|
|
7
|
+
* disabled.
|
|
8
|
+
*/
|
|
9
|
+
afterRun?: () => Promise<void>) => {
|
|
4
10
|
/**
|
|
5
11
|
* Call this function to stop the running watch server
|
|
6
12
|
*
|