Skip to content

Commit 00ec34f

Browse files
committed
Initial implementation of fred-cli
TypeScript CLI + library wrapping all 31 FRED API v2 endpoints. Zero runtime dependencies, Node 18+, JSON/CSV/table output formats. Includes unit tests (mocked HTTP), integration tests (live API), and CI/CD workflows (test, npm publish, security audit).
0 parents  commit 00ec34f

29 files changed

Lines changed: 3578 additions & 0 deletions

.github/workflows/npm-publish.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Publish to npm
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
permissions:
8+
contents: read
9+
id-token: write
10+
11+
jobs:
12+
publish:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- uses: actions/checkout@v4
17+
18+
- uses: actions/setup-node@v4
19+
with:
20+
node-version: 20.x
21+
registry-url: 'https://registry.npmjs.org'
22+
cache: 'npm'
23+
24+
- run: npm ci
25+
26+
- name: Set version from tag
27+
run: |
28+
VERSION="${GITHUB_REF_NAME#v}"
29+
npm version "$VERSION" --no-git-tag-version
30+
31+
- run: npm run build
32+
- run: npm test
33+
34+
- name: Publish
35+
run: npm publish --provenance --access public
36+
env:
37+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
38+
39+
- name: Verify publication
40+
run: |
41+
VERSION="${GITHUB_REF_NAME#v}"
42+
sleep 10
43+
npm view fred-cli@"$VERSION"

.github/workflows/security.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Security Audit
2+
3+
on:
4+
schedule:
5+
- cron: '0 9 * * 1' # Monday 9am UTC
6+
workflow_dispatch:
7+
8+
jobs:
9+
audit:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- uses: actions/checkout@v4
14+
15+
- uses: actions/setup-node@v4
16+
with:
17+
node-version: 20.x
18+
cache: 'npm'
19+
20+
- run: npm ci
21+
22+
- name: Audit all dependencies (moderate+)
23+
run: npm audit --audit-level=moderate || true
24+
25+
- name: Audit production dependencies (high+)
26+
run: npm audit --omit=dev --audit-level=high
27+
28+
- name: Check outdated dependencies
29+
run: npm outdated || true
30+
31+
- name: Save audit report
32+
if: always()
33+
run: |
34+
mkdir -p audit-reports
35+
npm audit --json > audit-reports/audit.json || true
36+
npm outdated --json > audit-reports/outdated.json || true
37+
38+
- name: Upload audit artifacts
39+
if: always()
40+
uses: actions/upload-artifact@v4
41+
with:
42+
name: audit-reports
43+
path: audit-reports/
44+
retention-days: 30

.github/workflows/test.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Test
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches: [main]
7+
8+
concurrency:
9+
group: ${{ github.workflow }}-${{ github.ref }}
10+
cancel-in-progress: true
11+
12+
jobs:
13+
test:
14+
runs-on: ubuntu-latest
15+
strategy:
16+
matrix:
17+
node-version: [18.x, 20.x]
18+
19+
steps:
20+
- uses: actions/checkout@v4
21+
22+
- uses: actions/setup-node@v4
23+
with:
24+
node-version: ${{ matrix.node-version }}
25+
cache: 'npm'
26+
27+
- run: npm ci
28+
- run: npm run build
29+
- run: npm test
30+
31+
- name: Integration tests
32+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
33+
env:
34+
FRED_API_KEY: ${{ secrets.FRED_API_KEY }}
35+
run: npm run test:integration

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
node_modules/
2+
dist/
3+
*.tsbuildinfo
4+
.DS_Store

CLAUDE.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# fred-cli
2+
3+
Unofficial CLI + TypeScript client for the FRED API v2 (Federal Reserve Economic Data).
4+
5+
## Build & Test
6+
7+
```bash
8+
npm run build # tsc -> dist/
9+
npm test # unit tests (mocked HTTP)
10+
npm run test:integration # live API tests (needs FRED_API_KEY)
11+
npm run dev -- <args> # run CLI directly via tsx
12+
```
13+
14+
## Architecture
15+
16+
- `src/api/client.ts``FredClient` class, one method per API endpoint, uses native `fetch`
17+
- `src/api/types.ts` — all TypeScript types for FRED API requests/responses
18+
- `src/cli.ts` — CLI entry point, routes commands to handlers
19+
- `src/commands/` — one file per command group (series, category, release, source, tags)
20+
- `src/cli/` — parseArgs configs, formatters (json/csv/table), help text
21+
- `src/tests/` — node:test runner, fixtures in `tests/fixtures/`
22+
23+
## Conventions
24+
25+
- Zero runtime dependencies (Node 18+ native fetch, parseArgs, test runner)
26+
- ESM (`"type": "module"`) with `.js` import extensions
27+
- All API params use snake_case (matching FRED API), CLI flags use kebab-case
28+
- JSON output includes `_truncated` and `_next_offset` when results are paginated
29+
- Tests mock `global.fetch` — no external mock libraries

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2026 fiale-plus
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.

0 commit comments

Comments
 (0)