Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
debomatic-webui
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
debomatic-webui-admins
debomatic-webui
Commits
18c0c552
Commit
18c0c552
authored
Jul 16, 2014
by
Leo Iannacone
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
indentation 4 spaces
parent
8e2d5d18
Changes
8
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
451 additions
and
451 deletions
+451
-451
debomatic-webui/debomatic-webui.coffee
debomatic-webui/debomatic-webui.coffee
+52
-52
debomatic-webui/lib/broadcaster.coffee
debomatic-webui/lib/broadcaster.coffee
+55
-55
debomatic-webui/lib/client.coffee
debomatic-webui/lib/client.coffee
+155
-155
debomatic-webui/lib/config.coffee
debomatic-webui/lib/config.coffee
+40
-40
debomatic-webui/lib/parser.coffee
debomatic-webui/lib/parser.coffee
+18
-18
debomatic-webui/lib/tail.coffee
debomatic-webui/lib/tail.coffee
+19
-19
debomatic-webui/lib/utils.coffee
debomatic-webui/lib/utils.coffee
+104
-104
debomatic-webui/routes/index.coffee
debomatic-webui/routes/index.coffee
+8
-8
No files found.
debomatic-webui/debomatic-webui.coffee
View file @
18c0c552
...
@@ -18,11 +18,11 @@ server = http.createServer(app)
...
@@ -18,11 +18,11 @@ server = http.createServer(app)
io
=
require
(
"socket.io"
)(
server
)
io
=
require
(
"socket.io"
)(
server
)
env
=
process
.
env
.
NODE_ENV
or
"development"
env
=
process
.
env
.
NODE_ENV
or
"development"
if
"development"
is
env
if
"development"
is
env
app
.
use
errorhandler
(
app
.
use
errorhandler
(
dumpExceptions
:
true
dumpExceptions
:
true
showStack
:
true
showStack
:
true
)
)
else
app
.
use
errorhandler
()
if
"production"
is
env
else
app
.
use
errorhandler
()
if
"production"
is
env
app
.
set
"views"
,
__dirname
+
"/views"
app
.
set
"views"
,
__dirname
+
"/views"
app
.
set
"view engine"
,
"ejs"
app
.
set
"view engine"
,
"ejs"
...
@@ -33,35 +33,35 @@ app.get "/", routes.index
...
@@ -33,35 +33,35 @@ app.get "/", routes.index
app
.
get
config
.
routes
.
distribution
,
routes
.
distribution
app
.
get
config
.
routes
.
distribution
,
routes
.
distribution
# parefernces page
# parefernces page
app
.
get
config
.
routes
.
preferences
,
routes
.
preferences
if
config
.
routes
.
preferences
app
.
get
config
.
routes
.
preferences
,
routes
.
preferences
if
config
.
routes
.
preferences
# commands page
# commands page
app
.
get
config
.
routes
.
commands
,
routes
.
commands
if
config
.
routes
.
commands
app
.
get
config
.
routes
.
commands
,
routes
.
commands
if
config
.
routes
.
commands
# debomatic static page
# debomatic static page
if
config
.
routes
.
debomatic
if
config
.
routes
.
debomatic
app
.
all
config
.
routes
.
debomatic
+
"*"
,
(
req
,
res
,
next
)
->
app
.
all
config
.
routes
.
debomatic
+
"*"
,
(
req
,
res
,
next
)
->
# send 403 status when users want to browse the chroots:
# send 403 status when users want to browse the chroots:
# - unstable/unstable
# - unstable/unstable
# - unstable/build/*
# - unstable/build/*
# this prevents system crashes
# this prevents system crashes
base
=
config
.
routes
.
debomatic
base
=
config
.
routes
.
debomatic
base
+=
(
if
base
[
base
.
length
-
1
]
isnt
"/"
then
"/"
else
""
)
# append /
base
+=
(
if
base
[
base
.
length
-
1
]
isnt
"/"
then
"/"
else
""
)
# append /
match
=
req
.
url
.
replace
(
base
,
""
).
split
(
"/"
)
match
=
req
.
url
.
replace
(
base
,
""
).
split
(
"/"
)
match
.
pop
()
if
match
[
match
.
length
-
1
]
is
""
match
.
pop
()
if
match
[
match
.
length
-
1
]
is
""
# case unstable/unstable
# case unstable/unstable
if
match
.
length
>=
2
and
((
match
[
0
]
is
match
[
1
])
or
(
match
[
1
]
is
"build"
and
match
.
length
>
2
))
# case unstable/build/*
if
match
.
length
>=
2
and
((
match
[
0
]
is
match
[
1
])
or
(
match
[
1
]
is
"build"
and
match
.
length
>
2
))
# case unstable/build/*
res
.
status
(
403
).
send
"<h1>403 Forbidden</h1>"
res
.
status
(
403
).
send
"<h1>403 Forbidden</h1>"
else
# call next() here to move on to next middleware/router
else
# call next() here to move on to next middleware/router
next
()
next
()
return
return
app
.
use
config
.
routes
.
debomatic
,
serve_static
(
config
.
debomatic
.
path
)
app
.
use
config
.
routes
.
debomatic
,
serve_static
(
config
.
debomatic
.
path
)
app
.
use
config
.
routes
.
debomatic
,
serve_index
(
config
.
debomatic
.
path
,
app
.
use
config
.
routes
.
debomatic
,
serve_index
(
config
.
debomatic
.
path
,
view
:
"details"
view
:
"details"
icons
:
true
icons
:
true
)
)
# serve stylesheet-javascript
# serve stylesheet-javascript
app
.
use
serve_static
(
__dirname
+
"/public"
)
app
.
use
serve_static
(
__dirname
+
"/public"
)
...
@@ -72,32 +72,32 @@ serve_static.mime.define "application/octet-stream": ["dsc"]
...
@@ -72,32 +72,32 @@ serve_static.mime.define "application/octet-stream": ["dsc"]
# Listening
# Listening
server
.
listen
config
.
port
,
config
.
host
,
null
,
(
err
)
->
server
.
listen
config
.
port
,
config
.
host
,
null
,
(
err
)
->
# Checking nodejs with sudo:
# Checking nodejs with sudo:
# Find out which user used sudo through the environment variable
# Find out which user used sudo through the environment variable
# and set his user id
# and set his user id
uid
=
parseInt
(
process
.
env
.
SUDO_UID
)
uid
=
parseInt
(
process
.
env
.
SUDO_UID
)
if
uid
if
uid
console
.
log
"Please do not run nodejs with sudo. Changing user to %d"
,
uid
console
.
log
"Please do not run nodejs with sudo. Changing user to %d"
,
uid
process
.
setgid
uid
process
.
setgid
uid
process
.
setuid
uid
process
.
setuid
uid
# statuses
# statuses
status
=
[]
status
=
[]
broadcast
=
new
Broadcaster
(
io
.
sockets
,
status
)
broadcast
=
new
Broadcaster
(
io
.
sockets
,
status
)
io
.
sockets
.
on
"connection"
,
(
socket
)
->
io
.
sockets
.
on
"connection"
,
(
socket
)
->
client
=
new
Client
(
socket
)
client
=
new
Client
(
socket
)
client
.
start
()
client
.
start
()
client
.
send_status
status
if
status
.
length
>
0
client
.
send_status
status
if
status
.
length
>
0
client
.
send_status_debomatic
()
client
.
send_status_debomatic
()
return
return
console
.
log
"Debomatic-webui listening on %s:%d in %s mode"
,
server
.
address
().
address
,
server
.
address
().
port
,
app
.
settings
.
env
console
.
log
"Debomatic-webui listening on %s:%d in %s mode"
,
server
.
address
().
address
,
server
.
address
().
port
,
app
.
settings
.
env
return
return
server
.
on
"error"
,
(
e
)
->
server
.
on
"error"
,
(
e
)
->
if
e
.
code
is
"EADDRINUSE"
if
e
.
code
is
"EADDRINUSE"
console
.
log
"Address in use %s:%d. Exit."
,
config
.
host
,
config
.
port
console
.
log
"Address in use %s:%d. Exit."
,
config
.
host
,
config
.
port
process
.
exit
1
process
.
exit
1
else
else
console
.
error
e
console
.
error
e
return
return
debomatic-webui/lib/broadcaster.coffee
View file @
18c0c552
__watch_status_check_same_obj
=
(
obj1
,
obj2
)
->
__watch_status_check_same_obj
=
(
obj1
,
obj2
)
->
if
obj1
.
status
is
obj2
.
status
if
obj1
.
status
is
obj2
.
status
if
obj1
.
distribution
is
obj2
.
distribution
if
obj1
.
distribution
is
obj2
.
distribution
if
obj1
.
hasOwnProperty
(
"package"
)
and
obj2
.
hasOwnProperty
(
"package"
)
if
obj1
.
hasOwnProperty
(
"package"
)
and
obj2
.
hasOwnProperty
(
"package"
)
return
true
if
obj1
.
package
is
obj2
.
package
return
true
if
obj1
.
package
is
obj2
.
package
return
false
return
false
return
true
return
true
false
false
# watcher on build_status
# watcher on build_status
__watch_status
=
(
socket
,
status
)
->
__watch_status
=
(
socket
,
status
)
->
watcher
=
new
Tail
(
config
.
debomatic
.
jsonfile
)
watcher
=
new
Tail
(
config
.
debomatic
.
jsonfile
)
watcher
.
on
"line"
,
(
new_content
)
->
watcher
.
on
"line"
,
(
new_content
)
->
data
=
null
data
=
null
try
try
data
=
JSON
.
parse
(
new_content
)
data
=
JSON
.
parse
(
new_content
)
catch
err
catch
err
utils
.
errors_handler
"Broadcaster:__watch_status:JSON.parse(new_content) - "
,
err
,
socket
utils
.
errors_handler
"Broadcaster:__watch_status:JSON.parse(new_content) - "
,
err
,
socket
return
return
# looking for same status already in statuses lists
# looking for same status already in statuses lists
if
data
.
hasOwnProperty
(
"success"
)
if
data
.
hasOwnProperty
(
"success"
)
i
=
0
i
=
0
while
i
<
status
.
length
while
i
<
status
.
length
if
__watch_status_check_same_obj
(
data
,
status
[
i
])
if
__watch_status_check_same_obj
(
data
,
status
[
i
])
status
.
splice
i
,
1
status
.
splice
i
,
1
break
break
else
continue
i
++
else
else
continue
status
.
push
data
i
++
socket
.
emit
config
.
events
.
broadcast
.
status_update
,
data
else
return
status
.
push
data
socket
.
emit
config
.
events
.
broadcast
.
status_update
,
data
return
watcher
.
on
"error"
,
(
msg
)
->
watcher
.
on
"error"
,
(
msg
)
->
socket
.
emit
config
.
events
.
error
,
msg
socket
.
emit
config
.
events
.
error
,
msg
return
return
return
return
# watcher on new distributions
# watcher on new distributions
__watch_distributions
=
(
socket
)
->
__watch_distributions
=
(
socket
)
->
fs
.
watch
config
.
debomatic
.
path
,
fs
.
watch
config
.
debomatic
.
path
,
persistent
:
true
persistent
:
true
,
(
event
,
fileName
)
->
,
(
event
,
fileName
)
->
# wait half a second to get pool subdir created
# wait half a second to get pool subdir created
setTimeout
(
->
setTimeout
(
->
utils
.
send_distributions
socket
utils
.
send_distributions
socket
return
return
),
500
),
500
return
return
return
__watch_pidfile
=
(
socket
)
->
fs
.
watchFile
config
.
debomatic
.
pidfile
,
persistent
:
false
interval
:
1007
,
(
curr
,
prev
)
->
status_debomatic
=
running
:
curr
.
ino
isnt
0
# if === 0 means pidfile does not exists
try
socket
.
emit
socket
.
emit
(
config
.
events
.
broadcast
.
status_debomatic
,
status_debomatic
)
return
return
__watch_pidfile
=
(
socket
)
->
fs
.
watchFile
config
.
debomatic
.
pidfile
,
persistent
:
false
interval
:
1007
,
(
curr
,
prev
)
->
status_debomatic
=
running
:
curr
.
ino
isnt
0
# if === 0 means pidfile does not exists
try
socket
.
emit
socket
.
emit
(
config
.
events
.
broadcast
.
status_debomatic
,
status_debomatic
)
return
return
return
Broadcaster
=
(
sockets
,
status
)
->
Broadcaster
=
(
sockets
,
status
)
->
__watch_status
sockets
,
status
__watch_status
sockets
,
status
__watch_distributions
sockets
__watch_distributions
sockets
__watch_pidfile
sockets
__watch_pidfile
sockets
{}
{}
"use strict"
"use strict"
config
=
require
(
"./config"
)
config
=
require
(
"./config"
)
fs
=
require
(
"fs"
)
fs
=
require
(
"fs"
)
...
...
debomatic-webui/lib/client.coffee
View file @
18c0c552
This diff is collapsed.
Click to expand it.
debomatic-webui/lib/config.coffee
View file @
18c0c552
#
#
# * Please DO NOT edit this file.
# *
Please DO NOT edit this file.
# *
# *
# * Edit auto-generated 'user.config.js' file instead.
# *
Edit auto-generated 'user.config.js' file instead.
# *
# *
#
#
...
@@ -10,8 +10,8 @@
...
@@ -10,8 +10,8 @@
#
#
# * Configure host and port.
# * Configure host and port.
# * Please for ports < 1000 use authbind. DO NOT RUN nodejs as root.
# *
Please for ports < 1000 use authbind. DO NOT RUN nodejs as root.
# * $ authbind nodejs index.js
# *
$ authbind nodejs index.js
#
#
# web configuration
# web configuration
...
@@ -38,16 +38,16 @@
...
@@ -38,16 +38,16 @@
# * update object1 with object2 values
# * update object1 with object2 values
#
#
_merge
=
(
object1
,
object2
)
->
_merge
=
(
object1
,
object2
)
->
result
=
{}
result
=
{}
for
p
of
object1
for
p
of
object1
if
object2
.
hasOwnProperty
(
p
)
if
object2
.
hasOwnProperty
(
p
)
if
typeof
object1
[
p
]
is
"object"
and
typeof
object2
[
p
]
is
"object"
if
typeof
object1
[
p
]
is
"object"
and
typeof
object2
[
p
]
is
"object"
result
[
p
]
=
_merge
(
object1
[
p
],
object2
[
p
])
result
[
p
]
=
_merge
(
object1
[
p
],
object2
[
p
])
else
else
result
[
p
]
=
object2
[
p
]
result
[
p
]
=
object2
[
p
]
else
else
result
[
p
]
=
object1
[
p
]
result
[
p
]
=
object1
[
p
]
result
result
"use strict"
"use strict"
config
=
{}
config
=
{}
config
.
host
=
"localhost"
config
.
host
=
"localhost"
...
@@ -87,8 +87,8 @@ config.web.preferences.file_fontsize = 13
...
@@ -87,8 +87,8 @@ config.web.preferences.file_fontsize = 13
config
.
web
.
preferences
.
debug
=
0
config
.
web
.
preferences
.
debug
=
0
config
.
version
=
"0.6.0"
config
.
version
=
"0.6.0"
config
.
debomatic
.
excluded_files
=
[
config
.
debomatic
.
excluded_files
=
[
"datestamp"
"datestamp"
"json"
"json"
]
]
config
.
events
=
{}
config
.
events
=
{}
config
.
events
.
error
=
"server-error"
config
.
events
.
error
=
"server-error"
...
@@ -111,29 +111,29 @@ config.status.update = "update"
...
@@ -111,29 +111,29 @@ config.status.update = "update"
config
.
status
.
success
=
true
config
.
status
.
success
=
true
config
.
status
.
fail
=
false
config
.
status
.
fail
=
false
try
try
Parser
=
require
(
"./parser"
)
Parser
=
require
(
"./parser"
)
parser
=
new
Parser
()
parser
=
new
Parser
()
user_config
=
parser
.
getUserConfig
()
user_config
=
parser
.
getUserConfig
()
if
user_config
if
user_config
console
.
log
"Reading user configutation ..."
console
.
log
"Reading user configutation ..."
config
=
_merge
(
config
,
require
(
user_config
))
config
=
_merge
(
config
,
require
(
user_config
))
else
else
console
.
log
"No user config specified. Using global settings."
console
.
log
"No user config specified. Using global settings."
catch
err
catch
err
if
err
.
code
is
"MODULE_NOT_FOUND"
if
err
.
code
is
"MODULE_NOT_FOUND"
console
.
log
"File %s not found."
,
user_config
console
.
log
"File %s not found."
,
user_config
process
.
exit
1
process
.
exit
1
else
else
console
.
error
"Error reading user configutation"
,
err
console
.
error
"Error reading user configutation"
,
err
process
.
exit
1
process
.
exit
1
finally
finally
# export some variable
# export some variable
config
.
web
.
paths
=
config
.
routes
config
.
web
.
paths
=
config
.
routes
config
.
web
.
events
=
config
.
events
config
.
web
.
events
=
config
.
events
config
.
web
.
status
=
config
.
status
config
.
web
.
status
=
config
.
status
config
.
web
.
host
=
config
.
host
config
.
web
.
host
=
config
.
host
# calculate pidfile
# calculate pidfile
config
.
debomatic
.
pidfile
=
"/var/run/debomatic-"
+
require
(
"crypto"
).
createHash
(
"sha256"
).
update
(
config
.
debomatic
.
path
).
digest
(
"hex"
)
config
.
debomatic
.
pidfile
=
"/var/run/debomatic-"
+
require
(
"crypto"
).
createHash
(
"sha256"
).
update
(
config
.
debomatic
.
path
).
digest
(
"hex"
)
module
.
exports
=
config
module
.
exports
=
config
debomatic-webui/lib/parser.coffee
View file @
18c0c552
#jshint multistr: true
#jshint multistr: true
Parser
=
->
Parser
=
->
args
=
process
.
argv
.
slice
(
2
)
args
=
process
.
argv
.
slice
(
2
)
help
=
->
help
=
->
console
.
log
"Usage: %s [-c config]
\n
-h print this help
\n
-c set user configuration file"
,
process
.
argv
[
1
].
split
(
"/"
).
pop
()
console
.
log
"Usage: %s [-c config]
\n
-h print this help
\n
-c set user configuration file"
,
process
.
argv
[
1
].
split
(
"/"
).
pop
()
process
.
exit
0
process
.
exit
0
return
return
@
getUserConfig
=
->
configFile
=
null
args
.
forEach
(
val
,
index
)
->
if
val
is
"-c"
configFile
=
args
[
index
+
1
]
return
if
configFile
process
.
cwd
()
+
"/"
+
configFile
else
null
@
getUserConfig
=
->
configFile
=
null
args
.
forEach
(
val
,
index
)
->
args
.
forEach
(
val
,
index
)
->
if
val
is
"-c"
help
()
if
val
is
"-h"
configFile
=
args
[
index
+
1
]
return
return
if
configFile
process
.
cwd
()
+
"/"
+
configFile
else
null
args
.
forEach
(
val
,
index
)
->
help
()
if
val
is
"-h"
return
return
return
"use strict"
"use strict"
module
.
exports
=
Parser
module
.
exports
=
Parser
debomatic-webui/lib/tail.coffee
View file @
18c0c552
...
@@ -2,28 +2,28 @@
...
@@ -2,28 +2,28 @@
fs
=
require
(
"fs"
)
fs
=
require
(
"fs"
)
Tail
=
require
(
"tail"
).
Tail
Tail
=
require
(
"tail"
).
Tail
Tail
::
watchEvent
=
(
e
)
->
Tail
::
watchEvent
=
(
e
)
->
_this
=
this
_this
=
this
if
e
is
"change"
if
e
is
"change"
fs
.
stat
@
filename
,
(
err
,
stats
)
->
fs
.
stat
@
filename
,
(
err
,
stats
)
->
if
err
if
err
_this
.
emit
"error"
,
err
_this
.
emit
"error"
,
err
return
return
_this
.
pos
=
stats
.
size
if
stats
.
size
<
_this
.
pos
_this
.
pos
=
stats
.
size
if
stats
.
size
<
_this
.
pos
if
stats
.
size
>
_this
.
pos
if
stats
.
size
>
_this
.
pos
_this
.
queue
.
push
_this
.
queue
.
push
start
:
_this
.
pos
start
:
_this
.
pos
end
:
stats
.
size
end
:
stats
.
size
_this
.
pos
=
stats
.
size
_this
.
pos
=
stats
.
size
_this
.
internalDispatcher
.
emit
"next"
if
_this
.
queue
.
length
is
1
_this
.
internalDispatcher
.
emit
"next"
if
_this
.
queue
.
length
is
1
else
if
e
is
"rename"
else
if
e
is
"rename"
@
unwatch
()
@
unwatch
()
_this
.
emit
"error"
,
"File "
+
@
filename
+
" deleted."
_this
.
emit
"error"
,
"File "
+
@
filename
+
" deleted."
return
return
Tail
::
close
=
->
Tail
::
close
=
->
@
unwatch
()
@
unwatch
()
return
return
module
.
exports
=
Tail
module
.
exports
=
Tail
debomatic-webui/lib/utils.coffee
View file @
18c0c552
__errors_handler
=
(
from
,
err
,
socket
)
->
__errors_handler
=
(
from
,
err
,
socket
)
->
from
=
"NO SOCKET: "
+
from
unless
socket
from
=
"NO SOCKET: "
+
from
unless
socket
console
.
error
from
,
err
.
message
console
.
error
from
,
err
.
message
socket
.
emit
config
.
events
.
error
,
err
.
message
if
socket
socket
.
emit
config
.
events
.
error
,
err
.
message
if
socket
return
return
__check_no_backward
=
(
backward_path
)
->
__check_no_backward
=
(
backward_path
)
->
try
try
return
backward_path
.
indexOf
(
".."
)
<
0
return
backward_path
.
indexOf
(
".."
)
<
0
catch
err
catch
err
return
true
return
true
return
return
__check_data_distribution
=
(
data
)
->
__check_data_distribution
=
(
data
)
->
__check_no_backward
(
data
)
and
__check_no_backward
(
data
.
distribution
)
and
__check_no_backward
(
data
.
distribution
.
name
)
__check_no_backward
(
data
)
and
__check_no_backward
(
data
.
distribution
)
and
__check_no_backward
(
data
.
distribution
.
name
)
__check_data_package
=
(
data
)
->
__check_data_package
=
(
data
)
->
__check_data_distribution
(
data
)
and
__check_no_backward
(
data
.
package
)
and
__check_no_backward
(
data
.
package
.
name
)
and
__check_no_backward
(
data
.
package
.
version
)
__check_data_distribution
(
data
)
and
__check_no_backward
(
data
.
package
)
and
__check_no_backward
(
data
.
package
.
name
)
and
__check_no_backward
(
data
.
package
.
version
)
__check_data_file
=
(
data
)
->
__check_data_file
=
(
data
)
->
__check_data_package
(
data
)
and
__check_no_backward
(
data
.
file
)
and
__check_no_backward
(
data
.
file
.
name
)
__check_data_package
(
data
)
and
__check_no_backward
(
data
.
file
)
and
__check_no_backward
(
data
.
file
.
name
)
__get_distribution_pool_path
=
(
data
)
->
__get_distribution_pool_path
=
(
data
)
->
path
.
join
config
.
debomatic
.
path
,
data
.
distribution
.
name
,
"pool"
path
.
join
config
.
debomatic
.
path
,
data
.
distribution
.
name
,
"pool"
__get_package_path
=
(
data
)
->
__get_package_path
=
(
data
)
->
path
.
join
__get_distribution_pool_path
(
data
),
data
.
package
.
name
+
"_"
+
data
.
package
.
version
path
.
join
__get_distribution_pool_path
(
data
),
data
.
package
.
name
+
"_"
+
data
.
package
.
version
__get_file_path
=
(
data
)
->
__get_file_path
=
(
data
)
->
path
.
join
__get_package_path
(
data
),
data
.
package
.
name
+
"_"
+
data
.
package
.
version
+
"."
+
data
.
file
.
name
path
.
join
__get_package_path
(
data
),
data
.
package
.
name
+
"_"
+
data
.
package
.
version
+
"."
+
data
.
file
.
name
__get_files_list
=
(
dir
,
onlyDirectories
,
callback
)
->
__get_files_list
=
(
dir
,
onlyDirectories
,
callback
)
->
fs
.
readdir
dir
,
(
err
,
files
)
->
fs
.
readdir
dir
,
(
err
,
files
)
->
result
=
[]
result
=
[]
if
err
if
err
__errors_handler
"__get_files_list"
,
err
__errors_handler
"__get_files_list"
,
err
return
return
files
.
forEach
(
f
)
->
files
.
forEach
(
f
)
->
try
try
complete_path
=
path
.
join
(
dir
,
f
)
complete_path
=
path
.
join
(
dir
,
f
)
stat
=
fs
.
statSync
(
complete_path
)
stat
=
fs
.
statSync
(
complete_path
)
if
onlyDirectories
if
onlyDirectories
result
.
push
f
if
stat
.
isDirectory
()
result
.
push
f
if
stat
.
isDirectory
()
else
else
result
.
push
f
if
stat
.
isFile
()
result
.
push
f
if
stat
.
isFile
()
catch
fs_error
catch
fs_error
__errors_handler
"__get_files_list:forEach"
,
fs_error
__errors_handler
"__get_files_list:forEach"
,
fs_error
return
return
callback
result
return
return
return
callback
result
return
return
return
__watch_path_onsocket
=
(
event_name
,
socket
,
data
,
watch_path
,
updater
)
->
__watch_path_onsocket
=
(
event_name
,
socket
,
data
,
watch_path
,
updater
)
->
socket_watchers
=
socket
.
watchers
or
{}
socket_watchers
=
socket
.
watchers
or
{}
try
try
watcher
=
socket_watchers
[
event_name
]
watcher
=
socket_watchers
[
event_name
]
watcher
.
close
()
if
watcher
watcher
.
close
()
if
watcher
fs
.
stat
watch_path
,
(
err
,
stats
)
->
fs
.
stat
watch_path
,
(
err
,
stats
)
->
if
err
if
err
__errors_handler
"__watch_path_onsocket:fs.stat"
,
err
,
socket
__errors_handler
"__watch_path_onsocket:fs.stat"
,
err
,
socket
return
if
stats
.
isDirectory
()
watcher
=
fs
.
watch
(
watch_path
,
persistent
:
true
,
(
event
,
fileName
)
->
updater
event_name
,
socket
,
data
if
event
is
"rename"
return
)
else
if
stats
.
isFile
()
watcher
=
new
Tail
(
watch_path
)
watcher
.
on
"line"
,
(
new_content
,
tailInfo
)
->
data
.
file
.
new_content
=
new_content
+
"
\n
"
updater
event_name
,
socket
,
data
return
watcher
.
on
"error"
,
(
msg
)
->
socket
.
emit
config
.
events
.
error
,
msg
return
socket_watchers
[
event_name
]
=
watcher
socket
.
watchers
=
socket_watchers
return
catch
err
__errors_handler
"__watch_path_onsocket <- "
+
arguments_
.
callee
.
caller
.
name
,
err
,
socket
return
return
if
stats
.
isDirectory
()
watcher
=
fs
.
watch
(
watch_path
,
persistent
:
true
,
(
event
,
fileName
)
->
updater
event_name
,
socket
,
data
if
event
is
"rename"
return
)
else
if
stats
.
isFile
()
watcher
=
new
Tail
(
watch_path
)
watcher
.
on
"line"
,
(
new_content
,
tailInfo
)
->
data
.
file
.
new_content
=
new_content
+
"
\n
"
updater
event_name
,
socket
,
data
return
watcher
.
on
"error"
,
(
msg
)
->
socket
.
emit
config
.
events
.
error
,
msg
return
socket_watchers
[
event_name
]
=
watcher
socket
.
watchers
=
socket_watchers
return
catch
err
__errors_handler
"__watch_path_onsocket <- "
+
arguments_
.
callee
.
caller
.
name
,
err
,
socket
return
return
return
__generic_handler_watcher
=
(
event_name
,
socket
,
data
,
watch_path
,
callback
)
->
__generic_handler_watcher
=
(
event_name
,
socket
,
data
,
watch_path
,
callback
)
->
callback
event_name
,
socket
,
data
callback
event_name
,
socket
,
data
__watch_path_onsocket
event_name
,
socket
,
data
,
watch_path
,
callback
__watch_path_onsocket
event_name
,
socket
,
data
,
watch_path
,
callback
return
__send_distributions
=
(
socket
)
->
__get_files_list
config
.
debomatic
.
path
,
true
,
(
directories
)
->
distributions
=
[]
directories
.
forEach
(
dir
)
->
data
=
{}
data
.
distribution
=
{}
data
.
distribution
.
name
=
dir
pool_path
=
__get_distribution_pool_path
(
data
)
distributions
.
push
dir
if
fs
.
existsSync
(
pool_path
)
return
socket
.
emit
config
.
events
.
broadcast
.
distributions
,
distributions
return
return
__send_distributions
=
(
socket
)
->
__get_files_list
config
.
debomatic
.
path
,
true
,
(
directories
)
->
distributions
=
[]
directories
.
forEach
(
dir
)
->
data
=
{}
data
.
distribution
=
{}
data
.
distribution
.
name
=
dir
pool_path
=
__get_distribution_pool_path
(
data
)
distributions
.
push
dir
if
fs
.
existsSync
(
pool_path
)
return
socket
.
emit
config
.
events
.
broadcast
.
distributions
,
distributions
return
return
return
"use strict"
"use strict"
path
=
require
(
"path"
)
path
=
require
(
"path"
)
fs
=
require
(
"fs"
)
fs
=
require
(
"fs"
)
config
=
require
(
"./config"
)
config
=
require
(
"./config"
)
Tail
=
require
(
"./tail"
)
Tail
=
require
(
"./tail"
)
utils
=
utils
=
check_data_distribution
:
(
data
)
->
check_data_distribution
:
(
data
)
->
__check_data_distribution
data
__check_data_distribution
data
check_data_package
:
(
data
)
->
check_data_package
:
(
data
)
->
__check_data_package
data
__check_data_package
data
check_data_file
:
(
data
)
->
check_data_file
:
(
data
)
->
__check_data_file
data
__check_data_file
data
get_distribution_pool_path
:
(
data
)
->
get_distribution_pool_path
:
(
data
)
->
__get_distribution_pool_path
data
__get_distribution_pool_path
data
get_package_path
:
(
data
)
->
get_package_path
:
(
data
)
->
__get_package_path
data
__get_package_path
data
get_file_path
:
(
data
)
->
get_file_path
:
(
data
)
->
__get_file_path
data
__get_file_path
data
get_files_list
:
(
dir
,
onlyDirectories
,
callback
)
->
get_files_list
:
(
dir
,
onlyDirectories
,
callback
)
->
__get_files_list
dir
,
onlyDirectories
,
callback
__get_files_list
dir
,
onlyDirectories
,
callback
watch_path_onsocket
:
(
event_name
,
socket
,
data
,
watch_path
,
updater
)
->
watch_path_onsocket
:
(
event_name
,
socket
,
data
,
watch_path
,
updater
)
->
__watch_path_onsocket
event_name
,
socket
,
data
,
watch_path
,
updater
__watch_path_onsocket
event_name
,
socket
,
data
,
watch_path
,
updater
generic_handler_watcher
:
(
event_name
,
socket
,
data
,
watch_path
,
callback
)
->
generic_handler_watcher
:
(
event_name
,
socket
,
data
,
watch_path
,
callback
)
->
__generic_handler_watcher
event_name
,
socket
,
data
,
watch_path
,
callback
__generic_handler_watcher
event_name
,
socket
,
data
,
watch_path
,
callback
send_distributions
:
(
socket
)
->
send_distributions
:
(
socket
)
->
__send_distributions
socket
__send_distributions
socket
errors_handler
:
(
from
,
error
,
socket
)
->
errors_handler
:
(
from
,
error
,
socket
)
->
__errors_handler
from
,
error
,
socket
__errors_handler
from
,
error
,
socket
module
.
exports
=
utils
module
.
exports
=
utils
debomatic-webui/routes/index.coffee
View file @
18c0c552
"use strict"
"use strict"
config
=
require
(
"../lib/config"
)
config
=
require
(
"../lib/config"
)
exports
.
index
=
(
req
,
res
)
->
exports
.
index
=
(
req
,
res
)
->
res
.
render
"index"
,
config
res
.
render
"index"
,
config
return
return
exports
.
distribution
=
(
req
,
res
)
->
exports
.
distribution
=
(
req
,
res
)
->
res
.
render
"distribution"
,
config
res
.
render
"distribution"
,
config
return
return
exports
.
preferences
=
(
req
,
res
)
->
exports
.
preferences
=
(
req
,
res
)
->
res
.
render
"preferences"
,
config
res
.
render
"preferences"
,
config
return
return
exports
.
commands
=
(
req
,
res
)
->
exports
.
commands
=
(
req
,
res
)
->
res
.
render
"commands"
,
config
res
.
render
"commands"
,
config
return
return
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment