Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
45b7aa1
Add package endpoint
terror Jul 16, 2025
3fb1242
Perfect test cov
terror Jul 16, 2025
40ba515
Write manifest hash + number of files
terror Jul 16, 2025
b1c738b
Read the manifest
terror Jul 17, 2025
e6249f1
Fix test
terror Jul 17, 2025
4245f90
Do this
terror Jul 17, 2025
620d301
Stuff
casey Jul 17, 2025
d22f494
Remove render command and use page wrapper template
casey Jul 17, 2025
e27c93d
Fix clippy lints
casey Jul 17, 2025
fa1c4a5
Placate clippy
casey Jul 17, 2025
4a575b8
Add page titles and metadata extraction
casey Jul 18, 2025
3f70594
Do it
terror Jul 21, 2025
dbfbb48
Remove unused
terror Jul 21, 2025
88dec9c
Load metadata
terror Jul 21, 2025
6a60fc1
Add metadata
terror Jul 21, 2025
356ad19
Trait order
terror Jul 21, 2025
4b8ce8b
Remove default
terror Jul 21, 2025
27f62fb
Rename
terror Jul 21, 2025
13abfac
Rename
terror Jul 21, 2025
afa90cc
Rename
terror Jul 21, 2025
6b3e8bf
Handle parent path
terror Jul 21, 2025
4b56a62
Move server_error
terror Jul 21, 2025
cf0fbad
Modify
casey Jul 21, 2025
bdbad2b
Use BTreeMap
casey Jul 21, 2025
e2ef235
Use constants
casey Jul 21, 2025
2a9b6ab
Fix test
casey Jul 21, 2025
038da47
Adjust
casey Jul 21, 2025
e7564db
Adjust
casey Jul 21, 2025
9fe7a1d
Adapt
casey Jul 21, 2025
06d7b8e
Adjust
casey Jul 21, 2025
f124f82
Add index tests
casey Jul 21, 2025
d8fc1f8
Add package test
casey Jul 21, 2025
86d47e9
Add template test
casey Jul 21, 2025
bcea4a0
Add fake signatures to package
casey Jul 21, 2025
a77248d
Placate clippy
casey Jul 21, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true
14 changes: 0 additions & 14 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -105,17 +105,3 @@ verify-release: tmp
--dir tmp \
$VERSION
cargo run verify tmp --key 3c977ea3a31cd37f0b540f02f33eab158f2ed7449f42b05613c921181aa95b79

render: tmp
#!/usr/bin/env bash
set -euxo pipefail
VERSION=`bin/version`
gh release download \
--repo casey/filepack \
--pattern '*' \
--dir tmp \
$VERSION
rm tmp/filepack.json
cargo run create tmp --sign --metadata metadata.yaml
cargo run render tmp > tmp/index.html
open tmp/index.html
121 changes: 0 additions & 121 deletions src/archive.rs

This file was deleted.

15 changes: 0 additions & 15 deletions src/archive_error.rs

This file was deleted.

