mirror of
https://github.com/pnpm/pnpm.git
synced 2026-03-30 04:52:04 -04:00
fix: create @pnpm/crypto.base32-hash
This commit is contained in:
5
.changeset/six-readers-draw.md
Normal file
5
.changeset/six-readers-draw.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"dependency-path": patch
|
||||
---
|
||||
|
||||
Use @pnpm/crypto.base32-hash.
|
||||
5
.changeset/smart-games-rest.md
Normal file
5
.changeset/smart-games-rest.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@pnpm/crypto.base32-hash": major
|
||||
---
|
||||
|
||||
Initial release.
|
||||
13
packages/crypto.base32-hash/README.md
Normal file
13
packages/crypto.base32-hash/README.md
Normal file
@@ -0,0 +1,13 @@
|
||||
# @pnpm/crypto.base32-hash
|
||||
|
||||
> Create a base32 hash
|
||||
|
||||
## Installation
|
||||
|
||||
```sh
|
||||
pnpm add @pnpm/crypto.base32-hash
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
||||
3
packages/crypto.base32-hash/jest.config.js
Normal file
3
packages/crypto.base32-hash/jest.config.js
Normal file
@@ -0,0 +1,3 @@
|
||||
const config = require('../../jest.config.js');
|
||||
|
||||
module.exports = Object.assign({}, config, {});
|
||||
43
packages/crypto.base32-hash/package.json
Normal file
43
packages/crypto.base32-hash/package.json
Normal file
@@ -0,0 +1,43 @@
|
||||
{
|
||||
"name": "@pnpm/crypto.base32-hash",
|
||||
"version": "0.0.0",
|
||||
"description": "Create a base32 hash",
|
||||
"main": "lib/index.js",
|
||||
"types": "lib/index.d.ts",
|
||||
"files": [
|
||||
"lib",
|
||||
"!*.map"
|
||||
],
|
||||
"scripts": {
|
||||
"lint": "eslint src/**/*.ts test/**/*.ts",
|
||||
"_test": "jest",
|
||||
"test": "pnpm run compile && pnpm run _test",
|
||||
"prepublishOnly": "pnpm run compile",
|
||||
"compile": "tsc --build && pnpm run lint --fix"
|
||||
},
|
||||
"repository": "https://github.com/pnpm/pnpm/blob/main/packages/crypto.base32-hash",
|
||||
"keywords": [
|
||||
"pnpm7",
|
||||
"hash",
|
||||
"crypto",
|
||||
"base32"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=14.6"
|
||||
},
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/pnpm/pnpm/issues"
|
||||
},
|
||||
"homepage": "https://github.com/pnpm/pnpm/blob/main/packages/crypto.base32-hash#readme",
|
||||
"dependencies": {
|
||||
"rfc4648": "^1.5.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@pnpm/crypto.base32-hash": "workspace:0.0.0"
|
||||
},
|
||||
"funding": "https://opencollective.com/pnpm",
|
||||
"exports": {
|
||||
".": "./lib/index.js"
|
||||
}
|
||||
}
|
||||
11
packages/crypto.base32-hash/src/index.ts
Normal file
11
packages/crypto.base32-hash/src/index.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import crypto from 'crypto'
|
||||
import fs from 'fs'
|
||||
import { base32 } from 'rfc4648'
|
||||
|
||||
export function createBase32Hash (str: string): string {
|
||||
return base32.stringify(crypto.createHash('md5').update(str).digest()).replace(/(=+)$/, '').toLowerCase()
|
||||
}
|
||||
|
||||
export async function createBase32HashFromFile (file: string): Promise<string> {
|
||||
return createBase32Hash(await fs.promises.readFile(file, 'utf8'))
|
||||
}
|
||||
6
packages/crypto.base32-hash/test/index.ts
Normal file
6
packages/crypto.base32-hash/test/index.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
/// <reference path="../../../typings/index.d.ts"/>
|
||||
import { createBase32Hash } from '@pnpm/crypto.base32-hash'
|
||||
|
||||
test('createBase32Hash()', () => {
|
||||
expect(createBase32Hash('AAA')).toEqual('4h5p7m7gcttmf65hikljmi4gw4')
|
||||
})
|
||||
12
packages/crypto.base32-hash/tsconfig.json
Normal file
12
packages/crypto.base32-hash/tsconfig.json
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"extends": "@pnpm/tsconfig",
|
||||
"compilerOptions": {
|
||||
"outDir": "lib",
|
||||
"rootDir": "src"
|
||||
},
|
||||
"include": [
|
||||
"src/**/*.ts",
|
||||
"../../typings/**/*.d.ts"
|
||||
],
|
||||
"references": []
|
||||
}
|
||||
8
packages/crypto.base32-hash/tsconfig.lint.json
Normal file
8
packages/crypto.base32-hash/tsconfig.lint.json
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"include": [
|
||||
"src/**/*.ts",
|
||||
"test/**/*.ts",
|
||||
"../../typings/**/*.d.ts"
|
||||
]
|
||||
}
|
||||
@@ -31,9 +31,9 @@
|
||||
},
|
||||
"homepage": "https://github.com/pnpm/pnpm/blob/main/packages/dependency-path#readme",
|
||||
"dependencies": {
|
||||
"@pnpm/crypto.base32-hash": "workspace:0.0.0",
|
||||
"@pnpm/types": "workspace:8.1.0",
|
||||
"encode-registry": "^3.0.0",
|
||||
"rfc4648": "^1.5.1",
|
||||
"semver": "^7.3.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import crypto from 'crypto'
|
||||
import { createBase32Hash } from '@pnpm/crypto.base32-hash'
|
||||
import { Registries } from '@pnpm/types'
|
||||
import encodeRegistry from 'encode-registry'
|
||||
import { base32 } from 'rfc4648'
|
||||
import semver from 'semver'
|
||||
|
||||
export function isAbsolute (dependencyPath: string) {
|
||||
@@ -163,7 +162,3 @@ export function createPeersFolderSuffix (peers: Array<{name: string, version: st
|
||||
}
|
||||
return `_${folderName}`
|
||||
}
|
||||
|
||||
function createBase32Hash (str: string): string {
|
||||
return base32.stringify(crypto.createHash('md5').update(str).digest()).replace(/(=+)$/, '').toLowerCase()
|
||||
}
|
||||
|
||||
@@ -9,6 +9,9 @@
|
||||
"../../typings/**/*.d.ts"
|
||||
],
|
||||
"references": [
|
||||
{
|
||||
"path": "../crypto.base32-hash"
|
||||
},
|
||||
{
|
||||
"path": "../types"
|
||||
}
|
||||
|
||||
13
pnpm-lock.yaml
generated
13
pnpm-lock.yaml
generated
@@ -610,6 +610,15 @@ importers:
|
||||
'@pnpm/logger': 4.0.0
|
||||
'@pnpm/prepare': link:../../privatePackages/prepare
|
||||
|
||||
packages/crypto.base32-hash:
|
||||
specifiers:
|
||||
'@pnpm/crypto.base32-hash': workspace:0.0.0
|
||||
rfc4648: ^1.5.1
|
||||
dependencies:
|
||||
rfc4648: 1.5.2
|
||||
devDependencies:
|
||||
'@pnpm/crypto.base32-hash': 'link:'
|
||||
|
||||
packages/default-reporter:
|
||||
specifiers:
|
||||
'@pnpm/config': workspace:15.2.1
|
||||
@@ -729,16 +738,16 @@ importers:
|
||||
|
||||
packages/dependency-path:
|
||||
specifiers:
|
||||
'@pnpm/crypto.base32-hash': workspace:0.0.0
|
||||
'@pnpm/types': workspace:8.1.0
|
||||
'@types/semver': ^7.3.4
|
||||
dependency-path: workspace:9.1.3
|
||||
encode-registry: ^3.0.0
|
||||
rfc4648: ^1.5.1
|
||||
semver: ^7.3.4
|
||||
dependencies:
|
||||
'@pnpm/crypto.base32-hash': link:../crypto.base32-hash
|
||||
'@pnpm/types': link:../types
|
||||
encode-registry: 3.0.0
|
||||
rfc4648: 1.5.2
|
||||
semver: 7.3.7
|
||||
devDependencies:
|
||||
'@types/semver': 7.3.9
|
||||
|
||||
Reference in New Issue
Block a user