@zinn-dev/cli 0.39.0 → 0.41.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +171 -40
- package/index.d.ts +2 -0
- package/index.js +34 -0
- package/package.json +27 -18
- package/skills/zinn/SKILL.md +63 -0
- package/src/actor.d.ts +7 -0
- package/src/actor.js +129 -0
- package/src/capabilities-schema.d.ts +163 -0
- package/src/capabilities-schema.js +124 -0
- package/src/capabilities.d.ts +21 -0
- package/src/capabilities.js +22 -0
- package/src/database.d.ts +6 -0
- package/src/database.js +27 -0
- package/src/errors.d.ts +158 -0
- package/src/errors.js +224 -0
- package/src/input.d.ts +116 -0
- package/src/input.js +119 -0
- package/src/lib.d.ts +66 -0
- package/src/lib.js +333 -0
- package/src/presentation/activity-presentation.d.ts +23 -0
- package/src/presentation/activity-presentation.js +403 -0
- package/src/presentation/color.d.ts +9 -0
- package/src/presentation/color.js +21 -0
- package/src/presentation/column-presentation.d.ts +14 -0
- package/src/presentation/column-presentation.js +29 -0
- package/src/presentation/description-presentation.d.ts +3 -0
- package/src/presentation/description-presentation.js +11 -0
- package/src/presentation/info-presentation.d.ts +4 -0
- package/src/presentation/info-presentation.js +96 -0
- package/src/presentation/row-layout.d.ts +22 -0
- package/src/presentation/row-layout.js +58 -0
- package/src/presentation/section.d.ts +4 -0
- package/src/presentation/section.js +9 -0
- package/src/presentation/task-presentation.d.ts +9 -0
- package/src/presentation/task-presentation.js +62 -0
- package/src/presentation/time.d.ts +1 -0
- package/src/presentation/time.js +13 -0
- package/src/project.d.ts +12 -0
- package/src/project.js +44 -0
- package/src/release-identity.d.ts +2 -0
- package/src/release-identity.js +1 -0
- package/src/result-schemas.d.ts +987 -0
- package/src/result-schemas.js +220 -0
- package/src/results.d.ts +23 -0
- package/src/results.js +17 -0
- package/src/routes/activity-router.d.ts +81 -0
- package/src/routes/activity-router.js +119 -0
- package/src/routes/backup-router.d.ts +21 -0
- package/src/routes/backup-router.js +30 -0
- package/src/routes/capabilities-router.d.ts +21 -0
- package/src/routes/capabilities-router.js +28 -0
- package/src/routes/comment-router.d.ts +203 -0
- package/src/routes/comment-router.js +241 -0
- package/src/routes/info-router.d.ts +21 -0
- package/src/routes/info-router.js +29 -0
- package/src/routes/label-router.d.ts +183 -0
- package/src/routes/label-router.js +218 -0
- package/src/routes/migrate-router.d.ts +21 -0
- package/src/routes/migrate-router.js +49 -0
- package/src/routes/project-router.d.ts +389 -0
- package/src/routes/project-router.js +514 -0
- package/src/routes/reindex-router.d.ts +21 -0
- package/src/routes/reindex-router.js +33 -0
- package/src/routes/relation-router.d.ts +124 -0
- package/src/routes/relation-router.js +223 -0
- package/src/routes/restore-router.d.ts +33 -0
- package/src/routes/restore-router.js +88 -0
- package/src/routes/router.d.ts +6 -0
- package/src/routes/router.js +204 -0
- package/src/routes/routes.d.ts +1735 -0
- package/src/routes/routes.js +23 -0
- package/src/routes/task-router.d.ts +945 -0
- package/src/routes/task-router.js +789 -0
- package/src/text-edit.d.ts +43 -0
- package/src/text-edit.js +57 -0
- package/src/types.d.ts +24 -0
- package/src/types.js +1 -0
- package/index.ts +0 -26
- package/release-stamp.json +0 -1
- package/src/actor.test.ts +0 -41
- package/src/actor.ts +0 -78
- package/src/database.test.ts +0 -70
- package/src/database.ts +0 -41
- package/src/lib.test.ts +0 -86
- package/src/lib.ts +0 -159
- package/src/presentation/activity-presentation.test.ts +0 -112
- package/src/presentation/activity-presentation.ts +0 -490
- package/src/presentation/color.ts +0 -29
- package/src/presentation/column-presentation.ts +0 -48
- package/src/presentation/description-presentation.ts +0 -18
- package/src/presentation/row-layout.ts +0 -77
- package/src/presentation/section.ts +0 -16
- package/src/presentation/task-presentation.ts +0 -92
- package/src/presentation/time.ts +0 -17
- package/src/project.test.ts +0 -479
- package/src/project.ts +0 -53
- package/src/routes/activity-router.ts +0 -81
- package/src/routes/backup-router.ts +0 -24
- package/src/routes/comment-router.ts +0 -171
- package/src/routes/label-router.ts +0 -168
- package/src/routes/migrate-router.test.ts +0 -31
- package/src/routes/migrate-router.ts +0 -48
- package/src/routes/project-router.ts +0 -415
- package/src/routes/reindex-router.ts +0 -27
- package/src/routes/relation-router.ts +0 -194
- package/src/routes/restore-router.test.ts +0 -44
- package/src/routes/restore-router.ts +0 -90
- package/src/routes/router.test.ts +0 -136
- package/src/routes/router.ts +0 -248
- package/src/routes/routes.ts +0 -20
- package/src/routes/task-router.ts +0 -649
- package/src/text-edit.ts +0 -68
- package/src/types.ts +0 -6
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import type { StyleFormat } from "./color";
|
|
2
|
-
|
|
3
|
-
import { styleOutputText } from "./color";
|
|
4
|
-
|
|
5
|
-
export type RowCell = { text: string; style?: StyleFormat };
|
|
6
|
-
|
|
7
|
-
const CELL_SEPARATOR = " | ";
|
|
8
|
-
const LINE_BREAK_PATTERN = /\r?\n/;
|
|
9
|
-
|
|
10
|
-
export function formatCell(cell: RowCell, width = cell.text.length) {
|
|
11
|
-
const paddedText = cell.text.padEnd(width);
|
|
12
|
-
|
|
13
|
-
if (cell.style == null) {
|
|
14
|
-
return paddedText;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
return styleOutputText(cell.style, paddedText);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Rows that join extra text onto their last cell, such as a task's labels, put one there too, which is why it is exported.
|
|
22
|
-
*/
|
|
23
|
-
export function formatCellSeparator() {
|
|
24
|
-
return styleOutputText("dim", CELL_SEPARATOR);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
function indentContinuationLines(text: string, indentWidth: number) {
|
|
28
|
-
return text.split(LINE_BREAK_PATTERN).join(`\n${" ".repeat(indentWidth)}`);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Lines rows up by padding each cell's text to its column's **widest** text.
|
|
33
|
-
* Widths use `String.length`, so emoji and CJK misalign.
|
|
34
|
-
* A row's last cell holds free text such as a title and is left unpadded.
|
|
35
|
-
*
|
|
36
|
-
* With `indentsContinuationLines`, a last cell that spans several lines starts each later line
|
|
37
|
-
* where the cell starts, below the padded cells before it. Without it, those lines are left as they are.
|
|
38
|
-
* Only a last cell may span lines: the widths do not account for line breaks.
|
|
39
|
-
*/
|
|
40
|
-
export function formatRows(
|
|
41
|
-
rows: Array<Array<RowCell>>,
|
|
42
|
-
options: { indentsContinuationLines?: boolean } = {},
|
|
43
|
-
) {
|
|
44
|
-
const columnWidths: Array<number> = [];
|
|
45
|
-
|
|
46
|
-
for (const row of rows) {
|
|
47
|
-
row.forEach((cell, columnIndex) => {
|
|
48
|
-
columnWidths[columnIndex] = Math.max(columnWidths[columnIndex] ?? 0, cell.text.length);
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
return rows
|
|
53
|
-
.map((row) => {
|
|
54
|
-
const lastCellIndex = row.length - 1;
|
|
55
|
-
const lastCellStartColumn = columnWidths
|
|
56
|
-
.slice(0, lastCellIndex)
|
|
57
|
-
.reduce((total, width) => total + width + CELL_SEPARATOR.length, 0);
|
|
58
|
-
|
|
59
|
-
return row
|
|
60
|
-
.map((cell, columnIndex) => {
|
|
61
|
-
if (columnIndex !== lastCellIndex) {
|
|
62
|
-
return formatCell(cell, columnWidths[columnIndex]!);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
if (!options.indentsContinuationLines) {
|
|
66
|
-
return formatCell(cell);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
return formatCell({
|
|
70
|
-
...cell,
|
|
71
|
-
text: indentContinuationLines(cell.text, lastCellStartColumn),
|
|
72
|
-
});
|
|
73
|
-
})
|
|
74
|
-
.join(formatCellSeparator());
|
|
75
|
-
})
|
|
76
|
-
.join("\n");
|
|
77
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { styleOutputText } from "./color";
|
|
2
|
-
|
|
3
|
-
/** A bold heading above its body, optionally preceded by a dim horizontal rule. */
|
|
4
|
-
export function formatSection(
|
|
5
|
-
heading: string,
|
|
6
|
-
body: string,
|
|
7
|
-
options: { separatorWidth?: number } = {},
|
|
8
|
-
) {
|
|
9
|
-
const section = `${styleOutputText("bold", `${heading}:`)}\n${body}`;
|
|
10
|
-
|
|
11
|
-
if (options.separatorWidth === undefined) {
|
|
12
|
-
return section;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
return `${styleOutputText("dim", "-".repeat(options.separatorWidth))}\n${section}`;
|
|
16
|
-
}
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import type { LabelColor, TaskPriority, TaskWithKey } from "@zinn-dev/core";
|
|
2
|
-
import type { RowCell } from "./row-layout";
|
|
3
|
-
|
|
4
|
-
import { column, label, task } from "@zinn-dev/core";
|
|
5
|
-
|
|
6
|
-
import { styleOutputText } from "./color";
|
|
7
|
-
import { columnNameCell } from "./column-presentation";
|
|
8
|
-
import { formatCellSeparator, formatRows } from "./row-layout";
|
|
9
|
-
|
|
10
|
-
export type PresentedTask = {
|
|
11
|
-
key: string;
|
|
12
|
-
status: "Active" | "Archived";
|
|
13
|
-
column: string;
|
|
14
|
-
title: string;
|
|
15
|
-
description: string | null;
|
|
16
|
-
priority: TaskPriority | null;
|
|
17
|
-
labels: Array<string>;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
const EMPTY_CELL_MARKER = "-";
|
|
21
|
-
const LABEL_NAME_SEPARATOR = ", ";
|
|
22
|
-
|
|
23
|
-
function taskPriorityCell(priority: TaskPriority | null, showsFullPriority: boolean): RowCell {
|
|
24
|
-
if (priority == null) {
|
|
25
|
-
return { text: EMPTY_CELL_MARKER, style: "dim" };
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
const priorityInitial = priority[0]!.toUpperCase();
|
|
29
|
-
return { text: showsFullPriority ? `${priorityInitial}${priority.slice(1)}` : priorityInitial };
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* `PresentedTask` carries label names only, so JSON stays a list of names.
|
|
34
|
-
* Text output looks the colors up from the label definitions instead.
|
|
35
|
-
*/
|
|
36
|
-
function getLabelColorsByName() {
|
|
37
|
-
return new Map(label.getAll().map((labelMatch) => [labelMatch.name, labelMatch.color]));
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
function formatLabelNames(labelNames: Array<string>, labelColorsByName: Map<string, LabelColor>) {
|
|
41
|
-
return labelNames
|
|
42
|
-
.map((labelName) => styleOutputText(labelColorsByName.get(labelName)!, labelName))
|
|
43
|
-
.join(LABEL_NAME_SEPARATOR);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export function presentTask(taskMatch: TaskWithKey): PresentedTask {
|
|
47
|
-
return {
|
|
48
|
-
key: taskMatch.key,
|
|
49
|
-
status: taskMatch.archived_at == null ? "Active" : "Archived",
|
|
50
|
-
column: column.getById(taskMatch.column_id)!.name,
|
|
51
|
-
title: taskMatch.title,
|
|
52
|
-
description: taskMatch.description,
|
|
53
|
-
priority: taskMatch.priority,
|
|
54
|
-
labels: task.label.getAll(taskMatch.key).map((label) => label.name),
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export function formatTaskRow(presented: PresentedTask) {
|
|
59
|
-
return formatTaskList([presented]);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
export function formatTaskList(
|
|
63
|
-
presentedTasks: Array<PresentedTask>,
|
|
64
|
-
options: { showsStatus?: boolean; showsFullPriority?: boolean } = {},
|
|
65
|
-
) {
|
|
66
|
-
const labelColorsByName = getLabelColorsByName();
|
|
67
|
-
|
|
68
|
-
return formatRows(
|
|
69
|
-
presentedTasks.map((presentedTask) => {
|
|
70
|
-
const statusCells: Array<RowCell> = options.showsStatus
|
|
71
|
-
? [{ text: presentedTask.status }]
|
|
72
|
-
: [];
|
|
73
|
-
const hasLabels = presentedTask.labels.length > 0;
|
|
74
|
-
// The last cell is never padded, so the color codes in its separator and label names do not affect column widths.
|
|
75
|
-
const labels = hasLabels
|
|
76
|
-
? `${formatCellSeparator()}${formatLabelNames(presentedTask.labels, labelColorsByName)}`
|
|
77
|
-
: "";
|
|
78
|
-
|
|
79
|
-
return [
|
|
80
|
-
{ text: presentedTask.key },
|
|
81
|
-
...statusCells,
|
|
82
|
-
columnNameCell(presentedTask.column),
|
|
83
|
-
taskPriorityCell(presentedTask.priority, options.showsFullPriority ?? false),
|
|
84
|
-
{ text: `${presentedTask.title}${labels}` },
|
|
85
|
-
];
|
|
86
|
-
}),
|
|
87
|
-
);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
export function formatTaskListWithStatus(presentedTasks: Array<PresentedTask>) {
|
|
91
|
-
return formatTaskList(presentedTasks, { showsStatus: true });
|
|
92
|
-
}
|
package/src/presentation/time.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
const MINUTES_PER_HOUR = 60;
|
|
2
|
-
|
|
3
|
-
export function formatLocalTime(timestamp: number) {
|
|
4
|
-
const date = new Date(timestamp);
|
|
5
|
-
const offsetMinutes = -date.getTimezoneOffset();
|
|
6
|
-
const offsetSign = offsetMinutes >= 0 ? "+" : "-";
|
|
7
|
-
const absoluteOffsetMinutes = Math.abs(offsetMinutes);
|
|
8
|
-
const offsetHours = Math.floor(absoluteOffsetMinutes / MINUTES_PER_HOUR);
|
|
9
|
-
const remainingOffsetMinutes = absoluteOffsetMinutes % MINUTES_PER_HOUR;
|
|
10
|
-
const pad = (value: number) => String(value).padStart(2, "0");
|
|
11
|
-
|
|
12
|
-
return (
|
|
13
|
-
`${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())} ` +
|
|
14
|
-
`${pad(date.getHours())}:${pad(date.getMinutes())} ` +
|
|
15
|
-
`${offsetSign}${pad(offsetHours)}:${pad(remainingOffsetMinutes)}`
|
|
16
|
-
);
|
|
17
|
-
}
|