Skip to content

Commit

Permalink
Merge pull request #207 from provenance-io/vmikulis/sc-tbd/package-lo…
Browse files Browse the repository at this point in the history
…ck-quickfix

bug(wcjs): Fix importing package json and add tests
  • Loading branch information
VigM-Figure authored Feb 8, 2024
2 parents 5896f59 + f8b220c commit a92a916
Show file tree
Hide file tree
Showing 8 changed files with 123 additions and 125 deletions.
2 changes: 2 additions & 0 deletions .husky/_/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/usr/bin/env sh
npm run test && npm run commentSniff
6 changes: 0 additions & 6 deletions .huskyrc

This file was deleted.

17 changes: 9 additions & 8 deletions examples/example-react-vite/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions examples/example-react-vite/package.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
{
"name": "example-react-vite",
"private": true,
"version": "3.8.1",
"version": "3.8.2",
"homepage": "/walletconnect-demo",
"type": "module",
"scripts": {
"dev": "vite --open",
"build": "tsc && vite build",
"preview": "vite preview",
"clean:cache": "rm -rf ./node_modules/.vite",
"start": "npm run clean:cache && npm i ../provenanceio-walletconnect-js-${npm_package_version}.tgz && npm run dev",
"start": "npm run install && npm run dev",
"install": "npm run clean:cache && npm i ../provenanceio-walletconnect-js-${npm_package_version}.tgz",
"start:host": "npm run dev --host"
},
"dependencies": {
"@microlink/react-json-view": "1.22.2",
"@provenanceio/wallet-utils": "2.8.0",
"@provenanceio/walletconnect-js": "file:../provenanceio-walletconnect-js-3.8.1.tgz",
"@provenanceio/walletconnect-js": "file:../provenanceio-walletconnect-js-3.8.2.tgz",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-helmet-async": "1.3.0",
Expand Down Expand Up @@ -52,4 +53,4 @@
"prettier"
]
}
}
}
22 changes: 11 additions & 11 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@provenanceio/walletconnect-js",
"version": "3.8.1",
"version": "3.8.2",
"private": false,
"sideEffects": false,
"main": "esm/index.js",
Expand Down Expand Up @@ -81,7 +81,7 @@
"eslint-plugin-react": "7.32.2",
"eslint-plugin-react-hooks": "4.6.0",
"file-loader": "6.2.0",
"husky": "8.0.1",
"husky": "^9.0.10",
"jest": "29.4.3",
"json-schema-to-typescript": "11.0.2",
"nodemon": "2.0.20",
Expand Down Expand Up @@ -109,7 +109,8 @@
"prebuild": "npm run test",
"start:watch": "nodemon -e js,ts,tsx,css --watch src --exec 'npm run build:pack && npm run watch:example-react'",
"start": "npm run start:watch && npm run start:example-react",
"test": "jest",
"test": "jest && npm run test:example-build",
"test:example-build": "npm run build:pack && cd examples/example-react-vite && npm run install && npm run build",
"tsc:commonjs": "tsc --module commonjs --outDir lib",
"tsc:esm": "tsc --module es2015 --outDir esm",
"vup:major": "npm version major --no-git-tag-version && cd examples/example-react-vite && npm version major --no-git-tag-version",
Expand Down
182 changes: 91 additions & 91 deletions scripts/commentSniffer.js
Original file line number Diff line number Diff line change
@@ -1,96 +1,96 @@
"use strict";
'use strict';
exports.__esModule = true;
module.exports.commentSniffer = function () {
var glob = require('glob'); // eslint-disable-line @typescript-eslint/no-var-requires
var fs = require('fs'); // eslint-disable-line @typescript-eslint/no-var-requires
var PrettyError = require('pretty-error'); // eslint-disable-line @typescript-eslint/no-var-requires
var getDirectories = function (src, callback) {
var res = glob.sync(src + '/**/*');
callback(res);
};
var fileTypes = ['.ts', '.tsx', '.js', '.jsx', '.md', '.mdx'];
var comments = [
'TEMP:',
'TEMPONLY:',
'TESTING:',
'TEST:',
'TESTONLY:',
'TESTINGONLY:',
'REMOVEME:',
'REMOVE:',
'HACK:',
];
var rootDirs = ['src', 'webDemo/src'];
var checkIfValidFile = function (fileSrc) {
var valid = false;
fileTypes.forEach(function (fileType) {
if (fileSrc.includes(fileType)) {
valid = true;
var glob = require('glob'); // eslint-disable-line @typescript-eslint/no-var-requires
var fs = require('fs'); // eslint-disable-line @typescript-eslint/no-var-requires
var PrettyError = require('pretty-error'); // eslint-disable-line @typescript-eslint/no-var-requires
var getDirectories = function (src, callback) {
var res = glob.sync(src + '/**/*');
callback(res);
};
var fileTypes = ['.ts', '.tsx', '.js', '.jsx', '.md', '.mdx'];
var comments = [
'// TEMP:',
'// TEMPONLY:',
'// TESTING:',
'// TEST:',
'// TESTONLY:',
'// TESTINGONLY:',
'// REMOVEME:',
'// REMOVE:',
'// HACK:',
];
var rootDirs = ['src', 'webDemo/src'];
var checkIfValidFile = function (fileSrc) {
var valid = false;
fileTypes.forEach(function (fileType) {
if (fileSrc.includes(fileType)) {
valid = true;
}
});
return valid;
};
var checkIfCommentMatches = function (fileData) {
var commentExists = false;
comments.forEach(function (comment) {
if (fileData.includes(comment)) {
commentExists = true;
}
});
return commentExists;
};
var runSniffer = function () {
var allErrors = [];
rootDirs.forEach(function (rootDir) {
getDirectories(rootDir, function (res) {
// Look at each file
res.forEach(function (fileLocation) {
var valid = checkIfValidFile(fileLocation);
if (valid) {
var data = fs.readFileSync(fileLocation);
var hasComment = checkIfCommentMatches(data);
if (hasComment) {
allErrors.push(fileLocation);
}
}
});
return valid;
};
var checkIfCommentMatches = function (fileData) {
var commentExists = false;
comments.forEach(function (comment) {
if (fileData.includes(comment)) {
commentExists = true;
}
});
return commentExists;
};
var runSniffer = function () {
var allErrors = [];
rootDirs.forEach(function (rootDir) {
getDirectories(rootDir, function (res) {
// Look at each file
res.forEach(function (fileLocation) {
var valid = checkIfValidFile(fileLocation);
if (valid) {
var data = fs.readFileSync(fileLocation);
var hasComment = checkIfCommentMatches(data);
if (hasComment) {
allErrors.push(fileLocation);
}
}
});
});
});
if (allErrors.length) {
var message_1 = 'Dev Local Only Comments Found! Please Fix/Remove:\n --------------------------------------------------\n';
allErrors.forEach(function (msg) {
message_1 += " \n \u2022 ".concat(msg);
});
var pe = new PrettyError();
pe.appendStyle({
'pretty-error > header > title > kind': { display: 'none' },
'pretty-error > header > colon': { display: 'none' },
'pretty-error > header > message': {
color: 'bright-white',
background: 'red',
padding: '0 1'
},
'pretty-error > trace > item': { display: 'none' }
});
var renderedError = pe.render(new Error(message_1));
console.log(renderedError); // eslint-disable-line no-console
process.exit(1);
}
else {
var pe = new PrettyError();
pe.appendStyle({
'pretty-error > header > title > kind': { display: 'none' },
'pretty-error > header > colon': { display: 'none' },
'pretty-error > header > message': {
color: 'bright-white',
background: 'green',
padding: '0 1'
},
'pretty-error > trace > item': { display: 'none' }
});
var renderedSuccess = pe.render(new Error('All comment checks passed'));
console.log(renderedSuccess); // eslint-disable-line no-console
}
};
runSniffer();
});
});
if (allErrors.length) {
var message_1 =
'Dev Local Only Comments Found! Please Fix/Remove:\n --------------------------------------------------\n';
allErrors.forEach(function (msg) {
message_1 += ' \n \u2022 '.concat(msg);
});
var pe = new PrettyError();
pe.appendStyle({
'pretty-error > header > title > kind': { display: 'none' },
'pretty-error > header > colon': { display: 'none' },
'pretty-error > header > message': {
color: 'bright-white',
background: 'red',
padding: '0 1',
},
'pretty-error > trace > item': { display: 'none' },
});
var renderedError = pe.render(new Error(message_1));
console.log(renderedError); // eslint-disable-line no-console
process.exit(1);
} else {
var pe = new PrettyError();
pe.appendStyle({
'pretty-error > header > title > kind': { display: 'none' },
'pretty-error > header > colon': { display: 'none' },
'pretty-error > header > message': {
color: 'bright-white',
background: 'green',
padding: '0 1',
},
'pretty-error > trace > item': { display: 'none' },
});
var renderedSuccess = pe.render(new Error('All comment checks passed'));
console.log(renderedSuccess); // eslint-disable-line no-console
}
};
runSniffer();
};
3 changes: 1 addition & 2 deletions src/services/walletConnectService.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Buffer } from 'buffer';
import events from 'events';
import { version } from '../../package.json';
import type {
AccountAttribute,
BroadcastEventData,
Expand Down Expand Up @@ -66,7 +65,7 @@ const defaultState: WCSState = {
representedGroupPolicy: null,
signedJWT: '',
status: 'disconnected',
version,
version: '3.8.2',
walletAppId: undefined,
walletInfo: {},
};
Expand Down

0 comments on commit a92a916

Please sign in to comment.