0.1.3
continuous-integration/drone/push Build is failing Details

This commit is contained in:
LordMZTE 2022-03-05 01:49:37 +01:00
parent cecf32b413
commit 5ead609763
Signed by: LordMZTE
GPG Key ID: B64802DC33A64FF6
8 changed files with 85 additions and 60 deletions

View File

@ -1,4 +1,11 @@
# 0.1.3
- add support for defines
- update dependencies
- switch from structopt to clap with macro
# 0.1.2
- optimize curseforge relation meta querying
- add debug logging
- import and init now set the modpack's ID to a kebab-case version of the name

View File

@ -6,6 +6,6 @@ edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
serde = { version = "1.0.129", features = ["derive"] }
thiserror = "1.0.26"
serde = { version = "1.0.136", features = ["derive"] }
thiserror = "1.0.30"
url = { version = "2.2.2", features = ["serde"] }

View File

@ -1,6 +1,6 @@
[package]
name = "mpt"
version = "0.1.2"
version = "0.1.3"
edition = "2018"
[[bin]]
@ -11,24 +11,24 @@ path = "src/main.rs"
[dependencies]
addonscript = { path = "../addonscript" }
async-trait = "0.1.51"
crossterm = "0.21.0"
async-trait = "0.1.52"
clap = { version = "3.1.5", features = ["derive"] }
crossterm = "0.23.0"
futures = "0.3.16"
heck = "0.3.3"
heck = "0.4.0"
indicatif = "0.16.2"
json5 = "0.3.0"
json5 = "0.4.1"
log = "0.4.14"
miette = { version = "3.1.0", features = ["fancy"] }
mlua = { version = "0.6.6", features = ["luajit", "serialize"] }
miette = { version = "4.2.1", features = ["fancy"] }
mlua = { version = "0.7.4", features = ["luajit", "serialize"] }
percent-encoding = "2.1.0"
reqwest = { version = "0.11.4", features = ["stream"] }
serde = { version = "1.0.129", features = ["derive"] }
serde_json = "1.0.67"
simplelog = "0.10.0"
structopt = "0.3.22"
tera = "1.12.1"
thiserror = "1.0.28"
tokio = { version = "1.10.1", features = ["rt-multi-thread", "macros", "fs"] }
reqwest = { version = "0.11.9", features = ["stream"] }
serde = { version = "1.0.136", features = ["derive"] }
serde_json = "1.0.79"
simplelog = "0.11.2"
tera = "1.15.0"
thiserror = "1.0.30"
tokio = { version = "1.17.0", features = ["rt-multi-thread", "macros", "fs"] }
toml = "0.5.8"
twitch = { path = "../twitch" }
url = "2.2.2"

View File

@ -3,7 +3,8 @@ use addonscript::{
installer::Installer,
link::Link,
Contributor,
File, Manifest,
File,
Manifest,
ManifestType,
Meta,
Relation,
@ -15,7 +16,7 @@ use addonscript::{
util::default_file_opts,
};
use crossterm::style::Stylize;
use heck::KebabCase;
use heck::ToKebabCase;
use log::info;
use miette::{bail, IntoDiagnostic, WrapErr};
use twitch::manifest::Manifest as TwManifest;

View File

@ -30,7 +30,7 @@ use crossterm::{
},
ExecutableCommand,
};
use heck::KebabCase;
use heck::ToKebabCase;
use miette::{IntoDiagnostic, WrapErr};
use reqwest::Client;
use std::path::Path;

View File

