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
07391b69
Commit
07391b69
authored
8 years ago
by
Josefine Wegert
Browse files
Options
Downloads
Patches
Plain Diff
work in progress: adding promises for building zip
parent
2dd19a80
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
app.js
+59
-57
59 additions, 57 deletions
app.js
with
59 additions
and
57 deletions
app.js
+
59
−
57
View file @
07391b69
...
@@ -66,10 +66,10 @@ if(typeof checkedFiles !== 'undefined' && checkedFiles.length > 0){
...
@@ -66,10 +66,10 @@ if(typeof checkedFiles !== 'undefined' && checkedFiles.length > 0){
app
.
get
(
'
/download
'
,
function
(
req
,
res
){
app
.
get
(
'
/download
'
,
function
(
req
,
res
){
const
promiseArray
=
[]
const
checkedFiles
=
req
.
query
.
checkedFiles
.
split
(
'
,
'
);
const
checkedFiles
=
req
.
query
.
checkedFiles
.
split
(
'
,
'
);
var
zip
=
new
JSZip
();
const
zip
=
new
JSZip
();
// create a file to stream archive data to.
// create a file to stream archive data to.
zip
.
file
(
"
README.txt
"
,
"
text for README
"
);
zip
.
file
(
"
README.txt
"
,
"
text for README
"
);
...
@@ -86,25 +86,28 @@ if (backendChecked){
...
@@ -86,25 +86,28 @@ if (backendChecked){
const
fileName
=
backendChecked
;
const
fileName
=
backendChecked
;
const
downloadURL
=
downloadFiles
[
backendChecked
];
const
downloadURL
=
downloadFiles
[
backendChecked
];
const
backendPromise
=
new
Promise
((
resolve
,
reject
)
=>
{
exec
(
'
git pull
'
+
'
&& cd
'
+
fileName
+
'
&& mvn compile war:war
'
,
(
error
,
stdout
,
stderr
)
=>
{
exec
(
'
git pull
'
+
'
&& cd
'
+
fileName
+
'
&& mvn compile war:war
'
,
(
error
,
stdout
,
stderr
)
=>
{
addBackend
();
//addBackend();
var
response
=
'
There was an error during your build.
'
+
'
Please contact "explorviz-developers-request@listserv.dfn.de"
'
+
'
and add the following information:
'
+
error
;
console
.
log
(
'
error in exec
'
,
error
);
if
(
error
)
{
if
(
error
)
{
res
.
send
(
response
);
reject
(
error
);
// res.send(response); beim promise.all
return
;
return
;
}
}
console
.
log
(
stdout
);
console
.
log
(
stdout
);
console
.
log
(
stderr
);
console
.
log
(
stderr
);
});
//.then(addBackend()), würde auch gehen (npm packet: exec-then), aber hilft nicht dabei, zu wissen, wann zip gebaut werden darf
resolve
({
fileName
:
"
backend.war
"
,
path
:
"
explorviz-ui-backend/target/explorviz-ui-backend-1.0-SNAPSHOT.war
"
});
});
})
promiseArray
.
push
(
backendPromise
);
console
.
log
(
'
promiseArray:
'
,
promiseArray
);
}
}
//--------------------------------------------------------------------------------frontend
//--------------------------------------------------------------------------------frontend
...
@@ -133,7 +136,7 @@ installAddons();
...
@@ -133,7 +136,7 @@ installAddons();
};
};
function
installAddons
(){
function
installAddons
(){
console
.
log
(
'
in installAddons()
'
);
checkedPlugins
=
checkedFiles
.
filter
(
function
(
file
){
checkedPlugins
=
checkedFiles
.
filter
(
function
(
file
){
return
/
\b
explorviz-frontend-plugin-
\w
*/
.
exec
(
file
);
return
/
\b
explorviz-frontend-plugin-
\w
*/
.
exec
(
file
);
});
});
...
@@ -188,14 +191,14 @@ console.log(stderr);
...
@@ -188,14 +191,14 @@ console.log(stderr);
};
// ------------------------------------------ember build
};
// ------------------------------------------ember build
function
addBackend
(){
//
function addBackend(){
// read a file as a stream and add it to a zip
//
// read a file as a stream and add it to a zip
console
.
log
(
'
addBackend()
'
);
//
console.log('addBackend()');
const
backendStream
=
fs
.
createReadStream
(
"
explorviz-ui-backend/target/explorviz-ui-backend-1.0-SNAPSHOT.war
"
);
//
const backendStream = fs.createReadStream("explorviz-ui-backend/target/explorviz-ui-backend-1.0-SNAPSHOT.war");
zip
.
file
(
"
backend.war
"
,
backendStream
);
//
zip.file("backend.war", backendStream);
backendFinished
=
true
;
//
backendFinished = true;
createZip
();
//
createZip();
};
//
};
function
addFrontend
(){
function
addFrontend
(){
console
.
log
(
"
in addFrontend
"
);
console
.
log
(
"
in addFrontend
"
);
...
@@ -218,49 +221,48 @@ var stream = fsReaddir('./explorviz-ui-frontend/dist/')
...
@@ -218,49 +221,48 @@ var stream = fsReaddir('./explorviz-ui-frontend/dist/')
function
createZip
(){
Promise
.
all
(
promiseArray
).
then
(
files
=>
{
console
.
log
(
'
frontendFinished
'
,
frontendFinished
);
//if (files.fileName === "backend.war"){
console
.
log
(
'
backendFinished
'
,
backendFinished
);
//if(frontendFinished){
console
.
log
(
'
files.path
'
,
files
.
path
);
// if (frontendChecked){
console
.
log
(
'
files.fileName
'
,
files
.
fileName
);
// if (backendChecked){
// if(frontendFinished && backendFinished){
backendStream
=
fs
.
createReadStream
(
files
.
path
);
// console.log('both');
zip
.
file
(
files
.
fileName
,
backendStream
);
//create zip and download it
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
(
'
finish
'
,
function
()
{
// JSZip generates a readable stream with a "end" event,
console
.
log
(
'
explorviz-builds.zip written.
'
);
// but is piped here in a writable stream which emits a "finish" event.
console
.
log
(
"
explorviz-builds.zip written.
"
);
res
.
download
(
'
explorviz-builds.zip
'
);
res
.
download
(
'
explorviz-builds.zip
'
);
});
});
//}
}).
catch
(
function
(
error
)
{
let
response
=
'
There was an error during your build.
'
+
'
Please contact "explorviz-developers-request@listserv.dfn.de"
'
+
'
and add the following information:
'
+
error
;
res
.
send
(
response
);
})
};
// } else if (frontendFinished) {//!backendChecked
// console.log('frontend only');
// zip.generateNodeStream({type:'nodebuffer',streamFiles:true}).pipe(fs.createWriteStream('explorviz-builds.zip')).on('finish', function () {
// // JSZip generates a readable stream with a "end" event,
// // but is piped here in a writable stream which emits a "finish" event.
// console.log("explorviz-builds.zip frontend only written.");
// res.download('explorviz-builds.zip');
// });}
// function createZip(){
// console.log('frontendFinished', frontendFinished);
// console.log('backendFinished', backendFinished);
// } else if (backendChecked){//!frontendChecked
// if (backendFinished){
// console.log('backend only');
// //create zip and download it
// //create zip and download it
// 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('finish', function () {
// // JSZip generates a readable stream with a "end" event,
// // JSZip generates a readable stream with a "end" event,
// // but is piped here in a writable stream which emits a "finish" event.
// // but is piped here in a writable stream which emits a "finish" event.
// console.log("explorviz-builds.zip
backend only
written.");
// console.log("explorviz-builds.zip written.");
// res.download('explorviz-builds.zip');
// res.download('explorviz-builds.zip');
// });
// });
// }
// }
// }
// };
});
});
app
.
listen
(
8080
);
app
.
listen
(
3000
);
console
.
log
(
"
Downloader started on port 8080.
"
);
console
.
log
(
"
Downloader started on port 3000.
"
);
\ No newline at end of file
\ No newline at end of file
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