@cemalidev/trate 1.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.env.example ADDED
@@ -0,0 +1,16 @@
1
+ # trate Environment Configuration
2
+
3
+ # API Configuration
4
+ TRATE_API_URL=https://trate-api.cemali.dev/v1
5
+
6
+ # Debug Mode (true/false)
7
+ TRATE_DEBUG=false
8
+
9
+ # Log Level (debug, info, warn, error)
10
+ TRATE_LOG_LEVEL=info
11
+
12
+ # Cache TTL in milliseconds (default: 300000 = 5 minutes)
13
+ TRATE_CACHE_TTL=300000
14
+
15
+ # API Timeout in milliseconds (default: 8000)
16
+ TRATE_API_TIMEOUT=8000
@@ -0,0 +1,61 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main, develop]
6
+ pull_request:
7
+ branches: [main, develop]
8
+
9
+ jobs:
10
+ lint-and-test:
11
+ name: Lint, Typecheck and Test
12
+ runs-on: ubuntu-latest
13
+
14
+ strategy:
15
+ matrix:
16
+ node-version: [20.x, 22.x]
17
+
18
+ steps:
19
+ - name: Checkout
20
+ uses: actions/checkout@v4
21
+
22
+ - name: Setup Node.js ${{ matrix.node-version }}
23
+ uses: actions/setup-node@v4
24
+ with:
25
+ node-version: ${{ matrix.node-version }}
26
+ cache: 'npm'
27
+
28
+ - name: Install dependencies
29
+ run: npm ci
30
+
31
+ - name: Run ESLint
32
+ run: npm run lint
33
+
34
+ - name: Run TypeScript typecheck
35
+ run: npm run typecheck
36
+
37
+ - name: Run tests
38
+ run: npm test -- --run
39
+
40
+ - name: Run build
41
+ run: npm run build
42
+
43
+ coverage:
44
+ name: Coverage
45
+ runs-on: ubuntu-latest
46
+
47
+ steps:
48
+ - name: Checkout
49
+ uses: actions/checkout@v4
50
+
51
+ - name: Setup Node.js
52
+ uses: actions/setup-node@v4
53
+ with:
54
+ node-version: 20.x
55
+ cache: 'npm'
56
+
57
+ - name: Install dependencies
58
+ run: npm ci
59
+
60
+ - name: Run tests with coverage
61
+ run: npm run test:coverage
@@ -0,0 +1,36 @@
1
+ name: Cleanup Old Versions
2
+
3
+ on:
4
+ workflow_dispatch:
5
+
6
+ jobs:
7
+ deprecate:
8
+ name: Deprecate old versions
9
+ runs-on: ubuntu-latest
10
+
11
+ steps:
12
+ - name: Deprecate old versions
13
+ run: |
14
+ curl -X PUT \
15
+ -H "Authorization: Bearer ${{ secrets.NPM_TOKEN }}" \
16
+ -H "Content-Type: application/json" \
17
+ -d '{"deprecated": "Please use v1.4.0 or later"}' \
18
+ "https://registry.npmjs.org/@cemalidev/trate/1.0.0"
19
+
20
+ curl -X PUT \
21
+ -H "Authorization: Bearer ${{ secrets.NPM_TOKEN }}" \
22
+ -H "Content-Type: application/json" \
23
+ -d '{"deprecated": "Please use v1.4.0 or later"}' \
24
+ "https://registry.npmjs.org/@cemalidev/trate/1.0.1"
25
+
26
+ curl -X PUT \
27
+ -H "Authorization: Bearer ${{ secrets.NPM_TOKEN }}" \
28
+ -H "Content-Type: application/json" \
29
+ -d '{"deprecated": "Please use v1.4.0 or later"}' \
30
+ "https://registry.npmjs.org/@cemalidev/trate/1.0.2"
31
+
32
+ curl -X PUT \
33
+ -H "Authorization: Bearer ${{ secrets.NPM_TOKEN }}" \
34
+ -H "Content-Type: application/json" \
35
+ -d '{"deprecated": "Please use v1.4.0 or later"}' \
36
+ "https://registry.npmjs.org/@cemalidev/trate/1.0.3"
@@ -0,0 +1,56 @@
1
+ name: Release
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - 'v*'
7
+
8
+ permissions:
9
+ contents: write
10
+
11
+ jobs:
12
+ release:
13
+ name: Release
14
+ runs-on: ubuntu-latest
15
+
16
+ steps:
17
+ - name: Checkout
18
+ uses: actions/checkout@v4
19
+ with:
20
+ fetch-depth: 0
21
+
22
+ - name: Setup Node.js
23
+ uses: actions/setup-node@v4
24
+ with:
25
+ node-version: 20.x
26
+ cache: 'npm'
27
+ registry-url: 'https://registry.npmjs.org'
28
+ scope: '@cemalidev'
29
+
30
+ - name: Set tag version in package.json
31
+ run: |
32
+ TAG_VERSION=${GITHUB_REF#refs/tags/v}
33
+ sed -i "s/\"version\": \".*\"/\"version\": \"$TAG_VERSION\"/" package.json
34
+
35
+ - name: Install dependencies
36
+ run: npm ci
37
+
38
+ - name: Run tests
39
+ run: npm test -- --run
40
+
41
+ - name: Build
42
+ run: npm run build
43
+
44
+ - name: Publish to npm
45
+ run: npm publish --access public
46
+ env:
47
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
48
+
49
+ - name: Create GitHub Release
50
+ run: |
51
+ gh release create ${{ github.ref_name }} \
52
+ --title "Release ${{ github.ref_name }}" \
53
+ --notes "See CHANGELOG.md for details" \
54
+ dist/**
55
+ env:
56
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env sh
2
+ . "$(dirname -- "$0")/_/husky.sh"
3
+
4
+ npx lint-staged
package/.prettierrc ADDED
@@ -0,0 +1,10 @@
1
+ {
2
+ "semi": true,
3
+ "trailingComma": "es5",
4
+ "singleQuote": true,
5
+ "printWidth": 100,
6
+ "tabWidth": 2,
7
+ "useTabs": false,
8
+ "arrowParens": "avoid",
9
+ "endOfLine": "lf"
10
+ }
package/CHANGELOG.md ADDED
@@ -0,0 +1,40 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [Unreleased]
9
+
10
+ ### Added
11
+ - Multi-language support (English, Turkish, German, French, Spanish)
12
+ - System language auto-detection
13
+ - `set-lang` command for manual language selection
14
+ - Graceful shutdown handling (SIGINT/SIGTERM)
15
+ - Error handling with `TrateError` class
16
+ - Logging utility with levels (debug, info, warn, error)
17
+ - Vitest testing framework with 44 tests
18
+ - ESLint and Prettier configuration
19
+ - GitHub Actions CI/CD workflows
20
+ - Test coverage reporting
21
+
22
+ ### Changed
23
+ - Refactored all hardcoded strings to use i18n system
24
+ - Updated config system to support locale preference
25
+ - Improved TypeScript strict mode compliance
26
+
27
+ ### Fixed
28
+ - Removed unused React configuration from tsconfig.json
29
+ - Added missing `@types/figlet` dev dependency
30
+ - Fixed in-memory cache type safety
31
+
32
+ ## [0.1.0] - Initial Release
33
+
34
+ ### Added
35
+ - Basic currency conversion (fiat, crypto, metals, Turkish gold)
36
+ - Favorites dashboard
37
+ - Configuration persistence with `conf` package
38
+ - Multiple API fallbacks
39
+ - ASCII art logo
40
+ - 5-minute API cache
@@ -0,0 +1,120 @@
1
+ # Contributing to trate
2
+
3
+ Thank you for your interest in contributing to trate!
4
+
5
+ ## Development Setup
6
+
7
+ 1. Fork the repository
8
+ 2. Clone your fork:
9
+ ```bash
10
+ git clone https://github.com/YOUR_USERNAME/trate.git
11
+ cd trate
12
+ ```
13
+ 3. Install dependencies:
14
+ ```bash
15
+ npm install
16
+ ```
17
+ 4. Create a branch for your changes:
18
+ ```bash
19
+ git checkout -b feature/my-new-feature
20
+ ```
21
+
22
+ ## Development Workflow
23
+
24
+ ### Code Style
25
+
26
+ We use ESLint and Prettier for code formatting:
27
+
28
+ ```bash
29
+ # Check lint
30
+ npm run lint
31
+
32
+ # Auto-fix lint issues
33
+ npm run lint:fix
34
+
35
+ # Format with Prettier
36
+ npx prettier --write src tests
37
+ ```
38
+
39
+ ### Testing
40
+
41
+ All new features should include tests:
42
+
43
+ ```bash
44
+ # Run tests
45
+ npm test
46
+
47
+ # Run tests in watch mode
48
+ npm run test:watch
49
+
50
+ # Run tests with coverage
51
+ npm run test:coverage
52
+ ```
53
+
54
+ ### Type Safety
55
+
56
+ We use TypeScript with strict mode:
57
+
58
+ ```bash
59
+ npm run typecheck
60
+ ```
61
+
62
+ ### Building
63
+
64
+ ```bash
65
+ npm run build
66
+ ```
67
+
68
+ ## Commit Messages
69
+
70
+ We follow [Conventional Commits](https://www.conventionalcommits.org/):
71
+
72
+ - `feat:` New feature
73
+ - `fix:` Bug fix
74
+ - `docs:` Documentation changes
75
+ - `style:` Code style changes (formatting, etc.)
76
+ - `refactor:` Code refactoring
77
+ - `test:` Adding or updating tests
78
+ - `chore:` Build process or auxiliary tool changes
79
+
80
+ Example:
81
+ ```
82
+ feat: add Spanish translation
83
+ fix: handle network timeout gracefully
84
+ docs: update README with new commands
85
+ ```
86
+
87
+ ## Pull Request Process
88
+
89
+ 1. Update the README.md if you add new features
90
+ 2. Update CHANGELOG.md under "Unreleased"
91
+ 3. Ensure all tests pass
92
+ 4. Ensure lint passes
93
+ 5. Update the version in package.json if applicable
94
+ 6. The PR will be reviewed and merged
95
+
96
+ ## Adding Translations
97
+
98
+ To add a new language:
99
+
100
+ 1. Create a new file in `src/i18n/` (e.g., `pt.ts`)
101
+ 2. Copy the structure from `en.ts`
102
+ 3. Translate all strings
103
+ 4. Update `src/i18n/index.ts`:
104
+ - Add to imports
105
+ - Add to `translations` object
106
+ - Add to `supportedLocales` array
107
+ 5. Add tests for the new language
108
+
109
+ ## Reporting Issues
110
+
111
+ Please include:
112
+ - Node.js version
113
+ - Operating system
114
+ - Steps to reproduce
115
+ - Expected vs actual behavior
116
+ - Error messages if applicable
117
+
118
+ ## License
119
+
120
+ By contributing, you agree that your contributions will be licensed under the MIT License.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Trate
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,140 @@
1
+ # Trate
2
+
3
+ > Terminal-based currency tracker - convert fiat, crypto, and precious metals instantly.
4
+
5
+ [![CI](https://github.com/cemalidev/trate/actions/workflows/ci.yml/badge.svg)](https://github.com/cemalidev/trate/actions)
6
+ [![npm version](https://img.shields.io/npm/v/trate.svg)](https://www.npmjs.com/package/trate)
7
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
8
+ [![Node.js Version](https://img.shields.io/badge/node-%3E%3D18.0.0-brightgreen)](https://nodejs.org/)
9
+
10
+ ## Features
11
+
12
+ - **Multi-currency support**: Fiat, cryptocurrency, and precious metals
13
+ - **Real-time rates**: Live exchange rates from multiple APIs
14
+ - **Favorites dashboard**: Track your favorite currencies
15
+ - **Multi-language**: English, Turkish, German, French, Spanish
16
+ - **Fast & lightweight**: Built with TypeScript and esbuild
17
+
18
+ ## Quick Start
19
+
20
+ ### Install
21
+
22
+ ```bash
23
+ npm install -g @cemalidev/trate
24
+ ```
25
+
26
+ ### Usage
27
+
28
+ ```bash
29
+ # Convert currency
30
+ trate 100 usd try
31
+
32
+ # Quick rate lookup
33
+ trate btc
34
+
35
+ # List favorites
36
+ trate list
37
+ ```
38
+
39
+ ## Supported Currencies
40
+
41
+ | Type | Examples |
42
+ | ---------------- | ----------------------------------------------------------------------------------- |
43
+ | **Fiat** | USD, EUR, GBP, JPY, CHF, CAD, AUD, NZD, CNY, HKD, SGD, INR, RUB, TRY, BRL, ZAR, MXN |
44
+ | **Crypto** | BTC, ETH, SOL, BNB, XRP, ADA, DOGE, DOT, AVAX, MATIC, LINK, UNI, LTC, ATOM |
45
+ | **Metals** | ONS (Gold), GRAM_ALTIN (Gram Gold), GUMUS_OZ (Silver) |
46
+ | **Turkish Gold** | CEYREK_ALTIN, YARIM_ALTIN, TAM_ALTIN, ATA_ALTIN |
47
+
48
+ ## Commands
49
+
50
+ | Command | Description |
51
+ | ---------------------------- | ------------------------------------ |
52
+ | `trate <amount> <from> <to>` | Convert currency |
53
+ | `trate <currency>` | Quick rate lookup |
54
+ | `trate set-base <currency>` | Set base currency |
55
+ | `trate add <currency>` | Add to favorites |
56
+ | `trate remove <currency>` | Remove from favorites |
57
+ | `trate list` | Show favorites dashboard |
58
+ | `trate set-lang <lang>` | Change language (tr, en, de, fr, es) |
59
+ | `trate refresh` | Clear cache |
60
+ | `trate help` | Show help |
61
+
62
+ ## Custom Aliases
63
+
64
+ Create shortcuts for currencies you use frequently:
65
+
66
+ ```bash
67
+ # Add alias
68
+ trate alias add ceyrek CEYREK_ALTIN
69
+ trate alias add gram ALTIN_KG
70
+ trate alias add gumus GUMUS_OZ
71
+
72
+ # Use alias in conversions
73
+ trate 100 usd ceyrek # 100 USD → CEYREK_ALTIN
74
+ trate ceyrek # Quick rate lookup
75
+
76
+ # List all aliases
77
+ trate alias list
78
+
79
+ # Remove alias
80
+ trate alias remove ceyrek
81
+ ```
82
+
83
+ | Command | Description |
84
+ | ------------------------------ | ---------------- |
85
+ | `trate alias list` | List all aliases |
86
+ | `trate alias add <alias> <to>` | Add alias |
87
+ | `trate alias remove <alias>` | Remove alias |
88
+
89
+ ## Installation from Source
90
+
91
+ ```bash
92
+ git clone https://github.com/cemalidev/trate.git
93
+ cd trate
94
+ npm install
95
+ npm run build
96
+ npm link
97
+ ```
98
+
99
+ ## Development
100
+
101
+ ```bash
102
+ # Install dependencies
103
+ npm install
104
+
105
+ # Build
106
+ npm run build
107
+
108
+ # Run tests
109
+ npm test
110
+
111
+ # Lint
112
+ npm run lint
113
+
114
+ # Type check
115
+ npm run typecheck
116
+ ```
117
+
118
+ ## Language Support
119
+
120
+ | Language | Code |
121
+ | -------- | ---- |
122
+ | Türkçe | `tr` |
123
+ | English | `en` |
124
+ | Deutsch | `de` |
125
+ | Français | `fr` |
126
+ | Español | `es` |
127
+
128
+ Change language with `trate set-lang <code>`
129
+
130
+ ## Architecture
131
+
132
+ See [ARCHITECTURE.md](docs/ARCHITECTURE.md) for technical details.
133
+
134
+ ## Contributing
135
+
136
+ Contributions are welcome! Please see [CONTRIBUTING.md](docs/CONTRIBUTING.md) for guidelines.
137
+
138
+ ## License
139
+
140
+ MIT License - see [LICENSE](LICENSE) for details.
package/build.cjs ADDED
@@ -0,0 +1,27 @@
1
+ const esbuild = require('esbuild');
2
+ const fs = require('fs');
3
+
4
+ async function build() {
5
+ await esbuild.build({
6
+ entryPoints: ['src/index.ts'],
7
+ bundle: true,
8
+ platform: 'node',
9
+ target: 'node18',
10
+ outfile: 'dist/index.js',
11
+ external: ['commander', 'conf', 'node-fetch', 'figlet', 'inquirer'],
12
+ format: 'esm',
13
+ sourcemap: false,
14
+ minify: false,
15
+ banner: {
16
+ js: '#!/usr/bin/env node',
17
+ },
18
+ });
19
+
20
+ fs.chmodSync('dist/index.js', '755');
21
+ console.log('Build complete!');
22
+ }
23
+
24
+ build().catch((err) => {
25
+ console.error(err);
26
+ process.exit(1);
27
+ });