@ -1,8 +1,8 @@
use clap::{Parser, Subcommand};
use log::{info, LevelFilter};
use miette::{IntoDiagnostic, WrapErr};
use simplelog::{ColorChoice, TermLogger, TerminalMode};
use std::path::PathBuf;
use structopt::StructOpt;
mod commands;
mod config;
@ -10,72 +10,79 @@ mod downloader;
mod forge;
mod util;
#[derive(StructOpt)]
#[derive(Parser)]
struct Opt {
#[structopt(short, long, parse(from_occurrences), help = "enable verbose logging")]
/// enable verbose logging
#[clap(short, long, parse(from_occurrences))]
verbose: u8,
#[structopt(subcommand)]
/// add a parameter to be used by the build script
/// (only useful with lua manifests)
#[clap(short = 'D')]
defines: Vec<String>,
#[clap(subcommand)]
cmd: Command,
}
#[derive(StructOpt)]
#[derive(Subcommand)]
enum Command {
#[structopt(about = "Initializes a new modpack")]
/// Initializes a new modpack
Init {
#[structopt(help = "The name of the modpack")]
/// The name of the modpack
modpack_name: String,
#[structopt(help = "Name of the modpack author")]
/// Name of the modpack author
name: String,
#[structopt(help = "The minecraft version of the modpack")]
/// The minecraft version of the modpack
mcversion: String,
},
#[structopt(name = "downloadmods", about = "Downloads mods of the pack")]
/// Downloads mods of the pack
#[clap(name = "downloadmods")]
DownloadMods {
#[structopt(help = "Directory to download mods to")]
/// Directory to download mods to
dir: PathBuf,
#[structopt(short, long, help = "Download all relations and not just mods")]
/// Download all relations and not just mods
#[clap(short, long)]
all: bool,
},
#[structopt(name = "buildtwitch", about = "Builds a twitch export of the pack")]
/// Builds a twitch export of the pack
#[clap(name = "buildtwitch")]
BuildTwitch {
#[structopt(
short,
long,
help = "Downloads all relations instead of just required ones"
)]
/// Downloads all relations instead of just required ones
#[clap(short, long)]
all: bool,
},
#[structopt(about = "Deletes artifacts and temporary files")]
/// Deletes artifacts and temporary files
Clean,
#[structopt(
name = "createmodlist",
about = "Creates a HTML list of the pack's mods."
)]
/// Creates a HTML list of the pack's mods
#[clap(name = "createmodlist")]
CreateModList {
#[structopt(
default_value = "build/modlist.html",
help = "File to write the mod list to"
)]
/// File to write the mod list to
#[clap(default_value = "build/modlist.html")]
outfile: PathBuf,
},
#[structopt(
about = "Imports a twitch manifest file and converts it to an addonscript modpack.json"
)]
/// Imports a twitch manifest file and converts it to an addonscript
/// modpack.json
Import {
#[structopt(help = "Twitch manifest to convert")]
/// Twitch manifest to convert
infile: PathBuf,
},
}
#[tokio::main]
async fn main() -> miette::Result<()> {
let Opt { cmd, verbose } = Opt::from_args();
let Opt {
cmd,
defines,
verbose,
} = Opt::parse();
let log_level = match verbose {
0 => LevelFilter::Off,
@ -104,7 +111,7 @@ async fn main() -> miette::Result<()> {
};
(manifest: $cmd:ident $($args:expr),* $(,)?) => {
run_cmd!($cmd util::parse_config_and_manifest().await?, $($args),*)
run_cmd!($cmd util::parse_config_and_manifest(defines, stringify!($cmd)).await?, $($args),*)
};
($cmd:ident $($args:expr),* $(,)?) => {{

View File

@ -24,15 +24,19 @@ pub async fn parse_config() -> miette::Result<Config> {
.await
.into_diagnostic()
.wrap_err("Failed to read config")?;
Ok(toml::from_slice(&conf)
toml::from_slice(&conf)
.into_diagnostic()
.wrap_err("Failed to parse config")?)
.wrap_err("Failed to parse config")
}
/// parses the config from the current working directory, reads the location of
/// the manifest file from it, parses the manifest and returns both the conig
/// and the manifest.
pub async fn parse_config_and_manifest() -> miette::Result<(Config, Manifest)> {
pub async fn parse_config_and_manifest(
defines: Vec<String>,
command: &str,
) -> miette::Result<(Config, Manifest)> {
let config = parse_config().await?;
let src = Path::new(&config.locations.src);
@ -55,6 +59,13 @@ pub async fn parse_config_and_manifest() -> miette::Result<(Config, Manifest)> {
let manifest = if is_lua {
let lua = Lua::new();
let mpt = lua.create_table().into_diagnostic()?;
mpt.set("defines", defines).into_diagnostic()?;
mpt.set("command", command).into_diagnostic()?;
lua.globals().set("mpt", mpt).into_diagnostic()?;
lua.load(&data)
.exec()
.into_diagnostic()
@ -185,8 +196,7 @@ pub enum UrlFileNameError {
pub fn url_file_name(url: &Url) -> Result<String, UrlFileNameError> {
let file_name = url
.path_segments()
.map(Iterator::last)
.flatten()
.and_then(Iterator::last)
.ok_or(UrlFileNameError::BaseUrl)?;
if file_name.is_empty() {

View File

@ -7,6 +7,6 @@ edition = "2018"
[dependencies]
addonscript = { path = "../addonscript" }
serde = { version = "1.0.130", features = ["derive"] }
thiserror = "1.0.28"
serde = { version = "1.0.136", features = ["derive"] }
thiserror = "1.0.30"
url = { version = "2.2.2", features = ["serde"] }