@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/emails.js
CHANGED
|
@@ -7,34 +7,34 @@ 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
9
|
export const EMAILS_PATH = '/api/v1/emails';
|
|
10
|
-
const { name: command, usage
|
|
10
|
+
const { name: command, usage } = spec('emails send');
|
|
11
11
|
const FLAGS = ['--to', '--title', '--body', '--body-file'];
|
|
12
12
|
const BODY_ESCAPE_RE = /\\(\\|r\\n|n|t)/g;
|
|
13
13
|
function unescapeBody(body) {
|
|
14
14
|
return body.replace(BODY_ESCAPE_RE, (_, escape) => (escape === '\\' ? '\\' : escape === 't' ? '\t' : '\n'));
|
|
15
15
|
}
|
|
16
|
-
async function parseSendArgs(args
|
|
17
|
-
const parsed = parseFlags(args, FLAGS
|
|
16
|
+
async function parseSendArgs(args) {
|
|
17
|
+
const parsed = parseFlags(args, FLAGS);
|
|
18
18
|
if ('error' in parsed)
|
|
19
19
|
return parsed;
|
|
20
20
|
const values = Object.fromEntries(parsed.entries);
|
|
21
21
|
const { '--to': to, '--title': title, '--body': body, '--body-file': bodyFile } = values;
|
|
22
22
|
if (to === undefined || title === undefined) {
|
|
23
23
|
const missing = to === undefined ? '--to' : '--title';
|
|
24
|
-
return { error:
|
|
24
|
+
return { error: `${missing} is required.` };
|
|
25
25
|
}
|
|
26
|
-
const content = await readText('--body', body === undefined ? undefined : unescapeBody(body), bodyFile
|
|
26
|
+
const content = await readText('--body', body === undefined ? undefined : unescapeBody(body), bodyFile);
|
|
27
27
|
return 'error' in content ? content : { to, title, body: content.text };
|
|
28
28
|
}
|
|
29
29
|
export async function runEmailSend(args, pretty, depth, deps = defaultAuthDeps(pretty, depth)) {
|
|
30
30
|
const { args: rest, dryRun } = splitDryRun(args);
|
|
31
|
-
const parsed = await parseSendArgs(rest
|
|
31
|
+
const parsed = await parseSendArgs(rest);
|
|
32
32
|
if ('error' in parsed) {
|
|
33
33
|
return pretty
|
|
34
|
-
? prettyResult(2, depth, command, parsed.error, [['
|
|
34
|
+
? prettyResult(2, depth, command, parsed.error, [['Usage', usage]])
|
|
35
35
|
: agentResult(2, { command, error: { code: 'invalid_arguments', message: parsed.error }, usage });
|
|
36
36
|
}
|
|
37
|
-
const sent = await authorized(deps, ({ siteUrl, token }) => postJson(new URL(EMAILS_PATH, siteUrl).href, token, dryRun ? { ...parsed, dryRun } : parsed, deps, pretty ? (dryRun ? '
|
|
37
|
+
const sent = await authorized(deps, ({ siteUrl, token }) => postJson(new URL(EMAILS_PATH, siteUrl).href, token, dryRun ? { ...parsed, dryRun } : parsed, deps, pretty ? (dryRun ? 'Validating the email.' : 'Sending the email.') : null));
|
|
38
38
|
if ('login' in sent)
|
|
39
39
|
return sent.login;
|
|
40
40
|
const { session: { siteUrl }, result } = sent;
|
|
@@ -49,26 +49,26 @@ export async function runEmailSend(args, pretty, depth, deps = defaultAuthDeps(p
|
|
|
49
49
|
else if (!accepted(result)) {
|
|
50
50
|
rejected = result.status === 400 && result.body?.rejected === true;
|
|
51
51
|
failure = rejected
|
|
52
|
-
? { code: 'spam_rejected', message: 'The server rejected the email as advertising or spam. The account may be blocked if this continues.', display: '
|
|
52
|
+
? { code: 'spam_rejected', message: 'The server rejected the email as advertising or spam. The account may be blocked if this continues.', display: 'The server rejected the email as advertising or spam. The account may be blocked if this continues.' }
|
|
53
53
|
: result.status === 429
|
|
54
|
-
? { code: 'rate_limited', message: 'Too many emails. Try again later.', display: '
|
|
54
|
+
? { code: 'rate_limited', message: 'Too many emails. Try again later.', display: 'Too many emails. Try again later.' }
|
|
55
55
|
: result.status === 400
|
|
56
|
-
? { code: 'rejected', message: 'The server rejected the email. Check the recipient, title and body.', display: '
|
|
56
|
+
? { code: 'rejected', message: 'The server rejected the email. Check the recipient, title and body.', display: 'The server rejected the email. Check the recipient, title and body.' }
|
|
57
57
|
: httpFailure(result.status);
|
|
58
58
|
}
|
|
59
59
|
if (failure) {
|
|
60
60
|
return pretty
|
|
61
|
-
? prettyResult(1, depth, command, rejected ? '
|
|
61
|
+
? prettyResult(1, depth, command, rejected ? 'The email was rejected.' : dryRun ? 'Could not validate the email.' : 'Could not send the email.', [['Server', siteUrl], ['Reason', failure.display]])
|
|
62
62
|
: agentResult(1, { command, siteUrl, delivered: false, ...(rejected ? { rejected } : {}), error: sendFailureError(result, failure) });
|
|
63
63
|
}
|
|
64
64
|
const { dryRun: checked, delivered, id, from, to, replyTo, bcc } = result.body;
|
|
65
65
|
if (!pretty) {
|
|
66
66
|
return agentResult(0, { command, siteUrl, ...(checked === true ? { dryRun: true } : {}), delivered, rejected, id, from, to, replyTo, bcc });
|
|
67
67
|
}
|
|
68
|
-
return prettyResult(0, depth, command, checked === true ? '
|
|
69
|
-
['
|
|
70
|
-
['
|
|
71
|
-
['
|
|
72
|
-
['
|
|
68
|
+
return prettyResult(0, depth, command, checked === true ? 'Validated the email. Nothing was sent.' : 'Sent the email.', [
|
|
69
|
+
['Server', siteUrl],
|
|
70
|
+
['From', from],
|
|
71
|
+
['To', to],
|
|
72
|
+
['Reply-To', replyTo]
|
|
73
73
|
]);
|
|
74
74
|
}
|
package/dist/commands/env.js
CHANGED
|
@@ -9,17 +9,17 @@ import { plannedChange, plannedRequest, splitDryRun } from "../runtime/dry-run.j
|
|
|
9
9
|
import { readEnv, sealEnv, validSeal } from "../runtime/env-file.js";
|
|
10
10
|
import { parseCommand } from "../runtime/flags.js";
|
|
11
11
|
import { PROJECT } from "../runtime/project-name.js";
|
|
12
|
-
import {
|
|
12
|
+
import { supportFailure, supportMessage } from "../runtime/support.js";
|
|
13
13
|
import { usageError } from "../runtime/usage-error.js";
|
|
14
14
|
export const ENV_FILE = '.env';
|
|
15
|
-
const NEXT_DEPLOY = '
|
|
16
|
-
const NAME_ERROR =
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const PROJECT_NOT_FOUND = { code: 'project_not_found', message:
|
|
21
|
-
const ENV_UNAVAILABLE = supportFailure('env_unavailable', { note:
|
|
22
|
-
const SEAL_KEY_CHANGED = { code: 'seal_key_changed', message:
|
|
15
|
+
const NEXT_DEPLOY = 'Changes apply to builds and the app server from the next deploy or rollback.';
|
|
16
|
+
const NAME_ERROR = 'The project name must be 1-63 lowercase letters, digits or hyphens that start and end with a letter or digit.';
|
|
17
|
+
const NOT_FOUND_MESSAGE = 'You have no project with that name. Check the name with deepdynamic projects.';
|
|
18
|
+
const SEAL_KEY_MESSAGE = 'The variables could not be saved. Run the same command again.';
|
|
19
|
+
const variableCount = (count) => `${count.toLocaleString('en-US')} environment variable${count === 1 ? '' : 's'}`;
|
|
20
|
+
const PROJECT_NOT_FOUND = { code: 'project_not_found', message: NOT_FOUND_MESSAGE, display: NOT_FOUND_MESSAGE };
|
|
21
|
+
const ENV_UNAVAILABLE = supportFailure('env_unavailable', { note: 'Nothing was sent.' });
|
|
22
|
+
const SEAL_KEY_CHANGED = { code: 'seal_key_changed', message: SEAL_KEY_MESSAGE, display: SEAL_KEY_MESSAGE };
|
|
23
23
|
const envUrl = (siteUrl, project, action = '') => new URL(`/api/v1/projects/${project}/env${action}`, siteUrl).href;
|
|
24
24
|
function envState(body, project) {
|
|
25
25
|
const value = body;
|
|
@@ -43,16 +43,16 @@ function failureOf(result) {
|
|
|
43
43
|
}
|
|
44
44
|
function failed(command, pretty, depth, siteUrl, project, message, failure) {
|
|
45
45
|
return pretty
|
|
46
|
-
? prettyResult(1, depth, command, message, [['
|
|
46
|
+
? prettyResult(1, depth, command, message, [['Server', siteUrl], ['Project', project], ['Reason', failure.display]])
|
|
47
47
|
: agentResult(1, { command, siteUrl, project, error: failureError(failure) });
|
|
48
48
|
}
|
|
49
49
|
function parseProject(command, names, max, pretty, depth) {
|
|
50
50
|
if (names.length < 1 || names.length > max) {
|
|
51
51
|
return usageError(command, max === 1
|
|
52
|
-
?
|
|
53
|
-
:
|
|
52
|
+
? 'Specify exactly one project name.'
|
|
53
|
+
: 'Specify the project name and at most one env file.', pretty, depth);
|
|
54
54
|
}
|
|
55
|
-
return PROJECT.test(names[0]) ? names[0] : usageError(command, NAME_ERROR
|
|
55
|
+
return PROJECT.test(names[0]) ? names[0] : usageError(command, NAME_ERROR, pretty, depth);
|
|
56
56
|
}
|
|
57
57
|
const getEnv = (session, project, deps, spinner) => request(envUrl(session.siteUrl, project), { method: 'GET', headers: { authorization: `Bearer ${session.token}` } }, deps, spinner);
|
|
58
58
|
async function readVars(command, path, pretty, depth) {
|
|
@@ -64,7 +64,7 @@ async function readVars(command, path, pretty, depth) {
|
|
|
64
64
|
const reason = error.code ?? String(error);
|
|
65
65
|
return {
|
|
66
66
|
result: pretty
|
|
67
|
-
? prettyResult(1, depth, command, '
|
|
67
|
+
? prettyResult(1, depth, command, 'Could not read the env file.', [['File', path], ['Reason', reason]])
|
|
68
68
|
: agentResult(1, { command, file: path, error: { code: 'env_file_unreadable', message: `Cannot read the env file (${reason}).` } })
|
|
69
69
|
};
|
|
70
70
|
}
|
|
@@ -73,14 +73,14 @@ async function readVars(command, path, pretty, depth) {
|
|
|
73
73
|
return read;
|
|
74
74
|
return {
|
|
75
75
|
result: pretty
|
|
76
|
-
? prettyResult(1, depth, command, '
|
|
77
|
-
: agentResult(1, { command, file: path, error: { code: 'invalid_env', message: read.error
|
|
76
|
+
? prettyResult(1, depth, command, 'Check the env file.', [['File', path], ['Reason', read.error]])
|
|
77
|
+
: agentResult(1, { command, file: path, error: { code: 'invalid_env', message: read.error } })
|
|
78
78
|
};
|
|
79
79
|
}
|
|
80
80
|
export async function runEnvPush(args, pretty, depth, deps = defaultAuthDeps(pretty, depth)) {
|
|
81
81
|
const command = 'projects env push';
|
|
82
82
|
const { args: rest, dryRun } = splitDryRun(args);
|
|
83
|
-
const parsed = parseCommand(rest, []
|
|
83
|
+
const parsed = parseCommand(rest, []);
|
|
84
84
|
if ('error' in parsed)
|
|
85
85
|
return usageError(command, parsed.error, pretty, depth);
|
|
86
86
|
const project = parseProject(command, parsed.names, 2, pretty, depth);
|
|
@@ -95,38 +95,38 @@ export async function runEnvPush(args, pretty, depth, deps = defaultAuthDeps(pre
|
|
|
95
95
|
const session = await signedIn(deps);
|
|
96
96
|
if ('login' in session)
|
|
97
97
|
return session.login;
|
|
98
|
-
return plannedChange(command, pretty, depth, session.siteUrl, { url: envUrl(session.siteUrl, project), body: { names } },
|
|
98
|
+
return plannedChange(command, pretty, depth, session.siteUrl, { url: envUrl(session.siteUrl, project), body: { names } }, `Checked ${variableCount(names.length)}. Nothing was sealed or sent.`, [['Project', project], ['File', file], ['Variables', names.join(', ')]], { project, file, names });
|
|
99
99
|
}
|
|
100
|
-
const sent = await authorized(deps, (session) => getEnv(session, project, deps, pretty ? '
|
|
100
|
+
const sent = await authorized(deps, (session) => getEnv(session, project, deps, pretty ? 'Preparing to save the environment variables.' : null));
|
|
101
101
|
if ('login' in sent)
|
|
102
102
|
return sent.login;
|
|
103
103
|
const { session } = sent;
|
|
104
104
|
const current = failureOf(sent.result) ? null : envState(sent.result.body, project);
|
|
105
105
|
const keyFailure = failureOf(sent.result) ?? (current ? current.seal ? null : ENV_UNAVAILABLE : UNEXPECTED);
|
|
106
106
|
if (keyFailure)
|
|
107
|
-
return failed(command, pretty, depth, session.siteUrl, project, '
|
|
107
|
+
return failed(command, pretty, depth, session.siteUrl, project, 'Could not save the environment variables.', keyFailure);
|
|
108
108
|
let sealed;
|
|
109
109
|
try {
|
|
110
110
|
sealed = sealEnv(read.vars, current.seal);
|
|
111
111
|
}
|
|
112
112
|
catch {
|
|
113
|
-
return failed(command, pretty, depth, session.siteUrl, project, '
|
|
113
|
+
return failed(command, pretty, depth, session.siteUrl, project, 'Could not save the environment variables.', UNEXPECTED);
|
|
114
114
|
}
|
|
115
|
-
const saved = await postJson(envUrl(session.siteUrl, project), session.token, { sealed, names }, deps, pretty ? '
|
|
115
|
+
const saved = await postJson(envUrl(session.siteUrl, project), session.token, { sealed, names }, deps, pretty ? 'Sealing and sending the environment variables.' : null);
|
|
116
116
|
const state = failureOf(saved) ? null : envState(saved.body, project);
|
|
117
117
|
const saveFailure = failureOf(saved) ?? (state ? null : UNEXPECTED);
|
|
118
118
|
if (saveFailure)
|
|
119
|
-
return failed(command, pretty, depth, session.siteUrl, project, '
|
|
119
|
+
return failed(command, pretty, depth, session.siteUrl, project, 'Could not save the environment variables.', saveFailure);
|
|
120
120
|
if (!pretty)
|
|
121
121
|
return agentResult(0, { command, siteUrl: session.siteUrl, project, file, names: state.names, updatedAt: state.updatedAt, appliesFrom: 'next_deploy' });
|
|
122
|
-
return prettyResult(0, depth, command,
|
|
123
|
-
['
|
|
122
|
+
return prettyResult(0, depth, command, `Sealed and saved ${variableCount(state.names.length)}. ${NEXT_DEPLOY}`, [
|
|
123
|
+
['Server', session.siteUrl], ['Project', project], ['File', file], ['Variables', state.names.join(', ')]
|
|
124
124
|
]);
|
|
125
125
|
}
|
|
126
126
|
export async function runEnvList(args, pretty, depth, deps = defaultAuthDeps(pretty, depth)) {
|
|
127
127
|
const command = 'projects env list';
|
|
128
128
|
const { args: rest, dryRun } = splitDryRun(args);
|
|
129
|
-
const parsed = parseCommand(rest, []
|
|
129
|
+
const parsed = parseCommand(rest, []);
|
|
130
130
|
if ('error' in parsed)
|
|
131
131
|
return usageError(command, parsed.error, pretty, depth);
|
|
132
132
|
const project = parseProject(command, parsed.names, 1, pretty, depth);
|
|
@@ -138,28 +138,28 @@ export async function runEnvList(args, pretty, depth, deps = defaultAuthDeps(pre
|
|
|
138
138
|
return session.login;
|
|
139
139
|
return plannedRequest(command, pretty, depth, session.siteUrl, envUrl(session.siteUrl, project));
|
|
140
140
|
}
|
|
141
|
-
const sent = await authorized(deps, (session) => getEnv(session, project, deps, pretty ? '
|
|
141
|
+
const sent = await authorized(deps, (session) => getEnv(session, project, deps, pretty ? 'Loading the environment variables.' : null));
|
|
142
142
|
if ('login' in sent)
|
|
143
143
|
return sent.login;
|
|
144
144
|
const { session, result } = sent;
|
|
145
145
|
const state = failureOf(result) ? null : envState(result.body, project);
|
|
146
146
|
const failure = failureOf(result) ?? (state ? null : UNEXPECTED);
|
|
147
147
|
if (failure)
|
|
148
|
-
return failed(command, pretty, depth, session.siteUrl, project, '
|
|
148
|
+
return failed(command, pretty, depth, session.siteUrl, project, 'Could not load the environment variables.', failure);
|
|
149
149
|
const { names, updatedAt, seal } = state;
|
|
150
150
|
if (!pretty)
|
|
151
151
|
return agentResult(0, { command, siteUrl: session.siteUrl, project, names, updatedAt, enabled: seal !== null });
|
|
152
|
-
return prettyResult(0, depth, command, names.length ?
|
|
153
|
-
['
|
|
154
|
-
...(names.length ? [['
|
|
155
|
-
...(seal ? [] : [['
|
|
152
|
+
return prettyResult(0, depth, command, names.length ? `Found ${variableCount(names.length)}. Only names are shown because not even the server can read the values.` : 'No environment variables are saved.', [
|
|
153
|
+
['Server', session.siteUrl], ['Project', project],
|
|
154
|
+
...(names.length ? [['Variables', names.join(', ')], ['Saved at', updatedAt ?? '']] : []),
|
|
155
|
+
...(seal ? [] : [['Notice', supportMessage('env_unavailable')]])
|
|
156
156
|
]);
|
|
157
157
|
}
|
|
158
158
|
export async function runEnvClear(args, pretty, depth, deps = defaultAuthDeps(pretty, depth)) {
|
|
159
159
|
const command = 'projects env clear';
|
|
160
160
|
const { args: plain, dryRun } = splitDryRun(args);
|
|
161
161
|
const { args: rest, yes } = splitYes(plain);
|
|
162
|
-
const parsed = parseCommand(rest, []
|
|
162
|
+
const parsed = parseCommand(rest, []);
|
|
163
163
|
if ('error' in parsed)
|
|
164
164
|
return usageError(command, parsed.error, pretty, depth);
|
|
165
165
|
const project = parseProject(command, parsed.names, 1, pretty, depth);
|
|
@@ -169,26 +169,26 @@ export async function runEnvClear(args, pretty, depth, deps = defaultAuthDeps(pr
|
|
|
169
169
|
const session = await signedIn(deps);
|
|
170
170
|
if ('login' in session)
|
|
171
171
|
return session.login;
|
|
172
|
-
return plannedChange(command, pretty, depth, session.siteUrl, { url: envUrl(session.siteUrl, project, '/clear') }, '
|
|
172
|
+
return plannedChange(command, pretty, depth, session.siteUrl, { url: envUrl(session.siteUrl, project, '/clear') }, 'Checked clearing the environment variables. Nothing was cleared.', [['Project', project]], { project });
|
|
173
173
|
}
|
|
174
174
|
if (!yes) {
|
|
175
175
|
return confirmationRequired(command, plain, pretty, depth, {
|
|
176
176
|
message: 'Clearing removes every stored environment variable of the project; the next deploy builds and runs without them.',
|
|
177
|
-
display: '
|
|
177
|
+
display: 'Clearing removes every saved environment variable; the next deploy builds and runs without them. Confirm with the user, then run the command with --yes.'
|
|
178
178
|
}, { project });
|
|
179
179
|
}
|
|
180
180
|
const sent = await authorized(deps, (session) => request(envUrl(session.siteUrl, project, '/clear'), {
|
|
181
181
|
method: 'POST', headers: { authorization: `Bearer ${session.token}` }
|
|
182
|
-
}, deps, pretty ? '
|
|
182
|
+
}, deps, pretty ? 'Clearing the environment variables.' : null));
|
|
183
183
|
if ('login' in sent)
|
|
184
184
|
return sent.login;
|
|
185
185
|
const { session, result } = sent;
|
|
186
186
|
const value = failureOf(result) ? null : result.body;
|
|
187
187
|
const failure = failureOf(result) ?? (value?.ok === true && value.project === project && typeof value.cleared === 'boolean' ? null : UNEXPECTED);
|
|
188
188
|
if (failure)
|
|
189
|
-
return failed(command, pretty, depth, session.siteUrl, project, '
|
|
189
|
+
return failed(command, pretty, depth, session.siteUrl, project, 'Could not clear the environment variables.', failure);
|
|
190
190
|
const cleared = value.cleared;
|
|
191
191
|
if (!pretty)
|
|
192
192
|
return agentResult(0, { command, siteUrl: session.siteUrl, project, cleared, appliesFrom: 'next_deploy' });
|
|
193
|
-
return prettyResult(0, depth, command, cleared ?
|
|
193
|
+
return prettyResult(0, depth, command, cleared ? `Cleared all saved environment variables. ${NEXT_DEPLOY}` : 'There were no environment variables to clear.', [['Server', session.siteUrl], ['Project', project]]);
|
|
194
194
|
}
|
package/dist/commands/help.js
CHANGED
|
@@ -8,22 +8,21 @@ import { usageError } from "../runtime/usage-error.js";
|
|
|
8
8
|
import { LOGIN_TIMEOUT_MS } from "./login/flow.js";
|
|
9
9
|
import { HELP_USAGE, details } from "./reference.js";
|
|
10
10
|
export const CLI_USAGE = 'deepdynamic [--pretty] [--login-timeout <seconds>] <command> [options]';
|
|
11
|
-
export const CLI_PRETTY_USAGE = 'deepdynamic [--pretty] [--login-timeout <초>] <명령> [옵션]';
|
|
12
11
|
const options = [
|
|
13
|
-
['-h, --help', '
|
|
14
|
-
['-v, --version', '
|
|
15
|
-
[' --pretty', '
|
|
16
|
-
[' --login-timeout',
|
|
12
|
+
['-h, --help', 'Show help'],
|
|
13
|
+
['-v, --version', 'Show the CLI version'],
|
|
14
|
+
[' --pretty', 'Show human-readable output instead of JSON'],
|
|
15
|
+
[' --login-timeout', `Seconds to wait for the login window, 1-${LOGIN_TIMEOUT_MS / 1000} (default ${LOGIN_TIMEOUT_MS / 1000})`]
|
|
17
16
|
];
|
|
18
17
|
const docs = [
|
|
19
|
-
['
|
|
20
|
-
['
|
|
18
|
+
['Agents', `${SITE_URL}/llms.txt`],
|
|
19
|
+
['Developers', `${SITE_URL}/docs/dev`],
|
|
21
20
|
['CLI', `${SITE_URL}/cli.md`]
|
|
22
21
|
];
|
|
23
22
|
export function runHelp(args, version, depth, pretty) {
|
|
24
23
|
const rest = args.filter((arg) => arg !== '--all');
|
|
25
24
|
if (rest.length) {
|
|
26
|
-
return usageError('help', unknownArgument(rest[0]
|
|
25
|
+
return usageError('help', unknownArgument(rest[0]), pretty, depth);
|
|
27
26
|
}
|
|
28
27
|
if (args.length)
|
|
29
28
|
return runCommands([], version, depth, pretty);
|
|
@@ -60,10 +59,10 @@ export function commandTree() {
|
|
|
60
59
|
export function runCommands(args, version, depth, pretty) {
|
|
61
60
|
const command = 'commands';
|
|
62
61
|
if (args.length)
|
|
63
|
-
return usageError(command, unknownArgument(args[0]
|
|
62
|
+
return usageError(command, unknownArgument(args[0]), pretty, depth);
|
|
64
63
|
if (!pretty)
|
|
65
64
|
return agentResult(0, { command, version, commands: commandTree() });
|
|
66
|
-
return prettyResult(0, depth, command, '
|
|
65
|
+
return prettyResult(0, depth, command, 'Listed all commands.', commands.map(({ name, summary }) => [`deepdynamic ${name}`, summary]));
|
|
67
66
|
}
|
|
68
67
|
export function runCommandHelp(args, pretty, depth) {
|
|
69
68
|
const length = args.findIndex((arg) => arg === '-h' || arg === '--help');
|
|
@@ -90,7 +89,7 @@ export function runCommandHelp(args, pretty, depth) {
|
|
|
90
89
|
});
|
|
91
90
|
}
|
|
92
91
|
const stdout = entries
|
|
93
|
-
.map((entry) => prettyResult(0, depth, entry.name, '
|
|
92
|
+
.map((entry) => prettyResult(0, depth, entry.name, 'Showed the help.', [['Usage', entry.usage], ...details[entry.name].prettyOptions]).stdout)
|
|
94
93
|
.join('');
|
|
95
94
|
return { code: 0, stdout, stderr: '' };
|
|
96
95
|
}
|
|
@@ -114,7 +113,7 @@ export function agentHome(version) {
|
|
|
114
113
|
options: [
|
|
115
114
|
{ flags: ['-h', '--help'], description: 'Show help.' },
|
|
116
115
|
{ flags: ['-v', '--version'], description: 'Show the CLI version.' },
|
|
117
|
-
{ flags: ['--pretty'], description: 'Use the human-readable
|
|
116
|
+
{ flags: ['--pretty'], description: 'Use the human-readable interface instead of JSON.' },
|
|
118
117
|
{
|
|
119
118
|
flags: [LOGIN_TIMEOUT_OPTION],
|
|
120
119
|
description: `Seconds to wait for the browser sign-in window, 1-${LOGIN_TIMEOUT_MS / 1000} (default ${LOGIN_TIMEOUT_MS / 1000}). The window still opens. When the seconds run out the command fails with login_timeout and that window can no longer sign in. Set it below the time limit of your shell.`
|
|
@@ -126,23 +125,23 @@ export function agentHome(version) {
|
|
|
126
125
|
}
|
|
127
126
|
export function renderHome(depth) {
|
|
128
127
|
const { bold } = paint(depth);
|
|
129
|
-
const lines = commands.map(({
|
|
128
|
+
const lines = commands.map(({ usage, summary }) => [requiredUsage(usage), summary]);
|
|
130
129
|
const labels = [...lines.map(([label]) => label), ...[...options, ...docs].map(([label]) => label)];
|
|
131
130
|
const labelWidth = Math.max(...labels.map(displayWidth));
|
|
132
131
|
const item = (label, text) => ` ${pad(label, labelWidth)} ${text}`;
|
|
133
132
|
return [
|
|
134
|
-
'
|
|
133
|
+
'The official CLI for deploying static and dynamic sites to DeepDynamic Cloud.',
|
|
135
134
|
'',
|
|
136
|
-
bold('
|
|
137
|
-
' deepdynamic
|
|
135
|
+
bold('Usage'),
|
|
136
|
+
' deepdynamic <command> [options]',
|
|
138
137
|
'',
|
|
139
|
-
bold('
|
|
138
|
+
bold('Commands'),
|
|
140
139
|
...lines.map(([label, summary]) => item(label, summary)),
|
|
141
140
|
'',
|
|
142
|
-
bold('
|
|
141
|
+
bold('Options'),
|
|
143
142
|
...options.map(([label, text]) => item(label, text)),
|
|
144
143
|
'',
|
|
145
|
-
bold('
|
|
144
|
+
bold('Docs'),
|
|
146
145
|
...docs.map(([label, url]) => item(label, url)),
|
|
147
146
|
''
|
|
148
147
|
].join('\n');
|