Skip to content

Commit

Permalink
update nodejs example
Browse files Browse the repository at this point in the history
  • Loading branch information
OlofBlomqvist committed Aug 3, 2023
1 parent 65ff687 commit 29fc5a6
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 33 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "marlowe_lang"
description = "experimental parser lib for Cardano Marlowe DSL"
version = "0.2.1"
version = "0.2.31"
edition = "2021"
authors = ["Olof Blomqvist <olof@twnet.se>"]
repository = "https://github.com/OlofBlomqvist/marlowe_rust"
Expand Down
35 changes: 27 additions & 8 deletions build_npm_packages.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ param(
$nodejs_dir = "pkg_njs"
$bundle_dir = "pkg_bundle"
$web_dir = "pkg_web"
$latest_dir = "pkg_latest"

if($skipBuild -ne $true) {

Expand All @@ -24,7 +25,9 @@ if($skipBuild -ne $true) {
if(Test-Path $web_dir) {
Remove-Item $web_dir/ -Recurse -Force -ErrorAction Stop
}

if(Test-Path $latest_dir) {
Remove-Item $latest_dir/ -Recurse -Force -ErrorAction Stop
}
# Build for NodeJS
wasm-pack build --all-features --release --target nodejs --out-dir $nodejs_dir/pkg
$j = Get-Content $nodejs_dir/pkg/package.json |convertfrom-json
Expand Down Expand Up @@ -71,22 +74,38 @@ if($skipBuild -ne $true) {
$bundlev = $j.version
#wasm-pack pack $bundle_dir

# Build latest
wasm-pack build --all-features --release --target nodejs --out-dir $latest_dir/pkg
$j = Get-Content $latest_dir/pkg/package.json |convertfrom-json
if($null -ne $version -and $version.Length -gt 0) {
$j.version = $version
} else {
$j.version = $j.version
}
$j | convertto-json | out-file .\$latest_dir/pkg/package.json

$latestlev = $j.version
#wasm-pack pack $bundle_dir

Write-Host -ForegroundColor Green "---> $njsv"
Write-Host -ForegroundColor Green "---> $webv"
Write-Host -ForegroundColor Green "---> $bundlev"
Write-Host -ForegroundColor Green "---> $latestlev"

} else {
Write-Warning "Build skipped"
}

if($publish) {
write-host -ForegroundColor Green "Publishing web... $web_dir $webv"
wasm-pack publish -t web --tag web $web_dir
write-host -ForegroundColor Green "Publishing nodejs... $nodejs_dir $njsv"
wasm-pack publish -t nodejs --tag nodejs $nodejs_dir
write-host -ForegroundColor Green "Publishing bundle... $bundle_dir $bundlev"
wasm-pack publish -t bundler --tag bundle $bundle_dir
# write-host -ForegroundColor Green "Publishing web... $web_dir $webv"
# wasm-pack publish -t web --tag web $web_dir
# write-host -ForegroundColor Green "Publishing nodejs... $nodejs_dir $njsv"
# wasm-pack publish -t nodejs --tag nodejs $nodejs_dir
# write-host -ForegroundColor Green "Publishing bundle... $bundle_dir $bundlev"
# wasm-pack publish -t bundler --tag bundle $bundle_dir
if($publishLatestTag) {
write-host -ForegroundColor Green "note: you need to publish @latest manually"
write-host -ForegroundColor Green "Publishing latest... $latest_dir $latestlev"
wasm-pack publish -t nodejs --tag latest $latest_dir

}
}
2 changes: 1 addition & 1 deletion examples/nodejs/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const m = require('marlowe_lang@nodejs');
const m = require('marlowe_lang');

let redeemer = m.decode_marlowe_input_cbor_hex("9fd8799fd87a9fd8799f4763686f69636531d8799fd87980d8799fd8799f581c22584b09e116a2b98819723bbe6eb65d01e1edc225fc2a3e46884d58ffd8799fd8799fd8799f581cb1131cc98fc9ff8936a281874115fce0b73f99b40542172c8eb223b9ffffffffffff02ffffff")
let datum = m.decode_cborhex_marlowe_plutus_datum ("d8799fd8799f40ffd8799fa1d8799fd8799fd87980d8799fd8799f581c22584b09e116a2b98819723bbe6eb65d01e1edc225fc2a3e46884d58ffd8799fd8799fd8799f581cb1131cc98fc9ff8936a281874115fce0b73f99b40542172c8eb223b9ffffffffffd8799f4040ffff1a002dc6c0a1d8799f4763686f69636531d8799fd87980d8799fd8799f581c22584b09e116a2b98819723bbe6eb65d01e1edc225fc2a3e46884d58ffd8799fd8799fd8799f581cb1131cc98fc9ff8936a281874115fce0b73f99b40542172c8eb223b9ffffffffffff02a01b0000018709761f88ffd87c9f9fd8799fd87a9fd8799f4763686f69636532d8799fd87980d8799fd8799f581c22584b09e116a2b98819723bbe6eb65d01e1edc225fc2a3e46884d58ffd8799fd8799fd8799f581cb1131cc98fc9ff8936a281874115fce0b73f99b40542172c8eb223b9ffffffffffff9fd8799f0304ffffffd87980ffff1b0000019ce9379560d87980ffff")
Expand Down
14 changes: 5 additions & 9 deletions examples/nodejs/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 1 addition & 13 deletions examples/nodejs/package.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,5 @@
{
"name": "marlowe_lang",
"collaborators": [
"Olof Blomqvist <olof@twnet.se>"
],
"description": "experimental parser lib for Cardano Marlowe DSL",
"version": "0.0.1",
"license": "SEE LICENSE IN licence",
"repository": {
"type": "git",
"url": "https://github.com/OlofBlomqvist/marlowe_rust"
},
"sideEffects": false,
"dependencies": {
"marlowe_lang": "nodejs"
"marlowe_lang": "0.2.1-nodejs"
}
}

0 comments on commit 29fc5a6

Please sign in to comment.