Skip to content

Commit

Permalink
build: use gobstones-scripts in the project
Browse files Browse the repository at this point in the history
  • Loading branch information
alanrodas committed Sep 4, 2024
1 parent a1af8c3 commit 51a5b67
Show file tree
Hide file tree
Showing 92 changed files with 2,395 additions and 1,147 deletions.
26 changes: 12 additions & 14 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
# http://editorconfig.org

root = true
root=true

[*]
charset = utf-8
end_of_line = lf
indent_style = space
indent_size = 4
trim_trailing_whitespace = true
insert_final_newline = true
charset=utf-8
end_of_line=lf
indent_style=space
indent_size=4
trim_trailing_whitespace=true
insert_final_newline=true

# Use 2 spaces since npm does not respect custom indentation settings
[package.json]
indent_style = space
indent_size = 2
[*.md]
trim_trailing_whitespace=false

# Use 2 spaces since npm does not respect custom indentation settings
[**/package-definition.json]
indent_style = space
indent_size = 2
[package.json]
indent_style=space
indent_size=2
6 changes: 4 additions & 2 deletions .github/workflows/on-commit-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ jobs:
uses: actions/setup-node@v4
with:
node-version: '20'
env:
HUSKY: 0
- name: Installing project dependencies
run: npm install
- name: Build the code
run: npm start build
env:
CI: true
10 changes: 6 additions & 4 deletions .github/workflows/on-commit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,18 @@ jobs:
test:
name: Run tests
runs-on: ubuntu-latest
env:
NODE_OPTIONS: --experimental-modules
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup node version
uses: actions/setup-node@v4
with:
node-version: '20'
env:
HUSKY: 0
- name: Installing project dependencies
run: npm install
- name: Linting the code
run: npm start lint
- name: Test the code
run: npm start test
env:
CI: true
2 changes: 0 additions & 2 deletions .github/workflows/on-tag-publish-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ jobs:
uses: actions/setup-node@v4
with:
node-version: '20'
env:
HUSKY: 0
- name: Installing project dependencies
run: npm install
- name: Building the docs
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/on-tag-release-github.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ jobs:
with:
node-version: '20'
env:
HUSKY: 0
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Installing project dependencies
run: npm install
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/on-tag-release-npm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ jobs:
with:
node-version: '20'
env:
HUSKY: 0
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Installing project dependencies
run: npm install
Expand Down
8 changes: 2 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# OS generated files #
# OS generated files
.DS_Store
Thumbs.db
.tmp/

# IDE generated file #
# IDE generated file
.idea/

# PackageManager specific lock files
Expand All @@ -28,7 +28,3 @@ dist/

# Docs generated folder
docs/

# Verdaccio storage
test/verdaccio/storage

14 changes: 7 additions & 7 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Read parameters
COMMIT_MSG_FILE=$1;
COMMIT_MSG_FILE=$1

# Set failing on command fail, and undefined variable use
set -eu;
set -eu

# This hook is invoked by git-commit and git-merge, and can be
# bypassed with the --no-verify option. It takes a single
Expand All @@ -23,10 +23,10 @@ set -eu;
# message sent has the correct format for the project, aborting otherwise.

# Show welcome message
echo "**************************";
echo "Linting the commit message";
echo "**************************";
echo "";
echo "**************************"
echo "Linting the commit message"
echo "**************************"
echo ""

# Run commitlint
npx --no -- commitlint --edit ${1};
npx --no -- commitlint --edit ${1}
35 changes: 19 additions & 16 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# NOTHING TO READ HERE

# Set failing on command fail, and undefined variable use
set -eu;
set -eu

# This hook is invoked by git-commit, and can be bypassed with the
# --no-verify option. It takes no parameters, and is invoked before
Expand All @@ -26,26 +26,29 @@ set -eu;
# Generated files are added to the commit.

# Show welcome message
echo "**************************";
echo "Running pre commit hooks";
echo "**************************";
echo "";
echo "**************************"
echo "Running pre commit hooks"
echo "**************************"
echo ""

# Run license
echo "\nAdd license text to code files\n";
npx --no -- nps license;

# Run prettify
echo "Run prettify\n";
npx --no -- nps prettify;
echo "\nAdd license text to code files\n"
npx --no -- gobstones-scripts run license --silent

# Run changelog
echo "\nRun changelog\n";
npx --no -- nps changelog;
echo "\nRun changelog\n"
# Only run if not first commit
if git-log &> /dev/null; then
npx --no -- gobstones-scripts run changelog --silent
fi

# Run prettify
echo "Run prettify\n"
npx --no -- gobstones-scripts run prettify --silent

# Add all generated files
echo "\nAdd generated files to commit\n";
git add --all;
echo "\nAdd generated files to commit\n"
git add --all

