@score-engine/cli
v1.0.0
Published
A CLI application to calculate the credit score based on the user's age, city, and monthly income.
Readme
Score Engine CLI
A CLI application to calculate the credit score based on the user's age, city, and monthly income.
Table of Contents
Requirements
- An OpenWeatherMap API key. Check the API documentation for more information.
Usage
# pnpm (recommended)
env OPENWEATHER_API_KEY=<api-key> \
pnpm dlx @score-engine/cli [--ajuda,-a|--idade <idade> --cidade <cidade> --renda-mensal <renda-mensal>]
# npm
env OPENWEATHER_API_KEY=<api-key> \
npx @score-engine/cli [--ajuda,-a|--idade <idade> --cidade <cidade> --renda-mensal <renda-mensal>]
# yarn
env OPENWEATHER_API_KEY=<api-key> \
yarn dlx @score-engine/cli [--ajuda,-a|--idade <idade> --cidade <cidade> --renda-mensal <renda-mensal>]Example
# Linux or WSL
env OPENWEATHER_API_KEY=<api-key> \
pnpm dlx @score-engine/cli --idade 20 --cidade São Paulo --renda-mensal 1000Local Usage
- Install Docker
- Build the image
docker build -t score-engine-cli:latest . - Create a
.envfile with your OpenWeatherMap API keycp .env.example .env - Run the image
docker run --env-file .env score-engine-cli:latest [--ajuda,-a|--idade <idade> --cidade <cidade> --renda-mensal <renda-mensal>]
Install Node.js >=v20 (LTS Iron) or above
# using nvm nvm install lts/ironInstall pnpm >=v9
corepack enable pnpmInstall dependencies
pnpm installRun the CLI
pnpm tsx src/index.ts [--ajuda,-a|--idade <idade> --cidade <cidade> --renda-mensal <renda-mensal>](Optional) Run the CLI with the build output
pnpm build && \ node ./dist/index.js [--ajuda,-a|--idade <idade> --cidade <cidade> --renda-mensal <renda-mensal>]
Testing
Tests are written using Vitest.
pnpm test
# or with Docker
docker run --entrypoint 'pnpm test' score-engine-cli:latestTo run the tests in watch mode, use the following command:
pnpm test:watch
# or with Docker
docker run --entrypoint 'pnpm test:watch' score-engine-cli:latestTo generate a coverage report, use the following command:
pnpm test:coverage
# or with Docker
docker run --entrypoint 'pnpm test:coverage' score-engine-cli:latestAvailable package commands
| Command | Description |
| --------------- | ----------------------------------------------- |
| build | Builds the CLI. |
| lint | Runs the linter (ESLint). |
| lint:fix | Runs the linter (ESLint) and fixes any issues. |
| prettify | Formats the files using Prettier. |
| test | Runs the tests. |
| test:coverage | Runs the tests and generates a coverage report. |
| test:watch | Runs the tests in watch mode. |
Tools used
- Programming Language: JavaScript (with TypeScript) on Node.js
- Building: tsup
- Changelogs: Changesets
- Code Quality pipelines: husky, lint-staged
- Containerization: Docker
- Formatting: Prettier
- Linting: ESLint
- Testing: Vitest
- Utilities: lodash.get
- Validation: zod
