Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
explorviz-downloader
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ExplorViz
explorviz-github-archive
explorviz-downloader
Commits
63b3ea18
Commit
63b3ea18
authored
7 years ago
by
Josefine Wegert
Browse files
Options
Downloads
Patches
Plain Diff
work in progress: add backend to zip and strange behaviour in frontend
parent
ba6763e3
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
app.js
+73
-62
73 additions, 62 deletions
app.js
with
73 additions
and
62 deletions
app.js
+
73
−
62
View file @
63b3ea18
...
@@ -17,12 +17,12 @@
...
@@ -17,12 +17,12 @@
const
downloadFiles
=
require
(
'
./downloadFiles.json
'
);
const
downloadFiles
=
require
(
'
./downloadFiles.json
'
);
const
downloadNames
=
Object
.
keys
(
downloadFiles
);
const
downloadNames
=
Object
.
keys
(
downloadFiles
);
let
app
=
express
();
var
app
=
express
();
app
.
use
(
bodyParser
.
urlencoded
({
app
.
use
(
bodyParser
.
urlencoded
({
extended
:
true
extended
:
true
}));
}));
app
.
use
(
bodyParser
.
json
());
app
.
use
(
bodyParser
.
json
());
//set handlebars as view engine
//set handlebars as view engine
app
.
engine
(
'
.hbs
'
,
exphbs
({
extname
:
'
.hbs
'
}));
app
.
engine
(
'
.hbs
'
,
exphbs
({
extname
:
'
.hbs
'
}));
...
@@ -88,7 +88,7 @@
...
@@ -88,7 +88,7 @@
function
backendClean
(){
function
backendClean
(){
return
new
Promise
((
resolve
,
reject
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
exec
(
'
cd explorviz-ui-backend/plugins/net/explorviz/plugins/
&& rm
*
'
,
(
error
,
stdout
,
stderr
)
=>
{
exec
(
'
cd explorviz-ui-backend/plugins/net/explorviz/
&& rm -rf
plugins/*
'
,
(
error
,
stdout
,
stderr
)
=>
{
if
(
error
)
{
if
(
error
)
{
reject
(
error
);
reject
(
error
);
return
;
return
;
...
@@ -107,7 +107,7 @@
...
@@ -107,7 +107,7 @@
return
new
Promise
((
resolve
,
reject
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
exec
(
'
cd
'
+
fileName
+
'
git pull
'
,
(
error
,
stdout
,
stderr
)
=>
{
exec
(
'
cd
'
+
fileName
+
'
git pull
'
,
(
error
,
stdout
,
stderr
)
=>
{
if
(
error
)
{
if
(
error
)
{
reject
(
error
);
reject
(
error
);
...
@@ -133,7 +133,7 @@
...
@@ -133,7 +133,7 @@
if
(
checkedPlugins
.
length
!==
0
){
if
(
checkedPlugins
.
length
!==
0
){
checkedPlugins
.
forEach
((
pluginName
)
=>
{
checkedPlugins
.
forEach
((
pluginName
)
=>
{
exec
(
'
git clone
'
+
downloadFiles
[
pluginName
]
+
'
cd
'
+
pluginName
+
'
cp -r .
explorviz-ui-backend/plugins/net/explorviz/plugins/
'
,
(
error
,
stdout
,
stderr
)
=>
{
//'cd explorviz-ui-backend/plugins/net/explorviz/plugins/ ' +
exec
(
'
git clone
'
+
downloadFiles
[
pluginName
]
+
'
&& cp -R
'
+
pluginName
+
'
/
'
+
'
explorviz-ui-backend/plugins/net/explorviz/plugins/
'
,
(
error
,
stdout
,
stderr
)
=>
{
//'cd explorviz-ui-backend/plugins/net/explorviz/plugins/ ' +
if
(
error
)
{
if
(
error
)
{
reject
(
error
);
reject
(
error
);
...
@@ -179,7 +179,6 @@
...
@@ -179,7 +179,6 @@
function
backendAll
(){
function
backendAll
(){
return
backendClean
().
then
(
function
(){
return
backendClean
().
then
(
function
(){
return
backendPull
().
then
(
function
(){
return
backendPull
().
then
(
function
(){
return
backendInstallAddons
().
then
(
function
(){
return
backendInstallAddons
().
then
(
function
(){
return
backendBuild
()
return
backendBuild
()
...
@@ -231,7 +230,7 @@
...
@@ -231,7 +230,7 @@
if
(
checkedPlugins
.
length
!==
0
){
if
(
checkedPlugins
.
length
!==
0
){
checkedPlugins
.
forEach
((
pluginName
)
=>
{
checkedPlugins
.
forEach
((
pluginName
)
=>
{
exec
(
'
cd
'
+
'
explorviz-ui-frontend
'
+
'
ember install
'
+
downloadFiles
[
pluginName
],
(
error
,
stdout
,
stderr
)
=>
{
exec
(
'
cd
'
+
'
explorviz-ui-frontend
'
+
'
ember install
'
+
downloadFiles
[
pluginName
],
(
error
,
stdout
,
stderr
)
=>
{
if
(
error
)
{
if
(
error
)
{
reject
(
error
);
reject
(
error
);
...
@@ -275,16 +274,17 @@
...
@@ -275,16 +274,17 @@
})
})
}
console
.
log
(
'
resolve build:
'
,
resolve
);
}
function
frontendAll
()
{
function
frontendAll
()
{
return
frontendPull
().
then
(
function
(){
return
frontendPull
().
then
(
function
(){
return
frontendInstallAddons
().
then
(
function
(){
return
frontendInstallAddons
().
then
(
function
(){
return
frontendBuild
()
return
frontendBuild
()
})
})
})
})
}
}
//frontend was selected and the next step (streaming to zip) has to wait until the frontend is built
//frontend was selected and the next step (streaming to zip) has to wait until the frontend is built
promiseArray
.
push
(
frontendAll
());
promiseArray
.
push
(
frontendAll
());
finalizeZip
();
finalizeZip
();
...
@@ -316,44 +316,53 @@ function streamFilesToZip(){
...
@@ -316,44 +316,53 @@ function streamFilesToZip(){
let
finishedArray
=
[];
let
finishedArray
=
[];
files
.
forEach
(
file
=>
{
files
.
forEach
(
file
=>
{
if
(
file
.
zipFileName
===
'
backend.war
'
){
if
(
file
.
zipFileName
===
'
backend.war
'
){
const
backendSteam
=
fsReaddir
(
file
.
path
).
on
(
'
data
'
,
function
(
data
){
// console.log('backendStream:');
const
backendReadStream
=
fs
.
createReadStream
(
data
);
// backendStream = fs.createReadStream(file.path);
zip
.
file
(
zipFileName
,
backendReadStream
);
// console.log('zip.file:');
}).
on
(
'
error
'
,
function
(){
// zip.file(file.zipFileName, backendStream);
console
.
log
(
'
error:
'
,
error
);
// console.log('backend done:');
}).
on
(
'
finish
'
,
function
(){
// finishedArray.push('backend done');
finishedArray
.
push
(
'
backend finished
'
);
const
backendStream
=
fs
.
readFileSync
(
file
.
path
,
"
base64
"
,
function
(
error
,
data
){
if
(
finishedArray
.
length
===
files
.
length
){
if
(
error
){
resolve
();
console
.
log
(
'
error:
'
,
error
)
}
}
})
});
//console.log('backendStream:', backendStream);
// backendStream = fs.createReadStream(file.path);
const
backendReadStream
=
fs
.
createReadStream
(
backendStream
);
// zip.file(file.zipFileName, backendStream);
// finishedArray.push('backend done');
zip
.
file
(
file
.
zipFileName
,
backendReadStream
);
}
finishedArray
.
push
(
'
backend finished
'
);
if
(
file
.
zipFileName
===
'
frontend
'
){
if
(
finishedArray
.
length
===
files
.
length
){
const
frontendStream
=
fsReaddir
(
file
.
path
)
resolve
();
.
on
(
'
error
'
,
function
(
err
)
{
}
console
.
log
(
'
error:
'
,
err
);
}).
on
(
'
data
'
,
function
(
data
){
for
(
let
i
=
0
;
i
<
data
.
length
;
i
++
)
{
const
frontendReadsStream
=
fs
.
createReadStream
(
data
[
i
]);
zip
.
file
(
data
[
i
],
frontendReadStream
);
}
}
if
(
file
.
zipFileName
===
'
frontend
'
){
const
frontendStream
=
fsReaddir
(
file
.
path
)
}).
on
(
'
finish
'
,
function
(){
.
on
(
'
error
'
,
function
(
err
)
{
finishedArray
.
push
(
'
frontend finished
'
);
console
.
log
(
'
error:
'
,
err
);
if
(
finishedArray
.
length
===
files
.
length
){
}).
on
(
'
data
'
,
function
(
data
){
resolve
();
for
(
let
i
=
0
;
i
<
data
.
length
;
i
++
)
{
}
const
frontendReadStream
=
fs
.
createReadStream
(
data
[
i
]);
})
console
.
log
(
'
data[i]:
'
,
data
[
i
]);
zip
.
file
(
data
[
i
],
frontendReadStream
);
}
}
}).
on
(
'
finish
'
,
function
(){
finishedArray
.
push
(
'
frontend finished
'
);
})
if
(
finishedArray
.
length
===
files
.
length
){
resolve
();
}
})
}
})
})
})
...
@@ -365,12 +374,14 @@ function createZip(){
...
@@ -365,12 +374,14 @@ function createZip(){
console
.
log
(
'
in createZip
'
);
console
.
log
(
'
in createZip
'
);
return
new
Promise
((
resolve
,
reject
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
zip
.
generateNodeStream
({
type
:
'
nodebuffer
'
,
streamFiles
:
true
}).
pipe
(
fs
.
createWriteStream
(
'
explorviz-builds.zip
'
)).
on
(
'
finish
'
,
function
()
{
zip
.
generateNodeStream
({
type
:
'
nodebuffer
'
,
streamFiles
:
true
}).
pipe
(
fs
.
createWriteStream
(
'
explorviz-builds.zip
'
)).
on
(
'
error
'
,
function
(
error
){
console
.
log
(
'
explorviz-builds.zip written.
'
);
console
.
log
(
'
error in createZip:
'
,
error
);
res
.
download
(
'
explorviz-builds.zip
'
);
}).
on
(
'
finish
'
,
function
()
{
});
console
.
log
(
'
explorviz-builds.zip written.
'
);
res
.
download
(
'
explorviz-builds.zip
'
);
})
});
})
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment