Skip to content

Commit

Permalink
PREAPPS-6152 Add husky and tslint-staged
Browse files Browse the repository at this point in the history
- upgrade prettier
  • Loading branch information
silentsakky committed Jun 23, 2021
1 parent c3ff62e commit c4056a2
Show file tree
Hide file tree
Showing 7 changed files with 180 additions and 17 deletions.
1 change: 1 addition & 0 deletions .husky/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx tslint-staged
4 changes: 4 additions & 0 deletions .husky/prepare-commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

./scripts/git-commit-msg.sh $1
2 changes: 1 addition & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"useTabs": true,
"singleQuote": true,
"printWidth": 100,
"trailingComma": "none",
"arrowParens": "avoid"
}
151 changes: 138 additions & 13 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 12 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
"size": "echo \"Gzipped Size: $(gzip-size $npm_package_main | pretty-bytes)\"",
"prepublishOnly": "npm test && npm run build && git commit -am $npm_package_version && git tag $npm_package_version && git push && git push --tags",
"publish:beta": "npm publish --tag=beta",
"security:audit": "audit-ci --moderate --report-type summary --pass-enoaudit"
"security:audit": "audit-ci --moderate --report-type summary --pass-enoaudit --skip-dev",
"prepare": "is-ci || husky install"
},
"keywords": [
"zimbra",
Expand All @@ -37,6 +38,11 @@
],
"repository": "Zimbra/zm-api-js-client",
"license": "BSD-3-Clause",
"tslintStaged": {
"tslintConfig": "tslint.json",
"include": [ "**/*.ts" ],
"exclude": []
},
"dependencies": {
"@apollo/client": "^3.2.1",
"dataloader": "^1.4.0",
Expand All @@ -62,15 +68,17 @@
"@types/lodash": "^4.14.162",
"@types/node": "^14.14.2",
"@types/whatwg-fetch": "^0.0.33",
"audit-ci": "^3.2.0",
"audit-ci": "^4.1.0",
"babel-plugin-lodash": "^3.3.4",
"chai": "^4.2.0",
"copyfiles": "^2.4.1",
"cross-var": "^1.1.0",
"file-matcher": "^1.3.0",
"husky": "^6.0.0",
"is-ci": "^3.0.0",
"mocha": "^8.3.2",
"npm-run-all": "^4.1.5",
"prettier": "^2.1.2",
"prettier": "^2.3.1",
"rimraf": "^3.0.2",
"rollup": "^2.32.1",
"rollup-plugin-graphql": "^0.1.0",
Expand All @@ -79,6 +87,7 @@
"tslint": "^5.20.1",
"tslint-config-prettier": "^1.18.0",
"tslint-plugin-prettier": "^2.3.0",
"tslint-staged": "^0.1.3",
"typescript": "^4.0.3",
"uglify-js": "^3.12.1"
}
Expand Down
20 changes: 20 additions & 0 deletions scripts/git-commit-msg.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash

# This way you can customize which branches should be skipped when
# prepending commit message.
if [ -z "$BRANCHES_TO_SKIP" ]; then
BRANCHES_TO_SKIP=(master)
fi

# Get the current branch name
BRANCH_NAME=$(git symbolic-ref --short HEAD)

# Strip any leading prefix, up to and including, the last "/". e.g. turn "feature/ISSUE-1234" into "ISSUE-1234"
BRANCH_NAME="${BRANCH_NAME##*/}"

BRANCH_EXCLUDED=$(printf "%s\n" "${BRANCHES_TO_SKIP[@]}" | grep -c "^$BRANCH_NAME$")
BRANCH_IN_COMMIT=$(grep -c "^$BRANCH_NAME" $1)

if [ -n "$BRANCH_NAME" ] && ! [[ $BRANCH_EXCLUDED -eq 1 ]] && ! [[ $BRANCH_IN_COMMIT -ge 1 ]]; then
sed -i.bak -e "1s/^/$BRANCH_NAME /" $1
fi

0 comments on commit c4056a2

Please sign in to comment.