Skip to content

Commit

Permalink
Add support for Pub (Dart) projects (#62)
Browse files Browse the repository at this point in the history
* Add Pub project cleaning

* Add link to dartlang site
  • Loading branch information
Desdaemon authored Sep 25, 2022
1 parent 72f9b5c commit 4764be1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ It will identify the disk space savings you would get from deleting temporary/un
- [Python](https://www.python.org/) projects
- [CMake](https://cmake.org) projects
- [Composer](https://getcomposer.org/) projects (PHP)
- [Pub](https://dart.dev/) projects (Dart)

## Installation

Expand Down
13 changes: 13 additions & 0 deletions kondo-lib/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const FILE_UNREAL_SUFFIX: &str = ".uproject";
const FILE_JUPYTER_SUFFIX: &str = ".ipynb";
const FILE_PYTHON_SUFFIX: &str = ".py";
const FILE_COMPOSER_JSON: &str = "composer.json";
const FILE_PUBSPEC_YAML: &str = "pubspec.yaml";

const PROJECT_CARGO_DIRS: [&str; 1] = ["target"];
const PROJECT_NODE_DIRS: [&str; 1] = ["node_modules"];
Expand All @@ -42,6 +43,12 @@ const PROJECT_UNREAL_DIRS: [&str; 5] = [
const PROJECT_JUPYTER_DIRS: [&str; 1] = [".ipynb_checkpoints"];
const PROJECT_PYTHON_DIRS: [&str; 3] = ["__pycache__", "__pypackages__", ".venv"];
const PROJECT_COMPOSER_DIRS: [&str; 1] = ["vendor"];
const PROJECT_PUB_DIRS: [&str; 4] = [
"build",
".dart_tool",
"linux/flutter/ephemeral",
"windows/flutter/ephemeral",
];

const PROJECT_CARGO_NAME: &str = "Cargo";
const PROJECT_NODE_NAME: &str = "Node";
Expand All @@ -54,6 +61,7 @@ const PROJECT_UNREAL_NAME: &str = "Unreal";
const PROJECT_JUPYTER_NAME: &str = "Jupyter";
const PROJECT_PYTHON_NAME: &str = "Python";
const PROJECT_COMPOSER_NAME: &str = "Composer";
const PROJECT_PUB_NAME: &str = "Pub";

#[derive(Debug, Clone)]
pub enum ProjectType {
Expand All @@ -69,6 +77,7 @@ pub enum ProjectType {
Jupyter,
Python,
Composer,
Pub,
}

#[derive(Debug, Clone)]
Expand Down Expand Up @@ -98,6 +107,7 @@ impl Project {
ProjectType::Python => &PROJECT_PYTHON_DIRS,
ProjectType::CMake => &PROJECT_CMAKE_DIRS,
ProjectType::Composer => &PROJECT_COMPOSER_DIRS,
ProjectType::Pub => &PROJECT_PUB_DIRS,
}
}

Expand Down Expand Up @@ -178,6 +188,7 @@ impl Project {
ProjectType::Python => PROJECT_PYTHON_NAME,
ProjectType::CMake => PROJECT_CMAKE_NAME,
ProjectType::Composer => PROJECT_COMPOSER_NAME,
ProjectType::Pub => PROJECT_PUB_NAME,
}
}

Expand Down Expand Up @@ -251,6 +262,7 @@ impl Iterator for ProjectIter {
FILE_MVN_BUILD => Some(ProjectType::Maven),
FILE_CMAKE_BUILD => Some(ProjectType::CMake),
FILE_COMPOSER_JSON => Some(ProjectType::Composer),
FILE_PUBSPEC_YAML => Some(ProjectType::Pub),
file_name if file_name.ends_with(FILE_UNREAL_SUFFIX) => {
Some(ProjectType::Unreal)
}
Expand Down Expand Up @@ -328,6 +340,7 @@ pub fn clean(project_path: &str) -> Result<(), Box<dyn error::Error>> {
FILE_MVN_BUILD => Some(ProjectType::Maven),
FILE_CMAKE_BUILD => Some(ProjectType::CMake),
FILE_COMPOSER_JSON => Some(ProjectType::Composer),
FILE_PUBSPEC_YAML => Some(ProjectType::Pub),
_ => None,
};
if let Some(project_type) = p_type {
Expand Down

0 comments on commit 4764be1

Please sign in to comment.