run402 1.9.2 → 1.10.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/lib/deploy.mjs CHANGED
@@ -15,7 +15,7 @@ Manifest format (JSON):
15
15
  {
16
16
  "name": "my-app",
17
17
  "migrations": "CREATE TABLE items ...",
18
- "site": [{ "file": "index.html", "data": "<html>...</html>" }],
18
+ "files": [{ "file": "index.html", "data": "<html>...</html>" }],
19
19
  "subdomain": "my-app"
20
20
  }
21
21
 
package/lib/init.mjs CHANGED
@@ -71,6 +71,7 @@ export async function run() {
71
71
  }
72
72
 
73
73
  // 4. Tier status
74
+ const store = loadKeyStore();
74
75
  let tierInfo = null;
75
76
  try {
76
77
  const { privateKeyToAccount } = await import("viem/accounts");
@@ -83,6 +84,13 @@ export async function run() {
83
84
  if (res.ok) tierInfo = await res.json();
84
85
  } catch {}
85
86
 
87
+ // Fall back to keystore if the API call failed or returned no tier
88
+ if (!tierInfo || !tierInfo.tier) {
89
+ const projects = Object.values(store.projects);
90
+ const active = projects.find(p => p.tier && p.lease_expires_at && new Date(p.lease_expires_at) > new Date());
91
+ if (active) tierInfo = { tier: active.tier, status: "active", lease_expires_at: active.lease_expires_at };
92
+ }
93
+
86
94
  if (tierInfo && tierInfo.tier && tierInfo.status === "active") {
87
95
  const expiry = tierInfo.lease_expires_at ? tierInfo.lease_expires_at.split("T")[0] : "unknown";
88
96
  line("Tier", `${tierInfo.tier} (expires ${expiry})`);
@@ -91,7 +99,6 @@ export async function run() {
91
99
  }
92
100
 
93
101
  // 5. Projects
94
- const store = loadKeyStore();
95
102
  line("Projects", `${Object.keys(store.projects).length} active`);
96
103
 
97
104
  // 6. Next step
package/lib/projects.mjs CHANGED
@@ -9,6 +9,7 @@ Subcommands:
9
9
  quote Show pricing tiers
10
10
  provision [--tier <tier>] [--name <n>] Provision a new Postgres project (pays via x402)
11
11
  list List all your projects (IDs, tiers, URLs, expiry)
12
+ info <id> Show project details: REST URL, keys, expiry
12
13
  sql <id> "<query>" Run a SQL query against a project's Postgres DB
13
14
  rest <id> <table> [params] Query a table via the REST API (PostgREST)
14
15
  usage <id> Show compute/storage usage for a project
@@ -21,6 +22,7 @@ Examples:
21
22
  run402 projects provision --tier prototype
22
23
  run402 projects provision --tier hobby --name my-app
23
24
  run402 projects list
25
+ run402 projects info abc123
24
26
  run402 projects sql abc123 "SELECT * FROM users LIMIT 5"
25
27
  run402 projects rest abc123 users "limit=10&select=id,name"
26
28
  run402 projects usage abc123
@@ -89,6 +91,22 @@ async function list() {
89
91
  console.log(JSON.stringify(entries.map(([id, p]) => ({ project_id: id, tier: p.tier, site_url: p.site_url, lease_expires_at: p.lease_expires_at, deployed_at: p.deployed_at })), null, 2));
90
92
  }
91
93
 
94
+ async function info(projectId) {
95
+ const p = findProject(projectId);
96
+ const active = p.lease_expires_at ? new Date(p.lease_expires_at) > new Date() : null;
97
+ console.log(JSON.stringify({
98
+ project_id: projectId,
99
+ tier: p.tier,
100
+ active,
101
+ lease_expires_at: p.lease_expires_at,
102
+ rest_url: `${API}/rest/v1`,
103
+ anon_key: p.anon_key,
104
+ service_key: p.service_key,
105
+ site_url: p.site_url || null,
106
+ deployed_at: p.deployed_at || null,
107
+ }, null, 2));
108
+ }
109
+
92
110
  async function sqlCmd(projectId, query) {
93
111
  const p = findProject(projectId);
94
112
  const res = await fetch(`${API}/projects/v1/admin/${projectId}/sql`, { method: "POST", headers: { "Authorization": `Bearer ${p.service_key}`, "Content-Type": "text/plain" }, body: query });
@@ -138,6 +156,7 @@ export async function run(sub, args) {
138
156
  case "quote": await quote(); break;
139
157
  case "provision": await provision(args); break;
140
158
  case "list": await list(); break;
159
+ case "info": await info(args[0]); break;
141
160
  case "sql": await sqlCmd(args[0], args[1]); break;
142
161
  case "rest": await rest(args[0], args[1], args[2]); break;
143
162
  case "usage": await usage(args[0]); break;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "run402",
3
- "version": "1.9.2",
3
+ "version": "1.10.1",
4
4
  "description": "CLI for Run402 — provision Postgres databases, deploy static sites, generate images, and manage wallets via x402 micropayments.",
5
5
  "type": "module",
6
6
  "bin": {