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
abc7ae3d
Commit
abc7ae3d
authored
7 years ago
by
Josefine Wegert
Browse files
Options
Downloads
Patches
Plain Diff
work in progress: try to get archiver running
parent
f026c909
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
+103
-34
103 additions, 34 deletions
app.js
with
103 additions
and
34 deletions
app.js
+
103
−
34
View file @
abc7ae3d
...
...
@@ -7,6 +7,7 @@ var exec = require('child_process').exec;
var
fs
=
require
(
'
fs
'
);
var
path
=
require
(
'
path
'
);
var
Zip
=
require
(
'
node-zip
'
);
var
archiver
=
require
(
'
archiver
'
);
var
exphbs
=
require
(
'
express-handlebars
'
);
var
logger
=
require
(
'
morgan
'
);
...
...
@@ -33,7 +34,7 @@ app.set('view engine', '.hbs');
//routes
app
.
get
(
'
/
'
,
function
(
req
,
res
){
res
.
render
(
'
home
'
,
{
downloadFiles
:
downloadNames
});
res
.
clearCookie
(
req
.
cookies
.
fileCookie
).
render
(
'
home
'
,
{
downloadFiles
:
downloadNames
});
});
...
...
@@ -41,22 +42,36 @@ app.post('/', function(req, res, next){
var
checkedFiles
=
Object
.
keys
(
req
.
body
);
if
(
typeof
checkedFiles
!==
'
undefined
'
&&
checkedFiles
.
length
>
0
){
console
.
log
(
'
files were checked
'
);
//set cookie to pass checked files for download
//set cookie to pass checked files for download
res
.
cookie
(
'
fileCookie
'
,
checkedFiles
).
render
(
'
download
'
);
}
else
{
console
.
log
(
'
files were not checked
'
);
res
.
render
(
'
home
'
,
{
downloadFiles
:
downloadNames
});
}
});
app
.
get
(
'
/download
'
,
function
(
req
,
res
){
console
.
log
(
"
checkedFiles in /download
"
,
req
.
cookies
.
fileCookie
);
// if (typeof req.body.backend !== 'undefined'){
console
.
log
(
"
inside backend branch
"
);
exec
(
'
cd /home/jweg/git/explorviz-ui-backend && mvn compile war:war
'
,
(
error
,
stdout
,
stderr
)
=>
{
req
.
cookies
.
fileCookie
.
forEach
((
fileName
)
=>
{
downloadURL
=
downloadFiles
[
fileName
];
var
zip
=
new
Zip
();
// create a file to stream archive data to.
var
output
=
fs
.
createWriteStream
(
__dirname
+
'
explorviz-builds.zip
'
);
var
archive
=
archiver
(
'
zip
'
,
{
base64
:
false
,
compression
:
'
DEFLATE
'
,
store
:
true
// Sets the compression method to STORE.
});
archive
.
append
(
fs
.
readFileSync
(
path
.
join
(
__dirname
,
'
README.txt
'
)),
{
name
:
'
README.txt
'
});
//----------------------------------------------------------------backend
if
(
fileName
===
'
explorviz-ui-backend
'
){
exec
(
'
git clone
'
+
downloadURL
+
'
'
+
fileName
+
'
&& cd
'
+
fileName
+
'
&& mvn compile war:war
'
,
(
error
,
stdout
,
stderr
)
=>
{
var
response
=
'
There was an error during your build.
'
+
...
...
@@ -71,44 +86,98 @@ console.log("checkedFiles in /download", req.cookies.fileCookie);
console
.
log
(
stdout
);
console
.
log
(
stderr
);
var
zip
=
new
Zip
();
archive
.
file
(
fileName
+
'
/target/explorviz-ui-backend-1.0-SNAPSHOT.war
'
,
{
name
:
'
backend/explorviz-backend.war
'
});
//-------------------------------------------------------------------frontend
});
}
else
if
(
fileName
===
'
explorviz-ui-frontend
'
){
exec
(
'
git clone
'
+
downloadURL
+
'
'
+
fileName
+
'
&& cd
'
+
fileName
+
'
&& npm install
'
,
(
error
,
stdout
,
stderr
)
=>
{
console
.
log
(
'
downloadURL
'
,
downloadURL
);
console
.
log
(
'
fileName
'
,
fileName
);
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
(
'
stdout
'
,
stdout
);
console
.
log
(
'
stderr
'
,
stderr
);
if
(
error
)
{
res
.
send
(
response
);
return
;
}
zip
.
folder
(
"
frontend
"
);
zip
.
folder
(
"
backend
"
);
zip
.
file
(
'
README.txt
'
,
fs
.
readFileSync
(
path
.
join
(
__dirname
,
'
README.txt
'
)));
zip
.
file
(
'
explorviz-backend.war
'
,
fs
.
readFileSync
(
'
/home/jweg/git/explorviz-ui-backend/target/explorviz-ui-backend-1.0-SNAPSHOT.war
'
));
//Plugins to install?
req
.
cookies
.
fileCookie
.
forEach
((
pluginName
)
=>
{
if
(
pluginName
===
/explorviz-frontend-plugin-*/
){
exec
(
'
ember install
'
+
downloadFiles
[
pluginName
],
(
error
,
stdout
,
stderr
)
=>
{
var
response
=
'
There was an error during your build.
'
+
'
Please contact "explorviz-developers-request@listserv.dfn.de"
'
+
'
and add the following information:
'
+
error
;
var
options
=
{
base64
:
false
,
compression
:
'
DEFLATE
'
};
if
(
error
)
{
res
.
send
(
response
);
return
;
}
fs
.
writeFile
(
'
explorviz-builds.zip
'
,
zip
.
generate
(
options
),
'
binary
'
,
function
(
error
)
{
if
(
error
)
{
console
.
log
(
stdout
);
console
.
log
(
stderr
);
});
};
});
//-----------------------------plugin-forEach
//build everything you have
exec
(
'
ember build --environment production
'
,
(
error
,
stdout
,
stderr
)
=>
{
var
response
=
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
(
'
stdout
'
,
stdout
);
console
.
log
(
'
stderr
'
,
stderr
);
if
(
error
)
{
res
.
send
(
response
);
return
;
}
console
.
log
(
stdout
);
console
.
log
(
stderr
);
res
.
send
(
response
);
return
;
});
// ------------------------------------------ember build
});
archive
.
directory
(
'
dist/
'
,
{
name
:
'
frontend/dist
'
});
}
}
else
{
//create zip and download it
// listen for all archive data to be written
output
.
on
(
'
close
'
,
function
()
{
console
.
log
(
archive
.
pointer
()
+
'
total bytes
'
);
console
.
log
(
'
archiver has been finalized and the output file descriptor has closed.
'
);
});
// good practice to catch this error explicitly
archive
.
on
(
'
error
'
,
function
(
err
)
{
throw
err
;
});
archive
.
pipe
(
output
);
archive
.
finalize
();
res
.
download
(
'
explorviz-builds.zip
'
);
}
});
});
// }
// else if (typeof req.body.frontend !== 'undefined'){
// console.log("inside frontend branch");
// res.send(req.body.frontend);
// } else {
// console.log("inside else branch");
// res.send("nix ausgewählt");
// }
});
});
...
...
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