This repository has been archived by the owner on Jun 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
/
Jakefile
65 lines (52 loc) · 1.92 KB
/
Jakefile
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
var JAKE = require("jake");
var FILE = require("file");
var OS = require("os");
var VERSION = "1.0";
var BUILD_PATH = FILE.path("Build");
var SERVER_BUILD_PATH = BUILD_PATH.join("Server");
var CLIENT_BUILD_PATH = SERVER_BUILD_PATH.join("static");
var DEPLOY_GIT_REMOTE = "[email protected]:githubissues.git";
JAKE.task("deploy", ["build"], function() {
var sha = getGitSHA();
OS.system("cd "+OS.enquote(SERVER_BUILD_PATH)+" " + buildCommandString([
["git", "pull"],
["git", "add", "."],
["git", "commit", "-a", "-m", sha+" built on "+(new Date())],
["git", "push", "heroku", "master"]
]));
});
JAKE.task("build", ["checkout"], function() {
// server
OS.system("cp -r Server/* " + OS.enquote(SERVER_BUILD_PATH.join(".")));
// client
OS.system("cd Client && jake deploy");
if (CLIENT_BUILD_PATH.isDirectory())
CLIENT_BUILD_PATH.rmtree();
FILE.copyTree(FILE.join("Client", "Build", "Deployment", "Issues"), CLIENT_BUILD_PATH);
});
JAKE.task("checkout", function() {
if (!SERVER_BUILD_PATH.isDirectory()) {
SERVER_BUILD_PATH.dirname().mkdirs();
OS.system(["git", "clone", DEPLOY_GIT_REMOTE, SERVER_BUILD_PATH, "-o", "heroku"]);
}
});
JAKE.task("zip", function() {
var zipName = "Issues-"+VERSION+".zip";
if (BUILD_PATH.join(zipName).isFile())
BUILD_PATH.join(zipName).remove();
OS.system("cd Client && jake desktop");
OS.system("cd Client/Build/Desktop/Issues && zip -r ../../../Build/"+zipName+" Issues.app");
});
function getGitSHA(directory) {
var p = OS.popen((directory ? "cd "+OS.enquote(directory)+" && " : "") + "git rev-parse --verify HEAD");
var sha = p.stdout.read().trim();
p.stdin.close();
p.stdout.close();
p.stderr.close();
return sha;
}
function buildCommandString(commands) {
return commands.map(function(command) {
return command.map(OS.enquote).join(" ");
}).join(" && ");
}