forked from alecgorge/jsonapi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjsonapi
executable file
·123 lines (98 loc) · 3.31 KB
/
jsonapi
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
#!/usr/bin/env coffee
DEFAULT_VERSION = "1.6.4"
usage = """
USAGE:
# List all available versions
jsonapi versions
# This screen
jsonapi
# Build all versions and put jars in builds/**/JSONAPI.jar
jsonapi build
# Build a specific version
jsonapi build 1.6.4
# Test the default version
jsonapi test
# Test a specific version
jsonapi test 1.6.2
"""
versions = {}
versions['1.4.7'] = package: 'v1_4_R1', cb_version: '1.4.7-R1.0'
versions['1.5.2'] = package: 'v1_5_R3', cb_version: '1.5.2-R1.0'
versions['1.6.2'] = package: 'v1_6_R2', cb_version: '1.6.2-R1.0'
versions['1.6.4'] = package: 'v1_6_R3', cb_version: '1.6.4-R2.0'
versions['1.7.2'] = package: 'v1_7_R1', cb_version: '1.7.2-R0.3'
versions['1.7.5'] = package: 'v1_7_R2', cb_version: '1.7.5-R0.1-SNAPSHOT'
versions['1.7.9'] = package: 'v1_7_R3', cb_version: '1.7.9-R0.2'
versions['1.7.10'] = package: 'v1_7_R4', cb_version: '1.7.10-R0.1-SNAPSHOT'
versions['1.4'] = versions['1.4.7']
versions['1.5'] = versions['1.5.2']
versions['1.6'] = versions['1.6.4']
versions['1.7'] = versions['1.7.10']
available_versions = Object.keys(versions)
build_cmd = (ver, cmd = "clean install") ->
v = ver.cb_version.split('-')[0].split('.').map (v) -> parseInt v
mc16OrNewer = if v[0] >= 1 and v[1] >= 6 then "yes" else "no"
mc17OrNewer = if v[0] >= 1 and v[1] >= 7 then "yes" else "no"
mc179OrNewer = if v[0] >= 1 and v[1] >= 7 and v[2] >= 9 then "yes" else "no"
return "mvn #{cmd} $@ -DmcPackage=#{ver.package} -DcbVersion=#{ver.cb_version} -Dmc16OrNewer=#{mc16OrNewer} -Dmc17OrNewer=#{mc17OrNewer} -Dmc179OrNewer=#{mc179OrNewer}"
eclipse_cmd = (ver) ->
return build_cmd ver, "eclipse:eclipse"
build = (to_build) ->
return to_build.map (ver) ->
return """
echo "Building #{ver.cb_version}"
#{build_cmd(ver)}
rc=$?
if [[ $rc != 0 ]] ; then
exit $rc
fi
"""
command = process.argv[2]
if command is "build"
version = process.argv[3] or "all"
to_build = []
if version is "all"
to_build = Object.keys(versions).filter((v) -> v.length > 3).map((v) -> return versions[v])
else
to_build.push versions[version]
if to_build.length > 0
console.log """
#!/usr/bin/env bash
# Generated with the command ./jsonapi build #{version}
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd $DIR
"""
console.log build(to_build).join("\n")
else
console.error "#{version} doesn't exist. Available versions: #{available_versions.join(', ')}"
else if command is "test"
version = process.argv[3] or DEFAULT_VERSION
ver = versions[version]
if not ver
console.error "#{version} doesn't exist. Available versions: #{available_versions.join(', ')}"
else
console.log """
#!/usr/bin/env bash
# Generated with the command ./jsonapi test #{version}
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd $DIR
#{build_cmd(ver)} && cd test/ && java -Xmx256M -jar craftbukkit-#{ver.cb_version}.jar
cd $DIR
"""
else if command is "eclipse"
version = process.argv[3] or DEFAULT_VERSION
ver = versions[version]
if not ver
console.error "#{version} doesn't exist. Available versions: #{available_versions.join(', ')}"
else
console.log """
#!/usr/bin/env bash
# Generated with the command ./jsonapi eclipse #{version}
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd $DIR
#{eclipse_cmd(ver)}
"""
else if command is "versions"
console.log available_versions.join("\n")
else
console.error usage