2023-08-30 20:54:59 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <filesystem>
|
|
|
|
#include <string>
|
|
|
|
#include <fstream>
|
|
|
|
#include <list>
|
2023-08-31 20:06:02 +00:00
|
|
|
#include <map>
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
#include <nlohmann/json.hpp>
|
2023-09-03 00:53:36 +00:00
|
|
|
#include <curl/curl.h>
|
2023-08-31 20:06:02 +00:00
|
|
|
|
|
|
|
#include "dependency.h"
|
2023-09-01 21:39:24 +00:00
|
|
|
#include "loggger.h"
|
2023-08-30 20:54:59 +00:00
|
|
|
|
|
|
|
class Project {
|
|
|
|
public:
|
2023-09-01 21:39:24 +00:00
|
|
|
enum class State {
|
2023-08-30 20:54:59 +00:00
|
|
|
unknown,
|
|
|
|
read,
|
2023-09-01 21:39:24 +00:00
|
|
|
discovering,
|
2023-08-30 20:54:59 +00:00
|
|
|
error
|
|
|
|
};
|
|
|
|
|
2023-09-01 21:39:24 +00:00
|
|
|
Project(const std::filesystem::path& location, const std::filesystem::path& destination);
|
|
|
|
~Project();
|
|
|
|
|
2023-08-30 20:54:59 +00:00
|
|
|
bool read();
|
2023-09-01 21:39:24 +00:00
|
|
|
void discover();
|
|
|
|
State getStatus() const;
|
2023-08-30 20:54:59 +00:00
|
|
|
std::string getName() const;
|
2023-08-31 20:06:02 +00:00
|
|
|
uint32_t dependenciesCount() const;
|
2023-08-30 20:54:59 +00:00
|
|
|
|
2023-09-01 21:39:24 +00:00
|
|
|
static void log(Logger::Severity severity, const std::string& message);
|
|
|
|
static void debug(const std::string& message);
|
|
|
|
static void info(const std::string& message);
|
2023-09-03 00:53:36 +00:00
|
|
|
static void minor(const std::string& message);
|
|
|
|
static void major(const std::string& message);
|
2023-09-01 21:39:24 +00:00
|
|
|
static void warn(const std::string& message);
|
|
|
|
static void error(const std::string& message);
|
|
|
|
static void fatal(const std::string& message);
|
|
|
|
static void printLog();
|
|
|
|
|
2023-08-30 20:54:59 +00:00
|
|
|
private:
|
2023-08-31 20:06:02 +00:00
|
|
|
void parse(const nlohmann::json& json);
|
|
|
|
void createDepencencyFromString(const std::string& entry);
|
|
|
|
void createDepencencyFromObject(const nlohmann::json& entry);
|
2023-08-30 20:54:59 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
std::filesystem::path location;
|
2023-09-01 21:39:24 +00:00
|
|
|
std::filesystem::path destination;
|
|
|
|
State state;
|
2023-08-30 20:54:59 +00:00
|
|
|
std::string name;
|
2023-08-31 20:06:02 +00:00
|
|
|
std::map<std::string, Dependency> dependencies;
|
2023-09-01 21:39:24 +00:00
|
|
|
const bool root;
|
|
|
|
|
|
|
|
static Logger* logger;
|
2023-08-30 20:54:59 +00:00
|
|
|
|
|
|
|
};
|