4
1
mirror of https://github.com/QuasarApp/CQtDeployer.git synced 2025-04-28 18:54:33 +00:00

109 lines
2.0 KiB
C++
Raw Normal View History

2018-08-19 11:00:13 +03:00
/*
2019-12-08 13:57:20 +03:00
* Copyright (C) 2018-2020 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"
2020-01-04 16:39:25 +03:00
#include "packing.h"
#include "pluginsparser.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-11-13 18:18:44 +03:00
_scaner = new DependenciesScanner();
2020-01-04 16:39:25 +03:00
_packing = new Packing();
_pluginParser = new PluginsParser();
_paramsParser = new ConfigParser(_fileManager, _pluginParser, _scaner, _packing);
2019-11-13 18:18:44 +03:00
2019-09-09 18:12:39 +03:00
}
2020-01-20 16:40:18 +03:00
int Deploy::run() {
2020-04-25 16:59:20 +03:00
2020-01-20 16:40:18 +03:00
if (!prepare()) {
return PrepareError;
}
2020-04-25 16:59:20 +03:00
_fileManager->loadDeployemendFiles(_paramsParser->config()->getTargetDir());
2020-01-20 16:40:18 +03:00
if (!deploy()) {
return DeployError;
2020-01-04 16:39:25 +03:00
}
2020-04-25 16:59:20 +03:00
if (!packing()) {
_fileManager->saveDeploymendFiles(_paramsParser->config()->getTargetDir());
2020-01-20 16:40:18 +03:00
return PackingError;
2020-04-25 16:59:20 +03:00
}
_fileManager->saveDeploymendFiles(_paramsParser->config()->getTargetDir());
2020-01-20 16:40:18 +03:00
return Good;
2019-09-09 18:12:39 +03:00
}
Deploy::~Deploy() {
if (_extracter) {
delete _extracter;
}
if (_paramsParser) {
delete _paramsParser;
}
if (_fileManager) {
delete _fileManager;
}
2019-11-13 18:18:44 +03:00
if (_scaner) {
delete _scaner;
}
2020-01-20 16:05:23 +03:00
if (_packing) {
delete _packing;
}
2020-01-28 14:48:53 +03:00
if (_pluginParser) {
delete _pluginParser;
}
2020-01-28 14:48:53 +03:00
DeployCore::_config = nullptr;
2018-08-18 22:36:28 +03:00
}
2019-09-08 13:37:33 +03:00
bool Deploy::prepare() {
2020-01-04 16:39:25 +03:00
2019-09-09 18:12:39 +03:00
if ( !_paramsParser->parseParams()) {
return false;
}
_extracter = new Extracter(_fileManager, _pluginParser, _paramsParser, _scaner);
2019-09-09 18:12:39 +03:00
return true;
2019-06-19 22:48:19 +03:00
}
2020-01-04 16:39:25 +03:00
bool Deploy::deploy() {
2019-09-10 18:22:49 +03:00
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-05-25 19:09:43 +03:00
2020-01-04 16:39:25 +03:00
return true;
}
2020-01-20 16:40:18 +03:00
bool Deploy::packing() {
2020-01-20 15:43:00 +03:00
2020-01-20 16:40:18 +03:00
return _packing->create();
2019-01-16 22:17:49 +03:00
}