@deepdynamic/cli 0.0.0-stage → 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/LICENSE +201 -0
- package/README.md +32 -2
- package/THIRD_PARTY_NOTICES.txt +102 -0
- package/dist/agents/content.js +12 -0
- package/dist/agents/edit.js +140 -0
- package/dist/agents/install.js +190 -0
- package/dist/agents/refresh.js +20 -0
- package/dist/agents/setup.js +29 -0
- package/dist/agents/targets.js +91 -0
- package/dist/auth/credentials.js +63 -0
- package/dist/auth/session.js +49 -0
- package/dist/cli.js +198 -0
- package/dist/commands/account.js +96 -0
- package/dist/commands/activity.js +80 -0
- package/dist/commands/blocked.js +89 -0
- package/dist/commands/deploy/agents.js +11 -0
- package/dist/commands/deploy/files.js +62 -0
- package/dist/commands/deploy/index.js +95 -0
- package/dist/commands/deploy/manifest.js +24 -0
- package/dist/commands/deploy/minify.js +27 -0
- package/dist/commands/deploy/progress.js +85 -0
- package/dist/commands/deploy/ship.js +117 -0
- package/dist/commands/deploy/upload.js +125 -0
- package/dist/commands/deployments.js +60 -0
- package/dist/commands/dns.js +777 -0
- package/dist/commands/domains.js +639 -0
- package/dist/commands/emails.js +74 -0
- package/dist/commands/env.js +194 -0
- package/dist/commands/help.js +148 -0
- package/dist/commands/keys.js +263 -0
- package/dist/commands/login/flow.js +155 -0
- package/dist/commands/login/index.js +26 -0
- package/dist/commands/logout.js +71 -0
- package/dist/commands/mail.js +241 -0
- package/dist/commands/notifications.js +133 -0
- package/dist/commands/plan.js +355 -0
- package/dist/commands/projects.js +838 -0
- package/dist/commands/reference.js +2187 -0
- package/dist/commands/search.js +86 -0
- package/dist/commands/server.js +301 -0
- package/dist/commands/sessions.js +114 -0
- package/dist/commands/sites.js +102 -0
- package/dist/commands/sms.js +65 -0
- package/dist/commands/status.js +87 -0
- package/dist/commands/support.js +115 -0
- package/dist/commands/update.js +100 -0
- package/dist/commands/usage.js +51 -0
- package/dist/commands/verify.js +149 -0
- package/dist/commands/version.js +6 -0
- package/dist/guide.js +37 -0
- package/dist/http/call.js +6 -0
- package/dist/http/request.js +54 -0
- package/dist/index.js +11 -0
- package/dist/metadata.js +4 -0
- package/dist/output.js +9 -0
- package/dist/pretty.js +70 -0
- package/dist/refresh-skills.js +5 -0
- package/dist/registry.js +688 -0
- package/dist/runtime/browser.js +15 -0
- package/dist/runtime/card-request.js +55 -0
- package/dist/runtime/confirm.js +21 -0
- package/dist/runtime/development.js +13 -0
- package/dist/runtime/domain-name.js +5 -0
- package/dist/runtime/dry-run.js +28 -0
- package/dist/runtime/env-file.js +55 -0
- package/dist/runtime/error-hints.js +26 -0
- package/dist/runtime/flags.js +48 -0
- package/dist/runtime/login-screen.js +78 -0
- package/dist/runtime/page.js +18 -0
- package/dist/runtime/project-name.js +1 -0
- package/dist/runtime/run-mode.js +7 -0
- package/dist/runtime/server-options.js +28 -0
- package/dist/runtime/spinner.js +17 -0
- package/dist/runtime/suggest.js +22 -0
- package/dist/runtime/support.js +13 -0
- package/dist/runtime/text-file.js +20 -0
- package/dist/runtime/timeout.js +22 -0
- package/dist/runtime/update-check.js +158 -0
- package/dist/runtime/update-install.js +80 -0
- package/dist/runtime/usage-error.js +9 -0
- package/dist/setup-agents.js +15 -0
- package/dist/site.js +1 -0
- package/dist/update-refresh.js +5 -0
- package/package.json +46 -3
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { startSpinner } from "../runtime/spinner.js";
|
|
2
|
+
import { supportFailure } from "../runtime/support.js";
|
|
3
|
+
import { call } from "./call.js";
|
|
4
|
+
export const REQUEST_TIMEOUT_MS = 20_000;
|
|
5
|
+
export const defaultDeps = () => ({ fetch, stream: process.stderr, timeoutMs: REQUEST_TIMEOUT_MS });
|
|
6
|
+
export class LoginExpiredError extends Error {
|
|
7
|
+
}
|
|
8
|
+
export const LOGIN_EXPIRED = {
|
|
9
|
+
code: 'login_required',
|
|
10
|
+
message: 'The access token is invalid or expired. Run deepdynamic login again.',
|
|
11
|
+
display: 'Your login has expired. Run deepdynamic login to log in again.'
|
|
12
|
+
};
|
|
13
|
+
export const UNEXPECTED = supportFailure('unexpected_response');
|
|
14
|
+
export function httpFailure(status) {
|
|
15
|
+
return supportFailure('http_error', { retryable: status >= 500 || status === 429 });
|
|
16
|
+
}
|
|
17
|
+
export function failureError({ code, message, retryable }) {
|
|
18
|
+
return { code, message, ...(retryable === undefined ? {} : { retryable }) };
|
|
19
|
+
}
|
|
20
|
+
export function sendFailureError(result, failure) {
|
|
21
|
+
const reached = 'failure' in result ? failure.code === 'connection_timeout' : result.status >= 500;
|
|
22
|
+
return { ...failureError(failure), ...(reached ? { retryable: false } : {}) };
|
|
23
|
+
}
|
|
24
|
+
export const readJson = (response) => response.json().catch(() => null);
|
|
25
|
+
export async function request(url, init, deps, spinner, read = readJson) {
|
|
26
|
+
const stop = spinner ? startSpinner(spinner, deps.stream) : () => { };
|
|
27
|
+
const controller = new AbortController();
|
|
28
|
+
const timer = setTimeout(() => controller.abort(), deps.timeoutMs);
|
|
29
|
+
try {
|
|
30
|
+
const response = await call(url, { ...init, redirect: 'manual', signal: controller.signal }, deps.fetch);
|
|
31
|
+
const body = await read(response);
|
|
32
|
+
return { status: response.status, body };
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
const failure = controller.signal.aborted
|
|
36
|
+
? { code: 'connection_timeout', message: 'The connection timed out.', display: 'The server did not respond in time.' }
|
|
37
|
+
: { code: 'connection_failed', message: 'Could not connect to the server.', display: 'Check the server URL and your network connection.' };
|
|
38
|
+
return { failure };
|
|
39
|
+
}
|
|
40
|
+
finally {
|
|
41
|
+
clearTimeout(timer);
|
|
42
|
+
stop();
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
export function postJson(url, token, payload, deps, spinner) {
|
|
46
|
+
return request(url, {
|
|
47
|
+
method: 'POST',
|
|
48
|
+
headers: { authorization: `Bearer ${token}`, 'content-type': 'application/json' },
|
|
49
|
+
body: JSON.stringify(payload)
|
|
50
|
+
}, deps, spinner);
|
|
51
|
+
}
|
|
52
|
+
export function accepted({ status, body }) {
|
|
53
|
+
return status === 200 && body?.ok === true;
|
|
54
|
+
}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { run } from "./cli.js";
|
|
3
|
+
import { version } from "./metadata.js";
|
|
4
|
+
import { colorDepth } from "./output.js";
|
|
5
|
+
import { pendingUpdate } from "./runtime/update-check.js";
|
|
6
|
+
process.once('SIGINT', () => process.exit(0));
|
|
7
|
+
const update = await pendingUpdate(version).catch(() => null);
|
|
8
|
+
const result = await run(process.argv.slice(2), version, colorDepth(process.stdout), undefined, update);
|
|
9
|
+
process.stdout.write(result.stdout);
|
|
10
|
+
process.stderr.write(result.stderr);
|
|
11
|
+
process.exitCode = result.code;
|
package/dist/metadata.js
ADDED
package/dist/output.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { errorHints } from "./runtime/error-hints.js";
|
|
2
|
+
export function colorDepth(stream) {
|
|
3
|
+
return stream.isTTY ? stream.getColorDepth() : 1;
|
|
4
|
+
}
|
|
5
|
+
const UNESCAPED = /[\u007f-\u009f\u2028\u2029]/g;
|
|
6
|
+
export const jsonLine = (value) => `${JSON.stringify(value).replace(UNESCAPED, (char) => `\\u${char.charCodeAt(0).toString(16).padStart(4, '0')}`)}\n`;
|
|
7
|
+
export function agentResult(code, data) {
|
|
8
|
+
return { code, stdout: jsonLine({ ok: code === 0, ...data, ...(data.error ? errorHints(data) : {}) }), stderr: '' };
|
|
9
|
+
}
|
package/dist/pretty.js
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { commands } from "./registry.js";
|
|
2
|
+
import { optionSuggestion } from "./runtime/flags.js";
|
|
3
|
+
const WIDE = /[ᄀ-ᅟ-가-힣]/;
|
|
4
|
+
const ESCAPES = /\x1b\[[\d;]*m|\x1b\]8;[^\x1b]*\x1b\\/g;
|
|
5
|
+
export const CONTROL = /[\x00-\x1f\x7f-\x9f\p{Bidi_C}\u200b\u2028\u2029\ufeff]/gu;
|
|
6
|
+
export class Styled {
|
|
7
|
+
text;
|
|
8
|
+
constructor(text) {
|
|
9
|
+
this.text = text;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
export const plain = (text) => text.replace(CONTROL, ' ');
|
|
13
|
+
const shown = (value) => (value instanceof Styled ? value.text : plain(value));
|
|
14
|
+
export function displayWidth(text) {
|
|
15
|
+
return [...text.replace(ESCAPES, '')].reduce((width, char) => width + (WIDE.test(char) ? 2 : 1), 0);
|
|
16
|
+
}
|
|
17
|
+
export function pad(text, width) {
|
|
18
|
+
return text + ' '.repeat(width - displayWidth(text));
|
|
19
|
+
}
|
|
20
|
+
export function paint(depth) {
|
|
21
|
+
const style = (codes) => (text) => (depth > 1 ? `\x1b[${codes}m${text}\x1b[0m` : text);
|
|
22
|
+
const tone = (truecolor, ansi256, ansi16) => (depth >= 24 ? truecolor : depth >= 8 ? ansi256 : ansi16);
|
|
23
|
+
const badge = (codes) => (text) => (depth > 1 ? style(codes)(` ${text} `) : `[${text}]`);
|
|
24
|
+
return {
|
|
25
|
+
bold: style('1'),
|
|
26
|
+
dim: style('2'),
|
|
27
|
+
rail: style('90'),
|
|
28
|
+
accent: style(tone('38;2;182;245;60', '38;5;155', '92')),
|
|
29
|
+
brand: style(`1;${tone('48;2;182;245;60;38;2;14;15;19', '48;5;155;38;5;16', '102;30')}`),
|
|
30
|
+
success: badge('42;30'),
|
|
31
|
+
error: badge('41;97')
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
const WORDMARK = [
|
|
35
|
+
' █▀▄ █▀▀ █▀▀ █▀█ █▀▄ █▄█ █▄░█ ▄▀█ █▀▄▀█ █ █▀▀ █▀▀ █▀█ █▀█ ▄▀█ █ ',
|
|
36
|
+
' █▄▀ ██▄ ██▄ █▀▀ █▄▀ ░█░ █░▀█ █▀█ █░▀░█ █ █▄▄ █▀░ █▄█ █▀▄ █▀█ █ '
|
|
37
|
+
];
|
|
38
|
+
export function renderWordmark(depth) {
|
|
39
|
+
const { bold, accent } = paint(depth);
|
|
40
|
+
const width = WORDMARK[0].length;
|
|
41
|
+
return [accent('▄'.repeat(width)), ...WORDMARK.map(bold), accent('▀'.repeat(width)), '', ''].join('\n');
|
|
42
|
+
}
|
|
43
|
+
export function renderBanner(version, depth, email, update = null) {
|
|
44
|
+
const { bold, dim, accent, brand } = paint(depth);
|
|
45
|
+
const lines = [
|
|
46
|
+
`${depth > 1 ? `${brand(' DD ')} ` : ''}${bold('DeepDynamic Cloud CLI')} ${dim(version)}`,
|
|
47
|
+
...(email ? [`${dim('Accounts :')} ${plain(email)}`] : []),
|
|
48
|
+
...(update?.event === 'update_available' ? [`${dim('Update :')} New version ${accent(plain(update.latest))} ${dim('· deepdynamic update')}`] : []),
|
|
49
|
+
...(update?.event === 'updated' ? [`${dim('Update :')} Updated ${plain(update.previous)} → ${accent(plain(version))}`] : [])
|
|
50
|
+
];
|
|
51
|
+
return [...lines, accent('─'.repeat(Math.max(...lines.map(displayWidth)))), ''].join('\n');
|
|
52
|
+
}
|
|
53
|
+
export function prettyResult(code, depth, command, message, details = []) {
|
|
54
|
+
const { bold, dim, rail, success, error } = paint(depth);
|
|
55
|
+
const summary = commands.find(({ name }) => name === command)?.summary;
|
|
56
|
+
const usage = details.find(([label]) => label === 'Usage')?.[1];
|
|
57
|
+
const suggestion = code === 2 && typeof usage === 'string' ? optionSuggestion(message, usage) : null;
|
|
58
|
+
if (suggestion)
|
|
59
|
+
details = [...details, ['Did you mean', suggestion]];
|
|
60
|
+
const rows = details.map(([label, value]) => [label === null ? null : plain(label), shown(value)]);
|
|
61
|
+
const labelWidth = Math.max(0, ...rows.map(([label]) => label === null ? 0 : displayWidth(label)));
|
|
62
|
+
const section = [
|
|
63
|
+
`${rail('╭')} ${bold(`deepdynamic ${command}`)}${summary ? ` ${dim(summary)}` : ''}`,
|
|
64
|
+
...rows.map(([label, value]) => label === null ? `${rail('│')}${value ? ` ${value}` : ''}` : `${rail('│')} ${dim(pad(label, labelWidth))} ${value}`),
|
|
65
|
+
rail('│'),
|
|
66
|
+
`${rail('╰')} ${code === 0 ? success('SUCCESS') : error('ERROR')} ${plain(message)}`,
|
|
67
|
+
''
|
|
68
|
+
].join('\n');
|
|
69
|
+
return code === 0 ? { code, stdout: section, stderr: '' } : { code, stdout: '', stderr: section };
|
|
70
|
+
}
|