@deepdynamic/cli 0.1.0 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/dist/agents/content.js +1 -1
  2. package/dist/agents/install.js +28 -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 +229 -243
  13. package/dist/commands/domains.js +188 -260
  14. package/dist/commands/emails.js +64 -26
  15. package/dist/commands/env.js +38 -38
  16. package/dist/commands/help.js +18 -19
  17. package/dist/commands/keys.js +84 -90
  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 +82 -69
  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 +139 -112
  26. package/dist/commands/search.js +29 -18
  27. package/dist/commands/server.js +100 -112
  28. package/dist/commands/sessions.js +38 -44
  29. package/dist/commands/sites.js +16 -16
  30. package/dist/commands/sms.js +31 -17
  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 +74 -146
  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 +40 -5
  56. package/dist/runtime/usage-error.js +2 -2
  57. package/dist/setup-agents.js +9 -2
  58. package/package.json +1 -1
@@ -7,7 +7,7 @@ import { plannedChange, plannedRequest } from "../runtime/dry-run.js";
7
7
  import { unknownArgument } from "../runtime/flags.js";
8
8
  import { spec } from "../registry.js";
9
9
  import { supportFailure } from "../runtime/support.js";
10
- import { fail, rehearsed } from "./dns.js";
10
+ import { rehearsed } from "./dns.js";
11
11
  export const PLAN_PATH = '/api/v1/billing';
12
12
  const SUBSCRIPTION_PATH = `${PLAN_PATH}/subscription`;
13
13
  const PRICES = { pro: 9900, team: 29000 };
@@ -17,163 +17,147 @@ const CANCEL = spec('plan cancel');
17
17
  const RESUME = spec('plan resume');
18
18
  const PAY = spec('plan pay');
19
19
  const PAY_PATH = `${PLAN_PATH}/charges/pay`;
20
- const PAY_FAILED = '미결제 요금을 결제하지 못했습니다.';
21
- const SUBSCRIBE_FAILED = '요금제를 바꾸지 못했습니다.';
22
- const CHARGE_STATES = { paid: '결제됨', pending: '처리 중', failed: '실패', waived: '면제' };
23
- const won = (amount) => `${amount.toLocaleString('ko-KR')}원`;
20
+ const PAY_FAILED = 'Could not pay the unpaid charges.';
21
+ const SUBSCRIBE_FAILED = 'Could not change the plan.';
22
+ const ASK = 'Confirm with the user, then run it again with --yes.';
23
+ const krw = (amount) => `${amount.toLocaleString('en-US')} KRW`;
24
+ const unpaidCharges = (count) => `${count.toLocaleString('en-US')} unpaid ${count === 1 ? 'charge' : 'charges'}`;
25
+ const known = (code, message) => ({ code, message, display: message });
24
26
  const UNAVAILABLE = supportFailure('unavailable');
25
27
  const CHANGE_UNAVAILABLE = supportFailure('unavailable', {
26
- note: { en: 'The change may already have been applied, so check deepdynamic plan before retrying.', ko: '이미 반영됐을 수 있으니 deepdynamic plan 으로 확인한 뒤 다시 시도하세요.' }
28
+ note: 'The change may already have been applied, so check deepdynamic plan before retrying.'
27
29
  });
28
- const CHARGE_PENDING = {
29
- code: 'charge_pending',
30
- message: 'A payment for this subscription is still being processed, so nothing was changed. Check deepdynamic plan a little later and contact support with deepdynamic support contact if it stays pending.',
31
- display: '처리 중인 결제가 있어 바꾸지 않았습니다. 잠시 뒤 deepdynamic plan 으로 확인하세요.'
32
- };
33
- const NO_SUBSCRIPTION = {
34
- code: 'no_subscription',
35
- message: 'The account has no paid subscription, so nothing was changed. Check it with deepdynamic plan.',
36
- display: '이용 중인 유료 요금제가 없습니다. deepdynamic plan 으로 확인하세요.'
37
- };
30
+ const CHARGE_PENDING = known('charge_pending', 'A payment for this subscription is still being processed, so nothing was changed. Check deepdynamic plan a little later and contact support with deepdynamic support contact if it stays pending.');
31
+ const NO_SUBSCRIPTION = known('no_subscription', 'The account has no paid subscription, so nothing was changed. Check it with deepdynamic plan.');
38
32
  const DECLINED = {
39
33
  code: 'payment_declined',
40
34
  message: 'The card company declined the payment, so nothing was charged or changed. reason holds its answer when it gave one. Ask the user to check the card or register another one, then run the same command again.',
41
- display: '카드사가 결제를 거절해 결제하지 않았습니다. 카드를 확인하거나 다른 카드를 등록한 뒤 다시 시도하세요.'
42
- };
43
- const NO_UNPAID = {
44
- code: 'no_unpaid',
45
- message: 'The account has no unpaid charge, so nothing was charged. Check it with deepdynamic plan.',
46
- display: '결제되지 않은 요금이 없습니다. deepdynamic plan 으로 확인하세요.'
35
+ display: 'The card company declined the payment, so nothing was charged. Check the card or register another one, then try again.'
47
36
  };
