auix 0.0.6 → 0.0.7

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/index.js CHANGED
@@ -1,1594 +1,1631 @@
1
1
  #!/usr/bin/env node
2
- import { formatWithOptions } from "node:util";
2
+ import { formatWithOptions, parseArgs } from "node:util";
3
+ import { existsSync, mkdirSync, readFileSync, readdirSync, rmSync, writeFileSync } from "node:fs";
4
+ import { homedir } from "node:os";
3
5
  import { basename, dirname, join, resolve, sep } from "node:path";
4
6
  import g$1 from "node:process";
5
7
  import * as tty from "node:tty";
6
- import { existsSync, mkdirSync, readFileSync, readdirSync, rmSync, writeFileSync } from "node:fs";
7
- import { homedir } from "node:os";
8
8
  import { execSync, spawn } from "node:child_process";
9
9
  import { createHash, randomUUID } from "node:crypto";
10
-
11
- //#region ../../node_modules/consola/dist/core.mjs
12
- const LogLevels = {
13
- silent: Number.NEGATIVE_INFINITY,
14
- fatal: 0,
15
- error: 0,
16
- warn: 1,
17
- log: 2,
18
- info: 3,
19
- success: 3,
20
- fail: 3,
21
- ready: 3,
22
- start: 3,
23
- box: 3,
24
- debug: 4,
25
- trace: 5,
26
- verbose: Number.POSITIVE_INFINITY
27
- };
28
- const LogTypes = {
29
- silent: { level: -1 },
30
- fatal: { level: LogLevels.fatal },
31
- error: { level: LogLevels.error },
32
- warn: { level: LogLevels.warn },
33
- log: { level: LogLevels.log },
34
- info: { level: LogLevels.info },
35
- success: { level: LogLevels.success },
36
- fail: { level: LogLevels.fail },
37
- ready: { level: LogLevels.info },
38
- start: { level: LogLevels.info },
39
- box: { level: LogLevels.info },
40
- debug: { level: LogLevels.debug },
41
- trace: { level: LogLevels.trace },
42
- verbose: { level: LogLevels.verbose }
43
- };
44
- function isPlainObject$1(value) {
45
- if (value === null || typeof value !== "object") return false;
46
- const prototype = Object.getPrototypeOf(value);
47
- if (prototype !== null && prototype !== Object.prototype && Object.getPrototypeOf(prototype) !== null) return false;
48
- if (Symbol.iterator in value) return false;
49
- if (Symbol.toStringTag in value) return Object.prototype.toString.call(value) === "[object Module]";
50
- return true;
10
+ //#region ../../node_modules/citty/dist/_chunks/libs/scule.mjs
11
+ const NUMBER_CHAR_RE = /\d/;
12
+ const STR_SPLITTERS = [
13
+ "-",
14
+ "_",
15
+ "/",
16
+ "."
17
+ ];
18
+ function isUppercase(char = "") {
19
+ if (NUMBER_CHAR_RE.test(char)) return;
20
+ return char !== char.toLowerCase();
51
21
  }
52
- function _defu(baseObject, defaults, namespace = ".", merger) {
53
- if (!isPlainObject$1(defaults)) return _defu(baseObject, {}, namespace, merger);
54
- const object = Object.assign({}, defaults);
55
- for (const key in baseObject) {
56
- if (key === "__proto__" || key === "constructor") continue;
57
- const value = baseObject[key];
58
- if (value === null || value === void 0) continue;
59
- if (merger && merger(object, key, value, namespace)) continue;
60
- if (Array.isArray(value) && Array.isArray(object[key])) object[key] = [...value, ...object[key]];
61
- else if (isPlainObject$1(value) && isPlainObject$1(object[key])) object[key] = _defu(value, object[key], (namespace ? `${namespace}.` : "") + key.toString(), merger);
62
- else object[key] = value;
22
+ function splitByCase(str, separators) {
23
+ const splitters = separators ?? STR_SPLITTERS;
24
+ const parts = [];
25
+ if (!str || typeof str !== "string") return parts;
26
+ let buff = "";
27
+ let previousUpper;
28
+ let previousSplitter;
29
+ for (const char of str) {
30
+ const isSplitter = splitters.includes(char);
31
+ if (isSplitter === true) {
32
+ parts.push(buff);
33
+ buff = "";
34
+ previousUpper = void 0;
35
+ continue;
36
+ }
37
+ const isUpper = isUppercase(char);
38
+ if (previousSplitter === false) {
39
+ if (previousUpper === false && isUpper === true) {
40
+ parts.push(buff);
41
+ buff = char;
42
+ previousUpper = isUpper;
43
+ continue;
44
+ }
45
+ if (previousUpper === true && isUpper === false && buff.length > 1) {
46
+ const lastChar = buff.at(-1);
47
+ parts.push(buff.slice(0, Math.max(0, buff.length - 1)));
48
+ buff = lastChar + char;
49
+ previousUpper = isUpper;
50
+ continue;
51
+ }
52
+ }
53
+ buff += char;
54
+ previousUpper = isUpper;
55
+ previousSplitter = isSplitter;
63
56
  }
64
- return object;
57
+ parts.push(buff);
58
+ return parts;
65
59
  }
66
- function createDefu(merger) {
67
- return (...arguments_) => arguments_.reduce((p, c) => _defu(p, c, "", merger), {});
60
+ function upperFirst(str) {
61
+ return str ? str[0].toUpperCase() + str.slice(1) : "";
68
62
  }
69
- const defu = createDefu();
70
- function isPlainObject(obj) {
71
- return Object.prototype.toString.call(obj) === "[object Object]";
63
+ function lowerFirst(str) {
64
+ return str ? str[0].toLowerCase() + str.slice(1) : "";
72
65
  }
73
- function isLogObj(arg) {
74
- if (!isPlainObject(arg)) return false;
75
- if (!arg.message && !arg.args) return false;
76
- if (arg.stack) return false;
77
- return true;
66
+ function pascalCase(str, opts) {
67
+ return str ? (Array.isArray(str) ? str : splitByCase(str)).map((p) => upperFirst(opts?.normalize ? p.toLowerCase() : p)).join("") : "";
78
68
  }
79
- let paused = false;
80
- const queue = [];
81
- var Consola = class Consola {
82
- options;
83
- _lastLog;
84
- _mockFn;
85
- /**
86
- * Creates an instance of Consola with specified options or defaults.
87
- *
88
- * @param {Partial<ConsolaOptions>} [options={}] - Configuration options for the Consola instance.
89
- */
90
- constructor(options = {}) {
91
- const types = options.types || LogTypes;
92
- this.options = defu({
93
- ...options,
94
- defaults: { ...options.defaults },
95
- level: _normalizeLogLevel(options.level, types),
96
- reporters: [...options.reporters || []]
97
- }, {
98
- types: LogTypes,
99
- throttle: 1e3,
100
- throttleMin: 5,
101
- formatOptions: {
102
- date: true,
103
- colors: false,
104
- compact: true
105
- }
106
- });
107
- for (const type in types) {
108
- const defaults = {
109
- type,
110
- ...this.options.defaults,
111
- ...types[type]
112
- };
113
- this[type] = this._wrapLogFn(defaults);
114
- this[type].raw = this._wrapLogFn(defaults, true);
115
- }
116
- if (this.options.mockFn) this.mockTypes();
117
- this._lastLog = {};
118
- }
119
- /**
120
- * Gets the current log level of the Consola instance.
121
- *
122
- * @returns {number} The current log level.
123
- */
124
- get level() {
125
- return this.options.level;
126
- }
127
- /**
128
- * Sets the minimum log level that will be output by the instance.
129
- *
130
- * @param {number} level - The new log level to set.
131
- */
132
- set level(level) {
133
- this.options.level = _normalizeLogLevel(level, this.options.types, this.options.level);
134
- }
135
- /**
136
- * Displays a prompt to the user and returns the response.
137
- * Throw an error if `prompt` is not supported by the current configuration.
138
- *
139
- * @template T
140
- * @param {string} message - The message to display in the prompt.
141
- * @param {T} [opts] - Optional options for the prompt. See {@link PromptOptions}.
142
- * @returns {promise<T>} A promise that infer with the prompt options. See {@link PromptOptions}.
143
- */
144
- prompt(message, opts) {
145
- if (!this.options.prompt) throw new Error("prompt is not supported!");
146
- return this.options.prompt(message, opts);
69
+ function camelCase(str, opts) {
70
+ return lowerFirst(pascalCase(str || "", opts));
71
+ }
72
+ function kebabCase(str, joiner) {
73
+ return str ? (Array.isArray(str) ? str : splitByCase(str)).map((p) => p.toLowerCase()).join(joiner ?? "-") : "";
74
+ }
75
+ //#endregion
76
+ //#region ../../node_modules/citty/dist/index.mjs
77
+ function toArray(val) {
78
+ if (Array.isArray(val)) return val;
79
+ return val === void 0 ? [] : [val];
80
+ }
81
+ function formatLineColumns(lines, linePrefix = "") {
82
+ const maxLength = [];
83
+ for (const line of lines) for (const [i, element] of line.entries()) maxLength[i] = Math.max(maxLength[i] || 0, element.length);
84
+ return lines.map((l) => l.map((c, i) => linePrefix + c[i === 0 ? "padStart" : "padEnd"](maxLength[i])).join(" ")).join("\n");
85
+ }
86
+ function resolveValue(input) {
87
+ return typeof input === "function" ? input() : input;
88
+ }
89
+ var CLIError = class extends Error {
90
+ code;
91
+ constructor(message, code) {
92
+ super(message);
93
+ this.name = "CLIError";
94
+ this.code = code;
147
95
  }
148
- /**
149
- * Creates a new instance of Consola, inheriting options from the current instance, with possible overrides.
150
- *
151
- * @param {Partial<ConsolaOptions>} options - Optional overrides for the new instance. See {@link ConsolaOptions}.
152
- * @returns {ConsolaInstance} A new Consola instance. See {@link ConsolaInstance}.
153
- */
154
- create(options) {
155
- const instance = new Consola({
156
- ...this.options,
157
- ...options
158
- });
159
- if (this._mockFn) instance.mockTypes(this._mockFn);
160
- return instance;
96
+ };
97
+ function parseRawArgs(args = [], opts = {}) {
98
+ const booleans = new Set(opts.boolean || []);
99
+ const strings = new Set(opts.string || []);
100
+ const aliasMap = opts.alias || {};
101
+ const defaults = opts.default || {};
102
+ const aliasToMain = /* @__PURE__ */ new Map();
103
+ const mainToAliases = /* @__PURE__ */ new Map();
104
+ for (const [key, value] of Object.entries(aliasMap)) {
105
+ const targets = value;
106
+ for (const target of targets) {
107
+ aliasToMain.set(key, target);
108
+ if (!mainToAliases.has(target)) mainToAliases.set(target, []);
109
+ mainToAliases.get(target).push(key);
110
+ aliasToMain.set(target, key);
111
+ if (!mainToAliases.has(key)) mainToAliases.set(key, []);
112
+ mainToAliases.get(key).push(target);
113
+ }
114
+ }
115
+ const options = {};
116
+ function getType(name) {
117
+ if (booleans.has(name)) return "boolean";
118
+ const aliases = mainToAliases.get(name) || [];
119
+ for (const alias of aliases) if (booleans.has(alias)) return "boolean";
120
+ return "string";
121
+ }
122
+ const allOptions = new Set([
123
+ ...booleans,
124
+ ...strings,
125
+ ...Object.keys(aliasMap),
126
+ ...Object.values(aliasMap).flat(),
127
+ ...Object.keys(defaults)
128
+ ]);
129
+ for (const name of allOptions) if (!options[name]) options[name] = {
130
+ type: getType(name),
131
+ default: defaults[name]
132
+ };
133
+ for (const [alias, main] of aliasToMain.entries()) if (alias.length === 1 && options[main] && !options[main].short) options[main].short = alias;
134
+ const processedArgs = [];
135
+ const negatedFlags = {};
136
+ for (let i = 0; i < args.length; i++) {
137
+ const arg = args[i];
138
+ if (arg === "--") {
139
+ processedArgs.push(...args.slice(i));
140
+ break;
141
+ }
142
+ if (arg.startsWith("--no-")) {
143
+ const flagName = arg.slice(5);
144
+ negatedFlags[flagName] = true;
145
+ continue;
146
+ }
147
+ processedArgs.push(arg);
161
148
  }
162
- /**
163
- * Creates a new Consola instance with the specified default log object properties.
164
- *
165
- * @param {InputLogObject} defaults - Default properties to include in any log from the new instance. See {@link InputLogObject}.
166
- * @returns {ConsolaInstance} A new Consola instance. See {@link ConsolaInstance}.
167
- */
168
- withDefaults(defaults) {
169
- return this.create({
170
- ...this.options,
171
- defaults: {
172
- ...this.options.defaults,
173
- ...defaults
174
- }
149
+ let parsed;
150
+ try {
151
+ parsed = parseArgs({
152
+ args: processedArgs,
153
+ options: Object.keys(options).length > 0 ? options : void 0,
154
+ allowPositionals: true,
155
+ strict: false
175
156
  });
157
+ } catch {
158
+ parsed = {
159
+ values: {},
160
+ positionals: processedArgs
161
+ };
176
162
  }
177
- /**
178
- * Creates a new Consola instance with a specified tag, which will be included in every log.
179
- *
180
- * @param {string} tag - The tag to include in each log of the new instance.
181
- * @returns {ConsolaInstance} A new Consola instance. See {@link ConsolaInstance}.
182
- */
183
- withTag(tag) {
184
- return this.withDefaults({ tag: this.options.defaults.tag ? this.options.defaults.tag + ":" + tag : tag });
163
+ const out = { _: [] };
164
+ out._ = parsed.positionals;
165
+ for (const [key, value] of Object.entries(parsed.values)) out[key] = value;
166
+ for (const [name] of Object.entries(negatedFlags)) {
167
+ out[name] = false;
168
+ const mainName = aliasToMain.get(name);
169
+ if (mainName) out[mainName] = false;
170
+ const aliases = mainToAliases.get(name);
171
+ if (aliases) for (const alias of aliases) out[alias] = false;
172
+ }
173
+ for (const [alias, main] of aliasToMain.entries()) {
174
+ if (out[alias] !== void 0 && out[main] === void 0) out[main] = out[alias];
175
+ if (out[main] !== void 0 && out[alias] === void 0) out[alias] = out[main];
185
176
  }
186
- /**
187
- * Adds a custom reporter to the Consola instance.
188
- * Reporters will be called for each log message, depending on their implementation and log level.
189
- *
190
- * @param {ConsolaReporter} reporter - The reporter to add. See {@link ConsolaReporter}.
191
- * @returns {Consola} The current Consola instance.
192
- */
193
- addReporter(reporter) {
194
- this.options.reporters.push(reporter);
195
- return this;
196
- }
197
- /**
198
- * Removes a custom reporter from the Consola instance.
199
- * If no reporter is specified, all reporters will be removed.
200
- *
201
- * @param {ConsolaReporter} reporter - The reporter to remove. See {@link ConsolaReporter}.
202
- * @returns {Consola} The current Consola instance.
203
- */
204
- removeReporter(reporter) {
205
- if (reporter) {
206
- const i = this.options.reporters.indexOf(reporter);
207
- if (i !== -1) return this.options.reporters.splice(i, 1);
208
- } else this.options.reporters.splice(0);
209
- return this;
210
- }
211
- /**
212
- * Replaces all reporters of the Consola instance with the specified array of reporters.
213
- *
214
- * @param {ConsolaReporter[]} reporters - The new reporters to set. See {@link ConsolaReporter}.
215
- * @returns {Consola} The current Consola instance.
216
- */
217
- setReporters(reporters) {
218
- this.options.reporters = Array.isArray(reporters) ? reporters : [reporters];
219
- return this;
220
- }
221
- wrapAll() {
222
- this.wrapConsole();
223
- this.wrapStd();
224
- }
225
- restoreAll() {
226
- this.restoreConsole();
227
- this.restoreStd();
228
- }
229
- /**
230
- * Overrides console methods with Consola logging methods for consistent logging.
231
- */
232
- wrapConsole() {
233
- for (const type in this.options.types) {
234
- if (!console["__" + type]) console["__" + type] = console[type];
235
- console[type] = this[type].raw;
177
+ return out;
178
+ }
179
+ const noColor = /* @__PURE__ */ (() => {
180
+ const env = globalThis.process?.env ?? {};
181
+ return env.NO_COLOR === "1" || env.TERM === "dumb" || env.TEST || env.CI;
182
+ })();
183
+ const _c = (c, r = 39) => (t) => noColor ? t : `\u001B[${c}m${t}\u001B[${r}m`;
184
+ const bold = /* @__PURE__ */ _c(1, 22);
185
+ const cyan = /* @__PURE__ */ _c(36);
186
+ const gray = /* @__PURE__ */ _c(90);
187
+ const underline = /* @__PURE__ */ _c(4, 24);
188
+ function parseArgs$1(rawArgs, argsDef) {
189
+ const parseOptions = {
190
+ boolean: [],
191
+ string: [],
192
+ alias: {},
193
+ default: {}
194
+ };
195
+ const args = resolveArgs(argsDef);
196
+ for (const arg of args) {
197
+ if (arg.type === "positional") continue;
198
+ if (arg.type === "string" || arg.type === "enum") parseOptions.string.push(arg.name);
199
+ else if (arg.type === "boolean") parseOptions.boolean.push(arg.name);
200
+ if (arg.default !== void 0) parseOptions.default[arg.name] = arg.default;
201
+ if (arg.alias) parseOptions.alias[arg.name] = arg.alias;
202
+ const camelName = camelCase(arg.name);
203
+ const kebabName = kebabCase(arg.name);
204
+ if (camelName !== arg.name || kebabName !== arg.name) {
205
+ const existingAliases = toArray(parseOptions.alias[arg.name] || []);
206
+ if (camelName !== arg.name && !existingAliases.includes(camelName)) existingAliases.push(camelName);
207
+ if (kebabName !== arg.name && !existingAliases.includes(kebabName)) existingAliases.push(kebabName);
208
+ if (existingAliases.length > 0) parseOptions.alias[arg.name] = existingAliases;
236
209
  }
237
210
  }
238
- /**
239
- * Restores the original console methods, removing Consola overrides.
240
- */
241
- restoreConsole() {
242
- for (const type in this.options.types) if (console["__" + type]) {
243
- console[type] = console["__" + type];
244
- delete console["__" + type];
211
+ const parsed = parseRawArgs(rawArgs, parseOptions);
212
+ const [ ...positionalArguments] = parsed._;
213
+ const parsedArgsProxy = new Proxy(parsed, { get(target, prop) {
214
+ return target[prop] ?? target[camelCase(prop)] ?? target[kebabCase(prop)];
215
+ } });
216
+ for (const [, arg] of args.entries()) if (arg.type === "positional") {
217
+ const nextPositionalArgument = positionalArguments.shift();
218
+ if (nextPositionalArgument !== void 0) parsedArgsProxy[arg.name] = nextPositionalArgument;
219
+ else if (arg.default === void 0 && arg.required !== false) throw new CLIError(`Missing required positional argument: ${arg.name.toUpperCase()}`, "EARG");
220
+ else parsedArgsProxy[arg.name] = arg.default;
221
+ } else if (arg.type === "enum") {
222
+ const argument = parsedArgsProxy[arg.name];
223
+ const options = arg.options || [];
224
+ if (argument !== void 0 && options.length > 0 && !options.includes(argument)) throw new CLIError(`Invalid value for argument: ${cyan(`--${arg.name}`)} (${cyan(argument)}). Expected one of: ${options.map((o) => cyan(o)).join(", ")}.`, "EARG");
225
+ } else if (arg.required && parsedArgsProxy[arg.name] === void 0) throw new CLIError(`Missing required argument: --${arg.name}`, "EARG");
226
+ return parsedArgsProxy;
227
+ }
228
+ function resolveArgs(argsDef) {
229
+ const args = [];
230
+ for (const [name, argDef] of Object.entries(argsDef || {})) args.push({
231
+ ...argDef,
232
+ name,
233
+ alias: toArray(argDef.alias)
234
+ });
235
+ return args;
236
+ }
237
+ function defineCommand(def) {
238
+ return def;
239
+ }
240
+ async function runCommand$1(cmd, opts) {
241
+ const cmdArgs = await resolveValue(cmd.args || {});
242
+ const parsedArgs = parseArgs$1(opts.rawArgs, cmdArgs);
243
+ const context = {
244
+ rawArgs: opts.rawArgs,
245
+ args: parsedArgs,
246
+ data: opts.data,
247
+ cmd
248
+ };
249
+ if (typeof cmd.setup === "function") await cmd.setup(context);
250
+ let result;
251
+ try {
252
+ const subCommands = await resolveValue(cmd.subCommands);
253
+ if (subCommands && Object.keys(subCommands).length > 0) {
254
+ const subCommandArgIndex = opts.rawArgs.findIndex((arg) => !arg.startsWith("-"));
255
+ const subCommandName = opts.rawArgs[subCommandArgIndex];
256
+ if (subCommandName) {
257
+ if (!subCommands[subCommandName]) throw new CLIError(`Unknown command ${cyan(subCommandName)}`, "E_UNKNOWN_COMMAND");
258
+ const subCommand = await resolveValue(subCommands[subCommandName]);
259
+ if (subCommand) await runCommand$1(subCommand, { rawArgs: opts.rawArgs.slice(subCommandArgIndex + 1) });
260
+ } else if (!cmd.run) throw new CLIError(`No command specified.`, "E_NO_COMMAND");
245
261
  }
262
+ if (typeof cmd.run === "function") result = await cmd.run(context);
263
+ } finally {
264
+ if (typeof cmd.cleanup === "function") await cmd.cleanup(context);
246
265
  }
247
- /**
248
- * Overrides standard output and error streams to redirect them through Consola.
249
- */
250
- wrapStd() {
251
- this._wrapStream(this.options.stdout, "log");
252
- this._wrapStream(this.options.stderr, "log");
266
+ return { result };
267
+ }
268
+ async function resolveSubCommand(cmd, rawArgs, parent) {
269
+ const subCommands = await resolveValue(cmd.subCommands);
270
+ if (subCommands && Object.keys(subCommands).length > 0) {
271
+ const subCommandArgIndex = rawArgs.findIndex((arg) => !arg.startsWith("-"));
272
+ const subCommandName = rawArgs[subCommandArgIndex];
273
+ const subCommand = await resolveValue(subCommands[subCommandName]);
274
+ if (subCommand) return resolveSubCommand(subCommand, rawArgs.slice(subCommandArgIndex + 1), cmd);
253
275
  }
254
- _wrapStream(stream, type) {
255
- if (!stream) return;
256
- if (!stream.__write) stream.__write = stream.write;
257
- stream.write = (data) => {
258
- this[type].raw(String(data).trim());
259
- };
276
+ return [cmd, parent];
277
+ }
278
+ async function showUsage(cmd, parent) {
279
+ try {
280
+ console.log(await renderUsage(cmd, parent) + "\n");
281
+ } catch (error) {
282
+ console.error(error);
260
283
  }
261
- /**
262
- * Restores the original standard output and error streams, removing the Consola redirection.
263
- */
264
- restoreStd() {
265
- this._restoreStream(this.options.stdout);
266
- this._restoreStream(this.options.stderr);
284
+ }
285
+ const negativePrefixRe = /^no[-A-Z]/;
286
+ async function renderUsage(cmd, parent) {
287
+ const cmdMeta = await resolveValue(cmd.meta || {});
288
+ const cmdArgs = resolveArgs(await resolveValue(cmd.args || {}));
289
+ const parentMeta = await resolveValue(parent?.meta || {});
290
+ const commandName = `${parentMeta.name ? `${parentMeta.name} ` : ""}` + (cmdMeta.name || process.argv[1]);
291
+ const argLines = [];
292
+ const posLines = [];
293
+ const commandsLines = [];
294
+ const usageLine = [];
295
+ for (const arg of cmdArgs) if (arg.type === "positional") {
296
+ const name = arg.name.toUpperCase();
297
+ const isRequired = arg.required !== false && arg.default === void 0;
298
+ const defaultHint = arg.default ? `="${arg.default}"` : "";
299
+ posLines.push([
300
+ cyan(name + defaultHint),
301
+ arg.description || "",
302
+ arg.valueHint ? `<${arg.valueHint}>` : ""
303
+ ]);
304
+ usageLine.push(isRequired ? `<${name}>` : `[${name}]`);
305
+ } else {
306
+ const isRequired = arg.required === true && arg.default === void 0;
307
+ const argStr = [...(arg.alias || []).map((a) => `-${a}`), `--${arg.name}`].join(", ") + (arg.type === "string" && (arg.valueHint || arg.default) ? `=${arg.valueHint ? `<${arg.valueHint}>` : `"${arg.default || ""}"`}` : "") + (arg.type === "enum" && arg.options ? `=<${arg.options.join("|")}>` : "");
308
+ argLines.push([cyan(argStr + (isRequired ? " (required)" : "")), arg.description || ""]);
309
+ if (arg.type === "boolean" && (arg.default === true || arg.negativeDescription) && !negativePrefixRe.test(arg.name)) {
310
+ const negativeArgStr = [...(arg.alias || []).map((a) => `--no-${a}`), `--no-${arg.name}`].join(", ");
311
+ argLines.push([cyan(negativeArgStr + (isRequired ? " (required)" : "")), arg.negativeDescription || ""]);
312
+ }
313
+ if (isRequired) usageLine.push(argStr);
267
314
  }
268
- _restoreStream(stream) {
269
- if (!stream) return;
270
- if (stream.__write) {
271
- stream.write = stream.__write;
272
- delete stream.__write;
315
+ if (cmd.subCommands) {
316
+ const commandNames = [];
317
+ const subCommands = await resolveValue(cmd.subCommands);
318
+ for (const [name, sub] of Object.entries(subCommands)) {
319
+ const meta = await resolveValue((await resolveValue(sub))?.meta);
320
+ if (meta?.hidden) continue;
321
+ commandsLines.push([cyan(name), meta?.description || ""]);
322
+ commandNames.push(name);
273
323
  }
324
+ usageLine.push(commandNames.join("|"));
274
325
  }
275
- /**
276
- * Pauses logging, queues incoming logs until resumed.
277
- */
278
- pauseLogs() {
279
- paused = true;
326
+ const usageLines = [];
327
+ const version = cmdMeta.version || parentMeta.version;
328
+ usageLines.push(gray(`${cmdMeta.description} (${commandName + (version ? ` v${version}` : "")})`), "");
329
+ const hasOptions = argLines.length > 0 || posLines.length > 0;
330
+ usageLines.push(`${underline(bold("USAGE"))} ${cyan(`${commandName}${hasOptions ? " [OPTIONS]" : ""} ${usageLine.join(" ")}`)}`, "");
331
+ if (posLines.length > 0) {
332
+ usageLines.push(underline(bold("ARGUMENTS")), "");
333
+ usageLines.push(formatLineColumns(posLines, " "));
334
+ usageLines.push("");
280
335
  }
281
- /**
282
- * Resumes logging, processing any queued logs.
283
- */
284
- resumeLogs() {
285
- paused = false;
286
- const _queue = queue.splice(0);
287
- for (const item of _queue) item[0]._logFn(item[1], item[2]);
336
+ if (argLines.length > 0) {
337
+ usageLines.push(underline(bold("OPTIONS")), "");
338
+ usageLines.push(formatLineColumns(argLines, " "));
339
+ usageLines.push("");
288
340
  }
289
- /**
290
- * Replaces logging methods with mocks if a mock function is provided.
291
- *
292
- * @param {ConsolaOptions["mockFn"]} mockFn - The function to use for mocking logging methods. See {@link ConsolaOptions["mockFn"]}.
293
- */
294
- mockTypes(mockFn) {
295
- const _mockFn = mockFn || this.options.mockFn;
296
- this._mockFn = _mockFn;
297
- if (typeof _mockFn !== "function") return;
298
- for (const type in this.options.types) {
299
- this[type] = _mockFn(type, this.options.types[type]) || this[type];
300
- this[type].raw = this[type];
301
- }
341
+ if (commandsLines.length > 0) {
342
+ usageLines.push(underline(bold("COMMANDS")), "");
343
+ usageLines.push(formatLineColumns(commandsLines, " "));
344
+ usageLines.push("", `Use ${cyan(`${commandName} <command> --help`)} for more information about a command.`);
302
345
  }
303
- _wrapLogFn(defaults, isRaw) {
304
- return (...args) => {
305
- if (paused) {
306
- queue.push([
307
- this,
308
- defaults,
309
- args,
310
- isRaw
311
- ]);
312
- return;
313
- }
314
- return this._logFn(defaults, args, isRaw);
315
- };
346
+ return usageLines.filter((l) => typeof l === "string").join("\n");
347
+ }
348
+ async function runMain(cmd, opts = {}) {
349
+ const rawArgs = opts.rawArgs || process.argv.slice(2);
350
+ const showUsage$1 = opts.showUsage || showUsage;
351
+ try {
352
+ if (rawArgs.includes("--help") || rawArgs.includes("-h")) {
353
+ await showUsage$1(...await resolveSubCommand(cmd, rawArgs));
354
+ process.exit(0);
355
+ } else if (rawArgs.length === 1 && rawArgs[0] === "--version") {
356
+ const meta = typeof cmd.meta === "function" ? await cmd.meta() : await cmd.meta;
357
+ if (!meta?.version) throw new CLIError("No version specified", "E_NO_VERSION");
358
+ console.log(meta.version);
359
+ } else await runCommand$1(cmd, { rawArgs });
360
+ } catch (error) {
361
+ if (error instanceof CLIError) {
362
+ await showUsage$1(...await resolveSubCommand(cmd, rawArgs));
363
+ console.error(error.message);
364
+ } else console.error(error, "\n");
365
+ process.exit(1);
316
366
  }
317
- _logFn(defaults, args, isRaw) {
318
- if ((defaults.level || 0) > this.level) return false;
319
- const logObj = {
320
- date: /* @__PURE__ */ new Date(),
321
- args: [],
322
- ...defaults,
323
- level: _normalizeLogLevel(defaults.level, this.options.types)
324
- };
325
- if (!isRaw && args.length === 1 && isLogObj(args[0])) Object.assign(logObj, args[0]);
326
- else logObj.args = [...args];
327
- if (logObj.message) {
328
- logObj.args.unshift(logObj.message);
329
- delete logObj.message;
330
- }
331
- if (logObj.additional) {
332
- if (!Array.isArray(logObj.additional)) logObj.additional = logObj.additional.split("\n");
333
- logObj.args.push("\n" + logObj.additional.join("\n"));
334
- delete logObj.additional;
335
- }
336
- logObj.type = typeof logObj.type === "string" ? logObj.type.toLowerCase() : "log";
337
- logObj.tag = typeof logObj.tag === "string" ? logObj.tag : "";
338
- const resolveLog = (newLog = false) => {
339
- const repeated = (this._lastLog.count || 0) - this.options.throttleMin;
340
- if (this._lastLog.object && repeated > 0) {
341
- const args2 = [...this._lastLog.object.args];
342
- if (repeated > 1) args2.push(`(repeated ${repeated} times)`);
343
- this._log({
344
- ...this._lastLog.object,
345
- args: args2
346
- });
347
- this._lastLog.count = 1;
348
- }
349
- if (newLog) {
350
- this._lastLog.object = logObj;
351
- this._log(logObj);
352
- }
353
- };
354
- clearTimeout(this._lastLog.timeout);
355
- const diffTime = this._lastLog.time && logObj.date ? logObj.date.getTime() - this._lastLog.time.getTime() : 0;
356
- this._lastLog.time = logObj.date;
357
- if (diffTime < this.options.throttle) try {
358
- const serializedLog = JSON.stringify([
359
- logObj.type,
360
- logObj.tag,
361
- logObj.args
362
- ]);
363
- const isSameLog = this._lastLog.serialized === serializedLog;
364
- this._lastLog.serialized = serializedLog;
365
- if (isSameLog) {
366
- this._lastLog.count = (this._lastLog.count || 0) + 1;
367
- if (this._lastLog.count > this.options.throttleMin) {
368
- this._lastLog.timeout = setTimeout(resolveLog, this.options.throttle);
369
- return;
370
- }
371
- }
372
- } catch {}
373
- resolveLog(true);
374
- }
375
- _log(logObj) {
376
- for (const reporter of this.options.reporters) reporter.log(logObj, { options: this.options });
367
+ }
368
+ //#endregion
369
+ //#region ../env/dist/index.js
370
+ function parseEnvString(content) {
371
+ const result = {};
372
+ for (const line of content.split("\n")) {
373
+ const trimmed = line.trim();
374
+ if (!trimmed || trimmed.startsWith("#")) continue;
375
+ const eqIndex = trimmed.indexOf("=");
376
+ if (eqIndex === -1) continue;
377
+ const key = trimmed.slice(0, eqIndex).trim();
378
+ let value = trimmed.slice(eqIndex + 1).trim();
379
+ if (value.startsWith("\"") && value.endsWith("\"") || value.startsWith("'") && value.endsWith("'")) value = value.slice(1, -1);
380
+ result[key] = value;
377
381
  }
378
- };
379
- function _normalizeLogLevel(input, types = {}, defaultLevel = 3) {
380
- if (input === void 0) return defaultLevel;
381
- if (typeof input === "number") return input;
382
- if (types[input] && types[input].level !== void 0) return types[input].level;
383
- return defaultLevel;
382
+ return result;
384
383
  }
385
- Consola.prototype.add = Consola.prototype.addReporter;
386
- Consola.prototype.remove = Consola.prototype.removeReporter;
387
- Consola.prototype.clear = Consola.prototype.removeReporter;
388
- Consola.prototype.withScope = Consola.prototype.withTag;
389
- Consola.prototype.mock = Consola.prototype.mockTypes;
390
- Consola.prototype.pause = Consola.prototype.pauseLogs;
391
- Consola.prototype.resume = Consola.prototype.resumeLogs;
392
- function createConsola$1(options = {}) {
393
- return new Consola(options);
384
+ function formatEnvString(vars) {
385
+ return Object.entries(vars).map(([key, value]) => {
386
+ return `${key}=${value.includes(" ") || value.includes("#") || value.includes("\n") ? `"${value}"` : value}`;
387
+ }).join("\n");
394
388
  }
395
-
396
- //#endregion
397
- //#region ../../node_modules/consola/dist/shared/consola.DRwqZj3T.mjs
398
- function parseStack(stack, message) {
399
- const cwd = process.cwd() + sep;
400
- return stack.split("\n").splice(message.split("\n").length).map((l) => l.trim().replace("file://", "").replace(cwd, ""));
389
+ function formatJsonString(vars) {
390
+ return JSON.stringify(vars, null, 2);
401
391
  }
402
- function writeStream(data, stream) {
403
- return (stream.__write || stream.write).call(stream, data);
392
+ function formatYamlString(vars) {
393
+ const specialChars = /[:#{}[\],&*?|<>=!%@`\-\s]/;
394
+ return Object.entries(vars).map(([key, value]) => {
395
+ return `${key}: ${value === "" || specialChars.test(value) ? `"${value}"` : value}`;
396
+ }).join("\n");
404
397
  }
405
- const bracket = (x) => x ? `[${x}]` : "";
406
- var BasicReporter = class {
407
- formatStack(stack, message, opts) {
408
- const indent = " ".repeat((opts?.errorLevel || 0) + 1);
409
- return indent + parseStack(stack, message).join(`
410
- ${indent}`);
411
- }
412
- formatError(err, opts) {
413
- const message = err.message ?? formatWithOptions(opts, err);
414
- const stack = err.stack ? this.formatStack(err.stack, message, opts) : "";
415
- const level = opts?.errorLevel || 0;
416
- const causedPrefix = level > 0 ? `${" ".repeat(level)}[cause]: ` : "";
417
- const causedError = err.cause ? "\n\n" + this.formatError(err.cause, {
418
- ...opts,
419
- errorLevel: level + 1
420
- }) : "";
421
- return causedPrefix + message + "\n" + stack + causedError;
422
- }
423
- formatArgs(args, opts) {
424
- return formatWithOptions(opts, ...args.map((arg) => {
425
- if (arg && typeof arg.stack === "string") return this.formatError(arg, opts);
426
- return arg;
427
- }));
398
+ function interpolateEnv(vars) {
399
+ const result = {};
400
+ for (const [key, value] of Object.entries(vars)) result[key] = value;
401
+ const pattern = /\$\{([^}]+)\}/g;
402
+ for (let i = 0; i < 10; i++) {
403
+ let changed = false;
404
+ for (const key of Object.keys(result)) {
405
+ const value = result[key];
406
+ if (!pattern.test(value)) continue;
407
+ pattern.lastIndex = 0;
408
+ const resolving = /* @__PURE__ */ new Set();
409
+ resolving.add(key);
410
+ const newValue = value.replace(pattern, (match, ref) => {
411
+ if (resolving.has(ref)) return match;
412
+ if (!(ref in result)) return match;
413
+ const refValue = result[ref];
414
+ if (pattern.test(refValue)) {
415
+ pattern.lastIndex = 0;
416
+ if ([...refValue.matchAll(/\$\{([^}]+)\}/g)].map((m) => m[1]).some((r) => resolving.has(r))) return match;
417
+ }
418
+ pattern.lastIndex = 0;
419
+ return refValue;
420
+ });
421
+ if (newValue !== value) {
422
+ result[key] = newValue;
423
+ changed = true;
424
+ }
425
+ }
426
+ if (!changed) break;
428
427
  }
429
- formatDate(date, opts) {
430
- return opts.date ? date.toLocaleTimeString() : "";
428
+ return result;
429
+ }
430
+ //#endregion
431
+ //#region src/config.ts
432
+ const CONFIG_DIR = join(homedir(), ".auix");
433
+ const CONFIG_FILE$1 = join(CONFIG_DIR, "config.json");
434
+ const PROJECT_FILE = ".auixrc";
435
+ const DEFAULT_BASE_URL = "https://api.auix.dev";
436
+ const DEFAULT_APP_URL = "https://auix.dev";
437
+ function loadGlobalConfig() {
438
+ if (!existsSync(CONFIG_FILE$1)) return {};
439
+ try {
440
+ return JSON.parse(readFileSync(CONFIG_FILE$1, "utf-8"));
441
+ } catch {
442
+ return {};
431
443
  }
432
- filterAndJoin(arr) {
433
- return arr.filter(Boolean).join(" ");
444
+ }
445
+ function saveGlobalConfig(config) {
446
+ mkdirSync(CONFIG_DIR, { recursive: true });
447
+ writeFileSync(CONFIG_FILE$1, `${JSON.stringify(config, null, 2)}\n`);
448
+ }
449
+ function loadProjectConfig() {
450
+ let dir = process.cwd();
451
+ while (true) {
452
+ const file = join(dir, PROJECT_FILE);
453
+ if (existsSync(file)) try {
454
+ return JSON.parse(readFileSync(file, "utf-8"));
455
+ } catch {
456
+ return {};
457
+ }
458
+ const parent = dirname(dir);
459
+ if (parent === dir) break;
460
+ dir = parent;
434
461
  }
435
- formatLogObj(logObj, opts) {
436
- const message = this.formatArgs(logObj.args, opts);
437
- if (logObj.type === "box") return "\n" + [
438
- bracket(logObj.tag),
439
- logObj.title && logObj.title,
440
- ...message.split("\n")
441
- ].filter(Boolean).map((l) => " > " + l).join("\n") + "\n";
442
- return this.filterAndJoin([
443
- bracket(logObj.type),
444
- bracket(logObj.tag),
445
- message
446
- ]);
462
+ return {};
463
+ }
464
+ function resolveApp() {
465
+ const project = loadProjectConfig();
466
+ if (!project.apps) return void 0;
467
+ const cwd = process.cwd();
468
+ for (const [dir, app] of Object.entries(project.apps)) {
469
+ const full = resolve(dir);
470
+ if (cwd === full || cwd.startsWith(`${full}/`)) return app;
447
471
  }
448
- log(logObj, ctx) {
449
- return writeStream(this.formatLogObj(logObj, {
450
- columns: ctx.options.stdout.columns || 0,
451
- ...ctx.options.formatOptions
452
- }) + "\n", logObj.level < 2 ? ctx.options.stderr || process.stderr : ctx.options.stdout || process.stdout);
472
+ }
473
+ function isJwtExpired(jwt) {
474
+ try {
475
+ const payload = JSON.parse(Buffer.from(jwt.split(".")[1], "base64url").toString());
476
+ return Date.now() >= (payload.exp ?? 0) * 1e3;
477
+ } catch {
478
+ return true;
453
479
  }
454
- };
455
-
456
- //#endregion
457
- //#region ../../node_modules/consola/dist/shared/consola.DXBYu-KD.mjs
458
- const { env = {}, argv = [], platform = "" } = typeof process === "undefined" ? {} : process;
459
- const isDisabled = "NO_COLOR" in env || argv.includes("--no-color");
460
- const isForced = "FORCE_COLOR" in env || argv.includes("--color");
461
- const isWindows = platform === "win32";
462
- const isDumbTerminal = env.TERM === "dumb";
463
- const isCompatibleTerminal = tty && tty.isatty && tty.isatty(1) && env.TERM && !isDumbTerminal;
464
- const isCI = "CI" in env && ("GITHUB_ACTIONS" in env || "GITLAB_CI" in env || "CIRCLECI" in env);
465
- const isColorSupported = !isDisabled && (isForced || isWindows && !isDumbTerminal || isCompatibleTerminal || isCI);
466
- function replaceClose(index, string, close, replace, head = string.slice(0, Math.max(0, index)) + replace, tail = string.slice(Math.max(0, index + close.length)), next = tail.indexOf(close)) {
467
- return head + (next < 0 ? tail : replaceClose(next, tail, close, replace));
468
480
  }
469
- function clearBleed(index, string, open, close, replace) {
470
- return index < 0 ? open + string + close : open + replaceClose(index, string, close, replace) + close;
481
+ function stripTrailingSlash(url) {
482
+ return url.replace(/\/$/, "");
471
483
  }
472
- function filterEmpty(open, close, replace = open, at = open.length + 1) {
473
- return (string) => string || !(string === "" || string === void 0) ? clearBleed(("" + string).indexOf(close, at), string, open, close, replace) : "";
484
+ /**
485
+ * Set the active organization and obtain a JWT.
486
+ * Used by login, switch, and token refresh.
487
+ */
488
+ async function setActiveAndGetJwt(appUrl, sessionToken, organizationId) {
489
+ const base = stripTrailingSlash(appUrl);
490
+ if (!(await fetch(`${base}/api/auth/organization/set-active`, {
491
+ method: "POST",
492
+ headers: {
493
+ "Content-Type": "application/json",
494
+ Authorization: `Bearer ${sessionToken}`
495
+ },
496
+ body: JSON.stringify({ organizationId })
497
+ })).ok) return void 0;
498
+ const tokenRes = await fetch(`${base}/api/auth/token`, { headers: { Authorization: `Bearer ${sessionToken}` } });
499
+ if (!tokenRes.ok) return void 0;
500
+ return (await tokenRes.json()).token;
474
501
  }
475
- function init(open, close, replace) {
476
- return filterEmpty(`\x1B[${open}m`, `\x1B[${close}m`, replace);
502
+ async function refreshJwt(config) {
503
+ if (!config.sessionToken || !config.appUrl || !config.organization?.id) return;
504
+ return setActiveAndGetJwt(config.appUrl, config.sessionToken, config.organization.id);
477
505
  }
478
- const colorDefs = {
479
- reset: init(0, 0),
480
- bold: init(1, 22, "\x1B[22m\x1B[1m"),
481
- dim: init(2, 22, "\x1B[22m\x1B[2m"),
482
- italic: init(3, 23),
483
- underline: init(4, 24),
484
- inverse: init(7, 27),
485
- hidden: init(8, 28),
486
- strikethrough: init(9, 29),
487
- black: init(30, 39),
488
- red: init(31, 39),
489
- green: init(32, 39),
490
- yellow: init(33, 39),
491
- blue: init(34, 39),
492
- magenta: init(35, 39),
493
- cyan: init(36, 39),
494
- white: init(37, 39),
495
- gray: init(90, 39),
496
- bgBlack: init(40, 49),
497
- bgRed: init(41, 49),
498
- bgGreen: init(42, 49),
499
- bgYellow: init(43, 49),
500
- bgBlue: init(44, 49),
501
- bgMagenta: init(45, 49),
502
- bgCyan: init(46, 49),
503
- bgWhite: init(47, 49),
504
- blackBright: init(90, 39),
505
- redBright: init(91, 39),
506
- greenBright: init(92, 39),
507
- yellowBright: init(93, 39),
508
- blueBright: init(94, 39),
509
- magentaBright: init(95, 39),
510
- cyanBright: init(96, 39),
511
- whiteBright: init(97, 39),
512
- bgBlackBright: init(100, 49),
513
- bgRedBright: init(101, 49),
514
- bgGreenBright: init(102, 49),
515
- bgYellowBright: init(103, 49),
516
- bgBlueBright: init(104, 49),
517
- bgMagentaBright: init(105, 49),
518
- bgCyanBright: init(106, 49),
519
- bgWhiteBright: init(107, 49)
520
- };
521
- function createColors(useColor = isColorSupported) {
522
- return useColor ? colorDefs : Object.fromEntries(Object.keys(colorDefs).map((key) => [key, String]));
506
+ async function getToken() {
507
+ const envToken = process.env.AUIX_TOKEN;
508
+ if (envToken) return envToken;
509
+ const config = loadGlobalConfig();
510
+ if (!config.token) return void 0;
511
+ if (!isJwtExpired(config.token)) return config.token;
512
+ const fresh = await refreshJwt(config);
513
+ if (fresh) {
514
+ saveGlobalConfig({
515
+ ...config,
516
+ token: fresh
517
+ });
518
+ return fresh;
519
+ }
523
520
  }
524
- const colors = createColors();
525
- function getColor$1(color, fallback = "reset") {
526
- return colors[color] || colors[fallback];
521
+ async function requireToken() {
522
+ const token = await getToken();
523
+ if (!token) throw new Error("Not authenticated. Run `auix login` or set AUIX_TOKEN.");
524
+ return token;
527
525
  }
528
- const ansiRegex$1 = [String.raw`[\u001B\u009B][[\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\d\/#&.:=?%@~_]+)*|[a-zA-Z\d]+(?:;[-a-zA-Z\d\/#&.:=?%@~_]*)*)?\u0007)`, String.raw`(?:(?:\d{1,4}(?:;\d{0,4})*)?[\dA-PR-TZcf-nq-uy=><~]))`].join("|");
529
- function stripAnsi$1(text) {
530
- return text.replace(new RegExp(ansiRegex$1, "g"), "");
526
+ function getBaseUrl() {
527
+ return process.env.AUIX_BASE_URL ?? loadGlobalConfig().baseUrl ?? DEFAULT_BASE_URL;
531
528
  }
532
- const boxStylePresets = {
533
- solid: {
534
- tl: "┌",
535
- tr: "",
536
- bl: "└",
537
- br: "┘",
538
- h: "─",
539
- v: ""
540
- },
541
- double: {
542
- tl: "╔",
543
- tr: "╗",
544
- bl: "╚",
545
- br: "╝",
546
- h: "═",
547
- v: "║"
548
- },
549
- doubleSingle: {
550
- tl: "╓",
551
- tr: "╖",
552
- bl: "╙",
553
- br: "╜",
554
- h: "─",
555
- v: "║"
556
- },
557
- doubleSingleRounded: {
558
- tl: "╭",
559
- tr: "╮",
560
- bl: "╰",
561
- br: "╯",
562
- h: "─",
563
- v: "║"
564
- },
565
- singleThick: {
566
- tl: "┏",
567
- tr: "┓",
568
- bl: "┗",
569
- br: "┛",
570
- h: "━",
571
- v: "┃"
572
- },
573
- singleDouble: {
574
- tl: "╒",
575
- tr: "╕",
576
- bl: "╘",
577
- br: "╛",
578
- h: "═",
579
- v: "│"
580
- },
581
- singleDoubleRounded: {
582
- tl: "╭",
583
- tr: "╮",
584
- bl: "╰",
585
- br: "╯",
586
- h: "═",
587
- v: "│"
588
- },
589
- rounded: {
590
- tl: "╭",
591
- tr: "╮",
592
- bl: "╰",
593
- br: "╯",
594
- h: "─",
595
- v: "│"
529
+ function getAppUrl() {
530
+ return process.env.AUIX_APP_URL ?? loadGlobalConfig().appUrl ?? DEFAULT_APP_URL;
531
+ }
532
+ const SESSION_FILE = join(CONFIG_DIR, "session.json");
533
+ function loadSession() {
534
+ if (!existsSync(SESSION_FILE)) return void 0;
535
+ try {
536
+ const session = JSON.parse(readFileSync(SESSION_FILE, "utf-8"));
537
+ if (new Date(session.expiresAt) <= /* @__PURE__ */ new Date()) return;
538
+ return session;
539
+ } catch {
540
+ return;
596
541
  }
597
- };
598
- const defaultStyle = {
599
- borderColor: "white",
600
- borderStyle: "rounded",
601
- valign: "center",
602
- padding: 2,
603
- marginLeft: 1,
604
- marginTop: 1,
605
- marginBottom: 1
606
- };
607
- function box(text, _opts = {}) {
608
- const opts = {
609
- ..._opts,
610
- style: {
611
- ...defaultStyle,
612
- ..._opts.style
542
+ }
543
+ function saveSession(session) {
544
+ mkdirSync(CONFIG_DIR, { recursive: true });
545
+ writeFileSync(SESSION_FILE, `${JSON.stringify(session, null, 2)}\n`);
546
+ }
547
+ //#endregion
548
+ //#region src/utils.ts
549
+ async function apiRequest(path, body) {
550
+ const baseUrl = getBaseUrl().replace(/\/$/, "");
551
+ return fetch(`${baseUrl}${path}`, {
552
+ method: "POST",
553
+ headers: {
554
+ "Content-Type": "application/json",
555
+ Authorization: `Bearer ${await requireToken()}`
556
+ },
557
+ body: JSON.stringify(body)
558
+ });
559
+ }
560
+ async function apiRequestWithToken(path, body, token) {
561
+ const baseUrl = getBaseUrl().replace(/\/$/, "");
562
+ return fetch(`${baseUrl}${path}`, {
563
+ method: "POST",
564
+ headers: {
565
+ "Content-Type": "application/json",
566
+ Authorization: `Bearer ${token}`
567
+ },
568
+ body: JSON.stringify(body)
569
+ });
570
+ }
571
+ async function apiRequestNoAuth(path, body) {
572
+ const baseUrl = getBaseUrl().replace(/\/$/, "");
573
+ return fetch(`${baseUrl}${path}`, {
574
+ method: "POST",
575
+ headers: { "Content-Type": "application/json" },
576
+ body: JSON.stringify(body)
577
+ });
578
+ }
579
+ function logError(message) {
580
+ console.error(`Error: ${message}`);
581
+ process.exit(1);
582
+ }
583
+ function maskValue(value) {
584
+ if (value.length <= 4) return "****";
585
+ return `${value.slice(0, 2)}****${value.slice(-2)}`;
586
+ }
587
+ //#endregion
588
+ //#region src/actions.ts
589
+ async function callAction(name, args) {
590
+ const baseUrl = getBaseUrl().replace(/\/$/, "");
591
+ const token = await requireToken();
592
+ const res = await fetch(`${baseUrl}/v1/actions/${name}`, {
593
+ method: "POST",
594
+ headers: {
595
+ "Content-Type": "application/json",
596
+ Authorization: `Bearer ${token}`
597
+ },
598
+ body: JSON.stringify(args)
599
+ });
600
+ if (!res.ok) {
601
+ const text = await res.text().catch(() => "");
602
+ let msg;
603
+ try {
604
+ msg = JSON.parse(text).error ?? text;
605
+ } catch {
606
+ msg = text;
613
607
  }
614
- };
615
- const textLines = text.split("\n");
616
- const boxLines = [];
617
- const _color = getColor$1(opts.style.borderColor);
618
- const borderStyle = { ...typeof opts.style.borderStyle === "string" ? boxStylePresets[opts.style.borderStyle] || boxStylePresets.solid : opts.style.borderStyle };
619
- if (_color) for (const key in borderStyle) borderStyle[key] = _color(borderStyle[key]);
620
- const paddingOffset = opts.style.padding % 2 === 0 ? opts.style.padding : opts.style.padding + 1;
621
- const height = textLines.length + paddingOffset;
622
- const width = Math.max(...textLines.map((line) => stripAnsi$1(line).length), opts.title ? stripAnsi$1(opts.title).length : 0) + paddingOffset;
623
- const widthOffset = width + paddingOffset;
624
- const leftSpace = opts.style.marginLeft > 0 ? " ".repeat(opts.style.marginLeft) : "";
625
- if (opts.style.marginTop > 0) boxLines.push("".repeat(opts.style.marginTop));
626
- if (opts.title) {
627
- const title = _color ? _color(opts.title) : opts.title;
628
- const left = borderStyle.h.repeat(Math.floor((width - stripAnsi$1(opts.title).length) / 2));
629
- const right = borderStyle.h.repeat(width - stripAnsi$1(opts.title).length - stripAnsi$1(left).length + paddingOffset);
630
- boxLines.push(`${leftSpace}${borderStyle.tl}${left}${title}${right}${borderStyle.tr}`);
631
- } else boxLines.push(`${leftSpace}${borderStyle.tl}${borderStyle.h.repeat(widthOffset)}${borderStyle.tr}`);
632
- const valignOffset = opts.style.valign === "center" ? Math.floor((height - textLines.length) / 2) : opts.style.valign === "top" ? height - textLines.length - paddingOffset : height - textLines.length;
633
- for (let i = 0; i < height; i++) if (i < valignOffset || i >= valignOffset + textLines.length) boxLines.push(`${leftSpace}${borderStyle.v}${" ".repeat(widthOffset)}${borderStyle.v}`);
634
- else {
635
- const line = textLines[i - valignOffset];
636
- const left = " ".repeat(paddingOffset);
637
- const right = " ".repeat(width - stripAnsi$1(line).length);
638
- boxLines.push(`${leftSpace}${borderStyle.v}${left}${line}${right}${borderStyle.v}`);
608
+ logError(`${name} failed (${res.status}): ${msg}`);
639
609
  }
640
- boxLines.push(`${leftSpace}${borderStyle.bl}${borderStyle.h.repeat(widthOffset)}${borderStyle.br}`);
641
- if (opts.style.marginBottom > 0) boxLines.push("".repeat(opts.style.marginBottom));
642
- return boxLines.join("\n");
610
+ return res.json();
643
611
  }
644
-
645
612
  //#endregion
646
- //#region ../../node_modules/consola/dist/index.mjs
647
- const r = Object.create(null), i = (e) => globalThis.process?.env || import.meta.env || globalThis.Deno?.env.toObject() || globalThis.__env__ || (e ? r : globalThis), o = new Proxy(r, {
648
- get(e, s) {
649
- return i()[s] ?? r[s];
613
+ //#region src/commands/audit-list.ts
614
+ const auditListCommand = defineCommand({
615
+ meta: {
616
+ name: "list",
617
+ description: "Query audit logs"
650
618
  },
651
- has(e, s) {
652
- return s in i() || s in r;
619
+ args: {
620
+ type: {
621
+ type: "string",
622
+ description: "Filter by resource type"
623
+ },
624
+ action: {
625
+ type: "string",
626
+ description: "created, updated, deleted, or accessed"
627
+ },
628
+ limit: {
629
+ type: "string",
630
+ description: "Max results (default 50)"
631
+ }
653
632
  },
654
- set(e, s, E) {
655
- const B = i(true);
656
- return B[s] = E, true;
633
+ async run({ args }) {
634
+ const data = await callAction("auix__audit_log_query", {
635
+ resourceType: args.type,
636
+ action: args.action,
637
+ limit: args.limit ? Number(args.limit) : void 0
638
+ });
639
+ if (data.items.length === 0) {
640
+ console.log("No audit logs found.");
641
+ return;
642
+ }
643
+ for (const a of data.items) {
644
+ const time = new Date(a.createdAt).toISOString().slice(0, 19);
645
+ const actor = a.actorName ?? "system";
646
+ console.log(` ${time} ${actor.padEnd(16)} ${a.summary}`);
647
+ }
648
+ console.log(`\nShowing ${data.items.length} of ${data.total} logs`);
649
+ }
650
+ });
651
+ //#endregion
652
+ //#region src/commands/branch-create.ts
653
+ const branchCreateCommand = defineCommand({
654
+ meta: {
655
+ name: "branch create",
656
+ description: "Create an env branch"
657
657
  },
658
- deleteProperty(e, s) {
659
- if (!s) return false;
660
- const E = i(true);
661
- return delete E[s], true;
658
+ args: {
659
+ name: {
660
+ type: "positional",
661
+ description: "Branch name",
662
+ required: true
663
+ },
664
+ "base-env": {
665
+ type: "string",
666
+ description: "Base environment (development, staging, production)"
667
+ }
662
668
  },
663
- ownKeys() {
664
- const e = i(true);
665
- return Object.keys(e);
669
+ async run({ args }) {
670
+ const res = await apiRequest("/v1/env/branch/create", {
671
+ name: args.name,
672
+ baseEnvironment: args["base-env"]
673
+ });
674
+ if (!res.ok) {
675
+ const text = await res.text().catch(() => "");
676
+ logError(`Failed to create branch (${res.status}): ${text}`);
677
+ }
678
+ const data = await res.json();
679
+ console.log(`Created branch: ${data.name}`);
666
680
  }
667
- }), t = typeof process < "u" && process.env && process.env.NODE_ENV || "", f = [
668
- ["APPVEYOR"],
669
- [
670
- "AWS_AMPLIFY",
671
- "AWS_APP_ID",
672
- { ci: true }
673
- ],
674
- ["AZURE_PIPELINES", "SYSTEM_TEAMFOUNDATIONCOLLECTIONURI"],
675
- ["AZURE_STATIC", "INPUT_AZURE_STATIC_WEB_APPS_API_TOKEN"],
676
- ["APPCIRCLE", "AC_APPCIRCLE"],
677
- ["BAMBOO", "bamboo_planKey"],
678
- ["BITBUCKET", "BITBUCKET_COMMIT"],
679
- ["BITRISE", "BITRISE_IO"],
680
- ["BUDDY", "BUDDY_WORKSPACE_ID"],
681
- ["BUILDKITE"],
682
- ["CIRCLE", "CIRCLECI"],
683
- ["CIRRUS", "CIRRUS_CI"],
684
- [
685
- "CLOUDFLARE_PAGES",
686
- "CF_PAGES",
687
- { ci: true }
688
- ],
689
- ["CODEBUILD", "CODEBUILD_BUILD_ARN"],
690
- ["CODEFRESH", "CF_BUILD_ID"],
691
- ["DRONE"],
692
- ["DRONE", "DRONE_BUILD_EVENT"],
693
- ["DSARI"],
694
- ["GITHUB_ACTIONS"],
695
- ["GITLAB", "GITLAB_CI"],
696
- ["GITLAB", "CI_MERGE_REQUEST_ID"],
697
- ["GOCD", "GO_PIPELINE_LABEL"],
698
- ["LAYERCI"],
699
- ["HUDSON", "HUDSON_URL"],
700
- ["JENKINS", "JENKINS_URL"],
701
- ["MAGNUM"],
702
- ["NETLIFY"],
703
- [
704
- "NETLIFY",
705
- "NETLIFY_LOCAL",
706
- { ci: false }
707
- ],
708
- ["NEVERCODE"],
709
- ["RENDER"],
710
- ["SAIL", "SAILCI"],
711
- ["SEMAPHORE"],
712
- ["SCREWDRIVER"],
713
- ["SHIPPABLE"],
714
- ["SOLANO", "TDDIUM"],
715
- ["STRIDER"],
716
- ["TEAMCITY", "TEAMCITY_VERSION"],
717
- ["TRAVIS"],
718
- ["VERCEL", "NOW_BUILDER"],
719
- [
720
- "VERCEL",
721
- "VERCEL",
722
- { ci: false }
723
- ],
724
- [
725
- "VERCEL",
726
- "VERCEL_ENV",
727
- { ci: false }
728
- ],
729
- ["APPCENTER", "APPCENTER_BUILD_ID"],
730
- [
731
- "CODESANDBOX",
732
- "CODESANDBOX_SSE",
733
- { ci: false }
734
- ],
735
- [
736
- "CODESANDBOX",
737
- "CODESANDBOX_HOST",
738
- { ci: false }
739
- ],
740
- ["STACKBLITZ"],
741
- ["STORMKIT"],
742
- ["CLEAVR"],
743
- ["ZEABUR"],
744
- [
745
- "CODESPHERE",
746
- "CODESPHERE_APP_ID",
747
- { ci: true }
748
- ],
749
- ["RAILWAY", "RAILWAY_PROJECT_ID"],
750
- ["RAILWAY", "RAILWAY_SERVICE_ID"],
751
- ["DENO-DEPLOY", "DENO_DEPLOYMENT_ID"],
752
- [
753
- "FIREBASE_APP_HOSTING",
754
- "FIREBASE_APP_HOSTING",
755
- { ci: true }
756
- ]
757
- ];
758
- function b() {
759
- if (globalThis.process?.env) for (const e of f) {
760
- const s = e[1] || e[0];
761
- if (globalThis.process?.env[s]) return {
762
- name: e[0].toLowerCase(),
763
- ...e[2]
764
- };
681
+ });
682
+ //#endregion
683
+ //#region ../../node_modules/consola/dist/core.mjs
684
+ const LogLevels = {
685
+ silent: Number.NEGATIVE_INFINITY,
686
+ fatal: 0,
687
+ error: 0,
688
+ warn: 1,
689
+ log: 2,
690
+ info: 3,
691
+ success: 3,
692
+ fail: 3,
693
+ ready: 3,
694
+ start: 3,
695
+ box: 3,
696
+ debug: 4,
697
+ trace: 5,
698
+ verbose: Number.POSITIVE_INFINITY
699
+ };
700
+ const LogTypes = {
701
+ silent: { level: -1 },
702
+ fatal: { level: LogLevels.fatal },
703
+ error: { level: LogLevels.error },
704
+ warn: { level: LogLevels.warn },
705
+ log: { level: LogLevels.log },
706
+ info: { level: LogLevels.info },
707
+ success: { level: LogLevels.success },
708
+ fail: { level: LogLevels.fail },
709
+ ready: { level: LogLevels.info },
710
+ start: { level: LogLevels.info },
711
+ box: { level: LogLevels.info },
712
+ debug: { level: LogLevels.debug },
713
+ trace: { level: LogLevels.trace },
714
+ verbose: { level: LogLevels.verbose }
715
+ };
716
+ function isPlainObject$1(value) {
717
+ if (value === null || typeof value !== "object") return false;
718
+ const prototype = Object.getPrototypeOf(value);
719
+ if (prototype !== null && prototype !== Object.prototype && Object.getPrototypeOf(prototype) !== null) return false;
720
+ if (Symbol.iterator in value) return false;
721
+ if (Symbol.toStringTag in value) return Object.prototype.toString.call(value) === "[object Module]";
722
+ return true;
723
+ }
724
+ function _defu(baseObject, defaults, namespace = ".", merger) {
725
+ if (!isPlainObject$1(defaults)) return _defu(baseObject, {}, namespace, merger);
726
+ const object = Object.assign({}, defaults);
727
+ for (const key in baseObject) {
728
+ if (key === "__proto__" || key === "constructor") continue;
729
+ const value = baseObject[key];
730
+ if (value === null || value === void 0) continue;
731
+ if (merger && merger(object, key, value, namespace)) continue;
732
+ if (Array.isArray(value) && Array.isArray(object[key])) object[key] = [...value, ...object[key]];
733
+ else if (isPlainObject$1(value) && isPlainObject$1(object[key])) object[key] = _defu(value, object[key], (namespace ? `${namespace}.` : "") + key.toString(), merger);
734
+ else object[key] = value;
765
735
  }
766
- return globalThis.process?.env?.SHELL === "/bin/jsh" && globalThis.process?.versions?.webcontainer ? {
767
- name: "stackblitz",
768
- ci: false
769
- } : {
770
- name: "",
771
- ci: false
772
- };
736
+ return object;
773
737
  }
774
- const l = b();
775
- l.name;
776
- function n(e) {
777
- return e ? e !== "false" : false;
738
+ function createDefu(merger) {
739
+ return (...arguments_) => arguments_.reduce((p, c) => _defu(p, c, "", merger), {});
778
740
  }
779
- const I = globalThis.process?.platform || "", T = n(o.CI) || l.ci !== false, a = n(globalThis.process?.stdout && globalThis.process?.stdout.isTTY), g = n(o.DEBUG), R = t === "test" || n(o.TEST);
780
- n(o.MINIMAL);
781
- const A = /^win/i.test(I);
782
- !n(o.NO_COLOR) && (n(o.FORCE_COLOR) || (a || A) && o.TERM);
783
- const C = (globalThis.process?.versions?.node || "").replace(/^v/, "") || null;
784
- Number(C?.split(".")[0]);
785
- const y = globalThis.process || Object.create(null), _ = { versions: {} };
786
- new Proxy(y, { get(e, s) {
787
- if (s === "env") return o;
788
- if (s in e) return e[s];
789
- if (s in _) return _[s];
790
- } });
791
- const c = globalThis.process?.release?.name === "node", O = !!globalThis.Bun || !!globalThis.process?.versions?.bun, D = !!globalThis.Deno, L = !!globalThis.fastly, S = !!globalThis.Netlify, u = !!globalThis.EdgeRuntime, N = globalThis.navigator?.userAgent === "Cloudflare-Workers", F = [
792
- [S, "netlify"],
793
- [u, "edge-light"],
794
- [N, "workerd"],
795
- [L, "fastly"],
796
- [D, "deno"],
797
- [O, "bun"],
798
- [c, "node"]
799
- ];
800
- function G() {
801
- const e = F.find((s) => s[0]);
802
- if (e) return { name: e[1] };
803
- }
804
- G()?.name;
805
- function ansiRegex({ onlyFirst = false } = {}) {
806
- const pattern = [`[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))`, "(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");
807
- return new RegExp(pattern, onlyFirst ? void 0 : "g");
808
- }
809
- const regex = ansiRegex();
810
- function stripAnsi(string) {
811
- if (typeof string !== "string") throw new TypeError(`Expected a \`string\`, got \`${typeof string}\``);
812
- return string.replace(regex, "");
813
- }
814
- function isAmbiguous(x) {
815
- return x === 161 || x === 164 || x === 167 || x === 168 || x === 170 || x === 173 || x === 174 || x >= 176 && x <= 180 || x >= 182 && x <= 186 || x >= 188 && x <= 191 || x === 198 || x === 208 || x === 215 || x === 216 || x >= 222 && x <= 225 || x === 230 || x >= 232 && x <= 234 || x === 236 || x === 237 || x === 240 || x === 242 || x === 243 || x >= 247 && x <= 250 || x === 252 || x === 254 || x === 257 || x === 273 || x === 275 || x === 283 || x === 294 || x === 295 || x === 299 || x >= 305 && x <= 307 || x === 312 || x >= 319 && x <= 322 || x === 324 || x >= 328 && x <= 331 || x === 333 || x === 338 || x === 339 || x === 358 || x === 359 || x === 363 || x === 462 || x === 464 || x === 466 || x === 468 || x === 470 || x === 472 || x === 474 || x === 476 || x === 593 || x === 609 || x === 708 || x === 711 || x >= 713 && x <= 715 || x === 717 || x === 720 || x >= 728 && x <= 731 || x === 733 || x === 735 || x >= 768 && x <= 879 || x >= 913 && x <= 929 || x >= 931 && x <= 937 || x >= 945 && x <= 961 || x >= 963 && x <= 969 || x === 1025 || x >= 1040 && x <= 1103 || x === 1105 || x === 8208 || x >= 8211 && x <= 8214 || x === 8216 || x === 8217 || x === 8220 || x === 8221 || x >= 8224 && x <= 8226 || x >= 8228 && x <= 8231 || x === 8240 || x === 8242 || x === 8243 || x === 8245 || x === 8251 || x === 8254 || x === 8308 || x === 8319 || x >= 8321 && x <= 8324 || x === 8364 || x === 8451 || x === 8453 || x === 8457 || x === 8467 || x === 8470 || x === 8481 || x === 8482 || x === 8486 || x === 8491 || x === 8531 || x === 8532 || x >= 8539 && x <= 8542 || x >= 8544 && x <= 8555 || x >= 8560 && x <= 8569 || x === 8585 || x >= 8592 && x <= 8601 || x === 8632 || x === 8633 || x === 8658 || x === 8660 || x === 8679 || x === 8704 || x === 8706 || x === 8707 || x === 8711 || x === 8712 || x === 8715 || x === 8719 || x === 8721 || x === 8725 || x === 8730 || x >= 8733 && x <= 8736 || x === 8739 || x === 8741 || x >= 8743 && x <= 8748 || x === 8750 || x >= 8756 && x <= 8759 || x === 8764 || x === 8765 || x === 8776 || x === 8780 || x === 8786 || x === 8800 || x === 8801 || x >= 8804 && x <= 8807 || x === 8810 || x === 8811 || x === 8814 || x === 8815 || x === 8834 || x === 8835 || x === 8838 || x === 8839 || x === 8853 || x === 8857 || x === 8869 || x === 8895 || x === 8978 || x >= 9312 && x <= 9449 || x >= 9451 && x <= 9547 || x >= 9552 && x <= 9587 || x >= 9600 && x <= 9615 || x >= 9618 && x <= 9621 || x === 9632 || x === 9633 || x >= 9635 && x <= 9641 || x === 9650 || x === 9651 || x === 9654 || x === 9655 || x === 9660 || x === 9661 || x === 9664 || x === 9665 || x >= 9670 && x <= 9672 || x === 9675 || x >= 9678 && x <= 9681 || x >= 9698 && x <= 9701 || x === 9711 || x === 9733 || x === 9734 || x === 9737 || x === 9742 || x === 9743 || x === 9756 || x === 9758 || x === 9792 || x === 9794 || x === 9824 || x === 9825 || x >= 9827 && x <= 9829 || x >= 9831 && x <= 9834 || x === 9836 || x === 9837 || x === 9839 || x === 9886 || x === 9887 || x === 9919 || x >= 9926 && x <= 9933 || x >= 9935 && x <= 9939 || x >= 9941 && x <= 9953 || x === 9955 || x === 9960 || x === 9961 || x >= 9963 && x <= 9969 || x === 9972 || x >= 9974 && x <= 9977 || x === 9979 || x === 9980 || x === 9982 || x === 9983 || x === 10045 || x >= 10102 && x <= 10111 || x >= 11094 && x <= 11097 || x >= 12872 && x <= 12879 || x >= 57344 && x <= 63743 || x >= 65024 && x <= 65039 || x === 65533 || x >= 127232 && x <= 127242 || x >= 127248 && x <= 127277 || x >= 127280 && x <= 127337 || x >= 127344 && x <= 127373 || x === 127375 || x === 127376 || x >= 127387 && x <= 127404 || x >= 917760 && x <= 917999 || x >= 983040 && x <= 1048573 || x >= 1048576 && x <= 1114109;
816
- }
817
- function isFullWidth(x) {
818
- return x === 12288 || x >= 65281 && x <= 65376 || x >= 65504 && x <= 65510;
819
- }
820
- function isWide(x) {
821
- return x >= 4352 && x <= 4447 || x === 8986 || x === 8987 || x === 9001 || x === 9002 || x >= 9193 && x <= 9196 || x === 9200 || x === 9203 || x === 9725 || x === 9726 || x === 9748 || x === 9749 || x >= 9776 && x <= 9783 || x >= 9800 && x <= 9811 || x === 9855 || x >= 9866 && x <= 9871 || x === 9875 || x === 9889 || x === 9898 || x === 9899 || x === 9917 || x === 9918 || x === 9924 || x === 9925 || x === 9934 || x === 9940 || x === 9962 || x === 9970 || x === 9971 || x === 9973 || x === 9978 || x === 9981 || x === 9989 || x === 9994 || x === 9995 || x === 10024 || x === 10060 || x === 10062 || x >= 10067 && x <= 10069 || x === 10071 || x >= 10133 && x <= 10135 || x === 10160 || x === 10175 || x === 11035 || x === 11036 || x === 11088 || x === 11093 || x >= 11904 && x <= 11929 || x >= 11931 && x <= 12019 || x >= 12032 && x <= 12245 || x >= 12272 && x <= 12287 || x >= 12289 && x <= 12350 || x >= 12353 && x <= 12438 || x >= 12441 && x <= 12543 || x >= 12549 && x <= 12591 || x >= 12593 && x <= 12686 || x >= 12688 && x <= 12773 || x >= 12783 && x <= 12830 || x >= 12832 && x <= 12871 || x >= 12880 && x <= 42124 || x >= 42128 && x <= 42182 || x >= 43360 && x <= 43388 || x >= 44032 && x <= 55203 || x >= 63744 && x <= 64255 || x >= 65040 && x <= 65049 || x >= 65072 && x <= 65106 || x >= 65108 && x <= 65126 || x >= 65128 && x <= 65131 || x >= 94176 && x <= 94180 || x === 94192 || x === 94193 || x >= 94208 && x <= 100343 || x >= 100352 && x <= 101589 || x >= 101631 && x <= 101640 || x >= 110576 && x <= 110579 || x >= 110581 && x <= 110587 || x === 110589 || x === 110590 || x >= 110592 && x <= 110882 || x === 110898 || x >= 110928 && x <= 110930 || x === 110933 || x >= 110948 && x <= 110951 || x >= 110960 && x <= 111355 || x >= 119552 && x <= 119638 || x >= 119648 && x <= 119670 || x === 126980 || x === 127183 || x === 127374 || x >= 127377 && x <= 127386 || x >= 127488 && x <= 127490 || x >= 127504 && x <= 127547 || x >= 127552 && x <= 127560 || x === 127568 || x === 127569 || x >= 127584 && x <= 127589 || x >= 127744 && x <= 127776 || x >= 127789 && x <= 127797 || x >= 127799 && x <= 127868 || x >= 127870 && x <= 127891 || x >= 127904 && x <= 127946 || x >= 127951 && x <= 127955 || x >= 127968 && x <= 127984 || x === 127988 || x >= 127992 && x <= 128062 || x === 128064 || x >= 128066 && x <= 128252 || x >= 128255 && x <= 128317 || x >= 128331 && x <= 128334 || x >= 128336 && x <= 128359 || x === 128378 || x === 128405 || x === 128406 || x === 128420 || x >= 128507 && x <= 128591 || x >= 128640 && x <= 128709 || x === 128716 || x >= 128720 && x <= 128722 || x >= 128725 && x <= 128727 || x >= 128732 && x <= 128735 || x === 128747 || x === 128748 || x >= 128756 && x <= 128764 || x >= 128992 && x <= 129003 || x === 129008 || x >= 129292 && x <= 129338 || x >= 129340 && x <= 129349 || x >= 129351 && x <= 129535 || x >= 129648 && x <= 129660 || x >= 129664 && x <= 129673 || x >= 129679 && x <= 129734 || x >= 129742 && x <= 129756 || x >= 129759 && x <= 129769 || x >= 129776 && x <= 129784 || x >= 131072 && x <= 196605 || x >= 196608 && x <= 262141;
822
- }
823
- function validate(codePoint) {
824
- if (!Number.isSafeInteger(codePoint)) throw new TypeError(`Expected a code point, got \`${typeof codePoint}\`.`);
741
+ const defu = createDefu();
742
+ function isPlainObject(obj) {
743
+ return Object.prototype.toString.call(obj) === "[object Object]";
825
744
  }
826
- function eastAsianWidth(codePoint, { ambiguousAsWide = false } = {}) {
827
- validate(codePoint);
828
- if (isFullWidth(codePoint) || isWide(codePoint) || ambiguousAsWide && isAmbiguous(codePoint)) return 2;
829
- return 1;
745
+ function isLogObj(arg) {
746
+ if (!isPlainObject(arg)) return false;
747
+ if (!arg.message && !arg.args) return false;
748
+ if (arg.stack) return false;
749
+ return true;
830
750
  }
831
- const emojiRegex = () => {
832
- return /[#*0-9]\uFE0F?\u20E3|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26AA\u26B0\u26B1\u26BD\u26BE\u26C4\u26C8\u26CF\u26D1\u26E9\u26F0-\u26F5\u26F7\u26F8\u26FA\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2757\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B55\u3030\u303D\u3297\u3299]\uFE0F?|[\u261D\u270C\u270D](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\u270A\u270B](?:\uD83C[\uDFFB-\uDFFF])?|[\u23E9-\u23EC\u23F0\u23F3\u25FD\u2693\u26A1\u26AB\u26C5\u26CE\u26D4\u26EA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2795-\u2797\u27B0\u27BF\u2B50]|\u26D3\uFE0F?(?:\u200D\uD83D\uDCA5)?|\u26F9(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\u2764\uFE0F?(?:\u200D(?:\uD83D\uDD25|\uD83E\uDE79))?|\uD83C(?:[\uDC04\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]\uFE0F?|[\uDF85\uDFC2\uDFC7](?:\uD83C[\uDFFB-\uDFFF])?|[\uDFC4\uDFCA](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDFCB\uDFCC](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF43\uDF45-\uDF4A\uDF4C-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uDDE6\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF]|\uDDE7\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF]|\uDDE8\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF7\uDDFA-\uDDFF]|\uDDE9\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF]|\uDDEA\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA]|\uDDEB\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7]|\uDDEC\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE]|\uDDED\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA]|\uDDEE\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9]|\uDDEF\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5]|\uDDF0\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF]|\uDDF1\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE]|\uDDF2\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF]|\uDDF3\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF]|\uDDF4\uD83C\uDDF2|\uDDF5\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE]|\uDDF6\uD83C\uDDE6|\uDDF7\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC]|\uDDF8\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF]|\uDDF9\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF]|\uDDFA\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF]|\uDDFB\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA]|\uDDFC\uD83C[\uDDEB\uDDF8]|\uDDFD\uD83C\uDDF0|\uDDFE\uD83C[\uDDEA\uDDF9]|\uDDFF\uD83C[\uDDE6\uDDF2\uDDFC]|\uDF44(?:\u200D\uD83D\uDFEB)?|\uDF4B(?:\u200D\uD83D\uDFE9)?|\uDFC3(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDFF3\uFE0F?(?:\u200D(?:\u26A7\uFE0F?|\uD83C\uDF08))?|\uDFF4(?:\u200D\u2620\uFE0F?|\uDB40\uDC67\uDB40\uDC62\uDB40(?:\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDC73\uDB40\uDC63\uDB40\uDC74|\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F)?)|\uD83D(?:[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3]\uFE0F?|[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC](?:\uD83C[\uDFFB-\uDFFF])?|[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4\uDEB5](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD74\uDD90](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC25\uDC27-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE41\uDE43\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEDC-\uDEDF\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB\uDFF0]|\uDC08(?:\u200D\u2B1B)?|\uDC15(?:\u200D\uD83E\uDDBA)?|\uDC26(?:\u200D(?:\u2B1B|\uD83D\uDD25))?|\uDC3B(?:\u200D\u2744\uFE0F?)?|\uDC41\uFE0F?(?:\u200D\uD83D\uDDE8\uFE0F?)?|\uDC68(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDC68\uDC69]\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE])))?))?|\uDC69(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?[\uDC68\uDC69]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?|\uDC69\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?))|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFE])))?))?|\uDC6F(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDD75(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDE2E(?:\u200D\uD83D\uDCA8)?|\uDE35(?:\u200D\uD83D\uDCAB)?|\uDE36(?:\u200D\uD83C\uDF2B\uFE0F?)?|\uDE42(?:\u200D[\u2194\u2195]\uFE0F?)?|\uDEB6(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?)|\uD83E(?:[\uDD0C\uDD0F\uDD18-\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5\uDEC3-\uDEC5\uDEF0\uDEF2-\uDEF8](?:\uD83C[\uDFFB-\uDFFF])?|[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD\uDDCF\uDDD4\uDDD6-\uDDDD](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDDDE\uDDDF](?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD0D\uDD0E\uDD10-\uDD17\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCC\uDDD0\uDDE0-\uDDFF\uDE70-\uDE7C\uDE80-\uDE89\uDE8F-\uDEC2\uDEC6\uDECE-\uDEDC\uDEDF-\uDEE9]|\uDD3C(?:\u200D[\u2640\u2642]\uFE0F?|\uD83C[\uDFFB-\uDFFF])?|\uDDCE(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDDD1(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1|\uDDD1\u200D\uD83E\uDDD2(?:\u200D\uD83E\uDDD2)?|\uDDD2(?:\u200D\uD83E\uDDD2)?))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?))?|\uDEF1(?:\uD83C(?:\uDFFB(?:\u200D\uD83E\uDEF2\uD83C[\uDFFC-\uDFFF])?|\uDFFC(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFD-\uDFFF])?|\uDFFD(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])?|\uDFFE(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFD\uDFFF])?|\uDFFF(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFE])?))?)/g;
833
- };
834
- const segmenter = globalThis.Intl?.Segmenter ? new Intl.Segmenter() : { segment: (str) => str.split("") };
835
- const defaultIgnorableCodePointRegex = /^\p{Default_Ignorable_Code_Point}$/u;
836
- function stringWidth$1(string, options = {}) {
837
- if (typeof string !== "string" || string.length === 0) return 0;
838
- const { ambiguousIsNarrow = true, countAnsiEscapeCodes = false } = options;
839
- if (!countAnsiEscapeCodes) string = stripAnsi(string);
840
- if (string.length === 0) return 0;
841
- let width = 0;
842
- const eastAsianWidthOptions = { ambiguousAsWide: !ambiguousIsNarrow };
843
- for (const { segment: character } of segmenter.segment(string)) {
844
- const codePoint = character.codePointAt(0);
845
- if (codePoint <= 31 || codePoint >= 127 && codePoint <= 159) continue;
846
- if (codePoint >= 8203 && codePoint <= 8207 || codePoint === 65279) continue;
847
- if (codePoint >= 768 && codePoint <= 879 || codePoint >= 6832 && codePoint <= 6911 || codePoint >= 7616 && codePoint <= 7679 || codePoint >= 8400 && codePoint <= 8447 || codePoint >= 65056 && codePoint <= 65071) continue;
848
- if (codePoint >= 55296 && codePoint <= 57343) continue;
849
- if (codePoint >= 65024 && codePoint <= 65039) continue;
850
- if (defaultIgnorableCodePointRegex.test(character)) continue;
851
- if (emojiRegex().test(character)) {
852
- width += 2;
853
- continue;
751
+ let paused = false;
752
+ const queue = [];
753
+ var Consola = class Consola {
754
+ options;
755
+ _lastLog;
756
+ _mockFn;
757
+ /**
758
+ * Creates an instance of Consola with specified options or defaults.
759
+ *
760
+ * @param {Partial<ConsolaOptions>} [options={}] - Configuration options for the Consola instance.
761
+ */
762
+ constructor(options = {}) {
763
+ const types = options.types || LogTypes;
764
+ this.options = defu({
765
+ ...options,
766
+ defaults: { ...options.defaults },
767
+ level: _normalizeLogLevel(options.level, types),
768
+ reporters: [...options.reporters || []]
769
+ }, {
770
+ types: LogTypes,
771
+ throttle: 1e3,
772
+ throttleMin: 5,
773
+ formatOptions: {
774
+ date: true,
775
+ colors: false,
776
+ compact: true
777
+ }
778
+ });
779
+ for (const type in types) {
780
+ const defaults = {
781
+ type,
782
+ ...this.options.defaults,
783
+ ...types[type]
784
+ };
785
+ this[type] = this._wrapLogFn(defaults);
786
+ this[type].raw = this._wrapLogFn(defaults, true);
854
787
  }
855
- width += eastAsianWidth(codePoint, eastAsianWidthOptions);
788
+ if (this.options.mockFn) this.mockTypes();
789
+ this._lastLog = {};
856
790
  }
857
- return width;
858
- }
859
- function isUnicodeSupported() {
860
- const { env } = g$1;
861
- const { TERM, TERM_PROGRAM } = env;
862
- if (g$1.platform !== "win32") return TERM !== "linux";
863
- return Boolean(env.WT_SESSION) || Boolean(env.TERMINUS_SUBLIME) || env.ConEmuTask === "{cmd::Cmder}" || TERM_PROGRAM === "Terminus-Sublime" || TERM_PROGRAM === "vscode" || TERM === "xterm-256color" || TERM === "alacritty" || TERM === "rxvt-unicode" || TERM === "rxvt-unicode-256color" || env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
864
- }
865
- const TYPE_COLOR_MAP = {
866
- info: "cyan",
867
- fail: "red",
868
- success: "green",
869
- ready: "green",
870
- start: "magenta"
871
- };
872
- const LEVEL_COLOR_MAP = {
873
- 0: "red",
874
- 1: "yellow"
875
- };
876
- const unicode = isUnicodeSupported();
877
- const s = (c, fallback) => unicode ? c : fallback;
878
- const TYPE_ICONS = {
879
- error: s("✖", "×"),
880
- fatal: s("✖", "×"),
881
- ready: s("✔", "√"),
882
- warn: s("⚠", "‼"),
883
- info: s("ℹ", "i"),
884
- success: s("✔", "√"),
885
- debug: s("⚙", "D"),
886
- trace: s("→", "→"),
887
- fail: s("✖", "×"),
888
- start: s("◐", "o"),
889
- log: ""
890
- };
891
- function stringWidth(str) {
892
- if (!(typeof Intl === "object") || !Intl.Segmenter) return stripAnsi$1(str).length;
893
- return stringWidth$1(str);
894
- }
895
- var FancyReporter = class extends BasicReporter {
896
- formatStack(stack, message, opts) {
897
- const indent = " ".repeat((opts?.errorLevel || 0) + 1);
898
- return `
899
- ${indent}` + parseStack(stack, message).map((line) => " " + line.replace(/^at +/, (m) => colors.gray(m)).replace(/\((.+)\)/, (_, m) => `(${colors.cyan(m)})`)).join(`
900
- ${indent}`);
791
+ /**
792
+ * Gets the current log level of the Consola instance.
793
+ *
794
+ * @returns {number} The current log level.
795
+ */
796
+ get level() {
797
+ return this.options.level;
901
798
  }
902
- formatType(logObj, isBadge, opts) {
903
- const typeColor = TYPE_COLOR_MAP[logObj.type] || LEVEL_COLOR_MAP[logObj.level] || "gray";
904
- if (isBadge) return getBgColor(typeColor)(colors.black(` ${logObj.type.toUpperCase()} `));
905
- const _type = typeof TYPE_ICONS[logObj.type] === "string" ? TYPE_ICONS[logObj.type] : logObj.icon || logObj.type;
906
- return _type ? getColor(typeColor)(_type) : "";
799
+ /**
800
+ * Sets the minimum log level that will be output by the instance.
801
+ *
802
+ * @param {number} level - The new log level to set.
803
+ */
804
+ set level(level) {
805
+ this.options.level = _normalizeLogLevel(level, this.options.types, this.options.level);
907
806
  }
908
- formatLogObj(logObj, opts) {
909
- const [message, ...additional] = this.formatArgs(logObj.args, opts).split("\n");
910
- if (logObj.type === "box") return box(characterFormat(message + (additional.length > 0 ? "\n" + additional.join("\n") : "")), {
911
- title: logObj.title ? characterFormat(logObj.title) : void 0,
912
- style: logObj.style
807
+ /**
808
+ * Displays a prompt to the user and returns the response.
809
+ * Throw an error if `prompt` is not supported by the current configuration.
810
+ *
811
+ * @template T
812
+ * @param {string} message - The message to display in the prompt.
813
+ * @param {T} [opts] - Optional options for the prompt. See {@link PromptOptions}.
814
+ * @returns {promise<T>} A promise that infer with the prompt options. See {@link PromptOptions}.
815
+ */
816
+ prompt(message, opts) {
817
+ if (!this.options.prompt) throw new Error("prompt is not supported!");
818
+ return this.options.prompt(message, opts);
819
+ }
820
+ /**
821
+ * Creates a new instance of Consola, inheriting options from the current instance, with possible overrides.
822
+ *
823
+ * @param {Partial<ConsolaOptions>} options - Optional overrides for the new instance. See {@link ConsolaOptions}.
824
+ * @returns {ConsolaInstance} A new Consola instance. See {@link ConsolaInstance}.
825
+ */
826
+ create(options) {
827
+ const instance = new Consola({
828
+ ...this.options,
829
+ ...options
913
830
  });
914
- const date = this.formatDate(logObj.date, opts);
915
- const coloredDate = date && colors.gray(date);
916
- const isBadge = logObj.badge ?? logObj.level < 2;
917
- const type = this.formatType(logObj, isBadge, opts);
918
- const tag = logObj.tag ? colors.gray(logObj.tag) : "";
919
- let line;
920
- const left = this.filterAndJoin([type, characterFormat(message)]);
921
- const right = this.filterAndJoin(opts.columns ? [tag, coloredDate] : [tag]);
922
- const space = (opts.columns || 0) - stringWidth(left) - stringWidth(right) - 2;
923
- line = space > 0 && (opts.columns || 0) >= 80 ? left + " ".repeat(space) + right : (right ? `${colors.gray(`[${right}]`)} ` : "") + left;
924
- line += characterFormat(additional.length > 0 ? "\n" + additional.join("\n") : "");
925
- if (logObj.type === "trace") {
926
- const _err = /* @__PURE__ */ new Error("Trace: " + logObj.message);
927
- line += this.formatStack(_err.stack || "", _err.message);
928
- }
929
- return isBadge ? "\n" + line + "\n" : line;
831
+ if (this._mockFn) instance.mockTypes(this._mockFn);
832
+ return instance;
930
833
  }
931
- };
932
- function characterFormat(str) {
933
- return str.replace(/`([^`]+)`/gm, (_, m) => colors.cyan(m)).replace(/\s+_([^_]+)_\s+/gm, (_, m) => ` ${colors.underline(m)} `);
934
- }
935
- function getColor(color = "white") {
936
- return colors[color] || colors.white;
937
- }
938
- function getBgColor(color = "bgWhite") {
939
- return colors[`bg${color[0].toUpperCase()}${color.slice(1)}`] || colors.bgWhite;
940
- }
941
- function createConsola(options = {}) {
942
- let level = _getDefaultLogLevel();
943
- if (process.env.CONSOLA_LEVEL) level = Number.parseInt(process.env.CONSOLA_LEVEL) ?? level;
944
- return createConsola$1({
945
- level,
946
- defaults: { level },
947
- stdout: process.stdout,
948
- stderr: process.stderr,
949
- prompt: (...args) => import("./prompt-ugNMxPnj.js").then((m) => m.prompt(...args)),
950
- reporters: options.reporters || [options.fancy ?? !(T || R) ? new FancyReporter() : new BasicReporter()],
951
- ...options
952
- });
953
- }
954
- function _getDefaultLogLevel() {
955
- if (g) return LogLevels.debug;
956
- if (R) return LogLevels.warn;
957
- return LogLevels.info;
958
- }
959
- const consola = createConsola();
960
-
961
- //#endregion
962
- //#region ../../node_modules/citty/dist/index.mjs
963
- function toArray(val) {
964
- if (Array.isArray(val)) return val;
965
- return val === void 0 ? [] : [val];
966
- }
967
- function formatLineColumns(lines, linePrefix = "") {
968
- const maxLengh = [];
969
- for (const line of lines) for (const [i, element] of line.entries()) maxLengh[i] = Math.max(maxLengh[i] || 0, element.length);
970
- return lines.map((l) => l.map((c, i) => linePrefix + c[i === 0 ? "padStart" : "padEnd"](maxLengh[i])).join(" ")).join("\n");
971
- }
972
- function resolveValue(input) {
973
- return typeof input === "function" ? input() : input;
974
- }
975
- var CLIError = class extends Error {
976
- constructor(message, code) {
977
- super(message);
978
- this.code = code;
979
- this.name = "CLIError";
980
- }
981
- };
982
- const NUMBER_CHAR_RE = /\d/;
983
- const STR_SPLITTERS = [
984
- "-",
985
- "_",
986
- "/",
987
- "."
988
- ];
989
- function isUppercase(char = "") {
990
- if (NUMBER_CHAR_RE.test(char)) return;
991
- return char !== char.toLowerCase();
992
- }
993
- function splitByCase(str, separators) {
994
- const splitters = separators ?? STR_SPLITTERS;
995
- const parts = [];
996
- if (!str || typeof str !== "string") return parts;
997
- let buff = "";
998
- let previousUpper;
999
- let previousSplitter;
1000
- for (const char of str) {
1001
- const isSplitter = splitters.includes(char);
1002
- if (isSplitter === true) {
1003
- parts.push(buff);
1004
- buff = "";
1005
- previousUpper = void 0;
1006
- continue;
1007
- }
1008
- const isUpper = isUppercase(char);
1009
- if (previousSplitter === false) {
1010
- if (previousUpper === false && isUpper === true) {
1011
- parts.push(buff);
1012
- buff = char;
1013
- previousUpper = isUpper;
1014
- continue;
1015
- }
1016
- if (previousUpper === true && isUpper === false && buff.length > 1) {
1017
- const lastChar = buff.at(-1);
1018
- parts.push(buff.slice(0, Math.max(0, buff.length - 1)));
1019
- buff = lastChar + char;
1020
- previousUpper = isUpper;
1021
- continue;
1022
- }
1023
- }
1024
- buff += char;
1025
- previousUpper = isUpper;
1026
- previousSplitter = isSplitter;
1027
- }
1028
- parts.push(buff);
1029
- return parts;
1030
- }
1031
- function upperFirst(str) {
1032
- return str ? str[0].toUpperCase() + str.slice(1) : "";
1033
- }
1034
- function lowerFirst(str) {
1035
- return str ? str[0].toLowerCase() + str.slice(1) : "";
1036
- }
1037
- function pascalCase(str, opts) {
1038
- return str ? (Array.isArray(str) ? str : splitByCase(str)).map((p) => upperFirst(opts?.normalize ? p.toLowerCase() : p)).join("") : "";
1039
- }
1040
- function camelCase(str, opts) {
1041
- return lowerFirst(pascalCase(str || "", opts));
1042
- }
1043
- function kebabCase(str, joiner) {
1044
- return str ? (Array.isArray(str) ? str : splitByCase(str)).map((p) => p.toLowerCase()).join(joiner ?? "-") : "";
1045
- }
1046
- function toArr(any) {
1047
- return any == void 0 ? [] : Array.isArray(any) ? any : [any];
1048
- }
1049
- function toVal(out, key, val, opts) {
1050
- let x;
1051
- const old = out[key];
1052
- const nxt = ~opts.string.indexOf(key) ? val == void 0 || val === true ? "" : String(val) : typeof val === "boolean" ? val : ~opts.boolean.indexOf(key) ? val === "false" ? false : val === "true" || (out._.push((x = +val, x * 0 === 0) ? x : val), !!val) : (x = +val, x * 0 === 0) ? x : val;
1053
- out[key] = old == void 0 ? nxt : Array.isArray(old) ? old.concat(nxt) : [old, nxt];
1054
- }
1055
- function parseRawArgs(args = [], opts = {}) {
1056
- let k;
1057
- let arr;
1058
- let arg;
1059
- let name;
1060
- let val;
1061
- const out = { _: [] };
1062
- let i = 0;
1063
- let j = 0;
1064
- let idx = 0;
1065
- const len = args.length;
1066
- const alibi = opts.alias !== void 0;
1067
- const strict = opts.unknown !== void 0;
1068
- const defaults = opts.default !== void 0;
1069
- opts.alias = opts.alias || {};
1070
- opts.string = toArr(opts.string);
1071
- opts.boolean = toArr(opts.boolean);
1072
- if (alibi) for (k in opts.alias) {
1073
- arr = opts.alias[k] = toArr(opts.alias[k]);
1074
- for (i = 0; i < arr.length; i++) (opts.alias[arr[i]] = arr.concat(k)).splice(i, 1);
1075
- }
1076
- for (i = opts.boolean.length; i-- > 0;) {
1077
- arr = opts.alias[opts.boolean[i]] || [];
1078
- for (j = arr.length; j-- > 0;) opts.boolean.push(arr[j]);
1079
- }
1080
- for (i = opts.string.length; i-- > 0;) {
1081
- arr = opts.alias[opts.string[i]] || [];
1082
- for (j = arr.length; j-- > 0;) opts.string.push(arr[j]);
1083
- }
1084
- if (defaults) for (k in opts.default) {
1085
- name = typeof opts.default[k];
1086
- arr = opts.alias[k] = opts.alias[k] || [];
1087
- if (opts[name] !== void 0) {
1088
- opts[name].push(k);
1089
- for (i = 0; i < arr.length; i++) opts[name].push(arr[i]);
1090
- }
1091
- }
1092
- const keys = strict ? Object.keys(opts.alias) : [];
1093
- for (i = 0; i < len; i++) {
1094
- arg = args[i];
1095
- if (arg === "--") {
1096
- out._ = out._.concat(args.slice(++i));
1097
- break;
1098
- }
1099
- for (j = 0; j < arg.length; j++) if (arg.charCodeAt(j) !== 45) break;
1100
- if (j === 0) out._.push(arg);
1101
- else if (arg.substring(j, j + 3) === "no-") {
1102
- name = arg.slice(Math.max(0, j + 3));
1103
- if (strict && !~keys.indexOf(name)) return opts.unknown(arg);
1104
- out[name] = false;
1105
- } else {
1106
- for (idx = j + 1; idx < arg.length; idx++) if (arg.charCodeAt(idx) === 61) break;
1107
- name = arg.substring(j, idx);
1108
- val = arg.slice(Math.max(0, ++idx)) || i + 1 === len || ("" + args[i + 1]).charCodeAt(0) === 45 || args[++i];
1109
- arr = j === 2 ? [name] : name;
1110
- for (idx = 0; idx < arr.length; idx++) {
1111
- name = arr[idx];
1112
- if (strict && !~keys.indexOf(name)) return opts.unknown("-".repeat(j) + name);
1113
- toVal(out, name, idx + 1 < arr.length || val, opts);
834
+ /**
835
+ * Creates a new Consola instance with the specified default log object properties.
836
+ *
837
+ * @param {InputLogObject} defaults - Default properties to include in any log from the new instance. See {@link InputLogObject}.
838
+ * @returns {ConsolaInstance} A new Consola instance. See {@link ConsolaInstance}.
839
+ */
840
+ withDefaults(defaults) {
841
+ return this.create({
842
+ ...this.options,
843
+ defaults: {
844
+ ...this.options.defaults,
845
+ ...defaults
1114
846
  }
1115
- }
847
+ });
1116
848
  }
1117
- if (defaults) {
1118
- for (k in opts.default) if (out[k] === void 0) out[k] = opts.default[k];
849
+ /**
850
+ * Creates a new Consola instance with a specified tag, which will be included in every log.
851
+ *
852
+ * @param {string} tag - The tag to include in each log of the new instance.
853
+ * @returns {ConsolaInstance} A new Consola instance. See {@link ConsolaInstance}.
854
+ */
855
+ withTag(tag) {
856
+ return this.withDefaults({ tag: this.options.defaults.tag ? this.options.defaults.tag + ":" + tag : tag });
1119
857
  }
1120
- if (alibi) for (k in out) {
1121
- arr = opts.alias[k] || [];
1122
- while (arr.length > 0) out[arr.shift()] = out[k];
858
+ /**
859
+ * Adds a custom reporter to the Consola instance.
860
+ * Reporters will be called for each log message, depending on their implementation and log level.
861
+ *
862
+ * @param {ConsolaReporter} reporter - The reporter to add. See {@link ConsolaReporter}.
863
+ * @returns {Consola} The current Consola instance.
864
+ */
865
+ addReporter(reporter) {
866
+ this.options.reporters.push(reporter);
867
+ return this;
1123
868
  }
1124
- return out;
1125
- }
1126
- function parseArgs(rawArgs, argsDef) {
1127
- const parseOptions = {
1128
- boolean: [],
1129
- string: [],
1130
- mixed: [],
1131
- alias: {},
1132
- default: {}
1133
- };
1134
- const args = resolveArgs(argsDef);
1135
- for (const arg of args) {
1136
- if (arg.type === "positional") continue;
1137
- if (arg.type === "string") parseOptions.string.push(arg.name);
1138
- else if (arg.type === "boolean") parseOptions.boolean.push(arg.name);
1139
- if (arg.default !== void 0) parseOptions.default[arg.name] = arg.default;
1140
- if (arg.alias) parseOptions.alias[arg.name] = arg.alias;
869
+ /**
870
+ * Removes a custom reporter from the Consola instance.
871
+ * If no reporter is specified, all reporters will be removed.
872
+ *
873
+ * @param {ConsolaReporter} reporter - The reporter to remove. See {@link ConsolaReporter}.
874
+ * @returns {Consola} The current Consola instance.
875
+ */
876
+ removeReporter(reporter) {
877
+ if (reporter) {
878
+ const i = this.options.reporters.indexOf(reporter);
879
+ if (i !== -1) return this.options.reporters.splice(i, 1);
880
+ } else this.options.reporters.splice(0);
881
+ return this;
1141
882
  }
1142
- const parsed = parseRawArgs(rawArgs, parseOptions);
1143
- const [ ...positionalArguments] = parsed._;
1144
- const parsedArgsProxy = new Proxy(parsed, { get(target, prop) {
1145
- return target[prop] ?? target[camelCase(prop)] ?? target[kebabCase(prop)];
1146
- } });
1147
- for (const [, arg] of args.entries()) if (arg.type === "positional") {
1148
- const nextPositionalArgument = positionalArguments.shift();
1149
- if (nextPositionalArgument !== void 0) parsedArgsProxy[arg.name] = nextPositionalArgument;
1150
- else if (arg.default === void 0 && arg.required !== false) throw new CLIError(`Missing required positional argument: ${arg.name.toUpperCase()}`, "EARG");
1151
- else parsedArgsProxy[arg.name] = arg.default;
1152
- } else if (arg.required && parsedArgsProxy[arg.name] === void 0) throw new CLIError(`Missing required argument: --${arg.name}`, "EARG");
1153
- return parsedArgsProxy;
1154
- }
1155
- function resolveArgs(argsDef) {
1156
- const args = [];
1157
- for (const [name, argDef] of Object.entries(argsDef || {})) args.push({
1158
- ...argDef,
1159
- name,
1160
- alias: toArray(argDef.alias)
1161
- });
1162
- return args;
1163
- }
1164
- function defineCommand(def) {
1165
- return def;
1166
- }
1167
- async function runCommand$1(cmd, opts) {
1168
- const cmdArgs = await resolveValue(cmd.args || {});
1169
- const parsedArgs = parseArgs(opts.rawArgs, cmdArgs);
1170
- const context = {
1171
- rawArgs: opts.rawArgs,
1172
- args: parsedArgs,
1173
- data: opts.data,
1174
- cmd
1175
- };
1176
- if (typeof cmd.setup === "function") await cmd.setup(context);
1177
- let result;
1178
- try {
1179
- const subCommands = await resolveValue(cmd.subCommands);
1180
- if (subCommands && Object.keys(subCommands).length > 0) {
1181
- const subCommandArgIndex = opts.rawArgs.findIndex((arg) => !arg.startsWith("-"));
1182
- const subCommandName = opts.rawArgs[subCommandArgIndex];
1183
- if (subCommandName) {
1184
- if (!subCommands[subCommandName]) throw new CLIError(`Unknown command \`${subCommandName}\``, "E_UNKNOWN_COMMAND");
1185
- const subCommand = await resolveValue(subCommands[subCommandName]);
1186
- if (subCommand) await runCommand$1(subCommand, { rawArgs: opts.rawArgs.slice(subCommandArgIndex + 1) });
1187
- } else if (!cmd.run) throw new CLIError(`No command specified.`, "E_NO_COMMAND");
1188
- }
1189
- if (typeof cmd.run === "function") result = await cmd.run(context);
1190
- } finally {
1191
- if (typeof cmd.cleanup === "function") await cmd.cleanup(context);
883
+ /**
884
+ * Replaces all reporters of the Consola instance with the specified array of reporters.
885
+ *
886
+ * @param {ConsolaReporter[]} reporters - The new reporters to set. See {@link ConsolaReporter}.
887
+ * @returns {Consola} The current Consola instance.
888
+ */
889
+ setReporters(reporters) {
890
+ this.options.reporters = Array.isArray(reporters) ? reporters : [reporters];
891
+ return this;
1192
892
  }
1193
- return { result };
1194
- }
1195
- async function resolveSubCommand(cmd, rawArgs, parent) {
1196
- const subCommands = await resolveValue(cmd.subCommands);
1197
- if (subCommands && Object.keys(subCommands).length > 0) {
1198
- const subCommandArgIndex = rawArgs.findIndex((arg) => !arg.startsWith("-"));
1199
- const subCommandName = rawArgs[subCommandArgIndex];
1200
- const subCommand = await resolveValue(subCommands[subCommandName]);
1201
- if (subCommand) return resolveSubCommand(subCommand, rawArgs.slice(subCommandArgIndex + 1), cmd);
893
+ wrapAll() {
894
+ this.wrapConsole();
895
+ this.wrapStd();
1202
896
  }
1203
- return [cmd, parent];
1204
- }
1205
- async function showUsage(cmd, parent) {
1206
- try {
1207
- consola.log(await renderUsage(cmd, parent) + "\n");
1208
- } catch (error) {
1209
- consola.error(error);
897
+ restoreAll() {
898
+ this.restoreConsole();
899
+ this.restoreStd();
1210
900
  }
1211
- }
1212
- async function renderUsage(cmd, parent) {
1213
- const cmdMeta = await resolveValue(cmd.meta || {});
1214
- const cmdArgs = resolveArgs(await resolveValue(cmd.args || {}));
1215
- const parentMeta = await resolveValue(parent?.meta || {});
1216
- const commandName = `${parentMeta.name ? `${parentMeta.name} ` : ""}` + (cmdMeta.name || process.argv[1]);
1217
- const argLines = [];
1218
- const posLines = [];
1219
- const commandsLines = [];
1220
- const usageLine = [];
1221
- for (const arg of cmdArgs) if (arg.type === "positional") {
1222
- const name = arg.name.toUpperCase();
1223
- const isRequired = arg.required !== false && arg.default === void 0;
1224
- const defaultHint = arg.default ? `="${arg.default}"` : "";
1225
- posLines.push([
1226
- "`" + name + defaultHint + "`",
1227
- arg.description || "",
1228
- arg.valueHint ? `<${arg.valueHint}>` : ""
1229
- ]);
1230
- usageLine.push(isRequired ? `<${name}>` : `[${name}]`);
1231
- } else {
1232
- const isRequired = arg.required === true && arg.default === void 0;
1233
- const argStr = (arg.type === "boolean" && arg.default === true ? [...(arg.alias || []).map((a) => `--no-${a}`), `--no-${arg.name}`].join(", ") : [...(arg.alias || []).map((a) => `-${a}`), `--${arg.name}`].join(", ")) + (arg.type === "string" && (arg.valueHint || arg.default) ? `=${arg.valueHint ? `<${arg.valueHint}>` : `"${arg.default || ""}"`}` : "");
1234
- argLines.push(["`" + argStr + (isRequired ? " (required)" : "") + "`", arg.description || ""]);
1235
- if (isRequired) usageLine.push(argStr);
901
+ /**
902
+ * Overrides console methods with Consola logging methods for consistent logging.
903
+ */
904
+ wrapConsole() {
905
+ for (const type in this.options.types) {
906
+ if (!console["__" + type]) console["__" + type] = console[type];
907
+ console[type] = this[type].raw;
908
+ }
1236
909
  }
1237
- if (cmd.subCommands) {
1238
- const commandNames = [];
1239
- const subCommands = await resolveValue(cmd.subCommands);
1240
- for (const [name, sub] of Object.entries(subCommands)) {
1241
- const meta = await resolveValue((await resolveValue(sub))?.meta);
1242
- commandsLines.push([`\`${name}\``, meta?.description || ""]);
1243
- commandNames.push(name);
910
+ /**
911
+ * Restores the original console methods, removing Consola overrides.
912
+ */
913
+ restoreConsole() {
914
+ for (const type in this.options.types) if (console["__" + type]) {
915
+ console[type] = console["__" + type];
916
+ delete console["__" + type];
1244
917
  }
1245
- usageLine.push(commandNames.join("|"));
1246
918
  }
1247
- const usageLines = [];
1248
- const version = cmdMeta.version || parentMeta.version;
1249
- usageLines.push(colors.gray(`${cmdMeta.description} (${commandName + (version ? ` v${version}` : "")})`), "");
1250
- const hasOptions = argLines.length > 0 || posLines.length > 0;
1251
- usageLines.push(`${colors.underline(colors.bold("USAGE"))} \`${commandName}${hasOptions ? " [OPTIONS]" : ""} ${usageLine.join(" ")}\``, "");
1252
- if (posLines.length > 0) {
1253
- usageLines.push(colors.underline(colors.bold("ARGUMENTS")), "");
1254
- usageLines.push(formatLineColumns(posLines, " "));
1255
- usageLines.push("");
919
+ /**
920
+ * Overrides standard output and error streams to redirect them through Consola.
921
+ */
922
+ wrapStd() {
923
+ this._wrapStream(this.options.stdout, "log");
924
+ this._wrapStream(this.options.stderr, "log");
1256
925
  }
1257
- if (argLines.length > 0) {
1258
- usageLines.push(colors.underline(colors.bold("OPTIONS")), "");
1259
- usageLines.push(formatLineColumns(argLines, " "));
1260
- usageLines.push("");
926
+ _wrapStream(stream, type) {
927
+ if (!stream) return;
928
+ if (!stream.__write) stream.__write = stream.write;
929
+ stream.write = (data) => {
930
+ this[type].raw(String(data).trim());
931
+ };
1261
932
  }
1262
- if (commandsLines.length > 0) {
1263
- usageLines.push(colors.underline(colors.bold("COMMANDS")), "");
1264
- usageLines.push(formatLineColumns(commandsLines, " "));
1265
- usageLines.push("", `Use \`${commandName} <command> --help\` for more information about a command.`);
933
+ /**
934
+ * Restores the original standard output and error streams, removing the Consola redirection.
935
+ */
936
+ restoreStd() {
937
+ this._restoreStream(this.options.stdout);
938
+ this._restoreStream(this.options.stderr);
1266
939
  }
1267
- return usageLines.filter((l) => typeof l === "string").join("\n");
1268
- }
1269
- async function runMain(cmd, opts = {}) {
1270
- const rawArgs = opts.rawArgs || process.argv.slice(2);
1271
- const showUsage$1 = opts.showUsage || showUsage;
1272
- try {
1273
- if (rawArgs.includes("--help") || rawArgs.includes("-h")) {
1274
- await showUsage$1(...await resolveSubCommand(cmd, rawArgs));
1275
- process.exit(0);
1276
- } else if (rawArgs.length === 1 && rawArgs[0] === "--version") {
1277
- const meta = typeof cmd.meta === "function" ? await cmd.meta() : await cmd.meta;
1278
- if (!meta?.version) throw new CLIError("No version specified", "E_NO_VERSION");
1279
- consola.log(meta.version);
1280
- } else await runCommand$1(cmd, { rawArgs });
1281
- } catch (error) {
1282
- const isCLIError = error instanceof CLIError;
1283
- if (!isCLIError) consola.error(error, "\n");
1284
- if (isCLIError) await showUsage$1(...await resolveSubCommand(cmd, rawArgs));
1285
- consola.error(error.message);
1286
- process.exit(1);
940
+ _restoreStream(stream) {
941
+ if (!stream) return;
942
+ if (stream.__write) {
943
+ stream.write = stream.__write;
944
+ delete stream.__write;
945
+ }
1287
946
  }
1288
- }
1289
-
1290
- //#endregion
1291
- //#region ../env/dist/index.js
1292
- function parseEnvString(content) {
1293
- const result = {};
1294
- for (const line of content.split("\n")) {
1295
- const trimmed = line.trim();
1296
- if (!trimmed || trimmed.startsWith("#")) continue;
1297
- const eqIndex = trimmed.indexOf("=");
1298
- if (eqIndex === -1) continue;
1299
- const key = trimmed.slice(0, eqIndex).trim();
1300
- let value = trimmed.slice(eqIndex + 1).trim();
1301
- if (value.startsWith("\"") && value.endsWith("\"") || value.startsWith("'") && value.endsWith("'")) value = value.slice(1, -1);
1302
- result[key] = value;
947
+ /**
948
+ * Pauses logging, queues incoming logs until resumed.
949
+ */
950
+ pauseLogs() {
951
+ paused = true;
1303
952
  }
1304
- return result;
1305
- }
1306
- function formatEnvString(vars) {
1307
- return Object.entries(vars).map(([key, value]) => {
1308
- return `${key}=${value.includes(" ") || value.includes("#") || value.includes("\n") ? `"${value}"` : value}`;
1309
- }).join("\n");
1310
- }
1311
- function formatJsonString(vars) {
1312
- return JSON.stringify(vars, null, 2);
1313
- }
1314
- function formatYamlString(vars) {
1315
- const specialChars = /[:#{}[\],&*?|<>=!%@`\-\s]/;
1316
- return Object.entries(vars).map(([key, value]) => {
1317
- return `${key}: ${value === "" || specialChars.test(value) ? `"${value}"` : value}`;
1318
- }).join("\n");
1319
- }
1320
- function interpolateEnv(vars) {
1321
- const result = {};
1322
- for (const [key, value] of Object.entries(vars)) result[key] = value;
1323
- const pattern = /\$\{([^}]+)\}/g;
1324
- for (let i = 0; i < 10; i++) {
1325
- let changed = false;
1326
- for (const key of Object.keys(result)) {
1327
- const value = result[key];
1328
- if (!pattern.test(value)) continue;
1329
- pattern.lastIndex = 0;
1330
- const resolving = /* @__PURE__ */ new Set();
1331
- resolving.add(key);
1332
- const newValue = value.replace(pattern, (match, ref) => {
1333
- if (resolving.has(ref)) return match;
1334
- if (!(ref in result)) return match;
1335
- const refValue = result[ref];
1336
- if (pattern.test(refValue)) {
1337
- pattern.lastIndex = 0;
1338
- if ([...refValue.matchAll(/\$\{([^}]+)\}/g)].map((m) => m[1]).some((r) => resolving.has(r))) return match;
1339
- }
1340
- pattern.lastIndex = 0;
1341
- return refValue;
1342
- });
1343
- if (newValue !== value) {
1344
- result[key] = newValue;
1345
- changed = true;
1346
- }
953
+ /**
954
+ * Resumes logging, processing any queued logs.
955
+ */
956
+ resumeLogs() {
957
+ paused = false;
958
+ const _queue = queue.splice(0);
959
+ for (const item of _queue) item[0]._logFn(item[1], item[2]);
960
+ }
961
+ /**
962
+ * Replaces logging methods with mocks if a mock function is provided.
963
+ *
964
+ * @param {ConsolaOptions["mockFn"]} mockFn - The function to use for mocking logging methods. See {@link ConsolaOptions["mockFn"]}.
965
+ */
966
+ mockTypes(mockFn) {
967
+ const _mockFn = mockFn || this.options.mockFn;
968
+ this._mockFn = _mockFn;
969
+ if (typeof _mockFn !== "function") return;
970
+ for (const type in this.options.types) {
971
+ this[type] = _mockFn(type, this.options.types[type]) || this[type];
972
+ this[type].raw = this[type];
1347
973
  }
1348
- if (!changed) break;
1349
974
  }
1350
- return result;
1351
- }
1352
-
1353
- //#endregion
1354
- //#region src/config.ts
1355
- const CONFIG_DIR = join(homedir(), ".auix");
1356
- const CONFIG_FILE$1 = join(CONFIG_DIR, "config.json");
1357
- const PROJECT_FILE = ".auixrc";
1358
- const DEFAULT_BASE_URL = "https://api.auix.dev";
1359
- const DEFAULT_APP_URL = "https://auix.dev";
1360
- function loadGlobalConfig() {
1361
- if (!existsSync(CONFIG_FILE$1)) return {};
1362
- try {
1363
- return JSON.parse(readFileSync(CONFIG_FILE$1, "utf-8"));
1364
- } catch {
1365
- return {};
975
+ _wrapLogFn(defaults, isRaw) {
976
+ return (...args) => {
977
+ if (paused) {
978
+ queue.push([
979
+ this,
980
+ defaults,
981
+ args,
982
+ isRaw
983
+ ]);
984
+ return;
985
+ }
986
+ return this._logFn(defaults, args, isRaw);
987
+ };
1366
988
  }
1367
- }
1368
- function saveGlobalConfig(config) {
1369
- mkdirSync(CONFIG_DIR, { recursive: true });
1370
- writeFileSync(CONFIG_FILE$1, `${JSON.stringify(config, null, 2)}\n`);
1371
- }
1372
- function loadProjectConfig() {
1373
- let dir = process.cwd();
1374
- while (true) {
1375
- const file = join(dir, PROJECT_FILE);
1376
- if (existsSync(file)) try {
1377
- return JSON.parse(readFileSync(file, "utf-8"));
1378
- } catch {
1379
- return {};
989
+ _logFn(defaults, args, isRaw) {
990
+ if ((defaults.level || 0) > this.level) return false;
991
+ const logObj = {
992
+ date: /* @__PURE__ */ new Date(),
993
+ args: [],
994
+ ...defaults,
995
+ level: _normalizeLogLevel(defaults.level, this.options.types)
996
+ };
997
+ if (!isRaw && args.length === 1 && isLogObj(args[0])) Object.assign(logObj, args[0]);
998
+ else logObj.args = [...args];
999
+ if (logObj.message) {
1000
+ logObj.args.unshift(logObj.message);
1001
+ delete logObj.message;
1380
1002
  }
1381
- const parent = dirname(dir);
1382
- if (parent === dir) break;
1383
- dir = parent;
1003
+ if (logObj.additional) {
1004
+ if (!Array.isArray(logObj.additional)) logObj.additional = logObj.additional.split("\n");
1005
+ logObj.args.push("\n" + logObj.additional.join("\n"));
1006
+ delete logObj.additional;
1007
+ }
1008
+ logObj.type = typeof logObj.type === "string" ? logObj.type.toLowerCase() : "log";
1009
+ logObj.tag = typeof logObj.tag === "string" ? logObj.tag : "";
1010
+ const resolveLog = (newLog = false) => {
1011
+ const repeated = (this._lastLog.count || 0) - this.options.throttleMin;
1012
+ if (this._lastLog.object && repeated > 0) {
1013
+ const args2 = [...this._lastLog.object.args];
1014
+ if (repeated > 1) args2.push(`(repeated ${repeated} times)`);
1015
+ this._log({
1016
+ ...this._lastLog.object,
1017
+ args: args2
1018
+ });
1019
+ this._lastLog.count = 1;
1020
+ }
1021
+ if (newLog) {
1022
+ this._lastLog.object = logObj;
1023
+ this._log(logObj);
1024
+ }
1025
+ };
1026
+ clearTimeout(this._lastLog.timeout);
1027
+ const diffTime = this._lastLog.time && logObj.date ? logObj.date.getTime() - this._lastLog.time.getTime() : 0;
1028
+ this._lastLog.time = logObj.date;
1029
+ if (diffTime < this.options.throttle) try {
1030
+ const serializedLog = JSON.stringify([
1031
+ logObj.type,
1032
+ logObj.tag,
1033
+ logObj.args
1034
+ ]);
1035
+ const isSameLog = this._lastLog.serialized === serializedLog;
1036
+ this._lastLog.serialized = serializedLog;
1037
+ if (isSameLog) {
1038
+ this._lastLog.count = (this._lastLog.count || 0) + 1;
1039
+ if (this._lastLog.count > this.options.throttleMin) {
1040
+ this._lastLog.timeout = setTimeout(resolveLog, this.options.throttle);
1041
+ return;
1042
+ }
1043
+ }
1044
+ } catch {}
1045
+ resolveLog(true);
1384
1046
  }
1385
- return {};
1386
- }
1387
- function resolveApp() {
1388
- const project = loadProjectConfig();
1389
- if (!project.apps) return void 0;
1390
- const cwd = process.cwd();
1391
- for (const [dir, app] of Object.entries(project.apps)) {
1392
- const full = resolve(dir);
1393
- if (cwd === full || cwd.startsWith(`${full}/`)) return app;
1047
+ _log(logObj) {
1048
+ for (const reporter of this.options.reporters) reporter.log(logObj, { options: this.options });
1394
1049
  }
1050
+ };
1051
+ function _normalizeLogLevel(input, types = {}, defaultLevel = 3) {
1052
+ if (input === void 0) return defaultLevel;
1053
+ if (typeof input === "number") return input;
1054
+ if (types[input] && types[input].level !== void 0) return types[input].level;
1055
+ return defaultLevel;
1395
1056
  }
1396
- function isJwtExpired(jwt) {
1397
- try {
1398
- const payload = JSON.parse(Buffer.from(jwt.split(".")[1], "base64url").toString());
1399
- return Date.now() >= (payload.exp ?? 0) * 1e3;
1400
- } catch {
1401
- return true;
1057
+ Consola.prototype.add = Consola.prototype.addReporter;
1058
+ Consola.prototype.remove = Consola.prototype.removeReporter;
1059
+ Consola.prototype.clear = Consola.prototype.removeReporter;
1060
+ Consola.prototype.withScope = Consola.prototype.withTag;
1061
+ Consola.prototype.mock = Consola.prototype.mockTypes;
1062
+ Consola.prototype.pause = Consola.prototype.pauseLogs;
1063
+ Consola.prototype.resume = Consola.prototype.resumeLogs;
1064
+ function createConsola$1(options = {}) {
1065
+ return new Consola(options);
1066
+ }
1067
+ //#endregion
1068
+ //#region ../../node_modules/consola/dist/shared/consola.DRwqZj3T.mjs
1069
+ function parseStack(stack, message) {
1070
+ const cwd = process.cwd() + sep;
1071
+ return stack.split("\n").splice(message.split("\n").length).map((l) => l.trim().replace("file://", "").replace(cwd, ""));
1072
+ }
1073
+ function writeStream(data, stream) {
1074
+ return (stream.__write || stream.write).call(stream, data);
1075
+ }
1076
+ const bracket = (x) => x ? `[${x}]` : "";
1077
+ var BasicReporter = class {
1078
+ formatStack(stack, message, opts) {
1079
+ const indent = " ".repeat((opts?.errorLevel || 0) + 1);
1080
+ return indent + parseStack(stack, message).join(`
1081
+ ${indent}`);
1082
+ }
1083
+ formatError(err, opts) {
1084
+ const message = err.message ?? formatWithOptions(opts, err);
1085
+ const stack = err.stack ? this.formatStack(err.stack, message, opts) : "";
1086
+ const level = opts?.errorLevel || 0;
1087
+ const causedPrefix = level > 0 ? `${" ".repeat(level)}[cause]: ` : "";
1088
+ const causedError = err.cause ? "\n\n" + this.formatError(err.cause, {
1089
+ ...opts,
1090
+ errorLevel: level + 1
1091
+ }) : "";
1092
+ return causedPrefix + message + "\n" + stack + causedError;
1093
+ }
1094
+ formatArgs(args, opts) {
1095
+ return formatWithOptions(opts, ...args.map((arg) => {
1096
+ if (arg && typeof arg.stack === "string") return this.formatError(arg, opts);
1097
+ return arg;
1098
+ }));
1099
+ }
1100
+ formatDate(date, opts) {
1101
+ return opts.date ? date.toLocaleTimeString() : "";
1102
+ }
1103
+ filterAndJoin(arr) {
1104
+ return arr.filter(Boolean).join(" ");
1105
+ }
1106
+ formatLogObj(logObj, opts) {
1107
+ const message = this.formatArgs(logObj.args, opts);
1108
+ if (logObj.type === "box") return "\n" + [
1109
+ bracket(logObj.tag),
1110
+ logObj.title && logObj.title,
1111
+ ...message.split("\n")
1112
+ ].filter(Boolean).map((l) => " > " + l).join("\n") + "\n";
1113
+ return this.filterAndJoin([
1114
+ bracket(logObj.type),
1115
+ bracket(logObj.tag),
1116
+ message
1117
+ ]);
1118
+ }
1119
+ log(logObj, ctx) {
1120
+ return writeStream(this.formatLogObj(logObj, {
1121
+ columns: ctx.options.stdout.columns || 0,
1122
+ ...ctx.options.formatOptions
1123
+ }) + "\n", logObj.level < 2 ? ctx.options.stderr || process.stderr : ctx.options.stdout || process.stdout);
1124
+ }
1125
+ };
1126
+ //#endregion
1127
+ //#region ../../node_modules/consola/dist/shared/consola.DXBYu-KD.mjs
1128
+ const { env = {}, argv = [], platform = "" } = typeof process === "undefined" ? {} : process;
1129
+ const isDisabled = "NO_COLOR" in env || argv.includes("--no-color");
1130
+ const isForced = "FORCE_COLOR" in env || argv.includes("--color");
1131
+ const isWindows = platform === "win32";
1132
+ const isDumbTerminal = env.TERM === "dumb";
1133
+ const isCompatibleTerminal = tty && tty.isatty && tty.isatty(1) && env.TERM && !isDumbTerminal;
1134
+ const isCI = "CI" in env && ("GITHUB_ACTIONS" in env || "GITLAB_CI" in env || "CIRCLECI" in env);
1135
+ const isColorSupported = !isDisabled && (isForced || isWindows && !isDumbTerminal || isCompatibleTerminal || isCI);
1136
+ function replaceClose(index, string, close, replace, head = string.slice(0, Math.max(0, index)) + replace, tail = string.slice(Math.max(0, index + close.length)), next = tail.indexOf(close)) {
1137
+ return head + (next < 0 ? tail : replaceClose(next, tail, close, replace));
1138
+ }
1139
+ function clearBleed(index, string, open, close, replace) {
1140
+ return index < 0 ? open + string + close : open + replaceClose(index, string, close, replace) + close;
1141
+ }
1142
+ function filterEmpty(open, close, replace = open, at = open.length + 1) {
1143
+ return (string) => string || !(string === "" || string === void 0) ? clearBleed(("" + string).indexOf(close, at), string, open, close, replace) : "";
1144
+ }
1145
+ function init(open, close, replace) {
1146
+ return filterEmpty(`\x1B[${open}m`, `\x1B[${close}m`, replace);
1147
+ }
1148
+ const colorDefs = {
1149
+ reset: init(0, 0),
1150
+ bold: init(1, 22, "\x1B[22m\x1B[1m"),
1151
+ dim: init(2, 22, "\x1B[22m\x1B[2m"),
1152
+ italic: init(3, 23),
1153
+ underline: init(4, 24),
1154
+ inverse: init(7, 27),
1155
+ hidden: init(8, 28),
1156
+ strikethrough: init(9, 29),
1157
+ black: init(30, 39),
1158
+ red: init(31, 39),
1159
+ green: init(32, 39),
1160
+ yellow: init(33, 39),
1161
+ blue: init(34, 39),
1162
+ magenta: init(35, 39),
1163
+ cyan: init(36, 39),
1164
+ white: init(37, 39),
1165
+ gray: init(90, 39),
1166
+ bgBlack: init(40, 49),
1167
+ bgRed: init(41, 49),
1168
+ bgGreen: init(42, 49),
1169
+ bgYellow: init(43, 49),
1170
+ bgBlue: init(44, 49),
1171
+ bgMagenta: init(45, 49),
1172
+ bgCyan: init(46, 49),
1173
+ bgWhite: init(47, 49),
1174
+ blackBright: init(90, 39),
1175
+ redBright: init(91, 39),
1176
+ greenBright: init(92, 39),
1177
+ yellowBright: init(93, 39),
1178
+ blueBright: init(94, 39),
1179
+ magentaBright: init(95, 39),
1180
+ cyanBright: init(96, 39),
1181
+ whiteBright: init(97, 39),
1182
+ bgBlackBright: init(100, 49),
1183
+ bgRedBright: init(101, 49),
1184
+ bgGreenBright: init(102, 49),
1185
+ bgYellowBright: init(103, 49),
1186
+ bgBlueBright: init(104, 49),
1187
+ bgMagentaBright: init(105, 49),
1188
+ bgCyanBright: init(106, 49),
1189
+ bgWhiteBright: init(107, 49)
1190
+ };
1191
+ function createColors(useColor = isColorSupported) {
1192
+ return useColor ? colorDefs : Object.fromEntries(Object.keys(colorDefs).map((key) => [key, String]));
1193
+ }
1194
+ const colors = createColors();
1195
+ function getColor$1(color, fallback = "reset") {
1196
+ return colors[color] || colors[fallback];
1197
+ }
1198
+ const ansiRegex$1 = [String.raw`[\u001B\u009B][[\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\d\/#&.:=?%@~_]+)*|[a-zA-Z\d]+(?:;[-a-zA-Z\d\/#&.:=?%@~_]*)*)?\u0007)`, String.raw`(?:(?:\d{1,4}(?:;\d{0,4})*)?[\dA-PR-TZcf-nq-uy=><~]))`].join("|");
1199
+ function stripAnsi$1(text) {
1200
+ return text.replace(new RegExp(ansiRegex$1, "g"), "");
1201
+ }
1202
+ const boxStylePresets = {
1203
+ solid: {
1204
+ tl: "┌",
1205
+ tr: "┐",
1206
+ bl: "└",
1207
+ br: "┘",
1208
+ h: "─",
1209
+ v: "│"
1210
+ },
1211
+ double: {
1212
+ tl: "╔",
1213
+ tr: "╗",
1214
+ bl: "╚",
1215
+ br: "╝",
1216
+ h: "═",
1217
+ v: "║"
1218
+ },
1219
+ doubleSingle: {
1220
+ tl: "╓",
1221
+ tr: "╖",
1222
+ bl: "╙",
1223
+ br: "╜",
1224
+ h: "─",
1225
+ v: "║"
1226
+ },
1227
+ doubleSingleRounded: {
1228
+ tl: "╭",
1229
+ tr: "╮",
1230
+ bl: "╰",
1231
+ br: "╯",
1232
+ h: "─",
1233
+ v: "║"
1234
+ },
1235
+ singleThick: {
1236
+ tl: "┏",
1237
+ tr: "┓",
1238
+ bl: "┗",
1239
+ br: "┛",
1240
+ h: "━",
1241
+ v: "┃"
1242
+ },
1243
+ singleDouble: {
1244
+ tl: "╒",
1245
+ tr: "╕",
1246
+ bl: "╘",
1247
+ br: "╛",
1248
+ h: "═",
1249
+ v: "│"
1250
+ },
1251
+ singleDoubleRounded: {
1252
+ tl: "╭",
1253
+ tr: "╮",
1254
+ bl: "╰",
1255
+ br: "╯",
1256
+ h: "═",
1257
+ v: "│"
1258
+ },
1259
+ rounded: {
1260
+ tl: "╭",
1261
+ tr: "╮",
1262
+ bl: "╰",
1263
+ br: "╯",
1264
+ h: "─",
1265
+ v: "│"
1266
+ }
1267
+ };
1268
+ const defaultStyle = {
1269
+ borderColor: "white",
1270
+ borderStyle: "rounded",
1271
+ valign: "center",
1272
+ padding: 2,
1273
+ marginLeft: 1,
1274
+ marginTop: 1,
1275
+ marginBottom: 1
1276
+ };
1277
+ function box(text, _opts = {}) {
1278
+ const opts = {
1279
+ ..._opts,
1280
+ style: {
1281
+ ...defaultStyle,
1282
+ ..._opts.style
1283
+ }
1284
+ };
1285
+ const textLines = text.split("\n");
1286
+ const boxLines = [];
1287
+ const _color = getColor$1(opts.style.borderColor);
1288
+ const borderStyle = { ...typeof opts.style.borderStyle === "string" ? boxStylePresets[opts.style.borderStyle] || boxStylePresets.solid : opts.style.borderStyle };
1289
+ if (_color) for (const key in borderStyle) borderStyle[key] = _color(borderStyle[key]);
1290
+ const paddingOffset = opts.style.padding % 2 === 0 ? opts.style.padding : opts.style.padding + 1;
1291
+ const height = textLines.length + paddingOffset;
1292
+ const width = Math.max(...textLines.map((line) => stripAnsi$1(line).length), opts.title ? stripAnsi$1(opts.title).length : 0) + paddingOffset;
1293
+ const widthOffset = width + paddingOffset;
1294
+ const leftSpace = opts.style.marginLeft > 0 ? " ".repeat(opts.style.marginLeft) : "";
1295
+ if (opts.style.marginTop > 0) boxLines.push("".repeat(opts.style.marginTop));
1296
+ if (opts.title) {
1297
+ const title = _color ? _color(opts.title) : opts.title;
1298
+ const left = borderStyle.h.repeat(Math.floor((width - stripAnsi$1(opts.title).length) / 2));
1299
+ const right = borderStyle.h.repeat(width - stripAnsi$1(opts.title).length - stripAnsi$1(left).length + paddingOffset);
1300
+ boxLines.push(`${leftSpace}${borderStyle.tl}${left}${title}${right}${borderStyle.tr}`);
1301
+ } else boxLines.push(`${leftSpace}${borderStyle.tl}${borderStyle.h.repeat(widthOffset)}${borderStyle.tr}`);
1302
+ const valignOffset = opts.style.valign === "center" ? Math.floor((height - textLines.length) / 2) : opts.style.valign === "top" ? height - textLines.length - paddingOffset : height - textLines.length;
1303
+ for (let i = 0; i < height; i++) if (i < valignOffset || i >= valignOffset + textLines.length) boxLines.push(`${leftSpace}${borderStyle.v}${" ".repeat(widthOffset)}${borderStyle.v}`);
1304
+ else {
1305
+ const line = textLines[i - valignOffset];
1306
+ const left = " ".repeat(paddingOffset);
1307
+ const right = " ".repeat(width - stripAnsi$1(line).length);
1308
+ boxLines.push(`${leftSpace}${borderStyle.v}${left}${line}${right}${borderStyle.v}`);
1309
+ }
1310
+ boxLines.push(`${leftSpace}${borderStyle.bl}${borderStyle.h.repeat(widthOffset)}${borderStyle.br}`);
1311
+ if (opts.style.marginBottom > 0) boxLines.push("".repeat(opts.style.marginBottom));
1312
+ return boxLines.join("\n");
1313
+ }
1314
+ //#endregion
1315
+ //#region ../../node_modules/consola/dist/index.mjs
1316
+ const r = Object.create(null), i = (e) => globalThis.process?.env || import.meta.env || globalThis.Deno?.env.toObject() || globalThis.__env__ || (e ? r : globalThis), o = new Proxy(r, {
1317
+ get(e, s) {
1318
+ return i()[s] ?? r[s];
1319
+ },
1320
+ has(e, s) {
1321
+ return s in i() || s in r;
1322
+ },
1323
+ set(e, s, E) {
1324
+ const B = i(true);
1325
+ return B[s] = E, true;
1326
+ },
1327
+ deleteProperty(e, s) {
1328
+ if (!s) return false;
1329
+ const E = i(true);
1330
+ return delete E[s], true;
1331
+ },
1332
+ ownKeys() {
1333
+ const e = i(true);
1334
+ return Object.keys(e);
1402
1335
  }
1403
- }
1404
- async function refreshJwt(config) {
1405
- if (!config.sessionToken || !config.appUrl) return void 0;
1406
- const base = config.appUrl.replace(/\/$/, "");
1407
- const res = await fetch(`${base}/api/auth/token`, { headers: { Authorization: `Bearer ${config.sessionToken}` } });
1408
- if (!res.ok) return void 0;
1409
- return (await res.json()).token;
1410
- }
1411
- async function getToken() {
1412
- const envToken = process.env.AUIX_TOKEN;
1413
- if (envToken) return envToken;
1414
- const config = loadGlobalConfig();
1415
- if (!config.token) return void 0;
1416
- if (!isJwtExpired(config.token)) return config.token;
1417
- const fresh = await refreshJwt(config);
1418
- if (fresh) {
1419
- saveGlobalConfig({
1420
- ...config,
1421
- token: fresh
1422
- });
1423
- return fresh;
1336
+ }), t = typeof process < "u" && process.env && process.env.NODE_ENV || "", f = [
1337
+ ["APPVEYOR"],
1338
+ [
1339
+ "AWS_AMPLIFY",
1340
+ "AWS_APP_ID",
1341
+ { ci: true }
1342
+ ],
1343
+ ["AZURE_PIPELINES", "SYSTEM_TEAMFOUNDATIONCOLLECTIONURI"],
1344
+ ["AZURE_STATIC", "INPUT_AZURE_STATIC_WEB_APPS_API_TOKEN"],
1345
+ ["APPCIRCLE", "AC_APPCIRCLE"],
1346
+ ["BAMBOO", "bamboo_planKey"],
1347
+ ["BITBUCKET", "BITBUCKET_COMMIT"],
1348
+ ["BITRISE", "BITRISE_IO"],
1349
+ ["BUDDY", "BUDDY_WORKSPACE_ID"],
1350
+ ["BUILDKITE"],
1351
+ ["CIRCLE", "CIRCLECI"],
1352
+ ["CIRRUS", "CIRRUS_CI"],
1353
+ [
1354
+ "CLOUDFLARE_PAGES",
1355
+ "CF_PAGES",
1356
+ { ci: true }
1357
+ ],
1358
+ ["CODEBUILD", "CODEBUILD_BUILD_ARN"],
1359
+ ["CODEFRESH", "CF_BUILD_ID"],
1360
+ ["DRONE"],
1361
+ ["DRONE", "DRONE_BUILD_EVENT"],
1362
+ ["DSARI"],
1363
+ ["GITHUB_ACTIONS"],
1364
+ ["GITLAB", "GITLAB_CI"],
1365
+ ["GITLAB", "CI_MERGE_REQUEST_ID"],
1366
+ ["GOCD", "GO_PIPELINE_LABEL"],
1367
+ ["LAYERCI"],
1368
+ ["HUDSON", "HUDSON_URL"],
1369
+ ["JENKINS", "JENKINS_URL"],
1370
+ ["MAGNUM"],
1371
+ ["NETLIFY"],
1372
+ [
1373
+ "NETLIFY",
1374
+ "NETLIFY_LOCAL",
1375
+ { ci: false }
1376
+ ],
1377
+ ["NEVERCODE"],
1378
+ ["RENDER"],
1379
+ ["SAIL", "SAILCI"],
1380
+ ["SEMAPHORE"],
1381
+ ["SCREWDRIVER"],
1382
+ ["SHIPPABLE"],
1383
+ ["SOLANO", "TDDIUM"],
1384
+ ["STRIDER"],
1385
+ ["TEAMCITY", "TEAMCITY_VERSION"],
1386
+ ["TRAVIS"],
1387
+ ["VERCEL", "NOW_BUILDER"],
1388
+ [
1389
+ "VERCEL",
1390
+ "VERCEL",
1391
+ { ci: false }
1392
+ ],
1393
+ [
1394
+ "VERCEL",
1395
+ "VERCEL_ENV",
1396
+ { ci: false }
1397
+ ],
1398
+ ["APPCENTER", "APPCENTER_BUILD_ID"],
1399
+ [
1400
+ "CODESANDBOX",
1401
+ "CODESANDBOX_SSE",
1402
+ { ci: false }
1403
+ ],
1404
+ [
1405
+ "CODESANDBOX",
1406
+ "CODESANDBOX_HOST",
1407
+ { ci: false }
1408
+ ],
1409
+ ["STACKBLITZ"],
1410
+ ["STORMKIT"],
1411
+ ["CLEAVR"],
1412
+ ["ZEABUR"],
1413
+ [
1414
+ "CODESPHERE",
1415
+ "CODESPHERE_APP_ID",
1416
+ { ci: true }
1417
+ ],
1418
+ ["RAILWAY", "RAILWAY_PROJECT_ID"],
1419
+ ["RAILWAY", "RAILWAY_SERVICE_ID"],
1420
+ ["DENO-DEPLOY", "DENO_DEPLOYMENT_ID"],
1421
+ [
1422
+ "FIREBASE_APP_HOSTING",
1423
+ "FIREBASE_APP_HOSTING",
1424
+ { ci: true }
1425
+ ]
1426
+ ];
1427
+ function b() {
1428
+ if (globalThis.process?.env) for (const e of f) {
1429
+ const s = e[1] || e[0];
1430
+ if (globalThis.process?.env[s]) return {
1431
+ name: e[0].toLowerCase(),
1432
+ ...e[2]
1433
+ };
1424
1434
  }
1435
+ return globalThis.process?.env?.SHELL === "/bin/jsh" && globalThis.process?.versions?.webcontainer ? {
1436
+ name: "stackblitz",
1437
+ ci: false
1438
+ } : {
1439
+ name: "",
1440
+ ci: false
1441
+ };
1425
1442
  }
1426
- async function requireToken() {
1427
- const token = await getToken();
1428
- if (!token) throw new Error("Not authenticated. Run `auix login` or set AUIX_TOKEN.");
1429
- return token;
1430
- }
1431
- function getBaseUrl() {
1432
- return process.env.AUIX_BASE_URL ?? loadGlobalConfig().baseUrl ?? DEFAULT_BASE_URL;
1443
+ const l = b();
1444
+ l.name;
1445
+ function n(e) {
1446
+ return e ? e !== "false" : false;
1433
1447
  }
1434
- function getAppUrl() {
1435
- return process.env.AUIX_APP_URL ?? loadGlobalConfig().appUrl ?? DEFAULT_APP_URL;
1448
+ const I = globalThis.process?.platform || "", T = n(o.CI) || l.ci !== false, a = n(globalThis.process?.stdout && globalThis.process?.stdout.isTTY), g = n(o.DEBUG), R = t === "test" || n(o.TEST);
1449
+ n(o.MINIMAL);
1450
+ const A = /^win/i.test(I);
1451
+ !n(o.NO_COLOR) && (n(o.FORCE_COLOR) || (a || A) && o.TERM);
1452
+ const C = (globalThis.process?.versions?.node || "").replace(/^v/, "") || null;
1453
+ Number(C?.split(".")[0]);
1454
+ const y = globalThis.process || Object.create(null), _ = { versions: {} };
1455
+ new Proxy(y, { get(e, s) {
1456
+ if (s === "env") return o;
1457
+ if (s in e) return e[s];
1458
+ if (s in _) return _[s];
1459
+ } });
1460
+ const c = globalThis.process?.release?.name === "node", O = !!globalThis.Bun || !!globalThis.process?.versions?.bun, D = !!globalThis.Deno, L = !!globalThis.fastly, S = !!globalThis.Netlify, u = !!globalThis.EdgeRuntime, N = globalThis.navigator?.userAgent === "Cloudflare-Workers", F = [
1461
+ [S, "netlify"],
1462
+ [u, "edge-light"],
1463
+ [N, "workerd"],
1464
+ [L, "fastly"],
1465
+ [D, "deno"],
1466
+ [O, "bun"],
1467
+ [c, "node"]
1468
+ ];
1469
+ function G() {
1470
+ const e = F.find((s) => s[0]);
1471
+ if (e) return { name: e[1] };
1436
1472
  }
1437
- const SESSION_FILE = join(CONFIG_DIR, "session.json");
1438
- function loadSession() {
1439
- if (!existsSync(SESSION_FILE)) return void 0;
1440
- try {
1441
- const session = JSON.parse(readFileSync(SESSION_FILE, "utf-8"));
1442
- if (new Date(session.expiresAt) <= /* @__PURE__ */ new Date()) return;
1443
- return session;
1444
- } catch {
1445
- return;
1446
- }
1473
+ G()?.name;
1474
+ function ansiRegex({ onlyFirst = false } = {}) {
1475
+ const pattern = [`[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))`, "(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");
1476
+ return new RegExp(pattern, onlyFirst ? void 0 : "g");
1447
1477
  }
1448
- function saveSession(session) {
1449
- mkdirSync(CONFIG_DIR, { recursive: true });
1450
- writeFileSync(SESSION_FILE, `${JSON.stringify(session, null, 2)}\n`);
1478
+ const regex = ansiRegex();
1479
+ function stripAnsi(string) {
1480
+ if (typeof string !== "string") throw new TypeError(`Expected a \`string\`, got \`${typeof string}\``);
1481
+ return string.replace(regex, "");
1451
1482
  }
1452
-
1453
- //#endregion
1454
- //#region src/utils.ts
1455
- async function apiRequest(path, body) {
1456
- const baseUrl = getBaseUrl().replace(/\/$/, "");
1457
- return fetch(`${baseUrl}${path}`, {
1458
- method: "POST",
1459
- headers: {
1460
- "Content-Type": "application/json",
1461
- Authorization: `Bearer ${await requireToken()}`
1462
- },
1463
- body: JSON.stringify(body)
1464
- });
1483
+ function isAmbiguous(x) {
1484
+ return x === 161 || x === 164 || x === 167 || x === 168 || x === 170 || x === 173 || x === 174 || x >= 176 && x <= 180 || x >= 182 && x <= 186 || x >= 188 && x <= 191 || x === 198 || x === 208 || x === 215 || x === 216 || x >= 222 && x <= 225 || x === 230 || x >= 232 && x <= 234 || x === 236 || x === 237 || x === 240 || x === 242 || x === 243 || x >= 247 && x <= 250 || x === 252 || x === 254 || x === 257 || x === 273 || x === 275 || x === 283 || x === 294 || x === 295 || x === 299 || x >= 305 && x <= 307 || x === 312 || x >= 319 && x <= 322 || x === 324 || x >= 328 && x <= 331 || x === 333 || x === 338 || x === 339 || x === 358 || x === 359 || x === 363 || x === 462 || x === 464 || x === 466 || x === 468 || x === 470 || x === 472 || x === 474 || x === 476 || x === 593 || x === 609 || x === 708 || x === 711 || x >= 713 && x <= 715 || x === 717 || x === 720 || x >= 728 && x <= 731 || x === 733 || x === 735 || x >= 768 && x <= 879 || x >= 913 && x <= 929 || x >= 931 && x <= 937 || x >= 945 && x <= 961 || x >= 963 && x <= 969 || x === 1025 || x >= 1040 && x <= 1103 || x === 1105 || x === 8208 || x >= 8211 && x <= 8214 || x === 8216 || x === 8217 || x === 8220 || x === 8221 || x >= 8224 && x <= 8226 || x >= 8228 && x <= 8231 || x === 8240 || x === 8242 || x === 8243 || x === 8245 || x === 8251 || x === 8254 || x === 8308 || x === 8319 || x >= 8321 && x <= 8324 || x === 8364 || x === 8451 || x === 8453 || x === 8457 || x === 8467 || x === 8470 || x === 8481 || x === 8482 || x === 8486 || x === 8491 || x === 8531 || x === 8532 || x >= 8539 && x <= 8542 || x >= 8544 && x <= 8555 || x >= 8560 && x <= 8569 || x === 8585 || x >= 8592 && x <= 8601 || x === 8632 || x === 8633 || x === 8658 || x === 8660 || x === 8679 || x === 8704 || x === 8706 || x === 8707 || x === 8711 || x === 8712 || x === 8715 || x === 8719 || x === 8721 || x === 8725 || x === 8730 || x >= 8733 && x <= 8736 || x === 8739 || x === 8741 || x >= 8743 && x <= 8748 || x === 8750 || x >= 8756 && x <= 8759 || x === 8764 || x === 8765 || x === 8776 || x === 8780 || x === 8786 || x === 8800 || x === 8801 || x >= 8804 && x <= 8807 || x === 8810 || x === 8811 || x === 8814 || x === 8815 || x === 8834 || x === 8835 || x === 8838 || x === 8839 || x === 8853 || x === 8857 || x === 8869 || x === 8895 || x === 8978 || x >= 9312 && x <= 9449 || x >= 9451 && x <= 9547 || x >= 9552 && x <= 9587 || x >= 9600 && x <= 9615 || x >= 9618 && x <= 9621 || x === 9632 || x === 9633 || x >= 9635 && x <= 9641 || x === 9650 || x === 9651 || x === 9654 || x === 9655 || x === 9660 || x === 9661 || x === 9664 || x === 9665 || x >= 9670 && x <= 9672 || x === 9675 || x >= 9678 && x <= 9681 || x >= 9698 && x <= 9701 || x === 9711 || x === 9733 || x === 9734 || x === 9737 || x === 9742 || x === 9743 || x === 9756 || x === 9758 || x === 9792 || x === 9794 || x === 9824 || x === 9825 || x >= 9827 && x <= 9829 || x >= 9831 && x <= 9834 || x === 9836 || x === 9837 || x === 9839 || x === 9886 || x === 9887 || x === 9919 || x >= 9926 && x <= 9933 || x >= 9935 && x <= 9939 || x >= 9941 && x <= 9953 || x === 9955 || x === 9960 || x === 9961 || x >= 9963 && x <= 9969 || x === 9972 || x >= 9974 && x <= 9977 || x === 9979 || x === 9980 || x === 9982 || x === 9983 || x === 10045 || x >= 10102 && x <= 10111 || x >= 11094 && x <= 11097 || x >= 12872 && x <= 12879 || x >= 57344 && x <= 63743 || x >= 65024 && x <= 65039 || x === 65533 || x >= 127232 && x <= 127242 || x >= 127248 && x <= 127277 || x >= 127280 && x <= 127337 || x >= 127344 && x <= 127373 || x === 127375 || x === 127376 || x >= 127387 && x <= 127404 || x >= 917760 && x <= 917999 || x >= 983040 && x <= 1048573 || x >= 1048576 && x <= 1114109;
1465
1485
  }
1466
- async function apiRequestWithToken(path, body, token) {
1467
- const baseUrl = getBaseUrl().replace(/\/$/, "");
1468
- return fetch(`${baseUrl}${path}`, {
1469
- method: "POST",
1470
- headers: {
1471
- "Content-Type": "application/json",
1472
- Authorization: `Bearer ${token}`
1473
- },
1474
- body: JSON.stringify(body)
1475
- });
1486
+ function isFullWidth(x) {
1487
+ return x === 12288 || x >= 65281 && x <= 65376 || x >= 65504 && x <= 65510;
1476
1488
  }
1477
- async function apiRequestNoAuth(path, body) {
1478
- const baseUrl = getBaseUrl().replace(/\/$/, "");
1479
- return fetch(`${baseUrl}${path}`, {
1480
- method: "POST",
1481
- headers: { "Content-Type": "application/json" },
1482
- body: JSON.stringify(body)
1483
- });
1489
+ function isWide(x) {
1490
+ return x >= 4352 && x <= 4447 || x === 8986 || x === 8987 || x === 9001 || x === 9002 || x >= 9193 && x <= 9196 || x === 9200 || x === 9203 || x === 9725 || x === 9726 || x === 9748 || x === 9749 || x >= 9776 && x <= 9783 || x >= 9800 && x <= 9811 || x === 9855 || x >= 9866 && x <= 9871 || x === 9875 || x === 9889 || x === 9898 || x === 9899 || x === 9917 || x === 9918 || x === 9924 || x === 9925 || x === 9934 || x === 9940 || x === 9962 || x === 9970 || x === 9971 || x === 9973 || x === 9978 || x === 9981 || x === 9989 || x === 9994 || x === 9995 || x === 10024 || x === 10060 || x === 10062 || x >= 10067 && x <= 10069 || x === 10071 || x >= 10133 && x <= 10135 || x === 10160 || x === 10175 || x === 11035 || x === 11036 || x === 11088 || x === 11093 || x >= 11904 && x <= 11929 || x >= 11931 && x <= 12019 || x >= 12032 && x <= 12245 || x >= 12272 && x <= 12287 || x >= 12289 && x <= 12350 || x >= 12353 && x <= 12438 || x >= 12441 && x <= 12543 || x >= 12549 && x <= 12591 || x >= 12593 && x <= 12686 || x >= 12688 && x <= 12773 || x >= 12783 && x <= 12830 || x >= 12832 && x <= 12871 || x >= 12880 && x <= 42124 || x >= 42128 && x <= 42182 || x >= 43360 && x <= 43388 || x >= 44032 && x <= 55203 || x >= 63744 && x <= 64255 || x >= 65040 && x <= 65049 || x >= 65072 && x <= 65106 || x >= 65108 && x <= 65126 || x >= 65128 && x <= 65131 || x >= 94176 && x <= 94180 || x === 94192 || x === 94193 || x >= 94208 && x <= 100343 || x >= 100352 && x <= 101589 || x >= 101631 && x <= 101640 || x >= 110576 && x <= 110579 || x >= 110581 && x <= 110587 || x === 110589 || x === 110590 || x >= 110592 && x <= 110882 || x === 110898 || x >= 110928 && x <= 110930 || x === 110933 || x >= 110948 && x <= 110951 || x >= 110960 && x <= 111355 || x >= 119552 && x <= 119638 || x >= 119648 && x <= 119670 || x === 126980 || x === 127183 || x === 127374 || x >= 127377 && x <= 127386 || x >= 127488 && x <= 127490 || x >= 127504 && x <= 127547 || x >= 127552 && x <= 127560 || x === 127568 || x === 127569 || x >= 127584 && x <= 127589 || x >= 127744 && x <= 127776 || x >= 127789 && x <= 127797 || x >= 127799 && x <= 127868 || x >= 127870 && x <= 127891 || x >= 127904 && x <= 127946 || x >= 127951 && x <= 127955 || x >= 127968 && x <= 127984 || x === 127988 || x >= 127992 && x <= 128062 || x === 128064 || x >= 128066 && x <= 128252 || x >= 128255 && x <= 128317 || x >= 128331 && x <= 128334 || x >= 128336 && x <= 128359 || x === 128378 || x === 128405 || x === 128406 || x === 128420 || x >= 128507 && x <= 128591 || x >= 128640 && x <= 128709 || x === 128716 || x >= 128720 && x <= 128722 || x >= 128725 && x <= 128727 || x >= 128732 && x <= 128735 || x === 128747 || x === 128748 || x >= 128756 && x <= 128764 || x >= 128992 && x <= 129003 || x === 129008 || x >= 129292 && x <= 129338 || x >= 129340 && x <= 129349 || x >= 129351 && x <= 129535 || x >= 129648 && x <= 129660 || x >= 129664 && x <= 129673 || x >= 129679 && x <= 129734 || x >= 129742 && x <= 129756 || x >= 129759 && x <= 129769 || x >= 129776 && x <= 129784 || x >= 131072 && x <= 196605 || x >= 196608 && x <= 262141;
1484
1491
  }
1485
- function logError(message) {
1486
- console.error(`Error: ${message}`);
1487
- process.exit(1);
1492
+ function validate(codePoint) {
1493
+ if (!Number.isSafeInteger(codePoint)) throw new TypeError(`Expected a code point, got \`${typeof codePoint}\`.`);
1488
1494
  }
1489
- function maskValue(value) {
1490
- if (value.length <= 4) return "****";
1491
- return `${value.slice(0, 2)}****${value.slice(-2)}`;
1495
+ function eastAsianWidth(codePoint, { ambiguousAsWide = false } = {}) {
1496
+ validate(codePoint);
1497
+ if (isFullWidth(codePoint) || isWide(codePoint) || ambiguousAsWide && isAmbiguous(codePoint)) return 2;
1498
+ return 1;
1492
1499
  }
1493
-
1494
- //#endregion
1495
- //#region src/actions.ts
1496
- async function callAction(name, args) {
1497
- const baseUrl = getBaseUrl().replace(/\/$/, "");
1498
- const token = await requireToken();
1499
- const res = await fetch(`${baseUrl}/v1/actions/${name}`, {
1500
- method: "POST",
1501
- headers: {
1502
- "Content-Type": "application/json",
1503
- Authorization: `Bearer ${token}`
1504
- },
1505
- body: JSON.stringify(args)
1506
- });
1507
- if (!res.ok) {
1508
- const text = await res.text().catch(() => "");
1509
- let msg;
1510
- try {
1511
- msg = JSON.parse(text).error ?? text;
1512
- } catch {
1513
- msg = text;
1500
+ const emojiRegex = () => {
1501
+ return /[#*0-9]\uFE0F?\u20E3|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26AA\u26B0\u26B1\u26BD\u26BE\u26C4\u26C8\u26CF\u26D1\u26E9\u26F0-\u26F5\u26F7\u26F8\u26FA\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2757\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B55\u3030\u303D\u3297\u3299]\uFE0F?|[\u261D\u270C\u270D](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\u270A\u270B](?:\uD83C[\uDFFB-\uDFFF])?|[\u23E9-\u23EC\u23F0\u23F3\u25FD\u2693\u26A1\u26AB\u26C5\u26CE\u26D4\u26EA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2795-\u2797\u27B0\u27BF\u2B50]|\u26D3\uFE0F?(?:\u200D\uD83D\uDCA5)?|\u26F9(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\u2764\uFE0F?(?:\u200D(?:\uD83D\uDD25|\uD83E\uDE79))?|\uD83C(?:[\uDC04\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]\uFE0F?|[\uDF85\uDFC2\uDFC7](?:\uD83C[\uDFFB-\uDFFF])?|[\uDFC4\uDFCA](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDFCB\uDFCC](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF43\uDF45-\uDF4A\uDF4C-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uDDE6\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF]|\uDDE7\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF]|\uDDE8\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF7\uDDFA-\uDDFF]|\uDDE9\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF]|\uDDEA\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA]|\uDDEB\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7]|\uDDEC\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE]|\uDDED\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA]|\uDDEE\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9]|\uDDEF\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5]|\uDDF0\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF]|\uDDF1\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE]|\uDDF2\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF]|\uDDF3\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF]|\uDDF4\uD83C\uDDF2|\uDDF5\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE]|\uDDF6\uD83C\uDDE6|\uDDF7\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC]|\uDDF8\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF]|\uDDF9\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF]|\uDDFA\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF]|\uDDFB\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA]|\uDDFC\uD83C[\uDDEB\uDDF8]|\uDDFD\uD83C\uDDF0|\uDDFE\uD83C[\uDDEA\uDDF9]|\uDDFF\uD83C[\uDDE6\uDDF2\uDDFC]|\uDF44(?:\u200D\uD83D\uDFEB)?|\uDF4B(?:\u200D\uD83D\uDFE9)?|\uDFC3(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDFF3\uFE0F?(?:\u200D(?:\u26A7\uFE0F?|\uD83C\uDF08))?|\uDFF4(?:\u200D\u2620\uFE0F?|\uDB40\uDC67\uDB40\uDC62\uDB40(?:\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDC73\uDB40\uDC63\uDB40\uDC74|\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F)?)|\uD83D(?:[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3]\uFE0F?|[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC](?:\uD83C[\uDFFB-\uDFFF])?|[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4\uDEB5](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD74\uDD90](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC25\uDC27-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE41\uDE43\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEDC-\uDEDF\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB\uDFF0]|\uDC08(?:\u200D\u2B1B)?|\uDC15(?:\u200D\uD83E\uDDBA)?|\uDC26(?:\u200D(?:\u2B1B|\uD83D\uDD25))?|\uDC3B(?:\u200D\u2744\uFE0F?)?|\uDC41\uFE0F?(?:\u200D\uD83D\uDDE8\uFE0F?)?|\uDC68(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDC68\uDC69]\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE])))?))?|\uDC69(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?[\uDC68\uDC69]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?|\uDC69\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?))|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFE])))?))?|\uDC6F(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDD75(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDE2E(?:\u200D\uD83D\uDCA8)?|\uDE35(?:\u200D\uD83D\uDCAB)?|\uDE36(?:\u200D\uD83C\uDF2B\uFE0F?)?|\uDE42(?:\u200D[\u2194\u2195]\uFE0F?)?|\uDEB6(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?)|\uD83E(?:[\uDD0C\uDD0F\uDD18-\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5\uDEC3-\uDEC5\uDEF0\uDEF2-\uDEF8](?:\uD83C[\uDFFB-\uDFFF])?|[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD\uDDCF\uDDD4\uDDD6-\uDDDD](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDDDE\uDDDF](?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD0D\uDD0E\uDD10-\uDD17\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCC\uDDD0\uDDE0-\uDDFF\uDE70-\uDE7C\uDE80-\uDE89\uDE8F-\uDEC2\uDEC6\uDECE-\uDEDC\uDEDF-\uDEE9]|\uDD3C(?:\u200D[\u2640\u2642]\uFE0F?|\uD83C[\uDFFB-\uDFFF])?|\uDDCE(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDDD1(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1|\uDDD1\u200D\uD83E\uDDD2(?:\u200D\uD83E\uDDD2)?|\uDDD2(?:\u200D\uD83E\uDDD2)?))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?))?|\uDEF1(?:\uD83C(?:\uDFFB(?:\u200D\uD83E\uDEF2\uD83C[\uDFFC-\uDFFF])?|\uDFFC(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFD-\uDFFF])?|\uDFFD(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])?|\uDFFE(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFD\uDFFF])?|\uDFFF(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFE])?))?)/g;
1502
+ };
1503
+ const segmenter = globalThis.Intl?.Segmenter ? new Intl.Segmenter() : { segment: (str) => str.split("") };
1504
+ const defaultIgnorableCodePointRegex = /^\p{Default_Ignorable_Code_Point}$/u;
1505
+ function stringWidth$1(string, options = {}) {
1506
+ if (typeof string !== "string" || string.length === 0) return 0;
1507
+ const { ambiguousIsNarrow = true, countAnsiEscapeCodes = false } = options;
1508
+ if (!countAnsiEscapeCodes) string = stripAnsi(string);
1509
+ if (string.length === 0) return 0;
1510
+ let width = 0;
1511
+ const eastAsianWidthOptions = { ambiguousAsWide: !ambiguousIsNarrow };
1512
+ for (const { segment: character } of segmenter.segment(string)) {
1513
+ const codePoint = character.codePointAt(0);
1514
+ if (codePoint <= 31 || codePoint >= 127 && codePoint <= 159) continue;
1515
+ if (codePoint >= 8203 && codePoint <= 8207 || codePoint === 65279) continue;
1516
+ if (codePoint >= 768 && codePoint <= 879 || codePoint >= 6832 && codePoint <= 6911 || codePoint >= 7616 && codePoint <= 7679 || codePoint >= 8400 && codePoint <= 8447 || codePoint >= 65056 && codePoint <= 65071) continue;
1517
+ if (codePoint >= 55296 && codePoint <= 57343) continue;
1518
+ if (codePoint >= 65024 && codePoint <= 65039) continue;
1519
+ if (defaultIgnorableCodePointRegex.test(character)) continue;
1520
+ if (emojiRegex().test(character)) {
1521
+ width += 2;
1522
+ continue;
1514
1523
  }
1515
- logError(`${name} failed (${res.status}): ${msg}`);
1524
+ width += eastAsianWidth(codePoint, eastAsianWidthOptions);
1516
1525
  }
1517
- return res.json();
1526
+ return width;
1518
1527
  }
1519
-
1520
- //#endregion
1521
- //#region src/commands/audit-list.ts
1522
- const auditListCommand = defineCommand({
1523
- meta: {
1524
- name: "list",
1525
- description: "Query audit logs"
1526
- },
1527
- args: {
1528
- type: {
1529
- type: "string",
1530
- description: "Filter by resource type"
1531
- },
1532
- action: {
1533
- type: "string",
1534
- description: "created, updated, deleted, or accessed"
1535
- },
1536
- limit: {
1537
- type: "string",
1538
- description: "Max results (default 50)"
1539
- }
1540
- },
1541
- async run({ args }) {
1542
- const data = await callAction("auix__audit_log_query", {
1543
- resourceType: args.type,
1544
- action: args.action,
1545
- limit: args.limit ? Number(args.limit) : void 0
1546
- });
1547
- if (data.items.length === 0) {
1548
- console.log("No audit logs found.");
1549
- return;
1550
- }
1551
- for (const a of data.items) {
1552
- const time = new Date(a.createdAt).toISOString().slice(0, 19);
1553
- const actor = a.actorName ?? "system";
1554
- console.log(` ${time} ${actor.padEnd(16)} ${a.summary}`);
1555
- }
1556
- console.log(`\nShowing ${data.items.length} of ${data.total} logs`);
1528
+ function isUnicodeSupported() {
1529
+ const { env } = g$1;
1530
+ const { TERM, TERM_PROGRAM } = env;
1531
+ if (g$1.platform !== "win32") return TERM !== "linux";
1532
+ return Boolean(env.WT_SESSION) || Boolean(env.TERMINUS_SUBLIME) || env.ConEmuTask === "{cmd::Cmder}" || TERM_PROGRAM === "Terminus-Sublime" || TERM_PROGRAM === "vscode" || TERM === "xterm-256color" || TERM === "alacritty" || TERM === "rxvt-unicode" || TERM === "rxvt-unicode-256color" || env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
1533
+ }
1534
+ const TYPE_COLOR_MAP = {
1535
+ info: "cyan",
1536
+ fail: "red",
1537
+ success: "green",
1538
+ ready: "green",
1539
+ start: "magenta"
1540
+ };
1541
+ const LEVEL_COLOR_MAP = {
1542
+ 0: "red",
1543
+ 1: "yellow"
1544
+ };
1545
+ const unicode = isUnicodeSupported();
1546
+ const s = (c, fallback) => unicode ? c : fallback;
1547
+ const TYPE_ICONS = {
1548
+ error: s("✖", "×"),
1549
+ fatal: s("✖", "×"),
1550
+ ready: s("✔", "√"),
1551
+ warn: s("", "‼"),
1552
+ info: s("ℹ", "i"),
1553
+ success: s("✔", "√"),
1554
+ debug: s("⚙", "D"),
1555
+ trace: s("→", "→"),
1556
+ fail: s("✖", "×"),
1557
+ start: s("◐", "o"),
1558
+ log: ""
1559
+ };
1560
+ function stringWidth(str) {
1561
+ if (!(typeof Intl === "object") || !Intl.Segmenter) return stripAnsi$1(str).length;
1562
+ return stringWidth$1(str);
1563
+ }
1564
+ var FancyReporter = class extends BasicReporter {
1565
+ formatStack(stack, message, opts) {
1566
+ const indent = " ".repeat((opts?.errorLevel || 0) + 1);
1567
+ return `
1568
+ ${indent}` + parseStack(stack, message).map((line) => " " + line.replace(/^at +/, (m) => colors.gray(m)).replace(/\((.+)\)/, (_, m) => `(${colors.cyan(m)})`)).join(`
1569
+ ${indent}`);
1557
1570
  }
1558
- });
1559
-
1560
- //#endregion
1561
- //#region src/commands/branch-create.ts
1562
- const branchCreateCommand = defineCommand({
1563
- meta: {
1564
- name: "branch create",
1565
- description: "Create an env branch"
1566
- },
1567
- args: {
1568
- name: {
1569
- type: "positional",
1570
- description: "Branch name",
1571
- required: true
1572
- },
1573
- "base-env": {
1574
- type: "string",
1575
- description: "Base environment (development, staging, production)"
1576
- }
1577
- },
1578
- async run({ args }) {
1579
- const res = await apiRequest("/v1/env/branch/create", {
1580
- name: args.name,
1581
- baseEnvironment: args["base-env"]
1571
+ formatType(logObj, isBadge, opts) {
1572
+ const typeColor = TYPE_COLOR_MAP[logObj.type] || LEVEL_COLOR_MAP[logObj.level] || "gray";
1573
+ if (isBadge) return getBgColor(typeColor)(colors.black(` ${logObj.type.toUpperCase()} `));
1574
+ const _type = typeof TYPE_ICONS[logObj.type] === "string" ? TYPE_ICONS[logObj.type] : logObj.icon || logObj.type;
1575
+ return _type ? getColor(typeColor)(_type) : "";
1576
+ }
1577
+ formatLogObj(logObj, opts) {
1578
+ const [message, ...additional] = this.formatArgs(logObj.args, opts).split("\n");
1579
+ if (logObj.type === "box") return box(characterFormat(message + (additional.length > 0 ? "\n" + additional.join("\n") : "")), {
1580
+ title: logObj.title ? characterFormat(logObj.title) : void 0,
1581
+ style: logObj.style
1582
1582
  });
1583
- if (!res.ok) {
1584
- const text = await res.text().catch(() => "");
1585
- logError(`Failed to create branch (${res.status}): ${text}`);
1583
+ const date = this.formatDate(logObj.date, opts);
1584
+ const coloredDate = date && colors.gray(date);
1585
+ const isBadge = logObj.badge ?? logObj.level < 2;
1586
+ const type = this.formatType(logObj, isBadge, opts);
1587
+ const tag = logObj.tag ? colors.gray(logObj.tag) : "";
1588
+ let line;
1589
+ const left = this.filterAndJoin([type, characterFormat(message)]);
1590
+ const right = this.filterAndJoin(opts.columns ? [tag, coloredDate] : [tag]);
1591
+ const space = (opts.columns || 0) - stringWidth(left) - stringWidth(right) - 2;
1592
+ line = space > 0 && (opts.columns || 0) >= 80 ? left + " ".repeat(space) + right : (right ? `${colors.gray(`[${right}]`)} ` : "") + left;
1593
+ line += characterFormat(additional.length > 0 ? "\n" + additional.join("\n") : "");
1594
+ if (logObj.type === "trace") {
1595
+ const _err = /* @__PURE__ */ new Error("Trace: " + logObj.message);
1596
+ line += this.formatStack(_err.stack || "", _err.message);
1586
1597
  }
1587
- const data = await res.json();
1588
- console.log(`Created branch: ${data.name}`);
1598
+ return isBadge ? "\n" + line + "\n" : line;
1589
1599
  }
1590
- });
1591
-
1600
+ };
1601
+ function characterFormat(str) {
1602
+ return str.replace(/`([^`]+)`/gm, (_, m) => colors.cyan(m)).replace(/\s+_([^_]+)_\s+/gm, (_, m) => ` ${colors.underline(m)} `);
1603
+ }
1604
+ function getColor(color = "white") {
1605
+ return colors[color] || colors.white;
1606
+ }
1607
+ function getBgColor(color = "bgWhite") {
1608
+ return colors[`bg${color[0].toUpperCase()}${color.slice(1)}`] || colors.bgWhite;
1609
+ }
1610
+ function createConsola(options = {}) {
1611
+ let level = _getDefaultLogLevel();
1612
+ if (process.env.CONSOLA_LEVEL) level = Number.parseInt(process.env.CONSOLA_LEVEL) ?? level;
1613
+ return createConsola$1({
1614
+ level,
1615
+ defaults: { level },
1616
+ stdout: process.stdout,
1617
+ stderr: process.stderr,
1618
+ prompt: (...args) => import("./prompt-CoAj8htw.js").then((m) => m.prompt(...args)),
1619
+ reporters: options.reporters || [options.fancy ?? !(T || R) ? new FancyReporter() : new BasicReporter()],
1620
+ ...options
1621
+ });
1622
+ }
1623
+ function _getDefaultLogLevel() {
1624
+ if (g) return LogLevels.debug;
1625
+ if (R) return LogLevels.warn;
1626
+ return LogLevels.info;
1627
+ }
1628
+ const consola = createConsola();
1592
1629
  //#endregion
1593
1630
  //#region src/commands/branch-delete.ts
1594
1631
  const branchDeleteCommand = defineCommand({
@@ -1615,7 +1652,6 @@ const branchDeleteCommand = defineCommand({
1615
1652
  console.log(`Deleted branch: ${args.name}`);
1616
1653
  }
1617
1654
  });
1618
-
1619
1655
  //#endregion
1620
1656
  //#region src/commands/branch-list.ts
1621
1657
  const branchListCommand = defineCommand({
@@ -1657,7 +1693,6 @@ const branchListCommand = defineCommand({
1657
1693
  console.log(`\n${data.branches.length} branches`);
1658
1694
  }
1659
1695
  });
1660
-
1661
1696
  //#endregion
1662
1697
  //#region src/commands/delete.ts
1663
1698
  const deleteCommand = defineCommand({
@@ -1684,7 +1719,6 @@ const deleteCommand = defineCommand({
1684
1719
  console.log("Deleted.");
1685
1720
  }
1686
1721
  });
1687
-
1688
1722
  //#endregion
1689
1723
  //#region src/commands/diff.ts
1690
1724
  const diffCommand = defineCommand({
@@ -1774,7 +1808,6 @@ const diffCommand = defineCommand({
1774
1808
  else console.log(`\n${added} added, ${removed} removed, ${changed} changed`);
1775
1809
  }
1776
1810
  });
1777
-
1778
1811
  //#endregion
1779
1812
  //#region src/commands/dynamic-create.ts
1780
1813
  const dynamicCreateCommand = defineCommand({
@@ -1825,7 +1858,6 @@ const dynamicCreateCommand = defineCommand({
1825
1858
  console.log(` TTL: ${ttlSeconds}s`);
1826
1859
  }
1827
1860
  });
1828
-
1829
1861
  //#endregion
1830
1862
  //#region src/commands/dynamic-lease.ts
1831
1863
  const dynamicLeaseCommand = defineCommand({
@@ -1851,7 +1883,6 @@ const dynamicLeaseCommand = defineCommand({
1851
1883
  console.log(` Expires: ${new Date(data.expiresAt).toLocaleString()}`);
1852
1884
  }
1853
1885
  });
1854
-
1855
1886
  //#endregion
1856
1887
  //#region src/commands/dynamic-list.ts
1857
1888
  const dynamicListCommand = defineCommand({
@@ -1896,7 +1927,6 @@ const dynamicListCommand = defineCommand({
1896
1927
  console.log(`\n${data.secrets.length} dynamic secrets`);
1897
1928
  }
1898
1929
  });
1899
-
1900
1930
  //#endregion
1901
1931
  //#region src/commands/flow-create.ts
1902
1932
  const flowCreateCommand = defineCommand({
@@ -1959,7 +1989,6 @@ const flowCreateCommand = defineCommand({
1959
1989
  console.log(`Created flow ${data.id} (disabled by default)`);
1960
1990
  }
1961
1991
  });
1962
-
1963
1992
  //#endregion
1964
1993
  //#region src/commands/flow-delete.ts
1965
1994
  const flowDeleteCommand = defineCommand({
@@ -1982,7 +2011,6 @@ const flowDeleteCommand = defineCommand({
1982
2011
  console.log("Deleted.");
1983
2012
  }
1984
2013
  });
1985
-
1986
2014
  //#endregion
1987
2015
  //#region src/commands/flow-dispatch.ts
1988
2016
  const flowDispatchCommand = defineCommand({
@@ -2000,7 +2028,6 @@ const flowDispatchCommand = defineCommand({
2000
2028
  console.log(`Dispatched execution ${data.executionId} (${data.mode})`);
2001
2029
  }
2002
2030
  });
2003
-
2004
2031
  //#endregion
2005
2032
  //#region src/commands/flow-duplicate.ts
2006
2033
  const flowDuplicateCommand = defineCommand({
@@ -2018,7 +2045,6 @@ const flowDuplicateCommand = defineCommand({
2018
2045
  console.log(`Duplicated as ${data.id} ("${data.name}")`);
2019
2046
  }
2020
2047
  });
2021
-
2022
2048
  //#endregion
2023
2049
  //#region src/commands/flow-executions.ts
2024
2050
  const flowExecutionsCommand = defineCommand({
@@ -2054,7 +2080,6 @@ const flowExecutionsCommand = defineCommand({
2054
2080
  console.log(`\n${data.length} executions`);
2055
2081
  }
2056
2082
  });
2057
-
2058
2083
  //#endregion
2059
2084
  //#region src/commands/flow-get.ts
2060
2085
  const flowGetCommand = defineCommand({
@@ -2072,7 +2097,6 @@ const flowGetCommand = defineCommand({
2072
2097
  console.log(JSON.stringify(data, null, 2));
2073
2098
  }
2074
2099
  });
2075
-
2076
2100
  //#endregion
2077
2101
  //#region src/commands/flow-list.ts
2078
2102
  const flowListCommand = defineCommand({
@@ -2117,7 +2141,6 @@ const flowListCommand = defineCommand({
2117
2141
  console.log(`\n${data.length} flows`);
2118
2142
  }
2119
2143
  });
2120
-
2121
2144
  //#endregion
2122
2145
  //#region src/commands/flow-toggle.ts
2123
2146
  const flowToggleCommand = defineCommand({
@@ -2147,7 +2170,6 @@ const flowToggleCommand = defineCommand({
2147
2170
  console.log(`Flow ${data.id} ${data.enabled ? "enabled" : "disabled"}`);
2148
2171
  }
2149
2172
  });
2150
-
2151
2173
  //#endregion
2152
2174
  //#region src/commands/history.ts
2153
2175
  const historyCommand = defineCommand({
@@ -2214,7 +2236,130 @@ const historyCommand = defineCommand({
2214
2236
  console.log(`\n${data.versions.length} versions`);
2215
2237
  }
2216
2238
  });
2217
-
2239
+ //#endregion
2240
+ //#region src/commands/incident-create.ts
2241
+ const incidentCreateCommand = defineCommand({
2242
+ meta: {
2243
+ name: "create",
2244
+ description: "Create an incident"
2245
+ },
2246
+ args: {
2247
+ title: {
2248
+ type: "string",
2249
+ description: "Incident title",
2250
+ required: true
2251
+ },
2252
+ impact: {
2253
+ type: "string",
2254
+ description: "none, minor, major, or critical",
2255
+ required: true
2256
+ },
2257
+ message: {
2258
+ type: "string",
2259
+ description: "Initial status message"
2260
+ }
2261
+ },
2262
+ async run({ args }) {
2263
+ const data = await callAction("auix__incident_create", {
2264
+ title: args.title,
2265
+ impact: args.impact,
2266
+ message: args.message
2267
+ });
2268
+ console.log(`Created incident ${data.id}`);
2269
+ }
2270
+ });
2271
+ //#endregion
2272
+ //#region src/commands/incident-list.ts
2273
+ const incidentListCommand = defineCommand({
2274
+ meta: {
2275
+ name: "list",
2276
+ description: "List incidents"
2277
+ },
2278
+ args: {
2279
+ status: {
2280
+ type: "string",
2281
+ description: "Filter by status"
2282
+ },
2283
+ limit: {
2284
+ type: "string",
2285
+ description: "Max results (default 20)"
2286
+ }
2287
+ },
2288
+ async run({ args }) {
2289
+ const data = await callAction("auix__incident_list", {
2290
+ status: args.status,
2291
+ limit: args.limit ? Number(args.limit) : void 0
2292
+ });
2293
+ if (data.length === 0) {
2294
+ console.log("No incidents found.");
2295
+ return;
2296
+ }
2297
+ for (const i of data) {
2298
+ const started = new Date(i.startedAt).toLocaleString();
2299
+ console.log(` ${i.id.slice(0, 8)} ${i.status.padEnd(12)} ${i.impact.padEnd(10)} ${i.title} (${started})`);
2300
+ }
2301
+ console.log(`\n${data.length} incidents`);
2302
+ }
2303
+ });
2304
+ //#endregion
2305
+ //#region src/commands/incident-resolve.ts
2306
+ const incidentResolveCommand = defineCommand({
2307
+ meta: {
2308
+ name: "resolve",
2309
+ description: "Resolve an incident"
2310
+ },
2311
+ args: {
2312
+ id: {
2313
+ type: "positional",
2314
+ description: "Incident ID",
2315
+ required: true
2316
+ },
2317
+ message: {
2318
+ type: "string",
2319
+ description: "Resolution message"
2320
+ }
2321
+ },
2322
+ async run({ args }) {
2323
+ const data = await callAction("auix__incident_resolve", {
2324
+ incidentId: args.id,
2325
+ message: args.message
2326
+ });
2327
+ console.log(`Incident ${data.id} resolved`);
2328
+ }
2329
+ });
2330
+ //#endregion
2331
+ //#region src/commands/incident-update.ts
2332
+ const incidentUpdateCommand = defineCommand({
2333
+ meta: {
2334
+ name: "update",
2335
+ description: "Update an incident"
2336
+ },
2337
+ args: {
2338
+ id: {
2339
+ type: "positional",
2340
+ description: "Incident ID",
2341
+ required: true
2342
+ },
2343
+ status: {
2344
+ type: "string",
2345
+ description: "New status",
2346
+ required: true
2347
+ },
2348
+ message: {
2349
+ type: "string",
2350
+ description: "Status update message",
2351
+ required: true
2352
+ }
2353
+ },
2354
+ async run({ args }) {
2355
+ const data = await callAction("auix__incident_update", {
2356
+ incidentId: args.id,
2357
+ status: args.status,
2358
+ message: args.message
2359
+ });
2360
+ console.log(`Incident ${data.id} updated to ${data.status}`);
2361
+ }
2362
+ });
2218
2363
  //#endregion
2219
2364
  //#region src/commands/init.ts
2220
2365
  function detectWorkspaceDirs() {
@@ -2407,7 +2552,6 @@ async function selectProject() {
2407
2552
  if (!trimmed) logError("Project slug cannot be empty.");
2408
2553
  return trimmed;
2409
2554
  }
2410
-
2411
2555
  //#endregion
2412
2556
  //#region src/commands/integration-list.ts
2413
2557
  const integrationListCommand = defineCommand({
@@ -2425,7 +2569,6 @@ const integrationListCommand = defineCommand({
2425
2569
  console.log(`\n${data.length} integrations`);
2426
2570
  }
2427
2571
  });
2428
-
2429
2572
  //#endregion
2430
2573
  //#region src/commands/list.ts
2431
2574
  const listCommand = defineCommand({
@@ -2498,7 +2641,6 @@ const listCommand = defineCommand({
2498
2641
  console.log(`\n${data.variables.length} variables`);
2499
2642
  }
2500
2643
  });
2501
-
2502
2644
  //#endregion
2503
2645
  //#region src/commands/lock.ts
2504
2646
  const lockCommand = defineCommand({
@@ -2542,7 +2684,6 @@ const lockCommand = defineCommand({
2542
2684
  console.log(`Locked (${data.id}).`);
2543
2685
  }
2544
2686
  });
2545
-
2546
2687
  //#endregion
2547
2688
  //#region src/commands/lock-status.ts
2548
2689
  const lockStatusCommand = defineCommand({
@@ -2586,7 +2727,6 @@ const lockStatusCommand = defineCommand({
2586
2727
  } else console.log("Unlocked");
2587
2728
  }
2588
2729
  });
2589
-
2590
2730
  //#endregion
2591
2731
  //#region src/commands/log-query.ts
2592
2732
  const logQueryCommand = defineCommand({
@@ -2631,7 +2771,6 @@ const logQueryCommand = defineCommand({
2631
2771
  console.log(`\nShowing ${data.items.length} of ${data.total} logs`);
2632
2772
  }
2633
2773
  });
2634
-
2635
2774
  //#endregion
2636
2775
  //#region src/commands/login.ts
2637
2776
  const CLIENT_ID = "auix-cli";
@@ -2642,7 +2781,7 @@ function openBrowser(url) {
2642
2781
  } catch {}
2643
2782
  }
2644
2783
  async function deviceFlow(appUrl) {
2645
- const base = appUrl.replace(/\/$/, "");
2784
+ const base = stripTrailingSlash(appUrl);
2646
2785
  const codeRes = await fetch(`${base}/api/auth/device/code`, {
2647
2786
  method: "POST",
2648
2787
  headers: { "Content-Type": "application/json" },
@@ -2682,7 +2821,7 @@ async function deviceFlow(appUrl) {
2682
2821
  return "";
2683
2822
  }
2684
2823
  async function selectOrganization(appUrl, sessionToken) {
2685
- const base = appUrl.replace(/\/$/, "");
2824
+ const base = stripTrailingSlash(appUrl);
2686
2825
  const res = await fetch(`${base}/api/auth/organization/list`, { headers: { Authorization: `Bearer ${sessionToken}` } });
2687
2826
  if (!res.ok) logError(`Failed to list organizations (${res.status}).`);
2688
2827
  const orgs = await res.json();
@@ -2702,7 +2841,7 @@ async function selectOrganization(appUrl, sessionToken) {
2702
2841
  return orgs.find((o) => o.id === selected);
2703
2842
  }
2704
2843
  async function fetchUser(appUrl, sessionToken) {
2705
- const base = appUrl.replace(/\/$/, "");
2844
+ const base = stripTrailingSlash(appUrl);
2706
2845
  const res = await fetch(`${base}/api/auth/get-session`, { headers: { Authorization: `Bearer ${sessionToken}` } });
2707
2846
  if (!res.ok) return {
2708
2847
  name: "unknown",
@@ -2714,20 +2853,6 @@ async function fetchUser(appUrl, sessionToken) {
2714
2853
  email: data.user?.email ?? "unknown"
2715
2854
  };
2716
2855
  }
2717
- async function getJwt(appUrl, sessionToken, organizationId) {
2718
- const base = appUrl.replace(/\/$/, "");
2719
- if (!(await fetch(`${base}/api/auth/organization/set-active`, {
2720
- method: "POST",
2721
- headers: {
2722
- "Content-Type": "application/json",
2723
- Authorization: `Bearer ${sessionToken}`
2724
- },
2725
- body: JSON.stringify({ organizationId })
2726
- })).ok) logError("Failed to set active organization.");
2727
- const tokenRes = await fetch(`${base}/api/auth/token`, { headers: { Authorization: `Bearer ${sessionToken}` } });
2728
- if (!tokenRes.ok) logError("Failed to obtain access token.");
2729
- return (await tokenRes.json()).token;
2730
- }
2731
2856
  const loginCommand = defineCommand({
2732
2857
  meta: {
2733
2858
  name: "login",
@@ -2750,13 +2875,16 @@ const loginCommand = defineCommand({
2750
2875
  const user = await fetchUser(appUrl, sessionToken);
2751
2876
  console.log(`Authenticated as ${user.email}\n`);
2752
2877
  const org = await selectOrganization(appUrl, sessionToken);
2878
+ const token = await setActiveAndGetJwt(appUrl, sessionToken, org.id);
2879
+ if (!token) logError("Failed to obtain access token.");
2753
2880
  saveGlobalConfig({
2754
- token: await getJwt(appUrl, sessionToken, org.id),
2881
+ token,
2755
2882
  sessionToken,
2756
2883
  baseUrl,
2757
2884
  appUrl,
2758
2885
  user,
2759
2886
  organization: {
2887
+ id: org.id,
2760
2888
  name: org.name,
2761
2889
  slug: org.slug
2762
2890
  }
@@ -2764,7 +2892,6 @@ const loginCommand = defineCommand({
2764
2892
  console.log(`\nLogged in to ${org.name}.`);
2765
2893
  }
2766
2894
  });
2767
-
2768
2895
  //#endregion
2769
2896
  //#region src/commands/logout.ts
2770
2897
  const CONFIG_FILE = join(homedir(), ".auix", "config.json");
@@ -2782,7 +2909,6 @@ const logoutCommand = defineCommand({
2782
2909
  console.log("Logged out.");
2783
2910
  }
2784
2911
  });
2785
-
2786
2912
  //#endregion
2787
2913
  //#region src/commands/member-list.ts
2788
2914
  const memberListCommand = defineCommand({
@@ -2804,7 +2930,152 @@ const memberListCommand = defineCommand({
2804
2930
  console.log(`\n${data.length} members`);
2805
2931
  }
2806
2932
  });
2807
-
2933
+ //#endregion
2934
+ //#region src/commands/monitor-create.ts
2935
+ const monitorCreateCommand = defineCommand({
2936
+ meta: {
2937
+ name: "create",
2938
+ description: "Create a monitor"
2939
+ },
2940
+ args: {
2941
+ project: {
2942
+ type: "string",
2943
+ description: "Project ID",
2944
+ required: true
2945
+ },
2946
+ name: {
2947
+ type: "string",
2948
+ description: "Monitor name",
2949
+ required: true
2950
+ },
2951
+ type: {
2952
+ type: "string",
2953
+ description: "http, tcp, dns, ssl, or heartbeat",
2954
+ required: true
2955
+ },
2956
+ url: {
2957
+ type: "string",
2958
+ description: "URL to check (for HTTP type)"
2959
+ },
2960
+ interval: {
2961
+ type: "string",
2962
+ description: "Check interval in seconds"
2963
+ }
2964
+ },
2965
+ async run({ args }) {
2966
+ const config = {};
2967
+ if (args.type === "http" && args.url) config.url = args.url;
2968
+ const data = await callAction("auix__monitor_create", {
2969
+ projectId: args.project,
2970
+ name: args.name,
2971
+ type: args.type,
2972
+ config,
2973
+ intervalSeconds: args.interval ? Number(args.interval) : void 0
2974
+ });
2975
+ console.log(`Created monitor ${data.id}`);
2976
+ }
2977
+ });
2978
+ //#endregion
2979
+ //#region src/commands/monitor-delete.ts
2980
+ const monitorDeleteCommand = defineCommand({
2981
+ meta: {
2982
+ name: "delete",
2983
+ description: "Delete a monitor"
2984
+ },
2985
+ args: { id: {
2986
+ type: "positional",
2987
+ description: "Monitor ID",
2988
+ required: true
2989
+ } },
2990
+ async run({ args }) {
2991
+ const confirmed = await consola.prompt(`Delete monitor ${args.id}?`, { type: "confirm" });
2992
+ if (!confirmed || typeof confirmed === "symbol") {
2993
+ console.log("Cancelled.");
2994
+ return;
2995
+ }
2996
+ await callAction("auix__monitor_delete", { monitorId: args.id });
2997
+ console.log("Deleted.");
2998
+ }
2999
+ });
3000
+ //#endregion
3001
+ //#region src/commands/monitor-get.ts
3002
+ const monitorGetCommand = defineCommand({
3003
+ meta: {
3004
+ name: "get",
3005
+ description: "Get monitor details"
3006
+ },
3007
+ args: { id: {
3008
+ type: "positional",
3009
+ description: "Monitor ID",
3010
+ required: true
3011
+ } },
3012
+ async run({ args }) {
3013
+ const data = await callAction("auix__monitor_get", { monitorId: args.id });
3014
+ console.log(JSON.stringify(data, null, 2));
3015
+ }
3016
+ });
3017
+ //#endregion
3018
+ //#region src/commands/monitor-list.ts
3019
+ const monitorListCommand = defineCommand({
3020
+ meta: {
3021
+ name: "list",
3022
+ description: "List monitors"
3023
+ },
3024
+ args: {
3025
+ project: {
3026
+ type: "string",
3027
+ description: "Filter by project ID"
3028
+ },
3029
+ status: {
3030
+ type: "string",
3031
+ description: "Filter by status"
3032
+ }
3033
+ },
3034
+ async run({ args }) {
3035
+ const data = await callAction("auix__monitor_list", {
3036
+ projectId: args.project,
3037
+ status: args.status
3038
+ });
3039
+ if (data.length === 0) {
3040
+ console.log("No monitors found.");
3041
+ return;
3042
+ }
3043
+ for (const m of data) {
3044
+ const checked = m.lastCheckedAt ? new Date(m.lastCheckedAt).toLocaleString() : "never";
3045
+ console.log(` ${m.id.slice(0, 8)} ${m.status.padEnd(10)} ${m.type.padEnd(10)} ${m.name} (last: ${checked})`);
3046
+ }
3047
+ console.log(`\n${data.length} monitors`);
3048
+ }
3049
+ });
3050
+ //#endregion
3051
+ //#region src/commands/monitor-toggle.ts
3052
+ const monitorToggleCommand = defineCommand({
3053
+ meta: {
3054
+ name: "toggle",
3055
+ description: "Enable or disable a monitor"
3056
+ },
3057
+ args: {
3058
+ id: {
3059
+ type: "positional",
3060
+ description: "Monitor ID",
3061
+ required: true
3062
+ },
3063
+ enabled: {
3064
+ type: "string",
3065
+ description: "true or false",
3066
+ required: true
3067
+ }
3068
+ },
3069
+ async run({ args }) {
3070
+ if (args.enabled !== "true" && args.enabled !== "false") logError("--enabled must be true or false");
3071
+ const enabled = args.enabled === "true";
3072
+ const data = await callAction("auix__monitor_toggle", {
3073
+ monitorId: args.id,
3074
+ enabled
3075
+ });
3076
+ console.log(`Monitor ${data.id} ${data.enabled ? "enabled" : "disabled"}`);
3077
+ }
3078
+ });
2808
3079
  //#endregion
2809
3080
  //#region src/commands/prism-list.ts
2810
3081
  const prismListCommand = defineCommand({
@@ -2850,7 +3121,6 @@ const prismListCommand = defineCommand({
2850
3121
  console.log(`\n${data.length} traces`);
2851
3122
  }
2852
3123
  });
2853
-
2854
3124
  //#endregion
2855
3125
  //#region src/commands/prism-metrics.ts
2856
3126
  const prismMetricsCommand = defineCommand({
@@ -2893,7 +3163,6 @@ const prismMetricsCommand = defineCommand({
2893
3163
  }
2894
3164
  }
2895
3165
  });
2896
-
2897
3166
  //#endregion
2898
3167
  //#region src/commands/project-create.ts
2899
3168
  const projectCreateCommand = defineCommand({
@@ -2926,7 +3195,6 @@ const projectCreateCommand = defineCommand({
2926
3195
  console.log(`Created project ${data.slug} (${data.id})`);
2927
3196
  }
2928
3197
  });
2929
-
2930
3198
  //#endregion
2931
3199
  //#region src/commands/project-delete.ts
2932
3200
  const projectDeleteCommand = defineCommand({
@@ -2949,7 +3217,6 @@ const projectDeleteCommand = defineCommand({
2949
3217
  console.log("Deleted.");
2950
3218
  }
2951
3219
  });
2952
-
2953
3220
  //#endregion
2954
3221
  //#region src/commands/project-get.ts
2955
3222
  const projectGetCommand = defineCommand({
@@ -2967,7 +3234,6 @@ const projectGetCommand = defineCommand({
2967
3234
  console.log(JSON.stringify(data, null, 2));
2968
3235
  }
2969
3236
  });
2970
-
2971
3237
  //#endregion
2972
3238
  //#region src/commands/project-list.ts
2973
3239
  const projectListCommand = defineCommand({
@@ -2988,7 +3254,6 @@ const projectListCommand = defineCommand({
2988
3254
  console.log(`\n${data.length} projects`);
2989
3255
  }
2990
3256
  });
2991
-
2992
3257
  //#endregion
2993
3258
  //#region src/commands/pull.ts
2994
3259
  const formatters = {
@@ -3063,7 +3328,6 @@ const pullCommand = defineCommand({
3063
3328
  console.log(`Pulled ${count} variables → ${args.out}`);
3064
3329
  }
3065
3330
  });
3066
-
3067
3331
  //#endregion
3068
3332
  //#region src/commands/push.ts
3069
3333
  const pushCommand = defineCommand({
@@ -3135,7 +3399,6 @@ const pushCommand = defineCommand({
3135
3399
  console.log(`Pushed: ${data.created} created, ${data.updated} updated, ${data.skipped} skipped`);
3136
3400
  }
3137
3401
  });
3138
-
3139
3402
  //#endregion
3140
3403
  //#region src/commands/rollback.ts
3141
3404
  const rollbackCommand = defineCommand({
@@ -3197,7 +3460,6 @@ const rollbackCommand = defineCommand({
3197
3460
  console.log(`Rolled back ${args.key} to v${versionNum}.`);
3198
3461
  }
3199
3462
  });
3200
-
3201
3463
  //#endregion
3202
3464
  //#region src/commands/rotation-create.ts
3203
3465
  const rotationCreateCommand = defineCommand({
@@ -3257,7 +3519,6 @@ const rotationCreateCommand = defineCommand({
3257
3519
  console.log(`Interval: ${intervalDays} days`);
3258
3520
  }
3259
3521
  });
3260
-
3261
3522
  //#endregion
3262
3523
  //#region src/commands/rotation-list.ts
3263
3524
  function formatDate$1(date) {
@@ -3312,7 +3573,6 @@ const rotationListCommand = defineCommand({
3312
3573
  console.log(`\n${data.policies.length} policies`);
3313
3574
  }
3314
3575
  });
3315
-
3316
3576
  //#endregion
3317
3577
  //#region src/commands/rotation-rotate.ts
3318
3578
  const rotationRotateCommand = defineCommand({
@@ -3339,7 +3599,6 @@ const rotationRotateCommand = defineCommand({
3339
3599
  console.log("Rotated successfully.");
3340
3600
  }
3341
3601
  });
3342
-
3343
3602
  //#endregion
3344
3603
  //#region src/commands/run.ts
3345
3604
  const FINGERPRINT_DIR = join(homedir(), ".auix");
@@ -3384,7 +3643,7 @@ async function ensureToken(project) {
3384
3643
  os: process.platform,
3385
3644
  arch: process.arch,
3386
3645
  nodeVersion: process.version,
3387
- cliVersion: "0.0.6",
3646
+ cliVersion: "0.0.7",
3388
3647
  shell: process.env.SHELL ?? process.env.COMSPEC,
3389
3648
  ci: isCI || void 0,
3390
3649
  ciName: process.env.GITHUB_ACTIONS ? "github-actions" : process.env.GITLAB_CI ? "gitlab-ci" : process.env.CIRCLECI ? "circleci" : void 0,
@@ -3522,7 +3781,6 @@ const runCommand = defineCommand({
3522
3781
  process.on("SIGTERM", cleanup);
3523
3782
  }
3524
3783
  });
3525
-
3526
3784
  //#endregion
3527
3785
  //#region src/commands/set.ts
3528
3786
  const setCommand = defineCommand({
@@ -3588,7 +3846,6 @@ const setCommand = defineCommand({
3588
3846
  console.log(`Set ${key}`);
3589
3847
  }
3590
3848
  });
3591
-
3592
3849
  //#endregion
3593
3850
  //#region src/commands/share-access.ts
3594
3851
  const shareAccessCommand = defineCommand({
@@ -3613,7 +3870,6 @@ const shareAccessCommand = defineCommand({
3613
3870
  console.log(data.value);
3614
3871
  }
3615
3872
  });
3616
-
3617
3873
  //#endregion
3618
3874
  //#region src/commands/share-create.ts
3619
3875
  const shareCreateCommand = defineCommand({
@@ -3651,7 +3907,82 @@ const shareCreateCommand = defineCommand({
3651
3907
  console.log("\nThis link can only be accessed once.");
3652
3908
  }
3653
3909
  });
3654
-
3910
+ //#endregion
3911
+ //#region src/commands/status-page-create.ts
3912
+ const statusPageCreateCommand = defineCommand({
3913
+ meta: {
3914
+ name: "create",
3915
+ description: "Create a status page"
3916
+ },
3917
+ args: {
3918
+ name: {
3919
+ type: "string",
3920
+ description: "Page name",
3921
+ required: true
3922
+ },
3923
+ slug: {
3924
+ type: "string",
3925
+ description: "URL slug",
3926
+ required: true
3927
+ },
3928
+ projects: {
3929
+ type: "string",
3930
+ description: "Comma-separated project IDs",
3931
+ required: true
3932
+ }
3933
+ },
3934
+ async run({ args }) {
3935
+ const projectIds = args.projects.split(",").map((id) => id.trim());
3936
+ const data = await callAction("auix__status_page_create", {
3937
+ name: args.name,
3938
+ slug: args.slug,
3939
+ projectIds
3940
+ });
3941
+ console.log(`Created status page ${data.slug} (${data.id})`);
3942
+ }
3943
+ });
3944
+ //#endregion
3945
+ //#region src/commands/status-page-delete.ts
3946
+ const statusPageDeleteCommand = defineCommand({
3947
+ meta: {
3948
+ name: "delete",
3949
+ description: "Delete a status page"
3950
+ },
3951
+ args: { id: {
3952
+ type: "positional",
3953
+ description: "Status page ID",
3954
+ required: true
3955
+ } },
3956
+ async run({ args }) {
3957
+ const confirmed = await consola.prompt(`Delete status page ${args.id}?`, { type: "confirm" });
3958
+ if (!confirmed || typeof confirmed === "symbol") {
3959
+ console.log("Cancelled.");
3960
+ return;
3961
+ }
3962
+ await callAction("auix__status_page_delete", { statusPageId: args.id });
3963
+ console.log("Deleted.");
3964
+ }
3965
+ });
3966
+ //#endregion
3967
+ //#region src/commands/status-page-list.ts
3968
+ const statusPageListCommand = defineCommand({
3969
+ meta: {
3970
+ name: "list",
3971
+ description: "List status pages"
3972
+ },
3973
+ async run() {
3974
+ const data = await callAction("auix__status_page_list", {});
3975
+ if (data.length === 0) {
3976
+ console.log("No status pages found.");
3977
+ return;
3978
+ }
3979
+ for (const p of data) {
3980
+ const state = p.enabled ? "enabled" : "disabled";
3981
+ console.log(` ${p.id.slice(0, 8)} ${p.slug.padEnd(20)} ${p.visibility.padEnd(10)} ${state.padEnd(8)} ${p.name}`);
3982
+ }
3983
+ console.log(`\n${data.length} status pages`);
3984
+ }
3985
+ });
3655
3986
  //#endregion
3656
3987
  //#region src/commands/switch.ts
3657
3988
  const switchCommand = defineCommand({
@@ -3663,7 +3994,7 @@ const switchCommand = defineCommand({
3663
3994
  const config = loadGlobalConfig();
3664
3995
  const appUrl = config.appUrl ?? getAppUrl();
3665
3996
  if (!config.sessionToken) logError("Not logged in. Run `auix login`.");
3666
- const base = appUrl.replace(/\/$/, "");
3997
+ const base = stripTrailingSlash(appUrl);
3667
3998
  const sessionToken = config.sessionToken;
3668
3999
  const orgsRes = await fetch(`${base}/api/auth/organization/list`, { headers: { Authorization: `Bearer ${sessionToken}` } });
3669
4000
  if (!orgsRes.ok) logError("Session expired. Run `auix login` to re-authenticate.");
@@ -3678,21 +4009,13 @@ const switchCommand = defineCommand({
3678
4009
  });
3679
4010
  if (typeof selected === "symbol") logError("Cancelled.");
3680
4011
  const org = orgs.find((o) => o.id === selected);
3681
- if (!(await fetch(`${base}/api/auth/organization/set-active`, {
3682
- method: "POST",
3683
- headers: {
3684
- "Content-Type": "application/json",
3685
- Authorization: `Bearer ${sessionToken}`
3686
- },
3687
- body: JSON.stringify({ organizationId: org.id })
3688
- })).ok) logError("Failed to set active organization.");
3689
- const tokenRes = await fetch(`${base}/api/auth/token`, { headers: { Authorization: `Bearer ${sessionToken}` } });
3690
- if (!tokenRes.ok) logError("Failed to obtain access token.");
3691
- const data = await tokenRes.json();
4012
+ const token = await setActiveAndGetJwt(appUrl, sessionToken, org.id);
4013
+ if (!token) logError("Failed to obtain access token.");
3692
4014
  saveGlobalConfig({
3693
4015
  ...config,
3694
- token: data.token,
4016
+ token,
3695
4017
  organization: {
4018
+ id: org.id,
3696
4019
  name: org.name,
3697
4020
  slug: org.slug
3698
4021
  }
@@ -3700,7 +4023,6 @@ const switchCommand = defineCommand({
3700
4023
  console.log(`Switched to ${org.name}.`);
3701
4024
  }
3702
4025
  });
3703
-
3704
4026
  //#endregion
3705
4027
  //#region src/commands/sync-add.ts
3706
4028
  const syncAddCommand = defineCommand({
@@ -3777,7 +4099,6 @@ const syncAddCommand = defineCommand({
3777
4099
  console.log(`Added sync target: ${args.name} (${data.id.slice(0, 8)})`);
3778
4100
  }
3779
4101
  });
3780
-
3781
4102
  //#endregion
3782
4103
  //#region src/commands/sync-list.ts
3783
4104
  const syncListCommand = defineCommand({
@@ -3836,7 +4157,6 @@ const syncListCommand = defineCommand({
3836
4157
  console.log(`\n${data.targets.length} targets`);
3837
4158
  }
3838
4159
  });
3839
-
3840
4160
  //#endregion
3841
4161
  //#region src/commands/sync-push.ts
3842
4162
  const syncPushCommand = defineCommand({
@@ -3878,7 +4198,6 @@ const syncPushCommand = defineCommand({
3878
4198
  else logError(`Sync failed: ${data.error}`);
3879
4199
  }
3880
4200
  });
3881
-
3882
4201
  //#endregion
3883
4202
  //#region src/commands/sync-remove.ts
3884
4203
  const syncRemoveCommand = defineCommand({
@@ -3905,7 +4224,6 @@ const syncRemoveCommand = defineCommand({
3905
4224
  console.log("Deleted.");
3906
4225
  }
3907
4226
  });
3908
-
3909
4227
  //#endregion
3910
4228
  //#region src/commands/token-create.ts
3911
4229
  const tokenCreateCommand = defineCommand({
@@ -3968,7 +4286,6 @@ const tokenCreateCommand = defineCommand({
3968
4286
  console.log("\nSave this key — it won't be shown again.");
3969
4287
  }
3970
4288
  });
3971
-
3972
4289
  //#endregion
3973
4290
  //#region src/commands/token-list.ts
3974
4291
  function formatScope(scope) {
@@ -4031,7 +4348,6 @@ const tokenListCommand = defineCommand({
4031
4348
  console.log(`\n${data.tokens.length} tokens`);
4032
4349
  }
4033
4350
  });
4034
-
4035
4351
  //#endregion
4036
4352
  //#region src/commands/token-revoke.ts
4037
4353
  const tokenRevokeCommand = defineCommand({
@@ -4058,7 +4374,6 @@ const tokenRevokeCommand = defineCommand({
4058
4374
  console.log("Revoked.");
4059
4375
  }
4060
4376
  });
4061
-
4062
4377
  //#endregion
4063
4378
  //#region src/commands/tool-list.ts
4064
4379
  const toolListCommand = defineCommand({
@@ -4084,7 +4399,6 @@ const toolListCommand = defineCommand({
4084
4399
  console.log(`\n${data.length} tools`);
4085
4400
  }
4086
4401
  });
4087
-
4088
4402
  //#endregion
4089
4403
  //#region src/commands/tool-provider-create.ts
4090
4404
  const toolProviderCreateCommand = defineCommand({
@@ -4135,7 +4449,6 @@ const toolProviderCreateCommand = defineCommand({
4135
4449
  console.log(`Created provider ${data.id}`);
4136
4450
  }
4137
4451
  });
4138
-
4139
4452
  //#endregion
4140
4453
  //#region src/commands/tool-provider-delete.ts
4141
4454
  const toolProviderDeleteCommand = defineCommand({
@@ -4158,7 +4471,6 @@ const toolProviderDeleteCommand = defineCommand({
4158
4471
  console.log("Deleted.");
4159
4472
  }
4160
4473
  });
4161
-
4162
4474
  //#endregion
4163
4475
  //#region src/commands/tool-provider-get.ts
4164
4476
  const toolProviderGetCommand = defineCommand({
@@ -4176,7 +4488,6 @@ const toolProviderGetCommand = defineCommand({
4176
4488
  console.log(JSON.stringify(data, null, 2));
4177
4489
  }
4178
4490
  });
4179
-
4180
4491
  //#endregion
4181
4492
  //#region src/commands/tool-provider-list.ts
4182
4493
  const toolProviderListCommand = defineCommand({
@@ -4194,7 +4505,6 @@ const toolProviderListCommand = defineCommand({
4194
4505
  console.log(`\n${data.length} providers`);
4195
4506
  }
4196
4507
  });
4197
-
4198
4508
  //#endregion
4199
4509
  //#region src/commands/tool-provider-sync.ts
4200
4510
  const toolProviderSyncCommand = defineCommand({
@@ -4213,7 +4523,6 @@ const toolProviderSyncCommand = defineCommand({
4213
4523
  for (const name of data.tools) console.log(` ${name}`);
4214
4524
  }
4215
4525
  });
4216
-
4217
4526
  //#endregion
4218
4527
  //#region src/commands/trace-get.ts
4219
4528
  const traceGetCommand = defineCommand({
@@ -4231,7 +4540,6 @@ const traceGetCommand = defineCommand({
4231
4540
  console.log(JSON.stringify(data, null, 2));
4232
4541
  }
4233
4542
  });
4234
-
4235
4543
  //#endregion
4236
4544
  //#region src/commands/trace-list.ts
4237
4545
  const traceListCommand = defineCommand({
@@ -4276,7 +4584,6 @@ const traceListCommand = defineCommand({
4276
4584
  console.log(`\n${data.length} traces`);
4277
4585
  }
4278
4586
  });
4279
-
4280
4587
  //#endregion
4281
4588
  //#region src/commands/unlock.ts
4282
4589
  const unlockCommand = defineCommand({
@@ -4319,7 +4626,6 @@ const unlockCommand = defineCommand({
4319
4626
  console.log("Unlocked.");
4320
4627
  }
4321
4628
  });
4322
-
4323
4629
  //#endregion
4324
4630
  //#region src/commands/webhook-add.ts
4325
4631
  const VALID_EVENTS = [
@@ -4377,7 +4683,6 @@ const webhookAddCommand = defineCommand({
4377
4683
  console.log(`Created webhook ${data.id}`);
4378
4684
  }
4379
4685
  });
4380
-
4381
4686
  //#endregion
4382
4687
  //#region src/commands/webhook-list.ts
4383
4688
  const webhookListCommand = defineCommand({
@@ -4421,7 +4726,6 @@ const webhookListCommand = defineCommand({
4421
4726
  console.log(`\n${data.webhooks.length} webhooks`);
4422
4727
  }
4423
4728
  });
4424
-
4425
4729
  //#endregion
4426
4730
  //#region src/commands/webhook-remove.ts
4427
4731
  const webhookRemoveCommand = defineCommand({
@@ -4448,7 +4752,6 @@ const webhookRemoveCommand = defineCommand({
4448
4752
  console.log("Removed.");
4449
4753
  }
4450
4754
  });
4451
-
4452
4755
  //#endregion
4453
4756
  //#region src/commands/whoami.ts
4454
4757
  const whoamiCommand = defineCommand({
@@ -4465,194 +4768,237 @@ const whoamiCommand = defineCommand({
4465
4768
  console.log(`App: ${config.appUrl ?? "https://auix.dev"}`);
4466
4769
  }
4467
4770
  });
4468
-
4469
4771
  //#endregion
4470
4772
  //#region src/index.ts
4471
- runMain(defineCommand({
4773
+ const envCommand = defineCommand({
4472
4774
  meta: {
4473
- name: "auix",
4474
- version: "0.0.6",
4475
- description: "AUIX CLI"
4775
+ name: "env",
4776
+ description: "Manage environment variables"
4476
4777
  },
4477
4778
  subCommands: {
4478
- login: loginCommand,
4479
- logout: logoutCommand,
4480
- whoami: whoamiCommand,
4481
- switch: switchCommand,
4482
- env: defineCommand({
4779
+ init: initCommand,
4780
+ run: runCommand,
4781
+ pull: pullCommand,
4782
+ push: pushCommand,
4783
+ list: listCommand,
4784
+ set: setCommand,
4785
+ delete: deleteCommand,
4786
+ diff: diffCommand,
4787
+ history: historyCommand,
4788
+ rollback: rollbackCommand,
4789
+ lock: lockCommand,
4790
+ unlock: unlockCommand,
4791
+ "lock-status": lockStatusCommand,
4792
+ branch: defineCommand({
4483
4793
  meta: {
4484
- name: "env",
4485
- description: "Manage environment variables"
4794
+ name: "branch",
4795
+ description: "Manage env branches"
4486
4796
  },
4487
4797
  subCommands: {
4488
- init: initCommand,
4489
- run: runCommand,
4490
- pull: pullCommand,
4491
- push: pushCommand,
4492
- list: listCommand,
4493
- set: setCommand,
4494
- delete: deleteCommand,
4495
- diff: diffCommand,
4496
- history: historyCommand,
4497
- rollback: rollbackCommand,
4498
- lock: lockCommand,
4499
- unlock: unlockCommand,
4500
- "lock-status": lockStatusCommand,
4501
- branch: defineCommand({
4502
- meta: {
4503
- name: "branch",
4504
- description: "Manage env branches"
4505
- },
4506
- subCommands: {
4507
- create: branchCreateCommand,
4508
- list: branchListCommand,
4509
- delete: branchDeleteCommand
4510
- }
4511
- }),
4512
- token: defineCommand({
4513
- meta: {
4514
- name: "token",
4515
- description: "Manage service tokens"
4516
- },
4517
- subCommands: {
4518
- create: tokenCreateCommand,
4519
- list: tokenListCommand,
4520
- revoke: tokenRevokeCommand
4521
- }
4522
- }),
4523
- webhook: defineCommand({
4524
- meta: {
4525
- name: "webhook",
4526
- description: "Manage env change webhooks"
4527
- },
4528
- subCommands: {
4529
- add: webhookAddCommand,
4530
- list: webhookListCommand,
4531
- remove: webhookRemoveCommand
4532
- }
4533
- }),
4534
- share: defineCommand({
4535
- meta: {
4536
- name: "share",
4537
- description: "One-time encrypted share links"
4538
- },
4539
- subCommands: {
4540
- create: shareCreateCommand,
4541
- access: shareAccessCommand
4542
- }
4543
- }),
4544
- sync: defineCommand({
4545
- meta: {
4546
- name: "sync",
4547
- description: "Sync env vars to external providers"
4548
- },
4549
- subCommands: {
4550
- add: syncAddCommand,
4551
- list: syncListCommand,
4552
- push: syncPushCommand,
4553
- remove: syncRemoveCommand
4554
- }
4555
- }),
4556
- rotation: defineCommand({
4557
- meta: {
4558
- name: "rotation",
4559
- description: "Manage credential rotation policies"
4560
- },
4561
- subCommands: {
4562
- create: rotationCreateCommand,
4563
- list: rotationListCommand,
4564
- rotate: rotationRotateCommand
4565
- }
4566
- }),
4567
- dynamic: defineCommand({
4568
- meta: {
4569
- name: "dynamic",
4570
- description: "Manage dynamic secrets"
4571
- },
4572
- subCommands: {
4573
- create: dynamicCreateCommand,
4574
- list: dynamicListCommand,
4575
- lease: dynamicLeaseCommand
4576
- }
4577
- })
4798
+ create: branchCreateCommand,
4799
+ list: branchListCommand,
4800
+ delete: branchDeleteCommand
4578
4801
  }
4579
4802
  }),
4580
- flow: defineCommand({
4803
+ token: defineCommand({
4581
4804
  meta: {
4582
- name: "flow",
4583
- description: "Manage automation flows"
4805
+ name: "token",
4806
+ description: "Manage service tokens"
4584
4807
  },
4585
4808
  subCommands: {
4586
- list: flowListCommand,
4587
- get: flowGetCommand,
4588
- create: flowCreateCommand,
4589
- toggle: flowToggleCommand,
4590
- duplicate: flowDuplicateCommand,
4591
- dispatch: flowDispatchCommand,
4592
- executions: flowExecutionsCommand,
4593
- delete: flowDeleteCommand
4809
+ create: tokenCreateCommand,
4810
+ list: tokenListCommand,
4811
+ revoke: tokenRevokeCommand
4594
4812
  }
4595
4813
  }),
4596
- tool: defineCommand({
4814
+ webhook: defineCommand({
4597
4815
  meta: {
4598
- name: "tool",
4599
- description: "Manage tools and providers"
4816
+ name: "webhook",
4817
+ description: "Manage env change webhooks"
4600
4818
  },
4601
4819
  subCommands: {
4602
- list: toolListCommand,
4603
- provider: defineCommand({
4604
- meta: {
4605
- name: "provider",
4606
- description: "Manage tool providers"
4607
- },
4608
- subCommands: {
4609
- list: toolProviderListCommand,
4610
- get: toolProviderGetCommand,
4611
- create: toolProviderCreateCommand,
4612
- sync: toolProviderSyncCommand,
4613
- delete: toolProviderDeleteCommand
4614
- }
4615
- })
4820
+ add: webhookAddCommand,
4821
+ list: webhookListCommand,
4822
+ remove: webhookRemoveCommand
4616
4823
  }
4617
4824
  }),
4618
- project: defineCommand({
4825
+ share: defineCommand({
4619
4826
  meta: {
4620
- name: "project",
4621
- description: "Manage projects"
4827
+ name: "share",
4828
+ description: "One-time encrypted share links"
4622
4829
  },
4623
4830
  subCommands: {
4624
- list: projectListCommand,
4625
- get: projectGetCommand,
4626
- create: projectCreateCommand,
4627
- delete: projectDeleteCommand
4831
+ create: shareCreateCommand,
4832
+ access: shareAccessCommand
4628
4833
  }
4629
4834
  }),
4630
- trace: defineCommand({
4835
+ sync: defineCommand({
4631
4836
  meta: {
4632
- name: "trace",
4633
- description: "Workflow execution traces"
4837
+ name: "sync",
4838
+ description: "Sync env vars to external providers"
4634
4839
  },
4635
4840
  subCommands: {
4636
- list: traceListCommand,
4637
- get: traceGetCommand
4841
+ add: syncAddCommand,
4842
+ list: syncListCommand,
4843
+ push: syncPushCommand,
4844
+ remove: syncRemoveCommand
4638
4845
  }
4639
4846
  }),
4640
- prism: defineCommand({
4847
+ rotation: defineCommand({
4641
4848
  meta: {
4642
- name: "prism",
4643
- description: "LLM call tracing"
4849
+ name: "rotation",
4850
+ description: "Manage credential rotation policies"
4644
4851
  },
4645
4852
  subCommands: {
4646
- list: prismListCommand,
4647
- metrics: prismMetricsCommand
4853
+ create: rotationCreateCommand,
4854
+ list: rotationListCommand,
4855
+ rotate: rotationRotateCommand
4648
4856
  }
4649
4857
  }),
4858
+ dynamic: defineCommand({
4859
+ meta: {
4860
+ name: "dynamic",
4861
+ description: "Manage dynamic secrets"
4862
+ },
4863
+ subCommands: {
4864
+ create: dynamicCreateCommand,
4865
+ list: dynamicListCommand,
4866
+ lease: dynamicLeaseCommand
4867
+ }
4868
+ })
4869
+ }
4870
+ });
4871
+ const flowCommand = defineCommand({
4872
+ meta: {
4873
+ name: "flow",
4874
+ description: "Manage automation flows"
4875
+ },
4876
+ subCommands: {
4877
+ list: flowListCommand,
4878
+ get: flowGetCommand,
4879
+ create: flowCreateCommand,
4880
+ toggle: flowToggleCommand,
4881
+ duplicate: flowDuplicateCommand,
4882
+ dispatch: flowDispatchCommand,
4883
+ executions: flowExecutionsCommand,
4884
+ delete: flowDeleteCommand
4885
+ }
4886
+ });
4887
+ const toolCommand = defineCommand({
4888
+ meta: {
4889
+ name: "tool",
4890
+ description: "Manage tools and providers"
4891
+ },
4892
+ subCommands: {
4893
+ list: toolListCommand,
4894
+ provider: defineCommand({
4895
+ meta: {
4896
+ name: "provider",
4897
+ description: "Manage tool providers"
4898
+ },
4899
+ subCommands: {
4900
+ list: toolProviderListCommand,
4901
+ get: toolProviderGetCommand,
4902
+ create: toolProviderCreateCommand,
4903
+ sync: toolProviderSyncCommand,
4904
+ delete: toolProviderDeleteCommand
4905
+ }
4906
+ })
4907
+ }
4908
+ });
4909
+ const projectCommand = defineCommand({
4910
+ meta: {
4911
+ name: "project",
4912
+ description: "Manage projects"
4913
+ },
4914
+ subCommands: {
4915
+ list: projectListCommand,
4916
+ get: projectGetCommand,
4917
+ create: projectCreateCommand,
4918
+ delete: projectDeleteCommand
4919
+ }
4920
+ });
4921
+ const traceCommand = defineCommand({
4922
+ meta: {
4923
+ name: "trace",
4924
+ description: "Workflow execution traces"
4925
+ },
4926
+ subCommands: {
4927
+ list: traceListCommand,
4928
+ get: traceGetCommand
4929
+ }
4930
+ });
4931
+ const prismCommand = defineCommand({
4932
+ meta: {
4933
+ name: "prism",
4934
+ description: "LLM call tracing"
4935
+ },
4936
+ subCommands: {
4937
+ list: prismListCommand,
4938
+ metrics: prismMetricsCommand
4939
+ }
4940
+ });
4941
+ const monitorCommand = defineCommand({
4942
+ meta: {
4943
+ name: "monitor",
4944
+ description: "Manage health check monitors"
4945
+ },
4946
+ subCommands: {
4947
+ list: monitorListCommand,
4948
+ get: monitorGetCommand,
4949
+ create: monitorCreateCommand,
4950
+ delete: monitorDeleteCommand,
4951
+ toggle: monitorToggleCommand
4952
+ }
4953
+ });
4954
+ const incidentCommand = defineCommand({
4955
+ meta: {
4956
+ name: "incident",
4957
+ description: "Manage incidents"
4958
+ },
4959
+ subCommands: {
4960
+ list: incidentListCommand,
4961
+ create: incidentCreateCommand,
4962
+ update: incidentUpdateCommand,
4963
+ resolve: incidentResolveCommand
4964
+ }
4965
+ });
4966
+ const statusPageCommand = defineCommand({
4967
+ meta: {
4968
+ name: "status-page",
4969
+ description: "Manage status pages"
4970
+ },
4971
+ subCommands: {
4972
+ list: statusPageListCommand,
4973
+ create: statusPageCreateCommand,
4974
+ delete: statusPageDeleteCommand
4975
+ }
4976
+ });
4977
+ runMain(defineCommand({
4978
+ meta: {
4979
+ name: "auix",
4980
+ version: "0.0.7",
4981
+ description: "AUIX CLI"
4982
+ },
4983
+ subCommands: {
4984
+ login: loginCommand,
4985
+ logout: logoutCommand,
4986
+ whoami: whoamiCommand,
4987
+ switch: switchCommand,
4988
+ env: envCommand,
4989
+ flow: flowCommand,
4990
+ tool: toolCommand,
4991
+ project: projectCommand,
4992
+ trace: traceCommand,
4993
+ prism: prismCommand,
4650
4994
  log: logQueryCommand,
4651
4995
  member: memberListCommand,
4996
+ monitor: monitorCommand,
4997
+ incident: incidentCommand,
4998
+ "status-page": statusPageCommand,
4652
4999
  audit: auditListCommand,
4653
5000
  integration: integrationListCommand
4654
5001
  }
4655
5002
  }));
4656
-
4657
5003
  //#endregion
4658
- export { };
5004
+ export {};