Fix NPM Step
Some checks failed
Generate and Release Protos / release (push) Failing after 22s

This commit is contained in:
2026-01-07 14:04:45 +00:00
parent affdb052b2
commit 018190f76b

View File

@@ -50,12 +50,17 @@ jobs:
run: |
npm init -y
# 1. Create a dynamic index.ts that exports everything from the subfolders
# This makes 'import { PisMapping } from "@owlboard/backend-data-contracts"' work.
find . -name "*.ts" | sed 's|^\./||; s|\.ts$||' | xargs -I {} echo "export * from './{}';" > index.ts
# 1. Create a dynamic index.ts using Namespace exports
# This converts 'rail_backend/v1/pis_mapping.ts'
# into 'export * as PisMapping from "./rail_backend/v1/pis_mapping";'
# We use awk to handle the naming conversion (snake_case to PascalCase-ish)
find . -name "*.ts" -not -name "index.ts" | sed 's|^\./||; s|\.ts$||' | awk -F'/' '{
name=$NF;
gsub(/_/, "", name);
printf "export * as %s from \"./%s\";\n", toupper(substr(name,1,1)) substr(name,2), $0
}' > index.ts
# 2. Update package.json
# We point main/types to the root dist/index file we are about to create
jq '.name = "@owlboard/backend-data-contracts" |
.version = "${{ steps.get_version.outputs.VERSION }}" |
.type = "module" |
@@ -64,8 +69,7 @@ jobs:
.publishConfig = { "registry": "https://git.fjla.uk/api/packages/owlboard/npm" }' \
package.json > temp.json && mv temp.json package.json
# 3. Compile using the created index.ts as the entry point
# tsc will automatically follow the imports in index.ts and find the nested files
# 3. Compile
npx tsc index.ts --declaration --module esnext --target es2022 --moduleResolution node --outDir dist/
npm publish