-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated the conjure script flow project to work with flows and services.
- Loading branch information
1 parent
b7c28d9
commit 7b32f1e
Showing
23 changed files
with
405 additions
and
393 deletions.
There are no files selected for viewing
41 changes: 0 additions & 41 deletions
41
conjure_script_flow/src/conjure/script/destroyers/controller_destroyer.clj
This file was deleted.
Oops, something went wrong.
38 changes: 0 additions & 38 deletions
38
conjure_script_flow/src/conjure/script/destroyers/controller_test_destroyer.clj
This file was deleted.
Oops, something went wrong.
36 changes: 36 additions & 0 deletions
36
conjure_script_flow/src/conjure/script/destroyers/flow_destroyer.clj
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,36 @@ | ||
(ns conjure.script.destroyers.flow-destroyer | ||
(:require [clojure.tools.logging :as logging] | ||
[conjure.flow.util :as util] | ||
[conjure.script.destroyers.flow-test-destroyer :as flow-test-destroyer])) | ||
|
||
(defn | ||
#^{:doc "Prints out how to use the destroy flow command."} | ||
usage [] | ||
(println "You must supply a service (Like hello-world).") | ||
(println "Usage: ./run.sh script/destroy.clj flow <service>")) | ||
|
||
(defn | ||
#^{:doc "Destroys the flow file from the given service."} | ||
destroy-flow-file [service silent] | ||
(if service | ||
(if-let [flows-directory (util/find-flows-directory)] | ||
(if-let [flow-file (util/find-flow-file flows-directory service)] | ||
(let [is-deleted (.delete flow-file)] | ||
(logging/info (str "File " (.getName flow-file) (if is-deleted " destroyed." " not destroyed.")))) | ||
(logging/info "Flow file not found. Doing nothing.")) | ||
(do | ||
(logging/error (str "Could not find flows directory.: " flows-directory)) | ||
(logging/error "Command ignored."))) | ||
(when (not silent) (usage)))) | ||
|
||
(defn | ||
#^{:doc "Destroys a flow file for the service name given in params."} | ||
destroy [params] | ||
(destroy-flow-file (first params) false)) | ||
|
||
(defn | ||
#^{:doc "Destroys all of the files created by the flow_generator."} | ||
destroy-all-dependencies | ||
[{ :keys [service actions silent] :or { actions (), silent false } }] | ||
(destroy-flow-file service silent) | ||
(flow-test-destroyer/destroy-all-dependencies service silent)) |
36 changes: 36 additions & 0 deletions
36
conjure_script_flow/src/conjure/script/destroyers/flow_test_destroyer.clj
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,36 @@ | ||
(ns conjure.script.destroyers.flow-test-destroyer | ||
(:require [clojure.tools.logging :as logging] | ||
[conjure.core.test.util :as util] | ||
[clojure.tools.file-utils :as file-utils])) | ||
|
||
(defn | ||
#^{:doc "Prints out how to use the destroy flow test command."} | ||
usage [] | ||
(println "You must supply a service (Like hello-world).") | ||
(println "Usage: ./run.sh script/destroy.clj flow-test <service>")) | ||
|
||
(defn | ||
#^{:doc "Destroys the flow file from the given service."} | ||
destroy-flow-test-file [service silent] | ||
(if service | ||
(if-let [functional-test-directory (util/find-functional-test-directory)] | ||
(if-let [functional-test-file (util/functional-test-file service functional-test-directory)] | ||
(let [is-deleted (.delete functional-test-file)] | ||
(logging/info (str "File " (.getName functional-test-file) (if is-deleted " destroyed." " not destroyed."))) | ||
(when is-deleted (file-utils/delete-if-empty functional-test-directory))) | ||
(logging/info "Flow test file not found. Doing nothing.")) | ||
(do | ||
(logging/info "Could not find the functional test directory.") | ||
(logging/info "Command ignored."))) | ||
(usage))) | ||
|
||
(defn | ||
#^{:doc "Destroys a flow test file for the service name given in params."} | ||
destroy [params] | ||
(destroy-flow-test-file (first params) false)) | ||
|
||
(defn | ||
#^{:doc "Destroys all of the files created by the flow_test_generator."} | ||
destroy-all-dependencies | ||
([service silent] | ||
(destroy-flow-test-file service silent))) |
72 changes: 0 additions & 72 deletions
72
conjure_script_flow/src/conjure/script/generators/controller_generator.clj
This file was deleted.
Oops, something went wrong.
48 changes: 0 additions & 48 deletions
48
conjure_script_flow/src/conjure/script/generators/controller_test_generator.clj
This file was deleted.
Oops, something went wrong.
72 changes: 72 additions & 0 deletions
72
conjure_script_flow/src/conjure/script/generators/flow_generator.clj
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,72 @@ | ||
(ns conjure.script.generators.flow-generator | ||
(:require [clojure.tools.logging :as logging] | ||
[clojure.string :as str-utils] | ||
[conjure.flow.builder :as builder] | ||
[conjure.flow.util :as util] | ||
[clojure.tools.file-utils :as file-utils] | ||
[conjure.script.generators.flow-test-generator :as flow-test-generator])) | ||
|
||
(defn | ||
#^{ :doc "Prints out how to use the generate flow command." } | ||
usage [] | ||
(println "You must supply a service name (Like hello-world).") | ||
(println "Usage: ./run.sh script/generate.clj flow <service> [action]*")) | ||
|
||
(defn | ||
#^{ :doc "Generates the action function for the given action." } | ||
generate-action-function [action] | ||
(str "(def-action " action " | ||
(bind))")) | ||
|
||
(defn | ||
#^{ :doc "Generates the action functions block for a flow file." } | ||
generate-all-action-functions [actions] | ||
(str-utils/join "\n\n" (map generate-action-function actions))) | ||
|
||
(defn | ||
#^{ :doc "Generates the content of the given flow file." } | ||
generate-flow-content | ||
([service flow-content] (generate-flow-content service flow-content nil)) | ||
([service flow-content requires] | ||
(str "(ns " (util/flow-namespace service) " | ||
(:use [conjure.flow.base])" (when requires (str "\n (:require " requires ")")) ") | ||
" flow-content))) | ||
|
||
(defn | ||
#^{ :doc "Creates a flow file with the given File and file content." } | ||
create-flow-files | ||
[{ :keys [service flow-content actions silent] :or { silent false } }] | ||
(if-let [flows-directory (util/find-flows-directory)] | ||
(do | ||
(when-let [flow-file (builder/create-flow-file | ||
{ :service service, | ||
:flows-directory flows-directory, | ||
:silent silent })] | ||
(file-utils/write-file-content flow-file flow-content)) | ||
(flow-test-generator/generate-functional-test service actions silent)) | ||
(logging/error "Could not find the flows directory"))) | ||
|
||
(defn | ||
#^{ :doc "Generates the flow content and saves it into the given flow file." } | ||
generate-file-content | ||
[{ :keys [service actions silent] :or { silent false } }] | ||
(create-flow-files | ||
{ :service service | ||
:flow-content (generate-flow-content service (generate-all-action-functions actions)) | ||
:actions actions | ||
:silent silent })) | ||
|
||
(defn | ||
#^{ :doc "Creates the flow file associated with the given service." } | ||
generate-flow-file | ||
[{ :keys [service actions silent] :or { actions (), silent false } }] | ||
(if (and service actions) | ||
(generate-file-content { :service service, :actions actions, :silent silent }) | ||
(when (not silent) | ||
(usage)))) | ||
|
||
(defn | ||
#^{ :doc "Generates a flow file for the service name and actions in params." } | ||
generate [params] | ||
(generate-flow-file { :service (first params), :actions (rest params) })) |
Oops, something went wrong.