File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3,6 +3,11 @@ name: Publish to npm with Provenance
33on :
44 release :
55 types : [published]
6+ workflow_dispatch : # Allow manual triggers for hotfixes
7+
8+ concurrency :
9+ group : publish-${{ github.ref }}
10+ cancel-in-progress : false # Don't cancel in-progress publishes
611
712jobs :
813 publish :
@@ -19,16 +24,14 @@ jobs:
1924 with :
2025 node-version : ' 20'
2126 registry-url : ' https://registry.npmjs.org'
27+ cache : ' npm' # Cache npm dependencies for faster builds
2228
2329 - name : Install dependencies
2430 run : npm ci
2531
2632 - name : Run tests
2733 run : npm test
2834
29- - name : Build browser bundle
30- run : npx esbuild index.js --bundle --minify --sourcemap --outfile=dist/bri.js
31-
3235 - name : Publish to npm with provenance
3336 run : npm publish --provenance --access public
3437 env :
Original file line number Diff line number Diff line change 11#! /usr/bin/env bash
2+ set -euo pipefail
23# .hooks/pre-commit - Pre-commit validation orchestrator for BRI 🐺
34# This script runs all check scripts in .hooks/pre-commit.d/
45# Each check script must exit 0 on success, non-zero on failure.
56
6- # Only run on main branch
7- CURRENT_BRANCH=$( git rev-parse --abbrev-ref HEAD)
8- if [ " $CURRENT_BRANCH " != " main" ]; then
9- echo " 🦍 Skipping pre-commit checks on branch: $CURRENT_BRANCH (checks only run on main)"
10- exit 0
11- fi
12-
137HOOKS_DIR=" $( cd " $( dirname " $0 " ) " && pwd) "
148CHECKS_DIR=" $HOOKS_DIR /pre-commit.d"
159
Original file line number Diff line number Diff line change @@ -85,7 +85,10 @@ check_file_documented() {
8585}
8686
8787# Get list of staged files (added or modified)
88- STAGED_FILES=$( git diff --cached --name-only --diff-filter=AM 2> /dev/null || true)
88+ if ! STAGED_FILES=$( git diff --cached --name-only --diff-filter=AM 2>&1 ) ; then
89+ echo " ❌ Failed to get staged files from git"
90+ exit 1
91+ fi
8992
9093# Exit early if no staged files
9194if [ -z " $STAGED_FILES " ]; then
@@ -105,7 +108,7 @@ for file in $STAGED_FILES; do
105108 dir=$( dirname " $file " )
106109 while [ " $dir " != " ." ] && [ " $dir " != " /" ]; do
107110 # Check if this directory is being newly created (not in HEAD)
108- if ! git ls-tree -d HEAD " $dir " & > /dev/null 2>&1 ; then
111+ if ! git ls-tree -d HEAD " $dir " > /dev/null 2>&1 ; then
109112 # Add to array if not already present
110113 if ! array_contains " $dir " " ${NEW_DIRS[@]} " ; then
111114 NEW_DIRS+=(" $dir " )
Original file line number Diff line number Diff line change @@ -22,7 +22,11 @@ if [ ! -f "$VALIDATOR" ]; then
2222fi
2323
2424# Get list of staged JS files (added or modified)
25- STAGED_FILES=$( git diff --cached --name-only --diff-filter=AM 2> /dev/null | grep ' \.js$' || true)
25+ if ! ALL_STAGED=$( git diff --cached --name-only --diff-filter=AM 2>&1 ) ; then
26+ echo " ❌ Failed to get staged files from git"
27+ exit 1
28+ fi
29+ STAGED_FILES=$( echo " $ALL_STAGED " | grep ' \.js$' || true)
2630
2731# Exit early if no JS files staged
2832if [ -z " $STAGED_FILES " ]; then
Original file line number Diff line number Diff line change @@ -18,7 +18,8 @@ function hasReturnValue(body) {
1818 . replace ( / ` (?: [ ^ ` \\ ] | \\ .) * ` / g, '""' ) ;
1919
2020 // Check for return with a value (not just "return;" or "return }")
21- return / r e t u r n \s + [ ^ ; \s } ] / . test ( cleaned ) ;
21+ // Handles: return value; return\n value; return {obj}; return [arr];
22+ return / r e t u r n [ \s \n ] + [ ^ ; \s } ] / . test ( cleaned ) ;
2223}
2324
2425/**
Original file line number Diff line number Diff line change 1+ {
2+ "type" : " commonjs"
3+ }
Original file line number Diff line number Diff line change @@ -37,6 +37,10 @@ array_contains() {
3737}
3838
3939# Get list of staged files (added or modified)
40+ # Returns 1 if git command fails, 0 otherwise (even if no files)
4041get_staged_files () {
41- git diff --cached --name-only --diff-filter=AM 2> /dev/null || true
42+ if ! git diff --cached --name-only --diff-filter=AM 2>&1 ; then
43+ return 1
44+ fi
45+ return 0
4246}
Original file line number Diff line number Diff line change 1414 },
1515 "scripts" : {
1616 "test" : " node --experimental-vm-modules node_modules/jest/bin/jest.js" ,
17- "test:coverage" : " node --experimental-vm-modules node_modules/jest/bin/jest.js --coverage"
17+ "test:coverage" : " node --experimental-vm-modules node_modules/jest/bin/jest.js --coverage" ,
18+ "prepare" : " git config core.hooksPath .hooks"
1819 },
1920 "devDependencies" : {
2021 "jest" : " ^29.7.0"
You can’t perform that action at this time.
0 commit comments