generated from krauters/typescript-core
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3197d61
commit ca2762a
Showing
17 changed files
with
381 additions
and
153 deletions.
There are no files selected for viewing
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 @@ | ||
. ./scripts/pre-commit/index.sh |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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,17 @@ | ||
#!/bin/sh | ||
|
||
# Check if MAIN_DIR is set; if not, use the default directory calculation | ||
if [ -z "$MAIN_DIR" ]; then | ||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)/../scripts/pre-commit" | ||
else | ||
SCRIPT_DIR="$MAIN_DIR" | ||
fi | ||
|
||
. "$SCRIPT_DIR/log.sh" | ||
log "Running pre-commit scripts from directory [${SCRIPT_DIR}]" | ||
|
||
|
||
. "$SCRIPT_DIR/version.sh" | ||
|
||
log 'All pre-commit checks passed.' | ||
exit 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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/bin/sh | ||
|
||
# This script provides reusable logging functions for other scripts. | ||
|
||
# Color codes | ||
RED='\033[1;31m' | ||
GREEN='\033[1;32m' | ||
NC='\033[0m' # No Color | ||
|
||
# Prefix for log messages | ||
PREFIX='[CHECKS]' | ||
|
||
# Log functions | ||
log() { | ||
echo "${GREEN}${PREFIX}${NC} $1" | ||
} | ||
|
||
error() { | ||
echo "${RED}${PREFIX}${NC} $1" | ||
} |
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 @@ | ||
#!/bin/sh | ||
|
||
log 'Running version check...' | ||
|
||
# Execute the version check from @krauters/utils | ||
if ! OUTPUT=$(npx ts-node "$SCRIPT_DIR/../../src/scripts/pre-commit.ts" 2>&1); then | ||
error "Version check failed:\n\n${OUTPUT}\n" | ||
error 'Aborting commit.' | ||
error "Run commit with '-n' to skip pre-commit hooks." | ||
exit 1 | ||
fi | ||
|
||
log "Version check output...\n\n${OUTPUT}\n" | ||
log 'Version check passed.' |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './version' |
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,25 @@ | ||
# Scripts | ||
|
||
This folder contains reusable TypeScript scripts intended for pre-commit checks and other automation tasks, designed to be used across multiple repositories. | ||
|
||
## Purpose | ||
|
||
- **Centralized Automation:** Provides a consistent way to enforce checks, such as version validation, before committing changes. | ||
- **Ease of Integration:** Ensures all consuming repositories maintain uniform pre-commit behavior. | ||
|
||
## Key Script | ||
|
||
- **`pre-commit.ts`**: This script handles pre-commit checks (like version validation). It’s meant to be executed via a bash script. | ||
|
||
## Usage | ||
|
||
1. **Install Dependencies**: | ||
``` | ||
npm install --save-dev @krauters/utils ts-node | ||
``` | ||
2. **Set Up Your Pre-Commit Hook**: | ||
- Use a bash script to call `/scripts/pre-commit/index.sh` (or other specific scripst) in your repo. | ||
```sh | ||
. ./node_modules/@krauters/utils/scripts/pre-commit/index.sh | ||
``` |
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 @@ | ||
import './version' |
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,3 @@ | ||
const { compareVersions } = require('../version') | ||
|
||
compareVersions() |
Oops, something went wrong.