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

Feature: PopDb - a caching system for pop-cli #92

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all 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
115 changes: 97 additions & 18 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 @@ -18,6 +18,7 @@ duct = "0.13"
git2 = "0.18"
log = "0.4"
# semver = "1.0.20"
sled = "0.34.7"
strum = "0.26"
strum_macros = "0.26"
tempfile = "3.8"
Expand Down
1 change: 0 additions & 1 deletion src/commands/build/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ impl BuildContractCommand {
clear_screen()?;
intro(format!("{}: Building a contract", style(" Pop CLI ").black().on_magenta()))?;
set_theme(Theme);

build_smart_contract(&self.path)?;
outro("Build completed successfully!")?;
Ok(())
Expand Down
5 changes: 2 additions & 3 deletions src/commands/build/parachain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,11 @@ pub struct BuildParachainCommand {
}

impl BuildParachainCommand {
pub(crate) fn execute(&self) -> anyhow::Result<()> {
pub(crate) fn execute(self) -> anyhow::Result<()> {
clear_screen()?;
intro(format!("{}: Building a parachain", style(" Pop CLI ").black().on_magenta()))?;
set_theme(Theme);
build_parachain(&self.path)?;

build_parachain(self.path)?;
outro("Build Completed Successfully!")?;
Ok(())
}
Expand Down
3 changes: 2 additions & 1 deletion src/commands/new/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use clap::Args;
use cliclack::{clear_screen, confirm, intro, outro, outro_cancel, set_theme};
use console::style;

use crate::{engines::contract_engine::create_smart_contract, style::Theme};
use crate::{db::PopDb, engines::contract_engine::create_smart_contract, style::Theme};

#[derive(Args)]
pub struct NewContractCommand {
Expand Down Expand Up @@ -47,6 +47,7 @@ impl NewContractCommand {
let mut spinner = cliclack::spinner();
spinner.start("Generating contract...");
create_smart_contract(self.name, contract_path.as_path())?;
PopDb::open_or_init().set_contract_path(contract_path.as_path());
spinner.stop("Smart contract created!");
outro(format!("cd into \"{}\" and enjoy hacking! 🚀", contract_path.display()))?;
Ok(())
Expand Down
6 changes: 4 additions & 2 deletions src/commands/new/pallet.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::{
db::PopDb,
engines::pallet_engine::{create_pallet_template, TemplatePalletConfig},
helpers::resolve_pallet_path,
style::Theme,
Expand All @@ -21,7 +22,7 @@ pub struct NewPalletCommand {
}

impl NewPalletCommand {
pub(crate) fn execute(&self) -> anyhow::Result<()> {
pub(crate) fn execute(self) -> anyhow::Result<()> {
clear_screen()?;
intro(format!(
"{}: Generating new pallet \"{}\"!",
Expand All @@ -45,7 +46,7 @@ impl NewPalletCommand {
))?;
return Ok(());
}
fs::remove_dir_all(pallet_path)?;
fs::remove_dir_all(&pallet_path)?;
}
let mut spinner = cliclack::spinner();
spinner.start("Generating pallet...");
Expand All @@ -57,6 +58,7 @@ impl NewPalletCommand {
description: self.description.clone().expect("default values"),
},
)?;
PopDb::open_or_init().set_pallet_path(&pallet_path);
spinner.stop("Generation complete");
outro(format!("cd into \"{}\" and enjoy hacking! 🚀", &self.name))?;
Ok(())
Expand Down
3 changes: 3 additions & 0 deletions src/commands/new/parachain.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::{
db::PopDb,
engines::parachain_engine::{instantiate_template_dir, Config},
helpers::git_init,
style::{style, Theme},
Expand Down Expand Up @@ -97,6 +98,8 @@ impl NewParachainCommand {
if let Some(tag) = tag {
log::info(format!("Version: {}", tag))?;
}
let pop_db = PopDb::open_or_init();
pop_db.set_parachain_path(&destination_path);
outro(format!("cd into \"{}\" and enjoy hacking! 🚀", destination_path.display()))?;
Ok(())
}
Expand Down
Loading
Loading