chore(paths): refactor data directory structure and update references
- Updated paths for instance data, workflows, and logs to use a unified `data/` directory. - Adjusted related documentation in AGENTS.md and README.md to reflect the new data structure. - Refactored path handling in server files to ensure consistency and clarity in data management. - Enhanced test scripts to align with the new directory structure for improved organization.
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
import { SERVER_ROOT } from "./paths.js";
|
||||
import { REPO_ROOT } from "./paths.js";
|
||||
|
||||
const ROOT_PKG = path.resolve(SERVER_ROOT, "../../package.json");
|
||||
const ROOT_PKG = path.join(REPO_ROOT, "package.json");
|
||||
|
||||
/**
|
||||
* JerapahFlow app version from the monorepo root package.json.
|
||||
|
||||
@@ -13,8 +13,8 @@
|
||||
"start:control": "node control.js",
|
||||
"start:web": "node web-server.js",
|
||||
"migrate": "node -e \"import('./db.js').then((m) => m.migrate().then(() => process.exit(0)))\"",
|
||||
"test:plugins": "JFLOW_PLUGINS_DIR=./data/plugins-smoke-test JFLOW_DB_PATH=./data/plugins-smoke.db node test/plugins-smoke.js",
|
||||
"test:workflow-history": "JFLOW_WORKFLOWS_DIR=./data/workflow-history-smoke JFLOW_DB_PATH=./data/workflow-history-smoke.db node test/workflow-history-smoke.js",
|
||||
"test:plugins": "JFLOW_DATA_DIR=./data JFLOW_PLUGINS_DIR=./data/plugins-smoke-test JFLOW_DB_PATH=./data/plugins-smoke.db node test/plugins-smoke.js",
|
||||
"test:workflow-history": "JFLOW_DATA_DIR=./data JFLOW_WORKFLOWS_DIR=./data/workflow-history-smoke JFLOW_DB_PATH=./data/workflow-history-smoke.db node test/workflow-history-smoke.js",
|
||||
"reset-admin": "node reset-admin.js",
|
||||
"test:profiles": "node test/profiles-smoke.js",
|
||||
"test:set-dry-run": "node test/set-dry-run-smoke.js",
|
||||
|
||||
+39
-15
@@ -1,25 +1,49 @@
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
import { fileURLToPath } from "url";
|
||||
|
||||
export const SERVER_ROOT = path.dirname(fileURLToPath(import.meta.url));
|
||||
export const REPO_ROOT = path.resolve(SERVER_ROOT, "../..");
|
||||
export const SCRIPTS_DIR = path.join(SERVER_ROOT, "scripts");
|
||||
export const DATA_DIR = path.join(SERVER_ROOT, "data");
|
||||
|
||||
/** Prefer `preferred` unless only `legacy` already has files. */
|
||||
function existingDir(preferred, legacy, probe) {
|
||||
const has = (dir) =>
|
||||
probe ? probe(dir) : fs.existsSync(dir);
|
||||
if (has(preferred) || !has(legacy)) return preferred;
|
||||
return legacy;
|
||||
}
|
||||
|
||||
function hasInstanceData(dir) {
|
||||
return (
|
||||
fs.existsSync(path.join(dir, "jerapah-flow.db")) ||
|
||||
fs.existsSync(path.join(dir, "workflows"))
|
||||
);
|
||||
}
|
||||
|
||||
/** Instance data (SQLite, live workflows, control-state). Not product source. */
|
||||
export const DATA_DIR = path.resolve(
|
||||
process.env.JFLOW_DATA_DIR ??
|
||||
existingDir(
|
||||
path.join(REPO_ROOT, "data"),
|
||||
path.join(SERVER_ROOT, "data"),
|
||||
hasInstanceData,
|
||||
),
|
||||
);
|
||||
/** Live instance workflows (not shipped in git). Override for tests. */
|
||||
export const WORKFLOWS_DIR =
|
||||
process.env.JFLOW_WORKFLOWS_DIR ?? path.join(DATA_DIR, "workflows");
|
||||
export const WORKFLOWS_DIR = path.resolve(
|
||||
process.env.JFLOW_WORKFLOWS_DIR ?? path.join(DATA_DIR, "workflows"),
|
||||
);
|
||||
/** User plugins (repo-root /plugins, outside the pnpm workspace). */
|
||||
export const PLUGINS_DIR =
|
||||
process.env.JFLOW_PLUGINS_DIR ??
|
||||
path.resolve(SERVER_ROOT, "../../plugins");
|
||||
export const PLUGINS_DIR = path.resolve(
|
||||
process.env.JFLOW_PLUGINS_DIR ?? path.join(REPO_ROOT, "plugins"),
|
||||
);
|
||||
/** Example plugin sources shipped with the repo. */
|
||||
export const EXAMPLE_PLUGINS_DIR = path.resolve(
|
||||
SERVER_ROOT,
|
||||
"../../examples/plugins",
|
||||
);
|
||||
export const EXAMPLE_PLUGINS_DIR = path.join(REPO_ROOT, "examples/plugins");
|
||||
/** Example workflow YAML presets (not loaded by the runner). */
|
||||
export const EXAMPLE_WORKFLOWS_DIR = path.resolve(
|
||||
SERVER_ROOT,
|
||||
"../../examples/workflows",
|
||||
export const EXAMPLE_WORKFLOWS_DIR = path.join(REPO_ROOT, "examples/workflows");
|
||||
export const LOGS_DIR = path.resolve(
|
||||
process.env.JFLOW_LOGS_DIR ??
|
||||
existingDir(path.join(REPO_ROOT, "logs"), path.join(SERVER_ROOT, "logs")),
|
||||
);
|
||||
export const LOGS_DIR = path.join(SERVER_ROOT, "logs");
|
||||
export const WEB_DIST = path.resolve(SERVER_ROOT, "../web/dist");
|
||||
export const WEB_DIST = path.join(REPO_ROOT, "packages/web/dist");
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
import path from "path";
|
||||
import pm2 from "pm2";
|
||||
import { SERVER_ROOT } from "./paths.js";
|
||||
|
||||
const REPO_ROOT = path.resolve(SERVER_ROOT, "../..");
|
||||
import { REPO_ROOT, SERVER_ROOT } from "./paths.js";
|
||||
|
||||
export const PM2_HTTP_NAME = "jflow-http";
|
||||
export const PM2_WORKER_NAME = "jflow-worker";
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
* Smoke: core vs plugin scripts, fork, example install, resolve, run.
|
||||
*
|
||||
* Run:
|
||||
* JFLOW_DATA_DIR=packages/server/data \
|
||||
* JFLOW_PLUGINS_DIR=packages/server/data/plugins-smoke-test \
|
||||
* JFLOW_DB_PATH=packages/server/data/plugins-smoke.db \
|
||||
* node packages/server/test/plugins-smoke.js
|
||||
|
||||
Reference in New Issue
Block a user