@graphql-codegen/cli 3.1.0-alpha-20230220215608-bfc52c524 → 3.1.0-alpha-20230220220141-e01f01d51
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 +30 -42
- package/esm/utils/watcher.js +30 -42
- package/package.json +4 -4
package/cjs/utils/watcher.js
CHANGED
|
@@ -51,10 +51,10 @@ const createWatcher = (initalContext, onNext) => {
|
|
|
51
51
|
if (typeof config.watch !== 'boolean') {
|
|
52
52
|
files.push(...(0, plugin_helpers_1.normalizeInstanceOrArray)(config.watch));
|
|
53
53
|
}
|
|
54
|
-
let
|
|
54
|
+
let watcherSubscription;
|
|
55
55
|
const runWatcher = async () => {
|
|
56
|
-
|
|
57
|
-
|
|
56
|
+
const parcelWatcher = await Promise.resolve().then(() => tslib_1.__importStar(require('@parcel/watcher')));
|
|
57
|
+
(0, debugging_js_1.debugLog)(`[Watcher] Parcel watcher loaded...`);
|
|
58
58
|
let isShutdown = false;
|
|
59
59
|
const debouncedExec = (0, debounce_1.default)(() => {
|
|
60
60
|
if (!isShutdown) {
|
|
@@ -79,51 +79,39 @@ const createWatcher = (initalContext, onNext) => {
|
|
|
79
79
|
ignored.push(entry.filename);
|
|
80
80
|
}
|
|
81
81
|
});
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
82
|
+
watcherSubscription = await parcelWatcher.subscribe(process.cwd(), async (_, events) => {
|
|
83
|
+
// it doesn't matter what has changed, need to run whole process anyway
|
|
84
|
+
await Promise.all(events.map(async ({ type: eventName, path }) => {
|
|
85
|
+
(0, hooks_js_1.lifecycleHooks)(config.hooks).onWatchTriggered(eventName, path);
|
|
86
|
+
(0, debugging_js_1.debugLog)(`[Watcher] triggered due to a file ${eventName} event: ${path}`);
|
|
87
|
+
const fullPath = (0, path_1.join)(process.cwd(), path);
|
|
88
|
+
// In ESM require is not defined
|
|
89
|
+
try {
|
|
90
|
+
delete require.cache[fullPath];
|
|
91
|
+
}
|
|
92
|
+
catch (err) { }
|
|
93
|
+
if (eventName === 'update' && config.configFilePath && fullPath === config.configFilePath) {
|
|
94
|
+
log(`${log_symbols_1.default.info} Config file has changed, reloading...`);
|
|
95
|
+
const context = await (0, config_js_1.loadContext)(config.configFilePath);
|
|
96
|
+
const newParsedConfig = context.getConfig();
|
|
97
|
+
newParsedConfig.watch = config.watch;
|
|
98
|
+
newParsedConfig.silent = config.silent;
|
|
99
|
+
newParsedConfig.overwrite = config.overwrite;
|
|
100
|
+
newParsedConfig.configFilePath = config.configFilePath;
|
|
101
|
+
config = newParsedConfig;
|
|
102
|
+
initalContext.updateConfig(config);
|
|
103
|
+
}
|
|
104
|
+
debouncedExec();
|
|
105
|
+
}));
|
|
106
|
+
}, { ignore: ignored });
|
|
96
107
|
(0, debugging_js_1.debugLog)(`[Watcher] Started`);
|
|
97
108
|
const shutdown = () => {
|
|
98
109
|
isShutdown = true;
|
|
99
110
|
(0, debugging_js_1.debugLog)(`[Watcher] Shutting down`);
|
|
100
111
|
log(`Shutting down watch...`);
|
|
101
|
-
|
|
112
|
+
watcherSubscription.unsubscribe();
|
|
102
113
|
(0, hooks_js_1.lifecycleHooks)(config.hooks).beforeDone();
|
|
103
114
|
};
|
|
104
|
-
// it doesn't matter what has changed, need to run whole process anyway
|
|
105
|
-
watcher.on('all', async (eventName, path) => {
|
|
106
|
-
(0, hooks_js_1.lifecycleHooks)(config.hooks).onWatchTriggered(eventName, path);
|
|
107
|
-
(0, debugging_js_1.debugLog)(`[Watcher] triggered due to a file ${eventName} event: ${path}`);
|
|
108
|
-
const fullPath = (0, path_1.join)(process.cwd(), path);
|
|
109
|
-
// In ESM require is not defined
|
|
110
|
-
try {
|
|
111
|
-
delete require.cache[fullPath];
|
|
112
|
-
}
|
|
113
|
-
catch (err) { }
|
|
114
|
-
if (eventName === 'change' && config.configFilePath && fullPath === config.configFilePath) {
|
|
115
|
-
log(`${log_symbols_1.default.info} Config file has changed, reloading...`);
|
|
116
|
-
const context = await (0, config_js_1.loadContext)(config.configFilePath);
|
|
117
|
-
const newParsedConfig = context.getConfig();
|
|
118
|
-
newParsedConfig.watch = config.watch;
|
|
119
|
-
newParsedConfig.silent = config.silent;
|
|
120
|
-
newParsedConfig.overwrite = config.overwrite;
|
|
121
|
-
newParsedConfig.configFilePath = config.configFilePath;
|
|
122
|
-
config = newParsedConfig;
|
|
123
|
-
initalContext.updateConfig(config);
|
|
124
|
-
}
|
|
125
|
-
debouncedExec();
|
|
126
|
-
});
|
|
127
115
|
process.once('SIGINT', shutdown);
|
|
128
116
|
process.once('SIGTERM', shutdown);
|
|
129
117
|
};
|
|
@@ -133,7 +121,7 @@ const createWatcher = (initalContext, onNext) => {
|
|
|
133
121
|
.then(onNext, () => Promise.resolve())
|
|
134
122
|
.then(runWatcher)
|
|
135
123
|
.catch(err => {
|
|
136
|
-
|
|
124
|
+
watcherSubscription.unsubscribe();
|
|
137
125
|
reject(err);
|
|
138
126
|
});
|
|
139
127
|
});
|
package/esm/utils/watcher.js
CHANGED
|
@@ -47,10 +47,10 @@ export const createWatcher = (initalContext, onNext) => {
|
|
|
47
47
|
if (typeof config.watch !== 'boolean') {
|
|
48
48
|
files.push(...normalizeInstanceOrArray(config.watch));
|
|
49
49
|
}
|
|
50
|
-
let
|
|
50
|
+
let watcherSubscription;
|
|
51
51
|
const runWatcher = async () => {
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
const parcelWatcher = await import('@parcel/watcher');
|
|
53
|
+
debugLog(`[Watcher] Parcel watcher loaded...`);
|
|
54
54
|
let isShutdown = false;
|
|
55
55
|
const debouncedExec = debounce(() => {
|
|
56
56
|
if (!isShutdown) {
|
|
@@ -75,51 +75,39 @@ export const createWatcher = (initalContext, onNext) => {
|
|
|
75
75
|
ignored.push(entry.filename);
|
|
76
76
|
}
|
|
77
77
|
});
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
78
|
+
watcherSubscription = await parcelWatcher.subscribe(process.cwd(), async (_, events) => {
|
|
79
|
+
// it doesn't matter what has changed, need to run whole process anyway
|
|
80
|
+
await Promise.all(events.map(async ({ type: eventName, path }) => {
|
|
81
|
+
lifecycleHooks(config.hooks).onWatchTriggered(eventName, path);
|
|
82
|
+
debugLog(`[Watcher] triggered due to a file ${eventName} event: ${path}`);
|
|
83
|
+
const fullPath = join(process.cwd(), path);
|
|
84
|
+
// In ESM require is not defined
|
|
85
|
+
try {
|
|
86
|
+
delete require.cache[fullPath];
|
|
87
|
+
}
|
|
88
|
+
catch (err) { }
|
|
89
|
+
if (eventName === 'update' && config.configFilePath && fullPath === config.configFilePath) {
|
|
90
|
+
log(`${logSymbols.info} Config file has changed, reloading...`);
|
|
91
|
+
const context = await loadContext(config.configFilePath);
|
|
92
|
+
const newParsedConfig = context.getConfig();
|
|
93
|
+
newParsedConfig.watch = config.watch;
|
|
94
|
+
newParsedConfig.silent = config.silent;
|
|
95
|
+
newParsedConfig.overwrite = config.overwrite;
|
|
96
|
+
newParsedConfig.configFilePath = config.configFilePath;
|
|
97
|
+
config = newParsedConfig;
|
|
98
|
+
initalContext.updateConfig(config);
|
|
99
|
+
}
|
|
100
|
+
debouncedExec();
|
|
101
|
+
}));
|
|
102
|
+
}, { ignore: ignored });
|
|
92
103
|
debugLog(`[Watcher] Started`);
|
|
93
104
|
const shutdown = () => {
|
|
94
105
|
isShutdown = true;
|
|
95
106
|
debugLog(`[Watcher] Shutting down`);
|
|
96
107
|
log(`Shutting down watch...`);
|
|
97
|
-
|
|
108
|
+
watcherSubscription.unsubscribe();
|
|
98
109
|
lifecycleHooks(config.hooks).beforeDone();
|
|
99
110
|
};
|
|
100
|
-
// it doesn't matter what has changed, need to run whole process anyway
|
|
101
|
-
watcher.on('all', async (eventName, path) => {
|
|
102
|
-
lifecycleHooks(config.hooks).onWatchTriggered(eventName, path);
|
|
103
|
-
debugLog(`[Watcher] triggered due to a file ${eventName} event: ${path}`);
|
|
104
|
-
const fullPath = join(process.cwd(), path);
|
|
105
|
-
// In ESM require is not defined
|
|
106
|
-
try {
|
|
107
|
-
delete require.cache[fullPath];
|
|
108
|
-
}
|
|
109
|
-
catch (err) { }
|
|
110
|
-
if (eventName === 'change' && config.configFilePath && fullPath === config.configFilePath) {
|
|
111
|
-
log(`${logSymbols.info} Config file has changed, reloading...`);
|
|
112
|
-
const context = await loadContext(config.configFilePath);
|
|
113
|
-
const newParsedConfig = context.getConfig();
|
|
114
|
-
newParsedConfig.watch = config.watch;
|
|
115
|
-
newParsedConfig.silent = config.silent;
|
|
116
|
-
newParsedConfig.overwrite = config.overwrite;
|
|
117
|
-
newParsedConfig.configFilePath = config.configFilePath;
|
|
118
|
-
config = newParsedConfig;
|
|
119
|
-
initalContext.updateConfig(config);
|
|
120
|
-
}
|
|
121
|
-
debouncedExec();
|
|
122
|
-
});
|
|
123
111
|
process.once('SIGINT', shutdown);
|
|
124
112
|
process.once('SIGTERM', shutdown);
|
|
125
113
|
};
|
|
@@ -129,7 +117,7 @@ export const createWatcher = (initalContext, onNext) => {
|
|
|
129
117
|
.then(onNext, () => Promise.resolve())
|
|
130
118
|
.then(runWatcher)
|
|
131
119
|
.catch(err => {
|
|
132
|
-
|
|
120
|
+
watcherSubscription.unsubscribe();
|
|
133
121
|
reject(err);
|
|
134
122
|
});
|
|
135
123
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-codegen/cli",
|
|
3
|
-
"version": "3.1.0-alpha-
|
|
3
|
+
"version": "3.1.0-alpha-20230220220141-e01f01d51",
|
|
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
|
},
|
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
"@babel/generator": "^7.18.13",
|
|
9
9
|
"@babel/template": "^7.18.10",
|
|
10
10
|
"@babel/types": "^7.18.13",
|
|
11
|
-
"@graphql-codegen/core": "3.0.1-alpha-
|
|
12
|
-
"@graphql-codegen/plugin-helpers": "4.1.0-alpha-
|
|
11
|
+
"@graphql-codegen/core": "3.0.1-alpha-20230220220141-e01f01d51",
|
|
12
|
+
"@graphql-codegen/plugin-helpers": "4.1.0-alpha-20230220220141-e01f01d51",
|
|
13
13
|
"@graphql-tools/apollo-engine-loader": "^7.3.6",
|
|
14
14
|
"@graphql-tools/code-file-loader": "^7.3.17",
|
|
15
15
|
"@graphql-tools/git-loader": "^7.2.13",
|
|
@@ -20,9 +20,9 @@
|
|
|
20
20
|
"@graphql-tools/prisma-loader": "^7.2.49",
|
|
21
21
|
"@graphql-tools/url-loader": "^7.13.2",
|
|
22
22
|
"@graphql-tools/utils": "^9.0.0",
|
|
23
|
+
"@parcel/watcher": "^2.1.0",
|
|
23
24
|
"@whatwg-node/fetch": "^0.8.0",
|
|
24
25
|
"chalk": "^4.1.0",
|
|
25
|
-
"chokidar": "^3.5.2",
|
|
26
26
|
"cosmiconfig": "^7.0.0",
|
|
27
27
|
"cosmiconfig-typescript-loader": "^4.3.0",
|
|
28
28
|
"debounce": "^1.2.0",
|