diff --git a/.github/actions/extend-space/action.yaml b/.github/actions/extend-space/action.yaml index 09d316a3a..67ccc0cb7 100644 --- a/.github/actions/extend-space/action.yaml +++ b/.github/actions/extend-space/action.yaml @@ -58,4 +58,4 @@ runs: -o lowerdir=${HOME}_lower,upperdir=$EXTENDED_PATH/home/upper,workdir=$EXTENDED_PATH/home/work \ $HOME sudo chown $(id -u):$(id -g) $HOME - df -h \ No newline at end of file + df -h diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index b746bc54f..fe8ed0101 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -15,7 +15,6 @@ jobs: - name: Extend space uses: ./.github/actions/extend-space - - name: Install nix uses: cachix/install-nix-action@v18 with: @@ -30,5 +29,5 @@ jobs: - name: Install and test run: | cd $GITHUB_WORKSPACE - nix develop --command bash -c "cargo install --path . && sh run_test.sh" + nix develop --command bash -c "cargo install --force --locked --path . && sh run_test.sh" diff --git a/.gitignore b/.gitignore index 89a98ca76..971de4a60 100644 --- a/.gitignore +++ b/.gitignore @@ -21,4 +21,4 @@ yarn-error.log* *.sln *.sw? result* -.cargo \ No newline at end of file +.cargo diff --git a/Cargo.lock b/Cargo.lock index 9286c64b4..dfb91a3b6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1694,9 +1694,9 @@ dependencies = [ [[package]] name = "fixt" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22ccb978b54171f597ebb93855417156a4df0c44e47d64ac0b0b3d909e3216b6" +checksum = "917d052dc8393531c999f5bd7f1bf4fc42e67948c97fa119d2eb2a8a0023b94e" dependencies = [ "holochain_serialized_bytes 0.0.51", "lazy_static", @@ -2174,9 +2174,9 @@ dependencies = [ [[package]] name = "hc_seed_bundle" -version = "0.1.6" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "63bba5629a49d90007bb81a27a9ba8f9c597a82246d44e73126130617f11c52b" +checksum = "ded13e388a81713db6919cd750e6113acf2fe5afbaedf8aff79780ec4fc47425" dependencies = [ "futures 0.3.28", "one_err", @@ -2189,9 +2189,9 @@ dependencies = [ [[package]] name = "hdi" -version = "0.2.3" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c3ec758c7f6a2adc57336caebc38ee86a07349ae622f58dacdc65645957f2c9" +checksum = "827278f012619c217651eeb18ad3744949d63785cc22ee206d89cc200712b37a" dependencies = [ "hdk_derive", "holo_hash", @@ -2206,9 +2206,9 @@ dependencies = [ [[package]] name = "hdk" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41155c2019be0cbad493ba092aff02002c304d09f0750e4a7bc363f472b8fd14" +checksum = "3219fdb85fe2e16800c89e5a6555f3849279b8ecef902cb81f3b57ac6c1ed6da" dependencies = [ "getrandom 0.2.10", "hdi", @@ -2226,9 +2226,9 @@ dependencies = [ [[package]] name = "hdk_derive" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5781d5b09f0229edadff38be6efc4c549384b7a711dc3e8f78c3f84002d8b7b2" +checksum = "f8da5340b0b193bd3630f5ba0324264876cbb65994b494b445660d401fca37d7" dependencies = [ "darling 0.14.4", "heck 0.4.1", @@ -2278,9 +2278,9 @@ checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" [[package]] name = "holo_hash" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df56e386a660feed3ab6db81be49918b7bc080979b48b1d4e6e19405feb6b651" +checksum = "0f9e35b124c78454bb311a660fc0ea1f330534b2960868fe65a9eb6e0c813057" dependencies = [ "arbitrary", "base64 0.13.1", @@ -2300,9 +2300,9 @@ dependencies = [ [[package]] name = "holochain" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b8868e8bfa5501c8a98c98e1a96c06f9b94c6295456c4dca1bfd96f744732b8" +checksum = "c875fa91e08e2e0b8c7478bf8275d6b5e04e864d491ca09d87d6f4ecc1dfb357" dependencies = [ "anyhow", "async-recursion", @@ -2385,9 +2385,9 @@ dependencies = [ [[package]] name = "holochain_cascade" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30b9ca60ed5b7ec8ce9e96fd058cd088ce5dcd94b3044915003ae06ade69b2e7" +checksum = "1637d41d2d4b7f7b41db063c883a749c90b710244d079e0d8a9cc24cb7c19506" dependencies = [ "async-trait", "derive_more", @@ -2418,9 +2418,9 @@ dependencies = [ [[package]] name = "holochain_conductor_api" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "144f16f4c7f730165ee685bab31d4ef51781591720112c63160753e1a23c2edb" +checksum = "ba67465b2faf6971a2bf978d5179957e877db0e160ac4a1f131e08c38bac803e" dependencies = [ "derive_more", "directories", @@ -2443,9 +2443,9 @@ dependencies = [ [[package]] name = "holochain_integrity_types" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f733f35118d450fdc165c097d8434224624e6a3ff18b49675be4a452149af04e" +checksum = "98f2a705ddf33a9cba6336ad1f40e662ea04e88023b8b9bed78a82e564b7000d" dependencies = [ "arbitrary", "holo_hash", @@ -2460,9 +2460,9 @@ dependencies = [ [[package]] name = "holochain_keystore" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "237842d444203febaffcde106c4e22168b569b697199c7430229ab4a888d013d" +checksum = "f854547b14923d5ca4d9b2a9291858df8d735d6c904a6a0613d11a37d2399b83" dependencies = [ "base64 0.13.1", "futures 0.3.28", @@ -2486,9 +2486,9 @@ dependencies = [ [[package]] name = "holochain_p2p" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e37d67250268a518dd55d320207a8a7ef0d47f88eb0d7a5468c4df5b168d86c" +checksum = "b095a5707e4a45bef2bfd13ff106822e98be7e21fd8fc40e87f82a7664d9c8bd" dependencies = [ "async-trait", "derive_more", @@ -2532,6 +2532,7 @@ dependencies = [ "holochain_util", "ignore", "include_dir", + "itertools 0.10.5", "json_value_merge", "mr_bundle", "path-clean", @@ -2607,9 +2608,9 @@ dependencies = [ [[package]] name = "holochain_sqlite" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b0478997b700ab1c98cd990336386c8b78c6a61c6c587269598babf58afa553" +checksum = "ae7f79b4e86b71ff73f2faa327830d43f156068dfce8b4cd13977af10ec6f1d3" dependencies = [ "anyhow", "async-trait", @@ -2658,9 +2659,9 @@ dependencies = [ [[package]] name = "holochain_state" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39da384cbf8ca1da473eb7ed5365e643e0018497cf68c7393da9254d46fa43c3" +checksum = "0401373ae16938b3102f802f6970978ee24fda34865fa6f6da5add2ea4f478cc" dependencies = [ "async-recursion", "base64 0.13.1", @@ -2700,9 +2701,9 @@ dependencies = [ [[package]] name = "holochain_test_wasm_common" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20c27abb2b4f79f0bdffa081cae3f64b722067c5612e18d9a0cab8e4352a3c9d" +checksum = "85d6f7ddee3dbe51b395d4c5c973933546cd3c9d9e7c956c6637fdc3e366fcb7" dependencies = [ "hdk", "serde", @@ -2710,9 +2711,9 @@ dependencies = [ [[package]] name = "holochain_types" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1dbb009ac2cebed3e0c216fc0ccb9d2d5c6ee31fcd7017617ff8411d6fb7a700" +checksum = "9fc1bbebd6204ae58879292e170a6196310a4d10472db4f49448e42a45587062" dependencies = [ "anyhow", "arbitrary", @@ -2765,9 +2766,9 @@ dependencies = [ [[package]] name = "holochain_util" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08c5ef241a2112529e041c2efec8ced3a7e0cbdbce4e987099172fb2a857aa3f" +checksum = "707f83ccf7d23e8b2ed88a2d866d91a98a654fbcf2c696887a0b838aac620264" dependencies = [ "backtrace", "cfg-if 0.1.10", @@ -2783,9 +2784,9 @@ dependencies = [ [[package]] name = "holochain_wasm_test_utils" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "176e6f1545fe86c407b95b22f309d29d4cbfe7643e302b7ebc388a6324452106" +checksum = "91d20bf6c75b4ba1027417e2b431d6a23ab368dfa3a3f4fe8c0872307493a830" dependencies = [ "holochain_types", "holochain_util", @@ -2843,9 +2844,9 @@ dependencies = [ [[package]] name = "holochain_websocket" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fbb14b20e79dd2ddefbbd3f64477e8d5dea7b095c58b3ed469987dec3ba3b08" +checksum = "aa8c5ccdf53a0010042f11fc28e152ccd46990fc24f2558b7a2181eeb0bcfbb5" dependencies = [ "futures 0.3.28", "ghost_actor 0.4.0-alpha.5", @@ -2868,9 +2869,9 @@ dependencies = [ [[package]] name = "holochain_zome_types" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29048ce963a001f672cbf5a1269a148fa2e0ab2f7c5cad58bb8d1c9968097041" +checksum = "e8f8b6797950868e2d919fd78a1677bfcc6325fbcb9399eb4a3b1eae35ed8f0c" dependencies = [ "arbitrary", "contrafact", @@ -3402,9 +3403,9 @@ dependencies = [ [[package]] name = "kitsune_p2p" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "646cc0379a2ed7529f09f3dae5aaa8c1a303ccf358b608b1b31661339b51ce4f" +checksum = "359ebd0d99020fd57f851e8a8ac800a454c93db5749ab5a0186dbf7bd79a33b2" dependencies = [ "arbitrary", "arrayref", @@ -3446,9 +3447,9 @@ dependencies = [ [[package]] name = "kitsune_p2p_dht" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b34bbe2d79872fbc9044b173dbb5927f410bf556df4f8fb182ceec3916a7b814" +checksum = "4b9d0233e9fe77979670dc2671fc0f53eac0b51e0a4b5c31d51cb589bb6fdc0d" dependencies = [ "colored", "derivative", @@ -3470,9 +3471,9 @@ dependencies = [ [[package]] name = "kitsune_p2p_dht_arc" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "393459f0d302ef9abbf80271174b5899737400efa5554a52b0883ae787be2489" +checksum = "b915373da861a9e582e7faef29ff51bee0e410e105756e9f41fc5920c2590287" dependencies = [ "derive_more", "gcollections", @@ -3484,9 +3485,9 @@ dependencies = [ [[package]] name = "kitsune_p2p_fetch" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82eaafc477b3f8f336f08fcaf52882c38dd3d78458864c852bd9042875f704d7" +checksum = "807666b9844769757369d8a2071b1648eb6148da0eae7160fe75ef8cc8918bdd" dependencies = [ "derive_more", "futures 0.3.28", @@ -3504,9 +3505,9 @@ dependencies = [ [[package]] name = "kitsune_p2p_mdns" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a563ae2f9b61e11ada532ab6e5379bb4fc9d965b79a4793e2cfb3c9610c870d2" +checksum = "28c7a5642525d40d98f274b1a1a5d7fb453828da76f3e1f18c9734e1a81e4f37" dependencies = [ "async-stream", "base64 0.13.1", @@ -3521,9 +3522,9 @@ dependencies = [ [[package]] name = "kitsune_p2p_proxy" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d2c0abf2abc852f6e668a3a6daae208df67a6a2e7fa3d6f22c085a8020fb386" +checksum = "3aedb9455aa171a9b453f50e4b0c27398ecab4d7903bc5bf357bdb07bc226cf9" dependencies = [ "base64 0.13.1", "blake2b_simd 0.5.11", @@ -3546,9 +3547,9 @@ dependencies = [ [[package]] name = "kitsune_p2p_timestamp" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e546f28741482c3a50e75f25f78b712fb2840dff20b17f194231d19cfe23424" +checksum = "0a4b591a6e0b5f3474b90978c795b07be7ca55576a83e49bc9d0888de8b3d155" dependencies = [ "arbitrary", "chrono", @@ -3559,9 +3560,9 @@ dependencies = [ [[package]] name = "kitsune_p2p_transport_quic" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5999a8af746ebee7b0f3954ef9fc3b7b61c13309916a95276e763283be9531f" +checksum = "edd569adbfb4fc4ede92a12be2b3f2fdf86b73a3841d70f6d7c091903acf0649" dependencies = [ "blake2b_simd 1.0.1", "futures 0.3.28", @@ -3579,9 +3580,9 @@ dependencies = [ [[package]] name = "kitsune_p2p_types" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a632abb5fc16d59d8b6b6faf772c92986bbd039d0e13c2cbd7b493f746e2a145" +checksum = "e284f88fec35889f9bd2ebd0e4f7eefa849741d3d5f8af30a6cd78a83cb63aa6" dependencies = [ "arbitrary", "base64 0.13.1", @@ -3624,9 +3625,9 @@ dependencies = [ [[package]] name = "lair_keystore" -version = "0.2.4" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d453c328fa04779277f6f4b8e4a71f2bd20e0f0566cb837e6f800bc58777e4a8" +checksum = "843c7dbcbc8d75eef0b30397a7eb0d04549aabeff4ea69ebd272aea991555746" dependencies = [ "lair_keystore_api", "pretty_assertions 1.4.0", @@ -3640,9 +3641,9 @@ dependencies = [ [[package]] name = "lair_keystore_api" -version = "0.2.4" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b379baacc103ee1939976fb8f32e6b8ae887a245fbde78bf1ef95e95b3035216" +checksum = "5829f25d0eab6309ae4307aa645f123a64e568a41ec17c358dcbd65dec207e10" dependencies = [ "base64 0.13.1", "dunce", @@ -3655,6 +3656,7 @@ dependencies = [ "serde", "serde_json", "serde_yaml 0.9.25", + "time 0.3.23", "tokio 1.31.0", "toml 0.5.11", "toml 0.7.6", @@ -4086,9 +4088,9 @@ checksum = "7843ec2de400bcbc6a6328c958dc38e5359da6e93e72e37bc5246bf1ae776389" [[package]] name = "mr_bundle" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c67909e9551fd2c5048661e9a73e0161ae40f1589758fb7d297ae7de97606076" +checksum = "efa038132eb233edfa394c0f0667a9cda4aca984f9011eff0214bca0785a4afc" dependencies = [ "arbitrary", "bytes 1.4.0", @@ -5988,9 +5990,9 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.183" +version = "1.0.166" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32ac8da02677876d532745a130fc9d8e6edfa81a269b107c5b00829b91d8eb3c" +checksum = "d01b7404f9d441d3ad40e6a636a7782c377d2abdbe4fa2440e2edcc2f4f10db8" dependencies = [ "serde_derive", ] @@ -6015,9 +6017,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.183" +version = "1.0.166" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aafe972d60b0b9bee71a91b92fee2d4fb3c9d7e8f6b179aa99f27203d99a4816" +checksum = "5dd83d6dde2b6b2d466e14d9d1acce8816dedee94f735eac6395808b3483c6d6" dependencies = [ "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index e3d4c1f9a..d8bc3ddba 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,10 +18,10 @@ name = "holochain_scaffolding_cli" path = "src/lib.rs" [dependencies] -holochain = {version = "0.1.5", features = ["test_utils"] } -holochain_types = "0.1.5" -holochain_util = { features = ["backtrace"], version = "0.1.1" } -mr_bundle = "0.1.1" +holochain = {version = "0.1.6", features = ["test_utils"] } +holochain_types = "0.1.6" +holochain_util = { features = ["backtrace"], version = "0.1.2" } +mr_bundle = "0.1.2" dirs = "4.0.0" ignore = "0.4" @@ -52,6 +52,7 @@ serde = "1" json_value_merge = "1.1.2" temp-dir = "0.1" semver = "1.0" +itertools = "0.10" [dev-dependencies] assert_cmd = "1.0" diff --git a/README.md b/README.md index 4c8d51193..3e7a14a54 100644 --- a/README.md +++ b/README.md @@ -7,15 +7,16 @@ CLI to easily generate and edit holochain apps. The easiest way to start using the scaffolding tool is through holonix: ```bash -nix-shell https://holochain.love -hc-scaffold --version +nix run github:holochain/holochain#hc-scaffold -- --version ``` Should print the version of the scaffolding tool. ## Usage -These are the commands that you can run with the scaffolding tool: +Refer to [the holochain developer instructions](https://developer.holochain.org/get-building/) to know how you can use the scaffolding tool to create your own apps. + +These are the commands that you can run with the scaffolding tool inside of a holonix develop shell: ```bash # Scaffold an example app diff --git a/flake.lock b/flake.lock index 945d5aae0..0242c60b8 100644 --- a/flake.lock +++ b/flake.lock @@ -196,6 +196,7 @@ "nix-filter": "nix-filter", "nixpkgs": "nixpkgs", "pre-commit-hooks-nix": "pre-commit-hooks-nix", + "repo-git": "repo-git", "rust-overlay": "rust-overlay_2", "scaffolding": [ "holochain", @@ -206,11 +207,11 @@ ] }, "locked": { - "lastModified": 1686327384, - "narHash": "sha256-V45ExUHvCS0x/+fBJYcUQY0LuwuM6g01XtgrR7q0po4=", + "lastModified": 1693421895, + "narHash": "sha256-hQpaccN0Hn4AAZM3zLzqkCjjC3o/i6so9RLF426fvsE=", "owner": "holochain", "repo": "holochain", - "rev": "10c6a62d4375cbdedef006f09afd29fa603ef5c6", + "rev": "997962fc9246e33643ee33cfc1fc44db21afb53e", "type": "github" }, "original": { @@ -222,16 +223,16 @@ "holochain_2": { "flake": false, "locked": { - "lastModified": 1686257124, - "narHash": "sha256-SvXGHOr96ob/NfQCeVJ2J4LWc83qkZn+/pnE9qVNB+I=", + "lastModified": 1692965835, + "narHash": "sha256-tylLGAliWQnnYjTdjTN8N7xxlcHgso085wkQ8NgmOpI=", "owner": "holochain", "repo": "holochain", - "rev": "db5b8b27da3bf296958c3bf54ac3950dc60a39c8", + "rev": "6d424d347d5296bc8e92ff5233f5a6ed22ed736f", "type": "github" }, "original": { "owner": "holochain", - "ref": "holochain-0.1.5", + "ref": "holochain-0.1.6", "repo": "holochain", "type": "github" } @@ -239,16 +240,16 @@ "lair": { "flake": false, "locked": { - "lastModified": 1682356264, - "narHash": "sha256-5ZYJ1gyyL3hLR8hCjcN5yremg8cSV6w1iKCOrpJvCmc=", + "lastModified": 1691746070, + "narHash": "sha256-CHsTI4yIlkfnYWx2sNgzAoDBvKTLIChybzyJNbB1sMU=", "owner": "holochain", "repo": "lair", - "rev": "43be404da0fd9d57bf4429c44def405bd6490f61", + "rev": "6ab41b60744515f1760669db6fc5272298a5f324", "type": "github" }, "original": { "owner": "holochain", - "ref": "lair_keystore-v0.2.4", + "ref": "lair_keystore-v0.3.0", "repo": "lair", "type": "github" } @@ -287,11 +288,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1686226982, - "narHash": "sha256-nLuiPoeiVfqqzeq9rmXxpybh77VS37dsY/k8N2LoxVg=", + "lastModified": 1686869522, + "narHash": "sha256-tbJ9B8WLCTnVP/LwESRlg0dII6Zyg2LmUU/mB9Lu98E=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "a64b73e07d4aa65cfcbda29ecf78eaf9e72e44bd", + "rev": "7c67f006ea0e7d0265f16d7df07cc076fdffd91f", "type": "github" }, "original": { @@ -334,6 +335,18 @@ "type": "github" } }, + "repo-git": { + "flake": false, + "locked": { + "narHash": "sha256-d6xi4mKdjkX2JFicDIv5niSzpyI0m/Hnm8GGAIU04kY=", + "type": "file", + "url": "file:/dev/null" + }, + "original": { + "type": "file", + "url": "file:/dev/null" + } + }, "root": { "inputs": { "holochain": "holochain", @@ -380,11 +393,11 @@ ] }, "locked": { - "lastModified": 1686277999, - "narHash": "sha256-Lko8PiXN8ecQSlFsn/7V5fyoUtb1H5zyMpe73hLmSis=", + "lastModified": 1693361441, + "narHash": "sha256-TRFdMQj9wSKMduNqe/1xF8TzcPWEdcn/hKWcVcZ5fO8=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "f46177d472fc5b754fd5ad382ae8a31a10979750", + "rev": "1fb2aa49635e9f30b6fa211ab7c454f7175e1ba3", "type": "github" }, "original": { @@ -396,11 +409,11 @@ "scaffolding": { "flake": false, "locked": { - "lastModified": 1683703271, - "narHash": "sha256-/oJnzkTwHlvVIU3AoWOu4w5mZyNw30t/6vHkQS0TdnQ=", + "lastModified": 1692137048, + "narHash": "sha256-YfW4pthiUXJbP0ribr0fvCo9P/cB7xfhpB8MwfQ/JLI=", "owner": "holochain", "repo": "scaffolding", - "rev": "264c13aecfec3bf284717538ff304cbf570a3fcd", + "rev": "104a269d91c8935ded04c44f950b055b0ad39f94", "type": "github" }, "original": { @@ -434,11 +447,11 @@ }, "locked": { "dir": "versions/0_1", - "lastModified": 1686327384, - "narHash": "sha256-V45ExUHvCS0x/+fBJYcUQY0LuwuM6g01XtgrR7q0po4=", + "lastModified": 1693421895, + "narHash": "sha256-hQpaccN0Hn4AAZM3zLzqkCjjC3o/i6so9RLF426fvsE=", "owner": "holochain", "repo": "holochain", - "rev": "10c6a62d4375cbdedef006f09afd29fa603ef5c6", + "rev": "997962fc9246e33643ee33cfc1fc44db21afb53e", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 6770e1d3b..e51588487 100644 --- a/flake.nix +++ b/flake.nix @@ -26,8 +26,7 @@ }: { devShells.default = pkgs.mkShell { inputsFrom = [ inputs.holochain.devShells.${system}.holonix ]; - # TODO: remove sqlite package once https://github.com/holochain/holochain/pull/2248 is released - packages = [ pkgs.nodejs-18_x pkgs.sqlite ]; + packages = [ pkgs.nodejs-18_x ]; }; }; }; diff --git a/run_test.sh b/run_test.sh index d6a36c858..ef0e8788a 100644 --- a/run_test.sh +++ b/run_test.sh @@ -1,6 +1,18 @@ #!/usr/bin/bash set -e +rm -rf /tmp/hello-world +cd /tmp + +hc-scaffold example hello-world +cd hello-world + +nix develop --command bash -c " +set -e +npm i +npm t +" + rm -rf /tmp/forum-svelte cd /tmp diff --git a/src/cli.rs b/src/cli.rs index 65c0b4616..5d8143bdd 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -1,7 +1,5 @@ use crate::error::{ScaffoldError, ScaffoldResult}; -use crate::file_tree::{ - dir_content, file_content, insert_file, load_directory_into_memory, FileTree, -}; +use crate::file_tree::{dir_content, file_content, load_directory_into_memory, FileTree}; use crate::scaffold::app::cargo::exec_metadata; use crate::scaffold::app::nix::setup_nix_developer_environment; use crate::scaffold::app::AppFileTree; @@ -72,6 +70,9 @@ pub enum HcScaffold { /// If "--templates-url" is given, the template must be located at the ".templates/" folder of the repository /// If not, the template must be an option from the built-in templates: "vanilla", "vue", "lit", "svelte" template: Option, + + #[structopt(long = "holo", hidden = true)] + holo_enabled: bool, }, /// Set up the template used in this project Template(HcScaffoldTemplate), @@ -228,6 +229,7 @@ impl HcScaffold { template, templates_url, templates_path, + holo_enabled, } => { let prompt = String::from("App name (no whitespaces):"); let name: String = match name { @@ -305,6 +307,7 @@ impl HcScaffold { &template_file_tree, template_name, scaffold_template, + holo_enabled, )?; let file_tree = MergeableFileSystemTree::::from(dir! { @@ -733,69 +736,7 @@ Collection "{}" scaffolded! &template_file_tree, template_name.clone(), false, - )?; - - // scaffold dna hello_world - let dna_name = String::from("hello_world"); - - let app_file_tree = - AppFileTree::get_or_choose(file_tree, &Some(name.clone()))?; - let ScaffoldedTemplate { file_tree, .. } = - scaffold_dna(app_file_tree, &template_file_tree, &dna_name)?; - - // scaffold integrity zome hello_world - let dna_file_tree = - DnaFileTree::get_or_choose(file_tree, &Some(dna_name.clone()))?; - let dna_manifest_path = dna_file_tree.dna_manifest_path.clone(); - - let integrity_zome_name = String::from("hello_world_integrity"); - let integrity_zome_path = PathBuf::new() - .join("dnas") - .join(&dna_name) - .join("zomes") - .join("integrity"); - let ScaffoldedTemplate { file_tree, .. } = - scaffold_integrity_zome_with_path( - dna_file_tree, - &template_file_tree, - &integrity_zome_name, - &integrity_zome_path, - )?; - - // scaffold integrity zome hello_world - let dna_file_tree = - DnaFileTree::from_dna_manifest_path(file_tree, &dna_manifest_path)?; - - let coordinator_zome_name = String::from("hello_world"); - let coordinator_zome_path = PathBuf::new() - .join("dnas") - .join(dna_name) - .join("zomes") - .join("coordinator"); - let ScaffoldedTemplate { mut file_tree, .. } = - scaffold_coordinator_zome_in_path( - dna_file_tree, - &template_file_tree, - &coordinator_zome_name, - &Some(vec![integrity_zome_name]), - &coordinator_zome_path, - )?; - - // Add "hello_world" function to coordinator - let hello_world_zome = format!( - r#"use hdk::prelude::*; - -#[hdk_extern] -pub fn hello_world(_: ()) -> ExternResult {{ - Ok(String::from("hello world from a Holochain app!")) -}} -"# - ); - - insert_file( - &mut file_tree, - &coordinator_zome_path.join("hello_world/src/lib.rs"), - &hello_world_zome, + false, )?; file_tree @@ -809,6 +750,7 @@ pub fn hello_world(_: ()) -> ExternResult {{ &template_file_tree, template_name.clone(), false, + false, )?; // scaffold dna hello_world diff --git a/src/reserved_words.rs b/src/reserved_words.rs index eb0470f91..d526a98a8 100644 --- a/src/reserved_words.rs +++ b/src/reserved_words.rs @@ -2,7 +2,7 @@ use convert_case::{Case, Casing}; use crate::error::{ScaffoldError, ScaffoldResult}; -const RESERVED_WORDS: [&str; 26] = [ +const RESERVED_WORDS: [&str; 27] = [ "type", "role", "enum", @@ -29,6 +29,7 @@ const RESERVED_WORDS: [&str; 26] = [ "EntryHash", "ActionHash", "AgentPubKey", + "Call", ]; // Returns an error if the given string is invalid due to it being a reserved word diff --git a/src/scaffold/entry_type.rs b/src/scaffold/entry_type.rs index c4b040eb8..4fc148bf7 100644 --- a/src/scaffold/entry_type.rs +++ b/src/scaffold/entry_type.rs @@ -208,10 +208,10 @@ pub fn scaffold_entry_type( )?; } - let zome_file_tree = + let mut zome_file_tree = ZomeFileTree::from_zome_manifest(zome_file_tree.dna_file_tree, coordinator_zome.clone())?; - let zome_file_tree = add_crud_functions_to_coordinator( + zome_file_tree = add_crud_functions_to_coordinator( zome_file_tree, &integrity_zome_name, &entry_def, diff --git a/src/scaffold/entry_type/fields.rs b/src/scaffold/entry_type/fields.rs index 0a347be57..329647a0a 100644 --- a/src/scaffold/entry_type/fields.rs +++ b/src/scaffold/entry_type/fields.rs @@ -220,7 +220,9 @@ pub fn choose_field( let maybe_linked_from = match &field_type { FieldType::AgentPubKey => { let link_from = Confirm::with_theme(&ColorfulTheme::default()) - .with_prompt("Should a link from this field be created when this entry is created?") + .with_prompt( + "Should a link from the AgentPubKey provided in this field also be created when entries of this type are created?" + ) .interact()?; match link_from { @@ -234,55 +236,51 @@ pub fn choose_field( } } FieldType::ActionHash | FieldType::EntryHash => { - let all_entry_types = get_all_entry_types(zome_file_tree)?.unwrap_or(vec![]); - if all_entry_types.len() == 0 { - None - } else { - let link_from = Confirm::with_theme(&ColorfulTheme::default()) + let link_from = Confirm::with_theme(&ColorfulTheme::default()) .with_prompt( - "Should a link from this field be created when this entry is created?", + format!( + "Should a link from the {} provided in this field also be created when entries of this type are created?", + field_type.to_string()) ) .interact()?; - match link_from { - false => None, - true => { - let mut all_options: Vec = all_entry_types - .clone() - .into_iter() - .map(|r| r.entry_type) - .collect(); - - if let Cardinality::Option | Cardinality::Vector = cardinality { - all_options.push(format!( - "{} (itself)", - entry_type_name.to_case(Case::Pascal) - )); - } - - let selection = Select::with_theme(&ColorfulTheme::default()) - .with_prompt(String::from( - "Which entry type is this field referring to?", - )) - .default(0) - .items(&all_options[..]) - .interact()?; - - let reference_entry_hash = match field_type { - FieldType::EntryHash => true, - _ => false, - }; - - match selection == all_entry_types.len() { - true => Some(Referenceable::EntryType(EntryTypeReference { - entry_type: entry_type_name.clone(), - reference_entry_hash, - })), - false => Some(Referenceable::EntryType(EntryTypeReference { - entry_type: all_entry_types[selection].entry_type.clone(), - reference_entry_hash, - })), - } + match link_from { + false => None, + true => { + let all_entry_types = get_all_entry_types(zome_file_tree)?.unwrap_or(vec![]); + let mut all_options: Vec = all_entry_types + .clone() + .into_iter() + .map(|r| r.entry_type) + .collect(); + + if let Cardinality::Option | Cardinality::Vector = cardinality { + all_options.push(format!( + "{} (itself)", + entry_type_name.to_case(Case::Pascal) + )); + } + + let selection = Select::with_theme(&ColorfulTheme::default()) + .with_prompt(String::from("Which entry type is this field referring to?")) + .default(0) + .items(&all_options[..]) + .interact()?; + + let reference_entry_hash = match field_type { + FieldType::EntryHash => true, + _ => false, + }; + + match selection == all_entry_types.len() { + true => Some(Referenceable::EntryType(EntryTypeReference { + entry_type: entry_type_name.clone(), + reference_entry_hash, + })), + false => Some(Referenceable::EntryType(EntryTypeReference { + entry_type: all_entry_types[selection].entry_type.clone(), + reference_entry_hash, + })), } } } diff --git a/src/scaffold/entry_type/integrity.rs b/src/scaffold/entry_type/integrity.rs index bbb5d2e84..a3612a301 100644 --- a/src/scaffold/entry_type/integrity.rs +++ b/src/scaffold/entry_type/integrity.rs @@ -1,5 +1,5 @@ use convert_case::{Case, Casing}; -use holochain::test_utils::itertools::Itertools; +use itertools::Itertools; use proc_macro2::TokenStream; use quote::{format_ident, quote}; use std::{ffi::OsString, path::PathBuf}; diff --git a/src/scaffold/link_type/integrity.rs b/src/scaffold/link_type/integrity.rs index 15479e378..759630ade 100644 --- a/src/scaffold/link_type/integrity.rs +++ b/src/scaffold/link_type/integrity.rs @@ -1,7 +1,7 @@ use std::{ffi::OsString, path::PathBuf}; use convert_case::{Case, Casing}; -use holochain::test_utils::itertools::Itertools; +use itertools::Itertools; use proc_macro2::TokenStream; use quote::{format_ident, quote}; @@ -425,15 +425,18 @@ fn signal_link_types_variants() -> ScaffoldResult> { fn signal_action_match_arms() -> ScaffoldResult> { Ok(vec![ - syn::parse_str::("Action::CreateLink(create_link) => { + syn::parse_str::( + "Action::CreateLink(create_link) => { if let Ok(Some(link_type)) = LinkTypes::from_type(create_link.zome_index, create_link.link_type) { emit_signal(Signal::LinkCreated { action, link_type })?; } Ok(()) - }")?, - syn::parse_str::("Action::DeleteLink(delete_link) => { + }", + )?, + syn::parse_str::( + "Action::DeleteLink(delete_link) => { let record = get(delete_link.link_add_address.clone(), GetOptions::default())?.ok_or( wasm_error!(WasmErrorInner::Guest( \"Failed to fetch CreateLink action\".to_string() @@ -454,7 +457,8 @@ fn signal_action_match_arms() -> ScaffoldResult> { ))); } } - }")? + }", + )?, ]) } diff --git a/src/scaffold/web_app.rs b/src/scaffold/web_app.rs index 4afb1ab2c..65ec37020 100644 --- a/src/scaffold/web_app.rs +++ b/src/scaffold/web_app.rs @@ -23,6 +23,7 @@ fn web_app_skeleton( template_file_tree: &FileTree, template_name: String, scaffold_template: bool, + holo_enabled: bool, ) -> ScaffoldResult { check_for_reserved_words(&app_name)?; @@ -53,7 +54,7 @@ fn web_app_skeleton( } let mut scaffold_template_result = - scaffold_web_app_template(app_file_tree, &template_file_tree, &app_name)?; + scaffold_web_app_template(app_file_tree, &template_file_tree, &app_name, holo_enabled)?; scaffold_template_result .file_tree @@ -71,6 +72,7 @@ pub fn scaffold_web_app( template_file_tree: &FileTree, template_name: String, scaffold_template: bool, + holo_enabled: bool, ) -> ScaffoldResult { let scaffolded_template = web_app_skeleton( app_name.clone(), @@ -79,6 +81,7 @@ pub fn scaffold_web_app( &template_file_tree, template_name, scaffold_template, + holo_enabled, )?; Ok(ScaffoldedTemplate { file_tree: scaffolded_template.file_tree, diff --git a/src/scaffold/zome/coordinator.rs b/src/scaffold/zome/coordinator.rs index 3c94172de..c00c744de 100644 --- a/src/scaffold/zome/coordinator.rs +++ b/src/scaffold/zome/coordinator.rs @@ -55,7 +55,6 @@ pub fn initial_lib_rs(dependencies: &Option>) -> String { s } }; - format!( r#"use hdk::prelude::*; {integrity_imports} diff --git a/src/templates/web_app.rs b/src/templates/web_app.rs index f3e9ccb53..aa7187d35 100644 --- a/src/templates/web_app.rs +++ b/src/templates/web_app.rs @@ -22,12 +22,14 @@ pub struct ScaffoldWebAppData { pub hdi_version: String, pub holochain_client_version: String, pub tryorama_version: String, + pub holo_enabled: bool, } pub fn scaffold_web_app_template( mut app_file_tree: FileTree, template_file_tree: &FileTree, app_name: &String, + holo_enabled: bool, ) -> ScaffoldResult { let data = ScaffoldWebAppData { app_name: app_name.clone(), @@ -36,6 +38,7 @@ pub fn scaffold_web_app_template( hdi_version: hdi_version(), holochain_client_version: holochain_client_version(), tryorama_version: tryorama_version(), + holo_enabled, }; let h = build_handlebars(template_file_tree)?; diff --git a/src/versions.rs b/src/versions.rs index 5d0e1095e..bc77dca9c 100644 --- a/src/versions.rs +++ b/src/versions.rs @@ -6,6 +6,10 @@ pub fn holochain_client_version() -> String { String::from("^0.12.2") } +pub fn web_sdk_version() -> String { + String::from("^0.6.10-prerelease") +} + pub fn hdi_version() -> String { holochain::HDI_VERSION.to_string() } diff --git a/templates/lit/web-app/package.json.hbs b/templates/lit/web-app/package.json.hbs index a7307d5a3..8aa91a451 100644 --- a/templates/lit/web-app/package.json.hbs +++ b/templates/lit/web-app/package.json.hbs @@ -10,6 +10,11 @@ "network": "hc s clean && npm run build:happ && UI_PORT=8888 concurrently \"npm start -w ui\" \"npm run launch:happ\" \"holochain-playground\"", "test": "npm run build:zomes && hc app pack workdir --recursive && npm t -w tests", "launch:happ": "echo \"pass\" | RUST_LOG=warn hc launch --piped -n $AGENTS workdir/{{app_name}}.happ --ui-port $UI_PORT network mdns", + {{#if holo_enabled}} + "start:holo": "AGENTS=2 npm run network:holo", + "network:holo": "npm run build:happ && UI_PORT=8888 concurrently \"npm run launch:holo-dev-server\" \"holochain-playground ws://localhost:4444\" \"concurrently-repeat 'VITE_APP_CHAPERONE_URL=http://localhost:24274 VITE_APP_IS_HOLO=true npm start -w ui' $AGENTS\"", + "launch:holo-dev-server": "holo-dev-server workdir/{{app_name}}.happ", + {{/if}} "package": "npm run build:happ && npm run package -w ui && hc web-app pack workdir --recursive", "build:happ": "npm run build:zomes && hc app pack workdir --recursive", "build:zomes": "RUSTFLAGS='' CARGO_TARGET_DIR=target cargo build --release --target wasm32-unknown-unknown" @@ -17,6 +22,9 @@ "devDependencies": { "@holochain-playground/cli": "^0.1.1", "concurrently": "^6.2.1", + {{#if holo_enabled}} + "concurrently-repeat": "^0.0.1", + {{/if}} "rimraf": "^3.0.2" }, "engines": { diff --git a/templates/lit/web-app/ui/package.json.hbs b/templates/lit/web-app/ui/package.json.hbs index dbbcab476..d27c18ad6 100644 --- a/templates/lit/web-app/ui/package.json.hbs +++ b/templates/lit/web-app/ui/package.json.hbs @@ -10,6 +10,9 @@ }, "dependencies": { "@holochain/client": "{{holochain_client_version}}", + {{#if holo_enabled}} + "@holo-host/web-sdk": "{{web_sdk_version}}", + {{/if}} "@lit-labs/context": "^0.2.0", "@lit-labs/task": "^2.0.0", "@material/mwc-circular-progress": "^0.27.0", diff --git a/templates/lit/web-app/ui/src/holochain-app.ts.hbs b/templates/lit/web-app/ui/src/holochain-app.ts.hbs index 56e82128e..ff9c61116 100644 --- a/templates/lit/web-app/ui/src/holochain-app.ts.hbs +++ b/templates/lit/web-app/ui/src/holochain-app.ts.hbs @@ -5,11 +5,22 @@ import { ActionHash, AppAgentClient, } from '@holochain/client'; +{{#if holo_enabled}} +import WebSdk from '@holo-host/web-sdk' +import type { AgentState } from '@holo-host/web-sdk'; +{{/if}} import { provide } from '@lit-labs/context'; import '@material/mwc-circular-progress'; +{{#if holo_enabled}} +import '@material/mwc-button'; +{{/if}} import { clientContext } from './contexts'; +{{#if holo_enabled}} +const IS_HOLO = ['true', '1', 't'].includes(import.meta.env.VITE_APP_IS_HOLO?.toLowerCase()) +{{/if}} + @customElement('holochain-app') export class HolochainApp extends LitElement { @state() loading = true; @@ -19,11 +30,41 @@ export class HolochainApp extends LitElement { client!: AppAgentClient; async firstUpdated() { + {{#if holo_enabled}} + if (IS_HOLO) { + const client = await WebSdk.connect({ + chaperoneUrl: import.meta.env.VITE_APP_CHAPERONE_URL, + authFormCustomization: { + appName: '{{app_name}}', + } + }); + + client.on('agent-state', (agent_state: AgentState) => { + this.loading = !agent_state.isAvailable || agent_state.isAnonymous; + }); + + client.signUp({ cancellable: false }); + this.client = client; + + } else { + // We pass '' as url because it will dynamically be replaced in launcher environments + this.client = await AppAgentWebsocket.connect('', '{{app_name}}'); + this.loading = false + } + {{else}} // We pass '' as url because it will dynamically be replaced in launcher environments this.client = await AppAgentWebsocket.connect('', '{{app_name}}'); this.loading = false; + {{/if}} + } + +{{#if holo_enabled}} + async logout() { + await (this.client as WebSdk).signOut(); + await (this.client as WebSdk).signIn({ cancellable: false }); } +{{/if}} render() { if (this.loading) @@ -53,6 +94,16 @@ import './todos/todos/create-todo'; Replace this "EDIT ME!" section with <create-todo></create-todo><all-todos></all-todos>. + {{#if holo_enabled}} + ${IS_HOLO ? html` + this.logout()} + > + `: ''} + {{/if}} `; } diff --git a/templates/lit/web-app/ui/tsconfig.json.hbs b/templates/lit/web-app/ui/tsconfig.json.hbs index 4914f5b25..89a6f6466 100644 --- a/templates/lit/web-app/ui/tsconfig.json.hbs +++ b/templates/lit/web-app/ui/tsconfig.json.hbs @@ -15,6 +15,9 @@ "sourceMap": true, "inlineSources": true, "incremental": true, + {{#if holo_enabled}} + "types": ["vite/client"], + {{/if}} "skipLibCheck": true }, "include": ["src/**/*.ts", "src/**/*.d.ts"] diff --git a/templates/svelte/web-app/package.json.hbs b/templates/svelte/web-app/package.json.hbs index a7307d5a3..d3b9f7b18 100644 --- a/templates/svelte/web-app/package.json.hbs +++ b/templates/svelte/web-app/package.json.hbs @@ -10,13 +10,21 @@ "network": "hc s clean && npm run build:happ && UI_PORT=8888 concurrently \"npm start -w ui\" \"npm run launch:happ\" \"holochain-playground\"", "test": "npm run build:zomes && hc app pack workdir --recursive && npm t -w tests", "launch:happ": "echo \"pass\" | RUST_LOG=warn hc launch --piped -n $AGENTS workdir/{{app_name}}.happ --ui-port $UI_PORT network mdns", + {{#if holo_enabled}} + "start:holo": "AGENTS=2 npm run network:holo", + "network:holo": "npm run build:happ && UI_PORT=8888 concurrently \"npm run launch:holo-dev-server\" \"holochain-playground ws://localhost:4444\" \"concurrently-repeat 'VITE_APP_CHAPERONE_URL=http://localhost:24274 VITE_APP_IS_HOLO=true npm start -w ui' $AGENTS\"", + "launch:holo-dev-server": "holo-dev-server workdir/{{app_name}}.happ", + {{/if}} "package": "npm run build:happ && npm run package -w ui && hc web-app pack workdir --recursive", "build:happ": "npm run build:zomes && hc app pack workdir --recursive", - "build:zomes": "RUSTFLAGS='' CARGO_TARGET_DIR=target cargo build --release --target wasm32-unknown-unknown" + "build:zomes": "RUSTFLAGS='' CARGO_TARGET_DIR=target cargo build --release --target wasm32-unknown-unknown" }, - "devDependencies": { + "devDependencies": { "@holochain-playground/cli": "^0.1.1", "concurrently": "^6.2.1", + {{#if holo_enabled}} + "concurrently-repeat": "^0.0.1", + {{/if}} "rimraf": "^3.0.2" }, "engines": { diff --git a/templates/svelte/web-app/ui/package.json.hbs b/templates/svelte/web-app/ui/package.json.hbs index 64d71c6c8..97c68ea03 100644 --- a/templates/svelte/web-app/ui/package.json.hbs +++ b/templates/svelte/web-app/ui/package.json.hbs @@ -9,6 +9,9 @@ }, "dependencies": { "@holochain/client": "{{holochain_client_version}}", + {{#if holo_enabled}} + "@holo-host/web-sdk": "{{web_sdk_version}}", + {{/if}} "@material/mwc-circular-progress": "^0.27.0", "@material/mwc-button": "^0.27.0", "@material/mwc-textfield": "^0.27.0", diff --git a/templates/svelte/web-app/ui/src/App.svelte.hbs b/templates/svelte/web-app/ui/src/App.svelte.hbs index 54d5328e4..153ae382b 100644 --- a/templates/svelte/web-app/ui/src/App.svelte.hbs +++ b/templates/svelte/web-app/ui/src/App.svelte.hbs @@ -2,19 +2,54 @@ import { onMount, setContext } from 'svelte'; import type { ActionHash, AppAgentClient } from '@holochain/client'; import { AppAgentWebsocket } from '@holochain/client'; +{{#if holo_enabled}} + import WebSdk from '@holo-host/web-sdk' +{{/if}} import '@material/mwc-circular-progress'; import { clientContext } from './contexts'; let client: AppAgentClient | undefined; - let loading = true; - $: client, loading; + let loading = true; + +{{#if holo_enabled}} + const IS_HOLO = ['true', '1', 't'].includes(import.meta.env.VITE_APP_IS_HOLO?.toLowerCase()) + + const logout = async () => { + await (client as WebSdk).signOut(); + (client as WebSdk).signIn({ cancellable: false }) + } +{{/if}} onMount(async () => { + {{#if holo_enabled}} + if (IS_HOLO) { + client = await WebSdk.connect({ + chaperoneUrl: import.meta.env.VITE_APP_CHAPERONE_URL, + authFormCustomization: { + appName: '{{app_name}}', + } + }); + + (client as WebSdk).on('agent-state', agent_state => { + loading = !agent_state.isAvailable || agent_state.isAnonymous + }); + + (client as WebSdk).signUp({ cancellable: false }); + + } else { + // We pass '' as url because it will dynamically be replaced in launcher environments + client = await AppAgentWebsocket.connect('', '{{app_name}}'); + + loading = false; + } + {{else}} // We pass '' as url because it will dynamically be replaced in launcher environments client = await AppAgentWebsocket.connect('', '{{app_name}}'); + loading = false; + {{/if}} }); setContext(clientContext, { @@ -46,6 +81,16 @@ import CreateTodo from './todos/todos/CreateTodo.svelte'; Replace this "EDIT ME!" section with <CreateTodo></CreateTodo><AllTodos></AllTodos>. + {{#if holo_enabled}} + {#if IS_HOLO} + logout()} + /> + {/if} + {{/if}} {/if} diff --git a/templates/vanilla/example/Cargo.toml.hbs b/templates/vanilla/example/Cargo.toml.hbs new file mode 100644 index 000000000..faf36abe9 --- /dev/null +++ b/templates/vanilla/example/Cargo.toml.hbs @@ -0,0 +1,19 @@ +[profile.dev] +opt-level = "z" + +[profile.release] +opt-level = "z" + +[workspace] +members = ["dnas/*/zomes/coordinator/*", "dnas/*/zomes/integrity/*"] + +[workspace.dependencies] +hdi = "=0.2.4" +hdk = "=0.1.4" +serde = "1" + +[workspace.dependencies.hello_world] +path = "dnas/hello_world/zomes/coordinator/hello_world" + +[workspace.dependencies.hello_world_integrity] +path = "dnas/hello_world/zomes/integrity/hello_world" diff --git a/templates/vanilla/example/dnas/hello_world/workdir/dna.yaml.hbs b/templates/vanilla/example/dnas/hello_world/workdir/dna.yaml.hbs new file mode 100644 index 000000000..19f9e661d --- /dev/null +++ b/templates/vanilla/example/dnas/hello_world/workdir/dna.yaml.hbs @@ -0,0 +1,19 @@ +--- +manifest_version: "1" +name: hello_world +integrity: + network_seed: ~ + properties: ~ + origin_time: 1679601731282690 + zomes: + - name: hello_world_integrity + hash: ~ + bundled: "../../../target/wasm32-unknown-unknown/release/hello_world_integrity.wasm" + dependencies: ~ +coordinator: + zomes: + - name: hello_world + hash: ~ + bundled: "../../../target/wasm32-unknown-unknown/release/hello_world.wasm" + dependencies: + - name: hello_world_integrity diff --git a/templates/vanilla/example/dnas/hello_world/zomes/coordinator/hello_world/Cargo.toml.hbs b/templates/vanilla/example/dnas/hello_world/zomes/coordinator/hello_world/Cargo.toml.hbs new file mode 100644 index 000000000..3cee1e254 --- /dev/null +++ b/templates/vanilla/example/dnas/hello_world/zomes/coordinator/hello_world/Cargo.toml.hbs @@ -0,0 +1,15 @@ +[package] +name = "hello_world" +version = "0.0.1" +edition = "2021" + +[lib] +crate-type = ["cdylib", "rlib"] +name = "hello_world" + +[dependencies] +hdk = { workspace = true } + +serde = { workspace = true } + +hello_world_integrity = { workspace = true } diff --git a/templates/vanilla/example/dnas/hello_world/zomes/coordinator/hello_world/src/lib.rs.hbs b/templates/vanilla/example/dnas/hello_world/zomes/coordinator/hello_world/src/lib.rs.hbs new file mode 100644 index 000000000..03fd3e35b --- /dev/null +++ b/templates/vanilla/example/dnas/hello_world/zomes/coordinator/hello_world/src/lib.rs.hbs @@ -0,0 +1,59 @@ +use hdk::prelude::*; +use hello_world_integrity::*; + +#[hdk_extern] +pub fn hello_world(message:String) -> ExternResult { + + // commit the Hello message + let action_hash = create_entry(&EntryTypes::Hello(Hello{message}))?; + + // link it to an anchor for later retrieval + let path = Path::from("hellos"); + create_link( + path.path_entry_hash()?, + action_hash.clone(), + LinkTypes::AllHellos, + (), + )?; + Ok(action_hash) +} + +#[derive(Serialize, Deserialize, Debug)] +pub struct HelloOutput { + pub message: String, + pub author: AgentPubKey +} + +#[hdk_extern] +pub fn get_hellos(_: ()) -> ExternResult> { + + // get all of the hellos linked to the anachor + let path = Path::from("hellos"); + let links = get_links(path.path_entry_hash()?, LinkTypes::AllHellos, None)?; + let get_input: Vec = links + .into_iter() + .map(|link| GetInput::new( + ActionHash::from(link.target).into(), + GetOptions::default(), + )) + .collect(); + + // load the records for all the links + let records = HDK.with(|hdk| hdk.borrow().get(get_input))?; + let records: Vec = records.into_iter().filter_map(|r| r).collect(); + + // convert the records into a usefull struct for the UI + let mut hellos = Vec::new(); + for r in records { + let maybe_hello: Option = r.entry.to_app_option().map_err(|e| wasm_error!(e))?; + if let Some(hello) = maybe_hello { + hellos.push( + HelloOutput { + message:hello.message, + author: r.action().author().clone(), + } + ) + } + } + Ok(hellos) +} diff --git a/templates/vanilla/example/dnas/hello_world/zomes/integrity/hello_world/Cargo.toml.hbs b/templates/vanilla/example/dnas/hello_world/zomes/integrity/hello_world/Cargo.toml.hbs new file mode 100644 index 000000000..ce8f18dd4 --- /dev/null +++ b/templates/vanilla/example/dnas/hello_world/zomes/integrity/hello_world/Cargo.toml.hbs @@ -0,0 +1,13 @@ +[package] +name = "hello_world_integrity" +version = "0.0.1" +edition = "2021" + +[lib] +crate-type = ["cdylib", "rlib"] +name = "hello_world_integrity" + +[dependencies] +hdi = { workspace = true } + +serde = { workspace = true } diff --git a/templates/vanilla/example/dnas/hello_world/zomes/integrity/hello_world/src/lib.rs.hbs b/templates/vanilla/example/dnas/hello_world/zomes/integrity/hello_world/src/lib.rs.hbs new file mode 100644 index 000000000..03c00c7f2 --- /dev/null +++ b/templates/vanilla/example/dnas/hello_world/zomes/integrity/hello_world/src/lib.rs.hbs @@ -0,0 +1,49 @@ +use hdi::prelude::*; + +/// this struct defines the content of the Hello entry +#[hdk_entry_helper] +#[derive(Clone, PartialEq)] +pub struct Hello { + pub message: String, +} + +/// Definition of the Hello entry type itself using the entry-helper struct as its content +#[derive(Serialize, Deserialize)] +#[serde(tag = "type")] +#[hdk_entry_defs] +#[unit_enum(UnitEntryTypes)] +pub enum EntryTypes { + Hello(Hello), +} + +/// Definition of a link type to be used for linking from an anchor to all created entreis +#[derive(Serialize, Deserialize)] +#[hdk_link_types] +pub enum LinkTypes { + AllHellos, +} + +/// Validation you perform during the genesis process. Nobody else on the network performs it, only you. +/// There *is no* access to network calls in this callback +#[hdk_extern] +pub fn genesis_self_check(_data: GenesisSelfCheckData) -> ExternResult { + Ok(ValidateCallbackResult::Valid) +} + +/// Validation the network performs when you try to join, you can't perform this validation yourself as you are not a member yet. +/// There *is* access to network calls in this function +pub fn validate_agent_joining(_agent_pub_key: AgentPubKey, _membrane_proof: &Option) -> ExternResult { + Ok(ValidateCallbackResult::Valid) +} + +/// This is the unified validation callback for all entries and link types in this integrity zome +/// In this example app we leave validation aside, please look at the Forum example for validation samples +/// +/// You can read more about validation here: https://docs.rs/hdi/latest/hdi/index.html#data-validation +/// +/// +#[hdk_extern] +pub fn validate(_op: Op) -> ExternResult { + Ok(ValidateCallbackResult::Valid) +} + diff --git a/templates/vanilla/example/tests/hello-world.test.ts.hbs b/templates/vanilla/example/tests/hello-world.test.ts.hbs new file mode 100644 index 000000000..c1e67f066 --- /dev/null +++ b/templates/vanilla/example/tests/hello-world.test.ts.hbs @@ -0,0 +1,58 @@ +import { assert, test } from "vitest"; + +import { runScenario, pause } from '@holochain/tryorama'; + + +test('send hello and retrieve hellos', async () => { + await runScenario(async scenario => { + // Construct proper paths for your app. + // This assumes app bundle created by the `hc app pack` command. + const testAppPath = process.cwd() + '/../workdir/hello-world.happ'; + + // Set up the app to be installed + const appSource = { appBundleSource: { path: testAppPath } }; + + // Add 2 players with the test app to the Scenario. The returned players + // can be destructured. + const [alice, beto] = await scenario.addPlayersWithApps([appSource, appSource]); + + // Shortcut peer discovery through gossip and register all agents in every + // conductor of the scenario. + await scenario.shareAllAgents(); + + // Alice sends a hello + const aliceCell = alice.cells[0] + const resultAlice = await aliceCell.callZome({ + zome_name: "hello_world", + fn_name: "hello_world", + payload: "hello world!", + }); + assert.ok(resultAlice); + + // Beto sends a hello + const betoCell = beto.cells[0] + const resultBeto = await betoCell.callZome({ + zome_name: "hello_world", + fn_name: "hello_world", + payload: "hola mundo!", + }); + assert.ok(resultBeto); + + await pause(1000) // wait for DHT to settle + + // Alice gets all hellos + const hellosAlice: Array = await aliceCell.callZome({ + zome_name: "hello_world", + fn_name: "get_hellos", + payload: undefined, + }); + + // confirm that both hellos are present + assert.equal(hellosAlice.length, 2); + assert.equal(hellosAlice[0].message, "hello world!"); + assert.deepEqual(hellosAlice[0].author, aliceCell.cell_id[1]); + assert.equal(hellosAlice[1].message, "hola mundo!"); + assert.deepEqual(hellosAlice[1].author, betoCell.cell_id[1]); + + }); + }); \ No newline at end of file diff --git a/templates/vanilla/example/ui/index.html.hbs b/templates/vanilla/example/ui/index.html.hbs index 97d5c0ae1..d129a050f 100644 --- a/templates/vanilla/example/ui/index.html.hbs +++ b/templates/vanilla/example/ui/index.html.hbs @@ -18,31 +18,86 @@ background-color: #ededed; } + Example hApp - - + + + My AgentPubKey: + Greeting sent! Click the button to see all hellos. + + Look for Hellos + + diff --git a/templates/vanilla/example/ui/package.json.hbs b/templates/vanilla/example/ui/package.json.hbs new file mode 100644 index 000000000..961a024f2 --- /dev/null +++ b/templates/vanilla/example/ui/package.json.hbs @@ -0,0 +1,27 @@ +{ + "name": "ui", + "description": "vanilla holochain web-app", + "license": "MIT", + "version": "0.0.0", + "scripts": { + "start": "vite --clearScreen false --port $UI_PORT", + "build": "vite build", + "package": "npm run build && cd dist && bestzip ../dist.zip *" + }, + "dependencies": { + "@holochain/client": "^0.12.2", + "@holo-host/identicon": "^0.1.0", + "@msgpack/msgpack": "^2.7.2" + }, + "devDependencies": { + "@open-wc/eslint-config": "^4.3.0", + "@typescript-eslint/eslint-plugin": "^4.29.2", + "@typescript-eslint/parser": "^4.29.2", + "bestzip": "^2.2.0", + "deepmerge": "^4.2.2", + "rimraf": "^3.0.2", + "tslib": "^2.3.1", + "typescript": "^4.9.3", + "vite": "^4.0.4" + } + } \ No newline at end of file diff --git a/templates/vanilla/example/workdir/happ.yaml.hbs b/templates/vanilla/example/workdir/happ.yaml.hbs new file mode 100644 index 000000000..5a9738d38 --- /dev/null +++ b/templates/vanilla/example/workdir/happ.yaml.hbs @@ -0,0 +1,18 @@ +--- +manifest_version: "1" +name: hello-world +description: ~ +roles: + - name: hello_world + provisioning: + strategy: create + deferred: false + dna: + bundled: "../dnas/hello_world/workdir/hello_world.dna" + modifiers: + network_seed: ~ + properties: ~ + origin_time: ~ + quantum_time: ~ + version: ~ + clone_limit: 0 diff --git a/templates/vanilla/example/workdir/web-happ.yaml.hbs b/templates/vanilla/example/workdir/web-happ.yaml.hbs new file mode 100644 index 000000000..0937bcc4c --- /dev/null +++ b/templates/vanilla/example/workdir/web-happ.yaml.hbs @@ -0,0 +1,7 @@ +--- +manifest_version: "1" +name: hello-world +ui: + bundled: "../ui/dist.zip" +happ_manifest: + bundled: "./hello-world.happ" diff --git a/templates/vue/web-app/package.json.hbs b/templates/vue/web-app/package.json.hbs index a7307d5a3..8aa91a451 100644 --- a/templates/vue/web-app/package.json.hbs +++ b/templates/vue/web-app/package.json.hbs @@ -10,6 +10,11 @@ "network": "hc s clean && npm run build:happ && UI_PORT=8888 concurrently \"npm start -w ui\" \"npm run launch:happ\" \"holochain-playground\"", "test": "npm run build:zomes && hc app pack workdir --recursive && npm t -w tests", "launch:happ": "echo \"pass\" | RUST_LOG=warn hc launch --piped -n $AGENTS workdir/{{app_name}}.happ --ui-port $UI_PORT network mdns", + {{#if holo_enabled}} + "start:holo": "AGENTS=2 npm run network:holo", + "network:holo": "npm run build:happ && UI_PORT=8888 concurrently \"npm run launch:holo-dev-server\" \"holochain-playground ws://localhost:4444\" \"concurrently-repeat 'VITE_APP_CHAPERONE_URL=http://localhost:24274 VITE_APP_IS_HOLO=true npm start -w ui' $AGENTS\"", + "launch:holo-dev-server": "holo-dev-server workdir/{{app_name}}.happ", + {{/if}} "package": "npm run build:happ && npm run package -w ui && hc web-app pack workdir --recursive", "build:happ": "npm run build:zomes && hc app pack workdir --recursive", "build:zomes": "RUSTFLAGS='' CARGO_TARGET_DIR=target cargo build --release --target wasm32-unknown-unknown" @@ -17,6 +22,9 @@ "devDependencies": { "@holochain-playground/cli": "^0.1.1", "concurrently": "^6.2.1", + {{#if holo_enabled}} + "concurrently-repeat": "^0.0.1", + {{/if}} "rimraf": "^3.0.2" }, "engines": { diff --git a/templates/vue/web-app/ui/package.json.hbs b/templates/vue/web-app/ui/package.json.hbs index 766c49544..a88de3310 100644 --- a/templates/vue/web-app/ui/package.json.hbs +++ b/templates/vue/web-app/ui/package.json.hbs @@ -9,6 +9,9 @@ }, "dependencies": { "@holochain/client": "{{holochain_client_version}}", + {{#if holo_enabled}} + "@holo-host/web-sdk": "{{web_sdk_version}}", + {{/if}} "@material/mwc-circular-progress": "^0.27.0", "@material/mwc-button": "^0.27.0", "@material/mwc-textfield": "^0.27.0", diff --git a/templates/vue/web-app/ui/src/App.vue.hbs b/templates/vue/web-app/ui/src/App.vue.hbs index a3b8908b7..3a7a9d841 100644 --- a/templates/vue/web-app/ui/src/App.vue.hbs +++ b/templates/vue/web-app/ui/src/App.vue.hbs @@ -33,13 +33,27 @@ export default defineComponent({ Replace this "EDIT ME!" section with <CreateTodo></CreateTodo><AllTodos></AllTodos>. + {{#if holo_enabled}} + + {{/if}}
<create-todo></create-todo><all-todos></all-todos>
<CreateTodo></CreateTodo><AllTodos></AllTodos>