Merge pull request #8 from ccollier86/codex/review-typed-fetch-refactor-progress
Add package readiness notes and metadata tests
This commit is contained in:
commit
9426e8e66c
2 changed files with 47 additions and 0 deletions
13
README.md
13
README.md
|
|
@ -58,6 +58,19 @@ const profile = await typed.get('/me')
|
|||
// profile.data is strongly typed based on your schema/runtime samples
|
||||
```
|
||||
|
||||
## 🧩 Install & runtime support
|
||||
|
||||
- Published as zero-dependency ESM with an accompanying CommonJS build for straightforward `npm install @catalystlabs/typedfetch` integration across bundlers, Node 16+, and modern browsers.
|
||||
- Ships type declarations (`dist/index.d.ts`) and a CLI entrypoint (`typedfetch`) out of the box.
|
||||
|
||||
```ts
|
||||
// ESM / TypeScript
|
||||
import { tf } from '@catalystlabs/typedfetch'
|
||||
|
||||
// CommonJS
|
||||
const { tf: tfCjs } = require('@catalystlabs/typedfetch')
|
||||
```
|
||||
|
||||
## ✨ Features
|
||||
|
||||
### 🔒 Type Safety
|
||||
|
|
|
|||
34
tests/package-config.test.ts
Normal file
34
tests/package-config.test.ts
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
import { readFileSync } from 'node:fs'
|
||||
import { dirname, resolve } from 'node:path'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
import { describe, expect, it } from 'vitest'
|
||||
|
||||
const __dirname = dirname(fileURLToPath(import.meta.url))
|
||||
const pkg = JSON.parse(
|
||||
readFileSync(resolve(__dirname, '..', 'package.json'), 'utf8')
|
||||
)
|
||||
|
||||
describe('package metadata', () => {
|
||||
it('exposes dual-build entrypoints for easy installation', () => {
|
||||
expect(pkg.main).toBe('./dist/index.js')
|
||||
expect(pkg.module).toBe('./dist/index.js')
|
||||
expect(pkg.types).toBe('./dist/index.d.ts')
|
||||
expect(pkg.exports?.['.']?.import).toBe('./dist/index.js')
|
||||
expect(pkg.exports?.['.']?.require).toBe('./dist/index.cjs')
|
||||
expect(pkg.exports?.['.']?.types).toBe('./dist/index.d.ts')
|
||||
})
|
||||
|
||||
it('ships distributable files and documentation', () => {
|
||||
expect(pkg.files).toEqual(
|
||||
expect.arrayContaining(['dist', 'README.md', 'LICENSE'])
|
||||
)
|
||||
})
|
||||
|
||||
it('includes the CLI entrypoint', () => {
|
||||
expect(pkg.bin?.typedfetch).toBe('./dist/cli.js')
|
||||
})
|
||||
|
||||
it('is versioned for publishing', () => {
|
||||
expect(pkg.version).not.toBe('0.0.0')
|
||||
})
|
||||
})
|
||||
Loading…
Reference in a new issue