mixdog 0.9.99 → 0.9.100
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
CHANGED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { createHash } from 'node:crypto'
|
|
4
|
+
import { readFile } from 'node:fs/promises'
|
|
5
|
+
import { resolve } from 'node:path'
|
|
6
|
+
import { pathToFileURL } from 'node:url'
|
|
7
|
+
|
|
8
|
+
import { normalizeRuntimeLockfile } from './runtime-dependency-cache-key.mjs'
|
|
9
|
+
|
|
10
|
+
export const DEPENDENCY_LOCK_CACHE_SCHEMA = 1
|
|
11
|
+
|
|
12
|
+
export function dependencyLockCacheKey(lockfile) {
|
|
13
|
+
const normalized = normalizeRuntimeLockfile(lockfile)
|
|
14
|
+
const fingerprint = createHash('sha256')
|
|
15
|
+
.update(JSON.stringify(normalized))
|
|
16
|
+
.digest('hex')
|
|
17
|
+
return `dependency-lock-v${DEPENDENCY_LOCK_CACHE_SCHEMA}-${fingerprint}`
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const invokedPath = process.argv[1] ? pathToFileURL(resolve(process.argv[1])).href : ''
|
|
21
|
+
if (invokedPath === import.meta.url) {
|
|
22
|
+
const lockfilePath = process.argv[2]
|
|
23
|
+
if (!lockfilePath) throw new Error('Usage: dependency-lock-cache-key.mjs <package-lock.json>')
|
|
24
|
+
readFile(resolve(lockfilePath))
|
|
25
|
+
.then((lockfile) => process.stdout.write(`${dependencyLockCacheKey(lockfile)}\n`))
|
|
26
|
+
.catch((error) => {
|
|
27
|
+
process.stderr.write(`Dependency lock cache key failed: ${error?.message || error}\n`)
|
|
28
|
+
process.exitCode = 1
|
|
29
|
+
})
|
|
30
|
+
}
|