@tarout/cli 0.2.0 → 0.2.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/README.md +62 -18
- package/dist/api-SHKZO2SZ.js +11 -0
- package/dist/billing-ENTHZKID.js +11 -0
- package/dist/chunk-FKX4CRPL.js +669 -0
- package/dist/chunk-FS74WWHV.js +198 -0
- package/dist/{chunk-VO4OYJW3.js → chunk-J3H7LTFT.js} +16 -1
- package/dist/chunk-XSJKHLNL.js +897 -0
- package/dist/index.js +16955 -3340
- package/dist/{prompts-B53LIJLG.js → prompts-WNFR34TG.js} +4 -1
- package/package.json +3 -3
- package/dist/chunk-GSKD67K4.js +0 -41
- package/dist/spinner-2NALE2OE.js +0 -14
|
@@ -0,0 +1,198 @@
|
|
|
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, null, 2));
|
|
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
|
+
};
|
|
57
|
+
function setGlobalOptions(options) {
|
|
58
|
+
globalOptions = { ...globalOptions, ...options };
|
|
59
|
+
}
|
|
60
|
+
function isJsonMode() {
|
|
61
|
+
return globalOptions.json;
|
|
62
|
+
}
|
|
63
|
+
function shouldSkipConfirmation() {
|
|
64
|
+
return globalOptions.yes;
|
|
65
|
+
}
|
|
66
|
+
function c(colorFn, str) {
|
|
67
|
+
return globalOptions.noColor ? str : colorFn(str);
|
|
68
|
+
}
|
|
69
|
+
var colors = {
|
|
70
|
+
success: (str) => c(chalk.green, str),
|
|
71
|
+
error: (str) => c(chalk.red, str),
|
|
72
|
+
warn: (str) => c(chalk.yellow, str),
|
|
73
|
+
info: (str) => c(chalk.blue, str),
|
|
74
|
+
dim: (str) => c(chalk.dim, str),
|
|
75
|
+
bold: (str) => c(chalk.bold, str),
|
|
76
|
+
cyan: (str) => c(chalk.cyan, str)
|
|
77
|
+
};
|
|
78
|
+
function getStatusBadge(status) {
|
|
79
|
+
const badges = {
|
|
80
|
+
running: colors.success("\u25CF running"),
|
|
81
|
+
idle: colors.warn("\u25CB idle"),
|
|
82
|
+
error: colors.error("\u2717 error"),
|
|
83
|
+
done: colors.success("\u2713 done"),
|
|
84
|
+
deploying: colors.info("\u25D0 deploying"),
|
|
85
|
+
stopped: colors.dim("\u25CB stopped"),
|
|
86
|
+
cancelled: colors.warn("\u25CB cancelled")
|
|
87
|
+
};
|
|
88
|
+
return badges[status.toLowerCase()] || status;
|
|
89
|
+
}
|
|
90
|
+
function log(message) {
|
|
91
|
+
if (!globalOptions.quiet && !globalOptions.json) {
|
|
92
|
+
console.log(message);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
function success(message) {
|
|
96
|
+
if (!globalOptions.quiet && !globalOptions.json) {
|
|
97
|
+
console.log(colors.success(`\u2713 ${message}`));
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
function error(message, suggestions) {
|
|
101
|
+
if (globalOptions.json) {
|
|
102
|
+
outputJson(jsonError("ERROR", message, suggestions));
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
console.error(colors.error(`Error: ${message}`));
|
|
106
|
+
if (suggestions && suggestions.length > 0) {
|
|
107
|
+
console.error("");
|
|
108
|
+
console.error("Did you mean one of these?");
|
|
109
|
+
for (const suggestion of suggestions) {
|
|
110
|
+
console.error(colors.dim(` - ${suggestion}`));
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
function table(headers, rows) {
|
|
115
|
+
if (globalOptions.json) {
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
const t = new Table({
|
|
119
|
+
head: headers.map((h) => colors.bold(h)),
|
|
120
|
+
style: { head: [], border: [] },
|
|
121
|
+
chars: {
|
|
122
|
+
top: "",
|
|
123
|
+
"top-mid": "",
|
|
124
|
+
"top-left": "",
|
|
125
|
+
"top-right": "",
|
|
126
|
+
bottom: "",
|
|
127
|
+
"bottom-mid": "",
|
|
128
|
+
"bottom-left": "",
|
|
129
|
+
"bottom-right": "",
|
|
130
|
+
left: " ",
|
|
131
|
+
"left-mid": "",
|
|
132
|
+
mid: "",
|
|
133
|
+
"mid-mid": "",
|
|
134
|
+
right: "",
|
|
135
|
+
"right-mid": "",
|
|
136
|
+
middle: " "
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
for (const row of rows) {
|
|
140
|
+
t.push(row);
|
|
141
|
+
}
|
|
142
|
+
console.log(t.toString());
|
|
143
|
+
}
|
|
144
|
+
function outputData(data) {
|
|
145
|
+
if (globalOptions.json) {
|
|
146
|
+
outputJson(jsonSuccess(data));
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
function outputError(code, message, details) {
|
|
150
|
+
if (globalOptions.json) {
|
|
151
|
+
outputJson(jsonError(code, message, void 0, details));
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
function outputJsonLine(payload) {
|
|
155
|
+
if (globalOptions.quiet) return;
|
|
156
|
+
console.log(JSON.stringify(payload));
|
|
157
|
+
}
|
|
158
|
+
function outputNeedsInput(request) {
|
|
159
|
+
outputJsonLine({ type: "needs_input", ...request });
|
|
160
|
+
}
|
|
161
|
+
function quietOutput(message) {
|
|
162
|
+
if (globalOptions.quiet || globalOptions.json) {
|
|
163
|
+
console.log(message);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
function box(title, content) {
|
|
167
|
+
if (globalOptions.json || globalOptions.quiet) {
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
console.log("");
|
|
171
|
+
console.log(colors.bold(title));
|
|
172
|
+
for (const line of content) {
|
|
173
|
+
console.log(` ${line}`);
|
|
174
|
+
}
|
|
175
|
+
console.log("");
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
export {
|
|
179
|
+
ExitCode,
|
|
180
|
+
exit,
|
|
181
|
+
jsonError,
|
|
182
|
+
outputJson,
|
|
183
|
+
setGlobalOptions,
|
|
184
|
+
isJsonMode,
|
|
185
|
+
shouldSkipConfirmation,
|
|
186
|
+
colors,
|
|
187
|
+
getStatusBadge,
|
|
188
|
+
log,
|
|
189
|
+
success,
|
|
190
|
+
error,
|
|
191
|
+
table,
|
|
192
|
+
outputData,
|
|
193
|
+
outputError,
|
|
194
|
+
outputJsonLine,
|
|
195
|
+
outputNeedsInput,
|
|
196
|
+
quietOutput,
|
|
197
|
+
box
|
|
198
|
+
};
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ExitCode,
|
|
3
|
+
exit,
|
|
4
|
+
isJsonMode,
|
|
5
|
+
outputNeedsInput
|
|
6
|
+
} from "./chunk-FS74WWHV.js";
|
|
7
|
+
|
|
1
8
|
// src/utils/prompts.ts
|
|
2
9
|
import inquirer from "inquirer";
|
|
3
10
|
async function confirm(message, defaultValue = false) {
|
|
@@ -44,10 +51,18 @@ async function password(message) {
|
|
|
44
51
|
]);
|
|
45
52
|
return value;
|
|
46
53
|
}
|
|
54
|
+
async function promptOrEmit(req, fallback) {
|
|
55
|
+
if (isJsonMode()) {
|
|
56
|
+
outputNeedsInput(req);
|
|
57
|
+
exit(ExitCode.NEEDS_INPUT);
|
|
58
|
+
}
|
|
59
|
+
return fallback();
|
|
60
|
+
}
|
|
47
61
|
|
|
48
62
|
export {
|
|
49
63
|
confirm,
|
|
50
64
|
input,
|
|
51
65
|
select,
|
|
52
|
-
password
|
|
66
|
+
password,
|
|
67
|
+
promptOrEmit
|
|
53
68
|
};
|