@netlify/cache-utils 5.1.2 → 5.1.4

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/lib/hash.js CHANGED
@@ -2,10 +2,10 @@ import { createHash } from 'crypto';
2
2
  import { createReadStream } from 'fs';
3
3
  import getStream from 'get-stream';
4
4
  import { locatePath } from 'locate-path';
5
- // We need a hashing algoritm that's as fast as possible.
5
+ // We need a hashing algorithm that's as fast as possible.
6
6
  // Userland CRC32 implementations are actually slower than Node.js SHA1.
7
7
  const HASH_ALGO = 'sha1';
8
- // Caching a big directory like `node_modules` is slow. However those can
8
+ // Caching a big directory like `node_modules` is slow. However, those can
9
9
  // sometime be represented by a digest file such as `package-lock.json`. If this
10
10
  // has not changed, we don't need to save cache again.
11
11
  export const getHash = async function (digests, move) {
package/lib/main.js CHANGED
@@ -1,4 +1,4 @@
1
- import del from 'del';
1
+ import { rm } from 'fs/promises';
2
2
  import { getCacheDir } from './dir.js';
3
3
  import { moveCacheFile, hasFiles } from './fs.js';
4
4
  import { list } from './list.js';
@@ -16,7 +16,7 @@ const saveOne = async function (path, { move = DEFAULT_MOVE, ttl = DEFAULT_TTL,
16
16
  if (identical) {
17
17
  return true;
18
18
  }
19
- await del(cachePath, { force: true });
19
+ await rm(cachePath, { force: true, recursive: true, maxRetries: 3 });
20
20
  await moveCacheFile(srcPath, cachePath, move);
21
21
  await writeManifest(manifestInfo);
22
22
  return true;
@@ -30,7 +30,7 @@ const restoreOne = async function (path, { move = DEFAULT_MOVE, cacheDir, cwd: c
30
30
  if (await isExpired(cachePath)) {
31
31
  return false;
32
32
  }
33
- await del(srcPath, { force: true });
33
+ await rm(srcPath, { force: true, recursive: true, maxRetries: 3 });
34
34
  await moveCacheFile(cachePath, srcPath, move);
35
35
  return true;
36
36
  };
@@ -40,7 +40,7 @@ const removeOne = async function (path, { cacheDir, cwd: cwdOpt, } = {}) {
40
40
  if (!(await hasFiles(cachePath))) {
41
41
  return false;
42
42
  }
43
- await del(cachePath, { force: true });
43
+ await rm(cachePath, { force: true, recursive: true, maxRetries: 3 });
44
44
  await removeManifest(cachePath);
45
45
  return true;
46
46
  };
package/lib/manifest.js CHANGED
@@ -1,6 +1,5 @@
1
- import { promises as fs } from 'fs';
1
+ import { mkdir, readFile, rm, writeFile } from 'fs/promises';
2
2
  import { dirname } from 'path';
3
- import del from 'del';
4
3
  import { pathExists } from 'path-exists';
5
4
  import { getExpires, checkExpires } from './expire.js';
6
5
  import { getHash } from './hash.js';
@@ -20,18 +19,18 @@ const isIdentical = async function ({ hash, manifestPath, manifestString }) {
20
19
  if (hash === undefined || !(await pathExists(manifestPath))) {
21
20
  return false;
22
21
  }
23
- const oldManifestString = await fs.readFile(manifestPath, 'utf8');
22
+ const oldManifestString = await readFile(manifestPath, 'utf8');
24
23
  return oldManifestString === manifestString;
25
24
  };
26
25
  // Persist the cache manifest to filesystem
27
26
  export const writeManifest = async function ({ manifestPath, manifestString }) {
28
- await fs.mkdir(dirname(manifestPath), { recursive: true });
29
- await fs.writeFile(manifestPath, manifestString);
27
+ await mkdir(dirname(manifestPath), { recursive: true });
28
+ await writeFile(manifestPath, manifestString);
30
29
  };
31
30
  // Remove the cache manifest from filesystem
32
31
  export const removeManifest = async function (cachePath) {
33
32
  const manifestPath = getManifestPath(cachePath);
34
- await del(manifestPath, { force: true });
33
+ await rm(manifestPath, { force: true, recursive: true, maxRetries: 3 });
35
34
  };
36
35
  // Retrieve the cache manifest filepath
37
36
  const getManifestPath = function (cachePath) {
@@ -52,7 +51,7 @@ export const isExpired = async function (cachePath) {
52
51
  };
53
52
  const readManifest = async function (cachePath) {
54
53
  const manifestPath = getManifestPath(cachePath);
55
- const manifestString = await fs.readFile(manifestPath, 'utf-8');
54
+ const manifestString = await readFile(manifestPath, 'utf-8');
56
55
  const manifest = JSON.parse(manifestString);
57
56
  return manifest;
58
57
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netlify/cache-utils",
3
- "version": "5.1.2",
3
+ "version": "5.1.4",
4
4
  "description": "Utility for caching files in Netlify Build",
5
5
  "type": "module",
6
6
  "exports": "./lib/main.js",
@@ -51,7 +51,6 @@
51
51
  "license": "MIT",
52
52
  "dependencies": {
53
53
  "cpy": "^8.1.0",
54
- "del": "^6.0.0",
55
54
  "get-stream": "^6.0.0",
56
55
  "globby": "^13.0.0",
57
56
  "junk": "^4.0.0",
@@ -61,13 +60,13 @@
61
60
  "readdirp": "^3.4.0"
62
61
  },
63
62
  "devDependencies": {
64
- "@types/node": "^14.18.31",
63
+ "@types/node": "^18.14.2",
65
64
  "tmp-promise": "^3.0.0",
66
- "typescript": "^4.8.4",
67
- "vitest": "^0.24.1"
65
+ "typescript": "^5.0.0",
66
+ "vitest": "^0.30.1"
68
67
  },
69
68
  "engines": {
70
69
  "node": "^14.16.0 || >=16.0.0"
71
70
  },
72
- "gitHead": "d78a65c209ed987d3475cd1f37cf357693b99e3c"
71
+ "gitHead": "63fb29bbcdc2255fad2dcde9b52c21b12bbf79f2"
73
72
  }