@deepdynamic/cli 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/dist/agents/content.js +1 -1
  2. package/dist/agents/install.js +22 -12
  3. package/dist/agents/refresh.js +20 -0
  4. package/dist/agents/setup.js +7 -7
  5. package/dist/cli.js +8 -8
  6. package/dist/commands/account.js +19 -19
  7. package/dist/commands/activity.js +13 -13
  8. package/dist/commands/blocked.js +16 -16
  9. package/dist/commands/deploy/index.js +16 -16
  10. package/dist/commands/deploy/ship.js +8 -8
  11. package/dist/commands/deployments.js +8 -7
  12. package/dist/commands/dns.js +228 -242
  13. package/dist/commands/domains.js +188 -260
  14. package/dist/commands/emails.js +17 -17
  15. package/dist/commands/env.js +38 -38
  16. package/dist/commands/help.js +18 -19
  17. package/dist/commands/keys.js +83 -89
  18. package/dist/commands/login/flow.js +11 -11
  19. package/dist/commands/login/index.js +3 -3
  20. package/dist/commands/logout.js +11 -11
  21. package/dist/commands/mail.js +62 -62
  22. package/dist/commands/notifications.js +30 -29
  23. package/dist/commands/plan.js +109 -125
  24. package/dist/commands/projects.js +159 -157
  25. package/dist/commands/reference.js +109 -102
  26. package/dist/commands/search.js +29 -18
  27. package/dist/commands/server.js +99 -112
  28. package/dist/commands/sessions.js +38 -44
  29. package/dist/commands/sites.js +16 -16
  30. package/dist/commands/sms.js +14 -14
  31. package/dist/commands/status.js +9 -9
  32. package/dist/commands/support.js +19 -19
  33. package/dist/commands/update.js +18 -16
  34. package/dist/commands/usage.js +12 -12
  35. package/dist/commands/verify.js +16 -16
  36. package/dist/guide.js +9 -48
  37. package/dist/http/request.js +3 -3
  38. package/dist/pretty.js +4 -4
  39. package/dist/refresh-skills.js +5 -0
  40. package/dist/registry.js +72 -144
  41. package/dist/runtime/card-request.js +6 -6
  42. package/dist/runtime/confirm.js +1 -1
  43. package/dist/runtime/development.js +1 -1
  44. package/dist/runtime/dry-run.js +2 -2
  45. package/dist/runtime/env-file.js +6 -9
  46. package/dist/runtime/flags.js +11 -13
  47. package/dist/runtime/login-screen.js +5 -5
  48. package/dist/runtime/page.js +4 -4
  49. package/dist/runtime/server-options.js +4 -8
  50. package/dist/runtime/spinner.js +3 -1
  51. package/dist/runtime/support.js +2 -3
  52. package/dist/runtime/text-file.js +5 -5
  53. package/dist/runtime/timeout.js +2 -2
  54. package/dist/runtime/update-check.js +48 -14
  55. package/dist/runtime/update-install.js +34 -4
  56. package/dist/runtime/usage-error.js +2 -2
  57. package/dist/setup-agents.js +9 -2
  58. package/package.json +1 -1
@@ -24,7 +24,9 @@ const COMMIT_PREFIX = /^[a-f0-9]{7,40}$/;
24
24
  const DEPLOY_STATUSES = ['published', 'deploying', 'failed', 'none'];
25
25
  const DEPLOY_STAGES = ['preparing', 'packing', 'uploading', 'verifying', 'awaiting_publish', 'publishing', 'published', 'failed'];
26
26
  const BUILD = /^pnpm (build|run [A-Za-z0-9][A-Za-z0-9:._-]{0,63})$/;
