@omnibase/cli 0.10.0 → 0.11.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/dist/commands/auth.d.ts.map +1 -1
- package/dist/commands/auth.js +15 -2
- package/dist/commands/auth.js.map +1 -1
- package/dist/commands/cloud.d.ts +10 -3
- package/dist/commands/cloud.d.ts.map +1 -1
- package/dist/commands/cloud.js +467 -44
- package/dist/commands/cloud.js.map +1 -1
- package/dist/commands/db/index.d.ts.map +1 -1
- package/dist/commands/db/index.js +21 -2
- package/dist/commands/db/index.js.map +1 -1
- package/dist/commands/email.d.ts.map +1 -1
- package/dist/commands/email.js +29 -3
- package/dist/commands/email.js.map +1 -1
- package/dist/commands/environment.d.ts.map +1 -1
- package/dist/commands/environment.js +10 -1
- package/dist/commands/environment.js.map +1 -1
- package/dist/commands/permissions.d.ts.map +1 -1
- package/dist/commands/permissions.js +49 -5
- package/dist/commands/permissions.js.map +1 -1
- package/dist/commands/restart.d.ts.map +1 -1
- package/dist/commands/restart.js +14 -1
- package/dist/commands/restart.js.map +1 -1
- package/dist/commands/stripe.d.ts.map +1 -1
- package/dist/commands/stripe.js +84 -9
- package/dist/commands/stripe.js.map +1 -1
- package/dist/commands/sync.d.ts.map +1 -1
- package/dist/commands/sync.js +16 -1
- package/dist/commands/sync.js.map +1 -1
- package/dist/index.js +39 -5
- package/dist/index.js.map +1 -1
- package/dist/utils/config.d.ts +8 -2
- package/dist/utils/config.d.ts.map +1 -1
- package/dist/utils/config.js +63 -14
- package/dist/utils/config.js.map +1 -1
- package/dist/utils/docker.d.ts.map +1 -1
- package/dist/utils/docker.js +5 -2
- package/dist/utils/docker.js.map +1 -1
- package/docker/docker-compose.base.yml +3 -3
- package/package.json +1 -1
- package/templates/omnibase.toml +0 -3
package/dist/commands/cloud.js
CHANGED
|
@@ -36,6 +36,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
36
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.packageWorkerBundle = packageWorkerBundle;
|
|
40
|
+
exports.resolveBundleEntry = resolveBundleEntry;
|
|
39
41
|
exports.pushEnvConfig = pushEnvConfig;
|
|
40
42
|
exports.addCloudCommands = addCloudCommands;
|
|
41
43
|
const child_process_1 = require("child_process");
|
|
@@ -47,7 +49,6 @@ const TOML = __importStar(require("smol-toml"));
|
|
|
47
49
|
const axios_1 = __importDefault(require("axios"));
|
|
48
50
|
const prompts_1 = require("@inquirer/prompts");
|
|
49
51
|
const path = __importStar(require("path"));
|
|
50
|
-
const dotenv_1 = require("dotenv");
|
|
51
52
|
const environment_1 = require("../utils/environment");
|
|
52
53
|
const credentials_1 = require("../utils/credentials");
|
|
53
54
|
const logger_1 = require("../utils/logger");
|
|
@@ -249,6 +250,8 @@ async function deployWorkers(envFlag, nameFlag, allFlag) {
|
|
|
249
250
|
`Ensure your profile is configured: 'omnibase cloud login'`);
|
|
250
251
|
}
|
|
251
252
|
const deployments = getDeployments(root);
|
|
253
|
+
const config = (0, config_1.loadConfig)(root);
|
|
254
|
+
const secrets = (0, config_1.loadSecretsMap)(root, env.name);
|
|
252
255
|
let targets;
|
|
253
256
|
if (nameFlag) {
|
|
254
257
|
const match = deployments.find((d) => d.name === nameFlag);
|
|
@@ -282,19 +285,20 @@ async function deployWorkers(envFlag, nameFlag, allFlag) {
|
|
|
282
285
|
(0, child_process_1.execSync)("bunx wrangler deploy --dry-run --outdir .bundle", {
|
|
283
286
|
cwd: workersDir,
|
|
284
287
|
stdio: "inherit",
|
|
288
|
+
env: { ...process.env, ...secrets },
|
|
285
289
|
});
|
|
286
290
|
}
|
|
287
291
|
catch (error) {
|
|
288
292
|
logger_1.logger.fail(`Build failed for '${dep.name}'. Check the output above.`);
|
|
289
293
|
continue;
|
|
290
294
|
}
|
|
291
|
-
const bundle = await packageWorkerBundle(workersDir);
|
|
295
|
+
const bundle = await packageWorkerBundle(workersDir, secrets);
|
|
292
296
|
logger_1.logger.succeed(`${dep.name}: packaged (${(bundle.length / 1024).toFixed(1)} KB)`);
|
|
293
297
|
logger_1.logger.start(`Deploying '${dep.name}'...`);
|
|
294
298
|
try {
|
|
295
299
|
const result = await uploadToManagedHosting(env, bundle, dep.name);
|
|
296
300
|
logger_1.logger.succeed(`${dep.name} deployed`);
|
|
297
|
-
logger_1.logger.log(` URL: ${result.url}`);
|
|
301
|
+
logger_1.logger.log(` URL: ${result.data?.url}`);
|
|
298
302
|
}
|
|
299
303
|
catch (error) {
|
|
300
304
|
logger_1.logger.fail(`${dep.name} deploy failed: ${(0, errors_1.formatHttpError)(error)}`);
|
|
@@ -307,13 +311,13 @@ async function deployWorkers(envFlag, nameFlag, allFlag) {
|
|
|
307
311
|
* `wrangler deploy --dispatch-namespace`. Framework-agnostic: everything is
|
|
308
312
|
* derived from the project's own wrangler config.
|
|
309
313
|
*/
|
|
310
|
-
async function packageWorkerBundle(workersDir) {
|
|
311
|
-
const config = await loadWranglerConfig(workersDir);
|
|
314
|
+
async function packageWorkerBundle(workersDir, secrets = {}) {
|
|
315
|
+
const config = (await (0, config_1.interpolateValue)(await loadWranglerConfig(workersDir), secrets));
|
|
312
316
|
delete config.build;
|
|
313
317
|
delete config.name;
|
|
314
|
-
config.main = "
|
|
318
|
+
config.main = await resolveBundleEntry(path.join(workersDir, ".bundle"), config.main);
|
|
315
319
|
const zip = new jszip_1.default();
|
|
316
|
-
await addDirToZip(zip, path.join(workersDir, ".bundle"), (name) => name.endsWith(".map"));
|
|
320
|
+
await addDirToZip(zip, path.join(workersDir, ".bundle"), (name) => name.endsWith(".map") || name === "README.md");
|
|
317
321
|
const assetsDir = config.assets?.directory;
|
|
318
322
|
if (assetsDir) {
|
|
319
323
|
config.assets = { ...config.assets, directory: "assets" };
|
|
@@ -325,6 +329,22 @@ async function packageWorkerBundle(workersDir) {
|
|
|
325
329
|
compression: "DEFLATE",
|
|
326
330
|
});
|
|
327
331
|
}
|
|
332
|
+
async function resolveBundleEntry(bundleDir, configuredMain) {
|
|
333
|
+
const entries = await (0, promises_1.readdir)(bundleDir, { withFileTypes: true });
|
|
334
|
+
const files = entries
|
|
335
|
+
.filter((e) => e.isFile() && !e.name.endsWith(".map"))
|
|
336
|
+
.map((e) => e.name);
|
|
337
|
+
if (configuredMain) {
|
|
338
|
+
const base = path.basename(configuredMain).replace(/\.[^.]+$/, "");
|
|
339
|
+
const match = files.find((f) => path.basename(f).replace(/\.[^.]+$/, "") === base);
|
|
340
|
+
if (match)
|
|
341
|
+
return match;
|
|
342
|
+
}
|
|
343
|
+
const candidates = files.filter((f) => !f.startsWith("chunk-") && /\.(js|mjs)$/.test(f));
|
|
344
|
+
if (candidates.length === 1)
|
|
345
|
+
return candidates[0];
|
|
346
|
+
throw new Error("Could not determine the worker entry module. Check the .bundle output.");
|
|
347
|
+
}
|
|
328
348
|
async function loadWranglerConfig(workersDir) {
|
|
329
349
|
const parsers = {
|
|
330
350
|
"wrangler.jsonc": stripJsonc,
|
|
@@ -430,10 +450,9 @@ async function resolveBranch(managedHostingUrl, projectId, branchFlag) {
|
|
|
430
450
|
* lives, since managed hosting owns Stripe env via the Connect account it
|
|
431
451
|
* provisions per branch.
|
|
432
452
|
*
|
|
433
|
-
* {VAR} secrets resolve from process.env
|
|
434
|
-
* .env.local is NEVER read here — it is strictly for local dev (omnibase start).
|
|
453
|
+
* {VAR} secrets resolve from process.env → omnibase/.env.<branch>.
|
|
435
454
|
*/
|
|
436
|
-
async function pushEnvConfig(envFlag
|
|
455
|
+
async function pushEnvConfig(envFlag) {
|
|
437
456
|
const root = (0, environment_1.findOmnibaseRoot)();
|
|
438
457
|
const env = await (0, environment_1.selectEnvironment)(envFlag);
|
|
439
458
|
if (env.name === "local") {
|
|
@@ -453,23 +472,7 @@ async function pushEnvConfig(envFlag, fromEnvPath) {
|
|
|
453
472
|
if (!config.project_id) {
|
|
454
473
|
throw new Error("project_id is required in omnibase/omnibase.toml for cloud env push.");
|
|
455
474
|
}
|
|
456
|
-
|
|
457
|
-
const secrets = {};
|
|
458
|
-
for (const [k, v] of Object.entries(process.env)) {
|
|
459
|
-
if (v !== undefined)
|
|
460
|
-
secrets[k] = v;
|
|
461
|
-
}
|
|
462
|
-
if (fromEnvPath) {
|
|
463
|
-
const resolvedPath = path.resolve(fromEnvPath);
|
|
464
|
-
const parsed = (0, dotenv_1.config)({ path: resolvedPath }).parsed;
|
|
465
|
-
if (!parsed) {
|
|
466
|
-
throw new Error(`--from-env file not found or empty: ${resolvedPath}`);
|
|
467
|
-
}
|
|
468
|
-
for (const [k, v] of Object.entries(parsed)) {
|
|
469
|
-
if (!(k in secrets))
|
|
470
|
-
secrets[k] = v;
|
|
471
|
-
}
|
|
472
|
-
}
|
|
475
|
+
const secrets = (0, config_1.loadSecretsMap)(root, env.name);
|
|
473
476
|
const resolved = (0, config_1.interpolateValue)(config, secrets);
|
|
474
477
|
if (resolved.versions) {
|
|
475
478
|
(0, config_1.assertValidVersions)(resolved.versions);
|
|
@@ -485,7 +488,7 @@ async function pushEnvConfig(envFlag, fromEnvPath) {
|
|
|
485
488
|
];
|
|
486
489
|
if (unresolved.length > 0) {
|
|
487
490
|
logger_1.logger.warn(`Unresolved ${unresolved.join(", ")} left literal. ` +
|
|
488
|
-
`Set them in process.env or
|
|
491
|
+
`Set them in process.env or omnibase/.env.${env.name}.`);
|
|
489
492
|
}
|
|
490
493
|
logger_1.logger.start(`Applying config (${sections.join(", ")}) to branch ${env.name}...`);
|
|
491
494
|
const api = (0, api_client_1.createManagedHostingClient)(env);
|
|
@@ -651,16 +654,172 @@ async function listWorkers(envFlag) {
|
|
|
651
654
|
throw new Error((0, errors_1.formatHttpError)(error));
|
|
652
655
|
}
|
|
653
656
|
}
|
|
657
|
+
/**
|
|
658
|
+
* Add an account-level custom domain (e.g. example.com or *.example.com)
|
|
659
|
+
*/
|
|
660
|
+
async function domainAdd(envFlag, domain) {
|
|
661
|
+
const env = await (0, environment_1.selectEnvironment)(envFlag);
|
|
662
|
+
const api = (0, api_client_1.createManagedHostingClient)(env);
|
|
663
|
+
logger_1.logger.start(`Adding domain ${domain}...`);
|
|
664
|
+
try {
|
|
665
|
+
const response = await api.post(`/api/v1/domains`, { hostname: domain });
|
|
666
|
+
const d = response.data;
|
|
667
|
+
logger_1.logger.succeed(`Domain ${domain} added (status: ${d.status})`);
|
|
668
|
+
if (d.dcv_record_name && d.dcv_record_value) {
|
|
669
|
+
logger_1.logger.log("Add these DNS records at your domain provider:");
|
|
670
|
+
logger_1.logger.log(` ${d.hostname} CNAME → ${d.cname_target}`);
|
|
671
|
+
logger_1.logger.log(` ${d.dcv_record_name} TXT → ${d.dcv_record_value}`);
|
|
672
|
+
logger_1.logger.log("Then run: omnibase cloud domains status <id>");
|
|
673
|
+
}
|
|
674
|
+
else {
|
|
675
|
+
logger_1.logger.log(`Point ${domain} to ${d.cname_target}`);
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
catch (error) {
|
|
679
|
+
logger_1.logger.fail("Failed to add domain");
|
|
680
|
+
throw new Error((0, errors_1.formatHttpError)(error));
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
/**
|
|
684
|
+
* List account-level domains
|
|
685
|
+
*/
|
|
686
|
+
async function domainList(envFlag) {
|
|
687
|
+
const env = await (0, environment_1.selectEnvironment)(envFlag);
|
|
688
|
+
const api = (0, api_client_1.createManagedHostingClient)(env);
|
|
689
|
+
logger_1.logger.start("Fetching domains...");
|
|
690
|
+
try {
|
|
691
|
+
const response = await api.get(`/api/v1/domains`);
|
|
692
|
+
const domains = response.data;
|
|
693
|
+
logger_1.logger.succeed(`Found ${domains?.length || 0} domain(s)`);
|
|
694
|
+
if (!domains || domains.length === 0)
|
|
695
|
+
return;
|
|
696
|
+
for (const d of domains) {
|
|
697
|
+
logger_1.logger.log(` ${d.hostname} — ${d.status}${d.ssl_status ? ` (ssl: ${d.ssl_status})` : ""}`);
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
catch (error) {
|
|
701
|
+
logger_1.logger.fail("Failed to fetch domains");
|
|
702
|
+
throw new Error((0, errors_1.formatHttpError)(error));
|
|
703
|
+
}
|
|
704
|
+
}
|
|
705
|
+
/**
|
|
706
|
+
* Remove an account-level domain
|
|
707
|
+
*/
|
|
708
|
+
async function domainRemove(envFlag, domainId) {
|
|
709
|
+
const env = await (0, environment_1.selectEnvironment)(envFlag);
|
|
710
|
+
const api = (0, api_client_1.createManagedHostingClient)(env);
|
|
711
|
+
logger_1.logger.start("Removing domain...");
|
|
712
|
+
try {
|
|
713
|
+
await api.delete(`/api/v1/domains/${domainId}`);
|
|
714
|
+
logger_1.logger.succeed("Domain removed");
|
|
715
|
+
}
|
|
716
|
+
catch (error) {
|
|
717
|
+
logger_1.logger.fail("Failed to remove domain");
|
|
718
|
+
throw new Error((0, errors_1.formatHttpError)(error));
|
|
719
|
+
}
|
|
720
|
+
}
|
|
721
|
+
/**
|
|
722
|
+
* Poll the status of an account-level domain until it activates or times out
|
|
723
|
+
*/
|
|
724
|
+
async function domainStatus(envFlag, domainId, pollSeconds) {
|
|
725
|
+
const env = await (0, environment_1.selectEnvironment)(envFlag);
|
|
726
|
+
const api = (0, api_client_1.createManagedHostingClient)(env);
|
|
727
|
+
const deadline = Date.now() + pollSeconds * 1000;
|
|
728
|
+
try {
|
|
729
|
+
while (Date.now() < deadline) {
|
|
730
|
+
const response = await api.get(`/api/v1/domains/${domainId}/status`);
|
|
731
|
+
const d = response.data;
|
|
732
|
+
logger_1.logger.log(` ${d.hostname} — ${d.status}${d.ssl_status ? ` (ssl: ${d.ssl_status})` : ""}`);
|
|
733
|
+
if (d.status === "active") {
|
|
734
|
+
logger_1.logger.succeed(`Domain ${d.hostname} is live`);
|
|
735
|
+
return;
|
|
736
|
+
}
|
|
737
|
+
if (d.dcv_record_name && d.dcv_record_value && d.status !== "active") {
|
|
738
|
+
logger_1.logger.log("DNS records needed:");
|
|
739
|
+
logger_1.logger.log(` ${d.hostname} CNAME → ${d.cname_target}`);
|
|
740
|
+
logger_1.logger.log(` ${d.dcv_record_name} TXT → ${d.dcv_record_value}`);
|
|
741
|
+
logger_1.logger.log("Waiting for DNS + certificate issuance...");
|
|
742
|
+
}
|
|
743
|
+
await new Promise((resolve) => setTimeout(resolve, 5000));
|
|
744
|
+
}
|
|
745
|
+
logger_1.logger.fail("Timed out waiting for domain activation");
|
|
746
|
+
}
|
|
747
|
+
catch (error) {
|
|
748
|
+
logger_1.logger.fail("Failed to check domain status");
|
|
749
|
+
throw new Error((0, errors_1.formatHttpError)(error));
|
|
750
|
+
}
|
|
751
|
+
}
|
|
752
|
+
/**
|
|
753
|
+
* Attach a validated account domain to a worker
|
|
754
|
+
*/
|
|
755
|
+
async function domainAttach(envFlag, domainId, workerName, hostname) {
|
|
756
|
+
const env = await (0, environment_1.selectEnvironment)(envFlag);
|
|
757
|
+
const api = (0, api_client_1.createManagedHostingClient)(env);
|
|
758
|
+
const branchId = env.branchId;
|
|
759
|
+
if (!branchId) {
|
|
760
|
+
throw new Error("No branch selected");
|
|
761
|
+
}
|
|
762
|
+
logger_1.logger.start(`Attaching domain ${domainId} to worker ${workerName}...`);
|
|
763
|
+
try {
|
|
764
|
+
const body = { account_domain_id: domainId };
|
|
765
|
+
if (hostname)
|
|
766
|
+
body.hostname = hostname;
|
|
767
|
+
const response = await api.post(`/api/v1/project_branches/${branchId}/workers/${encodeURIComponent(workerName)}/domains`, body);
|
|
768
|
+
const d = response.data;
|
|
769
|
+
logger_1.logger.succeed(`Domain ${d.hostname} attached (status: ${d.status})`);
|
|
770
|
+
}
|
|
771
|
+
catch (error) {
|
|
772
|
+
logger_1.logger.fail("Failed to attach domain");
|
|
773
|
+
throw new Error((0, errors_1.formatHttpError)(error));
|
|
774
|
+
}
|
|
775
|
+
}
|
|
776
|
+
/**
|
|
777
|
+
* Detach a domain from a worker
|
|
778
|
+
*/
|
|
779
|
+
async function domainDetach(envFlag, domainId) {
|
|
780
|
+
const env = await (0, environment_1.selectEnvironment)(envFlag);
|
|
781
|
+
const api = (0, api_client_1.createManagedHostingClient)(env);
|
|
782
|
+
const branchId = env.branchId;
|
|
783
|
+
if (!branchId) {
|
|
784
|
+
throw new Error("No branch selected");
|
|
785
|
+
}
|
|
786
|
+
logger_1.logger.start("Removing domain from worker...");
|
|
787
|
+
try {
|
|
788
|
+
await api.delete(`/api/v1/project_branches/${branchId}/worker-domains/${domainId}`);
|
|
789
|
+
logger_1.logger.succeed("Domain removed from worker");
|
|
790
|
+
}
|
|
791
|
+
catch (error) {
|
|
792
|
+
logger_1.logger.fail("Failed to remove domain from worker");
|
|
793
|
+
throw new Error((0, errors_1.formatHttpError)(error));
|
|
794
|
+
}
|
|
795
|
+
}
|
|
654
796
|
/**
|
|
655
797
|
* Add cloud commands to the CLI program
|
|
656
798
|
*/
|
|
657
799
|
function addCloudCommands(program) {
|
|
658
800
|
const cloud = program
|
|
659
801
|
.command("cloud")
|
|
660
|
-
.
|
|
802
|
+
.summary("Manage OmniBase Cloud")
|
|
803
|
+
.description("Manage OmniBase Cloud — profile authentication, branch provisioning, " +
|
|
804
|
+
"Cloudflare Workers deployments, custom domains, and environment config.\n\n" +
|
|
805
|
+
"Start with `login` to authenticate with an API key and create a profile, " +
|
|
806
|
+
"then `workers deploy` to ship deployments and `env push` to sync " +
|
|
807
|
+
"omnibase.toml config to a branch.");
|
|
661
808
|
cloud
|
|
662
809
|
.command("login")
|
|
663
|
-
.
|
|
810
|
+
.summary("Authenticate with an API key and save a profile")
|
|
811
|
+
.description("Verify an API key against the managed hosting API and save it as a " +
|
|
812
|
+
"local profile.\n\n" +
|
|
813
|
+
"The profile is named after the tenant and key (or `--name`) and is set " +
|
|
814
|
+
"as active, so subsequent cloud commands use it automatically. " +
|
|
815
|
+
"Authentication is stored in the CLI credentials file, not in the project.\n\n" +
|
|
816
|
+
"Before: obtain an API key from the OmniBase dashboard.\n" +
|
|
817
|
+
"After: a profile is saved and active. Verify with `omnibase cloud profiles`.\n\n" +
|
|
818
|
+
"```bash\n" +
|
|
819
|
+
"omnibase cloud login sk_live_abc123\n" +
|
|
820
|
+
"omnibase cloud login sk_live_abc123 --name staging\n" +
|
|
821
|
+
"omnibase cloud login sk_live_abc123 --url https://api.omnibase.io\n" +
|
|
822
|
+
"```")
|
|
664
823
|
.argument("<api_key>", "API Key")
|
|
665
824
|
.option("--url <url>", "Managed hosting URL")
|
|
666
825
|
.option("--name <name>", "Profile name")
|
|
@@ -669,7 +828,18 @@ function addCloudCommands(program) {
|
|
|
669
828
|
});
|
|
670
829
|
cloud
|
|
671
830
|
.command("logout [profile]")
|
|
672
|
-
.
|
|
831
|
+
.summary("Remove saved authentication profiles")
|
|
832
|
+
.description("Remove one, several, or all saved profiles.\n\n" +
|
|
833
|
+
"With a `[profile]` argument only that profile is removed. Without one, " +
|
|
834
|
+
"an interactive multi-select prompt shows all profiles. `--all` removes " +
|
|
835
|
+
"every profile and clears the active profile.\n\n" +
|
|
836
|
+
"If the active profile is removed, the first remaining profile becomes " +
|
|
837
|
+
"active (or none if the list is empty).\n\n" +
|
|
838
|
+
"```bash\n" +
|
|
839
|
+
"omnibase cloud logout\n" +
|
|
840
|
+
"omnibase cloud logout staging\n" +
|
|
841
|
+
"omnibase cloud logout --all\n" +
|
|
842
|
+
"```")
|
|
673
843
|
.option("--all", "Remove all profiles")
|
|
674
844
|
.action(async (profile, options) => {
|
|
675
845
|
try {
|
|
@@ -686,7 +856,17 @@ function addCloudCommands(program) {
|
|
|
686
856
|
});
|
|
687
857
|
cloud
|
|
688
858
|
.command("switch [profile]")
|
|
689
|
-
.
|
|
859
|
+
.summary("Change the active profile")
|
|
860
|
+
.description("Set which saved profile subsequent cloud commands use.\n\n" +
|
|
861
|
+
"With a `[profile]` argument the profile is switched directly. Without " +
|
|
862
|
+
"one, an interactive select shows all saved profiles with the current " +
|
|
863
|
+
"one marked.\n\n" +
|
|
864
|
+
"Before: at least one profile must exist (see `omnibase cloud login`).\n" +
|
|
865
|
+
"After: cloud commands resolve credentials from the active profile.\n\n" +
|
|
866
|
+
"```bash\n" +
|
|
867
|
+
"omnibase cloud switch\n" +
|
|
868
|
+
"omnibase cloud switch acme-prod\n" +
|
|
869
|
+
"```")
|
|
690
870
|
.action(async (profile) => {
|
|
691
871
|
try {
|
|
692
872
|
await switchProfile(profile);
|
|
@@ -702,17 +882,61 @@ function addCloudCommands(program) {
|
|
|
702
882
|
});
|
|
703
883
|
cloud
|
|
704
884
|
.command("profiles")
|
|
705
|
-
.
|
|
885
|
+
.summary("List saved authentication profiles")
|
|
886
|
+
.description("List every saved profile with its tenant, key name, and key prefix, " +
|
|
887
|
+
"marking the active profile.\n\n" +
|
|
888
|
+
"Before: at least one profile must exist (see `omnibase cloud login`).\n\n" +
|
|
889
|
+
"```bash\n" +
|
|
890
|
+
"omnibase cloud profiles\n" +
|
|
891
|
+
"```")
|
|
706
892
|
.action(async () => {
|
|
707
893
|
await listProfiles();
|
|
708
894
|
});
|
|
709
895
|
// Workers subcommand
|
|
710
896
|
const workers = cloud
|
|
711
897
|
.command("workers")
|
|
712
|
-
.
|
|
898
|
+
.summary("Manage Cloudflare Workers deployments")
|
|
899
|
+
.description("Deploy and inspect the Workers deployments defined in omnibase.toml " +
|
|
900
|
+
"or `omnibase/workers/`.\n\n" +
|
|
901
|
+
"Each deployment maps to a directory (default `omnibase/workers/`) " +
|
|
902
|
+
"containing a `wrangler.toml`, `wrangler.jsonc`, or `wrangler.json`. " +
|
|
903
|
+
"`deploy` ships a deployment to the managed hosting cloud; `list` shows " +
|
|
904
|
+
"what is currently deployed for a branch.");
|
|
713
905
|
workers
|
|
714
906
|
.command("deploy")
|
|
715
|
-
.
|
|
907
|
+
.summary("Deploy workers to Cloudflare via managed hosting")
|
|
908
|
+
.description("Build, package, and upload one or more Workers deployments for the " +
|
|
909
|
+
"selected cloud branch.\n\n" +
|
|
910
|
+
"End-to-end flow:\n" +
|
|
911
|
+
"1. Resolve the target environment (`--env` or interactive picker).\n" +
|
|
912
|
+
"2. Load the resolved secrets for that branch (see env resolution below).\n" +
|
|
913
|
+
"3. Run `bunx wrangler deploy --dry-run --outdir .bundle` in the " +
|
|
914
|
+
" deployment directory with the resolved env exported. If the wrangler " +
|
|
915
|
+
" config declares a `build.command`, wrangler runs it first, so the app " +
|
|
916
|
+
" is built as part of the deploy; the result is a production bundle.\n" +
|
|
917
|
+
"4. Package the bundle plus any `[assets]` into a self-contained zip, " +
|
|
918
|
+
" with the deployment's `wrangler.json` `[vars]` interpolated at " +
|
|
919
|
+
" package time.\n" +
|
|
920
|
+
"5. Upload the bundle to managed hosting, which runs " +
|
|
921
|
+
" `wrangler deploy --dispatch-namespace` and returns the live URL.\n\n" +
|
|
922
|
+
"By default a single-deployment project deploys it directly; with " +
|
|
923
|
+
"multiple deployments you are prompted to select one. `--name` picks a " +
|
|
924
|
+
"specific deployment by name and `--all` deploys every deployment.\n\n" +
|
|
925
|
+
"Before: the branch must be provisioned (has a branch ID) and a profile " +
|
|
926
|
+
"must be configured (`omnibase cloud login`). Deployments must exist in " +
|
|
927
|
+
"omnibase.toml or `omnibase/workers/`. Cloud environments are required — " +
|
|
928
|
+
"deploying to `local` is not supported.\n\n" +
|
|
929
|
+
"Environment variables: `{VAR}` references in the wrangler `[vars]` " +
|
|
930
|
+
"resolve from the branch env file. See the env resolution model on the " +
|
|
931
|
+
"[`cloud env`](/reference/cli/cloud/env) page.\n\n" +
|
|
932
|
+
"Caveats: values in `[vars]` are visible in the deployed worker — put " +
|
|
933
|
+
"secrets in `wrangler secret` or the managed-hosting secrets API, not in " +
|
|
934
|
+
"`[vars]`. Unresolved `{VAR}` values are left literal and the CLI warns.\n\n" +
|
|
935
|
+
"```bash\n" +
|
|
936
|
+
"omnibase cloud workers deploy --env dev\n" +
|
|
937
|
+
"omnibase cloud workers deploy --env staging --name api\n" +
|
|
938
|
+
"omnibase cloud workers deploy --env production --all\n" +
|
|
939
|
+
"```")
|
|
716
940
|
.option("--name <name>", "Deploy a specific deployment by name")
|
|
717
941
|
.option("--all", "Deploy all deployments")
|
|
718
942
|
.action(async (cmdOptions) => {
|
|
@@ -726,7 +950,13 @@ function addCloudCommands(program) {
|
|
|
726
950
|
});
|
|
727
951
|
workers
|
|
728
952
|
.command("list")
|
|
729
|
-
.
|
|
953
|
+
.summary("List deployed workers for a branch")
|
|
954
|
+
.description("List the workers currently deployed for the selected branch, including " +
|
|
955
|
+
"their public URLs.\n\n" +
|
|
956
|
+
"Before: a profile must be configured and the branch must be provisioned.\n\n" +
|
|
957
|
+
"```bash\n" +
|
|
958
|
+
"omnibase cloud workers list --env dev\n" +
|
|
959
|
+
"```")
|
|
730
960
|
.action(async () => {
|
|
731
961
|
try {
|
|
732
962
|
const globalOptions = program.opts();
|
|
@@ -736,13 +966,156 @@ function addCloudCommands(program) {
|
|
|
736
966
|
await (0, errors_1.handleCommandError)(error);
|
|
737
967
|
}
|
|
738
968
|
});
|
|
969
|
+
const domains = cloud
|
|
970
|
+
.command("domains")
|
|
971
|
+
.summary("Manage account-level custom domains")
|
|
972
|
+
.description("Add, validate, and attach custom domains (e.g. `example.com` or " +
|
|
973
|
+
"`*.example.com`) to workers.\n\n" +
|
|
974
|
+
"Domains are account-level: add one, point your DNS records at it, " +
|
|
975
|
+
"wait for activation with `status`, then attach it to a worker with " +
|
|
976
|
+
"`attach`.");
|
|
977
|
+
domains
|
|
978
|
+
.command("add <domain>")
|
|
979
|
+
.summary("Add a custom domain")
|
|
980
|
+
.description("Add an account-level custom domain, for example `example.com` or " +
|
|
981
|
+
"`*.example.com`.\n\n" +
|
|
982
|
+
"The response includes the CNAME target and, when required, a TXT " +
|
|
983
|
+
"DCV record. Add these at your DNS provider, then poll with " +
|
|
984
|
+
"`omnibase cloud domains status <id>` until the domain is active.\n\n" +
|
|
985
|
+
"Before: a profile and a provisioned branch must be configured.\n\n" +
|
|
986
|
+
"```bash\n" +
|
|
987
|
+
"omnibase cloud domains add example.com --env dev\n" +
|
|
988
|
+
"omnibase cloud domains add '*.example.com' --env dev\n" +
|
|
989
|
+
"```")
|
|
990
|
+
.action(async (domain, cmdOptions) => {
|
|
991
|
+
try {
|
|
992
|
+
const globalOptions = program.opts();
|
|
993
|
+
await domainAdd(globalOptions.env, domain);
|
|
994
|
+
}
|
|
995
|
+
catch (error) {
|
|
996
|
+
await (0, errors_1.handleCommandError)(error);
|
|
997
|
+
}
|
|
998
|
+
});
|
|
999
|
+
domains
|
|
1000
|
+
.command("list")
|
|
1001
|
+
.summary("List account-level custom domains")
|
|
1002
|
+
.description("List every account-level domain with its status and SSL status.\n\n" +
|
|
1003
|
+
"```bash\n" +
|
|
1004
|
+
"omnibase cloud domains list --env dev\n" +
|
|
1005
|
+
"```")
|
|
1006
|
+
.action(async () => {
|
|
1007
|
+
try {
|
|
1008
|
+
const globalOptions = program.opts();
|
|
1009
|
+
await domainList(globalOptions.env);
|
|
1010
|
+
}
|
|
1011
|
+
catch (error) {
|
|
1012
|
+
await (0, errors_1.handleCommandError)(error);
|
|
1013
|
+
}
|
|
1014
|
+
});
|
|
1015
|
+
domains
|
|
1016
|
+
.command("rm <domain-id>")
|
|
1017
|
+
.summary("Remove a custom domain")
|
|
1018
|
+
.description("Remove a custom domain by ID and detach it from all workers.\n\n" +
|
|
1019
|
+
"Use `omnibase cloud domains list` to find the domain ID.\n\n" +
|
|
1020
|
+
"```bash\n" +
|
|
1021
|
+
"omnibase cloud domains list --env dev\n" +
|
|
1022
|
+
"omnibase cloud domains rm dom_123 --env dev\n" +
|
|
1023
|
+
"```")
|
|
1024
|
+
.action(async (domainId, cmdOptions) => {
|
|
1025
|
+
try {
|
|
1026
|
+
const globalOptions = program.opts();
|
|
1027
|
+
await domainRemove(globalOptions.env, domainId);
|
|
1028
|
+
}
|
|
1029
|
+
catch (error) {
|
|
1030
|
+
await (0, errors_1.handleCommandError)(error);
|
|
1031
|
+
}
|
|
1032
|
+
});
|
|
1033
|
+
domains
|
|
1034
|
+
.command("status <domain-id>")
|
|
1035
|
+
.summary("Poll domain status until active")
|
|
1036
|
+
.description("Poll the status of a custom domain until it activates or the timeout " +
|
|
1037
|
+
"elapses (default 120s).\n\n" +
|
|
1038
|
+
"While DNS and certificate issuance are pending it prints the records " +
|
|
1039
|
+
"still needed; it exits successfully as soon as the domain is live.\n\n" +
|
|
1040
|
+
"Before: the domain must exist (see `omnibase cloud domains add`).\n\n" +
|
|
1041
|
+
"```bash\n" +
|
|
1042
|
+
"omnibase cloud domains status dom_123 --env dev\n" +
|
|
1043
|
+
"omnibase cloud domains status dom_123 --timeout 300 --env dev\n" +
|
|
1044
|
+
"```")
|
|
1045
|
+
.option("--timeout <seconds>", "Poll timeout in seconds", "120")
|
|
1046
|
+
.action(async (domainId, cmdOptions) => {
|
|
1047
|
+
try {
|
|
1048
|
+
const globalOptions = program.opts();
|
|
1049
|
+
await domainStatus(globalOptions.env, domainId, parseInt(cmdOptions.timeout, 10));
|
|
1050
|
+
}
|
|
1051
|
+
catch (error) {
|
|
1052
|
+
await (0, errors_1.handleCommandError)(error);
|
|
1053
|
+
}
|
|
1054
|
+
});
|
|
1055
|
+
domains
|
|
1056
|
+
.command("attach <domain-id>")
|
|
1057
|
+
.summary("Attach a validated domain to a worker")
|
|
1058
|
+
.description("Attach an activated account-level domain to a worker on the current " +
|
|
1059
|
+
"branch.\n\n" +
|
|
1060
|
+
"`--worker` is required and names the deployment (matching the name in " +
|
|
1061
|
+
"omnibase.toml or `omnibase/workers/`). For wildcard domains use " +
|
|
1062
|
+
"`--hostname` to choose the concrete hostname to route.\n\n" +
|
|
1063
|
+
"Before: the domain must be active (see `omnibase cloud domains status`).\n\n" +
|
|
1064
|
+
"```bash\n" +
|
|
1065
|
+
"omnibase cloud domains attach dom_123 --worker api --env dev\n" +
|
|
1066
|
+
"omnibase cloud domains attach dom_123 --worker api --hostname www.example.com --env dev\n" +
|
|
1067
|
+
"```")
|
|
1068
|
+
.requiredOption("--worker <name>", "Worker deployment name")
|
|
1069
|
+
.option("--hostname <hostname>", "Concrete hostname to route (required for wildcard domains)")
|
|
1070
|
+
.action(async (domainId, cmdOptions) => {
|
|
1071
|
+
try {
|
|
1072
|
+
const globalOptions = program.opts();
|
|
1073
|
+
await domainAttach(globalOptions.env, domainId, cmdOptions.worker, cmdOptions.hostname);
|
|
1074
|
+
}
|
|
1075
|
+
catch (error) {
|
|
1076
|
+
await (0, errors_1.handleCommandError)(error);
|
|
1077
|
+
}
|
|
1078
|
+
});
|
|
1079
|
+
domains
|
|
1080
|
+
.command("detach <domain-id>")
|
|
1081
|
+
.summary("Detach a domain from a worker")
|
|
1082
|
+
.description("Detach a domain from the current branch's worker. The account-level " +
|
|
1083
|
+
"domain itself is kept.\n\n" +
|
|
1084
|
+
"```bash\n" +
|
|
1085
|
+
"omnibase cloud domains detach dom_123 --env dev\n" +
|
|
1086
|
+
"```")
|
|
1087
|
+
.action(async (domainId, cmdOptions) => {
|
|
1088
|
+
try {
|
|
1089
|
+
const globalOptions = program.opts();
|
|
1090
|
+
await domainDetach(globalOptions.env, domainId);
|
|
1091
|
+
}
|
|
1092
|
+
catch (error) {
|
|
1093
|
+
await (0, errors_1.handleCommandError)(error);
|
|
1094
|
+
}
|
|
1095
|
+
});
|
|
739
1096
|
// Branch subcommand
|
|
740
1097
|
const branch = cloud
|
|
741
1098
|
.command("branch")
|
|
742
|
-
.
|
|
1099
|
+
.summary("Manage project branches")
|
|
1100
|
+
.description("Provision, list, and deprovision project branches.\n\n" +
|
|
1101
|
+
"Each branch is an isolated environment with its own database, API, " +
|
|
1102
|
+
"permissions, and workers. Use `new` to provision one, then reference " +
|
|
1103
|
+
"it with `--env <branch>` on other cloud commands.");
|
|
743
1104
|
branch
|
|
744
1105
|
.command("new")
|
|
745
|
-
.
|
|
1106
|
+
.summary("Create a new project branch")
|
|
1107
|
+
.description("Provision a new branch (environment) for the project.\n\n" +
|
|
1108
|
+
"The project ID comes from `--project-id` or the `project_id` in " +
|
|
1109
|
+
"omnibase.toml, and is prompted for if neither is set. Region and tier " +
|
|
1110
|
+
"default to a picker fed by the managed hosting options endpoint " +
|
|
1111
|
+
"(falling back to `syd` / `shared` prompts). A billing email is " +
|
|
1112
|
+
"required.\n\n" +
|
|
1113
|
+
"After: provisioning starts asynchronously. Once complete, use the " +
|
|
1114
|
+
"branch with `--env <branch>` on other commands.\n\n" +
|
|
1115
|
+
"```bash\n" +
|
|
1116
|
+
"omnibase cloud branch new --name staging\n" +
|
|
1117
|
+
"omnibase cloud branch new --project-id proj_123 --name dev --region syd --tier shared\n" +
|
|
1118
|
+
"```")
|
|
746
1119
|
.option("--project-id <id>", "Project ID")
|
|
747
1120
|
.option("--name <name>", "Branch name")
|
|
748
1121
|
.option("--region <region>", "Region (e.g. syd)")
|
|
@@ -758,7 +1131,14 @@ function addCloudCommands(program) {
|
|
|
758
1131
|
});
|
|
759
1132
|
branch
|
|
760
1133
|
.command("list")
|
|
761
|
-
.
|
|
1134
|
+
.summary("List project branches")
|
|
1135
|
+
.description("List all branches for the project with their status and API URL.\n\n" +
|
|
1136
|
+
"Before: a profile must be configured and `project_id` must be set in " +
|
|
1137
|
+
"omnibase.toml (or passed with `--project-id`).\n\n" +
|
|
1138
|
+
"```bash\n" +
|
|
1139
|
+
"omnibase cloud branch list\n" +
|
|
1140
|
+
"omnibase cloud branch list --project-id proj_123\n" +
|
|
1141
|
+
"```")
|
|
762
1142
|
.option("--project-id <id>", "Project ID")
|
|
763
1143
|
.action(async (cmdOptions) => {
|
|
764
1144
|
try {
|
|
@@ -770,7 +1150,15 @@ function addCloudCommands(program) {
|
|
|
770
1150
|
});
|
|
771
1151
|
branch
|
|
772
1152
|
.command("rm <branch>")
|
|
773
|
-
.
|
|
1153
|
+
.summary("Delete a project branch")
|
|
1154
|
+
.description("Delete a branch by name, slug, or ID. The branch is resolved against " +
|
|
1155
|
+
"the project's branch list, then deprovisioning is started.\n\n" +
|
|
1156
|
+
"This is destructive — the branch's database, workers, and services are " +
|
|
1157
|
+
"deprovisioned.\n\n" +
|
|
1158
|
+
"```bash\n" +
|
|
1159
|
+
"omnibase cloud branch rm staging\n" +
|
|
1160
|
+
"omnibase cloud branch rm br_123 --project-id proj_123\n" +
|
|
1161
|
+
"```")
|
|
774
1162
|
.option("--project-id <id>", "Project ID")
|
|
775
1163
|
.action(async (branchRef, cmdOptions) => {
|
|
776
1164
|
try {
|
|
@@ -783,15 +1171,50 @@ function addCloudCommands(program) {
|
|
|
783
1171
|
// Environment subcommand
|
|
784
1172
|
const envCmd = cloud
|
|
785
1173
|
.command("env")
|
|
786
|
-
.
|
|
1174
|
+
.summary("Manage environment configuration")
|
|
1175
|
+
.description("Push configuration to a cloud branch and resolve per-environment " +
|
|
1176
|
+
"variables.\n\n" +
|
|
1177
|
+
"**Environment variable injection**\n\n" +
|
|
1178
|
+
"Several commands resolve `{VAR}` references in your configuration " +
|
|
1179
|
+
"(e.g. `website_url = \"{PUBLIC_WEBSITE_URL}\"`) from a two-layer " +
|
|
1180
|
+
"model:\n\n" +
|
|
1181
|
+
"- **omnibase/omnibase.toml** (committed) — the structure, with `{VAR}` " +
|
|
1182
|
+
"references for per-environment values.\n" +
|
|
1183
|
+
"- **omnibase/.env.<branch>** (gitignored) — flat `KEY=VALUE`, one file " +
|
|
1184
|
+
"per branch/environment (`.env.local` for local dev).\n\n" +
|
|
1185
|
+
"Resolution order, per key, first non-empty wins:\n" +
|
|
1186
|
+
"`process.env` → `omnibase/.env.<branch>` (from `--env` or the " +
|
|
1187
|
+
"interactive picker) → the literal `{VAR}` left in place.\n\n" +
|
|
1188
|
+
"This drives `cloud workers deploy` (wrangler build env + packaged " +
|
|
1189
|
+
"`[vars]`), `cloud env push` (interpolation of the cloud config " +
|
|
1190
|
+
"sections), and `omnibase start` (control-plane env + dev-server spawns).\n\n" +
|
|
1191
|
+
"Caveats: unresolved `{VAR}` values are left literal and the CLI warns; " +
|
|
1192
|
+
"secrets belong in the managed-hosting secrets API or `wrangler secret`, " +
|
|
1193
|
+
"never in `[vars]` (vars are visible in the deployed worker).");
|
|
787
1194
|
envCmd
|
|
788
1195
|
.command("push")
|
|
789
|
-
.
|
|
790
|
-
.
|
|
1196
|
+
.summary("Push omnibase.toml config to managed hosting")
|
|
1197
|
+
.description("Push the cloud-relevant sections of omnibase.toml to the selected " +
|
|
1198
|
+
"branch, interpolating `{VAR}` references first.\n\n" +
|
|
1199
|
+
"Everything except `[local]`, `project_id`, and `deployments` is sent; " +
|
|
1200
|
+
"managed hosting applies what it understands and reports the rest. " +
|
|
1201
|
+
"`[local]` stays on this machine — that is where Stripe lives, since " +
|
|
1202
|
+
"managed hosting owns Stripe env via the Connect account it provisions " +
|
|
1203
|
+
"per branch. `[versions]` keys are validated before push.\n\n" +
|
|
1204
|
+
"Before: `project_id` must be set in omnibase.toml, a profile must be " +
|
|
1205
|
+
"configured, and the branch must be provisioned. Pushing to `local` is " +
|
|
1206
|
+
"not supported.\n\n" +
|
|
1207
|
+
"After: the branch reports which sections were applied and which were " +
|
|
1208
|
+
"ignored. Unresolved `{VAR}` values are warned about and left literal.\n\n" +
|
|
1209
|
+
"See the env resolution model on the [`cloud env`](/reference/cli/cloud/env) page.\n\n" +
|
|
1210
|
+
"```bash\n" +
|
|
1211
|
+
"omnibase cloud env push --env dev\n" +
|
|
1212
|
+
"omnibase cloud env push --env staging\n" +
|
|
1213
|
+
"```")
|
|
791
1214
|
.action(async (cmdOptions) => {
|
|
792
1215
|
try {
|
|
793
1216
|
const globalOptions = program.opts();
|
|
794
|
-
await pushEnvConfig(globalOptions.env
|
|
1217
|
+
await pushEnvConfig(globalOptions.env);
|
|
795
1218
|
}
|
|
796
1219
|
catch (error) {
|
|
797
1220
|
await (0, errors_1.handleCommandError)(error);
|