3.4 KiB
3.4 KiB
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
- Install dependencies:
cd sse-client
pnpm install
- Build the package:
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
{
"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
-
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
-
Set the token as an environment variable:
$env:GITEA_TOKEN = "your-token-here"
- Publish the package:
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:
- Initialize Git and add the remote:
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
- Create a branch for the package:
git checkout -b feature/sse-client
- Push to Gitea:
git push -u origin feature/sse-client
- Then publish the package:
$env:GITEA_TOKEN = "your-token-here"
pnpm publish
Using the Published Package
After publishing, you can use the package in other projects:
- Add it to your dependencies:
{
"dependencies": {
"@g1/sse-client": "1.0.0"
}
}
- 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}
- Install the package:
pnpm install
Updating the Package
To update the package:
- Make your changes
- Update the version in package.json (following semantic versioning)
- Build the package:
pnpm build
- 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