@deepdynamic/cli 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +32 -2
- package/THIRD_PARTY_NOTICES.txt +102 -0
- package/dist/agents/content.js +12 -0
- package/dist/agents/edit.js +140 -0
- package/dist/agents/install.js +180 -0
- package/dist/agents/setup.js +29 -0
- package/dist/agents/targets.js +91 -0
- package/dist/auth/credentials.js +63 -0
- package/dist/auth/session.js +49 -0
- package/dist/cli.js +198 -0
- package/dist/commands/account.js +96 -0
- package/dist/commands/activity.js +80 -0
- package/dist/commands/blocked.js +89 -0
- package/dist/commands/deploy/agents.js +11 -0
- package/dist/commands/deploy/files.js +62 -0
- package/dist/commands/deploy/index.js +95 -0
- package/dist/commands/deploy/manifest.js +24 -0
- package/dist/commands/deploy/minify.js +27 -0
- package/dist/commands/deploy/progress.js +85 -0
- package/dist/commands/deploy/ship.js +117 -0
- package/dist/commands/deploy/upload.js +125 -0
- package/dist/commands/deployments.js +59 -0
- package/dist/commands/dns.js +791 -0
- package/dist/commands/domains.js +711 -0
- package/dist/commands/emails.js +74 -0
- package/dist/commands/env.js +194 -0
- package/dist/commands/help.js +149 -0
- package/dist/commands/keys.js +269 -0
- package/dist/commands/login/flow.js +155 -0
- package/dist/commands/login/index.js +26 -0
- package/dist/commands/logout.js +71 -0
- package/dist/commands/mail.js +241 -0
- package/dist/commands/notifications.js +132 -0
- package/dist/commands/plan.js +371 -0
- package/dist/commands/projects.js +836 -0
- package/dist/commands/reference.js +2180 -0
- package/dist/commands/search.js +75 -0
- package/dist/commands/server.js +314 -0
- package/dist/commands/sessions.js +120 -0
- package/dist/commands/sites.js +102 -0
- package/dist/commands/sms.js +65 -0
- package/dist/commands/status.js +87 -0
- package/dist/commands/support.js +115 -0
- package/dist/commands/update.js +98 -0
- package/dist/commands/usage.js +51 -0
- package/dist/commands/verify.js +149 -0
- package/dist/commands/version.js +6 -0
- package/dist/guide.js +76 -0
- package/dist/http/call.js +6 -0
- package/dist/http/request.js +54 -0
- package/dist/index.js +11 -0
- package/dist/metadata.js +4 -0
- package/dist/output.js +9 -0
- package/dist/pretty.js +70 -0
- package/dist/registry.js +760 -0
- package/dist/runtime/browser.js +15 -0
- package/dist/runtime/card-request.js +55 -0
- package/dist/runtime/confirm.js +21 -0
- package/dist/runtime/development.js +13 -0
- package/dist/runtime/domain-name.js +5 -0
- package/dist/runtime/dry-run.js +28 -0
- package/dist/runtime/env-file.js +58 -0
- package/dist/runtime/error-hints.js +26 -0
- package/dist/runtime/flags.js +50 -0
- package/dist/runtime/login-screen.js +78 -0
- package/dist/runtime/page.js +18 -0
- package/dist/runtime/project-name.js +1 -0
- package/dist/runtime/run-mode.js +7 -0
- package/dist/runtime/server-options.js +32 -0
- package/dist/runtime/spinner.js +15 -0
- package/dist/runtime/suggest.js +22 -0
- package/dist/runtime/support.js +14 -0
- package/dist/runtime/text-file.js +20 -0
- package/dist/runtime/timeout.js +22 -0
- package/dist/runtime/update-check.js +124 -0
- package/dist/runtime/update-install.js +50 -0
- package/dist/runtime/usage-error.js +9 -0
- package/dist/setup-agents.js +8 -0
- package/dist/site.js +1 -0
- package/dist/update-refresh.js +5 -0
- package/package.json +46 -3
|
@@ -0,0 +1,791 @@
|
|
|
1
|
+
import { authorized, defaultAuthDeps, signedIn } from "../auth/session.js";
|
|
2
|
+
import { LOGIN_EXPIRED, accepted, httpFailure, postJson, request, sendFailureError } from "../http/request.js";
|
|
3
|
+
import { agentResult } from "../output.js";
|
|
4
|
+
import { prettyResult } from "../pretty.js";
|
|
5
|
+
import { cardRequired, requestCard } from "../runtime/card-request.js";
|
|
6
|
+
import { cleanDomain, isDomain } from "../runtime/domain-name.js";
|
|
7
|
+
import { spec } from "../registry.js";
|
|
8
|
+
import { confirmationRequired, splitYes } from "../runtime/confirm.js";
|
|
9
|
+
import { pageRows, pagination, parsePage } from "../runtime/page.js";
|
|
10
|
+
import { plannedChange, plannedRequest, rehearse, splitDryRun } from "../runtime/dry-run.js";
|
|
11
|
+
import { parseFlags, unknownArgument } from "../runtime/flags.js";
|
|
12
|
+
import { PROJECT } from "../runtime/project-name.js";
|
|
13
|
+
export const DNS_PATH = '/api/v1/dns';
|
|
14
|
+
export const DNS_SITE_DOMAIN = 'deepdynamic.dev';
|
|
15
|
+
const RECORD_TYPES = {
|
|
16
|
+
A: 'IPv4 주소', AAAA: 'IPv6 주소', CNAME: '다른 도메인', MX: '메일 서버', TXT: '확인용 문구', CAA: '인증서 발급 허용',
|
|
17
|
+
NS: '네임서버 위임', PTR: '역방향 조회', SRV: '서비스 위치'
|
|
18
|
+
};
|
|
19
|
+
export const DNS_RECORD_TYPES = Object.keys(RECORD_TYPES);
|
|
20
|
+
const TTLS = [['auto', 1, '자동'], ['300', 300, '5분'], ['3600', 3600, '1시간'], ['86400', 86400, '1일']];
|
|
21
|
+
const HOST_TYPES = ['CNAME', 'MX', 'NS', 'PTR'];
|
|
22
|
+
const LABEL = '[a-z0-9_]([a-z0-9_-]*[a-z0-9])?';
|
|
23
|
+
const NAME = new RegExp(`^(@|(\\*\\.)?${LABEL}(\\.${LABEL})*|\\*)$`);
|
|
24
|
+
const HOST = /^([a-z0-9]([a-z0-9-]*[a-z0-9])?\.)+[a-z]{2,}$/;
|
|
25
|
+
const RECORD_ID = /^[a-z0-9]([a-z0-9-]{0,62}[a-z0-9])?$/;
|
|
26
|
+
const PRIORITY = /^\d{1,5}$/;
|
|
27
|
+
const RECORD_FLAGS = ['--type', '--name', '--value', '--ttl', '--priority'];
|
|
28
|
+
const RESTORE_FLAGS = ['--project', '--name'];
|
|
29
|
+
const PROPAGATION = '적용하면 보통 몇 분 안에 전 세계로 퍼지고, 길게는 TTL 만큼 이전 값이 남아 있을 수 있습니다.';
|
|
30
|
+
const APPLIED_PROPAGATION = '보통 몇 분 안에 전 세계로 퍼지고, 길게는 TTL 만큼 이전 값이 남아 있을 수 있습니다.';
|
|
31
|
+
const PENDING = 'DNS를 준비하고 있습니다. 보통 몇 분 안에 끝납니다.';
|
|
32
|
+
const PENDING_APPLY = 'DNS를 준비하고 있습니다. 준비가 끝나면 저장한 레코드가 함께 적용됩니다.';
|
|
33
|
+
const NO_PROJECT = '연결한 프로젝트 없음';
|
|
34
|
+
const SYNC_EFFECT = '저장한 레코드를 기준으로 DNS 서버를 맞춥니다. 존을 아직 준비하고 있으면 존 생성·레코드 반영·네임서버 교체를 지금 바로 시도합니다.';
|
|
35
|
+
const SYNC_WARNING = 'DNS 서버에서만 직접 바꾼 레코드는 저장한 레코드에 없으므로 사라집니다.';
|
|
36
|
+
const DNSSEC_STATES = { on: '사용 중', enabling: '적용 중', disabling: '해제 중(2일 뒤 서명 해제)', off: '꺼짐', unsupported: '미지원' };
|
|
37
|
+
const DNSSEC_NOTES = {
|
|
38
|
+
on: '존 서명과 도메인을 산 곳(등록처)의 DS 레코드 등록을 마쳤습니다.',
|
|
39
|
+
enabling: '존 서명과 도메인을 산 곳(등록처)의 DS 레코드 등록을 진행하고 있습니다. 보통 몇 분 안에 끝납니다.',
|
|
40
|
+
disabling: '도메인을 산 곳(등록처)의 DS 레코드를 지우고, 이미 퍼진 DS 레코드가 만료되도록 2일 뒤 존 서명을 해제합니다.',
|
|
41
|
+
off: 'DNS 서버가 존에 서명하지 않습니다.',
|
|
42
|
+
unsupported: '도메인을 산 곳(등록처)이 이 도메인의 DS 레코드 등록을 거절했습니다. 이 TLD 는 DNSSEC 을 지원하지 않는 것 같아 켤 수 없습니다.'
|
|
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: '그 이름의 내 프로젝트를 찾을 수 없습니다.'
|
|
66
|
+
};
|
|
67
|
+
const NOT_FOUND = { domain_not_found: DOMAIN_NOT_FOUND, record_not_found: RECORD_NOT_FOUND, project_not_found: PROJECT_NOT_FOUND };
|
|
68
|
+
const DNSSEC_FAILURES = {
|
|
69
|
+
external_domain: {
|
|
70
|
+
code: 'external_domain',
|
|
71
|
+
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: '다른 곳에서 산 도메인입니다. DNSSEC 은 딥다이나믹에서 구입한 도메인만 켜고 끌 수 있습니다.'
|
|
73
|
+
},
|
|
74
|
+
dnssec_unsupported: {
|
|
75
|
+
code: 'dnssec_unsupported',
|
|
76
|
+
message: 'The registrar rejected the DS record of this domain, most likely because its TLD does not support DNSSEC, so DNSSEC cannot be turned on. Nothing changed; tell the user and do not retry.',
|
|
77
|
+
display: DNSSEC_NOTES.unsupported
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
export const fail = (pretty, message, display) => ({ error: pretty ? display : message });
|
|
81
|
+
const hostName = (name, domain) => name === '@' ? domain : `${name}.${domain}`;
|
|
82
|
+
const ttlLabel = (seconds) => TTLS.find(([, value]) => value === seconds)?.[2] ?? `${seconds}초`;
|
|
83
|
+
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' ? [['적용', PENDING_APPLY]] : [];
|
|
86
|
+
const analyticsState = (zone) => zone.analytics ? `Google Analytics ${zone.analytics.measurementId} · ${zone.analytics.connectedAt.slice(0, 10)} 등록` : 'Google Analytics 등록 전';
|
|
87
|
+
function dnssecRows(zone, explain = false) {
|
|
88
|
+
if (!zone.dnssec)
|
|
89
|
+
return [];
|
|
90
|
+
const state = ['DNSSEC', DNSSEC_STATES[zone.dnssec]];
|
|
91
|
+
if (!explain)
|
|
92
|
+
return [state];
|
|
93
|
+
return [state, ['안내', zone.dnssec === 'enabling' && zone.status === 'pending' ? DNSSEC_AFTER_ZONE : DNSSEC_NOTES[zone.dnssec]]];
|
|
94
|
+
}
|
|
95
|
+
function normalizeName(input, domain) {
|
|
96
|
+
const name = input.trim().toLowerCase().replace(/\.$/, '');
|
|
97
|
+
if (!name || name === domain)
|
|
98
|
+
return '@';
|
|
99
|
+
return name.endsWith(`.${domain}`) ? name.slice(0, -domain.length - 1) : name;
|
|
100
|
+
}
|
|
101
|
+
function normalizeValue(type, input) {
|
|
102
|
+
const value = input.trim();
|
|
103
|
+
if (HOST_TYPES.includes(type))
|
|
104
|
+
return value.toLowerCase().replace(/\.$/, '');
|
|
105
|
+
return type === 'A' || type === 'AAAA' ? value.toLowerCase() : value;
|
|
106
|
+
}
|
|
107
|
+
function isIpv4(value) {
|
|
108
|
+
const parts = value.split('.');
|
|
109
|
+
return parts.length === 4 && parts.every((part) => /^(0|[1-9]\d{0,2})$/.test(part) && Number(part) <= 255);
|
|
110
|
+
}
|
|
111
|
+
function isIpv6(value) {
|
|
112
|
+
const halves = value.split('::');
|
|
113
|
+
if (halves.length > 2)
|
|
114
|
+
return false;
|
|
115
|
+
const groups = halves.flatMap((half) => half ? half.split(':') : []);
|
|
116
|
+
if (!groups.every((group) => /^[0-9a-f]{1,4}$/.test(group)))
|
|
117
|
+
return false;
|
|
118
|
+
return halves.length === 2 ? groups.length < 8 : groups.length === 8;
|
|
119
|
+
}
|
|
120
|
+
function describeRecord(record, domain) {
|
|
121
|
+
const host = hostName(record.name, domain);
|
|
122
|
+
if (record.type === 'A' || record.type === 'AAAA')
|
|
123
|
+
return `${host} 방문자를 ${record.value} 서버로 안내합니다.`;
|
|
124
|
+
if (record.type === 'CNAME')
|
|
125
|
+
return `${host} 방문자를 ${record.value} 주소로 안내합니다.`;
|
|
126
|
+
if (record.type === 'MX')
|
|
127
|
+
return `${host} 앞으로 온 메일은 ${record.value} 서버가 받습니다.`;
|
|
128
|
+
if (record.type === 'TXT')
|
|
129
|
+
return `${host}의 소유 확인이나 메일 보안 설정에 쓰는 문구입니다.`;
|
|
130
|
+
return `${host}의 ${RECORD_TYPES[record.type]} 레코드입니다.`;
|
|
131
|
+
}
|
|
132
|
+
function recordRows(record, domain, propagation = PROPAGATION) {
|
|
133
|
+
return [
|
|
134
|
+
['레코드', `${record.type} ${hostName(record.name, domain)} → ${record.value}`],
|
|
135
|
+
['TTL', ttlLabel(record.ttl)],
|
|
136
|
+
...(record.priority === undefined ? [] : [['우선순위', `${record.priority} (숫자가 작을수록 먼저 메일을 받습니다)`]]),
|
|
137
|
+
['설명', describeRecord(record, domain)],
|
|
138
|
+
['전파', propagation]
|
|
139
|
+
];
|
|
140
|
+
}
|
|
141
|
+
function readFlags(args, flags, pretty) {
|
|
142
|
+
const parsed = parseFlags(args, flags, pretty);
|
|
143
|
+
if ('error' in parsed)
|
|
144
|
+
return parsed;
|
|
145
|
+
const values = {};
|
|
146
|
+
for (const [flag, value] of parsed.entries) {
|
|
147
|
+
if (values[flag] !== undefined)
|
|
148
|
+
return fail(pretty, `Give ${flag} only once.`, `${flag} 는 한 번만 지정하세요.`);
|
|
149
|
+
values[flag] = value;
|
|
150
|
+
}
|
|
151
|
+
return values;
|
|
152
|
+
}
|
|
153
|
+
export function parseDomain(input, pretty) {
|
|
154
|
+
if (input === undefined || input.startsWith('-'))
|
|
155
|
+
return fail(pretty, 'Specify the domain first.', '도메인을 먼저 지정하세요.');
|
|
156
|
+
const domain = cleanDomain(input);
|
|
157
|
+
return isDomain(domain) ? domain : fail(pretty, `Not a valid domain: ${input}`, `도메인 형식이 올바르지 않습니다: ${input}`);
|
|
158
|
+
}
|
|
159
|
+
function parseRecordId(input, pretty) {
|
|
160
|
+
if (input === undefined || input.startsWith('-'))
|
|
161
|
+
return fail(pretty, 'Specify the record ID after the domain.', '도메인 뒤에 레코드 ID 를 지정하세요.');
|
|
162
|
+
return RECORD_ID.test(input)
|
|
163
|
+
? input
|
|
164
|
+
: fail(pretty, `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}`, `레코드 ID 는 deepdynamic dns records 에 나온 1~64자의 영문 소문자·숫자·하이픈입니다: ${input}`);
|
|
165
|
+
}
|
|
166
|
+
function parseName(input, domain, pretty) {
|
|
167
|
+
const name = normalizeName(input, domain);
|
|
168
|
+
return NAME.test(name)
|
|
169
|
+
? name
|
|
170
|
+
: fail(pretty, `--name must be @ for the domain itself or a label such as www made of lowercase letters, digits, hyphens and underscores: ${input}`, `--name 에는 @ 또는 www 처럼 영문 소문자·숫자·하이픈으로 된 앞부분을 지정하세요: ${input}`);
|
|
171
|
+
}
|
|
172
|
+
const CONTROL = /[\u0000-\u001f\u007f]/;
|
|
173
|
+
const TARGET = /^(_?[a-z0-9]([a-z0-9-]*[a-z0-9])?\.)+[a-z]{2,}$/i;
|
|
174
|
+
const CAA = /^(\d{1,3}) (issue|issuewild|iodef|contactemail|contactphone) ("[^"]*")$/;
|
|
175
|
+
const inRange = (token, max) => /^\d{1,5}$/.test(token) && Number(token) <= max;
|
|
176
|
+
const hostOrRoot = (token) => token === '.' || TARGET.test(token);
|
|
177
|
+
const VALUE_CHECKS = {
|
|
178
|
+
A: isIpv4,
|
|
179
|
+
AAAA: isIpv6,
|
|
180
|
+
CNAME: (value) => HOST.test(value),
|
|
181
|
+
MX: (value) => HOST.test(value),
|
|
182
|
+
NS: (value) => HOST.test(value),
|
|
183
|
+
PTR: (value) => HOST.test(value),
|
|
184
|
+
TXT: (value) => value.length <= 4000 && !CONTROL.test(value),
|
|
185
|
+
CAA: (value) => { const match = CAA.exec(value); return !!match && Number(match[1]) <= 255; },
|
|
186
|
+
SRV: (value) => { const parts = value.split(' '); return parts.length === 4 && parts.slice(0, 3).every((part) => inRange(part, 65535)) && hostOrRoot(parts[3]); }
|
|
187
|
+
};
|
|
188
|
+
const VALUE_RULES = {
|
|
189
|
+
A: ['an IPv4 address such as 198.51.100.24', 'IPv4 주소 형식이어야 합니다. 예: 198.51.100.24'],
|
|
190
|
+
AAAA: ['an IPv6 address such as 2001:db8::1', 'IPv6 주소 형식이어야 합니다. 예: 2001:db8::1'],
|
|
191
|
+
CNAME: ['a host name such as mail.example.com', '도메인 형식이어야 합니다. https:// 나 경로, IP 주소는 쓸 수 없습니다. 예: mail.example.com'],
|
|
192
|
+
MX: ['a host name such as mail.example.com', '도메인 형식이어야 합니다. https:// 나 경로, IP 주소는 쓸 수 없습니다. 예: mail.example.com'],
|
|
193
|
+
NS: ['a host name such as mail.example.com', '도메인 형식이어야 합니다. https:// 나 경로, IP 주소는 쓸 수 없습니다. 예: mail.example.com'],
|
|
194
|
+
PTR: ['a host name such as mail.example.com', '도메인 형식이어야 합니다. https:// 나 경로, IP 주소는 쓸 수 없습니다. 예: mail.example.com'],
|
|
195
|
+
TXT: ['1-4000 characters without control characters', '1자 이상 4000자 이하이고 제어 문자를 담을 수 없습니다.'],
|
|
196
|
+
CAA: ['flags tag "value" with tag issue, issuewild, iodef, contactemail or contactphone, such as 0 issue "letsencrypt.org"', '"플래그 태그 "값"" 순서입니다. 태그는 issue·issuewild·iodef·contactemail·contactphone 중 하나입니다. 예: 0 issue "letsencrypt.org"'],
|
|
197
|
+
SRV: ['priority weight port target, such as 10 5 5060 sip.example.com', '"우선순위 가중치 포트 대상" 순서입니다. 예: 10 5 5060 sip.example.com']
|
|
198
|
+
};
|
|
199
|
+
function valueError(type, value, pretty) {
|
|
200
|
+
if (VALUE_CHECKS[type](value))
|
|
201
|
+
return null;
|
|
202
|
+
const [rule, prettyRule] = VALUE_RULES[type];
|
|
203
|
+
return fail(pretty, `--value for ${type} records must be ${rule}.`, `${type} 레코드의 --value 는 ${prettyRule}`);
|
|
204
|
+
}
|
|
205
|
+
function apexError(type, name, pretty) {
|
|
206
|
+
if (name !== '@')
|
|
207
|
+
return null;
|
|
208
|
+
if (type === 'CNAME')
|
|
209
|
+
return fail(pretty, 'A CNAME cannot be on the domain itself (@). Use a name such as www.', '도메인 자체(@)에는 CNAME 을 쓸 수 없습니다. www 같은 이름을 지정하세요.');
|
|
210
|
+
if (type === 'NS')
|
|
211
|
+
return fail(pretty, 'The NS records of the domain itself (@) cannot be changed.', '도메인 자체(@)의 NS 레코드는 바꿀 수 없습니다.');
|
|
212
|
+
return null;
|
|
213
|
+
}
|
|
214
|
+
function parseRecord(args, domain, pretty) {
|
|
215
|
+
const values = readFlags(args, RECORD_FLAGS, pretty);
|
|
216
|
+
if ('error' in values)
|
|
217
|
+
return values;
|
|
218
|
+
const { '--type': rawType, '--name': rawName, '--value': rawValue, '--ttl': rawTtl, '--priority': rawPriority } = values;
|
|
219
|
+
if (rawType === undefined || rawName === undefined || rawValue === undefined) {
|
|
220
|
+
const missing = RECORD_FLAGS.find((flag) => values[flag] === undefined);
|
|
221
|
+
return fail(pretty, `${missing} is required.`, `${missing} 를 지정하세요.`);
|
|
222
|
+
}
|
|
223
|
+
const type = rawType.trim().toUpperCase();
|
|
224
|
+
if (!Object.hasOwn(RECORD_TYPES, type)) {
|
|
225
|
+
return fail(pretty, `--type must be one of ${DNS_RECORD_TYPES.join(', ')}: ${rawType}`, `--type 에는 레코드 종류(${DNS_RECORD_TYPES.join(', ')})를 지정하세요: ${rawType}`);
|
|
226
|
+
}
|
|
227
|
+
const recordType = type;
|
|
228
|
+
const name = parseName(rawName, domain, pretty);
|
|
229
|
+
if (typeof name !== 'string')
|
|
230
|
+
return name;
|
|
231
|
+
const apex = apexError(recordType, name, pretty);
|
|
232
|
+
if (apex)
|
|
233
|
+
return apex;
|
|
234
|
+
const value = normalizeValue(recordType, rawValue);
|
|
235
|
+
const invalidValue = valueError(recordType, value, pretty);
|
|
236
|
+
if (invalidValue)
|
|
237
|
+
return invalidValue;
|
|
238
|
+
const ttl = rawTtl === undefined ? 1 : TTLS.find(([input]) => input === rawTtl)?.[1];
|
|
239
|
+
if (ttl === undefined)
|
|
240
|
+
return fail(pretty, `--ttl must be auto, 300, 3600 or 86400: ${rawTtl}`, `--ttl 에는 auto·300·3600·86400 중 하나를 지정하세요: ${rawTtl}`);
|
|
241
|
+
if (recordType !== 'MX') {
|
|
242
|
+
return rawPriority === undefined
|
|
243
|
+
? { type: recordType, name, value, ttl }
|
|
244
|
+
: fail(pretty, '--priority applies only to MX records.', '--priority 는 MX 레코드에만 씁니다.');
|
|
245
|
+
}
|
|
246
|
+
if (rawPriority === undefined)
|
|
247
|
+
return fail(pretty, '--priority is required for MX records.', '--priority 를 지정하세요. MX 레코드는 우선순위가 필요합니다.');
|
|
248
|
+
if (!PRIORITY.test(rawPriority) || Number(rawPriority) > 65535) {
|
|
249
|
+
return fail(pretty, `--priority must be an integer from 0 to 65535: ${rawPriority}`, `--priority 에는 0부터 65535 사이 정수를 지정하세요: ${rawPriority}`);
|
|
250
|
+
}
|
|
251
|
+
return { type: recordType, name, value, ttl, priority: Number(rawPriority) };
|
|
252
|
+
}
|
|
253
|
+
const getWithToken = (url, token, deps, spinner) => request(url, { method: 'GET', headers: { authorization: `Bearer ${token}` } }, deps, spinner);
|
|
254
|
+
function dnsFailure(result, notFound, conflict, failures = {}, succeeded = accepted) {
|
|
255
|
+
if ('failure' in result)
|
|
256
|
+
return result.failure;
|
|
257
|
+
if (succeeded(result))
|
|
258
|
+
return null;
|
|
259
|
+
const known = result.body?.code;
|
|
260
|
+
if (typeof known === 'string' && Object.hasOwn(failures, known))
|
|
261
|
+
return failures[known];
|
|
262
|
+
if (result.status === 401)
|
|
263
|
+
return LOGIN_EXPIRED;
|
|
264
|
+
if (result.status === 403)
|
|
265
|
+
return { code: 'login_required', message: 'The access token is not allowed to do this. Run deepdynamic login again.', display: '이 로그인으로는 할 수 없습니다. deepdynamic login 으로 다시 로그인하세요.' };
|
|
266
|
+
if (result.status === 404) {
|
|
267
|
+
const code = result.body?.code;
|
|
268
|
+
return typeof code === 'string' && Object.hasOwn(NOT_FOUND, code) ? NOT_FOUND[code] : notFound;
|
|
269
|
+
}
|
|
270
|
+
if (result.status === 400)
|
|
271
|
+
return { code: 'invalid_arguments', message: 'The server rejected the request. Check the arguments against the command help.', display: '요청 내용을 확인하세요.' };
|
|
272
|
+
if (result.status === 409) {
|
|
273
|
+
return conflict ?? { code: 'site_unavailable', message: 'The project name cannot be used as a site address.', display: '이 프로젝트로는 사이트를 연결할 수 없습니다.' };
|
|
274
|
+
}
|
|
275
|
+
return httpFailure(result.status);
|
|
276
|
+
}
|
|
277
|
+
async function applied(command, send, pretty, depth, deps) {
|
|
278
|
+
const sent = await authorized(deps, ({ siteUrl, token }) => {
|
|
279
|
+
const url = send.url(siteUrl);
|
|
280
|
+
const spinner = pretty ? send.spinner : null;
|
|
281
|
+
return send.method === 'GET' ? getWithToken(url, token, deps, spinner) : postJson(url, token, send.body ?? {}, deps, spinner);
|
|
282
|
+
});
|
|
283
|
+
if ('login' in sent)
|
|
284
|
+
return sent.login;
|
|
285
|
+
const { session, result } = sent;
|
|
286
|
+
const { siteUrl } = session;
|
|
287
|
+
if (cardRequired(result))
|
|
288
|
+
return requestCard(command, pretty, depth, session, deps);
|
|
289
|
+
const intercepted = 'failure' in result ? null : send.intercept?.(result, siteUrl);
|
|
290
|
+
if (intercepted)
|
|
291
|
+
return intercepted;
|
|
292
|
+
const failure = dnsFailure(result, send.notFound, send.conflict, send.failures, send.succeeded);
|
|
293
|
+
if (failure) {
|
|
294
|
+
return pretty
|
|
295
|
+
? prettyResult(1, depth, command, send.failed, [['서버', siteUrl], ['원인', failure.display]])
|
|
296
|
+
: agentResult(1, { command, siteUrl, error: sendFailureError(result, failure) });
|
|
297
|
+
}
|
|
298
|
+
return send.done(result.body, siteUrl);
|
|
299
|
+
}
|
|
300
|
+
export async function rehearsed(command, args, pretty, depth, deps, plan, confirm) {
|
|
301
|
+
const { usage, prettyUsage } = spec(command);
|
|
302
|
+
const { args: plain, dryRun } = splitDryRun(args);
|
|
303
|
+
const { args: rest, yes } = confirm ? splitYes(plain) : { args: plain, yes: false };
|
|
304
|
+
const planned = plan(rest);
|
|
305
|
+
if ('error' in planned) {
|
|
306
|
+
return pretty
|
|
307
|
+
? prettyResult(2, depth, command, planned.error, [['사용법', prettyUsage]])
|
|
308
|
+
: agentResult(2, { command, error: { code: 'invalid_arguments', message: planned.error }, usage });
|
|
309
|
+
}
|
|
310
|
+
if (!dryRun)
|
|
311
|
+
return confirm && !yes ? confirmationRequired(command, planned.confirmArgs ?? plain, pretty, depth, confirm) : applied(command, planned.send, pretty, depth, deps);
|
|
312
|
+
const session = await signedIn(deps);
|
|
313
|
+
if ('login' in session)
|
|
314
|
+
return session.login;
|
|
315
|
+
await rehearse(command, planned.steps, pretty, deps.stream, deps.pause);
|
|
316
|
+
return planned.result(session.siteUrl);
|
|
317
|
+
}
|
|
318
|
+
const zoneOf = (body) => body.zone;
|
|
319
|
+
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
|
+
function changed(command, pretty, depth, message, rows, zone, siteUrl, extra) {
|
|
321
|
+
return pretty
|
|
322
|
+
? prettyResult(0, depth, command, message, [['서버', siteUrl], ['도메인', zone.domain], ...rows, ...pendingRows(zone)])
|
|
323
|
+
: agentResult(0, { command, siteUrl, applied: true, domain: zone.domain, ...extra, zone });
|
|
324
|
+
}
|
|
325
|
+
export async function runDnsList(args, pretty, depth, deps = defaultAuthDeps(pretty, depth)) {
|
|
326
|
+
const command = 'dns';
|
|
327
|
+
return rehearsed(command, args, pretty, depth, deps, (rest) => {
|
|
328
|
+
const page = parsePage(rest, pretty);
|
|
329
|
+
if (typeof page !== 'number')
|
|
330
|
+
return page;
|
|
331
|
+
const listUrl = (siteUrl) => `${new URL(DNS_PATH, siteUrl).href}?page=${page}`;
|
|
332
|
+
return {
|
|
333
|
+
steps: [{ stage: 'prepare_request', message: '관리 중인 도메인 목록 조회 요청을 준비하고 있습니다.' }],
|
|
334
|
+
result: (siteUrl) => plannedRequest(command, pretty, depth, siteUrl, listUrl(siteUrl)),
|
|
335
|
+
send: {
|
|
336
|
+
method: 'GET',
|
|
337
|
+
url: listUrl,
|
|
338
|
+
spinner: '관리 중인 도메인을 불러오고 있습니다.',
|
|
339
|
+
failed: '관리 중인 도메인을 불러오지 못했습니다.',
|
|
340
|
+
notFound: httpFailure(404),
|
|
341
|
+
done: (body, siteUrl) => {
|
|
342
|
+
const { zones, ...paged } = body;
|
|
343
|
+
const paging = pagination(paged, command);
|
|
344
|
+
if (!pretty)
|
|
345
|
+
return agentResult(0, { command, siteUrl, ...paging, zones });
|
|
346
|
+
return prettyResult(0, depth, command, zones.length ? `관리 중인 도메인 ${zones.length}개를 불러왔습니다.` : '관리 중인 도메인이 없습니다. 도메인을 구입하면 여기서 레코드를 관리할 수 있습니다.', [
|
|
347
|
+
['서버', siteUrl],
|
|
348
|
+
...zones.map((zone) => [
|
|
349
|
+
zone.domain,
|
|
350
|
+
[zone.project ?? NO_PROJECT, zoneState(zone), ...(zone.dnssec ? [`DNSSEC ${DNSSEC_STATES[zone.dnssec]}`] : []), `레코드 ${zone.records.length}개`].join(' · ')
|
|
351
|
+
]),
|
|
352
|
+
...pageRows(paging)
|
|
353
|
+
]);
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
};
|
|
357
|
+
});
|
|
358
|
+
}
|
|
359
|
+
export async function runDnsRecords(args, pretty, depth, deps = defaultAuthDeps(pretty, depth)) {
|
|
360
|
+
const command = 'dns records';
|
|
361
|
+
return rehearsed(command, args, pretty, depth, deps, ([input, ...extra]) => {
|
|
362
|
+
const domain = parseDomain(input, pretty);
|
|
363
|
+
if (typeof domain !== 'string')
|
|
364
|
+
return domain;
|
|
365
|
+
if (extra.length)
|
|
366
|
+
return { error: unknownArgument(extra[0], pretty) };
|
|
367
|
+
return {
|
|
368
|
+
steps: [CHECK_DOMAIN, { stage: 'prepare_request', message: '레코드 목록 조회 요청을 준비하고 있습니다.' }],
|
|
369
|
+
result: (siteUrl) => plannedRequest(command, pretty, depth, siteUrl, recordsUrl(siteUrl, domain)),
|
|
370
|
+
send: {
|
|
371
|
+
method: 'GET',
|
|
372
|
+
url: (siteUrl) => recordsUrl(siteUrl, domain),
|
|
373
|
+
spinner: '레코드를 불러오고 있습니다.',
|
|
374
|
+
failed: '레코드를 불러오지 못했습니다.',
|
|
375
|
+
notFound: DOMAIN_NOT_FOUND,
|
|
376
|
+
done: (body, siteUrl) => {
|
|
377
|
+
const zone = zoneOf(body);
|
|
378
|
+
if (!pretty)
|
|
379
|
+
return agentResult(0, { command, siteUrl, zone });
|
|
380
|
+
return prettyResult(0, depth, command, zone.records.length ? `${zone.domain} 레코드 ${zone.records.length}개를 불러왔습니다.` : `${zone.domain} 에는 아직 레코드가 없습니다.`, [
|
|
381
|
+
['서버', siteUrl],
|
|
382
|
+
['프로젝트', zone.project ?? NO_PROJECT],
|
|
383
|
+
['상태', zoneState(zone)],
|
|
384
|
+
...dnssecRows(zone),
|
|
385
|
+
['Google', zone.searchConsole ? `Search Console ${zone.searchConsole.connectedAt.slice(0, 10)} 등록` : 'Search Console 등록 전'],
|
|
386
|
+
['GA4', analyticsState(zone)],
|
|
387
|
+
...zone.records.map((record) => [
|
|
388
|
+
record.id,
|
|
389
|
+
`${record.type} ${hostName(record.name, zone.domain)} → ${record.value}${record.priority === undefined ? '' : ` (우선순위 ${record.priority})`} · TTL ${ttlLabel(record.ttl)}`
|
|
390
|
+
]),
|
|
391
|
+
...(zone.nameservers ? [['네임서버', zone.nameservers.join(', ')]] : [])
|
|
392
|
+
]);
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
};
|
|
396
|
+
});
|
|
397
|
+
}
|
|
398
|
+
export async function runDnsAdd(args, pretty, depth, deps = defaultAuthDeps(pretty, depth)) {
|
|
399
|
+
const command = 'dns add';
|
|
400
|
+
return rehearsed(command, args, pretty, depth, deps, ([input, ...flags]) => {
|
|
401
|
+
const domain = parseDomain(input, pretty);
|
|
402
|
+
if (typeof domain !== 'string')
|
|
403
|
+
return domain;
|
|
404
|
+
const record = parseRecord(flags, domain, pretty);
|
|
405
|
+
if ('error' in record)
|
|
406
|
+
return record;
|
|
407
|
+
const host = hostName(record.name, domain);
|
|
408
|
+
return {
|
|
409
|
+
steps: [CHECK_DOMAIN, CHECK_RECORD, DESCRIBE_RECORD, PREPARE_REQUEST],
|
|
410
|
+
result: (siteUrl) => plannedChange(command, pretty, depth, siteUrl, { url: recordsUrl(siteUrl, domain), body: { ...record } }, 'DNS 레코드를 확인했습니다. 추가하지 않았습니다.', [['도메인', domain], ...recordRows(record, domain)], { domain, host, record }),
|
|
411
|
+
send: {
|
|
412
|
+
method: 'POST',
|
|
413
|
+
url: (siteUrl) => recordsUrl(siteUrl, domain),
|
|
414
|
+
body: { ...record },
|
|
415
|
+
spinner: '레코드를 추가하고 있습니다.',
|
|
416
|
+
failed: '레코드를 추가하지 못했습니다.',
|
|
417
|
+
notFound: DOMAIN_NOT_FOUND,
|
|
418
|
+
done: (body, siteUrl) => {
|
|
419
|
+
const zone = zoneOf(body);
|
|
420
|
+
const saved = savedRecord(zone, record);
|
|
421
|
+
return changed(command, pretty, depth, `${host} 레코드를 추가했습니다.`, [...(saved ? [['레코드 ID', saved.id]] : []), ...recordRows(record, domain, APPLIED_PROPAGATION)], zone, siteUrl, { host, record: saved ?? record });
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
};
|
|
425
|
+
});
|
|
426
|
+
}
|
|
427
|
+
export async function runDnsUpdate(args, pretty, depth, deps = defaultAuthDeps(pretty, depth)) {
|
|
428
|
+
const command = 'dns update';
|
|
429
|
+
return rehearsed(command, args, pretty, depth, deps, ([input, id, ...flags]) => {
|
|
430
|
+
const domain = parseDomain(input, pretty);
|
|
431
|
+
if (typeof domain !== 'string')
|
|
432
|
+
return domain;
|
|
433
|
+
const recordId = parseRecordId(id, pretty);
|
|
434
|
+
if (typeof recordId !== 'string')
|
|
435
|
+
return recordId;
|
|
436
|
+
const record = parseRecord(flags, domain, pretty);
|
|
437
|
+
if ('error' in record)
|
|
438
|
+
return record;
|
|
439
|
+
const host = hostName(record.name, domain);
|
|
440
|
+
return {
|
|
441
|
+
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 레코드를 확인했습니다. 수정하지 않았습니다.', [['도메인', domain], ['레코드 ID', recordId], ...recordRows(record, domain)], { domain, recordId, host, record }),
|
|
443
|
+
send: {
|
|
444
|
+
method: 'POST',
|
|
445
|
+
url: (siteUrl) => recordsUrl(siteUrl, domain, `/${encodeURIComponent(recordId)}`),
|
|
446
|
+
body: { ...record },
|
|
447
|
+
spinner: '레코드를 수정하고 있습니다.',
|
|
448
|
+
failed: '레코드를 수정하지 못했습니다.',
|
|
449
|
+
notFound: RECORD_NOT_FOUND,
|
|
450
|
+
done: (body, siteUrl) => changed(command, pretty, depth, `${host} 레코드를 수정했습니다.`, [['레코드 ID', recordId], ...recordRows(record, domain, APPLIED_PROPAGATION)], zoneOf(body), siteUrl, { recordId, host, record: { id: recordId, ...record } })
|
|
451
|
+
}
|
|
452
|
+
};
|
|
453
|
+
});
|
|
454
|
+
}
|
|
455
|
+
export async function runDnsDelete(args, pretty, depth, deps = defaultAuthDeps(pretty, depth)) {
|
|
456
|
+
const command = 'dns delete';
|
|
457
|
+
return rehearsed(command, args, pretty, depth, deps, ([input, id, ...extra]) => {
|
|
458
|
+
const domain = parseDomain(input, pretty);
|
|
459
|
+
if (typeof domain !== 'string')
|
|
460
|
+
return domain;
|
|
461
|
+
const recordId = parseRecordId(id, pretty);
|
|
462
|
+
if (typeof recordId !== 'string')
|
|
463
|
+
return recordId;
|
|
464
|
+
if (extra.length)
|
|
465
|
+
return { error: unknownArgument(extra[0], pretty) };
|
|
466
|
+
return {
|
|
467
|
+
confirmArgs: [domain, recordId],
|
|
468
|
+
steps: [CHECK_DOMAIN, CHECK_RECORD_ID, { stage: 'review_impact', message: '삭제하면 달라지는 점을 정리하고 있습니다.' }, PREPARE_REQUEST],
|
|
469
|
+
result: (siteUrl) => plannedChange(command, pretty, depth, siteUrl, { url: recordsUrl(siteUrl, domain, `/${encodeURIComponent(recordId)}/delete`), body: {} }, '삭제할 DNS 레코드를 확인했습니다. 삭제하지 않았습니다.', [
|
|
470
|
+
['도메인', domain],
|
|
471
|
+
['레코드 ID', recordId],
|
|
472
|
+
['삭제', '적용하면 이 레코드로 안내하던 길이 바로 사라집니다.'],
|
|
473
|
+
['주의', `사이트 연결 레코드라면 방문자가 사이트를 찾아오지 못합니다. 되살리려면 deepdynamic dns restore ${domain} --project <프로젝트> 를 씁니다.`],
|
|
474
|
+
['전파', PROPAGATION]
|
|
475
|
+
], { domain, recordId }),
|
|
476
|
+
send: {
|
|
477
|
+
method: 'POST',
|
|
478
|
+
url: (siteUrl) => recordsUrl(siteUrl, domain, `/${encodeURIComponent(recordId)}/delete`),
|
|
479
|
+
body: {},
|
|
480
|
+
spinner: '레코드를 삭제하고 있습니다.',
|
|
481
|
+
failed: '레코드를 삭제하지 못했습니다.',
|
|
482
|
+
notFound: RECORD_NOT_FOUND,
|
|
483
|
+
done: (body, siteUrl) => {
|
|
484
|
+
const zone = zoneOf(body);
|
|
485
|
+
return changed(command, pretty, depth, '레코드를 삭제했습니다.', [
|
|
486
|
+
['레코드 ID', recordId],
|
|
487
|
+
...(zone.target && !zone.connected ? [['주의', `지금은 방문자가 이 도메인으로 사이트를 찾아오지 못합니다. 되살리려면 deepdynamic dns restore ${domain} --project <프로젝트> 를 씁니다.`]] : []),
|
|
488
|
+
['전파', APPLIED_PROPAGATION]
|
|
489
|
+
], zone, siteUrl, { recordId });
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
};
|
|
493
|
+
}, {
|
|
494
|
+
message: 'Deleting removes the record from the DNS servers; if it connected the site, visitors can no longer reach it.',
|
|
495
|
+
display: '삭제하면 이 레코드가 DNS 서버에서 사라집니다. 사용자에게 확인한 뒤 --yes 를 붙여 실행하세요.'
|
|
496
|
+
});
|
|
497
|
+
}
|
|
498
|
+
export async function runDnsRestore(args, pretty, depth, deps = defaultAuthDeps(pretty, depth)) {
|
|
499
|
+
const command = 'dns restore';
|
|
500
|
+
return rehearsed(command, args, pretty, depth, deps, ([input, ...flags]) => {
|
|
501
|
+
const domain = parseDomain(input, pretty);
|
|
502
|
+
if (typeof domain !== 'string')
|
|
503
|
+
return domain;
|
|
504
|
+
const values = readFlags(flags, RESTORE_FLAGS, pretty);
|
|
505
|
+
if ('error' in values)
|
|
506
|
+
return values;
|
|
507
|
+
const { '--project': project, '--name': rawName = 'www' } = values;
|
|
508
|
+
if (project === undefined)
|
|
509
|
+
return fail(pretty, '--project is required.', '--project 를 지정하세요.');
|
|
510
|
+
if (!PROJECT.test(project)) {
|
|
511
|
+
return fail(pretty, `Project names are 1-63 lowercase letters, digits or hyphens and start and end with a letter or digit: ${project}`, `프로젝트 이름은 영문 소문자·숫자로 시작하고 끝나는 1~63자의 소문자·숫자·하이픈입니다: ${project}`);
|
|
512
|
+
}
|
|
513
|
+
const name = parseName(rawName, domain, pretty);
|
|
514
|
+
if (typeof name !== 'string')
|
|
515
|
+
return name;
|
|
516
|
+
if (name === '@')
|
|
517
|
+
return fail(pretty, '--name cannot be @ because a CNAME cannot be on the domain itself.', '--name 에 @ 는 쓸 수 없습니다. 도메인 자체에는 CNAME 을 만들 수 없습니다.');
|
|
518
|
+
const record = { type: 'CNAME', name, value: `${project}.${DNS_SITE_DOMAIN}`, ttl: 1 };
|
|
519
|
+
const host = hostName(name, domain);
|
|
520
|
+
const restoreUrl = (siteUrl) => new URL(`${DNS_PATH}/${encodeURIComponent(domain)}/restore`, siteUrl).href;
|
|
521
|
+
return {
|
|
522
|
+
confirmArgs: [domain, ...flags],
|
|
523
|
+
steps: [
|
|
524
|
+
CHECK_DOMAIN,
|
|
525
|
+
{ stage: 'check_project', message: '프로젝트 이름 형식을 확인하고 있습니다.' },
|
|
526
|
+
{ stage: 'build_record', message: '사이트 연결 CNAME 레코드를 만들고 있습니다.' },
|
|
527
|
+
{ stage: 'plan_cleanup', message: 'CNAME 과 겹치는 같은 이름 레코드의 처리를 정리하고 있습니다.' },
|
|
528
|
+
PREPARE_REQUEST
|
|
529
|
+
],
|
|
530
|
+
result: (siteUrl) => plannedChange(command, pretty, depth, siteUrl, { url: restoreUrl(siteUrl), body: { project, name } }, '사이트 연결 복구를 확인했습니다. 복구하지 않았습니다.', [
|
|
531
|
+
['도메인', domain],
|
|
532
|
+
['프로젝트', project],
|
|
533
|
+
['추가', `CNAME ${host} → ${record.value}`],
|
|
534
|
+
['TTL', ttlLabel(record.ttl)],
|
|
535
|
+
['설명', describeRecord(record, domain)],
|
|
536
|
+
['정리', `${host} 의 다른 레코드는 CNAME 과 함께 쓸 수 없어 적용할 때 정리됩니다.`],
|
|
537
|
+
['전파', PROPAGATION]
|
|
538
|
+
], { domain, host, project, record, replacesSameName: true }),
|
|
539
|
+
send: {
|
|
540
|
+
method: 'POST',
|
|
541
|
+
url: restoreUrl,
|
|
542
|
+
body: { project, name },
|
|
543
|
+
spinner: '사이트 연결을 복구하고 있습니다.',
|
|
544
|
+
failed: '사이트 연결을 복구하지 못했습니다.',
|
|
545
|
+
notFound: PROJECT_NOT_FOUND,
|
|
546
|
+
done: (body, siteUrl) => changed(command, pretty, depth, `${host} 사이트 연결을 복구했습니다.`, [
|
|
547
|
+
['프로젝트', project],
|
|
548
|
+
['추가', `CNAME ${host} → ${record.value}`],
|
|
549
|
+
['정리', `${host} 의 다른 레코드는 CNAME 과 함께 쓸 수 없어 정리했습니다.`],
|
|
550
|
+
['전파', APPLIED_PROPAGATION]
|
|
551
|
+
], zoneOf(body), siteUrl, { host, project, record })
|
|
552
|
+
}
|
|
553
|
+
};
|
|
554
|
+
}, {
|
|
555
|
+
message: 'Restoring replaces the other records of the same host and can move the domain to another project.',
|
|
556
|
+
display: '복구하면 같은 이름의 다른 레코드가 정리되고 도메인이 다른 프로젝트로 옮겨질 수 있습니다. 사용자에게 확인한 뒤 --yes 를 붙여 실행하세요.'
|
|
557
|
+
});
|
|
558
|
+
}
|
|
559
|
+
export async function runDnsSync(args, pretty, depth, deps = defaultAuthDeps(pretty, depth)) {
|
|
560
|
+
const command = 'dns sync';
|
|
561
|
+
return rehearsed(command, args, pretty, depth, deps, ([input, ...extra]) => {
|
|
562
|
+
const domain = parseDomain(input, pretty);
|
|
563
|
+
if (typeof domain !== 'string')
|
|
564
|
+
return domain;
|
|
565
|
+
if (extra.length)
|
|
566
|
+
return { error: unknownArgument(extra[0], pretty) };
|
|
567
|
+
const syncUrl = (siteUrl) => new URL(`${DNS_PATH}/${encodeURIComponent(domain)}/sync`, siteUrl).href;
|
|
568
|
+
return {
|
|
569
|
+
confirmArgs: [domain],
|
|
570
|
+
steps: [CHECK_DOMAIN, { stage: 'review_impact', message: '반영하면 달라지는 점을 정리하고 있습니다.' }, PREPARE_REQUEST],
|
|
571
|
+
result: (siteUrl) => plannedChange(command, pretty, depth, siteUrl, { url: syncUrl(siteUrl), body: {} }, 'DNS 동기화를 확인했습니다. 반영하지 않았습니다.', [
|
|
572
|
+
['도메인', domain],
|
|
573
|
+
['반영', SYNC_EFFECT],
|
|
574
|
+
['주의', SYNC_WARNING],
|
|
575
|
+
['전파', PROPAGATION]
|
|
576
|
+
], { domain }),
|
|
577
|
+
send: {
|
|
578
|
+
method: 'POST',
|
|
579
|
+
url: syncUrl,
|
|
580
|
+
body: {},
|
|
581
|
+
spinner: 'DNS 서버에 반영하고 있습니다.',
|
|
582
|
+
failed: 'DNS 서버에 반영하지 못했습니다.',
|
|
583
|
+
notFound: DOMAIN_NOT_FOUND,
|
|
584
|
+
failures: {
|
|
585
|
+
delegation_pending: {
|
|
586
|
+
code: 'delegation_pending',
|
|
587
|
+
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: `도메인을 산 곳의 네임서버가 아직 딥다이나믹 네임서버로 바뀌지 않았습니다. deepdynamic dns records ${domain} 에 나온 네임서버로 바꾼 뒤 몇 분 지나 다시 실행하세요.`
|
|
589
|
+
}
|
|
590
|
+
},
|
|
591
|
+
done: (body, siteUrl) => {
|
|
592
|
+
const zone = zoneOf(body);
|
|
593
|
+
return changed(command, pretty, depth, `${zone.domain} 레코드를 DNS 서버에 반영했습니다.`, [
|
|
594
|
+
['상태', zoneState(zone)],
|
|
595
|
+
...(zone.nameservers ? [['네임서버', zone.nameservers.join(', ')]] : []),
|
|
596
|
+
['전파', APPLIED_PROPAGATION]
|
|
597
|
+
], zone, siteUrl, {});
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
};
|
|
601
|
+
}, {
|
|
602
|
+
message: 'Syncing overwrites the DNS servers with the saved records, so records changed only on the DNS servers are removed.',
|
|
603
|
+
display: '동기화하면 저장한 레코드로 DNS 서버를 덮어써 DNS 서버에서만 바꾼 레코드가 사라집니다. 사용자에게 확인한 뒤 --yes 를 붙여 실행하세요.'
|
|
604
|
+
});
|
|
605
|
+
}
|
|
606
|
+
export async function runDnsDnssec(args, pretty, depth, deps = defaultAuthDeps(pretty, depth)) {
|
|
607
|
+
const command = 'dns dnssec';
|
|
608
|
+
return rehearsed(command, args, pretty, depth, deps, ([input, state, ...extra]) => {
|
|
609
|
+
const domain = parseDomain(input, pretty);
|
|
610
|
+
if (typeof domain !== 'string')
|
|
611
|
+
return domain;
|
|
612
|
+
if (state === undefined)
|
|
613
|
+
return fail(pretty, 'Give on or off after the domain.', '도메인 뒤에 on 또는 off 를 지정하세요.');
|
|
614
|
+
if (state.startsWith('-'))
|
|
615
|
+
return { error: unknownArgument(state, pretty) };
|
|
616
|
+
if (state !== 'on' && state !== 'off')
|
|
617
|
+
return fail(pretty, `Give on or off after the domain: ${state}`, `도메인 뒤에는 on 또는 off 만 올 수 있습니다: ${state}`);
|
|
618
|
+
if (extra.length)
|
|
619
|
+
return { error: unknownArgument(extra[0], pretty) };
|
|
620
|
+
const enabled = state === 'on';
|
|
621
|
+
const dnssecUrl = (siteUrl) => new URL(`${DNS_PATH}/${encodeURIComponent(domain)}/dnssec`, siteUrl).href;
|
|
622
|
+
return {
|
|
623
|
+
confirmArgs: [domain, state],
|
|
624
|
+
steps: [CHECK_DOMAIN, { stage: 'check_state', message: '바꿀 DNSSEC 설정과 달라지는 점을 정리하고 있습니다.' }, PREPARE_REQUEST],
|
|
625
|
+
result: (siteUrl) => plannedChange(command, pretty, depth, siteUrl, { url: dnssecUrl(siteUrl), body: { enabled } }, 'DNSSEC 변경을 확인했습니다. 바꾸지 않았습니다.', [
|
|
626
|
+
['도메인', domain],
|
|
627
|
+
['바꿀 설정', enabled ? 'DNSSEC 켜기' : 'DNSSEC 끄기'],
|
|
628
|
+
['반영', enabled ? DNSSEC_ON_EFFECT : DNSSEC_NOTES.disabling],
|
|
629
|
+
['대상', DNSSEC_SCOPE]
|
|
630
|
+
], { domain, enabled }),
|
|
631
|
+
send: {
|
|
632
|
+
method: 'POST',
|
|
633
|
+
url: dnssecUrl,
|
|
634
|
+
body: { enabled },
|
|
635
|
+
spinner: enabled ? 'DNSSEC 을 켜고 있습니다.' : 'DNSSEC 을 끄고 있습니다.',
|
|
636
|
+
failed: enabled ? 'DNSSEC 을 켜지 못했습니다.' : 'DNSSEC 을 끄지 못했습니다.',
|
|
637
|
+
notFound: DOMAIN_NOT_FOUND,
|
|
638
|
+
failures: DNSSEC_FAILURES,
|
|
639
|
+
done: (body, siteUrl) => {
|
|
640
|
+
const zone = zoneOf(body);
|
|
641
|
+
return changed(command, pretty, depth, `${zone.domain} DNSSEC 을 ${enabled ? '켰습니다' : '껐습니다'}.`, dnssecRows(zone, true), zone, siteUrl, { dnssec: zone.dnssec ?? null });
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
};
|
|
645
|
+
}, {
|
|
646
|
+
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: 'DNSSEC 을 켜거나 끄면 DNS 서버의 존 서명과 도메인을 산 곳(등록처)의 DS 레코드가 바뀝니다. 끄면 2일 뒤에 서명이 해제됩니다. 사용자에게 확인한 뒤 --yes 를 붙여 실행하세요.'
|
|
648
|
+
});
|
|
649
|
+
}
|
|
650
|
+
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.';
|
|
651
|
+
export async function runDnsGoogle(args, pretty, depth, deps = defaultAuthDeps(pretty, depth)) {
|
|
652
|
+
const command = 'dns google';
|
|
653
|
+
return rehearsed(command, args, pretty, depth, deps, ([input, ...extra]) => {
|
|
654
|
+
const domain = parseDomain(input, pretty);
|
|
655
|
+
if (typeof domain !== 'string')
|
|
656
|
+
return domain;
|
|
657
|
+
if (extra.length)
|
|
658
|
+
return { error: unknownArgument(extra[0], pretty) };
|
|
659
|
+
const googleUrl = (siteUrl) => new URL(`${DNS_PATH}/${encodeURIComponent(domain)}/google`, siteUrl).href;
|
|
660
|
+
return {
|
|
661
|
+
steps: [CHECK_DOMAIN, PREPARE_REQUEST],
|
|
662
|
+
result: (siteUrl) => plannedChange(command, pretty, depth, siteUrl, { url: googleUrl(siteUrl), body: {} }, 'Google Search Console 등록 요청을 확인했습니다. 보내지 않았습니다.', [
|
|
663
|
+
['도메인', domain],
|
|
664
|
+
['진행', '받은 주소를 같은 딥다이나믹 계정으로 로그인한 브라우저에서 10분 안에 열어 Google 계정을 고르고 두 권한을 허용하면, 소유 확인 TXT 추가·소유 확인·Search Console 속성 추가까지 이어서 합니다.']
|
|
665
|
+
], { domain }),
|
|
666
|
+
send: {
|
|
667
|
+
method: 'POST',
|
|
668
|
+
url: googleUrl,
|
|
669
|
+
body: {},
|
|
670
|
+
spinner: 'Google 동의 주소를 만들고 있습니다.',
|
|
671
|
+
failed: 'Google 동의 주소를 만들지 못했습니다.',
|
|
672
|
+
notFound: DOMAIN_NOT_FOUND,
|
|
673
|
+
failures: {
|
|
674
|
+
zone_pending: {
|
|
675
|
+
code: 'zone_pending',
|
|
676
|
+
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 를 아직 준비하고 있습니다. deepdynamic dns records ${domain} 의 상태가 준비되면 다시 실행하세요.`
|
|
678
|
+
},
|
|
679
|
+
delegation_propagating: {
|
|
680
|
+
code: 'delegation_propagating',
|
|
681
|
+
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: '네임서버 변경이 아직 인터넷에 퍼지는 중입니다. 도메인을 산 직후에는 10분쯤 걸리니 잠시 뒤 다시 실행하세요.'
|
|
683
|
+
}
|
|
684
|
+
},
|
|
685
|
+
done: (body, siteUrl) => {
|
|
686
|
+
const url = body.url;
|
|
687
|
+
return pretty
|
|
688
|
+
? prettyResult(0, depth, command, '브라우저에서 아래 주소를 열어 Google Search Console 등록을 마치세요.', [
|
|
689
|
+
['서버', siteUrl],
|
|
690
|
+
['도메인', domain],
|
|
691
|
+
['주소', url],
|
|
692
|
+
['안내', '같은 딥다이나믹 계정으로 로그인한 브라우저에서 10분 안에 여세요. 등록을 마치면 /projects 의 DNS 화면으로 돌아옵니다.'],
|
|
693
|
+
['확인', `deepdynamic dns records ${domain} 의 Google 항목`]
|
|
694
|
+
])
|
|
695
|
+
: agentResult(0, { command, siteUrl, domain, url, next: GOOGLE_NEXT.replace('<domain>', domain) });
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
};
|
|
699
|
+
});
|
|
700
|
+
}
|
|
701
|
+
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 = '받은 주소를 같은 딥다이나믹 계정으로 로그인한 브라우저에서 10분 안에 열어 Google 계정을 고르고 Google Analytics 수정 권한을 허용하면, 그 Google 계정의 첫 GA 계정에 도메인 이름의 GA4 속성과 웹 스트림을 새로 만들고 사이트에 Google 태그를 넣습니다.';
|
|
703
|
+
const ANALYTICS_OFF_EFFECT = '도메인과 사이트 호스트의 HTML 에 Google 태그를 더 이상 넣지 않습니다. GA4 속성은 Google 에 그대로 남습니다.';
|
|
704
|
+
const ANALYTICS_OFF_WARNING = '다시 등록하면 새 GA4 속성을 만들어 지금까지의 방문 기록과 이어지지 않습니다.';
|
|
705
|
+
const ANALYTICS_FAILURES = {
|
|
706
|
+
no_project: {
|
|
707
|
+
code: 'no_project',
|
|
708
|
+
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: '프로젝트에 연결되지 않은 도메인입니다. deepdynamic dns restore 로 프로젝트를 먼저 연결한 뒤 다시 실행하세요.'
|
|
710
|
+
}
|
|
711
|
+
};
|
|
712
|
+
export async function runDnsAnalytics(args, pretty, depth, deps = defaultAuthDeps(pretty, depth)) {
|
|
713
|
+
const command = 'dns analytics';
|
|
714
|
+
if (args.filter((arg) => !arg.startsWith('-'))[1] === 'off')
|
|
715
|
+
return runDnsAnalyticsOff(args, pretty, depth, deps);
|
|
716
|
+
return rehearsed(command, splitYes(args).args, pretty, depth, deps, ([input, ...extra]) => {
|
|
717
|
+
const domain = parseDomain(input, pretty);
|
|
718
|
+
if (typeof domain !== 'string')
|
|
719
|
+
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
|
+
}
|
|
725
|
+
const analyticsUrl = (siteUrl) => new URL(`${DNS_PATH}/${encodeURIComponent(domain)}/analytics`, siteUrl).href;
|
|
726
|
+
return {
|
|
727
|
+
steps: [CHECK_DOMAIN, PREPARE_REQUEST],
|
|
728
|
+
result: (siteUrl) => plannedChange(command, pretty, depth, siteUrl, { url: analyticsUrl(siteUrl), body: {} }, 'Google Analytics 등록 요청을 확인했습니다. 보내지 않았습니다.', [
|
|
729
|
+
['도메인', domain],
|
|
730
|
+
['진행', ANALYTICS_START]
|
|
731
|
+
], { domain }),
|
|
732
|
+
send: {
|
|
733
|
+
method: 'POST',
|
|
734
|
+
url: analyticsUrl,
|
|
735
|
+
body: {},
|
|
736
|
+
spinner: 'Google 동의 주소를 만들고 있습니다.',
|
|
737
|
+
failed: 'Google 동의 주소를 만들지 못했습니다.',
|
|
738
|
+
notFound: DOMAIN_NOT_FOUND,
|
|
739
|
+
failures: ANALYTICS_FAILURES,
|
|
740
|
+
done: (body, siteUrl) => {
|
|
741
|
+
const url = body.url;
|
|
742
|
+
return pretty
|
|
743
|
+
? prettyResult(0, depth, command, '브라우저에서 아래 주소를 열어 Google Analytics 등록을 마치세요.', [
|
|
744
|
+
['서버', siteUrl],
|
|
745
|
+
['도메인', domain],
|
|
746
|
+
['주소', url],
|
|
747
|
+
['안내', '같은 딥다이나믹 계정으로 로그인한 브라우저에서 10분 안에 여세요. 등록을 마치면 /projects 의 DNS 화면으로 돌아옵니다.'],
|
|
748
|
+
['확인', `deepdynamic dns records ${domain} 의 GA4 항목`]
|
|
749
|
+
])
|
|
750
|
+
: agentResult(0, { command, siteUrl, domain, url, next: ANALYTICS_NEXT.replaceAll('<domain>', domain) });
|
|
751
|
+
}
|
|
752
|
+
}
|
|
753
|
+
};
|
|
754
|
+
});
|
|
755
|
+
}
|
|
756
|
+
function runDnsAnalyticsOff(args, pretty, depth, deps) {
|
|
757
|
+
const command = 'dns analytics';
|
|
758
|
+
return rehearsed(command, args, pretty, depth, deps, ([input, , ...extra]) => {
|
|
759
|
+
const domain = parseDomain(input, pretty);
|
|
760
|
+
if (typeof domain !== 'string')
|
|
761
|
+
return domain;
|
|
762
|
+
if (extra.length)
|
|
763
|
+
return { error: unknownArgument(extra[0], pretty) };
|
|
764
|
+
const disconnectUrl = (siteUrl) => new URL(`${DNS_PATH}/${encodeURIComponent(domain)}/analytics/disconnect`, siteUrl).href;
|
|
765
|
+
return {
|
|
766
|
+
confirmArgs: [domain, 'off'],
|
|
767
|
+
steps: [CHECK_DOMAIN, { stage: 'review_impact', message: '해제하면 달라지는 점을 정리하고 있습니다.' }, PREPARE_REQUEST],
|
|
768
|
+
result: (siteUrl) => plannedChange(command, pretty, depth, siteUrl, { url: disconnectUrl(siteUrl), body: {} }, 'Google Analytics 해제를 확인했습니다. 바꾸지 않았습니다.', [
|
|
769
|
+
['도메인', domain],
|
|
770
|
+
['바꿀 설정', 'Google 태그 제거'],
|
|
771
|
+
['반영', ANALYTICS_OFF_EFFECT],
|
|
772
|
+
['주의', ANALYTICS_OFF_WARNING]
|
|
773
|
+
], { domain }),
|
|
774
|
+
send: {
|
|
775
|
+
method: 'POST',
|
|
776
|
+
url: disconnectUrl,
|
|
777
|
+
body: {},
|
|
778
|
+
spinner: '사이트에서 Google 태그를 빼고 있습니다.',
|
|
779
|
+
failed: 'Google Analytics 를 해제하지 못했습니다.',
|
|
780
|
+
notFound: DOMAIN_NOT_FOUND,
|
|
781
|
+
done: (body, siteUrl) => {
|
|
782
|
+
const zone = zoneOf(body);
|
|
783
|
+
return changed(command, pretty, depth, `${zone.domain} 사이트에서 Google 태그를 제거했습니다.`, [['GA4', analyticsState(zone)], ['안내', 'GA4 속성은 Google 에 그대로 남습니다. 다시 등록하면 새 속성을 만듭니다.']], zone, siteUrl, { analytics: zone.analytics ?? null });
|
|
784
|
+
}
|
|
785
|
+
}
|
|
786
|
+
};
|
|
787
|
+
}, {
|
|
788
|
+
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: '해제하면 사이트에 Google 태그를 더 이상 넣지 않아 방문 기록이 쌓이지 않습니다. GA4 속성은 Google 에 남지만 다시 등록하면 새 속성을 만듭니다. 사용자에게 확인한 뒤 --yes 를 붙여 실행하세요.'
|
|
790
|
+
});
|
|
791
|
+
}
|