@episoda/cli 0.2.160 → 0.2.161
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.
|
@@ -2909,7 +2909,7 @@ var require_package = __commonJS({
|
|
|
2909
2909
|
"package.json"(exports2, module2) {
|
|
2910
2910
|
module2.exports = {
|
|
2911
2911
|
name: "@episoda/cli",
|
|
2912
|
-
version: "0.2.
|
|
2912
|
+
version: "0.2.161",
|
|
2913
2913
|
description: "CLI tool for Episoda local development workflow orchestration",
|
|
2914
2914
|
main: "dist/index.js",
|
|
2915
2915
|
types: "dist/index.d.ts",
|
|
@@ -11514,45 +11514,6 @@ function getPreviewManager() {
|
|
|
11514
11514
|
var import_core13 = __toESM(require_dist());
|
|
11515
11515
|
|
|
11516
11516
|
// src/api/worktree-api.ts
|
|
11517
|
-
async function updateWorktree(config, request2) {
|
|
11518
|
-
const machineUuid = config.machine_uuid || config.device_id;
|
|
11519
|
-
if (!machineUuid || !config.access_token) {
|
|
11520
|
-
console.debug("[WorktreeAPI] updateWorktree: no machineUuid or access_token");
|
|
11521
|
-
return false;
|
|
11522
|
-
}
|
|
11523
|
-
const serverUrl = config.api_url || "https://episoda.dev";
|
|
11524
|
-
const url = `${serverUrl}/api/dev/worktrees`;
|
|
11525
|
-
try {
|
|
11526
|
-
const response = await fetch(url, {
|
|
11527
|
-
method: "POST",
|
|
11528
|
-
headers: {
|
|
11529
|
-
"Authorization": `Bearer ${config.access_token}`,
|
|
11530
|
-
"Content-Type": "application/json"
|
|
11531
|
-
},
|
|
11532
|
-
body: JSON.stringify({
|
|
11533
|
-
module_id: request2.moduleId,
|
|
11534
|
-
// EP1143: For cloud containers, use container_id; for local, use machine_id
|
|
11535
|
-
local_machine_id: process.env.EPISODA_MODE === "cloud" ? void 0 : machineUuid,
|
|
11536
|
-
cloud_container_id: process.env.EPISODA_MODE === "cloud" ? process.env.EPISODA_CONTAINER_ID : void 0,
|
|
11537
|
-
worktree_path: request2.worktreePath,
|
|
11538
|
-
branch_name: request2.branchName,
|
|
11539
|
-
status: request2.status,
|
|
11540
|
-
port: request2.port,
|
|
11541
|
-
preview_url: request2.previewUrl,
|
|
11542
|
-
error: request2.error
|
|
11543
|
-
})
|
|
11544
|
-
});
|
|
11545
|
-
if (!response.ok) {
|
|
11546
|
-
const text = await response.text();
|
|
11547
|
-
console.debug(`[WorktreeAPI] updateWorktree failed: ${response.status} ${text}`);
|
|
11548
|
-
return false;
|
|
11549
|
-
}
|
|
11550
|
-
return true;
|
|
11551
|
-
} catch (error) {
|
|
11552
|
-
console.debug(`[WorktreeAPI] updateWorktree network error:`, error);
|
|
11553
|
-
return false;
|
|
11554
|
-
}
|
|
11555
|
-
}
|
|
11556
11517
|
async function deleteWorktree(config, moduleUid) {
|
|
11557
11518
|
const machineUuid = config.machine_uuid || config.device_id;
|
|
11558
11519
|
if (!machineUuid || !config.access_token) {
|
|
@@ -11843,7 +11804,7 @@ async function handleWorktreeCreate(request2) {
|
|
|
11843
11804
|
console.log(`[Worktree] K1273: Clone successful`);
|
|
11844
11805
|
await execAsync2(`git -C "${bareRepoPath}" config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"`, { env: gitEnv });
|
|
11845
11806
|
const configPath = path23.join(episodaDir, "config.json");
|
|
11846
|
-
const
|
|
11807
|
+
const config = {
|
|
11847
11808
|
projectId,
|
|
11848
11809
|
workspaceSlug,
|
|
11849
11810
|
projectSlug,
|
|
@@ -11851,7 +11812,7 @@ async function handleWorktreeCreate(request2) {
|
|
|
11851
11812
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
11852
11813
|
worktrees: []
|
|
11853
11814
|
};
|
|
11854
|
-
fs22.writeFileSync(configPath, JSON.stringify(
|
|
11815
|
+
fs22.writeFileSync(configPath, JSON.stringify(config, null, 2), "utf-8");
|
|
11855
11816
|
console.log(`[Worktree] K1273: Project initialized at ${projectPath}`);
|
|
11856
11817
|
} catch (cloneError) {
|
|
11857
11818
|
console.error(`[Worktree] K1273: Git clone failed: ${cloneError.message}`);
|
|
@@ -11882,18 +11843,8 @@ async function handleWorktreeCreate(request2) {
|
|
|
11882
11843
|
const worktreePath = result.worktreePath;
|
|
11883
11844
|
console.log(`[Worktree] EP1373: worktree_add phase=worktree_add durationMs=${Date.now() - worktreeAddStartMs} moduleUid=${moduleUid} correlationId=${correlationId || "none"}`);
|
|
11884
11845
|
console.log(`[Worktree] EP1143: Worktree created at ${worktreePath}`);
|
|
11885
|
-
const config = await getConfigForApi();
|
|
11886
11846
|
let finalStatus = "ready";
|
|
11887
11847
|
let finalError;
|
|
11888
|
-
if (config?.access_token) {
|
|
11889
|
-
await updateWorktree(config, {
|
|
11890
|
-
moduleId,
|
|
11891
|
-
worktreePath,
|
|
11892
|
-
branchName,
|
|
11893
|
-
status: "pending"
|
|
11894
|
-
}).catch(() => {
|
|
11895
|
-
});
|
|
11896
|
-
}
|
|
11897
11848
|
if (envVars && Object.keys(envVars).length > 0) {
|
|
11898
11849
|
const envContent = Object.entries(envVars).map(([key, value]) => `${key}=${value}`).join("\n");
|
|
11899
11850
|
const envPath = path23.join(worktreePath, ".env");
|
|
@@ -11914,15 +11865,6 @@ ${buildCmd}` : buildCmd;
|
|
|
11914
11865
|
if (effectiveSetupScript) {
|
|
11915
11866
|
const setupStartMs = Date.now();
|
|
11916
11867
|
await manager.updateWorktreeStatus(moduleUid, "setup");
|
|
11917
|
-
if (config?.access_token) {
|
|
11918
|
-
await updateWorktree(config, {
|
|
11919
|
-
moduleId,
|
|
11920
|
-
worktreePath,
|
|
11921
|
-
branchName,
|
|
11922
|
-
status: "setup"
|
|
11923
|
-
}).catch(() => {
|
|
11924
|
-
});
|
|
11925
|
-
}
|
|
11926
11868
|
console.log(`[Worktree] EP1143: Running setup script...`);
|
|
11927
11869
|
const scriptResult = await manager.runSetupScript(moduleUid, effectiveSetupScript);
|
|
11928
11870
|
console.log(`[Worktree] EP1373: setup_script phase=worktree_setup durationMs=${Date.now() - setupStartMs} moduleUid=${moduleUid} correlationId=${correlationId || "none"} success=${scriptResult.success}`);
|
|
@@ -11965,33 +11907,15 @@ ${buildCmd}` : buildCmd;
|
|
|
11965
11907
|
} else if (finalStatus === "ready" && isCloud) {
|
|
11966
11908
|
console.log(`[Worktree] EP1262: Skipping preview start in cloud mode (server orchestrates)`);
|
|
11967
11909
|
}
|
|
11968
|
-
if (config?.access_token) {
|
|
11969
|
-
try {
|
|
11970
|
-
const updated = await updateWorktree(config, {
|
|
11971
|
-
moduleId,
|
|
11972
|
-
worktreePath,
|
|
11973
|
-
branchName,
|
|
11974
|
-
status: finalStatus,
|
|
11975
|
-
port,
|
|
11976
|
-
previewUrl,
|
|
11977
|
-
error: finalError
|
|
11978
|
-
});
|
|
11979
|
-
if (updated) {
|
|
11980
|
-
console.log(`[Worktree] EP1143: Updated worktrees table with status '${finalStatus}'`);
|
|
11981
|
-
} else {
|
|
11982
|
-
console.warn(`[Worktree] EP1143: Failed to update worktrees table`);
|
|
11983
|
-
}
|
|
11984
|
-
} catch (apiError) {
|
|
11985
|
-
console.error(`[Worktree] EP1143: Failed to update worktrees table: ${apiError.message}`);
|
|
11986
|
-
}
|
|
11987
|
-
}
|
|
11988
11910
|
console.log(`[Worktree] EP1373: worktree_create_total phase=worktree_create_total durationMs=${Date.now() - worktreeStartMs} moduleUid=${moduleUid} correlationId=${correlationId || "none"} status=${finalStatus}`);
|
|
11989
11911
|
console.log(`[Worktree] EP1143: Worktree ready for ${moduleUid}`);
|
|
11990
11912
|
return {
|
|
11991
11913
|
success: true,
|
|
11992
11914
|
worktreePath,
|
|
11993
11915
|
previewUrl,
|
|
11994
|
-
port
|
|
11916
|
+
port,
|
|
11917
|
+
status: finalStatus,
|
|
11918
|
+
error: finalError
|
|
11995
11919
|
};
|
|
11996
11920
|
} catch (error) {
|
|
11997
11921
|
console.error(`[Worktree] EP1143: Create failed: ${error.message}`);
|