37
+ const NO_UNPAID = known('no_unpaid', 'The account has no unpaid charge, so nothing was charged. Check it with deepdynamic plan.');
48
38
  const SUBSCRIBE_FAILURES = {
49
39
  unavailable: CHANGE_UNAVAILABLE,
50
40
  charge_pending: CHARGE_PENDING,
51
- invalid_plan: {
52
- code: 'invalid_plan',
53
- message: 'The server accepts only pro or team as the plan, so nothing was changed.',
54
- display: '요금제는 pro 나 team 만 지정할 수 있습니다.'
55
- },
56
- payment_unavailable: supportFailure('payment_unavailable', { note: { en: 'Nothing was charged or changed.', ko: '결제하지 않았습니다.' } })
41
+ invalid_plan: known('invalid_plan', 'The server accepts only pro or team as the plan, so nothing was changed.'),
42
+ unpaid_charges: known('unpaid_charges', 'The account has unpaid charges, so the plan was not changed and nothing was charged. Pay them with deepdynamic plan pay, then run the same command again.'),
43
+ payment_unavailable: supportFailure('payment_unavailable', { note: 'Nothing was charged or changed.' })
57
44
  };
58
45
  const SHOW_STEPS = [
59
- { stage: 'check_options', message: '조회 옵션을 확인하고 있습니다.' },
60
- { stage: 'prepare_request', message: '요금제 조회 요청을 준비하고 있습니다.' }
46
+ { stage: 'check_options', message: 'Checking the options.' },
47
+ { stage: 'prepare_request', message: 'Preparing the plan request.' }
61
48
  ];
62
49
  const SUBSCRIBE_STEPS = [
63
- { stage: 'check_options', message: '요금제 옵션을 확인하고 있습니다.' },
64
- { stage: 'calculate_charge', message: '요금제 월 요금을 계산하고 있습니다.' },
65
- { stage: 'check_consent', message: '결제 동의를 확인하고 있습니다.' },
66
- { stage: 'prepare_request', message: '요금제 변경 요청을 준비하고 있습니다.' }
50
+ { stage: 'check_options', message: 'Checking the plan options.' },
51
+ { stage: 'calculate_charge', message: 'Calculating the monthly price of the plan.' },
52
+ { stage: 'check_consent', message: 'Checking the payment consent.' },
53
+ { stage: 'prepare_request', message: 'Preparing the plan change request.' }
67
54
  ];
68
55
  const CANCEL_STEPS = [
69
- { stage: 'check_options', message: '해지 옵션을 확인하고 있습니다.' },
70
- { stage: 'summarize_impact', message: '해지 뒤 이용 기간과 환불을 정리하고 있습니다.' },
71
- { stage: 'prepare_request', message: '요금제 해지 요청을 준비하고 있습니다.' }
56
+ { stage: 'check_options', message: 'Checking the cancellation options.' },
57
+ { stage: 'summarize_impact', message: 'Summarizing the remaining period and refunds after cancelling.' },
58
+ { stage: 'prepare_request', message: 'Preparing the cancellation request.' }
72
59
  ];
73
60
  const RESUME_STEPS = [
74
- { stage: 'check_options', message: '해지 취소 옵션을 확인하고 있습니다.' },
75
- { stage: 'summarize_impact', message: '다시 이어질 자동 결제를 정리하고 있습니다.' },
76
- { stage: 'prepare_request', message: '해지 취소 요청을 준비하고 있습니다.' }
61
+ { stage: 'check_options', message: 'Checking the options for undoing the cancellation.' },
62
+ { stage: 'summarize_impact', message: 'Summarizing the automatic payments that resume.' },
63
+ { stage: 'prepare_request', message: 'Preparing the request to undo the cancellation.' }
77
64
  ];
78
65
  const PAY_STEPS = [
79
- { stage: 'check_options', message: '결제 옵션을 확인하고 있습니다.' },
80
- { stage: 'check_consent', message: '결제 동의를 확인하고 있습니다.' },
81
- { stage: 'prepare_request', message: '미결제 요금 결제 요청을 준비하고 있습니다.' }
66
+ { stage: 'check_options', message: 'Checking the payment options.' },
67
+ { stage: 'check_consent', message: 'Checking the payment consent.' },
68
+ { stage: 'prepare_request', message: 'Preparing the request to pay the unpaid charges.' }
82
69
  ];
