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

chore: backport and release 0.3000.9 #417

Merged
merged 8 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
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
1,132 changes: 525 additions & 607 deletions Cargo.lock

Large diffs are not rendered by default.

16 changes: 10 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
edition = "2021"
name = "holochain_scaffolding_cli"
version = "0.3000.8"
version = "0.3000.9"
description = "CLI to easily generate and modify holochain apps"
license = "CAL-1.0"
homepage = "https://developer.holochain.org"
Expand All @@ -18,10 +18,9 @@ name = "holochain_scaffolding_cli"
path = "src/lib.rs"

[dependencies]
holochain = { features = ["test_utils"], version = "0.3.4" }
holochain_types = "0.3.4"
holochain_util = { features = ["backtrace"], version = "0.3.4" }
mr_bundle = "0.3.4"
holochain = { features = ["hdk"], version = "0.3.5" }
holochain_types = "0.3.5"
mr_bundle = "0.3.5"

dirs = "4.0.0"
ignore = "0.4"
Expand Down Expand Up @@ -51,5 +50,10 @@ itertools = "0.10"
colored = "2.1.0"
dprint-plugin-typescript = "0.91.1"
markup_fmt = "0.10.0"
git2 = { version = "0.19.0", default-features = false, features = ["https", "ssh_key_from_memory", "vendored-libgit2", "vendored-openssl"] }
git2 = { version = "0.19.0", default-features = false, features = [
"https",
"ssh_key_from_memory",
"vendored-libgit2",
"vendored-openssl",
] }
once_cell = "1.20.2"
38 changes: 19 additions & 19 deletions flake.lock

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

2 changes: 1 addition & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

lib.wrapCustomTemplate = { system, pkgs, customTemplatePath }:
let
scaffolding = inputs.holochain.packages.${system}.hc-scaffold;
scaffolding = inputs.holonix.packages.${system}.hc-scaffold;
in
pkgs.runCommand "hc-scaffold"
{
Expand Down
4 changes: 2 additions & 2 deletions src/cli/example.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,11 +270,11 @@ impl Example {
};

let ScaffoldedTemplate {
file_tree,
mut file_tree,
next_instructions,
} = scaffold_example(file_tree, package_manager, &template_file_tree, &example)?;

let file_tree = ScaffoldConfig::write_to_package_json(file_tree, template_type)?;
ScaffoldConfig::write_to_package_json(&mut file_tree, template_type)?;

build_file_tree(file_tree, &app_dir)?;

Expand Down
6 changes: 4 additions & 2 deletions src/cli/web_app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ impl WebApp {
};

let ScaffoldedTemplate {
file_tree,
mut file_tree,
next_instructions,
} = scaffold_web_app(
&name,
Expand All @@ -101,7 +101,9 @@ impl WebApp {
self.holo_enabled,
)?;

let file_tree = ScaffoldConfig::write_to_package_json(file_tree, template_type)?;
if !template_type.is_nixified_custom_template() {
ScaffoldConfig::write_to_package_json(&mut file_tree, template_type)?;
}

build_file_tree(file_tree, &app_folder)?;

Expand Down
4 changes: 0 additions & 4 deletions src/error.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use std::{io, path::PathBuf};

use holochain_util::ffs;
use thiserror;

#[derive(Debug, thiserror::Error)]
Expand All @@ -9,9 +8,6 @@ pub enum ScaffoldError {
#[error("IO error: {0}")]
StdIoError(#[from] std::io::Error),

#[error("ffs::IoError: {0}")]
FfsIoError(#[from] ffs::IoError),

/// MrBundleError
#[error(transparent)]
MrBundleError(#[from] mr_bundle::error::MrBundleError),
Expand Down
4 changes: 1 addition & 3 deletions src/file_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,6 @@ pub fn insert_file(
let mut folder_path = file_path.to_path_buf();
folder_path.pop();

let content = convert_rust_line_to_doc_comments(file_path, content);

insert_file_tree_in_dir(
file_tree,
&folder_path,
Expand Down Expand Up @@ -232,7 +230,7 @@ pub fn map_rust_files<F: Fn(PathBuf, syn::File) -> ScaffoldResult<syn::File> + C
/// otherwise returns the original content unchanged.
fn convert_rust_line_to_doc_comments(file_path: &Path, content: &str) -> String {
if file_path.extension().and_then(|ext| ext.to_str()) == Some("rs") {
let re = Regex::new(r"^\/\/[^\/]|[^\/]\/\/[^\/]").expect("Failed to create regex");
let re = Regex::new(r"(?:^|[^:])/(/[^/])").expect("Failed to create regex");
content
.lines()
.map(|line| re.replace_all(line, "/// ").into_owned() + "\n")
Expand Down
2 changes: 1 addition & 1 deletion src/scaffold/app.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::{collections::BTreeMap, path::PathBuf};

use dialoguer::{theme::ColorfulTheme, Select};
use holochain::prelude::AppManifest;
use holochain_types::prelude::AppManifest;
use mr_bundle::Manifest;

use crate::{
Expand Down
8 changes: 4 additions & 4 deletions src/scaffold/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ impl ScaffoldConfig {
}

pub fn write_to_package_json(
mut web_app_file_tree: FileTree,
web_app_file_tree: &mut FileTree,
template_type: &TemplateType,
) -> ScaffoldResult<FileTree> {
) -> ScaffoldResult<()> {
let config = ScaffoldConfig {
template: template_type.clone(),
};
let package_json_path = PathBuf::from("package.json");

map_file(&mut web_app_file_tree, &package_json_path, |c| {
map_file(web_app_file_tree, &package_json_path, |c| {
let original_content = c.clone();
let json = serde_json::from_str::<Value>(&c)?;
let json = match json {
Expand All @@ -59,6 +59,6 @@ impl ScaffoldConfig {
Ok(json)
})?;

Ok(web_app_file_tree)
Ok(())
}
}
Loading