@deepdynamic/cli 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agents/content.js +1 -1
- package/dist/agents/install.js +22 -12
- package/dist/agents/refresh.js +20 -0
- package/dist/agents/setup.js +7 -7
- package/dist/cli.js +8 -8
- package/dist/commands/account.js +19 -19
- package/dist/commands/activity.js +13 -13
- package/dist/commands/blocked.js +16 -16
- package/dist/commands/deploy/index.js +16 -16
- package/dist/commands/deploy/ship.js +8 -8
- package/dist/commands/deployments.js +8 -7
- package/dist/commands/dns.js +228 -242
- package/dist/commands/domains.js +188 -260
- package/dist/commands/emails.js +17 -17
- package/dist/commands/env.js +38 -38
- package/dist/commands/help.js +18 -19
- package/dist/commands/keys.js +83 -89
- package/dist/commands/login/flow.js +11 -11
- package/dist/commands/login/index.js +3 -3
- package/dist/commands/logout.js +11 -11
- package/dist/commands/mail.js +62 -62
- package/dist/commands/notifications.js +30 -29
- package/dist/commands/plan.js +109 -125
- package/dist/commands/projects.js +159 -157
- package/dist/commands/reference.js +109 -102
- package/dist/commands/search.js +29 -18
- package/dist/commands/server.js +99 -112
- package/dist/commands/sessions.js +38 -44
- package/dist/commands/sites.js +16 -16
- package/dist/commands/sms.js +14 -14
- package/dist/commands/status.js +9 -9
- package/dist/commands/support.js +19 -19
- package/dist/commands/update.js +18 -16
- package/dist/commands/usage.js +12 -12
- package/dist/commands/verify.js +16 -16
- package/dist/guide.js +9 -48
- package/dist/http/request.js +3 -3
- package/dist/pretty.js +4 -4
- package/dist/refresh-skills.js +5 -0
- package/dist/registry.js +72 -144
- package/dist/runtime/card-request.js +6 -6
- package/dist/runtime/confirm.js +1 -1
- package/dist/runtime/development.js +1 -1
- package/dist/runtime/dry-run.js +2 -2
- package/dist/runtime/env-file.js +6 -9
- package/dist/runtime/flags.js +11 -13
- package/dist/runtime/login-screen.js +5 -5
- package/dist/runtime/page.js +4 -4
- package/dist/runtime/server-options.js +4 -8
- package/dist/runtime/spinner.js +3 -1
- package/dist/runtime/support.js +2 -3
- package/dist/runtime/text-file.js +5 -5
- package/dist/runtime/timeout.js +2 -2
- package/dist/runtime/update-check.js +48 -14
- package/dist/runtime/update-install.js +34 -4
- package/dist/runtime/usage-error.js +2 -2
- package/dist/setup-agents.js +9 -2
- package/package.json +1 -1
package/dist/commands/plan.js
CHANGED
|
@@ -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 {
|
|
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
|
|
23
|
-
const
|
|
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:
|
|
28
|
+
note: 'The change may already have been applied, so check deepdynamic plan before retrying.'
|
|
27
29
|
});
|
|
28
|
-
const CHARGE_PENDING =
|
|
29
|
-
|
|
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
|
-
|
|
53
|
-
|
|
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 raised 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
|
|
84
|
-
|
|
85
|
-
|
|
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
|
-
['
|
|
90
|
-
['
|
|
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 }) =>
|
|
100
|
-
upgraded: ({ plan, monthlyAmount }, charged) =>
|
|
101
|
-
downgraded: ({ plan, monthlyAmount }) =>
|
|
102
|
-
resumed: ({ plan }) =>
|
|
103
|
-
unchanged: ({ 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 }) =>
|
|
107
|
-
cancelled: ({ plan }) =>
|
|
108
|
-
unchanged: ({ plan, endsOn }) =>
|
|
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 }) =>
|
|
112
|
-
unchanged: ({ 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
|
|
116
|
-
const
|
|
117
|
-
const
|
|
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 ? ' ·
|
|
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 '
|
|
123
|
-
return endsOn ?
|
|
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
|
|
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
|
|
130
|
-
if (!Object.hasOwn(PRICES, plan))
|
|
131
|
-
return
|
|
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]
|
|
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
|
-
['
|
|
140
|
-
['
|
|
141
|
-
['
|
|
142
|
-
['
|
|
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,
|
|
150
|
-
['
|
|
151
|
-
['
|
|
152
|
-
['
|
|
153
|
-
['
|
|
154
|
-
['
|
|
155
|
-
['
|
|
156
|
-
...(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 ?
|
|
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:
|
|
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:
|
|
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, [['
|
|
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:
|
|
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,
|
|
211
|
-
['
|
|
212
|
-
...charges.map(({ period, amount }) => [period,
|
|
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
|
-
['
|
|
221
|
-
['
|
|
222
|
-
['
|
|
223
|
-
['
|
|
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
|
-
['
|
|
232
|
-
['
|
|
233
|
-
['
|
|
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
|
-
['
|
|
243
|
-
['
|
|
244
|
-
['
|
|
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]
|
|
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
|
|
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 }, '
|
|
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]
|
|
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: {} }, '
|
|
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]
|
|
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: {} }, '
|
|
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]
|
|
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
|
-
['
|
|
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 },
|