koigrid 0.1.0 → 0.3.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/CHANGELOG.md +32 -0
- package/dist/commands/apps.js +46 -7
- package/dist/commands/db.js +51 -0
- package/dist/commands/jobs.js +25 -5
- package/dist/manifest.js +4 -4
- package/package.json +3 -2
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to the koigrid CLI are documented here. Format: [Keep a Changelog](https://keepachangelog.com). Versions follow [SemVer](https://semver.org).
|
|
4
|
+
|
|
5
|
+
## [0.3.0] — 2026-07-05
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
- **HTTP cron jobs**: `koigrid jobs create <name> --schedule "…" --url <url> [--method POST] [--header "K: V"]`.
|
|
9
|
+
koigrid hits the URL on schedule — most crons just call an endpoint with a secret, so no container needed.
|
|
10
|
+
Headers are stored encrypted (put your `CRON_SECRET` there). The EventBridge → HTTP-target equivalent.
|
|
11
|
+
|
|
12
|
+
## [0.2.0] — 2026-07-04
|
|
13
|
+
|
|
14
|
+
### Added
|
|
15
|
+
- **`koigrid apps deploy <name> --dir <path>`** — deploy from a **local directory**, no git or Docker required.
|
|
16
|
+
The directory is packaged (excluding `node_modules`, `.git`, `.next`, `dist`, …) and uploaded straight to
|
|
17
|
+
koigrid via a presigned URL, then built on the runner (Dockerfile or nixpacks). Ideal for migrating a private
|
|
18
|
+
app: point at the folder and ship.
|
|
19
|
+
- **`koigrid apps deploy <name> --repo <url> --repo-token <token>`** — deploy a **private git repo** by passing
|
|
20
|
+
a token/deploy-key, without installing the GitHub App in a browser (works for agents/CI). The token is stored
|
|
21
|
+
encrypted at rest and redacted from build logs.
|
|
22
|
+
|
|
23
|
+
### Notes
|
|
24
|
+
- Both close the #1 adoption blocker found while dogfooding a real app (VicoHR) onto koigrid: a private codebase
|
|
25
|
+
could not be deployed without wiring GitHub OAuth or having Docker locally.
|
|
26
|
+
|
|
27
|
+
## [0.1.0] — 2026-07-03
|
|
28
|
+
|
|
29
|
+
### Added
|
|
30
|
+
- Initial release. Commands: `login`, `logout`, `whoami`, `usage`, `apps`, `db`, `redis`, `storage` (buckets),
|
|
31
|
+
`jobs`, `events`, `alarms`, `email`. Designed for AI agents: `--json` on every command, `koigrid help --json`
|
|
32
|
+
to introspect the full command tree, auth via `--token` / `KOIGRID_TOKEN`.
|
package/dist/commands/apps.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { execFileSync } from 'node:child_process';
|
|
1
2
|
import { api } from '../api.js';
|
|
2
3
|
import { output, green } from '../output.js';
|
|
3
4
|
export async function apps(a) {
|
|
@@ -14,10 +15,27 @@ export async function apps(a) {
|
|
|
14
15
|
}
|
|
15
16
|
case 'deploy': {
|
|
16
17
|
const name = a.positionals[0], image = a.flags.image, repo = a.flags.repo;
|
|
17
|
-
|
|
18
|
-
|
|
18
|
+
const dir = a.flags.dir; // deploy desde un directorio LOCAL (código privado, sin git/Docker)
|
|
19
|
+
const repoToken = a.flags['repo-token']; // token/deploy-key para repos privados
|
|
20
|
+
if (!name || (!image && !repo && !dir))
|
|
21
|
+
throw new Error('usage: koigrid apps deploy <name> --dir <path>|--image <img>|--repo <git-url> [--repo-token <t>] [--port N]');
|
|
19
22
|
const port = a.flags.port ? Number(a.flags.port) : 3000;
|
|
20
|
-
|
|
23
|
+
// deploy --dir: empaqueta el directorio (excluye lo pesado/irrelevante) → subida presignada a koigrid →
|
|
24
|
+
// el runner lo construye igual que un repo. No requiere git ni Docker local.
|
|
25
|
+
if (dir) {
|
|
26
|
+
const app = await api('/apps', { method: 'POST', body: { name, port } });
|
|
27
|
+
const aid = app.app?.id || app.id;
|
|
28
|
+
const up = await api(`/apps/${encodeURIComponent(aid)}/source-upload`, { method: 'POST', body: {} });
|
|
29
|
+
const { uploadUrl, archiveKey } = up.upload;
|
|
30
|
+
const excludes = ['node_modules', '.git', '.next', 'dist', 'build', '.vercel', '.turbo', 'coverage', '.DS_Store'];
|
|
31
|
+
const tar = execFileSync('tar', ['-czf', '-', ...excludes.map((e) => `--exclude=${e}`), '-C', dir, '.'], { maxBuffer: 1024 * 1024 * 1024 });
|
|
32
|
+
const put = await fetch(uploadUrl, { method: 'PUT', headers: { 'content-type': 'application/gzip' }, body: tar });
|
|
33
|
+
if (!put.ok)
|
|
34
|
+
throw new Error(`source upload failed (HTTP ${put.status})`);
|
|
35
|
+
await api(`/apps/${encodeURIComponent(aid)}/deployments`, { method: 'POST', body: { sourceType: 'archive', archiveKey } });
|
|
36
|
+
return json ? console.log(JSON.stringify({ id: aid, status: 'queued', source: 'dir' }, null, 2)) : console.log(green(`✓ Deploying "${name}" from ${dir}…`));
|
|
37
|
+
}
|
|
38
|
+
const app = await api('/apps', { method: 'POST', body: repo ? { name, sourceType: 'git', repo, port, ...(repoToken ? { repoToken } : {}) } : { name, sourceType: 'image', image, port } });
|
|
21
39
|
const aid = app.app?.id || app.id;
|
|
22
40
|
await api(`/apps/${encodeURIComponent(aid)}/deployments`, { method: 'POST', body: {} });
|
|
23
41
|
return json ? console.log(JSON.stringify({ id: aid, status: 'queued' }, null, 2)) : console.log(green(`✓ Deploying "${name}"…`));
|
|
@@ -95,19 +113,26 @@ export async function apps(a) {
|
|
|
95
113
|
throw new Error('usage: koigrid apps env <id> set KEY=VAL | rm KEY | ls');
|
|
96
114
|
}
|
|
97
115
|
case 'domains': {
|
|
98
|
-
need(' add <domain> | rm <domain> | ls');
|
|
116
|
+
need(' add <domain> | rm <domain> | ls | verify');
|
|
99
117
|
const act = a.positionals[1];
|
|
118
|
+
const cols = ['domain', 'status', 'record'];
|
|
119
|
+
const rowsOf = (l) => l.map((x) => (typeof x === 'string' ? { domain: x, status: '', record: '' } : { domain: x.domain, status: x.status ?? '', record: x.record ? `${x.record.type} ${x.record.name} → ${x.record.value}` : '' }));
|
|
100
120
|
if (!act || act === 'ls') {
|
|
101
121
|
const r = await api(`/apps/${encodeURIComponent(id)}/domains`);
|
|
102
122
|
const l = r.domains || r || [];
|
|
103
|
-
return output(l, json, { rows: l
|
|
123
|
+
return output(l, json, { rows: rowsOf(l), columns: cols });
|
|
124
|
+
}
|
|
125
|
+
if (act === 'verify') {
|
|
126
|
+
const r = await api(`/apps/${encodeURIComponent(id)}/domains?verify=1`);
|
|
127
|
+
const l = r.domains || r || [];
|
|
128
|
+
return output(l, json, { rows: rowsOf(l), columns: cols });
|
|
104
129
|
}
|
|
105
130
|
if (act === 'add') {
|
|
106
131
|
const d = a.positionals[2];
|
|
107
132
|
if (!d)
|
|
108
133
|
throw new Error('need <domain>');
|
|
109
134
|
const r = await api(`/apps/${encodeURIComponent(id)}/domains`, { method: 'POST', body: { domain: d } });
|
|
110
|
-
return console.log(json ? JSON.stringify(r, null, 2) : green(`✓ Added ${d} —
|
|
135
|
+
return console.log(json ? JSON.stringify(r, null, 2) : green(`✓ Added ${d} — create DNS: ${r.instructions}`));
|
|
111
136
|
}
|
|
112
137
|
if (act === 'rm') {
|
|
113
138
|
const d = a.positionals[2];
|
|
@@ -116,7 +141,7 @@ export async function apps(a) {
|
|
|
116
141
|
await api(`/apps/${encodeURIComponent(id)}/domains?domain=${encodeURIComponent(d)}`, { method: 'DELETE' });
|
|
117
142
|
return console.log(green(`✓ Removed ${d}`));
|
|
118
143
|
}
|
|
119
|
-
throw new Error('usage: koigrid apps domains <id> add <domain> | rm <domain> | ls');
|
|
144
|
+
throw new Error('usage: koigrid apps domains <id> add <domain> | rm <domain> | ls | verify');
|
|
120
145
|
}
|
|
121
146
|
case 'volumes': {
|
|
122
147
|
need(' add <name> --size N --mount /path | rm <volId> | ls');
|
|
@@ -167,6 +192,20 @@ export async function apps(a) {
|
|
|
167
192
|
const r = await api(`/apps/${encodeURIComponent(id)}/github`, { method: 'PUT', body });
|
|
168
193
|
return console.log(json ? JSON.stringify(r, null, 2) : green(`✓ Connected ${repo}`));
|
|
169
194
|
}
|
|
195
|
+
case 'resize': {
|
|
196
|
+
need(' [--memory <mb>] [--cpus <n>]');
|
|
197
|
+
if (a.flags.memory === undefined && a.flags.cpus === undefined) {
|
|
198
|
+
const r = await api(`/apps/${encodeURIComponent(id)}/resources`);
|
|
199
|
+
return console.log(json ? JSON.stringify(r, null, 2) : `memory: ${r.resources?.memoryMb}MB · cpus: ${r.resources?.cpus} (plan max: ${r.resources?.planMaxMemoryMb}MB / ${r.resources?.planMaxVcpu} vCPU)`);
|
|
200
|
+
}
|
|
201
|
+
const body = {};
|
|
202
|
+
if (a.flags.memory)
|
|
203
|
+
body.memoryMb = Number(a.flags.memory);
|
|
204
|
+
if (a.flags.cpus)
|
|
205
|
+
body.cpus = Number(a.flags.cpus);
|
|
206
|
+
const r = await api(`/apps/${encodeURIComponent(id)}/resources`, { method: 'PUT', body });
|
|
207
|
+
return console.log(json ? JSON.stringify(r, null, 2) : green(`✓ Resized → ${r.resources?.memoryMb}MB / ${r.resources?.cpus} vCPU${r.resources?.clamped ? ' (clamped to plan max)' : ''}`));
|
|
208
|
+
}
|
|
170
209
|
default: throw new Error(`unknown: apps ${sub}`);
|
|
171
210
|
}
|
|
172
211
|
}
|
package/dist/commands/db.js
CHANGED
|
@@ -60,6 +60,57 @@ export async function db(a) {
|
|
|
60
60
|
const r = await api(`/databases/${encodeURIComponent(id)}/restore`, { method: 'POST', body });
|
|
61
61
|
return console.log(json ? JSON.stringify(r, null, 2) : green('✓ Restoring to a new cluster…'));
|
|
62
62
|
}
|
|
63
|
+
case 'ext':
|
|
64
|
+
case 'extensions': {
|
|
65
|
+
need();
|
|
66
|
+
const name = a.positionals[1];
|
|
67
|
+
if (!name) {
|
|
68
|
+
const r = await api(`/databases/${encodeURIComponent(id)}/extensions`);
|
|
69
|
+
return console.log(json ? JSON.stringify(r, null, 2) : 'allowed: ' + (r.allowed || []).join(', '));
|
|
70
|
+
}
|
|
71
|
+
const r = await api(`/databases/${encodeURIComponent(id)}/extensions`, { method: 'POST', body: { name } });
|
|
72
|
+
return console.log(json ? JSON.stringify(r, null, 2) : green(`✓ Extension ${name} installed`));
|
|
73
|
+
}
|
|
74
|
+
case 'replicas': {
|
|
75
|
+
need();
|
|
76
|
+
const n = a.positionals[1];
|
|
77
|
+
if (n === undefined) {
|
|
78
|
+
const r = await api(`/databases/${encodeURIComponent(id)}/replicas`);
|
|
79
|
+
return console.log(json ? JSON.stringify(r, null, 2) : `replicas: ${r.replicas} / max ${r.maxReplicas}`);
|
|
80
|
+
}
|
|
81
|
+
const r = await api(`/databases/${encodeURIComponent(id)}/replicas`, { method: 'POST', body: { replicas: Number(n) } });
|
|
82
|
+
return console.log(json ? JSON.stringify(r, null, 2) : green(`✓ Scaling to ${n} read replica(s)…`));
|
|
83
|
+
}
|
|
84
|
+
case 'pub':
|
|
85
|
+
case 'publications': {
|
|
86
|
+
need();
|
|
87
|
+
const act = a.positionals[1];
|
|
88
|
+
if (!act || act === 'ls') {
|
|
89
|
+
const r = await api(`/databases/${encodeURIComponent(id)}/publications`);
|
|
90
|
+
const l = r.publications || [];
|
|
91
|
+
return output(l, json, { rows: l.map((x) => ({ name: x.name, allTables: x.allTables ? 'yes' : 'no' })), columns: ['name', 'allTables'] });
|
|
92
|
+
}
|
|
93
|
+
if (act === 'add') {
|
|
94
|
+
const name = a.positionals[2];
|
|
95
|
+
if (!name)
|
|
96
|
+
throw new Error('need <name>');
|
|
97
|
+
const body = { name };
|
|
98
|
+
if (a.flags['all-tables'])
|
|
99
|
+
body.allTables = true;
|
|
100
|
+
else if (a.flags.tables)
|
|
101
|
+
body.tables = String(a.flags.tables).split(',');
|
|
102
|
+
const r = await api(`/databases/${encodeURIComponent(id)}/publications`, { method: 'POST', body });
|
|
103
|
+
return console.log(json ? JSON.stringify(r, null, 2) : green(`✓ Publication ${name} created`));
|
|
104
|
+
}
|
|
105
|
+
if (act === 'rm') {
|
|
106
|
+
const name = a.positionals[2];
|
|
107
|
+
if (!name)
|
|
108
|
+
throw new Error('need <name>');
|
|
109
|
+
await api(`/databases/${encodeURIComponent(id)}/publications?name=${encodeURIComponent(name)}`, { method: 'DELETE' });
|
|
110
|
+
return console.log(green(`✓ Publication ${name} dropped`));
|
|
111
|
+
}
|
|
112
|
+
throw new Error('usage: koigrid db pub <id> ls | add <name> [--all-tables|--tables t1,t2] | rm <name>');
|
|
113
|
+
}
|
|
63
114
|
default: throw new Error(`unknown: db ${sub}`);
|
|
64
115
|
}
|
|
65
116
|
}
|
package/dist/commands/jobs.js
CHANGED
|
@@ -12,11 +12,31 @@ export async function jobs(a) {
|
|
|
12
12
|
const name = a.positionals[0];
|
|
13
13
|
const schedule = a.flags.schedule;
|
|
14
14
|
const image = a.flags.image;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
const url = a.flags.url;
|
|
16
|
+
if (!name || !schedule || (!image && !url))
|
|
17
|
+
throw new Error('usage: koigrid jobs create <name> --schedule "<cron>" (--image <img> [--command "..."] | --url <url> [--method POST] [--header "K: V"])');
|
|
18
|
+
const body = { name, schedule };
|
|
19
|
+
if (url) {
|
|
20
|
+
// Job HTTP: pega a una URL según el cron (no un contenedor). --header repetible ("K: V").
|
|
21
|
+
body.type = 'http';
|
|
22
|
+
body.url = url;
|
|
23
|
+
if (a.flags.method)
|
|
24
|
+
body.method = String(a.flags.method).toUpperCase();
|
|
25
|
+
const hdrs = [].concat(a.flags.header ?? []);
|
|
26
|
+
if (hdrs.length) {
|
|
27
|
+
body.headers = {};
|
|
28
|
+
for (const h of hdrs) {
|
|
29
|
+
const i = h.indexOf(':');
|
|
30
|
+
if (i > 0)
|
|
31
|
+
body.headers[h.slice(0, i).trim()] = h.slice(i + 1).trim();
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
body.image = image;
|
|
37
|
+
if (a.flags.command)
|
|
38
|
+
body.command = a.flags.command;
|
|
39
|
+
}
|
|
20
40
|
const r = await api('/jobs', { method: 'POST', body });
|
|
21
41
|
if (json)
|
|
22
42
|
console.log(JSON.stringify(r, null, 2));
|
package/dist/manifest.js
CHANGED
|
@@ -4,11 +4,11 @@ export const CLI_COMMANDS = [
|
|
|
4
4
|
{ name: 'whoami', summary: 'Show the authenticated account', subs: [], endpoints: ['me'] },
|
|
5
5
|
{ name: 'usage', summary: 'Show usage & cost', subs: [], endpoints: ['usage'] },
|
|
6
6
|
{
|
|
7
|
-
name: 'apps', aliases: ['app'], product: 'apps', summary: 'Deploy and manage apps',
|
|
8
|
-
subs: ['ls', 'deploy', 'logs', 'rm', 'scale', 'autoscale', 'env', 'domains', 'volumes', 'cdn', 'github', 'rollback', 'deployments'],
|
|
9
|
-
endpoints: ['apps', 'apps/[id]', 'apps/[id]/deployments', 'apps/[id]/logs', 'apps/[id]/scale', 'apps/[id]/autoscale', 'apps/[id]/env', 'apps/[id]/domains', 'apps/[id]/volumes', 'apps/[id]/volumes/[volId]', 'apps/[id]/cdn', 'apps/[id]/github', 'apps/[id]/rollback'],
|
|
7
|
+
name: 'apps', aliases: ['app'], product: 'apps', summary: 'Deploy and manage apps (git repo, container image, or local --dir)',
|
|
8
|
+
subs: ['ls', 'deploy', 'logs', 'rm', 'scale', 'resize', 'autoscale', 'env', 'domains', 'volumes', 'cdn', 'github', 'rollback', 'deployments'],
|
|
9
|
+
endpoints: ['apps', 'apps/[id]', 'apps/[id]/deployments', 'apps/[id]/source-upload', 'apps/[id]/logs', 'apps/[id]/scale', 'apps/[id]/resources', 'apps/[id]/autoscale', 'apps/[id]/env', 'apps/[id]/domains', 'apps/[id]/volumes', 'apps/[id]/volumes/[volId]', 'apps/[id]/cdn', 'apps/[id]/github', 'apps/[id]/rollback'],
|
|
10
10
|
},
|
|
11
|
-
{ name: 'db', aliases: ['databases', 'database'], product: 'databases', summary: 'Managed Postgres (HA)', subs: ['ls', 'create', 'rm', 'url', 'metrics', 'backups', 'restore'], endpoints: ['databases', 'databases/[id]', 'databases/[id]/connection', 'databases/[id]/backups', 'databases/[id]/restore', 'databases/[id]/metrics'] },
|
|
11
|
+
{ name: 'db', aliases: ['databases', 'database'], product: 'databases', summary: 'Managed Postgres (HA)', subs: ['ls', 'create', 'rm', 'url', 'metrics', 'backups', 'restore', 'ext', 'replicas', 'pub'], endpoints: ['databases', 'databases/[id]', 'databases/[id]/connection', 'databases/[id]/backups', 'databases/[id]/restore', 'databases/[id]/metrics', 'databases/[id]/extensions', 'databases/[id]/replicas', 'databases/[id]/publications'] },
|
|
12
12
|
{ name: 'redis', aliases: ['cache'], product: 'cache', summary: 'Managed Redis (HA)', subs: ['ls', 'create', 'rm', 'url', 'metrics', 'backups', 'restore'], endpoints: ['redis', 'redis/[id]', 'redis/[id]/connection', 'redis/[id]/backups', 'redis/[id]/restore', 'redis/[id]/metrics'] },
|
|
13
13
|
{ name: 'storage', aliases: ['buckets'], product: 'storage', summary: 'Object storage (S3)', subs: ['ls', 'create', 'rm', 'keys', 'key'], endpoints: ['buckets', 'buckets/[id]', 'storage/keys', 'storage/keys/[id]'] },
|
|
14
14
|
{ name: 'jobs', aliases: ['cron'], product: 'jobs', summary: 'Cron / scheduled jobs', subs: ['ls', 'create', 'update', 'rm', 'trigger', 'runs'], endpoints: ['jobs', 'jobs/[id]', 'jobs/[id]/runs', 'jobs/[id]/trigger'] },
|
package/package.json
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "koigrid",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "koigrid CLI \u2014 deploy apps, databases, redis, storage and more from your terminal (or your AI agent).",
|
|
5
5
|
"bin": {
|
|
6
6
|
"koigrid": "dist/index.js"
|
|
7
7
|
},
|
|
8
8
|
"type": "module",
|
|
9
9
|
"files": [
|
|
10
|
-
"dist"
|
|
10
|
+
"dist",
|
|
11
|
+
"CHANGELOG.md"
|
|
11
12
|
],
|
|
12
13
|
"engines": {
|
|
13
14
|
"node": ">=18"
|