@deepdynamic/cli 0.1.0 → 0.1.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/dist/agents/content.js +1 -1
- package/dist/agents/install.js +22 -12
- package/dist/agents/refresh.js +20 -0
- package/dist/agents/setup.js +7 -7
- package/dist/cli.js +8 -8
- package/dist/commands/account.js +19 -19
- package/dist/commands/activity.js +13 -13
- package/dist/commands/blocked.js +16 -16
- package/dist/commands/deploy/index.js +16 -16
- package/dist/commands/deploy/ship.js +8 -8
- package/dist/commands/deployments.js +8 -7
- package/dist/commands/dns.js +228 -242
- package/dist/commands/domains.js +188 -260
- package/dist/commands/emails.js +17 -17
- package/dist/commands/env.js +38 -38
- package/dist/commands/help.js +18 -19
- package/dist/commands/keys.js +83 -89
- package/dist/commands/login/flow.js +11 -11
- package/dist/commands/login/index.js +3 -3
- package/dist/commands/logout.js +11 -11
- package/dist/commands/mail.js +62 -62
- package/dist/commands/notifications.js +30 -29
- package/dist/commands/plan.js +109 -125
- package/dist/commands/projects.js +159 -157
- package/dist/commands/reference.js +109 -102
- package/dist/commands/search.js +29 -18
- package/dist/commands/server.js +99 -112
- package/dist/commands/sessions.js +38 -44
- package/dist/commands/sites.js +16 -16
- package/dist/commands/sms.js +14 -14
- package/dist/commands/status.js +9 -9
- package/dist/commands/support.js +19 -19
- package/dist/commands/update.js +18 -16
- package/dist/commands/usage.js +12 -12
- package/dist/commands/verify.js +16 -16
- package/dist/guide.js +9 -48
- package/dist/http/request.js +3 -3
- package/dist/pretty.js +4 -4
- package/dist/refresh-skills.js +5 -0
- package/dist/registry.js +72 -144
- package/dist/runtime/card-request.js +6 -6
- package/dist/runtime/confirm.js +1 -1
- package/dist/runtime/development.js +1 -1
- package/dist/runtime/dry-run.js +2 -2
- package/dist/runtime/env-file.js +6 -9
- package/dist/runtime/flags.js +11 -13
- package/dist/runtime/login-screen.js +5 -5
- package/dist/runtime/page.js +4 -4
- package/dist/runtime/server-options.js +4 -8
- package/dist/runtime/spinner.js +3 -1
- package/dist/runtime/support.js +2 -3
- package/dist/runtime/text-file.js +5 -5
- package/dist/runtime/timeout.js +2 -2
- package/dist/runtime/update-check.js +48 -14
- package/dist/runtime/update-install.js +34 -4
- package/dist/runtime/usage-error.js +2 -2
- package/dist/setup-agents.js +9 -2
- package/package.json +1 -1
package/dist/commands/dns.js
CHANGED
|
@@ -13,11 +13,11 @@ import { PROJECT } from "../runtime/project-name.js";
|
|
|
13
13
|
export const DNS_PATH = '/api/v1/dns';
|
|
14
14
|
export const DNS_SITE_DOMAIN = 'deepdynamic.dev';
|
|
15
15
|
const RECORD_TYPES = {
|
|
16
|
-
A: 'IPv4
|
|
17
|
-
NS: '
|
|
16
|
+
A: 'IPv4 address', AAAA: 'IPv6 address', CNAME: 'alias target', MX: 'mail server', TXT: 'verification text', CAA: 'allowed certificate authorities',
|
|
17
|
+
NS: 'nameserver delegation', PTR: 'reverse lookup', SRV: 'service location'
|
|
18
18
|
};
|
|
19
19
|
export const DNS_RECORD_TYPES = Object.keys(RECORD_TYPES);
|
|
20
|
-
const TTLS = [['auto', 1, '
|
|
20
|
+
const TTLS = [['auto', 1, 'auto'], ['300', 300, '5 minutes'], ['3600', 3600, '1 hour'], ['86400', 86400, '1 day']];
|
|
21
21
|
const HOST_TYPES = ['CNAME', 'MX', 'NS', 'PTR'];
|
|
22
22
|
const LABEL = '[a-z0-9_]([a-z0-9_-]*[a-z0-9])?';
|
|
23
23
|
const NAME = new RegExp(`^(@|(\\*\\.)?${LABEL}(\\.${LABEL})*|\\*)$`);
|
|
@@ -26,50 +26,40 @@ const RECORD_ID = /^[a-z0-9]([a-z0-9-]{0,62}[a-z0-9])?$/;
|
|
|
26
26
|
const PRIORITY = /^\d{1,5}$/;
|
|
27
27
|
const RECORD_FLAGS = ['--type', '--name', '--value', '--ttl', '--priority'];
|
|
28
28
|
const RESTORE_FLAGS = ['--project', '--name'];
|
|
29
|
-
const PROPAGATION = '
|
|
30
|
-
const APPLIED_PROPAGATION = '
|
|
31
|
-
const PENDING = 'DNS
|
|
32
|
-
const PENDING_APPLY = 'DNS
|
|
33
|
-
const NO_PROJECT = '
|
|
34
|
-
const SYNC_EFFECT = '
|
|
35
|
-
const SYNC_WARNING = 'DNS
|
|
36
|
-
const DNSSEC_STATES = { on: '
|
|
29
|
+
const PROPAGATION = 'Once applied, changes usually reach DNS resolvers worldwide within a few minutes, but the previous value can stay cached for up to the TTL.';
|
|
30
|
+
const APPLIED_PROPAGATION = 'Changes usually reach DNS resolvers worldwide within a few minutes, but the previous value can stay cached for up to the TTL.';
|
|
31
|
+
const PENDING = 'DNS is being set up. This usually finishes within a few minutes.';
|
|
32
|
+
const PENDING_APPLY = 'DNS is being set up. The saved records are applied once setup finishes.';
|
|
33
|
+
const NO_PROJECT = 'No connected project';
|
|
34
|
+
const SYNC_EFFECT = 'Makes the DNS servers match the saved records. If the zone is still being set up, tries to create the zone, apply the records and switch the nameservers right now.';
|
|
35
|
+
const SYNC_WARNING = 'Records changed only on the DNS servers are not in the saved records and will be removed.';
|
|
36
|
+
const DNSSEC_STATES = { on: 'on', enabling: 'enabling', disabling: 'disabling (signing stops in 2 days)', off: 'off', unsupported: 'not supported' };
|
|
37
37
|
const DNSSEC_NOTES = {
|
|
38
|
-
on: '
|
|
39
|
-
enabling: '
|
|
40
|
-
disabling: '
|
|
41
|
-
off: 'DNS
|
|
42
|
-
unsupported: '
|
|
43
|
-
};
|
|
44
|
-
const DNSSEC_AFTER_ZONE = 'DNS 준비가 끝나면 존 서명과 도메인을 산 곳(등록처)의 DS 레코드 등록을 시작합니다.';
|
|
45
|
-
const DNSSEC_ON_EFFECT = 'DNS 서버의 존에 서명하고 도메인을 산 곳(등록처)에 DS 레코드를 등록합니다. 요청 안에서 서명이 끝나기를 30초쯤 기다려 등록까지 마치고, 더 걸리면 몇 분 안에 이어서 끝냅니다. DNS를 아직 준비하고 있으면 준비가 끝난 뒤 시작합니다.';
|
|
46
|
-
const DNSSEC_SCOPE = '딥다이나믹에서 구입한 도메인만 DNSSEC 을 켜고 끌 수 있습니다.';
|
|
47
|
-
const CHECK_DOMAIN = { stage: 'check_domain', message: '도메인 형식을 확인하고 있습니다.' };
|
|
48
|
-
const CHECK_RECORD_ID = { stage: 'check_record_id', message: '레코드 ID 형식을 확인하고 있습니다.' };
|
|
49
|
-
const CHECK_RECORD = { stage: 'check_record', message: '레코드 종류·이름·값 형식을 확인하고 있습니다.' };
|
|
50
|
-
const DESCRIBE_RECORD = { stage: 'describe_record', message: '레코드가 어떻게 동작할지 정리하고 있습니다.' };
|
|
51
|
-
const PREPARE_REQUEST = { stage: 'prepare_request', message: '보낼 요청을 준비하고 있습니다.' };
|
|
52
|
-
export const DOMAIN_NOT_FOUND = {
|
|
53
|
-
code: 'domain_not_found',
|
|
54
|
-
message: 'The domain is not among the domains you manage. Check it with deepdynamic dns.',
|
|
55
|
-
display: '내 도메인 목록에 없는 도메인입니다.'
|
|
56
|
-
};
|
|
57
|
-
const RECORD_NOT_FOUND = {
|
|
58
|
-
code: 'record_not_found',
|
|
59
|
-
message: 'The domain has no record with that ID. Check it with deepdynamic dns records <domain>.',
|
|
60
|
-
display: '그 ID의 레코드를 찾을 수 없습니다.'
|
|
61
|
-
};
|
|
62
|
-
const PROJECT_NOT_FOUND = {
|
|
63
|
-
code: 'project_not_found',
|
|
64
|
-
message: 'You have no active project with that name. Check it with deepdynamic projects.',
|
|
65
|
-
display: '그 이름의 내 프로젝트를 찾을 수 없습니다.'
|
|
38
|
+
on: 'The zone is signed and the DS record is registered at the registrar.',
|
|
39
|
+
enabling: 'Signing the zone and registering the DS record at the registrar. This usually finishes within a few minutes.',
|
|
40
|
+
disabling: 'Removes the DS record at the registrar and stops signing the zone 2 days later, so that cached DS records expire first.',
|
|
41
|
+
off: 'The DNS servers do not sign the zone.',
|
|
42
|
+
unsupported: 'The registrar rejected the DS record for this domain. Its TLD most likely does not support DNSSEC, so DNSSEC cannot be turned on.'
|
|
66
43
|
};
|
|
44
|
+
const DNSSEC_AFTER_ZONE = 'Zone signing and DS record registration at the registrar start once DNS setup finishes.';
|
|
45
|
+
const DNSSEC_ON_EFFECT = 'Signs the zone on the DNS servers and registers a DS record at the registrar. The request waits about 30 seconds for signing and finishes the registration; if signing takes longer, it completes within a few minutes. If DNS is still being set up, this starts once setup finishes.';
|
|
46
|
+
const DNSSEC_SCOPE = 'DNSSEC can be turned on or off only for domains bought through DeepDynamic.';
|
|
47
|
+
const CONFIRM_NEXT = 'Confirm with the user, then run it with --yes.';
|
|
48
|
+
const CHECK_DOMAIN = { stage: 'check_domain', message: 'Checking the domain format.' };
|
|
49
|
+
const CHECK_RECORD_ID = { stage: 'check_record_id', message: 'Checking the record ID format.' };
|
|
50
|
+
const CHECK_RECORD = { stage: 'check_record', message: 'Checking the record type, name and value.' };
|
|
51
|
+
const DESCRIBE_RECORD = { stage: 'describe_record', message: 'Describing how the record will work.' };
|
|
52
|
+
const PREPARE_REQUEST = { stage: 'prepare_request', message: 'Preparing the request.' };
|
|
53
|
+
const plainFailure = (code, message) => ({ code, message, display: message });
|
|
54
|
+
export const DOMAIN_NOT_FOUND = plainFailure('domain_not_found', 'The domain is not among the domains you manage. Check it with deepdynamic dns.');
|
|
55
|
+
const RECORD_NOT_FOUND = plainFailure('record_not_found', 'The domain has no record with that ID. Check it with deepdynamic dns records <domain>.');
|
|
56
|
+
const PROJECT_NOT_FOUND = plainFailure('project_not_found', 'You have no active project with that name. Check it with deepdynamic projects.');
|
|
67
57
|
const NOT_FOUND = { domain_not_found: DOMAIN_NOT_FOUND, record_not_found: RECORD_NOT_FOUND, project_not_found: PROJECT_NOT_FOUND };
|
|
68
58
|
const DNSSEC_FAILURES = {
|
|
69
59
|
external_domain: {
|
|
70
60
|
code: 'external_domain',
|
|
71
61
|
message: 'The domain was bought elsewhere, and DNSSEC can be turned on or off only for domains bought through DeepDynamic. Nothing changed; tell the user DNSSEC is not available for this domain here.',
|
|
72
|
-
display:
|
|
62
|
+
display: `The domain was bought elsewhere. ${DNSSEC_SCOPE}`
|
|
73
63
|
},
|
|
74
64
|
dnssec_unsupported: {
|
|
75
65
|
code: 'dnssec_unsupported',
|
|
@@ -78,19 +68,20 @@ const DNSSEC_FAILURES = {
|
|
|
78
68
|
}
|
|
79
69
|
};
|
|
80
70
|
export const fail = (pretty, message, display) => ({ error: pretty ? display : message });
|
|
71
|
+
const count = (total, noun) => `${total.toLocaleString('en-US')} ${noun}${total === 1 ? '' : 's'}`;
|
|
81
72
|
const hostName = (name, domain) => name === '@' ? domain : `${name}.${domain}`;
|
|
82
|
-
const ttlLabel = (seconds) => TTLS.find(([, value]) => value === seconds)?.[2] ?? `${seconds}
|
|
73
|
+
const ttlLabel = (seconds) => TTLS.find(([, value]) => value === seconds)?.[2] ?? `${seconds.toLocaleString('en-US')} seconds`;
|
|
83
74
|
const recordsUrl = (siteUrl, domain, suffix = '') => new URL(`${DNS_PATH}/${encodeURIComponent(domain)}/records${suffix}`, siteUrl).href;
|
|
84
|
-
const zoneState = (zone) => zone.status === 'pending' ? PENDING : zone.connected ? '
|
|
85
|
-
const pendingRows = (zone) => zone.status === 'pending' ? [['
|
|
86
|
-
const analyticsState = (zone) => zone.analytics ? `Google Analytics ${zone.analytics.measurementId} · ${zone.analytics.connectedAt.slice(0, 10)}
|
|
75
|
+
const zoneState = (zone) => zone.status === 'pending' ? PENDING : zone.connected ? 'Site connected' : 'Not connected';
|
|
76
|
+
const pendingRows = (zone) => zone.status === 'pending' ? [['Pending', PENDING_APPLY]] : [];
|
|
77
|
+
const analyticsState = (zone) => zone.analytics ? `Google Analytics ${zone.analytics.measurementId} · registered ${zone.analytics.connectedAt.slice(0, 10)}` : 'Google Analytics not registered';
|
|
87
78
|
function dnssecRows(zone, explain = false) {
|
|
88
79
|
if (!zone.dnssec)
|
|
89
80
|
return [];
|
|
90
81
|
const state = ['DNSSEC', DNSSEC_STATES[zone.dnssec]];
|
|
91
82
|
if (!explain)
|
|
92
83
|
return [state];
|
|
93
|
-
return [state, ['
|
|
84
|
+
return [state, ['Notice', zone.dnssec === 'enabling' && zone.status === 'pending' ? DNSSEC_AFTER_ZONE : DNSSEC_NOTES[zone.dnssec]]];
|
|
94
85
|
}
|
|
95
86
|
function normalizeName(input, domain) {
|
|
96
87
|
const name = input.trim().toLowerCase().replace(/\.$/, '');
|
|
@@ -120,54 +111,54 @@ function isIpv6(value) {
|
|
|
120
111
|
function describeRecord(record, domain) {
|
|
121
112
|
const host = hostName(record.name, domain);
|
|
122
113
|
if (record.type === 'A' || record.type === 'AAAA')
|
|
123
|
-
return
|
|
114
|
+
return `Points ${host} to the server at ${record.value}.`;
|
|
124
115
|
if (record.type === 'CNAME')
|
|
125
|
-
return
|
|
116
|
+
return `Points ${host} to ${record.value}.`;
|
|
126
117
|
if (record.type === 'MX')
|
|
127
|
-
return
|
|
118
|
+
return `Mail for ${host} is delivered to the server ${record.value}.`;
|
|
128
119
|
if (record.type === 'TXT')
|
|
129
|
-
return
|
|
130
|
-
return
|
|
120
|
+
return `Text for ${host}, used for ownership verification or mail security settings.`;
|
|
121
|
+
return `Sets the ${RECORD_TYPES[record.type]} for ${host}.`;
|
|
131
122
|
}
|
|
132
123
|
function recordRows(record, domain, propagation = PROPAGATION) {
|
|
133
124
|
return [
|
|
134
|
-
['
|
|
125
|
+
['Record', `${record.type} ${hostName(record.name, domain)} → ${record.value}`],
|
|
135
126
|
['TTL', ttlLabel(record.ttl)],
|
|
136
|
-
...(record.priority === undefined ? [] : [['
|
|
137
|
-
['
|
|
138
|
-
['
|
|
127
|
+
...(record.priority === undefined ? [] : [['Priority', `${record.priority} (lower values receive mail first)`]]),
|
|
128
|
+
['Description', describeRecord(record, domain)],
|
|
129
|
+
['Propagation', propagation]
|
|
139
130
|
];
|
|
140
131
|
}
|
|
141
|
-
function readFlags(args, flags
|
|
142
|
-
const parsed = parseFlags(args, flags
|
|
132
|
+
function readFlags(args, flags) {
|
|
133
|
+
const parsed = parseFlags(args, flags);
|
|
143
134
|
if ('error' in parsed)
|
|
144
135
|
return parsed;
|
|
145
136
|
const values = {};
|
|
146
137
|
for (const [flag, value] of parsed.entries) {
|
|
147
138
|
if (values[flag] !== undefined)
|
|
148
|
-
return
|
|
139
|
+
return { error: `Give ${flag} only once.` };
|
|
149
140
|
values[flag] = value;
|
|
150
141
|
}
|
|
151
142
|
return values;
|
|
152
143
|
}
|
|
153
144
|
export function parseDomain(input, pretty) {
|
|
154
145
|
if (input === undefined || input.startsWith('-'))
|
|
155
|
-
return
|
|
146
|
+
return { error: 'Specify the domain first.' };
|
|
156
147
|
const domain = cleanDomain(input);
|
|
157
|
-
return isDomain(domain) ? domain :
|
|
148
|
+
return isDomain(domain) ? domain : { error: `Not a valid domain: ${input}` };
|
|
158
149
|
}
|
|
159
|
-
function parseRecordId(input
|
|
150
|
+
function parseRecordId(input) {
|
|
160
151
|
if (input === undefined || input.startsWith('-'))
|
|
161
|
-
return
|
|
152
|
+
return { error: 'Specify the record ID after the domain.' };
|
|
162
153
|
return RECORD_ID.test(input)
|
|
163
154
|
? input
|
|
164
|
-
:
|
|
155
|
+
: { error: `Record IDs are 1-64 lowercase letters, digits or hyphens that start and end with a letter or digit, as listed by deepdynamic dns records: ${input}` };
|
|
165
156
|
}
|
|
166
|
-
function parseName(input, domain
|
|
157
|
+
function parseName(input, domain) {
|
|
167
158
|
const name = normalizeName(input, domain);
|
|
168
159
|
return NAME.test(name)
|
|
169
160
|
? name
|
|
170
|
-
:
|
|
161
|
+
: { error: `--name must be @ for the domain itself or a label such as www made of lowercase letters, digits, hyphens and underscores: ${input}` };
|
|
171
162
|
}
|
|
172
163
|
const CONTROL = /[\u0000-\u001f\u007f]/;
|
|
173
164
|
const TARGET = /^(_?[a-z0-9]([a-z0-9-]*[a-z0-9])?\.)+[a-z]{2,}$/i;
|
|
@@ -185,50 +176,50 @@ const VALUE_CHECKS = {
|
|
|
185
176
|
CAA: (value) => { const match = CAA.exec(value); return !!match && Number(match[1]) <= 255; },
|
|
186
177
|
SRV: (value) => { const parts = value.split(' '); return parts.length === 4 && parts.slice(0, 3).every((part) => inRange(part, 65535)) && hostOrRoot(parts[3]); }
|
|
187
178
|
};
|
|
179
|
+
const HOST_RULE = 'a host name such as mail.example.com';
|
|
188
180
|
const VALUE_RULES = {
|
|
189
|
-
A:
|
|
190
|
-
AAAA:
|
|
191
|
-
CNAME:
|
|
192
|
-
MX:
|
|
193
|
-
NS:
|
|
194
|
-
PTR:
|
|
195
|
-
TXT:
|
|
196
|
-
CAA:
|
|
197
|
-
SRV:
|
|
181
|
+
A: 'an IPv4 address such as 198.51.100.24',
|
|
182
|
+
AAAA: 'an IPv6 address such as 2001:db8::1',
|
|
183
|
+
CNAME: HOST_RULE,
|
|
184
|
+
MX: HOST_RULE,
|
|
185
|
+
NS: HOST_RULE,
|
|
186
|
+
PTR: HOST_RULE,
|
|
187
|
+
TXT: '1-4000 characters without control characters',
|
|
188
|
+
CAA: 'flags tag "value" with tag issue, issuewild, iodef, contactemail or contactphone, such as 0 issue "letsencrypt.org"',
|
|
189
|
+
SRV: 'priority weight port target, such as 10 5 5060 sip.example.com'
|
|
198
190
|
};
|
|
199
191
|
function valueError(type, value, pretty) {
|
|
200
192
|
if (VALUE_CHECKS[type](value))
|
|
201
193
|
return null;
|
|
202
|
-
const
|
|
203
|
-
return fail(pretty,
|
|
194
|
+
const message = `--value for ${type} records must be ${VALUE_RULES[type]}.`;
|
|
195
|
+
return fail(pretty, message, HOST_TYPES.includes(type) ? `${message} Do not include https://, a path or an IP address.` : message);
|
|
204
196
|
}
|
|
205
|
-
function apexError(type, name
|
|
197
|
+
function apexError(type, name) {
|
|
206
198
|
if (name !== '@')
|
|
207
199
|
return null;
|
|
208
200
|
if (type === 'CNAME')
|
|
209
|
-
return
|
|
201
|
+
return { error: 'A CNAME cannot be on the domain itself (@). Use a name such as www.' };
|
|
210
202
|
if (type === 'NS')
|
|
211
|
-
return
|
|
203
|
+
return { error: 'The NS records of the domain itself (@) cannot be changed.' };
|
|
212
204
|
return null;
|
|
213
205
|
}
|
|
214
206
|
function parseRecord(args, domain, pretty) {
|
|
215
|
-
const values = readFlags(args, RECORD_FLAGS
|
|
207
|
+
const values = readFlags(args, RECORD_FLAGS);
|
|
216
208
|
if ('error' in values)
|
|
217
209
|
return values;
|
|
218
210
|
const { '--type': rawType, '--name': rawName, '--value': rawValue, '--ttl': rawTtl, '--priority': rawPriority } = values;
|
|
219
211
|
if (rawType === undefined || rawName === undefined || rawValue === undefined) {
|
|
220
212
|
const missing = RECORD_FLAGS.find((flag) => values[flag] === undefined);
|
|
221
|
-
return
|
|
213
|
+
return { error: `${missing} is required.` };
|
|
222
214
|
}
|
|
223
215
|
const type = rawType.trim().toUpperCase();
|
|
224
|
-
if (!Object.hasOwn(RECORD_TYPES, type))
|
|
225
|
-
return
|
|
226
|
-
}
|
|
216
|
+
if (!Object.hasOwn(RECORD_TYPES, type))
|
|
217
|
+
return { error: `--type must be one of ${DNS_RECORD_TYPES.join(', ')}: ${rawType}` };
|
|
227
218
|
const recordType = type;
|
|
228
|
-
const name = parseName(rawName, domain
|
|
219
|
+
const name = parseName(rawName, domain);
|
|
229
220
|
if (typeof name !== 'string')
|
|
230
221
|
return name;
|
|
231
|
-
const apex = apexError(recordType, name
|
|
222
|
+
const apex = apexError(recordType, name);
|
|
232
223
|
if (apex)
|
|
233
224
|
return apex;
|
|
234
225
|
const value = normalizeValue(recordType, rawValue);
|
|
@@ -237,17 +228,16 @@ function parseRecord(args, domain, pretty) {
|
|
|
237
228
|
return invalidValue;
|
|
238
229
|
const ttl = rawTtl === undefined ? 1 : TTLS.find(([input]) => input === rawTtl)?.[1];
|
|
239
230
|
if (ttl === undefined)
|
|
240
|
-
return
|
|
231
|
+
return { error: `--ttl must be auto, 300, 3600 or 86400: ${rawTtl}` };
|
|
241
232
|
if (recordType !== 'MX') {
|
|
242
233
|
return rawPriority === undefined
|
|
243
234
|
? { type: recordType, name, value, ttl }
|
|
244
|
-
:
|
|
235
|
+
: { error: '--priority applies only to MX records.' };
|
|
245
236
|
}
|
|
246
237
|
if (rawPriority === undefined)
|
|
247
|
-
return
|
|
248
|
-
if (!PRIORITY.test(rawPriority) || Number(rawPriority) > 65535)
|
|
249
|
-
return
|
|
250
|
-
}
|
|
238
|
+
return { error: '--priority is required for MX records.' };
|
|
239
|
+
if (!PRIORITY.test(rawPriority) || Number(rawPriority) > 65535)
|
|
240
|
+
return { error: `--priority must be an integer from 0 to 65535: ${rawPriority}` };
|
|
251
241
|
return { type: recordType, name, value, ttl, priority: Number(rawPriority) };
|
|
252
242
|
}
|
|
253
243
|
const getWithToken = (url, token, deps, spinner) => request(url, { method: 'GET', headers: { authorization: `Bearer ${token}` } }, deps, spinner);
|
|
@@ -262,16 +252,15 @@ function dnsFailure(result, notFound, conflict, failures = {}, succeeded = accep
|
|
|
262
252
|
if (result.status === 401)
|
|
263
253
|
return LOGIN_EXPIRED;
|
|
264
254
|
if (result.status === 403)
|
|
265
|
-
return
|
|
255
|
+
return plainFailure('login_required', 'The access token is not allowed to do this. Run deepdynamic login again.');
|
|
266
256
|
if (result.status === 404) {
|
|
267
257
|
const code = result.body?.code;
|
|
268
258
|
return typeof code === 'string' && Object.hasOwn(NOT_FOUND, code) ? NOT_FOUND[code] : notFound;
|
|
269
259
|
}
|
|
270
260
|
if (result.status === 400)
|
|
271
|
-
return
|
|
272
|
-
if (result.status === 409)
|
|
273
|
-
return conflict ??
|
|
274
|
-
}
|
|
261
|
+
return plainFailure('invalid_arguments', 'The server rejected the request. Check the arguments against the command help.');
|
|
262
|
+
if (result.status === 409)
|
|
263
|
+
return conflict ?? plainFailure('site_unavailable', 'The project name cannot be used as a site address.');
|
|
275
264
|
return httpFailure(result.status);
|
|
276
265
|
}
|
|
277
266
|
async function applied(command, send, pretty, depth, deps) {
|
|
@@ -292,19 +281,19 @@ async function applied(command, send, pretty, depth, deps) {
|
|
|
292
281
|
const failure = dnsFailure(result, send.notFound, send.conflict, send.failures, send.succeeded);
|
|
293
282
|
if (failure) {
|
|
294
283
|
return pretty
|
|
295
|
-
? prettyResult(1, depth, command, send.failed, [['
|
|
284
|
+
? prettyResult(1, depth, command, send.failed, [['Server', siteUrl], ['Reason', failure.display]])
|
|
296
285
|
: agentResult(1, { command, siteUrl, error: sendFailureError(result, failure) });
|
|
297
286
|
}
|
|
298
287
|
return send.done(result.body, siteUrl);
|
|
299
288
|
}
|
|
300
289
|
export async function rehearsed(command, args, pretty, depth, deps, plan, confirm) {
|
|
301
|
-
const { usage
|
|
290
|
+
const { usage } = spec(command);
|
|
302
291
|
const { args: plain, dryRun } = splitDryRun(args);
|
|
303
292
|
const { args: rest, yes } = confirm ? splitYes(plain) : { args: plain, yes: false };
|
|
304
293
|
const planned = plan(rest);
|
|
305
294
|
if ('error' in planned) {
|
|
306
295
|
return pretty
|
|
307
|
-
? prettyResult(2, depth, command, planned.error, [['
|
|
296
|
+
? prettyResult(2, depth, command, planned.error, [['Usage', usage]])
|
|
308
297
|
: agentResult(2, { command, error: { code: 'invalid_arguments', message: planned.error }, usage });
|
|
309
298
|
}
|
|
310
299
|
if (!dryRun)
|
|
@@ -319,35 +308,35 @@ const zoneOf = (body) => body.zone;
|
|
|
319
308
|
const savedRecord = (zone, record) => [...zone.records].reverse().find((item) => item.type === record.type && item.name === record.name && item.value === record.value && item.priority === record.priority) ?? null;
|
|
320
309
|
function changed(command, pretty, depth, message, rows, zone, siteUrl, extra) {
|
|
321
310
|
return pretty
|
|
322
|
-
? prettyResult(0, depth, command, message, [['
|
|
311
|
+
? prettyResult(0, depth, command, message, [['Server', siteUrl], ['Domain', zone.domain], ...rows, ...pendingRows(zone)])
|
|
323
312
|
: agentResult(0, { command, siteUrl, applied: true, domain: zone.domain, ...extra, zone });
|
|
324
313
|
}
|
|
325
314
|
export async function runDnsList(args, pretty, depth, deps = defaultAuthDeps(pretty, depth)) {
|
|
326
315
|
const command = 'dns';
|
|
327
316
|
return rehearsed(command, args, pretty, depth, deps, (rest) => {
|
|
328
|
-
const page = parsePage(rest
|
|
317
|
+
const page = parsePage(rest);
|
|
329
318
|
if (typeof page !== 'number')
|
|
330
319
|
return page;
|
|
331
320
|
const listUrl = (siteUrl) => `${new URL(DNS_PATH, siteUrl).href}?page=${page}`;
|
|
332
321
|
return {
|
|
333
|
-
steps: [{ stage: 'prepare_request', message: '
|
|
322
|
+
steps: [{ stage: 'prepare_request', message: 'Preparing the request to list managed domains.' }],
|
|
334
323
|
result: (siteUrl) => plannedRequest(command, pretty, depth, siteUrl, listUrl(siteUrl)),
|
|
335
324
|
send: {
|
|
336
325
|
method: 'GET',
|
|
337
326
|
url: listUrl,
|
|
338
|
-
spinner: '
|
|
339
|
-
failed: '
|
|
327
|
+
spinner: 'Loading managed domains.',
|
|
328
|
+
failed: 'Could not load managed domains.',
|
|
340
329
|
notFound: httpFailure(404),
|
|
341
330
|
done: (body, siteUrl) => {
|
|
342
331
|
const { zones, ...paged } = body;
|
|
343
332
|
const paging = pagination(paged, command);
|
|
344
333
|
if (!pretty)
|
|
345
334
|
return agentResult(0, { command, siteUrl, ...paging, zones });
|
|
346
|
-
return prettyResult(0, depth, command, zones.length ?
|
|
347
|
-
['
|
|
335
|
+
return prettyResult(0, depth, command, zones.length ? `Loaded ${count(zones.length, 'managed domain')}.` : 'You have no managed domains. Once you buy a domain, you can manage its records here.', [
|
|
336
|
+
['Server', siteUrl],
|
|
348
337
|
...zones.map((zone) => [
|
|
349
338
|
zone.domain,
|
|
350
|
-
[zone.project ?? NO_PROJECT, zoneState(zone), ...(zone.dnssec ? [`DNSSEC ${DNSSEC_STATES[zone.dnssec]}`] : []),
|
|
339
|
+
[zone.project ?? NO_PROJECT, zoneState(zone), ...(zone.dnssec ? [`DNSSEC ${DNSSEC_STATES[zone.dnssec]}`] : []), count(zone.records.length, 'record')].join(' · ')
|
|
351
340
|
]),
|
|
352
341
|
...pageRows(paging)
|
|
353
342
|
]);
|
|
@@ -363,32 +352,32 @@ export async function runDnsRecords(args, pretty, depth, deps = defaultAuthDeps(
|
|
|
363
352
|
if (typeof domain !== 'string')
|
|
364
353
|
return domain;
|
|
365
354
|
if (extra.length)
|
|
366
|
-
return { error: unknownArgument(extra[0]
|
|
355
|
+
return { error: unknownArgument(extra[0]) };
|
|
367
356
|
return {
|
|
368
|
-
steps: [CHECK_DOMAIN, { stage: 'prepare_request', message: '
|
|
357
|
+
steps: [CHECK_DOMAIN, { stage: 'prepare_request', message: 'Preparing the request to list records.' }],
|
|
369
358
|
result: (siteUrl) => plannedRequest(command, pretty, depth, siteUrl, recordsUrl(siteUrl, domain)),
|
|
370
359
|
send: {
|
|
371
360
|
method: 'GET',
|
|
372
361
|
url: (siteUrl) => recordsUrl(siteUrl, domain),
|
|
373
|
-
spinner: '
|
|
374
|
-
failed: '
|
|
362
|
+
spinner: 'Loading DNS records.',
|
|
363
|
+
failed: 'Could not load DNS records.',
|
|
375
364
|
notFound: DOMAIN_NOT_FOUND,
|
|
376
365
|
done: (body, siteUrl) => {
|
|
377
366
|
const zone = zoneOf(body);
|
|
378
367
|
if (!pretty)
|
|
379
368
|
return agentResult(0, { command, siteUrl, zone });
|
|
380
|
-
return prettyResult(0, depth, command, zone.records.length ?
|
|
381
|
-
['
|
|
382
|
-
['
|
|
383
|
-
['
|
|
369
|
+
return prettyResult(0, depth, command, zone.records.length ? `Loaded ${count(zone.records.length, 'record')} for ${zone.domain}.` : `${zone.domain} has no records yet.`, [
|
|
370
|
+
['Server', siteUrl],
|
|
371
|
+
['Project', zone.project ?? NO_PROJECT],
|
|
372
|
+
['Status', zoneState(zone)],
|
|
384
373
|
...dnssecRows(zone),
|
|
385
|
-
['Google', zone.searchConsole ? `Search Console ${zone.searchConsole.connectedAt.slice(0, 10)}
|
|
374
|
+
['Google', zone.searchConsole ? `Search Console registered ${zone.searchConsole.connectedAt.slice(0, 10)}` : 'Search Console not registered'],
|
|
386
375
|
['GA4', analyticsState(zone)],
|
|
387
376
|
...zone.records.map((record) => [
|
|
388
377
|
record.id,
|
|
389
|
-
`${record.type} ${hostName(record.name, zone.domain)} → ${record.value}${record.priority === undefined ? '' : ` (
|
|
378
|
+
`${record.type} ${hostName(record.name, zone.domain)} → ${record.value}${record.priority === undefined ? '' : ` (priority ${record.priority})`} · TTL ${ttlLabel(record.ttl)}`
|
|
390
379
|
]),
|
|
391
|
-
...(zone.nameservers ? [['
|
|
380
|
+
...(zone.nameservers ? [['Nameservers', zone.nameservers.join(', ')]] : [])
|
|
392
381
|
]);
|
|
393
382
|
}
|
|
394
383
|
}
|
|
@@ -407,18 +396,18 @@ export async function runDnsAdd(args, pretty, depth, deps = defaultAuthDeps(pret
|
|
|
407
396
|
const host = hostName(record.name, domain);
|
|
408
397
|
return {
|
|
409
398
|
steps: [CHECK_DOMAIN, CHECK_RECORD, DESCRIBE_RECORD, PREPARE_REQUEST],
|
|
410
|
-
result: (siteUrl) => plannedChange(command, pretty, depth, siteUrl, { url: recordsUrl(siteUrl, domain), body: { ...record } }, 'DNS
|
|
399
|
+
result: (siteUrl) => plannedChange(command, pretty, depth, siteUrl, { url: recordsUrl(siteUrl, domain), body: { ...record } }, 'Checked the DNS record without adding it.', [['Domain', domain], ...recordRows(record, domain)], { domain, host, record }),
|
|
411
400
|
send: {
|
|
412
401
|
method: 'POST',
|
|
413
402
|
url: (siteUrl) => recordsUrl(siteUrl, domain),
|
|
414
403
|
body: { ...record },
|
|
415
|
-
spinner: '
|
|
416
|
-
failed: '
|
|
404
|
+
spinner: 'Adding the DNS record.',
|
|
405
|
+
failed: 'Could not add the DNS record.',
|
|
417
406
|
notFound: DOMAIN_NOT_FOUND,
|
|
418
407
|
done: (body, siteUrl) => {
|
|
419
408
|
const zone = zoneOf(body);
|
|
420
409
|
const saved = savedRecord(zone, record);
|
|
421
|
-
return changed(command, pretty, depth,
|
|
410
|
+
return changed(command, pretty, depth, `Added the DNS record for ${host}.`, [...(saved ? [['Record ID', saved.id]] : []), ...recordRows(record, domain, APPLIED_PROPAGATION)], zone, siteUrl, { host, record: saved ?? record });
|
|
422
411
|
}
|
|
423
412
|
}
|
|
424
413
|
};
|
|
@@ -430,7 +419,7 @@ export async function runDnsUpdate(args, pretty, depth, deps = defaultAuthDeps(p
|
|
|
430
419
|
const domain = parseDomain(input, pretty);
|
|
431
420
|
if (typeof domain !== 'string')
|
|
432
421
|
return domain;
|
|
433
|
-
const recordId = parseRecordId(id
|
|
422
|
+
const recordId = parseRecordId(id);
|
|
434
423
|
if (typeof recordId !== 'string')
|
|
435
424
|
return recordId;
|
|
436
425
|
const record = parseRecord(flags, domain, pretty);
|
|
@@ -439,15 +428,15 @@ export async function runDnsUpdate(args, pretty, depth, deps = defaultAuthDeps(p
|
|
|
439
428
|
const host = hostName(record.name, domain);
|
|
440
429
|
return {
|
|
441
430
|
steps: [CHECK_DOMAIN, CHECK_RECORD_ID, CHECK_RECORD, DESCRIBE_RECORD, PREPARE_REQUEST],
|
|
442
|
-
result: (siteUrl) => plannedChange(command, pretty, depth, siteUrl, { url: recordsUrl(siteUrl, domain, `/${encodeURIComponent(recordId)}`), body: { ...record } }, 'DNS
|
|
431
|
+
result: (siteUrl) => plannedChange(command, pretty, depth, siteUrl, { url: recordsUrl(siteUrl, domain, `/${encodeURIComponent(recordId)}`), body: { ...record } }, 'Checked the DNS record without updating it.', [['Domain', domain], ['Record ID', recordId], ...recordRows(record, domain)], { domain, recordId, host, record }),
|
|
443
432
|
send: {
|
|
444
433
|
method: 'POST',
|
|
445
434
|
url: (siteUrl) => recordsUrl(siteUrl, domain, `/${encodeURIComponent(recordId)}`),
|
|
446
435
|
body: { ...record },
|
|
447
|
-
spinner: '
|
|
448
|
-
failed: '
|
|
436
|
+
spinner: 'Updating the DNS record.',
|
|
437
|
+
failed: 'Could not update the DNS record.',
|
|
449
438
|
notFound: RECORD_NOT_FOUND,
|
|
450
|
-
done: (body, siteUrl) => changed(command, pretty, depth,
|
|
439
|
+
done: (body, siteUrl) => changed(command, pretty, depth, `Updated the DNS record for ${host}.`, [['Record ID', recordId], ...recordRows(record, domain, APPLIED_PROPAGATION)], zoneOf(body), siteUrl, { recordId, host, record: { id: recordId, ...record } })
|
|
451
440
|
}
|
|
452
441
|
};
|
|
453
442
|
});
|
|
@@ -458,41 +447,41 @@ export async function runDnsDelete(args, pretty, depth, deps = defaultAuthDeps(p
|
|
|
458
447
|
const domain = parseDomain(input, pretty);
|
|
459
448
|
if (typeof domain !== 'string')
|
|
460
449
|
return domain;
|
|
461
|
-
const recordId = parseRecordId(id
|
|
450
|
+
const recordId = parseRecordId(id);
|
|
462
451
|
if (typeof recordId !== 'string')
|
|
463
452
|
return recordId;
|
|
464
453
|
if (extra.length)
|
|
465
|
-
return { error: unknownArgument(extra[0]
|
|
454
|
+
return { error: unknownArgument(extra[0]) };
|
|
466
455
|
return {
|
|
467
456
|
confirmArgs: [domain, recordId],
|
|
468
|
-
steps: [CHECK_DOMAIN, CHECK_RECORD_ID, { stage: 'review_impact', message: '
|
|
469
|
-
result: (siteUrl) => plannedChange(command, pretty, depth, siteUrl, { url: recordsUrl(siteUrl, domain, `/${encodeURIComponent(recordId)}/delete`), body: {} }, '
|
|
470
|
-
['
|
|
471
|
-
['
|
|
472
|
-
['
|
|
473
|
-
['
|
|
474
|
-
['
|
|
457
|
+
steps: [CHECK_DOMAIN, CHECK_RECORD_ID, { stage: 'review_impact', message: 'Reviewing the impact of the deletion.' }, PREPARE_REQUEST],
|
|
458
|
+
result: (siteUrl) => plannedChange(command, pretty, depth, siteUrl, { url: recordsUrl(siteUrl, domain, `/${encodeURIComponent(recordId)}/delete`), body: {} }, 'Checked the DNS record deletion without deleting it.', [
|
|
459
|
+
['Domain', domain],
|
|
460
|
+
['Record ID', recordId],
|
|
461
|
+
['Impact', 'Once applied, the record is removed and stops routing traffic right away.'],
|
|
462
|
+
['Warning', `If this record connects the site, visitors can no longer reach the site. To restore it, run deepdynamic dns restore ${domain} --project <project>.`],
|
|
463
|
+
['Propagation', PROPAGATION]
|
|
475
464
|
], { domain, recordId }),
|
|
476
465
|
send: {
|
|
477
466
|
method: 'POST',
|
|
478
467
|
url: (siteUrl) => recordsUrl(siteUrl, domain, `/${encodeURIComponent(recordId)}/delete`),
|
|
479
468
|
body: {},
|
|
480
|
-
spinner: '
|
|
481
|
-
failed: '
|
|
469
|
+
spinner: 'Deleting the DNS record.',
|
|
470
|
+
failed: 'Could not delete the DNS record.',
|
|
482
471
|
notFound: RECORD_NOT_FOUND,
|
|
483
472
|
done: (body, siteUrl) => {
|
|
484
473
|
const zone = zoneOf(body);
|
|
485
|
-
return changed(command, pretty, depth, '
|
|
486
|
-
['
|
|
487
|
-
...(zone.target && !zone.connected ? [['
|
|
488
|
-
['
|
|
474
|
+
return changed(command, pretty, depth, 'Deleted the DNS record.', [
|
|
475
|
+
['Record ID', recordId],
|
|
476
|
+
...(zone.target && !zone.connected ? [['Warning', `Visitors cannot reach the site through this domain now. To restore it, run deepdynamic dns restore ${domain} --project <project>.`]] : []),
|
|
477
|
+
['Propagation', APPLIED_PROPAGATION]
|
|
489
478
|
], zone, siteUrl, { recordId });
|
|
490
479
|
}
|
|
491
480
|
}
|
|
492
481
|
};
|
|
493
482
|
}, {
|
|
494
483
|
message: 'Deleting removes the record from the DNS servers; if it connected the site, visitors can no longer reach it.',
|
|
495
|
-
display:
|
|
484
|
+
display: `Deleting removes this record from the DNS servers. ${CONFIRM_NEXT}`
|
|
496
485
|
});
|
|
497
486
|
}
|
|
498
487
|
export async function runDnsRestore(args, pretty, depth, deps = defaultAuthDeps(pretty, depth)) {
|
|
@@ -501,20 +490,19 @@ export async function runDnsRestore(args, pretty, depth, deps = defaultAuthDeps(
|
|
|
501
490
|
const domain = parseDomain(input, pretty);
|
|
502
491
|
if (typeof domain !== 'string')
|
|
503
492
|
return domain;
|
|
504
|
-
const values = readFlags(flags, RESTORE_FLAGS
|
|
493
|
+
const values = readFlags(flags, RESTORE_FLAGS);
|
|
505
494
|
if ('error' in values)
|
|
506
495
|
return values;
|
|
507
496
|
const { '--project': project, '--name': rawName = 'www' } = values;
|
|
508
497
|
if (project === undefined)
|
|
509
|
-
return
|
|
510
|
-
if (!PROJECT.test(project))
|
|
511
|
-
return
|
|
512
|
-
|
|
513
|
-
const name = parseName(rawName, domain, pretty);
|
|
498
|
+
return { error: '--project is required.' };
|
|
499
|
+
if (!PROJECT.test(project))
|
|
500
|
+
return { error: `Project names are 1-63 lowercase letters, digits or hyphens and start and end with a letter or digit: ${project}` };
|
|
501
|
+
const name = parseName(rawName, domain);
|
|
514
502
|
if (typeof name !== 'string')
|
|
515
503
|
return name;
|
|
516
504
|
if (name === '@')
|
|
517
|
-
return
|
|
505
|
+
return { error: '--name cannot be @ because a CNAME cannot be on the domain itself.' };
|
|
518
506
|
const record = { type: 'CNAME', name, value: `${project}.${DNS_SITE_DOMAIN}`, ttl: 1 };
|
|
519
507
|
const host = hostName(name, domain);
|
|
520
508
|
const restoreUrl = (siteUrl) => new URL(`${DNS_PATH}/${encodeURIComponent(domain)}/restore`, siteUrl).href;
|
|
@@ -522,38 +510,38 @@ export async function runDnsRestore(args, pretty, depth, deps = defaultAuthDeps(
|
|
|
522
510
|
confirmArgs: [domain, ...flags],
|
|
523
511
|
steps: [
|
|
524
512
|
CHECK_DOMAIN,
|
|
525
|
-
{ stage: 'check_project', message: '
|
|
526
|
-
{ stage: 'build_record', message: '
|
|
527
|
-
{ stage: 'plan_cleanup', message: '
|
|
513
|
+
{ stage: 'check_project', message: 'Checking the project name format.' },
|
|
514
|
+
{ stage: 'build_record', message: 'Building the site CNAME record.' },
|
|
515
|
+
{ stage: 'plan_cleanup', message: 'Planning the cleanup of same-name records that conflict with the CNAME.' },
|
|
528
516
|
PREPARE_REQUEST
|
|
529
517
|
],
|
|
530
|
-
result: (siteUrl) => plannedChange(command, pretty, depth, siteUrl, { url: restoreUrl(siteUrl), body: { project, name } }, '
|
|
531
|
-
['
|
|
532
|
-
['
|
|
533
|
-
['
|
|
518
|
+
result: (siteUrl) => plannedChange(command, pretty, depth, siteUrl, { url: restoreUrl(siteUrl), body: { project, name } }, 'Checked the site connection restore without restoring it.', [
|
|
519
|
+
['Domain', domain],
|
|
520
|
+
['Project', project],
|
|
521
|
+
['Record', `CNAME ${host} → ${record.value}`],
|
|
534
522
|
['TTL', ttlLabel(record.ttl)],
|
|
535
|
-
['
|
|
536
|
-
['
|
|
537
|
-
['
|
|
523
|
+
['Description', describeRecord(record, domain)],
|
|
524
|
+
['Cleanup', `Other records of ${host} cannot coexist with a CNAME and are removed when applied.`],
|
|
525
|
+
['Propagation', PROPAGATION]
|
|
538
526
|
], { domain, host, project, record, replacesSameName: true }),
|
|
539
527
|
send: {
|
|
540
528
|
method: 'POST',
|
|
541
529
|
url: restoreUrl,
|
|
542
530
|
body: { project, name },
|
|
543
|
-
spinner: '
|
|
544
|
-
failed: '
|
|
531
|
+
spinner: 'Restoring the site connection.',
|
|
532
|
+
failed: 'Could not restore the site connection.',
|
|
545
533
|
notFound: PROJECT_NOT_FOUND,
|
|
546
|
-
done: (body, siteUrl) => changed(command, pretty, depth,
|
|
547
|
-
['
|
|
548
|
-
['
|
|
549
|
-
['
|
|
550
|
-
['
|
|
534
|
+
done: (body, siteUrl) => changed(command, pretty, depth, `Restored the site connection for ${host}.`, [
|
|
535
|
+
['Project', project],
|
|
536
|
+
['Record', `CNAME ${host} → ${record.value}`],
|
|
537
|
+
['Cleanup', `Other records of ${host} cannot coexist with a CNAME and were removed.`],
|
|
538
|
+
['Propagation', APPLIED_PROPAGATION]
|
|
551
539
|
], zoneOf(body), siteUrl, { host, project, record })
|
|
552
540
|
}
|
|
553
541
|
};
|
|
554
542
|
}, {
|
|
555
543
|
message: 'Restoring replaces the other records of the same host and can move the domain to another project.',
|
|
556
|
-
display:
|
|
544
|
+
display: `Restoring removes the other records of the same host and can move the domain to another project. ${CONFIRM_NEXT}`
|
|
557
545
|
});
|
|
558
546
|
}
|
|
559
547
|
export async function runDnsSync(args, pretty, depth, deps = defaultAuthDeps(pretty, depth)) {
|
|
@@ -563,44 +551,44 @@ export async function runDnsSync(args, pretty, depth, deps = defaultAuthDeps(pre
|
|
|
563
551
|
if (typeof domain !== 'string')
|
|
564
552
|
return domain;
|
|
565
553
|
if (extra.length)
|
|
566
|
-
return { error: unknownArgument(extra[0]
|
|
554
|
+
return { error: unknownArgument(extra[0]) };
|
|
567
555
|
const syncUrl = (siteUrl) => new URL(`${DNS_PATH}/${encodeURIComponent(domain)}/sync`, siteUrl).href;
|
|
568
556
|
return {
|
|
569
557
|
confirmArgs: [domain],
|
|
570
|
-
steps: [CHECK_DOMAIN, { stage: 'review_impact', message: '
|
|
571
|
-
result: (siteUrl) => plannedChange(command, pretty, depth, siteUrl, { url: syncUrl(siteUrl), body: {} }, 'DNS
|
|
572
|
-
['
|
|
573
|
-
['
|
|
574
|
-
['
|
|
575
|
-
['
|
|
558
|
+
steps: [CHECK_DOMAIN, { stage: 'review_impact', message: 'Reviewing the impact of the sync.' }, PREPARE_REQUEST],
|
|
559
|
+
result: (siteUrl) => plannedChange(command, pretty, depth, siteUrl, { url: syncUrl(siteUrl), body: {} }, 'Checked the DNS sync without applying it.', [
|
|
560
|
+
['Domain', domain],
|
|
561
|
+
['Effect', SYNC_EFFECT],
|
|
562
|
+
['Warning', SYNC_WARNING],
|
|
563
|
+
['Propagation', PROPAGATION]
|
|
576
564
|
], { domain }),
|
|
577
565
|
send: {
|
|
578
566
|
method: 'POST',
|
|
579
567
|
url: syncUrl,
|
|
580
568
|
body: {},
|
|
581
|
-
spinner: '
|
|
582
|
-
failed: '
|
|
569
|
+
spinner: 'Syncing the DNS servers.',
|
|
570
|
+
failed: 'Could not sync the DNS servers.',
|
|
583
571
|
notFound: DOMAIN_NOT_FOUND,
|
|
584
572
|
failures: {
|
|
585
573
|
delegation_pending: {
|
|
586
574
|
code: 'delegation_pending',
|
|
587
575
|
message: `The registrar of this domain bought elsewhere does not point at the DeepDynamic nameservers yet, so the zone stays pending. Ask the user to set the nameservers in zone.nameservers of deepdynamic dns records ${domain} at the registrar where the domain was bought, then run this again a few minutes later.`,
|
|
588
|
-
display:
|
|
576
|
+
display: `The registrar where the domain was bought does not use the DeepDynamic nameservers yet. Set the nameservers listed by deepdynamic dns records ${domain} there, then run this again a few minutes later.`
|
|
589
577
|
}
|
|
590
578
|
},
|
|
591
579
|
done: (body, siteUrl) => {
|
|
592
580
|
const zone = zoneOf(body);
|
|
593
|
-
return changed(command, pretty, depth,
|
|
594
|
-
['
|
|
595
|
-
...(zone.nameservers ? [['
|
|
596
|
-
['
|
|
581
|
+
return changed(command, pretty, depth, `Synced the records of ${zone.domain} to the DNS servers.`, [
|
|
582
|
+
['Status', zoneState(zone)],
|
|
583
|
+
...(zone.nameservers ? [['Nameservers', zone.nameservers.join(', ')]] : []),
|
|
584
|
+
['Propagation', APPLIED_PROPAGATION]
|
|
597
585
|
], zone, siteUrl, {});
|
|
598
586
|
}
|
|
599
587
|
}
|
|
600
588
|
};
|
|
601
589
|
}, {
|
|
602
590
|
message: 'Syncing overwrites the DNS servers with the saved records, so records changed only on the DNS servers are removed.',
|
|
603
|
-
display:
|
|
591
|
+
display: `Syncing overwrites the DNS servers with the saved records, so records changed only on the DNS servers are removed. ${CONFIRM_NEXT}`
|
|
604
592
|
});
|
|
605
593
|
}
|
|
606
594
|
export async function runDnsDnssec(args, pretty, depth, deps = defaultAuthDeps(pretty, depth)) {
|
|
@@ -610,44 +598,45 @@ export async function runDnsDnssec(args, pretty, depth, deps = defaultAuthDeps(p
|
|
|
610
598
|
if (typeof domain !== 'string')
|
|
611
599
|
return domain;
|
|
612
600
|
if (state === undefined)
|
|
613
|
-
return
|
|
601
|
+
return { error: 'Give on or off after the domain.' };
|
|
614
602
|
if (state.startsWith('-'))
|
|
615
|
-
return { error: unknownArgument(state
|
|
603
|
+
return { error: unknownArgument(state) };
|
|
616
604
|
if (state !== 'on' && state !== 'off')
|
|
617
|
-
return
|
|
605
|
+
return { error: `Give on or off after the domain: ${state}` };
|
|
618
606
|
if (extra.length)
|
|
619
|
-
return { error: unknownArgument(extra[0]
|
|
607
|
+
return { error: unknownArgument(extra[0]) };
|
|
620
608
|
const enabled = state === 'on';
|
|
621
609
|
const dnssecUrl = (siteUrl) => new URL(`${DNS_PATH}/${encodeURIComponent(domain)}/dnssec`, siteUrl).href;
|
|
622
610
|
return {
|
|
623
611
|
confirmArgs: [domain, state],
|
|
624
|
-
steps: [CHECK_DOMAIN, { stage: 'check_state', message: '
|
|
625
|
-
result: (siteUrl) => plannedChange(command, pretty, depth, siteUrl, { url: dnssecUrl(siteUrl), body: { enabled } }, 'DNSSEC
|
|
626
|
-
['
|
|
627
|
-
['
|
|
628
|
-
['
|
|
629
|
-
['
|
|
612
|
+
steps: [CHECK_DOMAIN, { stage: 'check_state', message: 'Reviewing the DNSSEC change and its impact.' }, PREPARE_REQUEST],
|
|
613
|
+
result: (siteUrl) => plannedChange(command, pretty, depth, siteUrl, { url: dnssecUrl(siteUrl), body: { enabled } }, 'Checked the DNSSEC change without applying it.', [
|
|
614
|
+
['Domain', domain],
|
|
615
|
+
['Change', enabled ? 'Turn DNSSEC on' : 'Turn DNSSEC off'],
|
|
616
|
+
['Effect', enabled ? DNSSEC_ON_EFFECT : DNSSEC_NOTES.disabling],
|
|
617
|
+
['Target', DNSSEC_SCOPE]
|
|
630
618
|
], { domain, enabled }),
|
|
631
619
|
send: {
|
|
632
620
|
method: 'POST',
|
|
633
621
|
url: dnssecUrl,
|
|
634
622
|
body: { enabled },
|
|
635
|
-
spinner: enabled ? 'DNSSEC
|
|
636
|
-
failed: enabled ? '
|
|
623
|
+
spinner: enabled ? 'Turning DNSSEC on.' : 'Turning DNSSEC off.',
|
|
624
|
+
failed: enabled ? 'Could not turn DNSSEC on.' : 'Could not turn DNSSEC off.',
|
|
637
625
|
notFound: DOMAIN_NOT_FOUND,
|
|
638
626
|
failures: DNSSEC_FAILURES,
|
|
639
627
|
done: (body, siteUrl) => {
|
|
640
628
|
const zone = zoneOf(body);
|
|
641
|
-
return changed(command, pretty, depth,
|
|
629
|
+
return changed(command, pretty, depth, `Turned DNSSEC ${enabled ? 'on' : 'off'} for ${zone.domain}.`, dnssecRows(zone, true), zone, siteUrl, { dnssec: zone.dnssec ?? null });
|
|
642
630
|
}
|
|
643
631
|
}
|
|
644
632
|
};
|
|
645
633
|
}, {
|
|
646
634
|
message: 'Turning DNSSEC on or off changes the signing of the DNS zone and the DS record at the registrar; turning it off finishes only 2 days later.',
|
|
647
|
-
display:
|
|
635
|
+
display: `Turning DNSSEC on or off changes the zone signing on the DNS servers and the DS record at the registrar. Turning it off stops signing 2 days later. ${CONFIRM_NEXT}`
|
|
648
636
|
});
|
|
649
637
|
}
|
|
650
638
|
const GOOGLE_NEXT = 'Open url in a browser signed in to the same DeepDynamic account within 10 minutes, pick the Google account that should own the Search Console property and allow both permissions. The browser then adds the ownership TXT record, verifies the domain and adds the sc-domain: property, and lands on /projects#dns with the result. Confirm with deepdynamic dns records <domain>: zone.searchConsole.connectedAt is set once it is done.';
|
|
639
|
+
const CONSENT_NOTICE = 'Open it within 10 minutes in a browser signed in to the same DeepDynamic account. When registration finishes, the browser returns to the DNS tab of the My Projects page.';
|
|
651
640
|
export async function runDnsGoogle(args, pretty, depth, deps = defaultAuthDeps(pretty, depth)) {
|
|
652
641
|
const command = 'dns google';
|
|
653
642
|
return rehearsed(command, args, pretty, depth, deps, ([input, ...extra]) => {
|
|
@@ -655,42 +644,42 @@ export async function runDnsGoogle(args, pretty, depth, deps = defaultAuthDeps(p
|
|
|
655
644
|
if (typeof domain !== 'string')
|
|
656
645
|
return domain;
|
|
657
646
|
if (extra.length)
|
|
658
|
-
return { error: unknownArgument(extra[0]
|
|
647
|
+
return { error: unknownArgument(extra[0]) };
|
|
659
648
|
const googleUrl = (siteUrl) => new URL(`${DNS_PATH}/${encodeURIComponent(domain)}/google`, siteUrl).href;
|
|
660
649
|
return {
|
|
661
650
|
steps: [CHECK_DOMAIN, PREPARE_REQUEST],
|
|
662
|
-
result: (siteUrl) => plannedChange(command, pretty, depth, siteUrl, { url: googleUrl(siteUrl), body: {} }, 'Google Search Console
|
|
663
|
-
['
|
|
664
|
-
['
|
|
651
|
+
result: (siteUrl) => plannedChange(command, pretty, depth, siteUrl, { url: googleUrl(siteUrl), body: {} }, 'Checked the Google Search Console registration request without sending it.', [
|
|
652
|
+
['Domain', domain],
|
|
653
|
+
['Next', 'Open the returned URL within 10 minutes in a browser signed in to the same DeepDynamic account, pick a Google account and allow both permissions. The ownership TXT record is then added, the domain is verified and the Search Console property is added.']
|
|
665
654
|
], { domain }),
|
|
666
655
|
send: {
|
|
667
656
|
method: 'POST',
|
|
668
657
|
url: googleUrl,
|
|
669
658
|
body: {},
|
|
670
|
-
spinner: '
|
|
671
|
-
failed: '
|
|
659
|
+
spinner: 'Creating the Google consent URL.',
|
|
660
|
+
failed: 'Could not create the Google consent URL.',
|
|
672
661
|
notFound: DOMAIN_NOT_FOUND,
|
|
673
662
|
failures: {
|
|
674
663
|
zone_pending: {
|
|
675
664
|
code: 'zone_pending',
|
|
676
665
|
message: `The DNS zone of this domain is still pending, and Google can verify it only after the zone is ready. Check zone.status with deepdynamic dns records ${domain} and run this again once it is ready.`,
|
|
677
|
-
display: `DNS
|
|
666
|
+
display: `DNS is still being set up. Run this again once deepdynamic dns records ${domain} shows that setup has finished.`
|
|
678
667
|
},
|
|
679
668
|
delegation_propagating: {
|
|
680
669
|
code: 'delegation_propagating',
|
|
681
670
|
message: 'Public DNS still shows the old nameservers for this domain (a freshly bought domain takes about 10 minutes at the registry), so Google could not see the ownership TXT yet. Wait about 10 minutes and run this again.',
|
|
682
|
-
display: '
|
|
671
|
+
display: 'The nameserver change is still propagating across the internet. Right after buying a domain this takes about 10 minutes, so run this again shortly.'
|
|
683
672
|
}
|
|
684
673
|
},
|
|
685
674
|
done: (body, siteUrl) => {
|
|
686
675
|
const url = body.url;
|
|
687
676
|
return pretty
|
|
688
|
-
? prettyResult(0, depth, command, '
|
|
689
|
-
['
|
|
690
|
-
['
|
|
691
|
-
['
|
|
692
|
-
['
|
|
693
|
-
['
|
|
677
|
+
? prettyResult(0, depth, command, 'Open the URL below in a browser to finish the Google Search Console registration.', [
|
|
678
|
+
['Server', siteUrl],
|
|
679
|
+
['Domain', domain],
|
|
680
|
+
['URL', url],
|
|
681
|
+
['Notice', CONSENT_NOTICE],
|
|
682
|
+
['Check', `Google row of deepdynamic dns records ${domain}`]
|
|
694
683
|
])
|
|
695
684
|
: agentResult(0, { command, siteUrl, domain, url, next: GOOGLE_NEXT.replace('<domain>', domain) });
|
|
696
685
|
}
|
|
@@ -699,14 +688,14 @@ export async function runDnsGoogle(args, pretty, depth, deps = defaultAuthDeps(p
|
|
|
699
688
|
});
|
|
700
689
|
}
|
|
701
690
|
const ANALYTICS_NEXT = 'Open url in a browser signed in to the same DeepDynamic account within 10 minutes, pick the Google account that should own the GA4 property and allow the Google Analytics edit permission. The browser then creates a new GA4 property named after the domain with a web data stream for https://<siteName>.<domain> under the first Google Analytics account of that Google account, adds the Google tag to the domain and its site host, and lands on /projects#dns with the result. Confirm with deepdynamic dns records <domain>: zone.analytics.measurementId is set once it is done.';
|
|
702
|
-
const ANALYTICS_START = '
|
|
703
|
-
const ANALYTICS_OFF_EFFECT = '
|
|
704
|
-
const ANALYTICS_OFF_WARNING = '
|
|
691
|
+
const ANALYTICS_START = 'Open the returned URL within 10 minutes in a browser signed in to the same DeepDynamic account, pick a Google account and allow the Google Analytics edit permission. A new GA4 property named after the domain and a web stream are then created under the first Google Analytics account of that Google account, and the Google tag is added to the site.';
|
|
692
|
+
const ANALYTICS_OFF_EFFECT = 'Stops adding the Google tag to the HTML of the domain and the site host. The GA4 property stays in Google.';
|
|
693
|
+
const ANALYTICS_OFF_WARNING = 'Registering again creates a new GA4 property that does not continue the visit data collected so far.';
|
|
705
694
|
const ANALYTICS_FAILURES = {
|
|
706
695
|
no_project: {
|
|
707
696
|
code: 'no_project',
|
|
708
697
|
message: 'The domain is not connected to a project, so there is no site to add the Google tag to. Connect one with deepdynamic dns restore <domain> --project <name> --yes, then run this again.',
|
|
709
|
-
display: '
|
|
698
|
+
display: 'The domain is not connected to a project. Connect one with deepdynamic dns restore first, then run this again.'
|
|
710
699
|
}
|
|
711
700
|
};
|
|
712
701
|
export async function runDnsAnalytics(args, pretty, depth, deps = defaultAuthDeps(pretty, depth)) {
|
|
@@ -717,35 +706,32 @@ export async function runDnsAnalytics(args, pretty, depth, deps = defaultAuthDep
|
|
|
717
706
|
const domain = parseDomain(input, pretty);
|
|
718
707
|
if (typeof domain !== 'string')
|
|
719
708
|
return domain;
|
|
720
|
-
if (extra.length)
|
|
721
|
-
return extra[0].startsWith('-')
|
|
722
|
-
? { error: unknownArgument(extra[0], pretty) }
|
|
723
|
-
: fail(pretty, `Only off can follow the domain: ${extra[0]}`, `도메인 뒤에는 off 만 올 수 있습니다: ${extra[0]}`);
|
|
724
|
-
}
|
|
709
|
+
if (extra.length)
|
|
710
|
+
return { error: extra[0].startsWith('-') ? unknownArgument(extra[0]) : `Only off can follow the domain: ${extra[0]}` };
|
|
725
711
|
const analyticsUrl = (siteUrl) => new URL(`${DNS_PATH}/${encodeURIComponent(domain)}/analytics`, siteUrl).href;
|
|
726
712
|
return {
|
|
727
713
|
steps: [CHECK_DOMAIN, PREPARE_REQUEST],
|
|
728
|
-
result: (siteUrl) => plannedChange(command, pretty, depth, siteUrl, { url: analyticsUrl(siteUrl), body: {} }, 'Google Analytics
|
|
729
|
-
['
|
|
730
|
-
['
|
|
714
|
+
result: (siteUrl) => plannedChange(command, pretty, depth, siteUrl, { url: analyticsUrl(siteUrl), body: {} }, 'Checked the Google Analytics registration request without sending it.', [
|
|
715
|
+
['Domain', domain],
|
|
716
|
+
['Next', ANALYTICS_START]
|
|
731
717
|
], { domain }),
|
|
732
718
|
send: {
|
|
733
719
|
method: 'POST',
|
|
734
720
|
url: analyticsUrl,
|
|
735
721
|
body: {},
|
|
736
|
-
spinner: '
|
|
737
|
-
failed: '
|
|
722
|
+
spinner: 'Creating the Google consent URL.',
|
|
723
|
+
failed: 'Could not create the Google consent URL.',
|
|
738
724
|
notFound: DOMAIN_NOT_FOUND,
|
|
739
725
|
failures: ANALYTICS_FAILURES,
|
|
740
726
|
done: (body, siteUrl) => {
|
|
741
727
|
const url = body.url;
|
|
742
728
|
return pretty
|
|
743
|
-
? prettyResult(0, depth, command, '
|
|
744
|
-
['
|
|
745
|
-
['
|
|
746
|
-
['
|
|
747
|
-
['
|
|
748
|
-
['
|
|
729
|
+
? prettyResult(0, depth, command, 'Open the URL below in a browser to finish the Google Analytics registration.', [
|
|
730
|
+
['Server', siteUrl],
|
|
731
|
+
['Domain', domain],
|
|
732
|
+
['URL', url],
|
|
733
|
+
['Notice', CONSENT_NOTICE],
|
|
734
|
+
['Check', `GA4 row of deepdynamic dns records ${domain}`]
|
|
749
735
|
])
|
|
750
736
|
: agentResult(0, { command, siteUrl, domain, url, next: ANALYTICS_NEXT.replaceAll('<domain>', domain) });
|
|
751
737
|
}
|
|
@@ -760,32 +746,32 @@ function runDnsAnalyticsOff(args, pretty, depth, deps) {
|
|
|
760
746
|
if (typeof domain !== 'string')
|
|
761
747
|
return domain;
|
|
762
748
|
if (extra.length)
|
|
763
|
-
return { error: unknownArgument(extra[0]
|
|
749
|
+
return { error: unknownArgument(extra[0]) };
|
|
764
750
|
const disconnectUrl = (siteUrl) => new URL(`${DNS_PATH}/${encodeURIComponent(domain)}/analytics/disconnect`, siteUrl).href;
|
|
765
751
|
return {
|
|
766
752
|
confirmArgs: [domain, 'off'],
|
|
767
|
-
steps: [CHECK_DOMAIN, { stage: 'review_impact', message: '
|
|
768
|
-
result: (siteUrl) => plannedChange(command, pretty, depth, siteUrl, { url: disconnectUrl(siteUrl), body: {} }, 'Google Analytics
|
|
769
|
-
['
|
|
770
|
-
['
|
|
771
|
-
['
|
|
772
|
-
['
|
|
753
|
+
steps: [CHECK_DOMAIN, { stage: 'review_impact', message: 'Reviewing the impact of removing Google Analytics.' }, PREPARE_REQUEST],
|
|
754
|
+
result: (siteUrl) => plannedChange(command, pretty, depth, siteUrl, { url: disconnectUrl(siteUrl), body: {} }, 'Checked the Google Analytics removal without applying it.', [
|
|
755
|
+
['Domain', domain],
|
|
756
|
+
['Change', 'Remove the Google tag'],
|
|
757
|
+
['Effect', ANALYTICS_OFF_EFFECT],
|
|
758
|
+
['Warning', ANALYTICS_OFF_WARNING]
|
|
773
759
|
], { domain }),
|
|
774
760
|
send: {
|
|
775
761
|
method: 'POST',
|
|
776
762
|
url: disconnectUrl,
|
|
777
763
|
body: {},
|
|
778
|
-
spinner: '
|
|
779
|
-
failed: '
|
|
764
|
+
spinner: 'Removing the Google tag from the site.',
|
|
765
|
+
failed: 'Could not remove Google Analytics.',
|
|
780
766
|
notFound: DOMAIN_NOT_FOUND,
|
|
781
767
|
done: (body, siteUrl) => {
|
|
782
768
|
const zone = zoneOf(body);
|
|
783
|
-
return changed(command, pretty, depth,
|
|
769
|
+
return changed(command, pretty, depth, `Removed the Google tag from the ${zone.domain} site.`, [['GA4', analyticsState(zone)], ['Notice', 'The GA4 property stays in Google. Registering again creates a new property.']], zone, siteUrl, { analytics: zone.analytics ?? null });
|
|
784
770
|
}
|
|
785
771
|
}
|
|
786
772
|
};
|
|
787
773
|
}, {
|
|
788
774
|
message: 'Removing stops adding the Google tag to the site, so visits are no longer recorded. The GA4 property stays in Google, and registering again creates a new property that does not continue the old data.',
|
|
789
|
-
display:
|
|
775
|
+
display: `Removing stops adding the Google tag to the site, so visits are no longer recorded. The GA4 property stays in Google, but registering again creates a new property. ${CONFIRM_NEXT}`
|
|
790
776
|
});
|
|
791
777
|
}
|