File: commands/webfan/remove.js

Recommend this page to a friend!
  Classes of Melanie Wehowski   Widget CLI   commands/webfan/remove.js   Download  
File: commands/webfan/remove.js
Role: Auxiliary script
Content type: text/plain
Description: Auxiliary script
Class: Widget CLI
Process commands entered by the user
Author: By
Last change:
Date: 7 years ago
Size: 4,411 bytes
 

Contents

Class file image Download
/* webfan (C) Till Wehowski, Webfan.de - All rights reserved. */ var DBS = { apc : 'apc', projects : 'apc.projects' }; exports.finalize = function(){ var CLI = this; CLI.data.data = CLI.result; CLI.emit('cmd.finalized', CLI.data.data); }; exports.prepare = function(_CLI){ _CLI.finalState.add('cmd.finalized'); _CLI.result = ''; _CLI.result+='Remove items...:' +'\n'; //remove a project //.projects (parent, id, vendor, packagename, type, tag, install_secret , password ,password_alg, uid, organisation, title, dir, file) //.projects_required_php_version (projectID, version) //.projects_required_php_packages (projectID, vendor, packagename, version) //.projects_required_php_ext (projectID, ext, version) //.projects_required_widget (projectID, widget) //.projects_required_npm (projectID, package) // rmdir project.dir _CLI.addOption('project', 'Remove a project with the given #ID', function(name, value) { var table = DBS.projects, project = null; var taskGroup = 'apc.project.remove:' + value + ':'+frdl.Guid.newGuid(); var priority = 2; var group = frdl.task(taskGroup); group.pause(); var sqlTask = frdl.task().ql; var cliTask = frdl.task().cli; _CLI.result+='Try to remove project: '+value +'\n'; var q2='SELECT * FROM ' + table + ' ' + " WHERE id="+frdl.ql_escape_string(value) + " LIMIT 1"; frdl.c(q2, function(err, data){ if(err){ _CLI.error(err); group.clearAll(); return; } if(0===data.data.length)return; var row; while((row = frdl.sql.fetch_object(data)) && row){ project = row; } frdl.task(taskGroup, 'schedule', new sqlTask( 'DELETE FROM '+DBS.apc+'.'+'projects_required_php_version ' + " WHERE projectID="+frdl.ql_escape_string(project.id) + " LIMIT 1" , /*'frdl.alert'*/false, priority)); frdl.task(taskGroup, 'schedule', new sqlTask( 'DELETE FROM '+DBS.apc+'.'+'projects_required_php_packages ' + " WHERE projectID="+frdl.ql_escape_string(project.id) + " " , /*'frdl.alert'*/false, priority)); frdl.task(taskGroup, 'schedule', new sqlTask( 'DELETE FROM '+DBS.apc+'.'+'projects_required_php_ext ' + " WHERE projectID="+frdl.ql_escape_string(project.id) + " " , /*'frdl.alert'*/false, priority)); frdl.task(taskGroup, 'schedule', new sqlTask( 'DELETE FROM '+DBS.apc+'.'+'projects_required_widget ' + " WHERE projectID="+frdl.ql_escape_string(project.id) + " " , /*'frdl.alert'*/false, priority)); frdl.task(taskGroup, 'schedule', new sqlTask( 'DELETE FROM '+DBS.apc+'.'+'projects_required_npm ' + " WHERE projectID="+frdl.ql_escape_string(project.id) + " " , /*'frdl.alert'*/false, priority)); frdl.task(taskGroup, 'schedule', new sqlTask( 'DELETE FROM '+table + " WHERE id="+frdl.ql_escape_string(project.id) + " LIMIT 1 " , /*'frdl.alert'*/false, priority)); frdl.task(taskGroup, 'schedule', "var fs = require('fs');fs.rmdir('"+project.dir+"');"); frdl.task(taskGroup, 'schedule', new sqlTask( 'COMMIT' , /*'frdl.alert'*/false, priority)); group.resume(); }); }, ' [TEXT]') ; };