From e2a2dcef9a32c037e56b6b767c35e42bc0f7fe64 Mon Sep 17 00:00:00 2001 From: jeffgreiner-eaton Date: Thu, 26 Sep 2024 12:50:53 -0400 Subject: [PATCH 1/2] Add husky pre-commit hook --- .husky/pre-commit | 1 + components/jest.config.js | 5 ++ package.json | 101 ++++++++++++++++++++------------------ yarn.lock | 5 ++ 4 files changed, 63 insertions(+), 49 deletions(-) create mode 100644 .husky/pre-commit diff --git a/.husky/pre-commit b/.husky/pre-commit new file mode 100644 index 000000000..03ddd2cba --- /dev/null +++ b/.husky/pre-commit @@ -0,0 +1 @@ +cd ./components && yarn prettier:check && yarn lint && yarn coverage & cd .. diff --git a/components/jest.config.js b/components/jest.config.js index 1fa55a268..845f8aff0 100644 --- a/components/jest.config.js +++ b/components/jest.config.js @@ -9,6 +9,11 @@ module.exports = { '^.+\\.tsx?$': 'ts-jest', }, collectCoverage: true, + coverageThreshold: { + "global": { + "lines": 75 + } + }, coverageReporters: ['text', 'cobertura'], transformIgnorePatterns: [ 'node_modules/(?!(react-native|@react-native/*|react-native-vector-icons|react-native-animatable|react-native-reanimated|react-native-iphone-x-helper|react-native-modal|react-native-collapsible|@react-native/polyfills)/)', diff --git a/package.json b/package.json index 084e87130..22f31c141 100644 --- a/package.json +++ b/package.json @@ -1,51 +1,54 @@ { - "name": "react-native-components", - "version": "0.0.0", - "scripts": { - "initialize": "bash scripts/initializeSubmodule.sh", - "build": "bash ./scripts/buildComponents.sh", - "install:showcase-ios": "yarn initialize && cd demos/showcase && yarn && cd ios && pod install && cd ../../.. && yarn link:components", - "install:showcase-android": "yarn initialize && cd demos/showcase && yarn && cd ../.. && yarn link:components", - "install:storybook-ios": "cd demos/storybook && yarn && cd ios && pod install && cd ../../.. && yarn link:components", - "install:storybook-android": "cd demos/storybook && yarn && cd ../.. && yarn link:components", - "install:storybook-api": "cd demos/api && yarn && cd ../.. && yarn link:components", - "install:all": "yarn && cd components && yarn install && cd .. && yarn install:showcase-ios && yarn install:storybook-ios && yarn install:storybook-api", - "install:all-android": "cd components && yarn install && cd .. && yarn install:showcase-android && yarn install:storybook-android && yarn install:storybook-api", - "link:components": "bash ./scripts/linkComponents.sh", - "publish:package": "cd dist && rm -f *.tgz && set npm_config_yes=true && npx -p @brightlayer-ui/publish blui-publish", - "tag:package": "cd dist && set npm_config_yes=true && npx -p @brightlayer-ui/tag blui-tag -s -blui-react-native-component-library", - "start": "yarn start:showcase", - "start:showcase": "yarn start:showcase-ios", - "start:showcase-ios": "yarn install:showcase-ios && cd demos/showcase && yarn ios", - "start:showcase-android": "yarn install:showcase-android && cd demos/showcase && yarn android", - "start:storybook": "yarn start:storybook-ios", - "start:storybook-ios": "yarn install:storybook-ios && cd demos/storybook && yarn ios", - "start:storybook-android": "yarn install:storybook-android && cd demos/storybook && yarn android", - "start:storybook-api": "yarn install:storybook-api && cd demos/api && yarn start", - "test": "cd components && yarn test", - "test:watch": "cd components && yarn test:watch", - "test:artifacts": "echo \"TODO: TEST ARTIFACTS\"", - "prettier": "prettier \"docs/**.{ts,tsx,js,jsx,json,css,scss,md,html}\" --write && cd components && yarn prettier && cd ../demos/api && yarn prettier && cd ../storybook && yarn prettier", - "prettier:check": "prettier \"docs/**.{ts,tsx,js,jsx,json,css,scss,md,html}\" --check && cd components && yarn prettier:check && cd ../demos/api && yarn prettier:check && cd ../storybook && yarn prettier:check", - "lint": "cd components && yarn lint && cd ../demos/api && yarn lint && cd ../storybook && yarn lint", - "lint:fix": "cd components && yarn lint:fix && cd ../demos/api && yarn lint:fix && cd ../storybook && yarn lint:fix", - "update:submodule": "git submodule update --remote", - "precommit": "yarn install:all && yarn prettier && yarn lint && yarn test && yarn build && yarn test:artifacts && yarn generate:licenses", - "coverage": "cd components && yarn test --coverage --watchAll=false", - "generate:licenses": "cd ./components && npm-license-crawler -onlyDirectDependencies -json LICENSES.json" - }, - "directories": { - "doc": "docs" - }, - "prettier": "@brightlayer-ui/prettier-config", - "devDependencies": { - "@brightlayer-ui/prettier-config": "^1.0.3", - "eslint-plugin-react-hooks": "^4.6.2", - "npm-license-crawler": "^0.2.1", - "prettier": "^3.3.3" - }, - "jest": { - "coverageDirectory": "./components/coverage/", - "collectCoverage": true - } + "name": "react-native-components", + "version": "0.0.0", + "scripts": { + "initialize": "bash scripts/initializeSubmodule.sh", + "build": "bash ./scripts/buildComponents.sh", + "install:showcase-ios": "yarn initialize && cd demos/showcase && yarn && cd ios && pod install && cd ../../.. && yarn link:components", + "install:showcase-android": "yarn initialize && cd demos/showcase && yarn && cd ../.. && yarn link:components", + "install:storybook-ios": "cd demos/storybook && yarn && cd ios && pod install && cd ../../.. && yarn link:components", + "install:storybook-android": "cd demos/storybook && yarn && cd ../.. && yarn link:components", + "install:storybook-api": "cd demos/api && yarn && cd ../.. && yarn link:components", + "install:all": "yarn && cd components && yarn install && cd .. && yarn install:showcase-ios && yarn install:storybook-ios && yarn install:storybook-api", + "install:components": "yarn && cd components && yarn", + "install:all-android": "cd components && yarn install && cd .. && yarn install:showcase-android && yarn install:storybook-android && yarn install:storybook-api", + "link:components": "bash ./scripts/linkComponents.sh", + "publish:package": "cd dist && rm -f *.tgz && set npm_config_yes=true && npx -p @brightlayer-ui/publish blui-publish", + "tag:package": "cd dist && set npm_config_yes=true && npx -p @brightlayer-ui/tag blui-tag -s -blui-react-native-component-library", + "start": "yarn start:showcase", + "start:showcase": "yarn start:showcase-ios", + "start:showcase-ios": "yarn install:showcase-ios && cd demos/showcase && yarn ios", + "start:showcase-android": "yarn install:showcase-android && cd demos/showcase && yarn android", + "start:storybook": "yarn start:storybook-ios", + "start:storybook-ios": "yarn install:storybook-ios && cd demos/storybook && yarn ios", + "start:storybook-android": "yarn install:storybook-android && cd demos/storybook && yarn android", + "start:storybook-api": "yarn install:storybook-api && cd demos/api && yarn start", + "test": "cd components && yarn test", + "test:watch": "cd components && yarn test:watch", + "test:artifacts": "echo \"TODO: TEST ARTIFACTS\"", + "prettier": "prettier \"docs/**.{ts,tsx,js,jsx,json,css,scss,md,html}\" --write && cd components && yarn prettier", + "prettier:check": "prettier \"docs/**.{ts,tsx,js,jsx,json,css,scss,md,html}\" --check && cd components && yarn prettier:check", + "lint": "cd components && yarn lint", + "lint:fix": "cd components && yarn lint:fix", + "update:submodule": "git submodule update --remote", + "precommit": "yarn install:all && yarn prettier && yarn lint && yarn test && yarn build && yarn test:artifacts && yarn generate:licenses", + "coverage": "cd components && yarn test --coverage --watchAll=false", + "generate:licenses": "cd ./components && npm-license-crawler -onlyDirectDependencies -json LICENSES.json", + "prepare": "husky" + }, + "directories": { + "doc": "docs" + }, + "prettier": "@brightlayer-ui/prettier-config", + "devDependencies": { + "@brightlayer-ui/prettier-config": "^1.0.3", + "eslint-plugin-react-hooks": "^4.6.2", + "husky": "^9.1.6", + "npm-license-crawler": "^0.2.1", + "prettier": "^3.3.3" + }, + "jest": { + "coverageDirectory": "./components/coverage/", + "collectCoverage": true + } } diff --git a/yarn.lock b/yarn.lock index c88660e6a..b5259de27 100644 --- a/yarn.lock +++ b/yarn.lock @@ -159,6 +159,11 @@ has-flag@^3.0.0: resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-3.0.0.tgz#b5d454dc2199ae225699f3467e5a07f3b955bafd" integrity sha1-tdRU3CGZriJWmfNGfloH87lVuv0= +husky@^9.1.6: + version "9.1.6" + resolved "https://registry.yarnpkg.com/husky/-/husky-9.1.6.tgz#e23aa996b6203ab33534bdc82306b0cf2cb07d6c" + integrity sha512-sqbjZKK7kf44hfdE94EoX8MZNk0n7HeW37O4YrVGCF4wzgQjp+akPAkfUK5LZ6KuR/6sqeAVuXHji+RzQgOn5A== + inflight@^1.0.4: version "1.0.6" resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9" From 2799da7872edb120bb87a5496e49a87038ce39ca Mon Sep 17 00:00:00 2001 From: jeffgreiner-eaton Date: Thu, 26 Sep 2024 13:12:55 -0400 Subject: [PATCH 2/2] test with yarn --- .husky/pre-commit | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.husky/pre-commit b/.husky/pre-commit index 03ddd2cba..236e790bf 100644 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -1 +1 @@ -cd ./components && yarn prettier:check && yarn lint && yarn coverage & cd .. +cd ./components && yarn && yarn prettier:check && yarn lint && yarn coverage & cd ..