@deepdynamic/cli 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agents/content.js +1 -1
- package/dist/agents/install.js +28 -12
- package/dist/agents/refresh.js +20 -0
- package/dist/agents/setup.js +7 -7
- package/dist/cli.js +8 -8
- package/dist/commands/account.js +19 -19
- package/dist/commands/activity.js +13 -13
- package/dist/commands/blocked.js +16 -16
- package/dist/commands/deploy/index.js +16 -16
- package/dist/commands/deploy/ship.js +8 -8
- package/dist/commands/deployments.js +8 -7
- package/dist/commands/dns.js +229 -243
- package/dist/commands/domains.js +188 -260
- package/dist/commands/emails.js +64 -26
- package/dist/commands/env.js +38 -38
- package/dist/commands/help.js +18 -19
- package/dist/commands/keys.js +84 -90
- package/dist/commands/login/flow.js +11 -11
- package/dist/commands/login/index.js +3 -3
- package/dist/commands/logout.js +11 -11
- package/dist/commands/mail.js +82 -69
- package/dist/commands/notifications.js +30 -29
- package/dist/commands/plan.js +109 -125
- package/dist/commands/projects.js +159 -157
- package/dist/commands/reference.js +139 -112
- package/dist/commands/search.js +29 -18
- package/dist/commands/server.js +100 -112
- package/dist/commands/sessions.js +38 -44
- package/dist/commands/sites.js +16 -16
- package/dist/commands/sms.js +31 -17
- package/dist/commands/status.js +9 -9
- package/dist/commands/support.js +19 -19
- package/dist/commands/update.js +18 -16
- package/dist/commands/usage.js +12 -12
- package/dist/commands/verify.js +16 -16
- package/dist/guide.js +9 -48
- package/dist/http/request.js +3 -3
- package/dist/pretty.js +4 -4
- package/dist/refresh-skills.js +5 -0
- package/dist/registry.js +74 -146
- package/dist/runtime/card-request.js +6 -6
- package/dist/runtime/confirm.js +1 -1
- package/dist/runtime/development.js +1 -1
- package/dist/runtime/dry-run.js +2 -2
- package/dist/runtime/env-file.js +6 -9
- package/dist/runtime/flags.js +11 -13
- package/dist/runtime/login-screen.js +5 -5
- package/dist/runtime/page.js +4 -4
- package/dist/runtime/server-options.js +4 -8
- package/dist/runtime/spinner.js +3 -1
- package/dist/runtime/support.js +2 -3
- package/dist/runtime/text-file.js +5 -5
- package/dist/runtime/timeout.js +2 -2
- package/dist/runtime/update-check.js +48 -14
- package/dist/runtime/update-install.js +40 -5
- package/dist/runtime/usage-error.js +2 -2
- package/dist/setup-agents.js +9 -2
- package/package.json +1 -1
package/dist/commands/search.js
CHANGED
|
@@ -7,7 +7,7 @@ import { spec } from "../registry.js";
|
|
|
7
7
|
import { plannedRequest, splitDryRun } from "../runtime/dry-run.js";
|
|
8
8
|
import { parseServerArgs } from "../runtime/server-options.js";
|
|
9
9
|
export const SEARCH_PATH = '/api/v1/search';
|
|
10
|
-
const { name: command, usage
|
|
10
|
+
const { name: command, usage } = spec('search');
|
|
11
11
|
function isPageInfo(body) {
|
|
12
12
|
const info = body;
|
|
13
13
|
return info?.ok === true
|
|
@@ -19,42 +19,53 @@ function searchablePages(body) {
|
|
|
19
19
|
const pages = body?.pages;
|
|
20
20
|
return Array.isArray(pages) && pages.every((page) => typeof page === 'string') ? pages : null;
|
|
21
21
|
}
|
|
22
|
-
function
|
|
22
|
+
function normalizePage(raw) {
|
|
23
|
+
const segments = [];
|
|
24
|
+
for (const segment of raw.split('/')) {
|
|
25
|
+
if (segment === '..')
|
|
26
|
+
segments.pop();
|
|
27
|
+
else if (segment && segment !== '.')
|
|
28
|
+
segments.push(segment);
|
|
29
|
+
}
|
|
30
|
+
return `/${segments.join('/')}`;
|
|
31
|
+
}
|
|
32
|
+
const searchUrl = (page, siteUrl) => new URL(`${SEARCH_PATH}${page.split('/').filter(Boolean).map((segment) => `/${encodeURIComponent(segment)}`).join('')}`, siteUrl);
|
|
33
|
+
function parseSearchArgs(args) {
|
|
23
34
|
const first = args[0];
|
|
24
35
|
if (first === undefined || first.startsWith('-') || !first.trim()) {
|
|
25
|
-
return { error:
|
|
36
|
+
return { error: 'A page path is required, for example: deepdynamic search /pricing' };
|
|
26
37
|
}
|
|
27
|
-
const server = parseServerArgs(args.slice(1)
|
|
28
|
-
return 'error' in server ? server : { page: first
|
|
38
|
+
const server = parseServerArgs(args.slice(1));
|
|
39
|
+
return 'error' in server ? server : { page: normalizePage(first), siteUrl: server.siteUrl };
|
|
29
40
|
}
|
|
30
41
|
export async function runSearch(args, pretty, depth, deps = defaultDeps()) {
|
|
31
42
|
const { args: rest, dryRun } = splitDryRun(args);
|
|
32
|
-
const options = parseSearchArgs(rest
|
|
43
|
+
const options = parseSearchArgs(rest);
|
|
33
44
|
if ('error' in options) {
|
|
34
45
|
return pretty
|
|
35
|
-
? prettyResult(2, depth, command, options.error, [['
|
|
46
|
+
? prettyResult(2, depth, command, options.error, [['Usage', usage]])
|
|
36
47
|
: agentResult(2, { command, error: { code: 'invalid_arguments', message: options.error }, usage });
|
|
37
48
|
}
|
|
38
49
|
const siteUrl = options.siteUrl ?? await readLoginSiteUrl() ?? SITE_URL;
|
|
39
|
-
const endpoint =
|
|
50
|
+
const endpoint = searchUrl(options.page, siteUrl);
|
|
40
51
|
if (dryRun)
|
|
41
52
|
return plannedRequest(command, pretty, depth, siteUrl, endpoint.href);
|
|
42
|
-
const result = await request(endpoint.href, { method: 'GET' }, deps, pretty ? '
|
|
53
|
+
const result = await request(endpoint.href, { method: 'GET' }, deps, pretty ? 'Loading page info.' : null);
|
|
43
54
|
if ('failure' in result || result.status !== 200 || !isPageInfo(result.body)) {
|
|
44
55
|
const pages = 'failure' in result || result.status !== 404 ? null : searchablePages(result.body);
|
|
45
56
|
const failure = 'failure' in result
|
|
46
57
|
? result.failure
|
|
47
58
|
: result.status === 404
|
|
48
|
-
? { code: 'page_not_found', message: `No searchable page at ${options.page}.`, display:
|
|
59
|
+
? { code: 'page_not_found', message: `No searchable page at ${options.page}.`, display: `No searchable page at ${options.page}.` }
|
|
49
60
|
: result.status !== 200
|
|
50
61
|
? httpFailure(result.status)
|
|
51
62
|
: UNEXPECTED;
|
|
52
63
|
return pretty
|
|
53
|
-
? prettyResult(1, depth, command, '
|
|
54
|
-
['
|
|
55
|
-
['
|
|
56
|
-
['
|
|
57
|
-
...(pages ? [['
|
|
64
|
+
? prettyResult(1, depth, command, 'Could not load page info.', [
|
|
65
|
+
['Server', siteUrl],
|
|
66
|
+
['Page', options.page],
|
|
67
|
+
['Reason', failure.display],
|
|
68
|
+
...(pages ? [['Searchable', pages.join(', ')]] : [])
|
|
58
69
|
])
|
|
59
70
|
: agentResult(1, {
|
|
60
71
|
command,
|
|
@@ -67,9 +78,9 @@ export async function runSearch(args, pretty, depth, deps = defaultDeps()) {
|
|
|
67
78
|
if (!pretty) {
|
|
68
79
|
return agentResult(0, { command, siteUrl, page, url, markdown });
|
|
69
80
|
}
|
|
70
|
-
return prettyResult(0, depth, command,
|
|
71
|
-
['
|
|
72
|
-
['
|
|
81
|
+
return prettyResult(0, depth, command, `Loaded page info for ${page.replace(CONTROL, ' ')}.`, [
|
|
82
|
+
['Server', siteUrl],
|
|
83
|
+
['URL', url.replace(CONTROL, ' ')],
|
|
73
84
|
...markdown.trimEnd().split('\n').map((line) => ['', line.replace(CONTROL, ' ')])
|
|
74
85
|
]);
|
|
75
86
|
}
|
package/dist/commands/server.js
CHANGED
|
@@ -19,102 +19,88 @@ const STARTING_LIMIT = AUTOPILOT_LIMITS[1];
|
|
|
19
19
|
const LIST = spec('server');
|
|
20
20
|
const SET = spec('server set');
|
|
21
21
|
const AUTOPILOT = spec('server autopilot');
|
|
22
|
-
const RESTART = '
|
|
23
|
-
const SERVER_STATES = { running: '
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
};
|
|
29
|
-
const SERVER_UNAVAILABLE = supportFailure('server_unavailable', { note: { en: 'Nothing was changed.', ko: '바뀐 것은 없습니다.' } });
|
|
30
|
-
const UNREACHABLE = supportFailure('server_unreachable', { note: { en: 'Nothing was read or changed.', ko: '읽거나 바꾼 것은 없습니다.' } });
|
|
22
|
+
const RESTART = 'Applying restarts the server, so the site stops for about a minute. A stopped server picks up the change the next time it starts.';
|
|
23
|
+
const SERVER_STATES = { running: 'Running', stopped: 'Stopped', preparing: 'Preparing', failed: 'Setup failed' };
|
|
24
|
+
const failure = (code, message) => ({ code, message, display: message });
|
|
25
|
+
const PROJECT_NOT_FOUND = failure('project_not_found', 'You have no active project with that name. Check it with deepdynamic server.');
|
|
26
|
+
const SERVER_UNAVAILABLE = supportFailure('server_unavailable', { note: 'Nothing was changed.' });
|
|
27
|
+
const UNREACHABLE = supportFailure('server_unreachable', { note: 'Nothing was read or changed.' });
|
|
31
28
|
const LIST_FAILURES = {
|
|
32
29
|
server_unreachable: UNREACHABLE,
|
|
33
30
|
list_failed: supportFailure('list_failed')
|
|
34
31
|
};
|
|
32
|
+
const AUTOPILOT_UNPAID = failure('unpaid_charges', 'The account has unpaid charges, so autopilot was not turned on. Pay them with deepdynamic plan pay, then run the same command again.');
|
|
35
33
|
const SET_FAILURES = {
|
|
36
34
|
server_unreachable: UNREACHABLE,
|
|
37
|
-
autopilot_on:
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
server_busy: {
|
|
48
|
-
code: 'server_busy',
|
|
49
|
-
message: 'The server is busy with a restart, update or deploy, or cannot take more CPU or RAM right now. Retry later.',
|
|
50
|
-
display: '서버가 다른 작업을 하고 있거나 지금은 CPU·RAM 을 늘릴 수 없습니다. 잠시 후 다시 시도하세요.'
|
|
51
|
-
},
|
|
52
|
-
cpu_too_small: {
|
|
53
|
-
code: 'cpu_too_small',
|
|
54
|
-
message: 'With that few cores the current CPU use would go over 100%. Keep more cores.',
|
|
55
|
-
display: '지금 CPU 사용량으로는 코어를 이만큼 줄일 수 없습니다.'
|
|
56
|
-
},
|
|
57
|
-
memory_too_small: {
|
|
58
|
-
code: 'memory_too_small',
|
|
59
|
-
message: 'The server uses more RAM than that. Keep more RAM.',
|
|
60
|
-
display: '지금 쓰는 RAM보다 작게 줄일 수 없습니다.'
|
|
61
|
-
}
|
|
35
|
+
autopilot_on: failure('autopilot_on', 'Autopilot is on, so the spec cannot be changed by hand. Turn it off first with deepdynamic server autopilot off.'),
|
|
36
|
+
server_not_ready: failure('server_not_ready', 'The project server is not ready yet. Check it with deepdynamic server and retry once it is running or stopped.'),
|
|
37
|
+
server_busy: failure('server_busy', 'The server is busy with a restart, update or deploy, or cannot take more CPU or RAM right now. Retry later.'),
|
|
38
|
+
cpu_too_small: failure('cpu_too_small', 'With that few cores the current CPU use would go over 100%. Keep more cores.'),
|
|
39
|
+
memory_too_small: failure('memory_too_small', 'The server uses more RAM than that. Keep more RAM.'),
|
|
40
|
+
unpaid_charges: failure('unpaid_charges', 'The account has unpaid charges, so the spec was not raised and nothing was charged. Pay them with deepdynamic plan pay, then run the same command again.'),
|
|
41
|
+
charge_pending: failure('charge_pending', 'A server options payment or another spec change is still in progress, so nothing was charged or changed. Retry a little later.'),
|
|
42
|
+
payment_declined: failure('payment_declined', 'The card company declined the payment for the difference, so nothing was charged or changed. Ask the user to check the card or register another one, then run the same command again.'),
|
|
43
|
+
payment_unavailable: supportFailure('payment_unavailable', { note: 'Nothing was charged or changed.' }),
|
|
44
|
+
spec_unconfirmed: failure('spec_unconfirmed', 'The change was sent, but the server did not confirm it in time. Do not retry yet: it is checked again within about 15 minutes, and if it was not applied, any difference charged is refunded automatically. Check the spec later with deepdynamic server.')
|
|
62
45
|
};
|
|
63
46
|
const LIST_STEPS = [
|
|
64
|
-
{ stage: 'check_options', message: '
|
|
65
|
-
{ stage: 'prepare_request', message: '
|
|
47
|
+
{ stage: 'check_options', message: 'Checking the options.' },
|
|
48
|
+
{ stage: 'prepare_request', message: 'Preparing the server list request.' }
|
|
66
49
|
];
|
|
67
50
|
const SET_STEPS = [
|
|
68
|
-
{ stage: 'check_options', message: 'CPU
|
|
69
|
-
{ stage: 'calculate_charge', message: '
|
|
70
|
-
{ stage: 'check_consent', message: '
|
|
71
|
-
{ stage: 'prepare_request', message: '
|
|
51
|
+
{ stage: 'check_options', message: 'Checking the CPU and RAM options.' },
|
|
52
|
+
{ stage: 'calculate_charge', message: 'Calculating the monthly extra charge after the change.' },
|
|
53
|
+
{ stage: 'check_consent', message: 'Checking consent to the extra charge.' },
|
|
54
|
+
{ stage: 'prepare_request', message: 'Preparing the server spec change request.' }
|
|
72
55
|
];
|
|
73
56
|
const autopilotSteps = (enabled) => [
|
|
74
|
-
{ stage: 'check_options', message: '
|
|
57
|
+
{ stage: 'check_options', message: 'Checking the autopilot setting.' },
|
|
75
58
|
enabled
|
|
76
|
-
? { stage: 'check_limit', message: '
|
|
77
|
-
: { stage: 'check_manual_control', message: '
|
|
78
|
-
{ stage: 'prepare_request', message: '
|
|
59
|
+
? { stage: 'check_limit', message: 'Checking the monthly limit.' }
|
|
60
|
+
: { stage: 'check_manual_control', message: 'Checking the switch to manual spec changes.' },
|
|
61
|
+
{ stage: 'prepare_request', message: 'Preparing the autopilot request.' }
|
|
79
62
|
];
|
|
80
|
-
const won = (amount) => `${amount.toLocaleString('
|
|
81
|
-
const
|
|
63
|
+
const won = (amount) => `${amount.toLocaleString('en-US')} KRW`;
|
|
64
|
+
const monthly = (amount) => `${won(amount)}/month`;
|
|
65
|
+
const price = (amount) => amount ? `+${monthly(amount)}` : 'No extra charge';
|
|
82
66
|
const extraOf = (cores, memory) => (cores - 1) * CORE_PRICE + (memory - 1) * MEMORY_PRICE;
|
|
83
|
-
const
|
|
84
|
-
|
|
85
|
-
|
|
67
|
+
const coreCount = (cores) => `${cores} ${cores === 1 ? 'core' : 'cores'}`;
|
|
68
|
+
const specText = (cores, memory) => `CPU ${coreCount(cores)} · RAM ${memory}GB`;
|
|
69
|
+
const count = (amount, noun) => `${amount} ${noun}${amount === 1 ? '' : 's'}`;
|
|
70
|
+
function pickFlags(args, flags) {
|
|
71
|
+
const parsed = parseFlags(args, flags);
|
|
86
72
|
if ('error' in parsed)
|
|
87
73
|
return parsed;
|
|
88
74
|
const repeated = parsed.entries.find(([flag], index) => parsed.entries.findIndex(([other]) => other === flag) !== index);
|
|
89
75
|
if (repeated)
|
|
90
|
-
return { error:
|
|
76
|
+
return { error: `Give ${repeated[0]} only once.` };
|
|
91
77
|
return { values: Object.fromEntries(parsed.entries) };
|
|
92
78
|
}
|
|
93
|
-
function oneOf(flag, value, choices
|
|
79
|
+
function oneOf(flag, value, choices) {
|
|
94
80
|
if (value === undefined)
|
|
95
81
|
return {};
|
|
96
82
|
if (choices.includes(value))
|
|
97
83
|
return { value: Number(value) };
|
|
98
|
-
return { error:
|
|
84
|
+
return { error: `${flag} must be one of ${choices.join(', ')}: ${value}` };
|
|
99
85
|
}
|
|
100
|
-
function parseSet(args
|
|
86
|
+
function parseSet(args) {
|
|
101
87
|
const [project, ...rest] = args.filter((arg) => arg !== '--yes');
|
|
102
88
|
if (project === undefined || project.startsWith('-'))
|
|
103
|
-
return { error:
|
|
89
|
+
return { error: 'Specify the project name first.' };
|
|
104
90
|
if (!PROJECT.test(project)) {
|
|
105
|
-
return { error:
|
|
91
|
+
return { error: 'Project names are 1-63 lowercase letters, digits or hyphens and start and end with a letter or digit.' };
|
|
106
92
|
}
|
|
107
|
-
const flags = pickFlags(rest, ['--cores', '--memory']
|
|
93
|
+
const flags = pickFlags(rest, ['--cores', '--memory']);
|
|
108
94
|
if ('error' in flags)
|
|
109
95
|
return flags;
|
|
110
|
-
const cores = oneOf('--cores', flags.values['--cores'], CORES
|
|
96
|
+
const cores = oneOf('--cores', flags.values['--cores'], CORES);
|
|
111
97
|
if ('error' in cores)
|
|
112
98
|
return cores;
|
|
113
|
-
const memory = oneOf('--memory', flags.values['--memory'], MEMORIES
|
|
99
|
+
const memory = oneOf('--memory', flags.values['--memory'], MEMORIES);
|
|
114
100
|
if ('error' in memory)
|
|
115
101
|
return memory;
|
|
116
102
|
if (cores.value === undefined && memory.value === undefined) {
|
|
117
|
-
return { error:
|
|
103
|
+
return { error: 'Give --cores, --memory or both.' };
|
|
118
104
|
}
|
|
119
105
|
return { project, cores: cores.value, memory: memory.value, consented: args.includes('--yes') };
|
|
120
106
|
}
|
|
@@ -135,60 +121,60 @@ function setRows({ project, cpu, ram, monthlyExtra, consentRequired, consented }
|
|
|
135
121
|
const known = (cpu?.monthlyExtra ?? 0) + (ram?.monthlyExtra ?? 0);
|
|
136
122
|
const kept = cpu ? 'RAM' : 'CPU';
|
|
137
123
|
const total = monthlyExtra !== null
|
|
138
|
-
? monthlyExtra ?
|
|
139
|
-
: known ?
|
|
140
|
-
const charge = '
|
|
124
|
+
? monthlyExtra ? monthly(monthlyExtra) : 'None'
|
|
125
|
+
: known ? `${monthly(known)} + the current ${kept} charge` : `The current ${kept} charge only`;
|
|
126
|
+
const charge = 'Any increase over the current spec is billed to the account as an extra charge from the next billing date.';
|
|
141
127
|
return [
|
|
142
|
-
['
|
|
143
|
-
['CPU', cpu ? `${cpu.cores}
|
|
144
|
-
['RAM', ram ? `${ram.memoryGb}GB · ${price(ram.monthlyExtra)}` : '
|
|
145
|
-
['
|
|
146
|
-
['
|
|
147
|
-
['
|
|
148
|
-
? '
|
|
149
|
-
: consented ?
|
|
150
|
-
['
|
|
128
|
+
['Project', project],
|
|
129
|
+
['CPU', cpu ? `${coreCount(cpu.cores)} · ${price(cpu.monthlyExtra)}` : 'Unchanged (keeps the current setting)'],
|
|
130
|
+
['RAM', ram ? `${ram.memoryGb}GB · ${price(ram.monthlyExtra)}` : 'Unchanged (keeps the current setting)'],
|
|
131
|
+
['New extra charge', total],
|
|
132
|
+
['Restart', RESTART],
|
|
133
|
+
['Billing consent', !consentRequired
|
|
134
|
+
? 'Not needed. This change does not raise the charge.'
|
|
135
|
+
: consented ? `Given (--yes). ${charge}` : `Required. ${charge} Add --yes once the user agrees to the amount.`],
|
|
136
|
+
['Autopilot', 'While it is on, the spec cannot be changed by hand. Turn it off first with deepdynamic server autopilot off.']
|
|
151
137
|
];
|
|
152
138
|
}
|
|
153
|
-
function parseAutopilot(args
|
|
139
|
+
function parseAutopilot(args) {
|
|
154
140
|
const [mode, ...rest] = args;
|
|
155
141
|
if (mode !== 'on' && mode !== 'off')
|
|
156
|
-
return { error:
|
|
157
|
-
const flags = pickFlags(rest, ['--limit']
|
|
142
|
+
return { error: 'Specify on or off.' };
|
|
143
|
+
const flags = pickFlags(rest, ['--limit']);
|
|
158
144
|
if ('error' in flags)
|
|
159
145
|
return flags;
|
|
160
146
|
const value = flags.values['--limit'];
|
|
161
147
|
if (value === undefined)
|
|
162
148
|
return mode === 'on' ? { enabled: true, limit: STARTING_LIMIT, defaulted: true } : { enabled: false, limit: null, defaulted: false };
|
|
163
149
|
if (mode === 'off')
|
|
164
|
-
return { error:
|
|
150
|
+
return { error: '--limit is only accepted with on.' };
|
|
165
151
|
const limit = AUTOPILOT_LIMITS.find((amount) => String(amount) === value);
|
|
166
152
|
const choices = AUTOPILOT_LIMITS.join(', ');
|
|
167
153
|
if (limit === undefined)
|
|
168
|
-
return { error:
|
|
154
|
+
return { error: `--limit must be one of ${choices}: ${value}` };
|
|
169
155
|
return { enabled: true, limit, defaulted: false };
|
|
170
156
|
}
|
|
171
157
|
function autopilotRows(enabled, limit, defaulted) {
|
|
172
158
|
if (!enabled || limit === null) {
|
|
173
159
|
return [
|
|
174
|
-
['
|
|
175
|
-
['
|
|
176
|
-
['
|
|
160
|
+
['Autopilot', 'Turn off'],
|
|
161
|
+
['Auto scaling', 'Turning it off stops scaling the spec up or down automatically.'],
|
|
162
|
+
['Manual changes', 'Turning it off lets you change CPU and RAM with deepdynamic server set.']
|
|
177
163
|
];
|
|
178
164
|
}
|
|
179
165
|
return [
|
|
180
|
-
['
|
|
181
|
-
['
|
|
182
|
-
['
|
|
183
|
-
['
|
|
184
|
-
['
|
|
166
|
+
['Autopilot', 'Turn on'],
|
|
167
|
+
['Monthly limit', defaulted ? `${won(limit)} (starting limit, change it with --limit)` : won(limit)],
|
|
168
|
+
['Auto scaling', 'Scales CPU and RAM up when the spec runs short and back down when there is room. The server restarts briefly on each change.'],
|
|
169
|
+
['Limit reached', 'Extra charges are billed only within the monthly limit. At the limit, autopilot stops scaling up and sends a notification first.'],
|
|
170
|
+
['Manual changes', 'While it is on, the spec cannot be changed with deepdynamic server set.']
|
|
185
171
|
];
|
|
186
172
|
}
|
|
187
173
|
function serverRow({ project, name, server, cores, memory, cpu, memoryUsed, restarting }) {
|
|
188
|
-
const state = restarting ? '
|
|
174
|
+
const state = restarting ? 'Restarting' : SERVER_STATES[server] ?? server;
|
|
189
175
|
if (server !== 'running' && server !== 'stopped')
|
|
190
176
|
return [project, `${name} · ${state}`];
|
|
191
|
-
const usage = server === 'running' ? ` ·
|
|
177
|
+
const usage = server === 'running' ? ` · Usage: CPU ${cpu === null ? 'not measured' : `${cpu}%`}, RAM ${memoryUsed === null ? 'not measured' : `${memoryUsed}/${memory}GB`}` : '';
|
|
192
178
|
return [project, `${name} · ${state} · ${specText(cores, memory)} · ${price(extraOf(cores, memory))}${usage}`];
|
|
193
179
|
}
|
|
194
180
|
function listed(command, pretty, depth, body, siteUrl) {
|
|
@@ -196,25 +182,27 @@ function listed(command, pretty, depth, body, siteUrl) {
|
|
|
196
182
|
const servers = aircraft.map(({ project, name, deploy, server, cores, memory, cpu, memoryUsed, restarting }) => ({ project, name, deploy, server, cores, memory, cpu, memoryUsed, restarting }));
|
|
197
183
|
if (!pretty)
|
|
198
184
|
return agentResult(0, { command, siteUrl, servers, monthlyExtra, currency: 'KRW', autopilot });
|
|
199
|
-
return prettyResult(0, depth, command, servers.length ?
|
|
200
|
-
['
|
|
185
|
+
return prettyResult(0, depth, command, servers.length ? `Loaded ${count(servers.length, 'server')}.` : 'No servers found.', [
|
|
186
|
+
['Server', siteUrl],
|
|
201
187
|
...servers.map(serverRow),
|
|
202
|
-
['
|
|
203
|
-
['
|
|
188
|
+
['Total extra charge', monthly(monthlyExtra)],
|
|
189
|
+
['Autopilot', autopilot.enabled ? `On · Monthly limit ${won(autopilot.limit)}${autopilot.limitBlocked ? ' · Limit reached, not scaling up further' : ''}` : 'Off']
|
|
204
190
|
]);
|
|
205
191
|
}
|
|
206
192
|
function specApplied(command, pretty, depth, body, siteUrl) {
|
|
207
193
|
const { project, cores, memory, monthlyExtra, previousMonthlyExtra, changed, restarting } = body;
|
|
194
|
+
const charged = typeof body.charged === 'number' ? body.charged : 0;
|
|
208
195
|
if (!pretty)
|
|
209
|
-
return agentResult(0, { command, siteUrl, applied: changed, project, cores, memory, monthlyExtra, previousMonthlyExtra, currency: 'KRW', restarting });
|
|
196
|
+
return agentResult(0, { command, siteUrl, applied: changed, project, cores, memory, monthlyExtra, previousMonthlyExtra, charged, currency: 'KRW', restarting });
|
|
210
197
|
const message = !changed
|
|
211
|
-
? '
|
|
212
|
-
:
|
|
198
|
+
? 'The server already has that spec. Nothing was changed.'
|
|
199
|
+
: `Changed the ${project} server to ${specText(cores, memory)}. ${restarting ? 'The server is restarting.' : 'The change applies the next time the server starts.'}`;
|
|
213
200
|
return prettyResult(0, depth, command, message, [
|
|
214
|
-
['
|
|
215
|
-
['
|
|
216
|
-
['
|
|
217
|
-
['
|
|
201
|
+
['Server', siteUrl],
|
|
202
|
+
['Project', project],
|
|
203
|
+
['Spec', specText(cores, memory)],
|
|
204
|
+
['Monthly extra charge', `${won(monthlyExtra)} (previously ${won(previousMonthlyExtra)})`],
|
|
205
|
+
...(charged > 0 ? [['Charged now', won(charged)]] : [])
|
|
218
206
|
]);
|
|
219
207
|
}
|
|
220
208
|
function consentNeeded(command, args, pretty, depth) {
|
|
@@ -225,7 +213,7 @@ function consentNeeded(command, args, pretty, depth) {
|
|
|
225
213
|
const { monthlyExtra, previousMonthlyExtra } = answer;
|
|
226
214
|
return confirmationRequired(command, args, pretty, depth, {
|
|
227
215
|
message: `The change raises the monthly extra charge from ${previousMonthlyExtra} to ${monthlyExtra} KRW and needs the user's consent.`,
|
|
228
|
-
display:
|
|
216
|
+
display: `The monthly extra charge rises from ${won(previousMonthlyExtra)} to ${won(monthlyExtra)}. Confirm with the user, then run it with --yes.`
|
|
229
217
|
}, { monthlyExtra, previousMonthlyExtra, currency: 'KRW' });
|
|
230
218
|
};
|
|
231
219
|
}
|
|
@@ -233,7 +221,7 @@ export async function runServerList(args, pretty, depth, deps = defaultAuthDeps(
|
|
|
233
221
|
const command = LIST.name;
|
|
234
222
|
return rehearsed(command, args, pretty, depth, deps, (rest) => {
|
|
235
223
|
if (rest.length)
|
|
236
|
-
return { error: unknownArgument(rest[0]
|
|
224
|
+
return { error: unknownArgument(rest[0]) };
|
|
237
225
|
const url = (siteUrl) => new URL(SERVER_PATH, siteUrl).href;
|
|
238
226
|
return {
|
|
239
227
|
steps: LIST_STEPS,
|
|
@@ -241,8 +229,8 @@ export async function runServerList(args, pretty, depth, deps = defaultAuthDeps(
|
|
|
241
229
|
send: {
|
|
242
230
|
method: 'GET',
|
|
243
231
|
url,
|
|
244
|
-
spinner: '
|
|
245
|
-
failed: '
|
|
232
|
+
spinner: 'Loading the server list.',
|
|
233
|
+
failed: 'Could not load the server list.',
|
|
246
234
|
notFound: httpFailure(404),
|
|
247
235
|
failures: LIST_FAILURES,
|
|
248
236
|
done: (body, siteUrl) => listed(command, pretty, depth, body, siteUrl)
|
|
@@ -253,7 +241,7 @@ export async function runServerList(args, pretty, depth, deps = defaultAuthDeps(
|
|
|
253
241
|
export async function runServerSet(args, pretty, depth, deps = defaultAuthDeps(pretty, depth)) {
|
|
254
242
|
const command = SET.name;
|
|
255
243
|
return rehearsed(command, args, pretty, depth, deps, (rest) => {
|
|
256
|
-
const parsed = parseSet(rest
|
|
244
|
+
const parsed = parseSet(rest);
|
|
257
245
|
if ('error' in parsed)
|
|
258
246
|
return parsed;
|
|
259
247
|
const { project, cores, memory, consented } = parsed;
|
|
@@ -262,13 +250,13 @@ export async function runServerSet(args, pretty, depth, deps = defaultAuthDeps(p
|
|
|
262
250
|
const url = (siteUrl) => new URL(`${SERVER_PATH}/${encodeURIComponent(project)}/spec`, siteUrl).href;
|
|
263
251
|
return {
|
|
264
252
|
steps: SET_STEPS,
|
|
265
|
-
result: (siteUrl) => plannedChange(command, pretty, depth, siteUrl, { url: url(siteUrl), body }, '
|
|
253
|
+
result: (siteUrl) => plannedChange(command, pretty, depth, siteUrl, { url: url(siteUrl), body }, 'Checked the server spec change. Nothing was changed.', setRows(plan), plan),
|
|
266
254
|
send: {
|
|
267
255
|
method: 'POST',
|
|
268
256
|
url,
|
|
269
257
|
body,
|
|
270
|
-
spinner: '
|
|
271
|
-
failed: '
|
|
258
|
+
spinner: 'Changing the server spec.',
|
|
259
|
+
failed: 'Could not change the server spec.',
|
|
272
260
|
notFound: PROJECT_NOT_FOUND,
|
|
273
261
|
conflict: SERVER_UNAVAILABLE,
|
|
274
262
|
failures: SET_FAILURES,
|
|
@@ -281,7 +269,7 @@ export async function runServerSet(args, pretty, depth, deps = defaultAuthDeps(p
|
|
|
281
269
|
export async function runServerAutopilot(args, pretty, depth, deps = defaultAuthDeps(pretty, depth)) {
|
|
282
270
|
const command = AUTOPILOT.name;
|
|
283
271
|
return rehearsed(command, args, pretty, depth, deps, (rest) => {
|
|
284
|
-
const parsed = parseAutopilot(rest
|
|
272
|
+
const parsed = parseAutopilot(rest);
|
|
285
273
|
if ('error' in parsed)
|
|
286
274
|
return parsed;
|
|
287
275
|
const { enabled, limit, defaulted } = parsed;
|
|
@@ -290,23 +278,23 @@ export async function runServerAutopilot(args, pretty, depth, deps = defaultAuth
|
|
|
290
278
|
const url = (siteUrl) => new URL(`${SERVER_PATH}/autopilot`, siteUrl).href;
|
|
291
279
|
return {
|
|
292
280
|
steps: autopilotSteps(enabled),
|
|
293
|
-
result: (siteUrl) => plannedChange(command, pretty, depth, siteUrl, { url: url(siteUrl), body },
|
|
281
|
+
result: (siteUrl) => plannedChange(command, pretty, depth, siteUrl, { url: url(siteUrl), body }, `Checked the autopilot change. Autopilot was not turned ${enabled ? 'on' : 'off'}.`, autopilotRows(enabled, limit, defaulted), plan),
|
|
294
282
|
send: {
|
|
295
283
|
method: 'POST',
|
|
296
284
|
url,
|
|
297
285
|
body,
|
|
298
|
-
spinner: enabled ? '
|
|
299
|
-
failed: enabled ? '
|
|
286
|
+
spinner: enabled ? 'Turning autopilot on.' : 'Turning autopilot off.',
|
|
287
|
+
failed: enabled ? 'Could not turn autopilot on.' : 'Could not turn autopilot off.',
|
|
300
288
|
notFound: httpFailure(404),
|
|
301
|
-
failures: { server_unreachable: UNREACHABLE },
|
|
289
|
+
failures: { server_unreachable: UNREACHABLE, unpaid_charges: AUTOPILOT_UNPAID },
|
|
302
290
|
done: (result, siteUrl) => {
|
|
303
291
|
const saved = result;
|
|
304
292
|
const monthlyLimit = saved.enabled ? saved.limit : null;
|
|
305
293
|
if (!pretty)
|
|
306
294
|
return agentResult(0, { command, siteUrl, applied: true, enabled: saved.enabled, monthlyLimit, currency: 'KRW', manualChangesAllowed: !saved.enabled });
|
|
307
295
|
return saved.enabled
|
|
308
|
-
? prettyResult(0, depth, command,
|
|
309
|
-
: prettyResult(0, depth, command, '
|
|
296
|
+
? prettyResult(0, depth, command, `Turned autopilot on. The monthly limit is ${won(saved.limit)}.`, [['Server', siteUrl], ...autopilotRows(true, saved.limit, false).slice(1)])
|
|
297
|
+
: prettyResult(0, depth, command, 'Turned autopilot off.', [['Server', siteUrl], ...autopilotRows(false, null, false).slice(1)]);
|
|
310
298
|
}
|
|
311
299
|
}
|
|
312
300
|
};
|