Skip to content
Merged
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
42 changes: 42 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/usr/bin/env sh

# Auto-update version to CalVer+ShortSHA format (YYYYMMDD-SHA)

# Get current date in YYYYMMDD format
DATE=$(date +%Y%m%d)

# Get previous commit short SHA (HEAD if exists, otherwise use initial)
if git rev-parse --verify HEAD >/dev/null 2>&1; then
SHA=$(git rev-parse --short HEAD)
else
# For initial commit, use placeholder
SHA="initial"
fi

# New version
NEW_VERSION="${DATE}-${SHA}"

# Get current version from package.json
CURRENT_VERSION=$(node -p "require('./package.json').version")

# Only update if version has changed
if [ "$CURRENT_VERSION" != "$NEW_VERSION" ]; then
echo "Updating version: $CURRENT_VERSION → $NEW_VERSION"

# Update package.json version using Node
node -e "
const fs = require('fs');
const pkg = require('./package.json');
pkg.version = '$NEW_VERSION';
fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2) + '\n');
"

# Update package-lock.json
npm install --package-lock-only --silent

# Stage the updated files
git add package.json package-lock.json
fi

# Run tests
npm test
27 changes: 25 additions & 2 deletions package-lock.json

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

6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
{
"name": "foaas",
"version": "2.4.0",
"version": "20260316-a33ab98",
"description": "Fuck Off As A Service",
"main": "lib/server.js",
"scripts": {
"start": "node lib/server.js",
"test": "nyc --reporter=lcov --exclude=spec jasmine",
"coverage": "nyc report --reporter=text-lcov | coveralls"
"coverage": "nyc report --reporter=text-lcov | coveralls",
"prepare": "husky"
},
"repository": "git@github.com:doomcrewinc/foaas",
"author": "Tom Cully / doomcrewinc",
"license": "WTFPL",
"devDependencies": {
"coveralls-next": "6.0.1",
"husky": "^9.1.7",
"jasmine": "^6.0.0",
"nyc": "^17.1.0"
},
Expand Down
Loading