Adjust workflow for correct module generation
Some checks failed
Generate and Release Protos / release (push) Failing after 23s
Some checks failed
Generate and Release Protos / release (push) Failing after 23s
This commit is contained in:
@@ -40,31 +40,29 @@ jobs:
|
||||
run: |
|
||||
npm init -y
|
||||
|
||||
# 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
|
||||
# 1. Create the Namespaced index.ts from the FLAT files
|
||||
# This turns 'rail_backend_v1_pis_mapping.ts' into 'RailBackendV1PisMapping'
|
||||
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);
|
||||
}
|
||||
printf "export * as %s from \"./%s.js\";\n", namespace, $0
|
||||
}' > index.ts
|
||||
|
||||
# 2. Update package.json
|
||||
jq '.name = "@owlboard/backend-data-contracts" |
|
||||
.version = "${{ steps.get_version.outputs.VERSION }}" |
|
||||
.type = "module" |
|
||||
.main = "./dist/index.js" |
|
||||
.types = "./dist/index.d.ts" |
|
||||
.publishConfig = { "registry": "https://git.fjla.uk/api/packages/owlboard/npm" }' \
|
||||
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
|
||||
|
||||
# 3. Compile
|
||||
npx tsc index.ts --declaration --module esnext --target es2022 --moduleResolution node --outDir dist/
|
||||
# 3. Compile (No tsconfig needed with these flags)
|
||||
npx tsc index.ts --declaration --module nodenext --target es2022 --moduleResolution nodenext --outDir dist/ --skipLibCheck true
|
||||
|
||||
# 4. Publish
|
||||
npm config set //git.fjla.uk/api/packages/owlboard/npm/:_authToken ${{ secrets.PACKAGE_PUSH }}
|
||||
npm publish
|
||||
env:
|
||||
NODE_AUTH_TOKEN: ${{ secrets.PACKAGE_PUSH }}
|
||||
|
||||
- name: Publish Go
|
||||
run: |
|
||||
|
||||
Reference in New Issue
Block a user