@prisma/fetch-engine 5.23.0-dev.5 → 5.23.0-dev.7

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.
@@ -26,17 +26,17 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
26
26
  mod
27
27
  ));
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var chunk_QLWYUM7O_exports = {};
30
- __export(chunk_QLWYUM7O_exports, {
29
+ var chunk_2O3VJOGU_exports = {};
30
+ __export(chunk_2O3VJOGU_exports, {
31
31
  downloadZip: () => downloadZip,
32
32
  require_is_stream: () => require_is_stream,
33
33
  require_temp_dir: () => require_temp_dir
34
34
  });
35
- module.exports = __toCommonJS(chunk_QLWYUM7O_exports);
35
+ module.exports = __toCommonJS(chunk_2O3VJOGU_exports);
36
36
  var import_chunk_VTJS2JJN = require("./chunk-VTJS2JJN.js");
37
37
  var import_chunk_RGVHWUUH = require("./chunk-RGVHWUUH.js");
38
38
  var import_chunk_FQ2BOR66 = require("./chunk-FQ2BOR66.js");
39
- var import_chunk_KDPLGCY6 = require("./chunk-KDPLGCY6.js");
39
+ var import_chunk_OFSFRIEP = require("./chunk-OFSFRIEP.js");
40
40
  var import_chunk_AH6QHEOA = require("./chunk-AH6QHEOA.js");
41
41
  var import_debug = __toESM(require("@prisma/debug"));
42
42
  var import_fs = __toESM(require("fs"));
@@ -8001,7 +8001,7 @@ async function fetchChecksum(url) {
8001
8001
  try {
8002
8002
  const checksumUrl = `${url}.sha256`;
8003
8003
  const response = await fetch(checksumUrl, {
8004
- agent: (0, import_chunk_KDPLGCY6.getProxyAgent)(url)
8004
+ agent: (0, import_chunk_OFSFRIEP.getProxyAgent)(url)
8005
8005
  });
8006
8006
  if (!response.ok) {
8007
8007
  let errorMessage = `Failed to fetch sha256 checksum at ${checksumUrl} - ${response.status} ${response.statusText}`;
@@ -8047,7 +8047,7 @@ async function downloadZip(url, target, progressCb) {
8047
8047
  async () => {
8048
8048
  const response = await fetch(url, {
8049
8049
  compress: false,
8050
- agent: (0, import_chunk_KDPLGCY6.getProxyAgent)(url)
8050
+ agent: (0, import_chunk_OFSFRIEP.getProxyAgent)(url)
8051
8051
  });
8052
8052
  if (!response.ok) {
8053
8053
  throw new Error(`Failed to fetch the engine file at ${url} - ${response.status} ${response.statusText}`);
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var chunk_74KKSUUB_exports = {};
30
+ __export(chunk_74KKSUUB_exports, {
31
+ cleanupCache: () => cleanupCache
32
+ });
33
+ module.exports = __toCommonJS(chunk_74KKSUUB_exports);
34
+ var import_chunk_RGVHWUUH = require("./chunk-RGVHWUUH.js");
35
+ var import_chunk_BBSR4B7O = require("./chunk-BBSR4B7O.js");
36
+ var import_chunk_AH6QHEOA = require("./chunk-AH6QHEOA.js");
37
+ var import_debug = __toESM(require("@prisma/debug"));
38
+ var import_fs = __toESM(require("fs"));
39
+ var import_path = __toESM(require("path"));
40
+ var import_util = require("util");
41
+ var import_p_map = (0, import_chunk_AH6QHEOA.__toESM)((0, import_chunk_RGVHWUUH.require_p_map)());
42
+ var import_rimraf = (0, import_chunk_AH6QHEOA.__toESM)((0, import_chunk_RGVHWUUH.require_rimraf)());
43
+ var debug = (0, import_debug.default)("cleanupCache");
44
+ var del = (0, import_util.promisify)(import_rimraf.default);
45
+ async function cleanupCache(n = 5) {
46
+ try {
47
+ const rootCacheDir = await (0, import_chunk_BBSR4B7O.getRootCacheDir)();
48
+ if (!rootCacheDir) {
49
+ debug("no rootCacheDir found");
50
+ return;
51
+ }
52
+ const channel = "master";
53
+ const cacheDir = import_path.default.join(rootCacheDir, channel);
54
+ const dirs = await import_fs.default.promises.readdir(cacheDir);
55
+ const dirsWithMeta = await Promise.all(
56
+ dirs.map(async (dirName) => {
57
+ const dir = import_path.default.join(cacheDir, dirName);
58
+ const statResult = await import_fs.default.promises.stat(dir);
59
+ return {
60
+ dir,
61
+ created: statResult.birthtime
62
+ };
63
+ })
64
+ );
65
+ dirsWithMeta.sort((a, b) => a.created < b.created ? 1 : -1);
66
+ const dirsToRemove = dirsWithMeta.slice(n);
67
+ await (0, import_p_map.default)(dirsToRemove, (dir) => del(dir.dir), { concurrency: 20 });
68
+ } catch (e) {
69
+ }
70
+ }