diff --git a/.husky/pre-commit b/.husky/pre-commit new file mode 100755 index 0000000000..8527102f54 --- /dev/null +++ b/.husky/pre-commit @@ -0,0 +1,4 @@ +#!/bin/sh +. "$(dirname "$0")/_/husky.sh" + +npm run lerna-lint diff --git a/.husky/pre-push b/.husky/pre-push new file mode 100755 index 0000000000..d1096ab18a --- /dev/null +++ b/.husky/pre-push @@ -0,0 +1,4 @@ +#!/bin/sh +. "$(dirname "$0")/_/husky.sh" + +npm run test diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d16b0b50b5..978272ecef 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -28,6 +28,7 @@ Contributions via pull requests are much appreciated. Before sending us a pull r 1. You are working against the latest source on the **main** branch. 2. You check existing open, and recently merged pull requests to make sure someone else hasn't addressed the problem already. 3. You open an [RFC issue](https://github.com/awslabs/aws-lambda-powertools-typescript/issues/new?assignees=&labels=RFC%2C+triage&template=rfc.md&title=RFC%3A+) to discuss any significant work - we would hate for your time to be wasted. +4. You lint and test the code. When you've setup the repository with `npm run init-environment`, pre-commit and push-hooks will automatically lint and test the code. Pull request builds will run the same checks as well. ### Dev setup @@ -35,16 +36,16 @@ To send us a pull request, please follow these steps: 1. Fork the repository. 2. Install dependencies: `npm install` -3. Create a new branch to focus on the specific change you are contributing e.g. `git checkout -b improv/logger-debug-sampling` -4. Run all tests, and code baseline checks: `npm run test` -5. Commit to your fork using clear commit messages. -6. Send us a pull request with a [conventional semantic title](https://github.com/awslabs/aws-lambda-powertools-typescript/pull/67), and answering any default questions in the pull request interface. -7. Pay attention to any automated CI failures reported in the pull request, and stay involved in the conversation. - -GitHub provides additional document on [forking a repository](https://help.github.com/articles/fork-a-repo/) and +3. Prepare utilities like commit hooks: `npm run init-environment` +4. Create a new branch to focus on the specific change you are contributing e.g. `git checkout -b improv/logger-debug-sampling` +5. Run all tests, and code baseline checks: `npm run test` +6. Commit to your fork using clear commit messages. +7. Send us a pull request with a [conventional semantic title](https://github.com/awslabs/aws-lambda-powertools-typescript/blob/main/.github/semantic.yml), and answering any default questions in the pull request interface. [Here's an example](https://github.com/awslabs/aws-lambda-powertools-python/pull/67). +8. Pay attention to any automated CI failures reported in the pull request, and stay involved in the conversation. + +GitHub provides an additional document on [forking a repository](https://help.github.com/articles/fork-a-repo/) and [creating a pull request](https://help.github.com/articles/creating-a-pull-request/). - ### Conventions Category | Convention diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json index 408d22eb5f..e907111bb1 100644 --- a/npm-shrinkwrap.json +++ b/npm-shrinkwrap.json @@ -18,6 +18,7 @@ "@typescript-eslint/eslint-plugin": "^4.11.1", "@typescript-eslint/parser": "^4.11.1", "eslint": "^7.16.0", + "husky": "^7.0.1", "jest": "^27.0.4", "lerna": "^4.0.0", "ts-jest": "^27.0.3", @@ -1702,7 +1703,7 @@ "cosmiconfig": "^7.0.0", "dedent": "^0.7.0", "dot-prop": "^6.0.1", - "glob-parent": "^5.1.2", + "glob-parent": "^5.1.1", "globby": "^11.0.2", "load-json-file": "^6.2.0", "npmlog": "^4.1.2", @@ -4640,7 +4641,7 @@ "dependencies": { "@nodelib/fs.stat": "^2.0.2", "@nodelib/fs.walk": "^1.2.3", - "glob-parent": "^5.1.2", + "glob-parent": "^5.1.0", "merge2": "^1.3.0", "micromatch": "^4.0.2", "picomatch": "^2.2.1" @@ -5069,7 +5070,7 @@ "object-assign": "^4.0.1", "read-pkg-up": "^1.0.1", "redent": "^1.0.0", - "trim-newlines": "^3.0.1" + "trim-newlines": "^1.0.0" }, "engines": { "node": ">=0.10.0" @@ -5658,6 +5659,21 @@ "ms": "^2.0.0" } }, + "node_modules/husky": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/husky/-/husky-7.0.1.tgz", + "integrity": "sha512-gceRaITVZ+cJH9sNHqx5tFwbzlLCVxtVZcusME8JYQ8Edy5mpGDOqD8QBCdMhpyo9a+JXddnujQ4rpY2Ff9SJA==", + "dev": true, + "bin": { + "husky": "lib/bin.js" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/typicode" + } + }, "node_modules/iconv-lite": { "version": "0.4.24", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", @@ -7741,7 +7757,7 @@ "normalize-package-data": "^3.0.0", "read-pkg-up": "^7.0.1", "redent": "^3.0.0", - "trim-newlines": "^3.0.1", + "trim-newlines": "^3.0.0", "type-fest": "^0.18.0", "yargs-parser": "^20.2.3" }, @@ -10146,6 +10162,11 @@ "safer-buffer": "^2.0.2", "tweetnacl": "~0.14.0" }, + "bin": { + "sshpk-conv": "bin/sshpk-conv", + "sshpk-sign": "bin/sshpk-sign", + "sshpk-verify": "bin/sshpk-verify" + }, "engines": { "node": ">=0.10.0" } @@ -12707,7 +12728,7 @@ "cosmiconfig": "^7.0.0", "dedent": "^0.7.0", "dot-prop": "^6.0.1", - "glob-parent": "^5.1.2", + "glob-parent": "^5.1.1", "globby": "^11.0.2", "load-json-file": "^6.2.0", "npmlog": "^4.1.2", @@ -15046,7 +15067,7 @@ "requires": { "@nodelib/fs.stat": "^2.0.2", "@nodelib/fs.walk": "^1.2.3", - "glob-parent": "^5.1.2", + "glob-parent": "^5.1.0", "merge2": "^1.3.0", "micromatch": "^4.0.2", "picomatch": "^2.2.1" @@ -15388,7 +15409,7 @@ "object-assign": "^4.0.1", "read-pkg-up": "^1.0.1", "redent": "^1.0.0", - "trim-newlines": "^3.0.1" + "trim-newlines": "^1.0.0" } }, "normalize-package-data": { @@ -15837,6 +15858,12 @@ "ms": "^2.0.0" } }, + "husky": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/husky/-/husky-7.0.1.tgz", + "integrity": "sha512-gceRaITVZ+cJH9sNHqx5tFwbzlLCVxtVZcusME8JYQ8Edy5mpGDOqD8QBCdMhpyo9a+JXddnujQ4rpY2Ff9SJA==", + "dev": true + }, "iconv-lite": { "version": "0.4.24", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", @@ -17455,7 +17482,7 @@ "normalize-package-data": "^3.0.0", "read-pkg-up": "^7.0.1", "redent": "^3.0.0", - "trim-newlines": "^3.0.1", + "trim-newlines": "^3.0.0", "type-fest": "^0.18.0", "yargs-parser": "^20.2.3" }, diff --git a/package.json b/package.json index d73f58b6d2..80da5e749c 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,8 @@ "main": "lib/index.js", "types": "lib/", "scripts": { + "init-environment": "husky install", + "test": "npm run lerna-test", "commit": "commit", "lerna-ci": "lerna exec -- npm ci", "lerna-test": "lerna exec -- npm run test", @@ -39,6 +41,7 @@ "@typescript-eslint/eslint-plugin": "^4.11.1", "@typescript-eslint/parser": "^4.11.1", "eslint": "^7.16.0", + "husky": "^7.0.1", "jest": "^27.0.4", "lerna": "^4.0.0", "ts-jest": "^27.0.3",