Skip to content

Commit

Permalink
Dev CLI: Remove targets record file on clean.
Browse files Browse the repository at this point in the history
Remove record file entirely on the start of an clean job instead
of trying to update the record file, making clean command more reliable
because updating the record file may fail more often than removing it.
  • Loading branch information
AmmarAbouZor committed Feb 17, 2025
1 parent 4c56636 commit ceabc14
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 21 deletions.
6 changes: 6 additions & 0 deletions cli/development-cli/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# 0.4.1

## Changes:

* Clean command removes checksum records entirely, making it more reliable.

# 0.4.0

## Changes:
Expand Down
2 changes: 1 addition & 1 deletion cli/development-cli/Cargo.lock

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

2 changes: 1 addition & 1 deletion cli/development-cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "cargo-chipmunk"
version = "0.4.0"
version = "0.4.1"
authors = ["Ammar Abou Zor <[email protected]>"]
edition = "2021"
description = "CLI Tool for chipmunk application development"
Expand Down
9 changes: 0 additions & 9 deletions cli/development-cli/src/build_state_records.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,15 +259,6 @@ impl BuildStateRecords {
})
}

/// Remove the target from the states records
pub fn remove_state_if_exist(&mut self, target: Target) -> anyhow::Result<()> {
self.involved_targets.insert(target);

self.states.remove(&target);

Ok(())
}

/// Clears the states from previous build then calculates the states for the involved targets.
fn update_records(&mut self) -> anyhow::Result<()> {
self.states.clear();
Expand Down
2 changes: 2 additions & 0 deletions cli/development-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,8 @@ async fn main_process(command: Command) -> Result<(), Error> {
JobsState::init(JobsConfig::new(false));
init_tracker(ui_mode);
validate_dev_tools()?;

BuildStateRecords::remove_records_file()?;
let targets = get_targets_or_all(target);
let results = jobs_runner::run(&targets, JobType::Clean).await?;
(JobType::Clean, results)
Expand Down
10 changes: 0 additions & 10 deletions cli/development-cli/src/target/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ use std::{borrow::Cow, collections::BTreeSet, fmt::Display, iter, path::PathBuf,
use tokio::fs;

use crate::{
build_state_records::BuildStateRecords,
dev_tools::DevTool,
fstools,
job_type::JobType,
Expand Down Expand Up @@ -515,15 +514,6 @@ impl Target {
pub async fn reset(&self) -> anyhow::Result<SpawnResult> {
let job_def = JobDefinition::new(*self, JobType::Clean);

{
// Clean doesn't differentiate between development and production, and both of them will be
// cleaned from the files when the data are persisted.
let mut checksum = BuildStateRecords::get(false)?.lock().map_err(|err| {
anyhow::anyhow!("Error while acquiring items jobs mutex: Error {err}")
})?;
checksum.remove_state_if_exist(*self)?;
}

let mut paths_to_remove = vec![self.cwd().join("dist")];
let path = match self.kind() {
TargetKind::Ts => self.cwd().join("node_modules"),
Expand Down

0 comments on commit ceabc14

Please sign in to comment.