# Exit
exit 0;
exit 0
42 changes: 24 additions & 18 deletions .husky/pre-push
Original file line number Diff line number Diff line change
@@ -1,34 +1,40 @@
# Read parameters
REMOTE_NAME=$1;
REMOTE_URL=$2;
REMOTE_NAME=$1
REMOTE_URL=$2
# Read the input and split it approprietly
INPUT=$(cat);
COUNTER=0;
INPUT=$(cat)
COUNTER=0
for WORD in $INPUT; do
case $COUNTER in
0)
LOCAL_REF=$WORD;;
LOCAL_REF=$WORD
;;
1)
LOCAL_OBJ_NAME=$WORD;;
LOCAL_OBJ_NAME=$WORD
;;
2)
REMOTE_REF=$WORD;;
REMOTE_REF=$WORD
;;
3)
REMOTE_OBJ_NAME=$WORD;;
REMOTE_OBJ_NAME=$WORD
;;
esac
COUNTER=$((COUNTER + 1))
done

case "$LOCAL_REF" in
refs\/tags*)
# Apply specific code when publishing tags
IS_TAG=1;;
IS_TAG=1
;;
*)
# Apply specific code when publishing any branch
IS_TAG=0;;
IS_TAG=0
;;
esac

# Set failing on command fail, and undefined variable use
set -eu;
set -eu

# This hook is called by git-push and can be used to prevent a
# push from taking place. The hook is called with two parameters
Expand Down Expand Up @@ -65,13 +71,13 @@ set -eu;
# to match that of the tag.

# Show welcome message
echo "**************************";
echo "Running pre push hooks";
echo "**************************";
echo "";
echo "**************************"
echo "Running pre push hooks"
echo "**************************"
echo ""

# Run all the tests
echo "Running tests";
npx --no -- nps test;
echo "Running tests"
npx --no -- gobstones-scripts run test --silent

exit 0;
exit 0
38 changes: 19 additions & 19 deletions .husky/prepare-commit-msg
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Read parameters
COMMIT_MSG_FILE=$1;
COMMIT_SOURCE=$2;
SHA1=$3;
COMMIT_MSG_FILE=$1
COMMIT_SOURCE=$2
SHA1=$3

# Set failing on command fail, and undefined variable use
set -eu;
set -eu

# This hook is invoked by git-commit right after preparing
# the default log message, and before the editor is started.
Expand Down Expand Up @@ -34,44 +34,44 @@ set -eu;
# semantic commit message through a prompt.

# Show welcome message
echo "**************************";
echo "Generate commit message";
echo "**************************";
echo "";
echo "**************************"
echo "Generate commit message"
echo "**************************"
echo ""

# Check if we are doing an amend
if [ "$COMMIT_SOURCE" = 'commit' ] && [ -n "$SHA1" ]; then
if [ "$COMMIT_SOURCE" = 'commit' ] && [ -n $SHA1 ]; then
# Amends do not call the "cz" command.
exit 0;
exit 0
fi

# Check if we are doing an squash
if [ "$COMMIT_SOURCE" = 'squash' ]; then
# Squashes should not trigger the cz command.
exit 0;
exit 0
fi

# Check if we are doing an merge
if [ "$COMMIT_SOURCE" = 'merge' ]; then
# Merging should not trigger the cz command.
exit 0;
exit 0
fi

# Check if we are using a template
if [ "$COMMIT_SOURCE" = 'template' ]; then
# Cannot use templates, warn the user and fail.
echo "Setting a template through -t or commit.template in this project ";
echo "has been disabled. Please run a simple commit.\n";
exit 1;
echo "Setting a template through -t or commit.template in this project "
echo "has been disabled. Please run a simple commit.\n"
exit 1
fi

# Check if a message was given
if [ "$COMMIT_SOURCE" = 'message' ]; then
# Cannot use message, warn the user and fail.
echo "Setting a message through -m or -F option in this project ";
echo "has been disabled. Please run a simple commit.\n";
exit 1;
echo "Setting a message through -m or -F option in this project "
echo "has been disabled. Please run a simple commit.\n"
exit 1
fi

# Regular commit has been performed, run the command.
exec < /dev/tty && npx cz --hook || true;
exec < /dev/tty && npx cz --hook || true
15 changes: 11 additions & 4 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
# Editor and style files
.editorconfig
.prettierignore
.prettierrc
.eslintrc.js
.vscode/*
.github/*
.husky/*

# tests
test/*
jest.config.js
coverage

# docs
docs

# Building Configuration Files
webpack.config.js
rollup.config.js
tsconfig.json
package-scripts.js

# Additional documentation
TODO.md

# Add files in init-files
!init-files/*
!config/*
23 changes: 0 additions & 23 deletions .prettierignore

This file was deleted.

Loading

0 comments on commit 51a5b67

Please sign in to comment.