Skip to content
Snippets Groups Projects
Commit df43aef3 authored by Josefine Wegert's avatar Josefine Wegert
Browse files

writes backend without addons to zip, backend and frontend together still not working

parent 63b3ea18
Branches
No related tags found
No related merge requests found
......@@ -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 /\bexplorviz-backend-plugin-\w*/.exec(file);
......@@ -133,7 +136,7 @@
if(checkedPlugins.length !== 0 ){
checkedPlugins.forEach((pluginName) => {
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/ ' +
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/ ' +
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();
}
......@@ -310,33 +315,47 @@ 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('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);
}
});
});
//console.log('backendStream:', backendStream);
const backendReadStream = fs.createReadStream(backendStream);
}
zip.file(file.zipFileName, backendReadStream);
finishedArray.push('backend finished');
if(finishedArray.length === files.length){
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();
}
}
......@@ -347,7 +366,6 @@ const backendStream = fs.readFileSync(file.path, "base64", function(error, data)
}).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);
}
......@@ -357,6 +375,7 @@ const backendStream = fs.readFileSync(file.path, "base64", function(error, data)
resolve();
}
})
console.log('frontendStream:', frontendStream);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment