157 lines
3.4 KiB
Markdown

# Publishing the SSE Client Package
This document explains how to build and publish the SSE client package to the Generation One Gitea repository.
## Prerequisites
- Node.js and pnpm installed
- Access to the Generation One Gitea repository
- Gitea access token with `packages:write` permission
## Building the Package
1. Install dependencies:
```bash
cd sse-client
pnpm install
```
2. Build the package:
```bash
pnpm build
```
This will compile the TypeScript code and generate the distribution files in the `dist` directory.
## Configuration for Publishing
The package is already configured for publishing to the Generation One Gitea repository with the following files:
### package.json
```json
{
"name": "@g1/sse-client",
"version": "1.0.0",
"description": "A custom SSE client that supports headers and bypasses certificate issues",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"repository": {
"type": "git",
"url": "https://git.generation.one/GenerationOne/g1-ts-common-packages.git"
},
"publishConfig": {
"registry": "https://git.generation.one/api/packages/GenerationOne/npm/"
}
}
```
### .npmrc
```
# Gitea registry configuration
@g1:registry=https://git.generation.one/api/packages/GenerationOne/npm/
//git.generation.one/api/packages/GenerationOne/npm/:_authToken=${GITEA_TOKEN}
```
## Publishing to Gitea
### Method 1: Direct Publishing
1. Generate an access token in Gitea:
- Log in to https://git.generation.one
- Go to your user settings (click your profile picture)
- Select "Applications" or "Access Tokens"
- Create a new token with the "packages:write" scope
- Copy the generated token
2. Set the token as an environment variable:
```powershell
$env:GITEA_TOKEN = "your-token-here"
```
3. Publish the package:
```powershell
pnpm publish --no-git-checks
```
The `--no-git-checks` flag allows publishing without committing to Git first.
### Method 2: Commit to Git Repository First
If you prefer to commit the code to the Git repository before publishing:
1. Initialize Git and add the remote:
```powershell
git init
git add .
git commit -m "Initial commit of SSE client package"
git remote add origin https://git.generation.one/GenerationOne/g1-ts-common-packages.git
```
2. Create a branch for the package:
```powershell
git checkout -b feature/sse-client
```
3. Push to Gitea:
```powershell
git push -u origin feature/sse-client
```
4. Then publish the package:
```powershell
$env:GITEA_TOKEN = "your-token-here"
pnpm publish
```
## Using the Published Package
After publishing, you can use the package in other projects:
1. Add it to your dependencies:
```json
{
"dependencies": {
"@g1/sse-client": "1.0.0"
}
}
```
2. Configure your project's .npmrc file:
```
@g1:registry=https://git.generation.one/api/packages/GenerationOne/npm/
//git.generation.one/api/packages/GenerationOne/npm/:_authToken=${GITEA_TOKEN}
```
3. Install the package:
```bash
pnpm install
```
## Updating the Package
To update the package:
1. Make your changes
2. Update the version in package.json (following semantic versioning)
3. Build the package: `pnpm build`
4. Publish the new version: `pnpm publish --no-git-checks`
## Troubleshooting
- **Authentication Error**: Make sure your GITEA_TOKEN environment variable is set correctly
- **Version Conflict**: If the version already exists, update the version number in package.json
- **Registry Not Found**: Verify the registry URL in .npmrc and package.json