feat: change project structure
This commit is contained in:
parent
825783ca61
commit
a41d05f7b6
|
@ -70,15 +70,26 @@ impl Project {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn read_source_files(&mut self) -> Result<(), Error> {
|
fn read_source_files(&mut self) -> Result<(), Error> {
|
||||||
let lib = self.root.join("lib");
|
let lib = self.root.join(format!("src/{}", self.config.name));
|
||||||
let scripts = self.root.join("scripts");
|
let scripts = self.root.join("src/scripts");
|
||||||
|
|
||||||
|
self.read_root_lib_file()?;
|
||||||
self.aiken_files(&scripts, ModuleKind::Script)?;
|
self.aiken_files(&scripts, ModuleKind::Script)?;
|
||||||
self.aiken_files(&lib, ModuleKind::Lib)?;
|
self.aiken_files(&lib, ModuleKind::Lib)?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn read_root_lib_file(&mut self) -> Result<(), Error> {
|
||||||
|
let root_lib_path = self.root.join(format!("src/{}.ak", self.config.name));
|
||||||
|
|
||||||
|
if root_lib_path.exists() {
|
||||||
|
self.add_module(root_lib_path, &self.root.join("src"), ModuleKind::Lib)?;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
fn parse_sources(&mut self) -> Result<ParsedModules, Error> {
|
fn parse_sources(&mut self) -> Result<ParsedModules, Error> {
|
||||||
let mut errors = Vec::new();
|
let mut errors = Vec::new();
|
||||||
let mut parsed_modules = HashMap::with_capacity(self.sources.len());
|
let mut parsed_modules = HashMap::with_capacity(self.sources.len());
|
||||||
|
@ -235,7 +246,7 @@ impl Project {
|
||||||
full_module_path: &Path,
|
full_module_path: &Path,
|
||||||
kind: ModuleKind,
|
kind: ModuleKind,
|
||||||
) -> String {
|
) -> String {
|
||||||
// ../../lib/module.ak
|
// ../../{config.name}/module.ak
|
||||||
|
|
||||||
// module.ak
|
// module.ak
|
||||||
let mut module_path = full_module_path
|
let mut module_path = full_module_path
|
||||||
|
@ -244,7 +255,7 @@ impl Project {
|
||||||
.to_path_buf();
|
.to_path_buf();
|
||||||
|
|
||||||
// module
|
// module
|
||||||
let _ = module_path.set_extension("");
|
module_path.set_extension("");
|
||||||
|
|
||||||
// Stringify
|
// Stringify
|
||||||
let name = module_path
|
let name = module_path
|
||||||
|
@ -256,7 +267,7 @@ impl Project {
|
||||||
let name = name.replace('\\', "/");
|
let name = name.replace('\\', "/");
|
||||||
|
|
||||||
// project_name/module
|
// project_name/module
|
||||||
if kind.is_lib() {
|
if kind.is_lib() && name != self.config.name {
|
||||||
format!("{}/{}", self.config.name, name)
|
format!("{}/{}", self.config.name, name)
|
||||||
} else {
|
} else {
|
||||||
name
|
name
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
pub type ScriptContext {
|
||||||
|
thing: String
|
||||||
|
}
|
|
@ -1,3 +1,4 @@
|
||||||
|
use sample
|
||||||
use sample/syntax.{append}
|
use sample/syntax.{append}
|
||||||
|
|
||||||
pub type Datum {
|
pub type Datum {
|
||||||
|
@ -9,7 +10,7 @@ pub type Redeemer {
|
||||||
Sell
|
Sell
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn validate(datum: Datum, rdmr: Redeemer, ctx: syntax.ScriptContext) -> Bool {
|
pub fn validate(datum: Datum, rdmr: Redeemer, ctx: sample.ScriptContext) -> Bool {
|
||||||
let thing = if True {
|
let thing = if True {
|
||||||
3
|
3
|
||||||
} else {
|
} else {
|
Loading…
Reference in New Issue