Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 85 additions & 0 deletions .githooks/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
#!/bin/sh

# ANSI color codes
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color

echo "${YELLOW}*****~~~~~ Commit hook initiated ~~~~~~*****${NC}"

commit_msg_file=$1
commit_msg=$(cat "$commit_msg_file")

# Formatting
echo
echo "${YELLOW}*****~~~~~ Formatting - Check for unformatted files ~~~~~~*****${NC}"

# Check for unformatted ReScript files
npm run re:format

echo
echo "${GREEN}*****~~~~~ All files are formatted. ~~~~~~*****${NC}"
echo

# Trailing Space Check
echo
echo "${YELLOW}*****~~~~~ Evaluating for trailing spaces ~~~~~~*****${NC}"

find . -type f -name '.DS_Store' -exec rm {} +

TRAIL_SRC=$(grep -r '[[:blank:]]$' src --exclude='*.bs.js' --exclude='*.resi')

if [[ ! -z "$TRAIL_SRC" ]]; then
echo "$TRAIL_SRC"
echo
echo "${RED}!Please remove trailing spaces before committing changes${NC}"
echo "${YELLOW}Usage of EditorConfig [https://editorconfig.org/#download] plugin is recommended for development${NC}"
exit 1
fi

echo
echo "${GREEN}*****~~~~~ Done Evaluating ~~~~~~*****${NC}"

# Commit Message Validation
echo
echo "${YELLOW}*****~~~~~ Commit message validation! ~~~~~*****${NC}"
echo

commit_regex="^(Merge branch|(feat|fix|chore|refactor|docs|test|style|enhancement|ci|revert)(\([a-zA-Z0-9-]+\))?:).+"

if ! echo "$commit_msg" | grep -Ei "$commit_regex" ; then
echo "${RED}Aborting commit. Your commit message does not follow the conventional format.${NC}"
echo "${YELLOW}The commit message should begin with one of the following keywords followed by a colon and an optional scope in parentheses:${NC}"
echo "${YELLOW}'feat', 'fix', 'chore', 'refactor', 'docs', 'test', 'style', 'enhancement', 'revert', or 'ci'${NC}"
echo "${YELLOW}Example: 'feat(api): add user authentication endpoint' or 'fix(ui): resolve button alignment issue'${NC}"
exit 1
fi

# Gitleaks Secret Scan
echo
echo "${YELLOW}*****~~~~~ Scanning for secrets with Gitleaks ~~~~~~*****${NC}"
echo

if ! command -v gitleaks &> /dev/null; then
echo "${YELLOW}gitleaks not found. Installing via Homebrew...${NC}"
if command -v brew &> /dev/null; then
brew install gitleaks
else
echo "${RED}Homebrew not found. Please install gitleaks manually: https://github.com/gitleaks/gitleaks${NC}"
exit 1
fi
fi

if ! gitleaks protect --staged --redact --verbose; then
echo "${RED}Gitleaks detected secrets in staged changes. Aborting commit.${NC}"
echo "${YELLOW}Please remove the secrets before committing.${NC}"
exit 1
fi

echo "${GREEN}*****~~~~~ No secrets detected ~~~~~~*****${NC}"

echo
echo "${GREEN}*****~~~~~ Commit hook completed ~~~~~~*****${NC}"
echo
exit 0
89 changes: 87 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,89 @@
# Dependencies
node_modules
.DS_Store

# Build outputs
lib/bs
yarn.lock
lib/ocaml
.merlin

# ReScript
.bsb.lock

# Package manager lockfiles
yarn.lock

# OS files
.DS_Store
Thumbs.db

# Logs
npm-debug.log*
yarn-debug.log*
yarn-error.log*
*.log

# Environment variables
.env
.env.local
.env.*.local

# Coverage
coverage/

# Temp
tmp/
temp/

# IDE - VSCode
.vscode/
*.code-workspace

