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
df43aef3
Commit
df43aef3
authored
7 years ago
by
Josefine Wegert
Browse files
Options
Downloads
Patches
Plain Diff
writes backend without addons to zip, backend and frontend together still not working
parent
63b3ea18
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
+91
-72
91 additions, 72 deletions
app.js
with
91 additions
and
72 deletions
app.js
+
91
−
72
View file @
df43aef3
...
...
@@ -17,12 +17,12 @@
const
downloadFiles
=
require
(
'
./downloadFiles.json
'
);
const
downloadNames
=
Object
.
keys
(
downloadFiles
);
var
app
=
express
();
var
app
=
express
();
app
.
use
(
bodyParser
.
urlencoded
({
extended
:
true
}));
app
.
use
(
bodyParser
.
json
());
app
.
use
(
bodyParser
.
urlencoded
({
extended
:
true
}));
app
.
use
(
bodyParser
.
json
());
//set handlebars as view engine
app
.
engine
(
'
.hbs
'
,
exphbs
({
extname
:
'
.hbs
'
}));
...
...
@@ -87,6 +87,7 @@
function
backendClean
(){
console
.
log
(
'
in backendClean
'
);
return
new
Promise
((
resolve
,
reject
)
=>
{
exec
(
'
cd explorviz-ui-backend/plugins/net/explorviz/ && rm -rf plugins/*
'
,
(
error
,
stdout
,
stderr
)
=>
{
if
(
error
)
{
...
...
@@ -104,7 +105,7 @@
}
function
backendPull
(){
console
.
log
(
'
in backendPull
'
);
return
new
Promise
((
resolve
,
reject
)
=>
{
exec
(
'
cd
'
+
fileName
+
'
git pull
'
,
(
error
,
stdout
,
stderr
)
=>
{
...
...
@@ -124,7 +125,9 @@
}
function
backendInstallAddons
(){
console
.
log
(
'
in backendInstallAddons
'
);
return
new
Promise
((
resolve
,
reject
)
=>
{
checkedPlugins
=
checkedFiles
.
filter
(
function
(
file
){
return
/
\b
explorviz-backend-plugin-
\w
*/
.
exec
(
file
);
...
...
@@ -133,7 +136,7 @@
if
(
checkedPlugins
.
length
!==
0
){
checkedPlugins
.
forEach
((
pluginName
)
=>
{
exec
(
'
git clone
'
+
downloadFiles
[
pluginName
]
+
'
&& c
p -R
'
+
pluginName
+
'
/
'
+
'
explorviz-ui-backend/plugins/net/explorviz/plugins/
'
,
(
error
,
stdout
,
stderr
)
=>
{
//'cd explorviz-ui-backend/plugins/net/explorviz/plugins/ ' +
exec
(
'
git clone
'
+
downloadFiles
[
pluginName
]
+
'
&& c
d
'
+
pluginName
+
'
&& cp -R
'
+
'
.
'
+
'
../
explorviz-ui-backend/plugins/net/explorviz/plugins/
'
,
(
error
,
stdout
,
stderr
)
=>
{
//'cd explorviz-ui-backend/plugins/net/explorviz/plugins/ ' +
if
(
error
)
{
reject
(
error
);
...
...
@@ -158,6 +161,7 @@
}
function
backendBuild
(){
console
.
log
(
'
in backendBuild
'
);
return
new
Promise
((
resolve
,
reject
)
=>
{
exec
(
'
cd
'
+
fileName
+
'
&& mvn compile war:war
'
,
(
error
,
stdout
,
stderr
)
=>
{
if
(
error
)
{
...
...
@@ -188,6 +192,7 @@
}
promiseArray
.
push
(
backendAll
());
console
.
log
(
'
promiseArray:
'
,
promiseArray
);
finalizeZip
();
}
...
...
@@ -274,17 +279,17 @@
})
console
.
log
(
'
resolve build:
'
,
resolve
);
}
console
.
log
(
'
resolve build:
'
,
resolve
);
}
function
frontendAll
()
{
function
frontendAll
()
{
return
frontendPull
().
then
(
function
(){
return
frontendInstallAddons
().
then
(
function
(){
return
frontendBuild
()
})
})
}
return
frontendPull
().
then
(
function
(){
return
frontendInstallAddons
().
then
(
function
(){
return
frontendBuild
()
})
})
}
//frontend was selected and the next step (streaming to zip) has to wait until the frontend is built
promiseArray
.
push
(
frontendAll
());
finalizeZip
();
...
...
@@ -310,59 +315,73 @@ function streamFilesToZip(){
console
.
log
(
'
in streamFilesToZip
'
);
return
new
Promise
((
resolve
,
reject
)
=>
{
console
.
log
(
'
promiseArray:
'
,
promiseArray
);
Promise
.
all
(
promiseArray
).
then
(
files
=>
{
console
.
log
(
'
in Promise.all
'
);
let
finishedArray
=
[];
files
.
forEach
(
file
=>
{
if
(
file
.
zipFileName
===
'
backend.war
'
){
// console.log('backendStream:');
// backendStream = fs.createReadStream(file.path);
// console.log('zip.file:');
// zip.file(file.zipFileName, backendStream);
// console.log('backend done:');
// finishedArray.push('backend done');
const
backendStream
=
fs
.
readFileSync
(
file
.
path
,
"
base64
"
,
function
(
error
,
data
){
if
(
error
){
console
.
log
(
'
error:
'
,
error
)
}
});
//console.log('backendStream:', backendStream);
const
backendReadStream
=
fs
.
createReadStream
(
backendStream
);
zip
.
file
(
file
.
zipFileName
,
backendReadStream
);
finishedArray
.
push
(
'
backend finished
'
);
if
(
finishedArray
.
length
===
files
.
length
){
resolve
();
}
}
if
(
file
.
zipFileName
===
'
frontend
'
){
const
frontendStream
=
fsReaddir
(
file
.
path
)
.
on
(
'
error
'
,
function
(
err
)
{
console
.
log
(
'
error:
'
,
err
);
}).
on
(
'
data
'
,
function
(
data
){
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
();
}
})
}
})
console
.
log
(
'
in backend.war
'
);
fs
.
readFileAsync
=
function
(
filePath
){
return
new
Promise
(
function
(
resolve
,
reject
)
{
fs
.
readFile
(
filePath
,
function
(
err
,
data
)
{
if
(
err
)
{
reject
(
err
);
}
else
{
resolve
(
data
);
}
});
});
}
function
addBackendToZip
(
data
){
return
new
Promise
(
function
(
resolve
,
reject
){
zip
.
file
(
file
.
zipFileName
,
data
);
resolve
();
})
}
backendContent
=
fs
.
readFileAsync
(
file
.
path
);
backendContent
.
then
(
function
(
data
){
addBackendToZip
(
data
).
then
(
function
(){
resolve
(
finishedArray
.
push
(
'
backend finished
'
));
})
})
if
(
finishedArray
.
length
===
files
.
length
){
resolve
();
}
}
if
(
file
.
zipFileName
===
'
frontend
'
){
const
frontendStream
=
fsReaddir
(
file
.
path
)
.
on
(
'
error
'
,
function
(
err
)
{
console
.
log
(
'
error:
'
,
err
);
}).
on
(
'
data
'
,
function
(
data
){
for
(
let
i
=
0
;
i
<
data
.
length
;
i
++
)
{
const
frontendReadStream
=
fs
.
createReadStream
(
data
[
i
]);
zip
.
file
(
data
[
i
],
frontendReadStream
);
}
}).
on
(
'
finish
'
,
function
(){
finishedArray
.
push
(
'
frontend finished
'
);
if
(
finishedArray
.
length
===
files
.
length
){
resolve
();
}
})
console
.
log
(
'
frontendStream:
'
,
frontendStream
);
}
})
})
...
...
@@ -372,16 +391,16 @@ const backendStream = fs.readFileSync(file.path, "base64", function(error, data)
function
createZip
(){
console
.
log
(
'
in createZip
'
);
return
new
Promise
((
resolve
,
reject
)
=>
{
zip
.
generateNodeStream
({
type
:
'
nodebuffer
'
,
streamFiles
:
true
}).
pipe
(
fs
.
createWriteStream
(
'
explorviz-builds.zip
'
)).
on
(
'
error
'
,
function
(
error
){
console
.
log
(
'
error in createZip:
'
,
error
);
}).
on
(
'
finish
'
,
function
()
{
console
.
log
(
'
explorviz-builds.zip written.
'
);
res
.
download
(
'
explorviz-builds.zip
'
);
});
})
console
.
log
(
'
error in createZip:
'
,
error
);
}).
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