--- /dev/null
+#!/usr/bin/env escript
+% coding: utf-8
+% Copyright 2008 Grégory Burri\r
+%\r
+% This file is part of Euphorik.\r
+%\r
+% Euphorik is free software: you can redistribute it and/or modify\r
+% it under the terms of the GNU General Public License as published by\r
+% the Free Software Foundation, either version 3 of the License, or\r
+% (at your option) any later version.\r
+%\r
+% Euphorik is distributed in the hope that it will be useful,\r
+% but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+% GNU General Public License for more details.\r
+%\r
+% You should have received a copy of the GNU General Public License\r
+% along with Euphorik. If not, see <http://www.gnu.org/licenses/>.
+\r
+% This file replace the old one 'tools.rb' written in a crapy language ;)
+% TODO :
+% - création de unit tests (voir eunit) et validation avant la mise en prod
+\r
+\r
+main(Args) ->\r
+ file:set_cwd(".."),\r
+ case Args of\r
+ ["prod"] -> in_prod("gburri@euphorik.ch:/var/www/euphorik");\r
+ ["pre"] -> in_preprod("gburri@euphorik.ch:/var/www/euphorik_preprod", "var/www/euphorik");\r
+ ["js"] -> verif_js();\r
+ ["version"] -> update_version();\r
+ _ ->\r
+ io:format(\r
+ "Usage : ~s (prod | pre | js | version)~n"\r
+ " prod : in production~n"\r
+ " pre : in preproduction, data are copied from production~n"\r
+ " js : check the JavaScript files~n"\r
+ " version : update the version into somes files from the VERSION file",\r
+ [escript:script_name()]\r
+ )\r
+ end.\r
+\r
+\r
+% A simple fonction to log message.\r
+log(Str) ->\r
+ io:format("===== ~s =====~n", [Str]).\r
+ \r
+\r
+% Execute an OS commande and print the result to stdout.\r
+cmd(Commande_str) ->\r
+ cmd(Commande_str, []). \r
+cmd(Commande_str, Params) ->\r
+ io:format("~s~n", [os:cmd(lists:flatten(io_lib:format(Commande_str, Params)))]).\r
+\r
+\r
+-record(uri, {\r
+ host,\r
+ path % in absolute\r
+}).\r
+\r
+\r
+% Create an uri record from an uri string.\r
+create_uri(Uri_str) ->\r
+ [Host, Path] = string:tokens(Uri_str, ":"),\r
+ #uri{host = Host, path = Path}.\r
+\r
+\r
+% Update the version into somes files from the VERSION file.\r
+update_version() ->\r
+ log("Update the version tag"),\r
+ todo.\r
+\r
+\r
+% Check the JavaScript files.\r
+verif_js() ->\r
+ todo.\r
+\r
+\r
+% Start the production processus.\r
+in_prod(Uri) ->\r
+ compile_server_part(Uri),\r
+ make_var_directory(Uri),\r
+ copy_files(Uri),\r
+ define_files_rights(Uri),\r
+ update_server().\r
+\r
+\r
+% Start the pre-production processus.\r
+in_preprod(Uri, data_path) ->\r
+ compile_server_part(Uri),\r
+ make_var_directory(Uri),\r
+ copy_files(Uri),\r
+ define_files_rights(Uri),\r
+ start_server(),\r
+ update_server().\r
+\r
+ \r
+% Compile the Erlang modules.\r
+compile_server_part(Uri) ->\r
+ todo.\r
+ \r
+\r
+% Create the 'var' folder if it doesn't exist.\r
+make_var_directory(Uri) ->\r
+ todo.\r
+ \r
+ \r
+% Copy files from developpement env to production server.\r
+copy_files(Uri) ->\r
+ copy_static_part(Uri),\r
+ copy_packed_js(Uri).\r
+ \r
+ \r
+% Copy all static files like modules, styles, pages, etc.\r
+copy_static_part(Uri) ->\r
+ %~ creer_rep('modules')\r
+ %~ system("rsync -r --exclude 'euphorik_test.beam' modules/ebin #{@uri}:#{@rep}/modules")\r
+ %~ system("rsync -r modules/include #{@uri}:#{@rep}/modules")\r
+ todo.\r
+ \r
+\r
+% Minify and pack JavaScript in one file then copy it to ther server.\r
+copy_packed_js(Uri) ->\r
+ todo.\r
+ \r
+ \r
+% Define the rights for the copied folder et files.\r
+define_files_rights(Uri) ->\r
+ todo. \r
+ \r
+ \r
+% Start the server if it not already started (in preproduction case only).\r
+start_server() ->\r
+ todo.\r
+ \r
+ \r
+% Run a erlang script to \r
+update_server() ->\r
+ todo.\r
+