revert 619b73d03e
There's really no scenario where we want to generate boilerplate that always end up being removed. In particular, the boilerplate breaks tutorial as it generate conflicting validators in the blueprint. The only argument in favor of the boilerplate is to serve as example and show people some syntax reminder. However, this is better done in the README or on the user manual directly.
This commit is contained in:
parent
89c55a23fa
commit
7883aff5f7
|
@ -1,5 +1,12 @@
|
|||
# Changelog
|
||||
|
||||
## v1.0.16-alpha - unreleased
|
||||
|
||||
### Removed
|
||||
|
||||
- **aiken**: `aiken new` no longer accept an `--empty` flag. Projects are
|
||||
generated empty by default.
|
||||
|
||||
## v1.0.15-alpha - 2023-08-19
|
||||
|
||||
### Fixed
|
||||
|
|
|
@ -21,9 +21,6 @@ pub struct Args {
|
|||
/// Library only
|
||||
#[clap(long, short)]
|
||||
lib: bool,
|
||||
/// Empty project
|
||||
#[clap(long, short)]
|
||||
empty: bool,
|
||||
}
|
||||
|
||||
pub fn exec(args: Args) -> miette::Result<()> {
|
||||
|
@ -42,10 +39,10 @@ fn create_project(args: Args, package_name: &PackageName) -> miette::Result<()>
|
|||
})?;
|
||||
}
|
||||
|
||||
create_lib(&root, package_name, args.empty)?;
|
||||
create_lib(&root, package_name)?;
|
||||
|
||||
if !args.lib {
|
||||
create_validators(&root, package_name, args.empty)?;
|
||||
create_validators(&root)?;
|
||||
}
|
||||
|
||||
readme(&root, &package_name.repo)?;
|
||||
|
@ -72,7 +69,7 @@ fn print_success_message(package_name: &PackageName) {
|
|||
{aiken} check
|
||||
{aiken} build
|
||||
|
||||
{hint} You may want to update the {stdlib} version in {toml}.
|
||||
{hint} You may want to update the {stdlib} version in {toml}.
|
||||
"#,
|
||||
s = "successfully"
|
||||
.if_supports_color(Stderr, |s| s.bright_green())
|
||||
|
@ -99,60 +96,14 @@ fn print_success_message(package_name: &PackageName) {
|
|||
)
|
||||
}
|
||||
|
||||
fn create_lib(root: &Path, package_name: &PackageName, empty: bool) -> miette::Result<()> {
|
||||
fn create_lib(root: &Path, package_name: &PackageName) -> miette::Result<()> {
|
||||
let lib = root.join("lib").join(&package_name.repo);
|
||||
|
||||
fs::create_dir_all(&lib).into_diagnostic()?;
|
||||
|
||||
if empty {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
fs::write(
|
||||
lib.join("types.ak"),
|
||||
formatdoc! {
|
||||
r#"
|
||||
/// Custom type
|
||||
pub type Datum {{
|
||||
/// A utf8 encoded message
|
||||
message: ByteArray,
|
||||
}}
|
||||
|
||||
test sum() {{
|
||||
1 + 1 == 2
|
||||
}}
|
||||
"#,
|
||||
},
|
||||
)
|
||||
.into_diagnostic()
|
||||
fs::create_dir_all(&lib).into_diagnostic()
|
||||
}
|
||||
|
||||
fn create_validators(root: &Path, package_name: &PackageName, empty: bool) -> miette::Result<()> {
|
||||
fn create_validators(root: &Path) -> miette::Result<()> {
|
||||
let validators = root.join("validators");
|
||||
|
||||
fs::create_dir_all(&validators).into_diagnostic()?;
|
||||
|
||||
if empty {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
fs::write(
|
||||
validators.join("hello.ak"),
|
||||
formatdoc! {
|
||||
r#"
|
||||
use aiken/transaction.{{ScriptContext}}
|
||||
use {name}/types
|
||||
|
||||
validator {{
|
||||
fn spend(datum: types.Datum, _redeemer: Data, _ctx: ScriptContext) -> Bool {{
|
||||
datum.message == "Hello World!"
|
||||
}}
|
||||
}}
|
||||
"#,
|
||||
name = package_name.repo
|
||||
},
|
||||
)
|
||||
.into_diagnostic()
|
||||
fs::create_dir_all(&validators).into_diagnostic()
|
||||
}
|
||||
|
||||
fn readme(root: &Path, project_name: &str) -> miette::Result<()> {
|
||||
|
|
Loading…
Reference in New Issue