Skip to content

Conversation

fmonper1
Copy link
Contributor

@fmonper1 fmonper1 commented Sep 11, 2025

This pull request introduces significant improvements to the build, packaging, and developer workflow for the SDK, focusing on multi-platform support, streamlined script execution, and enhanced distribution packaging. The main changes include new build and install scripts for handling binaries across platforms, updates to the package manifest for correct publishing, and refactoring of workflow build scripts for better modularity and usability.

Build and Packaging Automation:

  • Added build-bins.sh to automate building CLI binaries for multiple platforms (darwin, linux, windows, arm64, x64) and generate corresponding package.json files for each binary.
  • Introduced build-pkg.sh to orchestrate SDK and binary builds, set executable permissions, clean up build artifacts, and prepare the dist folder for publishing.
  • Added mock-install.sh to simulate local installation of the SDK into a target directory, including moving built binaries and creating symlinks for executables in node_modules/.bin.

Package Manifest and Distribution:

  • Updated package.json:
    • Changed package name to @chainlink/cre-sdk.
    • Added files, include, and bin fields to ensure correct files and binaries are included in the published package.
    • Added/updated build scripts to support multi-platform builds and declaration generation.
    • Added rimraf as a dev dependency for cleaning up build artifacts. [1] [2] [3]

Developer Workflow and Script Refactoring:

  • Refactored workflow build scripts:
    • Modularized workflow JS and WASM build logic into build-single-workflow-js-cmd.ts and compile-single-workflow-to-wasm-cmd.ts for reusability and argument clarity. [1] [2]
    • Updated build-single-workflow.ts to use the new modular functions, improving clarity and maintainability. [1] [2]
    • Enhanced scripts/run.ts to use a mapping of script names to main functions, simplifying script execution and error handling.

SDK Exports and TypeScript Configuration:

  • Added and corrected exports in src/sdk/index.ts, src/sdk/runtime/index.ts, and src/sdk/utils/index.ts to ensure all necessary modules and types are available for consumers. [1] [2] [3]
  • Added tsconfig.types.json to generate TypeScript declaration files (.d.ts) only for SDK code, excluding workflow sources.

Minor Refactoring and Improvements:

  • Refactored runtime assertion methods to use arrow functions for consistency. [1] [2]
  • Updated the WASM compilation script to use a specific local binary for macOS ARM builds.

These changes collectively improve the SDK's build reliability, cross-platform support, and developer experience.

@fmonper1 fmonper1 marked this pull request as ready for review September 15, 2025 10:03
@fmonper1 fmonper1 requested a review from a team as a code owner September 15, 2025 10:03
Comment on lines +133 to +135
console.log(
'Platform specific package already installed. Will fall back to manually downloading binary.'
)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thought: I'm confused with this log

If the package is already installed, the install script isn't expected to do anything, right?
The code says so.
OTOH, IIUC the log is saying it will manually download a binary.

@bradford-m bradford-m requested a review from timweri September 15, 2025 11:34

execFileSync(getBinaryPath(), process.argv.slice(2), {
stdio: 'inherit',
})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: add EOF new line

"proto:format": "bunx @bufbuild/buf format --write",
"test": "bun test",
"test:standard": "./scripts/run-standard-tests.sh",
"build": "bun build --target=node --entrypoints ./src/sdk/index.ts ./src/sdk/utils/index.ts ./src/sdk/runtime/index.ts --outdir=dist && bun run build:declaration && bun run build:cli",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: these scripts are easier to find in alphabetical order.

@ernest-nowacki
Copy link
Contributor

Problem with this branch is now when I just do bun install I get error: postinstall script from "cre-ts-sdk" exited with 1.

This is probably connected with the fact that bun is by default blocking post install

@fmonper1
Copy link
Contributor Author

Problem with this branch is now when I just do bun install I get error: postinstall script from "cre-ts-sdk" exited with 1.

This is probably connected with the fact that bun is by default blocking post install

Fixed here -> 6a9acfd

ernest-nowacki
ernest-nowacki previously approved these changes Sep 16, 2025
@fmonper1 fmonper1 merged commit 88351af into main Sep 16, 2025
7 checks passed
@fmonper1 fmonper1 deleted the build-package branch September 16, 2025 13:46
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.

5 participants