|
|
@ -14,42 +14,47 @@ import (
|
|
14
|
14
|
type Project struct {
|
|
15
|
15
|
Id string
|
|
16
|
16
|
Commands Commands
|
|
17
|
|
Detect func(string) bool
|
|
|
17
|
Detect Matcher
|
|
18
|
18
|
}
|
|
19
|
19
|
|
|
|
20
|
type Matcher func(string) bool
|
|
|
21
|
|
|
20
|
22
|
type Commands map[string]string
|
|
21
|
23
|
|
|
22
|
24
|
var ProjectTypes = []*Project{
|
|
23
|
|
&Project{"c/default", Commands{"run": "gcc -o $(basename {file} .c) {file} && ./$(basename {file} .c)"}, cDefault},
|
|
|
25
|
&Project{"c/default", Commands{"run": "gcc -o $(basename {file} .c) {file} && ./$(basename {file} .c)"},
|
|
|
26
|
matchPattern("*.c")},
|
|
24
|
27
|
&Project{"clojure/leiningen", Commands{"build": "lein uberjar", "run": "lein run", "test": "lein test"},
|
|
25
|
|
clojureLeiningen},
|
|
26
|
|
&Project{"coffeescript/default", Commands{"run": "coffee {file}"}, coffeescriptDefault},
|
|
27
|
|
&Project{"docker/fig", Commands{"build": "fig build", "run": "fig up"}, dockerFig},
|
|
28
|
|
&Project{"docker/default", Commands{"build": "docker build ."}, dockerDefault},
|
|
|
28
|
matchFile("project.clj")},
|
|
|
29
|
&Project{"coffeescript/default", Commands{"run": "coffee {file}"}, matchPattern("*.coffee")},
|
|
|
30
|
&Project{"docker/fig", Commands{"build": "fig build", "run": "fig up"}, matchFile("fig.yml")},
|
|
|
31
|
&Project{"docker/default", Commands{"build": "docker build ."}, matchFile("Dockerfile")},
|
|
29
|
32
|
&Project{"executable", Commands{"run": "{file}"}, executableDefault},
|
|
30
|
33
|
&Project{"go/default", Commands{"build": "go build {file}", "run": "go build $(basename {file}) && ./$(basename {file} .go)"},
|
|
31
|
|
goDefault},
|
|
32
|
|
&Project{"haskell/cabal", Commands{"build": "cabal build", "run": "cabal run", "test": "cabal test"}, haskellCabal},
|
|
|
34
|
matchPattern("*.go")},
|
|
|
35
|
&Project{"haskell/cabal", Commands{"build": "cabal build", "run": "cabal run", "test": "cabal test"},
|
|
|
36
|
matchPattern("*.cabal")},
|
|
33
|
37
|
&Project{"haskell/default", Commands{"run": "runhaskell {file}"}, haskellDefault},
|
|
34
|
38
|
&Project{"idris/default", Commands{"run": "idris -o $(basename {file} .idr) {file} && ./$(basename {file} .idr)"},
|
|
35
|
|
idrisDefault},
|
|
36
|
|
&Project{"java/maven", Commands{"build": "mvn compile", "test": "mvn compile test"}, javaMaven},
|
|
37
|
|
&Project{"javascript/npm", Commands{"build": "npm install", "test": "npm test"}, javascriptNpm},
|
|
38
|
|
&Project{"javascript/meteor", Commands{"run": "meteor"}, javascriptMeteor},
|
|
39
|
|
&Project{"javascript/default", Commands{"run": "node {file}"}, javascriptDefault},
|
|
40
|
|
&Project{"julia/default", Commands{"run": "julia {file}"}, juliaDefault},
|
|
|
39
|
matchPattern("*.idr")},
|
|
|
40
|
&Project{"java/maven", Commands{"build": "mvn compile", "test": "mvn compile test"}, matchFile("pom.xml")},
|
|
|
41
|
&Project{"javascript/npm", Commands{"build": "npm install", "test": "npm test"}, matchFile("package.json")},
|
|
|
42
|
&Project{"javascript/meteor", Commands{"run": "meteor"}, matchFile(".meteor/.id")},
|
|
|
43
|
&Project{"javascript/default", Commands{"run": "node {file}"}, matchPattern("*.js")},
|
|
|
44
|
&Project{"julia/default", Commands{"run": "julia {file}"}, matchPattern("*.jl")},
|
|
41
|
45
|
&Project{"python/django", Commands{"build": "python manage.py syncdb", "run": "python manage.py runserver",
|
|
42
|
|
"test": "python manage.py test"}, pythonDjango},
|
|
43
|
|
&Project{"python/default", Commands{"run": "python {file}"}, pythonDefault},
|
|
|
46
|
"test": "python manage.py test"}, matchFile("manage.py")},
|
|
|
47
|
&Project{"python/default", Commands{"run": "python {file}"}, matchPattern("*.py")},
|
|
44
|
48
|
&Project{"ruby/rails", Commands{"build": "bundle exec rake db:migrate", "run": "rails server",
|
|
45
|
|
"test": "bundle exec rake test"}, rubyRails},
|
|
46
|
|
&Project{"ruby/rake", Commands{"run": "rake", "test": "rake test"}, rubyRake},
|
|
47
|
|
&Project{"ruby/default", Commands{"run": "ruby {file}"}, rubyDefault},
|
|
48
|
|
&Project{"rust/cargo", Commands{"build": "cargo build", "run": "cargo run", "test": "cargo test"}, rustCargo},
|
|
49
|
|
&Project{"rust/default", Commands{"run": "rustc {file} && ./$(basename {file} .rs)"}, rustDefault},
|
|
50
|
|
&Project{"cmake", Commands{"build": "mkdir .build && cd .build && cmake .. && make"}, cmakeDefault},
|
|
51
|
|
&Project{"make", Commands{"run": "make", "test": "make test"}, makeDefault},
|
|
52
|
|
&Project{"procfile", Commands{}, procfileDefault},
|
|
|
49
|
"test": "bundle exec rake test"}, matchFile("bin/rails")},
|
|
|
50
|
&Project{"ruby/rake", Commands{"run": "rake", "test": "rake test"}, matchFile("Rakefile")},
|
|
|
51
|
&Project{"ruby/default", Commands{"run": "ruby {file}"}, matchPattern("*.rb")},
|
|
|
52
|
&Project{"rust/cargo", Commands{"build": "cargo build", "run": "cargo run", "test": "cargo test"},
|
|
|
53
|
matchFile("Cargo.toml")},
|
|
|
54
|
&Project{"rust/default", Commands{"run": "rustc {file} && ./$(basename {file} .rs)"}, matchPattern("*.rs")},
|
|
|
55
|
&Project{"cmake", Commands{"build": "mkdir .build && cd .build && cmake .. && make"}, matchFile("CMakeLists.txt")},
|
|
|
56
|
&Project{"make", Commands{"run": "make", "test": "make test"}, matchFile("Makefile")},
|
|
|
57
|
&Project{"procfile", Commands{}, matchFile("Procfile")},
|
|
53
|
58
|
}
|
|
54
|
59
|
|
|
55
|
60
|
func Detect(file string) (*Project, error) {
|
|
|
@ -99,102 +104,22 @@ func hasFile(fileOrDir string, file string) bool {
|
|
99
|
104
|
return fileutil.IsFile(fileutil.Join(fileOrDir, file))
|
|
100
|
105
|
}
|
|
101
|
106
|
|
|
102
|
|
func cDefault(file string) bool {
|
|
103
|
|
return matchingFileOrDir(file, "*.c")
|
|
104
|
|
}
|
|
105
|
|
|
|
106
|
|
func clojureLeiningen(file string) bool {
|
|
107
|
|
return hasFile(file, "project.clj")
|
|
108
|
|
}
|
|
109
|
|
|
|
110
|
|
func cmakeDefault(file string) bool {
|
|
111
|
|
return hasFile(file, "CMakeLists.txt")
|
|
112
|
|
}
|
|
113
|
|
|
|
114
|
|
func coffeescriptDefault(file string) bool {
|
|
115
|
|
return matchingFileOrDir(file, "*.coffee")
|
|
116
|
|
}
|
|
117
|
|
|
|
118
|
|
func dockerFig(file string) bool {
|
|
119
|
|
return hasFile(file, "fig.yml")
|
|
|
107
|
func matchPattern(ext string) Matcher {
|
|
|
108
|
return func(file string) bool {
|
|
|
109
|
return matchingFileOrDir(file, ext)
|
|
|
110
|
}
|
|
120
|
111
|
}
|
|
121
|
112
|
|
|
122
|
|
func dockerDefault(file string) bool {
|
|
123
|
|
return hasFile(file, "Dockerfile")
|
|
|
113
|
func matchFile(fileName string) Matcher {
|
|
|
114
|
return func(file string) bool {
|
|
|
115
|
return hasFile(file, fileName)
|
|
|
116
|
}
|
|
124
|
117
|
}
|
|
125
|
118
|
|
|
126
|
119
|
func executableDefault(file string) bool {
|
|
127
|
120
|
return fileutil.IsExecutable(file)
|
|
128
|
121
|
}
|
|
129
|
122
|
|
|
130
|
|
func goDefault(file string) bool {
|
|
131
|
|
return matchingFileOrDir(file, "*.go")
|
|
132
|
|
}
|
|
133
|
|
|
|
134
|
|
func haskellCabal(file string) bool {
|
|
135
|
|
return matchingFileOrDir(file, "*.cabal")
|
|
136
|
|
}
|
|
137
|
|
|
|
138
|
123
|
func haskellDefault(file string) bool {
|
|
139
|
124
|
return matchingFileOrDir(file, "*.hs") || matchingFileOrDir(file, "*.lhs")
|
|
140
|
125
|
}
|
|
141
|
|
|
|
142
|
|
func idrisDefault(file string) bool {
|
|
143
|
|
return matchingFileOrDir(file, "*.idr")
|
|
144
|
|
}
|
|
145
|
|
|
|
146
|
|
func javaMaven(file string) bool {
|
|
147
|
|
return hasFile(file, "pom.xml")
|
|
148
|
|
}
|
|
149
|
|
|
|
150
|
|
func javascriptNpm(file string) bool {
|
|
151
|
|
return hasFile(file, "package.json")
|
|
152
|
|
}
|
|
153
|
|
|
|
154
|
|
func javascriptMeteor(file string) bool {
|
|
155
|
|
return hasFile(file, ".meteor/.id")
|
|
156
|
|
}
|
|
157
|
|
|
|
158
|
|
func javascriptDefault(file string) bool {
|
|
159
|
|
return matchingFileOrDir(file, "*.js")
|
|
160
|
|
}
|
|
161
|
|
|
|
162
|
|
func juliaDefault(file string) bool {
|
|
163
|
|
return matchingFileOrDir(file, "*.jl")
|
|
164
|
|
}
|
|
165
|
|
|
|
166
|
|
func makeDefault(file string) bool {
|
|
167
|
|
return hasFile(file, "Makefile")
|
|
168
|
|
}
|
|
169
|
|
|
|
170
|
|
func procfileDefault(file string) bool {
|
|
171
|
|
return hasFile(file, "Procfile")
|
|
172
|
|
}
|
|
173
|
|
|
|
174
|
|
func pythonDjango(file string) bool {
|
|
175
|
|
return hasFile(file, "manage.py")
|
|
176
|
|
}
|
|
177
|
|
|
|
178
|
|
func pythonDefault(file string) bool {
|
|
179
|
|
return matchingFileOrDir(file, "*.py")
|
|
180
|
|
}
|
|
181
|
|
|
|
182
|
|
func rubyRails(file string) bool {
|
|
183
|
|
return hasFile(file, "bin/rails")
|
|
184
|
|
}
|
|
185
|
|
|
|
186
|
|
func rubyRake(file string) bool {
|
|
187
|
|
return hasFile(file, "Rakefile")
|
|
188
|
|
}
|
|
189
|
|
|
|
190
|
|
func rubyDefault(file string) bool {
|
|
191
|
|
return matchingFileOrDir(file, "*.rb")
|
|
192
|
|
}
|
|
193
|
|
|
|
194
|
|
func rustCargo(file string) bool {
|
|
195
|
|
return hasFile(file, "Cargo.toml")
|
|
196
|
|
}
|
|
197
|
|
|
|
198
|
|
func rustDefault(file string) bool {
|
|
199
|
|
return matchingFileOrDir(file, "*.rs")
|
|
200
|
|
}
|