1.1.0 • Published 3 years ago
pickly-posts-client v1.1.0
purpose
- this project to create npm library for pickly posts client. This client is generated using open api tools based off the openAPI defenitions for the posts api.
Build prerequisits
inialize project
- run
git init
- run
yarn init
in the root directory - In package.json:
- "name": "PACKAGE-NAME"
- "repository": { "type": "git", "url": "https://github.com/Sahl-A/posts_client" }
- "main": "lib/index.js"
- run
semantic-release
- Documentation: https://semantic-release.gitbook.io/semantic-release/v/beta/
- create github token: https://github.com/semantic-release/github
- Add the generated token as a secret in the github repo with name GH_TOKEN
- yarn add semantic-release-cli --dev
- in the root directory:
npx semantic-release-cli setup
and answer the questions and provide the github token and choose github actions as our CI - Once finished, it will add changes to package.json, e.g, add semantic release script, add it to dependencies, convert the repository url to https
- Add the CI configuration in release.yaml inside .github/workflows.
- make sure to add GH_TOKEN & NPM_TOKEN as environment variables. The NPM_TOKEN will be added to the repo secrets automatically when running the CI action
- make sure to enable the npm package to work with github CI: -- https://github.blog/changelog/2020-10-02-npm-automation-tokens/
- Add the following configuration in releaserc.yaml in project root directory:
branches: - main
commitizen
- Add commitizen locally:
yarn add commitizen --dev
- Initialize the conventional changelog adapter:
npx commitizen init cz-conventional-changelog --save-dev --save-exact
- The above command added cz-conventional-changelog package and added it to dependencies and added its configuration to package.json
- For the sake of consistency, remove the config of commitizen added by the above command from package.json and add the following in .czrc:
{ "path": "cz-conventional-changelog" }
- The command
npx commitizen init cz-conventional-changelog --save-dev --save-exact
ran using npm and added package-lock.json. Since we work with yarn, we will runyarn
to update the yarn.lock file, then remove package-lock.json - add
"commit": "cz"
in scripts in package.json - run
yarn commit
, it will open a dialoge to fullfill. - Read more about the commit conventions:
- Add commitizen locally:
Buisness logic prerequisits
openAPI definitions file
- add post.openApi.yml file in the root directory
openapi-generator-cli
- if not installed:
sudo yarn global add @openapitools/openapi-generator-cli
- after installation run the following in root path:
openapi-generator-cli generate -g typescript-axios -i OPENAPI_FILE.yaml -o lib/
- if not installed:
axios
yarn add axios
typescript
- if typescript is not installed:
yarn global add typescript
- in project root directory
tsc --init
- In the created tsconfig.json uncomment the following keys:
- moduleResolution: "node"
- declaration: true
- sourceMap: true
- target: "ESNext"
- in project root directory
tsc --build
- in package.json add "main": "lib/index.js"
- if typescript is not installed: