team-toon-tack 3.2.13 → 3.2.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/scripts/status.js +47 -2
- package/package.json +1 -1
package/dist/scripts/status.js
CHANGED
|
@@ -24,6 +24,40 @@ function parseArgs(args) {
|
|
|
24
24
|
}
|
|
25
25
|
return { issueId, setStatus };
|
|
26
26
|
}
|
|
27
|
+
async function fetchTaskFromRemote(issueId, config) {
|
|
28
|
+
const adapter = createAdapter(config);
|
|
29
|
+
const sourceType = getSourceType(config);
|
|
30
|
+
const issue = await adapter.searchIssue(issueId);
|
|
31
|
+
if (!issue)
|
|
32
|
+
return undefined;
|
|
33
|
+
return {
|
|
34
|
+
id: issue.id,
|
|
35
|
+
linearId: issue.sourceId,
|
|
36
|
+
sourceId: issue.sourceId,
|
|
37
|
+
sourceType,
|
|
38
|
+
title: issue.title,
|
|
39
|
+
status: issue.status,
|
|
40
|
+
localStatus: "pending",
|
|
41
|
+
assignee: issue.assigneeEmail,
|
|
42
|
+
priority: issue.priority,
|
|
43
|
+
labels: issue.labels,
|
|
44
|
+
description: issue.description,
|
|
45
|
+
parentIssueId: issue.parentIssueId,
|
|
46
|
+
url: issue.url,
|
|
47
|
+
attachments: issue.attachments?.map((a) => ({
|
|
48
|
+
id: a.id,
|
|
49
|
+
title: a.title,
|
|
50
|
+
url: a.url,
|
|
51
|
+
sourceType: a.sourceType,
|
|
52
|
+
})),
|
|
53
|
+
comments: issue.comments?.map((c) => ({
|
|
54
|
+
id: c.id,
|
|
55
|
+
body: c.body,
|
|
56
|
+
createdAt: c.createdAt,
|
|
57
|
+
user: c.user,
|
|
58
|
+
})),
|
|
59
|
+
};
|
|
60
|
+
}
|
|
27
61
|
async function status() {
|
|
28
62
|
const args = process.argv.slice(2);
|
|
29
63
|
if (args.includes("--help") || args.includes("-h")) {
|
|
@@ -65,6 +99,7 @@ Examples:
|
|
|
65
99
|
// Find task
|
|
66
100
|
let task;
|
|
67
101
|
let issueId = argIssueId;
|
|
102
|
+
let fromRemote = false;
|
|
68
103
|
if (!issueId) {
|
|
69
104
|
const inProgressTasks = data.tasks.filter((t) => t.localStatus === "in-progress");
|
|
70
105
|
if (inProgressTasks.length === 0) {
|
|
@@ -82,8 +117,15 @@ Examples:
|
|
|
82
117
|
else {
|
|
83
118
|
task = data.tasks.find((t) => t.id === issueId || t.id === `MP-${issueId}`);
|
|
84
119
|
if (!task) {
|
|
85
|
-
|
|
86
|
-
|
|
120
|
+
// Fetch from remote
|
|
121
|
+
console.error(`Issue ${issueId} not in local data. Fetching from remote...`);
|
|
122
|
+
task = await fetchTaskFromRemote(issueId, config);
|
|
123
|
+
if (!task) {
|
|
124
|
+
console.error(`Issue ${issueId} not found.`);
|
|
125
|
+
process.exit(1);
|
|
126
|
+
}
|
|
127
|
+
issueId = task.id;
|
|
128
|
+
fromRemote = true;
|
|
87
129
|
}
|
|
88
130
|
}
|
|
89
131
|
// If setting status
|
|
@@ -182,6 +224,9 @@ Examples:
|
|
|
182
224
|
}
|
|
183
225
|
// Save if anything changed
|
|
184
226
|
if (needsSave) {
|
|
227
|
+
if (fromRemote) {
|
|
228
|
+
data.tasks.push(task);
|
|
229
|
+
}
|
|
185
230
|
await saveCycleData(data);
|
|
186
231
|
if (newLocalStatus && newLocalStatus !== oldLocalStatus) {
|
|
187
232
|
console.log(`Local: ${task.id} ${oldLocalStatus} → ${newLocalStatus}`);
|