Skip to content

Commit

Permalink
prepare for crate publish
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam McKee committed Nov 26, 2024
1 parent 43477db commit 8c5afba
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 23 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ members = [
"l3_base",
"l3_cli",
]
resolver = "2"

[workspace.dependencies]
anyhow = "1.0.92"
Expand All @@ -16,13 +17,15 @@ tokio = { version = "1.41.0", features = ["full"] }
[workspace.package]
authors = ["Adam McKee <[email protected]>"]
edition = "2021"
license = "BSD-2-Clause"
repository = "https://github.com/eighty4/l3"

[package]
name = "l3"
version = "0.0.1"
authors = { workspace = true }
edition = { workspace = true }
license = { workspace = true }
repository = { workspace = true }

[dependencies]
Expand Down
9 changes: 9 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Copyright 2024 Adam McKee Bennett <[email protected]>

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.
3 changes: 3 additions & 0 deletions fn_build/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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]
Expand All @@ -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 }
Expand Down
3 changes: 1 addition & 2 deletions fn_build/src/archive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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)?;
Expand Down
10 changes: 5 additions & 5 deletions fn_build/src/build_test.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -70,10 +69,11 @@ async fn build_fn_produces_archive() {
}

assert!(unzipped_root.join("node_modules").is_dir());
let dependency_source_paths: Vec<PathBuf> = 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<PathBuf> =
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!(
Expand Down
15 changes: 0 additions & 15 deletions fn_build/src/paths.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,5 @@
use std::fs::read_dir;
use std::path::{Path, PathBuf, MAIN_SEPARATOR_STR};

pub fn collect_files(p: &Path) -> Vec<PathBuf> {
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());
Expand Down
1 change: 0 additions & 1 deletion fn_build/src/runtime/build_fn.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
2 changes: 2 additions & 0 deletions l3_base/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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]
Expand Down
6 changes: 6 additions & 0 deletions l3_cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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" }
Expand Down

0 comments on commit 8c5afba

Please sign in to comment.