Skip to content

ci(phase2): replace install.js postinstall with per-platform npm packages - #1246

Open
kbarnold wants to merge 5 commits into
masterfrom
ci/phase2-package-restructure
Open

ci(phase2): replace install.js postinstall with per-platform npm packages#1246
kbarnold wants to merge 5 commits into
masterfrom
ci/phase2-package-restructure

Conversation

@kbarnold

Copy link
Copy Markdown
Contributor

Summary

  • Replaces the install.js postinstall script (which downloaded binaries from GitHub Releases at install time) with per-platform optional npm packages (@sap/mbt-linux-x64, @sap/mbt-linux-arm64, @sap/mbt-darwin-x64, @sap/mbt-darwin-arm64, @sap/mbt-win32-x64)
  • Rewrites bin/mbt to use require.resolve to locate the platform binary shipped in the appropriate optional package
  • Adds npm publish templates (.github/publish/npm/) and a render script (.github/scripts/render-npm-packages.sh) that the release workflow will use to prepare and publish all 6 packages (5 platform + 1 wrapper) after goreleaser builds the binaries
  • Updates .goreleaser.yml to goreleaser v2 format (version: 2, name_template replacing removed archives.replacements)
  • Removes axios, tar, unzip-stream dependencies; package-lock.json drops from 440 to 22 lines

Motivation

The install.js approach downloads unverified binaries at install time over HTTPS, which is a supply-chain risk vector. The per-platform package approach ships signed, checksummed binaries through the npm registry (same channel as the package itself), which is safer and works offline/air-gapped after install.

Test plan

  • CI passes (Go tests, golangci-lint)
  • Local smoke test passed on darwin/arm64: goreleaser build --snapshot --cleanrender-npm-packages.shnpm install wrapper + platform tarball → node_modules/.bin/mbt --version prints correct version
  • Linux/Windows round-trip testing to be done in the publish workflow (Phase 3)

kbarnold added 5 commits July 22, 2026 12:47
…ackages

- Rewrite bin/mbt to resolve the platform binary via require.resolve on
  @sap/mbt-<os>-<arch> instead of looking in unpacked_bin/
- Delete install.js (postinstall network download) and index.js (empty stub)
- Remove axios/tar/unzip-stream dependencies
- Remove the "install" postinstall script from package.json
- Rename package from "mbt" to "@sap/mbt", set version placeholder "0.0.0-dev"
- Add optionalDependencies for the five per-platform packages (versions are
  0.0.0-dev placeholders; the publish workflow overwrites them at release time)
- Remove install.js and index.js from the "files" list

Consumer install behavior is unchanged: npm install @sap/mbt still works and
selects the correct platform binary. No postinstall network call.
…ckages

- .github/publish/npm/mbt-wrapper/package.json.tmpl — wrapper package
  template; {{.Version}} is substituted at publish time
- .github/publish/npm/mbt-platform/package.json.tmpl — per-platform
  package template; substitutes Version, Os, Arch, BinExt
- .github/scripts/render-npm-packages.sh — renders templates and copies
  goreleaser-built binaries into /tmp/publish/<pkg>/ ready for npm publish

The render script is called by the release-publish workflow (Phase 4).
It can also be run locally against a goreleaser snapshot build for dry-run
testing (step 11 of Phase 2).
…overy

- Add required `version: 2` header to .goreleaser.yml (goreleaser v2+)
- Replace deprecated `archives.replacements` with `name_template` using
  the title filter to preserve Darwin/Linux/Windows capitalisation
- Fix render-npm-packages.sh to locate binaries via find rather than
  constructing the path, since goreleaser v2 uses project_name as the
  directory prefix (cloud-mta-build-tool_linux_amd64_v1/) not binary name
- Fix PLATFORMS table to use an indexed array to avoid associative array
  unbound variable errors on some bash versions

Smoke tested: goreleaser build --snapshot + render script + npm install
+ mbt --version all pass on darwin/arm64.
Removes the old axios/tar/unzip-stream lock entries; now only the
@sap/mbt wrapper metadata is tracked. optionalDependencies remain at
0.0.0-dev placeholders until the publish workflow stamps the real version.
@whydrae

whydrae commented Jul 24, 2026

Copy link
Copy Markdown

Closes: #1231 #1243 #1244

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants