Step 644: self-hosting project config

This commit is contained in:
Bill
2026-02-17 21:47:58 -07:00
parent 0ae1ab830a
commit 97acad04aa
4 changed files with 228 additions and 0 deletions

View File

@@ -0,0 +1,53 @@
#pragma once
// Step 644: .whetstone.json for self-hosting editor project
#include <nlohmann/json.hpp>
#include <string>
#include <vector>
using json = nlohmann::json;
struct SelfHostingProjectConfig {
std::string projectName;
std::string workspaceRoot;
std::vector<std::string> sourceRoots;
std::vector<std::string> testTargets;
bool selfHosting = false;
};
class SelfHostingProjectConfigModel {
public:
static json toJson(const SelfHostingProjectConfig& cfg) {
return {
{"projectName", cfg.projectName},
{"workspaceRoot", cfg.workspaceRoot},
{"sourceRoots", cfg.sourceRoots},
{"testTargets", cfg.testTargets},
{"selfHosting", cfg.selfHosting}
};
}
static bool fromJson(const json& j, SelfHostingProjectConfig* out, std::string* error) {
if (!out || !error) return false;
error->clear();
if (!j.is_object()) {
*error = "config_invalid";
return false;
}
out->projectName = j.value("projectName", "");
out->workspaceRoot = j.value("workspaceRoot", "");
out->sourceRoots = j.value("sourceRoots", std::vector<std::string>{});
out->testTargets = j.value("testTargets", std::vector<std::string>{});
out->selfHosting = j.value("selfHosting", false);
if (out->projectName.empty()) {
*error = "project_name_missing";
return false;
}
return true;
}
static bool canSelfHost(const SelfHostingProjectConfig& cfg) {
return cfg.selfHosting && !cfg.workspaceRoot.empty() && !cfg.sourceRoots.empty();
}
};