feat(deps): start laying out some types and functions

This commit is contained in:
rvcas
2022-12-15 22:06:40 -05:00
committed by Lucas
parent b3266fb837
commit a6fd8f92a8
7 changed files with 80 additions and 1 deletions

View File

@@ -0,0 +1,41 @@
use std::path::Path;
use crate::{
error::Error,
paths,
telemetry::{Event, EventListener},
};
use self::manifest::Manifest;
pub mod manifest;
pub enum UseManifest {
Yes,
No,
}
pub fn download<T>(
event_listener: &T,
new_package: Option<(Vec<String>, bool)>,
use_manifest: UseManifest,
root_path: &Path,
) -> Result<Manifest, Error>
where
T: EventListener,
{
let build_path = root_path.join(paths::build());
let mut build_lock = fslock::LockFile::open(&build_path).expect("Build Lock Creation");
if !build_lock
.try_lock_with_pid()
.expect("Trying build locking")
{
event_listener.handle_event(Event::WaitingForBuildDirLock);
build_lock.lock_with_pid().expect("Build locking")
}
todo!()
}

View File

@@ -0,0 +1,17 @@
use std::collections::HashMap;
pub struct Manifest {
pub requirements: HashMap<String, String>,
pub packages: Vec<Package>,
}
pub struct Package {
pub name: String,
pub version: String,
pub requirements: Vec<String>,
pub source: PackageSource,
}
pub enum PackageSource {
GitHub { url: String },
}

View File

@@ -1,9 +1,11 @@
pub mod config;
pub mod deps;
pub mod docs;
pub mod error;
pub mod format;
pub mod module;
pub mod options;
pub mod paths;
pub mod pretty;
pub mod script;
pub mod telemetry;
@@ -17,6 +19,7 @@ use aiken_lang::{
uplc::CodeGenerator,
IdGenerator,
};
use deps::UseManifest;
use miette::NamedSource;
use options::{CodeGenMode, Options};
use pallas::{
@@ -148,6 +151,8 @@ where
}
pub fn compile(&mut self, options: Options) -> Result<(), Error> {
let manifest = deps::download(&self.event_listener, None, UseManifest::Yes, &self.root)?;
self.event_listener
.handle_event(Event::StartingCompilation {
root: self.root.clone(),
@@ -718,7 +723,7 @@ where
let cbor_hex = hex::encode(&cbor);
fs::write(script_path, &cbor_hex)?;
fs::write(script_path, cbor_hex)?;
// Create the payment script JSON file
let payment_script_path = script_output_dir.join("payment_script.json");

View File

@@ -0,0 +1,5 @@
use std::path::PathBuf;
pub fn build() -> PathBuf {
PathBuf::from("build")
}

View File

@@ -35,4 +35,5 @@ pub enum Event {
FinishedTests {
tests: Vec<EvalInfo>,
},
WaitingForBuildDirLock,
}