83
- const CANCEL_CONFIRM = {
84
- message: 'Cancelling ends the paid plan. If the current billing period\'s payment has been made, the plan stays until the day before the next billing date and deepdynamic plan resume can undo it. If it has not been made yet, the subscription ends now, the account is on free at once and it cannot be undone.',
85
- display: '해지하면 유료 요금제가 끝납니다. 이번 결제 기간 요금을 결제했으면 다음 결제일 전날까지 쓰고 deepdynamic plan resume 으로 되돌릴 수 있지만, 아직 결제하지 않았으면 바로 끝나 free 가 되고 되돌릴 수 없습니다. 사용자에게 확인한 뒤 --yes 를 붙여 실행하세요.'
86
- };
87
- const RESUMABLE = ['되돌리기', '다음 결제일이 되기 전에 deepdynamic plan resume 으로 해지 예약을 취소할 수 있습니다.'];
70
+ const CANCEL_IMPACT = 'Cancelling ends the paid plan. If the current billing period\'s payment has been made, the plan stays until the day before the next billing date and deepdynamic plan resume can undo it. If it has not been made yet, the subscription ends now, the account is on free at once and it cannot be undone.';
71
+ const CANCEL_CONFIRM = { message: CANCEL_IMPACT, display: `${CANCEL_IMPACT} ${ASK}` };
72
+ const RESUMABLE = ['Undo', 'Run deepdynamic plan resume before the next billing date to undo the scheduled cancellation.'];
88
73
  const CANCEL_ROWS = [
89
- ['해지', '이번 결제 기간 요금을 결제했으면 다음 결제일 전날까지 지금 요금제를 쓰고 그다음 free 로 돌아갑니다.'],
90
- ['결제 전', '이번 결제 기간 요금을 아직 결제하지 않았으면 바로 끝나고 지금부터 free 입니다.'],
91
- ['환불', '이미 결제한 금액은 환불되지 않습니다.'],
74
+ ['Cancellation', 'If this billing period is paid, the current plan stays until the day before the next billing date and then returns to free.'],
75
+ ['Unpaid period', 'If this billing period is not paid yet, the plan ends now and the account is on free from now on.'],
76
+ ['Refund', 'Amounts already paid are not refunded.'],
92
77
  RESUMABLE
93
78
  ];
94
79
  const RESUME_ROWS = [
95
- ['해지 취소', '해지 예약을 없애 지금 요금제를 계속 씁니다.'],
96
- ['자동 결제', '다음 결제일부터 다시 매달 같은 날 등록한 카드로 결제됩니다.']
80
+ ['Undo', 'Removes the scheduled cancellation, so the current plan continues.'],
81
+ ['Auto-pay', 'From the next billing date, the registered card is charged on the same day every month again.']
97
82
  ];
98
83
  const SUBSCRIBE_MESSAGES = {
99
- subscribed: ({ plan }) => `${plan} 요금제를 구독했습니다.`,
100
- upgraded: ({ plan, monthlyAmount }, charged) => `${plan} 요금제로 올렸습니다.${charged ? '' : ` 이번 결제 기간 요금은 정기 결제 때 ${won(monthlyAmount)}으로 결제됩니다.`}`,
101
- downgraded: ({ plan, monthlyAmount }) => `${plan} 요금제로 낮췄습니다. 이미 결제한 금액은 환불되지 않고 다음 정기 결제부터 월 ${won(monthlyAmount)}이 결제됩니다.`,
102
- resumed: ({ plan }) => `해지 예약을 취소했습니다. ${plan} 요금제를 계속 씁니다.`,
103
- unchanged: ({ plan }) => `이미 ${plan} 요금제를 쓰고 있어 바꾸지 않았습니다.`
84
+ subscribed: ({ plan }) => `Subscribed to the ${plan} plan.`,
85
+ upgraded: ({ plan, monthlyAmount }, charged) => `Upgraded to the ${plan} plan.${charged ? '' : ` The ${krw(monthlyAmount)} for this billing period is charged with the scheduled payment.`}`,
86
+ downgraded: ({ plan, monthlyAmount }) => `Downgraded to the ${plan} plan. Amounts already paid are not refunded, and ${krw(monthlyAmount)} a month is charged from the next scheduled payment.`,
87
+ resumed: ({ plan }) => `Undid the scheduled cancellation. The ${plan} plan continues.`,
88
+ unchanged: ({ plan }) => `Already on the ${plan} plan, so nothing was changed.`
104
89
  };
105
90
  const CANCEL_MESSAGES = {
106
- scheduled: ({ plan, endsOn }) => `해지를 예약했습니다. ${endsOn}까지 ${plan} 요금제를 쓰고 그다음 free 로 돌아갑니다.`,
107
- cancelled: ({ plan }) => `${plan} 요금제를 해지했습니다. 이번 결제 기간 요금을 결제하기 전이라 바로 끝났고 지금부터 free 입니다.`,
108
- unchanged: ({ plan, endsOn }) => `이미 해지를 예약해 두었습니다. ${endsOn}까지 ${plan} 요금제를 씁니다.`
91
+ scheduled: ({ plan, endsOn }) => `Scheduled the cancellation. The ${plan} plan stays until ${endsOn} and then returns to free.`,
92
+ cancelled: ({ plan }) => `Cancelled the ${plan} plan. This billing period was not paid yet, so it ended now and the account is on free.`,
93
+ unchanged: ({ plan, endsOn }) => `The cancellation is already scheduled. The ${plan} plan stays until ${endsOn}.`
109
94
  };
110
95
  const RESUME_MESSAGES = {
111
- resumed: ({ plan }) => `해지 예약을 취소했습니다. ${plan} 요금제가 다음 달에도 자동 결제됩니다.`,
112
- unchanged: ({ plan }) => `해지 예약이 없어 바꾸지 않았습니다. ${plan} 요금제가 매달 자동 결제되고 있습니다.`
96
+ resumed: ({ plan }) => `Undid the scheduled cancellation. The ${plan} plan renews automatically next month.`,
97
+ unchanged: ({ plan }) => `No cancellation is scheduled, so nothing was changed. The ${plan} plan renews automatically every month.`
113
98
  };
114
99
  const succeeded = ({ status }) => status === 200;
115
- const planText = ({ plan, monthlyAmount }) => `${plan} · 월 ${won(monthlyAmount)}`;
116
- const cardText = ({ brand, last4, expMonth, expYear }) => `${brand} ····${last4} · 유효기간 ${String(expMonth).padStart(2, '0')}/${expYear}`;
117
- const chargeText = ({ period, amount, status }) => `${period} · ${won(amount)} · ${CHARGE_STATES[status] ?? status}`;
100
+ const monthly = (plan, amount) => `${plan} · ${krw(amount)}/month`;
101
+ const planText = ({ plan, monthlyAmount }) => monthly(plan, monthlyAmount);
102
+ const cardText = ({ brand, last4, expMonth, expYear }) => `${brand} ····${last4} · expires ${String(expMonth).padStart(2, '0')}/${expYear}`;
103
+ const chargeText = ({ period, amount, status }) => `${period} · ${krw(amount)} · ${status}`;
118
104
  const gb = (bytes) => `${Number((bytes / 1e9).toFixed(1))}GB`;
119
- const bandwidthText = ({ period, usedBytes, limitBytes, limited }) => `${period} · ${gb(usedBytes)} / ${gb(limitBytes)}${limitBytes > 0 ? ` (${Math.floor((usedBytes * 100) / limitBytes)}%)` : ''}${limited ? ' · 한도를 넘어 사이트를 limited.deepdynamic.net 으로 돌리는 중' : ''}`;
105
+ const bandwidthText = ({ period, usedBytes, limitBytes, limited }) => `${period} · ${gb(usedBytes)} / ${gb(limitBytes)}${limitBytes > 0 ? ` (${Math.floor((usedBytes * 100) / limitBytes)}%)` : ''}${limited ? ' · over the limit, sites are redirected to limited.deepdynamic.net' : ''}`;
120
106
  function subscriptionText({ status, monthlyAmount, endsOn }) {
121
107
  if (status === 'cancelled')
122
- return '해지됨 · 지금부터 free';
123
- return endsOn ? `해지 예약됨 · ${endsOn}까지 쓰고 free 로 돌아감` : `매달 ${won(monthlyAmount)} 자동 결제`;
108
+ return 'Cancelled · free from now on';
109
+ return endsOn ? `Cancellation scheduled · stays until ${endsOn}, then free` : `${krw(monthlyAmount)} paid automatically every month`;
124
110
  }
