team-toon-tack 1.0.5 → 1.0.6
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/package.json +1 -1
- package/scripts/init.ts +21 -2
- package/scripts/sync.ts +33 -4
- package/scripts/utils.ts +9 -0
package/package.json
CHANGED
package/scripts/init.ts
CHANGED
|
@@ -277,7 +277,14 @@ async function init() {
|
|
|
277
277
|
complete: 'Done',
|
|
278
278
|
need_review: 'In Review'
|
|
279
279
|
},
|
|
280
|
-
priority_order: ['urgent', 'high', 'medium', 'low', 'none']
|
|
280
|
+
priority_order: ['urgent', 'high', 'medium', 'low', 'none'],
|
|
281
|
+
current_cycle: currentCycle ? {
|
|
282
|
+
id: currentCycle.id,
|
|
283
|
+
name: currentCycle.name || 'Cycle',
|
|
284
|
+
start_date: currentCycle.startsAt?.toISOString().split('T')[0] || '',
|
|
285
|
+
end_date: currentCycle.endsAt?.toISOString().split('T')[0] || ''
|
|
286
|
+
} : undefined,
|
|
287
|
+
cycle_history: []
|
|
281
288
|
};
|
|
282
289
|
|
|
283
290
|
// Find current user key
|
|
@@ -299,11 +306,23 @@ async function init() {
|
|
|
299
306
|
const existingContent = await fs.readFile(paths.configPath, 'utf-8');
|
|
300
307
|
const existingConfig = decode(existingContent) as unknown as Config;
|
|
301
308
|
|
|
302
|
-
// Merge:
|
|
309
|
+
// Merge: preserve existing custom fields
|
|
303
310
|
config.status_transitions = {
|
|
304
311
|
...existingConfig.status_transitions,
|
|
305
312
|
...config.status_transitions
|
|
306
313
|
};
|
|
314
|
+
// Preserve cycle history
|
|
315
|
+
if (existingConfig.cycle_history) {
|
|
316
|
+
config.cycle_history = existingConfig.cycle_history;
|
|
317
|
+
}
|
|
318
|
+
// Preserve current_cycle if not fetched fresh
|
|
319
|
+
if (!currentCycle && existingConfig.current_cycle) {
|
|
320
|
+
config.current_cycle = existingConfig.current_cycle;
|
|
321
|
+
}
|
|
322
|
+
// Preserve priority_order if exists
|
|
323
|
+
if (existingConfig.priority_order) {
|
|
324
|
+
config.priority_order = existingConfig.priority_order;
|
|
325
|
+
}
|
|
307
326
|
} catch {
|
|
308
327
|
// Ignore merge errors
|
|
309
328
|
}
|
package/scripts/sync.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getLinearClient, loadConfig, loadLocalConfig, loadCycleData, saveCycleData, getTeamId, getPrioritySortIndex, CycleData, Task, Attachment, Comment } from './utils';
|
|
1
|
+
import { getLinearClient, loadConfig, loadLocalConfig, loadCycleData, saveCycleData, saveConfig, getTeamId, getPrioritySortIndex, CycleData, Task, Attachment, Comment, CycleInfo } from './utils';
|
|
2
2
|
|
|
3
3
|
async function sync() {
|
|
4
4
|
const args = process.argv.slice(2);
|
|
@@ -49,12 +49,41 @@ Examples:
|
|
|
49
49
|
const activeCycle = cycles.nodes[0];
|
|
50
50
|
const cycleId = activeCycle.id;
|
|
51
51
|
const cycleName = activeCycle.name ?? 'Cycle';
|
|
52
|
+
const newCycleInfo: CycleInfo = {
|
|
53
|
+
id: cycleId,
|
|
54
|
+
name: cycleName,
|
|
55
|
+
start_date: activeCycle.startsAt?.toISOString().split('T')[0] ?? '',
|
|
56
|
+
end_date: activeCycle.endsAt?.toISOString().split('T')[0] ?? ''
|
|
57
|
+
};
|
|
52
58
|
|
|
53
|
-
// Check if cycle changed
|
|
59
|
+
// Check if cycle changed and update config with history
|
|
54
60
|
const existingData = await loadCycleData();
|
|
55
|
-
|
|
56
|
-
|
|
61
|
+
const oldCycleId = config.current_cycle?.id ?? existingData?.cycleId;
|
|
62
|
+
|
|
63
|
+
if (oldCycleId && oldCycleId !== cycleId) {
|
|
64
|
+
const oldCycleName = config.current_cycle?.name ?? existingData?.cycleName ?? 'Unknown';
|
|
65
|
+
console.log(`Cycle changed: ${oldCycleName} → ${cycleName}`);
|
|
66
|
+
|
|
67
|
+
// Move old cycle to history
|
|
68
|
+
if (config.current_cycle) {
|
|
69
|
+
config.cycle_history = config.cycle_history ?? [];
|
|
70
|
+
config.cycle_history.unshift(config.current_cycle);
|
|
71
|
+
// Keep only last 10 cycles
|
|
72
|
+
if (config.cycle_history.length > 10) {
|
|
73
|
+
config.cycle_history = config.cycle_history.slice(0, 10);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// Update current cycle
|
|
78
|
+
config.current_cycle = newCycleInfo;
|
|
79
|
+
await saveConfig(config);
|
|
80
|
+
console.log('Config updated with new cycle (old cycle saved to history).');
|
|
57
81
|
} else {
|
|
82
|
+
// Update current cycle info even if ID unchanged (dates might change)
|
|
83
|
+
if (!config.current_cycle || config.current_cycle.id !== cycleId) {
|
|
84
|
+
config.current_cycle = newCycleInfo;
|
|
85
|
+
await saveConfig(config);
|
|
86
|
+
}
|
|
58
87
|
console.log(`Current cycle: ${cycleName}`);
|
|
59
88
|
}
|
|
60
89
|
|
package/scripts/utils.ts
CHANGED
|
@@ -52,6 +52,13 @@ export interface LabelConfig {
|
|
|
52
52
|
color?: string;
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
+
export interface CycleInfo {
|
|
56
|
+
id: string;
|
|
57
|
+
name: string;
|
|
58
|
+
start_date: string;
|
|
59
|
+
end_date: string;
|
|
60
|
+
}
|
|
61
|
+
|
|
55
62
|
export interface Config {
|
|
56
63
|
teams: Record<string, TeamConfig>;
|
|
57
64
|
users: Record<string, UserConfig>;
|
|
@@ -60,6 +67,8 @@ export interface Config {
|
|
|
60
67
|
statuses?: Record<string, { name: string; type: string }>;
|
|
61
68
|
status_transitions?: Record<string, string>;
|
|
62
69
|
priority_order?: string[]; // e.g., ['urgent', 'high', 'medium', 'low', 'none']
|
|
70
|
+
current_cycle?: CycleInfo;
|
|
71
|
+
cycle_history?: CycleInfo[];
|
|
63
72
|
}
|
|
64
73
|
|
|
65
74
|
// Linear priority value to name mapping (fixed by Linear API)
|