@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
|
@@ -0,0 +1,514 @@
|
|
|
1
|
+
import { jsonResult } from "../results.js";
|
|
2
|
+
import { parseArgs } from "node:util";
|
|
3
|
+
import { column, project, columnOrderSchema } from "@zinn-dev/core";
|
|
4
|
+
import { CliError } from "../errors.js";
|
|
5
|
+
import { generateCommandUsage, getOptionInputs, noInput, violatesConstraint } from "../input.js";
|
|
6
|
+
import { confirmationDescription, canPrompt, confirmAction, dashValueHelp, diagnostic, output, quit, validatePositionals, validateOrderForms, requireStringOption, validateUniqueOptions, } from "../lib.js";
|
|
7
|
+
import { resolveTextEdit, textEditHelp, textEditOptions, textEditConstraints, } from "../text-edit.js";
|
|
8
|
+
import { formatColumnList } from "../presentation/column-presentation.js";
|
|
9
|
+
import { formatDescriptionPreview } from "../presentation/description-presentation.js";
|
|
10
|
+
import { formatCellSeparator, formatRows } from "../presentation/row-layout.js";
|
|
11
|
+
import { formatSection } from "../presentation/section.js";
|
|
12
|
+
import { currentActor } from "../actor.js";
|
|
13
|
+
import { resolveProjectKey, requiredProjectDescription } from "../project.js";
|
|
14
|
+
function presentProject(projectMatch) {
|
|
15
|
+
return { key: projectMatch.key, name: projectMatch.name, description: projectMatch.description };
|
|
16
|
+
}
|
|
17
|
+
function formatProject(presented, options = {}) {
|
|
18
|
+
return formatProjectList([presented], options);
|
|
19
|
+
}
|
|
20
|
+
function formatProjectList(presentedProjects, { showsDescriptionPreview = true } = {}) {
|
|
21
|
+
return formatRows(presentedProjects.map((presented) => {
|
|
22
|
+
const descriptionPreview = showsDescriptionPreview
|
|
23
|
+
? formatDescriptionPreview(presented.description)
|
|
24
|
+
: "";
|
|
25
|
+
const description = descriptionPreview.length > 0 ? `${formatCellSeparator()}${descriptionPreview}` : "";
|
|
26
|
+
return [{ text: presented.key }, { text: `${presented.name}${description}` }];
|
|
27
|
+
}));
|
|
28
|
+
}
|
|
29
|
+
function presentColumn(columnMatch) {
|
|
30
|
+
const columnProject = project.getById(columnMatch.project_id);
|
|
31
|
+
return { project: columnProject.key, name: columnMatch.name };
|
|
32
|
+
}
|
|
33
|
+
function formatColumn(presented) {
|
|
34
|
+
return formatColumnList([presented], { showsProject: true });
|
|
35
|
+
}
|
|
36
|
+
const projectEditConstraint = {
|
|
37
|
+
kind: "atLeastOne",
|
|
38
|
+
members: ["option:name", "option:description"],
|
|
39
|
+
};
|
|
40
|
+
const projectInputs = {
|
|
41
|
+
create: {
|
|
42
|
+
options: {
|
|
43
|
+
name: { type: "string", value: { kind: "text", name: "text" } },
|
|
44
|
+
description: { type: "string", value: { kind: "text", name: "text" } },
|
|
45
|
+
},
|
|
46
|
+
forms: [
|
|
47
|
+
{
|
|
48
|
+
id: "default",
|
|
49
|
+
positionals: [{ name: "project-key", min: 1, max: 1, value: { kind: "project-key" } }],
|
|
50
|
+
},
|
|
51
|
+
],
|
|
52
|
+
constraints: [],
|
|
53
|
+
},
|
|
54
|
+
list: noInput,
|
|
55
|
+
view: {
|
|
56
|
+
options: {},
|
|
57
|
+
forms: [
|
|
58
|
+
{
|
|
59
|
+
id: "default",
|
|
60
|
+
positionals: [{ name: "project-key", min: 0, max: 1, value: { kind: "project-key" } }],
|
|
61
|
+
},
|
|
62
|
+
],
|
|
63
|
+
constraints: [],
|
|
64
|
+
notes: [requiredProjectDescription],
|
|
65
|
+
},
|
|
66
|
+
edit: {
|
|
67
|
+
options: {
|
|
68
|
+
name: { type: "string", value: { kind: "text", name: "text" } },
|
|
69
|
+
description: { type: "string", value: { kind: "text", name: "text" } },
|
|
70
|
+
...textEditOptions,
|
|
71
|
+
},
|
|
72
|
+
forms: [
|
|
73
|
+
{
|
|
74
|
+
id: "default",
|
|
75
|
+
positionals: [{ name: "project-key", min: 0, max: 1, value: { kind: "project-key" } }],
|
|
76
|
+
},
|
|
77
|
+
],
|
|
78
|
+
constraints: [...textEditConstraints("--description"), projectEditConstraint],
|
|
79
|
+
notes: [requiredProjectDescription, textEditHelp("--description")],
|
|
80
|
+
},
|
|
81
|
+
delete: {
|
|
82
|
+
options: { yes: { type: "boolean" } },
|
|
83
|
+
forms: [
|
|
84
|
+
{
|
|
85
|
+
id: "default",
|
|
86
|
+
positionals: [{ name: "project-key", min: 0, max: 1, value: { kind: "project-key" } }],
|
|
87
|
+
},
|
|
88
|
+
],
|
|
89
|
+
constraints: [],
|
|
90
|
+
notes: [requiredProjectDescription],
|
|
91
|
+
},
|
|
92
|
+
column_create: {
|
|
93
|
+
options: {},
|
|
94
|
+
forms: [
|
|
95
|
+
{
|
|
96
|
+
id: "default",
|
|
97
|
+
positionals: [
|
|
98
|
+
{ name: "project-key", min: 1, max: 1, value: { kind: "project-key" } },
|
|
99
|
+
{ name: "column-name", min: 1, max: 1, value: { kind: "column-name" } },
|
|
100
|
+
],
|
|
101
|
+
},
|
|
102
|
+
],
|
|
103
|
+
constraints: [],
|
|
104
|
+
},
|
|
105
|
+
column_list: {
|
|
106
|
+
options: {},
|
|
107
|
+
forms: [
|
|
108
|
+
{
|
|
109
|
+
id: "default",
|
|
110
|
+
positionals: [{ name: "project-key", min: 0, max: 1, value: { kind: "project-key" } }],
|
|
111
|
+
},
|
|
112
|
+
],
|
|
113
|
+
constraints: [],
|
|
114
|
+
notes: [requiredProjectDescription],
|
|
115
|
+
},
|
|
116
|
+
column_edit: {
|
|
117
|
+
options: { name: { type: "string", required: true, value: { kind: "text", name: "text" } } },
|
|
118
|
+
forms: [
|
|
119
|
+
{
|
|
120
|
+
id: "default",
|
|
121
|
+
positionals: [
|
|
122
|
+
{ name: "project-key", min: 1, max: 1, value: { kind: "project-key" } },
|
|
123
|
+
{ name: "column-name", min: 1, max: 1, value: { kind: "column-name" } },
|
|
124
|
+
],
|
|
125
|
+
},
|
|
126
|
+
],
|
|
127
|
+
constraints: [],
|
|
128
|
+
},
|
|
129
|
+
column_order: {
|
|
130
|
+
options: {},
|
|
131
|
+
forms: [
|
|
132
|
+
{
|
|
133
|
+
id: "absolute",
|
|
134
|
+
positionals: [
|
|
135
|
+
{ name: "project-key", min: 1, max: 1, value: { kind: "project-key" } },
|
|
136
|
+
{ name: "column-name", min: 1, max: 1, value: { kind: "column-name" } },
|
|
137
|
+
{
|
|
138
|
+
name: "direction",
|
|
139
|
+
min: 1,
|
|
140
|
+
max: 1,
|
|
141
|
+
value: { kind: "enum", choices: columnOrderSchema.options[0].shape.direction.options },
|
|
142
|
+
},
|
|
143
|
+
],
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
id: "relative",
|
|
147
|
+
positionals: [
|
|
148
|
+
{ name: "project-key", min: 1, max: 1, value: { kind: "project-key" } },
|
|
149
|
+
{ name: "column-name", min: 1, max: 1, value: { kind: "column-name" } },
|
|
150
|
+
{
|
|
151
|
+
name: "direction",
|
|
152
|
+
min: 1,
|
|
153
|
+
max: 1,
|
|
154
|
+
value: { kind: "enum", choices: columnOrderSchema.options[1].shape.direction.options },
|
|
155
|
+
},
|
|
156
|
+
{ name: "target-column-name", min: 1, max: 1, value: { kind: "column-name" } },
|
|
157
|
+
],
|
|
158
|
+
},
|
|
159
|
+
],
|
|
160
|
+
constraints: [],
|
|
161
|
+
},
|
|
162
|
+
};
|
|
163
|
+
export const projectRouter = {
|
|
164
|
+
create: {
|
|
165
|
+
summary: "Create a project with the default columns.",
|
|
166
|
+
effects: { domain: "create", storage: "normal-open" },
|
|
167
|
+
confirmation: { kind: "none" },
|
|
168
|
+
input: projectInputs.create,
|
|
169
|
+
results: [jsonResult("Project")],
|
|
170
|
+
run: (args) => {
|
|
171
|
+
const { values, positionals, tokens } = parseArgs({
|
|
172
|
+
args,
|
|
173
|
+
options: projectInputs.create.options,
|
|
174
|
+
allowPositionals: true,
|
|
175
|
+
strict: true,
|
|
176
|
+
tokens: true,
|
|
177
|
+
});
|
|
178
|
+
validateUniqueOptions(tokens, projectInputs.create.options);
|
|
179
|
+
validatePositionals(positionals, projectInputs.create.forms[0]);
|
|
180
|
+
const projectKey = positionals[0];
|
|
181
|
+
try {
|
|
182
|
+
const createdProject = project.create({ key: projectKey, name: values.name, description: values.description }, currentActor());
|
|
183
|
+
output(presentProject(createdProject), formatProject);
|
|
184
|
+
}
|
|
185
|
+
catch (err) {
|
|
186
|
+
throw err;
|
|
187
|
+
}
|
|
188
|
+
},
|
|
189
|
+
help: `${generateCommandUsage("project create", projectInputs.create)}
|
|
190
|
+
|
|
191
|
+
Create a project with the default columns.
|
|
192
|
+
Project keys are stored in uppercase.
|
|
193
|
+
|
|
194
|
+
An omitted name defaults to the uppercase project key.
|
|
195
|
+
Names are trimmed and cannot be blank or contain line breaks or control characters.
|
|
196
|
+
Descriptions may contain multiple lines. If omitted, they are saved as null.
|
|
197
|
+
|
|
198
|
+
${dashValueHelp("--description")}
|
|
199
|
+
|
|
200
|
+
Example: zinn project create MDR --name 'Macrodata Refinement'`,
|
|
201
|
+
},
|
|
202
|
+
list: {
|
|
203
|
+
summary: "List projects, their keys, and truncated description previews.",
|
|
204
|
+
effects: { domain: "read", storage: "normal-open" },
|
|
205
|
+
confirmation: { kind: "none" },
|
|
206
|
+
input: projectInputs.list,
|
|
207
|
+
results: [jsonResult("ProjectList")],
|
|
208
|
+
run: (args) => {
|
|
209
|
+
const { positionals } = parseArgs({
|
|
210
|
+
options: projectInputs.list.options,
|
|
211
|
+
args,
|
|
212
|
+
allowPositionals: true,
|
|
213
|
+
strict: true,
|
|
214
|
+
});
|
|
215
|
+
validatePositionals(positionals, projectInputs.list.forms[0]);
|
|
216
|
+
const projects = project.getAll();
|
|
217
|
+
output(projects.map(presentProject), formatProjectList);
|
|
218
|
+
},
|
|
219
|
+
help: `${generateCommandUsage("project list", projectInputs.list)}
|
|
220
|
+
|
|
221
|
+
List projects, their keys, and truncated description previews.
|
|
222
|
+
|
|
223
|
+
Example: zinn project list`,
|
|
224
|
+
},
|
|
225
|
+
view: {
|
|
226
|
+
summary: "Show a project with its description and the number of tasks in each column.",
|
|
227
|
+
effects: { domain: "read", storage: "normal-open" },
|
|
228
|
+
confirmation: { kind: "none" },
|
|
229
|
+
input: projectInputs.view,
|
|
230
|
+
results: [jsonResult("ProjectView")],
|
|
231
|
+
run: (args) => {
|
|
232
|
+
const { positionals } = parseArgs({
|
|
233
|
+
options: projectInputs.view.options,
|
|
234
|
+
args,
|
|
235
|
+
allowPositionals: true,
|
|
236
|
+
strict: true,
|
|
237
|
+
});
|
|
238
|
+
validatePositionals(positionals, projectInputs.view.forms[0]);
|
|
239
|
+
const projectKey = resolveProjectKey(positionals[0], { required: true });
|
|
240
|
+
const projectMatch = project.getByKey(projectKey);
|
|
241
|
+
if (projectMatch == null) {
|
|
242
|
+
throw new CliError(`Project with key "${project.standardizeKey(projectKey)}" does not exist!`, "not_found", { entity: "project", key: project.standardizeKey(projectKey), source: "explicit" });
|
|
243
|
+
}
|
|
244
|
+
const taskCounts = column.getTaskCountsByProjectKey(projectMatch.key);
|
|
245
|
+
const presentedProject = {
|
|
246
|
+
...presentProject(projectMatch),
|
|
247
|
+
columns: taskCounts.columns.map((columnCount) => ({
|
|
248
|
+
name: columnCount.column.name,
|
|
249
|
+
taskCount: columnCount.taskCount,
|
|
250
|
+
})),
|
|
251
|
+
archivedTaskCount: taskCounts.archivedTaskCount,
|
|
252
|
+
};
|
|
253
|
+
output(presentedProject, (viewedProject) => {
|
|
254
|
+
// The full description follows as its own section, so the row leaves out the preview.
|
|
255
|
+
const sections = [formatProject(viewedProject, { showsDescriptionPreview: false })];
|
|
256
|
+
if (viewedProject.description != null) {
|
|
257
|
+
sections.push(formatSection("Description", viewedProject.description));
|
|
258
|
+
}
|
|
259
|
+
const columnTaskCounts = formatColumnList(viewedProject.columns, {
|
|
260
|
+
showsTaskCounts: true,
|
|
261
|
+
archivedTaskCount: viewedProject.archivedTaskCount,
|
|
262
|
+
});
|
|
263
|
+
sections.push(formatSection("Columns", columnTaskCounts));
|
|
264
|
+
return sections.join("\n\n");
|
|
265
|
+
});
|
|
266
|
+
},
|
|
267
|
+
help: `${generateCommandUsage("project view", projectInputs.view)}
|
|
268
|
+
|
|
269
|
+
Show a project with its description and the number of tasks in each column.
|
|
270
|
+
${requiredProjectDescription}
|
|
271
|
+
The description prints in full, keeping its line breaks. Archived tasks are counted as one total.
|
|
272
|
+
|
|
273
|
+
Example: zinn project view MDR`,
|
|
274
|
+
},
|
|
275
|
+
edit: {
|
|
276
|
+
summary: "Change the supplied project fields. At least one edit flag is required.",
|
|
277
|
+
effects: { domain: "update", storage: "normal-open" },
|
|
278
|
+
confirmation: { kind: "none" },
|
|
279
|
+
input: projectInputs.edit,
|
|
280
|
+
results: [jsonResult("Project")],
|
|
281
|
+
run: (args) => {
|
|
282
|
+
const { values, positionals, tokens } = parseArgs({
|
|
283
|
+
args,
|
|
284
|
+
options: projectInputs.edit.options,
|
|
285
|
+
allowPositionals: true,
|
|
286
|
+
strict: true,
|
|
287
|
+
tokens: true,
|
|
288
|
+
});
|
|
289
|
+
validateUniqueOptions(tokens, projectInputs.edit.options);
|
|
290
|
+
validatePositionals(positionals, projectInputs.edit.forms[0]);
|
|
291
|
+
const projectKey = resolveProjectKey(positionals[0], { required: true });
|
|
292
|
+
const description = resolveTextEdit(values.description, values, "--description");
|
|
293
|
+
if (violatesConstraint(projectEditConstraint, getOptionInputs({ ...values, description }))) {
|
|
294
|
+
quit("Provide an edit flag: --name or --description", undefined, { field: [] });
|
|
295
|
+
}
|
|
296
|
+
const editedProject = project.edit({ projectKey, name: values.name, description }, currentActor());
|
|
297
|
+
output(presentProject(editedProject), formatProject);
|
|
298
|
+
},
|
|
299
|
+
help: `${generateCommandUsage("project edit", projectInputs.edit)}
|
|
300
|
+
|
|
301
|
+
Change the supplied project fields. At least one edit flag is required.
|
|
302
|
+
${requiredProjectDescription}
|
|
303
|
+
Use --description '' to clear the description.
|
|
304
|
+
|
|
305
|
+
${textEditHelp("--description")}
|
|
306
|
+
|
|
307
|
+
${dashValueHelp("--description")}
|
|
308
|
+
|
|
309
|
+
Examples:
|
|
310
|
+
zinn project edit MDR --name 'Macrodata Refinement'
|
|
311
|
+
zinn project edit MDR --description database --replacing board --all`,
|
|
312
|
+
},
|
|
313
|
+
delete: {
|
|
314
|
+
summary: "Permanently delete a project and all of its columns and tasks after confirmation.",
|
|
315
|
+
effects: { domain: "delete", storage: "normal-open" },
|
|
316
|
+
confirmation: {
|
|
317
|
+
kind: "project-delete",
|
|
318
|
+
description: `${confirmationDescription} When the project key is omitted, deleting the configured default project always requires a terminal prompt; --yes is ignored.`,
|
|
319
|
+
},
|
|
320
|
+
input: projectInputs.delete,
|
|
321
|
+
results: [jsonResult("Project")],
|
|
322
|
+
run: async (args) => {
|
|
323
|
+
const { values, positionals, tokens } = parseArgs({
|
|
324
|
+
args,
|
|
325
|
+
options: projectInputs.delete.options,
|
|
326
|
+
allowPositionals: true,
|
|
327
|
+
strict: true,
|
|
328
|
+
tokens: true,
|
|
329
|
+
});
|
|
330
|
+
validateUniqueOptions(tokens, projectInputs.delete.options);
|
|
331
|
+
validatePositionals(positionals, projectInputs.delete.forms[0]);
|
|
332
|
+
const typedProjectKey = positionals[0];
|
|
333
|
+
const projectKey = resolveProjectKey(typedProjectKey, { required: true });
|
|
334
|
+
try {
|
|
335
|
+
const projectMatch = project.getByKey(projectKey);
|
|
336
|
+
if (projectMatch == null) {
|
|
337
|
+
throw new CliError(`Project with key "${projectKey}" does not exist!`, "not_found", {
|
|
338
|
+
entity: "project",
|
|
339
|
+
key: projectKey,
|
|
340
|
+
source: "explicit",
|
|
341
|
+
});
|
|
342
|
+
}
|
|
343
|
+
// Like `gh repo delete`: --yes never skips the prompt for a project the command did not name
|
|
344
|
+
const isYesIgnored = values.yes === true && typedProjectKey === undefined;
|
|
345
|
+
if (isYesIgnored && !canPrompt()) {
|
|
346
|
+
quit(`Cannot delete the default project ${projectMatch.key} without a terminal. Type its key to use --yes: zinn project delete ${projectMatch.key} --yes`, undefined, { argument: "project-key", reason: "confirmation_required" });
|
|
347
|
+
}
|
|
348
|
+
if (isYesIgnored) {
|
|
349
|
+
diagnostic("Warning: --yes is ignored because no project key was typed");
|
|
350
|
+
}
|
|
351
|
+
const canDelete = await confirmAction(`Are you sure you want to delete ${projectMatch.key} and all of its columns and tasks?`, values.yes === true && typedProjectKey !== undefined, typedProjectKey === undefined
|
|
352
|
+
? "Project deletion with --json needs a typed <project-key> and --yes"
|
|
353
|
+
: undefined);
|
|
354
|
+
if (canDelete) {
|
|
355
|
+
const deletedProject = project.delete(projectKey, currentActor());
|
|
356
|
+
output(presentProject(deletedProject), (p) => `Deleted ${formatProject(p)}`);
|
|
357
|
+
}
|
|
358
|
+
else {
|
|
359
|
+
output(presentProject(projectMatch), (p) => `Deletion cancelled for ${formatProject(p)}`);
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
catch (err) {
|
|
363
|
+
throw err;
|
|
364
|
+
}
|
|
365
|
+
},
|
|
366
|
+
help: `${generateCommandUsage("project delete", projectInputs.delete)}
|
|
367
|
+
|
|
368
|
+
Permanently delete a project and all of its columns and tasks after confirmation.
|
|
369
|
+
${requiredProjectDescription}
|
|
370
|
+
When the project key is omitted, confirmation is always required: --yes is ignored, and without a terminal the command refuses.
|
|
371
|
+
Use a typed project key and --yes to skip the prompt, including with --json.
|
|
372
|
+
|
|
373
|
+
Example: zinn project delete MDR`,
|
|
374
|
+
},
|
|
375
|
+
column: {
|
|
376
|
+
create: {
|
|
377
|
+
summary: "Add a column at the end of a project's board.",
|
|
378
|
+
effects: { domain: "create", storage: "normal-open" },
|
|
379
|
+
confirmation: { kind: "none" },
|
|
380
|
+
input: projectInputs.column_create,
|
|
381
|
+
results: [jsonResult("Column")],
|
|
382
|
+
run: (args) => {
|
|
383
|
+
const { positionals } = parseArgs({
|
|
384
|
+
options: projectInputs.column_create.options,
|
|
385
|
+
args,
|
|
386
|
+
allowPositionals: true,
|
|
387
|
+
strict: true,
|
|
388
|
+
});
|
|
389
|
+
validatePositionals(positionals, projectInputs.column_create.forms[0]);
|
|
390
|
+
const projectKey = positionals[0];
|
|
391
|
+
const columnName = positionals[1];
|
|
392
|
+
try {
|
|
393
|
+
const createdColumn = column.create({ projectKey, name: columnName }, currentActor());
|
|
394
|
+
output(presentColumn(createdColumn), formatColumn);
|
|
395
|
+
}
|
|
396
|
+
catch (err) {
|
|
397
|
+
throw err;
|
|
398
|
+
}
|
|
399
|
+
},
|
|
400
|
+
help: `${generateCommandUsage("project column create", projectInputs.column_create)}
|
|
401
|
+
|
|
402
|
+
Add a column at the end of a project's board.
|
|
403
|
+
Names are trimmed, cannot be blank or contain line breaks or control characters, and must be unique within the project regardless of casing.
|
|
404
|
+
|
|
405
|
+
Example: zinn project column create MDR Boardlog`,
|
|
406
|
+
},
|
|
407
|
+
list: {
|
|
408
|
+
summary: "List a project's columns in board order with their unarchived task counts.",
|
|
409
|
+
effects: { domain: "read", storage: "normal-open" },
|
|
410
|
+
confirmation: { kind: "none" },
|
|
411
|
+
input: projectInputs.column_list,
|
|
412
|
+
results: [jsonResult("ColumnList")],
|
|
413
|
+
run: (args) => {
|
|
414
|
+
const { positionals } = parseArgs({
|
|
415
|
+
options: projectInputs.column_list.options,
|
|
416
|
+
args,
|
|
417
|
+
allowPositionals: true,
|
|
418
|
+
strict: true,
|
|
419
|
+
});
|
|
420
|
+
validatePositionals(positionals, projectInputs.column_list.forms[0]);
|
|
421
|
+
const projectKey = resolveProjectKey(positionals[0], { required: true });
|
|
422
|
+
const taskCounts = column.getTaskCountsByProjectKey(projectKey);
|
|
423
|
+
const columns = taskCounts.columns.map((columnCount) => ({
|
|
424
|
+
name: columnCount.column.name,
|
|
425
|
+
taskCount: columnCount.taskCount,
|
|
426
|
+
}));
|
|
427
|
+
output(columns, (presentedColumns) => formatColumnList(presentedColumns, {
|
|
428
|
+
showsTaskCounts: true,
|
|
429
|
+
}));
|
|
430
|
+
},
|
|
431
|
+
help: `${generateCommandUsage("project column list", projectInputs.column_list)}
|
|
432
|
+
|
|
433
|
+
List a project's columns in board order with their unarchived task counts.
|
|
434
|
+
${requiredProjectDescription}
|
|
435
|
+
|
|
436
|
+
Example: zinn project column list MDR`,
|
|
437
|
+
},
|
|
438
|
+
edit: {
|
|
439
|
+
summary: "Rename a column.",
|
|
440
|
+
effects: { domain: "update", storage: "normal-open" },
|
|
441
|
+
confirmation: { kind: "none" },
|
|
442
|
+
input: projectInputs.column_edit,
|
|
443
|
+
results: [jsonResult("Column")],
|
|
444
|
+
run: (args) => {
|
|
445
|
+
const { values, positionals, tokens } = parseArgs({
|
|
446
|
+
args,
|
|
447
|
+
options: projectInputs.column_edit.options,
|
|
448
|
+
allowPositionals: true,
|
|
449
|
+
strict: true,
|
|
450
|
+
tokens: true,
|
|
451
|
+
});
|
|
452
|
+
validateUniqueOptions(tokens, projectInputs.column_edit.options);
|
|
453
|
+
validatePositionals(positionals, projectInputs.column_edit.forms[0]);
|
|
454
|
+
const name = requireStringOption(projectInputs.column_edit.options.name, values.name, "name", "Provide an edit flag: --name");
|
|
455
|
+
const editedColumn = column.edit({
|
|
456
|
+
projectKey: positionals[0],
|
|
457
|
+
columnName: positionals[1],
|
|
458
|
+
name,
|
|
459
|
+
}, currentActor());
|
|
460
|
+
output(presentColumn(editedColumn), formatColumn);
|
|
461
|
+
},
|
|
462
|
+
help: `${generateCommandUsage("project column edit", projectInputs.column_edit)}
|
|
463
|
+
|
|
464
|
+
Rename a column.
|
|
465
|
+
The --name flag is required.
|
|
466
|
+
|
|
467
|
+
Columns are matched by name, and matching is case-insensitive.
|
|
468
|
+
Names are trimmed, and must remain unique within the same project.
|
|
469
|
+
Changing only the casing of a column's own name is allowed.
|
|
470
|
+
|
|
471
|
+
${dashValueHelp("--name")}
|
|
472
|
+
|
|
473
|
+
Example: zinn project column edit MDR 'In Progress' --name Refining`,
|
|
474
|
+
},
|
|
475
|
+
order: {
|
|
476
|
+
summary: "Change a column's position on the project's board.",
|
|
477
|
+
effects: { domain: "update", storage: "normal-open" },
|
|
478
|
+
confirmation: { kind: "none" },
|
|
479
|
+
input: projectInputs.column_order,
|
|
480
|
+
results: [jsonResult("Column")],
|
|
481
|
+
run: (args) => {
|
|
482
|
+
const { positionals } = parseArgs({
|
|
483
|
+
options: projectInputs.column_order.options,
|
|
484
|
+
args,
|
|
485
|
+
allowPositionals: true,
|
|
486
|
+
strict: true,
|
|
487
|
+
});
|
|
488
|
+
const form = validateOrderForms(positionals, projectInputs.column_order.forms);
|
|
489
|
+
const projectKey = positionals[0];
|
|
490
|
+
const columnName = positionals[1];
|
|
491
|
+
let orderedColumn;
|
|
492
|
+
if (form.id === "relative") {
|
|
493
|
+
const direction = positionals[2];
|
|
494
|
+
orderedColumn = column.order({ projectKey, columnName, direction, targetColumnName: positionals[3] }, currentActor());
|
|
495
|
+
}
|
|
496
|
+
else {
|
|
497
|
+
const direction = positionals[2];
|
|
498
|
+
orderedColumn = column.order({ projectKey, columnName, direction }, currentActor());
|
|
499
|
+
}
|
|
500
|
+
// TODO: maybe also print the new full column state?
|
|
501
|
+
output(presentColumn(orderedColumn), formatColumn);
|
|
502
|
+
},
|
|
503
|
+
help: `${generateCommandUsage("project column order", projectInputs.column_order)}
|
|
504
|
+
|
|
505
|
+
Change a column's position on the project's board.
|
|
506
|
+
Use first or last for either end, previous or next for one position,
|
|
507
|
+
or before or after to place it relative to another column.
|
|
508
|
+
|
|
509
|
+
Columns are matched by name, and matching is case-insensitive.
|
|
510
|
+
|
|
511
|
+
Example: zinn project column order MDR Review before 'In Progress'`,
|
|
512
|
+
},
|
|
513
|
+
},
|
|
514
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export declare const reindexCommand: {
|
|
2
|
+
summary: string;
|
|
3
|
+
effects: {
|
|
4
|
+
domain: "none";
|
|
5
|
+
storage: "reindex";
|
|
6
|
+
};
|
|
7
|
+
confirmation: {
|
|
8
|
+
kind: "none";
|
|
9
|
+
};
|
|
10
|
+
input: {
|
|
11
|
+
readonly options: {};
|
|
12
|
+
readonly forms: readonly [{
|
|
13
|
+
readonly id: "default";
|
|
14
|
+
readonly positionals: readonly [];
|
|
15
|
+
}];
|
|
16
|
+
readonly constraints: readonly [];
|
|
17
|
+
};
|
|
18
|
+
results: import("../results.js").CommandResult[];
|
|
19
|
+
run: (args: string[]) => void;
|
|
20
|
+
help: string;
|
|
21
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { jsonResult } from "../results.js";
|
|
2
|
+
import { parseArgs } from "node:util";
|
|
3
|
+
import { reindex } from "@zinn-dev/core";
|
|
4
|
+
import { reportLockWait } from "../database.js";
|
|
5
|
+
import { generateCommandUsage, noInput } from "../input.js";
|
|
6
|
+
import { output, validatePositionals } from "../lib.js";
|
|
7
|
+
export const reindexCommand = {
|
|
8
|
+
summary: "Rebuild the search index that `zinn task search` uses from the tasks and their comments, archived tasks included.",
|
|
9
|
+
effects: { domain: "none", storage: "reindex" },
|
|
10
|
+
confirmation: { kind: "none" },
|
|
11
|
+
input: noInput,
|
|
12
|
+
results: [jsonResult("Reindex")],
|
|
13
|
+
run: (args) => {
|
|
14
|
+
const { positionals } = parseArgs({
|
|
15
|
+
options: noInput.options,
|
|
16
|
+
args,
|
|
17
|
+
strict: true,
|
|
18
|
+
allowPositionals: true,
|
|
19
|
+
});
|
|
20
|
+
validatePositionals(positionals, noInput.forms[0]);
|
|
21
|
+
const result = reindex.run({ onWait: reportLockWait });
|
|
22
|
+
output(result, (r) => {
|
|
23
|
+
const noun = r.taskCount === 1 ? "task" : "tasks";
|
|
24
|
+
return `Rebuilt the search index from ${r.taskCount} ${noun}`;
|
|
25
|
+
});
|
|
26
|
+
},
|
|
27
|
+
help: `${generateCommandUsage("reindex", noInput)}
|
|
28
|
+
|
|
29
|
+
Rebuild the search index that \`zinn task search\` uses from the tasks and their comments, archived tasks included.
|
|
30
|
+
|
|
31
|
+
Only the index changes, completely or not at all, so no backup is saved.
|
|
32
|
+
Fails, leaving the database as it is, when there is no database yet or when this Zinn cannot change it, such as a database with a newer schema version.`,
|
|
33
|
+
};
|