@aaronshaf/ger
Version:
Gerrit CLI and SDK - A modern CLI tool and TypeScript SDK for Gerrit Code Review, built with Effect-TS
96 lines (71 loc) • 2.17 kB
Markdown
Accepted
Beyond CLI usage, developers may want to use ger programmatically in their own tools, scripts, or automation.
Export SDK modules for programmatic usage via package.json exports.
- **Reusability**: Build custom tools on top of ger
- **Testing**: Import specific modules in tests
- **Automation**: Script Gerrit operations
- **Type safety**: Full TypeScript types included
```json
// package.json
{
"name": "@aaronshaf/ger",
"exports": {
".": "./src/index.ts",
"./api/gerrit": "./src/api/gerrit.ts",
"./services/config": "./src/services/config.ts",
"./schemas/gerrit": "./src/schemas/gerrit.ts",
"./utils": "./src/utils/index.ts"
}
}
```
- Build custom integrations
- Reuse validated schemas
- Access type-safe API client
- Import only what you need
- More surface area to maintain
- Breaking changes affect SDK users
- Documentation burden
```typescript
// Import API service
import { GerritApiService, GerritApiServiceLive } from '@aaronshaf/ger'
import { Effect } from 'effect'
// Custom automation
const myScript = Effect.gen(function* () {
const api = yield* GerritApiService
const changes = yield* api.listChanges('owner:self status:open')
for (const change of changes) {
console.log(`${change._number}: ${change.subject}`)
}
})
Effect.runPromise(
myScript.pipe(Effect.provide(GerritApiServiceLive))
)
```
```typescript
// Import schemas for validation
import { ChangeInfo } from '@aaronshaf/ger/schemas/gerrit'
import { Schema } from '@effect/schema'
const validateChange = (data: unknown) =>
Schema.decodeUnknownSync(ChangeInfo)(data)
```
```typescript
// Import utilities
import { normalizeChangeIdentifier, extractChangeIdFromCommitMessage } from '@aaronshaf/ger/utils'
const changeId = normalizeChangeIdentifier('https://gerrit.example.com/c/project/+/12345')
```
See EXAMPLES.md for detailed SDK usage patterns:
- Effect-based API calls
- Config service setup
- Custom change processing
- Batch operations