@graphql-codegen/cli 4.0.2-alpha-20230706143738-f59fb0497 → 5.0.0-alpha-20230707093832-19f7bddb4
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 -19
- package/esm/utils/watcher.js +15 -19
- package/package.json +7 -2
package/cjs/utils/watcher.js
CHANGED
|
@@ -34,7 +34,15 @@ const createWatcher = (initialContext, onNext) => {
|
|
|
34
34
|
let watcherSubscription;
|
|
35
35
|
const runWatcher = async (abortSignal) => {
|
|
36
36
|
const watchDirectory = await findHighestCommonDirectory(allAffirmativePatterns);
|
|
37
|
-
|
|
37
|
+
// Try to load the parcel watcher, but don't fail if it's not available.
|
|
38
|
+
let parcelWatcher;
|
|
39
|
+
try {
|
|
40
|
+
parcelWatcher = await Promise.resolve().then(() => tslib_1.__importStar(require('@parcel/watcher')));
|
|
41
|
+
}
|
|
42
|
+
catch (err) {
|
|
43
|
+
log(`Parcel watcher not found. To use this feature, please make sure to provide @parcel/watcher as a peer dependency.`);
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
38
46
|
(0, debugging_js_1.debugLog)(`[Watcher] Parcel watcher loaded...`);
|
|
39
47
|
let isShutdown = false;
|
|
40
48
|
const debouncedExec = (0, debounce_1.default)(() => {
|
|
@@ -185,39 +193,27 @@ const findHighestCommonDirectory = async (files) => {
|
|
|
185
193
|
};
|
|
186
194
|
/**
|
|
187
195
|
* Find the longest common prefix of an array of paths, where each item in
|
|
188
|
-
* the array
|
|
189
|
-
* joined together by a path separator
|
|
196
|
+
* the array an array of path segments which comprise an absolute path when
|
|
197
|
+
* joined together by a path separator
|
|
190
198
|
*
|
|
191
199
|
* Adapted from:
|
|
192
200
|
* https://duncan-mcardle.medium.com/leetcode-problem-14-longest-common-prefix-javascript-3bc6a2f777c4
|
|
193
201
|
*
|
|
194
|
-
*
|
|
195
|
-
*
|
|
196
|
-
*
|
|
197
|
-
* @param splitPaths An array of arrays, where each item is a path split by its separator.
|
|
198
|
-
* The first item is treated separately as it could be a drive letter in Windows.
|
|
199
|
-
* @returns An array of path segments representing the longest common prefix of splitPaths.
|
|
202
|
+
* @param splitPaths An array of arrays, where each item is a path split by its separator
|
|
203
|
+
* @returns An array of path segments representing the longest common prefix of splitPaths
|
|
200
204
|
*/
|
|
201
205
|
const longestCommonPrefix = (splitPaths) => {
|
|
202
206
|
// Return early on empty input
|
|
203
207
|
if (!splitPaths.length) {
|
|
204
208
|
return [];
|
|
205
209
|
}
|
|
206
|
-
// Added: handle Windows drive letters
|
|
207
|
-
const driveLetter = splitPaths[0][0];
|
|
208
|
-
if (driveLetter && splitPaths.every(string => string[0] === driveLetter)) {
|
|
209
|
-
splitPaths = splitPaths.map(path => path.slice(1));
|
|
210
|
-
}
|
|
211
|
-
else {
|
|
212
|
-
return [];
|
|
213
|
-
}
|
|
214
210
|
// Loop through the segments of the first path
|
|
215
211
|
for (let i = 0; i <= splitPaths[0].length; i++) {
|
|
216
212
|
// Check if this path segment is present in the same position of every path
|
|
217
213
|
if (!splitPaths.every(string => string[i] === splitPaths[0][i])) {
|
|
218
214
|
// If not, return the path segments up to and including the previous segment
|
|
219
|
-
return
|
|
215
|
+
return splitPaths[0].slice(0, i);
|
|
220
216
|
}
|
|
221
217
|
}
|
|
222
|
-
return
|
|
218
|
+
return splitPaths[0];
|
|
223
219
|
};
|
package/esm/utils/watcher.js
CHANGED
|
@@ -30,7 +30,15 @@ export const createWatcher = (initialContext, onNext) => {
|
|
|
30
30
|
let watcherSubscription;
|
|
31
31
|
const runWatcher = async (abortSignal) => {
|
|
32
32
|
const watchDirectory = await findHighestCommonDirectory(allAffirmativePatterns);
|
|
33
|
-
|
|
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 (err) {
|
|
39
|
+
log(`Parcel watcher not found. To use this feature, please make sure to provide @parcel/watcher as a peer dependency.`);
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
34
42
|
debugLog(`[Watcher] Parcel watcher loaded...`);
|
|
35
43
|
let isShutdown = false;
|
|
36
44
|
const debouncedExec = debounce(() => {
|
|
@@ -180,39 +188,27 @@ const findHighestCommonDirectory = async (files) => {
|
|
|
180
188
|
};
|
|
181
189
|
/**
|
|
182
190
|
* Find the longest common prefix of an array of paths, where each item in
|
|
183
|
-
* the array
|
|
184
|
-
* joined together by a path separator
|
|
191
|
+
* the array an array of path segments which comprise an absolute path when
|
|
192
|
+
* joined together by a path separator
|
|
185
193
|
*
|
|
186
194
|
* Adapted from:
|
|
187
195
|
* https://duncan-mcardle.medium.com/leetcode-problem-14-longest-common-prefix-javascript-3bc6a2f777c4
|
|
188
196
|
*
|
|
189
|
-
*
|
|
190
|
-
*
|
|
191
|
-
*
|
|
192
|
-
* @param splitPaths An array of arrays, where each item is a path split by its separator.
|
|
193
|
-
* The first item is treated separately as it could be a drive letter in Windows.
|
|
194
|
-
* @returns An array of path segments representing the longest common prefix of splitPaths.
|
|
197
|
+
* @param splitPaths An array of arrays, where each item is a path split by its separator
|
|
198
|
+
* @returns An array of path segments representing the longest common prefix of splitPaths
|
|
195
199
|
*/
|
|
196
200
|
const longestCommonPrefix = (splitPaths) => {
|
|
197
201
|
// Return early on empty input
|
|
198
202
|
if (!splitPaths.length) {
|
|
199
203
|
return [];
|
|
200
204
|
}
|
|
201
|
-
// Added: handle Windows drive letters
|
|
202
|
-
const driveLetter = splitPaths[0][0];
|
|
203
|
-
if (driveLetter && splitPaths.every(string => string[0] === driveLetter)) {
|
|
204
|
-
splitPaths = splitPaths.map(path => path.slice(1));
|
|
205
|
-
}
|
|
206
|
-
else {
|
|
207
|
-
return [];
|
|
208
|
-
}
|
|
209
205
|
// Loop through the segments of the first path
|
|
210
206
|
for (let i = 0; i <= splitPaths[0].length; i++) {
|
|
211
207
|
// Check if this path segment is present in the same position of every path
|
|
212
208
|
if (!splitPaths.every(string => string[i] === splitPaths[0][i])) {
|
|
213
209
|
// If not, return the path segments up to and including the previous segment
|
|
214
|
-
return
|
|
210
|
+
return splitPaths[0].slice(0, i);
|
|
215
211
|
}
|
|
216
212
|
}
|
|
217
|
-
return
|
|
213
|
+
return splitPaths[0];
|
|
218
214
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-codegen/cli",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0-alpha-20230707093832-19f7bddb4",
|
|
4
|
+
"peerDependenciesMeta": {
|
|
5
|
+
"@parcel/watcher": {
|
|
6
|
+
"optional": true
|
|
7
|
+
}
|
|
8
|
+
},
|
|
4
9
|
"peerDependencies": {
|
|
10
|
+
"@parcel/watcher": "^2.1.0",
|
|
5
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"
|
|
6
12
|
},
|
|
7
13
|
"dependencies": {
|
|
@@ -20,7 +26,6 @@
|
|
|
20
26
|
"@graphql-tools/prisma-loader": "^8.0.0",
|
|
21
27
|
"@graphql-tools/url-loader": "^8.0.0",
|
|
22
28
|
"@graphql-tools/utils": "^10.0.0",
|
|
23
|
-
"@parcel/watcher": "^2.1.0",
|
|
24
29
|
"@whatwg-node/fetch": "^0.8.0",
|
|
25
30
|
"chalk": "^4.1.0",
|
|
26
31
|
"cosmiconfig": "^8.1.3",
|