leafrelay 0.1.7 → 0.2.1
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/README.md +3 -1
- package/README.zh-CN.md +3 -1
- package/dist/{chunk-MNOPLM7M.js → chunk-Q3R5N4YE.js} +201 -133
- package/dist/chunk-Q3R5N4YE.js.map +1 -0
- package/dist/chunk-UO7Z3BQN.js +5157 -0
- package/dist/chunk-UO7Z3BQN.js.map +1 -0
- package/dist/cli.js +21 -36
- package/dist/cli.js.map +1 -1
- package/dist/daemon.js +959 -0
- package/dist/daemon.js.map +1 -0
- package/dist/index.d.ts +11 -722
- package/dist/index.js +3 -69
- package/package.json +6 -3
- package/dist/chunk-MNOPLM7M.js.map +0 -1
- package/dist/cli.d.ts +0 -1
package/dist/cli.js
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
|
-
|
|
3
|
+
connectCliDaemon,
|
|
4
|
+
daemonRestart,
|
|
5
|
+
daemonStatus,
|
|
6
|
+
daemonStop,
|
|
7
|
+
serve
|
|
8
|
+
} from "./chunk-UO7Z3BQN.js";
|
|
9
|
+
import {
|
|
4
10
|
configPath,
|
|
5
|
-
normalizeServerUrl
|
|
6
|
-
|
|
7
|
-
startServe
|
|
8
|
-
} from "./chunk-MNOPLM7M.js";
|
|
11
|
+
normalizeServerUrl
|
|
12
|
+
} from "./chunk-Q3R5N4YE.js";
|
|
9
13
|
|
|
10
14
|
// src/cli.ts
|
|
11
15
|
import { Command } from "commander";
|
|
@@ -14,7 +18,6 @@ import { Command } from "commander";
|
|
|
14
18
|
import { input, password, select } from "@inquirer/prompts";
|
|
15
19
|
async function login(server, options) {
|
|
16
20
|
const url = normalizeServerUrl(server);
|
|
17
|
-
const api = new BaseAPI(url);
|
|
18
21
|
const environmentCookie = process.env.LEAFRELAY_COOKIE;
|
|
19
22
|
let cookie = options.cookie ?? environmentCookie;
|
|
20
23
|
let email = options.email;
|
|
@@ -34,42 +37,24 @@ async function login(server, options) {
|
|
|
34
37
|
secret = await password({ message: "Password" });
|
|
35
38
|
}
|
|
36
39
|
}
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
40
|
+
const client = await connectCliDaemon();
|
|
41
|
+
try {
|
|
42
|
+
const user = await client.login(cookie ? { server: url, cookie } : { server: url, email: email ?? "", password: secret ?? await password({ message: "Password" }) });
|
|
43
|
+
console.log(`Logged in to ${url} as ${user.userEmail || email || user.userId}.`);
|
|
44
|
+
console.log(`Session saved to ${configPath()}.`);
|
|
45
|
+
} finally {
|
|
46
|
+
client.close();
|
|
40
47
|
}
|
|
41
|
-
await saveServerSession({
|
|
42
|
-
url,
|
|
43
|
-
userId: response.userInfo.userId,
|
|
44
|
-
userEmail: response.userInfo.userEmail || email || "",
|
|
45
|
-
identity: response.identity,
|
|
46
|
-
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
47
|
-
});
|
|
48
|
-
console.log(`Logged in to ${url} as ${response.userInfo.userEmail || email || response.userInfo.userId}.`);
|
|
49
|
-
console.log(`Session saved to ${configPath()}.`);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
// src/serve.ts
|
|
53
|
-
async function serve(directory = process.cwd()) {
|
|
54
|
-
const running = await startServe(directory);
|
|
55
|
-
await new Promise((resolveStop) => {
|
|
56
|
-
const stop = () => {
|
|
57
|
-
process.off("SIGINT", stop);
|
|
58
|
-
process.off("SIGTERM", stop);
|
|
59
|
-
running.stop().then(resolveStop, (error) => {
|
|
60
|
-
console.error(error);
|
|
61
|
-
resolveStop();
|
|
62
|
-
});
|
|
63
|
-
};
|
|
64
|
-
process.on("SIGINT", stop);
|
|
65
|
-
process.on("SIGTERM", stop);
|
|
66
|
-
});
|
|
67
48
|
}
|
|
68
49
|
|
|
69
50
|
// src/cli.ts
|
|
70
|
-
var program = new Command().name("leafrelay").description("Keep a local directory synchronized with an Overleaf project.").version("0.1
|
|
51
|
+
var program = new Command().name("leafrelay").description("Keep a local directory synchronized with an Overleaf project.").version("0.2.1");
|
|
71
52
|
program.command("login").description("Authenticate to Overleaf and save the session in ~/.leafrelay/config.json.").argument("[server]", "Overleaf server URL", "https://www.overleaf.com/").option("--cookie <cookie>", "Overleaf browser cookie").option("--email <email>", "Overleaf account email").option("--password <password>", "Overleaf account password").action(login);
|
|
72
53
|
program.command("serve").description("Synchronize the current directory with its configured Overleaf project.").argument("[directory]", "Local replica directory", process.cwd()).action(serve);
|
|
54
|
+
var daemon = program.command("daemon").description("Inspect or control the shared LeafRelay daemon.");
|
|
55
|
+
daemon.command("status").description("Show daemon clients and replicas.").action(daemonStatus);
|
|
56
|
+
daemon.command("stop").description("Stop the daemon and its active replicas.").action(daemonStop);
|
|
57
|
+
daemon.command("restart").description("Restart the daemon.").action(daemonRestart);
|
|
73
58
|
program.parseAsync().catch((error) => {
|
|
74
59
|
console.error(error instanceof Error ? error.message : String(error));
|
|
75
60
|
process.exitCode = 1;
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/cli.ts","../src/login.ts"
|
|
1
|
+
{"version":3,"sources":["../src/cli.ts","../src/login.ts"],"sourcesContent":["#!/usr/bin/env node\nimport {Command} from 'commander';\nimport {login} from './login';\nimport {daemonRestart, daemonStatus, daemonStop, serve} from './serve';\n\ndeclare const LEAFRELAY_VERSION: string;\n\nconst program = new Command()\n .name('leafrelay')\n .description('Keep a local directory synchronized with an Overleaf project.')\n .version(LEAFRELAY_VERSION);\n\nprogram.command('login')\n .description('Authenticate to Overleaf and save the session in ~/.leafrelay/config.json.')\n .argument('[server]', 'Overleaf server URL', 'https://www.overleaf.com/')\n .option('--cookie <cookie>', 'Overleaf browser cookie')\n .option('--email <email>', 'Overleaf account email')\n .option('--password <password>', 'Overleaf account password')\n .action(login);\n\nprogram.command('serve')\n .description('Synchronize the current directory with its configured Overleaf project.')\n .argument('[directory]', 'Local replica directory', process.cwd())\n .action(serve);\n\nconst daemon = program.command('daemon')\n .description('Inspect or control the shared LeafRelay daemon.');\n\ndaemon.command('status').description('Show daemon clients and replicas.').action(daemonStatus);\ndaemon.command('stop').description('Stop the daemon and its active replicas.').action(daemonStop);\ndaemon.command('restart').description('Restart the daemon.').action(daemonRestart);\n\nprogram.parseAsync().catch(error => {\n console.error(error instanceof Error ? error.message : String(error));\n process.exitCode = 1;\n});\n","import {input, password, select} from '@inquirer/prompts';\nimport {configPath, normalizeServerUrl} from '@leafrelay/core';\nimport {connectCliDaemon} from './daemonClient';\n\nexport interface LoginOptions {\n cookie?: string;\n email?: string;\n password?: string;\n}\n\nexport async function login(server: string, options: LoginOptions): Promise<void> {\n const url = normalizeServerUrl(server);\n const environmentCookie = process.env.LEAFRELAY_COOKIE;\n let cookie = options.cookie ?? environmentCookie;\n let email = options.email;\n let secret = options.password;\n\n if (!cookie && !email) {\n const method = await select({\n message:`Log in to ${url}`,\n choices:[\n {name:'Browser cookie', value:'cookie'},\n {name:'Email and password', value:'password'},\n ],\n });\n if (method==='cookie') {\n cookie = await password({message:'Cookie'});\n } else {\n email = await input({message:'Email'});\n secret = await password({message:'Password'});\n }\n }\n\n const client = await connectCliDaemon();\n try {\n const user = await client.login(cookie\n ? {server:url, cookie}\n : {server:url, email:email ?? '', password:secret ?? await password({message:'Password'})});\n console.log(`Logged in to ${url} as ${user.userEmail || email || user.userId}.`);\n console.log(`Session saved to ${configPath()}.`);\n } finally {\n client.close();\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AACA,SAAQ,eAAc;;;ACDtB,SAAQ,OAAO,UAAU,cAAa;AAUtC,eAAsB,MAAM,QAAgB,SAAsC;AAC9E,QAAM,MAAM,mBAAmB,MAAM;AACrC,QAAM,oBAAoB,QAAQ,IAAI;AACtC,MAAI,SAAS,QAAQ,UAAU;AAC/B,MAAI,QAAQ,QAAQ;AACpB,MAAI,SAAS,QAAQ;AAErB,MAAI,CAAC,UAAU,CAAC,OAAO;AACnB,UAAM,SA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