-
Notifications
You must be signed in to change notification settings - Fork 2
float js/ts bindings #76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
5ee78fa
init
rouzwelt 58f0442
Update tsconfig.json
rouzwelt 3557773
Update npm-package-release.yaml
rouzwelt 8a16631
Update flake.nix
rouzwelt 8c7fe8f
fix
rouzwelt 5f28389
Update float.test.ts
rouzwelt 98448dd
update
rouzwelt 08733df
update
rouzwelt ff64e5a
Update lib.rs
rouzwelt aa3fa11
fixes
rouzwelt 3f81029
Update lib.rs
rouzwelt 07a9537
cjs/esm test
rouzwelt 8b4f716
Update float.test.ts
rouzwelt ea8fb9a
Update float.test.ts
rouzwelt 2851d93
Update float.test.ts
rouzwelt f09dd9b
Update float.test.ts
rouzwelt ad4f775
Update float.test.ts
rouzwelt bc11d21
Update float.test.ts
rouzwelt 742d220
Update float.test.ts
rouzwelt 07bfed5
single quote
rouzwelt d4ad14b
fix build script
rouzwelt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,115 @@ | ||
| name: NPM Packages Release | ||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
|
|
||
| jobs: | ||
| release: | ||
| if: ${{ github.ref == 'refs/heads/main' && !startsWith(github.event.head_commit.message, 'NPM Package Release') }} | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| id-token: write | ||
| contents: write | ||
| outputs: | ||
| version: ${{ env.NEW_VERSION }} | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| ssh-key: ${{ secrets.PUBLISH_PRIVATE_KEY }} | ||
| submodules: recursive | ||
| fetch-depth: 0 | ||
|
|
||
| - uses: DeterminateSystems/nix-installer-action@main | ||
| with: | ||
| determinate: true | ||
| - uses: DeterminateSystems/flakehub-cache-action@main | ||
|
|
||
| - name: Install NodeJS v22 | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: 22 | ||
| cache: "npm" | ||
|
|
||
| - run: nix develop -c rainix-sol-prelude | ||
|
|
||
| - name: Test JS/TS Binding | ||
| run: nix develop -c test-js-bindings | ||
|
|
||
| - name: Git Config | ||
| run: | | ||
| git config --global user.email "${{ secrets.CI_GIT_EMAIL }}" | ||
| git config --global user.name "${{ secrets.CI_GIT_USER }}" | ||
|
|
||
| # get hash of latest published pkgs from npm and concat them | ||
| - name: Get Old Hash | ||
| run: | | ||
| OLD_HASH=$(npm view @rainlanguage/float@latest dist.shasum 2>/dev/null || echo "none") | ||
| echo "OLD_HASH=$OLD_HASH" >> $GITHUB_ENV | ||
| echo "old hash: $OLD_HASH" | ||
|
|
||
| # calc hash of current workspace pkgs by packing them and concat them | ||
| - name: Get New Hash | ||
| run: | | ||
| NEW_HASH=$(npm pack --silent | xargs shasum | cut -c1-40) | ||
| echo "NEW_HASH=$NEW_HASH" >> $GITHUB_ENV | ||
| echo "new hash: $NEW_HASH" | ||
| rm -f *.tgz | ||
|
|
||
| # from here on, we'll skip if OLD_HASH and NEW_HASH are the same (ie no publish) | ||
| # this means we need to skip every step by using an if statement. | ||
| # set npm version | ||
| - name: Set Version | ||
| if: ${{ env.OLD_HASH != env.NEW_HASH }} | ||
| run: | | ||
| NEW_VERSION=$(npm version prerelease --preid alpha --no-git-tag-version) | ||
| echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV | ||
|
|
||
| # Commit changes and tag | ||
| - name: Commit And Tag | ||
| if: ${{ env.OLD_HASH != env.NEW_HASH }} | ||
| run: | | ||
| git add "package.json" | ||
| git add "package-lock.json" | ||
| git commit -m "NPM Package Release v${{ env.NEW_VERSION }}" | ||
| git tag npm-v${{ env.NEW_VERSION }} | ||
|
|
||
| # Push the commit to remote | ||
| - name: Push Changes To Remote | ||
| if: ${{ env.OLD_HASH != env.NEW_HASH }} | ||
| run: | | ||
| git push origin | ||
| git push -u origin npm-v${{ env.NEW_VERSION }} | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| # Create float npm package tarball | ||
| - name: Create float NPM Package Tarball | ||
| if: ${{ env.OLD_HASH != env.NEW_HASH }} | ||
| run: echo "NPM_PACKAGE=$(npm pack --silent)" >> $GITHUB_ENV | ||
|
|
||
| - name: Rename float NPM Package Tarball | ||
| if: ${{ env.OLD_HASH != env.NEW_HASH }} | ||
| run: mv ${{ env.NPM_PACKAGE }} float_npm_package_${{ env.NEW_VERSION }}.tgz | ||
|
|
||
| # publish float pkg to npm | ||
| - name: Publish float pkg To NPM | ||
| if: ${{ env.OLD_HASH != env.NEW_HASH }} | ||
| uses: JS-DevTools/npm-publish@v3 | ||
| with: | ||
| token: ${{ secrets.NPM_TOKEN }} | ||
| access: public | ||
| package: float_npm_package_${{ env.NEW_VERSION }}.tgz | ||
|
|
||
| # Create gitHub release with tarballs | ||
| - name: Create GitHub Release with float pkg | ||
| if: ${{ env.OLD_HASH != env.NEW_HASH }} | ||
| id: gh_release | ||
| uses: softprops/action-gh-release@v2 | ||
| with: | ||
| tag_name: npm-v${{ env.NEW_VERSION }} | ||
| name: NPM Package Release v${{ env.NEW_VERSION }} | ||
| files: | | ||
| float_npm_package_${{ env.NEW_VERSION }}.tgz | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,7 @@ | ||
| out | ||
| cache | ||
| .direnv | ||
| target | ||
| target | ||
| temp | ||
| dist | ||
| node_modules |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧹 Nitpick (assertive)
🛠️ Refactor suggestion
WasmEncodedError conversion needs improvement.
The TODO comment indicates that detailed readable messages are needed. Consider implementing more specific error descriptions for better user experience.
impl From<FloatError> for WasmEncodedError { fn from(value: FloatError) -> Self { + let readable_msg = match &value { + FloatError::InvalidHex(hex) => format!("Invalid hexadecimal string: {}", hex), + FloatError::JsSysError(msg) => format!("JavaScript error: {}", msg), + FloatError::DecimalFloat(_) => "Decimal float operation failed".to_string(), + _ => value.to_string(), + }; WasmEncodedError { msg: value.to_string(), - readable_msg: value.to_string(), // todo: add detailed readable msg for errors + readable_msg, } } }Do you want me to generate a more comprehensive error message mapping implementation?
📝 Committable suggestion
🤖 Prompt for AI Agents
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will be added in followups
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rouzwelt Sounds good! Deferring the detailed error message improvements to follow-up PRs is a reasonable approach to keep this PR focused on the core JavaScript/TypeScript bindings functionality.
🧠 Learnings used
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rouzwelt do we have an issue for that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.