19 changes: 0 additions & 19 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@ use super::*;
#[derive(Debug, Snafu)]
#[snafu(context(suffix(false)), visibility(pub(crate)))]
pub(crate) enum Error {
#[snafu(display("failed to load archive at `{path}`"))]
ArchiveLoad {
path: DisplayPath,
source: ArchiveError,
},
#[snafu(display("failed to get current directory"))]
CurrentDir { source: io::Error },
#[snafu(display("failed to get local data directory"))]
Expand Down Expand Up @@ -56,13 +51,6 @@ pub(crate) enum Error {
},
#[snafu(display("fingerprint mismatch"))]
FingerprintMismatch { backtrace: Option<Backtrace> },
#[snafu(display("file `{path}` hash {actual} does not match manifest hash {expected}"))]
HashMismatch {
actual: Hash,
backtrace: Option<Backtrace>,
expected: Hash,
path: DisplayPath,
},
#[snafu(display("public key `{public_key}` doesn't match private key `{private_key}`"))]
KeyMismatch {
backtrace: Option<Backtrace>,
Expand Down Expand Up @@ -174,13 +162,6 @@ pub(crate) enum Error {
backtrace: Option<Backtrace>,
key: PublicKey,
},
#[snafu(display("file `{path}` size {actual} does not match manifest size {expected}"))]
SizeMismatch {
actual: u64,
backtrace: Option<Backtrace>,
expected: u64,
path: DisplayPath,
},
#[snafu(display("I/O error reading standard input"))]
StandardInputIo {
backtrace: Option<Backtrace>,
Expand Down
1 change: 1 addition & 0 deletions src/hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ impl Hash {
self.0.as_bytes()
}

#[cfg(test)]
pub(crate) fn bytes(input: &[u8]) -> Self {
Self(blake3::hash(input))
}
Expand Down
19 changes: 0 additions & 19 deletions src/into_u64.rs

This file was deleted.

65 changes: 39 additions & 26 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,33 +1,32 @@
use {
self::{
archive::Archive, archive_error::ArchiveError, arguments::Arguments, bytes::Bytes,
display_path::DisplayPath, display_secret::DisplaySecret, entry::Entry, error::Error,
hash::Hash, into_u64::IntoU64, lint::Lint, lint_group::LintGroup, list::List,
arguments::Arguments, bytes::Bytes, display_path::DisplayPath, display_secret::DisplaySecret,
entry::Entry, error::Error, hash::Hash, lint::Lint, lint_group::LintGroup, list::List,
manifest::Manifest, metadata::Metadata, options::Options, owo_colorize_ext::OwoColorizeExt,
page::Page, private_key::PrivateKey, public_key::PublicKey, relative_path::RelativePath,
package::Package, private_key::PrivateKey, public_key::PublicKey, relative_path::RelativePath,
signature::Signature, signature_error::SignatureError, style::Style, subcommand::Subcommand,
template::Template, utf8_path_ext::Utf8PathExt,
},
blake3::Hasher,
boilerplate::Boilerplate,
camino::{Utf8Component, Utf8Path, Utf8PathBuf},
clap::{Parser, ValueEnum},
html_escaper::Escape,
html_escaper::{Escape, Trusted},
indicatif::{ProgressBar, ProgressStyle},
lexiclean::Lexiclean,
owo_colors::Styled,
serde::{Deserialize, Deserializer, Serialize, Serializer},
serde_with::{DeserializeFromStr, SerializeDisplay},
snafu::{ensure, ErrorCompat, IntoError, OptionExt, ResultExt, Snafu},
snafu::{ensure, ErrorCompat, OptionExt, ResultExt, Snafu},
std::{
array::TryFromSliceError,
backtrace::{Backtrace, BacktraceStatus},
cmp::Ordering,
collections::{BTreeMap, HashMap, HashSet},
collections::{BTreeMap, HashMap},
env,
fmt::{self, Display, Formatter},
fs::{self, File},
io::{self, BufReader, BufWriter, IsTerminal, Read, Write},
fs::File,
io::{self, IsTerminal},
path::{Path, PathBuf},
process,
str::{self, FromStr},
Expand All @@ -38,27 +37,42 @@ use {
};

#[cfg(test)]
use assert_fs::{
fixture::{FileWriteBin, PathChild},
TempDir,
use {
assert_fs::{
fixture::{FileWriteStr, PathChild, PathCreateDir},
TempDir,
},
std::ffi::OsString,
};

#[cfg(test)]
macro_rules! assert_matches {
($expression:expr, $( $pattern:pat_param )|+ $( if $guard:expr )? $(,)?) => {
match $expression {
$( $pattern )|+ $( if $guard )? => {}
left => panic!(
"assertion failed: (left ~= right)\n left: `{:?}`\n right: `{}`",
left,
stringify!($($pattern)|+ $(if $guard)?)
),
macro_rules! command {
( $($argument:expr),* $(,)?) => {
{
#![allow(clippy::vec_init_then_push)]

let mut arguments = Vec::<OsString>::new();

arguments.push("filepack".into());

arguments.push("--quiet".into());

$(
arguments.push($argument.into());
)*

let arguments = match Arguments::try_parse_from(arguments) {
Ok(arguments) => arguments,
Err(error) => {
panic!("{error}");
}
};

arguments.run().unwrap();
}
}
};
}

mod archive;
mod archive_error;
mod arguments;
mod bytes;
mod display_path;
Expand All @@ -67,15 +81,14 @@ mod entry;
mod error;
mod filesystem;
mod hash;
mod into_u64;
mod lint;
mod lint_group;
mod list;
mod manifest;
mod metadata;
mod options;
mod owo_colorize_ext;
mod page;
mod package;
mod private_key;
mod progress_bar;
mod public_key;
Expand Down
6 changes: 3 additions & 3 deletions src/manifest.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use super::*;

#[derive(Debug, Deserialize, PartialEq, Serialize)]
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
#[serde(deny_unknown_fields, rename_all = "kebab-case")]
pub(crate) struct Manifest {
#[serde(default, skip_serializing_if = "BTreeMap::is_empty")]
Expand All @@ -25,7 +25,7 @@ impl Manifest {
hasher.finalize().into()
}

pub(crate) fn load(path: Option<&Utf8Path>) -> Result<(Utf8PathBuf, String, Self)> {
pub(crate) fn load(path: Option<&Utf8Path>) -> Result<(Utf8PathBuf, Self)> {
let path = if let Some(path) = path {
if filesystem::metadata(path)?.is_dir() {
path.join(Manifest::FILENAME)
Expand All @@ -42,7 +42,7 @@ impl Manifest {
let manifest =
serde_json::from_str(&json).context(error::DeserializeManifest { path: &path })?;

Ok((path, json, manifest))
Ok((path, manifest))
}

pub(crate) fn store(&self, path: &Utf8Path) -> Result<()> {
Expand Down
7 changes: 1 addition & 6 deletions src/metadata.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use super::*;

#[derive(Debug, Deserialize, Serialize)]
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
#[serde(rename_all = "kebab-case")]
pub(crate) struct Metadata {
pub(crate) title: String,
Expand All @@ -9,11 +9,6 @@ pub(crate) struct Metadata {
impl Metadata {
pub(crate) const FILENAME: &'static str = "metadata.json";

pub(crate) fn load(path: &Utf8Path) -> Result<Self> {
serde_json::from_str(&filesystem::read_to_string(path)?)
.context(error::DeserializeMetadata { path })
}

pub(crate) fn store(&self, path: &Utf8Path) -> Result<()> {
filesystem::write(path, format!("{}\n", serde_json::to_string(self).unwrap()))
}
Expand Down
Loading
Loading