Skip to content

Commit

Permalink
feat: initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
al-mart committed Oct 12, 2024
1 parent 0038073 commit a21be3b
Show file tree
Hide file tree
Showing 116 changed files with 25,241 additions and 1 deletion.
11 changes: 11 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Editor configuration, see http://editorconfig.org
root = true

[*]
charset = utf-8
insert_final_newline = true
trim_trailing_whitespace = true

[*.md]
max_line_length = 120
trim_trailing_whitespace = false
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
text eol=lf
71 changes: 71 additions & 0 deletions .github/actions/commit-and-push-changes/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: 'commit-and-push'
description: 'Commit and push tags'
runs:
using: "composite"
steps:
- name: Get changed libs
shell: bash
run: |
# Ensure jq is installed
if ! command -v jq &> /dev/null
then
echo "jq could not be found, please ensure it is installed."
exit 1
fi
# Get affected projects and initialize variables
UPDATED_LIBS=()
AFFECTED_PROJECTS=($(npx nx show projects --affected --base=HEAD~1))
# Check if there are any affected projects
if [[ ${#AFFECTED_PROJECTS[@]} -eq 0 ]]; then
echo "No affected projects found. Exiting."
exit 0
fi
# Initialize the commit message
COMMIT_MESSAGE='version: '
# Loop through affected projects and check their versions
for PROJECT in "${AFFECTED_PROJECTS[@]}"; do
PACKAGE="libs/$PROJECT/package.json"
if [[ -f $PACKAGE ]]; then
TAG=''
PROJECT_VERSION=$(jq ".version" -r < "$PACKAGE")
if [[ $PROJECT_VERSION ]]; then
TAG="$PROJECT-v$PROJECT_VERSION"
UPDATED_LIBS+=("$TAG")
fi
# Update commit message
COMMIT_MESSAGE="$COMMIT_MESSAGE ($TAG)"
else
echo "Package.json not found for project $PROJECT. Skipping."
fi
done
# If no libraries were updated, skip the commit
if [[ ${#UPDATED_LIBS[@]} -eq 0 ]]; then
echo "No updated libraries found. Skipping commit and push."
exit 0
fi
# Commit the changes if there are updated libs
echo "${COMMIT_MESSAGE}"
git add .
git commit -m "${COMMIT_MESSAGE}"
git push origin
# Tag the updated libraries
for TAG in "${UPDATED_LIBS[@]}"; do
if git rev-parse "$TAG" >/dev/null 2>&1; then
echo "Tag $TAG already exists. Skipping force push."
else
git tag "$TAG"
fi
done
# Push tags
git push origin --tags
57 changes: 57 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Publish libs
on:
push:
branches:
- main
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
jobs:
release:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Get tags
run: git fetch --tags origin
- name: Enable Corepack (for Yarn v4)
run: corepack enable
- name: Get Yarn cache directory
id: yarn-cache-dir
shell: bash
run: echo "dir=$(yarn cache dir)" >> ${GITHUB_OUTPUT}
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
cache: 'yarn'
cache-dependency-path: yarn.lock
- name: Cache Yarn modules
id: cache-yarn
uses: actions/cache@v3
with:
path: ${{ steps.yarn-cache-dir.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- if: ${{ steps.cache-yarn.outputs.cache-hit != 'true' }}
name: List the state of Yarn modules
continue-on-error: true
run: yarn list
- name: Init git
run: |
git config --global user.name 'Safe angular Action'
git config --global user.email '[email protected]'
- name: Install dependencies with Yarn v4
run: yarn install

- name: Version
run: |
echo "Checking for affected libraries and updating versions..."
npx nx affected --base=HEAD~1 --target=version --parallel=1 || exit 1
- name: Commit
uses: ./.github/actions/commit-and-push-changes
if: success()
continue-on-error: true
47 changes: 47 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# See http://help.github.com/ignore-files/ for more about ignoring files.

# compiled output
dist
tmp
/out-tsc

# dependencies
node_modules

# IDEs and editors
/.idea
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace

# IDE - VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json

# misc
/.sass-cache
/connect.lock
/coverage
/libpeerconnection.log
npm-debug.log
yarn-error.log
testem.log
/typings

# System Files
.DS_Store
Thumbs.db

.nx/cache
.nx/workspace-data

.angular
.yarn/install-state.gz
!.yarn/releases/yarn-*.cjs

19 changes: 19 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
echo "Checking commit-message format..."

# Get commit-message from the temporary file
INPUT_FILE=$1
commit_msg=$(head -n1 "$INPUT_FILE" | sed -e 's/\ *$//g')

# Use grep for regex matching in sh
echo "$commit_msg" | grep -Eq "^(feat|fix|perf|release|hotfix|revert): [a-z, ]{3,75}$"

if [ $? -ne 0 ]; then
echo "Your commit-message format is not valid: $commit_msg"
echo "Valid format examples:"
echo "feat: message is not longer than 75 symbols "
echo "fix: message is longer than 3 symbols"
echo "Available prefixes are: feat, fix, perf, release, hotfix, revert"
exit 1
fi

exit 0
1 change: 1 addition & 0 deletions .husky/post-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
git update-index -g
14 changes: 14 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Get the list of staged files
FILES=$(git diff --cached --name-only --diff-filter=ACMR)

# If no files are staged, exit
[ -z "$FILES" ] && exit 0

# Add back the modified/prettified files to staging (handling files with spaces)
echo "$FILES" | tr '\n' '\0' | xargs -0 git add

# Run linting and testing for precommit
yarn lint:precommit
yarn test:precommit

exit 0
1 change: 1 addition & 0 deletions .nxignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
**/eslint.config.js
12 changes: 12 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"recommendations": [
"nrwl.angular-console",
"esbenp.prettier-vscode",
"firsttris.vscode-jest-runner",
"ms-playwright.playwright",
"dbaeumer.vscode-eslint",
"streetsidesoftware.code-spell-checker",
"eamodio.gitlens",
"pflannery.vscode-versionlens"
]
}
21 changes: 21 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"files.eol": "\n",
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit"
},
"cSpell.language": "en",
"typescript.tsdk": "node_modules/typescript/lib",
"typescript.updateImportsOnFileMove.enabled": "always",
"javascript.updateImportsOnFileMove.enabled": "always",
"editor.linkedEditing": true,
"eslint.probe": ["javascript", "typescript", "html", "markdown"],
"eslint.validate": ["json"],
"prettier.prettierPath": "./node_modules/prettier/index.cjs",
"prettier.configPath": "./prettier.config.mjs",
"eslint.experimental.useFlatConfig": true,
"[json]": {
"editor.defaultFormatter": "vscode.json-language-features"
}
}
Loading

0 comments on commit a21be3b

Please sign in to comment.