WANTED: testers for the upcoming RAD scaffolding tool

[EDIT] This tool has landed in the most recent blessed Holonix, so it’s easy to install.

Yep, you read it here first – our v2 of the RAD scaffolding tool is ready! V1 simply scaffolded a demo note-taking hApp, whereas this one builds a DNA and a basic UI, all from a spec file of your creation! It takes the Rust version of Holochain one step closer to the easy hackability of the old prototype with its scaffolding GUI.

I’m inviting forum members to be the first testers of this tool. It’s currently available in Holonix, the Holochain dev tools environment, so just follow the installation instructions (update: it now works great on Windows 10 and macOS Catalina without annoying hacks).

Now cd to your Holochain projects directory, create a JSON spec that describes your DNA’s entry types – you can find a description of the JSON format and a sample at the scaffolding tool’s README.

Finally, point the scaffolding tool at your JSON spec file:

$ hc-happ-scaffold <spec-file.json> <new-project-folder>

It’ll chug away for a good few minutes (code generation is quick, but DNA compilation takes a while), and then at the end, in the <new-project-folder> you’ll find DNA and UI source code, ready to run with:

$ cd <new-project-folder>
$ npm start

This starts up the sim2h server, Holochain conductor, and React dev web server, then fires up your web browser with the UI.

The zomes in the DNA are fairly straightforward—just structs and entry type definitions for your data types, plus zome functions to create, read, update, delete, and list entries of each type. (Any of these functions are optional for a given entry type; you can specify which ones you do want.) The built-in validation function specifies that only an entry’s author can edit or delete it.

We chose to build the UI with React because it is such a popular framework; it’s likely that developers new to Holochain will already have experience with it. Apollo GraphQL, on the other hand, is emerging as a favourite among both the community and our own hAppy Team because it’s an easy-to-use abstraction that lets you swap out back-end implementations easily. If you’re already using Apollo or GraphQL in your UI, you can look at the generated source code for examples of how we use them.

The UI is basic but usable – a CRUD forms style UI. It’s handy as a Swagger-like API testing tool.

Try it out and let us know how it goes!

Share your feedback below; I’ll share it with the hAppy dev team. Thank you so much, and have fun scaffolding!!!

2 Likes

Works beautifully for me!

The only hiccup was that I got an error while first running

It told me that I need to make “avatarURL” into snake case “avatar_url”.

Yes, thanks – another tester discovered that too. I’ve got a PR up to change the sample code, but the long term fix, I think, would be to introduce better error messaging or even auto-convert with a warning.

… can anyone tell me what I’m doing wrong, please.

Thanks,

Hank

Nothing wrong on your part – the sample on the repo has some bad trailing commas on the last line of each "definition" block, which trips up the super strict JSON parser we’re using. Remove those and you should be successful!

Hi Paul,

the auto-generated Cargo.toml file in dna-src/zomes/zome/code contained hdk, hdk_proc_macros and holochain_wasm_utils in version “=0.0.50-alpha4”.

The compiler complained about "expected struct hdk::entry_definition::ValidatingEntryType, found a different struct hdk::entry_definition::ValidatingEntryType", or "expected enum hdk::error::ZomeApiError, found a different enum hdk::error::ZomeApiError" suggesting “Perhaps two different versions of crate hdk are being used?”.

I changed the version manually to “=0.0.51-alpha1”, which is the up-to-date version on crates.io, and all works fine now.

All the best,
Michal

Hi @comcmipi – thanks for the bug report. I think you may have caught our deployment tooling with its pants down, so to speak – a transitional period where the code for one project was pointing to one version of the HDK but the generated template for your DNA was pointing to another version.

Would you be able to re-test from a completely clean slate and see if you still get that error?

Dear @pauldaoust ,

I can confirm the pants are up again and the issue is solved!

A little more nitpicking: immediately after running the hc-happ-scaffold script, en error is returned (script continues anyway, which is ok):

/nix/store/b0s1949hkla53xkhg6zp43xfid8i35rl-hc-happ-scaffold/bin/hc-happ-scaffold: line 2: my-type-spec.json: command not found

On the second line of the script a test for presence of the argument (spec json file) is carried out:

${1?"Command Usage Error: ARG 1 - PATH TO SCHEMA REQUIRED"}

If the argument is specified, the script tries to execute the argument, which is obviously not desired / necessary. One possible solution is to change it to a dummy variable assignment, e.g.

_=${1?"Command Usage Error: ARG 1 - PATH TO SCHEMA REQUIRED"}

that does the job right (i.e. exists script it argument is not specified), but doesn’t produce error message if the spec json file was specified.

Thank you for the great work you are doing,
best regards,

Michal

1 Like

oh yeah, that’s kinda yucky. Looks like it’s simply smoke testing for the presence of a file rather than doing anything with it at that point. Would you have the time to create a GitHub issue for this? https://github.com/holochain/holonix/issues/ (That’s not the repo for the scaffolding tool, but it is the repo that holds the command hc-happ-scaffold that actually downloads the spec file and runs the scaffolding tool.)

Done: https://github.com/holochain/holonix/issues/174

1 Like