feat: remove unnecessary feature flags

This commit is contained in:
daimond113 2024-09-29 00:26:46 +02:00
parent afee3a0c2a
commit 821cc989ef
No known key found for this signature in database
GPG key ID: 3A8ECE51328B513C
11 changed files with 13 additions and 87 deletions

View file

@ -28,10 +28,7 @@ bin = [
"serde_json", "serde_json",
"winreg" "winreg"
] ]
wally-compat = ["zip", "serde_json", "roblox"] wally-compat = ["zip", "serde_json"]
roblox = []
lune = []
luau = []
patches = ["git2"] patches = ["git2"]
[[bin]] [[bin]]

View file

@ -47,9 +47,6 @@ sentry-log = "0.34.0"
sentry-actix = "0.34.0" sentry-actix = "0.34.0"
pesde = { path = "..", features = [ pesde = { path = "..", features = [
"roblox",
"lune",
"luau",
"wally-compat", "wally-compat",
"git2", "git2",
] } ] }

View file

@ -105,14 +105,7 @@ impl InitCommand {
let target_env = inquire::Select::new( let target_env = inquire::Select::new(
"What environment are you targeting for your package?", "What environment are you targeting for your package?",
vec![ vec!["roblox", "roblox_server", "lune", "luau"],
#[cfg(feature = "roblox")]
"roblox",
#[cfg(feature = "lune")]
"lune",
#[cfg(feature = "luau")]
"luau",
],
) )
.prompt() .prompt()
.unwrap(); .unwrap();
@ -121,6 +114,7 @@ impl InitCommand {
["environment"] = toml_edit::value(target_env); ["environment"] = toml_edit::value(target_env);
if target_env == "roblox" if target_env == "roblox"
|| target_env == "roblox_server"
|| inquire::Confirm::new(&format!( || inquire::Confirm::new(&format!(
"Would you like to setup a default {} script?", "Would you like to setup a default {} script?",
ScriptName::RobloxSyncConfigGenerator ScriptName::RobloxSyncConfigGenerator

View file

@ -4,7 +4,6 @@ use pesde::Project;
mod add; mod add;
mod auth; mod auth;
mod config; mod config;
#[cfg(any(feature = "lune", feature = "luau"))]
mod execute; mod execute;
mod init; mod init;
mod install; mod install;
@ -65,7 +64,6 @@ pub enum Subcommand {
Outdated(outdated::OutdatedCommand), Outdated(outdated::OutdatedCommand),
/// Executes a binary package without needing to be run in a project directory /// Executes a binary package without needing to be run in a project directory
#[cfg(any(feature = "lune", feature = "luau"))]
#[clap(name = "x", visible_alias = "execute", visible_alias = "exec")] #[clap(name = "x", visible_alias = "execute", visible_alias = "exec")]
Execute(execute::ExecuteCommand), Execute(execute::ExecuteCommand),
} }
@ -93,7 +91,6 @@ impl Subcommand {
Subcommand::Add(add) => add.run(project), Subcommand::Add(add) => add.run(project),
Subcommand::Update(update) => update.run(project, multi, reqwest), Subcommand::Update(update) => update.run(project, multi, reqwest),
Subcommand::Outdated(outdated) => outdated.run(project), Subcommand::Outdated(outdated) => outdated.run(project),
#[cfg(any(feature = "lune", feature = "luau"))]
Subcommand::Execute(execute) => execute.run(project, reqwest), Subcommand::Execute(execute) => execute.run(project, reqwest),
} }
} }

View file

@ -46,7 +46,6 @@ impl PublishCommand {
anyhow::bail!("no exports found in target"); anyhow::bail!("no exports found in target");
} }
#[cfg(feature = "roblox")]
if matches!( if matches!(
manifest.target, manifest.target,
Target::Roblox { .. } | Target::RobloxServer { .. } Target::Roblox { .. } | Target::RobloxServer { .. }
@ -82,7 +81,6 @@ impl PublishCommand {
)); ));
let mut display_includes: Vec<String> = vec![MANIFEST_FILE_NAME.to_string()]; let mut display_includes: Vec<String> = vec![MANIFEST_FILE_NAME.to_string()];
#[cfg(feature = "roblox")]
let mut display_build_files: Vec<String> = vec![]; let mut display_build_files: Vec<String> = vec![];
let (lib_path, bin_path, target_kind) = ( let (lib_path, bin_path, target_kind) = (
@ -91,14 +89,11 @@ impl PublishCommand {
manifest.target.kind(), manifest.target.kind(),
); );
#[cfg(feature = "roblox")]
let mut roblox_target = match &mut manifest.target { let mut roblox_target = match &mut manifest.target {
Target::Roblox { build_files, .. } => Some(build_files), Target::Roblox { build_files, .. } => Some(build_files),
Target::RobloxServer { build_files, .. } => Some(build_files), Target::RobloxServer { build_files, .. } => Some(build_files),
_ => None, _ => None,
}; };
#[cfg(not(feature = "roblox"))]
let roblox_target = None::<()>;
if !manifest.includes.insert(MANIFEST_FILE_NAME.to_string()) { if !manifest.includes.insert(MANIFEST_FILE_NAME.to_string()) {
display_includes.push(MANIFEST_FILE_NAME.to_string()); display_includes.push(MANIFEST_FILE_NAME.to_string());
@ -398,20 +393,16 @@ impl PublishCommand {
.map_or("(none)".to_string(), |p| p.to_string()) .map_or("(none)".to_string(), |p| p.to_string())
); );
match roblox_target { if roblox_target {
#[cfg(feature = "roblox")] println!("\tbuild files: {}", display_build_files.join(", "));
true => { } else {
println!("\tbuild files: {}", display_build_files.join(", ")); println!(
} "\tbin path: {}",
_ => { manifest
println!( .target
"\tbin path: {}", .bin_path()
manifest .map_or("(none)".to_string(), |p| p.to_string())
.target );
.bin_path()
.map_or("(none)".to_string(), |p| p.to_string())
);
}
} }
println!( println!(

View file

@ -3,9 +3,6 @@
//! pesde has its own registry, however it can also use Wally, and Git repositories as package sources. //! pesde has its own registry, however it can also use Wally, and Git repositories as package sources.
//! It has been designed with multiple targets in mind, namely Roblox, Lune, and Luau. //! It has been designed with multiple targets in mind, namely Roblox, Lune, and Luau.
#[cfg(not(any(feature = "roblox", feature = "lune", feature = "luau")))]
compile_error!("at least one of the features `roblox`, `lune`, or `luau` must be enabled");
use crate::{lockfile::Lockfile, manifest::Manifest}; use crate::{lockfile::Lockfile, manifest::Manifest};
use gix::sec::identity::Account; use gix::sec::identity::Account;
use std::{ use std::{

View file

@ -105,7 +105,6 @@ pub fn get_lib_require_path(
path path
}; };
#[cfg(feature = "roblox")]
if matches!(target, TargetKind::Roblox | TargetKind::RobloxServer) { if matches!(target, TargetKind::Roblox | TargetKind::RobloxServer) {
let (prefix, path) = match target.try_into() { let (prefix, path) = match target.try_into() {
Ok(place_kind) if !destination_dir.starts_with(root_container_dir) => ( Ok(place_kind) if !destination_dir.starts_with(root_container_dir) => (
@ -177,7 +176,6 @@ pub mod errors {
#[derive(Debug, Error)] #[derive(Debug, Error)]
pub enum GetLibRequirePath { pub enum GetLibRequirePath {
/// The path for the RobloxPlaceKind could not be found /// The path for the RobloxPlaceKind could not be found
#[cfg(feature = "roblox")]
#[error("could not find the path for the RobloxPlaceKind {0}")] #[error("could not find the path for the RobloxPlaceKind {0}")]
RobloxPlaceKindPathNotFound(crate::manifest::target::RobloxPlaceKind), RobloxPlaceKindPathNotFound(crate::manifest::target::RobloxPlaceKind),
} }

View file

@ -90,7 +90,6 @@ impl Project {
.or_default() .or_default()
.insert(version_id, types); .insert(version_id, types);
#[cfg(feature = "roblox")]
if let Some(build_files) = Some(&node.target) if let Some(build_files) = Some(&node.target)
.filter(|_| !node.node.pkg_ref.like_wally()) .filter(|_| !node.node.pkg_ref.like_wally())
.and_then(|t| t.build_files()) .and_then(|t| t.build_files())
@ -281,7 +280,6 @@ pub mod errors {
FullMoon(String, Vec<full_moon::Error>), FullMoon(String, Vec<full_moon::Error>),
/// An error occurred while generating a Roblox sync config /// An error occurred while generating a Roblox sync config
#[cfg(feature = "roblox")]
#[error("error generating roblox sync config for {0}")] #[error("error generating roblox sync config for {0}")]
GenerateRobloxSyncConfig(String, #[source] std::io::Error), GenerateRobloxSyncConfig(String, #[source] std::io::Error),

View file

@ -77,7 +77,6 @@ pub struct Manifest {
/// A list of globs pointing to workspace members' directories /// A list of globs pointing to workspace members' directories
#[serde(default, skip_serializing_if = "Vec::is_empty")] #[serde(default, skip_serializing_if = "Vec::is_empty")]
pub workspace_members: Vec<String>, pub workspace_members: Vec<String>,
#[cfg(feature = "roblox")]
/// The Roblox place of this project /// The Roblox place of this project
#[serde(default, skip_serializing)] #[serde(default, skip_serializing)]
pub place: BTreeMap<target::RobloxPlaceKind, String>, pub place: BTreeMap<target::RobloxPlaceKind, String>,

View file

@ -13,29 +13,21 @@ use std::{
)] )]
pub enum TargetKind { pub enum TargetKind {
/// A Roblox target /// A Roblox target
#[cfg(feature = "roblox")]
Roblox, Roblox,
/// A Roblox server target /// A Roblox server target
#[cfg(feature = "roblox")]
RobloxServer, RobloxServer,
/// A Lune target /// A Lune target
#[cfg(feature = "lune")]
Lune, Lune,
/// A Luau target /// A Luau target
#[cfg(feature = "luau")]
Luau, Luau,
} }
impl Display for TargetKind { impl Display for TargetKind {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
match self { match self {
#[cfg(feature = "roblox")]
TargetKind::Roblox => write!(f, "roblox"), TargetKind::Roblox => write!(f, "roblox"),
#[cfg(feature = "roblox")]
TargetKind::RobloxServer => write!(f, "roblox_server"), TargetKind::RobloxServer => write!(f, "roblox_server"),
#[cfg(feature = "lune")]
TargetKind::Lune => write!(f, "lune"), TargetKind::Lune => write!(f, "lune"),
#[cfg(feature = "luau")]
TargetKind::Luau => write!(f, "luau"), TargetKind::Luau => write!(f, "luau"),
} }
} }
@ -46,13 +38,9 @@ impl FromStr for TargetKind {
fn from_str(s: &str) -> Result<Self, Self::Err> { fn from_str(s: &str) -> Result<Self, Self::Err> {
match s { match s {
#[cfg(feature = "roblox")]
"roblox" => Ok(Self::Roblox), "roblox" => Ok(Self::Roblox),
#[cfg(feature = "roblox")]
"roblox_server" => Ok(Self::RobloxServer), "roblox_server" => Ok(Self::RobloxServer),
#[cfg(feature = "lune")]
"lune" => Ok(Self::Lune), "lune" => Ok(Self::Lune),
#[cfg(feature = "luau")]
"luau" => Ok(Self::Luau), "luau" => Ok(Self::Luau),
t => Err(errors::TargetKindFromStr::Unknown(t.to_string())), t => Err(errors::TargetKindFromStr::Unknown(t.to_string())),
} }
@ -62,13 +50,9 @@ impl FromStr for TargetKind {
impl TargetKind { impl TargetKind {
/// All possible target variants /// All possible target variants
pub const VARIANTS: &'static [TargetKind] = &[ pub const VARIANTS: &'static [TargetKind] = &[
#[cfg(feature = "roblox")]
TargetKind::Roblox, TargetKind::Roblox,
#[cfg(feature = "roblox")]
TargetKind::RobloxServer, TargetKind::RobloxServer,
#[cfg(feature = "lune")]
TargetKind::Lune, TargetKind::Lune,
#[cfg(feature = "luau")]
TargetKind::Luau, TargetKind::Luau,
]; ];
@ -91,7 +75,6 @@ impl TargetKind {
#[serde(rename_all = "snake_case", tag = "environment")] #[serde(rename_all = "snake_case", tag = "environment")]
pub enum Target { pub enum Target {
/// A Roblox target /// A Roblox target
#[cfg(feature = "roblox")]
Roblox { Roblox {
/// The path to the lib export file /// The path to the lib export file
#[serde(default)] #[serde(default)]
@ -101,7 +84,6 @@ pub enum Target {
build_files: BTreeSet<String>, build_files: BTreeSet<String>,
}, },
/// A Roblox server target /// A Roblox server target
#[cfg(feature = "roblox")]
RobloxServer { RobloxServer {
/// The path to the lib export file /// The path to the lib export file
#[serde(default)] #[serde(default)]
@ -111,7 +93,6 @@ pub enum Target {
build_files: BTreeSet<String>, build_files: BTreeSet<String>,
}, },
/// A Lune target /// A Lune target
#[cfg(feature = "lune")]
Lune { Lune {
/// The path to the lib export file /// The path to the lib export file
#[serde(default)] #[serde(default)]
@ -121,7 +102,6 @@ pub enum Target {
bin: Option<RelativePathBuf>, bin: Option<RelativePathBuf>,
}, },
/// A Luau target /// A Luau target
#[cfg(feature = "luau")]
Luau { Luau {
/// The path to the lib export file /// The path to the lib export file
#[serde(default)] #[serde(default)]
@ -136,13 +116,9 @@ impl Target {
/// Returns the kind of this target /// Returns the kind of this target
pub fn kind(&self) -> TargetKind { pub fn kind(&self) -> TargetKind {
match self { match self {
#[cfg(feature = "roblox")]
Target::Roblox { .. } => TargetKind::Roblox, Target::Roblox { .. } => TargetKind::Roblox,
#[cfg(feature = "roblox")]
Target::RobloxServer { .. } => TargetKind::RobloxServer, Target::RobloxServer { .. } => TargetKind::RobloxServer,
#[cfg(feature = "lune")]
Target::Lune { .. } => TargetKind::Lune, Target::Lune { .. } => TargetKind::Lune,
#[cfg(feature = "luau")]
Target::Luau { .. } => TargetKind::Luau, Target::Luau { .. } => TargetKind::Luau,
} }
} }
@ -150,13 +126,9 @@ impl Target {
/// Returns the path to the lib export file /// Returns the path to the lib export file
pub fn lib_path(&self) -> Option<&RelativePathBuf> { pub fn lib_path(&self) -> Option<&RelativePathBuf> {
match self { match self {
#[cfg(feature = "roblox")]
Target::Roblox { lib, .. } => lib.as_ref(), Target::Roblox { lib, .. } => lib.as_ref(),
#[cfg(feature = "roblox")]
Target::RobloxServer { lib, .. } => lib.as_ref(), Target::RobloxServer { lib, .. } => lib.as_ref(),
#[cfg(feature = "lune")]
Target::Lune { lib, .. } => lib.as_ref(), Target::Lune { lib, .. } => lib.as_ref(),
#[cfg(feature = "luau")]
Target::Luau { lib, .. } => lib.as_ref(), Target::Luau { lib, .. } => lib.as_ref(),
} }
} }
@ -164,13 +136,9 @@ impl Target {
/// Returns the path to the bin export file /// Returns the path to the bin export file
pub fn bin_path(&self) -> Option<&RelativePathBuf> { pub fn bin_path(&self) -> Option<&RelativePathBuf> {
match self { match self {
#[cfg(feature = "roblox")]
Target::Roblox { .. } => None, Target::Roblox { .. } => None,
#[cfg(feature = "roblox")]
Target::RobloxServer { .. } => None, Target::RobloxServer { .. } => None,
#[cfg(feature = "lune")]
Target::Lune { bin, .. } => bin.as_ref(), Target::Lune { bin, .. } => bin.as_ref(),
#[cfg(feature = "luau")]
Target::Luau { bin, .. } => bin.as_ref(), Target::Luau { bin, .. } => bin.as_ref(),
} }
} }
@ -178,9 +146,7 @@ impl Target {
/// Returns the Roblox build files /// Returns the Roblox build files
pub fn build_files(&self) -> Option<&BTreeSet<String>> { pub fn build_files(&self) -> Option<&BTreeSet<String>> {
match self { match self {
#[cfg(feature = "roblox")]
Target::Roblox { build_files, .. } => Some(build_files), Target::Roblox { build_files, .. } => Some(build_files),
#[cfg(feature = "roblox")]
Target::RobloxServer { build_files, .. } => Some(build_files), Target::RobloxServer { build_files, .. } => Some(build_files),
_ => None, _ => None,
} }
@ -193,7 +159,6 @@ impl Display for Target {
} }
} }
#[cfg(feature = "roblox")]
/// The kind of a Roblox place property /// The kind of a Roblox place property
#[derive( #[derive(
SerializeDisplay, Deserialize, Debug, Clone, Copy, PartialEq, Eq, Hash, Ord, PartialOrd, SerializeDisplay, Deserialize, Debug, Clone, Copy, PartialEq, Eq, Hash, Ord, PartialOrd,
@ -206,7 +171,6 @@ pub enum RobloxPlaceKind {
Server, Server,
} }
#[cfg(feature = "roblox")]
impl TryInto<RobloxPlaceKind> for &TargetKind { impl TryInto<RobloxPlaceKind> for &TargetKind {
type Error = (); type Error = ();
@ -219,7 +183,6 @@ impl TryInto<RobloxPlaceKind> for &TargetKind {
} }
} }
#[cfg(feature = "roblox")]
impl Display for RobloxPlaceKind { impl Display for RobloxPlaceKind {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
match self { match self {

View file

@ -12,7 +12,6 @@ use std::{
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub enum ScriptName { pub enum ScriptName {
/// Generates a config for syncing tools for Roblox. For example, for Rojo it should create a `default.project.json` file /// Generates a config for syncing tools for Roblox. For example, for Rojo it should create a `default.project.json` file
#[cfg(feature = "roblox")]
RobloxSyncConfigGenerator, RobloxSyncConfigGenerator,
/// Prints a sourcemap for a Wally package, used for finding the library export file /// Prints a sourcemap for a Wally package, used for finding the library export file
#[cfg(feature = "wally-compat")] #[cfg(feature = "wally-compat")]
@ -21,15 +20,11 @@ pub enum ScriptName {
impl Display for ScriptName { impl Display for ScriptName {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
#[cfg(feature = "roblox")]
match self { match self {
#[cfg(feature = "roblox")]
ScriptName::RobloxSyncConfigGenerator => write!(f, "roblox_sync_config_generator"), ScriptName::RobloxSyncConfigGenerator => write!(f, "roblox_sync_config_generator"),
#[cfg(feature = "wally-compat")] #[cfg(feature = "wally-compat")]
ScriptName::SourcemapGenerator => write!(f, "sourcemap_generator"), ScriptName::SourcemapGenerator => write!(f, "sourcemap_generator"),
} }
#[cfg(not(feature = "roblox"))]
Ok(())
} }
} }