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