@graphql-codegen/cli 2.6.0-alpha-3f811f314.0 → 2.6.0-alpha-88c2fecd3.0

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.
Files changed (4) hide show
  1. package/bin.js +7 -37
  2. package/index.js +7 -37
  3. package/index.mjs +7 -37
  4. package/package.json +1 -1
package/bin.js CHANGED
@@ -57,7 +57,6 @@ const os = require('os');
57
57
  const Listr = _interopDefault(require('listr'));
58
58
  const isGlob = _interopDefault(require('is-glob'));
59
59
  const debounce = _interopDefault(require('debounce'));
60
- const promises = require('fs/promises');
61
60
  const mkdirp = _interopDefault(require('mkdirp'));
62
61
  const crypto = require('crypto');
63
62
  const inquirer = _interopDefault(require('inquirer'));
@@ -1257,15 +1256,16 @@ const createWatcher = (initalContext, onNext) => {
1257
1256
  });
1258
1257
  };
1259
1258
 
1259
+ const { writeFile: fsWriteFile, readFile: fsReadFile, stat: fsStat } = fs.promises;
1260
1260
  function writeFile(filepath, content) {
1261
- return promises.writeFile(filepath, content);
1261
+ return fsWriteFile(filepath, content);
1262
1262
  }
1263
1263
  function readFile(filepath) {
1264
- return promises.readFile(filepath, 'utf-8');
1264
+ return fsReadFile(filepath, 'utf-8');
1265
1265
  }