# IDE - JetBrains (IntelliJ, WebStorm, etc.)
.idea/
*.iml
*.iws
*.ipr

# IDE - Vim/Neovim
*.swp
*.swo
*~
.netrwhist

# IDE - Emacs
\#*\#
.\#*

# IDE - Sublime Text
*.sublime-project
*.sublime-workspace

# AI Agents - Cursor
.cursor/
.cursorignore
.cursorindexingignore

# AI Agents - OpenCode
.opencode/

# AI Agents - GitHub Copilot
.github/copilot-instructions.md

# AI Agents - Cline / Roo
.cline/
.roo/
.clinerules

# AI Agents - Windsurf
.windsurfrules

# AI Agents - Claude / Anthropic
CLAUDE.md
.claude/

# AI Agents - Aider
.aider*

# AI Agents - General
.ai/
*.aigenerated
22 changes: 20 additions & 2 deletions package-lock.json

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

13 changes: 11 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@juspay-tech/react-hyper-js",
"version": "2.3.0",
"version": "2.3.1",
"main": "dist/bundle.js",
"files": [
"dist/",
Expand All @@ -24,18 +24,27 @@
"react-dom": "^17.0.0 || ^18.0.0 || ^19.0.0"
},
"scripts": {
"pre-commit": "bash .githooks/commit-msg",
"build": "webpack --mode production",
"re:build": "rescript",
"re:start": "rescript build -w",
"re:format": "rescript format -all",
"re:clean": "rescript clean",
"publish:public": "npm publish --access public"
"publish:public": "npm publish --access public",
"setup:hooks": "git config core.hooksPath .githooks && chmod +x .githooks/commit-msg",
"postinstall": "npm run setup:hooks"
},
"husky": {
"hooks": {
"pre-commit": "npm run pre-commit"
}
},
"devDependencies": {
"@babel/core": "^7.27.4",
"@babel/preset-env": "^7.27.2",
"@babel/preset-react": "^7.27.1",
"babel-loader": "^10.0.0",
"husky": "^9.1.7",
"rescript": "^11.1.0",
"webpack": "^5.99.9",
"webpack-cli": "^6.0.1"
Expand Down
4 changes: 2 additions & 2 deletions src/components/Elements.res
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ let make = (~children, ~stripe: Promise.t<OrcaJs.switchInstance>, ~options: JSON

React.useEffect0(() => {
stripe
->Js.Promise.then_((switchInstance: OrcaJs.switchInstance) => {
->(Js.Promise.then_((switchInstance: OrcaJs.switchInstance) => {
let orcaElementsConfig = switchInstance.elements(options)
let newElemValues: Context.elementsType = {
options: elementOptions,
Expand All @@ -31,7 +31,7 @@ let make = (~children, ~stripe: Promise.t<OrcaJs.switchInstance>, ~options: JSON
setSwitchState(_ => switchValClone)
setElementsState(_ => newElemValues)
Promise.resolve(switchValClone)
}, _)
}, _))
->ignore
None
})
Expand Down
4 changes: 2 additions & 2 deletions src/components/HyperElements.res
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ let make = (~children, ~hyper: Promise.t<OrcaJs.switchInstance>, ~options: JSON.

React.useEffect0(() => {
hyper
->Js.Promise.then_((switchInstance: OrcaJs.switchInstance) => {
->(Js.Promise.then_((switchInstance: OrcaJs.switchInstance) => {
let orcaElementsConfig = switchInstance.elements(options)
let newElemValues: Context.elementsType = {
options: elementOptions,
Expand Down Expand Up @@ -41,7 +41,7 @@ let make = (~children, ~hyper: Promise.t<OrcaJs.switchInstance>, ~options: JSON.
setElementsState(_ => newElemValues)
setPaymentSessionState(_ => newPaymentSessionValues)
Promise.resolve(switchValClone)
}, _)
}, _))
->ignore
None
})
Expand Down
Loading