-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add: New package JSON hash added #186
Open
ThulinaWickramasinghe
wants to merge
54
commits into
development
Choose a base branch
from
feat/add-json-hash
base: development
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 52 commits
Commits
Show all changes
54 commits
Select commit
Hold shift + click to select a range
607bbac
Feat!: added support for more complex filters
Akalanka47000 acb7572
Merge pull request #168 from sliit-foss/feat/increase-filter-query-fi…
Akalanka47000 6269a04
CI: @sliit-foss/automatic-versioning - sync release
github-actions[bot] 00260c1
Fix(mongoose-audit): exception when change is null
Akalanka47000 3f4071e
Merge pull request #171 from sliit-foss/fix/mongoose-audit-exception
Akalanka47000 dab0359
CI: @sliit-foss/automatic-versioning - sync release
github-actions[bot] 05abfbc
Chore(git): add non-pnpm lock files to gitignore
ThulinaWickramasinghe d857c8a
Chore(git-hooks): remove husky
ThulinaWickramasinghe 4684693
Chore(git-hooks): setup lefthook
ThulinaWickramasinghe 661eeb0
Merge pull request #1 from ThulinaWickramasinghe/feat/integrate-lefthook
ThulinaWickramasinghe 34dd036
Fix: address PR comments
ThulinaWickramasinghe 3964d52
Fix: add cache flag for eslint
ThulinaWickramasinghe 3b32d86
Merge pull request #2 from ThulinaWickramasinghe/feat/integrate-lefthook
ThulinaWickramasinghe e2f4d01
Fix(lefthook): change linting command from 'code' to 'lint'
ThulinaWickramasinghe b5d79d1
Chore(deps): update prettier version
ThulinaWickramasinghe 8e7e60f
Merge pull request #3 from ThulinaWickramasinghe/feat/integrate-lefthook
ThulinaWickramasinghe 1bd33c9
Chore: updated lockfile
Akalanka47000 f297337
Chore: updated lefthook scripts
Akalanka47000 222c131
Merge pull request #173 from ThulinaWickramasinghe/main
Akalanka47000 9d6d920
feat(actions-exec-wrapper): add type support
ThulinaWickramasinghe 61566aa
Docs: update require statements for default exports
ThulinaWickramasinghe f86e4e5
Fix(actions-exec-wrapper): link types in package.json
ThulinaWickramasinghe 79d2024
Merge pull request #176 from sliit-foss/fix/default-export-require-docs
Akalanka47000 5aaa0aa
Merge pull request #175 from sliit-foss/feat/actions-exec-type-support
Akalanka47000 55802c4
CI: @sliit-foss/automatic-versioning - sync release
github-actions[bot] fad5b35
Fix(filter-query): added automatic parsing of object ids
Akalanka47000 e948d14
Merge pull request #177 from sliit-foss/fix/filter-query-object-id-pa…
Akalanka47000 ab55e85
CI: @sliit-foss/automatic-versioning - sync release
github-actions[bot] 44c39f2
Fix(mongoose-filter-query): incorrect parsing of regexp
Akalanka47000 3ad4a5b
Merge pull request #179 from sliit-foss/fix/filter-query-regexp-parsing
Akalanka47000 6c456fa
CI: @sliit-foss/automatic-versioning - sync release
github-actions[bot] f213613
Fix(mongoose-filter-query): default boolean parsing
Akalanka47000 2e53191
Fix: erroneus test
Akalanka47000 4371256
Merge pull request #180 from sliit-foss/fix/filter-query-default-bool…
Akalanka47000 8730510
CI: @sliit-foss/automatic-versioning - sync release
github-actions[bot] 9878cc8
Feat(filter-query): added support for regexp modifiers
Akalanka47000 1e1c0bc
Merge pull request #181 from sliit-foss/feat/filter-query-regex-modif…
Akalanka47000 1547432
CI: @sliit-foss/automatic-versioning - sync release
github-actions[bot] 7338f24
Feat(service-connector): added support for retrying
Akalanka47000 c2558e6
Merge pull request #182 from sliit-foss/feat/service-connector-retry
Akalanka47000 c8651dd
CI: @sliit-foss/automatic-versioning - sync release
github-actions[bot] d6efc2a
Fix(filter-query): in & nin object id parse
Akalanka47000 e067694
Merge pull request #183 from sliit-foss/fix/filter-query-object-id-pa…
Akalanka47000 5cd0edd
CI: @sliit-foss/automatic-versioning - sync release
github-actions[bot] 9b3d674
Feat!(filter-query): added prepaginate flag to query
Akalanka47000 a8f7548
CI: @sliit-foss/automatic-versioning - sync release
github-actions[bot] bdaf418
Feat!: added aggregate paginate plugin
Akalanka47000 af60063
CI: @sliit-foss/automatic-versioning - sync release
github-actions[bot] 042633e
Style: remove unwanted .gitkeep file
ThulinaWickramasinghe 955db95
Fix: remove fixed pnpm version
ThulinaWickramasinghe e57fc53
Feat(json-hash): add new package json-hash
ThulinaWickramasinghe 130c06f
Style(json-hash): remove commented code
ThulinaWickramasinghe 1e35f75
Refactor(json-hash): remove redundant code
ThulinaWickramasinghe f0e5f8c
Test(json-hash): remove browser tests, fix async issue and add test f…
ThulinaWickramasinghe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
{ | ||
"printWidth": 120, | ||
"trailingComma": "none" | ||
"trailingComma": "none", | ||
"semi": true, | ||
"quoteProps": "consistent" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
pre-commit: | ||
parallel: true | ||
commands: | ||
format: | ||
glob: "*.{css,html,json,less,md,scss,yaml,yml,js,jsx,ts,tsx}" | ||
run: npx prettier --write --cache {staged_files} && git add {staged_files} | ||
lint: | ||
glob: "*.{js,jsx,ts,tsx}" | ||
run: npm run lint && git add {staged_files} | ||
|
||
commit-msg: | ||
commands: | ||
commitlint: | ||
run: npx commitlint --edit --color |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,7 @@ | |
"dev": "turbo run dev", | ||
"lint": "turbo run lint", | ||
"format": "prettier --write \"**/*.{js,ts,tsx,md}\" --cache", | ||
"prepare": "husky install", | ||
"prepare": "lefthook install", | ||
"release": "turbo run release", | ||
"submodules:load": "git submodule update --init", | ||
"submodules:sync": "git submodule update --recursive --remote", | ||
|
@@ -31,17 +31,17 @@ | |
"turbo": "1.7.3" | ||
}, | ||
"devDependencies": { | ||
"@commitlint/cli": "17.4.2", | ||
"@commitlint/config-conventional": "17.4.2", | ||
"@commitlint/cli": "19.2.1", | ||
"@commitlint/config-conventional": "19.1.0", | ||
"@sliit-foss/eslint-config-internal": "workspace:*", | ||
"eslint": "8.33.0", | ||
"eslint-config-turbo": "0.0.7", | ||
"husky": "8.0.3", | ||
"lefthook": "1.6.10", | ||
"nodemon": "2.0.21", | ||
"prettier": "2.8.3" | ||
"prettier": "3.2.5" | ||
}, | ||
"engines": { | ||
"node": ">=14.0.0" | ||
}, | ||
"packageManager": "[email protected]" | ||
"node": ">=14.0.0", | ||
"pnpm": ">=7.5.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,33 @@ | ||
{ | ||
"name": "@sliit-foss/actions-exec-wrapper", | ||
"version": "1.1.1", | ||
"description": "A wrapper around the @actions/exec module which promisifies the console output of a command", | ||
"main": "dist/index.js", | ||
"scripts": { | ||
"build": "node ../../scripts/esbuild.config.js", | ||
"build:watch": "bash ../../scripts/esbuild.watch.sh", | ||
"bump-version": "bash ../../scripts/bump-version.sh --name=@sliit-foss/actions-exec-wrapper", | ||
"lint": "bash ../../scripts/lint.sh", | ||
"release": "bash ../../scripts/release.sh", | ||
"test": "bash ../../scripts/test/test.sh" | ||
}, | ||
"dependencies": { | ||
"@actions/exec": "1.1.1" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/sliit-foss/npm-catalogue.git" | ||
}, | ||
"keywords": [ | ||
"@actions/exec", | ||
"actions-exec-wrapper", | ||
"console-output" | ||
], | ||
"author": "SLIIT FOSS", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/sliit-foss/npm-catalogue/issues" | ||
}, | ||
"homepage": "https://github.com/sliit-foss/npm-catalogue/blob/main/packages/actions-exec-wrapper/readme.md" | ||
} | ||
{ | ||
"name": "@sliit-foss/actions-exec-wrapper", | ||
"version": "1.1.2", | ||
"description": "A wrapper around the @actions/exec module which promisifies the console output of a command", | ||
"main": "dist/index.js", | ||
"types": "types/index.d.ts", | ||
"scripts": { | ||
"build": "node ../../scripts/esbuild.config.js", | ||
"build:watch": "bash ../../scripts/esbuild.watch.sh", | ||
"bump-version": "bash ../../scripts/bump-version.sh --name=@sliit-foss/actions-exec-wrapper", | ||
"lint": "bash ../../scripts/lint.sh", | ||
"release": "bash ../../scripts/release.sh", | ||
"test": "bash ../../scripts/test/test.sh" | ||
}, | ||
"dependencies": { | ||
"@actions/exec": "1.1.1" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/sliit-foss/npm-catalogue.git" | ||
}, | ||
"keywords": [ | ||
"@actions/exec", | ||
"actions-exec-wrapper", | ||
"console-output" | ||
], | ||
"author": "SLIIT FOSS", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/sliit-foss/npm-catalogue/issues" | ||
}, | ||
"homepage": "https://github.com/sliit-foss/npm-catalogue/blob/main/packages/actions-exec-wrapper/readme.md" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/** | ||
* @description Runs a given CLI command and return's it's standard output(stdout) | ||
* @param command The command to be run | ||
* @returns Command output wrapped around a promise | ||
* @example | ||
* exec("npm --version") | ||
* .then((result) => { | ||
* console.log(result); | ||
* }) | ||
* .catch((error) => { | ||
* console.log(error); | ||
* }); | ||
*/ | ||
export default function execute(command: string): Promise<string>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
{ | ||
"name": "json-hash", | ||
"version": "1.0.0", | ||
"description": "Hash JS objects reliablly on both Node.js and browser", | ||
"main": "dist/index.js", | ||
"scripts": { | ||
"build": "node ../../scripts/esbuild.config.js", | ||
"build:watch": "bash ../../scripts/esbuild.watch.sh", | ||
"bump-version": "bash ../../scripts/bump-version.sh --name=@sliit-foss/json-hash", | ||
"lint": "bash ../../scripts/lint.sh", | ||
"release": "bash ../../scripts/release.sh", | ||
"test": "bash ../../scripts/test/test.sh" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/sliit-foss/npm-catalogue.git" | ||
}, | ||
"dependencies": { | ||
"json-stable-stringify": "1.1.1" | ||
}, | ||
"devDependencies": { | ||
"lodash": "4.17.10" | ||
}, | ||
"keywords": [ | ||
"json", | ||
"hash", | ||
"hashing", | ||
"object-hash" | ||
], | ||
"author": "SLIIT FOSS", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/sliit-foss/npm-catalogue/issues" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
export const algos = { | ||
"SHA-1": "sha1", | ||
"SHA-256": "sha256", | ||
"SHA-384": "sha384", | ||
"SHA-512": "sha512" | ||
}; | ||
|
||
export const getNodeJSAlgoName = (algorithm) => { | ||
return algos[algorithm]; | ||
}; | ||
|
||
export const isAvailableAlgo = (algorithm) => { | ||
if (Object.prototype.hasOwnProperty.call(algos, algorithm)) { | ||
return true; | ||
} | ||
|
||
return false; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { getNodeJSAlgoName, isAvailableAlgo } from "./algorithms.js"; | ||
|
||
export const computeHash = async (obj, { algorithm = "SHA-1", sort = false }) => { | ||
if (!isAvailableAlgo(algorithm)) { | ||
throw new Error("Provided algorithm is not available"); | ||
} | ||
|
||
if (typeof obj !== "string") { | ||
if (sort) { | ||
const { default: stringify } = await import("json-stable-stringify"); | ||
obj = stringify(obj); | ||
} else { | ||
obj = JSON.stringify(obj); | ||
} | ||
} | ||
|
||
// For browser | ||
// eslint-disable-next-line no-undef | ||
if (typeof window !== "undefined" && window.crypto && window.crypto.subtle) { | ||
const msgUint8 = new TextEncoder().encode(obj); // encode as (utf-8) Uint8Array | ||
|
||
// eslint-disable-next-line no-undef | ||
const hashBuffer = await window.crypto.subtle.digest(algorithm, msgUint8); // hash data | ||
const hashArray = Array.from(new Uint8Array(hashBuffer)); // convert buffer to byte array | ||
const hashHex = hashArray.map((b) => b.toString(16).padStart(2, "0")).join(""); // convert bytes to hex string | ||
return hashHex; | ||
} | ||
|
||
// For Node.js | ||
if (typeof global !== "undefined" && global.crypto) { | ||
const { createHash } = await import("crypto"); | ||
const hash = createHash(getNodeJSAlgoName(algorithm)).update(obj).digest("hex"); | ||
return hash; | ||
} | ||
}; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can use algos[algorithm] here instead right, will be more readable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done