125
- function parseSubscribe(args, pretty) {
111
+ function parseSubscribe(args) {
126
112
  const { args: plain, yes } = splitYes(args);
127
113
  const [plan, ...extra] = plain;
128
114
  if (plan === undefined || plan.startsWith('-'))
129
- return fail(pretty, 'Specify the plan first: pro or team.', '요금제(pro 또는 team)를 먼저 지정하세요.');
130
- if (!Object.hasOwn(PRICES, plan)) {
131
- return fail(pretty, `The plan must be pro or team: ${plan}. To return to free, run deepdynamic plan cancel.`, `요금제에는 pro 나 team 을 지정하세요: ${plan}. free 로 돌아가려면 deepdynamic plan cancel 을 실행하세요.`);
132
- }
115
+ return { error: 'Specify the plan first: pro or team.' };
116
+ if (!Object.hasOwn(PRICES, plan))
117
+ return { error: `The plan must be pro or team: ${plan}. To return to free, run deepdynamic plan cancel.` };
133
118
  if (extra.length)
134
- return { error: unknownArgument(extra[0], pretty) };
119
+ return { error: unknownArgument(extra[0]) };
135
120
  return { plan: plan, consented: yes };
136
121
  }
137
122
  function subscribeRows(plan, consented) {
138
123
  return [
139
- ['요금제', `${plan} · 월 ${won(PRICES[plan])}`],
140
- ['결제', '구독 중이 아니면 첫 달 요금을 지금 결제하고, 그 날짜가 매달 결제일이 됩니다. pro 에서 team 으로 올리면 이번 결제 기간에 결제한 금액을 뺀 차액을 지금 결제하고, team 에서 pro 로 낮추면 결제·환불 없이 바로 바뀝니다.'],
141
- ['자동 결제', `그다음부터 매달 ${won(PRICES[plan])}이 등록한 카드로 결제됩니다.`],
142
- ['결제 동의', consented ? '동의함 (--yes). 지금 결제할 금액이 있으면 바로 결제됩니다.' : '구독하거나 올릴 때 필요합니다. 금액에 동의하면 --yes 를 붙이세요.']
124
+ ['Plan', monthly(plan, PRICES[plan])],
125
+ ['Payment', 'Without a subscription, the first month is charged now and that date becomes the monthly billing day. Upgrading from pro to team charges the team price minus what was paid for this billing period now. Downgrading from team to pro applies at once with no charge or refund.'],
126
+ ['Auto-pay', `After that, ${krw(PRICES[plan])} is charged to the registered card every month.`],
127
+ ['Consent', consented ? 'Given (--yes). Any amount due now is charged at once.' : 'Required to subscribe or upgrade. Add --yes once the user agrees to the amount.']
143
128
  ];
144
129
  }
145
130
  function shown(command, pretty, depth, body, siteUrl) {
146
131
  const { plan, subscription, card, charges, unpaid = { count: 0, amount: 0, charges: [] }, bandwidth } = body;
147
132
  if (!pretty)
148
133
  return agentResult(0, { command, siteUrl, plan, subscription, card, charges, unpaid, ...(bandwidth ? { bandwidth } : {}), currency: 'KRW' });
149
- return prettyResult(0, depth, command, `지금 요금제는 ${plan}입니다.`, [
150
- ['서버', siteUrl],
151
- ['요금제', subscription ? planText(subscription) : plan],
152
- ['구독', subscription ? subscriptionText(subscription) : '없음'],
153
- ['결제 카드', card ? cardText(card) : '등록되지 않음'],
154
- ['최근 결제', charges.length ? chargeText(charges[0]) : '없음'],
155
- ['미결제', unpaid.count ? `${unpaid.count}건 · ${won(unpaid.amount)} · deepdynamic plan pay 로 결제` : '없음'],
156
- ...(bandwidth ? [['대역폭', bandwidthText(bandwidth)]] : [])
134
+ return prettyResult(0, depth, command, `The current plan is ${plan}.`, [
135
+ ['Server', siteUrl],
136
+ ['Plan', subscription ? planText(subscription) : plan],
137
+ ['Subscription', subscription ? subscriptionText(subscription) : 'None'],
138
+ ['Billing card', card ? cardText(card) : 'Not registered'],
139
+ ['Last charge', charges.length ? chargeText(charges[0]) : 'None'],
140
+ ['Unpaid', unpaid.count ? `${unpaidCharges(unpaid.count)} · ${krw(unpaid.amount)} · pay with deepdynamic plan pay` : 'None'],
141
+ ...(bandwidth ? [['Bandwidth', bandwidthText(bandwidth)]] : [])
157
142
  ]);
158
143
  }
159
144
  function consentNeeded(command, args, pretty, depth, plan, { chargeNow, monthlyAmount, previousMonthlyAmount }) {
160
145
  const subscribing = previousMonthlyAmount === 0;
161
146
  const now = chargeNow ? `charges ${chargeNow} KRW now` : 'charges nothing now';
162
- const charge = chargeNow ? `지금 ${won(chargeNow)}이 결제되고` : '지금 결제되는 금액은 없고';
163
- const ask = '사용자에게 확인한 뒤 --yes 를 붙여 실행하세요.';
147
+ const charge = chargeNow ? `charges ${krw(chargeNow)} now` : 'charges nothing now';
164
148
  return confirmationRequired(command, args, pretty, depth, subscribing
165
149
  ? {
166
150
  message: `Subscribing to ${plan} ${now} and ${monthlyAmount} KRW every month after that, so it needs the user's consent.`,
167
- display: `${plan} 요금제를 구독하면 ${charge} 매달 ${won(monthlyAmount)}이 자동 결제됩니다. ${ask}`
151
+ display: `Subscribing to ${plan} ${charge} and ${krw(monthlyAmount)} automatically every month after that. ${ASK}`
168
152
  }
169
153
  : {
170
154
  message: `Changing to ${plan} ${now} and raises the monthly payment from ${previousMonthlyAmount} to ${monthlyAmount} KRW, so it needs the user's consent.`,
171
- display: `${plan} 요금제로 바꾸면 ${charge} 매달 자동 결제 금액이 ${won(previousMonthlyAmount)}에서 ${won(monthlyAmount)}으로 늘어납니다. ${ask}`
155
+ display: `Changing to ${plan} ${charge} and raises the automatic monthly payment from ${krw(previousMonthlyAmount)} to ${krw(monthlyAmount)}. ${ASK}`
172
156
  }, { plan, chargeNow, monthlyAmount, previousMonthlyAmount, currency: 'KRW' });
173
157
  }
174
158
  function declined(command, pretty, depth, siteUrl, reason, headline = SUBSCRIBE_FAILED) {
175
159
  return pretty
176
- ? prettyResult(1, depth, command, headline, [['서버', siteUrl], ['원인', DECLINED.display], ...(reason ? [['카드사 응답', reason]] : [])])
160
+ ? prettyResult(1, depth, command, headline, [['Server', siteUrl], ['Reason', DECLINED.display], ...(reason ? [['Issuer response', reason]] : [])])
177
161
  : agentResult(1, { command, siteUrl, error: failureError(DECLINED), reason });
178
162
  }
179
163
  function subscribeAnswer(command, args, plan, pretty, depth) {
@@ -199,7 +183,7 @@ function payAnswer(command, args, pretty, depth) {
199
183
  const { count, amount } = answer.unpaid;
200
184
  return confirmationRequired(command, args, pretty, depth, {
201
185
  message: `Paying the unpaid charges charges ${amount} KRW for ${count} charge(s) to the billing card now, so it needs the user's consent.`,
202
- display: `결제되지 않은 요금 ${count}건 ${won(amount)}이 등록한 카드로 지금 결제됩니다. 사용자에게 확인한 뒤 --yes 를 붙여 실행하세요.`
186
+ display: `This pays ${unpaidCharges(count)}, ${krw(amount)} in total, with the registered card now. ${ASK}`
203
187
  }, { unpaid: answer.unpaid, currency: 'KRW' });
204
188
  };
205
189
  }
@@ -207,9 +191,9 @@ function paid(command, pretty, depth, body, siteUrl) {
207
191
  const { paid: charges, charged } = body;
208
192
  if (!pretty)
209
193
  return agentResult(0, { command, siteUrl, applied: true, paid: charges, charged, currency: 'KRW' });
210
- return prettyResult(0, depth, command, `미결제 요금 ${charges.length}건 ${won(charged)}을 결제했습니다.`, [
211
- ['서버', siteUrl],
212
- ...charges.map(({ period, amount }) => [period, won(amount)])
194
+ return prettyResult(0, depth, command, `Paid ${unpaidCharges(charges.length)}, ${krw(charged)} in total.`, [
195
+ ['Server', siteUrl],
196
+ ...charges.map(({ period, amount }) => [period, krw(amount)])
213
197
  ]);
214
198
  }
215
199
  function subscribed(command, pretty, depth, body, siteUrl) {
@@ -217,10 +201,10 @@ function subscribed(command, pretty, depth, body, siteUrl) {
217
201
  if (!pretty)
218
202
  return agentResult(0, { command, siteUrl, applied: result !== 'unchanged', result, charged, currency: 'KRW', subscription });
219
203
  return prettyResult(0, depth, command, SUBSCRIBE_MESSAGES[result](subscription, charged), [
220
- ['서버', siteUrl],
221
- ['요금제', planText(subscription)],
222
- ['결제한 금액', charged ? won(charged) : '없음'],
223
- ['구독', subscriptionText(subscription)]
204
+ ['Server', siteUrl],
205
+ ['Plan', planText(subscription)],
206
+ ['Charged', charged ? krw(charged) : 'None'],
207
+ ['Subscription', subscriptionText(subscription)]
224
208
  ]);
225
209
  }
226
210
  function cancelled(command, pretty, depth, body, siteUrl) {
@@ -228,9 +212,9 @@ function cancelled(command, pretty, depth, body, siteUrl) {
228
212
  if (!pretty)
229
213
  return agentResult(0, { command, siteUrl, applied: result !== 'unchanged', result, currency: 'KRW', subscription });
230
214
  return prettyResult(0, depth, command, CANCEL_MESSAGES[result](subscription), [
231
- ['서버', siteUrl],
232
- ['해지한 요금제', planText(subscription)],
233
- ['구독', subscriptionText(subscription)],
215
+ ['Server', siteUrl],
216
+ ['Cancelled plan', planText(subscription)],
217
+ ['Subscription', subscriptionText(subscription)],
234
218
  ...(result === 'cancelled' ? [] : [RESUMABLE])
235
219
  ]);
236
220
  }
@@ -239,16 +223,16 @@ function resumed(command, pretty, depth, body, siteUrl) {
239
223
  if (!pretty)
240
224
  return agentResult(0, { command, siteUrl, applied: result === 'resumed', result, currency: 'KRW', subscription });
241
225
  return prettyResult(0, depth, command, RESUME_MESSAGES[result](subscription), [
242
- ['서버', siteUrl],
243
- ['요금제', planText(subscription)],
244
- ['구독', subscriptionText(subscription)]
226
+ ['Server', siteUrl],
227
+ ['Plan', planText(subscription)],
228
+ ['Subscription', subscriptionText(subscription)]
245
229
  ]);
246
230
  }
247
231
  export async function runPlanShow(args, pretty, depth, deps = defaultAuthDeps(pretty, depth)) {
248
232
  const command = SHOW.name;
249
233
  return rehearsed(command, args, pretty, depth, deps, (rest) => {
250
234
  if (rest.length)
251
- return { error: unknownArgument(rest[0], pretty) };
235
+ return { error: unknownArgument(rest[0]) };
252
236
  const url = (siteUrl) => new URL(PLAN_PATH, siteUrl).href;
253
237
  return {
254
238
  steps: SHOW_STEPS,
@@ -256,8 +240,8 @@ export async function runPlanShow(args, pretty, depth, deps = defaultAuthDeps(pr
256
240
  send: {
257
241
  method: 'GET',
258
242
  url,
259
- spinner: '요금제 정보를 불러오고 있습니다.',
260
- failed: '요금제 정보를 불러오지 못했습니다.',
243
+ spinner: 'Loading the plan details.',
244
+ failed: 'Could not load the plan details.',
261
245
  notFound: httpFailure(404),
262
246
  failures: { unavailable: UNAVAILABLE },
263
247
  succeeded,
@@ -269,7 +253,7 @@ export async function runPlanShow(args, pretty, depth, deps = defaultAuthDeps(pr
269
253
  export async function runPlanSubscribe(args, pretty, depth, deps = defaultAuthDeps(pretty, depth)) {
270
254
  const command = SUBSCRIBE.name;
271
255
  return rehearsed(command, args, pretty, depth, deps, (rest) => {
272
- const parsed = parseSubscribe(rest, pretty);
256
+ const parsed = parseSubscribe(rest);
273
257
  if ('error' in parsed)
274
258
  return parsed;
275
259
  const { plan, consented } = parsed;
@@ -277,12 +261,12 @@ export async function runPlanSubscribe(args, pretty, depth, deps = defaultAuthDe
277
261
  const url = (siteUrl) => new URL(SUBSCRIPTION_PATH, siteUrl).href;
278
262
  return {
279
263
  steps: SUBSCRIBE_STEPS,
280
- result: (siteUrl) => plannedChange(command, pretty, depth, siteUrl, { url: url(siteUrl), body }, '요금제 변경을 확인했습니다. 결제하지 않았습니다.', subscribeRows(plan, consented), { plan, monthlyAmount: PRICES[plan], currency: 'KRW', consentRequired: true, consented }),
264
+ result: (siteUrl) => plannedChange(command, pretty, depth, siteUrl, { url: url(siteUrl), body }, 'Checked the plan change. Nothing was charged.', subscribeRows(plan, consented), { plan, monthlyAmount: PRICES[plan], currency: 'KRW', consentRequired: true, consented }),
281
265
  send: {
282
266
  method: 'POST',
283
267
  url,
284
268
  body,
285
- spinner: '요금제를 바꾸고 있습니다.',
269
+ spinner: 'Changing the plan.',
286
270
  failed: SUBSCRIBE_FAILED,
287
271
  notFound: httpFailure(404),
288
272
  failures: SUBSCRIBE_FAILURES,
@@ -298,17 +282,17 @@ export async function runPlanCancel(args, pretty, depth, deps = defaultAuthDeps(
298
282
  const consented = splitYes(args).yes;
299
283
  return rehearsed(command, args, pretty, depth, deps, (rest) => {
300
284
  if (rest.length)
301
- return { error: unknownArgument(rest[0], pretty) };
285
+ return { error: unknownArgument(rest[0]) };
302
286
  const url = (siteUrl) => new URL(`${SUBSCRIPTION_PATH}/cancel`, siteUrl).href;
303
287
  return {
304
288
  steps: CANCEL_STEPS,
305
- result: (siteUrl) => plannedChange(command, pretty, depth, siteUrl, { url: url(siteUrl), body: {} }, '요금제 해지를 확인했습니다. 해지하지 않았습니다.', [...CANCEL_ROWS, ['해지 동의', consented ? '동의함 (--yes).' : '필요합니다. 사용자에게 확인한 뒤 --yes 를 붙이세요.']], { autoRenew: false, refund: false, consented }),
289
+ result: (siteUrl) => plannedChange(command, pretty, depth, siteUrl, { url: url(siteUrl), body: {} }, 'Checked the cancellation. The plan was not cancelled.', [...CANCEL_ROWS, ['Consent', consented ? 'Given (--yes).' : 'Required. Confirm with the user, then add --yes.']], { autoRenew: false, refund: false, consented }),
306
290
  send: {
307
291
  method: 'POST',
308
292
  url,
309
293
  body: {},
310
- spinner: '요금제를 해지하고 있습니다.',
311
- failed: '요금제를 해지하지 못했습니다.',
294
+ spinner: 'Cancelling the plan.',
295
+ failed: 'Could not cancel the plan.',
312
296
  notFound: httpFailure(404),
313
297
  failures: { unavailable: CHANGE_UNAVAILABLE, charge_pending: CHARGE_PENDING, no_subscription: NO_SUBSCRIPTION },
314
298
  succeeded,
@@ -321,17 +305,17 @@ export async function runPlanResume(args, pretty, depth, deps = defaultAuthDeps(
321
305
  const command = RESUME.name;
322
306
  return rehearsed(command, args, pretty, depth, deps, (rest) => {
323
307
  if (rest.length)
324
- return { error: unknownArgument(rest[0], pretty) };
308
+ return { error: unknownArgument(rest[0]) };
325
309
  const url = (siteUrl) => new URL(`${SUBSCRIPTION_PATH}/resume`, siteUrl).href;
326
310
  return {
327
311
  steps: RESUME_STEPS,
328
- result: (siteUrl) => plannedChange(command, pretty, depth, siteUrl, { url: url(siteUrl), body: {} }, '해지 취소를 확인했습니다. 바꾸지 않았습니다.', RESUME_ROWS, { autoRenew: true }),
312
+ result: (siteUrl) => plannedChange(command, pretty, depth, siteUrl, { url: url(siteUrl), body: {} }, 'Checked undoing the cancellation. Nothing was changed.', RESUME_ROWS, { autoRenew: true }),
329
313
  send: {
330
314
  method: 'POST',
331
315
  url,
332
316
  body: {},
333
- spinner: '해지 예약을 취소하고 있습니다.',
334
- failed: '해지 예약을 취소하지 못했습니다.',
317
+ spinner: 'Undoing the scheduled cancellation.',
318
+ failed: 'Could not undo the scheduled cancellation.',
335
319
  notFound: httpFailure(404),
336
320
  failures: { unavailable: CHANGE_UNAVAILABLE, no_subscription: NO_SUBSCRIPTION },
337
321
  succeeded,
@@ -345,20 +329,20 @@ export async function runPlanPay(args, pretty, depth, deps = defaultAuthDeps(pre
345
329
  return rehearsed(command, args, pretty, depth, deps, (rest) => {
346
330
  const { args: extra, yes } = splitYes(rest);
347
331
  if (extra.length)
348
- return { error: unknownArgument(extra[0], pretty) };
332
+ return { error: unknownArgument(extra[0]) };
349
333
  const body = yes ? { consented: true } : {};
350
334
  const url = (siteUrl) => new URL(PAY_PATH, siteUrl).href;
351
335
  return {
352
336
  steps: PAY_STEPS,
353
- result: (siteUrl) => plannedChange(command, pretty, depth, siteUrl, { url: url(siteUrl), body }, '미결제 요금 결제를 확인했습니다. 결제하지 않았습니다.', [
354
- ['결제', '결제되지 않은 정기 결제 요금을 오래된 달부터 등록한 카드로 지금 결제합니다.'],
355
- ['결제 동의', yes ? '동의함 (--yes).' : '필요합니다. 금액을 사용자에게 확인한 뒤 --yes 를 붙이세요.']
337
+ result: (siteUrl) => plannedChange(command, pretty, depth, siteUrl, { url: url(siteUrl), body }, 'Checked paying the unpaid charges. Nothing was charged.', [
338
+ ['Payment', 'Charges the unpaid monthly charges to the registered card now, oldest month first.'],
339
+ ['Consent', yes ? 'Given (--yes).' : 'Required. Confirm the amount with the user, then add --yes.']
356
340
  ], { currency: 'KRW', consentRequired: true, consented: yes }),
357
341
  send: {
358
342
  method: 'POST',
359
343
  url,
360
344
  body,
361
- spinner: '미결제 요금을 결제하고 있습니다.',
345
+ spinner: 'Paying the unpaid charges.',
362
346
  failed: PAY_FAILED,
363
347
  notFound: NO_UNPAID,
364
348
  failures: { unavailable: CHANGE_UNAVAILABLE, charge_pending: CHARGE_PENDING, no_unpaid: NO_UNPAID, payment_unavailable: SUBSCRIBE_FAILURES.payment_unavailable },