@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/README.md
CHANGED
|
@@ -44,24 +44,24 @@ linear team list
|
|
|
44
44
|
|
|
45
45
|
### Authentication
|
|
46
46
|
|
|
47
|
-
| Command
|
|
48
|
-
|
|
49
|
-
| `linear auth`
|
|
50
|
-
| `linear auth whoami` | Show current user info
|
|
47
|
+
| Command | Description |
|
|
48
|
+
| -------------------- | ---------------------------------------------------- |
|
|
49
|
+
| `linear auth` | Authenticate with Linear (opens browser for API key) |
|
|
50
|
+
| `linear auth whoami` | Show current user info |
|
|
51
51
|
|
|
52
52
|
### Issues
|
|
53
53
|
|
|
54
|
-
| Command
|
|
55
|
-
|
|
56
|
-
| `linear issue list`
|
|
57
|
-
| `linear issue view [id]`
|
|
58
|
-
| `linear issue start [id]` | Start working on an issue
|
|
59
|
-
| `linear issue create`
|
|
54
|
+
| Command | Description |
|
|
55
|
+
| ------------------------- | ------------------------------------------------ |
|
|
56
|
+
| `linear issue list` | List your assigned issues |
|
|
57
|
+
| `linear issue view [id]` | View issue details (interactive picker if no ID) |
|
|
58
|
+
| `linear issue start [id]` | Start working on an issue |
|
|
59
|
+
| `linear issue create` | Create a new issue |
|
|
60
60
|
|
|
61
61
|
### Teams
|
|
62
62
|
|
|
63
|
-
| Command
|
|
64
|
-
|
|
63
|
+
| Command | Description |
|
|
64
|
+
| ------------------ | -------------- |
|
|
65
65
|
| `linear team list` | List all teams |
|
|
66
66
|
|
|
67
67
|
## Configuration
|
|
@@ -101,6 +101,7 @@ bun run src/main.ts --help
|
|
|
101
101
|
## Architecture
|
|
102
102
|
|
|
103
103
|
Built with:
|
|
104
|
+
|
|
104
105
|
- **[Bun](https://bun.sh)**: Fast JavaScript runtime with native compilation
|
|
105
106
|
- **[Effect](https://effect.website)**: TypeScript library for type-safe, composable code
|
|
106
107
|
- **[@effect/cli](https://github.com/Effect-TS/effect/tree/main/packages/cli)**: CLI framework with prompts and argument parsing
|
package/bin/linear
ADDED
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,50 +1,57 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cvr/linear",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"repository": {
|
|
5
|
+
"type": "git",
|
|
6
|
+
"url": "https://github.com/cevr/linear-cli.git"
|
|
7
|
+
},
|
|
5
8
|
"bin": {
|
|
6
9
|
"linear": "./bin/linear"
|
|
7
10
|
},
|
|
8
11
|
"files": [
|
|
9
12
|
"src",
|
|
10
|
-
"bin",
|
|
11
13
|
"tsconfig.json"
|
|
12
14
|
],
|
|
15
|
+
"type": "module",
|
|
16
|
+
"publishConfig": {
|
|
17
|
+
"access": "public"
|
|
18
|
+
},
|
|
13
19
|
"scripts": {
|
|
14
20
|
"build": "bun build ./src/main.ts --compile --outfile bin/linear",
|
|
15
21
|
"postinstall": "bun run build",
|
|
16
|
-
"prepublishOnly": "rm -rf bin",
|
|
17
22
|
"test": "vitest run",
|
|
18
23
|
"test:watch": "vitest",
|
|
19
24
|
"link": "ln -sf $(pwd)/bin/linear ~/.local/bin/linear",
|
|
20
|
-
"
|
|
25
|
+
"lint": "oxlint --fix",
|
|
26
|
+
"fmt": "oxfmt",
|
|
27
|
+
"fmt:check": "oxfmt --check",
|
|
28
|
+
"typecheck": "bunx tsc --noEmit",
|
|
29
|
+
"gate": "concurrently -n type,lint,fmt,test -c blue,yellow,magenta,green \"bun run typecheck\" \"bun run lint\" \"bun run fmt\" \"bun run test\"",
|
|
30
|
+
"prepare": "lefthook install",
|
|
21
31
|
"version": "changeset version",
|
|
22
32
|
"release": "changeset publish"
|
|
23
33
|
},
|
|
24
|
-
"publishConfig": {
|
|
25
|
-
"access": "public"
|
|
26
|
-
},
|
|
27
|
-
"repository": {
|
|
28
|
-
"type": "git",
|
|
29
|
-
"url": "https://github.com/cevr/linear-cli.git"
|
|
30
|
-
},
|
|
31
|
-
"engines": {
|
|
32
|
-
"bun": ">=1.0.0"
|
|
33
|
-
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"effect": "^
|
|
36
|
-
"@effect/
|
|
37
|
-
"@effect/platform": "^0.87.
|
|
38
|
-
"@
|
|
39
|
-
"
|
|
35
|
+
"@effect/cli": "^0.73.1",
|
|
36
|
+
"@effect/platform": "^0.94.2",
|
|
37
|
+
"@effect/platform-bun": "^0.87.1",
|
|
38
|
+
"@linear/sdk": "^71.0.0",
|
|
39
|
+
"effect": "^3.19.15"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@changesets/changelog-github": "^0.5.0",
|
|
43
43
|
"@changesets/cli": "^2.27.0",
|
|
44
|
-
"@effect/language-service": "^0.
|
|
44
|
+
"@effect/language-service": "^0.72.0",
|
|
45
45
|
"@effect/vitest": "^0.27.0",
|
|
46
46
|
"@types/bun": "latest",
|
|
47
|
+
"concurrently": "^9.2.1",
|
|
48
|
+
"lefthook": "^2.0.15",
|
|
49
|
+
"oxfmt": "^0.26.0",
|
|
50
|
+
"oxlint": "^1.41.0",
|
|
47
51
|
"typescript": "^5.7.3",
|
|
48
|
-
"vitest": "^
|
|
52
|
+
"vitest": "^4.0.18"
|
|
53
|
+
},
|
|
54
|
+
"engines": {
|
|
55
|
+
"bun": ">=1.0.0"
|
|
49
56
|
}
|
|
50
57
|
}
|
package/src/commands/auth.ts
CHANGED
|
@@ -1,69 +1,71 @@
|
|
|
1
|
-
import { Command } from "@effect/cli"
|
|
2
|
-
import { Console, Effect } from "effect"
|
|
3
|
-
import { ConfigService } from "../services/Config.js"
|
|
4
|
-
import { LinearService } from "../services/Linear.js"
|
|
5
|
-
import { BrowserService } from "../services/Browser.js"
|
|
6
|
-
import { StdinService } from "../services/Stdin.js"
|
|
1
|
+
import { Command } from "@effect/cli";
|
|
2
|
+
import { Console, Effect } from "effect";
|
|
3
|
+
import { ConfigService } from "../services/Config.js";
|
|
4
|
+
import { LinearService } from "../services/Linear.js";
|
|
5
|
+
import { BrowserService } from "../services/Browser.js";
|
|
6
|
+
import { StdinService } from "../services/Stdin.js";
|
|
7
7
|
|
|
8
|
-
const LINEAR_API_KEY_URL = "https://linear.app/settings/account/security"
|
|
8
|
+
const LINEAR_API_KEY_URL = "https://linear.app/settings/account/security";
|
|
9
9
|
|
|
10
10
|
// linear auth - Interactive authentication flow
|
|
11
11
|
export const authCommand = Command.make("auth", {}, () =>
|
|
12
12
|
Effect.gen(function* () {
|
|
13
|
-
const browser = yield* BrowserService
|
|
14
|
-
const config = yield* ConfigService
|
|
15
|
-
const stdin = yield* StdinService
|
|
13
|
+
const browser = yield* BrowserService;
|
|
14
|
+
const config = yield* ConfigService;
|
|
15
|
+
const stdin = yield* StdinService;
|
|
16
16
|
|
|
17
|
-
yield* Console.log(`\nTo authenticate, you'll need a Linear API key.`)
|
|
18
|
-
yield* Console.log(`Opening: ${LINEAR_API_KEY_URL}\n`)
|
|
17
|
+
yield* Console.log(`\nTo authenticate, you'll need a Linear API key.`);
|
|
18
|
+
yield* Console.log(`Opening: ${LINEAR_API_KEY_URL}\n`);
|
|
19
19
|
|
|
20
20
|
// Open browser
|
|
21
|
-
yield* browser
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
21
|
+
yield* browser
|
|
22
|
+
.open(LINEAR_API_KEY_URL)
|
|
23
|
+
.pipe(
|
|
24
|
+
Effect.catchAll(() =>
|
|
25
|
+
Console.log(`Could not open browser. Please visit the URL manually.`),
|
|
26
|
+
),
|
|
27
|
+
);
|
|
26
28
|
|
|
27
29
|
// Simple prompt using readline
|
|
28
|
-
const token = yield* stdin.readLine("Paste your API key: ")
|
|
30
|
+
const token = yield* stdin.readLine("Paste your API key: ");
|
|
29
31
|
|
|
30
32
|
// Validate token by making an API call
|
|
31
|
-
yield* Console.log("\nValidating token...")
|
|
33
|
+
yield* Console.log("\nValidating token...");
|
|
32
34
|
|
|
33
35
|
// Save token first so LinearService can use it
|
|
34
|
-
yield* config.saveToken(token)
|
|
36
|
+
yield* config.saveToken(token);
|
|
35
37
|
|
|
36
38
|
// Now validate with the saved token
|
|
37
|
-
const linear = yield* LinearService
|
|
39
|
+
const linear = yield* LinearService;
|
|
38
40
|
const viewer = yield* linear.getViewer.pipe(
|
|
39
41
|
Effect.catchTag("InvalidTokenError", (e) =>
|
|
40
42
|
Effect.gen(function* () {
|
|
41
|
-
yield* Console.error(`\nError: ${e.message}`)
|
|
42
|
-
yield* Console.error("Please try again with a valid API key.")
|
|
43
|
-
return yield* Effect.die(e)
|
|
44
|
-
})
|
|
45
|
-
)
|
|
46
|
-
)
|
|
43
|
+
yield* Console.error(`\nError: ${e.message}`);
|
|
44
|
+
yield* Console.error("Please try again with a valid API key.");
|
|
45
|
+
return yield* Effect.die(e);
|
|
46
|
+
}),
|
|
47
|
+
),
|
|
48
|
+
);
|
|
47
49
|
|
|
48
|
-
yield* Console.log(`\nAuthenticated as ${viewer.name} (${viewer.email})`)
|
|
49
|
-
})
|
|
50
|
-
)
|
|
50
|
+
yield* Console.log(`\nAuthenticated as ${viewer.name} (${viewer.email})`);
|
|
51
|
+
}),
|
|
52
|
+
);
|
|
51
53
|
|
|
52
54
|
// linear auth whoami - Show current user
|
|
53
55
|
export const whoamiCommand = Command.make("whoami", {}, () =>
|
|
54
56
|
Effect.gen(function* () {
|
|
55
|
-
const linear = yield* LinearService
|
|
56
|
-
const viewer = yield* linear.getViewer
|
|
57
|
+
const linear = yield* LinearService;
|
|
58
|
+
const viewer = yield* linear.getViewer;
|
|
57
59
|
|
|
58
|
-
yield* Console.log(`\nLogged in as:`)
|
|
59
|
-
yield* Console.log(` Name: ${viewer.name}`)
|
|
60
|
-
yield* Console.log(` Email: ${viewer.email}`)
|
|
61
|
-
yield* Console.log(` Admin: ${viewer.admin ? "Yes" : "No"}`)
|
|
60
|
+
yield* Console.log(`\nLogged in as:`);
|
|
61
|
+
yield* Console.log(` Name: ${viewer.name}`);
|
|
62
|
+
yield* Console.log(` Email: ${viewer.email}`);
|
|
63
|
+
yield* Console.log(` Admin: ${viewer.admin ? "Yes" : "No"}`);
|
|
62
64
|
if (viewer.statusLabel) {
|
|
63
|
-
yield* Console.log(` Status: ${viewer.statusEmoji ?? ""} ${viewer.statusLabel}`)
|
|
65
|
+
yield* Console.log(` Status: ${viewer.statusEmoji ?? ""} ${viewer.statusLabel}`);
|
|
64
66
|
}
|
|
65
|
-
})
|
|
66
|
-
)
|
|
67
|
+
}),
|
|
68
|
+
);
|
|
67
69
|
|
|
68
70
|
// Combined auth command with subcommands
|
|
69
|
-
export const auth = authCommand.pipe(Command.withSubcommands([whoamiCommand]))
|
|
71
|
+
export const auth = authCommand.pipe(Command.withSubcommands([whoamiCommand]));
|