@tarout/cli 0.2.0 → 0.2.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/README.md +62 -18
- package/dist/api-735LN7BA.js +11 -0
- package/dist/billing-WOKNOS4N.js +11 -0
- package/dist/chunk-5XBVQICT.js +996 -0
- package/dist/chunk-7YS2WBLB.js +669 -0
- package/dist/chunk-CJMIX35A.js +127 -0
- package/dist/chunk-KL3JNPAY.js +203 -0
- package/dist/index.js +17849 -3317
- package/dist/{prompts-B53LIJLG.js → prompts-QQ2FZKQT.js} +4 -1
- package/package.json +3 -3
- package/dist/chunk-GSKD67K4.js +0 -41
- package/dist/chunk-VO4OYJW3.js +0 -53
- package/dist/spinner-2NALE2OE.js +0 -14
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ExitCode,
|
|
3
|
+
exit,
|
|
4
|
+
isJsonMode,
|
|
5
|
+
isNonInteractiveMode,
|
|
6
|
+
outputNeedsInput
|
|
7
|
+
} from "./chunk-KL3JNPAY.js";
|
|
8
|
+
|
|
9
|
+
// src/utils/prompts.ts
|
|
10
|
+
import inquirer from "inquirer";
|
|
11
|
+
function emitNeedsInputAndExit(descriptor, rest) {
|
|
12
|
+
outputNeedsInput({ ...descriptor, ...rest });
|
|
13
|
+
exit(ExitCode.NEEDS_INPUT);
|
|
14
|
+
}
|
|
15
|
+
function shouldEmitNeedsInput() {
|
|
16
|
+
return isJsonMode() || isNonInteractiveMode();
|
|
17
|
+
}
|
|
18
|
+
function emitUnannotatedPromptError(kind, question) {
|
|
19
|
+
outputNeedsInput({
|
|
20
|
+
field: "unannotated_prompt",
|
|
21
|
+
kind,
|
|
22
|
+
question,
|
|
23
|
+
flag: "--yes",
|
|
24
|
+
context: {
|
|
25
|
+
hint: "This prompt site does not yet expose a CLI flag. Re-invoke with --yes (for confirms) or provide the value as a positional/flag argument, or file an issue to ask for explicit flag support for this command."
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
exit(ExitCode.NEEDS_INPUT);
|
|
29
|
+
}
|
|
30
|
+
async function confirm(message, defaultValue = false, descriptor) {
|
|
31
|
+
if (descriptor && shouldEmitNeedsInput()) {
|
|
32
|
+
emitNeedsInputAndExit(descriptor, {
|
|
33
|
+
kind: "confirm",
|
|
34
|
+
question: message,
|
|
35
|
+
default: defaultValue
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
if (!descriptor && shouldEmitNeedsInput()) {
|
|
39
|
+
emitUnannotatedPromptError("confirm", message);
|
|
40
|
+
}
|
|
41
|
+
const { confirmed } = await inquirer.prompt([
|
|
42
|
+
{
|
|
43
|
+
type: "confirm",
|
|
44
|
+
name: "confirmed",
|
|
45
|
+
message,
|
|
46
|
+
default: defaultValue
|
|
47
|
+
}
|
|
48
|
+
]);
|
|
49
|
+
return confirmed;
|
|
50
|
+
}
|
|
51
|
+
async function input(message, defaultValue, descriptor) {
|
|
52
|
+
if (descriptor && shouldEmitNeedsInput()) {
|
|
53
|
+
emitNeedsInputAndExit(descriptor, {
|
|
54
|
+
kind: "input",
|
|
55
|
+
question: message,
|
|
56
|
+
default: defaultValue
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
if (!descriptor && shouldEmitNeedsInput()) {
|
|
60
|
+
emitUnannotatedPromptError("input", message);
|
|
61
|
+
}
|
|
62
|
+
const { value } = await inquirer.prompt([
|
|
63
|
+
{
|
|
64
|
+
type: "input",
|
|
65
|
+
name: "value",
|
|
66
|
+
message,
|
|
67
|
+
default: defaultValue
|
|
68
|
+
}
|
|
69
|
+
]);
|
|
70
|
+
return value;
|
|
71
|
+
}
|
|
72
|
+
async function select(message, choices, descriptor) {
|
|
73
|
+
if (descriptor && shouldEmitNeedsInput()) {
|
|
74
|
+
emitNeedsInputAndExit(descriptor, {
|
|
75
|
+
kind: "select",
|
|
76
|
+
question: message,
|
|
77
|
+
choices: choices.map((c) => ({ label: c.name, value: c.value }))
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
if (!descriptor && shouldEmitNeedsInput()) {
|
|
81
|
+
emitUnannotatedPromptError("select", message);
|
|
82
|
+
}
|
|
83
|
+
const { value } = await inquirer.prompt([
|
|
84
|
+
{
|
|
85
|
+
type: "list",
|
|
86
|
+
name: "value",
|
|
87
|
+
message,
|
|
88
|
+
choices
|
|
89
|
+
}
|
|
90
|
+
]);
|
|
91
|
+
return value;
|
|
92
|
+
}
|
|
93
|
+
async function password(message, descriptor) {
|
|
94
|
+
if (descriptor && shouldEmitNeedsInput()) {
|
|
95
|
+
emitNeedsInputAndExit(
|
|
96
|
+
{ ...descriptor, sensitive: true },
|
|
97
|
+
{ kind: "password", question: message }
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
if (!descriptor && shouldEmitNeedsInput()) {
|
|
101
|
+
emitUnannotatedPromptError("password", message);
|
|
102
|
+
}
|
|
103
|
+
const { value } = await inquirer.prompt([
|
|
104
|
+
{
|
|
105
|
+
type: "password",
|
|
106
|
+
name: "value",
|
|
107
|
+
message,
|
|
108
|
+
mask: "*"
|
|
109
|
+
}
|
|
110
|
+
]);
|
|
111
|
+
return value;
|
|
112
|
+
}
|
|
113
|
+
async function promptOrEmit(req, fallback) {
|
|
114
|
+
if (shouldEmitNeedsInput()) {
|
|
115
|
+
outputNeedsInput(req);
|
|
116
|
+
exit(ExitCode.NEEDS_INPUT);
|
|
117
|
+
}
|
|
118
|
+
return fallback();
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export {
|
|
122
|
+
confirm,
|
|
123
|
+
input,
|
|
124
|
+
select,
|
|
125
|
+
password,
|
|
126
|
+
promptOrEmit
|
|
127
|
+
};
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
// src/utils/exit-codes.ts
|
|
2
|
+
var ExitCode = {
|
|
3
|
+
SUCCESS: 0,
|
|
4
|
+
GENERAL_ERROR: 1,
|
|
5
|
+
INVALID_ARGUMENTS: 2,
|
|
6
|
+
AUTH_ERROR: 3,
|
|
7
|
+
NOT_FOUND: 4,
|
|
8
|
+
PERMISSION_DENIED: 5,
|
|
9
|
+
// External agent must collect a value and re-invoke. Pairs with a
|
|
10
|
+
// `needs_input` JSON event on stdout. Distinct from INVALID_ARGUMENTS so
|
|
11
|
+
// the agent doesn't treat a missing-input case as a malformed call.
|
|
12
|
+
NEEDS_INPUT: 6,
|
|
13
|
+
// Deployment-specific exit codes
|
|
14
|
+
DEPLOYMENT_FAILED: 10,
|
|
15
|
+
DEPLOYMENT_TIMEOUT: 11,
|
|
16
|
+
BUILD_FAILED: 12
|
|
17
|
+
};
|
|
18
|
+
function exit(code) {
|
|
19
|
+
process.exit(code);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// src/lib/output.ts
|
|
23
|
+
import chalk from "chalk";
|
|
24
|
+
import Table from "cli-table3";
|
|
25
|
+
|
|
26
|
+
// src/utils/json.ts
|
|
27
|
+
function jsonSuccess(data, meta) {
|
|
28
|
+
return {
|
|
29
|
+
success: true,
|
|
30
|
+
data,
|
|
31
|
+
...meta && { meta }
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
function jsonError(code, message, suggestions, details) {
|
|
35
|
+
return {
|
|
36
|
+
success: false,
|
|
37
|
+
error: {
|
|
38
|
+
code,
|
|
39
|
+
message,
|
|
40
|
+
...suggestions && { suggestions },
|
|
41
|
+
...details !== void 0 && { details }
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
function outputJson(response) {
|
|
46
|
+
console.log(JSON.stringify(response));
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// src/lib/output.ts
|
|
50
|
+
var globalOptions = {
|
|
51
|
+
json: false,
|
|
52
|
+
quiet: false,
|
|
53
|
+
verbose: false,
|
|
54
|
+
noColor: false,
|
|
55
|
+
yes: false,
|
|
56
|
+
nonInteractive: false
|
|
57
|
+
};
|
|
58
|
+
function setGlobalOptions(options) {
|
|
59
|
+
globalOptions = { ...globalOptions, ...options };
|
|
60
|
+
}
|
|
61
|
+
function isJsonMode() {
|
|
62
|
+
return globalOptions.json;
|
|
63
|
+
}
|
|
64
|
+
function shouldSkipConfirmation() {
|
|
65
|
+
return globalOptions.yes;
|
|
66
|
+
}
|
|
67
|
+
function isNonInteractiveMode() {
|
|
68
|
+
return globalOptions.nonInteractive;
|
|
69
|
+
}
|
|
70
|
+
function c(colorFn, str) {
|
|
71
|
+
return globalOptions.noColor ? str : colorFn(str);
|
|
72
|
+
}
|
|
73
|
+
var colors = {
|
|
74
|
+
success: (str) => c(chalk.green, str),
|
|
75
|
+
error: (str) => c(chalk.red, str),
|
|
76
|
+
warn: (str) => c(chalk.yellow, str),
|
|
77
|
+
info: (str) => c(chalk.blue, str),
|
|
78
|
+
dim: (str) => c(chalk.dim, str),
|
|
79
|
+
bold: (str) => c(chalk.bold, str),
|
|
80
|
+
cyan: (str) => c(chalk.cyan, str)
|
|
81
|
+
};
|
|
82
|
+
function getStatusBadge(status) {
|
|
83
|
+
const badges = {
|
|
84
|
+
running: colors.success("\u25CF running"),
|
|
85
|
+
idle: colors.warn("\u25CB idle"),
|
|
86
|
+
error: colors.error("\u2717 error"),
|
|
87
|
+
done: colors.success("\u2713 done"),
|
|
88
|
+
deploying: colors.info("\u25D0 deploying"),
|
|
89
|
+
stopped: colors.dim("\u25CB stopped"),
|
|
90
|
+
cancelled: colors.warn("\u25CB cancelled")
|
|
91
|
+
};
|
|
92
|
+
return badges[status.toLowerCase()] || status;
|
|
93
|
+
}
|
|
94
|
+
function log(message) {
|
|
95
|
+
if (!globalOptions.quiet && !globalOptions.json) {
|
|
96
|
+
console.log(message);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
function success(message) {
|
|
100
|
+
if (!globalOptions.quiet && !globalOptions.json) {
|
|
101
|
+
console.log(colors.success(`\u2713 ${message}`));
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
function error(message, suggestions) {
|
|
105
|
+
if (globalOptions.json) {
|
|
106
|
+
outputJson(jsonError("ERROR", message, suggestions));
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
console.error(colors.error(`Error: ${message}`));
|
|
110
|
+
if (suggestions && suggestions.length > 0) {
|
|
111
|
+
console.error("");
|
|
112
|
+
console.error("Did you mean one of these?");
|
|
113
|
+
for (const suggestion of suggestions) {
|
|
114
|
+
console.error(colors.dim(` - ${suggestion}`));
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
function table(headers, rows) {
|
|
119
|
+
if (globalOptions.json) {
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
const t = new Table({
|
|
123
|
+
head: headers.map((h) => colors.bold(h)),
|
|
124
|
+
style: { head: [], border: [] },
|
|
125
|
+
chars: {
|
|
126
|
+
top: "",
|
|
127
|
+
"top-mid": "",
|
|
128
|
+
"top-left": "",
|
|
129
|
+
"top-right": "",
|
|
130
|
+
bottom: "",
|
|
131
|
+
"bottom-mid": "",
|
|
132
|
+
"bottom-left": "",
|
|
133
|
+
"bottom-right": "",
|
|
134
|
+
left: " ",
|
|
135
|
+
"left-mid": "",
|
|
136
|
+
mid: "",
|
|
137
|
+
"mid-mid": "",
|
|
138
|
+
right: "",
|
|
139
|
+
"right-mid": "",
|
|
140
|
+
middle: " "
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
for (const row of rows) {
|
|
144
|
+
t.push(row);
|
|
145
|
+
}
|
|
146
|
+
console.log(t.toString());
|
|
147
|
+
}
|
|
148
|
+
function outputData(data) {
|
|
149
|
+
if (globalOptions.json) {
|
|
150
|
+
outputJson(jsonSuccess(data));
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
function outputError(code, message, details) {
|
|
154
|
+
if (globalOptions.json) {
|
|
155
|
+
outputJson(jsonError(code, message, void 0, details));
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
function outputJsonLine(payload) {
|
|
159
|
+
if (globalOptions.quiet) return;
|
|
160
|
+
console.log(JSON.stringify(payload));
|
|
161
|
+
}
|
|
162
|
+
function outputNeedsInput(request) {
|
|
163
|
+
outputJsonLine({ type: "needs_input", ...request });
|
|
164
|
+
}
|
|
165
|
+
function quietOutput(message) {
|
|
166
|
+
if (globalOptions.quiet || globalOptions.json) {
|
|
167
|
+
console.log(message);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
function box(title, content) {
|
|
171
|
+
if (globalOptions.json || globalOptions.quiet) {
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
console.log("");
|
|
175
|
+
console.log(colors.bold(title));
|
|
176
|
+
for (const line of content) {
|
|
177
|
+
console.log(` ${line}`);
|
|
178
|
+
}
|
|
179
|
+
console.log("");
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
export {
|
|
183
|
+
ExitCode,
|
|
184
|
+
exit,
|
|
185
|
+
jsonError,
|
|
186
|
+
outputJson,
|
|
187
|
+
setGlobalOptions,
|
|
188
|
+
isJsonMode,
|
|
189
|
+
shouldSkipConfirmation,
|
|
190
|
+
isNonInteractiveMode,
|
|
191
|
+
colors,
|
|
192
|
+
getStatusBadge,
|
|
193
|
+
log,
|
|
194
|
+
success,
|
|
195
|
+
error,
|
|
196
|
+
table,
|
|
197
|
+
outputData,
|
|
198
|
+
outputError,
|
|
199
|
+
outputJsonLine,
|
|
200
|
+
outputNeedsInput,
|
|
201
|
+
quietOutput,
|
|
202
|
+
box
|
|
203
|
+
};
|