2018-08-19 11:00:13 +03:00
|
|
|
/*
|
2019-01-26 07:54:56 +03:00
|
|
|
* Copyright (C) 2018-2019 QuasarApp.
|
2018-08-19 11:00:13 +03:00
|
|
|
* Distributed under the lgplv3 software license, see the accompanying
|
|
|
|
* Everyone is permitted to copy and distribute verbatim copies
|
|
|
|
* of this license document, but changing it is not allowed.
|
2018-10-24 17:26:42 +03:00
|
|
|
*/
|
2018-08-19 11:00:13 +03:00
|
|
|
|
2019-09-14 13:59:11 +03:00
|
|
|
#include "configparser.h"
|
2018-08-17 20:47:49 +03:00
|
|
|
#include "deploy.h"
|
2019-09-08 13:37:33 +03:00
|
|
|
#include "extracter.h"
|
|
|
|
#include "filemanager.h"
|
2018-10-24 17:26:42 +03:00
|
|
|
#include <quasarapp.h>
|
2019-08-24 01:04:36 +03:00
|
|
|
|
2019-09-08 13:37:33 +03:00
|
|
|
Deploy::Deploy() {
|
|
|
|
_fileManager = new FileManager();
|
2019-09-14 13:59:11 +03:00
|
|
|
_paramsParser = new ConfigParser(_fileManager);
|
2019-09-09 18:12:39 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
int Deploy::run() {
|
|
|
|
|
|
|
|
if (!prepare()) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return deploy();
|
|
|
|
}
|
|
|
|
|
|
|
|
Deploy::~Deploy() {
|
|
|
|
|
|
|
|
if (_extracter) {
|
|
|
|
delete _extracter;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_paramsParser) {
|
|
|
|
delete _paramsParser;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_fileManager) {
|
|
|
|
delete _fileManager;
|
|
|
|
}
|
2018-08-18 22:36:28 +03:00
|
|
|
}
|
|
|
|
|
2019-09-08 13:37:33 +03:00
|
|
|
bool Deploy::prepare() {
|
2019-09-09 18:12:39 +03:00
|
|
|
if ( !_paramsParser->parseParams()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2019-09-11 13:09:09 +03:00
|
|
|
_extracter = new Extracter(_fileManager, _paramsParser);
|
2019-09-09 18:12:39 +03:00
|
|
|
|
|
|
|
return true;
|
2019-06-19 22:48:19 +03:00
|
|
|
}
|
|
|
|
|
2019-09-08 13:37:33 +03:00
|
|
|
int Deploy::deploy() {
|
2019-09-10 18:22:49 +03:00
|
|
|
|
2019-09-08 13:37:33 +03:00
|
|
|
_fileManager->loadDeployemendFiles(_paramsParser->config()->targetDir);
|
2019-09-16 10:56:22 +03:00
|
|
|
|
|
|
|
switch (DeployCore::getMode() ) {
|
|
|
|
case RunMode::Deploy:
|
|
|
|
_extracter->deploy();
|
|
|
|
break;
|
|
|
|
case RunMode::Clear:
|
|
|
|
_extracter->clear();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2019-09-08 13:37:33 +03:00
|
|
|
_fileManager->saveDeploymendFiles(_paramsParser->config()->targetDir);
|
2019-05-25 19:09:43 +03:00
|
|
|
|
2019-09-08 13:37:33 +03:00
|
|
|
return 0;
|
2019-01-16 22:17:49 +03:00
|
|
|
}
|