@cortex-context/cli 0.0.14 → 0.0.15
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/index.js
CHANGED
|
@@ -18309,12 +18309,26 @@ async function deployLocalStack(workspacePath, opts = {}) {
|
|
|
18309
18309
|
if (!(0, import_fs5.existsSync)(templatePath)) {
|
|
18310
18310
|
return { started: false, error: `Template not found: ${templatePath}` };
|
|
18311
18311
|
}
|
|
18312
|
-
|
|
18313
|
-
|
|
18314
|
-
|
|
18312
|
+
(0, import_fs5.cpSync)(templatePath, destPath);
|
|
18313
|
+
const specsSample = (0, import_path5.join)(workspacePath, "specs-sample");
|
|
18314
|
+
const reposSample = (0, import_path5.join)(workspacePath, "repos-sample");
|
|
18315
|
+
(0, import_fs5.mkdirSync)(specsSample, { recursive: true });
|
|
18316
|
+
(0, import_fs5.mkdirSync)(reposSample, { recursive: true });
|
|
18315
18317
|
const envPath = (0, import_path5.join)(workspacePath, ".env");
|
|
18316
|
-
|
|
18317
|
-
|
|
18318
|
+
let existingEnv = "";
|
|
18319
|
+
if ((0, import_fs5.existsSync)(envPath)) {
|
|
18320
|
+
existingEnv = (0, import_fs5.readFileSync)(envPath, "utf-8");
|
|
18321
|
+
}
|
|
18322
|
+
const setEnvVar = (content, key, value) => {
|
|
18323
|
+
const re = new RegExp(`^${key}=.*$`, "m");
|
|
18324
|
+
const line = `${key}=${value}`;
|
|
18325
|
+
return re.test(content) ? content.replace(re, line) : content + (content.endsWith("\n") || !content ? "" : "\n") + line + "\n";
|
|
18326
|
+
};
|
|
18327
|
+
let envContent = existingEnv;
|
|
18328
|
+
envContent = setEnvVar(envContent, "CORTEX_API_TOKEN", opts.token ?? "");
|
|
18329
|
+
envContent = setEnvVar(envContent, "SPECS_DIR_HOST", opts.specsDir ?? "./specs-sample");
|
|
18330
|
+
envContent = setEnvVar(envContent, "REPOS_DIR_HOST", opts.reposDir ?? "./repos-sample");
|
|
18331
|
+
if (!envContent.endsWith("\n")) envContent += "\n";
|
|
18318
18332
|
(0, import_fs5.writeFileSync)(envPath, envContent, { encoding: "utf-8" });
|
|
18319
18333
|
const imageTag = opts.embeddings ? "latest-embeddings" : "latest";
|
|
18320
18334
|
const cortexImage = `ghcr.io/rodrigoroldan/cortex-context:${imageTag}`;
|
|
@@ -18369,7 +18383,7 @@ ${stderr.trim()}` : ""}`
|
|
|
18369
18383
|
};
|
|
18370
18384
|
}
|
|
18371
18385
|
try {
|
|
18372
|
-
(0, import_child_process.execSync)(`${composeCmd} up -d --force-recreate cortex-api`, {
|
|
18386
|
+
(0, import_child_process.execSync)(`${composeCmd} up -d --no-deps --force-recreate cortex-api`, {
|
|
18373
18387
|
cwd: workspacePath,
|
|
18374
18388
|
stdio: ["inherit", "inherit", "pipe"],
|
|
18375
18389
|
env: { ...process.env, CORTEX_IMAGE: cortexImage }
|
|
@@ -18679,7 +18693,7 @@ async function initCommand(options) {
|
|
|
18679
18693
|
const spinner2 = ora(
|
|
18680
18694
|
" Starting Cortex stack with Docker Compose..."
|
|
18681
18695
|
).start();
|
|
18682
|
-
const dockerResult = await deployLocalStack(workspacePath);
|
|
18696
|
+
const dockerResult = await deployLocalStack(workspacePath, { token: cortexToken });
|
|
18683
18697
|
if (!dockerResult.started) {
|
|
18684
18698
|
spinner2.fail(
|
|
18685
18699
|
source_default.red(` \u2717 Docker deploy failed: ${dockerResult.error}`)
|