From ae312e82d81aaf342cef24cb6a041a2f7b2be067 Mon Sep 17 00:00:00 2001 From: 1aerostorm Date: Sat, 4 May 2024 23:16:48 +0300 Subject: [PATCH] Update golos-lib-js to 0.9.71, support check-integrity --- .gitignore | 1 + app/components/App.jsx | 2 ++ check_integrity.js | 59 ++++++++++++++++++++++++++++++++++++++++++ package.json | 10 ++++--- yarn.lock | 18 +++++++++---- 5 files changed, 81 insertions(+), 9 deletions(-) create mode 100644 check_integrity.js diff --git a/.gitignore b/.gitignore index 2498620f8..99d72176d 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,7 @@ app/assets/static/*.js app/assets/static/*.json app/assets/sitemap.xml default_cfg.js +app/JsLibHash.json config/golos.json config/golos-dev.json diff --git a/app/components/App.jsx b/app/components/App.jsx index 2f0c2721c..f44da0d73 100644 --- a/app/components/App.jsx +++ b/app/components/App.jsx @@ -33,6 +33,7 @@ import { authRegisterUrl, } from 'app/utils/AuthApiClient'; import { APP_ICON, VEST_TICKER, } from 'app/client_config'; import session from 'app/utils/session' import { loadGrayHideSettings } from 'app/utils/ContentAccess' +import libInfo from 'app/JsLibHash.json' const GlobalStyle = createGlobalStyle` body { @@ -109,6 +110,7 @@ class App extends React.Component { componentDidMount() { if (process.env.BROWSER) { console.log('ui-blogs version:', $STM_Config.ui_version); + console.log('golos-lib-js version:', libInfo.version, 'hash:', libInfo.hash) } const { nightmodeEnabled } = this.props; diff --git a/check_integrity.js b/check_integrity.js new file mode 100644 index 000000000..0183f12b4 --- /dev/null +++ b/check_integrity.js @@ -0,0 +1,59 @@ +const fs = require('fs') +const { hashElement } = require('folder-hash') + +async function main(argv) { + try { + const hashOut = './lib/my_hash.js' + + const path = 'node_modules/golos-lib-js' + + const res = await hashElement(path, { + files: { + exclude: [ + path + '/lib/my_hash.js', + path + '/dist/golos.min.js.gz', + path + '/dist/golos-tests.min.js.gz', + path + '/dist/stats.html', + // These not including when NPM publishes + '.npmrc', + '.babelrc', + '.gitignore', + '.npmignore', + 'yarn.lock', + ], + matchBasename: true, + matchPath: true, + }, + folders: { + exclude: [ + 'node_modules', + path + '/src', + path + '/examples' + ], + matchPath: true, + ignoreRootName: true + } + }) + + console.log(res.children) + //console.log(res.children.filter(o => o.name === 'lib')[0].children.filter(o => o.name === 'auth')[0].children) + + console.log('LIBRARY HASH IS', res.hash) + + if (argv[2] === '--save') { + let json = 'node_modules/golos-lib-js/package.json' + json = fs.readFileSync(json, 'utf8') + json = JSON.parse(json) + + const appPath = 'app/JsLibHash.json' + let data = {} + data.version = json.version + data.hash = res.hash + fs.writeFileSync(appPath, JSON.stringify(data)) + } + } catch (err) { + console.error('LIBRARY HASH FAILED:', err) + } +} + +main(process.argv) diff --git a/package.json b/package.json index f986eba2a..3113d8688 100644 --- a/package.json +++ b/package.json @@ -9,18 +9,19 @@ "main": "dist/electron/electron.js", "scripts": { "build-version": "./server/build-version.sh", - "build": "NODE_ENV=production NODE_CONFIG_ENV=production,blacklist ./node_modules/.bin/webpack --config ./webpack/prod.config.js", + "build-hash": "node check_integrity --save", + "build": "npm run build-hash && NODE_ENV=production NODE_CONFIG_ENV=production,blacklist ./node_modules/.bin/webpack --config ./webpack/prod.config.js", "mocha": "NODE_ENV=test mocha ./mocha.setup.js", "test": "npm run mocha -- app/**/*.test.js", "test:watch:all": "npm test -- --watch --watch-extensions jsx", "test:watch": "npm run mocha -- --watch --watch-extensions jsx", "prod": "NODE_ENV=production NODE_CONFIG_ENV=production,blacklist ./node_modules/@babel/node/bin/babel-node.js server/index.js", - "dev": "cross-env NODE_CONFIG_ENV=blacklist ./node_modules/@babel/node/bin/babel-node.js ./webpack/dev-server.js", + "dev": "npm run build-hash && cross-env NODE_CONFIG_ENV=blacklist ./node_modules/@babel/node/bin/babel-node.js ./webpack/dev-server.js", "start:local": "./.env.start.local.sh", "storybook": "start-storybook -p 6006", "build-storybook": "build-storybook", "dev:app": "cross-env NODE_CONFIG_ENV=blacklist IS_APP=1 ./node_modules/@babel/node/bin/babel-node.js ./webpack/dev-server.js", - "build:app": "cross-env NODE_ENV=production NODE_CONFIG_ENV=production,desktop ./node_modules/.bin/webpack --config ./webpack/prod-app.config.js", + "build:app": "npm run build-hash && cross-env NODE_ENV=production NODE_CONFIG_ENV=production,desktop ./node_modules/.bin/webpack --config ./webpack/prod-app.config.js", "build:app-entry": "cross-env NODE_ENV=production NODE_CONFIG_ENV=production,desktop ./node_modules/@babel/node/bin/babel-node.js build_app_entry.js" }, "author": "Golos ", @@ -52,7 +53,7 @@ "fs-extra": "^10.0.1", "git-rev-sync": "^3.0.2", "golos-dex-lib-js": "^1.0.2", - "golos-lib-js": "^0.9.68", + "golos-lib-js": "^0.9.71", "history": "^2.0.0-rc2", "immutable": "^3.8.2", "intl": "^1.2.5", @@ -149,6 +150,7 @@ "eslint-plugin-import": "^2.7.0", "eslint-plugin-jsx-a11y": "^6.0.2", "eslint-plugin-react": "^7.4.0", + "folder-hash": "^4.0.4", "jsdom": "^21.0.0", "mini-css-extract-plugin": "^0.4.0", "mocha": "^5.2.0", diff --git a/yarn.lock b/yarn.lock index 1282c38b1..c55f11db1 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4826,6 +4826,14 @@ flux-standard-action@^0.6.0: dependencies: lodash.isplainobject "^3.2.0" +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" + for-each@^0.3.3: version "0.3.3" resolved "https://registry.yarnpkg.com/for-each/-/for-each-0.3.3.tgz#69b447e88a0a5d32c3e7084f3f1710034b21376e" @@ -5237,10 +5245,10 @@ golos-lib-js@^0.9.64: stream-browserify "^3.0.0" ws "^8.2.3" -golos-lib-js@^0.9.68: - version "0.9.68" - resolved "https://registry.yarnpkg.com/golos-lib-js/-/golos-lib-js-0.9.68.tgz#62f3c4a7755eacfbe6dc2f6ebc3111f2ff74e6dd" - integrity sha512-KoQMFHtINYdM0hhe9dKPpWXZLo3MkFXyRxY/zQq0kbBjAwJBU4P1WEMwmPS+MPujjizfvU6nerUOLI4Lj7ChFw== +golos-lib-js@^0.9.71: + version "0.9.71" + resolved "https://registry.yarnpkg.com/golos-lib-js/-/golos-lib-js-0.9.71.tgz#794bc6582a96f0e1a3bc4301e0c5dfac976a15bf" + integrity sha512-FkR7nuyMUXj+IT8ErTFhu6BsaEvPaLZAr72r5H+GUhqbD8q98tFfBURCKw0MGfiO9CEv0zdDG3daPTq2TThvxA== dependencies: abort-controller "^3.0.0" assert "^2.0.0" @@ -7383,7 +7391,7 @@ minimatch@3.0.4, minimatch@^3.0.2, minimatch@^3.0.3, minimatch@^3.0.4: dependencies: brace-expansion "^1.1.7" -minimatch@^5.0.1: +minimatch@^5.0.1, 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==