Skip to content
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

Add holo and hello world to hc 0.2 #123

Merged
merged 36 commits into from
Sep 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
b878e76
Fixed question text
guillemcordoba Feb 28, 2023
65a378a
Merge branch 'main' of github.com:holochain/scaffolding
guillemcordoba Feb 28, 2023
df4a4b3
Fixed readme
guillemcordoba Mar 12, 2023
4e8efa5
extend space
guillemcordoba Mar 13, 2023
81d3175
extend space
guillemcordoba Mar 13, 2023
dd239c6
extend space
guillemcordoba Mar 13, 2023
fe11f68
Attempt fix CI
guillemcordoba Mar 13, 2023
2db9841
Attempt fix CI
guillemcordoba Mar 13, 2023
975fea9
Attempt fix CI
guillemcordoba Mar 13, 2023
4082155
Attempt fix CI
guillemcordoba Mar 13, 2023
028d42d
Attempt fix CI
guillemcordoba Mar 13, 2023
01fad14
Upped flake
guillemcordoba Mar 13, 2023
c5d84c1
Update README.md
guillemcordoba Mar 17, 2023
a9496c4
updates hello-world
zippy Mar 28, 2023
0fe5d13
fix package.json template file
zippy Mar 28, 2023
0067725
Fixed linked from question
guillemcordoba Mar 29, 2023
643d0c4
Merge branch 'main' of github.com:holochain/scaffolding
guillemcordoba Mar 29, 2023
a348dc5
Added call as reserved word
guillemcordoba Mar 29, 2023
1cd0ee7
remove code from early attempt and fix UI
zippy Mar 30, 2023
3167bb1
Merge pull request #82 from holochain/hello-world-refresh
guillemcordoba Mar 30, 2023
006fdfc
added test for hello-world
zippy Mar 30, 2023
09f513f
Add holo_enabled flag and update svelte template
Mar 30, 2023
40bb936
Merge pull request #83 from holochain/hello-world-test
guillemcordoba Mar 31, 2023
7db9f41
update vue template for holo
Apr 3, 2023
40c38f2
update lit template for holo
Apr 3, 2023
0ea25f9
Merge branch 'main' into add-holo
robbiecarlton Apr 3, 2023
49ca10e
Clean up indentation
Apr 3, 2023
a818c4b
Merge branch 'add-holo' of github.com:robbiecarlton/scaffolding into …
Apr 3, 2023
ebfbdfe
Fix tests
Apr 5, 2023
21130bb
Merge pull request #85 from holochain/add-holo
robbiecarlton Apr 13, 2023
7a15e0e
Merge branch 'develop' into add-holo-and-hello-world-hc-0.2
Sep 20, 2023
6dc7730
remove lockfile check
Sep 20, 2023
d956507
Remove duplicate extend-space
Sep 20, 2023
162ded7
Remove lockfile check and second extend space
Sep 20, 2023
f12dab7
fix hello world template
Sep 25, 2023
1a06907
Merge branch 'hc-0.2-into-develop' into add-holo-and-hello-world-hc-0.2
Sep 25, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/actions/extend-space/action.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Extends disk space on github hosted runners


name: "Extend space"
description: "Teases out as much free space as possible"

Expand Down Expand Up @@ -58,4 +57,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
df -h
30 changes: 0 additions & 30 deletions .github/workflows/check-offline.yaml

This file was deleted.

1 change: 0 additions & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ jobs:

- name: Extend space
uses: ./.github/actions/extend-space

- name: Install nix
uses: cachix/install-nix-action@v23
with:
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ yarn-error.log*
*.sln
*.sw?
result*
.cargo
.cargo
18 changes: 18 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
30 changes: 15 additions & 15 deletions flake.lock

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

12 changes: 12 additions & 0 deletions run_test.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
#!/usr/bin/env 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
Expand Down
74 changes: 8 additions & 66 deletions src/cli.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -72,6 +70,9 @@ pub enum HcScaffold {
/// If "--templates-url" is given, the template must be located at the ".templates/<TEMPLATE NAME>" folder of the repository
/// If not, the template must be an option from the built-in templates: "vanilla", "vue", "lit", "svelte"
template: Option<String>,

#[structopt(long = "holo", hidden = true)]
holo_enabled: bool,
},
/// Set up the template used in this project
Template(HcScaffoldTemplate),
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -305,6 +307,7 @@ impl HcScaffold {
&template_file_tree,
template_name,
scaffold_template,
holo_enabled,
)?;

let file_tree = MergeableFileSystemTree::<OsString, String>::from(dir! {
Expand Down Expand Up @@ -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<String> {{
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
Expand All @@ -809,6 +750,7 @@ pub fn hello_world(_: ()) -> ExternResult<String> {{
&template_file_tree,
template_name.clone(),
false,
false,
)?;

// scaffold dna hello_world
Expand Down
3 changes: 2 additions & 1 deletion src/reserved_words.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/scaffold/entry_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading