Skip to content

Commit

Permalink
ci: add husky and commit-lint integration
Browse files Browse the repository at this point in the history
  • Loading branch information
robsonos committed Dec 19, 2023
1 parent 6a51572 commit bb013c4
Show file tree
Hide file tree
Showing 5 changed files with 518 additions and 30 deletions.
4 changes: 4 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx --no -- commitlint --edit ${1}
42 changes: 38 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash

```

#### Sample .zshrc
#### Local setup

Your `~/.zshrc` should look more or less like this the following:
Your `~/.zshrc` should look more or less like the following:

```shell
# rbenv
Expand All @@ -58,8 +58,29 @@ eval "$(jenv init -)"

# nvm
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"

# nvm autoload .nvmrc
autoload -U add-zsh-hook
load-nvmrc() {
local nvmrc_path
nvmrc_path="$(nvm_find_nvmrc)"

if [ -n "$nvmrc_path" ]; then
local nvmrc_node_version
nvmrc_node_version=$(nvm version "$(cat "${nvmrc_path}")")

if [ "$nvmrc_node_version" = "N/A" ]; then
nvm install
elif [ "$nvmrc_node_version" != "$(nvm version)" ]; then
nvm use
fi
elif [ -n "$(PWD=$OLDPWD nvm_find_nvmrc)" ] && [ "$(nvm version)" != "$(nvm version default)" ]; then
echo "Reverting to nvm default version"
nvm use default
fi
}

# android
export ANDROID_HOME=$HOME/Library/Android/sdk
Expand All @@ -69,6 +90,19 @@ export PATH=$PATH:$ANDROID_HOME/tools/bin
export PATH=$PATH:$ANDROID_HOME/emulator
```

You will also need a `~/.huskyrc` like this the following for [husky](https://typicode.github.io/husky/):

```shell
# nvm
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"

if [ -f ".nvmrc" ]; then
nvm use --silent
fi

```

#### Dependency version

ruby:
Expand Down
1 change: 1 addition & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = { extends: ['@commitlint/config-conventional'] };
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,16 @@
"clean": "rimraf ./dist",
"watch": "tsc --watch",
"test": "echo \"No test specified\"",
"prepare": "husky install",
"prepublishOnly": "npm run build"
},
"devDependencies": {
"@capacitor/android": "^5.3.0",
"@capacitor/core": "^5.3.0",
"@capacitor/docgen": "^0.2.0",
"@capacitor/ios": "^5.3.0",
"@commitlint/cli": "^18.4.3",
"@commitlint/config-conventional": "^18.4.3",
"@ionic/eslint-config": "^0.3.0",
"@ionic/prettier-config": "^2.0.0",
"@semantic-release/changelog": "^6.0.3",
Expand Down
Loading

0 comments on commit bb013c4

Please sign in to comment.