1266
1266
  async function fileExists(filePath) {
1267
1267
  try {
1268
- return (await promises.stat(filePath)).isFile();
1268
+ return (await fsStat(filePath)).isFile();
1269
1269
  }
1270
1270
  catch (err) {
1271
1271
  return false;
@@ -1310,39 +1310,9 @@ async function generate(input, saveToFile = true) {
1310
1310
  }
1311
1311
  await context.profiler.run(async () => {
1312
1312
  await lifecycleHooks(config.hooks).beforeAllFileWrite(generationResult.map(r => r.filename));
1313
- await Promise.all(generationResult.map(async (result) => {
1314
- const exists = await fileExists(result.filename);
1315
- if (!shouldOverwrite(config, result.filename) && exists) {
1316
- return;
1317
- }
1318
- const content = result.content || '';
1319
- const currentHash = hash(content);
1320
- let previousHash = recentOutputHash.get(result.filename);
1321
- if (!previousHash && exists) {
1322
- previousHash = hash(await readFile(result.filename));
1323
- }
1324
- if (previousHash && currentHash === previousHash) {
1325
- debugLog(`Skipping file (${result.filename}) writing due to indentical hash...`);
1326
- return;
1327
- }
1328
- if (content.length === 0) {
1329
- return;
1330
- }
1331
- recentOutputHash.set(result.filename, currentHash);
1332
- const basedir = path.dirname(result.filename);
1333
- await lifecycleHooks(result.hooks).beforeOneFileWrite(result.filename);
1334
- await lifecycleHooks(config.hooks).beforeOneFileWrite(result.filename);
1335
- await mkdirp(basedir);
1336
- const absolutePath = path.isAbsolute(result.filename)
1337
- ? result.filename
1338
- : path.join(input.cwd || process.cwd(), result.filename);
1339
- await writeFile(absolutePath, result.content);
1340
- await lifecycleHooks(result.hooks).afterOneFileWrite(result.filename);
1341
- await lifecycleHooks(config.hooks).afterOneFileWrite(result.filename);
1342
- }));
1343
1313
  }, 'Lifecycle: beforeAllFileWrite');
1344
1314
  await context.profiler.run(() => Promise.all(generationResult.map(async (result) => {
1345
- const exists = fileExists(result.filename);
1315
+ const exists = await fileExists(result.filename);
1346
1316
  if (!shouldOverwrite(config, result.filename) && exists) {
1347
1317
  return;
1348
1318
  }
@@ -1353,7 +1323,7 @@ async function generate(input, saveToFile = true) {
1353
1323
  previousHash = hash(await readFile(result.filename));
1354
1324
  }
1355
1325
  if (previousHash && currentHash === previousHash) {
1356
- debugLog(`Skipping file (${result.filename}) writing due to identical hash...`);
1326
+ debugLog(`Skipping file (${result.filename}) writing due to indentical hash...`);
1357
1327
  return;
1358
1328
  }
1359
1329
  if (content.length === 0) {
@@ -1363,7 +1333,7 @@ async function generate(input, saveToFile = true) {
1363
1333
  const basedir = path.dirname(result.filename);
1364
1334
  await lifecycleHooks(result.hooks).beforeOneFileWrite(result.filename);
1365
1335
  await lifecycleHooks(config.hooks).beforeOneFileWrite(result.filename);
1366
- mkdirp.sync(basedir);
1336
+ await mkdirp(basedir);
1367
1337
  const absolutePath = path.isAbsolute(result.filename)
1368
1338
  ? result.filename
1369
1339
  : path.join(input.cwd || process.cwd(), result.filename);
package/index.js CHANGED
@@ -58,7 +58,6 @@ const Listr = _interopDefault(require('listr'));
58
58
  const child_process = require('child_process');
59
59
  const isGlob = _interopDefault(require('is-glob'));
60
60
  const debounce = _interopDefault(require('debounce'));
61
- const promises = require('fs/promises');
62
61
  const mkdirp = _interopDefault(require('mkdirp'));
63
62
  const crypto = require('crypto');
64
63
  const inquirer = _interopDefault(require('inquirer'));
@@ -1258,15 +1257,16 @@ const createWatcher = (initalContext, onNext) => {
1258
1257
  });
1259
1258
  };
1260
1259
 
1260
+ const { writeFile: fsWriteFile, readFile: fsReadFile, stat: fsStat } = fs.promises;
1261
1261
  function writeFile(filepath, content) {
1262
- return promises.writeFile(filepath, content);
1262
+ return fsWriteFile(filepath, content);
1263
1263
  }
1264
1264
  function readFile(filepath) {
1265
- return promises.readFile(filepath, 'utf-8');
1265
+ return fsReadFile(filepath, 'utf-8');
1266
1266
  }
1267
1267
  async function fileExists(filePath) {
1268
1268
  try {
1269
- return (await promises.stat(filePath)).isFile();
1269
+ return (await fsStat(filePath)).isFile();
1270
1270
  }
1271
1271
  catch (err) {
1272
1272
  return false;
@@ -1311,39 +1311,9 @@ async function generate(input, saveToFile = true) {
1311
1311
  }
1312
1312
  await context.profiler.run(async () => {
1313
1313
  await lifecycleHooks(config.hooks).beforeAllFileWrite(generationResult.map(r => r.filename));
1314
- await Promise.all(generationResult.map(async (result) => {
1315
- const exists = await fileExists(result.filename);
1316
- if (!shouldOverwrite(config, result.filename) && exists) {
1317
- return;
1318
- }
1319
- const content = result.content || '';
1320
- const currentHash = hash(content);
1321
- let previousHash = recentOutputHash.get(result.filename);
1322
- if (!previousHash && exists) {
1323
- previousHash = hash(await readFile(result.filename));
1324
- }
1325
- if (previousHash && currentHash === previousHash) {
1326
- debugLog(`Skipping file (${result.filename}) writing due to indentical hash...`);
1327
- return;
1328
- }
1329
- if (content.length === 0) {
1330
- return;
1331
- }
1332
- recentOutputHash.set(result.filename, currentHash);
1333
- const basedir = path.dirname(result.filename);
1334
- await lifecycleHooks(result.hooks).beforeOneFileWrite(result.filename);
1335
- await lifecycleHooks(config.hooks).beforeOneFileWrite(result.filename);
1336
- await mkdirp(basedir);
1337
- const absolutePath = path.isAbsolute(result.filename)
1338
- ? result.filename
1339
- : path.join(input.cwd || process.cwd(), result.filename);
1340
- await writeFile(absolutePath, result.content);
1341
- await lifecycleHooks(result.hooks).afterOneFileWrite(result.filename);
1342
- await lifecycleHooks(config.hooks).afterOneFileWrite(result.filename);
1343
- }));
1344
1314
  }, 'Lifecycle: beforeAllFileWrite');
1345
1315
  await context.profiler.run(() => Promise.all(generationResult.map(async (result) => {
1346
- const exists = fileExists(result.filename);
1316
+ const exists = await fileExists(result.filename);
1347
1317
  if (!shouldOverwrite(config, result.filename) && exists) {
1348
1318
  return;
1349
1319
  }
@@ -1354,7 +1324,7 @@ async function generate(input, saveToFile = true) {
1354
1324
  previousHash = hash(await readFile(result.filename));
1355
1325
  }
1356
1326
  if (previousHash && currentHash === previousHash) {
1357
- debugLog(`Skipping file (${result.filename}) writing due to identical hash...`);
1327
+ debugLog(`Skipping file (${result.filename}) writing due to indentical hash...`);
1358
1328
  return;
1359
1329
  }
1360
1330
  if (content.length === 0) {
@@ -1364,7 +1334,7 @@ async function generate(input, saveToFile = true) {
1364
1334
  const basedir = path.dirname(result.filename);
1365
1335
  await lifecycleHooks(result.hooks).beforeOneFileWrite(result.filename);
1366
1336
  await lifecycleHooks(config.hooks).beforeOneFileWrite(result.filename);
1367
- mkdirp.sync(basedir);
1337
+ await mkdirp(basedir);
1368
1338
  const absolutePath = path.isAbsolute(result.filename)
1369
1339
  ? result.filename
1370
1340
  : path.join(input.cwd || process.cwd(), result.filename);
package/index.mjs CHANGED
@@ -31,7 +31,6 @@ import Listr from 'listr';
31
31
  import { exec } from 'child_process';
32
32
  import isGlob from 'is-glob';
33
33
  import debounce from 'debounce';
34
- import { writeFile as writeFile$1, readFile as readFile$1, stat } from 'fs/promises';
35
34
  import mkdirp from 'mkdirp';
36
35
  import { createHash } from 'crypto';
37
36
  import inquirer from 'inquirer';
@@ -1231,15 +1230,16 @@ const createWatcher = (initalContext, onNext) => {
1231
1230
  });
1232
1231
  };
1233
1232
 
1233
+ const { writeFile: fsWriteFile, readFile: fsReadFile, stat: fsStat } = promises;
1234
1234
  function writeFile(filepath, content) {
1235
- return writeFile$1(filepath, content);
1235
+ return fsWriteFile(filepath, content);
1236
1236
  }
1237
1237
  function readFile(filepath) {
1238
- return readFile$1(filepath, 'utf-8');
1238
+ return fsReadFile(filepath, 'utf-8');
1239
1239
  }
1240
1240
  async function fileExists(filePath) {
1241
1241
  try {
1242
- return (await stat(filePath)).isFile();
1242
+ return (await fsStat(filePath)).isFile();
1243
1243
  }
1244
1244
  catch (err) {
1245
1245
  return false;
@@ -1284,39 +1284,9 @@ async function generate(input, saveToFile = true) {
1284
1284
  }
1285
1285
  await context.profiler.run(async () => {
1286
1286
  await lifecycleHooks(config.hooks).beforeAllFileWrite(generationResult.map(r => r.filename));
1287
- await Promise.all(generationResult.map(async (result) => {
1288
- const exists = await fileExists(result.filename);
1289
- if (!shouldOverwrite(config, result.filename) && exists) {
1290
- return;
1291
- }
1292
- const content = result.content || '';
1293
- const currentHash = hash(content);
1294
- let previousHash = recentOutputHash.get(result.filename);
1295
- if (!previousHash && exists) {
1296
- previousHash = hash(await readFile(result.filename));
1297
- }
1298
- if (previousHash && currentHash === previousHash) {
1299
- debugLog(`Skipping file (${result.filename}) writing due to indentical hash...`);
1300
- return;
1301
- }
1302
- if (content.length === 0) {
1303
- return;
1304
- }
1305
- recentOutputHash.set(result.filename, currentHash);
1306
- const basedir = dirname(result.filename);
1307
- await lifecycleHooks(result.hooks).beforeOneFileWrite(result.filename);
1308
- await lifecycleHooks(config.hooks).beforeOneFileWrite(result.filename);
1309
- await mkdirp(basedir);
1310
- const absolutePath = isAbsolute(result.filename)
1311
- ? result.filename
1312
- : join(input.cwd || process.cwd(), result.filename);
1313
- await writeFile(absolutePath, result.content);
1314
- await lifecycleHooks(result.hooks).afterOneFileWrite(result.filename);
1315
- await lifecycleHooks(config.hooks).afterOneFileWrite(result.filename);
1316
- }));
1317
1287
  }, 'Lifecycle: beforeAllFileWrite');
1318
1288
  await context.profiler.run(() => Promise.all(generationResult.map(async (result) => {
1319
- const exists = fileExists(result.filename);
1289
+ const exists = await fileExists(result.filename);
1320
1290
  if (!shouldOverwrite(config, result.filename) && exists) {
1321
1291
  return;
1322
1292
  }
@@ -1327,7 +1297,7 @@ async function generate(input, saveToFile = true) {
1327
1297
  previousHash = hash(await readFile(result.filename));
1328
1298
  }
1329
1299
  if (previousHash && currentHash === previousHash) {
1330
- debugLog(`Skipping file (${result.filename}) writing due to identical hash...`);
1300
+ debugLog(`Skipping file (${result.filename}) writing due to indentical hash...`);
1331
1301
  return;
1332
1302
  }
1333
1303
  if (content.length === 0) {
@@ -1337,7 +1307,7 @@ async function generate(input, saveToFile = true) {
1337
1307
  const basedir = dirname(result.filename);
1338
1308
  await lifecycleHooks(result.hooks).beforeOneFileWrite(result.filename);
1339
1309
  await lifecycleHooks(config.hooks).beforeOneFileWrite(result.filename);
1340
- mkdirp.sync(basedir);
1310
+ await mkdirp(basedir);
1341
1311
  const absolutePath = isAbsolute(result.filename)
1342
1312
  ? result.filename
1343
1313
  : join(input.cwd || process.cwd(), result.filename);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphql-codegen/cli",
3
- "version": "2.6.0-alpha-3f811f314.0",
3
+ "version": "2.6.0-alpha-88c2fecd3.0",
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
  },