Skip to content

Commit

Permalink
build: directly generate js libs to node_modules
Browse files Browse the repository at this point in the history
Roll back stellar#122, but
keep `crowdfund-contract` and `abundance-token` in
`optionalDependencies`.

As I worked with the old version in earnest, iterating on a local copy
of the CLI and generating new JS libs over and over, the two-step
generate-to-.soroban, then install-to-node_modules wasn't working very
well. Probably because the new library wasn't being added until the
`postinstall` step, and the dependencies are optional.

Generating directly to `node_modules` feels dirty, but it works
consistently. At least in this version, you can still see the
dependencies listed in the `optionalDependencies` section, so they're
not quite as surprising/mysterious.
  • Loading branch information
chadoh committed Jul 20, 2023
1 parent abdac3a commit 8cd9fd2
Show file tree
Hide file tree
Showing 3 changed files with 253 additions and 30 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package-lock.json linguist-generated=true -diff
270 changes: 245 additions & 25 deletions package-lock.json

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

12 changes: 7 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
"start": "next start",
"lint": "next lint",
"setup": "./initialize.sh ${NETWORK:-futurenet} && npm install",
"clean": "rm -rf .next .soroban .soroban-example-dapp node_modules",
"clean": "rm -rf .next .soroban .soroban-example-dapp",
"reset": "npm run clean && npm run setup",
"postinstall": "rm -rf ./.soroban/crowdfund-contract && rm -rf ./.soroban/abundance-token && ./target/bin/soroban contract bindings typescript --wasm ./target/wasm32-unknown-unknown/release/soroban_crowdfund_contract.wasm --id $(cat ./.soroban-example-dapp/crowdfund_id) --rpc-url $(cat ./.soroban-example-dapp/rpc-url) --network-passphrase \"$(cat ./.soroban-example-dapp/passphrase)\" --output-dir ./.soroban/crowdfund-contract --contract-name crowdfund-contract && ./target/bin/soroban contract bindings typescript --wasm ./target/wasm32-unknown-unknown/release/abundance_token.wasm --id $(cat ./.soroban-example-dapp/abundance_token_id) --rpc-url $(cat ./.soroban-example-dapp/rpc-url) --network-passphrase \"$(cat ./.soroban-example-dapp/passphrase)\" --output-dir ./.soroban/abundance-token --contract-name abundance-token"
"postinstall": "cargo build --target wasm32-unknown-unknown --release && ./target/bin/soroban contract bindings typescript --wasm ./target/wasm32-unknown-unknown/release/soroban_crowdfund_contract.wasm --id $(cat ./.soroban-example-dapp/crowdfund_id) --output-dir ./node_modules/crowdfund-contract --network $(cat ./.soroban-example-dapp/network) --contract-name crowdfund-contract && ./target/bin/soroban contract bindings typescript --wasm ./target/wasm32-unknown-unknown/release/abundance_token.wasm --id $(cat ./.soroban-example-dapp/abundance_token_id) --output-dir ./node_modules/abundance-token --network $(cat ./.soroban-example-dapp/network) --contract-name abundance-token"
},
"dependencies": {
"@radix-ui/react-dialog": "1.0.2",
Expand All @@ -22,9 +22,7 @@
"next": "^13.4.4",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"soroban-client": "0.9.2",
"crowdfund-contract": "file:.soroban/crowdfund-contract",
"abundance-token": "file:.soroban/abundance-token"
"soroban-client": "0.9.1"
},
"devDependencies": {
"@types/humanize-duration": "^3.27.1",
Expand All @@ -35,6 +33,10 @@
"eslint-config-next": "^13.3.1",
"typescript": "5.1.3"
},
"optionalDependencies": {
"crowdfund-contract": "file:node_modules/crowdfund-contract",
"abundance-token": "file:node_modules/abundance-token"
},
"engines": {
"node": ">=17",
"npm": ">=8"
Expand Down

0 comments on commit 8cd9fd2

Please sign in to comment.