@oalo-ai/cli 0.3.0 → 0.4.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/man/oalo.1 +57 -2
- package/package.json +1 -1
- package/plugin/skills/oalo/SKILL.md +13 -0
- package/src/bot-settings.json +13 -0
- package/src/commands/apps.js +7 -2
- package/src/commands/build.js +219 -0
- package/src/commands/channels.js +10 -5
- package/src/commands/data.js +12 -4
- package/src/commands/deploy.js +24 -3
- package/src/commands/docs.js +3 -1
- package/src/commands/link.js +2 -2
- package/src/commands/metrics.js +4 -1
- package/src/commands/migrate.js +6 -3
- package/src/commands/secrets.js +2 -1
- package/src/commands/sources.js +30 -0
- package/src/commands/typegen.js +9 -3
- package/src/config.js +26 -8
- package/src/coord-release.json +9 -9
- package/src/graphfiles.js +13 -3
- package/src/help.js +31 -1
- package/src/index.js +11 -1
- package/src/migrate/plan.js +21 -5
package/man/oalo.1
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
.TH OALO 1 "" "oalo 0.
|
|
1
|
+
.TH OALO 1 "" "oalo 0.4.1" "OALO CLI"
|
|
2
2
|
.SH NAME
|
|
3
3
|
oalo \- wire a local app into your Oalo workspace
|
|
4
4
|
.SH SYNOPSIS
|
|
@@ -634,6 +634,51 @@ auto on: a dev deploy that finds nothing runnable, or a preview that doesn't run
|
|
|
634
634
|
Admins and members with Developer access only.
|
|
635
635
|
.PP
|
|
636
636
|
Exit codes: 0 done; 1 refused, or (status) the last setup failed; 2 bad arguments or no CLI token.
|
|
637
|
+
.SS build
|
|
638
|
+
A store build of a Flutter or Expo app: the .ipa for App Store Connect and the .aab for Google Play, with download links.
|
|
639
|
+
.PP
|
|
640
|
+
\fBoalo build [\-\-app <slug>] [\-\-wait] [\-\-download] [\-\-json]\fR
|
|
641
|
+
.br
|
|
642
|
+
\fBoalo build status [\-\-app <slug>] [\-\-build <id>] [\-\-wait] [\-\-download] [\-\-json]\fR
|
|
643
|
+
.br
|
|
644
|
+
\fBoalo build list [\-\-app <slug>] [\-\-json]\fR
|
|
645
|
+
.br
|
|
646
|
+
\fBoalo build upload <file> \-\-target <name> [\-\-app <slug>] [\-\-build <id>]\fR
|
|
647
|
+
.br
|
|
648
|
+
.TP
|
|
649
|
+
\fB\-\-app <slug>\fR
|
|
650
|
+
The app. Default: the one saved with \fBoalo link \-\-app\fR.
|
|
651
|
+
.TP
|
|
652
|
+
\fB\-\-wait\fR
|
|
653
|
+
Follow the build until it's done (15 to 60 minutes), then print the links.
|
|
654
|
+
.TP
|
|
655
|
+
\fB\-\-download\fR
|
|
656
|
+
Save the .ipa and .aab in this folder when the build is done (implies \-\-wait). An existing file is left as it is.
|
|
657
|
+
.TP
|
|
658
|
+
\fB\-\-build <id>\fR
|
|
659
|
+
status, upload: that build instead of the latest one (\fBoalo build list\fR shows the ids).
|
|
660
|
+
.TP
|
|
661
|
+
\fB\-\-target <name>\fR
|
|
662
|
+
upload: the platform the file is for, one the app's .oalo/app.json lists under targets.external (garmin, macos).
|
|
663
|
+
.TP
|
|
664
|
+
\fB\-\-json\fR
|
|
665
|
+
The reply as JSON.
|
|
666
|
+
.IP \(bu 2
|
|
667
|
+
One build makes the file of each platform whose signing is set up (the app's Native Build tab says what's missing). Flutter apps build on Codemagic, Expo apps on EAS with your own Expo token (set it in Integrations, on the Expo tab). The version code goes up by one each build.
|
|
668
|
+
.IP \(bu 2
|
|
669
|
+
A build uses the app's code on Oalo, not this folder: \fBoalo deploy\fR your commits first.
|
|
670
|
+
.IP \(bu 2
|
|
671
|
+
Extra targets are built only when the app's .oalo/app.json declares them. A watch app: add \fB"targets": {"watchos": {"scheme": "<its Xcode scheme>"}}\fR, deploy, then set up its signing in the app's Native Build tab ("Set up the watch app's signing"); it ships inside the .ipa. A Wear OS app: \fB"wearos": {"module": "wear"}\fR (its Gradle module in android/), built as its own \-wear.aab for Play's Wear OS track. Platforms built elsewhere: \fB"external": ["garmin"]\fR, then \fBoalo build upload <file> \-\-target garmin\fR keeps the file with a build.
|
|
672
|
+
.IP \(bu 2
|
|
673
|
+
The files are private on your Base. Their links last an hour; \fBoalo build status\fR gives fresh ones. The app's Native Build tab in the dashboard has the same downloads.
|
|
674
|
+
.IP \(bu 2
|
|
675
|
+
Nothing is sent to the stores. Upload the .ipa with Transporter (or \fBxcrun altool \-\-upload\-app\fR), and the .aab in Google Play Console under a release.
|
|
676
|
+
.IP \(bu 2
|
|
677
|
+
\fBoalo deploy\fR updates the app's web preview; it doesn't make a store build.
|
|
678
|
+
.IP \(bu 2
|
|
679
|
+
One build of an app at a time. Admins and members with Developer access only.
|
|
680
|
+
.PP
|
|
681
|
+
Exit codes: 0 started, or (status, \-\-wait) built; 1 refused, the build failed, or a download failed; 2 bad arguments or no CLI token.
|
|
637
682
|
.SS sources
|
|
638
683
|
Feeds that send Oalo rows from outside (another system, a webhook, an export), keeping only the fields you choose.
|
|
639
684
|
.PP
|
|
@@ -649,6 +694,8 @@ Feeds that send Oalo rows from outside (another system, a webhook, an export), k
|
|
|
649
694
|
.br
|
|
650
695
|
\fBoalo sources create <name> \-\-bot <bot> [\-\-auth bearer|hmac|url]\fR
|
|
651
696
|
.br
|
|
697
|
+
\fBoalo sources create <name> \-\-from\-postgres <postgres url> \-\-relation <schema.view> [\-\-key <column>] [\-\-cursor <column>] [\-\-every <minutes>] [\-\-table <new model>] [\-\-now]\fR
|
|
698
|
+
.br
|
|
652
699
|
\fBoalo sources push <name> <file.csv|.json|.jsonl> [\-\-json]\fR
|
|
653
700
|
.br
|
|
654
701
|
\fBoalo sources push <name> <doc.pdf|.docx|.md|.html|.txt> [more...] [\-\-json]\fR
|
|
@@ -670,6 +717,9 @@ Feeds that send Oalo rows from outside (another system, a webhook, an export), k
|
|
|
670
717
|
\fBoalo sources delete <name> [\-\-wipe]\fR
|
|
671
718
|
.br
|
|
672
719
|
.TP
|
|
720
|
+
\fB\-\-from\-postgres <url>\fR
|
|
721
|
+
create: a view (or table) in your own Postgres, in one step. The Base reads its columns and makes the model from them, then reads the view on a schedule (\-\-every, default 60 minutes; \-\-cursor <column> for only new or changed rows, else the whole view each time as a snapshot). Put the address in a variable: \-\-from\-postgres "$DB_URL". See \fBoalo docs data\-sources\fR.
|
|
722
|
+
.TP
|
|
673
723
|
\fB\-\-from <file>\fR
|
|
674
724
|
create: a sample of what the sender sends. Its fields and their types make the source's fields and a new model (\-\-table, default the source's name).
|
|
675
725
|
.TP
|
|
@@ -1182,7 +1232,7 @@ Each file holds the editable object (\fBflow\fR or \fBloop\fR) plus the CLI's bo
|
|
|
1182
1232
|
.IP \(bu 2
|
|
1183
1233
|
A file you have edited is kept, not overwritten, unless you pass \-\-force.
|
|
1184
1234
|
.IP \(bu 2
|
|
1185
|
-
To create a flow or loop, write a file in the same shape without id or version, then push it.
|
|
1235
|
+
To create a flow or loop, write a file in the same shape without id or version, then push it. A new loop: {"kind": "loop", "name": "<name>", "loop": {"entry", "nodes", "edges", ...}, "triggers": [...]}. A new flow: {"kind": "flow", "bot": "<bot_ id>", "flow": {"name", "graph", ...}}. Run oalo pull once first for the node contracts in .oalo/catalog/.
|
|
1186
1236
|
.IP \(bu 2
|
|
1187
1237
|
Needs a CLI token.
|
|
1188
1238
|
.PP
|
|
@@ -1613,6 +1663,11 @@ Hours after the customer's last WhatsApp message to flag the 24\-hour window as
|
|
|
1613
1663
|
.br
|
|
1614
1664
|
Values: a number from 1 to 23. Default: 20.
|
|
1615
1665
|
.TP
|
|
1666
|
+
\fBlead_watch.no_reply_hours\fR
|
|
1667
|
+
Hours after our last message with no answer from the customer before the conversation is tagged "no reply" and the No reply from customer trigger fires. 0 turns it off.
|
|
1668
|
+
.br
|
|
1669
|
+
Values: a number from 0 to 168. Default: 24.
|
|
1670
|
+
.TP
|
|
1616
1671
|
\fBallow_ambient_uploads\fR
|
|
1617
1672
|
Show an attach button in the web chat, so members can send files with their message.
|
|
1618
1673
|
.br
|
package/package.json
CHANGED
|
@@ -25,6 +25,11 @@ oalo qa <bot> "hola" "..." --channel whatsapp # talk to the bot, read the tran
|
|
|
25
25
|
oalo status # what changed locally and on the server
|
|
26
26
|
```
|
|
27
27
|
|
|
28
|
+
A new loop or flow is a file you write without `id` or `version`, then push.
|
|
29
|
+
A loop: `{"kind": "loop", "name": "<name>", "loop": {"entry", "nodes", "edges", ...}, "triggers": [...]}`.
|
|
30
|
+
A flow: `{"kind": "flow", "bot": "<bot_ id>", "flow": {"name", "graph", ...}}`. Run
|
|
31
|
+
`oalo pull` once first, for the node contracts in `.oalo/catalog/`.
|
|
32
|
+
|
|
28
33
|
Over MCP the same steps are `oalo_node_catalog`, `oalo_get_flow` / `oalo_get_loop` /
|
|
29
34
|
`oalo_get_tool_source`, `oalo_lint_flow` / `oalo_lint_loop`, `oalo_save_flow` /
|
|
30
35
|
`oalo_save_loop` / `oalo_save_tool_source`, `oalo_test_conversation` and
|
|
@@ -222,6 +227,7 @@ oalo deploy --new [<name>] # this repo becomes a new app, its history
|
|
|
222
227
|
oalo deploy --new --from <https url> # a repo on a Git host becomes an app, no checkout
|
|
223
228
|
oalo deploy --app shop # this branch's commits to the preview (dev)
|
|
224
229
|
oalo deploy --app shop --env prod # build and swap the live release
|
|
230
|
+
oalo build --app shop --download # a Flutter or Expo app's store files (.ipa, .aab), saved here
|
|
225
231
|
```
|
|
226
232
|
|
|
227
233
|
0. **A repo that isn't on Oalo yet** (the person wants to host their code):
|
|
@@ -286,6 +292,13 @@ oalo deploy --app shop --env prod # build and swap the live release
|
|
|
286
292
|
set NAME=value`: for values it can't read (Fly secrets, Primcloud) the
|
|
287
293
|
person puts them in a .env file and you pass `--env-file`. Then the data
|
|
288
294
|
(rule 7), and live only when the person says so.
|
|
295
|
+
9. **App Store and Google Play files** (a Flutter or Expo app): `oalo deploy`
|
|
296
|
+
updates only the web preview. `oalo build --app shop --download` makes a
|
|
297
|
+
store build (15 to 60 minutes, both platforms) and saves the `.ipa` and
|
|
298
|
+
`.aab` where you run it. Oalo doesn't upload them: tell the person to
|
|
299
|
+
deliver the `.ipa` with Transporter and upload the `.aab` in Google Play
|
|
300
|
+
Console. Each build raises the version code, so start one only when asked.
|
|
301
|
+
Don't build them locally with Xcode, Gradle, `flutter build` or `eas build`.
|
|
289
302
|
|
|
290
303
|
## An app's environment variables
|
|
291
304
|
|
package/src/bot-settings.json
CHANGED
|
@@ -392,6 +392,19 @@
|
|
|
392
392
|
23
|
|
393
393
|
]
|
|
394
394
|
},
|
|
395
|
+
{
|
|
396
|
+
"clear_word": null,
|
|
397
|
+
"default": 24,
|
|
398
|
+
"doc": "Hours after our last message with no answer from the customer before the conversation is tagged \"no reply\" and the No reply from customer trigger fires. 0 turns it off.",
|
|
399
|
+
"effect": null,
|
|
400
|
+
"group": "replies",
|
|
401
|
+
"key": "lead_watch.no_reply_hours",
|
|
402
|
+
"type": "number",
|
|
403
|
+
"values": [
|
|
404
|
+
0,
|
|
405
|
+
168
|
|
406
|
+
]
|
|
407
|
+
},
|
|
395
408
|
{
|
|
396
409
|
"clear_word": null,
|
|
397
410
|
"default": false,
|
package/src/commands/apps.js
CHANGED
|
@@ -39,11 +39,16 @@ export async function apps(flags) {
|
|
|
39
39
|
if (flags.json) return void console.log(JSON.stringify(rows, null, 2));
|
|
40
40
|
if (!rows.length) return void console.log(`no apps in ${url}`);
|
|
41
41
|
|
|
42
|
+
// A Base stores app hostnames as labels (`dev-shop-acme`); the domain is the
|
|
43
|
+
// workspace's own, less its first label (`acme.oalo.ai` -> `oalo.ai`).
|
|
44
|
+
const apex = new URL(url).hostname.split(".").slice(1).join(".");
|
|
45
|
+
const host = (h) => (h && !h.includes(".") && apex ? `${h}.${apex}` : h);
|
|
46
|
+
|
|
42
47
|
for (const a of rows.sort((x, y) => String(x.slug).localeCompare(String(y.slug)))) {
|
|
43
48
|
const runtime = a.app_type === "server" ? `server/${a.config?.server_runtime || "node"}` : a.app_type;
|
|
44
49
|
console.log(`${a.slug} ${dim(`${runtime}, ${a.status}${a.slug === cfg.appId ? ", linked" : ""}`)}`);
|
|
45
|
-
if (a.preview_hostname) console.log(dim(` preview https://${a.preview_hostname}/`));
|
|
46
|
-
const live = a.custom_hostname || a.prod_hostname;
|
|
50
|
+
if (a.preview_hostname) console.log(dim(` preview https://${host(a.preview_hostname)}/`));
|
|
51
|
+
const live = host(a.custom_hostname || a.prod_hostname);
|
|
47
52
|
if (a.release?.commit_hash) {
|
|
48
53
|
console.log(dim(` live https://${live}/ at ${String(a.release.commit_hash).slice(0, 8)}${a.release.launched_at ? `, ${String(a.release.launched_at).slice(0, 16).replace("T", " ")}` : ""}`));
|
|
49
54
|
if (a.incident) console.log(` ! ${a.incident.title} (since ${String(a.incident.opened_at).slice(0, 16).replace("T", " ")}): oalo incidents --app ${a.slug}`);
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
import { createReadStream, createWriteStream, existsSync, renameSync, rmSync, statSync } from "node:fs";
|
|
2
|
+
import { basename, join } from "node:path";
|
|
3
|
+
import { Readable } from "node:stream";
|
|
4
|
+
import { pipeline } from "node:stream/promises";
|
|
5
|
+
import { OaloChannel } from "../channel.js";
|
|
6
|
+
import { resolve as resolveConfig, controlPlane, HOW_TO_CONNECT } from "../config.js";
|
|
7
|
+
import { dim } from "../events.js";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* `oalo build`: a store build of a Flutter or Expo app. One build makes both
|
|
11
|
+
* files: the .ipa for App Store Connect (upload it with Transporter) and the
|
|
12
|
+
* .aab for Google Play Console. The files are private on your Base; their
|
|
13
|
+
* download links last an hour, and asking again gives fresh ones.
|
|
14
|
+
*
|
|
15
|
+
* oalo build [--app <slug>] [--wait] [--download] [--json] start one
|
|
16
|
+
* oalo build status [--app <slug>] [--build <id>] [--wait] [--download] [--json]
|
|
17
|
+
* oalo build list [--app <slug>] [--json]
|
|
18
|
+
* oalo build upload <file> --target <name> [--app <slug>] [--build <id>] keep a file built elsewhere with a build
|
|
19
|
+
*/
|
|
20
|
+
export async function build(flags, rest, opts = {}) {
|
|
21
|
+
const sub = rest[1] || "start";
|
|
22
|
+
if (!["start", "status", "list", "upload"].includes(sub)) return fail(`unknown build command: ${sub}\n\n${USAGE}`, 2);
|
|
23
|
+
if (sub === "upload" && (!rest[2] || typeof flags.target !== "string")) return fail("usage: oalo build upload <file> --target <name> [--app <slug>] [--build <id>]", 2);
|
|
24
|
+
if (sub === "upload" && !existsSync(rest[2])) return fail(`no file ${rest[2]}`, 2);
|
|
25
|
+
|
|
26
|
+
const cfg = resolveConfig(flags);
|
|
27
|
+
const { url, token } = controlPlane(cfg);
|
|
28
|
+
if (!url || !token) return fail(`oalo build needs a CLI token.\n\n${HOW_TO_CONNECT}`, 2);
|
|
29
|
+
const app = typeof flags.app === "string" ? flags.app : cfg.appId;
|
|
30
|
+
if (!app) return fail("which app? Pass --app <slug> (`oalo apps` lists them), or save it with `oalo link --app <slug>`.", 2);
|
|
31
|
+
|
|
32
|
+
const call = makeCall(opts.channel || ((o) => new OaloChannel(o)), { url, token });
|
|
33
|
+
const sleep = opts.sleep || ((ms) => new Promise((r) => setTimeout(r, ms)));
|
|
34
|
+
const wait = flags.wait === true || flags.download === true;
|
|
35
|
+
|
|
36
|
+
if (sub === "upload") return upload(call, app, rest[2], flags, opts);
|
|
37
|
+
|
|
38
|
+
let r;
|
|
39
|
+
try {
|
|
40
|
+
if (sub === "list") r = await call("native_build:list", { app });
|
|
41
|
+
else if (sub === "start") r = await call("native_build:start", { app });
|
|
42
|
+
else r = await call("native_build:status", { app, ...(typeof flags.build === "string" ? { build: flags.build } : {}) });
|
|
43
|
+
} catch (e) {
|
|
44
|
+
return fail(e.message, 1);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (sub === "list") {
|
|
48
|
+
if (flags.json) return void console.log(JSON.stringify(r, null, 2));
|
|
49
|
+
if (!r.builds.length) return void console.log(`${r.app}: no store builds yet. oalo build --app ${r.app} starts one.`);
|
|
50
|
+
for (const b of r.builds) console.log(`${b.id} ${label(b)} ${state(b)} ${dim(b.created_at || "")}`);
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (sub === "start" && !flags.json) {
|
|
55
|
+
console.log(`${r.app}: building ${label(r)} for ${platformNames(r.targets)} (${r.id}). This takes 15 to 60 minutes.`);
|
|
56
|
+
if (!wait) console.log(dim(`oalo build status --app ${r.app} shows how it's going; --wait follows it, --download also saves the files here.`));
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// Follow it until it's done.
|
|
60
|
+
let b = r;
|
|
61
|
+
let tries = 0;
|
|
62
|
+
while (wait && b.status === "processing") {
|
|
63
|
+
if (++tries > 720) return fail(`${b.app}: still building after 6 hours; oalo build status --app ${b.app} checks again.`, 1);
|
|
64
|
+
await sleep(opts.pollMs ?? 30000);
|
|
65
|
+
try {
|
|
66
|
+
b = await call("native_build:status", { app, build: r.id });
|
|
67
|
+
} catch (e) {
|
|
68
|
+
// A dropped connection on a long wait isn't the build failing.
|
|
69
|
+
if (tries % 10 === 0) console.error(dim(`still waiting (${e.message})`));
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (flags.json && !flags.download) return void console.log(JSON.stringify(b, null, 2));
|
|
74
|
+
if (sub === "start" && !wait) return;
|
|
75
|
+
|
|
76
|
+
report(b, url);
|
|
77
|
+
if (b.status === "processing") return;
|
|
78
|
+
// A build where one platform failed still keeps the others' files (Android
|
|
79
|
+
// built, iOS didn't, say): list and download those, and still exit 1.
|
|
80
|
+
const partial = b.success === false;
|
|
81
|
+
if (partial) process.exitCode = 1;
|
|
82
|
+
if (partial && !files(b).length) return;
|
|
83
|
+
|
|
84
|
+
if (flags.download) {
|
|
85
|
+
const saved = [];
|
|
86
|
+
for (const [platform, link] of files(b)) {
|
|
87
|
+
try {
|
|
88
|
+
saved.push(await download(link, opts.fetch || fetch, opts.cwd || process.cwd()));
|
|
89
|
+
} catch (e) {
|
|
90
|
+
return fail(`couldn't download the ${platform} file: ${e.message}`, 1);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
if (flags.json) return void console.log(JSON.stringify({ ...b, saved }, null, 2));
|
|
94
|
+
for (const s of saved) console.log(s.skipped ? `${s.file} is already here; left as it is` : `saved ${s.file} (${(s.bytes / 1e6).toFixed(1)} MB)`);
|
|
95
|
+
}
|
|
96
|
+
nextSteps(b);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const USAGE = [
|
|
100
|
+
"usage: oalo build [--app <slug>] [--wait] [--download] [--json]",
|
|
101
|
+
" oalo build status [--app <slug>] [--build <id>] [--wait] [--download] [--json]",
|
|
102
|
+
" oalo build list [--app <slug>] [--json]",
|
|
103
|
+
" oalo build upload <file> --target <name> [--app <slug>] [--build <id>]",
|
|
104
|
+
].join("\n");
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* A file built elsewhere (a Garmin watch face, a macOS app: a target the
|
|
108
|
+
* app's .oalo/app.json lists under targets.external), kept with a build on
|
|
109
|
+
* the Base: an upload address from the Base, the file straight to private
|
|
110
|
+
* storage, then attached.
|
|
111
|
+
*/
|
|
112
|
+
async function upload(call, app, file, flags, opts) {
|
|
113
|
+
const params = { app, target: flags.target, filename: basename(file), ...(typeof flags.build === "string" ? { build: flags.build } : {}) };
|
|
114
|
+
try {
|
|
115
|
+
const up = await call("native_build:upload_url", params);
|
|
116
|
+
const size = statSync(file).size;
|
|
117
|
+
const res = await (opts.fetch || fetch)(up.url, {
|
|
118
|
+
method: "PUT",
|
|
119
|
+
headers: { "content-type": "application/octet-stream", "content-length": String(size) },
|
|
120
|
+
body: Readable.toWeb(createReadStream(file)),
|
|
121
|
+
duplex: "half",
|
|
122
|
+
});
|
|
123
|
+
if (!res.ok) return fail(`upload failed: HTTP ${res.status}`, 1);
|
|
124
|
+
const b = await call("native_build:attach", { app, target: flags.target, key: up.key, build: up.build });
|
|
125
|
+
if (flags.json) return void console.log(JSON.stringify(b, null, 2));
|
|
126
|
+
console.log(`kept ${basename(file)} (${(size / 1e6).toFixed(1)} MB) with ${b.app || app} ${label(b)} (${b.id}) as ${flags.target}.`);
|
|
127
|
+
console.log(dim(`oalo build status --app ${app} --build ${b.id} lists its files with download links.`));
|
|
128
|
+
} catch (e) {
|
|
129
|
+
return fail(e.message, 1);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/** One call per request: a build is followed for up to an hour, longer than a channel is worth holding. */
|
|
134
|
+
function makeCall(open, conn) {
|
|
135
|
+
return async (event, params) => {
|
|
136
|
+
const ch = open(conn);
|
|
137
|
+
try {
|
|
138
|
+
await ch.connect();
|
|
139
|
+
return await ch.call(event, params, 120000);
|
|
140
|
+
} finally {
|
|
141
|
+
ch.close();
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// The platforms a build makes (the ones whose signing was ready), in words.
|
|
147
|
+
const PLATFORM_NAMES = { ios: "iOS", android: "Android", watchos: "its watch app", wearos: "Wear OS" };
|
|
148
|
+
function platformNames(targets) {
|
|
149
|
+
const names = (Array.isArray(targets) && targets.length ? targets : ["ios", "android"]).map((p) => PLATFORM_NAMES[p] || p);
|
|
150
|
+
return names.length > 1 ? `${names.slice(0, -1).join(", ")} and ${names.at(-1)}` : names[0];
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
const label = (b) => `${b.version || "?"} (${b.version_code || "?"})`;
|
|
154
|
+
const state = (b) => (b.status === "processing" ? "building" : b.success ? "built" : `failed: ${b.error_message || "no reason given"}`);
|
|
155
|
+
|
|
156
|
+
function report(b, base) {
|
|
157
|
+
if (b.status === "processing") {
|
|
158
|
+
console.log(`${b.app}: ${label(b)} is building (${b.id}, started ${b.created_at}).`);
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
if (!b.success) {
|
|
162
|
+
console.error(`${b.app}: ${label(b)} failed: ${b.error_message || "no reason given"}`);
|
|
163
|
+
const made = files(b);
|
|
164
|
+
if (made.length) {
|
|
165
|
+
console.log(`These were made anyway (links last ${Math.round((b.links_expire_in_s || 3600) / 60)} minutes):`);
|
|
166
|
+
for (const [platform, link] of made) console.log(` ${platform.padEnd(8)} ${link}`);
|
|
167
|
+
}
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
const mins = Math.round((b.links_expire_in_s || 3600) / 60);
|
|
171
|
+
console.log(`${b.app}: ${label(b)} built.`);
|
|
172
|
+
const all = files(b);
|
|
173
|
+
for (const [platform, link] of all) console.log(` ${platform.padEnd(8)} ${link}`);
|
|
174
|
+
if (!all.length) console.log(" (no files were kept for this build)");
|
|
175
|
+
console.log(dim(`The links last ${mins} minutes; oalo build status gives fresh ones. Also in the dashboard: ${String(base).replace(/^ws/, "http")}, the app's Native Build tab.`));
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/** [label, link] for each file the build kept: iOS, Android, Wear OS, then any attached with `oalo build upload`. */
|
|
179
|
+
function files(b) {
|
|
180
|
+
const out = [["iOS", b.ios_build_url], ["Android", b.android_build_url], ["Wear OS", b.wear_build_url]];
|
|
181
|
+
for (const [target, link] of Object.entries(b.extra_build_urls || {})) out.push([target, link]);
|
|
182
|
+
return out.filter(([, link]) => link);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
function nextSteps(b) {
|
|
186
|
+
if (!files(b).length) return;
|
|
187
|
+
console.log(dim("Next:"));
|
|
188
|
+
// The watch line only when this build made a watch app (targets lists it).
|
|
189
|
+
const watch = Array.isArray(b.targets) && b.targets.includes("watchos") ? " The watch app is inside it." : "";
|
|
190
|
+
if (b.ios_build_url) console.log(dim(` iOS: open the .ipa in Transporter and Deliver it to App Store Connect (or: xcrun altool --upload-app -t ios -f <file.ipa> --apiKey <key id> --apiIssuer <issuer id>).${watch}`));
|
|
191
|
+
if (b.android_build_url) console.log(dim(" Android: in Google Play Console, open the app, then a testing track or Production, Create new release, and upload the .aab."));
|
|
192
|
+
if (b.wear_build_url) console.log(dim(" Wear OS: in Play Console, the same app's Wear OS release track (add the Wear OS form factor once), and upload the -wear.aab."));
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/** Save a download link's file here, named as on the Base (`<slug>-<version>-<code>.ipa`). Never overwrites. */
|
|
196
|
+
async function download(link, fetchFn, cwd) {
|
|
197
|
+
const file = basename(new URL(link).pathname);
|
|
198
|
+
const dest = join(cwd, file);
|
|
199
|
+
if (existsSync(dest)) return { file, skipped: true, bytes: 0 };
|
|
200
|
+
const res = await fetchFn(link);
|
|
201
|
+
if (!res.ok) throw new Error(`HTTP ${res.status}${res.status === 403 ? " (the link may have expired; run oalo build status --download again)" : ""}`);
|
|
202
|
+
const tmp = `${dest}.part`;
|
|
203
|
+
let bytes = 0;
|
|
204
|
+
const counted = Readable.fromWeb(res.body);
|
|
205
|
+
counted.on("data", (c) => (bytes += c.length));
|
|
206
|
+
try {
|
|
207
|
+
await pipeline(counted, createWriteStream(tmp));
|
|
208
|
+
} catch (e) {
|
|
209
|
+
rmSync(tmp, { force: true });
|
|
210
|
+
throw e;
|
|
211
|
+
}
|
|
212
|
+
renameSync(tmp, dest);
|
|
213
|
+
return { file, bytes };
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
function fail(message, code) {
|
|
217
|
+
console.error(message);
|
|
218
|
+
process.exitCode = code;
|
|
219
|
+
}
|
package/src/commands/channels.js
CHANGED
|
@@ -93,14 +93,19 @@ function print(sub, channel, ref, r) {
|
|
|
93
93
|
}
|
|
94
94
|
if (sub === "check") {
|
|
95
95
|
const status = r.channel?.send_status;
|
|
96
|
-
console.log(`${r.number}: ${status === "ok" ? "Oalo can send on it." : `Oalo can't send on it yet (${status || "unknown"}).`}`);
|
|
97
96
|
const d = r.diagnosis || {};
|
|
97
|
+
// A blocker Meta reports (a blocked account, a payment method) means it
|
|
98
|
+
// can't send, whatever our last send status says. Each finding once.
|
|
99
|
+
const seen = new Set();
|
|
100
|
+
const findings = (d.findings || []).filter((f) => f.level !== "ok" && !seen.has(f.text) && seen.add(f.text));
|
|
101
|
+
const blocked = findings.some((f) => f.level === "blocker");
|
|
102
|
+
const can = status === "ok" && !blocked;
|
|
103
|
+
console.log(`${r.number}: ${can ? "Oalo can send on it." : `Oalo can't send on it yet (${status && status !== "ok" ? status : blocked ? "see below" : "unknown"}).`}`);
|
|
98
104
|
if (d.error) console.log(dim(` ${d.error}`));
|
|
99
|
-
for (const f of
|
|
100
|
-
|
|
101
|
-
console.log(` ${f.level === "blocker" ? "!" : "-"} ${f.text}${f.side === "meta" ? dim(" (on Meta's side)") : ""}`);
|
|
105
|
+
for (const f of findings) {
|
|
106
|
+
console.log(` ${f.level === "blocker" ? "!" : "-"} ${String(f.text).replace(/\.\.+/g, ".")}${f.side === "meta" ? dim(" (on Meta's side)") : ""}`);
|
|
102
107
|
}
|
|
103
|
-
if (
|
|
108
|
+
if (!can) process.exitCode = 1;
|
|
104
109
|
}
|
|
105
110
|
}
|
|
106
111
|
|
package/src/commands/data.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { readFileSync } from "node:fs";
|
|
2
2
|
import { basename } from "node:path";
|
|
3
3
|
import { OaloChannel } from "../channel.js";
|
|
4
|
-
import { resolve as resolveConfig, controlPlane, HOW_TO_CONNECT } from "../config.js";
|
|
4
|
+
import { resolve as resolveConfig, controlPlane, readToken, HOW_TO_CONNECT } from "../config.js";
|
|
5
5
|
import { requireFeature } from "../server.js";
|
|
6
6
|
import { ApiError } from "../api.js";
|
|
7
7
|
import { dim } from "../events.js";
|
|
@@ -236,6 +236,13 @@ async function keepFromAi(flags, rest, cfg, opts) {
|
|
|
236
236
|
|
|
237
237
|
/** The read side: the saved sync token, on the chosen schema. */
|
|
238
238
|
function readCfg(flags, cfg) {
|
|
239
|
+
// A folder linked with `oalo link` carries its own token; otherwise use the
|
|
240
|
+
// data token `oalo login` saved for the workspace, as whoami does.
|
|
241
|
+
if (!cfg.serverUrl || !cfg.token) {
|
|
242
|
+
const { url } = controlPlane(cfg);
|
|
243
|
+
const saved = url && readToken({ serverUrl: url, appId: cfg.appId }, "sync");
|
|
244
|
+
if (saved) cfg = { ...cfg, serverUrl: url, token: saved };
|
|
245
|
+
}
|
|
239
246
|
if (!cfg.serverUrl || !cfg.token) {
|
|
240
247
|
// Exit 2, as the help says for "no token" (audit C2).
|
|
241
248
|
throw Object.assign(new Error(`no workspace or data token for this project.\n\n${HOW_TO_CONNECT}`), { exitCode: 2 });
|
|
@@ -327,7 +334,8 @@ async function list(flags, rest, cfg) {
|
|
|
327
334
|
out(flags, page, () => {
|
|
328
335
|
for (const row of page.rows || []) console.log(JSON.stringify({ id: row.id, ...row.document }));
|
|
329
336
|
console.error(dim(`${(page.rows || []).length} rows from ${table} in ${c.serverUrl} (${c.env})` +
|
|
330
|
-
|
|
337
|
+
// --since pages forward; newest-first (`--order -seqnum`) can't continue that way.
|
|
338
|
+
(page.has_more ? (String(flags.order || "").startsWith("-") ? "; more with a bigger --limit" : `; more with --since ${page.next_since}`) : "")));
|
|
331
339
|
});
|
|
332
340
|
}
|
|
333
341
|
|
|
@@ -383,12 +391,12 @@ async function push(flags, rest, cfg) {
|
|
|
383
391
|
const read = readCfg({ ...flags, env }, cfg);
|
|
384
392
|
const manifest = await listModels(read);
|
|
385
393
|
if (!manifest.models?.[table]) {
|
|
386
|
-
throw new Error(`there is no model named ${table} in ${
|
|
394
|
+
throw new Error(`there is no model named ${table} in ${read.serverUrl}. Create it first: oalo data models create ${table} --field name:type ...`);
|
|
387
395
|
}
|
|
388
396
|
|
|
389
397
|
if (flags["dry-run"]) {
|
|
390
398
|
out(flags, { table, env, rows: todo.length, skipped: missing.length, first: todo[0] ?? null }, () => {
|
|
391
|
-
console.log(`${todo.length} rows would be upserted into ${table} in ${
|
|
399
|
+
console.log(`${todo.length} rows would be upserted into ${table} in ${read.serverUrl} (${env}), by ${idField}.`);
|
|
392
400
|
if (todo[0]) console.log(dim(`first: ${JSON.stringify(todo[0])}`));
|
|
393
401
|
console.log(dim("dry run: nothing was written"));
|
|
394
402
|
});
|
package/src/commands/deploy.js
CHANGED
|
@@ -3,7 +3,7 @@ import { mkdtempSync, rmSync, statSync, createReadStream, writeFileSync } from "
|
|
|
3
3
|
import { tmpdir } from "node:os";
|
|
4
4
|
import { join } from "node:path";
|
|
5
5
|
import { Readable } from "node:stream";
|
|
6
|
-
import { resolve as resolveConfig, controlPlane, HOW_TO_CONNECT, readConfig, writeConfig } from "../config.js";
|
|
6
|
+
import { resolve as resolveConfig, controlPlane, HOW_TO_CONNECT, readConfig, writeConfig, ensureGitignored } from "../config.js";
|
|
7
7
|
import { requireFeature } from "../server.js";
|
|
8
8
|
import { targetEnv } from "../data.js";
|
|
9
9
|
import { dim } from "../events.js";
|
|
@@ -126,13 +126,22 @@ export async function deploy(flags) {
|
|
|
126
126
|
// A new app: this project now deploys to it (as `oalo link --app` saves).
|
|
127
127
|
if (result.created) {
|
|
128
128
|
writeConfig({ ...(readConfig(root) || {}), serverUrl: url, appId: result.app, env: "dev" }, root);
|
|
129
|
+
// As `oalo link` does: the link file stays out of the repo's commits.
|
|
130
|
+
ensureGitignored(root);
|
|
129
131
|
if (result.app_type === "code_only") {
|
|
130
132
|
// The server's progress line already said what to add.
|
|
131
133
|
console.log(`created ${result.app} from ${result.commit.slice(0, 8)}, its history kept. Nothing runs yet (see above).`);
|
|
132
134
|
console.log(dim("After adding what it needs: commit, then `oalo deploy`. `oalo docs bring-your-repo` has the details."));
|
|
133
135
|
} else {
|
|
134
136
|
console.log(`created ${result.app} (${result.app_type}) from ${result.commit.slice(0, 8)}, its history kept: ${result.url}`);
|
|
135
|
-
|
|
137
|
+
// A server app's preview is checked as a deploy's is (newer Bases); the
|
|
138
|
+
// code is saved either way, but a preview that doesn't run exits 1.
|
|
139
|
+
if (result.preview === "ok") console.log(dim("Its preview answers. Next deploys: `oalo deploy`; live: `oalo deploy --env prod`."));
|
|
140
|
+
else if (result.preview === "failed") {
|
|
141
|
+
console.error(`its preview doesn't run: ${result.preview_error || "see `oalo logs`"}. Fix it, commit, then \`oalo deploy\`.`);
|
|
142
|
+
process.exitCode = 1;
|
|
143
|
+
} else console.log(dim("Its preview is being set up (`oalo logs` shows it). Next deploys: `oalo deploy`; live: `oalo deploy --env prod`."));
|
|
144
|
+
storeBuildHint(result.app_type, result.app);
|
|
136
145
|
}
|
|
137
146
|
}
|
|
138
147
|
|
|
@@ -164,6 +173,12 @@ export async function deploy(flags) {
|
|
|
164
173
|
}
|
|
165
174
|
if (result.install === "failed") console.log(dim("The install failed, so the preview may be missing packages (see above)."));
|
|
166
175
|
if (env === "dev") console.log(dim(`When the preview looks right: oalo deploy --app ${app} --env prod`));
|
|
176
|
+
storeBuildHint(result.app_type, app);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/** A deploy updates a mobile app's web preview; the store files come from `oalo build`. */
|
|
180
|
+
function storeBuildHint(type, app) {
|
|
181
|
+
if (type === "flutter" || type === "expo") console.log(dim(`For the App Store and Google Play (.ipa and .aab): oalo build --app ${app} --download`));
|
|
167
182
|
}
|
|
168
183
|
|
|
169
184
|
/**
|
|
@@ -319,7 +334,13 @@ async function pull(url, token, app, root) {
|
|
|
319
334
|
const dir = mkdtempSync(join(tmpdir(), "oalo-pull-"));
|
|
320
335
|
try {
|
|
321
336
|
const file = join(dir, "app.bundle");
|
|
322
|
-
|
|
337
|
+
let bytes;
|
|
338
|
+
try {
|
|
339
|
+
bytes = Buffer.from(await res.arrayBuffer());
|
|
340
|
+
} catch (e) {
|
|
341
|
+
return fail(`could not fetch ${app}: the download stopped part way (${e.message}). Try again.`, 1);
|
|
342
|
+
}
|
|
343
|
+
writeFileSync(file, bytes);
|
|
323
344
|
const ref = `refs/remotes/oalo/${app}`;
|
|
324
345
|
git(["fetch", "--quiet", "--no-tags", file, `+HEAD:${ref}`], root);
|
|
325
346
|
const sha = git(["rev-parse", ref], root);
|
package/src/commands/docs.js
CHANGED
|
@@ -16,7 +16,9 @@ import { dim } from "../events.js";
|
|
|
16
16
|
* notes.md` saves one; `--json` gives the structured form.
|
|
17
17
|
*/
|
|
18
18
|
export async function docs(flags, rest) {
|
|
19
|
-
|
|
19
|
+
// `oalo docs list` (and `ls`) is what people and agents type for the list:
|
|
20
|
+
// there is no page by either name.
|
|
21
|
+
const slug = ["list", "ls"].includes(rest[1]) ? undefined : rest[1];
|
|
20
22
|
const cfg = resolveConfig(flags);
|
|
21
23
|
const { url, token } = controlPlane(cfg);
|
|
22
24
|
if (!url || !token) {
|
package/src/commands/link.js
CHANGED
|
@@ -137,14 +137,14 @@ async function status(flags) {
|
|
|
137
137
|
try {
|
|
138
138
|
const m = await fetchManifest(cfg);
|
|
139
139
|
const models = Object.keys(m?.models || {}).length;
|
|
140
|
-
console.log(`reachable yes
|
|
140
|
+
console.log(`reachable yes, schema version ${m?.schema_version}, ${models} models`);
|
|
141
141
|
if (cfg.schemaVersion != null && m?.schema_version !== cfg.schemaVersion) {
|
|
142
142
|
console.log(
|
|
143
143
|
`\nschema moved since link (${cfg.schemaVersion} -> ${m.schema_version}). re-run oalo typegen.`,
|
|
144
144
|
);
|
|
145
145
|
}
|
|
146
146
|
} catch (e) {
|
|
147
|
-
console.log(`reachable NO
|
|
147
|
+
console.log(`reachable NO: ${e.message}`);
|
|
148
148
|
process.exitCode = 1;
|
|
149
149
|
}
|
|
150
150
|
}
|
package/src/commands/metrics.js
CHANGED
|
@@ -67,6 +67,9 @@ export function queryFromFlags(what, flags) {
|
|
|
67
67
|
if (!Number.isInteger(d) || d < 1) throw new Error("--days is a whole number of days");
|
|
68
68
|
q.days = d;
|
|
69
69
|
}
|
|
70
|
+
// A chart over time needs a window; with none, all of time is refused for a
|
|
71
|
+
// daily chart (over 366 days). Default to a window that fits each step.
|
|
72
|
+
if (q.every && q.days === undefined) q.days = { day: 30, week: 182, month: 366 }[q.every];
|
|
70
73
|
if (typeof flags.time === "string") q.time = flags.time;
|
|
71
74
|
if (flags.compare) q.compare = true;
|
|
72
75
|
if (flags.env === "dev" || flags.env === "prod") q.env = flags.env;
|
|
@@ -135,7 +138,7 @@ const DASHBOARDS_USAGE = [
|
|
|
135
138
|
|
|
136
139
|
function printResult(r) {
|
|
137
140
|
if (r.steps) {
|
|
138
|
-
for (const s of r.steps) console.log(`${s.step} ${s.contacts}${s.rate != null ? dim(` ${Math.round(s.rate
|
|
141
|
+
for (const s of r.steps) console.log(`${s.step} ${s.contacts}${s.rate != null ? dim(` ${Math.round(s.rate)}%`) : ""}`);
|
|
139
142
|
return;
|
|
140
143
|
}
|
|
141
144
|
const fmt = (v) => (Number.isInteger(v) ? String(v) : v.toFixed(2));
|
package/src/commands/migrate.js
CHANGED
|
@@ -48,6 +48,8 @@ export async function migrate(flags, rest, opts = {}) {
|
|
|
48
48
|
let plan;
|
|
49
49
|
try {
|
|
50
50
|
plan = buildPlan(platform, { files, remote, envFile, fromApp });
|
|
51
|
+
// The same command again, with what it was given, for the "run it again" steps.
|
|
52
|
+
plan.rerun = `oalo migrate ${platform}${fromApp ? ` --from-app ${fromApp}` : ""}${typeof flags["env-file"] === "string" ? ` --env-file ${flags["env-file"]}` : ""}`;
|
|
51
53
|
} catch (e) {
|
|
52
54
|
return fail(e.message, 1);
|
|
53
55
|
}
|
|
@@ -112,7 +114,7 @@ export async function migrate(flags, rest, opts = {}) {
|
|
|
112
114
|
console.log(`set ${varsResult.saved} variable${varsResult.saved === 1 ? "" : "s"} on ${varsResult.app} (prod)`);
|
|
113
115
|
if (varsResult.relaunch) console.log(dim("the live app gets them at its next release"));
|
|
114
116
|
} else if (varsResult?.skipped) {
|
|
115
|
-
console.log(`variables not set yet: this folder isn't linked to an Oalo app. After \`oalo deploy --new\`, run
|
|
117
|
+
console.log(`variables not set yet: this folder isn't linked to an Oalo app. After \`oalo deploy --new\`, run \`${plan.rerun} --apply\` again.`);
|
|
116
118
|
}
|
|
117
119
|
printNeeds(plan);
|
|
118
120
|
printNext(plan, app, platform, true);
|
|
@@ -290,10 +292,11 @@ function printNext(plan, app, platform, applied) {
|
|
|
290
292
|
...(["write", "merge"].includes(plan.manifest.action) ? [".oalo/app.json"] : []),
|
|
291
293
|
];
|
|
292
294
|
const later = !app && plan.vars.set.length;
|
|
293
|
-
|
|
295
|
+
const rerun = plan.rerun || `oalo migrate ${platform}`;
|
|
296
|
+
if (!applied) steps.push(`${rerun} --apply${later ? " (writes the files; the variables wait until the app exists)" : ""}`);
|
|
294
297
|
if (files.length) steps.push(`git add ${files.join(" ")} && git commit -m "Move to Oalo"`);
|
|
295
298
|
if (!app) steps.push("oalo deploy --new");
|
|
296
|
-
if (later) steps.push(
|
|
299
|
+
if (later) steps.push(`${rerun} --apply (now it sets the variables)`);
|
|
297
300
|
if (plan.vars.missing.length) steps.push("oalo env set NAME --secret --env prod (for each one still needed)");
|
|
298
301
|
steps.push("oalo env set NAME --env dev (test values for the preview)");
|
|
299
302
|
steps.push("your data: keep the database and set EXTERNAL_DATABASE_URL, or copy it in with oalo db restore");
|
package/src/commands/secrets.js
CHANGED
|
@@ -22,7 +22,8 @@ export async function secrets(flags, rest, opts = {}) {
|
|
|
22
22
|
|
|
23
23
|
const app = typeof flags.app === "string" ? flags.app : cfg.appId;
|
|
24
24
|
if (!app) return fail("which app? Pass --app <slug> (`oalo apps` lists them), or save it with `oalo link --app <slug>`.", 2);
|
|
25
|
-
|
|
25
|
+
// rest[0] is the command itself (`secrets`), as for every command.
|
|
26
|
+
const [, action, fingerprint] = rest;
|
|
26
27
|
if (action && action !== "dismiss") return fail(`unknown: oalo secrets ${action}. Try \`oalo secrets\` or \`oalo secrets dismiss <fingerprint>\`.`, 2);
|
|
27
28
|
if (action === "dismiss" && !fingerprint) return fail("oalo secrets dismiss needs the finding's fingerprint (from `oalo secrets`).", 2);
|
|
28
29
|
|
package/src/commands/sources.js
CHANGED
|
@@ -16,6 +16,7 @@ import { dim } from "../events.js";
|
|
|
16
16
|
* oalo sources create <name> --table <model or table> [--fields a,b] [--keep-from-ai a,b] [--retention days] ...
|
|
17
17
|
* oalo sources show <name> its address, fields and recent arrivals
|
|
18
18
|
* oalo sources create <name> --bot <bot> documents into a bot's knowledge
|
|
19
|
+
* oalo sources create <name> --from-postgres <url> --relation <schema.view> [--key c] [--cursor c] [--every m] [--now]
|
|
19
20
|
* oalo sources push <name> <file.csv|.json|.jsonl>
|
|
20
21
|
* oalo sources push <name> <doc.pdf> [more...] into a knowledge source
|
|
21
22
|
* oalo sources remove <name> <document> a knowledge source's document
|
|
@@ -86,6 +87,7 @@ const USAGE = [
|
|
|
86
87
|
" oalo sources show <name> | rotate <name> | delete <name> [--wipe]",
|
|
87
88
|
" oalo sources fields <name> a,b | retention <name> <days|off>",
|
|
88
89
|
" oalo sources create <name> --bot <bot> [--auth ...] documents into the bot's knowledge",
|
|
90
|
+
" oalo sources create <name> --from-postgres <postgres url> --relation <schema.view> [--key <column>] [--cursor <column>] [--every <minutes>] [--now]",
|
|
89
91
|
" oalo sources push <name> <file.csv|.json|.jsonl> or, for --bot, <doc.pdf|.docx|.md|.html|.txt> ...",
|
|
90
92
|
" oalo sources remove <name> <document>",
|
|
91
93
|
" oalo sources fetch <name> <https url> [--every <minutes>] [--header \"Name: value\"] [--records-at <a.b>] [--document <name>]",
|
|
@@ -119,6 +121,34 @@ async function create(ch, name, flags) {
|
|
|
119
121
|
if (flags["keep-from-ai"]) params.keep_from_ai = list_(flags["keep-from-ai"]);
|
|
120
122
|
if (flags.retention) params.retention_days = flags.retention;
|
|
121
123
|
|
|
124
|
+
// A view in an outside Postgres: the Base reads its columns, makes the
|
|
125
|
+
// model and sets the fetch in one step (AppBuilder.Sources.create_from_pg).
|
|
126
|
+
if (flags["from-postgres"] !== undefined) {
|
|
127
|
+
if (typeof flags["from-postgres"] !== "string" || !/^postgres(ql)?:\/\//.test(flags["from-postgres"]))
|
|
128
|
+
return fail("--from-postgres takes a postgres:// address (put it in a variable: --from-postgres \"$DB_URL\")", 2);
|
|
129
|
+
for (const f of ["relation", "key", "cursor", "every"]) if (flags[f] === true) return fail(`--${f} needs a value`, 2);
|
|
130
|
+
if (!flags.relation) return fail("--from-postgres needs the view to read: --relation schema.view", 2);
|
|
131
|
+
if (flags.from) return fail("use --from or --from-postgres, not both", 2);
|
|
132
|
+
params.from_postgres = flags["from-postgres"];
|
|
133
|
+
for (const f of ["relation", "key", "cursor", "every"]) if (flags[f]) params[f] = flags[f];
|
|
134
|
+
const s = await ch.call("sources:create", params, 60000);
|
|
135
|
+
if (flags.json && !flags.now) return void console.log(JSON.stringify(s, null, 2));
|
|
136
|
+
const f = s.fetch || {};
|
|
137
|
+
console.log(`made source ${s.name} -> ${s.table} (${s.env}), a new model`);
|
|
138
|
+
console.log(` fields ${Object.entries(s.fields).map(([k, t]) => `${k}:${t}`).join(", ")}`);
|
|
139
|
+
if (s.keep_from_ai?.length) console.log(` kept from AI ${s.keep_from_ai.join(", ")}`);
|
|
140
|
+
console.log(` id ${s.id_field}${s.mode === "snapshot" ? ", snapshot (each run is the whole view; rows it drops are deleted)" : ""}`);
|
|
141
|
+
console.log(` reads ${f.relation} from ${f.url} every ${f.every_minutes} minutes${f.cursor ? `, only rows past the last ${f.cursor} seen` : ""}`);
|
|
142
|
+
if (flags.now) {
|
|
143
|
+
const r = await ch.call("sources:fetch_now", { name: s.name }, 120000);
|
|
144
|
+
if (flags.json) return void console.log(JSON.stringify({ ...s, run: r }, null, 2));
|
|
145
|
+
console.log(` first run ${r.records ?? 0} rows read${r.upserted !== undefined ? `, ${r.upserted} saved` : ""}${r.deleted ? `, ${r.deleted} deleted` : ""}`);
|
|
146
|
+
} else {
|
|
147
|
+
console.log(dim(`The first read is within a minute. \`oalo sources fetch ${s.name} --now\` reads at once.`));
|
|
148
|
+
}
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
|
|
122
152
|
if (typeof flags.from === "string") {
|
|
123
153
|
const text = readFileSync(flags.from, "utf8");
|
|
124
154
|
// A sample is enough to read the fields and their types.
|
package/src/commands/typegen.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { readFileSync, writeFileSync, mkdirSync, existsSync } from "node:fs";
|
|
2
2
|
import { dirname, join } from "node:path";
|
|
3
|
-
import { resolve as resolveConfig, HOW_TO_CONNECT } from "../config.js";
|
|
3
|
+
import { resolve as resolveConfig, controlPlane, readToken, HOW_TO_CONNECT } from "../config.js";
|
|
4
4
|
import { fetchManifest, fetchWorkflows, syncGet } from "../api.js";
|
|
5
5
|
|
|
6
6
|
const DEFAULT_OUT = "oalo.generated.ts";
|
|
@@ -59,7 +59,7 @@ function renderModel(table, model) {
|
|
|
59
59
|
const fields = model.fields || [];
|
|
60
60
|
const lines = [];
|
|
61
61
|
|
|
62
|
-
lines.push(`/** \`${table}
|
|
62
|
+
lines.push(`/** \`${table}\`: primary key \`${model.primary_key || "id"}\`${
|
|
63
63
|
model.shared ? ", shared" : ""
|
|
64
64
|
}${model.owner_field ? `, owned via \`${model.owner_field}\`` : ""} */`);
|
|
65
65
|
lines.push(`export interface ${docTypeName(table)} {`);
|
|
@@ -394,7 +394,13 @@ function render(manifest, cfg, workflows = []) {
|
|
|
394
394
|
export { render as renderTypes };
|
|
395
395
|
|
|
396
396
|
export async function typegen(flags) {
|
|
397
|
-
|
|
397
|
+
let cfg = resolveConfig(flags);
|
|
398
|
+
// Without a linked folder, the data token `oalo login` saved (as in data.js).
|
|
399
|
+
if (!cfg.serverUrl || !cfg.token) {
|
|
400
|
+
const { url } = controlPlane(cfg);
|
|
401
|
+
const saved = url && readToken({ serverUrl: url, appId: cfg.appId }, "sync");
|
|
402
|
+
if (saved) cfg = { ...cfg, serverUrl: url, token: saved };
|
|
403
|
+
}
|
|
398
404
|
|
|
399
405
|
if (!cfg.serverUrl || !cfg.token) {
|
|
400
406
|
console.error(`no workspace or data token for this project.\n\n${HOW_TO_CONNECT}`);
|
package/src/config.js
CHANGED
|
@@ -66,13 +66,12 @@ export const TOKEN_KINDS = ["sync", "cli"];
|
|
|
66
66
|
|
|
67
67
|
export function readToken(config, kind = "sync") {
|
|
68
68
|
const all = readJson(CRED_PATH, {});
|
|
69
|
-
// `oalo login` saves per workspace (no app), so an app-specific link falls
|
|
70
|
-
// back to the workspace's own entry.
|
|
71
|
-
const entry = all[credKey(config)] || (config.appId ? all[credKey({ ...config, appId: null })] : null);
|
|
72
|
-
if (!entry) return null;
|
|
73
69
|
// Tolerate the earlier flat shape ({token, saved_at}) as a sync token.
|
|
74
|
-
|
|
75
|
-
|
|
70
|
+
const pick = (entry) => (!entry ? null : typeof entry.token === "string" ? (kind === "sync" ? entry.token : null) : entry[kind]?.token ?? null);
|
|
71
|
+
// `oalo login` saves per workspace (no app), so an app-specific link falls
|
|
72
|
+
// back to the workspace's own entry, kind by kind: an app entry holding only
|
|
73
|
+
// a sync token must not hide the workspace's CLI token.
|
|
74
|
+
return pick(all[credKey(config)]) ?? (config.appId ? pick(all[credKey({ ...config, appId: null })]) : null);
|
|
76
75
|
}
|
|
77
76
|
|
|
78
77
|
export function writeToken(config, token, kind = "sync", extra = {}) {
|
|
@@ -120,15 +119,34 @@ export function forgetWorkspace(serverUrl) {
|
|
|
120
119
|
* The control-plane URL and CLI token for a command. When this project (or
|
|
121
120
|
* --server / OALO_URL) names a workspace, only that workspace's token is used;
|
|
122
121
|
* a token saved for another workspace would just fail to authenticate. With
|
|
123
|
-
* no workspace named, the
|
|
122
|
+
* no workspace named, the one saved workspace is used. With several saved, it
|
|
123
|
+
* refuses (WhichWorkspace) rather than pick one: "the latest login" sent an
|
|
124
|
+
* unlinked folder's commands to another customer's live Base.
|
|
124
125
|
*/
|
|
125
126
|
export function controlPlane(cfg) {
|
|
126
127
|
if (cfg.cliToken) return { url: cfg.serverUrl, token: cfg.cliToken };
|
|
127
128
|
const saved = listWorkspaces("cli");
|
|
129
|
+
if (!cfg.serverUrl) {
|
|
130
|
+
const urls = [...new Set(saved.map((w) => w.serverUrl))];
|
|
131
|
+
if (urls.length > 1) throw new WhichWorkspace(urls);
|
|
132
|
+
}
|
|
128
133
|
const match = cfg.serverUrl ? saved.find((w) => w.serverUrl === cfg.serverUrl) : saved[0];
|
|
129
134
|
return { url: cfg.serverUrl || match?.serverUrl || null, token: match?.token || null };
|
|
130
135
|
}
|
|
131
136
|
|
|
137
|
+
/** Several workspaces are saved and nothing says which one a command is for. */
|
|
138
|
+
export class WhichWorkspace extends Error {
|
|
139
|
+
constructor(urls) {
|
|
140
|
+
super(
|
|
141
|
+
"This machine has more than one workspace saved, and nothing here says which one to use:\n" +
|
|
142
|
+
urls.map((u) => ` ${u}`).join("\n") +
|
|
143
|
+
"\n\nLink this folder to one with `oalo link --server <url>`, or pass --server <url>, or set OALO_URL."
|
|
144
|
+
);
|
|
145
|
+
this.code = "OALO_WHICH_WORKSPACE";
|
|
146
|
+
this.urls = urls;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
132
150
|
/** How to get a CLI token, for "needs a CLI token" messages. */
|
|
133
151
|
export const HOW_TO_CONNECT =
|
|
134
152
|
"Connect this machine with:\n oalo login <workspace> (your Base at <workspace>.oalo.ai)\n\n" +
|
|
@@ -140,7 +158,7 @@ export function ensureGitignored(cwd = process.cwd()) {
|
|
|
140
158
|
const rule = ".oalo/credentials*";
|
|
141
159
|
const current = existsSync(gi) ? readFileSync(gi, "utf8") : "";
|
|
142
160
|
if (current.includes(rule)) return false;
|
|
143
|
-
appendFileSync(gi, `${current.endsWith("\n") || !current ? "" : "\n"}\n# Oalo
|
|
161
|
+
appendFileSync(gi, `${current.endsWith("\n") || !current ? "" : "\n"}\n# Oalo: never commit credentials\n${rule}\n`);
|
|
144
162
|
return true;
|
|
145
163
|
}
|
|
146
164
|
|
package/src/coord-release.json
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.
|
|
2
|
+
"version": "0.4.1",
|
|
3
3
|
"targets": {
|
|
4
4
|
"darwin-arm64": {
|
|
5
5
|
"file": "oalo-coord-darwin-arm64.gz",
|
|
6
|
-
"sha256": "
|
|
7
|
-
"bytes":
|
|
6
|
+
"sha256": "83bca933ccbc22511fa1bf506dc7fe39731a46da59efb354f4a2e45bc80d6b3c",
|
|
7
|
+
"bytes": 24851980
|
|
8
8
|
},
|
|
9
9
|
"darwin-x64": {
|
|
10
10
|
"file": "oalo-coord-darwin-x64.gz",
|
|
11
|
-
"sha256": "
|
|
12
|
-
"bytes":
|
|
11
|
+
"sha256": "6ba7d6b98f0ac541e6eca0f649c7c4110cbbf2bcc7fb0bcfa8fc9d708629c9d0",
|
|
12
|
+
"bytes": 26990319
|
|
13
13
|
},
|
|
14
14
|
"linux-x64": {
|
|
15
15
|
"file": "oalo-coord-linux-x64.gz",
|
|
16
|
-
"sha256": "
|
|
17
|
-
"bytes":
|
|
16
|
+
"sha256": "43312caa34706ca12b502678936c12940c3d7495960841546e2935ec543b6117",
|
|
17
|
+
"bytes": 36882974
|
|
18
18
|
},
|
|
19
19
|
"linux-arm64": {
|
|
20
20
|
"file": "oalo-coord-linux-arm64.gz",
|
|
21
|
-
"sha256": "
|
|
22
|
-
"bytes":
|
|
21
|
+
"sha256": "64a426d6bfc9e646f12b9d6c1edd0b62f3830f33718b55e6232e92379255c9f8",
|
|
22
|
+
"bytes": 37123721
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
}
|
package/src/graphfiles.js
CHANGED
|
@@ -205,9 +205,19 @@ export function standing(file, remote) {
|
|
|
205
205
|
return "clean";
|
|
206
206
|
}
|
|
207
207
|
|
|
208
|
+
/**
|
|
209
|
+
* The smallest new file of each kind, for errors and help: a new loop or flow
|
|
210
|
+
* is often written from scratch, with no pulled file to copy.
|
|
211
|
+
*/
|
|
212
|
+
export const NEW_FILE_SHAPE = {
|
|
213
|
+
loop: '{"kind": "loop", "name": "<name>", "loop": {"description": "...", "entry": "<first node id>", "nodes": [...], "edges": [...]}, "triggers": [{"type": "api", "description": "...", "input": {"x": "string"}, "output": {"y": "string"}}]}',
|
|
214
|
+
flow: '{"kind": "flow", "bot": "<bot_ public id>", "flow": {"name": "<name>", "description": "...", "graph": {...}}}',
|
|
215
|
+
};
|
|
216
|
+
const SHAPES = `A new loop file: ${NEW_FILE_SHAPE.loop}\nA new flow file: ${NEW_FILE_SHAPE.flow}\nNode settings: .oalo/catalog/loop.json and flow.json (oalo pull writes them).`;
|
|
217
|
+
|
|
208
218
|
export function readGraphFile(path) {
|
|
209
219
|
const file = JSON.parse(readFileSync(path, "utf8"));
|
|
210
|
-
if (!["flow", "loop", "tool"].includes(file.kind)) throw new Error(`${path}: not an oalo flow, loop or tool file (kind is ${JSON.stringify(file.kind)})`);
|
|
220
|
+
if (!["flow", "loop", "tool"].includes(file.kind)) throw new Error(`${path}: not an oalo flow, loop or tool file (kind is ${JSON.stringify(file.kind)}).\n${SHAPES}`);
|
|
211
221
|
if (file.kind === "tool") {
|
|
212
222
|
if (!file.name || !file.tool) throw new Error(`${path}: a tool file needs \`name\` and \`tool\``);
|
|
213
223
|
const src = join(dirname(path), file.source || `${slug(file.name)}.js`);
|
|
@@ -215,8 +225,8 @@ export function readGraphFile(path) {
|
|
|
215
225
|
// Not written back: the .js file is the source of truth for the code.
|
|
216
226
|
Object.defineProperty(file, "_source", { value: readFileSync(src, "utf8"), enumerable: false });
|
|
217
227
|
}
|
|
218
|
-
if (file.kind === "flow" && (!file.bot || !file.flow)) throw new Error(`${path}: a flow file needs \`bot\` and \`flow
|
|
219
|
-
if (file.kind === "loop" && (!file.name || !file.loop)) throw new Error(`${path}: a loop file needs \`name\` and \`loop
|
|
228
|
+
if (file.kind === "flow" && (!file.bot || !file.flow)) throw new Error(`${path}: a flow file needs \`bot\` and \`flow\`.\nA new flow file: ${NEW_FILE_SHAPE.flow}`);
|
|
229
|
+
if (file.kind === "loop" && (!file.name || !file.loop)) throw new Error(`${path}: a loop file needs \`name\` and \`loop\`.\nA new loop file: ${NEW_FILE_SHAPE.loop}`);
|
|
220
230
|
return file;
|
|
221
231
|
}
|
|
222
232
|
|
package/src/help.js
CHANGED
|
@@ -409,6 +409,34 @@ export const COMMANDS = [
|
|
|
409
409
|
],
|
|
410
410
|
exits: { 0: "done", 1: "refused, or (status) the last setup failed", 2: "bad arguments or no CLI token" },
|
|
411
411
|
},
|
|
412
|
+
{
|
|
413
|
+
name: "build",
|
|
414
|
+
summary: "A store build of a Flutter or Expo app: the .ipa for App Store Connect and the .aab for Google Play, with download links.",
|
|
415
|
+
usage: [
|
|
416
|
+
"oalo build [--app <slug>] [--wait] [--download] [--json]",
|
|
417
|
+
"oalo build status [--app <slug>] [--build <id>] [--wait] [--download] [--json]",
|
|
418
|
+
"oalo build list [--app <slug>] [--json]",
|
|
419
|
+
"oalo build upload <file> --target <name> [--app <slug>] [--build <id>]",
|
|
420
|
+
],
|
|
421
|
+
flags: [
|
|
422
|
+
{ flag: "--app <slug>", desc: "The app. Default: the one saved with `oalo link --app`." },
|
|
423
|
+
{ flag: "--wait", desc: "Follow the build until it's done (15 to 60 minutes), then print the links." },
|
|
424
|
+
{ flag: "--download", desc: "Save the .ipa and .aab in this folder when the build is done (implies --wait). An existing file is left as it is." },
|
|
425
|
+
{ flag: "--build <id>", desc: "status, upload: that build instead of the latest one (`oalo build list` shows the ids)." },
|
|
426
|
+
{ flag: "--target <name>", desc: "upload: the platform the file is for, one the app's .oalo/app.json lists under targets.external (garmin, macos)." },
|
|
427
|
+
{ flag: "--json", desc: "The reply as JSON." },
|
|
428
|
+
],
|
|
429
|
+
notes: [
|
|
430
|
+
"One build makes the file of each platform whose signing is set up (the app's Native Build tab says what's missing). Flutter apps build on Codemagic, Expo apps on EAS with your own Expo token (set it in Integrations, on the Expo tab). The version code goes up by one each build.",
|
|
431
|
+
"A build uses the app's code on Oalo, not this folder: `oalo deploy` your commits first.",
|
|
432
|
+
"Extra targets are built only when the app's .oalo/app.json declares them. A watch app: add `\"targets\": {\"watchos\": {\"scheme\": \"<its Xcode scheme>\"}}`, deploy, then set up its signing in the app's Native Build tab (\"Set up the watch app's signing\"); it ships inside the .ipa. A Wear OS app: `\"wearos\": {\"module\": \"wear\"}` (its Gradle module in android/), built as its own -wear.aab for Play's Wear OS track. Platforms built elsewhere: `\"external\": [\"garmin\"]`, then `oalo build upload <file> --target garmin` keeps the file with a build.",
|
|
433
|
+
"The files are private on your Base. Their links last an hour; `oalo build status` gives fresh ones. The app's Native Build tab in the dashboard has the same downloads.",
|
|
434
|
+
"Nothing is sent to the stores. Upload the .ipa with Transporter (or `xcrun altool --upload-app`), and the .aab in Google Play Console under a release.",
|
|
435
|
+
"`oalo deploy` updates the app's web preview; it doesn't make a store build.",
|
|
436
|
+
"One build of an app at a time. Admins and members with Developer access only.",
|
|
437
|
+
],
|
|
438
|
+
exits: { 0: "started, or (status, --wait) built", 1: "refused, the build failed, or a download failed", 2: "bad arguments or no CLI token" },
|
|
439
|
+
},
|
|
412
440
|
{
|
|
413
441
|
name: "sources",
|
|
414
442
|
summary: "Feeds that send Oalo rows from outside (another system, a webhook, an export), keeping only the fields you choose.",
|
|
@@ -419,6 +447,7 @@ export const COMMANDS = [
|
|
|
419
447
|
" (either form) [--keep-from-ai a,b] [--retention <days>]",
|
|
420
448
|
"oalo sources show <name> [--json]",
|
|
421
449
|
"oalo sources create <name> --bot <bot> [--auth bearer|hmac|url]",
|
|
450
|
+
"oalo sources create <name> --from-postgres <postgres url> --relation <schema.view> [--key <column>] [--cursor <column>] [--every <minutes>] [--table <new model>] [--now]",
|
|
422
451
|
"oalo sources push <name> <file.csv|.json|.jsonl> [--json]",
|
|
423
452
|
"oalo sources push <name> <doc.pdf|.docx|.md|.html|.txt> [more...] [--json]",
|
|
424
453
|
"oalo sources remove <name> <document>",
|
|
@@ -431,6 +460,7 @@ export const COMMANDS = [
|
|
|
431
460
|
"oalo sources delete <name> [--wipe]",
|
|
432
461
|
],
|
|
433
462
|
flags: [
|
|
463
|
+
{ flag: "--from-postgres <url>", desc: "create: a view (or table) in your own Postgres, in one step. The Base reads its columns and makes the model from them, then reads the view on a schedule (--every, default 60 minutes; --cursor <column> for only new or changed rows, else the whole view each time as a snapshot). Put the address in a variable: --from-postgres \"$DB_URL\". See `oalo docs data-sources`." },
|
|
434
464
|
{ flag: "--from <file>", desc: "create: a sample of what the sender sends. Its fields and their types make the source's fields and a new model (--table, default the source's name)." },
|
|
435
465
|
{ flag: "--bot <bot>", desc: "create: send documents into this bot's knowledge (its public id, from oalo bots) instead of rows into a table. Each upload is one document by name; the same name replaces it." },
|
|
436
466
|
{ flag: "--table <model>", desc: "create: the model or plain table the rows go to (a table the app made with its own SQL, or an import kept as it is). An existing one keeps all its fields or columns, or the ones in --fields. A plain table's --id-field must be a unique column." },
|
|
@@ -733,7 +763,7 @@ export const COMMANDS = [
|
|
|
733
763
|
"A loop file also lists the loop's `triggers` (what starts it). Add or delete entries and push: push adds the new ones and removes the ones you deleted, and keeps any a teammate added since your pull. Set a trigger's `enabled` to turn it on or off.",
|
|
734
764
|
"Each file holds the editable object (`flow` or `loop`) plus the CLI's bookkeeping: id, version (sent back as base_version on push) and base_hash (how the CLI knows you edited it). Edit the object; leave the bookkeeping alone.",
|
|
735
765
|
"A file you have edited is kept, not overwritten, unless you pass --force.",
|
|
736
|
-
"To create a flow or loop, write a file in the same shape without id or version, then push it.",
|
|
766
|
+
"To create a flow or loop, write a file in the same shape without id or version, then push it. A new loop: {\"kind\": \"loop\", \"name\": \"<name>\", \"loop\": {\"entry\", \"nodes\", \"edges\", ...}, \"triggers\": [...]}. A new flow: {\"kind\": \"flow\", \"bot\": \"<bot_ id>\", \"flow\": {\"name\", \"graph\", ...}}. Run oalo pull once first for the node contracts in .oalo/catalog/.",
|
|
737
767
|
"Needs a CLI token.",
|
|
738
768
|
],
|
|
739
769
|
exits: { 0: "pulled", 1: "pull failed", 2: "bad arguments or no token" },
|
package/src/index.js
CHANGED
|
@@ -27,6 +27,7 @@ import { dockerfile } from "./commands/dockerfile.js";
|
|
|
27
27
|
import { bots } from "./commands/bots.js";
|
|
28
28
|
import { sources } from "./commands/sources.js";
|
|
29
29
|
import { setup } from "./commands/setup.js";
|
|
30
|
+
import { build } from "./commands/build.js";
|
|
30
31
|
import { incidents } from "./commands/incidents.js";
|
|
31
32
|
import { channels } from "./commands/channels.js";
|
|
32
33
|
import { products } from "./commands/products.js";
|
|
@@ -89,7 +90,13 @@ if ((flags.version || cmd === "version") && !flags.help) {
|
|
|
89
90
|
}
|
|
90
91
|
}
|
|
91
92
|
|
|
92
|
-
|
|
93
|
+
try {
|
|
94
|
+
await dispatch(cmd);
|
|
95
|
+
} catch (e) {
|
|
96
|
+
// controlPlane() refusing to guess between saved workspaces: a usage error.
|
|
97
|
+
if (e?.code === "OALO_WHICH_WORKSPACE") finish(e.message, 2, process.stderr);
|
|
98
|
+
else throw e;
|
|
99
|
+
}
|
|
93
100
|
}
|
|
94
101
|
|
|
95
102
|
async function dispatch(cmd) {
|
|
@@ -154,6 +161,9 @@ async function dispatch(cmd) {
|
|
|
154
161
|
case "setup":
|
|
155
162
|
await setup(flags, rest);
|
|
156
163
|
break;
|
|
164
|
+
case "build":
|
|
165
|
+
await build(flags, rest);
|
|
166
|
+
break;
|
|
157
167
|
case "incidents":
|
|
158
168
|
await incidents(flags, rest);
|
|
159
169
|
break;
|
package/src/migrate/plan.js
CHANGED
|
@@ -86,7 +86,7 @@ export function buildPlan(platform, input) {
|
|
|
86
86
|
const procfile = procfilePlan(files, read.processes, read.release, warnings);
|
|
87
87
|
const manifest = manifestPlan(files, procfile, read.sizes || {}, read.health, warnings);
|
|
88
88
|
const varPlan = filterVars(def, vars, missing, warnings);
|
|
89
|
-
commonChecks(files, warnings);
|
|
89
|
+
commonChecks(files, warnings, varPlan);
|
|
90
90
|
|
|
91
91
|
return { platform, label: def.label, procfile, manifest, vars: varPlan, warnings: dedupe(warnings) };
|
|
92
92
|
}
|
|
@@ -205,7 +205,7 @@ function fromRender(files, fromApp, warnings, missing, vars) {
|
|
|
205
205
|
if (s.preDeployCommand) release = joinCommands(s.preDeployCommand);
|
|
206
206
|
if (s.healthCheckPath) health = s.healthCheckPath;
|
|
207
207
|
} else if (type === "worker" || type === "bworker") {
|
|
208
|
-
proc = procName(name);
|
|
208
|
+
proc = uniqueProc(procName(name), processes);
|
|
209
209
|
} else {
|
|
210
210
|
warnings.push(`${name} has type ${type}, which oalo migrate doesn't map: add it to the Procfile by hand.`);
|
|
211
211
|
continue;
|
|
@@ -252,11 +252,16 @@ function fromFly(files, warnings, vars, remote, missing) {
|
|
|
252
252
|
if (!cfg) return { processes: null, release: null, sizes: {}, health: null };
|
|
253
253
|
|
|
254
254
|
const http = cfg.http_service || null;
|
|
255
|
-
|
|
255
|
+
// The group behind [http_service]: the one it names, else Fly's default
|
|
256
|
+
// `app`, else one named `web`, else the only group there is.
|
|
257
|
+
const groups = Object.keys(cfg.processes || {});
|
|
258
|
+
const webGroup =
|
|
259
|
+
(http?.processes && http.processes[0]) ||
|
|
260
|
+
(groups.includes("app") ? "app" : groups.includes("web") ? "web" : groups.length === 1 ? groups[0] : "app");
|
|
256
261
|
const processes = [];
|
|
257
262
|
const sizes = {};
|
|
258
263
|
for (const [group, cmd] of Object.entries(cfg.processes || {})) {
|
|
259
|
-
processes.push([group === webGroup ? "web" : procName(group), String(cmd)]);
|
|
264
|
+
processes.push([group === webGroup ? "web" : uniqueProc(procName(group), processes), String(cmd)]);
|
|
260
265
|
}
|
|
261
266
|
if (!Object.keys(cfg.processes || {}).length && !files.dockerfile && !files.procfile) {
|
|
262
267
|
warnings.push("fly.toml names no [processes] and there's no Dockerfile or Procfile: add a Procfile with a `web:` line.");
|
|
@@ -447,10 +452,14 @@ function privateHost(value) {
|
|
|
447
452
|
|
|
448
453
|
// ── checks every platform gets ────────────────────────────────────────
|
|
449
454
|
|
|
450
|
-
function commonChecks(files, warnings) {
|
|
455
|
+
function commonChecks(files, warnings, varPlan) {
|
|
451
456
|
if (files.packageJson && !files.lockfile && !files.dockerfile) {
|
|
452
457
|
warnings.push("package.json has no lockfile committed next to it (package-lock.json, yarn.lock, pnpm-lock.yaml or bun.lock): the build needs one.");
|
|
453
458
|
}
|
|
459
|
+
// Every variable is set as a secret, and a Dockerfile's build only sees public ones.
|
|
460
|
+
if (files.dockerfile && varPlan?.set?.length) {
|
|
461
|
+
warnings.push("The variables are set as secrets, which your app reads when it runs but a Dockerfile's build doesn't see. If the build needs one (an ARG), set it again with `oalo env set NAME=value --public --env prod`.");
|
|
462
|
+
}
|
|
454
463
|
}
|
|
455
464
|
|
|
456
465
|
// ── helpers ───────────────────────────────────────────────────────────
|
|
@@ -459,6 +468,13 @@ function joinCommands(c) {
|
|
|
459
468
|
return Array.isArray(c) ? c.map(String).join(" && ") : String(c);
|
|
460
469
|
}
|
|
461
470
|
|
|
471
|
+
/** `worker`, then `worker-2`, ...: two services can reduce to the same Procfile name. */
|
|
472
|
+
function uniqueProc(name, processes) {
|
|
473
|
+
const taken = new Set(processes.map(([n]) => n));
|
|
474
|
+
if (!taken.has(name)) return name;
|
|
475
|
+
for (let i = 2; ; i++) if (!taken.has(`${name}-${i}`)) return `${name}-${i}`;
|
|
476
|
+
}
|
|
477
|
+
|
|
462
478
|
function procName(name) {
|
|
463
479
|
const n = String(name).toLowerCase().replace(/[^a-z0-9_-]+/g, "-").replace(/^-+|-+$/g, "");
|
|
464
480
|
return n && PROC_RE.test(n) && n !== "web" && n !== "release" ? n : "worker";
|