@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
|
@@ -4,84 +4,78 @@ import { agentResult } from "../output.js";
|
|
|
4
4
|
import { prettyResult } from "../pretty.js";
|
|
5
5
|
import { plannedChange, plannedRequest } from "../runtime/dry-run.js";
|
|
6
6
|
import { unknownArgument } from "../runtime/flags.js";
|
|
7
|
-
import {
|
|
7
|
+
import { rehearsed } from "./dns.js";
|
|
8
8
|
export const SESSIONS_PATH = '/api/v1/security/sessions';
|
|
9
9
|
const SESSION_ID = /^(?:[0-9a-f]{64}|[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})$/;
|
|
10
10
|
const TOKEN_VALUE = /^dd(?:c_|_)/i;
|
|
11
|
-
const KIND_LABELS = { web: '
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
};
|
|
17
|
-
const CURRENT_SESSION = {
|
|
18
|
-
code: 'current_session',
|
|
19
|
-
message: 'That is the session this CLI is using. It cannot be revoked here; run deepdynamic logout to end it.',
|
|
20
|
-
display: '지금 이 CLI 가 쓰는 세션입니다. 여기서는 회수할 수 없고 deepdynamic logout 으로 끝낼 수 있습니다.'
|
|
21
|
-
};
|
|
22
|
-
const LIST_STEPS = [{ stage: 'prepare_request', message: '세션 목록 요청을 준비하고 있습니다.' }];
|
|
11
|
+
const KIND_LABELS = { web: 'Browser', cli: 'CLI' };
|
|
12
|
+
const failure = (code, message) => ({ code, message, display: message });
|
|
13
|
+
const SESSION_NOT_FOUND = failure('session_not_found', 'No session with that ID is among your sessions. Check them with deepdynamic sessions.');
|
|
14
|
+
const CURRENT_SESSION = failure('current_session', 'That is the session this CLI is using. It cannot be revoked here; run deepdynamic logout to end it.');
|
|
15
|
+
const LIST_STEPS = [{ stage: 'prepare_request', message: 'Preparing the session list request.' }];
|
|
23
16
|
const REVOKE_STEPS = [
|
|
24
|
-
{ stage: 'validate_id', message: '
|
|
25
|
-
{ stage: 'summarize_impact', message: '
|
|
26
|
-
{ stage: 'prepare_request', message: '
|
|
17
|
+
{ stage: 'validate_id', message: 'Checking the session ID format.' },
|
|
18
|
+
{ stage: 'summarize_impact', message: 'Summarizing the access that revoking cuts off.' },
|
|
19
|
+
{ stage: 'prepare_request', message: 'Preparing the revoke request.' }
|
|
27
20
|
];
|
|
28
21
|
const sessionsUrl = (siteUrl, suffix = '') => new URL(`${SESSIONS_PATH}${suffix}`, siteUrl).href;
|
|
29
|
-
const when = (iso) => (iso === null ? '
|
|
30
|
-
const describe = (session) => session.kind === 'web' ? `${session.device?.browser ?? 'Unknown'} · ${session.device?.os ?? 'Unknown'}` : (session.name ?? 'CLI
|
|
22
|
+
const when = (iso) => (iso === null ? 'never' : iso.replace('T', ' ').replace(/\.\d{3}Z$/, ' UTC'));
|
|
23
|
+
const describe = (session) => session.kind === 'web' ? `${session.device?.browser ?? 'Unknown'} · ${session.device?.os ?? 'Unknown'}` : (session.name ?? 'CLI token');
|
|
24
|
+
const count = (amount, noun) => `${amount} ${noun}${amount === 1 ? '' : 's'}`;
|
|
31
25
|
function sessionLine(session) {
|
|
32
26
|
const parts = [
|
|
33
|
-
...(session.current ? ['
|
|
27
|
+
...(session.current ? ['Current'] : []),
|
|
34
28
|
KIND_LABELS[session.kind],
|
|
35
29
|
describe(session),
|
|
36
|
-
`IP ${session.ip ?? '
|
|
37
|
-
...(session.lastIp && session.lastIp !== session.ip ? [
|
|
38
|
-
|
|
30
|
+
`IP ${session.ip ?? 'unknown'}`,
|
|
31
|
+
...(session.lastIp && session.lastIp !== session.ip ? [`Last IP ${session.lastIp}`] : []),
|
|
32
|
+
`Last active ${when(session.lastSeen)}`
|
|
39
33
|
];
|
|
40
34
|
return [session.id, parts.join(' · ')];
|
|
41
35
|
}
|
|
42
36
|
function sessionRows(session) {
|
|
43
37
|
return [
|
|
44
|
-
['
|
|
45
|
-
['
|
|
46
|
-
['IP', session.ip ?? '
|
|
47
|
-
...(session.lastIp ? [['
|
|
48
|
-
['
|
|
49
|
-
['
|
|
50
|
-
['
|
|
38
|
+
['Session ID', session.id],
|
|
39
|
+
['Type', `${KIND_LABELS[session.kind]} · ${describe(session)}`],
|
|
40
|
+
['IP', session.ip ?? 'unknown'],
|
|
41
|
+
...(session.lastIp ? [['Last IP', session.lastIp]] : []),
|
|
42
|
+
['Last active', when(session.lastSeen)],
|
|
43
|
+
['Signed in', when(session.createdAt)],
|
|
44
|
+
['Expires', when(session.expiresAt)]
|
|
51
45
|
];
|
|
52
46
|
}
|
|
53
|
-
function parseRevoke(args
|
|
47
|
+
function parseRevoke(args) {
|
|
54
48
|
const option = args.find((arg) => arg.startsWith('-'));
|
|
55
49
|
if (option)
|
|
56
|
-
return { error: unknownArgument(option
|
|
50
|
+
return { error: unknownArgument(option) };
|
|
57
51
|
if (args.length !== 1)
|
|
58
|
-
return
|
|
52
|
+
return { error: 'Specify exactly one session ID.' };
|
|
59
53
|
if (TOKEN_VALUE.test(args[0]))
|
|
60
|
-
return
|
|
54
|
+
return { error: 'Pass the session ID listed by deepdynamic sessions, not a token value.' };
|
|
61
55
|
const id = args[0].toLowerCase();
|
|
62
56
|
if (!SESSION_ID.test(id))
|
|
63
|
-
return
|
|
57
|
+
return { error: 'Session IDs are the id values listed by deepdynamic sessions.' };
|
|
64
58
|
return id;
|
|
65
59
|
}
|
|
66
60
|
export async function runSessionsList(args, pretty, depth, deps = defaultAuthDeps(pretty, depth)) {
|
|
67
61
|
const command = 'sessions';
|
|
68
62
|
return rehearsed(command, args, pretty, depth, deps, (rest) => {
|
|
69
63
|
if (rest.length)
|
|
70
|
-
return { error: unknownArgument(rest[0]
|
|
64
|
+
return { error: unknownArgument(rest[0]) };
|
|
71
65
|
return {
|
|
72
66
|
steps: LIST_STEPS,
|
|
73
67
|
result: (siteUrl) => plannedRequest(command, pretty, depth, siteUrl, sessionsUrl(siteUrl)),
|
|
74
68
|
send: {
|
|
75
69
|
method: 'GET',
|
|
76
70
|
url: (siteUrl) => sessionsUrl(siteUrl),
|
|
77
|
-
spinner: '
|
|
78
|
-
failed: '
|
|
71
|
+
spinner: 'Loading login sessions.',
|
|
72
|
+
failed: 'Could not load login sessions.',
|
|
79
73
|
notFound: httpFailure(404),
|
|
80
74
|
done: (body, siteUrl) => {
|
|
81
75
|
const { sessions } = body;
|
|
82
76
|
if (!pretty)
|
|
83
77
|
return agentResult(0, { command, siteUrl, sessions });
|
|
84
|
-
return prettyResult(0, depth, command,
|
|
78
|
+
return prettyResult(0, depth, command, `Loaded ${count(sessions.length, 'active session')}.`, [['Server', siteUrl], ...sessions.map(sessionLine)]);
|
|
85
79
|
}
|
|
86
80
|
}
|
|
87
81
|
};
|
|
@@ -90,31 +84,31 @@ export async function runSessionsList(args, pretty, depth, deps = defaultAuthDep
|
|
|
90
84
|
export async function runSessionsRevoke(args, pretty, depth, deps = defaultAuthDeps(pretty, depth)) {
|
|
91
85
|
const command = 'sessions revoke';
|
|
92
86
|
return rehearsed(command, args, pretty, depth, deps, (rest) => {
|
|
93
|
-
const id = parseRevoke(rest
|
|
87
|
+
const id = parseRevoke(rest);
|
|
94
88
|
if (typeof id !== 'string')
|
|
95
89
|
return id;
|
|
96
90
|
const path = `/${encodeURIComponent(id)}/revoke`;
|
|
97
91
|
return {
|
|
98
92
|
steps: REVOKE_STEPS,
|
|
99
|
-
result: (siteUrl) => plannedChange(command, pretty, depth, siteUrl, { url: sessionsUrl(siteUrl, path), body: {} }, '
|
|
93
|
+
result: (siteUrl) => plannedChange(command, pretty, depth, siteUrl, { url: sessionsUrl(siteUrl, path), body: {} }, 'Checked the session revoke request. The session was not revoked.', [['Session ID', id], ['Impact', 'Revoking signs out the browser or terminal that uses this session at once.']], { sessionId: id }),
|
|
100
94
|
send: {
|
|
101
95
|
method: 'POST',
|
|
102
96
|
url: (siteUrl) => sessionsUrl(siteUrl, path),
|
|
103
97
|
body: {},
|
|
104
|
-
spinner: '
|
|
105
|
-
failed: '
|
|
98
|
+
spinner: 'Revoking the session.',
|
|
99
|
+
failed: 'Could not revoke the session.',
|
|
106
100
|
notFound: SESSION_NOT_FOUND,
|
|
107
101
|
failures: { current_session: CURRENT_SESSION },
|
|
108
102
|
done: (body, siteUrl) => {
|
|
109
103
|
const { session } = body;
|
|
110
104
|
return pretty
|
|
111
|
-
? prettyResult(0, depth, command,
|
|
105
|
+
? prettyResult(0, depth, command, `Revoked the ${session.kind === 'web' ? 'browser' : 'CLI'} session.`, [['Server', siteUrl], ...sessionRows(session), ['Impact', 'The browser or terminal that used this session is now signed out.']])
|
|
112
106
|
: agentResult(0, { command, siteUrl, applied: true, sessionId: session.id, session });
|
|
113
107
|
}
|
|
114
108
|
}
|
|
115
109
|
};
|
|
116
110
|
}, {
|
|
117
111
|
message: 'Revoking signs out the browser or terminal that uses the session at once.',
|
|
118
|
-
display: '
|
|
112
|
+
display: 'Revoking signs out the browser or terminal that uses the session at once. Confirm with the user, then run it with --yes.'
|
|
119
113
|
});
|
|
120
114
|
}
|
package/dist/commands/sites.js
CHANGED
|
@@ -8,7 +8,7 @@ import { spec } from "../registry.js";
|
|
|
8
8
|
import { plannedRequest, splitDryRun } from "../runtime/dry-run.js";
|
|
9
9
|
import { SERVER_OPTION, parseServerArgs } from "../runtime/server-options.js";
|
|
10
10
|
export const SITES_PATH = '/api/v1/sites';
|
|
11
|
-
const { name: command, usage
|
|
11
|
+
const { name: command, usage } = spec('sites');
|
|
12
12
|
const FLAGS = ['--page', SERVER_OPTION];
|
|
13
13
|
const PAGE_RE = /^[1-9]\d{0,5}$/;
|
|
14
14
|
function isSite(value) {
|
|
@@ -32,8 +32,8 @@ function isListing(body) {
|
|
|
32
32
|
&& Array.isArray(listing.sites)
|
|
33
33
|
&& listing.sites.every(isSite);
|
|
34
34
|
}
|
|
35
|
-
function parseSitesArgs(args
|
|
36
|
-
const parsed = parseFlags(args, FLAGS
|
|
35
|
+
function parseSitesArgs(args) {
|
|
36
|
+
const parsed = parseFlags(args, FLAGS);
|
|
37
37
|
if ('error' in parsed)
|
|
38
38
|
return parsed;
|
|
39
39
|
let page = 1;
|
|
@@ -46,10 +46,10 @@ function parseSitesArgs(args, pretty) {
|
|
|
46
46
|
page = Number(value);
|
|
47
47
|
}
|
|
48
48
|
else {
|
|
49
|
-
return { error:
|
|
49
|
+
return { error: `--page requires a positive integer: ${value}` };
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
|
-
const server = parseServerArgs(serverArgs
|
|
52
|
+
const server = parseServerArgs(serverArgs);
|
|
53
53
|
return 'error' in server ? server : { page, siteUrl: server.siteUrl };
|
|
54
54
|
}
|
|
55
55
|
const plain = (text) => text.replace(CONTROL, ' ');
|
|
@@ -57,15 +57,15 @@ function rows({ name, tagline, url, regions, monthlyVisits, createdAt }) {
|
|
|
57
57
|
return [
|
|
58
58
|
[plain(name), plain(url)],
|
|
59
59
|
...(tagline ? [['', plain(tagline)]] : []),
|
|
60
|
-
['', plain(`${regions} ·
|
|
60
|
+
['', plain(`${regions} · ${monthlyVisits.toLocaleString('en-US')} visits/month · published ${createdAt.slice(0, 10)}`)]
|
|
61
61
|
];
|
|
62
62
|
}
|
|
63
63
|
export async function runSites(args, pretty, depth, deps = defaultDeps()) {
|
|
64
64
|
const { args: rest, dryRun } = splitDryRun(args);
|
|
65
|
-
const options = parseSitesArgs(rest
|
|
65
|
+
const options = parseSitesArgs(rest);
|
|
66
66
|
if ('error' in options) {
|
|
67
67
|
return pretty
|
|
68
|
-
? prettyResult(2, depth, command, options.error, [['
|
|
68
|
+
? prettyResult(2, depth, command, options.error, [['Usage', usage]])
|
|
69
69
|
: agentResult(2, { command, error: { code: 'invalid_arguments', message: options.error }, usage });
|
|
70
70
|
}
|
|
71
71
|
const siteUrl = options.siteUrl ?? await readLoginSiteUrl() ?? SITE_URL;
|
|
@@ -73,7 +73,7 @@ export async function runSites(args, pretty, depth, deps = defaultDeps()) {
|
|
|
73
73
|
endpoint.searchParams.set('page', String(options.page));
|
|
74
74
|
if (dryRun)
|
|
75
75
|
return plannedRequest(command, pretty, depth, siteUrl, endpoint.href);
|
|
76
|
-
const result = await request(endpoint.href, { method: 'GET' }, deps, pretty ? '
|
|
76
|
+
const result = await request(endpoint.href, { method: 'GET' }, deps, pretty ? 'Loading public sites.' : null);
|
|
77
77
|
if ('failure' in result || result.status !== 200 || !isListing(result.body)) {
|
|
78
78
|
const failure = 'failure' in result
|
|
79
79
|
? result.failure
|
|
@@ -81,7 +81,7 @@ export async function runSites(args, pretty, depth, deps = defaultDeps()) {
|
|
|
81
81
|
? httpFailure(result.status)
|
|
82
82
|
: UNEXPECTED;
|
|
83
83
|
return pretty
|
|
84
|
-
? prettyResult(1, depth, command, '
|
|
84
|
+
? prettyResult(1, depth, command, 'Could not load public sites.', [['Server', siteUrl], ['Reason', failure.display]])
|
|
85
85
|
: agentResult(1, { command, siteUrl, error: failureError(failure) });
|
|
86
86
|
}
|
|
87
87
|
const { total, page, pageSize, totalPages, sites } = result.body;
|
|
@@ -90,13 +90,13 @@ export async function runSites(args, pretty, depth, deps = defaultDeps()) {
|
|
|
90
90
|
return agentResult(0, { command, siteUrl, total, page, pageSize, totalPages, next, sites });
|
|
91
91
|
}
|
|
92
92
|
return prettyResult(0, depth, command, total === 0
|
|
93
|
-
? '
|
|
93
|
+
? 'No sites have been published yet.'
|
|
94
94
|
: sites.length
|
|
95
|
-
?
|
|
96
|
-
:
|
|
97
|
-
['
|
|
95
|
+
? `Loaded ${sites.length} of ${total} public site${total === 1 ? '' : 's'}.`
|
|
96
|
+
: `Page ${page} has no sites.`, [
|
|
97
|
+
['Server', siteUrl],
|
|
98
98
|
...sites.flatMap(rows),
|
|
99
|
-
['
|
|
100
|
-
...(next ? [['
|
|
99
|
+
['Page', `${page} / ${totalPages}`],
|
|
100
|
+
...(next ? [['Next', next]] : [])
|
|
101
101
|
]);
|
|
102
102
|
}
|
package/dist/commands/sms.js
CHANGED
|
@@ -6,30 +6,35 @@ import { spec } from "../registry.js";
|
|
|
6
6
|
import { splitDryRun } from "../runtime/dry-run.js";
|
|
7
7
|
import { parseFlags } from "../runtime/flags.js";
|
|
8
8
|
import { readText } from "../runtime/text-file.js";
|
|
9
|
+
import { holdReasonText } from "./emails.js";
|
|
9
10
|
export const SMS_PATH = '/api/v1/sms';
|
|
10
|
-
const { name: command, usage
|
|
11
|
+
const { name: command, usage } = spec('sms send');
|
|
11
12
|
const FLAGS = ['--to', '--body', '--body-file'];
|
|
12
|
-
async function parseSendArgs(args
|
|
13
|
-
const parsed = parseFlags(args, FLAGS
|
|
13
|
+
async function parseSendArgs(args) {
|
|
14
|
+
const parsed = parseFlags(args, FLAGS);
|
|
14
15
|
if ('error' in parsed)
|
|
15
16
|
return parsed;
|
|
16
17
|
const values = Object.fromEntries(parsed.entries);
|
|
17
18
|
const { '--to': to, '--body': body, '--body-file': bodyFile } = values;
|
|
18
19
|
if (to === undefined) {
|
|
19
|
-
return { error:
|
|
20
|
+
return { error: '--to is required.' };
|
|
20
21
|
}
|
|
21
|
-
const content = await readText('--body', body, bodyFile
|
|
22
|
+
const content = await readText('--body', body, bodyFile);
|
|
22
23
|
return 'error' in content ? content : { to, body: content.text };
|
|
23
24
|
}
|
|
25
|
+
function heldResult({ status, body }) {
|
|
26
|
+
const sent = body;
|
|
27
|
+
return status === 202 && sent?.ok === true && sent.held === true;
|
|
28
|
+
}
|
|
24
29
|
export async function runSmsSend(args, pretty, depth, deps = defaultAuthDeps(pretty, depth)) {
|
|
25
30
|
const { args: rest, dryRun } = splitDryRun(args);
|
|
26
|
-
const parsed = await parseSendArgs(rest
|
|
31
|
+
const parsed = await parseSendArgs(rest);
|
|
27
32
|
if ('error' in parsed) {
|
|
28
33
|
return pretty
|
|
29
|
-
? prettyResult(2, depth, command, parsed.error, [['
|
|
34
|
+
? prettyResult(2, depth, command, parsed.error, [['Usage', usage]])
|
|
30
35
|
: agentResult(2, { command, error: { code: 'invalid_arguments', message: parsed.error }, usage });
|
|
31
36
|
}
|
|
32
|
-
const sent = await authorized(deps, ({ siteUrl, token }) => postJson(new URL(SMS_PATH, siteUrl).href, token, dryRun ? { ...parsed, dryRun } : parsed, deps, pretty ? (dryRun ? '
|
|
37
|
+
const sent = await authorized(deps, ({ siteUrl, token }) => postJson(new URL(SMS_PATH, siteUrl).href, token, dryRun ? { ...parsed, dryRun } : parsed, deps, pretty ? (dryRun ? 'Validating the SMS.' : 'Sending the SMS.') : null));
|
|
33
38
|
if ('login' in sent)
|
|
34
39
|
return sent.login;
|
|
35
40
|
const { session: { siteUrl }, result } = sent;
|
|
@@ -41,25 +46,34 @@ export async function runSmsSend(args, pretty, depth, deps = defaultAuthDeps(pre
|
|
|
41
46
|
else if (result.status === 401) {
|
|
42
47
|
failure = LOGIN_EXPIRED;
|
|
43
48
|
}
|
|
44
|
-
else if (!accepted(result)) {
|
|
49
|
+
else if (!accepted(result) && !heldResult(result)) {
|
|
45
50
|
rejected = result.status === 400 && result.body?.rejected === true;
|
|
46
51
|
failure = rejected
|
|
47
|
-
? { code: 'spam_rejected', message: 'The server rejected the message as advertising or spam. The account may be blocked if this continues.', display: '
|
|
52
|
+
? { code: 'spam_rejected', message: 'The server rejected the message as advertising or spam. The account may be blocked if this continues.', display: 'The server rejected the message as advertising or spam. The account may be blocked if this continues.' }
|
|
48
53
|
: result.status === 400
|
|
49
|
-
? { code: 'rejected', message: 'The server rejected the message. Check the recipient and body.', display: '
|
|
54
|
+
? { code: 'rejected', message: 'The server rejected the message. Check the recipient and body.', display: 'The server rejected the message. Check the recipient and body.' }
|
|
50
55
|
: httpFailure(result.status);
|
|
51
56
|
}
|
|
52
57
|
if (failure) {
|
|
53
58
|
return pretty
|
|
54
|
-
? prettyResult(1, depth, command, rejected ? '
|
|
59
|
+
? prettyResult(1, depth, command, rejected ? 'The SMS was rejected.' : dryRun ? 'Could not validate the SMS.' : 'Could not send the SMS.', [['Server', siteUrl], ['Reason', failure.display]])
|
|
55
60
|
: agentResult(1, { command, siteUrl, delivered: false, ...(rejected ? { rejected } : {}), error: sendFailureError(result, failure) });
|
|
56
61
|
}
|
|
57
|
-
const { dryRun: checked, delivered, id, to } = result.body;
|
|
62
|
+
const { dryRun: checked, held, code, reasons, delivered, id, to } = result.body;
|
|
63
|
+
const review = held === true ? { held: true, code, reasons } : {};
|
|
58
64
|
if (!pretty) {
|
|
59
|
-
return agentResult(0, { command, siteUrl, ...(checked === true ? { dryRun: true } : {}), delivered, rejected, id, to });
|
|
65
|
+
return agentResult(0, { command, siteUrl, ...(checked === true ? { dryRun: true } : {}), ...review, delivered, rejected, id, to });
|
|
60
66
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
67
|
+
const done = checked === true
|
|
68
|
+
? held === true
|
|
69
|
+
? 'Validated the SMS. It would be held for review, so nothing was sent.'
|
|
70
|
+
: 'Validated the SMS. Nothing was sent.'
|
|
71
|
+
: held === true
|
|
72
|
+
? 'Held the SMS for review. An administrator will send it or turn it down within 72 hours.'
|
|
73
|
+
: 'Sent the SMS.';
|
|
74
|
+
return prettyResult(0, depth, command, done, [
|
|
75
|
+
['Server', siteUrl],
|
|
76
|
+
['To', to],
|
|
77
|
+
...(held === true ? [['Held for', holdReasonText(reasons)]] : [])
|
|
64
78
|
]);
|
|
65
79
|
}
|
package/dist/commands/status.js
CHANGED
|
@@ -9,7 +9,7 @@ import { plannedRequest, splitDryRun } from "../runtime/dry-run.js";
|
|
|
9
9
|
import { parseServerArgs } from "../runtime/server-options.js";
|
|
10
10
|
import { startSpinner } from "../runtime/spinner.js";
|
|
11
11
|
import { supportFailure } from "../runtime/support.js";
|
|
12
|
-
const { name: command, usage
|
|
12
|
+
const { name: command, usage } = spec('system status');
|
|
13
13
|
const BACKEND_UNAVAILABLE = supportFailure('backend_unavailable');
|
|
14
14
|
async function checkBackend(siteUrl, signal, fetcher) {
|
|
15
15
|
try {
|
|
@@ -23,10 +23,10 @@ async function checkBackend(siteUrl, signal, fetcher) {
|
|
|
23
23
|
}
|
|
24
24
|
export async function runStatus(args, pretty, depth, deps = { fetch, stream: process.stderr, timeoutMs: 10_000 }) {
|
|
25
25
|
const { args: rest, dryRun } = splitDryRun(args);
|
|
26
|
-
const options = parseServerArgs(rest
|
|
26
|
+
const options = parseServerArgs(rest);
|
|
27
27
|
if ('error' in options) {
|
|
28
28
|
return pretty
|
|
29
|
-
? prettyResult(2, depth, command, options.error, [['
|
|
29
|
+
? prettyResult(2, depth, command, options.error, [['Usage', usage]])
|
|
30
30
|
: agentResult(2, {
|
|
31
31
|
command,
|
|
32
32
|
error: { code: 'invalid_arguments', message: options.error },
|
|
@@ -36,7 +36,7 @@ export async function runStatus(args, pretty, depth, deps = { fetch, stream: pro
|
|
|
36
36
|
const siteUrl = options.siteUrl ?? await readLoginSiteUrl() ?? SITE_URL;
|
|
37
37
|
if (dryRun)
|
|
38
38
|
return plannedRequest(command, pretty, depth, siteUrl, new URL('/api/v1/status', siteUrl).href);
|
|
39
|
-
const stop = pretty ? startSpinner('
|
|
39
|
+
const stop = pretty ? startSpinner('Connecting to the deployment server.', deps.stream) : () => { };
|
|
40
40
|
const controller = new AbortController();
|
|
41
41
|
const timer = setTimeout(() => controller.abort(), deps.timeoutMs);
|
|
42
42
|
let httpStatus = null;
|
|
@@ -64,8 +64,8 @@ export async function runStatus(args, pretty, depth, deps = { fetch, stream: pro
|
|
|
64
64
|
}
|
|
65
65
|
catch {
|
|
66
66
|
failure = controller.signal.aborted
|
|
67
|
-
? { code: 'connection_timeout', message: 'The connection timed out.', display: '
|
|
68
|
-
: { code: 'connection_failed', message: 'Could not connect to the deployment server.', display: '
|
|
67
|
+
? { code: 'connection_timeout', message: 'The connection timed out.', display: 'The server did not respond in time.' }
|
|
68
|
+
: { code: 'connection_failed', message: 'Could not connect to the deployment server.', display: 'Check the server URL and your network connection.' };
|
|
69
69
|
}
|
|
70
70
|
finally {
|
|
71
71
|
clearTimeout(timer);
|
|
@@ -81,7 +81,7 @@ export async function runStatus(args, pretty, depth, deps = { fetch, stream: pro
|
|
|
81
81
|
});
|
|
82
82
|
}
|
|
83
83
|
if (!failure)
|
|
84
|
-
return prettyResult(0, depth, command, '
|
|
85
|
-
const target = backend === 'unavailable' ? '
|
|
86
|
-
return prettyResult(1, depth, command,
|
|
84
|
+
return prettyResult(0, depth, command, 'Connected to the deployment server.', [['Server', siteUrl], ['Services', 'OK']]);
|
|
85
|
+
const target = backend === 'unavailable' ? 'the services' : 'the deployment server';
|
|
86
|
+
return prettyResult(1, depth, command, `Could not connect to ${target}.`, [['Server', siteUrl], ['Reason', failure.display]]);
|
|
87
87
|
}
|
package/dist/commands/support.js
CHANGED
|
@@ -19,16 +19,16 @@ function isGuide(body) {
|
|
|
19
19
|
export async function runQa(args, pretty, depth, deps = defaultDeps()) {
|
|
20
20
|
const command = QA.name;
|
|
21
21
|
const { args: rest, dryRun } = splitDryRun(args);
|
|
22
|
-
const options = parseServerArgs(rest
|
|
22
|
+
const options = parseServerArgs(rest);
|
|
23
23
|
if ('error' in options) {
|
|
24
24
|
return pretty
|
|
25
|
-
? prettyResult(2, depth, command, options.error, [['
|
|
25
|
+
? prettyResult(2, depth, command, options.error, [['Usage', QA.usage]])
|
|
26
26
|
: agentResult(2, { command, error: { code: 'invalid_arguments', message: options.error }, usage: QA.usage });
|
|
27
27
|
}
|
|
28
28
|
const siteUrl = options.siteUrl ?? await readLoginSiteUrl() ?? SITE_URL;
|
|
29
29
|
if (dryRun)
|
|
30
30
|
return plannedRequest(command, pretty, depth, siteUrl, new URL(CONTACT_PATH, siteUrl).href);
|
|
31
|
-
const result = await request(new URL(CONTACT_PATH, siteUrl).href, { method: 'GET' }, deps, pretty ? '
|
|
31
|
+
const result = await request(new URL(CONTACT_PATH, siteUrl).href, { method: 'GET' }, deps, pretty ? 'Loading the FAQ.' : null);
|
|
32
32
|
if ('failure' in result || result.status !== 200 || !isGuide(result.body)) {
|
|
33
33
|
const failure = 'failure' in result
|
|
34
34
|
? result.failure
|
|
@@ -36,23 +36,23 @@ export async function runQa(args, pretty, depth, deps = defaultDeps()) {
|
|
|
36
36
|
? httpFailure(result.status)
|
|
37
37
|
: UNEXPECTED;
|
|
38
38
|
return pretty
|
|
39
|
-
? prettyResult(1, depth, command, '
|
|
39
|
+
? prettyResult(1, depth, command, 'Could not load the FAQ.', [['Server', siteUrl], ['Reason', failure.display]])
|
|
40
40
|
: agentResult(1, { command, siteUrl, error: failureError(failure) });
|
|
41
41
|
}
|
|
42
42
|
const guide = result.body;
|
|
43
43
|
if (!pretty) {
|
|
44
44
|
return agentResult(0, { command, siteUrl, ...guide, send: CONTACT.usage });
|
|
45
45
|
}
|
|
46
|
-
return prettyResult(0, depth, command, '
|
|
46
|
+
return prettyResult(0, depth, command, 'Loaded the FAQ.', [
|
|
47
47
|
...guide.faq.flatMap(({ question, answer }, index) => [
|
|
48
|
-
[`Q${index + 1}`, question.
|
|
49
|
-
['', answer.
|
|
48
|
+
[`Q${index + 1}`, question.en],
|
|
49
|
+
['', answer.en]
|
|
50
50
|
]),
|
|
51
|
-
['
|
|
51
|
+
['Contact', 'deepdynamic support contact --message <text>']
|
|
52
52
|
]);
|
|
53
53
|
}
|
|
54
|
-
async function parseContactArgs(args
|
|
55
|
-
const parsed = parseFlags(args, CONTACT_FLAGS
|
|
54
|
+
async function parseContactArgs(args) {
|
|
55
|
+
const parsed = parseFlags(args, CONTACT_FLAGS);
|
|
56
56
|
if ('error' in parsed)
|
|
57
57
|
return parsed;
|
|
58
58
|
let message;
|
|
@@ -66,19 +66,19 @@ async function parseContactArgs(args, pretty) {
|
|
|
66
66
|
else
|
|
67
67
|
teamEmails.push(value);
|
|
68
68
|
}
|
|
69
|
-
const content = await readText('--message', message, messageFile
|
|
69
|
+
const content = await readText('--message', message, messageFile);
|
|
70
70
|
return 'error' in content ? content : { message: content.text, teamEmails };
|
|
71
71
|
}
|
|
72
72
|
export async function runContact(args, pretty, depth, deps = defaultAuthDeps(pretty, depth)) {
|
|
73
73
|
const command = CONTACT.name;
|
|
74
74
|
const { args: rest, dryRun } = splitDryRun(args);
|
|
75
|
-
const parsed = await parseContactArgs(rest
|
|
75
|
+
const parsed = await parseContactArgs(rest);
|
|
76
76
|
if ('error' in parsed) {
|
|
77
77
|
return pretty
|
|
78
|
-
? prettyResult(2, depth, command, parsed.error, [['
|
|
78
|
+
? prettyResult(2, depth, command, parsed.error, [['Usage', CONTACT.usage]])
|
|
79
79
|
: agentResult(2, { command, error: { code: 'invalid_arguments', message: parsed.error }, usage: CONTACT.usage });
|
|
80
80
|
}
|
|
81
|
-
const sent = await authorized(deps, ({ siteUrl, token }) => postJson(new URL(CONTACT_PATH, siteUrl).href, token, { message: parsed.message, ...(parsed.teamEmails.length ? { teamEmails: parsed.teamEmails } : {}), ...(dryRun ? { dryRun } : {}) }, deps, pretty ? (dryRun ? '
|
|
81
|
+
const sent = await authorized(deps, ({ siteUrl, token }) => postJson(new URL(CONTACT_PATH, siteUrl).href, token, { message: parsed.message, ...(parsed.teamEmails.length ? { teamEmails: parsed.teamEmails } : {}), ...(dryRun ? { dryRun } : {}) }, deps, pretty ? (dryRun ? 'Validating the inquiry.' : 'Sending the inquiry.') : null));
|
|
82
82
|
if ('login' in sent)
|
|
83
83
|
return sent.login;
|
|
84
84
|
const { session: { siteUrl }, result } = sent;
|
|
@@ -91,25 +91,25 @@ export async function runContact(args, pretty, depth, deps = defaultAuthDeps(pre
|
|
|
91
91
|
}
|
|
92
92
|
else if (!accepted(result)) {
|
|
93
93
|
failure = result.status === 429
|
|
94
|
-
? { code: 'rate_limited', message: 'Too many inquiries. Try again later.', display: '
|
|
94
|
+
? { code: 'rate_limited', message: 'Too many inquiries. Try again later.', display: 'Too many inquiries. Try again later.' }
|
|
95
95
|
: result.status === 400
|
|
96
|
-
? { code: 'rejected', message: 'The server rejected the inquiry. Check the message and team emails.', display: '
|
|
96
|
+
? { code: 'rejected', message: 'The server rejected the inquiry. Check the message and team emails.', display: 'The server rejected the inquiry. Check the message and team emails.' }
|
|
97
97
|
: httpFailure(result.status);
|
|
98
98
|
}
|
|
99
99
|
if (failure) {
|
|
100
100
|
return pretty
|
|
101
|
-
? prettyResult(1, depth, command, dryRun ? '
|
|
101
|
+
? prettyResult(1, depth, command, dryRun ? 'Could not validate the inquiry.' : 'Could not send the inquiry.', [['Server', siteUrl], ['Reason', failure.display]])
|
|
102
102
|
: agentResult(1, { command, siteUrl, error: sendFailureError(result, failure) });
|
|
103
103
|
}
|
|
104
104
|
const { id, dryRun: checked } = result.body;
|
|
105
105
|
const email = await readAccountEmail();
|
|
106
106
|
if (checked === true) {
|
|
107
107
|
return pretty
|
|
108
|
-
? prettyResult(0, depth, command, '
|
|
108
|
+
? prettyResult(0, depth, command, 'Validated the inquiry. Nothing was sent.', [['Server', siteUrl]])
|
|
109
109
|
: agentResult(0, { command, siteUrl, dryRun: true, replyTo: email });
|
|
110
110
|
}
|
|
111
111
|
if (!pretty) {
|
|
112
112
|
return agentResult(0, { command, siteUrl, id: typeof id === 'string' ? id : null, replyTo: email });
|
|
113
113
|
}
|
|
114
|
-
return prettyResult(0, depth, command, '
|
|
114
|
+
return prettyResult(0, depth, command, 'Sent the inquiry. Replies go to the account email.', [['Server', siteUrl], ['Reply to', email ?? 'The logged-in account']]);
|
|
115
115
|
}
|
package/dist/commands/update.js
CHANGED
|
@@ -5,7 +5,7 @@ import { confirmationRequired, splitYes } from "../runtime/confirm.js";
|
|
|
5
5
|
import { splitDryRun } from "../runtime/dry-run.js";
|
|
6
6
|
import { unknownArgument } from "../runtime/flags.js";
|
|
7
7
|
import { startSpinner } from "../runtime/spinner.js";
|
|
8
|
-
import { REGISTRY_URL, isNewer, latestOf, saveUpdateCache, updateCachePath, updateLockPath, withUpdateLock } from "../runtime/update-check.js";
|
|
8
|
+
import { REGISTRY_URL, isNewer, latestOf, saveUpdateCache, startSkillRefresh, updateCachePath, updateLockPath, withUpdateLock } from "../runtime/update-check.js";
|
|
9
9
|
import { PACKAGE_DIR, findPackageManager, installArgs, packageManagerOf, runProgram } from "../runtime/update-install.js";
|
|
10
10
|
import { usageError } from "../runtime/usage-error.js";
|
|
11
11
|
const command = 'update';
|
|
@@ -15,23 +15,24 @@ export const defaultUpdateCommandDeps = () => ({
|
|
|
15
15
|
now: Date.now,
|
|
16
16
|
packageManager: packageManagerOf(PACKAGE_DIR),
|
|
17
17
|
find: findPackageManager,
|
|
18
|
-
install: runProgram
|
|
18
|
+
install: runProgram,
|
|
19
|
+
refreshSkills: startSkillRefresh
|
|
19
20
|
});
|
|
20
21
|
const registryFailure = (status) => ({
|
|
21
22
|
code: 'http_error',
|
|
22
23
|
message: 'The npm registry answered with an error.',
|
|
23
|
-
display: 'npm
|
|
24
|
+
display: 'The npm registry returned an error. Try again later.',
|
|
24
25
|
retryable: status >= 500 || status === 429
|
|
25
26
|
});
|
|
26
27
|
const REGISTRY_UNEXPECTED = {
|
|
27
28
|
code: 'unexpected_response',
|
|
28
29
|
message: 'The npm registry did not return the latest version.',
|
|
29
|
-
display: 'npm
|
|
30
|
+
display: 'The npm registry did not return the latest version.'
|
|
30
31
|
};
|
|
31
32
|
const UPDATE_IN_PROGRESS = {
|
|
32
33
|
code: 'update_in_progress',
|
|
33
34
|
message: 'An automatic update is running in the background. Retry in a minute.',
|
|
34
|
-
display: '
|
|
35
|
+
display: 'An automatic update is running in the background. Retry in a minute.',
|
|
35
36
|
retryable: true
|
|
36
37
|
};
|
|
37
38
|
function failed(failure, pretty, depth, data, rows = [], detail) {
|
|
@@ -43,33 +44,33 @@ export async function runUpdate(args, current, pretty, depth, deps = defaultUpda
|
|
|
43
44
|
const { args: withoutYes, yes } = splitYes(args);
|
|
44
45
|
const { args: rest, dryRun } = splitDryRun(withoutYes);
|
|
45
46
|
if (rest.length)
|
|
46
|
-
return usageError(command, unknownArgument(rest[0]
|
|
47
|
+
return usageError(command, unknownArgument(rest[0]), pretty, depth);
|
|
47
48
|
const manager = deps.packageManager;
|
|
48
49
|
if (dryRun) {
|
|
49
50
|
return pretty
|
|
50
|
-
? prettyResult(0, depth, command, '
|
|
51
|
+
? prettyResult(0, depth, command, 'Checked without sending the request or installing.', [['Current', current], ['Request', `GET ${REGISTRY_URL}`], ['Install', `${manager} ${installArgs(manager, '<latest-version>').join(' ')}`]])
|
|
51
52
|
: agentResult(0, { command, current, packageManager: manager, dryRun: true, request: { method: 'GET', url: REGISTRY_URL } });
|
|
52
53
|
}
|
|
53
|
-
const response = await request(REGISTRY_URL, { method: 'GET' }, deps, pretty ? '
|
|
54
|
+
const response = await request(REGISTRY_URL, { method: 'GET' }, deps, pretty ? 'Checking for the latest version.' : null);
|
|
54
55
|
const latest = 'failure' in response || response.status !== 200 ? null : latestOf(response.body);
|
|
55
56
|
if (!latest) {
|
|
56
57
|
const failure = 'failure' in response ? response.failure : response.status !== 200 ? registryFailure(response.status) : REGISTRY_UNEXPECTED;
|
|
57
|
-
return failed(failure, pretty, depth, { current }, [['
|
|
58
|
+
return failed(failure, pretty, depth, { current }, [['Current', current]]);
|
|
58
59
|
}
|
|
59
60
|
await saveUpdateCache(deps.cachePath, { checkedAt: deps.now(), latest }).catch(() => { });
|
|
60
61
|
if (!isNewer(latest, current)) {
|
|
61
62
|
return pretty
|
|
62
|
-
? prettyResult(0, depth, command, '
|
|
63
|
+
? prettyResult(0, depth, command, 'Already on the latest version.', [['Current', current], ['Latest', latest]])
|
|
63
64
|
: agentResult(0, { command, current, latest, packageManager: manager, updated: false });
|
|
64
65
|
}
|
|
65
66
|
const argv = installArgs(manager, latest);
|
|
66
67
|
const install = `${manager} ${argv.join(' ')}`;
|
|
67
68
|
const data = { current, latest, packageManager: manager, install };
|
|
68
|
-
const rows = [['
|
|
69
|
+
const rows = [['Current', current], ['Latest', latest], ['Install', install]];
|
|
69
70
|
if (!yes) {
|
|
70
71
|
return confirmationRequired(command, args, pretty, depth, {
|
|
71
72
|
message: `DeepDynamic CLI ${latest} is available (current ${current}). The update runs: ${install}.`,
|
|
72
|
-
display:
|
|
73
|
+
display: `A new version is available (current ${current}, latest ${latest}). Updating runs ${install}.`
|
|
73
74
|
}, data);
|
|
74
75
|
}
|
|
75
76
|
const path = await deps.find(manager);
|
|
@@ -77,10 +78,10 @@ export async function runUpdate(args, current, pretty, depth, deps = defaultUpda
|
|
|
77
78
|
return failed({
|
|
78
79
|
code: 'package_manager_not_found',
|
|
79
80
|
message: `${manager} was not found on PATH. Update the CLI with the package manager that installed it, for example: ${install}`,
|
|
80
|
-
display:
|
|
81
|
+
display: `${manager} was not found on PATH. Update the CLI with the package manager that installed it.`
|
|
81
82
|
}, pretty, depth, data, rows);
|
|
82
83
|
}
|
|
83
|
-
const stop = pretty ? startSpinner(
|
|
84
|
+
const stop = pretty ? startSpinner(`Installing the latest version (${latest}).`, deps.stream) : () => { };
|
|
84
85
|
const installed = await withUpdateLock(updateLockPath(deps.cachePath), () => deps.install(path, argv), deps.now);
|
|
85
86
|
stop();
|
|
86
87
|
if (!installed)
|
|
@@ -89,10 +90,11 @@ export async function runUpdate(args, current, pretty, depth, deps = defaultUpda
|
|
|
89
90
|
return failed({
|
|
90
91
|
code: 'update_failed',
|
|
91
92
|
message: `${install} failed. Read error.detail, fix the cause (for example permissions of the global folder) or run the command yourself.`,
|
|
92
|
-
display: `${manager}
|
|
93
|
+
display: `${manager} failed to install the update. Check the output below or run the install command yourself.`
|
|
93
94
|
}, pretty, depth, data, [...rows, [manager, installed.output]], installed.output);
|
|
94
95
|
}
|
|
96
|
+
deps.refreshSkills();
|
|
95
97
|
return pretty
|
|
96
|
-
? prettyResult(0, depth, command,
|
|
98
|
+
? prettyResult(0, depth, command, `Updated ${current} → ${latest}.`, [['Previous', current], ['Current', latest]])
|
|
97
99
|
: agentResult(0, { command, current, latest, packageManager: manager, updated: true });
|
|
98
100
|
}
|