From 018190f76b487f157700703724f0e25ac2e9ef5a Mon Sep 17 00:00:00 2001 From: Fred Boniface Date: Wed, 7 Jan 2026 14:04:45 +0000 Subject: [PATCH] Fix NPM Step --- .gitea/workflows/release.yaml | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/.gitea/workflows/release.yaml b/.gitea/workflows/release.yaml index 3a1ffa5..43c0ca8 100644 --- a/.gitea/workflows/release.yaml +++ b/.gitea/workflows/release.yaml @@ -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