freellm 1.0.14 → 1.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/README.md +9 -0
- package/dist/cli.js +72 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -76,6 +76,15 @@ npx freellm --port 8080 # custom port (default: 3000)
|
|
|
76
76
|
npx freellm --no-open # don't open browser automatically
|
|
77
77
|
```
|
|
78
78
|
|
|
79
|
+
## Updating
|
|
80
|
+
|
|
81
|
+
When installed globally, `freellm` runs the app and checks/self-updates:
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
freellm # start the app
|
|
85
|
+
freellm update # update to the latest version on npm
|
|
86
|
+
```
|
|
87
|
+
|
|
79
88
|
## Data storage
|
|
80
89
|
|
|
81
90
|
All data (database + encryption key) is stored in `~/.freellm/`.
|
package/dist/cli.js
CHANGED
|
@@ -1,10 +1,80 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
const index_1 = require("./index");
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
const child_process_1 = require("child_process");
|
|
9
|
+
const fs_1 = require("fs");
|
|
4
10
|
const args = process.argv.slice(2);
|
|
5
|
-
|
|
6
|
-
|
|
11
|
+
function getCurrentVersion() {
|
|
12
|
+
try {
|
|
13
|
+
const pkg = JSON.parse((0, fs_1.readFileSync)(path_1.default.join(__dirname, '..', 'package.json'), 'utf8'));
|
|
14
|
+
return pkg.version;
|
|
15
|
+
}
|
|
16
|
+
catch {
|
|
17
|
+
return '0.0.0';
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
async function getLatestVersion() {
|
|
21
|
+
try {
|
|
22
|
+
const res = await fetch('https://registry.npmjs.org/freellm/latest', {
|
|
23
|
+
signal: AbortSignal.timeout(10000),
|
|
24
|
+
});
|
|
25
|
+
if (!res.ok)
|
|
26
|
+
return null;
|
|
27
|
+
const data = (await res.json());
|
|
28
|
+
return data.version;
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
function compareVersions(a, b) {
|
|
35
|
+
const pa = a.split('.').map(Number);
|
|
36
|
+
const pb = b.split('.').map(Number);
|
|
37
|
+
for (let i = 0; i < Math.max(pa.length, pb.length); i++) {
|
|
38
|
+
const x = pa[i] ?? 0;
|
|
39
|
+
const y = pb[i] ?? 0;
|
|
40
|
+
if (x > y)
|
|
41
|
+
return 1;
|
|
42
|
+
if (x < y)
|
|
43
|
+
return -1;
|
|
44
|
+
}
|
|
45
|
+
return 0;
|
|
46
|
+
}
|
|
47
|
+
async function update() {
|
|
48
|
+
console.log('');
|
|
49
|
+
console.log(' FreeLLM — checking for updates...');
|
|
50
|
+
const current = getCurrentVersion();
|
|
51
|
+
const latest = await getLatestVersion();
|
|
52
|
+
if (!latest) {
|
|
53
|
+
console.log(' Could not reach the npm registry. Check your connection and try again.');
|
|
54
|
+
process.exit(1);
|
|
55
|
+
}
|
|
56
|
+
if (compareVersions(current, latest) >= 0) {
|
|
57
|
+
console.log(` You're already on the latest version (${current}).`);
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
console.log(` Updating ${current} → ${latest}...`);
|
|
61
|
+
const result = (0, child_process_1.spawnSync)('npm', ['install', '-g', `freellm@${latest}`], {
|
|
62
|
+
stdio: 'inherit',
|
|
63
|
+
shell: process.platform === 'win32',
|
|
64
|
+
});
|
|
65
|
+
if (result.status !== 0) {
|
|
66
|
+
console.error(` Update failed. Try running: npm install -g freellm@${latest}`);
|
|
67
|
+
process.exit(1);
|
|
68
|
+
}
|
|
69
|
+
console.log(` Updated to FreeLLM ${latest}. Run "freellm" to start.`);
|
|
70
|
+
}
|
|
7
71
|
async function main() {
|
|
72
|
+
if (args[0] === 'update' || args[0] === 'upgrade') {
|
|
73
|
+
await update();
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
const port = args.includes('--port') ? Number(args[args.indexOf('--port') + 1]) : Number(process.env.PORT ?? 3000);
|
|
77
|
+
const noOpen = args.includes('--no-open');
|
|
8
78
|
console.log('');
|
|
9
79
|
console.log(' UniLLM — Universal LLM Proxy');
|
|
10
80
|
console.log(' One OpenAI-compatible endpoint for 15+ free providers');
|