@sovaria/cli 0.0.0-stage → 0.2.11
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 +42 -2
- package/bin/sov.js +178 -0
- package/package.json +38 -4
- package/wheels/sovaria_cli-0.2.11-py3-none-any.whl +0 -0
- package/wheels/sovaria_sdk-0.4.6-py3-none-any.whl +0 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Sovaria
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,43 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @sovaria/cli
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
`sov`, the Sovaria command-line interface: sign in, link a folder to a project, run SQL and migrations,
|
|
4
|
+
manage documents, storage, functions, auth, realtime, keys and logs, and connect AI assistants over MCP.
|
|
5
|
+
|
|
6
|
+
```bash
|
|
7
|
+
npm install -g @sovaria/cli
|
|
8
|
+
sov --help
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Or run it without installing: `npx @sovaria/cli --help`.
|
|
12
|
+
|
|
13
|
+
**Needs Python 3.11 or newer.** The CLI is written in Python. On first run this package sets up a private
|
|
14
|
+
environment in `~/.sovaria/npm-cli` from the files it ships with (other dependencies come from PyPI) and
|
|
15
|
+
then starts in under a second. It uses [uv](https://docs.astral.sh/uv/) when it is installed. Prefer pip?
|
|
16
|
+
`pip install sovaria-cli` installs the same CLI.
|
|
17
|
+
|
|
18
|
+
## Get started
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
sov auth login # sign in through the browser
|
|
22
|
+
sov link # pick the org and project for this folder
|
|
23
|
+
sov db sql "select now()"
|
|
24
|
+
sov fn deploy ./hello # deploy a function
|
|
25
|
+
sov mcp config --remote --client claude # connect an AI assistant to your project
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Guide: <https://sovaria.in/docs/cli-guide> · Every command: <https://sovaria.in/docs/cli-reference>
|
|
29
|
+
|
|
30
|
+
## Settings
|
|
31
|
+
|
|
32
|
+
| Variable | Use |
|
|
33
|
+
|---|---|
|
|
34
|
+
| `SOVARIA_PYTHON` | The Python to use (3.11+), when it isn't on your `PATH` as `python3` |
|
|
35
|
+
| `SOVARIA_CLI_HOME` | Where to keep the environment (default `~/.sovaria/npm-cli`) |
|
|
36
|
+
| `SOVARIA_CLI_REINSTALL=1` | Set the environment up again |
|
|
37
|
+
| `SOVARIA_CLI_NO_UV=1` | Use Python's `venv` and pip even when uv is installed |
|
|
38
|
+
|
|
39
|
+
On Debian or Ubuntu without uv, Python needs its venv module: `sudo apt install python3-venv`.
|
|
40
|
+
|
|
41
|
+
## License
|
|
42
|
+
|
|
43
|
+
MIT
|
package/bin/sov.js
ADDED
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// The Sovaria CLI (`sov`) from npm. The CLI itself is Python: this launcher keeps it in a private
|
|
3
|
+
// environment under ~/.sovaria/npm-cli (created on first run from the wheels bundled in this package,
|
|
4
|
+
// third-party dependencies from PyPI) and runs it with your arguments, exit code and Ctrl-C.
|
|
5
|
+
//
|
|
6
|
+
// SOVARIA_PYTHON=/path/to/python3.12 use this Python (3.11 or newer)
|
|
7
|
+
// SOVARIA_CLI_HOME=/some/dir keep the environment somewhere else
|
|
8
|
+
// SOVARIA_CLI_REINSTALL=1 set the environment up again
|
|
9
|
+
// SOVARIA_CLI_NO_UV=1 don't use uv even when it is installed
|
|
10
|
+
'use strict';
|
|
11
|
+
|
|
12
|
+
const { spawn, spawnSync } = require('node:child_process');
|
|
13
|
+
const crypto = require('node:crypto');
|
|
14
|
+
const fs = require('node:fs');
|
|
15
|
+
const os = require('node:os');
|
|
16
|
+
const path = require('node:path');
|
|
17
|
+
const { pathToFileURL } = require('node:url');
|
|
18
|
+
|
|
19
|
+
const PKG = require('../package.json');
|
|
20
|
+
const WHEELS = path.join(__dirname, '..', 'wheels');
|
|
21
|
+
const WIN = process.platform === 'win32';
|
|
22
|
+
const HOME = process.env.SOVARIA_CLI_HOME || path.join(os.homedir(), '.sovaria', 'npm-cli');
|
|
23
|
+
|
|
24
|
+
function fail(message) {
|
|
25
|
+
process.stderr.write(`sov: ${message}\n`);
|
|
26
|
+
process.exit(1);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function wheelFiles() {
|
|
30
|
+
let names = [];
|
|
31
|
+
try {
|
|
32
|
+
names = fs.readdirSync(WHEELS).filter((f) => f.endsWith('.whl')).sort();
|
|
33
|
+
} catch {
|
|
34
|
+
// handled below
|
|
35
|
+
}
|
|
36
|
+
if (!names.some((n) => n.startsWith('sovaria_cli-')) || !names.some((n) => n.startsWith('sovaria_sdk-'))) {
|
|
37
|
+
fail('this package is incomplete (its Python wheels are missing). Reinstall it: npm install -g @sovaria/cli');
|
|
38
|
+
}
|
|
39
|
+
return names.map((n) => path.join(WHEELS, n));
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function fingerprint(files) {
|
|
43
|
+
const h = crypto.createHash('sha256');
|
|
44
|
+
for (const f of files) h.update(path.basename(f)).update(fs.readFileSync(f));
|
|
45
|
+
return h.digest('hex').slice(0, 12);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function run(cmd, args, opts = {}) {
|
|
49
|
+
return spawnSync(cmd, args, { encoding: 'utf8', windowsHide: true, ...opts });
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function pythonVersion(cmd, pre) {
|
|
53
|
+
const r = run(cmd, [...pre, '-c', 'import sys; print("%d.%d" % sys.version_info[:2])']);
|
|
54
|
+
if (r.status !== 0 || !r.stdout) return null;
|
|
55
|
+
const [major, minor] = r.stdout.trim().split('.').map(Number);
|
|
56
|
+
return major > 3 || (major === 3 && minor >= 11) ? `${major}.${minor}` : null;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function findPython({ optional = false } = {}) {
|
|
60
|
+
const candidates = [];
|
|
61
|
+
if (process.env.SOVARIA_PYTHON) candidates.push([process.env.SOVARIA_PYTHON, []]);
|
|
62
|
+
if (WIN) candidates.push(['py', ['-3.13']], ['py', ['-3.12']], ['py', ['-3.11']], ['python', []], ['py', ['-3']]);
|
|
63
|
+
else candidates.push(['python3.13', []], ['python3.12', []], ['python3.11', []], ['python3', []], ['python', []]);
|
|
64
|
+
for (const [cmd, pre] of candidates) {
|
|
65
|
+
const version = pythonVersion(cmd, pre);
|
|
66
|
+
if (version) return { cmd, pre, version };
|
|
67
|
+
}
|
|
68
|
+
if (process.env.SOVARIA_PYTHON) fail(`SOVARIA_PYTHON (${process.env.SOVARIA_PYTHON}) isn't Python 3.11 or newer.`);
|
|
69
|
+
if (optional) return null;
|
|
70
|
+
return fail('the Sovaria CLI needs Python 3.11 or newer. Install it from https://www.python.org/downloads/ '
|
|
71
|
+
+ '(or with your package manager), or point SOVARIA_PYTHON at one, then run sov again.');
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function envPython(dir) {
|
|
75
|
+
return WIN ? path.join(dir, 'Scripts', 'python.exe') : path.join(dir, 'bin', 'python');
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function envSov(dir) {
|
|
79
|
+
return WIN ? path.join(dir, 'Scripts', 'sov.exe') : path.join(dir, 'bin', 'sov');
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function hasUv() {
|
|
83
|
+
if (process.env.SOVARIA_CLI_NO_UV) return false;
|
|
84
|
+
return run('uv', ['--version']).status === 0;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function requirements(files) {
|
|
88
|
+
// Direct references, so both pip and uv install exactly these files (with the SDK's MCP extra).
|
|
89
|
+
return files.map((f) => {
|
|
90
|
+
const name = path.basename(f).startsWith('sovaria_sdk-') ? 'sovaria-sdk[mcp]' : 'sovaria-cli';
|
|
91
|
+
return `${name} @ ${pathToFileURL(f).href}`;
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function sleep(ms) {
|
|
96
|
+
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function withLock(lockDir, fn) {
|
|
100
|
+
const deadline = Date.now() + 5 * 60_000;
|
|
101
|
+
for (;;) {
|
|
102
|
+
try {
|
|
103
|
+
fs.mkdirSync(lockDir);
|
|
104
|
+
break;
|
|
105
|
+
} catch (err) {
|
|
106
|
+
if (err.code !== 'EEXIST') throw err;
|
|
107
|
+
let age = 0;
|
|
108
|
+
try { age = Date.now() - fs.statSync(lockDir).mtimeMs; } catch { continue; }
|
|
109
|
+
if (age > 10 * 60_000) { fs.rmSync(lockDir, { recursive: true, force: true }); continue; }
|
|
110
|
+
if (Date.now() > deadline) fail(`another sov is still setting up (${lockDir}). If none is, delete that folder.`);
|
|
111
|
+
sleep(500);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
try { return fn(); } finally { fs.rmSync(lockDir, { recursive: true, force: true }); }
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function install(dir, files) {
|
|
118
|
+
const uv = hasUv();
|
|
119
|
+
// uv can fetch a Python itself when there's no 3.11+ on this machine.
|
|
120
|
+
const py = findPython({ optional: uv });
|
|
121
|
+
process.stderr.write(`Setting up the Sovaria CLI ${PKG.version} (first run, about a minute)…\n`);
|
|
122
|
+
fs.rmSync(dir, { recursive: true, force: true });
|
|
123
|
+
fs.mkdirSync(path.dirname(dir), { recursive: true });
|
|
124
|
+
const reqs = requirements(files);
|
|
125
|
+
let r;
|
|
126
|
+
if (uv) {
|
|
127
|
+
const target = !py ? '3.12' : py.pre.length ? py.version : py.cmd;
|
|
128
|
+
r = run('uv', ['venv', '--quiet', '--python', target, dir], { stdio: ['ignore', 'pipe', 'pipe'] });
|
|
129
|
+
if (r.status === 0) r = run('uv', ['pip', 'install', '--quiet', '--compile-bytecode', '--python', envPython(dir), ...reqs], { stdio: ['ignore', 'pipe', 'pipe'] });
|
|
130
|
+
} else {
|
|
131
|
+
r = run(py.cmd, [...py.pre, '-m', 'venv', dir], { stdio: ['ignore', 'pipe', 'pipe'] });
|
|
132
|
+
if (r.status !== 0) {
|
|
133
|
+
fs.rmSync(dir, { recursive: true, force: true });
|
|
134
|
+
fail('Python couldn\'t create a virtual environment. On Debian or Ubuntu: sudo apt install python3-venv '
|
|
135
|
+
+ '(or install uv: https://docs.astral.sh/uv/), then run sov again.');
|
|
136
|
+
}
|
|
137
|
+
r = run(envPython(dir), ['-m', 'pip', 'install', '--quiet', '--disable-pip-version-check', ...reqs],
|
|
138
|
+
{ stdio: ['ignore', 'pipe', 'pipe'] });
|
|
139
|
+
}
|
|
140
|
+
if (r.status !== 0) {
|
|
141
|
+
fs.rmSync(dir, { recursive: true, force: true });
|
|
142
|
+
const detail = `${r.stderr || ''}${r.stdout || ''}`.trim().split('\n').slice(-12).join('\n');
|
|
143
|
+
fail(`setting up the CLI failed:\n${detail}\nCheck your internet connection (dependencies come from PyPI) and run sov again.`);
|
|
144
|
+
}
|
|
145
|
+
fs.writeFileSync(path.join(dir, '.sovaria-installed'), `${PKG.version}\n`);
|
|
146
|
+
// Environments of older versions of this package are no longer used.
|
|
147
|
+
for (const entry of fs.readdirSync(HOME)) {
|
|
148
|
+
const full = path.join(HOME, entry);
|
|
149
|
+
if (full !== dir && /^\d+\.\d+\.\d+.*-[0-9a-f]{12}$/.test(entry)) fs.rmSync(full, { recursive: true, force: true });
|
|
150
|
+
}
|
|
151
|
+
process.stderr.write('The Sovaria CLI is ready.\n');
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
function main() {
|
|
155
|
+
const files = wheelFiles();
|
|
156
|
+
const dir = path.join(HOME, `${PKG.version}-${fingerprint(files)}`);
|
|
157
|
+
const ready = () => fs.existsSync(path.join(dir, '.sovaria-installed')) && fs.existsSync(envSov(dir));
|
|
158
|
+
if (process.env.SOVARIA_CLI_REINSTALL || !ready()) {
|
|
159
|
+
fs.mkdirSync(HOME, { recursive: true });
|
|
160
|
+
withLock(`${dir}.lock`, () => {
|
|
161
|
+
if (process.env.SOVARIA_CLI_REINSTALL || !ready()) install(dir, files);
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
const child = spawn(envSov(dir), process.argv.slice(2), { stdio: 'inherit', windowsHide: false });
|
|
165
|
+
// Ctrl-C reaches the CLI itself (same terminal); this launcher just waits for it.
|
|
166
|
+
for (const sig of ['SIGINT', 'SIGTERM', 'SIGHUP']) process.on(sig, () => { try { child.kill(sig); } catch { /* gone */ } });
|
|
167
|
+
child.on('error', (err) => fail(`couldn't start the CLI (${err.message}). Run with SOVARIA_CLI_REINSTALL=1 to set it up again.`));
|
|
168
|
+
child.on('exit', (code, signal) => {
|
|
169
|
+
if (signal) {
|
|
170
|
+
process.removeAllListeners(signal);
|
|
171
|
+
process.kill(process.pid, signal);
|
|
172
|
+
} else {
|
|
173
|
+
process.exit(code ?? 1);
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
main();
|
package/package.json
CHANGED
|
@@ -1,6 +1,40 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sovaria/cli",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.2.11",
|
|
4
|
+
"description": "The Sovaria command-line interface (sov): log in, link a project, run SQL and migrations, deploy functions, manage auth, storage, realtime and more. Needs Python 3.11+.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"sovaria",
|
|
7
|
+
"cli",
|
|
8
|
+
"sov",
|
|
9
|
+
"baas",
|
|
10
|
+
"backend",
|
|
11
|
+
"database",
|
|
12
|
+
"postgres",
|
|
13
|
+
"functions",
|
|
14
|
+
"mcp"
|
|
15
|
+
],
|
|
16
|
+
"homepage": "https://sovaria.in/docs/cli-guide",
|
|
17
|
+
"bugs": {
|
|
18
|
+
"url": "https://sovaria.in/contact"
|
|
19
|
+
},
|
|
20
|
+
"license": "MIT",
|
|
21
|
+
"author": "Sovaria (https://sovaria.in)",
|
|
22
|
+
"bin": {
|
|
23
|
+
"sov": "bin/sov.js"
|
|
24
|
+
},
|
|
25
|
+
"files": [
|
|
26
|
+
"bin/sov.js",
|
|
27
|
+
"wheels/*.whl",
|
|
28
|
+
"README.md",
|
|
29
|
+
"LICENSE"
|
|
30
|
+
],
|
|
31
|
+
"engines": {
|
|
32
|
+
"node": ">=18"
|
|
33
|
+
},
|
|
34
|
+
"scripts": {
|
|
35
|
+
"prepublishOnly": "node bin/check-package.js"
|
|
36
|
+
},
|
|
37
|
+
"publishConfig": {
|
|
38
|
+
"access": "public"
|
|
39
|
+
}
|
|
40
|
+
}
|
|
Binary file
|
|
Binary file
|