From 20cb7b101cf0d878e237f4f7002ea5cb8fd652f4 Mon Sep 17 00:00:00 2001 From: Fred Boniface Date: Wed, 7 Jan 2026 18:25:43 +0000 Subject: [PATCH] Try fix workflow --- .gitea/workflows/release.yaml | 38 ++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/.gitea/workflows/release.yaml b/.gitea/workflows/release.yaml index c119825..8067a3b 100644 --- a/.gitea/workflows/release.yaml +++ b/.gitea/workflows/release.yaml @@ -38,29 +38,39 @@ jobs: - name: Build and Publish TS working-directory: gen/ts run: | + # 1. Initialize with defaults npm init -y - # 1. Create the Namespaced index.ts from the FLAT files - # This turns 'rail_backend_v1_pis_mapping.ts' into 'RailBackendV1PisMapping' + # 2. Build index.ts carefully + # We ensure a space before 'from' and explicit double quotes around the path + echo "// Auto-generated" > index.ts find . -maxdepth 1 -name "*.ts" -not -name "index.ts" | sed 's|^\./||; s|\.ts$||' | awk '{ - split($0, parts, "_"); - namespace=""; - for (i in parts) { - namespace = namespace toupper(substr(parts[i],1,1)) substr(parts[i],2); + # Create Namespace: split by underscore, capitalize each part + n = split($0, parts, "_"); + name = ""; + for (i=1; i<=n; i++) { + name = name toupper(substr(parts[i],1,1)) substr(parts[i],2); } - printf "export * as %s from \"./%s.js\";\n", namespace, $0 - }' > index.ts + # CRITICAL: Space before from, escaped quotes around path + printf "export * as %s from \"./%s.js\";\n", name, $0 + }' >> index.ts - # 2. Update package.json + # 3. Debug: Print index.ts so we can see it in logs if it fails again + cat index.ts + + # 4. Update package.json using a robust jq call + # We use --arg to ensure the VERSION string doesn't break the JSON VERSION="${{ steps.get_version.outputs.VERSION }}" - jq --arg ver "$VERSION" '.name = "@owlboard/backend-data-contracts" | - .version = $ver | .type = "module" | .main = "./dist/index.js" | .types = "./dist/index.d.ts"' \ - package.json > temp.json && mv temp.json package.json + jq --arg ver "$VERSION" \ + --arg name "@owlboard/backend-data-contracts" \ + '.name = $name | .version = $ver | .type = "module" | .main = "./dist/index.js" | .types = "./dist/index.d.ts"' \ + package.json > package.json.tmp && mv package.json.tmp package.json - # 3. Compile (No tsconfig needed with these flags) + # 5. Compile with explicit flags + # We use 'nodenext' because it matches the .js extensions in our index.ts npx tsc index.ts --declaration --module nodenext --target es2022 --moduleResolution nodenext --outDir dist/ --skipLibCheck true - # 4. Publish + # 6. Authenticate and Publish npm config set //git.fjla.uk/api/packages/owlboard/npm/:_authToken ${{ secrets.PACKAGE_PUSH }} npm publish