freellmapikey 1.0.0 → 1.0.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/bin/{cli.mjs → cli.js} +12 -11
- package/package.json +2 -2
package/bin/{cli.mjs → cli.js}
RENAMED
|
@@ -7,19 +7,20 @@
|
|
|
7
7
|
* npx freellmapikey start → start server (must be set up first)
|
|
8
8
|
* npx freellmapikey update → git pull + rebuild
|
|
9
9
|
*/
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
'use strict';
|
|
11
|
+
const { execSync, spawn } = require('child_process');
|
|
12
|
+
const { existsSync } = require('fs');
|
|
13
|
+
const { join } = require('path');
|
|
14
|
+
const { homedir } = require('os');
|
|
14
15
|
|
|
15
16
|
const INSTALL_DIR = join(homedir(), '.freellmapikey');
|
|
16
17
|
const REPO_URL = 'https://github.com/nalepy/freellmapikey.git';
|
|
17
18
|
const SERVER_DIST = join(INSTALL_DIR, 'server', 'dist', 'index.js');
|
|
18
19
|
|
|
19
|
-
const cmd = process.argv[2]
|
|
20
|
+
const cmd = process.argv[2] || 'auto';
|
|
20
21
|
|
|
21
|
-
function run(command, opts
|
|
22
|
-
execSync(command, { stdio: 'inherit',
|
|
22
|
+
function run(command, opts) {
|
|
23
|
+
execSync(command, Object.assign({ stdio: 'inherit' }, opts));
|
|
23
24
|
}
|
|
24
25
|
|
|
25
26
|
function isSetUp() {
|
|
@@ -45,10 +46,10 @@ function start() {
|
|
|
45
46
|
const child = spawn(process.execPath, [SERVER_DIST], {
|
|
46
47
|
cwd: INSTALL_DIR,
|
|
47
48
|
stdio: 'inherit',
|
|
48
|
-
env: {
|
|
49
|
+
env: Object.assign({}, process.env),
|
|
49
50
|
});
|
|
50
|
-
child.on('exit', (code)
|
|
51
|
-
process.on('SIGINT', ()
|
|
51
|
+
child.on('exit', function(code) { process.exit(code || 0); });
|
|
52
|
+
process.on('SIGINT', function() { child.kill('SIGINT'); });
|
|
52
53
|
}
|
|
53
54
|
|
|
54
55
|
if (cmd === 'setup') {
|
|
@@ -56,7 +57,7 @@ if (cmd === 'setup') {
|
|
|
56
57
|
} else if (cmd === 'start') {
|
|
57
58
|
start();
|
|
58
59
|
} else if (cmd === 'update') {
|
|
59
|
-
run(
|
|
60
|
+
run('git -C "' + INSTALL_DIR + '" pull');
|
|
60
61
|
run('npm install', { cwd: INSTALL_DIR });
|
|
61
62
|
run('npm run build', { cwd: INSTALL_DIR });
|
|
62
63
|
console.log('\n✅ Updated!\n');
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "freellmapikey",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "One OpenAI-compatible endpoint. 18 free-tier providers. ~1.3B tokens/month.",
|
|
5
5
|
"private": false,
|
|
6
6
|
"bin": {
|
|
7
|
-
"freellmapikey": "./bin/cli.
|
|
7
|
+
"freellmapikey": "./bin/cli.js"
|
|
8
8
|
},
|
|
9
9
|
"files": [
|
|
10
10
|
"bin/",
|