lockfile-hasher 1.0.0 → 1.0.2

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/dist/index.d.ts CHANGED
@@ -1,10 +1,6 @@
1
- type LockFileName = 'package-lock.json' | 'pnpm-lock.yaml' | 'yarn.lock';
2
1
  /**
3
2
  * Generate a combined hash of all lock files in a repo.
4
3
  * @param {string} rootPath - Root path of the repository
5
- * @param {LockFileName} lockFileName - Name of the lock file to search for.
6
- * Currently supports 'package-lock.json', 'pnpm-lock.yaml', and 'yarn.lock'
7
4
  * @returns {Promise<string>} - Combined hash string
8
5
  */
9
- export declare function generateCombinedLockFileHash(rootPath: string, lockFileName: LockFileName): Promise<string>;
10
- export {};
6
+ export declare function generateCombinedLockFileHash(rootPath: string): Promise<string>;
package/dist/index.js CHANGED
@@ -1,18 +1,16 @@
1
- // hash-package-locks.js
2
1
  import crypto from 'node:crypto';
3
2
  import { readFile } from 'node:fs/promises';
4
3
  import path from 'node:path';
5
4
  import { glob } from 'glob';
5
+ const GLOB_PATTERNS = ['**/package-lock.json', '**/yarn.lock', '**/pnpm-lock.yaml'];
6
+ const GLOB_OPTIONS = { ignore: '**/node_modules/**' };
6
7
  /**
7
8
  * Generate a combined hash of all lock files in a repo.
8
9
  * @param {string} rootPath - Root path of the repository
9
- * @param {LockFileName} lockFileName - Name of the lock file to search for.
10
- * Currently supports 'package-lock.json', 'pnpm-lock.yaml', and 'yarn.lock'
11
10
  * @returns {Promise<string>} - Combined hash string
12
11
  */
13
- export async function generateCombinedLockFileHash(rootPath, lockFileName) {
14
- const pattern = path.join(rootPath, `**/${lockFileName}`);
15
- const files = await glob(pattern, { ignore: '**/node_modules/**' });
12
+ export async function generateCombinedLockFileHash(rootPath) {
13
+ const files = await Promise.all(GLOB_PATTERNS.map((pattern) => glob(path.join(rootPath, pattern), GLOB_OPTIONS))).then((results) => results.flat());
16
14
  const fileContents = await Promise.all(files.map((file) => readFile(file)));
17
15
  // Generate hash for each file
18
16
  const hashesMap = {};
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,wBAAwB;AACxB,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAI5B;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,4BAA4B,CAChD,QAAgB,EAChB,YAA0B;IAE1B,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,MAAM,YAAY,EAAE,CAAC,CAAC;IAC1D,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,OAAO,EAAE,EAAE,MAAM,EAAE,oBAAoB,EAAE,CAAC,CAAC;IACpE,MAAM,YAAY,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAE5E,8BAA8B;IAC9B,MAAM,SAAS,GAA2B,EAAE,CAAC;IAE7C,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE;QACxB,MAAM,YAAY,GAAG,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;QACnD,MAAM,WAAW,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC;QACpC,MAAM,IAAI,GAAG,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC3E,SAAS,CAAC,YAAY,CAAC,GAAG,IAAI,CAAC;IACjC,CAAC,CAAC,CAAC;IAEH,6CAA6C;IAC7C,MAAM,aAAa,G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22 +1,13 @@
1
1
  {
2
2
  "name": "lockfile-hasher",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "Generates a combined hash of all the lockfiles in a repository",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "type": "module",
8
- "packageManager": "pnpm@10.6.2",
9
8
  "files": [
10
9
  "dist"
11
10
  ],
12
- "scripts": {
13
- "build": "rm -rf dist && tsc",
14
- "check-format": "biome check .",
15
- "ci": "pnpm run test && pnpm run check-format",
16
- "format": "biome check --write .",
17
- "prepublishOnly": "pnpm run ci",
18
- "test": "node --experimental-strip-types --test"
19
- },
20
11
  "repository": {
21
12
  "type": "git",
22
13
  "url": "git+https://github.com/onlywei/lockfile-hasher.git"
@@ -36,12 +27,14 @@
36
27
  "@types/node": "^22.13.4",
37
28
  "typescript": "^5.8.2"
38
29
  },
39
- "pnpm": {
40
- "onlyBuiltDependencies": [
41
- "@biomejs/biome"
42
- ]
43
- },
44
30
  "dependencies": {
45
31
  "glob": "^11.0.1"
32
+ },
33
+ "scripts": {
34
+ "build": "rm -rf dist && tsc",
35
+ "check-format": "biome check .",
36
+ "ci": "pnpm run test && pnpm run check-format && pnpm run build",
37
+ "format": "biome check --write .",
38
+ "test": "node --experimental-strip-types --test"
46
39
  }
47
- }
40
+ }