@aloth/olcli 0.1.0
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/LICENSE +21 -0
- package/README.md +226 -0
- package/dist/cli.d.ts +9 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +873 -0
- package/dist/cli.js.map +1 -0
- package/dist/client.d.ts +163 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +572 -0
- package/dist/client.js.map +1 -0
- package/dist/config.d.ts +16 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +70 -0
- package/dist/config.js.map +1 -0
- package/package.json +59 -0
package/dist/config.js
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration management for olcli
|
|
3
|
+
*/
|
|
4
|
+
import Conf from 'conf';
|
|
5
|
+
import { existsSync, readFileSync, writeFileSync } from 'node:fs';
|
|
6
|
+
import { join } from 'node:path';
|
|
7
|
+
const config = new Conf({
|
|
8
|
+
projectName: 'olcli',
|
|
9
|
+
schema: {
|
|
10
|
+
sessionCookie: { type: 'string' },
|
|
11
|
+
csrf: { type: 'string' },
|
|
12
|
+
lastProject: { type: 'string' }
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
export function getSessionCookie() {
|
|
16
|
+
// Check environment variable first
|
|
17
|
+
if (process.env.OVERLEAF_SESSION) {
|
|
18
|
+
return process.env.OVERLEAF_SESSION;
|
|
19
|
+
}
|
|
20
|
+
// Check .olauth file in current directory
|
|
21
|
+
const olAuthPath = join(process.cwd(), '.olauth');
|
|
22
|
+
if (existsSync(olAuthPath)) {
|
|
23
|
+
try {
|
|
24
|
+
const content = readFileSync(olAuthPath, 'utf-8').trim();
|
|
25
|
+
// Parse cookie from olauth file (format: key=value or just value)
|
|
26
|
+
if (content.includes('=')) {
|
|
27
|
+
const cookies = content.split(';').map(c => c.trim());
|
|
28
|
+
const sessionCookie = cookies.find(c => c.startsWith('overleaf_session2='));
|
|
29
|
+
if (sessionCookie) {
|
|
30
|
+
return sessionCookie.split('=')[1];
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return content;
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
// Ignore errors
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
// Check global config
|
|
40
|
+
return config.get('sessionCookie');
|
|
41
|
+
}
|
|
42
|
+
export function setSessionCookie(cookie) {
|
|
43
|
+
config.set('sessionCookie', cookie);
|
|
44
|
+
}
|
|
45
|
+
export function getCsrf() {
|
|
46
|
+
return config.get('csrf');
|
|
47
|
+
}
|
|
48
|
+
export function setCsrf(csrf) {
|
|
49
|
+
config.set('csrf', csrf);
|
|
50
|
+
}
|
|
51
|
+
export function getLastProject() {
|
|
52
|
+
return config.get('lastProject');
|
|
53
|
+
}
|
|
54
|
+
export function setLastProject(projectId) {
|
|
55
|
+
config.set('lastProject', projectId);
|
|
56
|
+
}
|
|
57
|
+
export function clearConfig() {
|
|
58
|
+
config.clear();
|
|
59
|
+
}
|
|
60
|
+
export function getConfigPath() {
|
|
61
|
+
return config.path;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Save session cookie in .olauth format for compatibility
|
|
65
|
+
*/
|
|
66
|
+
export function saveOlAuth(cookie, path) {
|
|
67
|
+
const authPath = path || join(process.cwd(), '.olauth');
|
|
68
|
+
writeFileSync(authPath, `overleaf_session2=${cookie}`, 'utf-8');
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAClE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AASjC,MAAM,MAAM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MAAM,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;AACrC,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,MAAc;IAC7C,MAAM,CAAC,GAAG,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC;AACtC,CAAC;AAED,MAAM,UAAU,OAAO;IACrB,OAAO,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;AAC5B,CAAC;AAED,MAAM,UAAU,OAAO,CAAC,IAAY;IAClC,MAAM,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;AAC3B,CAAC;AAED,MAAM,UAAU,cAAc;IAC5B,OAAO,MAAM,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;AACnC,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,SAAiB;IAC9C,MAAM,CAAC,GAAG,CAAC,aAAa,EAAE,SAAS,CAAC,CAAC;AACvC,CAAC;AAED,MAAM,UAAU,WAAW;IACzB,MAAM,CAAC,KAAK,EAAE,CAAC;AACjB,CAAC;AAED,MAAM,UAAU,aAAa;IAC3B,OAAO,MAAM,CAAC,IAAI,CAAC;AACrB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,MAAc,EAAE,IAAa;IACtD,MAAM,QAAQ,GAAG,IAAI,IAAI,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,SAAS,CAAC,CAAC;IACxD,aAAa,CAAC,QAAQ,EAAE,qBAAqB,MAAM,EAAE,EAAE,OAAO,CAAC,CAAC;AAClE,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@aloth/olcli",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Overleaf CLI - sync and manage LaTeX projects from the command line",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"olcli": "./dist/cli.js"
|
|
8
|
+
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"build": "tsc",
|
|
11
|
+
"dev": "tsx src/cli.ts",
|
|
12
|
+
"lint": "eslint src/",
|
|
13
|
+
"prepare": "npm run build"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"overleaf",
|
|
17
|
+
"latex",
|
|
18
|
+
"cli",
|
|
19
|
+
"sync",
|
|
20
|
+
"tex",
|
|
21
|
+
"pdf",
|
|
22
|
+
"academic",
|
|
23
|
+
"writing"
|
|
24
|
+
],
|
|
25
|
+
"author": "Alexander Loth <alex@alexloth.com> (https://alexloth.com)",
|
|
26
|
+
"license": "MIT",
|
|
27
|
+
"repository": {
|
|
28
|
+
"type": "git",
|
|
29
|
+
"url": "git+https://github.com/aloth/olcli.git"
|
|
30
|
+
},
|
|
31
|
+
"bugs": {
|
|
32
|
+
"url": "https://github.com/aloth/olcli/issues"
|
|
33
|
+
},
|
|
34
|
+
"homepage": "https://github.com/aloth/olcli#readme",
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"adm-zip": "^0.5.16",
|
|
37
|
+
"chalk": "^5.3.0",
|
|
38
|
+
"cheerio": "^1.0.0",
|
|
39
|
+
"commander": "^12.1.0",
|
|
40
|
+
"conf": "^13.0.0",
|
|
41
|
+
"ora": "^8.0.1",
|
|
42
|
+
"tough-cookie": "^4.1.4"
|
|
43
|
+
},
|
|
44
|
+
"devDependencies": {
|
|
45
|
+
"@types/adm-zip": "^0.5.7",
|
|
46
|
+
"@types/node": "^22.0.0",
|
|
47
|
+
"@types/tough-cookie": "^4.0.5",
|
|
48
|
+
"tsx": "^4.7.0",
|
|
49
|
+
"typescript": "^5.4.0"
|
|
50
|
+
},
|
|
51
|
+
"engines": {
|
|
52
|
+
"node": ">=18"
|
|
53
|
+
},
|
|
54
|
+
"files": [
|
|
55
|
+
"dist",
|
|
56
|
+
"README.md",
|
|
57
|
+
"LICENSE"
|
|
58
|
+
]
|
|
59
|
+
}
|