@cvr/linear 0.3.0 → 0.4.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 +14 -10
- package/bin/linear +0 -0
- package/package.json +4 -2
- package/skills/linear/SKILL.md +11 -6
- package/src/cli.ts +14 -0
- package/src/commands/api.ts +92 -11
- package/src/commands/auth.ts +33 -40
- package/src/commands/issue.ts +183 -126
- package/src/commands/project.ts +14 -8
- package/src/commands/team.ts +10 -7
- package/src/domain/Input.ts +55 -0
- package/src/domain/Linear.ts +134 -0
- package/src/lib/errors.ts +0 -15
- package/src/lib/flags.ts +5 -0
- package/src/main.ts +2 -18
- package/src/services/Config.ts +114 -125
- package/src/services/Linear.ts +398 -436
- package/src/services/Browser.ts +0 -23
- package/src/services/Stdin.ts +0 -27
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
|
|
3
|
+
export const IssueSelector = Schema.String.pipe(Schema.brand("IssueSelector"));
|
|
4
|
+
export type IssueSelector = Schema.Schema.Type<typeof IssueSelector>;
|
|
5
|
+
|
|
6
|
+
export class ViewerStatus extends Schema.Class<ViewerStatus>("ViewerStatus")({
|
|
7
|
+
emoji: Schema.optional(Schema.String),
|
|
8
|
+
label: Schema.optional(Schema.String),
|
|
9
|
+
}) {}
|
|
10
|
+
|
|
11
|
+
export class Viewer extends Schema.Class<Viewer>("Viewer")({
|
|
12
|
+
id: Schema.String,
|
|
13
|
+
name: Schema.String,
|
|
14
|
+
email: Schema.String,
|
|
15
|
+
admin: Schema.Boolean,
|
|
16
|
+
status: Schema.optional(ViewerStatus),
|
|
17
|
+
}) {}
|
|
18
|
+
|
|
19
|
+
export class Team extends Schema.Class<Team>("Team")({
|
|
20
|
+
id: Schema.String,
|
|
21
|
+
key: Schema.String,
|
|
22
|
+
name: Schema.String,
|
|
23
|
+
description: Schema.optional(Schema.String),
|
|
24
|
+
}) {}
|
|
25
|
+
|
|
26
|
+
export class Project extends Schema.Class<Project>("Project")({
|
|
27
|
+
id: Schema.String,
|
|
28
|
+
name: Schema.String,
|
|
29
|
+
slug: Schema.String,
|
|
30
|
+
state: Schema.String,
|
|
31
|
+
url: Schema.String,
|
|
32
|
+
}) {}
|
|
33
|
+
|
|
34
|
+
export class IssueReference extends Schema.Class<IssueReference>("IssueReference")({
|
|
35
|
+
id: Schema.String,
|
|
36
|
+
identifier: Schema.String,
|
|
37
|
+
title: Schema.String,
|
|
38
|
+
url: Schema.String,
|
|
39
|
+
}) {}
|
|
40
|
+
|
|
41
|
+
export class IssueState extends Schema.Class<IssueState>("IssueState")({
|
|
42
|
+
id: Schema.String,
|
|
43
|
+
name: Schema.String,
|
|
44
|
+
type: Schema.String,
|
|
45
|
+
}) {}
|
|
46
|
+
|
|
47
|
+
export class IssuePriority extends Schema.Class<IssuePriority>("IssuePriority")({
|
|
48
|
+
value: Schema.Number,
|
|
49
|
+
label: Schema.String,
|
|
50
|
+
}) {}
|
|
51
|
+
|
|
52
|
+
export class IssueSummary extends IssueReference.extend<IssueSummary>("IssueSummary")({
|
|
53
|
+
branchName: Schema.String,
|
|
54
|
+
priority: IssuePriority,
|
|
55
|
+
state: Schema.optional(IssueState),
|
|
56
|
+
}) {}
|
|
57
|
+
|
|
58
|
+
export class IssueTeam extends Schema.Class<IssueTeam>("IssueTeam")({
|
|
59
|
+
id: Schema.String,
|
|
60
|
+
key: Schema.String,
|
|
61
|
+
name: Schema.String,
|
|
62
|
+
}) {}
|
|
63
|
+
|
|
64
|
+
export class IssueAssignee extends Schema.Class<IssueAssignee>("IssueAssignee")({
|
|
65
|
+
id: Schema.String,
|
|
66
|
+
name: Schema.String,
|
|
67
|
+
email: Schema.String,
|
|
68
|
+
}) {}
|
|
69
|
+
|
|
70
|
+
export class IssueProject extends Schema.Class<IssueProject>("IssueProject")({
|
|
71
|
+
id: Schema.String,
|
|
72
|
+
name: Schema.String,
|
|
73
|
+
url: Schema.String,
|
|
74
|
+
}) {}
|
|
75
|
+
|
|
76
|
+
export class IssueLabel extends Schema.Class<IssueLabel>("IssueLabel")({
|
|
77
|
+
id: Schema.String,
|
|
78
|
+
name: Schema.String,
|
|
79
|
+
}) {}
|
|
80
|
+
|
|
81
|
+
export class IssueCommentAuthor extends Schema.Class<IssueCommentAuthor>("IssueCommentAuthor")({
|
|
82
|
+
id: Schema.String,
|
|
83
|
+
name: Schema.String,
|
|
84
|
+
}) {}
|
|
85
|
+
|
|
86
|
+
export class IssueComment extends Schema.Class<IssueComment>("IssueComment")({
|
|
87
|
+
id: Schema.String,
|
|
88
|
+
body: Schema.String,
|
|
89
|
+
createdAt: Schema.String,
|
|
90
|
+
url: Schema.String,
|
|
91
|
+
author: Schema.optional(IssueCommentAuthor),
|
|
92
|
+
}) {}
|
|
93
|
+
|
|
94
|
+
export class IssueRelation extends Schema.Class<IssueRelation>("IssueRelation")({
|
|
95
|
+
id: Schema.String,
|
|
96
|
+
type: Schema.String,
|
|
97
|
+
direction: Schema.Literals(["outbound", "inbound"]),
|
|
98
|
+
issue: IssueReference,
|
|
99
|
+
}) {}
|
|
100
|
+
|
|
101
|
+
export class IssueDetails extends IssueSummary.extend<IssueDetails>("IssueDetails")({
|
|
102
|
+
description: Schema.optional(Schema.String),
|
|
103
|
+
team: Schema.optional(IssueTeam),
|
|
104
|
+
assignee: Schema.optional(IssueAssignee),
|
|
105
|
+
project: Schema.optional(IssueProject),
|
|
106
|
+
parent: Schema.optional(IssueReference),
|
|
107
|
+
labels: Schema.Array(IssueLabel),
|
|
108
|
+
children: Schema.optional(Schema.Array(IssueReference)),
|
|
109
|
+
comments: Schema.optional(Schema.Array(IssueComment)),
|
|
110
|
+
relations: Schema.optional(Schema.Array(IssueRelation)),
|
|
111
|
+
}) {}
|
|
112
|
+
|
|
113
|
+
export class StartedIssue extends Schema.Class<StartedIssue>("StartedIssue")({
|
|
114
|
+
issue: IssueReference,
|
|
115
|
+
state: IssueState,
|
|
116
|
+
branchName: Schema.String,
|
|
117
|
+
}) {}
|
|
118
|
+
|
|
119
|
+
export class CreatedIssue extends IssueReference.extend<CreatedIssue>("CreatedIssue")({}) {}
|
|
120
|
+
|
|
121
|
+
export interface IssueDetailsOptions {
|
|
122
|
+
readonly comments: boolean;
|
|
123
|
+
readonly children: boolean;
|
|
124
|
+
readonly relations: boolean;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export interface CreateIssueInput {
|
|
128
|
+
readonly title: string;
|
|
129
|
+
readonly teamId: string;
|
|
130
|
+
readonly description?: string;
|
|
131
|
+
readonly parent?: IssueSelector;
|
|
132
|
+
readonly projectId?: string;
|
|
133
|
+
readonly priority?: number;
|
|
134
|
+
}
|
package/src/lib/errors.ts
CHANGED
|
@@ -9,10 +9,6 @@ export class LinearApiError extends Schema.TaggedErrorClass<LinearApiError>()("L
|
|
|
9
9
|
code: Schema.optional(Schema.String),
|
|
10
10
|
}) {}
|
|
11
11
|
|
|
12
|
-
export class BrowserError extends Schema.TaggedErrorClass<BrowserError>()("BrowserError", {
|
|
13
|
-
message: Schema.String,
|
|
14
|
-
}) {}
|
|
15
|
-
|
|
16
12
|
export class TokenNotFoundError extends Schema.TaggedErrorClass<TokenNotFoundError>()(
|
|
17
13
|
"TokenNotFoundError",
|
|
18
14
|
{
|
|
@@ -43,14 +39,3 @@ export class InvalidInputError extends Schema.TaggedErrorClass<InvalidInputError
|
|
|
43
39
|
message: Schema.String,
|
|
44
40
|
},
|
|
45
41
|
) {}
|
|
46
|
-
|
|
47
|
-
export const AppError = Schema.Union([
|
|
48
|
-
ConfigError,
|
|
49
|
-
LinearApiError,
|
|
50
|
-
BrowserError,
|
|
51
|
-
TokenNotFoundError,
|
|
52
|
-
InvalidTokenError,
|
|
53
|
-
NoIssuesError,
|
|
54
|
-
InvalidInputError,
|
|
55
|
-
]);
|
|
56
|
-
export type AppError = typeof AppError.Type;
|
package/src/lib/flags.ts
ADDED
package/src/main.ts
CHANGED
|
@@ -1,22 +1,10 @@
|
|
|
1
|
-
// @effect-diagnostics strictEffectProvide:off
|
|
2
1
|
import { Command } from "effect/unstable/cli";
|
|
3
2
|
import { BunRuntime, BunServices } from "@effect/platform-bun";
|
|
4
3
|
import { Console, Effect, Layer } from "effect";
|
|
5
4
|
import packageJson from "../package.json" with { type: "json" };
|
|
6
|
-
import {
|
|
7
|
-
import { api } from "./commands/api.js";
|
|
8
|
-
import { team } from "./commands/team.js";
|
|
9
|
-
import { issue } from "./commands/issue.js";
|
|
10
|
-
import { project } from "./commands/project.js";
|
|
5
|
+
import { linear } from "./cli.js";
|
|
11
6
|
import { ConfigService } from "./services/Config.js";
|
|
12
7
|
import { LinearService } from "./services/Linear.js";
|
|
13
|
-
import { BrowserService } from "./services/Browser.js";
|
|
14
|
-
import { StdinService } from "./services/Stdin.js";
|
|
15
|
-
|
|
16
|
-
// Root command
|
|
17
|
-
const linear = Command.make("linear", {}, () =>
|
|
18
|
-
Console.log("Linear CLI - Use --help to see available commands"),
|
|
19
|
-
).pipe(Command.withSubcommands([auth, team, project, issue, api]));
|
|
20
8
|
|
|
21
9
|
// Build the CLI runner
|
|
22
10
|
const cli = Command.run(linear, { version: packageJson.version });
|
|
@@ -25,12 +13,8 @@ const cli = Command.run(linear, { version: packageJson.version });
|
|
|
25
13
|
// - BunServices provides FileSystem, Path, Terminal, Stdio, and child processes
|
|
26
14
|
// - ConfigService depends on FileSystem, Path
|
|
27
15
|
// - LinearService depends on ConfigService
|
|
28
|
-
// - BrowserService is standalone
|
|
29
|
-
|
|
30
16
|
// Build layers with dependencies
|
|
31
|
-
const MainLayer =
|
|
32
|
-
Layer.provideMerge(BrowserService.layer),
|
|
33
|
-
Layer.provideMerge(LinearService.layer),
|
|
17
|
+
const MainLayer = LinearService.layer.pipe(
|
|
34
18
|
Layer.provideMerge(ConfigService.layer),
|
|
35
19
|
Layer.provideMerge(BunServices.layer),
|
|
36
20
|
);
|
package/src/services/Config.ts
CHANGED
|
@@ -1,18 +1,20 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { parse } from "toml";
|
|
2
|
+
import { Config, Context, Effect, FileSystem, Layer, Option, Path, Redacted, Schema } from "effect";
|
|
2
3
|
import { ConfigError, TokenNotFoundError } from "../lib/errors.js";
|
|
3
4
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
export class LinearConfig extends Schema.Class<LinearConfig>("LinearConfig")({
|
|
6
|
+
teamId: Schema.optional(Schema.String),
|
|
7
|
+
}) {}
|
|
8
|
+
|
|
9
|
+
class LinearConfigFile extends Schema.Class<LinearConfigFile>("LinearConfigFile")({
|
|
10
|
+
team_id: Schema.optional(Schema.String),
|
|
11
|
+
}) {}
|
|
10
12
|
|
|
11
13
|
export class ConfigService extends Context.Service<
|
|
12
14
|
ConfigService,
|
|
13
15
|
{
|
|
14
|
-
readonly getToken: Effect.Effect<string
|
|
15
|
-
readonly saveToken: (token: string) => Effect.Effect<void, ConfigError>;
|
|
16
|
+
readonly getToken: Effect.Effect<Redacted.Redacted<string>, TokenNotFoundError | ConfigError>;
|
|
17
|
+
readonly saveToken: (token: Redacted.Redacted<string>) => Effect.Effect<void, ConfigError>;
|
|
16
18
|
readonly getConfig: Effect.Effect<LinearConfig, ConfigError>;
|
|
17
19
|
}
|
|
18
20
|
>()("@cvr/linear/services/Config/ConfigService") {
|
|
@@ -21,144 +23,131 @@ export class ConfigService extends Context.Service<
|
|
|
21
23
|
Effect.gen(function* () {
|
|
22
24
|
const fs = yield* FileSystem.FileSystem;
|
|
23
25
|
const path = yield* Path.Path;
|
|
24
|
-
|
|
25
26
|
const homeDir = yield* Config.string("HOME").pipe(Config.withDefault(""));
|
|
26
|
-
const envToken = yield* Config.
|
|
27
|
+
const envToken = yield* Config.redacted("LINEAR_API_KEY").pipe(Config.option);
|
|
27
28
|
const configDir = path.join(homeDir, ".config", "linear");
|
|
28
29
|
const tokenPath = path.join(configDir, "token");
|
|
29
30
|
const configPath = path.join(configDir, "config.toml");
|
|
30
31
|
|
|
31
|
-
const ensureConfigDir =
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
32
|
+
const ensureConfigDir = fs
|
|
33
|
+
.makeDirectory(configDir, { recursive: true })
|
|
34
|
+
.pipe(
|
|
35
|
+
Effect.mapError((error) =>
|
|
36
|
+
ConfigError.make({ message: `Failed to create config directory: ${error}` }),
|
|
37
|
+
),
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
const getToken = readTokenFile(fs, tokenPath).pipe(
|
|
41
|
+
Effect.flatMap(
|
|
42
|
+
Option.match({
|
|
43
|
+
onSome: Effect.succeed,
|
|
44
|
+
onNone: () =>
|
|
45
|
+
Option.match(envToken, {
|
|
46
|
+
onSome: Effect.succeed,
|
|
47
|
+
onNone: () => TokenNotFoundError.default,
|
|
48
|
+
}),
|
|
49
|
+
}),
|
|
39
50
|
),
|
|
51
|
+
Effect.withSpan("ConfigService.getToken"),
|
|
40
52
|
);
|
|
41
53
|
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
if (Option.isSome(envToken)) {
|
|
55
|
-
return envToken.value;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
// 3. Error
|
|
59
|
-
return yield* TokenNotFoundError.default;
|
|
60
|
-
}).pipe(Effect.withSpan("ConfigService.getToken"));
|
|
61
|
-
|
|
62
|
-
const saveToken = Effect.fn("ConfigService.saveToken")((token: string) =>
|
|
63
|
-
Effect.gen(function* () {
|
|
64
|
-
yield* ensureConfigDir;
|
|
65
|
-
yield* Effect.tryPromise({
|
|
66
|
-
try: () => Bun.write(tokenPath, token.trim()),
|
|
67
|
-
catch: (e) => ConfigError.make({ message: `Failed to save token: ${e}` }),
|
|
68
|
-
});
|
|
69
|
-
}),
|
|
70
|
-
);
|
|
54
|
+
const saveToken = Effect.fn("ConfigService.saveToken")(function* (
|
|
55
|
+
token: Redacted.Redacted<string>,
|
|
56
|
+
) {
|
|
57
|
+
yield* ensureConfigDir;
|
|
58
|
+
yield* fs
|
|
59
|
+
.writeFileString(tokenPath, Redacted.value(token).trim(), { mode: 0o600 })
|
|
60
|
+
.pipe(
|
|
61
|
+
Effect.mapError((error) =>
|
|
62
|
+
ConfigError.make({ message: `Failed to save token: ${error}` }),
|
|
63
|
+
),
|
|
64
|
+
);
|
|
65
|
+
});
|
|
71
66
|
|
|
72
67
|
const getConfig = Effect.gen(function* () {
|
|
73
|
-
|
|
74
|
-
const
|
|
75
|
-
|
|
76
|
-
|
|
68
|
+
const cwd = path.resolve(".");
|
|
69
|
+
for (const candidate of [path.join(cwd, ".linear.toml"), path.join(cwd, "linear.toml")]) {
|
|
70
|
+
const projectConfig = yield* readConfigFile(fs, candidate);
|
|
71
|
+
if (Option.isSome(projectConfig)) {
|
|
72
|
+
return projectConfig.value;
|
|
73
|
+
}
|
|
77
74
|
}
|
|
78
75
|
|
|
79
|
-
|
|
80
|
-
const globalConfig = yield* loadTomlConfig(configPath);
|
|
81
|
-
return globalConfig;
|
|
76
|
+
return Option.getOrElse(yield* readConfigFile(fs, configPath), () => new LinearConfig({}));
|
|
82
77
|
}).pipe(Effect.withSpan("ConfigService.getConfig"));
|
|
83
78
|
|
|
84
|
-
return ConfigService.of({
|
|
85
|
-
getToken,
|
|
86
|
-
saveToken,
|
|
87
|
-
getConfig,
|
|
88
|
-
});
|
|
79
|
+
return ConfigService.of({ getToken, saveToken, getConfig });
|
|
89
80
|
}),
|
|
90
81
|
);
|
|
91
82
|
|
|
92
83
|
static readonly layerTest = (options?: { token?: string; config?: LinearConfig }) =>
|
|
93
84
|
Layer.succeed(ConfigService, {
|
|
94
85
|
getToken:
|
|
95
|
-
options?.token
|
|
96
|
-
? Effect.
|
|
97
|
-
: Effect.
|
|
98
|
-
saveToken: (
|
|
99
|
-
getConfig: Effect.succeed(options?.config ?? {}),
|
|
86
|
+
options?.token === undefined
|
|
87
|
+
? Effect.fail(TokenNotFoundError.default)
|
|
88
|
+
: Effect.succeed(Redacted.make(options.token)),
|
|
89
|
+
saveToken: () => Effect.void,
|
|
90
|
+
getConfig: Effect.succeed(options?.config ?? new LinearConfig({})),
|
|
100
91
|
});
|
|
101
92
|
}
|
|
102
93
|
|
|
103
|
-
const
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
switch (key?.trim()) {
|
|
127
|
-
case "team_id":
|
|
128
|
-
teamId = value;
|
|
129
|
-
break;
|
|
130
|
-
case "workspace":
|
|
131
|
-
workspace = value;
|
|
132
|
-
break;
|
|
133
|
-
case "issue_sort":
|
|
134
|
-
if (value === "manual" || value === "priority") {
|
|
135
|
-
issueSort = value;
|
|
136
|
-
}
|
|
137
|
-
break;
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
return { teamId, workspace, issueSort } as LinearConfig;
|
|
141
|
-
},
|
|
142
|
-
catch: (e) => ConfigError.make({ message: `Failed to load config: ${e}` }),
|
|
143
|
-
}),
|
|
144
|
-
);
|
|
145
|
-
|
|
146
|
-
const loadProjectConfig = Effect.fn("ConfigService.loadProjectConfig")((pathService: Path.Path) =>
|
|
147
|
-
Effect.gen(function* () {
|
|
148
|
-
const cwd = process.cwd();
|
|
149
|
-
const candidates = [
|
|
150
|
-
pathService.join(cwd, ".linear.toml"),
|
|
151
|
-
pathService.join(cwd, "linear.toml"),
|
|
152
|
-
];
|
|
153
|
-
|
|
154
|
-
for (const candidate of candidates) {
|
|
155
|
-
const exists = yield* Effect.promise(() => Bun.file(candidate).exists());
|
|
156
|
-
if (exists) {
|
|
157
|
-
const config = yield* loadTomlConfig(candidate);
|
|
158
|
-
return Option.some(config);
|
|
159
|
-
}
|
|
160
|
-
}
|
|
94
|
+
const readTokenFile = (
|
|
95
|
+
fs: Context.Service.Shape<typeof FileSystem.FileSystem>,
|
|
96
|
+
tokenPath: string,
|
|
97
|
+
): Effect.Effect<Option.Option<Redacted.Redacted<string>>, ConfigError> =>
|
|
98
|
+
fs.exists(tokenPath).pipe(
|
|
99
|
+
Effect.mapError((error) =>
|
|
100
|
+
ConfigError.make({ message: `Failed to inspect token file: ${error}` }),
|
|
101
|
+
),
|
|
102
|
+
Effect.flatMap((exists) =>
|
|
103
|
+
exists
|
|
104
|
+
? fs.readFileString(tokenPath).pipe(
|
|
105
|
+
Effect.mapError((error) =>
|
|
106
|
+
ConfigError.make({ message: `Failed to read token file: ${error}` }),
|
|
107
|
+
),
|
|
108
|
+
Effect.map((token) => token.trim()),
|
|
109
|
+
Effect.map((token) =>
|
|
110
|
+
token.length === 0 ? Option.none() : Option.some(Redacted.make(token)),
|
|
111
|
+
),
|
|
112
|
+
)
|
|
113
|
+
: Effect.succeed(Option.none()),
|
|
114
|
+
),
|
|
115
|
+
);
|
|
161
116
|
|
|
117
|
+
const readConfigFile = Effect.fn("ConfigService.readConfigFile")(function* (
|
|
118
|
+
fs: Context.Service.Shape<typeof FileSystem.FileSystem>,
|
|
119
|
+
filePath: string,
|
|
120
|
+
): Effect.fn.Return<Option.Option<LinearConfig>, ConfigError> {
|
|
121
|
+
const exists = yield* fs
|
|
122
|
+
.exists(filePath)
|
|
123
|
+
.pipe(
|
|
124
|
+
Effect.mapError((error) =>
|
|
125
|
+
ConfigError.make({ message: `Failed to inspect ${filePath}: ${error}` }),
|
|
126
|
+
),
|
|
127
|
+
);
|
|
128
|
+
if (!exists) {
|
|
162
129
|
return Option.none();
|
|
163
|
-
}
|
|
164
|
-
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
const content = yield* fs
|
|
133
|
+
.readFileString(filePath)
|
|
134
|
+
.pipe(
|
|
135
|
+
Effect.mapError((error) =>
|
|
136
|
+
ConfigError.make({ message: `Failed to read ${filePath}: ${error}` }),
|
|
137
|
+
),
|
|
138
|
+
);
|
|
139
|
+
const parsed = yield* Effect.try({
|
|
140
|
+
try: () => parse(content),
|
|
141
|
+
catch: (error) => ConfigError.make({ message: `Failed to parse ${filePath}: ${error}` }),
|
|
142
|
+
});
|
|
143
|
+
const decoded = yield* Schema.decodeUnknownEffect(LinearConfigFile)(parsed).pipe(
|
|
144
|
+
Effect.mapError((error) =>
|
|
145
|
+
ConfigError.make({ message: `Invalid Linear config in ${filePath}: ${error}` }),
|
|
146
|
+
),
|
|
147
|
+
);
|
|
148
|
+
return Option.some(
|
|
149
|
+
new LinearConfig({
|
|
150
|
+
teamId: decoded.team_id,
|
|
151
|
+
}),
|
|
152
|
+
);
|
|
153
|
+
});
|