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 ce6a6b8
Showing
15 changed files
with
399 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,36 @@ | ||
#!/bin/sh | ||
|
||
# This script is an example of how a pre-commit hook might be set up | ||
# to execute pre-commit scripts from @krauters/utils. | ||
# | ||
# Prerequisite: Make sure to install @krauters/utils and ts-node in your project | ||
# npm install --save-dev @krauters/utils ts-node | ||
|
||
RED='\033[1;31m' | ||
GREEN='\033[1;32m' | ||
NC='\033[0m' | ||
|
||
PREFIX='[CHECKS]' | ||
|
||
log() { | ||
echo "${GREEN}${PREFIX}${NC} $1" | ||
} | ||
|
||
error() { | ||
echo "${RED}${PREFIX}${NC} $1" | ||
} | ||
|
||
log 'Running pre-commit scripts...' | ||
|
||
# Adjust the path based on whether it's run from node_modules or locally as shown | ||
# if ! OUTPUT=$(npx ts-node ./node_modules/@krauters/utils/src/scripts/pre-commit.ts 2>&1); then | ||
if ! OUTPUT=$(npx ts-node ./src/scripts/pre-commit.ts 2>&1); then | ||
error "Pre-commit check failed:\n\n${OUTPUT}\n" | ||
error 'Aborting commit.' | ||
error 'Run commit with '-n' to skip pre-commit hooks.' | ||
exit 1 | ||
fi | ||
|
||
log "Script output...\n\n${OUTPUT}\n" | ||
log '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
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 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,23 @@ | ||
# 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 `pre-commit.ts` (or other specific scripst) in your repo. | ||
For a detailed example, see [example.sh](./example.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,36 @@ | ||
#!/bin/sh | ||
|
||
# This script is an example of how a pre-commit hook might be set up | ||
# to execute pre-commit scripts from @krauters/utils. | ||
# | ||
# Prerequisite: Make sure to install @krauters/utils and ts-node in your project | ||
# npm install --save-dev @krauters/utils ts-node | ||
|
||
RED='\033[1;31m' | ||
GREEN='\033[1;32m' | ||
NC='\033[0m' | ||
|
||
PREFIX='[CHECKS]' | ||
|
||
log() { | ||
echo "${GREEN}${PREFIX}${NC} $1" | ||
} | ||
|
||
error() { | ||
echo "${RED}${PREFIX}${NC} $1" | ||
} | ||
|
||
log 'Running pre-commit scripts...' | ||
|
||
# Adjust the path based on whether it's run from node_modules or locally as shown | ||
# if ! OUTPUT=$(npx ts-node ./node_modules/@krauters/utils/src/scripts/pre-commit.ts 2>&1); then | ||
if ! OUTPUT=$(npx ts-node ./pre-commit.ts 2>&1); then | ||
error "Pre-commit check failed:\n\n${OUTPUT}\n" | ||
error 'Aborting commit.' | ||
error 'Run commit with '-n' to skip pre-commit hooks.' | ||
exit 1 | ||
fi | ||
|
||
log "Script output...\n\n${OUTPUT}\n" | ||
log '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 @@ | ||
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.