@graphql-codegen/cli 3.1.0-alpha-20230218173514-243806a7b → 3.1.0-alpha-20230219101228-e69f22193

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.
@@ -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 watcherSubscription;
54
+ let watcher;
55
55
  const runWatcher = async () => {
56
- const parcelWatcher = await Promise.resolve().then(() => tslib_1.__importStar(require('@parcel/watcher')));
57
- (0, debugging_js_1.debugLog)(`[Watcher] Parcel watcher loaded...`);
56
+ var _a, _b;
57
+ const chokidar = await Promise.resolve().then(() => tslib_1.__importStar(require('chokidar')));
58
58
  let isShutdown = false;
59
59
  const debouncedExec = (0, debounce_1.default)(() => {
60
60
  if (!isShutdown) {
@@ -79,39 +79,51 @@ const createWatcher = (initalContext, onNext) => {
79
79
  ignored.push(entry.filename);
80
80
  }
81
81
  });
82
- watcherSubscription = await parcelWatcher.subscribe(process.cwd(), async (err, 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 });
82
+ watcher = chokidar.watch(files, {
83
+ persistent: true,
84
+ ignoreInitial: true,
85
+ followSymlinks: true,
86
+ cwd: process.cwd(),
87
+ disableGlobbing: false,
88
+ usePolling: (_a = config.watchConfig) === null || _a === void 0 ? void 0 : _a.usePolling,
89
+ interval: (_b = config.watchConfig) === null || _b === void 0 ? void 0 : _b.interval,
90
+ depth: 99,
91
+ awaitWriteFinish: true,
92
+ ignorePermissionErrors: false,
93
+ atomic: true,
94
+ ignored,
95
+ });
107
96
  (0, debugging_js_1.debugLog)(`[Watcher] Started`);
108
97
  const shutdown = () => {
109
98
  isShutdown = true;
110
99
  (0, debugging_js_1.debugLog)(`[Watcher] Shutting down`);
111
100
  log(`Shutting down watch...`);
112
- watcherSubscription.unsubscribe();
101
+ watcher.close();
113
102
  (0, hooks_js_1.lifecycleHooks)(config.hooks).beforeDone();
114
103
  };
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
+ });
115
127
  process.once('SIGINT', shutdown);
116
128
  process.once('SIGTERM', shutdown);
117
129
  };
@@ -121,7 +133,7 @@ const createWatcher = (initalContext, onNext) => {
121
133
  .then(onNext, () => Promise.resolve())
122
134
  .then(runWatcher)
123
135
  .catch(err => {
124
- watcherSubscription.unsubscribe();
136
+ watcher.close();
125
137
  reject(err);
126
138
  });
127
139
  });
@@ -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 watcherSubscription;
50
+ let watcher;
51
51
  const runWatcher = async () => {
52
- const parcelWatcher = await import('@parcel/watcher');
53
- debugLog(`[Watcher] Parcel watcher loaded...`);
52
+ var _a, _b;
53
+ const chokidar = await import('chokidar');
54
54
  let isShutdown = false;
55
55
  const debouncedExec = debounce(() => {
56
56
  if (!isShutdown) {
@@ -75,39 +75,51 @@ export const createWatcher = (initalContext, onNext) => {
75
75
  ignored.push(entry.filename);
76
76
  }
77
77
  });
78
- watcherSubscription = await parcelWatcher.subscribe(process.cwd(), async (err, 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 });
78
+ watcher = chokidar.watch(files, {
79
+ persistent: true,
80
+ ignoreInitial: true,
81
+ followSymlinks: true,
82
+ cwd: process.cwd(),
83
+ disableGlobbing: false,
84
+ usePolling: (_a = config.watchConfig) === null || _a === void 0 ? void 0 : _a.usePolling,
85
+ interval: (_b = config.watchConfig) === null || _b === void 0 ? void 0 : _b.interval,
86
+ depth: 99,
87
+ awaitWriteFinish: true,
88
+ ignorePermissionErrors: false,
89
+ atomic: true,
90
+ ignored,
91
+ });
103
92
  debugLog(`[Watcher] Started`);
104
93
  const shutdown = () => {
105
94
  isShutdown = true;
106
95
  debugLog(`[Watcher] Shutting down`);
107
96
  log(`Shutting down watch...`);
108
- watcherSubscription.unsubscribe();
97
+ watcher.close();
109
98
  lifecycleHooks(config.hooks).beforeDone();
110
99
  };
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
+ });
111
123
  process.once('SIGINT', shutdown);
112
124
  process.once('SIGTERM', shutdown);
113
125
  };
@@ -117,7 +129,7 @@ export const createWatcher = (initalContext, onNext) => {
117
129
  .then(onNext, () => Promise.resolve())
118
130
  .then(runWatcher)
119
131
  .catch(err => {
120
- watcherSubscription.unsubscribe();
132
+ watcher.close();
121
133
  reject(err);
122
134
  });
123
135
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphql-codegen/cli",
3
- "version": "3.1.0-alpha-20230218173514-243806a7b",
3
+ "version": "3.1.0-alpha-20230219101228-e69f22193",
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-20230218173514-243806a7b",
12
- "@graphql-codegen/plugin-helpers": "4.1.0-alpha-20230218173514-243806a7b",
11
+ "@graphql-codegen/core": "3.0.1-alpha-20230219101228-e69f22193",
12
+ "@graphql-codegen/plugin-helpers": "4.1.0-alpha-20230219101228-e69f22193",
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",
24
23
  "@whatwg-node/fetch": "^0.8.0",
25
24
  "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",