Skip to content

Commit

Permalink
JS - 0.9.70, Library integrity check hash
Browse files Browse the repository at this point in the history
  • Loading branch information
1aerostorm committed May 4, 2024
1 parent e239559 commit 3df3a81
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 2 deletions.
1 change: 1 addition & 0 deletions .github/workflows/js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ jobs:
with:
node-version: 16
- run: yarn install
- run: yarn build
- run: yarn test
28 changes: 28 additions & 0 deletions golos-lib-js/check_integrity.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
const fs = require('fs')
const { hashElement } = require('folder-hash')

async function main() {
try {
const hashOut = './lib/my_hash.js'

const res = await hashElement('.', {
files: { include: (f) => {
if (f === 'golos.min.js.gz') return false
if (f === 'golos-tests.min.js.gz') return false
if (f === 'stats.html') return false
return true
} }
})
console.log(JSON.stringify(res.children.filter(el => el.name === 'dist')))

let code = fs.readFileSync(hashOut, 'utf8')
code = code.replace('NO_HASH', res.hash)
fs.writeFileSync(hashOut, code)

console.log('LIBRARY HASH IS', res.hash)
} catch (err) {
console.error('LIBRARY HASH FAILED:', err)
}
}

main()
6 changes: 4 additions & 2 deletions golos-lib-js/package.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
{
"name": "golos-lib-js",
"version": "0.9.69",
"version": "0.9.70",
"description": "Golos-js the JavaScript library with API for GOLOS blockchain",
"main": "lib/index.js",
"scripts": {
"test": "mocha -t 20000 --recursive --require @babel/register",
"test-auth": "npm test -- --grep 'golos.auth'",
"test-messages": "npm test -- --watch --grep 'golos.messages'",
"build": "node ./include_core.js && npm run build-browser && npm run build-node",
"build": "node ./include_core.js && npm run build-browser && npm run build-node && npm run check-integrity",
"build-browser": "rm -rf dist && NODE_ENV=production webpack && gzip -k -f ./dist/*.js && du -h ./dist/*",
"build-node": "mkdir -p ./lib && cp -r ./src/* ./lib/ && babel ./src --out-dir ./lib",
"check-integrity": "node check_integrity.js",
"disable-test-prepublish": "npm run test && npm run build"
},
"browser": {
Expand Down Expand Up @@ -64,6 +65,7 @@
"chai": "^4.3.4",
"chai-as-promised": "^7.1.1",
"eslint": "^8.1.0",
"folder-hash": "^4.0.4",
"json-loader": "^0.5.4",
"mocha": "^9.1.1",
"mocha-make-stub": "^2.3.2",
Expand Down
5 changes: 5 additions & 0 deletions golos-lib-js/src/libs.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { MY_HASH } from './my_hash.js'

class Libs {
constructor(rootObj) {
Expand Down Expand Up @@ -32,6 +33,10 @@ class Libs {
}
return false
}

libHash = () => {
return MY_HASH
}
}

module.exports = Libs
1 change: 1 addition & 0 deletions golos-lib-js/src/my_hash.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const MY_HASH = 'NO_HASH'
29 changes: 29 additions & 0 deletions golos-lib-js/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1311,6 +1311,13 @@ brace-expansion@^1.1.7:
balanced-match "^1.0.0"
concat-map "0.0.1"

brace-expansion@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-2.0.1.tgz#1edc459e0f0c548486ecf9fc99f2221364b9a0ae"
integrity sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==
dependencies:
balanced-match "^1.0.0"

braces@~3.0.2:
version "3.0.2"
resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.2.tgz#3454e1a462ee8d599e236df336cd9ea4f8afe107"
Expand Down Expand Up @@ -1633,6 +1640,13 @@ debug@^2.6.8:
dependencies:
ms "2.0.0"

debug@^4.3.3:
version "4.3.4"
resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.4.tgz#1319f6579357f2338d3337d2cdd4914bb5dcc865"
integrity sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==
dependencies:
ms "2.1.2"

decamelize@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-4.0.0.tgz#aa472d7bf660eb15f3494efd531cab7f2a709837"
Expand Down Expand Up @@ -2023,6 +2037,14 @@ flatted@^3.1.0:
resolved "https://registry.yarnpkg.com/flatted/-/flatted-3.2.2.tgz#64bfed5cb68fe3ca78b3eb214ad97b63bedce561"
integrity sha512-JaTY/wtrcSyvXJl4IMFHPKyFur1sE9AUqc0QnhOaJ0CxHtAoIV8pYDzeEfAaNEtGkOfq4gr3LBFmdXW5mOQFnA==

folder-hash@^4.0.4:
version "4.0.4"
resolved "https://registry.yarnpkg.com/folder-hash/-/folder-hash-4.0.4.tgz#f5ffa14e9fc6f3213598f6a367207adf7d419edc"
integrity sha512-zEyYH+UsHEfJJcCRSf9ai5I4CTZwZ8ObONRuEI5hcEmJY5pS0FUWKruX9mMnYJrgC7MlPFDYnGsK1R+WFYjLlQ==
dependencies:
debug "^4.3.3"
minimatch "~5.1.2"

foreach@^2.0.5:
version "2.0.5"
resolved "https://registry.yarnpkg.com/foreach/-/foreach-2.0.5.tgz#0bee005018aeb260d0a3af3ae658dd0136ec1b99"
Expand Down Expand Up @@ -2667,6 +2689,13 @@ minimatch@3.0.4, minimatch@^3.0.4:
dependencies:
brace-expansion "^1.1.7"

minimatch@~5.1.2:
version "5.1.6"
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-5.1.6.tgz#1cfcb8cf5522ea69952cd2af95ae09477f122a96"
integrity sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g==
dependencies:
brace-expansion "^2.0.1"

minimist@^1.2.0, minimist@^1.2.5:
version "1.2.5"
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.5.tgz#67d66014b66a6a8aaa0c083c5fd58df4e4e97602"
Expand Down

0 comments on commit 3df3a81

Please sign in to comment.