kodingo-cli 1.0.20 → 1.0.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -27,13 +27,18 @@ const node_fs_1 = __importDefault(require("node:fs"));
|
|
|
27
27
|
const node_path_1 = __importDefault(require("node:path"));
|
|
28
28
|
const node_os_1 = __importDefault(require("node:os"));
|
|
29
29
|
exports.CONFIG_PATH = node_path_1.default.join(node_os_1.default.homedir(), ".kodingo", "config.json");
|
|
30
|
+
function normalizePath(p) {
|
|
31
|
+
return p.replace(/\\/g, '/').toLowerCase();
|
|
32
|
+
}
|
|
30
33
|
function readConfig() {
|
|
31
34
|
if (!node_fs_1.default.existsSync(exports.CONFIG_PATH)) {
|
|
32
|
-
return { mode: "
|
|
35
|
+
return { mode: "cloud", apiUrl: "https://kodingo-api.onrender.com" };
|
|
33
36
|
}
|
|
34
37
|
try {
|
|
35
38
|
const raw = node_fs_1.default.readFileSync(exports.CONFIG_PATH, "utf-8");
|
|
36
39
|
const parsed = JSON.parse(raw);
|
|
40
|
+
if (!parsed.mode)
|
|
41
|
+
parsed.mode = "cloud";
|
|
37
42
|
return parsed;
|
|
38
43
|
}
|
|
39
44
|
catch {
|
|
@@ -70,11 +75,14 @@ function getPersistence() {
|
|
|
70
75
|
if (config.mode === "cloud") {
|
|
71
76
|
if (!config.apiUrl)
|
|
72
77
|
throw new Error("Cloud mode requires apiUrl in ~/.kodingo/config.json");
|
|
73
|
-
|
|
74
|
-
|
|
78
|
+
// Try workspace-scoped token first, fall back to global token
|
|
79
|
+
const wsConfig = readWorkspaceConfig(normalizePath(process.cwd()));
|
|
80
|
+
const token = wsConfig?.token ?? config.token ?? "";
|
|
81
|
+
if (!token)
|
|
82
|
+
throw new Error("No project token found. Run `kodingo init` in your project directory first.");
|
|
75
83
|
// Inject into env so cloud-persistence picks them up
|
|
76
|
-
process.env.KODINGO_API_URL = config.apiUrl;
|
|
77
|
-
process.env.KODINGO_API_TOKEN =
|
|
84
|
+
process.env.KODINGO_API_URL = wsConfig?.apiUrl ?? config.apiUrl;
|
|
85
|
+
process.env.KODINGO_API_TOKEN = token;
|
|
78
86
|
return require("../adapters/cloud-adapter/cloud-persistence");
|
|
79
87
|
}
|
|
80
88
|
return require("../adapters/db-adapter/memory-persistence");
|