Skip to content

Commit

Permalink
Add with_sourcemap and build_xml settings, improve argon init
Browse files Browse the repository at this point in the history
  • Loading branch information
DervexDev committed May 4, 2024
1 parent 3e96bca commit 245dcc2
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 35 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,17 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),

## [Unreleased]

### Added

- Support for values in boolean flags for `init` command, example: `--git=false`
- New setting `with_sourcemap` - always run commands with sourcemap generation
- New setting `build_xml` - build using XML format by default

### Changed

- You can now specify to update CLI or plugin only in `update` command
- Properties are now serialized alphabetically ([#25])
- Renamed `auto_detect` setting to `detect_project`

[#25]: https://github.com/argon-rbx/argon/pull/25

Expand Down
6 changes: 3 additions & 3 deletions src/cli/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ impl Build {

let project_path = project::resolve(self.project.clone().unwrap_or_default())?;
let sourcemap_path = {
if self.sourcemap {
if self.sourcemap || config.with_sourcemap {
Some(project_path.with_file_name("sourcemap.json"))
} else {
None
Expand All @@ -82,7 +82,7 @@ impl Build {

let project = Project::load(&project_path)?;

let mut xml = self.xml;
let mut xml = self.xml || config.build_xml;
let path = if self.plugin {
if project.is_place() {
exit!("Cannot build plugin from place project");
Expand Down Expand Up @@ -138,7 +138,7 @@ impl Build {
}
.resolve()?;

let use_ts = self.ts || config.ts_mode || if config.auto_detect { project.is_ts() } else { false };
let use_ts = self.ts || config.ts_mode || if config.detect_project { project.is_ts() } else { false };

if use_ts {
argon_info!("Compiling TypeScript files..");
Expand Down
50 changes: 37 additions & 13 deletions src/cli/init.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use anyhow::Result;
use clap::Parser;
use clap::{ArgAction, Parser};
use colored::Colorize;
use std::path::PathBuf;

Expand All @@ -21,20 +21,44 @@ pub struct Init {
license: Option<String>,

/// Configure Git
#[arg(short, long)]
git: bool,
#[arg(
short,
long,
default_missing_value("true"),
num_args(0..=1),
action = ArgAction::Set,
)]
git: Option<bool>,

/// Setup Wally
#[arg(short, long)]
wally: bool,
#[arg(
short,
long,
default_missing_value("true"),
num_args(0..=1),
action = ArgAction::Set,
)]
wally: Option<bool>,

/// Include docs (README, CHANGELOG, etc.)
#[arg(short, long)]
docs: bool,
#[arg(
short,
long,
default_missing_value("true"),
num_args(0..=1),
action = ArgAction::Set,
)]
docs: Option<bool>,

/// Initialize using roblox-ts
#[arg(short, long)]
ts: bool,
#[arg(
short,
long,
default_missing_value("true"),
num_args(0..=1),
action = ArgAction::Set,
)]
ts: Option<bool>,
}

impl Init {
Expand All @@ -44,10 +68,10 @@ impl Init {
let project = self.project.unwrap_or_default();
let template = self.template.unwrap_or(config.template.clone());
let license = self.license.unwrap_or(config.license.clone());
let git = self.git || config.use_git;
let wally = self.wally || config.use_wally;
let docs = self.docs || config.include_docs;
let ts = self.ts || config.ts_mode;
let git = self.git.unwrap_or(config.use_git);
let wally = self.wally.unwrap_or(config.use_wally);
let docs = self.docs.unwrap_or(config.include_docs);
let ts = self.ts.unwrap_or(config.ts_mode);

if ts {
if workspace::init_ts(&project, &template, &license, git, wally, docs)? {
Expand Down
4 changes: 2 additions & 2 deletions src/cli/serve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ impl Serve {

let project_path = project::resolve(self.project.clone().unwrap_or_default())?;
let sourcemap_path = {
if self.sourcemap {
if self.sourcemap || config.with_sourcemap {
Some(project_path.with_file_name("sourcemap.json"))
} else {
None
Expand All @@ -79,7 +79,7 @@ impl Serve {
exit!("Cannot serve non-place project!");
}

let use_ts = self.ts || config.ts_mode || if config.auto_detect { project.is_ts() } else { false };
let use_ts = self.ts || config.ts_mode || if config.detect_project { project.is_ts() } else { false };

if use_ts {
debug!("Starting roblox-ts");
Expand Down
4 changes: 2 additions & 2 deletions src/cli/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ use crate::{argon_error, argon_info, config::Config, updater};
#[derive(Parser)]
pub struct Update {
/// Update the Argon CLI only
#[clap(short, long)]
#[arg(short, long)]
pub cli: bool,
/// Update the Argon plugin only
#[clap(short, long)]
#[arg(short, long)]
pub plugin: bool,
}

Expand Down
44 changes: 29 additions & 15 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,32 +21,40 @@ pub struct Config {
pub template: String,
/// Default project license (SPDX identifier)
pub license: String,
/// Include documentation in the project (README, CHANGELOG, etc.)
pub include_docs: bool,
/// Use git for source control
pub use_git: bool,
/// Use Wally for package management
pub use_wally: bool,

/// Run Argon asynchronously, freeing up the terminal
pub run_async: bool,
/// Scan for the first available port if selected one is in use
pub scan_ports: bool,
/// Automatically detect project type
pub detect_project: bool,
/// Always run commands with sourcemap generation
pub with_sourcemap: bool,
/// Build using XML format by default
pub build_xml: bool,

/// Check for new Argon releases on startup
pub check_updates: bool,
/// Automatically install Argon updates if available
pub auto_update: bool,
/// Install Roblox plugin locally and keep it updated
pub install_plugin: bool,
/// Share anonymous Argon usage statistics with the community
pub share_stats: bool,
/// Automatically detect project type
pub auto_detect: bool,
/// Use git for source control
pub use_git: bool,
/// Use Wally for package management
pub use_wally: bool,
/// Include documentation in the project (README, LICENSE, etc.)
pub include_docs: bool,

/// Use Rojo namespace by default
pub rojo_mode: bool,
/// Use roblox-ts by default
pub ts_mode: bool,

/// Move files to the bin instead of deleting them (two-way sync)
pub move_to_bin: bool,
/// Share anonymous Argon usage statistics with the community
pub share_stats: bool,
}

impl Default for Config {
Expand All @@ -56,19 +64,25 @@ impl Default for Config {
port: 8000,
template: String::from("place"),
license: String::from("Apache-2.0"),
include_docs: true,
use_git: true,
use_wally: false,

run_async: false,
scan_ports: true,
detect_project: true,
with_sourcemap: false,
build_xml: false,

check_updates: true,
auto_update: false,
install_plugin: true,
share_stats: true,
auto_detect: true,
use_git: true,
use_wally: false,
include_docs: true,

rojo_mode: false,
ts_mode: false,

move_to_bin: false,
share_stats: true,
}
}
}
Expand Down

0 comments on commit 245dcc2

Please sign in to comment.