@graphql-codegen/cli 4.0.2-alpha-20230725231005-5bc75d7f6 → 4.0.2-alpha-20230725234859-7c312d8e7
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/utils/watcher.js +15 -14
- package/esm/utils/watcher.js +15 -14
- package/package.json +1 -1
package/cjs/utils/watcher.js
CHANGED
|
@@ -174,19 +174,22 @@ exports.createWatcher = createWatcher;
|
|
|
174
174
|
const findHighestCommonDirectory = async (files) => {
|
|
175
175
|
const dirPaths = files
|
|
176
176
|
.map(filePath => ((0, path_1.isAbsolute)(filePath) ? filePath : (0, path_1.resolve)(filePath)))
|
|
177
|
-
.map(
|
|
178
|
-
.map(
|
|
177
|
+
.map(filePath => (0, path_1.normalize)(filePath)) // Normalize the file paths
|
|
178
|
+
.map(patterned => micromatch_1.default.scan(patterned).base);
|
|
179
|
+
// Log the dirPaths for debugging
|
|
180
|
+
(0, debugging_js_1.debugLog)(`[Watcher] dirPaths: ${JSON.stringify(dirPaths)}`);
|
|
179
181
|
return (async (maybeValidPath) => {
|
|
180
|
-
|
|
181
|
-
(0, debugging_js_1.debugLog)(`[Watcher] Longest common prefix of all files: ${normalizedPath}...`);
|
|
182
|
+
(0, debugging_js_1.debugLog)(`[Watcher] Longest common prefix of all files: ${maybeValidPath}...`);
|
|
182
183
|
try {
|
|
183
|
-
await (0, file_system_js_1.access)(
|
|
184
|
-
|
|
184
|
+
await (0, file_system_js_1.access)(maybeValidPath);
|
|
185
|
+
(0, debugging_js_1.debugLog)(`[Watcher] Access to ${maybeValidPath} successful.`);
|
|
186
|
+
return maybeValidPath;
|
|
185
187
|
}
|
|
186
|
-
catch {
|
|
187
|
-
|
|
188
|
-
log(`[Watcher]
|
|
189
|
-
|
|
188
|
+
catch (error) {
|
|
189
|
+
(0, debugging_js_1.debugLog)(`[Watcher] Error accessing path: ${error.message}`);
|
|
190
|
+
log(`[Watcher] Longest common prefix (${maybeValidPath}) is not accessible`);
|
|
191
|
+
log(`[Watcher] Watching current working directory (${process.cwd()}) instead`);
|
|
192
|
+
return process.cwd();
|
|
190
193
|
}
|
|
191
194
|
})(longestCommonPrefix(dirPaths.map(path => path.split(path_1.sep))).join(path_1.sep));
|
|
192
195
|
};
|
|
@@ -202,17 +205,15 @@ const findHighestCommonDirectory = async (files) => {
|
|
|
202
205
|
* @returns An array of path segments representing the longest common prefix of splitPaths
|
|
203
206
|
*/
|
|
204
207
|
const longestCommonPrefix = (splitPaths) => {
|
|
205
|
-
// Return early on empty input
|
|
206
208
|
if (!splitPaths.length) {
|
|
207
209
|
return [];
|
|
208
210
|
}
|
|
209
|
-
// Loop through the segments of the first path
|
|
210
211
|
for (let i = 0; i <= splitPaths[0].length; i++) {
|
|
211
|
-
// Check if this path segment is present in the same position of every path
|
|
212
212
|
if (!splitPaths.every(string => string[i] === splitPaths[0][i])) {
|
|
213
|
-
|
|
213
|
+
(0, debugging_js_1.debugLog)(`[Watcher] longestCommonPrefix at index ${i}: ${splitPaths[0].slice(0, i).join(path_1.sep)}`);
|
|
214
214
|
return splitPaths[0].slice(0, i);
|
|
215
215
|
}
|
|
216
216
|
}
|
|
217
|
+
(0, debugging_js_1.debugLog)(`[Watcher] longestCommonPrefix: ${splitPaths[0].join(path_1.sep)}`);
|
|
217
218
|
return splitPaths[0];
|
|
218
219
|
};
|
package/esm/utils/watcher.js
CHANGED
|
@@ -169,19 +169,22 @@ export const createWatcher = (initialContext, onNext) => {
|
|
|
169
169
|
const findHighestCommonDirectory = async (files) => {
|
|
170
170
|
const dirPaths = files
|
|
171
171
|
.map(filePath => (isAbsolute(filePath) ? filePath : resolve(filePath)))
|
|
172
|
-
.map(
|
|
173
|
-
.map(
|
|
172
|
+
.map(filePath => normalize(filePath)) // Normalize the file paths
|
|
173
|
+
.map(patterned => mm.scan(patterned).base);
|
|
174
|
+
// Log the dirPaths for debugging
|
|
175
|
+
debugLog(`[Watcher] dirPaths: ${JSON.stringify(dirPaths)}`);
|
|
174
176
|
return (async (maybeValidPath) => {
|
|
175
|
-
|
|
176
|
-
debugLog(`[Watcher] Longest common prefix of all files: ${normalizedPath}...`);
|
|
177
|
+
debugLog(`[Watcher] Longest common prefix of all files: ${maybeValidPath}...`);
|
|
177
178
|
try {
|
|
178
|
-
await access(
|
|
179
|
-
|
|
179
|
+
await access(maybeValidPath);
|
|
180
|
+
debugLog(`[Watcher] Access to ${maybeValidPath} successful.`);
|
|
181
|
+
return maybeValidPath;
|
|
180
182
|
}
|
|
181
|
-
catch {
|
|
182
|
-
|
|
183
|
-
log(`[Watcher]
|
|
184
|
-
|
|
183
|
+
catch (error) {
|
|
184
|
+
debugLog(`[Watcher] Error accessing path: ${error.message}`);
|
|
185
|
+
log(`[Watcher] Longest common prefix (${maybeValidPath}) is not accessible`);
|
|
186
|
+
log(`[Watcher] Watching current working directory (${process.cwd()}) instead`);
|
|
187
|
+
return process.cwd();
|
|
185
188
|
}
|
|
186
189
|
})(longestCommonPrefix(dirPaths.map(path => path.split(sep))).join(sep));
|
|
187
190
|
};
|
|
@@ -197,17 +200,15 @@ const findHighestCommonDirectory = async (files) => {
|
|
|
197
200
|
* @returns An array of path segments representing the longest common prefix of splitPaths
|
|
198
201
|
*/
|
|
199
202
|
const longestCommonPrefix = (splitPaths) => {
|
|
200
|
-
// Return early on empty input
|
|
201
203
|
if (!splitPaths.length) {
|
|
202
204
|
return [];
|
|
203
205
|
}
|
|
204
|
-
// Loop through the segments of the first path
|
|
205
206
|
for (let i = 0; i <= splitPaths[0].length; i++) {
|
|
206
|
-
// Check if this path segment is present in the same position of every path
|
|
207
207
|
if (!splitPaths.every(string => string[i] === splitPaths[0][i])) {
|
|
208
|
-
|
|
208
|
+
debugLog(`[Watcher] longestCommonPrefix at index ${i}: ${splitPaths[0].slice(0, i).join(sep)}`);
|
|
209
209
|
return splitPaths[0].slice(0, i);
|
|
210
210
|
}
|
|
211
211
|
}
|
|
212
|
+
debugLog(`[Watcher] longestCommonPrefix: ${splitPaths[0].join(sep)}`);
|
|
212
213
|
return splitPaths[0];
|
|
213
214
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-codegen/cli",
|
|
3
|
-
"version": "4.0.2-alpha-
|
|
3
|
+
"version": "4.0.2-alpha-20230725234859-7c312d8e7",
|
|
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
|
},
|