Déplacement de la configuration des outils
This commit is contained in:
@@ -69,7 +69,7 @@ async function main() {
|
|||||||
|
|
||||||
const config = loadWeatherConfig();
|
const config = loadWeatherConfig();
|
||||||
if (!hasConfiguredProvider(config)) {
|
if (!hasConfiguredProvider(config)) {
|
||||||
console.error("No weather provider configured. Update tools/config.json (weather.providers) before running this script.");
|
console.error("No weather provider configured. Update tools/config/config.json (weather.providers) before running this script.");
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
const files = await resolveMarkdownTargets(pathArgs, { rootDir: CONTENT_ROOT });
|
const files = await resolveMarkdownTargets(pathArgs, { rootDir: CONTENT_ROOT });
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ const execFileAsync = util.promisify(execFile);
|
|||||||
|
|
||||||
const SITE_ROOT = path.resolve(__dirname, "..");
|
const SITE_ROOT = path.resolve(__dirname, "..");
|
||||||
const CONTENT_DIR = path.join(SITE_ROOT, "content");
|
const CONTENT_DIR = path.join(SITE_ROOT, "content");
|
||||||
const CONFIG_PATH = path.join(__dirname, "config.json");
|
const CONFIG_PATH = path.join(__dirname, "config", "config.json");
|
||||||
const DAY_MS = 24 * 60 * 60 * 1000;
|
const DAY_MS = 24 * 60 * 60 * 1000;
|
||||||
|
|
||||||
const DEFAULT_CONFIG = {
|
const DEFAULT_CONFIG = {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ const { loadEnv } = require("./lib/env");
|
|||||||
|
|
||||||
loadEnv();
|
loadEnv();
|
||||||
|
|
||||||
const DEFAULT_CONFIG_PATH = "tools/stats.json";
|
const DEFAULT_CONFIG_PATH = "tools/config/stats.json";
|
||||||
const DEFAULT_DATA_OUTPUT = "content/stats/data/stats.json";
|
const DEFAULT_DATA_OUTPUT = "content/stats/data/stats.json";
|
||||||
const DEFAULT_IMAGE_DIR = "content/stats/images";
|
const DEFAULT_IMAGE_DIR = "content/stats/images";
|
||||||
|
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ function applyEnvOverrides(config = {}) {
|
|||||||
return merged;
|
return merged;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function loadToolsConfig(configPath = "tools/config.json") {
|
async function loadToolsConfig(configPath = "tools/config/config.json") {
|
||||||
const resolved = path.resolve(configPath);
|
const resolved = path.resolve(configPath);
|
||||||
if (cached && cached.path === resolved) {
|
if (cached && cached.path === resolved) {
|
||||||
return cached.data;
|
return cached.data;
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ const DEFAULT_WEATHER_CONFIG = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
function loadWeatherConfig(configPath = path.resolve(__dirname, "..", "..", "config.json")) {
|
function loadWeatherConfig(configPath = path.resolve(__dirname, "..", "..", "config", "config.json")) {
|
||||||
loadEnv();
|
loadEnv();
|
||||||
|
|
||||||
let raw = {};
|
let raw = {};
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ async function run({ stat }) {
|
|||||||
const toolsConfig = await loadToolsConfig();
|
const toolsConfig = await loadToolsConfig();
|
||||||
const url = stat.url || toolsConfig.goaccess?.url;
|
const url = stat.url || toolsConfig.goaccess?.url;
|
||||||
if (!url) {
|
if (!url) {
|
||||||
throw new Error("URL GoAccess manquante (GOACCESS_URL ou goaccess.url dans tools/config.json)");
|
throw new Error("URL GoAccess manquante (GOACCESS_URL ou goaccess.url dans tools/config/config.json)");
|
||||||
}
|
}
|
||||||
const metric = stat.metric || "hits";
|
const metric = stat.metric || "hits";
|
||||||
const windowDays = Number.isFinite(stat.days) ? stat.days : 30;
|
const windowDays = Number.isFinite(stat.days) ? stat.days : 30;
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ def load_env(env_path=None):
|
|||||||
|
|
||||||
|
|
||||||
def load_config():
|
def load_config():
|
||||||
cfg_path = os.path.join(ROOT_DIR, "tools", "config.json")
|
cfg_path = os.path.join(ROOT_DIR, "tools", "config", "config.json")
|
||||||
try:
|
try:
|
||||||
with open(cfg_path, "r", encoding="utf-8") as handle:
|
with open(cfg_path, "r", encoding="utf-8") as handle:
|
||||||
return json.load(handle)
|
return json.load(handle)
|
||||||
@@ -87,7 +87,7 @@ def main():
|
|||||||
goaccess_url = url or os.environ.get("GOACCESS_URL") or (cfg.get("goaccess") or {}).get("url")
|
goaccess_url = url or os.environ.get("GOACCESS_URL") or (cfg.get("goaccess") or {}).get("url")
|
||||||
|
|
||||||
if not goaccess_url:
|
if not goaccess_url:
|
||||||
print("Missing GoAccess URL (set GOACCESS_URL or goaccess.url in tools/config.json)", file=sys.stderr)
|
print("Missing GoAccess URL (set GOACCESS_URL or goaccess.url in tools/config/config.json)", file=sys.stderr)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|||||||
Reference in New Issue
Block a user