@cvr/linear 0.5.0 → 0.5.1
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 +1 -1
- package/bin/linear +2 -2
- package/package.json +5 -5
- package/src/cli.ts +1 -1
- package/src/commands/api.ts +6 -5
- package/src/commands/auth.ts +3 -3
- package/src/commands/file.ts +2 -2
- package/src/commands/issue.ts +32 -24
- package/src/commands/project.ts +1 -1
- package/src/commands/team.ts +1 -1
- package/src/lib/errors.ts +7 -7
- package/src/lib/flags.ts +6 -4
- package/src/main.ts +1 -1
- package/src/services/Config.ts +3 -3
- package/tsconfig.json +3 -1
package/README.md
CHANGED
|
@@ -145,7 +145,7 @@ Built with:
|
|
|
145
145
|
|
|
146
146
|
- **[Bun](https://bun.sh)**: Fast JavaScript runtime with native compilation
|
|
147
147
|
- **[Effect](https://effect.website)**: TypeScript library for type-safe, composable code
|
|
148
|
-
- **[Effect CLI](https://github.com/Effect-TS/effect/tree/main/packages/effect/src/
|
|
148
|
+
- **[Effect CLI](https://github.com/Effect-TS/effect/tree/main/packages/effect/src/cli)**: CLI framework with prompts and argument parsing
|
|
149
149
|
- **[@linear/sdk](https://github.com/linear/linear)**: Official Linear GraphQL SDK
|
|
150
150
|
|
|
151
151
|
## Credits
|
package/bin/linear
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
[diffend] Oversized file quarantined before diffing.
|
|
2
2
|
name: package/bin/linear
|
|
3
|
-
size:
|
|
4
|
-
sha256:
|
|
3
|
+
size: 83912160 bytes
|
|
4
|
+
sha256: 128240f654731526d32f5ed7b9e5d23650f7dfe5308684ec93e5cebb16b9757f
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cvr/linear",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/cevr/linear-cli.git"
|
|
@@ -34,17 +34,17 @@
|
|
|
34
34
|
"release": "changeset publish"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@effect/platform-bun": "4.0.0
|
|
37
|
+
"@effect/platform-bun": "4.0.0",
|
|
38
38
|
"@linear/sdk": "^88.2.0",
|
|
39
|
-
"effect": "4.0.0
|
|
39
|
+
"effect": "4.0.0",
|
|
40
40
|
"graphql": "^17.0.2",
|
|
41
41
|
"toml": "^5.0.0"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@changesets/changelog-github": "^1.0.1",
|
|
45
45
|
"@changesets/cli": "^3.0.3",
|
|
46
|
-
"@effect/tsgo": "^0.
|
|
47
|
-
"@effect/vitest": "4.0.0
|
|
46
|
+
"@effect/tsgo": "^0.47.2",
|
|
47
|
+
"@effect/vitest": "4.0.0",
|
|
48
48
|
"@types/bun": "^1.3.14",
|
|
49
49
|
"@typescript/native-preview": "7.0.0-dev.20260707.2",
|
|
50
50
|
"concurrently": "^10.0.3",
|
package/src/cli.ts
CHANGED
package/src/commands/api.ts
CHANGED
|
@@ -1,27 +1,28 @@
|
|
|
1
1
|
import { Console, Effect, FileSystem, Option, Path, Schema } from "effect";
|
|
2
|
-
import { Command, Flag } from "effect/
|
|
2
|
+
import { Command, Flag } from "effect/cli";
|
|
3
3
|
import { Kind } from "graphql/language/kinds.js";
|
|
4
4
|
import { parse } from "graphql/language/parser.js";
|
|
5
5
|
import { InvalidInputError } from "../lib/errors.js";
|
|
6
6
|
import { encodeJson } from "../lib/json.js";
|
|
7
7
|
import { LinearService } from "../services/Linear.js";
|
|
8
8
|
|
|
9
|
-
const queryOption = Flag.
|
|
9
|
+
const queryOption = Flag.String("query").pipe(
|
|
10
10
|
Flag.withDescription("GraphQL document"),
|
|
11
11
|
Flag.optional,
|
|
12
12
|
);
|
|
13
13
|
|
|
14
|
-
const queryFileOption = Flag.
|
|
14
|
+
const queryFileOption = Flag.String("query-file").pipe(
|
|
15
15
|
Flag.withDescription("Read the GraphQL document from a file"),
|
|
16
16
|
Flag.optional,
|
|
17
17
|
);
|
|
18
18
|
|
|
19
|
-
const variablesOption = Flag.
|
|
19
|
+
const variablesOption = Flag.String("variables").pipe(
|
|
20
20
|
Flag.withDescription("GraphQL variables as a JSON object"),
|
|
21
21
|
Flag.withDefault("{}"),
|
|
22
22
|
);
|
|
23
23
|
|
|
24
|
-
const allowMutationOption = Flag.
|
|
24
|
+
const allowMutationOption = Flag.Boolean("allow-mutation").pipe(
|
|
25
|
+
Flag.withDefault(false),
|
|
25
26
|
Flag.withDescription("Explicitly authorize a raw GraphQL mutation"),
|
|
26
27
|
);
|
|
27
28
|
|
package/src/commands/auth.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Command, Prompt } from "effect/
|
|
2
|
-
import { ChildProcess } from "effect/
|
|
1
|
+
import { Command, Prompt } from "effect/cli";
|
|
2
|
+
import { ChildProcess } from "effect/process";
|
|
3
3
|
import { Console, Effect } from "effect";
|
|
4
4
|
import { jsonFlag } from "../lib/flags.js";
|
|
5
5
|
import { encodeJson } from "../lib/json.js";
|
|
@@ -27,7 +27,7 @@ export const authCommand = Command.make("auth", {}, () =>
|
|
|
27
27
|
yield* Console.log(`Could not open browser. Please visit the URL manually.`);
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
const token = yield* Prompt.
|
|
30
|
+
const token = yield* Prompt.Hidden({ message: "Paste your API key" });
|
|
31
31
|
|
|
32
32
|
// Validate token by making an API call
|
|
33
33
|
yield* Console.log("\nValidating token...");
|
package/src/commands/file.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Argument, Command } from "effect/
|
|
1
|
+
import { Argument, Command } from "effect/cli";
|
|
2
2
|
import { Console, Effect } from "effect";
|
|
3
3
|
import type { SavedFile } from "../domain/Linear.js";
|
|
4
4
|
import { parseUploadUrl } from "../domain/Input.js";
|
|
@@ -7,7 +7,7 @@ import { InvalidInputError } from "../lib/errors.js";
|
|
|
7
7
|
import { jsonFlag, outputDirFlag, overwriteFlag } from "../lib/flags.js";
|
|
8
8
|
import { encodeJson } from "../lib/json.js";
|
|
9
9
|
|
|
10
|
-
const uploadUrlsArg = Argument.
|
|
10
|
+
const uploadUrlsArg = Argument.String("url").pipe(
|
|
11
11
|
Argument.withDescription("https://uploads.linear.app/... URL (repeat for several files)"),
|
|
12
12
|
Argument.variadic(),
|
|
13
13
|
);
|
package/src/commands/issue.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Argument, Command, Flag, Prompt } from "effect/
|
|
1
|
+
import { Argument, Command, Flag, Prompt } from "effect/cli";
|
|
2
2
|
import { Console, Effect, Option } from "effect";
|
|
3
3
|
import type { IssueDetails } from "../domain/Linear.js";
|
|
4
4
|
import { extractUploadLinks, uniqueByUrl } from "../domain/Files.js";
|
|
@@ -13,70 +13,77 @@ import { LinearService } from "../services/Linear.js";
|
|
|
13
13
|
import { ConfigService } from "../services/Config.js";
|
|
14
14
|
|
|
15
15
|
// Options
|
|
16
|
-
const stateOption = Flag.
|
|
16
|
+
const stateOption = Flag.String("state").pipe(
|
|
17
17
|
Flag.withAlias("s"),
|
|
18
18
|
Flag.withDescription("Filter by state type (started, unstarted, backlog, etc.)"),
|
|
19
19
|
Flag.optional,
|
|
20
20
|
);
|
|
21
21
|
|
|
22
|
-
const limitOption = Flag.
|
|
22
|
+
const limitOption = Flag.Int("limit").pipe(
|
|
23
23
|
Flag.withAlias("n"),
|
|
24
24
|
Flag.withDefault(20),
|
|
25
25
|
Flag.withDescription("Number of issues to show"),
|
|
26
26
|
);
|
|
27
27
|
|
|
28
|
-
const commentsOption = Flag.
|
|
28
|
+
const commentsOption = Flag.Boolean("comments").pipe(
|
|
29
|
+
Flag.withDefault(false),
|
|
29
30
|
Flag.withDescription("Include issue comments"),
|
|
30
31
|
);
|
|
31
32
|
|
|
32
|
-
const childrenOption = Flag.
|
|
33
|
+
const childrenOption = Flag.Boolean("children").pipe(
|
|
34
|
+
Flag.withDefault(false),
|
|
35
|
+
Flag.withDescription("Include sub-issues"),
|
|
36
|
+
);
|
|
33
37
|
|
|
34
|
-
const relationsOption = Flag.
|
|
38
|
+
const relationsOption = Flag.Boolean("relations").pipe(
|
|
39
|
+
Flag.withDefault(false),
|
|
35
40
|
Flag.withDescription("Include inbound and outbound issue relations"),
|
|
36
41
|
);
|
|
37
42
|
|
|
38
|
-
const titleOption = Flag.
|
|
43
|
+
const titleOption = Flag.String("title").pipe(
|
|
39
44
|
Flag.withDescription("Issue title; enables non-interactive creation"),
|
|
40
45
|
Flag.optional,
|
|
41
46
|
);
|
|
42
47
|
|
|
43
|
-
const descriptionOption = Flag.
|
|
48
|
+
const descriptionOption = Flag.String("description").pipe(
|
|
44
49
|
Flag.withDescription("Issue description in Markdown"),
|
|
45
50
|
Flag.optional,
|
|
46
51
|
);
|
|
47
52
|
|
|
48
|
-
const teamOption = Flag.
|
|
53
|
+
const teamOption = Flag.String("team").pipe(
|
|
49
54
|
Flag.withDescription("Team key or UUID"),
|
|
50
55
|
Flag.optional,
|
|
51
56
|
);
|
|
52
57
|
|
|
53
|
-
const parentOption = Flag.
|
|
58
|
+
const parentOption = Flag.String("parent").pipe(
|
|
54
59
|
Flag.withDescription("Parent issue identifier or UUID"),
|
|
55
60
|
Flag.optional,
|
|
56
61
|
);
|
|
57
62
|
|
|
58
|
-
const projectOption = Flag.
|
|
63
|
+
const projectOption = Flag.String("project").pipe(
|
|
59
64
|
Flag.withDescription("Project name, slug, or UUID"),
|
|
60
65
|
Flag.optional,
|
|
61
66
|
);
|
|
62
67
|
|
|
63
|
-
const priorityOption = Flag.
|
|
68
|
+
const priorityOption = Flag.Int("priority").pipe(
|
|
64
69
|
Flag.withDescription("Priority from 0 (none) to 4 (low)"),
|
|
65
70
|
Flag.optional,
|
|
66
71
|
);
|
|
67
72
|
|
|
68
|
-
const dryRunOption = Flag.
|
|
73
|
+
const dryRunOption = Flag.Boolean("dry-run").pipe(
|
|
74
|
+
Flag.withDefault(false),
|
|
69
75
|
Flag.withDescription("Validate and print the mutation without writing"),
|
|
70
76
|
);
|
|
71
77
|
|
|
72
|
-
const interactiveOption = Flag.
|
|
78
|
+
const interactiveOption = Flag.Boolean("interactive").pipe(
|
|
79
|
+
Flag.withDefault(false),
|
|
73
80
|
Flag.withDescription("Allow prompts when required input is missing"),
|
|
74
81
|
);
|
|
75
82
|
|
|
76
|
-
const bodyOption = Flag.
|
|
83
|
+
const bodyOption = Flag.String("body").pipe(Flag.withDescription("Comment body in Markdown"));
|
|
77
84
|
|
|
78
85
|
// Args
|
|
79
|
-
const issueIdsArg = Argument.
|
|
86
|
+
const issueIdsArg = Argument.String("id").pipe(
|
|
80
87
|
Argument.withDescription("Issue ID, URL, or identifier (repeat for bulk reads)"),
|
|
81
88
|
Argument.variadic(),
|
|
82
89
|
);
|
|
@@ -187,7 +194,7 @@ export const issueViewCommand = Command.make(
|
|
|
187
194
|
);
|
|
188
195
|
|
|
189
196
|
// linear issue start [id] - Start working on an issue
|
|
190
|
-
const optionalIssueIdArg = Argument.
|
|
197
|
+
const optionalIssueIdArg = Argument.String("id").pipe(
|
|
191
198
|
Argument.withDescription("Issue ID, URL, or identifier"),
|
|
192
199
|
Argument.optional,
|
|
193
200
|
);
|
|
@@ -291,13 +298,13 @@ export const issueCreateCommand = Command.make(
|
|
|
291
298
|
const requestedTeam = Option.getOrUndefined(team) ?? linearConfig.teamId;
|
|
292
299
|
const teamId = yield* resolveTeamId(teams, requestedTeam, isInteractive);
|
|
293
300
|
const issueTitle = yield* Option.match(title, {
|
|
294
|
-
onNone: () => Prompt.
|
|
301
|
+
onNone: () => Prompt.String({ message: "Issue title" }),
|
|
295
302
|
onSome: Effect.succeed,
|
|
296
303
|
});
|
|
297
304
|
const issueDescription = yield* Option.match(description, {
|
|
298
305
|
onNone: () => {
|
|
299
306
|
if (isInteractive) {
|
|
300
|
-
return Prompt.
|
|
307
|
+
return Prompt.String({
|
|
301
308
|
message: "Description (optional, press Enter to skip)",
|
|
302
309
|
default: "",
|
|
303
310
|
});
|
|
@@ -374,7 +381,7 @@ export const issueCreateCommand = Command.make(
|
|
|
374
381
|
export const issueCommentCommand = Command.make(
|
|
375
382
|
"comment",
|
|
376
383
|
{
|
|
377
|
-
id: Argument.
|
|
384
|
+
id: Argument.String("id").pipe(Argument.withDescription("Issue ID, URL, or identifier")),
|
|
378
385
|
body: bodyOption,
|
|
379
386
|
dryRun: dryRunOption,
|
|
380
387
|
json: jsonFlag,
|
|
@@ -420,7 +427,8 @@ export const issueCommentCommand = Command.make(
|
|
|
420
427
|
]),
|
|
421
428
|
);
|
|
422
429
|
|
|
423
|
-
const downloadOption = Flag.
|
|
430
|
+
const downloadOption = Flag.Boolean("download").pipe(
|
|
431
|
+
Flag.withDefault(false),
|
|
424
432
|
Flag.withDescription("Save every listed file into --output-dir"),
|
|
425
433
|
);
|
|
426
434
|
|
|
@@ -428,7 +436,7 @@ const downloadOption = Flag.boolean("download").pipe(
|
|
|
428
436
|
export const issueFilesCommand = Command.make(
|
|
429
437
|
"files",
|
|
430
438
|
{
|
|
431
|
-
id: Argument.
|
|
439
|
+
id: Argument.String("id").pipe(Argument.withDescription("Issue ID, URL, or identifier")),
|
|
432
440
|
download: downloadOption,
|
|
433
441
|
outputDir: outputDirFlag,
|
|
434
442
|
overwrite: overwriteFlag,
|
|
@@ -517,7 +525,7 @@ const selectIssue = Effect.gen(function* () {
|
|
|
517
525
|
description: candidate.state?.name ?? "Unknown state",
|
|
518
526
|
}));
|
|
519
527
|
|
|
520
|
-
const selected = yield* Prompt.
|
|
528
|
+
const selected = yield* Prompt.Select({
|
|
521
529
|
message: "Select an issue",
|
|
522
530
|
choices,
|
|
523
531
|
});
|
|
@@ -570,7 +578,7 @@ const renderIssueDetails = Effect.fn("IssueCommand.renderDetails")(function* (
|
|
|
570
578
|
});
|
|
571
579
|
|
|
572
580
|
function selectTeam(teams: readonly { id: string; key: string; name: string }[]) {
|
|
573
|
-
return Prompt.
|
|
581
|
+
return Prompt.Select({
|
|
574
582
|
message: "Select a team",
|
|
575
583
|
choices: teams.map((team) => ({
|
|
576
584
|
title: `${team.key}: ${team.name}`,
|
package/src/commands/project.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Console, Effect } from "effect";
|
|
2
|
-
import { Command } from "effect/
|
|
2
|
+
import { Command } from "effect/cli";
|
|
3
3
|
import { jsonFlag } from "../lib/flags.js";
|
|
4
4
|
import { encodeJson } from "../lib/json.js";
|
|
5
5
|
import { LinearService } from "../services/Linear.js";
|
package/src/commands/team.ts
CHANGED
package/src/lib/errors.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { Schema } from "effect";
|
|
2
2
|
|
|
3
|
-
export class ConfigError extends Schema.
|
|
3
|
+
export class ConfigError extends Schema.TaggedError<ConfigError>()("ConfigError", {
|
|
4
4
|
message: Schema.String,
|
|
5
5
|
}) {}
|
|
6
6
|
|
|
7
|
-
export class LinearApiError extends Schema.
|
|
7
|
+
export class LinearApiError extends Schema.TaggedError<LinearApiError>()("LinearApiError", {
|
|
8
8
|
message: Schema.String,
|
|
9
9
|
code: Schema.optional(Schema.String),
|
|
10
10
|
}) {}
|
|
11
11
|
|
|
12
|
-
export class TokenNotFoundError extends Schema.
|
|
12
|
+
export class TokenNotFoundError extends Schema.TaggedError<TokenNotFoundError>()(
|
|
13
13
|
"TokenNotFoundError",
|
|
14
14
|
{
|
|
15
15
|
message: Schema.String,
|
|
@@ -20,26 +20,26 @@ export class TokenNotFoundError extends Schema.TaggedErrorClass<TokenNotFoundErr
|
|
|
20
20
|
});
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
export class InvalidTokenError extends Schema.
|
|
23
|
+
export class InvalidTokenError extends Schema.TaggedError<InvalidTokenError>()(
|
|
24
24
|
"InvalidTokenError",
|
|
25
25
|
{
|
|
26
26
|
message: Schema.String,
|
|
27
27
|
},
|
|
28
28
|
) {}
|
|
29
29
|
|
|
30
|
-
export class NoIssuesError extends Schema.
|
|
30
|
+
export class NoIssuesError extends Schema.TaggedError<NoIssuesError>()("NoIssuesError", {
|
|
31
31
|
message: Schema.String,
|
|
32
32
|
}) {
|
|
33
33
|
static readonly default = NoIssuesError.make({ message: "No issues found to select from." });
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
export class InvalidInputError extends Schema.
|
|
36
|
+
export class InvalidInputError extends Schema.TaggedError<InvalidInputError>()(
|
|
37
37
|
"InvalidInputError",
|
|
38
38
|
{
|
|
39
39
|
message: Schema.String,
|
|
40
40
|
},
|
|
41
41
|
) {}
|
|
42
42
|
|
|
43
|
-
export class FileWriteError extends Schema.
|
|
43
|
+
export class FileWriteError extends Schema.TaggedError<FileWriteError>()("FileWriteError", {
|
|
44
44
|
message: Schema.String,
|
|
45
45
|
}) {}
|
package/src/lib/flags.ts
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
|
-
import { Flag } from "effect/
|
|
1
|
+
import { Flag } from "effect/cli";
|
|
2
2
|
|
|
3
|
-
export const jsonFlag = Flag.
|
|
3
|
+
export const jsonFlag = Flag.Boolean("json").pipe(
|
|
4
|
+
Flag.withDefault(false),
|
|
4
5
|
Flag.withDescription("Emit stable JSON for scripts and agents"),
|
|
5
6
|
);
|
|
6
7
|
|
|
7
|
-
export const outputDirFlag = Flag.
|
|
8
|
+
export const outputDirFlag = Flag.String("output-dir").pipe(
|
|
8
9
|
Flag.withAlias("o"),
|
|
9
10
|
Flag.withDefault("."),
|
|
10
11
|
Flag.withDescription("Directory to save files in; created when missing"),
|
|
11
12
|
);
|
|
12
13
|
|
|
13
|
-
export const overwriteFlag = Flag.
|
|
14
|
+
export const overwriteFlag = Flag.Boolean("overwrite").pipe(
|
|
15
|
+
Flag.withDefault(false),
|
|
14
16
|
Flag.withDescription("Replace files that already exist in the output directory"),
|
|
15
17
|
);
|
package/src/main.ts
CHANGED
package/src/services/Config.ts
CHANGED
|
@@ -23,8 +23,8 @@ export class ConfigService extends Context.Service<
|
|
|
23
23
|
Effect.gen(function* () {
|
|
24
24
|
const fs = yield* FileSystem.FileSystem;
|
|
25
25
|
const path = yield* Path.Path;
|
|
26
|
-
const homeDir = yield* Config.
|
|
27
|
-
const envToken = yield* Config.
|
|
26
|
+
const homeDir = yield* Config.String("HOME").pipe(Config.withDefault(""));
|
|
27
|
+
const envToken = yield* Config.Redacted("LINEAR_API_KEY").pipe(Config.option);
|
|
28
28
|
const configDir = path.join(homeDir, ".config", "linear");
|
|
29
29
|
const tokenPath = path.join(configDir, "token");
|
|
30
30
|
const configPath = path.join(configDir, "config.toml");
|
|
@@ -98,7 +98,7 @@ const readTokenFile = (
|
|
|
98
98
|
),
|
|
99
99
|
Effect.flatMap((exists) => {
|
|
100
100
|
if (!exists) {
|
|
101
|
-
return Effect.
|
|
101
|
+
return Effect.succeedNone;
|
|
102
102
|
}
|
|
103
103
|
return fs.readFileString(tokenPath).pipe(
|
|
104
104
|
Effect.mapError((error) =>
|
package/tsconfig.json
CHANGED
|
@@ -49,8 +49,10 @@
|
|
|
49
49
|
"processEnv": "off",
|
|
50
50
|
"processEnvInEffect": "off",
|
|
51
51
|
"deterministicKeys": "error",
|
|
52
|
-
"importFromBarrel": "warning",
|
|
53
52
|
"instanceOfSchema": "warning",
|
|
53
|
+
// Effect 4.0.0 marks the whole effect/cli module @stability unstable. This CLI is
|
|
54
|
+
// built on it, so the rule would flag every command, flag, and prompt definition.
|
|
55
|
+
"unstableApiUsage": "off",
|
|
54
56
|
"missedPipeableOpportunity": "suggestion",
|
|
55
57
|
"missingEffectServiceDependency": "warning",
|
|
56
58
|
"schemaUnionOfLiterals": "warning",
|