@deepdynamic/cli 0.1.0 → 0.1.2
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 +28 -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 +229 -243
- package/dist/commands/domains.js +188 -260
- package/dist/commands/emails.js +64 -26
- package/dist/commands/env.js +38 -38
- package/dist/commands/help.js +18 -19
- package/dist/commands/keys.js +84 -90
- 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 +82 -69
- 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 +139 -112
- package/dist/commands/search.js +29 -18
- package/dist/commands/server.js +100 -112
- package/dist/commands/sessions.js +38 -44
- package/dist/commands/sites.js +16 -16
- package/dist/commands/sms.js +31 -17
- 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 +74 -146
- 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 +40 -5
- package/dist/runtime/usage-error.js +2 -2
- package/dist/setup-agents.js +9 -2
- package/package.json +1 -1
package/dist/commands/domains.js
CHANGED
|
@@ -22,85 +22,46 @@ const TOTAL = /^[1-9]\d{0,9}$/;
|
|
|
22
22
|
const NO_AUTO_RENEW = '--no-auto-renew';
|
|
23
23
|
const YES = '--yes';
|
|
24
24
|
const SEOUL_OFFSET_MS = 9 * 3_600_000;
|
|
25
|
-
const EXPIRY_WARNING = '
|
|
26
|
-
const NO_PROJECT = '
|
|
27
|
-
const DNS_ONLY = '
|
|
28
|
-
const REMOVE_EFFECT = '
|
|
29
|
-
const REMOVE_WARNING = '
|
|
30
|
-
const DNS_LABELS = { ns: '
|
|
25
|
+
const EXPIRY_WARNING = 'The domain expires after its expiry date. Someone else can then register it first, and its site connection is cut as well.';
|
|
26
|
+
const NO_PROJECT = 'No project';
|
|
27
|
+
const DNS_ONLY = 'None (DNS only; connect a site later with deepdynamic dns restore)';
|
|
28
|
+
const REMOVE_EFFECT = 'A registration still waiting for the ownership check is only deleted. For a connected domain, its DNS zone, the records in it and its HTTPS certificate are deleted, and the site stops opening on the domain.';
|
|
29
|
+
const REMOVE_WARNING = 'If you changed the nameservers to DeepDynamic, change them back at your registrar so that mail and other records answer again. If you connected with CNAME, delete the 2 CNAME records you added.';
|
|
30
|
+
const DNS_LABELS = { ns: 'Nameservers', cname: 'CNAME records' };
|
|
31
31
|
const VERIFIED = {
|
|
32
|
-
ns: { pending: '
|
|
33
|
-
cname: { pending: '
|
|
34
|
-
};
|
|
35
|
-
const PROJECT_NOT_FOUND = {
|
|
36
|
-
code: 'project_not_found',
|
|
37
|
-
message: 'You have no project with that name. Check the name with deepdynamic projects.',
|
|
38
|
-
display: '그 이름의 내 프로젝트가 없습니다.'
|
|
39
|
-
};
|
|
40
|
-
const DOMAIN_NOT_FOUND = {
|
|
41
|
-
code: 'domain_not_found',
|
|
42
|
-
message: 'The domain is not in your domain list. Check it with deepdynamic domains.',
|
|
43
|
-
display: '내 도메인 목록에 없는 도메인입니다.'
|
|
44
|
-
};
|
|
45
|
-
const DOMAIN_PURCHASED = {
|
|
46
|
-
code: 'domain_purchased',
|
|
47
|
-
message: 'The domain was bought through DeepDynamic and is already managed with deepdynamic domains and deepdynamic dns, so it cannot be registered as a domain bought elsewhere.',
|
|
48
|
-
display: '딥다이나믹에서 구입한 도메인입니다. deepdynamic domains 와 deepdynamic dns 로 바로 관리할 수 있습니다.'
|
|
49
|
-
};
|
|
50
|
-
const DNS_LOOKUP_FAILED = supportFailure('dns_lookup_failed', { note: { en: 'Nothing was changed.', ko: '바뀐 것은 없습니다.' } });
|
|
51
|
-
const CLAIM_NOT_FOUND = {
|
|
52
|
-
code: 'claim_not_found',
|
|
53
|
-
message: 'The domain is neither waiting for an ownership check nor connected to your account. Register it first with deepdynamic domains register <domain> [--project <project>]; a registration that is not verified within 7 days expires.',
|
|
54
|
-
display: '소유 확인을 기다리는 도메인이 아닙니다. deepdynamic domains register 로 먼저 등록하세요.'
|
|
32
|
+
ns: { pending: 'Verified ownership. Waiting for the nameserver change.', ready: 'Verified ownership. The nameservers are connected.' },
|
|
33
|
+
cname: { pending: 'Verified ownership. Waiting for the CNAME records.', ready: 'Verified ownership. The CNAME records are connected.' }
|
|
55
34
|
};
|
|
35
|
+
const failureOf = (code, message, display = message) => ({ code, message, display });
|
|
36
|
+
const PROJECT_NOT_FOUND = failureOf('project_not_found', 'You have no project with that name. Check the name with deepdynamic projects.');
|
|
37
|
+
const DOMAIN_NOT_FOUND = failureOf('domain_not_found', 'The domain is not in your domain list. Check it with deepdynamic domains.');
|
|
38
|
+
const DOMAIN_PURCHASED = failureOf('domain_purchased', 'The domain was bought through DeepDynamic and is already managed with deepdynamic domains and deepdynamic dns, so it cannot be registered as a domain bought elsewhere.', 'The domain was bought through DeepDynamic. Manage it directly with deepdynamic domains and deepdynamic dns.');
|
|
39
|
+
const DNS_LOOKUP_FAILED = supportFailure('dns_lookup_failed', { note: 'Nothing was changed.' });
|
|
40
|
+
const CLAIM_NOT_FOUND = failureOf('claim_not_found', 'The domain is neither waiting for an ownership check nor connected to your account. Register it first with deepdynamic domains register <domain> [--project <project>]; a registration that is not verified within 7 days expires.', 'The domain is not waiting for an ownership check. Register it first with deepdynamic domains register.');
|
|
56
41
|
const REGISTER_FAILURES = {
|
|
57
42
|
project_not_found: PROJECT_NOT_FOUND,
|
|
58
43
|
domain_purchased: DOMAIN_PURCHASED,
|
|
59
|
-
already_registered:
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
display: '이미 연결한 도메인입니다. 프로젝트나 연결 방식을 바꾸려면 deepdynamic domains remove 로 해제한 뒤 다시 등록하세요.'
|
|
63
|
-
},
|
|
64
|
-
limit_reached: {
|
|
65
|
-
code: 'limit_reached',
|
|
66
|
-
message: 'The account already has 10 domains bought elsewhere, counting the ones still waiting for the ownership check. Disconnect one with deepdynamic domains remove <domain> --yes first.',
|
|
67
|
-
display: '다른 곳에서 산 도메인은 소유 확인을 기다리는 것까지 계정당 10개까지 연결할 수 있습니다.'
|
|
68
|
-
},
|
|
69
|
-
site_unavailable: {
|
|
70
|
-
code: 'site_unavailable',
|
|
71
|
-
message: 'The project name cannot be used as a site address. Rename the project with deepdynamic projects rename.',
|
|
72
|
-
display: '이 프로젝트 이름으로는 사이트를 연결할 수 없습니다. deepdynamic projects rename 으로 이름을 바꾸세요.'
|
|
73
|
-
},
|
|
44
|
+
already_registered: failureOf('already_registered', 'The domain is already connected to your account. Check it with deepdynamic domains. To change its project or mode, disconnect it with deepdynamic domains remove <domain> --yes and register it again.', 'The domain is already connected. To change its project or DNS mode, disconnect it with deepdynamic domains remove and register it again.'),
|
|
45
|
+
limit_reached: failureOf('limit_reached', 'The account already has 10 domains bought elsewhere, counting the ones still waiting for the ownership check. Disconnect one with deepdynamic domains remove <domain> --yes first.', 'An account can connect up to 10 domains bought elsewhere, including the ones waiting for the ownership check.'),
|
|
46
|
+
site_unavailable: failureOf('site_unavailable', 'The project name cannot be used as a site address. Rename the project with deepdynamic projects rename.'),
|
|
74
47
|
dns_lookup_failed: DNS_LOOKUP_FAILED
|
|
75
48
|
};
|
|
76
49
|
const VERIFY_FAILURES = {
|
|
77
50
|
claim_not_found: CLAIM_NOT_FOUND,
|
|
78
|
-
txt_not_found:
|
|
79
|
-
code: 'txt_not_found',
|
|
80
|
-
message: 'The ownership TXT record was not found. Show the user error.record and ask them to add it at the DNS provider where the domain was bought (name error.record.name, value error.record.value), then run deepdynamic domains verify <domain> again a few minutes later.',
|
|
81
|
-
display: '소유 확인용 TXT 레코드를 찾지 못했습니다. 레코드를 추가했다면 몇 분 뒤 다시 실행하세요.'
|
|
82
|
-
},
|
|
51
|
+
txt_not_found: failureOf('txt_not_found', 'The ownership TXT record was not found. Show the user error.record and ask them to add it at the DNS provider where the domain was bought (name error.record.name, value error.record.value), then run deepdynamic domains verify <domain> again a few minutes later.', 'The ownership TXT record was not found. If you added it, run the command again in a few minutes.'),
|
|
83
52
|
domain_purchased: DOMAIN_PURCHASED,
|
|
84
53
|
dns_lookup_failed: DNS_LOOKUP_FAILED
|
|
85
54
|
};
|
|
86
55
|
const REMOVE_FAILURES = {
|
|
87
56
|
not_found: DOMAIN_NOT_FOUND,
|
|
88
|
-
domain_purchased:
|
|
89
|
-
code: 'domain_purchased',
|
|
90
|
-
message: 'The domain was bought through DeepDynamic, and only domains bought elsewhere can be disconnected.',
|
|
91
|
-
display: '딥다이나믹에서 구입한 도메인은 연결을 해제할 수 없습니다.'
|
|
92
|
-
}
|
|
57
|
+
domain_purchased: failureOf('domain_purchased', 'The domain was bought through DeepDynamic, and only domains bought elsewhere can be disconnected.', 'Domains bought through DeepDynamic cannot be disconnected.')
|
|
93
58
|
};
|
|
94
59
|
const AUTO_RENEW_FAILURES = {
|
|
95
|
-
external_domain:
|
|
96
|
-
code: 'external_domain',
|
|
97
|
-
message: 'The domain was bought elsewhere, so it renews at the registrar where it was bought. Tell the user to change auto-renew there.',
|
|
98
|
-
display: '다른 곳에서 산 도메인입니다. 자동 갱신은 도메인을 산 곳에서 바꾸세요.'
|
|
99
|
-
}
|
|
60
|
+
external_domain: failureOf('external_domain', 'The domain was bought elsewhere, so it renews at the registrar where it was bought. Tell the user to change auto-renew there.', 'The domain was bought elsewhere. Change auto-renew at the registrar where you bought it.')
|
|
100
61
|
};
|
|
101
62
|
const target = (name) => {
|
|
102
|
-
const { usage
|
|
103
|
-
return { command: name, usage
|
|
63
|
+
const { usage } = spec(name);
|
|
64
|
+
return { command: name, usage };
|
|
104
65
|
};
|
|
105
66
|
const LIST = target('domains');
|
|
106
67
|
const SEARCH = target('domains search');
|
|
@@ -111,14 +72,11 @@ const VERIFY = target('domains verify');
|
|
|
111
72
|
const REMOVE = target('domains remove');
|
|
112
73
|
const AUTO_RENEW = target('domains auto-renew');
|
|
113
74
|
const PAYMENT_FAILURES = {
|
|
114
|
-
payment_declined:
|
|
115
|
-
|
|
116
|
-
message: 'The card company declined the payment, so nothing was charged or bought. reason holds its answer when it gave one. Ask the user to check the card or register another one, then run the same command again.',
|
|
117
|
-
display: '카드사가 결제를 거절해 결제하지 않았습니다. 카드를 확인하거나 다른 카드를 등록한 뒤 다시 시도하세요.'
|
|
118
|
-
},
|
|
119
|
-
payment_unavailable: supportFailure('payment_unavailable', { note: { en: 'Nothing was charged or bought.', ko: '결제하지 않았습니다.' } })
|
|
75
|
+
payment_declined: failureOf('payment_declined', 'The card company declined the payment, so nothing was charged or bought. reason holds its answer when it gave one. Ask the user to check the card or register another one, then run the same command again.', 'The card company declined the payment, so nothing was charged. Check the card or register another one, then try again.'),
|
|
76
|
+
payment_unavailable: supportFailure('payment_unavailable', { note: 'Nothing was charged or bought.' })
|
|
120
77
|
};
|
|
121
|
-
const
|
|
78
|
+
const krw = (amount) => `${amount.toLocaleString('en-US')} KRW`;
|
|
79
|
+
const counted = (count, noun) => `${count.toLocaleString('en-US')} ${noun}${count === 1 ? '' : 's'}`;
|
|
122
80
|
const seoulToday = (now) => new Date(now.getTime() + SEOUL_OFFSET_MS).toISOString().slice(0, 10);
|
|
123
81
|
const domainUrl = (siteUrl, domain, action) => new URL(`${DOMAINS_PATH}/${encodeURIComponent(domain)}/${action}`, siteUrl).href;
|
|
124
82
|
const getWithToken = (url, token, deps, spinner) => request(url, { method: 'GET', headers: { authorization: `Bearer ${token}` } }, deps, spinner);
|
|
@@ -126,52 +84,45 @@ function addYears(date, years) {
|
|
|
126
84
|
const [year, month, day] = date.split('-');
|
|
127
85
|
return `${Number(year) + years}-${month}-${month === '02' && day === '29' ? '28' : day}`;
|
|
128
86
|
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
}
|
|
133
|
-
const seoulDateLabel = (iso) => dateLabel(seoulToday(new Date(iso)));
|
|
134
|
-
const recordRows = ({ name, value }) => [['TXT 이름', name], ['TXT 값', value]];
|
|
87
|
+
const dateLabel = (date) => date.slice(0, 10);
|
|
88
|
+
const seoulDateLabel = (iso) => seoulToday(new Date(iso));
|
|
89
|
+
const recordRows = ({ name, value }) => [['TXT name', name], ['TXT value', value]];
|
|
135
90
|
const cnameRows = (connect) => (connect ?? []).map(({ name, value }) => ['CNAME', `${name} → ${value}`]);
|
|
136
|
-
const connectionLabel = ({ dns, status }) => status === 'ready' ? '
|
|
91
|
+
const connectionLabel = ({ dns, status }) => status === 'ready' ? 'connected' : dns === 'ns' ? 'awaiting nameserver change' : 'awaiting CNAME records';
|
|
137
92
|
function domainLabel(item) {
|
|
138
93
|
const project = item.project ?? NO_PROJECT;
|
|
139
94
|
if (item.expiresAt)
|
|
140
|
-
return `${project} · ${dateLabel(item.expiresAt)}
|
|
95
|
+
return `${project} · until ${dateLabel(item.expiresAt)} · auto-renew ${item.autoRenew ? 'on' : 'off'}`;
|
|
141
96
|
if (item.verification)
|
|
142
|
-
return `${project} ·
|
|
143
|
-
return `${project} ·
|
|
97
|
+
return `${project} · external · awaiting ownership check · verify by ${seoulDateLabel(item.verification.expiresAt)}`;
|
|
98
|
+
return `${project} · external · ${connectionLabel(item)}`;
|
|
144
99
|
}
|
|
145
100
|
const txtRecordOf = (result) => ('failure' in result ? undefined : result.body?.record);
|
|
146
|
-
function parseDomain(input
|
|
101
|
+
function parseDomain(input) {
|
|
147
102
|
if (input === undefined || input.startsWith('-'))
|
|
148
|
-
return { error:
|
|
103
|
+
return { error: 'Specify the domain, such as example.com.' };
|
|
149
104
|
const domain = cleanDomain(input);
|
|
150
|
-
return isDomain(domain) ? domain : { error:
|
|
105
|
+
return isDomain(domain) ? domain : { error: 'Write the domain in a form such as example.com.' };
|
|
151
106
|
}
|
|
152
|
-
function parseProject(value
|
|
107
|
+
function parseProject(value) {
|
|
153
108
|
if (value === undefined)
|
|
154
109
|
return null;
|
|
155
110
|
if (PROJECT.test(value))
|
|
156
111
|
return value;
|
|
157
|
-
return {
|
|
158
|
-
error: pretty
|
|
159
|
-
? '--project 의 프로젝트 이름은 영문 소문자·숫자로 시작하고 끝나는 1~63자의 소문자·숫자·하이픈입니다.'
|
|
160
|
-
: '--project must be a project name of 1-63 lowercase letters, digits or hyphens that starts and ends with a letter or digit.'
|
|
161
|
-
};
|
|
112
|
+
return { error: '--project must be a project name of 1-63 lowercase letters, digits or hyphens that starts and ends with a letter or digit.' };
|
|
162
113
|
}
|
|
163
|
-
function flagValues(args, flags
|
|
164
|
-
const parsed = parseFlags(args, flags
|
|
114
|
+
function flagValues(args, flags) {
|
|
115
|
+
const parsed = parseFlags(args, flags);
|
|
165
116
|
if ('error' in parsed)
|
|
166
117
|
return parsed;
|
|
167
118
|
const repeated = flags.find((flag) => parsed.entries.filter(([name]) => name === flag).length > 1);
|
|
168
119
|
if (repeated)
|
|
169
|
-
return { error:
|
|
120
|
+
return { error: `Give ${repeated} once.` };
|
|
170
121
|
return { values: Object.fromEntries(parsed.entries) };
|
|
171
122
|
}
|
|
172
|
-
function invalid({ command, usage
|
|
123
|
+
function invalid({ command, usage }, error, pretty, depth) {
|
|
173
124
|
return pretty
|
|
174
|
-
? prettyResult(2, depth, command, error, [['
|
|
125
|
+
? prettyResult(2, depth, command, error, [['Usage', usage]])
|
|
175
126
|
: agentResult(2, { command, error: { code: 'invalid_arguments', message: error }, usage });
|
|
176
127
|
}
|
|
177
128
|
async function planned(target, prepared, pretty, deps) {
|
|
@@ -192,23 +143,23 @@ function domainFailure(result, notFound, known = {}) {
|
|
|
192
143
|
if (result.status === 401)
|
|
193
144
|
return LOGIN_EXPIRED;
|
|
194
145
|
if (result.status === 403)
|
|
195
|
-
return
|
|
146
|
+
return failureOf('login_required', 'The access token is not allowed to do this. Run deepdynamic login again.');
|
|
196
147
|
if (result.status === 404)
|
|
197
148
|
return notFound;
|
|
198
149
|
if (result.status === 400) {
|
|
199
150
|
return result.body?.unsupportedTld === true
|
|
200
|
-
? {
|
|
201
|
-
:
|
|
151
|
+
? { ...failureOf('unsupported_tld', `The TLD is not supported. List supported TLDs with ${TLDS_HELP}.`), retryable: false }
|
|
152
|
+
: failureOf('invalid_arguments', 'The server rejected the request. Check the arguments against the command help.');
|
|
202
153
|
}
|
|
203
154
|
if (result.status === 409) {
|
|
204
155
|
return result.body?.total
|
|
205
|
-
?
|
|
206
|
-
:
|
|
156
|
+
? failureOf('price_changed', 'The price changed. Check the new total and run again with it.')
|
|
157
|
+
: failureOf('domain_unavailable', 'The domain cannot be bought.');
|
|
207
158
|
}
|
|
208
159
|
if (result.status === 422)
|
|
209
160
|
return supportFailure('registration_rejected');
|
|
210
161
|
if (result.status === 429)
|
|
211
|
-
return
|
|
162
|
+
return failureOf('rate_limited', 'Too many requests. Try again in a minute.');
|
|
212
163
|
return httpFailure(result.status);
|
|
213
164
|
}
|
|
214
165
|
function errorBody(result, failure) {
|
|
@@ -223,85 +174,77 @@ function errorBody(result, failure) {
|
|
|
223
174
|
}
|
|
224
175
|
function failed(target, result, failure, pretty, depth, siteUrl, message, extra = {}, rows = []) {
|
|
225
176
|
return pretty
|
|
226
|
-
? prettyResult(1, depth, target.command, message, [['
|
|
177
|
+
? prettyResult(1, depth, target.command, message, [['Server', siteUrl], ['Reason', failure.display], ...rows])
|
|
227
178
|
: agentResult(1, { command: target.command, siteUrl, ...extra, error: errorBody(result, failure) });
|
|
228
179
|
}
|
|
229
180
|
export async function runDomainsList(args, pretty, depth, deps = defaultAuthDeps(pretty, depth)) {
|
|
230
181
|
const { args: rest, dryRun } = splitDryRun(args);
|
|
231
|
-
const page = parsePage(rest
|
|
182
|
+
const page = parsePage(rest);
|
|
232
183
|
if (typeof page !== 'number')
|
|
233
184
|
return invalid(LIST, page.error, pretty, depth);
|
|
234
185
|
const listUrl = (siteUrl) => `${new URL(DOMAINS_PATH, siteUrl).href}?page=${page}`;
|
|
235
186
|
if (dryRun) {
|
|
236
187
|
return planned(LIST, {
|
|
237
|
-
steps: [{ stage: 'prepare_request', message: '
|
|
188
|
+
steps: [{ stage: 'prepare_request', message: 'Preparing the domain list request.' }],
|
|
238
189
|
finish: (siteUrl) => plannedRequest(LIST.command, pretty, depth, siteUrl, listUrl(siteUrl))
|
|
239
190
|
}, pretty, deps);
|
|
240
191
|
}
|
|
241
|
-
const sent = await authorized(deps, ({ siteUrl, token }) => getWithToken(listUrl(siteUrl), token, deps, pretty ? '
|
|
192
|
+
const sent = await authorized(deps, ({ siteUrl, token }) => getWithToken(listUrl(siteUrl), token, deps, pretty ? 'Loading domains.' : null));
|
|
242
193
|
if ('login' in sent)
|
|
243
194
|
return sent.login;
|
|
244
195
|
const { session: { siteUrl }, result } = sent;
|
|
245
196
|
const failure = domainFailure(result, httpFailure(404));
|
|
246
197
|
if (failure)
|
|
247
|
-
return failed(LIST, result, failure, pretty, depth, siteUrl, '
|
|
198
|
+
return failed(LIST, result, failure, pretty, depth, siteUrl, 'Could not load the domain list.');
|
|
248
199
|
const { domains, ...paged } = result.body;
|
|
249
200
|
const paging = pagination(paged, LIST.command);
|
|
250
201
|
if (!pretty)
|
|
251
202
|
return agentResult(0, { command: LIST.command, siteUrl, ...paging, domains });
|
|
252
|
-
return prettyResult(0, depth, LIST.command, domains.length ?
|
|
253
|
-
['
|
|
203
|
+
return prettyResult(0, depth, LIST.command, domains.length ? `Loaded ${counted(domains.length, 'domain')}.` : 'You have no bought or connected domains.', [
|
|
204
|
+
['Server', siteUrl],
|
|
254
205
|
...domains.map((item) => [item.domain, domainLabel(item)]),
|
|
255
206
|
...pageRows(paging)
|
|
256
207
|
]);
|
|
257
208
|
}
|
|
258
|
-
function searchName(input
|
|
209
|
+
function searchName(input) {
|
|
259
210
|
if (input === undefined || input.startsWith('-'))
|
|
260
|
-
return { error:
|
|
211
|
+
return { error: 'Specify the name to search, such as my-brand.' };
|
|
261
212
|
const name = cleanDomain(input);
|
|
262
213
|
if (!LABEL.test(name.split('.')[0])) {
|
|
263
|
-
return {
|
|
264
|
-
error: pretty
|
|
265
|
-
? '영문 소문자·숫자·하이픈으로 63자 이내로 적으세요. 하이픈으로 시작하거나 끝날 수 없습니다.'
|
|
266
|
-
: 'The name must be up to 63 lowercase letters, digits or hyphens and cannot start or end with a hyphen. A suffix such as .com may follow.'
|
|
267
|
-
};
|
|
214
|
+
return { error: 'The name must be up to 63 lowercase letters, digits or hyphens and cannot start or end with a hyphen. A suffix such as .com may follow.' };
|
|
268
215
|
}
|
|
269
216
|
return name;
|
|
270
217
|
}
|
|
271
|
-
function searchTlds(name, value
|
|
218
|
+
function searchTlds(name, value) {
|
|
272
219
|
if (value === undefined)
|
|
273
220
|
return null;
|
|
274
221
|
if (name.includes('.'))
|
|
275
|
-
return { error:
|
|
222
|
+
return { error: 'Do not give --tlds when the name already has a TLD.' };
|
|
276
223
|
const tlds = value.trim().toLowerCase();
|
|
277
224
|
if (TLDS_VALUE.test(tlds) && new Set(tlds.split(',')).size <= DOMAIN_SEARCH_MAX_TLDS)
|
|
278
225
|
return tlds;
|
|
279
|
-
return {
|
|
280
|
-
error: pretty
|
|
281
|
-
? `--tlds 에는 site,online 처럼 TLD 를 쉼표로 ${DOMAIN_SEARCH_MAX_TLDS}개까지 지정하세요.`
|
|
282
|
-
: `--tlds must be up to ${DOMAIN_SEARCH_MAX_TLDS} comma-separated TLDs, such as site,online.`
|
|
283
|
-
};
|
|
226
|
+
return { error: `--tlds must be up to ${DOMAIN_SEARCH_MAX_TLDS} comma-separated TLDs, such as site,online.` };
|
|
284
227
|
}
|
|
285
228
|
function priceLabel(price, renewalPrice, minYears) {
|
|
286
|
-
const term = minYears > 1 ? ` / ${minYears}
|
|
287
|
-
const renewal = renewalPrice && renewalPrice.amount !== price.amount ? ` ·
|
|
288
|
-
return `${
|
|
229
|
+
const term = minYears > 1 ? ` / ${counted(minYears, 'year')} · ${minYears}-year minimum` : ' / 1 year';
|
|
230
|
+
const renewal = renewalPrice && renewalPrice.amount !== price.amount ? ` · renewal ${krw(renewalPrice.amount)}` : '';
|
|
231
|
+
return `${krw(price.amount)}${term}${renewal}`;
|
|
289
232
|
}
|
|
290
233
|
function searchLabel({ available, premium, price, renewalPrice, minYears }) {
|
|
291
234
|
if (!available)
|
|
292
|
-
return '
|
|
293
|
-
return `${premium ? '
|
|
235
|
+
return 'taken';
|
|
236
|
+
return `${premium ? 'premium' : 'available'}${price ? ` · ${priceLabel(price, renewalPrice, minYears)}` : ''}`;
|
|
294
237
|
}
|
|
295
238
|
export async function runDomainsSearch(args, pretty, depth, deps = defaultAuthDeps(pretty, depth)) {
|
|
296
239
|
const { args: rest, dryRun } = splitDryRun(args);
|
|
297
240
|
const [input, ...options] = rest;
|
|
298
|
-
const name = searchName(input
|
|
241
|
+
const name = searchName(input);
|
|
299
242
|
if (typeof name !== 'string')
|
|
300
243
|
return invalid(SEARCH, name.error, pretty, depth);
|
|
301
|
-
const flags = flagValues(options, ['--tlds']
|
|
244
|
+
const flags = flagValues(options, ['--tlds']);
|
|
302
245
|
if ('error' in flags)
|
|
303
246
|
return invalid(SEARCH, flags.error, pretty, depth);
|
|
304
|
-
const tlds = searchTlds(name, flags.values['--tlds']
|
|
247
|
+
const tlds = searchTlds(name, flags.values['--tlds']);
|
|
305
248
|
if (tlds !== null && typeof tlds !== 'string')
|
|
306
249
|
return invalid(SEARCH, tlds.error, pretty, depth);
|
|
307
250
|
const searchUrl = (siteUrl) => {
|
|
@@ -314,91 +257,85 @@ export async function runDomainsSearch(args, pretty, depth, deps = defaultAuthDe
|
|
|
314
257
|
const siteUrl = await loginSiteUrl();
|
|
315
258
|
if (dryRun) {
|
|
316
259
|
await rehearse(SEARCH.command, [
|
|
317
|
-
{ stage: 'validate_name', message: '
|
|
318
|
-
{ stage: 'prepare_request', message: '
|
|
260
|
+
{ stage: 'validate_name', message: 'Checking the domain name format.' },
|
|
261
|
+
{ stage: 'prepare_request', message: 'Preparing the search request.' }
|
|
319
262
|
], pretty, deps.stream, deps.pause);
|
|
320
263
|
return plannedRequest(SEARCH.command, pretty, depth, siteUrl, searchUrl(siteUrl));
|
|
321
264
|
}
|
|
322
|
-
const result = await request(searchUrl(siteUrl), { method: 'GET' }, deps, pretty ? '
|
|
265
|
+
const result = await request(searchUrl(siteUrl), { method: 'GET' }, deps, pretty ? 'Checking availability.' : null);
|
|
323
266
|
const failure = domainFailure(result, httpFailure(404));
|
|
324
267
|
if (failure)
|
|
325
|
-
return failed(SEARCH, result, failure, pretty, depth, siteUrl, '
|
|
268
|
+
return failed(SEARCH, result, failure, pretty, depth, siteUrl, 'Could not check availability.', { name });
|
|
326
269
|
const results = result.body.results;
|
|
327
270
|
if (!pretty)
|
|
328
271
|
return agentResult(0, { command: SEARCH.command, siteUrl, name, results });
|
|
329
|
-
return prettyResult(0, depth, SEARCH.command, results.length ? '
|
|
330
|
-
['
|
|
272
|
+
return prettyResult(0, depth, SEARCH.command, results.length ? 'Checked availability.' : 'No results came back. Search again in a moment.', [
|
|
273
|
+
['Server', siteUrl],
|
|
331
274
|
...results.map((item) => [item.domain, searchLabel(item)]),
|
|
332
|
-
...(results.some(({ available }) => available) ? [['
|
|
275
|
+
...(results.some(({ available }) => available) ? [['Buy', 'deepdynamic domains buy <domain> [--project <project>]']] : [])
|
|
333
276
|
]);
|
|
334
277
|
}
|
|
335
278
|
export async function runDomainsTlds(args, pretty, depth, deps = defaultAuthDeps(pretty, depth)) {
|
|
336
279
|
const { args: rest, dryRun } = splitDryRun(args);
|
|
337
280
|
if (rest.length)
|
|
338
|
-
return invalid(TLDS, unknownArgument(rest[0]
|
|
281
|
+
return invalid(TLDS, unknownArgument(rest[0]), pretty, depth);
|
|
339
282
|
const siteUrl = await loginSiteUrl();
|
|
340
283
|
const url = new URL(`${DOMAINS_PATH}/tlds`, siteUrl).href;
|
|
341
284
|
if (dryRun) {
|
|
342
|
-
await rehearse(TLDS.command, [{ stage: 'prepare_request', message: '
|
|
285
|
+
await rehearse(TLDS.command, [{ stage: 'prepare_request', message: 'Preparing the supported TLD list request.' }], pretty, deps.stream, deps.pause);
|
|
343
286
|
return plannedRequest(TLDS.command, pretty, depth, siteUrl, url);
|
|
344
287
|
}
|
|
345
|
-
const result = await request(url, { method: 'GET' }, deps, pretty ? '
|
|
288
|
+
const result = await request(url, { method: 'GET' }, deps, pretty ? 'Loading supported TLDs.' : null);
|
|
346
289
|
const failure = domainFailure(result, httpFailure(404));
|
|
347
290
|
if (failure)
|
|
348
|
-
return failed(TLDS, result, failure, pretty, depth, siteUrl, '
|
|
291
|
+
return failed(TLDS, result, failure, pretty, depth, siteUrl, 'Could not load the supported TLDs.');
|
|
349
292
|
const tlds = result.body.tlds;
|
|
350
293
|
if (!pretty)
|
|
351
294
|
return agentResult(0, { command: TLDS.command, siteUrl, tlds });
|
|
352
|
-
return prettyResult(0, depth, TLDS.command,
|
|
353
|
-
['
|
|
295
|
+
return prettyResult(0, depth, TLDS.command, `Loaded ${counted(tlds.length, 'supported TLD')}.`, [
|
|
296
|
+
['Server', siteUrl],
|
|
354
297
|
...tlds.map(({ tld, recommended, price, renewalPrice, minYears }) => [
|
|
355
298
|
`.${tld}`,
|
|
356
|
-
`${priceLabel(price, renewalPrice, minYears)}${recommended ? ' ·
|
|
299
|
+
`${priceLabel(price, renewalPrice, minYears)}${recommended ? ' · recommended' : ''}`
|
|
357
300
|
])
|
|
358
301
|
]);
|
|
359
302
|
}
|
|
360
|
-
function parseBuy(rest
|
|
303
|
+
function parseBuy(rest) {
|
|
361
304
|
const autoRenew = !rest.includes(NO_AUTO_RENEW);
|
|
362
305
|
const consented = rest.includes(YES);
|
|
363
306
|
const [input, ...options] = rest.filter((arg) => arg !== NO_AUTO_RENEW && arg !== YES);
|
|
364
|
-
const domain = parseDomain(input
|
|
307
|
+
const domain = parseDomain(input);
|
|
365
308
|
if (typeof domain !== 'string')
|
|
366
309
|
return domain;
|
|
367
310
|
const tld = domain.slice(domain.indexOf('.') + 1);
|
|
368
|
-
const flags = flagValues(options, ['--project', '--years', '--total']
|
|
311
|
+
const flags = flagValues(options, ['--project', '--years', '--total']);
|
|
369
312
|
if ('error' in flags)
|
|
370
313
|
return flags;
|
|
371
|
-
const project = parseProject(flags.values['--project']
|
|
314
|
+
const project = parseProject(flags.values['--project']);
|
|
372
315
|
if (project !== null && typeof project !== 'string')
|
|
373
316
|
return project;
|
|
374
317
|
const minYears = DOMAIN_MIN_YEARS[tld] ?? 1;
|
|
375
318
|
const term = flags.values['--years'] ?? String(minYears);
|
|
376
319
|
if (!YEARS.test(term))
|
|
377
|
-
return { error:
|
|
378
|
-
if (Number(term) < minYears)
|
|
379
|
-
return {
|
|
380
|
-
error: pretty
|
|
381
|
-
? `.${tld} 도메인은 ${minYears}년부터 등록할 수 있습니다. --years 를 ${minYears} 이상으로 지정하세요.`
|
|
382
|
-
: `.${tld} domains need a term of at least ${minYears} years. Give --years ${minYears} or more.`
|
|
383
|
-
};
|
|
384
|
-
}
|
|
320
|
+
return { error: '--years must be 1, 2 or 3.' };
|
|
321
|
+
if (Number(term) < minYears)
|
|
322
|
+
return { error: `.${tld} domains need a term of at least ${minYears} years. Give --years ${minYears} or more.` };
|
|
385
323
|
const total = flags.values['--total'];
|
|
386
324
|
if (total !== undefined && !TOTAL.test(total))
|
|
387
|
-
return { error:
|
|
388
|
-
if (consented && total === undefined)
|
|
389
|
-
return { error:
|
|
390
|
-
}
|
|
325
|
+
return { error: '--total must be the total in won, such as 17900.' };
|
|
326
|
+
if (consented && total === undefined)
|
|
327
|
+
return { error: 'Give --total with the amount you confirmed together with --yes.' };
|
|
391
328
|
return { domain, project, years: Number(term), autoRenew, consented, total: total === undefined ? null : Number(total) };
|
|
392
329
|
}
|
|
393
330
|
function quoteRows(quote, until) {
|
|
394
331
|
return [
|
|
395
|
-
['
|
|
396
|
-
['
|
|
397
|
-
['
|
|
398
|
-
['
|
|
399
|
-
['
|
|
400
|
-
['
|
|
401
|
-
...(quote.premium ? [['
|
|
332
|
+
['Domain', quote.domain],
|
|
333
|
+
['Project', quote.project ?? DNS_ONLY],
|
|
334
|
+
['Term', counted(quote.years, 'year')],
|
|
335
|
+
['Valid until', dateLabel(until)],
|
|
336
|
+
['Auto-renew', quote.autoRenew ? `on (renews on ${dateLabel(until)})` : `off (expires on ${dateLabel(until)})`],
|
|
337
|
+
['Total', krw(quote.total.amount)],
|
|
338
|
+
...(quote.premium ? [['Price', 'Premium price set by the registry.']] : [])
|
|
402
339
|
];
|
|
403
340
|
}
|
|
404
341
|
function echoesRequest(parsed, body) {
|
|
@@ -408,7 +345,7 @@ function echoesRequest(parsed, body) {
|
|
|
408
345
|
}
|
|
409
346
|
export async function runDomainsBuy(args, pretty, depth, deps = defaultAuthDeps(pretty, depth)) {
|
|
410
347
|
const { args: rest, dryRun } = splitDryRun(args);
|
|
411
|
-
const parsed = parseBuy(rest
|
|
348
|
+
const parsed = parseBuy(rest);
|
|
412
349
|
if ('error' in parsed)
|
|
413
350
|
return invalid(BUY, parsed.error, pretty, depth);
|
|
414
351
|
const purchase = !dryRun && parsed.consented;
|
|
@@ -419,28 +356,24 @@ export async function runDomainsBuy(args, pretty, depth, deps = defaultAuthDeps(
|
|
|
419
356
|
autoRenew: parsed.autoRenew,
|
|
420
357
|
...(purchase ? { total: parsed.total } : { dryRun: true })
|
|
421
358
|
};
|
|
422
|
-
const sent = await authorized(deps, ({ siteUrl, token }) => postJson(new URL(`${DOMAINS_PATH}/purchase`, siteUrl).href, token, payload, deps, pretty ? (purchase ? '
|
|
359
|
+
const sent = await authorized(deps, ({ siteUrl, token }) => postJson(new URL(`${DOMAINS_PATH}/purchase`, siteUrl).href, token, payload, deps, pretty ? (purchase ? 'Buying the domain.' : 'Checking the total.') : null));
|
|
423
360
|
if ('login' in sent)
|
|
424
361
|
return sent.login;
|
|
425
362
|
const { session, result } = sent;
|
|
426
363
|
const { siteUrl } = session;
|
|
427
364
|
if (cardRequired(result))
|
|
428
365
|
return requestCard(BUY.command, pretty, depth, session, deps, { domain: parsed.domain });
|
|
429
|
-
const failure = domainFailure(result,
|
|
430
|
-
code: 'project_not_found',
|
|
431
|
-
message: 'You have no project with that name. Create it with deepdynamic projects create <name>.',
|
|
432
|
-
display: '그 이름의 내 프로젝트가 없습니다.'
|
|
433
|
-
}, PAYMENT_FAILURES) ?? (purchase || echoesRequest(parsed, result.body) ? null : UNEXPECTED);
|
|
366
|
+
const failure = domainFailure(result, failureOf('project_not_found', 'You have no project with that name. Create it with deepdynamic projects create <name>.'), PAYMENT_FAILURES) ?? (purchase || echoesRequest(parsed, result.body) ? null : UNEXPECTED);
|
|
434
367
|
if (failure) {
|
|
435
368
|
const answer = 'failure' in result || failure === UNEXPECTED ? null : result.body;
|
|
436
369
|
const total = answer?.total;
|
|
437
370
|
const reason = failure.code === 'payment_declined' && typeof answer?.reason === 'string' ? answer.reason : null;
|
|
438
371
|
return pretty
|
|
439
|
-
? prettyResult(1, depth, BUY.command, purchase ? '
|
|
440
|
-
['
|
|
441
|
-
['
|
|
442
|
-
...(reason ? [['
|
|
443
|
-
...(total ? [['
|
|
372
|
+
? prettyResult(1, depth, BUY.command, purchase ? 'Could not buy the domain.' : 'Could not check the total.', [
|
|
373
|
+
['Server', siteUrl],
|
|
374
|
+
['Reason', failure.display],
|
|
375
|
+
...(reason ? [['Card response', reason]] : []),
|
|
376
|
+
...(total ? [['New total', krw(total.amount)]] : [])
|
|
444
377
|
])
|
|
445
378
|
: agentResult(1, { command: BUY.command, siteUrl, domain: parsed.domain, ...(total ? { total } : {}), ...(reason ? { reason } : {}), error: errorBody(result, failure) });
|
|
446
379
|
}
|
|
@@ -450,16 +383,16 @@ export async function runDomainsBuy(args, pretty, depth, deps = defaultAuthDeps(
|
|
|
450
383
|
const retry = `deepdynamic domains buy ${quote.domain}${quote.project === null ? '' : ` --project ${quote.project}`} --years ${quote.years}${quote.autoRenew ? '' : ' --no-auto-renew'} --yes --total ${quote.total.amount}`;
|
|
451
384
|
if (purchase) {
|
|
452
385
|
return pretty
|
|
453
|
-
? prettyResult(0, depth, BUY.command,
|
|
386
|
+
? prettyResult(0, depth, BUY.command, `Bought ${quote.domain}.`, [['Server', siteUrl], ...quoteRows(quote, until)])
|
|
454
387
|
: agentResult(0, { command: BUY.command, siteUrl, ...quote, expiresAt: until });
|
|
455
388
|
}
|
|
456
389
|
if (dryRun) {
|
|
457
390
|
return pretty
|
|
458
|
-
? prettyResult(0, depth, BUY.command, '
|
|
391
|
+
? prettyResult(0, depth, BUY.command, 'Checked the total. Nothing was bought.', [['Server', siteUrl], ...quoteRows(quote, until), ['Run', retry]])
|
|
459
392
|
: agentResult(0, { command: BUY.command, siteUrl, dryRun: true, applied: false, ...quote, expiresAt: until, next: retry });
|
|
460
393
|
}
|
|
461
394
|
return pretty
|
|
462
|
-
? prettyResult(3, depth, BUY.command, '
|
|
395
|
+
? prettyResult(3, depth, BUY.command, 'Payment consent is required. Check the total, then run the command below.', [['Server', siteUrl], ...quoteRows(quote, until), ['Run', retry]])
|
|
463
396
|
: agentResult(3, {
|
|
464
397
|
command: BUY.command,
|
|
465
398
|
siteUrl,
|
|
@@ -468,32 +401,27 @@ export async function runDomainsBuy(args, pretty, depth, deps = defaultAuthDeps(
|
|
|
468
401
|
error: { code: 'confirmation_required', message: `Show the user the total, and after they agree run: ${retry}`, next: retry, retryable: false }
|
|
469
402
|
});
|
|
470
403
|
}
|
|
471
|
-
function parseRegister(rest
|
|
404
|
+
function parseRegister(rest) {
|
|
472
405
|
const [input, ...options] = rest;
|
|
473
|
-
const domain = parseDomain(input
|
|
406
|
+
const domain = parseDomain(input);
|
|
474
407
|
if (typeof domain !== 'string')
|
|
475
408
|
return domain;
|
|
476
|
-
const flags = flagValues(options, ['--project', '--dns', '--site']
|
|
409
|
+
const flags = flagValues(options, ['--project', '--dns', '--site']);
|
|
477
410
|
if ('error' in flags)
|
|
478
411
|
return flags;
|
|
479
|
-
const project = parseProject(flags.values['--project']
|
|
412
|
+
const project = parseProject(flags.values['--project']);
|
|
480
413
|
if (project !== null && typeof project !== 'string')
|
|
481
414
|
return project;
|
|
482
415
|
const dns = flags.values['--dns'] ?? 'ns';
|
|
483
416
|
if (dns !== 'ns' && dns !== 'cname')
|
|
484
|
-
return { error:
|
|
485
|
-
if (dns === 'cname' && project === null)
|
|
486
|
-
return { error:
|
|
487
|
-
}
|
|
417
|
+
return { error: '--dns must be ns or cname.' };
|
|
418
|
+
if (dns === 'cname' && project === null)
|
|
419
|
+
return { error: '--dns cname needs --project. Use --dns ns to connect without a project.' };
|
|
488
420
|
const site = flags.values['--site'];
|
|
489
421
|
if (site === '@' && dns !== 'cname')
|
|
490
|
-
return { error:
|
|
422
|
+
return { error: '--site @ works only with --dns cname.' };
|
|
491
423
|
if (site !== undefined && site !== '@' && !LABEL.test(site)) {
|
|
492
|
-
return {
|
|
493
|
-
error: pretty
|
|
494
|
-
? '--site 에는 www 처럼 영문 소문자·숫자·하이픈으로 된 1~63자 이름을 지정하세요. --dns cname 이면 @ 도 쓸 수 있습니다.'
|
|
495
|
-
: '--site must be a label of 1-63 lowercase letters, digits or hyphens such as www, or @ with --dns cname.'
|
|
496
|
-
};
|
|
424
|
+
return { error: '--site must be a label of 1-63 lowercase letters, digits or hyphens such as www, or @ with --dns cname.' };
|
|
497
425
|
}
|
|
498
426
|
return { domain, project, dns, site: site ?? null };
|
|
499
427
|
}
|
|
@@ -502,11 +430,11 @@ function plannedHost({ domain, dns, site }) {
|
|
|
502
430
|
return domain;
|
|
503
431
|
if (site)
|
|
504
432
|
return `${site}.${domain}`;
|
|
505
|
-
return dns === 'ns' ? `www.${domain}` : `www.${domain}
|
|
433
|
+
return dns === 'ns' ? `www.${domain}` : `www.${domain} or ${domain} (www is added to an apex domain; a subdomain is used as is)`;
|
|
506
434
|
}
|
|
507
435
|
export async function runDomainsRegister(args, pretty, depth, deps = defaultAuthDeps(pretty, depth)) {
|
|
508
436
|
const { args: rest, dryRun } = splitDryRun(args);
|
|
509
|
-
const parsed = parseRegister(rest
|
|
437
|
+
const parsed = parseRegister(rest);
|
|
510
438
|
if ('error' in parsed)
|
|
511
439
|
return invalid(REGISTER, parsed.error, pretty, depth);
|
|
512
440
|
const { domain, project, dns, site } = parsed;
|
|
@@ -515,27 +443,27 @@ export async function runDomainsRegister(args, pretty, depth, deps = defaultAuth
|
|
|
515
443
|
if (dryRun) {
|
|
516
444
|
return planned(REGISTER, {
|
|
517
445
|
steps: [
|
|
518
|
-
{ stage: 'validate_domain', message: '
|
|
519
|
-
{ stage: 'validate_project', message: '
|
|
520
|
-
{ stage: 'validate_dns', message: '
|
|
521
|
-
{ stage: 'prepare_request', message: '
|
|
446
|
+
{ stage: 'validate_domain', message: 'Checking the domain format.' },
|
|
447
|
+
{ stage: 'validate_project', message: 'Checking the project name.' },
|
|
448
|
+
{ stage: 'validate_dns', message: 'Checking the DNS mode and site name.' },
|
|
449
|
+
{ stage: 'prepare_request', message: 'Preparing the registration request.' }
|
|
522
450
|
],
|
|
523
|
-
finish: (siteUrl) => plannedChange(REGISTER.command, pretty, depth, siteUrl, { url: new URL(DOMAINS_PATH, siteUrl).href, body: payload }, '
|
|
524
|
-
['
|
|
525
|
-
['
|
|
526
|
-
['
|
|
527
|
-
['
|
|
528
|
-
['
|
|
451
|
+
finish: (siteUrl) => plannedChange(REGISTER.command, pretty, depth, siteUrl, { url: new URL(DOMAINS_PATH, siteUrl).href, body: payload }, 'Checked the registration. Nothing was registered.', [
|
|
452
|
+
['Domain', domain],
|
|
453
|
+
['Project', project ?? DNS_ONLY],
|
|
454
|
+
['DNS mode', DNS_LABELS[dns]],
|
|
455
|
+
['Site URL', plannedHost(parsed)],
|
|
456
|
+
['Notice', `Registering makes the server create an ownership TXT record and return it. Add that record in the DNS settings at your registrar, then verify ownership with ${next}.`]
|
|
529
457
|
], { domain, project, dns, site })
|
|
530
458
|
}, pretty, deps);
|
|
531
459
|
}
|
|
532
|
-
const sent = await authorized(deps, ({ siteUrl, token }) => postJson(new URL(DOMAINS_PATH, siteUrl).href, token, payload, deps, pretty ? '
|
|
460
|
+
const sent = await authorized(deps, ({ siteUrl, token }) => postJson(new URL(DOMAINS_PATH, siteUrl).href, token, payload, deps, pretty ? 'Registering the domain.' : null));
|
|
533
461
|
if ('login' in sent)
|
|
534
462
|
return sent.login;
|
|
535
463
|
const { session: { siteUrl }, result } = sent;
|
|
536
464
|
const failure = domainFailure(result, PROJECT_NOT_FOUND, REGISTER_FAILURES);
|
|
537
465
|
if (failure)
|
|
538
|
-
return failed(REGISTER, result, failure, pretty, depth, siteUrl, '
|
|
466
|
+
return failed(REGISTER, result, failure, pretty, depth, siteUrl, 'Could not register the domain.', { domain });
|
|
539
467
|
const registered = result.body;
|
|
540
468
|
const view = {
|
|
541
469
|
domain: registered.domain,
|
|
@@ -548,64 +476,64 @@ export async function runDomainsRegister(args, pretty, depth, deps = defaultAuth
|
|
|
548
476
|
};
|
|
549
477
|
if (!pretty)
|
|
550
478
|
return agentResult(0, { command: REGISTER.command, siteUrl, ...view, next });
|
|
551
|
-
return prettyResult(0, depth, REGISTER.command,
|
|
552
|
-
['
|
|
553
|
-
['
|
|
554
|
-
['
|
|
555
|
-
['
|
|
556
|
-
['
|
|
479
|
+
return prettyResult(0, depth, REGISTER.command, `Registered ${view.domain}. Add the ownership TXT record.`, [
|
|
480
|
+
['Server', siteUrl],
|
|
481
|
+
['Domain', view.domain],
|
|
482
|
+
['Project', view.project ?? DNS_ONLY],
|
|
483
|
+
['DNS mode', DNS_LABELS[view.dns]],
|
|
484
|
+
['Site URL', view.siteHost],
|
|
557
485
|
...recordRows(view.record),
|
|
558
|
-
['
|
|
486
|
+
['Verify by', seoulDateLabel(view.expiresAt)],
|
|
559
487
|
view.dns === 'ns'
|
|
560
|
-
? ['
|
|
561
|
-
: ['
|
|
488
|
+
? ['After verification', 'Change the nameservers at your registrar to connect the domain. The nameservers to use are shown when ownership is verified.']
|
|
489
|
+
: ['After verification', 'Also add the 2 CNAME records below in the DNS settings at your registrar to connect the domain.'],
|
|
562
490
|
...cnameRows(view.connect),
|
|
563
|
-
['
|
|
491
|
+
['Next', `Add the TXT record in the DNS settings at your registrar, then verify ownership with ${next}.`]
|
|
564
492
|
]);
|
|
565
493
|
}
|
|
566
494
|
function connectionRows({ domain, dns, status, nameservers, connect, imported }) {
|
|
567
495
|
if (status === 'ready')
|
|
568
496
|
return [];
|
|
569
497
|
if (dns === 'cname') {
|
|
570
|
-
return [...cnameRows(connect), ['
|
|
498
|
+
return [...cnameRows(connect), ['Next', `Add the 2 CNAME records above in the DNS settings at your registrar. They are checked automatically every 5 minutes, or run deepdynamic domains verify ${domain} to check now.`]];
|
|
571
499
|
}
|
|
572
500
|
return [
|
|
573
501
|
...(nameservers
|
|
574
|
-
? nameservers.map((nameserver) => ['
|
|
575
|
-
: [['
|
|
576
|
-
...(imported > 0 ? [['
|
|
577
|
-
['
|
|
578
|
-
['
|
|
502
|
+
? nameservers.map((nameserver) => ['Nameservers', nameserver])
|
|
503
|
+
: [['Nameservers', `Not created yet. Run deepdynamic domains verify ${domain} again in a few minutes.`]]),
|
|
504
|
+
...(imported > 0 ? [['Imported', counted(imported, 'record')]] : []),
|
|
505
|
+
['Warning', `Before changing the nameservers, check the imported records with deepdynamic dns records ${domain} and add any missing ones (mail, subdomains and so on) with deepdynamic dns add. Once the nameservers change, the records at the old DNS provider stop answering.`],
|
|
506
|
+
['Next', `Change the nameservers at your registrar to the ones above. They are checked automatically every 5 minutes, or run deepdynamic domains verify ${domain} to check now.`]
|
|
579
507
|
];
|
|
580
508
|
}
|
|
581
509
|
export async function runDomainsVerify(args, pretty, depth, deps = defaultAuthDeps(pretty, depth)) {
|
|
582
510
|
const { args: rest, dryRun } = splitDryRun(args);
|
|
583
511
|
const [input, ...extra] = rest;
|
|
584
|
-
const domain = parseDomain(input
|
|
512
|
+
const domain = parseDomain(input);
|
|
585
513
|
if (typeof domain !== 'string')
|
|
586
514
|
return invalid(VERIFY, domain.error, pretty, depth);
|
|
587
515
|
if (extra.length)
|
|
588
|
-
return invalid(VERIFY, unknownArgument(extra[0]
|
|
516
|
+
return invalid(VERIFY, unknownArgument(extra[0]), pretty, depth);
|
|
589
517
|
if (dryRun) {
|
|
590
518
|
return planned(VERIFY, {
|
|
591
519
|
steps: [
|
|
592
|
-
{ stage: 'validate_domain', message: '
|
|
593
|
-
{ stage: 'prepare_request', message: '
|
|
520
|
+
{ stage: 'validate_domain', message: 'Checking the domain format.' },
|
|
521
|
+
{ stage: 'prepare_request', message: 'Preparing the ownership check request.' }
|
|
594
522
|
],
|
|
595
|
-
finish: (siteUrl) => plannedChange(VERIFY.command, pretty, depth, siteUrl, { url: domainUrl(siteUrl, domain, 'verify'), body: {} }, '
|
|
596
|
-
['
|
|
597
|
-
['
|
|
523
|
+
finish: (siteUrl) => plannedChange(VERIFY.command, pretty, depth, siteUrl, { url: domainUrl(siteUrl, domain, 'verify'), body: {} }, 'Checked the ownership check request. Nothing was sent.', [
|
|
524
|
+
['Domain', domain],
|
|
525
|
+
['Impact', `Verifies ownership with the _deepdynamic.${domain} TXT record and connects the domain. For a domain that is already connected, only the nameservers or CNAME records are checked again.`]
|
|
598
526
|
], { domain })
|
|
599
527
|
}, pretty, deps);
|
|
600
528
|
}
|
|
601
|
-
const sent = await authorized(deps, ({ siteUrl, token }) => postJson(domainUrl(siteUrl, domain, 'verify'), token, {}, deps, pretty ? '
|
|
529
|
+
const sent = await authorized(deps, ({ siteUrl, token }) => postJson(domainUrl(siteUrl, domain, 'verify'), token, {}, deps, pretty ? 'Checking ownership and connection.' : null));
|
|
602
530
|
if ('login' in sent)
|
|
603
531
|
return sent.login;
|
|
604
532
|
const { session: { siteUrl }, result } = sent;
|
|
605
533
|
const failure = domainFailure(result, CLAIM_NOT_FOUND, VERIFY_FAILURES);
|
|
606
534
|
if (failure) {
|
|
607
535
|
const record = failure.code === 'txt_not_found' ? txtRecordOf(result) : undefined;
|
|
608
|
-
return failed(VERIFY, result, failure, pretty, depth, siteUrl, '
|
|
536
|
+
return failed(VERIFY, result, failure, pretty, depth, siteUrl, 'Could not verify ownership.', { domain }, record ? recordRows(record) : []);
|
|
609
537
|
}
|
|
610
538
|
const body = result.body;
|
|
611
539
|
const view = {
|
|
@@ -621,12 +549,12 @@ export async function runDomainsVerify(args, pretty, depth, deps = defaultAuthDe
|
|
|
621
549
|
if (!pretty)
|
|
622
550
|
return agentResult(0, { command: VERIFY.command, siteUrl, ...view });
|
|
623
551
|
return prettyResult(0, depth, VERIFY.command, VERIFIED[view.dns][view.status], [
|
|
624
|
-
['
|
|
625
|
-
['
|
|
626
|
-
['
|
|
627
|
-
['
|
|
628
|
-
['
|
|
629
|
-
['
|
|
552
|
+
['Server', siteUrl],
|
|
553
|
+
['Domain', view.domain],
|
|
554
|
+
['Project', view.project ?? NO_PROJECT],
|
|
555
|
+
['DNS mode', DNS_LABELS[view.dns]],
|
|
556
|
+
['Site URL', view.siteHost],
|
|
557
|
+
['Status', connectionLabel(view)],
|
|
630
558
|
...connectionRows(view)
|
|
631
559
|
]);
|
|
632
560
|
}
|
|
@@ -634,68 +562,68 @@ export async function runDomainsRemove(args, pretty, depth, deps = defaultAuthDe
|
|
|
634
562
|
const { args: plain, dryRun } = splitDryRun(args);
|
|
635
563
|
const { args: rest, yes } = splitYes(plain);
|
|
636
564
|
const [input, ...extra] = rest;
|
|
637
|
-
const domain = parseDomain(input
|
|
565
|
+
const domain = parseDomain(input);
|
|
638
566
|
if (typeof domain !== 'string')
|
|
639
567
|
return invalid(REMOVE, domain.error, pretty, depth);
|
|
640
568
|
if (extra.length)
|
|
641
|
-
return invalid(REMOVE, unknownArgument(extra[0]
|
|
569
|
+
return invalid(REMOVE, unknownArgument(extra[0]), pretty, depth);
|
|
642
570
|
if (dryRun) {
|
|
643
571
|
return planned(REMOVE, {
|
|
644
572
|
steps: [
|
|
645
|
-
{ stage: 'validate_domain', message: '
|
|
646
|
-
{ stage: 'review_impact', message: '
|
|
647
|
-
{ stage: 'prepare_request', message: '
|
|
573
|
+
{ stage: 'validate_domain', message: 'Checking the domain format.' },
|
|
574
|
+
{ stage: 'review_impact', message: 'Reviewing what disconnecting changes.' },
|
|
575
|
+
{ stage: 'prepare_request', message: 'Preparing the disconnect request.' }
|
|
648
576
|
],
|
|
649
|
-
finish: (siteUrl) => plannedChange(REMOVE.command, pretty, depth, siteUrl, { url: domainUrl(siteUrl, domain, 'remove'), body: {} }, '
|
|
577
|
+
finish: (siteUrl) => plannedChange(REMOVE.command, pretty, depth, siteUrl, { url: domainUrl(siteUrl, domain, 'remove'), body: {} }, 'Checked the disconnect. Nothing was disconnected.', [['Domain', domain], ['Impact', REMOVE_EFFECT], ['Warning', REMOVE_WARNING]], { domain })
|
|
650
578
|
}, pretty, deps);
|
|
651
579
|
}
|
|
652
580
|
if (!yes) {
|
|
653
581
|
return confirmationRequired(REMOVE.command, [domain], pretty, depth, {
|
|
654
582
|
message: 'Removing deletes the DNS zone, its records and the HTTPS certificate of the domain, and the site stops opening on it.',
|
|
655
|
-
display: '
|
|
583
|
+
display: 'Disconnecting deletes the DNS zone, its records and the HTTPS certificate of this domain, and the site stops opening on it. Confirm with the user, then run it again with --yes.'
|
|
656
584
|
}, { domain });
|
|
657
585
|
}
|
|
658
|
-
const sent = await authorized(deps, ({ siteUrl, token }) => postJson(domainUrl(siteUrl, domain, 'remove'), token, {}, deps, pretty ? '
|
|
586
|
+
const sent = await authorized(deps, ({ siteUrl, token }) => postJson(domainUrl(siteUrl, domain, 'remove'), token, {}, deps, pretty ? 'Disconnecting the domain.' : null));
|
|
659
587
|
if ('login' in sent)
|
|
660
588
|
return sent.login;
|
|
661
589
|
const { session: { siteUrl }, result } = sent;
|
|
662
590
|
const failure = domainFailure(result, DOMAIN_NOT_FOUND, REMOVE_FAILURES);
|
|
663
591
|
if (failure)
|
|
664
|
-
return failed(REMOVE, result, failure, pretty, depth, siteUrl, '
|
|
592
|
+
return failed(REMOVE, result, failure, pretty, depth, siteUrl, 'Could not disconnect the domain.', { domain });
|
|
665
593
|
return pretty
|
|
666
|
-
? prettyResult(0, depth, REMOVE.command,
|
|
594
|
+
? prettyResult(0, depth, REMOVE.command, `Disconnected ${domain}.`, [['Server', siteUrl], ['Domain', domain], ['Warning', REMOVE_WARNING]])
|
|
667
595
|
: agentResult(0, { command: REMOVE.command, siteUrl, domain, removed: true });
|
|
668
596
|
}
|
|
669
597
|
export async function runDomainsAutoRenew(args, pretty, depth, deps = defaultAuthDeps(pretty, depth)) {
|
|
670
598
|
const { args: plain, dryRun } = splitDryRun(args);
|
|
671
599
|
const { args: rest, yes } = splitYes(plain);
|
|
672
600
|
const [input, state, ...extra] = rest;
|
|
673
|
-
const domain = parseDomain(input
|
|
601
|
+
const domain = parseDomain(input);
|
|
674
602
|
if (typeof domain !== 'string')
|
|
675
603
|
return invalid(AUTO_RENEW, domain.error, pretty, depth);
|
|
676
604
|
if (state !== 'on' && state !== 'off')
|
|
677
|
-
return invalid(AUTO_RENEW,
|
|
605
|
+
return invalid(AUTO_RENEW, 'Give on or off after the domain.', pretty, depth);
|
|
678
606
|
if (extra.length)
|
|
679
|
-
return invalid(AUTO_RENEW, unknownArgument(extra[0]
|
|
607
|
+
return invalid(AUTO_RENEW, unknownArgument(extra[0]), pretty, depth);
|
|
680
608
|
const enabled = state === 'on';
|
|
681
|
-
const effect = enabled ? [] : [['
|
|
609
|
+
const effect = enabled ? [] : [['Warning', EXPIRY_WARNING]];
|
|
682
610
|
if (dryRun) {
|
|
683
611
|
return planned(AUTO_RENEW, {
|
|
684
612
|
steps: [
|
|
685
|
-
{ stage: 'validate_domain', message: '
|
|
686
|
-
{ stage: 'plan_renewal', message: '
|
|
687
|
-
{ stage: 'prepare_request', message: '
|
|
613
|
+
{ stage: 'validate_domain', message: 'Checking the domain format.' },
|
|
614
|
+
{ stage: 'plan_renewal', message: 'Reviewing the expiry impact.' },
|
|
615
|
+
{ stage: 'prepare_request', message: 'Preparing the auto-renew change request.' }
|
|
688
616
|
],
|
|
689
|
-
finish: (siteUrl) => plannedChange(AUTO_RENEW.command, pretty, depth, siteUrl, { url: domainUrl(siteUrl, domain, 'auto-renew'), body: { enabled } }, '
|
|
617
|
+
finish: (siteUrl) => plannedChange(AUTO_RENEW.command, pretty, depth, siteUrl, { url: domainUrl(siteUrl, domain, 'auto-renew'), body: { enabled } }, 'Checked the auto-renew change. Nothing was changed.', [['Domain', domain], ['Change', enabled ? 'Turn auto-renew on' : 'Turn auto-renew off'], ...effect], { domain, autoRenew: enabled })
|
|
690
618
|
}, pretty, deps);
|
|
691
619
|
}
|
|
692
620
|
if (!enabled && !yes) {
|
|
693
621
|
return confirmationRequired(AUTO_RENEW.command, [domain, state], pretty, depth, {
|
|
694
622
|
message: 'Turning auto-renew off lets the domain expire at the end of its term.',
|
|
695
|
-
display: '
|
|
623
|
+
display: 'Turning auto-renew off lets the domain expire at the end of its term. Confirm with the user, then run it again with --yes.'
|
|
696
624
|
}, { domain });
|
|
697
625
|
}
|
|
698
|
-
const sent = await authorized(deps, ({ siteUrl, token }) => postJson(domainUrl(siteUrl, domain, 'auto-renew'), token, { enabled }, deps, pretty ? '
|
|
626
|
+
const sent = await authorized(deps, ({ siteUrl, token }) => postJson(domainUrl(siteUrl, domain, 'auto-renew'), token, { enabled }, deps, pretty ? 'Changing auto-renew.' : null));
|
|
699
627
|
if ('login' in sent)
|
|
700
628
|
return sent.login;
|
|
701
629
|
const { session, result } = sent;
|
|
@@ -704,8 +632,8 @@ export async function runDomainsAutoRenew(args, pretty, depth, deps = defaultAut
|
|
|
704
632
|
return requestCard(AUTO_RENEW.command, pretty, depth, session, deps, { domain });
|
|
705
633
|
const failure = domainFailure(result, DOMAIN_NOT_FOUND, AUTO_RENEW_FAILURES);
|
|
706
634
|
if (failure)
|
|
707
|
-
return failed(AUTO_RENEW, result, failure, pretty, depth, siteUrl, '
|
|
635
|
+
return failed(AUTO_RENEW, result, failure, pretty, depth, siteUrl, 'Could not change auto-renew.', { domain });
|
|
708
636
|
return pretty
|
|
709
|
-
? prettyResult(0, depth, AUTO_RENEW.command, enabled ? '
|
|
637
|
+
? prettyResult(0, depth, AUTO_RENEW.command, enabled ? 'Turned auto-renew on.' : 'Turned auto-renew off.', [['Server', siteUrl], ['Domain', domain], ...effect])
|
|
710
638
|
: agentResult(0, { command: AUTO_RENEW.command, siteUrl, domain, autoRenew: enabled });
|
|
711
639
|
}
|