summaryrefslogtreecommitdiff
path: root/src/cli/overleafApi.ts
diff options
context:
space:
mode:
authorYurenHao0426 <blackhao0426@gmail.com>2026-09-13 04:24:07 +0000
committerYurenHao0426 <blackhao0426@gmail.com>2026-09-13 04:24:07 +0000
commita55e313de44444d22ef928b1bb91fd96284ea367 (patch)
tree7273cbee484effff4878fa81a8a3313e14695aba /src/cli/overleafApi.ts
parent55bf3f24c57521907a1bac7180aa29ea8cbf83d7 (diff)
Add copy command to clone Overleaf projects server-sidefix-cli-shebang
Adds `lattex-cli copy <source-id|name> <new-name>` which uses Overleaf's POST /project/{id}/clone endpoint to create a server-side copy of a project. Includes API method, CLI wiring, help text, and tests. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Diffstat (limited to 'src/cli/overleafApi.ts')
-rw-r--r--src/cli/overleafApi.ts11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/cli/overleafApi.ts b/src/cli/overleafApi.ts
index 6301638..94bdac2 100644
--- a/src/cli/overleafApi.ts
+++ b/src/cli/overleafApi.ts
@@ -348,6 +348,17 @@ export class OverleafApi {
}
}
+ /** Clone (copy) a project on Overleaf, returning the new project ID */
+ async copyProject(sourceProjectId: string, newName: string): Promise<string> {
+ const result = await this.requestWithCsrf('POST', `/project/${sourceProjectId}/clone`, {
+ projectName: newName
+ })
+ if (!result.ok || !(result.data as any)?.project_id) {
+ throw new Error(`Copy project failed: HTTP ${result.status}`)
+ }
+ return (result.data as any).project_id
+ }
+
/** Flush project (ensure OT changes are saved to database) */
async flushProject(projectId: string): Promise<void> {
await this.requestWithCsrf('POST', `/project/${projectId}/flush`)