27
- const STATUS_LABELS = { published: '● 게시됨', deploying: '◐ 게시 중', failed: '✕ 배포 실패', none: '○ 배포 전' };
27
+ const STATUS_LABELS = { published: '● Published', deploying: '◐ Deploying', failed: '✕ Deploy failed', none: '○ Not deployed' };
28
+ const plainFailure = (code, message) => ({ code, message, display: message });
29
+ const counted = (count, noun) => `${count.toLocaleString('en-US')} ${noun}${count === 1 ? '' : 's'}`;
28
30
  function projectStatus(body, project) {
29
31
  const value = body;
30
32
  const server = value?.server;
@@ -58,30 +60,30 @@ function exchangeFailure(result) {
58
60
  if (result.status === 401)
59
61
  return LOGIN_EXPIRED;
60
62
  if (result.status === 404)
61
- return { code: 'project_not_found', message: 'You have no project with that name. Create it with deepdynamic projects create <name>.', display: '그 이름의 내 프로젝트가 없습니다.' };
63
+ return plainFailure('project_not_found', 'You have no project with that name. Create it with deepdynamic projects create <name>.');
62
64
  if (result.status === 409)
63
- return { code: 'project_taken', message: 'Another account already uses that project name. Choose a different name.', display: '다른 계정이 이미 쓰는 이름입니다.' };
65
+ return plainFailure('project_taken', 'Another account already uses that project name. Choose a different name.');
64
66
  if (result.status === 400)
65
- return { code: 'invalid_arguments', message: 'The server rejected the project name. Follow the naming steps in deepdynamic projects create --help.', display: '프로젝트 이름을 확인하세요.' };
67
+ return plainFailure('invalid_arguments', 'The server rejected the project name. Follow the naming steps in deepdynamic projects create --help.');
66
68
  if (result.status !== 200 && result.status !== 201)
67
69
  return httpFailure(result.status);
68
70
  return null;
69
71
  }
70
- function parseName(args, pretty) {
71
- const parsed = parseCommand(args, [], pretty);
72
+ function parseName(args) {
73
+ const parsed = parseCommand(args, []);
72
74
  if ('error' in parsed)
73
75
  return parsed;
74
76
  const { names } = parsed;
75
77
  if (names.length !== 1)
76
- return { error: pretty ? '프로젝트 이름을 하나만 지정하세요.' : 'Specify exactly one project name.' };
78
+ return { error: 'Specify exactly one project name.' };
77
79
  if (!PROJECT.test(names[0]))
78
- return { error: pretty ? '프로젝트 이름은 영문 소문자·숫자로 시작하고 끝나는 1~63자의 소문자·숫자·하이픈입니다.' : 'Project names are 1-63 lowercase letters, digits or hyphens and start and end with a letter or digit.' };
80
+ return { error: 'Project names are 1-63 lowercase letters, digits or hyphens and start and end with a letter or digit.' };
79
81
  return names[0];
80
82
  }
81
83
  function finish(command, code, depth, pretty, siteUrl, project, server, site, failure, message) {
82
84
  if (pretty) {
83
85
  return prettyResult(code, depth, command, message, [
84
- ['서버', siteUrl], ['프로젝트', project], ...(site ? [['발급 주소', site]] : []), ['상태', failure?.display ?? server.message]
86
+ ['Server', siteUrl], ['Project', project], ...(site ? [['Site URL', site]] : []), ['Status', failure?.display ?? server.message]
85
87
  ]);
86
88
  }
87
89
  return agentResult(code, {
@@ -90,15 +92,15 @@ function finish(command, code, depth, pretty, siteUrl, project, server, site, fa
90
92
  });
91
93
  }
92
94
  async function runProjects(command, args, pretty, depth, deps, waitMs) {
93
- const { usage, prettyUsage } = spec(command);
94
- const project = parseName(args, pretty);
95
+ const { usage } = spec(command);
96
+ const project = parseName(args);
95
97
  if (typeof project !== 'string') {
96
98
  return pretty
97
- ? prettyResult(2, depth, command, project.error, [['사용법', prettyUsage]])
99
+ ? prettyResult(2, depth, command, project.error, [['Usage', usage]])
98
100
  : agentResult(2, { command, error: { code: 'invalid_arguments', message: project.error }, usage });
99
101
  }
100
102
  const sent = await authorized(deps, (session) => command === 'projects create'
101
- ? postJson(new URL(PROJECTS_PATH, session.siteUrl).href, session.token, { project }, deps, pretty ? '프로젝트를 만들고 있습니다.' : null)
103
+ ? postJson(new URL(PROJECTS_PATH, session.siteUrl).href, session.token, { project }, deps, pretty ? 'Creating the project.' : null)
102
104
  : readStatus(session, project, deps));
103
105
  if ('login' in sent)
104
106
  return sent.login;
@@ -113,24 +115,24 @@ async function runProjects(command, args, pretty, depth, deps, waitMs) {
113
115
  if (!status) {
114
116
  const shown = failure ?? UNEXPECTED;
115
117
  return pretty
116
- ? prettyResult(1, depth, command, '프로젝트를 확인하지 못했습니다.', [['서버', session.siteUrl], ['프로젝트', project], ['원인', shown.display]])
118
+ ? prettyResult(1, depth, command, 'Could not check the project.', [['Server', session.siteUrl], ['Project', project], ['Reason', shown.display]])
117
119
  : agentResult(1, { command, siteUrl: session.siteUrl, project, error: failureError(shown) });
118
120
  }
119
121
  const { server, site, poll } = status;
120
122
  if (server.stage === 'failed') {
121
123
  const failed = supportFailure('server_failed');
122
- return finish(command, 1, depth, pretty, session.siteUrl, project, server, site, failed, '프로젝트 서버를 준비하지 못했습니다.');
124
+ return finish(command, 1, depth, pretty, session.siteUrl, project, server, site, failed, 'Could not prepare the project server.');
123
125
  }
124
126
  if (server.ready || command === 'projects status') {
125
- return finish(command, 0, depth, pretty, session.siteUrl, project, server, site, null, server.ready ? '프로젝트 서버가 준비되었습니다.' : '프로젝트 서버를 준비하고 있습니다.');
127
+ return finish(command, 0, depth, pretty, session.siteUrl, project, server, site, null, server.ready ? 'The project server is ready.' : 'The project server is being prepared.');
126
128
  }
127
129
  const output = pretty ? `${plain(server.message)}\n` : jsonLine({ event: 'project_progress', project, server });
128
130
  if (output !== lastOutput)
129
131
  deps.stream.write(output);
130
132
  lastOutput = output;
131
133
  if (Date.now() >= deadline) {
132
- const pending = { code: 'server_pending', message: `The project server is still being prepared. Keep running deepdynamic projects status ${project} until server.ready is true or server.stage is failed.`, display: `아직 준비 중입니다. 준비될 때까지 deepdynamic projects status ${project} 로 계속 확인하세요.` };
133
- return finish(command, 1, depth, pretty, session.siteUrl, project, server, site, pending, '프로젝트 서버가 아직 준비 중입니다.');
134
+ const pending = { code: 'server_pending', message: `The project server is still being prepared. Keep running deepdynamic projects status ${project} until server.ready is true or server.stage is failed.`, display: `Still being prepared. Keep checking with deepdynamic projects status ${project} until it is ready.` };
135
+ return finish(command, 1, depth, pretty, session.siteUrl, project, server, site, pending, 'The project server is still being prepared.');
134
136
  }
135
137
  await (deps.pause ?? pauseFor)(poll ?? 5000);
136
138
  result = await readStatus(session, project, deps);
@@ -138,10 +140,10 @@ async function runProjects(command, args, pretty, depth, deps, waitMs) {
138
140
  }
139
141
  async function checkProjectName(args, pretty, depth, deps) {
140
142
  const command = 'projects create';
141
- const project = parseName(args, pretty);
143
+ const project = parseName(args);
142
144
  if (typeof project !== 'string')
143
145
  return usageError(command, project.error, pretty, depth);
144
- const sent = await authorized(deps, (session) => postJson(new URL(PROJECTS_PATH, session.siteUrl).href, session.token, { project, dryRun: true }, deps, pretty ? '이름을 확인하고 있습니다.' : null));
146
+ const sent = await authorized(deps, (session) => postJson(new URL(PROJECTS_PATH, session.siteUrl).href, session.token, { project, dryRun: true }, deps, pretty ? 'Checking the name.' : null));
145
147
  if ('login' in sent)
146
148
  return sent.login;
147
149
  const { session, result } = sent;
@@ -150,20 +152,20 @@ async function checkProjectName(args, pretty, depth, deps) {
150
152
  if (failure || value?.ok !== true || value.dryRun !== true || value.project !== project || typeof value.available !== 'boolean' || typeof value.owned !== 'boolean') {
151
153
  const shown = failure ?? UNEXPECTED;
152
154
  return pretty
153
- ? prettyResult(1, depth, command, '이름을 확인하지 못했습니다.', [['서버', session.siteUrl], ['프로젝트', project], ['원인', shown.display]])
155
+ ? prettyResult(1, depth, command, 'Could not check the name.', [['Server', session.siteUrl], ['Project', project], ['Reason', shown.display]])
154
156
  : agentResult(1, { command, siteUrl: session.siteUrl, dryRun: true, project, error: failureError(shown) });
155
157
  }
156
158
  const { available, owned } = value;
157
159
  if (!pretty)
158
160
  return agentResult(0, { command, siteUrl: session.siteUrl, dryRun: true, project, available, owned });
159
161
  return prettyResult(0, depth, command, available
160
- ? '쓸 수 있는 이름입니다. 프로젝트는 만들지 않았습니다.'
161
- : owned ? '이미 내 프로젝트입니다. 새로 만들지 말고 이 이름으로 배포하세요.' : '다른 계정이 쓰는 이름입니다. 다른 이름을 고르세요.', [
162
- ['서버', session.siteUrl], ['프로젝트', project]
162
+ ? 'The name is available. No project was created.'
163
+ : owned ? 'You already own this project. Deploy to it instead of creating it again.' : 'Another account uses this name. Choose a different name.', [
164
+ ['Server', session.siteUrl], ['Project', project]
163
165
  ]);
164
166
  }
165
167
  export async function runProjectsCreate(args, pretty, depth, deps = defaultAuthDeps(pretty, depth)) {
166
- const timeout = parseTimeout(args, SERVER_WAIT_SECONDS, pretty);
168
+ const timeout = parseTimeout(args, SERVER_WAIT_SECONDS);
167
169
  if ('error' in timeout)
168
170
  return usageError('projects create', timeout.error, pretty, depth);
169
171
  return timeout.rest.includes('--dry-run')
@@ -175,7 +177,7 @@ export async function runProjectsStatus(args, pretty, depth, deps = defaultAuthD
175
177
  const { args: rest, dryRun } = splitDryRun(args);
176
178
  if (!dryRun)
177
179
  return runProjects(command, rest, pretty, depth, deps, 0);
178
- const project = parseName(rest, pretty);
180
+ const project = parseName(rest);
179
181
  if (typeof project !== 'string')
180
182
  return usageError(command, project.error, pretty, depth);
181
183
  return preview(command, pretty, depth, deps, (siteUrl) => new URL(`${PROJECTS_PATH}/${project}`, siteUrl).href);
@@ -204,38 +206,38 @@ function isProjectSummary(item) {
204
206
  function ago(iso, now) {
205
207
  const minutes = Math.floor((now - Date.parse(iso)) / 60_000);
206
208
  if (minutes < 1)
207
- return '방금';
209
+ return 'just now';
208
210
  if (minutes < 60)
209
- return `${minutes}분 전`;
211
+ return `${counted(minutes, 'minute')} ago`;
210
212
  if (minutes < 24 * 60)
211
- return `${Math.floor(minutes / 60)}시간 전`;
213
+ return `${counted(Math.floor(minutes / 60), 'hour')} ago`;
212
214
  const days = Math.floor(minutes / (24 * 60));
213
215
  if (days === 1)
214
- return '어제';
215
- return days < 30 ? `${days}일 전` : iso.slice(0, 10);
216
+ return 'yesterday';
217
+ return days < 30 ? `${days} days ago` : iso.slice(0, 10);
216
218
  }
217
219
  const offline = ({ server, status, live }) => server?.stage === 'stopped' && live !== null && status !== 'deploying';
218
220
  function projectRow(item, now) {
219
221
  const { project, status, latest, live, deployments } = item;
220
- const label = offline(item) ? '■ 서버 꺼짐' : status === 'failed' && latest?.errorCode === 'publish_failed' ? '✕ 빌드 실패' : STATUS_LABELS[status];
221
- const build = !latest ? '-' : typeof latest.manifest.build === 'string' ? latest.manifest.build : '정적';
222
+ const label = offline(item) ? '■ Server off' : status === 'failed' && latest?.errorCode === 'publish_failed' ? '✕ Build failed' : STATUS_LABELS[status];
223
+ const build = !latest ? '-' : typeof latest.manifest.build === 'string' ? latest.manifest.build : 'static';
222
224
  return [project, label, build, String(deployments), live ? ago(live.publishedAt, now) : '-'];
223
225
  }
224
226
  export async function runProjectsList(args, pretty, depth, deps = defaultAuthDeps(pretty, depth)) {
225
227
  const command = 'projects';
226
228
  const invalid = (message) => usageError(command, message, pretty, depth);
227
229
  const { args: rest, dryRun } = splitDryRun(args);
228
- const flags = parseFlags(rest, ['--page'], pretty);
230
+ const flags = parseFlags(rest, ['--page']);
229
231
  if ('error' in flags)
230
232
  return invalid(flags.error);
231
233
  const page = flags.entries[0]?.[1] ?? '1';
232
234
  if (flags.entries.length > 1 || !/^[1-9]\d{0,5}$/.test(page))
233
- return invalid(pretty ? '--page 에는 1 이상의 정수를 한 번만 지정하세요.' : 'Give --page once, as a positive integer.');
235
+ return invalid('Give --page once, as a positive integer.');
234
236
  if (dryRun)
235
237
  return preview(command, pretty, depth, deps, (siteUrl) => `${new URL(PROJECTS_PATH, siteUrl).href}?page=${page}`);
236
238
  const sent = await authorized(deps, (session) => request(`${new URL(PROJECTS_PATH, session.siteUrl).href}?page=${page}`, {
237
239
  method: 'GET', headers: { authorization: `Bearer ${session.token}` }
238
- }, deps, pretty ? '프로젝트 목록을 불러오고 있습니다.' : null));
240
+ }, deps, pretty ? 'Loading projects.' : null));
239
241
  if ('login' in sent)
240
242
  return sent.login;
241
243
  const { session, result } = sent;
@@ -245,7 +247,7 @@ export async function runProjectsList(args, pretty, depth, deps = defaultAuthDep
245
247
  || !Array.isArray(value.projects) || !value.projects.every(isProjectSummary)) {
246
248
  const shown = failure ?? UNEXPECTED;
247
249
  return pretty
248
- ? prettyResult(1, depth, command, '프로젝트 목록을 확인하지 못했습니다.', [['서버', session.siteUrl], ['원인', shown.display]])
250
+ ? prettyResult(1, depth, command, 'Could not load the project list.', [['Server', session.siteUrl], ['Reason', shown.display]])
249
251
  : agentResult(1, { command, siteUrl: session.siteUrl, error: failureError(shown) });
250
252
  }
251
253
  const { total, pageSize, totalPages } = value;
@@ -254,17 +256,17 @@ export async function runProjectsList(args, pretty, depth, deps = defaultAuthDep
254
256
  if (!pretty)
255
257
  return agentResult(0, { command, siteUrl: session.siteUrl, total, page: value.page, pageSize, totalPages, next, projects });
256
258
  const footer = [
257
- ['페이지', `${value.page} / ${totalPages} (${total}개)`],
258
- ...(next ? [['다음', next]] : []),
259
- ...(projects.length ? [['주소', 'deepdynamic projects status <이름>']] : [])
259
+ ['Page', `${value.page} / ${totalPages} (${total} total)`],
260
+ ...(next ? [['Next', next]] : []),
261
+ ...(projects.length ? [['URL', 'deepdynamic projects status <name>']] : [])
260
262
  ];
261
263
  if (!projects.length) {
262
- return prettyResult(0, depth, command, total ? `${value.page}페이지에는 프로젝트가 없습니다.` : '아직 프로젝트가 없습니다. deepdynamic projects create <이름> 으로 만드세요.', total ? footer : []);
264
+ return prettyResult(0, depth, command, total ? `Page ${value.page} has no projects.` : 'You have no projects yet. Create one with deepdynamic projects create <name>.', total ? footer : []);
263
265
  }
264
266
  const { accent, dim } = paint(depth);
265
267
  const tones = { published: accent, none: dim };
266
268
  const now = Date.now();
267
- const table = [['이름', '상태', '빌드', '배포', '마지막 게시'], ...projects.map((item) => projectRow(item, now).map(plain))];
269
+ const table = [['Name', 'Status', 'Build', 'Deploys', 'Last published'], ...projects.map((item) => projectRow(item, now).map(plain))];
268
270
  const widths = table[0].map((_, column) => Math.max(...table.map((row) => displayWidth(row[column]))));
269
271
  const lines = table.map((row, index) => row.map((cell, column) => {
270
272
  const text = column === 3 ? ' '.repeat(widths[column] - displayWidth(cell)) + cell : pad(cell, widths[column]);
@@ -273,7 +275,7 @@ export async function runProjectsList(args, pretty, depth, deps = defaultAuthDep
273
275
  const item = projects[index - 1];
274
276
  return column === 1 ? (offline(item) ? dim : tones[item.status] ?? String)(text) : text;
275
277
  }).join(' ').trimEnd());
276
- return prettyResult(0, depth, command, `최근 활동 순으로 ${projects.length}개를 표시했습니다.`, [
278
+ return prettyResult(0, depth, command, `Listed ${counted(projects.length, 'project')}, most recently active first.`, [
277
279
  ...lines.map((line) => [null, new Styled(line)]),
278
280
  [null, ''],
279
281
  ...footer
@@ -305,14 +307,14 @@ async function loadHistory(command, project, pretty, depth, deps) {
305
307
  const shown = failure ?? UNEXPECTED;
306
308
  return {
307
309
  result: pretty
308
- ? prettyResult(1, depth, command, '배포 이력을 확인하지 못했습니다.', [['서버', sent.session.siteUrl], ['프로젝트', project], ['원인', shown.display]])
310
+ ? prettyResult(1, depth, command, 'Could not load the deploy history.', [['Server', sent.session.siteUrl], ['Project', project], ['Reason', shown.display]])
309
311
  : agentResult(1, { command, siteUrl: sent.session.siteUrl, project, error: failureError(shown) })
310
312
  };
311
313
  }
312
314
  export async function runProjectsHistory(args, pretty, depth, deps = defaultAuthDeps(pretty, depth)) {
313
315
  const command = 'projects history';
314
316
  const { args: rest, dryRun } = splitDryRun(args);
315
- const project = parseName(rest, pretty);
317
+ const project = parseName(rest);
316
318
  if (typeof project !== 'string')
317
319
  return usageError(command, project.error, pretty, depth);
318
320
  if (dryRun)
@@ -323,16 +325,16 @@ export async function runProjectsHistory(args, pretty, depth, deps = defaultAuth
323
325
  const { session, deployments } = history;
324
326
  if (!pretty)
325
327
  return agentResult(0, { command, siteUrl: session.siteUrl, project, deployments });
326
- return prettyResult(0, depth, command, deployments.length ? `게시된 배포 ${deployments.length}개를 찾았습니다.` : '아직 게시된 배포가 없습니다.', [
327
- ['서버', session.siteUrl], ['프로젝트', project],
328
+ return prettyResult(0, depth, command, deployments.length ? `Found ${counted(deployments.length, 'published deployment')}.` : 'No deployment has been published yet.', [
329
+ ['Server', session.siteUrl], ['Project', project],
328
330
  ...deployments.map(({ commit, publishedAt, current }, index) => [
329
- index === 0 ? '배포' : '',
330
- `${commit.slice(0, 12)} ${new Date(publishedAt).toISOString().slice(0, 16).replace('T', ' ')} UTC${current ? ' (현재)' : ''}`
331
+ index === 0 ? 'Deployments' : '',
332
+ `${commit.slice(0, 12)} ${new Date(publishedAt).toISOString().slice(0, 16).replace('T', ' ')} UTC${current ? ' (current)' : ''}`
331
333
  ])
332
334
  ]);
333
335
  }
334
336
  const METRIC_PERIODS = ['24h', '7d', '30d'];
335
- const PERIOD_LABELS = { '24h': '24시간', '7d': '7일', '30d': '30일' };
337
+ const PERIOD_LABELS = { '24h': '24 hours', '7d': '7 days', '30d': '30 days' };
336
338
  const PERIOD_LENGTHS = { '24h': 24, '7d': 7, '30d': 30 };
337
339
  const isMetricPeriod = (value) => METRIC_PERIODS.includes(value);
338
340
  const isPercent = (value) => typeof value === 'number' && value >= 0 && value <= 100;
@@ -390,84 +392,84 @@ function metricReport(body, project, period) {
390
392
  traffic: value.traffic
391
393
  };
392
394
  }
393
- function parseMetric(args, pretty) {
394
- const parsed = parseCommand(args, ['--period'], pretty);
395
+ function parseMetric(args) {
396
+ const parsed = parseCommand(args, ['--period']);
395
397
  if ('error' in parsed)
396
398
  return parsed;
397
- const project = parseName(parsed.names, pretty);
399
+ const project = parseName(parsed.names);
398
400
  if (typeof project !== 'string')
399
401
  return project;
400
402
  if (parsed.entries.length > 1)
401
- return { error: pretty ? '--period 는 한 번만 지정하세요.' : 'Give --period only once.' };
403
+ return { error: 'Give --period only once.' };
402
404
  const period = parsed.entries[0]?.[1] ?? '7d';
403
405
  if (!isMetricPeriod(period)) {
404
- return { error: pretty ? `--period 에는 ${METRIC_PERIODS.join(', ')} 중 하나를 지정하세요: ${period}` : `--period must be one of ${METRIC_PERIODS.join(', ')}: ${period}` };
406
+ return { error: `--period must be one of ${METRIC_PERIODS.join(', ')}: ${period}` };
405
407
  }
406
408
  return { project, period };
407
409
  }
408
- const metricNumber = (value) => value.toLocaleString('ko-KR');
409
- const metricChange = (value, previous) => previous === 0 ? '비교 데이터 없음' : `이전 기간 대비 ${value < previous ? '-' : '+'}${(Math.abs(value - previous) / previous * 100).toFixed(1)}%`;
410
+ const metricNumber = (value) => value.toLocaleString('en-US');
411
+ const metricChange = (value, previous) => previous === 0 ? 'no previous data' : `${value < previous ? '-' : '+'}${(Math.abs(value - previous) / previous * 100).toFixed(1)}% vs previous period`;
410
412
  const compared = (shown, value, previous) => `${shown} · ${metricChange(value, previous)}`;
411
- const stay = (seconds) => `${Math.floor(seconds / 60)}분 ${seconds % 60}초`;
413
+ const stay = (seconds) => `${counted(Math.floor(seconds / 60), 'minute')} ${counted(seconds % 60, 'second')}`;
412
414
  const shares = (items) => items.map(({ label, share }) => `${label} ${share.toFixed(1)}%`).join(' · ');
413
415
  const BAR_WIDTH = 20;
414
- const severityLabels = { critical: '긴급', high: '주의' };
416
+ const severityLabels = { critical: 'Critical', high: 'High' };
415
417
  function trendRows(title, labels, current, previous) {
416
418
  const peak = Math.max(1, ...current, ...previous);
417
419
  return labels.map((label, index) => {
418
420
  const width = current[index] > 0 ? Math.max(1, Math.round(current[index] / peak * BAR_WIDTH)) : 0;
419
- return [index === 0 ? title : '', `${label.padEnd(8)}${'█'.repeat(width).padEnd(BAR_WIDTH)} ${metricNumber(current[index])}회 (이전 ${metricNumber(previous[index])}회)`];
421
+ return [index === 0 ? title : '', `${label.padEnd(8)}${'█'.repeat(width).padEnd(BAR_WIDTH)} ${metricNumber(current[index])} (previous ${metricNumber(previous[index])})`];
420
422
  });
421
423
  }
422
424
  function softwareRows({ server, poweredBy, advisories }) {
423
425
  const observed = [server, poweredBy].filter(Boolean).join(' · ');
424
426
  if (!observed)
425
- return [['서버 소프트웨어', '아직 관측된 서버 응답이 없습니다.']];
427
+ return [['Server software', 'No server responses observed yet.']];
426
428
  const notes = advisories.length
427
- ? advisories.map(({ severity, product, version, summary, reference }, index) => [index === 0 ? '취약 버전 안내' : '', `[${severityLabels[severity]}] ${product}/${version} · ${summary} (${reference})`])
428
- : [['취약 버전 안내', '알려진 취약 버전이 없습니다.']];
429
- return [['서버 소프트웨어', observed], ...notes];
429
+ ? advisories.map(({ severity, product, version, summary, reference }, index) => [index === 0 ? 'Vulnerable versions' : '', `[${severityLabels[severity]}] ${product}/${version} · ${summary} (${reference})`])
430
+ : [['Vulnerable versions', 'No known vulnerable versions.']];
431
+ return [['Server software', observed], ...notes];
430
432
  }
431
433
  function trafficRows(traffic) {
432
434
  if (traffic.requests === 0)
433
- return [['엣지 트래픽', '아직 집계된 요청이 없습니다.']];
434
- const ratio = (count) => `${metricNumber(count)}회 (${(count / traffic.requests * 100).toFixed(1)}%)`;
435
+ return [['Edge traffic', 'No requests counted yet.']];
436
+ const ratio = (count) => `${metricNumber(count)} (${(count / traffic.requests * 100).toFixed(1)}%)`;
435
437
  return [
436
- ['엣지 트래픽', `요청 수 ${metricNumber(traffic.requests)}회`],
437
- ['서버 페이지뷰', `${metricNumber(traffic.pageviews)}회`],
438
- ['방문자 (시간별 합)', `${metricNumber(traffic.visitors)}명`],
439
- ['봇 요청', `${metricNumber(traffic.bots)}회`],
440
- ['응답 정상 (2xx)', ratio(traffic.statuses.ok)],
441
- ['응답 이동 (3xx)', ratio(traffic.statuses.redirect)],
442
- ['요청 오류 (4xx)', ratio(traffic.statuses.client)],
443
- ['서버 오류 (5xx)', ratio(traffic.statuses.server)],
444
- ...traffic.paths.map(({ path, count, share }, index) => [index === 0 ? '서버 페이지뷰가 많은 경로' : '', `${path} ${metricNumber(count)}회 (${share.toFixed(1)}%)`])
438
+ ['Edge traffic', counted(traffic.requests, 'request')],
439
+ ['Server pageviews', metricNumber(traffic.pageviews)],
440
+ ['Visitors (hourly sum)', metricNumber(traffic.visitors)],
441
+ ['Bot requests', metricNumber(traffic.bots)],
442
+ ['Success (2xx)', ratio(traffic.statuses.ok)],
443
+ ['Redirects (3xx)', ratio(traffic.statuses.redirect)],
444
+ ['Client errors (4xx)', ratio(traffic.statuses.client)],
445
+ ['Server errors (5xx)', ratio(traffic.statuses.server)],
446
+ ...traffic.paths.map(({ path, count, share }, index) => [index === 0 ? 'Top paths (server pageviews)' : '', `${path} ${metricNumber(count)} (${share.toFixed(1)}%)`])
445
447
  ];
446
448
  }
447
449
  function metricRows(siteUrl, project, period, { report, software, traffic }) {
448
450
  const { labels, visits, previousVisits, views, previousViews, range, totalVisits, totalViews, previousTotalVisits, previousTotalViews, duration, previousDuration, bounce, previousBounce, sources, devices, pages } = report;
449
451
  return [
450
- ['서버', siteUrl], ['프로젝트', project],
451
- ['기간', `${PERIOD_LABELS[period]} · ${range} · 한국 시간`],
452
- ['방문 수', compared(`${metricNumber(totalVisits)}회`, totalVisits, previousTotalVisits)],
453
- ['페이지뷰', compared(`${metricNumber(totalViews)}회`, totalViews, previousTotalViews)],
454
- ['평균 체류 시간', compared(stay(duration), duration, previousDuration)],
455
- ['이탈률', compared(`${bounce.toFixed(1)}%`, bounce, previousBounce)],
456
- ...trendRows('방문 추이', labels, visits, previousVisits),
457
- ...trendRows('페이지뷰 추이', labels, views, previousViews),
458
- ['유입 경로', shares(sources)],
459
- ['기기', shares(devices)],
452
+ ['Server', siteUrl], ['Project', project],
453
+ ['Period', `${PERIOD_LABELS[period]} · ${range} · KST`],
454
+ ['Visits', compared(metricNumber(totalVisits), totalVisits, previousTotalVisits)],
455
+ ['Pageviews', compared(metricNumber(totalViews), totalViews, previousTotalViews)],
456
+ ['Avg. visit duration', compared(stay(duration), duration, previousDuration)],
457
+ ['Bounce rate', compared(`${bounce.toFixed(1)}%`, bounce, previousBounce)],
458
+ ...trendRows('Visit trend', labels, visits, previousVisits),
459
+ ...trendRows('Pageview trend', labels, views, previousViews),
460
+ ['Traffic sources', shares(sources)],
461
+ ['Devices', shares(devices)],
460
462
  ...(software ? softwareRows(software) : []),
461
463
  ...(traffic ? trafficRows(traffic) : []),
462
464
  ...(pages.length
463
- ? pages.map(({ path, count, share }, index) => [index === 0 ? '많이 찾은 페이지' : '', `${path} ${metricNumber(count)}회 (${share.toFixed(1)}%)`])
464
- : [['많이 찾은 페이지', '없음']])
465
+ ? pages.map(({ path, count, share }, index) => [index === 0 ? 'Top pages' : '', `${path} ${metricNumber(count)} (${share.toFixed(1)}%)`])
466
+ : [['Top pages', 'None']])
465
467
  ];
466
468
  }
467
469
  export async function runProjectsMetric(args, pretty, depth, deps = defaultAuthDeps(pretty, depth)) {
468
470
  const command = 'projects metric';
469
471
  const { args: rest, dryRun } = splitDryRun(args);
470
- const parsed = parseMetric(rest, pretty);
472
+ const parsed = parseMetric(rest);
471
473
  if ('error' in parsed)
472
474
  return usageError(command, parsed.error, pretty, depth);
473
475
  const { project, period } = parsed;
@@ -476,7 +478,7 @@ export async function runProjectsMetric(args, pretty, depth, deps = defaultAuthD
476
478
  return preview(command, pretty, depth, deps, url);
477
479
  const sent = await authorized(deps, (session) => request(url(session.siteUrl), {
478
480
  method: 'GET', headers: { authorization: `Bearer ${session.token}` }
479
- }, deps, pretty ? '방문 통계를 불러오고 있습니다.' : null));
481
+ }, deps, pretty ? 'Loading visit statistics.' : null));
480
482
  if ('login' in sent)
481
483
  return sent.login;
482
484
  const { session, result } = sent;
@@ -485,12 +487,12 @@ export async function runProjectsMetric(args, pretty, depth, deps = defaultAuthD
485
487
  if (!metric) {
486
488
  const shown = failure ?? UNEXPECTED;
487
489
  return pretty
488
- ? prettyResult(1, depth, command, '방문 통계를 확인하지 못했습니다.', [['서버', session.siteUrl], ['프로젝트', project], ['원인', shown.display]])
490
+ ? prettyResult(1, depth, command, 'Could not load the visit statistics.', [['Server', session.siteUrl], ['Project', project], ['Reason', shown.display]])
489
491
  : agentResult(1, { command, siteUrl: session.siteUrl, project, error: failureError(shown) });
490
492
  }
491
493
  if (!pretty)
492
494
  return agentResult(0, { command, siteUrl: session.siteUrl, project, period, ...metric });
493
- const message = metric.report.totalVisits ? `${PERIOD_LABELS[period]} 방문 통계를 불러왔습니다.` : `${PERIOD_LABELS[period]} 동안 방문 기록이 없습니다.`;
495
+ const message = metric.report.totalVisits ? `Loaded visit statistics for the last ${PERIOD_LABELS[period]}.` : `No visits in the last ${PERIOD_LABELS[period]}.`;
494
496
  return prettyResult(0, depth, command, message, metricRows(session.siteUrl, project, period, metric));
495
497
  }
496
498
  export async function runProjectsRollback(args, pretty, depth, deps = { ...defaultAuthDeps(pretty, depth), restore: restoreDeployment }) {
@@ -498,48 +500,48 @@ export async function runProjectsRollback(args, pretty, depth, deps = { ...defau
498
500
  const invalid = (message) => usageError(command, message, pretty, depth);
499
501
  const { args: plain, dryRun } = splitDryRun(args);
500
502
  const { args: rest, yes } = splitYes(plain);
501
- const timeout = parseTimeout(rest, PUBLISH_WAIT_SECONDS, pretty);
503
+ const timeout = parseTimeout(rest, PUBLISH_WAIT_SECONDS);
502
504
  if ('error' in timeout)
503
505
  return invalid(timeout.error);
504
- const parsed = parseCommand(timeout.rest, ['--to'], pretty);
506
+ const parsed = parseCommand(timeout.rest, ['--to']);
505
507
  if ('error' in parsed)
506
508
  return invalid(parsed.error);
507
- const project = parseName(parsed.names, pretty);
509
+ const project = parseName(parsed.names);
508
510
  if (typeof project !== 'string')
509
511
  return invalid(project.error);
510
512
  const to = parsed.entries[0]?.[1];
511
513
  if (parsed.entries.length > 1 || (to !== undefined && !COMMIT_PREFIX.test(to))) {
512
- return invalid(pretty ? '--to 에는 deepdynamic projects history 에 나온 커밋을 7~40자로 한 번만 지정하세요.' : 'Give --to once, as 7-40 lowercase hex characters of a commit from deepdynamic projects history.');
514
+ return invalid('Give --to once, as 7-40 lowercase hex characters of a commit from deepdynamic projects history.');
513
515
  }
514
516
  if (dryRun)
515
517
  return plannedRollback(project, to ?? null, pretty, depth, deps);
516
518
  if (!yes) {
517
519
  return confirmationRequired(command, plain, pretty, depth, {
518
520
  message: 'Rolling back replaces the live site with an earlier deployment.',
519
- display: '되돌리면 지금 게시된 사이트가 이전 배포로 바뀝니다. 사용자에게 확인한 뒤 --yes 를 붙여 실행하세요.'
521
+ display: 'Rolling back replaces the live site with an earlier deployment. Confirm with the user, then run the command with --yes.'
520
522
  }, { project });
521
523
  }
522
524
  const history = await loadHistory(command, project, pretty, depth, deps);
523
525
  if ('result' in history)
524
526
  return history.result;
525
527
  const { session, deployments } = history;
526
- const refuse = (code, message, display) => pretty
527
- ? prettyResult(1, depth, command, display, [['서버', session.siteUrl], ['프로젝트', project]])
528
+ const refuse = (code, message) => pretty
529
+ ? prettyResult(1, depth, command, message, [['Server', session.siteUrl], ['Project', project]])
528
530
  : agentResult(1, { command, siteUrl: session.siteUrl, project, deployments, error: { code, message } });
529
531
  const matches = to === undefined ? deployments.slice(1, 2) : deployments.filter(({ commit }) => commit.startsWith(to));
530
532
  if (matches.length !== 1) {
531
533
  return to === undefined
532
- ? refuse('no_previous_deployment', 'There is no earlier published deployment to roll back to. Nothing was changed.', '되돌릴 이전 배포가 없습니다. 바꾼 것이 없습니다.')
533
- : refuse('deployment_not_found', `No single published deployment matches ${to}. Pick a commit from deepdynamic projects history ${project}. Nothing was changed.`, `${to} 에 맞는 배포를 하나로 정하지 못했습니다. deepdynamic projects history ${project} 로 커밋을 확인하세요.`);
534
+ ? refuse('no_previous_deployment', 'There is no earlier published deployment to roll back to. Nothing was changed.')
535
+ : refuse('deployment_not_found', `No single published deployment matches ${to}. Pick a commit from deepdynamic projects history ${project}. Nothing was changed.`);
534
536
  }
535
537
  const [target] = matches;
536
538
  if (target.current)
537
- return refuse('already_current', 'That deployment is already published. Nothing was changed.', '이미 게시 중인 배포입니다. 바꾼 것이 없습니다.');
539
+ return refuse('already_current', 'That deployment is already published. Nothing was changed.');
538
540
  return shipDeployment({
539
541
  command, project, manifest: target.manifest,
540
542
  context: { project, target: { commit: target.commit, publishedAt: target.publishedAt } },
541
543
  success: {},
542
- rows: [['프로젝트', project], ['되돌릴 커밋', target.commit]],
544
+ rows: [['Project', project], ['Target', target.commit]],
543
545
  waitMs: timeout.waitMs,
544
546
  send: (remote, branch, token, onUploading) => deps.restore(remote, branch, token, target.commit, { onUploading })
545
547
  }, pretty, depth, deps);
@@ -557,34 +559,34 @@ async function plannedRollback(project, to, pretty, depth, deps) {
557
559
  ];
558
560
  if (!pretty)
559
561
  return agentResult(0, { command, siteUrl, dryRun: true, applied: false, plan: { project, to }, requests });
560
- return prettyResult(0, depth, command, '되돌리기를 확인했습니다. 되돌리지 않았습니다.', [
561
- ['서버', siteUrl], ['프로젝트', project], ['되돌릴 커밋', to ?? '지금 게시된 배포의 바로 전 배포'],
562
- ...requests.map(({ method, url }, index) => [index === 0 ? '요청' : '', `${method} ${url}`])
562
+ return prettyResult(0, depth, command, 'Checked the rollback. Nothing was rolled back.', [
563
+ ['Server', siteUrl], ['Project', project], ['Target', to ?? 'The deployment before the live one'],
564
+ ...requests.map(({ method, url }, index) => [index === 0 ? 'Request' : '', `${method} ${url}`])
563
565
  ]);
564
566
  }
565
567
  export async function runProjectsRename(args, pretty, depth, deps = defaultAuthDeps(pretty, depth)) {
566
568
  const command = 'projects rename';
567
569
  const invalid = (message) => usageError(command, message, pretty, depth);
568
570
  const dryRun = args.includes('--dry-run');
569
- const parsed = parseCommand(args.filter((arg) => arg !== '--dry-run'), [], pretty);
571
+ const parsed = parseCommand(args.filter((arg) => arg !== '--dry-run'), []);
570
572
  if ('error' in parsed)
571
573
  return invalid(parsed.error);
572
574
  const { names } = parsed;
573
575
  if (names.length !== 2)
574
- return invalid(pretty ? '지금 이름과 새 이름을 차례로 지정하세요.' : 'Specify the current name and then the new name.');
575
- const [project, name] = names.map((value) => parseName([value], pretty));
576
+ return invalid('Specify the current name and then the new name.');
577
+ const [project, name] = names.map((value) => parseName([value]));
576
578
  if (typeof project !== 'string')
577
579
  return invalid(project.error);
578
580
  if (typeof name !== 'string')
579
581
  return invalid(name.error);
580
582
  if (project === name)
581
- return invalid(pretty ? '새 이름이 지금 이름과 같습니다.' : 'The new name is the same as the current name.');
582
- const sent = await authorized(deps, (session) => postJson(new URL(`${PROJECTS_PATH}/${project}/rename`, session.siteUrl).href, session.token, dryRun ? { name, dryRun: true } : { name }, deps, pretty ? (dryRun ? '이름을 확인하고 있습니다.' : '프로젝트 이름을 바꾸고 있습니다.') : null));
583
+ return invalid('The new name is the same as the current name.');
584
+ const sent = await authorized(deps, (session) => postJson(new URL(`${PROJECTS_PATH}/${project}/rename`, session.siteUrl).href, session.token, dryRun ? { name, dryRun: true } : { name }, deps, pretty ? (dryRun ? 'Checking the name.' : 'Renaming the project.') : null));
583
585
  if ('login' in sent)
584
586
  return sent.login;
585
587
  const { session, result } = sent;
586
588
  const failure = !('failure' in result) && result.status === 409
587
- ? { code: 'project_taken', message: 'Another project already uses that name. Pick another name with the naming steps in deepdynamic projects create --help.', display: '이미 쓰이는 이름입니다. 다른 이름을 고르세요.' }
589
+ ? plainFailure('project_taken', 'Another project already uses that name. Pick another name with the naming steps in deepdynamic projects create --help.')
588
590
  : exchangeFailure(result);
589
591
  const value = failure ? null : result.body;
590
592
  const valid = dryRun
@@ -593,31 +595,31 @@ export async function runProjectsRename(args, pretty, depth, deps = defaultAuthD
593
595
  if (failure || !valid) {
594
596
  const shown = failure ?? UNEXPECTED;
595
597
  return pretty
596
- ? prettyResult(1, depth, command, '프로젝트 이름을 바꾸지 못했습니다.', [['서버', session.siteUrl], ['프로젝트', project], ['새 이름', name], ['원인', shown.display]])
598
+ ? prettyResult(1, depth, command, 'Could not rename the project.', [['Server', session.siteUrl], ['Project', project], ['New name', name], ['Reason', shown.display]])
597
599
  : agentResult(1, { command, siteUrl: session.siteUrl, project, name, renamed: false, error: failureError(shown) });
598
600
  }
599
601
  if (dryRun) {
600
602
  const available = value?.available === true;
601
603
  if (!pretty)
602
604
  return agentResult(0, { command, siteUrl: session.siteUrl, dryRun: true, project, name, available });
603
- return prettyResult(0, depth, command, available ? '쓸 수 있는 이름입니다. 이름은 바꾸지 않았습니다.' : '이미 쓰이는 이름입니다. 다른 이름을 고르세요.', [
604
- ['서버', session.siteUrl], ['프로젝트', project], ['새 이름', name]
605
+ return prettyResult(0, depth, command, available ? 'The name is available. The project was not renamed.' : 'The name is already taken. Choose a different name.', [
606
+ ['Server', session.siteUrl], ['Project', project], ['New name', name]
605
607
  ]);
606
608
  }
607
609
  if (!pretty)
608
610
  return agentResult(0, { command, siteUrl: session.siteUrl, project: name, previous: project, renamed: true });
609
- return prettyResult(0, depth, command, '프로젝트 이름을 바꿨습니다. 발급 주소는 새 이름으로 바뀌고 다음 배포 때 연결됩니다. 서버·저장소·배포 이력은 그대로입니다.', [
610
- ['서버', session.siteUrl], ['이전 이름', project], ['새 이름', name], ['배포', `deepdynamic projects deploy ${name} <폴더> --agent <코드>`]
611
+ return prettyResult(0, depth, command, 'Renamed the project. The site URL changes to the new name on the next deploy. The server, repository and deploy history stay the same.', [
612
+ ['Server', session.siteUrl], ['Previous', project], ['New name', name], ['Next', `deepdynamic projects deploy ${name} <directory> --agent <code>`]
611
613
  ]);
612
614
  }
613
- const pwaLabel = (enabled) => enabled ? '켬' : '끔';
615
+ const pwaLabel = (enabled) => enabled ? 'on' : 'off';
614
616
  function pwaFailure(result) {
615
617
  if ('failure' in result)
616
618
  return result.failure;
617
619
  if (result.status === 403)
618
- return { code: 'login_required', message: 'The access token lacks the project scope for this command. Run deepdynamic login again.', display: '이 로그인으로는 할 수 없습니다. deepdynamic login 으로 다시 로그인하세요.' };
620
+ return plainFailure('login_required', 'The access token lacks the project scope for this command. Run deepdynamic login again.');
619
621
  if (result.status === 503)
620
- return supportFailure('unavailable', { note: { en: 'The setting was not applied.', ko: '설정은 바뀌지 않았습니다.' }, retryable: true });
622
+ return supportFailure('unavailable', { note: 'The setting was not applied.', retryable: true });
621
623
  return exchangeFailure(result);
622
624
  }
623
625
  function pwaState(body, project) {
@@ -628,19 +630,19 @@ export async function runProjectsPwa(args, pretty, depth, deps = defaultAuthDeps
628
630
  const command = 'projects pwa';
629
631
  const invalid = (message) => usageError(command, message, pretty, depth);
630
632
  const { args: rest, dryRun } = splitDryRun(args);
631
- const parsed = parseCommand(rest, [], pretty);
633
+ const parsed = parseCommand(rest, []);
632
634
  if ('error' in parsed)
633
635
  return invalid(parsed.error);
634
636
  const [input, state, ...extra] = parsed.names;
635
637
  if (input === undefined)
636
- return invalid(pretty ? '프로젝트 이름을 지정하세요.' : 'Specify the project name.');
637
- const project = parseName([input], pretty);
638
+ return invalid('Specify the project name.');
639
+ const project = parseName([input]);
638
640
  if (typeof project !== 'string')
639
641
  return invalid(project.error);
640
642
  if (state !== undefined && state !== 'on' && state !== 'off')
641
- return invalid(pretty ? '프로젝트 이름 뒤에는 on 또는 off 만 올 수 있습니다.' : 'After the project name give on or off, or nothing to show the current state.');
643
+ return invalid('After the project name give on or off, or nothing to show the current state.');
642
644
  if (extra.length)
643
- return invalid(unknownArgument(extra[0], pretty));
645
+ return invalid(unknownArgument(extra[0]));
644
646
  const enabled = state === undefined ? null : state === 'on';
645
647
  const url = (siteUrl) => new URL(`${PROJECTS_PATH}/${project}/pwa`, siteUrl).href;
646
648
  if (dryRun) {
@@ -649,11 +651,11 @@ export async function runProjectsPwa(args, pretty, depth, deps = defaultAuthDeps
649
651
  const session = await signedIn(deps);
650
652
  if ('login' in session)
651
653
  return session.login;
652
- return plannedChange(command, pretty, depth, session.siteUrl, { url: url(session.siteUrl), body: { enabled } }, '앱 설치(PWA) 변경을 확인했습니다. 바꾸지 않았습니다.', [['프로젝트', project], ['바꿀 설정', `앱 설치(PWA) ${pwaLabel(enabled)}`]], { project, pwa: enabled });
654
+ return plannedChange(command, pretty, depth, session.siteUrl, { url: url(session.siteUrl), body: { enabled } }, 'Checked the PWA change. Nothing was changed.', [['Project', project], ['PWA', pwaLabel(enabled)]], { project, pwa: enabled });
653
655
  }
654
656
  const sent = await authorized(deps, (session) => enabled === null
655
- ? request(url(session.siteUrl), { method: 'GET', headers: { authorization: `Bearer ${session.token}` } }, deps, pretty ? '앱 설치 설정을 불러오고 있습니다.' : null)
656
- : postJson(url(session.siteUrl), session.token, { enabled }, deps, pretty ? '앱 설치 설정을 바꾸고 있습니다.' : null));
657
+ ? request(url(session.siteUrl), { method: 'GET', headers: { authorization: `Bearer ${session.token}` } }, deps, pretty ? 'Loading the PWA setting.' : null)
658
+ : postJson(url(session.siteUrl), session.token, { enabled }, deps, pretty ? 'Changing the PWA setting.' : null));
657
659
  if ('login' in sent)
658
660
  return sent.login;
659
661
  const { session, result } = sent;
@@ -662,15 +664,15 @@ export async function runProjectsPwa(args, pretty, depth, deps = defaultAuthDeps
662
664
  if (pwa === null) {
663
665
  const shown = failure ?? UNEXPECTED;
664
666
  return pretty
665
- ? prettyResult(1, depth, command, enabled === null ? '앱 설치 설정을 확인하지 못했습니다.' : '앱 설치 설정을 바꾸지 못했습니다.', [['서버', session.siteUrl], ['프로젝트', project], ['원인', shown.display]])
667
+ ? prettyResult(1, depth, command, enabled === null ? 'Could not load the PWA setting.' : 'Could not change the PWA setting.', [['Server', session.siteUrl], ['Project', project], ['Reason', shown.display]])
666
668
  : agentResult(1, { command, siteUrl: session.siteUrl, project, error: failureError(shown) });
667
669
  }
668
670
  if (!pretty)
669
671
  return agentResult(0, { command, siteUrl: session.siteUrl, project, pwa });
670
672
  const message = enabled === null
671
- ? (pwa ? '방문자가 이 사이트를 앱으로 설치할 수 있습니다.' : '앱 설치가 꺼져 있습니다.')
672
- : (pwa ? '앱 설치(PWA)를 켰습니다. 방문자가 사이트를 앱으로 설치할 수 있습니다.' : '앱 설치(PWA)를 껐습니다. 설치 안내가 더 이상 뜨지 않습니다.');
673
- return prettyResult(0, depth, command, message, [['서버', session.siteUrl], ['프로젝트', project], ['앱 설치(PWA)', pwaLabel(pwa)]]);
673
+ ? (pwa ? 'PWA is on. Visitors can install this site as an app.' : 'PWA is off. Visitors cannot install this site as an app.')
674
+ : (pwa ? 'Turned PWA on. Visitors can install the site as an app.' : 'Turned PWA off. Visitors no longer see the install prompt.');
675
+ return prettyResult(0, depth, command, message, [['Server', session.siteUrl], ['Project', project], ['PWA', pwaLabel(pwa)]]);
674
676
  }
675
677
  function postProject(session, project, action, deps, spinner) {
676
678
  return request(new URL(`${PROJECTS_PATH}/${project}/${action}`, session.siteUrl).href, {
@@ -681,79 +683,79 @@ async function plannedProjectChange(command, project, action, message, pretty, d
681
683
  const session = await signedIn(deps);
682
684
  if ('login' in session)
683
685
  return session.login;
684
- return plannedChange(command, pretty, depth, session.siteUrl, { url: new URL(`${PROJECTS_PATH}/${project}/${action}`, session.siteUrl).href }, message, [['프로젝트', project]], { project });
686
+ return plannedChange(command, pretty, depth, session.siteUrl, { url: new URL(`${PROJECTS_PATH}/${project}/${action}`, session.siteUrl).href }, message, [['Project', project]], { project });
685
687
  }
686
688
  export async function runProjectsStop(args, pretty, depth, deps = defaultAuthDeps(pretty, depth)) {
687
689
  const command = 'projects stop';
688
690
  const { args: plain, dryRun } = splitDryRun(args);
689
691
  const { args: rest, yes } = splitYes(plain);
690
- const project = parseName(rest, pretty);
692
+ const project = parseName(rest);
691
693
  if (typeof project !== 'string')
692
694
  return usageError(command, project.error, pretty, depth);
693
695
  if (dryRun)
694
- return plannedProjectChange(command, project, 'stop', '프로젝트 서버 끄기를 확인했습니다. 끄지 않았습니다.', pretty, depth, deps);
696
+ return plannedProjectChange(command, project, 'stop', 'Checked stopping the project server. Nothing was stopped.', pretty, depth, deps);
695
697
  if (!yes) {
696
698
  return confirmationRequired(command, plain, pretty, depth, {
697
699
  message: 'Stopping cancels the running deploys of the project and turns its server off, so the site is offline until the next deploy.',
698
- display: '끄면 진행 중인 배포가 취소되고 다음 배포 전까지 사이트가 내려갑니다. 사용자에게 확인한 뒤 --yes 를 붙여 실행하세요.'
700
+ display: 'Stopping cancels running deploys and takes the site offline until the next deploy. Confirm with the user, then run the command with --yes.'
699
701
  }, { project });
700
702
  }
701
- const sent = await authorized(deps, (session) => postProject(session, project, 'stop', deps, pretty ? '프로젝트 서버를 끄고 있습니다.' : null));
703
+ const sent = await authorized(deps, (session) => postProject(session, project, 'stop', deps, pretty ? 'Stopping the project server.' : null));
702
704
  if ('login' in sent)
703
705
  return sent.login;
704
706
  const { session, result } = sent;
705
707
  const failure = !('failure' in result) && result.status === 409
706
- ? { code: 'server_updating', message: 'The project server is installing updates. Keep running deepdynamic projects stop until it no longer fails with server_updating.', display: '프로젝트 서버가 업데이트를 설치하고 있습니다. 업데이트가 끝나면 다시 시도하세요.' }
708
+ ? { code: 'server_updating', message: 'The project server is installing updates. Keep running deepdynamic projects stop until it no longer fails with server_updating.', display: 'The project server is installing updates. Try again after they finish.' }
707
709
  : exchangeFailure(result);
708
710
  const status = failure ? null : projectStatus(result.body, project);
709
711
  if (!status) {
710
712
  const shown = failure ?? UNEXPECTED;
711
713
  return pretty
712
- ? prettyResult(1, depth, command, '프로젝트 서버를 끄지 못했습니다.', [['서버', session.siteUrl], ['프로젝트', project], ['원인', shown.display]])
714
+ ? prettyResult(1, depth, command, 'Could not stop the project server.', [['Server', session.siteUrl], ['Project', project], ['Reason', shown.display]])
713
715
  : agentResult(1, { command, siteUrl: session.siteUrl, project, error: failureError(shown) });
714
716
  }
715
717
  const { server, site } = status;
716
- return finish(command, 0, depth, pretty, session.siteUrl, project, server, site, null, server.stage === 'stopped' ? '프로젝트 서버를 껐습니다. 다시 배포하면 켜집니다.' : '켜져 있는 프로젝트 서버가 없습니다.');
718
+ return finish(command, 0, depth, pretty, session.siteUrl, project, server, site, null, server.stage === 'stopped' ? 'Stopped the project server. The next deploy turns it back on.' : 'No project server is running.');
717
719
  }
718
720
  export async function runProjectsDelete(args, pretty, depth, deps = defaultAuthDeps(pretty, depth)) {
719
721
  const command = 'projects delete';
720
722
  const { args: plain, dryRun } = splitDryRun(args);
721
723
  const { args: rest, yes } = splitYes(plain);
722
- const project = parseName(rest, pretty);
724
+ const project = parseName(rest);
723
725
  if (typeof project !== 'string')
724
726
  return usageError(command, project.error, pretty, depth);
725
727
  if (dryRun)
726
- return plannedProjectChange(command, project, 'delete', '프로젝트 삭제를 확인했습니다. 삭제하지 않았습니다.', pretty, depth, deps);
728
+ return plannedProjectChange(command, project, 'delete', 'Checked deleting the project. Nothing was deleted.', pretty, depth, deps);
727
729
  if (!yes) {
728
730
  return confirmationRequired(command, plain, pretty, depth, {
729
731
  message: 'Deleting removes the project, its server and its deploy history permanently.',
730
- display: '삭제하면 프로젝트와 서버, 배포 이력이 모두 사라지고 되돌릴 수 없습니다. 사용자에게 확인한 뒤 --yes 를 붙여 실행하세요.'
732
+ display: 'Deleting removes the project, its server and its deploy history. This cannot be undone. Confirm with the user, then run the command with --yes.'
731
733
  }, { project });
732
734
  }
733
- const sent = await authorized(deps, (session) => postProject(session, project, 'delete', deps, pretty ? '프로젝트를 삭제하고 있습니다.' : null));
735
+ const sent = await authorized(deps, (session) => postProject(session, project, 'delete', deps, pretty ? 'Deleting the project.' : null));
734
736
  if ('login' in sent)
735
737
  return sent.login;
736
738
  const { session, result } = sent;
737
739
  const failure = !('failure' in result) && result.status === 409
738
- ? { code: 'server_busy', message: 'The project server is busy with another job. Try again after it finishes.', display: '프로젝트 서버가 아직 만들어지는 중이거나 다른 작업을 하고 있습니다. 작업이 끝나면 다시 시도하세요.' }
740
+ ? { code: 'server_busy', message: 'The project server is busy with another job. Try again after it finishes.', display: 'The project server is still being created or is busy with another job. Try again after it finishes.' }
739
741
  : exchangeFailure(result);
740
742
  const value = failure ? null : result.body;
741
743
  if (failure || value?.ok !== true || value.project !== project || value.deleted !== true) {
742
744
  const shown = failure ?? UNEXPECTED;
743
745
  return pretty
744
- ? prettyResult(1, depth, command, '프로젝트를 삭제하지 못했습니다.', [['서버', session.siteUrl], ['프로젝트', project], ['원인', shown.display]])
746
+ ? prettyResult(1, depth, command, 'Could not delete the project.', [['Server', session.siteUrl], ['Project', project], ['Reason', shown.display]])
745
747
  : agentResult(1, { command, siteUrl: session.siteUrl, project, deleted: false, error: failureError(shown) });
746
748
  }
747
749
  if (!pretty)
748
750
  return agentResult(0, { command, siteUrl: session.siteUrl, project, deleted: true });
749
- return prettyResult(0, depth, command, '프로젝트를 삭제했습니다. 서버는 뒤에서 끄고 지웁니다.', [['서버', session.siteUrl], ['프로젝트', project]]);
751
+ return prettyResult(0, depth, command, 'Deleted the project. Its server is stopped and removed in the background.', [['Server', session.siteUrl], ['Project', project]]);
750
752
  }
751
753
  const PHOTOCARD_SIDES = [1, 2];
752
- const PHOTOCARD_LABELS = { 1: '앞면', 2: '뒷면' };
754
+ const PHOTOCARD_LABELS = { 1: 'Front', 2: 'Back' };
753
755
  const FLIGHT_REQUIRED = {
754
756
  code: 'flight_required',
755
757
  message: 'The project has no flight yet. Deploy it once with deepdynamic projects deploy <name> <directory> --agent <code>, then run this again.',
756
- display: '아직 편명이 없는 프로젝트입니다. --agent 를 붙여 한 번 배포한 뒤 다시 실행하세요.'
758
+ display: 'The photocard needs a deploy made with --agent. Deploy the project once with --agent, then run this again.'
757
759
  };
758
760
  function attachmentName(header) {
759
761
  const encoded = /filename\*=UTF-8''([^;]+)/i.exec(header ?? '')?.[1];
@@ -783,14 +785,14 @@ export async function runProjectsPhotocard(args, pretty, depth, deps = { ...defa
783
785
  const command = 'projects photocard';
784
786
  const invalid = (message) => usageError(command, message, pretty, depth);
785
787
  const { args: rest, dryRun } = splitDryRun(args);
786
- const parsed = parseCommand(rest, ['--out'], pretty);
788
+ const parsed = parseCommand(rest, ['--out']);
787
789
  if ('error' in parsed)
788
790
  return invalid(parsed.error);
789
- const project = parseName(parsed.names, pretty);
791
+ const project = parseName(parsed.names);
790
792
  if (typeof project !== 'string')
791
793
  return invalid(project.error);
792
794
  if (parsed.entries.length > 1)
793
- return invalid(pretty ? '--out 은 한 번만 지정하세요.' : 'Give --out at most once.');
795
+ return invalid('Give --out at most once.');
794
796
  const out = parsed.entries[0]?.[1] ?? '.';
795
797
  const url = (siteUrl, side) => `${new URL(`${PROJECTS_PATH}/${project}/photocard`, siteUrl).href}?side=${side}`;
796
798
  if (dryRun) {
@@ -799,18 +801,18 @@ export async function runProjectsPhotocard(args, pretty, depth, deps = { ...defa
799
801
  return session.login;
800
802
  const requests = PHOTOCARD_SIDES.map((side) => ({ method: 'GET', url: url(session.siteUrl, side) }));
801
803
  return pretty
802
- ? prettyResult(0, depth, command, '요청을 보내지 않고 확인만 했습니다.', [['서버', session.siteUrl], ['프로젝트', project], ['저장 폴더', out], ...requests.map(({ url }) => ['요청', `GET ${url}`])])
804
+ ? prettyResult(0, depth, command, 'Checked without sending the requests.', [['Server', session.siteUrl], ['Project', project], ['Directory', out], ...requests.map(({ url }) => ['Request', `GET ${url}`])])
803
805
  : agentResult(0, { command, siteUrl: session.siteUrl, dryRun: true, project, out, requests });
804
806
  }
805
807
  const images = [];
806
808
  const failed = (siteUrl, shown) => pretty
807
- ? prettyResult(1, depth, command, '포토카드를 저장하지 못했습니다.', [['서버', siteUrl], ['프로젝트', project], ['원인', shown.display]])
809
+ ? prettyResult(1, depth, command, 'Could not save the photocard.', [['Server', siteUrl], ['Project', project], ['Reason', shown.display]])
808
810
  : agentResult(1, { command, siteUrl, project, images, error: failureError(shown) });
809
811
  let siteUrl = '';
810
812
  for (const side of PHOTOCARD_SIDES) {
811
813
  const sent = await authorized(deps, (session) => request(url(session.siteUrl, side), {
812
814
  method: 'GET', headers: { authorization: `Bearer ${session.token}` }
813
- }, deps, pretty ? `포토카드 ${PHOTOCARD_LABELS[side]}을 만들고 있습니다.` : null, readPhotocard));
815
+ }, deps, pretty ? `Rendering the photocard ${PHOTOCARD_LABELS[side].toLowerCase()}.` : null, readPhotocard));
814
816
  if ('login' in sent)
815
817
  return sent.login;
816
818
  siteUrl = sent.session.siteUrl;
@@ -824,13 +826,13 @@ export async function runProjectsPhotocard(args, pretty, depth, deps = { ...defa
824
826
  await deps.writeFile(path, image.bytes);
825
827
  }
826
828
  catch {
827
- return failed(siteUrl, { code: 'save_failed', message: `Could not write ${path}. Check that the directory exists and is writable.`, display: `${path} 에 쓰지 못했습니다. 폴더가 있고 쓸 수 있는지 확인하세요.` });
829
+ return failed(siteUrl, plainFailure('save_failed', `Could not write ${path}. Check that the directory exists and is writable.`));
828
830
  }
829
831
  images.push({ side, path, bytes: image.bytes.length });
830
832
  }
831
833
  if (!pretty)
832
834
  return agentResult(0, { command, siteUrl, project, images });
833
- return prettyResult(0, depth, command, '포토카드 앞면과 뒷면을 PNG 로 저장했습니다.', [
834
- ['서버', siteUrl], ['프로젝트', project], ...images.map(({ side, path }) => [PHOTOCARD_LABELS[side], path])
835
+ return prettyResult(0, depth, command, 'Saved the photocard front and back as PNG files.', [
836
+ ['Server', siteUrl], ['Project', project], ...images.map(({ side, path }) => [PHOTOCARD_LABELS[side], path])
835
837
  ]);
836
838
  }