forked from howsoai/howso-engine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy_howso.amlg
124 lines (106 loc) · 3.84 KB
/
deploy_howso.amlg
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
(seq
;Creates and deploys an instance of the howso trainee as a single file with the specified extension
;along with associated migration scripts. Stores out the file from source code with the updated current version.
;
; This file needs to be executed after any changes are made to any Howso code in order to generate the binary file version of
; Howso and migrations for deployment to Howso - copies the binary files to the deployment folder
;
;acceptable binary file extensions are:
;
; caml - compressed Amalgam
; baml - bundelded Amalgam, TODO: not yet implemented
#extension "caml"
;set to 1 to automatically copy out the files to the specified folder (OS will be autodetected)
#copy_to_deployment_path 1
#howso_linux_deployment_path "~/.howso/lib/dev/engine/"
#howso_windows_deployment_path "%USERPROFILE%\\.howso\\lib\\dev\\engine\\"
;----------------------------------------------------------------------------------------------;
;don't load escaped filenames
(load_entity "./howso.amlg" "howso" (false) (false))
(call_entity "howso" "initialize_for_deployment" (assoc file_extension (get_value extension) ))
(if (= (null) (call_entity "howso" "debug_label" (assoc label "!parameterValidationMap")))
(seq
(print "Parameter Validation Map failed to build. Run unit_tests/ut_h_type_hints.amlg.")
(conclude)
)
)
;set the version to whatever is in version.txt and split it on "."
(declare (assoc version (get (load "version.json") "version") ))
(declare (assoc version_list (split version "\\.") ))
(assign_to_entities "howso" (assoc
version version
major_version (first version_list)
minor_version (get version_list 1)
point_version (last version_list)
))
;insert local "version" if one wasn't passed in from the server, specifically for deploying on local dev machines
;use the user, git branch and timestamp as the major/minor/point version
;get user and git branch using platform independent commands
(if (= version "0.0.0")
(seq
;store the user and name of git branch
(declare (assoc
whoami (last (system "system" "whoami"))
git_version (last (system "system" "git rev-parse --abbrev-ref HEAD"))
))
(assign_to_entities "howso" (assoc
;truncate the carriage return from two vars that were read in from the temp file
major_version (trunc whoami)
minor_version (trunc git_version)
point_version (format (system_time) "number" "date:%Y-%m-%d-%H.%M.%S")
))
(assign (assoc
version_list (retrieve_from_entity "howso" (list "major_version" "minor_version" "point_version"))
))
)
)
;output Howso in the specified extension
(print "Saving Howso as " extension "\n")
(store (concat "./howso." extension) (retrieve_entity_root "howso" 1))
(null
#store_as_clean_caml
(store
(concat filename extension)
;remove all the comments by only keeping labels and values (code)
(rewrite
(lambda
(set_labels
(set_concurrency
(get_value (current_value))
(get_concurrency (current_value))
)
(get_labels (current_value))
)
)
(retrieve_entity_root entity_name 1)
)
)
)
(load_entity "./migrations/migrations.amlg" "migrations")
;write out to camls
(call store_as_clean_caml (assoc
filename "migrations."
entity_name "migrations"
))
(if copy_to_deployment_path
(let
(assoc
copy_cmd "cp"
deployment_path howso_linux_deployment_path
)
(if (= (system "os") "Windows")
(assign (assoc
copy_cmd "copy"
deployment_path
(concat
"\""
(trunc (last (system "system" (concat "echo " howso_windows_deployment_path)) ))
"\""
)
))
)
(print "howso " (last (system "system" (concat copy_cmd " howso." extension " " deployment_path))) )
(print "migrations " (last (system "system" (concat copy_cmd " migrations." extension " " deployment_path "migrations"))) )
)
)
)