Skip to content

Commit

Permalink
fix: πŸ› husky hooks for release
Browse files Browse the repository at this point in the history
βœ… Closes: REALT-3804
  • Loading branch information
Pavel Bely authored and Drapegnik committed Dec 22, 2021
1 parent d0380be commit b99be90
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,5 @@ yarn-error.log*

# build
dist

.npmrc
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
.PHONY:
install:
npm i
npm ci --also=dev
husky install
npm run npmrc:public

# prettier + eslint + tsc
.PHONY:
Expand All @@ -15,6 +17,7 @@ dist:

cp package.json dist
cp README.md dist
cp .npmrc dist
cp -r src/* dist
cp -r patches dist
cp -r .husky dist
Expand Down
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,30 @@ make release # to push new version & generate changelog
make prerelease # only push new version to npm, for testing
```

## How to test publish

In order to locally test the current package with
the project infrastructure, you can use
npm proxy register [Verdaccio](https://verdaccio.org/)

Locally, the easiest way to run it through Docker is to run
the following command:
```bash
$ docker run -it --rm --name verdaccio -p 4873:4873 verdaccio/verdaccio
```

To check that everything is working,
go to the web ui url in browser:
http://localhost:4873

In order to publish and pull the package from the Proxy repository,
you need to add the following code to `.npmrc`
```text
registry=http://localhost:4873
```
Now you can safely pull and publish to the local npm register!


## [EditorConfig](https://editorconfig.org)

Create configuration file `.editorconfig` at the root of the project. Insert the following content:
Expand Down
9 changes: 9 additions & 0 deletions bin/create-npmrc.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash

NPM_REGISTER="https://registry.npmjs.org"

if [[ $LOCAL == "true" ]];then
NPM_REGISTER="http://0.0.0.0:4873/"
fi;

echo "registry=$NPM_REGISTER" > $PWD/.npmrc
3 changes: 3 additions & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
extends: ['@commitlint/config-conventional'],
};
3 changes: 3 additions & 0 deletions lint-staged.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
'*.@(js|ts|tsx)': ['prettier --write', 'eslint --fix'],
};
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@
},
"scripts": {
"postinstall": "bash bin/copy-husky.sh",
"release": "release-it",
"pre-release": "release-it --no-git",
"release": "HUSKY=0 release-it",
"pre-release": "HUSKY=0 release-it --no-git",
"format": "prettier --write .",
"npmrc:local": "LOCAL=true bash bin/create-npmrc.sh",
"npmrc:public": "bash bin/create-npmrc.sh",
"lint": "eslint . --ext .ts,.tsx,.js,.jsx,.json --fix --cache"
},
"dependencies": {
Expand Down

0 comments on commit b99be90

Please sign in to comment.