lockfile-hasher 1.0.0 → 1.0.1
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/package.json +9 -16
- package/dist/index.d.ts +0 -10
- package/dist/index.js +0 -34
- package/dist/index.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,22 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lockfile-hasher",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
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",
|
|
37
|
+
"format": "biome check --write .",
|
|
38
|
+
"test": "node --experimental-strip-types --test"
|
|
46
39
|
}
|
|
47
|
-
}
|
|
40
|
+
}
|
package/dist/index.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
type LockFileName = 'package-lock.json' | 'pnpm-lock.yaml' | 'yarn.lock';
|
|
2
|
-
/**
|
|
3
|
-
* Generate a combined hash of all lock files in a repo.
|
|
4
|
-
* @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
|
-
* @returns {Promise<string>} - Combined hash string
|
|
8
|
-
*/
|
|
9
|
-
export declare function generateCombinedLockFileHash(rootPath: string, lockFileName: LockFileName): Promise<string>;
|
|
10
|
-
export {};
|
package/dist/index.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
// hash-package-locks.js
|
|
2
|
-
import crypto from 'node:crypto';
|
|
3
|
-
import { readFile } from 'node:fs/promises';
|
|
4
|
-
import path from 'node:path';
|
|
5
|
-
import { glob } from 'glob';
|
|
6
|
-
/**
|
|
7
|
-
* Generate a combined hash of all lock files in a repo.
|
|
8
|
-
* @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
|
-
* @returns {Promise<string>} - Combined hash string
|
|
12
|
-
*/
|
|
13
|
-
export async function generateCombinedLockFileHash(rootPath, lockFileName) {
|
|
14
|
-
const pattern = path.join(rootPath, `**/${lockFileName}`);
|
|
15
|
-
const files = await glob(pattern, { ignore: '**/node_modules/**' });
|
|
16
|
-
const fileContents = await Promise.all(files.map((file) => readFile(file)));
|
|
17
|
-
// Generate hash for each file
|
|
18
|
-
const hashesMap = {};
|
|
19
|
-
files.forEach((file, i) => {
|
|
20
|
-
const relativePath = path.relative(rootPath, file);
|
|
21
|
-
const fileContent = fileContents[i];
|
|
22
|
-
const hash = crypto.createHash('sha256').update(fileContent).digest('hex');
|
|
23
|
-
hashesMap[relativePath] = hash;
|
|
24
|
-
});
|
|
25
|
-
// Sort the entries to ensure consistent hash
|
|
26
|
-
const sortedEntries = Object.entries(hashesMap).sort(([pathA], [pathB]) => {
|
|
27
|
-
return pathA.localeCompare(pathB);
|
|
28
|
-
});
|
|
29
|
-
// Create a string representation of all hashes
|
|
30
|
-
const combinedString = sortedEntries.map(([relPath, hash]) => `${relPath}:${hash}`).join('|');
|
|
31
|
-
// Generate a new hash from the combined string
|
|
32
|
-
return crypto.createHash('sha256').update(combinedString).digest('hex');
|
|
33
|
-
}
|
|
34
|
-
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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;IA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