diff --git a/Cargo.lock b/Cargo.lock index e244d31..23b0a8e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1613,6 +1613,7 @@ version = "0.0.1" dependencies = [ "anyhow", "base64 0.22.1", + "l3_api_base", "rustpython-parser", "serde", "serde_json", diff --git a/Cargo.toml b/Cargo.toml index 01d5ea9..a41c5da 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,6 +4,7 @@ members = [ "l3_base", "l3_cli", ] +resolver = "2" [workspace.dependencies] anyhow = "1.0.92" @@ -16,6 +17,7 @@ tokio = { version = "1.41.0", features = ["full"] } [workspace.package] authors = ["Adam McKee "] edition = "2021" +license = "BSD-2-Clause" repository = "https://github.com/eighty4/l3" [package] @@ -23,6 +25,7 @@ name = "l3" version = "0.0.1" authors = { workspace = true } edition = { workspace = true } +license = { workspace = true } repository = { workspace = true } [dependencies] diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..04b4bde --- /dev/null +++ b/LICENSE @@ -0,0 +1,9 @@ +Copyright 2024 Adam McKee Bennett + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/fn_build/Cargo.toml b/fn_build/Cargo.toml index 691e676..ebf75ad 100644 --- a/fn_build/Cargo.toml +++ b/fn_build/Cargo.toml @@ -1,8 +1,10 @@ [package] name = "l3_fn_build" version = "0.0.1" +description = "Lib for Lambda function builds" authors = { workspace = true } edition = { workspace = true } +license = { workspace = true } repository = { workspace = true } [lib] @@ -12,6 +14,7 @@ path = "src/lib.rs" [dependencies] anyhow = { workspace = true } base64 = "0.22.1" +l3_api_base = { path = "../l3_base" } rustpython-parser = "0.4.0" serde = { workspace = true } serde_json = { workspace = true } diff --git a/fn_build/src/archive.rs b/fn_build/src/archive.rs index 96e2be0..310663c 100644 --- a/fn_build/src/archive.rs +++ b/fn_build/src/archive.rs @@ -3,7 +3,6 @@ use std::fs::File; use std::io::{Read, Write}; use std::path::Path; -use crate::paths::collect_files; use zip::write::FileOptions; use zip::ZipWriter; @@ -21,7 +20,7 @@ pub fn write_archive(archive_file: &Path, build_dir: &Path) -> Result<(), anyhow FileOptions::default().compression_method(zip::CompressionMethod::Deflated); let mut buf = Vec::new(); - for abs in collect_files(build_dir) { + for abs in l3_api_base::collect_files(build_dir) { File::open(build_dir.join(&abs))?.read_to_end(&mut buf)?; let rel = abs.strip_prefix(build_dir)?; zip_writer.start_file(rel.to_string_lossy(), compress_options)?; diff --git a/fn_build/src/build_test.rs b/fn_build/src/build_test.rs index 50e58c1..818906e 100644 --- a/fn_build/src/build_test.rs +++ b/fn_build/src/build_test.rs @@ -1,4 +1,3 @@ -use crate::paths::collect_files; use crate::runtime::node::{build_node_fn, NodeConfig}; use crate::runtime::Runtime; use crate::testing::unzip; @@ -70,10 +69,11 @@ async fn build_fn_produces_archive() { } assert!(unzipped_root.join("node_modules").is_dir()); - let dependency_source_paths: Vec = collect_files(&project_dir.join("node_modules")) - .iter() - .map(|p| p.strip_prefix(project_dir.as_ref()).unwrap().to_path_buf()) - .collect(); + let dependency_source_paths: Vec = + l3_api_base::collect_files(&project_dir.join("node_modules")) + .iter() + .map(|p| p.strip_prefix(project_dir.as_ref()).unwrap().to_path_buf()) + .collect(); assert!(!dependency_source_paths.is_empty()); for path in dependency_source_paths { assert_eq!( diff --git a/fn_build/src/paths.rs b/fn_build/src/paths.rs index 16688e0..7151b59 100644 --- a/fn_build/src/paths.rs +++ b/fn_build/src/paths.rs @@ -1,20 +1,5 @@ -use std::fs::read_dir; use std::path::{Path, PathBuf, MAIN_SEPARATOR_STR}; -pub fn collect_files(p: &Path) -> Vec { - let mut paths = Vec::new(); - for dir_entry_result in read_dir(p).unwrap() { - let dir_entry = dir_entry_result.unwrap(); - let p = dir_entry.path(); - if p.is_dir() { - paths.append(&mut collect_files(&p)); - } else { - paths.push(p); - } - } - paths -} - /// Joins file paths and rewrites `.` and `..` segments from result. pub fn join_file_paths(base: &Path, relative: &Path) -> PathBuf { debug_assert!(!base.is_dir()); diff --git a/fn_build/src/runtime/build_fn.rs b/fn_build/src/runtime/build_fn.rs index f0be887..0862bcc 100644 --- a/fn_build/src/runtime/build_fn.rs +++ b/fn_build/src/runtime/build_fn.rs @@ -1,6 +1,5 @@ use crate::archive::write_archive; use crate::checksum::Checksum; -use crate::paths::collect_files; use crate::{ FnBuildError, FnBuildManifest, FnBuildOutput, FnBuildResult, FnBuildSpec, FnHandler, FnParseManifest, diff --git a/l3_base/Cargo.toml b/l3_base/Cargo.toml index 5c74136..97549fb 100644 --- a/l3_base/Cargo.toml +++ b/l3_base/Cargo.toml @@ -1,8 +1,10 @@ [package] name = "l3_api_base" version = "0.0.1" +description = "Shared APIs for LLL crates" authors = { workspace = true } edition = { workspace = true } +license = { workspace = true } repository = { workspace = true } [lib] diff --git a/l3_cli/Cargo.toml b/l3_cli/Cargo.toml index 79137f3..efc5d3a 100644 --- a/l3_cli/Cargo.toml +++ b/l3_cli/Cargo.toml @@ -1,10 +1,16 @@ [package] name = "l3_cli" version = "0.0.1" +description = "Lambda compute tooling" authors = { workspace = true } edition = { workspace = true } +license = { workspace = true } repository = { workspace = true } +[[bin]] +name = "l3" +path = "src/main.rs" + [dependencies] l3_api_base = { path = "../l3_base" } l3_fn_build = { path = "../fn_build" }