runcloud 0.2.148 → 0.2.150

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.
@@ -2,6 +2,11 @@ import { stdin as input, stdout as output } from 'node:process';
2
2
  import { createInterface } from 'node:readline/promises';
3
3
  import { ApiClient, friendlyApiError } from '../api.js';
4
4
  import { requireCredentials, resolveProject } from '../config.js';
5
+ export function renderPendingRegistration(order) {
6
+ const action = `run \`newly domains connect-registered ${order.domain}\``;
7
+ const base = `${order.domain} ${order.status} (not connected) — ${action}`;
8
+ return order.error_message ? `${base} (error: ${order.error_message})` : base;
9
+ }
5
10
  function makeClient(project) {
6
11
  const creds = requireCredentials();
7
12
  return {
@@ -76,6 +81,9 @@ export async function runDomainList(client, projectId, log = console.log) {
76
81
  const result = (await client.get(`/projects/${projectId}/domains`));
77
82
  const projectDomains = result.domains ?? [];
78
83
  log(projectDomains.length ? projectDomains.map(renderProjectDomain).join('\n') : 'No domains.');
84
+ const pending = result.pending_registrations ?? [];
85
+ if (pending.length)
86
+ log(pending.map(renderPendingRegistration).join('\n'));
79
87
  }
80
88
  export async function runDomainConnect(client, projectId, hostname, opts, log = console.log) {
81
89
  const result = await client.post(`/projects/${projectId}/domains/connect`, {
@@ -86,12 +94,26 @@ export async function runDomainConnect(client, projectId, hostname, opts, log =
86
94
  log(renderProjectDomain(result.domain));
87
95
  log(JSON.stringify(result.dns_instructions, null, 2));
88
96
  }
97
+ export async function runDomainConnectRegistered(client, projectId, hostname, log = console.log) {
98
+ const result = await client.post(`/projects/${projectId}/domains/connect-registered`, {
99
+ hostname,
100
+ });
101
+ log(renderProjectDomain(result.domain));
102
+ log(JSON.stringify(result.dns_instructions, null, 2));
103
+ }
89
104
  export async function runDomainStatus(client, projectId, hostnameOrId, log = console.log) {
90
105
  const list = (await client.get(`/projects/${projectId}/domains`));
91
106
  const projectDomains = list.domains ?? [];
92
107
  const domain = hostnameOrId
93
108
  ? projectDomains.find((item) => item.id === hostnameOrId || item.hostname === hostnameOrId)
94
109
  : projectDomains[0];
110
+ if (!domain && hostnameOrId) {
111
+ const pending = (list.pending_registrations ?? []).find((order) => order.domain === hostnameOrId);
112
+ if (pending) {
113
+ log(renderPendingRegistration(pending));
114
+ return;
115
+ }
116
+ }
95
117
  if (!domain)
96
118
  throw new Error('Domain not found.');
97
119
  const refreshed = await client.post(`/projects/${projectId}/domains/${domain.id}/refresh`, {});
@@ -184,6 +206,21 @@ export function registerDomains(program) {
184
206
  process.exitCode = 1;
185
207
  }
186
208
  });
209
+ domains
210
+ .command('connect-registered')
211
+ .argument('<hostname>')
212
+ .option('--project <id>', 'project id (defaults to the linked directory)')
213
+ .description('Connect a domain Newly already registered for this project to the published website (retries the automatic connect)')
214
+ .action(async (hostname, opts) => {
215
+ try {
216
+ const { client, projectId } = makeClient(opts.project);
217
+ await runDomainConnectRegistered(client, projectId, hostname);
218
+ }
219
+ catch (e) {
220
+ console.error(friendlyApiError(e));
221
+ process.exitCode = 1;
222
+ }
223
+ });
187
224
  domains
188
225
  .command('status')
189
226
  .argument('[hostname-or-id]')
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const CLI_VERSION = '0.2.148';
1
+ export const CLI_VERSION = '0.2.150';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "runcloud",
3
- "version": "0.2.148",
3
+ "version": "0.2.150",
4
4
  "description": "Create and control run.cloud remote mobile simulators and cloud sandboxes",
5
5
  "license": "Apache-2.0",
6
6
  "keywords": [
Binary file
Binary file