@cvr/linear 0.1.0 → 0.2.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 +13 -12
- package/bin/linear +0 -0
- package/package.json +29 -22
- package/src/commands/auth.ts +42 -40
- package/src/commands/issue.ts +167 -191
- package/src/commands/team.ts +17 -17
- package/src/lib/errors.ts +24 -26
- package/src/main.ts +22 -30
- package/src/services/Browser.ts +5 -5
- package/src/services/Config.ts +78 -80
- package/src/services/Linear.ts +124 -123
- package/src/services/Stdin.ts +9 -9
- package/tsconfig.json +0 -1
package/src/commands/issue.ts
CHANGED
|
@@ -1,330 +1,306 @@
|
|
|
1
|
-
import { Args, Command, Options, Prompt } from "@effect/cli"
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { Args, Command, Options, Prompt } from "@effect/cli";
|
|
2
|
+
import type { Terminal } from "@effect/platform";
|
|
3
|
+
import type { Context, Types } from "effect";
|
|
4
|
+
import { Console, Effect, Option } from "effect";
|
|
5
|
+
import { NoIssuesError, type LinearApiError, type TokenNotFoundError } from "../lib/errors.js";
|
|
6
|
+
import { LinearService } from "../services/Linear.js";
|
|
7
|
+
import { ConfigService } from "../services/Config.js";
|
|
8
|
+
|
|
9
|
+
/** Resolve LinearFetch<T> | undefined (LinearFetch is Promise-like lazy loader) */
|
|
10
|
+
const resolveFetch = <T>(fetch: PromiseLike<T> | undefined): Effect.Effect<T | null> =>
|
|
11
|
+
fetch
|
|
12
|
+
? Effect.tryPromise(() => Promise.resolve(fetch)).pipe(Effect.orElseSucceed(() => null))
|
|
13
|
+
: Effect.succeed(null);
|
|
5
14
|
|
|
6
15
|
// Options
|
|
7
16
|
const stateOption = Options.text("state").pipe(
|
|
8
17
|
Options.withAlias("s"),
|
|
9
18
|
Options.withDescription("Filter by state type (started, unstarted, backlog, etc.)"),
|
|
10
|
-
Options.optional
|
|
11
|
-
)
|
|
12
|
-
|
|
13
|
-
const teamOption = Options.text("team").pipe(
|
|
14
|
-
Options.withAlias("t"),
|
|
15
|
-
Options.withDescription("Filter by team key or ID"),
|
|
16
|
-
Options.optional
|
|
17
|
-
)
|
|
19
|
+
Options.optional,
|
|
20
|
+
);
|
|
18
21
|
|
|
19
22
|
const limitOption = Options.integer("limit").pipe(
|
|
20
23
|
Options.withAlias("n"),
|
|
21
24
|
Options.withDefault(20),
|
|
22
|
-
Options.withDescription("Number of issues to show")
|
|
23
|
-
)
|
|
25
|
+
Options.withDescription("Number of issues to show"),
|
|
26
|
+
);
|
|
24
27
|
|
|
25
28
|
// Args
|
|
26
29
|
const issueIdArg = Args.text({ name: "id" }).pipe(
|
|
27
30
|
Args.withDescription("Issue ID or identifier (e.g., ABC-123)"),
|
|
28
|
-
Args.optional
|
|
29
|
-
)
|
|
31
|
+
Args.optional,
|
|
32
|
+
);
|
|
30
33
|
|
|
31
34
|
// linear issue list - List issues
|
|
32
35
|
export const issueListCommand = Command.make(
|
|
33
36
|
"list",
|
|
34
|
-
{ state: stateOption,
|
|
35
|
-
({ state,
|
|
37
|
+
{ state: stateOption, limit: limitOption },
|
|
38
|
+
({ state, limit }) =>
|
|
36
39
|
Effect.gen(function* () {
|
|
37
|
-
const linear = yield* LinearService
|
|
40
|
+
const linear = yield* LinearService;
|
|
38
41
|
|
|
39
|
-
const stateFilter = Option.getOrUndefined(state)
|
|
40
|
-
const issues = yield* linear.getMyIssues({ state: stateFilter })
|
|
42
|
+
const stateFilter = Option.getOrUndefined(state);
|
|
43
|
+
const issues = yield* linear.getMyIssues({ state: stateFilter });
|
|
41
44
|
|
|
42
45
|
if (issues.length === 0) {
|
|
43
|
-
yield* Console.log("No issues found.")
|
|
44
|
-
return
|
|
46
|
+
yield* Console.log("No issues found.");
|
|
47
|
+
return;
|
|
45
48
|
}
|
|
46
49
|
|
|
47
|
-
yield* Console.log("\nYour Issues:\n")
|
|
50
|
+
yield* Console.log("\nYour Issues:\n");
|
|
48
51
|
|
|
49
|
-
const displayed = issues.slice(0, limit)
|
|
52
|
+
const displayed = issues.slice(0, limit);
|
|
50
53
|
for (const issue of displayed) {
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
const stateName = state?.name ?? "Unknown"
|
|
56
|
-
const priority = issue.priority ?? 0
|
|
57
|
-
const priorityIcon = getPriorityIcon(priority)
|
|
54
|
+
const issueState = yield* resolveFetch(issue.state);
|
|
55
|
+
const stateName = issueState?.name ?? "Unknown";
|
|
56
|
+
const priority = issue.priority ?? 0;
|
|
57
|
+
const priorityIcon = getPriorityIcon(priority);
|
|
58
58
|
|
|
59
59
|
yield* Console.log(
|
|
60
|
-
` ${priorityIcon} ${issue.identifier.padEnd(10)} ${stateName.padEnd(12)} ${truncate(issue.title, 50)}
|
|
61
|
-
)
|
|
60
|
+
` ${priorityIcon} ${issue.identifier.padEnd(10)} ${stateName.padEnd(12)} ${truncate(issue.title, 50)}`,
|
|
61
|
+
);
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
if (issues.length > limit) {
|
|
65
|
-
yield* Console.log(`\n ... and ${issues.length - limit} more`)
|
|
65
|
+
yield* Console.log(`\n ... and ${issues.length - limit} more`);
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
yield* Console.log("")
|
|
69
|
-
})
|
|
70
|
-
)
|
|
68
|
+
yield* Console.log("");
|
|
69
|
+
}),
|
|
70
|
+
);
|
|
71
71
|
|
|
72
72
|
// linear issue view [id] - View issue details
|
|
73
|
-
export const issueViewCommand = Command.make(
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
})
|
|
99
|
-
|
|
100
|
-
yield* Console.log("")
|
|
101
|
-
yield* Console.log(`${issue.identifier}: ${issue.title}`)
|
|
102
|
-
yield* Console.log(`${"─".repeat(60)}`)
|
|
103
|
-
yield* Console.log(`State: ${state?.name ?? "Unknown"}`)
|
|
104
|
-
yield* Console.log(`Team: ${team?.name ?? "Unknown"}`)
|
|
105
|
-
yield* Console.log(`Priority: ${getPriorityLabel(issue.priority ?? 0)}`)
|
|
106
|
-
yield* Console.log(`Assignee: ${assignee?.name ?? "Unassigned"}`)
|
|
107
|
-
yield* Console.log(`URL: ${issue.url}`)
|
|
108
|
-
|
|
109
|
-
if (issue.description) {
|
|
110
|
-
yield* Console.log(`\nDescription:\n${issue.description}`)
|
|
111
|
-
}
|
|
73
|
+
export const issueViewCommand = Command.make("view", { id: issueIdArg }, ({ id }) =>
|
|
74
|
+
Effect.gen(function* () {
|
|
75
|
+
const linear = yield* LinearService;
|
|
76
|
+
|
|
77
|
+
// If no ID provided, prompt for selection
|
|
78
|
+
const issueId = yield* Option.match(id, {
|
|
79
|
+
onNone: () => selectIssue(linear),
|
|
80
|
+
onSome: (id) => Effect.succeed(id),
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
const issue = yield* linear.getIssue(issueId);
|
|
84
|
+
const issueState = yield* resolveFetch(issue.state);
|
|
85
|
+
const assignee = yield* resolveFetch(issue.assignee);
|
|
86
|
+
const issueTeam = yield* resolveFetch(issue.team);
|
|
87
|
+
|
|
88
|
+
yield* Console.log("");
|
|
89
|
+
yield* Console.log(`${issue.identifier}: ${issue.title}`);
|
|
90
|
+
yield* Console.log(`${"─".repeat(60)}`);
|
|
91
|
+
yield* Console.log(`State: ${issueState?.name ?? "Unknown"}`);
|
|
92
|
+
yield* Console.log(`Team: ${issueTeam?.name ?? "Unknown"}`);
|
|
93
|
+
yield* Console.log(`Priority: ${getPriorityLabel(issue.priority ?? 0)}`);
|
|
94
|
+
yield* Console.log(`Assignee: ${assignee?.name ?? "Unassigned"}`);
|
|
95
|
+
yield* Console.log(`URL: ${issue.url}`);
|
|
96
|
+
|
|
97
|
+
if (issue.description) {
|
|
98
|
+
yield* Console.log(`\nDescription:\n${issue.description}`);
|
|
99
|
+
}
|
|
112
100
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
)
|
|
101
|
+
yield* Console.log("");
|
|
102
|
+
}),
|
|
103
|
+
);
|
|
116
104
|
|
|
117
105
|
// linear issue start [id] - Start working on an issue
|
|
118
|
-
export const issueStartCommand = Command.make(
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
yield* linear.updateIssueState(issue.id, startedState.id)
|
|
153
|
-
yield* Console.log(`\nStarted: ${issue.identifier} - ${issue.title}`)
|
|
154
|
-
yield* Console.log(`State changed to: ${startedState.name}`)
|
|
155
|
-
} else {
|
|
156
|
-
yield* Console.log(`\nCould not find a "started" state for this issue's team.`)
|
|
157
|
-
}
|
|
106
|
+
export const issueStartCommand = Command.make("start", { id: issueIdArg }, ({ id }) =>
|
|
107
|
+
Effect.gen(function* () {
|
|
108
|
+
const linear = yield* LinearService;
|
|
109
|
+
|
|
110
|
+
// If no ID provided, prompt for selection
|
|
111
|
+
const issueId = yield* Option.match(id, {
|
|
112
|
+
onNone: () => selectIssue(linear),
|
|
113
|
+
onSome: (id) => Effect.succeed(id),
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
const issue = yield* linear.getIssue(issueId);
|
|
117
|
+
const issueTeam = yield* resolveFetch(issue.team);
|
|
118
|
+
|
|
119
|
+
// Get the "Started" state for this team
|
|
120
|
+
const states = yield* Effect.tryPromise({
|
|
121
|
+
try: async () => {
|
|
122
|
+
if (!issueTeam) return [];
|
|
123
|
+
const connection = await issueTeam.states();
|
|
124
|
+
return connection.nodes;
|
|
125
|
+
},
|
|
126
|
+
catch: () => [],
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
const startedState = states.find(
|
|
130
|
+
(s) => s.type === "started" || s.name.toLowerCase() === "in progress",
|
|
131
|
+
);
|
|
132
|
+
|
|
133
|
+
if (startedState) {
|
|
134
|
+
yield* linear.updateIssueState(issue.id, startedState.id);
|
|
135
|
+
yield* Console.log(`\nStarted: ${issue.identifier} - ${issue.title}`);
|
|
136
|
+
yield* Console.log(`State changed to: ${startedState.name}`);
|
|
137
|
+
} else {
|
|
138
|
+
yield* Console.log(`\nCould not find a "started" state for this issue's team.`);
|
|
139
|
+
}
|
|
158
140
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
141
|
+
// Show branch name for git
|
|
142
|
+
if (issue.branchName) {
|
|
143
|
+
yield* Console.log(`\nBranch name: ${issue.branchName}`);
|
|
144
|
+
}
|
|
163
145
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
)
|
|
146
|
+
yield* Console.log("");
|
|
147
|
+
}),
|
|
148
|
+
);
|
|
167
149
|
|
|
168
150
|
// linear issue create - Create a new issue
|
|
169
151
|
export const issueCreateCommand = Command.make("create", {}, () =>
|
|
170
152
|
Effect.gen(function* () {
|
|
171
|
-
const linear = yield* LinearService
|
|
172
|
-
const config = yield* ConfigService
|
|
173
|
-
const linearConfig = yield* config.getConfig
|
|
153
|
+
const linear = yield* LinearService;
|
|
154
|
+
const config = yield* ConfigService;
|
|
155
|
+
const linearConfig = yield* config.getConfig;
|
|
174
156
|
|
|
175
157
|
// Get teams for selection
|
|
176
|
-
const teams = yield* linear.getTeams
|
|
158
|
+
const teams = yield* linear.getTeams;
|
|
177
159
|
|
|
178
160
|
if (teams.length === 0) {
|
|
179
|
-
yield* Console.error("No teams found. Cannot create issue.")
|
|
180
|
-
return
|
|
161
|
+
yield* Console.error("No teams found. Cannot create issue.");
|
|
162
|
+
return;
|
|
181
163
|
}
|
|
182
164
|
|
|
183
165
|
// Select team (or use default from config)
|
|
184
|
-
let teamId: string
|
|
166
|
+
let teamId: string;
|
|
185
167
|
|
|
186
168
|
if (linearConfig.teamId) {
|
|
187
|
-
const team = teams.find(
|
|
188
|
-
(t) => t.id === linearConfig.teamId || t.key === linearConfig.teamId
|
|
189
|
-
)
|
|
169
|
+
const team = teams.find((t) => t.id === linearConfig.teamId || t.key === linearConfig.teamId);
|
|
190
170
|
if (team) {
|
|
191
|
-
teamId = team.id
|
|
192
|
-
yield* Console.log(`Using team from config: ${team.name}`)
|
|
171
|
+
teamId = team.id;
|
|
172
|
+
yield* Console.log(`Using team from config: ${team.name}`);
|
|
193
173
|
} else {
|
|
194
|
-
teamId = yield* selectTeam(teams)
|
|
174
|
+
teamId = yield* selectTeam(teams);
|
|
195
175
|
}
|
|
196
176
|
} else if (teams.length === 1) {
|
|
197
|
-
teamId = teams[0].id
|
|
198
|
-
yield* Console.log(`Using team: ${teams[0].name}`)
|
|
177
|
+
teamId = teams[0].id;
|
|
178
|
+
yield* Console.log(`Using team: ${teams[0].name}`);
|
|
199
179
|
} else {
|
|
200
|
-
teamId = yield* selectTeam(teams)
|
|
180
|
+
teamId = yield* selectTeam(teams);
|
|
201
181
|
}
|
|
202
182
|
|
|
203
183
|
// Prompt for title
|
|
204
184
|
const title = yield* Prompt.text({
|
|
205
185
|
message: "Issue title",
|
|
206
|
-
})
|
|
186
|
+
});
|
|
207
187
|
|
|
208
188
|
// Prompt for description (optional)
|
|
209
189
|
const description = yield* Prompt.text({
|
|
210
190
|
message: "Description (optional, press Enter to skip)",
|
|
211
191
|
default: "",
|
|
212
|
-
})
|
|
192
|
+
});
|
|
213
193
|
|
|
214
194
|
// Create the issue
|
|
215
195
|
const issue = yield* linear.createIssue({
|
|
216
196
|
title,
|
|
217
197
|
teamId,
|
|
218
198
|
description: description || undefined,
|
|
219
|
-
})
|
|
199
|
+
});
|
|
220
200
|
|
|
221
|
-
yield* Console.log(`\nCreated: ${issue.identifier} - ${issue.title}`)
|
|
222
|
-
yield* Console.log(`URL: ${issue.url}`)
|
|
223
|
-
yield* Console.log("")
|
|
224
|
-
})
|
|
225
|
-
)
|
|
201
|
+
yield* Console.log(`\nCreated: ${issue.identifier} - ${issue.title}`);
|
|
202
|
+
yield* Console.log(`URL: ${issue.url}`);
|
|
203
|
+
yield* Console.log("");
|
|
204
|
+
}),
|
|
205
|
+
);
|
|
226
206
|
|
|
227
207
|
// Combined issue command with subcommands
|
|
228
208
|
export const issue = Command.make("issue", {}, () =>
|
|
229
|
-
Console.log("Use 'linear issue list' to list issues. See --help for more.")
|
|
209
|
+
Console.log("Use 'linear issue list' to list issues. See --help for more."),
|
|
230
210
|
).pipe(
|
|
231
211
|
Command.withSubcommands([
|
|
232
212
|
issueListCommand,
|
|
233
213
|
issueViewCommand,
|
|
234
214
|
issueStartCommand,
|
|
235
215
|
issueCreateCommand,
|
|
236
|
-
])
|
|
237
|
-
)
|
|
216
|
+
]),
|
|
217
|
+
);
|
|
238
218
|
|
|
239
219
|
// Helper functions
|
|
240
220
|
|
|
241
221
|
function selectIssue(
|
|
242
|
-
linear: Context.Tag.Service<typeof LinearService
|
|
243
|
-
): Effect.Effect<
|
|
222
|
+
linear: Context.Tag.Service<typeof LinearService>,
|
|
223
|
+
): Effect.Effect<
|
|
224
|
+
string,
|
|
225
|
+
LinearApiError | TokenNotFoundError | NoIssuesError | Types.NoInfer<Terminal.QuitException>,
|
|
226
|
+
Terminal.Terminal
|
|
227
|
+
> {
|
|
244
228
|
return Effect.gen(function* () {
|
|
245
|
-
const issues = yield* linear.getMyIssues({ state: "started" })
|
|
229
|
+
const issues = yield* linear.getMyIssues({ state: "started" });
|
|
246
230
|
const allIssues =
|
|
247
|
-
issues.length > 0
|
|
248
|
-
? issues
|
|
249
|
-
: yield* linear.getMyIssues({ state: "unstarted" })
|
|
231
|
+
issues.length > 0 ? issues : yield* linear.getMyIssues({ state: "unstarted" });
|
|
250
232
|
|
|
251
233
|
if (allIssues.length === 0) {
|
|
252
|
-
yield*
|
|
253
|
-
return yield* Effect.die("No issues")
|
|
234
|
+
return yield* NoIssuesError.default;
|
|
254
235
|
}
|
|
255
236
|
|
|
256
237
|
// Build choices with state info
|
|
257
238
|
const choices = yield* Effect.all(
|
|
258
239
|
allIssues.slice(0, 20).map((issue) =>
|
|
259
240
|
Effect.gen(function* () {
|
|
260
|
-
const
|
|
261
|
-
try: () => issue.state,
|
|
262
|
-
catch: () => null,
|
|
263
|
-
})
|
|
241
|
+
const issueState = yield* resolveFetch(issue.state);
|
|
264
242
|
return {
|
|
265
243
|
title: `${issue.identifier}: ${truncate(issue.title, 40)}`,
|
|
266
244
|
value: issue.identifier,
|
|
267
|
-
description:
|
|
268
|
-
}
|
|
269
|
-
})
|
|
270
|
-
)
|
|
271
|
-
)
|
|
245
|
+
description: issueState?.name ?? "Unknown state",
|
|
246
|
+
};
|
|
247
|
+
}),
|
|
248
|
+
),
|
|
249
|
+
);
|
|
272
250
|
|
|
273
251
|
const selected = yield* Prompt.select({
|
|
274
252
|
message: "Select an issue",
|
|
275
253
|
choices,
|
|
276
|
-
})
|
|
254
|
+
});
|
|
277
255
|
|
|
278
|
-
return selected
|
|
279
|
-
})
|
|
256
|
+
return selected;
|
|
257
|
+
});
|
|
280
258
|
}
|
|
281
259
|
|
|
282
|
-
function selectTeam(
|
|
283
|
-
teams: readonly { id: string; key: string; name: string }[]
|
|
284
|
-
): Effect.Effect<string, any, any> {
|
|
260
|
+
function selectTeam(teams: readonly { id: string; key: string; name: string }[]) {
|
|
285
261
|
return Prompt.select({
|
|
286
262
|
message: "Select a team",
|
|
287
263
|
choices: teams.map((team) => ({
|
|
288
264
|
title: `${team.key}: ${team.name}`,
|
|
289
265
|
value: team.id,
|
|
290
266
|
})),
|
|
291
|
-
})
|
|
267
|
+
});
|
|
292
268
|
}
|
|
293
269
|
|
|
294
270
|
function truncate(str: string, len: number): string {
|
|
295
|
-
return str.length > len ? str.slice(0, len - 1) + "…" : str
|
|
271
|
+
return str.length > len ? str.slice(0, len - 1) + "…" : str;
|
|
296
272
|
}
|
|
297
273
|
|
|
298
274
|
function getPriorityIcon(priority: number): string {
|
|
299
275
|
switch (priority) {
|
|
300
276
|
case 0:
|
|
301
|
-
return "○" // No priority
|
|
277
|
+
return "○"; // No priority
|
|
302
278
|
case 1:
|
|
303
|
-
return "⬆" // Urgent
|
|
279
|
+
return "⬆"; // Urgent
|
|
304
280
|
case 2:
|
|
305
|
-
return "↑" // High
|
|
281
|
+
return "↑"; // High
|
|
306
282
|
case 3:
|
|
307
|
-
return "─" // Medium
|
|
283
|
+
return "─"; // Medium
|
|
308
284
|
case 4:
|
|
309
|
-
return "↓" // Low
|
|
285
|
+
return "↓"; // Low
|
|
310
286
|
default:
|
|
311
|
-
return "○"
|
|
287
|
+
return "○";
|
|
312
288
|
}
|
|
313
289
|
}
|
|
314
290
|
|
|
315
291
|
function getPriorityLabel(priority: number): string {
|
|
316
292
|
switch (priority) {
|
|
317
293
|
case 0:
|
|
318
|
-
return "No priority"
|
|
294
|
+
return "No priority";
|
|
319
295
|
case 1:
|
|
320
|
-
return "Urgent"
|
|
296
|
+
return "Urgent";
|
|
321
297
|
case 2:
|
|
322
|
-
return "High"
|
|
298
|
+
return "High";
|
|
323
299
|
case 3:
|
|
324
|
-
return "Medium"
|
|
300
|
+
return "Medium";
|
|
325
301
|
case 4:
|
|
326
|
-
return "Low"
|
|
302
|
+
return "Low";
|
|
327
303
|
default:
|
|
328
|
-
return "Unknown"
|
|
304
|
+
return "Unknown";
|
|
329
305
|
}
|
|
330
306
|
}
|
package/src/commands/team.ts
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
import { Command } from "@effect/cli"
|
|
2
|
-
import { Console, Effect } from "effect"
|
|
3
|
-
import { LinearService } from "../services/Linear.js"
|
|
1
|
+
import { Command } from "@effect/cli";
|
|
2
|
+
import { Console, Effect } from "effect";
|
|
3
|
+
import { LinearService } from "../services/Linear.js";
|
|
4
4
|
|
|
5
5
|
// linear team list - List all teams
|
|
6
6
|
export const teamListCommand = Command.make("list", {}, () =>
|
|
7
7
|
Effect.gen(function* () {
|
|
8
|
-
const linear = yield* LinearService
|
|
9
|
-
const teams = yield* linear.getTeams
|
|
8
|
+
const linear = yield* LinearService;
|
|
9
|
+
const teams = yield* linear.getTeams;
|
|
10
10
|
|
|
11
11
|
if (teams.length === 0) {
|
|
12
|
-
yield* Console.log("No teams found.")
|
|
13
|
-
return
|
|
12
|
+
yield* Console.log("No teams found.");
|
|
13
|
+
return;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
yield* Console.log("\nTeams:\n")
|
|
16
|
+
yield* Console.log("\nTeams:\n");
|
|
17
17
|
|
|
18
18
|
for (const team of teams) {
|
|
19
|
-
const key = team.key
|
|
20
|
-
const name = team.name
|
|
21
|
-
const description = team.description ? ` - ${team.description}` : ""
|
|
22
|
-
yield* Console.log(` ${key.padEnd(8)} ${name}${description}`)
|
|
19
|
+
const key = team.key;
|
|
20
|
+
const name = team.name;
|
|
21
|
+
const description = team.description ? ` - ${team.description}` : "";
|
|
22
|
+
yield* Console.log(` ${key.padEnd(8)} ${name}${description}`);
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
yield* Console.log("")
|
|
26
|
-
})
|
|
27
|
-
)
|
|
25
|
+
yield* Console.log("");
|
|
26
|
+
}),
|
|
27
|
+
);
|
|
28
28
|
|
|
29
29
|
// Combined team command with subcommands
|
|
30
30
|
export const team = Command.make("team", {}, () =>
|
|
31
|
-
Console.log("Use 'linear team list' to list teams. See --help for more.")
|
|
32
|
-
).pipe(Command.withSubcommands([teamListCommand]))
|
|
31
|
+
Console.log("Use 'linear team list' to list teams. See --help for more."),
|
|
32
|
+
).pipe(Command.withSubcommands([teamListCommand]));
|
package/src/lib/errors.ts
CHANGED
|
@@ -1,50 +1,48 @@
|
|
|
1
|
-
import { Schema } from "effect"
|
|
1
|
+
import { Schema } from "effect";
|
|
2
2
|
|
|
3
|
-
export class ConfigError extends Schema.TaggedError<ConfigError>()(
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
message: Schema.String,
|
|
7
|
-
}
|
|
8
|
-
) {}
|
|
3
|
+
export class ConfigError extends Schema.TaggedError<ConfigError>()("ConfigError", {
|
|
4
|
+
message: Schema.String,
|
|
5
|
+
}) {}
|
|
9
6
|
|
|
10
|
-
export class LinearApiError extends Schema.TaggedError<LinearApiError>()(
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
code: Schema.optional(Schema.String),
|
|
15
|
-
}
|
|
16
|
-
) {}
|
|
7
|
+
export class LinearApiError extends Schema.TaggedError<LinearApiError>()("LinearApiError", {
|
|
8
|
+
message: Schema.String,
|
|
9
|
+
code: Schema.optional(Schema.String),
|
|
10
|
+
}) {}
|
|
17
11
|
|
|
18
|
-
export class BrowserError extends Schema.TaggedError<BrowserError>()(
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
message: Schema.String,
|
|
22
|
-
}
|
|
23
|
-
) {}
|
|
12
|
+
export class BrowserError extends Schema.TaggedError<BrowserError>()("BrowserError", {
|
|
13
|
+
message: Schema.String,
|
|
14
|
+
}) {}
|
|
24
15
|
|
|
25
16
|
export class TokenNotFoundError extends Schema.TaggedError<TokenNotFoundError>()(
|
|
26
17
|
"TokenNotFoundError",
|
|
27
18
|
{
|
|
28
19
|
message: Schema.String,
|
|
29
|
-
}
|
|
20
|
+
},
|
|
30
21
|
) {
|
|
31
22
|
static readonly default = TokenNotFoundError.make({
|
|
32
23
|
message: "No token found. Run 'linear auth' to authenticate.",
|
|
33
|
-
})
|
|
24
|
+
});
|
|
34
25
|
}
|
|
35
26
|
|
|
36
27
|
export class InvalidTokenError extends Schema.TaggedError<InvalidTokenError>()(
|
|
37
28
|
"InvalidTokenError",
|
|
38
29
|
{
|
|
39
30
|
message: Schema.String,
|
|
40
|
-
}
|
|
31
|
+
},
|
|
41
32
|
) {}
|
|
42
33
|
|
|
34
|
+
export class NoIssuesError extends Schema.TaggedError<NoIssuesError>()("NoIssuesError", {
|
|
35
|
+
message: Schema.String,
|
|
36
|
+
}) {
|
|
37
|
+
static readonly default = NoIssuesError.make({ message: "No issues found to select from." });
|
|
38
|
+
}
|
|
39
|
+
|
|
43
40
|
export const AppError = Schema.Union(
|
|
44
41
|
ConfigError,
|
|
45
42
|
LinearApiError,
|
|
46
43
|
BrowserError,
|
|
47
44
|
TokenNotFoundError,
|
|
48
|
-
InvalidTokenError
|
|
49
|
-
|
|
50
|
-
|
|
45
|
+
InvalidTokenError,
|
|
46
|
+
NoIssuesError,
|
|
47
|
+
);
|
|
48
|
+
export type AppError = typeof AppError.Type;
|