@omg-dev/cli 0.4.32 → 0.4.33

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.
Files changed (2) hide show
  1. package/dist/omg.mjs +65 -0
  2. package/package.json +1 -1
package/dist/omg.mjs CHANGED
@@ -446,6 +446,15 @@ function getStatus(token, slug) {
446
446
  function listApps(token) {
447
447
  return controlPlane("/api/cli/apps/list", token);
448
448
  }
449
+ function getVisibility(token, slug) {
450
+ return controlPlane(`/api/cli/apps/visibility?slug=${encodeURIComponent(slug)}`, token);
451
+ }
452
+ function setVisibility(token, slug, visibility) {
453
+ return controlPlane("/api/cli/apps/visibility", token, {
454
+ method: "POST",
455
+ body: JSON.stringify({ slug, visibility })
456
+ });
457
+ }
449
458
  function envList(token, slug) {
450
459
  return controlPlane(`/api/cli/env/list?slug=${encodeURIComponent(slug)}`, token);
451
460
  }
@@ -1469,6 +1478,51 @@ async function runEnv(opts) {
1469
1478
  }
1470
1479
  }
1471
1480
 
1481
+ // src/visibility.ts
1482
+ var PUBLIC = "public";
1483
+ var OMG_USERS = "omg-users";
1484
+ function parseVisibility(arg) {
1485
+ const v = arg.trim().toLowerCase();
1486
+ if (v === PUBLIC || v === "anyone" || v === "open")
1487
+ return PUBLIC;
1488
+ if (v === OMG_USERS || v === "omg" || v === "users" || v === "private")
1489
+ return OMG_USERS;
1490
+ return null;
1491
+ }
1492
+ function describeVisibility(v) {
1493
+ return v === PUBLIC ? "public \u2014 anyone with the link" : "omg-users \u2014 any signed-in omg user";
1494
+ }
1495
+ async function runVisibility(opts) {
1496
+ const { args, slug, token, out } = opts;
1497
+ const target = args[0];
1498
+ if (!target) {
1499
+ const { visibility: visibility2, published } = await getVisibility(token, slug);
1500
+ out(`${slug}: ${describeVisibility(visibility2)}`);
1501
+ if (!published) {
1502
+ out("");
1503
+ out("Not published yet \u2014 run `omg deploy` first.");
1504
+ } else if (visibility2 === OMG_USERS) {
1505
+ out("");
1506
+ out("Non-browser clients (mobile apps, webhooks) will be redirected to sign in.");
1507
+ out("Run `omg visibility public` to serve anyone with the link.");
1508
+ }
1509
+ return 0;
1510
+ }
1511
+ const next = parseVisibility(target);
1512
+ if (!next) {
1513
+ out(`Unknown visibility "${target}".`);
1514
+ out("");
1515
+ out(" omg visibility public anyone with the link");
1516
+ out(" omg visibility omg-users any signed-in omg user (default)");
1517
+ return 1;
1518
+ }
1519
+ const { visibility } = await setVisibility(token, slug, next);
1520
+ out(`${slug}: ${describeVisibility(visibility)}`);
1521
+ out("");
1522
+ out("Live now \u2014 the gate is enforced at the edge, no redeploy needed.");
1523
+ return 0;
1524
+ }
1525
+
1472
1526
  // src/index.ts
1473
1527
  var argv = process.argv.slice(2);
1474
1528
  var cmd = argv[0] ?? "help";
@@ -1503,6 +1557,7 @@ var HELP = `omg \u2014 deploy a local project to omg.dev
1503
1557
  omg env rm KEY [KEY2 ...] remove
1504
1558
  omg env pull [--out .env] [--force] write real values locally
1505
1559
  omg env push [--file .env] import a local .env
1560
+ omg visibility [public|omg-users] the published app's access gate
1506
1561
  omg link <slug> [--dir <path>]
1507
1562
  omg login [--token <omg_sk_...>]
1508
1563
  omg logout
@@ -1612,6 +1667,16 @@ async function main() {
1612
1667
  }
1613
1668
  return runEnv({ args: argv.slice(1), slug: link.slug, token, root, flag, out });
1614
1669
  }
1670
+ case "visibility":
1671
+ case "access": {
1672
+ const token = await requireToken();
1673
+ const link = readLink(root);
1674
+ if (!link?.slug) {
1675
+ out("Not linked to an app. Run `omg deploy` or `omg link <slug>` first.");
1676
+ return 1;
1677
+ }
1678
+ return runVisibility({ args: argv.slice(1), slug: link.slug, token, out });
1679
+ }
1615
1680
  case "deploy": {
1616
1681
  const token = await requireToken();
1617
1682
  const link = readLink(root);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@omg-dev/cli",
3
- "version": "0.4.32",
3
+ "version": "0.4.33",
4
4
  "description": "Deploy and develop omg apps from your terminal.",
5
5
  "type": "module",
6
6
  "bin": {