Skip to content

Commit 02f45d9

Browse files
chore(deps): remove hasha (#7017)
1 parent c095fef commit 02f45d9

File tree

5 files changed

+16
-63
lines changed

5 files changed

+16
-63
lines changed

package-lock.json

Lines changed: 0 additions & 56 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,6 @@
122122
"gh-release-fetch": "4.0.3",
123123
"git-repo-info": "2.1.1",
124124
"gitconfiglocal": "2.1.0",
125-
"hasha": "5.2.2",
126125
"http-proxy": "1.18.1",
127126
"http-proxy-middleware": "2.0.7",
128127
"https-proxy-agent": "7.0.6",

src/utils/deploy/hash-config.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import hasha from 'hasha'
1+
import { createHash } from 'node:crypto'
2+
23
// @ts-expect-error TS(7016) FIXME: Could not find a declaration file for module 'toml... Remove this comment to see the full error message
34
import tomlify from 'tomlify-j0.4'
45

@@ -7,7 +8,7 @@ export const hashConfig = ({ config }) => {
78
if (!config) throw new Error('Missing config option')
89
const configString = serializeToml(config)
910

10-
const hash = hasha(configString, { algorithm: 'sha1' })
11+
const hash = createHash('sha1').update(configString).digest('hex')
1112

1213
return {
1314
assetType: 'file',

src/utils/deploy/hasher-segments.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
import { createHash } from 'node:crypto'
2+
import { createReadStream } from 'node:fs'
3+
import { pipeline } from 'node:stream/promises'
4+
15
// @ts-expect-error TS(7016) FIXME: Could not find a declaration file for module 'flus... Remove this comment to see the full error message
26
import flushWriteStream from 'flush-write-stream'
3-
import hasha from 'hasha'
47
// @ts-expect-error TS(7016) FIXME: Could not find a declaration file for module 'para... Remove this comment to see the full error message
58
import transform from 'parallel-transform'
69
// @ts-expect-error TS(7016) FIXME: Could not find a declaration file for module 'thro... Remove this comment to see the full error message
@@ -10,17 +13,23 @@ import { obj as map } from 'through2-map'
1013

1114
import { normalizePath } from './util.js'
1215

16+
const hashFile = async (filePath: string, algorithm: string) => {
17+
const hasher = createHash(algorithm)
18+
await pipeline([createReadStream(filePath), hasher])
19+
20+
return hasher.digest('hex')
21+
}
22+
1323
// a parallel transform stream segment ctor that hashes fileObj's created by folder-walker
1424
// TODO: use promises instead of callbacks
1525
/* eslint-disable promise/prefer-await-to-callbacks */
1626
// @ts-expect-error TS(7031) FIXME: Binding element 'concurrentHash' implicitly has an... Remove this comment to see the full error message
1727
export const hasherCtor = ({ concurrentHash, hashAlgorithm }) => {
18-
const hashaOpts = { algorithm: hashAlgorithm }
1928
if (!concurrentHash) throw new Error('Missing required opts')
2029
// @ts-expect-error TS(7006) FIXME: Parameter 'fileObj' implicitly has an 'any' type.
2130
return transform(concurrentHash, { objectMode: true }, async (fileObj, cb) => {
2231
try {
23-
const hash = await hasha.fromFile(fileObj.filepath, hashaOpts)
32+
const hash = await hashFile(fileObj.filepath, hashAlgorithm)
2433
// insert hash and asset type to file obj
2534
return cb(null, { ...fileObj, hash })
2635
} catch (error) {

src/utils/read-repo-url.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ const getRepoURLContents = async function (repoHost, ownerAndRepo, contentsPath)
3535
console.error(`Error occurred while fetching ${APIURL}`, error)
3636
}
3737
}
38-
throw new Error('unsupported host ', repoHost)
38+
throw new Error(`unsupported host: ${repoHost}`)
3939
}
4040

4141
/**

0 commit comments

Comments
 (0)