Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .eslintignore

This file was deleted.

10 changes: 0 additions & 10 deletions .eslintrc.json

This file was deleted.

6 changes: 3 additions & 3 deletions .github/workflows/canary-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ jobs:
env:
INPUT_TOKEN: ${{ secrets.NPM_TOKEN }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 16
node-version: 22
- run: yarn version --no-git-tag-version --prerelease --preid=canary-$(git rev-parse --short HEAD) --access=public
- run: yarn
- run: yarn build
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ jobs:
fail-fast: false
matrix:
node-version:
- 16
- 22
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- run: yarn install
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/stable-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ jobs:
env:
INPUT_TOKEN: ${{ secrets.NPM_TOKEN }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 16
node-version: 22
- run: yarn
- run: yarn build
- uses: JS-DevTools/npm-publish@v1
- uses: JS-DevTools/npm-publish@v3
with:
access: public
token: ${{ secrets.NPM_TOKEN }}
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ dist
node_modules
yarn-error.log
package-lock.json

*.csv
.vscode
3 changes: 0 additions & 3 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

yarn run precommit
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

### [2.0.1](https://github.com/zidious/crypto-cli/compare/v2.0.0...v2.0.1) (2025-03-28)

### Bug Fixes

- adjust price formatting to account for meme coins ([#71](https://github.com/zidious/crypto-cli/issues/71)) ([f96a58e](https://github.com/zidious/crypto-cli/commit/f96a58e7c95ea4920d62318fc0220350046d28b6))
- remove casing requirement ([#66](https://github.com/zidious/crypto-cli/issues/66)) ([ea4ddfc](https://github.com/zidious/crypto-cli/commit/ea4ddfcd8d543d19d4c5a66e41830134dd7a7695))

## [2.0.0](https://github.com/zidious/crypto-cli/compare/v1.2.0...v2.0.0) (2023-11-29)

### ⚠ BREAKING CHANGES
Expand Down
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,17 @@ $ crypto bitcoin

## Flags

| Name | Description |
| ------------------------ | ------------------------------------------- |
| `--price-change`, `--pc` | Coin price change (%) in the past 24 hours |
| `--volume`, `--v` | Coin volume in the past 24 hours |
| `--ath-change`, `--athc` | Percent price change from the all time high |
| `--high`, `--h` | Highest price sold in the past 24 hours |
| `--low`, `--l` | Lowest price sold in the past 24 hours |
| `--ath` | Coin all time high price |
| `--save json,csv` | Save coin data via JSON and/or CSV |
| `--help` | Flag description and usage examples |
| `--version` | Current version |
| Name | Description |
| ----------------------- | ------------------------------------------- |
| `--price-change`, `-pc` | Coin price change (%) in the past 24 hours |
| `--volume`, `-v` | Coin volume in the past 24 hours |
| `--ath-change`, `-athc` | Percent price change from the all time high |
| `--high`, `-h` | Highest price sold in the past 24 hours |
| `--low`, `-l` | Lowest price sold in the past 24 hours |
| `--ath` | Coin all time high price |
| `--save json,csv` | Save coin data via JSON and/or CSV |
| `--help` | Flag description and usage examples |
| `--version` | Current version |

## Local Development

Expand Down
31 changes: 31 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { defineConfig, globalIgnores } from "eslint/config";
import typescriptEslint from "@typescript-eslint/eslint-plugin";
import tsParser from "@typescript-eslint/parser";
import path from "node:path";
import { fileURLToPath } from "node:url";
import js from "@eslint/js";
import { FlatCompat } from "@eslint/eslintrc";

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all
});

export default defineConfig([globalIgnores(["**/dist/", "**/coverage/", "**/node_modules/"]), {
extends: compat.extends(
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
),

plugins: {
"@typescript-eslint": typescriptEslint,
},

languageOptions: {
parser: tsParser,
},
}]);
45 changes: 23 additions & 22 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "coffee-crypto-cli",
"version": "2.0.0",
"version": "2.0.1",
"description": "Cryptocurrency CLI price tool",
"main": "dist/index.js",
"author": "Gabe Olesen",
Expand All @@ -20,36 +20,37 @@
"build": "tsc",
"test": "mocha 'src/*.test.ts'",
"lint": "eslint --fix",
"prepare": "husky install",
"prepare": "husky",
"precommit": "lint-staged"
},
"engines": {
"node": ">=14"
"node": ">=22"
},
"type": "module",
"dependencies": {
"@crypto-coffee/coingecko-api": "^1.2.0",
"chalk": "^5.3.0",
"json2csv": "^6.0.0-alpha.2",
"meow": "^11.0.0"
"@json2csv/node": "^7.0.6",
"chalk": "^5.4.1",
"meow": "^13.2.0"
},
"devDependencies": {
"@types/chai": "^4.3.4",
"@types/json2csv": "^5.0.3",
"@types/mocha": "^10.0.1",
"@types/node": "^20.6.0",
"@typescript-eslint/eslint-plugin": "^6.13.1",
"@typescript-eslint/parser": "^6.13.1",
"chai": "^4.3.8",
"eslint": "^8.49.0",
"execa": "^8.0.1",
"husky": "^8.0.3",
"lint-staged": "^14.0.1",
"mocha": "^10.2.0",
"prettier": "^3.0.3",
"rimraf": "^4.3.0",
"ts-node": "^10.9.1",
"typescript": "^5.2.2"
"@eslint/eslintrc": "^3.3.1",
"@eslint/js": "^9.23.0",
"@types/chai": "^5.2.1",
"@types/mocha": "^10.0.10",
"@types/node": "^22.13.14",
"@typescript-eslint/eslint-plugin": "^8.28.0",
"@typescript-eslint/parser": "^8.28.0",
"chai": "^5.2.0",
"eslint": "^9.23.0",
"execa": "^9.5.2",
"husky": "^9.1.7",
"lint-staged": "^15.5.0",
"mocha": "^11.1.0",
"prettier": "^3.5.3",
"rimraf": "^6.0.1",
"ts-node": "^10.9.2",
"typescript": "^5.8.2"
},
"lint-staged": {
"*.ts": [
Expand Down
6 changes: 3 additions & 3 deletions src/actions/saveCoinData.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import fs from 'fs'
import { parseAsync } from 'json2csv'
import { AsyncParser } from '@json2csv/node'
import { formatFileName, logError, logSuccess } from '../utils.js'
import { CSVEXT, JSONEXT } from '../constants.js'
import { CoinMarkets } from '@crypto-coffee/coingecko-api/dist/types.js'
Expand Down Expand Up @@ -67,9 +67,8 @@ const writeFile = async (
}

const formatCsvFile = async (coin: Partial<CoinMarkets>): Promise<string> => {
return await parseAsync(coin, {
const parser = new AsyncParser({
delimiter: ',',
excelStrings: false,
fields: [
{
label: 'Name',
Expand Down Expand Up @@ -105,4 +104,5 @@ const formatCsvFile = async (coin: Partial<CoinMarkets>): Promise<string> => {
}
]
})
return await parser.parse(coin).promise()
}
14 changes: 7 additions & 7 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,26 +39,26 @@ const cli = meow(
flags: {
priceChange: {
type: 'boolean',
alias: 'pc'
shortFlag: 'pc'
},
volume: {
type: 'boolean',
alias: 'v'
shortFlag: 'v'
},
high: {
type: 'boolean',
alias: 'h'
shortFlag: 'h'
},
low: {
type: 'boolean',
alias: 'l'
shortFlag: 'l'
},
ath: {
type: 'boolean'
},
athChange: {
type: 'boolean',
alias: 'athc'
shortFlag: 'athc'
},
save: {
type: 'string'
Expand All @@ -69,7 +69,7 @@ const cli = meow(

const app = async () => {
const { save } = cli.flags as Flags
const coinTickers = cli.input[0]
const coinTickers = cli.input[0].toLowerCase().trim()

if (!coinTickers) {
logError('No coin name provided. Check `crypto --help` for help')
Expand Down Expand Up @@ -103,6 +103,6 @@ app().catch(error => {
logError(
`An error occured: ${
(error as Error).message
}\n Please report the issue here: https://github.com/Zidious/crypto-cli`
}\n Please report the issue here: https://github.com/Zidious/crypto-cli/issues`
)
})
16 changes: 10 additions & 6 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@ import chalk from 'chalk'
const ERROR = chalk.bold.red
const SUCCESS = chalk.bold.green

const formatter = new Intl.NumberFormat('en-US', {
style: 'currency',
currency: 'USD'
})

export const logError = (message: string) => {
console.error(ERROR(message))
process.exit(1)
Expand All @@ -18,7 +13,16 @@ export const logSuccess = (message: string) => {
}

export const format = (price: number) => {
return formatter.format(price)
const decimalPart = price.toString().split('.')[1]
// If the decimal part starts with 000, it's likely a meme coin
// and we want to show more decimal places to avoid showing 0.00
const isMemeCoin = decimalPart && decimalPart.slice(0, 3) === '000'

return new Intl.NumberFormat('en-US', {
style: 'currency',
currency: 'USD',
maximumFractionDigits: isMemeCoin ? 10 : 2
}).format(price)
}

export const formatFileName = (coinName: string, fileExt: string): string => {
Expand Down
Loading
Loading