@blocklive/cli 0.0.0-stage → 0.7.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/LICENSE +3 -0
- package/README.md +202 -2
- package/dist/browser.js +194 -0
- package/dist/catalog.js +1016 -0
- package/dist/change.js +181 -0
- package/dist/cli.js +1176 -0
- package/dist/config.js +105 -0
- package/dist/csv.js +76 -0
- package/dist/errors.js +75 -0
- package/dist/http.js +189 -0
- package/dist/idempotency.js +39 -0
- package/dist/image-file.js +95 -0
- package/dist/lock.js +186 -0
- package/dist/login.js +203 -0
- package/dist/main.js +49 -0
- package/dist/read.js +155 -0
- package/dist/reads/developer-request.js +31 -0
- package/dist/reads/developers.js +53 -0
- package/dist/reads/domains.js +84 -0
- package/dist/reads/events.js +956 -0
- package/dist/reads/index.js +47 -0
- package/dist/reads/invoices.js +177 -0
- package/dist/reads/payment-account.js +177 -0
- package/dist/reads/places.js +55 -0
- package/dist/reads/promo-import.js +183 -0
- package/dist/reads/promos.js +62 -0
- package/dist/reads/requests.js +119 -0
- package/dist/reads/tickets.js +386 -0
- package/dist/safe.js +88 -0
- package/dist/secrets.js +267 -0
- package/dist/stdin.js +72 -0
- package/dist/style.js +44 -0
- package/dist/unattended.js +311 -0
- package/package.json +30 -5
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.claimDomain = exports.listDomains = void 0;
|
|
4
|
+
const errors_1 = require("../errors");
|
|
5
|
+
const read_1 = require("../read");
|
|
6
|
+
const requests_1 = require("./requests");
|
|
7
|
+
function status(d) {
|
|
8
|
+
if (d.held)
|
|
9
|
+
return 'held for Blocklive to review';
|
|
10
|
+
if (d.pendingAction === 'remove')
|
|
11
|
+
return 'being removed';
|
|
12
|
+
switch (d.state) {
|
|
13
|
+
case 'pending':
|
|
14
|
+
return 'waiting for the TXT record';
|
|
15
|
+
case 'provisioning':
|
|
16
|
+
return 'connecting';
|
|
17
|
+
case 'active':
|
|
18
|
+
return d.verified === false || d.misconfigured
|
|
19
|
+
? 'connected, DNS not right'
|
|
20
|
+
: 'connected';
|
|
21
|
+
case 'legacy':
|
|
22
|
+
return 'connected before the check; add the TXT record';
|
|
23
|
+
case 'unclaimed':
|
|
24
|
+
return 'set before the check, not connected';
|
|
25
|
+
default:
|
|
26
|
+
return d.state;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
async function listDomains(read, rest) {
|
|
30
|
+
const team = (0, read_1.named)(rest, 'list', 'team');
|
|
31
|
+
const answer = await read.client.get(`/domains/${encodeURIComponent(team)}`);
|
|
32
|
+
if (read.json) {
|
|
33
|
+
read.io.out(JSON.stringify(answer));
|
|
34
|
+
return errors_1.EXIT.ok;
|
|
35
|
+
}
|
|
36
|
+
const out = read.io.out;
|
|
37
|
+
if (!answer.domains.length)
|
|
38
|
+
out(`No custom domains at ${answer.place.name}.`);
|
|
39
|
+
for (const [i, d] of answer.domains.entries()) {
|
|
40
|
+
if (i)
|
|
41
|
+
out('');
|
|
42
|
+
out(`${d.hostname} ${d.event.title}`);
|
|
43
|
+
out(` ${status(d)}${d.updatedAt ? ` (since ${(0, read_1.day)(d.updatedAt)})` : ''}`);
|
|
44
|
+
if (d.recordsUnavailable)
|
|
45
|
+
out(" Its DNS records couldn't be read just now. Try again in a minute.");
|
|
46
|
+
else if (d.records.length) {
|
|
47
|
+
out(' Set these DNS records:');
|
|
48
|
+
for (const line of (0, read_1.table)([
|
|
49
|
+
['TYPE', 'NAME', 'VALUE'],
|
|
50
|
+
...d.records.map((r) => [r.type, r.name, r.value]),
|
|
51
|
+
]))
|
|
52
|
+
out(` ${line}`);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
out('');
|
|
56
|
+
out(`Connect, check or remove domains on Blocklive: ${read.base}${answer.path}`);
|
|
57
|
+
return errors_1.EXIT.ok;
|
|
58
|
+
}
|
|
59
|
+
exports.listDomains = listDomains;
|
|
60
|
+
const HOSTNAME = /^(?=.{4,253}$)([a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z]([a-z0-9-]{0,61}[a-z0-9])?$/;
|
|
61
|
+
async function claimDomain(read, rest) {
|
|
62
|
+
const [verb, event, given, ...extra] = rest;
|
|
63
|
+
const hostname = (given ?? '').trim().toLowerCase();
|
|
64
|
+
if (verb !== 'claim' ||
|
|
65
|
+
extra.length ||
|
|
66
|
+
!event ||
|
|
67
|
+
!/^[A-Za-z0-9][A-Za-z0-9-]{0,199}$/.test(event) ||
|
|
68
|
+
!HOSTNAME.test(hostname))
|
|
69
|
+
throw (0, errors_1.usage)('Name the event and the domain: blocklive domains claim <event> tickets.example.com');
|
|
70
|
+
const asked = await read.client.post(`/events/${encodeURIComponent(event)}/domain-claim`, { hostname });
|
|
71
|
+
const title = asked.event?.title ?? event;
|
|
72
|
+
read.io.err(`Asked to connect ${asked.summary.hostname} to ${title}${asked.summary.current
|
|
73
|
+
? ` (it has ${asked.summary.current.hostname} now)`
|
|
74
|
+
: ''}.`);
|
|
75
|
+
const now = await (0, requests_1.confirmOnBlocklive)(read, asked);
|
|
76
|
+
if (!now)
|
|
77
|
+
return errors_1.EXIT.ok;
|
|
78
|
+
if (read.json)
|
|
79
|
+
read.io.out(JSON.stringify(now));
|
|
80
|
+
else
|
|
81
|
+
read.io.out(`Claimed ${asked.summary.hostname} for ${title}. Set its DNS records: blocklive domains list <team>`);
|
|
82
|
+
return errors_1.EXIT.ok;
|
|
83
|
+
}
|
|
84
|
+
exports.claimDomain = claimDomain;
|