Skip to content

Commit 8f7b372

Browse files
authored
Merge pull request #6 from weezy20/template-crates-io-deps
2 parents a1853a2 + d2fe4e5 commit 8f7b372

31 files changed

+208
-2320
lines changed

.gitmodules

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
[submodule "templates/ept"]
22
path = templates/ept
33
url = [email protected]:paritytech/extended-parachain-template.git
4+
5+
[submodule "templates/vanilla-parachain"]
6+
path = templates/vanilla-parachain
7+
url = [email protected]:r0guelabs/vanilla-parachain.git
8+

src/generator.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,15 @@ use askama::Template;
66

77
// TODO: This should be coupled with Runtime in the sense that pallets part of a Runtime may need a default genesis config
88
#[derive(Template)]
9-
#[template(path = "chain_spec.templ", escape = "none")]
9+
#[template(path = "vanilla/chain_spec.templ", escape = "none")]
1010
pub(crate) struct ChainSpec {
1111
pub(crate) token_symbol: String,
1212
pub(crate) decimals: u8,
1313
pub(crate) initial_endowment: String,
1414
}
1515
// todo : generate directory structure
1616
// todo : This is only for development
17+
#[allow(unused)]
1718
pub fn generate() {
1819
let cs = ChainSpec {
1920
token_symbol: "DOT".to_owned(),

src/template.rs

+15-8
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ pub struct Config {
1414
pub(crate) initial_endowment: String,
1515
}
1616

17+
/// Creates a new template at `target` dir
1718
pub fn instantiate_template_dir(template: &Template, target: &Path, config: Config) -> Result<()> {
18-
use Template::*;
19-
// TODO : if target folder exists, prompt user to clean dir or abort
2019
sanitize(target)?;
20+
use Template::*;
2121
let url = match template {
2222
EPT => "https://github.com/paritytech/extended-parachain-template.git",
2323
FPT => "https://github.com/paritytech/frontier-parachain-template.git",
@@ -26,17 +26,16 @@ pub fn instantiate_template_dir(template: &Template, target: &Path, config: Conf
2626
return instantiate_vanilla_template(target, config);
2727
}
2828
};
29-
Repository::clone(url, target)?;
29+
clone_and_degit(url, target)?;
30+
Repository::init(target)?;
3031
Ok(())
3132
}
3233
// TODO: The config will shape the emitted template
3334
pub fn instantiate_vanilla_template(target: &Path, config: Config) -> Result<()> {
3435
let temp_dir = ::tempfile::TempDir::new_in(std::env::temp_dir())?;
35-
let temp_path = temp_dir.path();
36+
let source = temp_dir.path();
3637
// println!("Temporary directory created at {:?}", temp_path);
37-
38-
Repository::clone("https://github.com/weezy20/DoTemplate.git", temp_path)?;
39-
let source = temp_path.join("templates/vanilla-parachain");
38+
clone_and_degit("https://github.com/r0guelabs/vanilla-parachain.git", source)?;
4039

4140
for entry in WalkDir::new(&source) {
4241
let entry = entry?;
@@ -60,7 +59,7 @@ pub fn instantiate_vanilla_template(target: &Path, config: Config) -> Result<()>
6059
&target.join("node/src/chain_spec.rs"),
6160
chainspec.render().expect("infallible").as_ref(),
6261
);
63-
62+
Repository::init(target)?;
6463
Ok(())
6564
}
6665

@@ -86,3 +85,11 @@ fn sanitize(target: &Path) -> Result<()> {
8685
}
8786
Ok(())
8887
}
88+
89+
/// Clone `url` into `target` and degit it
90+
fn clone_and_degit(url: &str, target: &Path) -> Result<()> {
91+
let repo = Repository::clone(url, target)?;
92+
let git_dir = repo.path();
93+
fs::remove_dir_all(&git_dir)?;
94+
Ok(())
95+
}

templates/vanilla-parachain/LICENSE

-24
This file was deleted.

templates/vanilla-parachain/README.md

-22
This file was deleted.

templates/vanilla-parachain/node/Cargo.toml

-94
This file was deleted.

templates/vanilla-parachain/node/build.rs

-7
This file was deleted.

0 commit comments

Comments
 (0)