kodingo-cli 1.0.8 → 1.0.9
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.
package/dist/commands/init.js
CHANGED
|
@@ -38,10 +38,26 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
38
38
|
return result;
|
|
39
39
|
};
|
|
40
40
|
})();
|
|
41
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
42
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
43
|
+
};
|
|
41
44
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
45
|
exports.registerInitCommand = registerInitCommand;
|
|
43
46
|
const readline = __importStar(require("node:readline"));
|
|
44
47
|
const persistence_config_1 = require("../utils/persistence-config");
|
|
48
|
+
const path_1 = __importDefault(require("path"));
|
|
49
|
+
const fs_1 = __importDefault(require("fs"));
|
|
50
|
+
function findRepoRoot(startPath) {
|
|
51
|
+
let current = startPath;
|
|
52
|
+
while (true) {
|
|
53
|
+
if (fs_1.default.existsSync(path_1.default.join(current, ".git")))
|
|
54
|
+
return current;
|
|
55
|
+
const parent = path_1.default.dirname(current);
|
|
56
|
+
if (parent === current)
|
|
57
|
+
return startPath;
|
|
58
|
+
current = parent;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
45
61
|
// ── Prompt helper ─────────────────────────────────────────────────────────────
|
|
46
62
|
function prompt(rl, question) {
|
|
47
63
|
return new Promise((resolve) => rl.question(question, (ans) => resolve(ans.trim())));
|
|
@@ -119,6 +135,9 @@ function registerInitCommand(program) {
|
|
|
119
135
|
await verifyCloudConnection(apiUrl, token);
|
|
120
136
|
const config = { mode: "cloud", apiUrl, token };
|
|
121
137
|
(0, persistence_config_1.writeConfig)(config);
|
|
138
|
+
// Also save workspace-specific config scoped to this repo
|
|
139
|
+
const repoRoot = findRepoRoot(process.cwd());
|
|
140
|
+
(0, persistence_config_1.writeWorkspaceConfig)(repoRoot, { mode: "cloud", apiUrl, token });
|
|
122
141
|
console.log(`\n✔ Cloud mode configured successfully.`);
|
|
123
142
|
console.log(` API URL : ${apiUrl}`);
|
|
124
143
|
console.log(` Config : ${persistence_config_1.CONFIG_PATH}`);
|
|
@@ -6,6 +6,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.CONFIG_PATH = void 0;
|
|
7
7
|
exports.readConfig = readConfig;
|
|
8
8
|
exports.writeConfig = writeConfig;
|
|
9
|
+
exports.writeWorkspaceConfig = writeWorkspaceConfig;
|
|
10
|
+
exports.readWorkspaceConfig = readWorkspaceConfig;
|
|
9
11
|
exports.isCloudMode = isCloudMode;
|
|
10
12
|
exports.getPersistence = getPersistence;
|
|
11
13
|
/**
|
|
@@ -46,6 +48,16 @@ function writeConfig(config) {
|
|
|
46
48
|
}
|
|
47
49
|
node_fs_1.default.writeFileSync(exports.CONFIG_PATH, JSON.stringify(config, null, 2), "utf-8");
|
|
48
50
|
}
|
|
51
|
+
function writeWorkspaceConfig(repoPath, wsConfig) {
|
|
52
|
+
const existing = readConfig();
|
|
53
|
+
const workspaces = existing.workspaces ?? {};
|
|
54
|
+
workspaces[repoPath] = wsConfig;
|
|
55
|
+
writeConfig({ ...existing, workspaces });
|
|
56
|
+
}
|
|
57
|
+
function readWorkspaceConfig(repoPath) {
|
|
58
|
+
const config = readConfig();
|
|
59
|
+
return config.workspaces?.[repoPath] ?? null;
|
|
60
|
+
}
|
|
49
61
|
function isCloudMode() {
|
|
50
62
|
return readConfig().mode === "cloud";
|
|
51
63
|
}
|