-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Added support for deleting a system - Added support for deleting a base - Added a link for slack channel to readme Co-authored-by: Joakim Tengstrand <[email protected]>
- Loading branch information
1 parent
2e9e8a5
commit da2b6cb
Showing
10 changed files
with
626 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,36 @@ | ||
(ns leiningen.polylith.cmd.delete | ||
(:require [leiningen.polylith.cmd.delete.component :as delete-component] | ||
[leiningen.polylith.cmd.delete.base :as delete-base] | ||
[leiningen.polylith.cmd.delete.system :as delete-system] | ||
[leiningen.polylith.cmd.shared :as shared])) | ||
|
||
(defn validate [ws-path cmd component] | ||
(let [components (shared/all-components ws-path)] | ||
(defn validate [ws-path type entity entity2] | ||
(let [components (shared/all-components ws-path) | ||
bases (shared/all-bases ws-path) | ||
systems (shared/all-systems ws-path)] | ||
(cond | ||
(not (shared/component? cmd)) [false "Illegal first argument."] | ||
(not (contains? components component)) [false (str "Component '" component "' does not exist.")] | ||
(not (or (shared/component? type) | ||
(shared/base? type) | ||
(shared/system? type))) [false "Illegal first argument."] | ||
(and (shared/component? type) | ||
(not (contains? components entity))) [false (str "Component '" entity "' does not exist.")] | ||
(and (shared/base? type) | ||
(not (contains? bases entity))) [false (str "Base '" entity "' does not exist.")] | ||
(and (shared/system? type) | ||
(not (contains? systems entity))) [false (str "System '" entity "' does not exist.")] | ||
(and (shared/system? type) | ||
(-> entity2 nil? not) | ||
(not (contains? bases entity2))) [false (str "Base '" entity2 "' does not exist.")] | ||
:else [true]))) | ||
|
||
(defn execute [ws-path top-dir [cmd component]] | ||
(let [[ok? message] (validate ws-path cmd component)] | ||
(defn execute [ws-path top-dir [type entity entity2]] | ||
(let [[ok? message] (validate ws-path type entity entity2)] | ||
(if ok? | ||
(delete-component/delete ws-path top-dir component) | ||
(do | ||
(when (shared/component? type) | ||
(delete-component/delete ws-path top-dir entity)) | ||
(when (shared/base? type) | ||
(delete-base/delete ws-path top-dir entity)) | ||
(when (shared/system? type) | ||
(delete-system/delete ws-path top-dir entity entity2))) | ||
(println message)))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
(ns leiningen.polylith.cmd.delete.base | ||
(:require [leiningen.polylith.cmd.shared :as shared] | ||
[leiningen.polylith.file :as file])) | ||
|
||
(defn delete-from-environment [base ns-dir dev-path] | ||
(file/delete-dir (str dev-path "/docs/" base "-readme.md")) | ||
(file/delete-dir (str dev-path "/project-files/bases/" base "-project.clj")) | ||
(file/delete-dir (str dev-path "/resources/" base)) | ||
(file/delete-dir (str dev-path "/src/" ns-dir)) | ||
(file/delete-dir (str dev-path "/test/" ns-dir))) | ||
|
||
(defn delete [ws-path top-dir base] | ||
(let [base-dir (str ws-path "/bases/" base) | ||
base-ns-dir (shared/full-dir-name top-dir base) | ||
dev-dirs (file/directory-names (str ws-path "/environments")) | ||
system-dirs (file/directory-names (str ws-path "/systems")) | ||
env-path (str ws-path "/environments/") | ||
ns-dir (shared/full-dir-name top-dir base)] | ||
(file/delete-dir base-dir) | ||
(doseq [sys-dir system-dirs] | ||
(file/delete-file! (str ws-path "/systems/" sys-dir "/src/" base-ns-dir)) | ||
(file/delete-file! (str ws-path "/systems/" sys-dir "/resources/" base))) | ||
(doseq [dev-dir dev-dirs] | ||
(delete-from-environment base ns-dir (str env-path dev-dir))))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
(ns leiningen.polylith.cmd.delete.system | ||
(:require [leiningen.polylith.cmd.shared :as shared] | ||
[leiningen.polylith.file :as file] | ||
[leiningen.polylith.cmd.delete.base :as delete-base])) | ||
|
||
(defn delete-from-environment [system ns-dir dev-path] | ||
(file/delete-dir (str dev-path "/docs/" system "-readme.md")) | ||
(file/delete-dir (str dev-path "/project-files/systems/" system "-project.clj")) | ||
(file/delete-dir (str dev-path "/src/" ns-dir)) | ||
(file/delete-dir (str dev-path "/test/" ns-dir))) | ||
|
||
(defn delete [ws-path top-dir system base] | ||
(let [system-dir (str ws-path "/systems/" system) | ||
dev-dirs (file/directory-names (str ws-path "/environments")) | ||
env-path (str ws-path "/environments/") | ||
ns-dir (shared/full-dir-name top-dir system)] | ||
(when base | ||
(delete-base/delete ws-path top-dir base)) | ||
(file/delete-dir system-dir) | ||
(doseq [dev-dir dev-dirs] | ||
(delete-from-environment system ns-dir (str env-path dev-dir))))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,28 @@ | ||
(ns leiningen.polylith.cmd.help.delete) | ||
|
||
(defn help [] | ||
(println " Deletes a component and its interface if no other components use it.") | ||
(println " Deletes a component and its interface if no other components use it:") | ||
(println) | ||
(println " lein polylith delete c NAME") | ||
(println " NAME = component to delete") | ||
(println " lein polylith delete c[omponent] NAME") | ||
(println " NAME = Component name") | ||
(println " --------------------------------------------------------") | ||
(println " Deletes a base:") | ||
(println) | ||
(println " lein polylith delete b[ase] NAME") | ||
(println " NAME = Base name.") | ||
(println " --------------------------------------------------------") | ||
(println " Deletes a system (and its base if given):") | ||
(println) | ||
(println " lein polylith delete s[ystem] NAME [BASE]") | ||
(println " NAME = System name.") | ||
(println " BASE = Base name.") | ||
(println) | ||
(println " example:") | ||
(println " lein polylith delete c mycomponent")) | ||
(println " lein polylith delete c mycomponent") | ||
(println " lein polylith delete component mycomponent") | ||
(println " lein polylith delete b mybase") | ||
(println " lein polylith create base mybase") | ||
(println " lein polylith delete s mysystem") | ||
(println " lein polylith delete system mysystem") | ||
(println " lein polylith delete s mysystem mybase") | ||
(println " lein polylith delete system mysystem mybase")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
(ns leiningen.polylith.version) | ||
|
||
(def version "0.2.2") | ||
(def date "2019-02-14") | ||
(def version "0.2.3") | ||
(def date "2020-05-09") |
Oops, something went wrong.