@graphql-codegen/cli 7.2.0 → 7.3.0-alpha-20260819142612-e67b77fd858dd4b58f56ceda6a16331c3af57c9d
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/generate-and-save.js +27 -11
- package/cjs/version.js +1 -1
- package/esm/generate-and-save.js +27 -11
- package/esm/version.js +1 -1
- package/package.json +4 -4
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 || '';
|
|
@@ -123,17 +123,33 @@ async function generate(input, saveToFile = true) {
|
|
|
123
123
|
}
|
|
124
124
|
return outputFiles;
|
|
125
125
|
}
|
|
126
|
-
function
|
|
127
|
-
const
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
(
|
|
131
|
-
|
|
126
|
+
function normalizeOverwriteConfig(config, outputPath) {
|
|
127
|
+
const overwrite = (function getOverwriteOption() {
|
|
128
|
+
const { overwrite: result = true } = config;
|
|
129
|
+
const outputConfig = config.generates[outputPath];
|
|
130
|
+
if (!outputConfig) {
|
|
131
|
+
(0, debugging_js_1.debugLog)(`Couldn't find a config of ${outputPath}`);
|
|
132
|
+
return result;
|
|
133
|
+
}
|
|
134
|
+
if (isConfiguredOutput(outputConfig) && outputConfig.overwrite !== undefined) {
|
|
135
|
+
return outputConfig.overwrite;
|
|
136
|
+
}
|
|
137
|
+
return result;
|
|
138
|
+
})();
|
|
139
|
+
if (overwrite === true) {
|
|
140
|
+
return {
|
|
141
|
+
removeStaleFiles: true,
|
|
142
|
+
updateExistingFiles: true,
|
|
143
|
+
};
|
|
132
144
|
}
|
|
133
|
-
if (
|
|
134
|
-
return
|
|
145
|
+
if (overwrite === false) {
|
|
146
|
+
return {
|
|
147
|
+
removeStaleFiles: false,
|
|
148
|
+
updateExistingFiles: false,
|
|
149
|
+
};
|
|
135
150
|
}
|
|
136
|
-
|
|
151
|
+
const { removeStaleFiles = true, updateExistingFiles = true } = overwrite;
|
|
152
|
+
return { removeStaleFiles, updateExistingFiles };
|
|
137
153
|
}
|
|
138
154
|
function isConfiguredOutput(output) {
|
|
139
155
|
return typeof output.plugins !== 'undefined';
|
package/cjs/version.js
CHANGED
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 || '';
|
|
@@ -119,17 +119,33 @@ export async function generate(input, saveToFile = true) {
|
|
|
119
119
|
}
|
|
120
120
|
return outputFiles;
|
|
121
121
|
}
|
|
122
|
-
function
|
|
123
|
-
const
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
122
|
+
function normalizeOverwriteConfig(config, outputPath) {
|
|
123
|
+
const overwrite = (function getOverwriteOption() {
|
|
124
|
+
const { overwrite: result = true } = config;
|
|
125
|
+
const outputConfig = config.generates[outputPath];
|
|
126
|
+
if (!outputConfig) {
|
|
127
|
+
debugLog(`Couldn't find a config of ${outputPath}`);
|
|
128
|
+
return result;
|
|
129
|
+
}
|
|
130
|
+
if (isConfiguredOutput(outputConfig) && outputConfig.overwrite !== undefined) {
|
|
131
|
+
return outputConfig.overwrite;
|
|
132
|
+
}
|
|
133
|
+
return result;
|
|
134
|
+
})();
|
|
135
|
+
if (overwrite === true) {
|
|
136
|
+
return {
|
|
137
|
+
removeStaleFiles: true,
|
|
138
|
+
updateExistingFiles: true,
|
|
139
|
+
};
|
|
128
140
|
}
|
|
129
|
-
if (
|
|
130
|
-
return
|
|
141
|
+
if (overwrite === false) {
|
|
142
|
+
return {
|
|
143
|
+
removeStaleFiles: false,
|
|
144
|
+
updateExistingFiles: false,
|
|
145
|
+
};
|
|
131
146
|
}
|
|
132
|
-
|
|
147
|
+
const { removeStaleFiles = true, updateExistingFiles = true } = overwrite;
|
|
148
|
+
return { removeStaleFiles, updateExistingFiles };
|
|
133
149
|
}
|
|
134
150
|
function isConfiguredOutput(output) {
|
|
135
151
|
return typeof output.plugins !== 'undefined';
|
package/esm/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '7.
|
|
1
|
+
export const version = '7.3.0-alpha-20260819142612-e67b77fd858dd4b58f56ceda6a16331c3af57c9d';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-codegen/cli",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.3.0-alpha-20260819142612-e67b77fd858dd4b58f56ceda6a16331c3af57c9d",
|
|
4
4
|
"peerDependenciesMeta": {
|
|
5
5
|
"@parcel/watcher": {
|
|
6
6
|
"optional": true
|
|
@@ -43,9 +43,9 @@
|
|
|
43
43
|
"tslib": "^2.4.0",
|
|
44
44
|
"yaml": "^2.3.1",
|
|
45
45
|
"yargs": "^18.0.0",
|
|
46
|
-
"@graphql-codegen/client-preset": "^6.1.
|
|
47
|
-
"@graphql-codegen/
|
|
48
|
-
"@graphql-codegen/
|
|
46
|
+
"@graphql-codegen/client-preset": "^6.1.3",
|
|
47
|
+
"@graphql-codegen/plugin-helpers": "^7.2.0-alpha-20260819142612-e67b77fd858dd4b58f56ceda6a16331c3af57c9d",
|
|
48
|
+
"@graphql-codegen/core": "^6.2.0"
|
|
49
49
|
},
|
|
50
50
|
"repository": {
|
|
51
51
|
"type": "git",
|