automate.ax 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +119 -0
- package/dist/automation/actions.d.ts +200 -0
- package/dist/automation/actions.d.ts.map +1 -0
- package/dist/automation/actions.js +286 -0
- package/dist/automation/automation.d.ts +16 -0
- package/dist/automation/automation.d.ts.map +1 -0
- package/dist/automation/automation.js +10 -0
- package/dist/automation/integrations.d.ts +63 -0
- package/dist/automation/integrations.d.ts.map +1 -0
- package/dist/automation/integrations.js +58 -0
- package/dist/automation/runtime.d.ts +73 -0
- package/dist/automation/runtime.d.ts.map +1 -0
- package/dist/automation/runtime.js +92 -0
- package/dist/automation/signal.d.ts +58 -0
- package/dist/automation/signal.d.ts.map +1 -0
- package/dist/automation/signal.js +80 -0
- package/dist/automation/subscribe.d.ts +10 -0
- package/dist/automation/subscribe.d.ts.map +1 -0
- package/dist/automation/subscribe.js +16 -0
- package/dist/cli/command-names.d.ts +46 -0
- package/dist/cli/command-names.d.ts.map +1 -0
- package/dist/cli/command-names.js +46 -0
- package/dist/cli/commands/accept.d.ts +20 -0
- package/dist/cli/commands/accept.d.ts.map +1 -0
- package/dist/cli/commands/accept.js +42 -0
- package/dist/cli/commands/debug.d.ts +4 -0
- package/dist/cli/commands/debug.d.ts.map +1 -0
- package/dist/cli/commands/debug.js +52 -0
- package/dist/cli/commands/deploy.d.ts +24 -0
- package/dist/cli/commands/deploy.d.ts.map +1 -0
- package/dist/cli/commands/deploy.js +292 -0
- package/dist/cli/commands/login.d.ts +20 -0
- package/dist/cli/commands/login.d.ts.map +1 -0
- package/dist/cli/commands/login.js +145 -0
- package/dist/cli/commands/logout.d.ts +4 -0
- package/dist/cli/commands/logout.d.ts.map +1 -0
- package/dist/cli/commands/logout.js +32 -0
- package/dist/cli/commands/me.d.ts +4 -0
- package/dist/cli/commands/me.d.ts.map +1 -0
- package/dist/cli/commands/me.js +48 -0
- package/dist/cli/commands/org-api-key-create.d.ts +26 -0
- package/dist/cli/commands/org-api-key-create.d.ts.map +1 -0
- package/dist/cli/commands/org-api-key-create.js +51 -0
- package/dist/cli/commands/org-api-key-delete.d.ts +33 -0
- package/dist/cli/commands/org-api-key-delete.d.ts.map +1 -0
- package/dist/cli/commands/org-api-key-delete.js +57 -0
- package/dist/cli/commands/org-api-key-list.d.ts +16 -0
- package/dist/cli/commands/org-api-key-list.d.ts.map +1 -0
- package/dist/cli/commands/org-api-key-list.js +58 -0
- package/dist/cli/commands/org-api-key-rename.d.ts +32 -0
- package/dist/cli/commands/org-api-key-rename.d.ts.map +1 -0
- package/dist/cli/commands/org-api-key-rename.js +54 -0
- package/dist/cli/commands/org-api-key.d.ts +2 -0
- package/dist/cli/commands/org-api-key.d.ts.map +1 -0
- package/dist/cli/commands/org-api-key.js +18 -0
- package/dist/cli/commands/org-billing.d.ts +16 -0
- package/dist/cli/commands/org-billing.d.ts.map +1 -0
- package/dist/cli/commands/org-billing.js +78 -0
- package/dist/cli/commands/org-create.d.ts +20 -0
- package/dist/cli/commands/org-create.d.ts.map +1 -0
- package/dist/cli/commands/org-create.js +64 -0
- package/dist/cli/commands/org-delete.d.ts +27 -0
- package/dist/cli/commands/org-delete.d.ts.map +1 -0
- package/dist/cli/commands/org-delete.js +53 -0
- package/dist/cli/commands/org-invite.d.ts +39 -0
- package/dist/cli/commands/org-invite.d.ts.map +1 -0
- package/dist/cli/commands/org-invite.js +66 -0
- package/dist/cli/commands/org-leave.d.ts +27 -0
- package/dist/cli/commands/org-leave.d.ts.map +1 -0
- package/dist/cli/commands/org-leave.js +56 -0
- package/dist/cli/commands/org-list.d.ts +4 -0
- package/dist/cli/commands/org-list.d.ts.map +1 -0
- package/dist/cli/commands/org-list.js +36 -0
- package/dist/cli/commands/org-remove.d.ts +33 -0
- package/dist/cli/commands/org-remove.d.ts.map +1 -0
- package/dist/cli/commands/org-remove.js +66 -0
- package/dist/cli/commands/org-rename.d.ts +26 -0
- package/dist/cli/commands/org-rename.d.ts.map +1 -0
- package/dist/cli/commands/org-rename.js +58 -0
- package/dist/cli/commands/org-show.d.ts +16 -0
- package/dist/cli/commands/org-show.d.ts.map +1 -0
- package/dist/cli/commands/org-show.js +48 -0
- package/dist/cli/commands/org-upgrade.d.ts +42 -0
- package/dist/cli/commands/org-upgrade.d.ts.map +1 -0
- package/dist/cli/commands/org-upgrade.js +171 -0
- package/dist/cli/commands/org.d.ts +2 -0
- package/dist/cli/commands/org.d.ts.map +1 -0
- package/dist/cli/commands/org.js +32 -0
- package/dist/cli/commands/project-create.d.ts +27 -0
- package/dist/cli/commands/project-create.d.ts.map +1 -0
- package/dist/cli/commands/project-create.js +61 -0
- package/dist/cli/commands/project-delete.d.ts +27 -0
- package/dist/cli/commands/project-delete.d.ts.map +1 -0
- package/dist/cli/commands/project-delete.js +55 -0
- package/dist/cli/commands/project-list.d.ts +17 -0
- package/dist/cli/commands/project-list.d.ts.map +1 -0
- package/dist/cli/commands/project-list.js +89 -0
- package/dist/cli/commands/project-rename.d.ts +26 -0
- package/dist/cli/commands/project-rename.d.ts.map +1 -0
- package/dist/cli/commands/project-rename.js +60 -0
- package/dist/cli/commands/project-show.d.ts +16 -0
- package/dist/cli/commands/project-show.d.ts.map +1 -0
- package/dist/cli/commands/project-show.js +37 -0
- package/dist/cli/commands/project.d.ts +2 -0
- package/dist/cli/commands/project.d.ts.map +1 -0
- package/dist/cli/commands/project.js +20 -0
- package/dist/cli/index.d.ts +19 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +63 -0
- package/dist/cli/lib/api-client.d.ts +3 -0
- package/dist/cli/lib/api-client.d.ts.map +1 -0
- package/dist/cli/lib/api-client.js +14 -0
- package/dist/cli/lib/auth-client.d.ts +80 -0
- package/dist/cli/lib/auth-client.d.ts.map +1 -0
- package/dist/cli/lib/auth-client.js +61 -0
- package/dist/cli/lib/automation-build.d.ts +30 -0
- package/dist/cli/lib/automation-build.d.ts.map +1 -0
- package/dist/cli/lib/automation-build.js +90 -0
- package/dist/cli/lib/config-dir.d.ts +47 -0
- package/dist/cli/lib/config-dir.d.ts.map +1 -0
- package/dist/cli/lib/config-dir.js +146 -0
- package/dist/cli/lib/detail-block.d.ts +16 -0
- package/dist/cli/lib/detail-block.d.ts.map +1 -0
- package/dist/cli/lib/detail-block.js +25 -0
- package/dist/cli/lib/env.d.ts +4 -0
- package/dist/cli/lib/env.d.ts.map +1 -0
- package/dist/cli/lib/env.js +7 -0
- package/dist/cli/lib/hijack-clack-logger.d.ts +2 -0
- package/dist/cli/lib/hijack-clack-logger.d.ts.map +1 -0
- package/dist/cli/lib/hijack-clack-logger.js +8 -0
- package/dist/cli/lib/io.d.ts +19 -0
- package/dist/cli/lib/io.d.ts.map +1 -0
- package/dist/cli/lib/io.js +87 -0
- package/dist/cli/lib/json-output.d.ts +9 -0
- package/dist/cli/lib/json-output.d.ts.map +1 -0
- package/dist/cli/lib/json-output.js +12 -0
- package/dist/cli/lib/organization-detail-block.d.ts +30 -0
- package/dist/cli/lib/organization-detail-block.d.ts.map +1 -0
- package/dist/cli/lib/organization-detail-block.js +72 -0
- package/dist/cli/lib/project-config.d.ts +10 -0
- package/dist/cli/lib/project-config.d.ts.map +1 -0
- package/dist/cli/lib/project-config.js +21 -0
- package/dist/cli/lib/spinner.d.ts +18 -0
- package/dist/cli/lib/spinner.d.ts.map +1 -0
- package/dist/cli/lib/spinner.js +111 -0
- package/dist/cli/usage.d.ts +9 -0
- package/dist/cli/usage.d.ts.map +1 -0
- package/dist/cli/usage.js +468 -0
- package/dist/cli/utils.d.ts +291 -0
- package/dist/cli/utils.d.ts.map +1 -0
- package/dist/cli/utils.js +561 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +5 -0
- package/dist/config.d.ts +11 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +9 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/package.json +92 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hijack-clack-logger.d.ts","sourceRoot":"","sources":["../../../src/cli/lib/hijack-clack-logger.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { log } from "@clack/prompts";
|
|
2
|
+
import { green, red } from "ansis";
|
|
3
|
+
log.success = (message, opts) => {
|
|
4
|
+
log.message(message, { ...opts, symbol: green("✓") });
|
|
5
|
+
};
|
|
6
|
+
log.error = (message, opts) => {
|
|
7
|
+
log.message(message, { ...opts, symbol: red("✖") });
|
|
8
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export declare const accent: import("ansis").Ansis;
|
|
2
|
+
export declare const dimmed: import("ansis").Ansis;
|
|
3
|
+
/** Values supported by the terminal table renderer. */
|
|
4
|
+
type TableCellValue = string | number | boolean | bigint | null | undefined;
|
|
5
|
+
type TableInput<Row> = {
|
|
6
|
+
columns: readonly {
|
|
7
|
+
header: string;
|
|
8
|
+
cell: (row: Row) => TableCellValue;
|
|
9
|
+
}[];
|
|
10
|
+
rows: readonly Row[];
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Renders rows and column definitions as a bordered terminal table.
|
|
14
|
+
*
|
|
15
|
+
* @param input - Table columns and row values.
|
|
16
|
+
*/
|
|
17
|
+
export declare function renderTable<Row>(input: TableInput<Row>): string;
|
|
18
|
+
export {};
|
|
19
|
+
//# sourceMappingURL=io.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"io.d.ts","sourceRoot":"","sources":["../../../src/cli/lib/io.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,MAAM,uBAAc,CAAA;AACjC,eAAO,MAAM,MAAM,uBAAU,CAAA;AAE7B,uDAAuD;AACvD,KAAK,cAAc,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,CAAA;AAE3E,KAAK,UAAU,CAAC,GAAG,IAAI;IACrB,OAAO,EAAE,SAAS;QAChB,MAAM,EAAE,MAAM,CAAA;QACd,IAAI,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,cAAc,CAAA;KACnC,EAAE,CAAA;IACH,IAAI,EAAE,SAAS,GAAG,EAAE,CAAA;CACrB,CAAA;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,KAAK,EAAE,UAAU,CAAC,GAAG,CAAC,UA4EtD"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { fg, gray, yellow } from "ansis";
|
|
2
|
+
import stringWidth from "string-width";
|
|
3
|
+
export const accent = yellow.bold;
|
|
4
|
+
export const dimmed = fg(250);
|
|
5
|
+
/**
|
|
6
|
+
* Renders rows and column definitions as a bordered terminal table.
|
|
7
|
+
*
|
|
8
|
+
* @param input - Table columns and row values.
|
|
9
|
+
*/
|
|
10
|
+
export function renderTable(input) {
|
|
11
|
+
const { columns, rows } = input;
|
|
12
|
+
const { bodyLines, headerLines, widths } = prepareTable({ columns, rows });
|
|
13
|
+
const border = {
|
|
14
|
+
top: drawBorder("├", "┬", "┐", "─"),
|
|
15
|
+
middle: drawBorder("├", "┼", "┤", "─"),
|
|
16
|
+
bottom: drawBorder("├", "┴", "┘", "─"),
|
|
17
|
+
};
|
|
18
|
+
const lines = [border.top, drawRow(headerLines, true)];
|
|
19
|
+
if (bodyLines.length === 0) {
|
|
20
|
+
lines.push(border.bottom);
|
|
21
|
+
return lines.join("\n");
|
|
22
|
+
}
|
|
23
|
+
lines.push(border.middle);
|
|
24
|
+
for (const [index, row] of bodyLines.entries()) {
|
|
25
|
+
lines.push(drawRow(row, false));
|
|
26
|
+
lines.push(index === bodyLines.length - 1 ? border.bottom : border.middle);
|
|
27
|
+
}
|
|
28
|
+
return lines.join("\n");
|
|
29
|
+
/**
|
|
30
|
+
* Draws a horizontal border using the table's computed column widths.
|
|
31
|
+
*
|
|
32
|
+
* @param left - Character at the left edge.
|
|
33
|
+
* @param middle - Character joining adjacent columns.
|
|
34
|
+
* @param right - Character at the right edge.
|
|
35
|
+
* @param fill - Character repeated across each column.
|
|
36
|
+
*/
|
|
37
|
+
function drawBorder(left, middle, right, fill) {
|
|
38
|
+
return gray(left + widths.map((width) => fill.repeat(width + 2)).join(middle) + right);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Renders one logical row, including cells containing multiple lines.
|
|
42
|
+
*
|
|
43
|
+
* @param cells - Lines for each cell in the row.
|
|
44
|
+
* @param isHeader - Whether to apply header styling.
|
|
45
|
+
*/
|
|
46
|
+
function drawRow(cells, isHeader) {
|
|
47
|
+
const rowLines = [];
|
|
48
|
+
for (let lineIndex = 0; lineIndex < Math.max(...cells.map((cell) => cell.length)); lineIndex += 1) {
|
|
49
|
+
rowLines.push(gray("│") +
|
|
50
|
+
cells
|
|
51
|
+
.map((cell, columnIndex) => {
|
|
52
|
+
const content = padCell(cell[lineIndex] ?? "", widths[columnIndex] ?? 0);
|
|
53
|
+
return isHeader ? yellow(content) : content;
|
|
54
|
+
})
|
|
55
|
+
.join(gray("│")) +
|
|
56
|
+
gray("│"));
|
|
57
|
+
}
|
|
58
|
+
return rowLines.join("\n");
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Expands table values into lines and calculates each column's width.
|
|
63
|
+
*
|
|
64
|
+
* @param input - Table columns and rows to prepare.
|
|
65
|
+
*/
|
|
66
|
+
function prepareTable(input) {
|
|
67
|
+
const { columns, rows } = input;
|
|
68
|
+
const headerLines = columns.map((column) => [column.header]);
|
|
69
|
+
const bodyLines = rows.map((row) => columns.map((column) => String(column.cell(row) ?? "").split("\n")));
|
|
70
|
+
const widths = columns.map((_, columnIndex) => Math.max(stringWidth(headerLines[columnIndex]?.[0] ?? ""), ...bodyLines.flatMap((row) => (row[columnIndex] ?? [""]).map((line) => stringWidth(line)))));
|
|
71
|
+
return {
|
|
72
|
+
bodyLines,
|
|
73
|
+
headerLines,
|
|
74
|
+
lineWidth: widths.reduce((sum, width) => sum + width + 2, 0) +
|
|
75
|
+
Math.max(widths.length - 1, 0) * 2,
|
|
76
|
+
widths,
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Pads a table cell to a target visible width.
|
|
81
|
+
*
|
|
82
|
+
* @param value - Cell text to pad.
|
|
83
|
+
* @param width - Target display width excluding outer spaces.
|
|
84
|
+
*/
|
|
85
|
+
function padCell(value, width) {
|
|
86
|
+
return ` ${value}${" ".repeat(width - stringWidth(value) + 1)}`;
|
|
87
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** Checks whether the current process was invoked in JSON output mode. */
|
|
2
|
+
export declare function isJsonOutput(): boolean;
|
|
3
|
+
/**
|
|
4
|
+
* Writes a value as indented JSON to standard output.
|
|
5
|
+
*
|
|
6
|
+
* @param value - Serializable value to write.
|
|
7
|
+
*/
|
|
8
|
+
export declare function writeJson(value: unknown): void;
|
|
9
|
+
//# sourceMappingURL=json-output.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json-output.d.ts","sourceRoot":"","sources":["../../../src/cli/lib/json-output.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,wBAAgB,YAAY,YAE3B;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,QAEvC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** Checks whether the current process was invoked in JSON output mode. */
|
|
2
|
+
export function isJsonOutput() {
|
|
3
|
+
return process.argv.includes("--json");
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Writes a value as indented JSON to standard output.
|
|
7
|
+
*
|
|
8
|
+
* @param value - Serializable value to write.
|
|
9
|
+
*/
|
|
10
|
+
export function writeJson(value) {
|
|
11
|
+
console.log(JSON.stringify(value, null, 2));
|
|
12
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
interface OrganizationDetail {
|
|
2
|
+
activeSubscription?: {
|
|
3
|
+
periodEnd?: Date | string | null;
|
|
4
|
+
status: string;
|
|
5
|
+
} | null;
|
|
6
|
+
createdAt: Date | string;
|
|
7
|
+
id: string;
|
|
8
|
+
limits: {
|
|
9
|
+
projects: number;
|
|
10
|
+
seats: number;
|
|
11
|
+
};
|
|
12
|
+
memberCount: number;
|
|
13
|
+
name: string;
|
|
14
|
+
pendingInvitationCount: number;
|
|
15
|
+
plan?: string | null;
|
|
16
|
+
projectCount: number;
|
|
17
|
+
role?: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Renders an organization's identity, plan, usage, and billing details.
|
|
21
|
+
*
|
|
22
|
+
* @param org - Organization data to display.
|
|
23
|
+
* @param options - Optional fields to include in the block.
|
|
24
|
+
* @param options.includeRole - Whether to include the caller's role.
|
|
25
|
+
*/
|
|
26
|
+
export declare function renderOrganizationDetailBlock(org: OrganizationDetail, options?: {
|
|
27
|
+
includeRole?: boolean;
|
|
28
|
+
}): string;
|
|
29
|
+
export {};
|
|
30
|
+
//# sourceMappingURL=organization-detail-block.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"organization-detail-block.d.ts","sourceRoot":"","sources":["../../../src/cli/lib/organization-detail-block.ts"],"names":[],"mappings":"AAIA,UAAU,kBAAkB;IAC1B,kBAAkB,CAAC,EAAE;QACnB,SAAS,CAAC,EAAE,IAAI,GAAG,MAAM,GAAG,IAAI,CAAA;QAChC,MAAM,EAAE,MAAM,CAAA;KACf,GAAG,IAAI,CAAA;IACR,SAAS,EAAE,IAAI,GAAG,MAAM,CAAA;IACxB,EAAE,EAAE,MAAM,CAAA;IACV,MAAM,EAAE;QACN,QAAQ,EAAE,MAAM,CAAA;QAChB,KAAK,EAAE,MAAM,CAAA;KACd,CAAA;IACD,WAAW,EAAE,MAAM,CAAA;IACnB,IAAI,EAAE,MAAM,CAAA;IACZ,sBAAsB,EAAE,MAAM,CAAA;IAC9B,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,YAAY,EAAE,MAAM,CAAA;IACpB,IAAI,CAAC,EAAE,MAAM,CAAA;CACd;AAED;;;;;;GAMG;AACH,wBAAgB,6BAA6B,CAC3C,GAAG,EAAE,kBAAkB,EACvB,OAAO,GAAE;IAAE,WAAW,CAAC,EAAE,OAAO,CAAA;CAAO,UAwBxC"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { toTitleCase } from "remeda";
|
|
2
|
+
import { renderDetailBlock } from "./detail-block.js";
|
|
3
|
+
import { dimmed } from "./io.js";
|
|
4
|
+
/**
|
|
5
|
+
* Renders an organization's identity, plan, usage, and billing details.
|
|
6
|
+
*
|
|
7
|
+
* @param org - Organization data to display.
|
|
8
|
+
* @param options - Optional fields to include in the block.
|
|
9
|
+
* @param options.includeRole - Whether to include the caller's role.
|
|
10
|
+
*/
|
|
11
|
+
export function renderOrganizationDetailBlock(org, options = {}) {
|
|
12
|
+
return renderDetailBlock({
|
|
13
|
+
[dimmed `Name`]: org.name,
|
|
14
|
+
[dimmed `ID`]: dimmed(org.id),
|
|
15
|
+
[dimmed `Created`]: formatDate(org.createdAt),
|
|
16
|
+
[dimmed `Plan`]: getPlanName(org.plan),
|
|
17
|
+
...(options.includeRole && org.role
|
|
18
|
+
? { [dimmed `Role`]: toTitleCase(org.role) }
|
|
19
|
+
: {}),
|
|
20
|
+
[dimmed `Seats`]: `${org.memberCount + org.pendingInvitationCount} / ${org.limits.seats}`,
|
|
21
|
+
[dimmed `Projects`]: `${org.projectCount} / ${org.limits.projects}`,
|
|
22
|
+
...(org.activeSubscription
|
|
23
|
+
? {
|
|
24
|
+
[dimmed `Billing`]: formatBillingStatus(org.activeSubscription),
|
|
25
|
+
[dimmed `Renews`]: org.activeSubscription.periodEnd
|
|
26
|
+
? formatDate(org.activeSubscription.periodEnd)
|
|
27
|
+
: null,
|
|
28
|
+
}
|
|
29
|
+
: {}),
|
|
30
|
+
}, { keyAlignment: "right" });
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Converts an internal plan identifier to a display name.
|
|
34
|
+
*
|
|
35
|
+
* @param plan - Internal plan identifier.
|
|
36
|
+
*/
|
|
37
|
+
function getPlanName(plan) {
|
|
38
|
+
switch (plan) {
|
|
39
|
+
case "enterprise":
|
|
40
|
+
return "Enterprise";
|
|
41
|
+
case "pro":
|
|
42
|
+
return "Pro";
|
|
43
|
+
default:
|
|
44
|
+
return "Free";
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Converts a subscription status to a billing label.
|
|
49
|
+
*
|
|
50
|
+
* @param billing - Subscription billing state.
|
|
51
|
+
* @param billing.status - Internal subscription status identifier.
|
|
52
|
+
*/
|
|
53
|
+
function formatBillingStatus(billing) {
|
|
54
|
+
return ({
|
|
55
|
+
active: "Active",
|
|
56
|
+
canceled: "Canceled",
|
|
57
|
+
incomplete: "Incomplete",
|
|
58
|
+
incomplete_expired: "Incomplete",
|
|
59
|
+
past_due: "Payment issue",
|
|
60
|
+
paused: "Paused",
|
|
61
|
+
trialing: "Trial",
|
|
62
|
+
unpaid: "Payment issue",
|
|
63
|
+
}[billing.status] ?? "Active");
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Formats a date for the user's locale.
|
|
67
|
+
*
|
|
68
|
+
* @param date - Date value to format.
|
|
69
|
+
*/
|
|
70
|
+
function formatDate(date) {
|
|
71
|
+
return new Date(date).toLocaleDateString();
|
|
72
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Loads and validates a project's Automate.ax configuration file.
|
|
3
|
+
*
|
|
4
|
+
* @param configPath - Absolute path to the configuration file.
|
|
5
|
+
* @throws When the file cannot be loaded or its contents are invalid.
|
|
6
|
+
*/
|
|
7
|
+
export declare function loadProjectConfig(configPath: string): Promise<{
|
|
8
|
+
projectId: string;
|
|
9
|
+
}>;
|
|
10
|
+
//# sourceMappingURL=project-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project-config.d.ts","sourceRoot":"","sources":["../../../src/cli/lib/project-config.ts"],"names":[],"mappings":"AASA;;;;;GAKG;AACH,wBAAsB,iBAAiB,CAAC,UAAU,EAAE,MAAM;;GAQzD"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { loadConfig } from "c12";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import z from "zod";
|
|
4
|
+
/** Schema for the project identifier stored in a Automate.ax config file. */
|
|
5
|
+
const projectConfigSchema = z.object({
|
|
6
|
+
projectId: z.string(),
|
|
7
|
+
});
|
|
8
|
+
/**
|
|
9
|
+
* Loads and validates a project's Automate.ax configuration file.
|
|
10
|
+
*
|
|
11
|
+
* @param configPath - Absolute path to the configuration file.
|
|
12
|
+
* @throws When the file cannot be loaded or its contents are invalid.
|
|
13
|
+
*/
|
|
14
|
+
export async function loadProjectConfig(configPath) {
|
|
15
|
+
const { config } = await loadConfig({
|
|
16
|
+
configFile: path.basename(configPath),
|
|
17
|
+
configFileRequired: true,
|
|
18
|
+
cwd: path.dirname(configPath),
|
|
19
|
+
});
|
|
20
|
+
return projectConfigSchema.parse(config);
|
|
21
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Starts a spinner before an operation and clears it after successful
|
|
3
|
+
* completion.
|
|
4
|
+
*
|
|
5
|
+
* @param message - Status message displayed while the operation runs.
|
|
6
|
+
* @param operation - Asynchronous operation to execute.
|
|
7
|
+
*/
|
|
8
|
+
export declare function withSpinner<T>(message: string, operation: () => Promise<T>): Promise<T>;
|
|
9
|
+
/**
|
|
10
|
+
* Replaces any active spinner with a new status message.
|
|
11
|
+
*
|
|
12
|
+
* @param message - Status message to display.
|
|
13
|
+
* @param interruptMessage - Message shown when the user interrupts the wait.
|
|
14
|
+
*/
|
|
15
|
+
export declare function startSpinner(message: string, interruptMessage?: string): void;
|
|
16
|
+
/** Clears the active spinner and removes its terminal output. */
|
|
17
|
+
export declare function clearSpinner(): void;
|
|
18
|
+
//# sourceMappingURL=spinner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spinner.d.ts","sourceRoot":"","sources":["../../../src/cli/lib/spinner.ts"],"names":[],"mappings":"AAQA;;;;;;GAMG;AACH,wBAAsB,WAAW,CAAC,CAAC,EACjC,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAC1B,OAAO,CAAC,CAAC,CAAC,CAMZ;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,gBAAgB,SAAc,QAM3E;AAED,iEAAiE;AACjE,wBAAgB,YAAY,SAG3B"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { S_BAR, cancel, isCI, log, settings, unicode } from "@clack/prompts";
|
|
2
|
+
import { dim, gray, yellow } from "ansis";
|
|
3
|
+
import { clearScreenDown, cursorTo, moveCursor } from "node:readline";
|
|
4
|
+
import { isJsonOutput } from "./json-output.js";
|
|
5
|
+
let activeSpinner;
|
|
6
|
+
let sigintHandlerInstalled = false;
|
|
7
|
+
/**
|
|
8
|
+
* Starts a spinner before an operation and clears it after successful
|
|
9
|
+
* completion.
|
|
10
|
+
*
|
|
11
|
+
* @param message - Status message displayed while the operation runs.
|
|
12
|
+
* @param operation - Asynchronous operation to execute.
|
|
13
|
+
*/
|
|
14
|
+
export async function withSpinner(message, operation) {
|
|
15
|
+
startSpinner(message);
|
|
16
|
+
return await operation().then((result) => {
|
|
17
|
+
clearSpinner();
|
|
18
|
+
return result;
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Replaces any active spinner with a new status message.
|
|
23
|
+
*
|
|
24
|
+
* @param message - Status message to display.
|
|
25
|
+
* @param interruptMessage - Message shown when the user interrupts the wait.
|
|
26
|
+
*/
|
|
27
|
+
export function startSpinner(message, interruptMessage = "Cancelled") {
|
|
28
|
+
clearSpinner();
|
|
29
|
+
if (isJsonOutput())
|
|
30
|
+
return;
|
|
31
|
+
ensureSigintHandler();
|
|
32
|
+
activeSpinner = createSpinner(message, interruptMessage);
|
|
33
|
+
}
|
|
34
|
+
/** Clears the active spinner and removes its terminal output. */
|
|
35
|
+
export function clearSpinner() {
|
|
36
|
+
activeSpinner?.clear();
|
|
37
|
+
activeSpinner = undefined;
|
|
38
|
+
}
|
|
39
|
+
/** Handles interruption by clearing and marking the active operation canceled. */
|
|
40
|
+
function handleSigint() {
|
|
41
|
+
if (!activeSpinner)
|
|
42
|
+
return;
|
|
43
|
+
const { interruptMessage, message } = activeSpinner;
|
|
44
|
+
clearSpinner();
|
|
45
|
+
log.error(dim.strikethrough(message));
|
|
46
|
+
cancel(interruptMessage);
|
|
47
|
+
process.exit(0);
|
|
48
|
+
}
|
|
49
|
+
/** Installs the process interruption handler at most once. */
|
|
50
|
+
function ensureSigintHandler() {
|
|
51
|
+
if (sigintHandlerInstalled)
|
|
52
|
+
return;
|
|
53
|
+
sigintHandlerInstalled = true;
|
|
54
|
+
process.on("SIGINT", handleSigint);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Creates an interactive spinner or a static status line for non-TTY output.
|
|
58
|
+
*
|
|
59
|
+
* @param message - Status message to display.
|
|
60
|
+
* @param interruptMessage - Message shown when the user interrupts the wait.
|
|
61
|
+
*/
|
|
62
|
+
function createSpinner(message, interruptMessage) {
|
|
63
|
+
const frames = unicode ? ["◒", "◐", "◓", "◑"] : ["•", "o", "O", "0"];
|
|
64
|
+
let frameIndex = 0;
|
|
65
|
+
let interval;
|
|
66
|
+
let previousOutput;
|
|
67
|
+
let wroteGuide = false;
|
|
68
|
+
let active = true;
|
|
69
|
+
/** Removes the previously rendered spinner frame from the terminal. */
|
|
70
|
+
function clearPreviousOutput() {
|
|
71
|
+
if (previousOutput === undefined)
|
|
72
|
+
return;
|
|
73
|
+
const lines = previousOutput.split("\n");
|
|
74
|
+
if (lines.length > 1)
|
|
75
|
+
moveCursor(process.stderr, 0, -(lines.length - 1));
|
|
76
|
+
cursorTo(process.stderr, 0);
|
|
77
|
+
clearScreenDown(process.stderr);
|
|
78
|
+
}
|
|
79
|
+
/** Renders the next spinner frame. */
|
|
80
|
+
function render() {
|
|
81
|
+
clearPreviousOutput();
|
|
82
|
+
previousOutput = `${yellow(frames[frameIndex] ?? frames[0])} ${message}`;
|
|
83
|
+
process.stderr.write(previousOutput);
|
|
84
|
+
frameIndex = frameIndex + 1 < frames.length ? frameIndex + 1 : 0;
|
|
85
|
+
}
|
|
86
|
+
/** Stops animation and removes all spinner output. */
|
|
87
|
+
function clear() {
|
|
88
|
+
if (!active)
|
|
89
|
+
return;
|
|
90
|
+
active = false;
|
|
91
|
+
if (interval)
|
|
92
|
+
clearInterval(interval);
|
|
93
|
+
clearPreviousOutput();
|
|
94
|
+
if (wroteGuide) {
|
|
95
|
+
moveCursor(process.stderr, 0, -1);
|
|
96
|
+
cursorTo(process.stderr, 0);
|
|
97
|
+
clearScreenDown(process.stderr);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
if (!process.stderr.isTTY || isCI()) {
|
|
101
|
+
log.message(message, { output: process.stderr, symbol: "-" });
|
|
102
|
+
return { clear, interruptMessage, message };
|
|
103
|
+
}
|
|
104
|
+
if (settings.withGuide) {
|
|
105
|
+
wroteGuide = true;
|
|
106
|
+
process.stderr.write(`${gray(S_BAR)}\n`);
|
|
107
|
+
}
|
|
108
|
+
render();
|
|
109
|
+
interval = setInterval(render, unicode ? 80 : 120);
|
|
110
|
+
return { clear, interruptMessage, message };
|
|
111
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { RunMainOptions } from "citty";
|
|
2
|
+
/**
|
|
3
|
+
* Prints CLI help with Automate.ax's own accent color and grouped root commands.
|
|
4
|
+
*
|
|
5
|
+
* @param cmd - Command definition to render.
|
|
6
|
+
* @param parent - Parent definition for a nested command.
|
|
7
|
+
*/
|
|
8
|
+
export declare const showUsage: NonNullable<RunMainOptions["showUsage"]>;
|
|
9
|
+
//# sourceMappingURL=usage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usage.d.ts","sourceRoot":"","sources":["../../src/cli/usage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAMV,cAAc,EAEf,MAAM,OAAO,CAAA;AA8Bd;;;;;GAKG;AACH,eAAO,MAAM,SAAS,EAAE,WAAW,CAAC,cAAc,CAAC,WAAW,CAAC,CAO9D,CAAA"}
|