Windsurf workflow for the /publish-outdated-packages-to-gitea-registry slash command. Documents prerequisites (token scopes), step-by-step usage (dry-run, publish, commit bumps), detection algorithm, corp proxy handling, and troubleshooting.
5.1 KiB
| description |
|---|
| Publish only outdated @bytelyst/* packages to the Gitea npm registry |
Publish Outdated Packages to Gitea Registry
Detects which @bytelyst/* packages in packages/ have local changes compared to what's published in the Gitea npm registry, and republishes only the outdated ones.
Registry (auto-detected via NETWORK env var):
NETWORK=corp→http://localhost:3300(SSH tunnel to Azure VM)NETWORK=home→http://<azure-vm>:3300(direct, from~/.gitea_vm_hostorgitea.bytelyst.com)
Auth: GITEA_NPM_TOKEN env var (auto-loaded from ~/.gitea_npm_token by switch-network.sh)
Token scope required: read:package + write:package
Prerequisites
The Gitea NPM token must have both read:package and write:package scopes.
To create/update the token:
- Open Gitea token settings:
- Corp network:
http://localhost:3300/-/user/settings/applications - Home network:
http://<azure-vm>:3300/-/user/settings/applications
- Corp network:
- Create a new token with scopes:
read:package,write:package - Save it:
echo "<token>" > ~/.gitea_npm_token - Reload shell:
source ~/.zshrc
Steps
1. Verify prerequisites
// turbo
echo "Token: ${GITEA_NPM_TOKEN:0:5}..." && curl -s -o /dev/null -w "Gitea HTTP: %{http_code}\n" "http://${GITEA_NPM_HOST:-localhost}:3300/"
2. Dry-run: detect outdated packages
Run the script in --dry-run mode first to see which packages need publishing without making any changes.
// turbo
cd /Users/sd9235/code/mygh/learning_ai_common_plat && bash scripts/publish-outdated-gitea-packages.sh --dry-run
Review the output:
- UP-TO-DATE — local content matches registry (no action needed)
- OUTDATED — local content differs from registry (will bump patch version + publish)
- NOT FOUND — version not in registry (will publish as-is)
- SKIP — native SDKs or packages without dist/
3. Publish outdated packages
If the dry-run shows outdated packages, run the script without --dry-run to publish them.
cd /Users/sd9235/code/mygh/learning_ai_common_plat && bash scripts/publish-outdated-gitea-packages.sh
The script will:
- Build all packages (
pnpm build) - Compare each package's local content fingerprint against the registry's
- For outdated packages: auto-bump the patch version (e.g., 0.1.0 -> 0.1.1) and publish
- For not-found packages: publish as-is (current version)
- Print which
package.jsonfiles were bumped so you can commit them
4. Commit version bumps
After publishing, the script reports which package.json files had their version bumped. Commit them:
cd /Users/sd9235/code/mygh/learning_ai_common_plat && git add packages/*/package.json && git commit -m "chore(packages): bump versions for Gitea registry publish"
5. (Optional) Publish a single package
cd /Users/sd9235/code/mygh/learning_ai_common_plat && bash scripts/publish-outdated-gitea-packages.sh --filter @bytelyst/errors
6. (Optional) Skip the build step
If you already ran pnpm build:
cd /Users/sd9235/code/mygh/learning_ai_common_plat && bash scripts/publish-outdated-gitea-packages.sh --skip-build
How detection works
For each package in packages/:
pnpm packcreates a local tarball- Downloads the same version's tarball from the registry
- Extracts both and computes SHA-256 fingerprints of all file contents
- If fingerprints differ (or version not in registry) -> marked for publish
This is metadata-independent (ignores tar timestamps) and catches any source/dist change.
Corp proxy handling
When NETWORK=corp, the script automatically:
- Routes to
http://localhost:3300(SSH tunnel) instead of the Azure VM - Unsets all
NPM_CONFIG_*and*_proxyenv vars for thenpm publishcommand
On both networks, the script:
- Strips
publishConfig.registryfrom tarballs (avoids hardcoded external domain) - Runs
npm publishfrom/tmp(avoids repo.npmrcscoped registry override)
Troubleshooting
| Issue | Fix |
|---|---|
GITEA_NPM_TOKEN is required |
Run source ~/.zshrc or export GITEA_NPM_TOKEN=$(cat ~/.gitea_npm_token) |
| Gitea unreachable | Check if Gitea VM is running. Verify GITEA_NPM_HOST resolves |
| E401 on publish | Token needs write:package scope. Regenerate at http://localhost:3300/-/user/settings/applications |
| All packages show OUTDATED | Normal after first run. Subsequent runs will show UP-TO-DATE for unchanged packages |
| Package has no dist/ | Run pnpm build first or don't use --skip-build |
Script location
scripts/publish-outdated-gitea-packages.sh in learning_ai_common_plat
Run bash scripts/publish-outdated-gitea-packages.sh --help for usage.