@bdsqqq/lnr-core 0.1.0 → 1.1.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/package.json CHANGED
@@ -1,11 +1,17 @@
1
1
  {
2
2
  "name": "@bdsqqq/lnr-core",
3
- "version": "0.1.0",
4
- "description": "core business logic for linear-cli",
3
+ "version": "1.1.1",
4
+ "description": "core business logic for lnr",
5
5
  "type": "module",
6
6
  "private": false,
7
7
  "main": "src/index.ts",
8
8
  "types": "src/index.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./src/index.ts",
12
+ "import": "./src/index.ts"
13
+ }
14
+ },
9
15
  "files": [
10
16
  "src"
11
17
  ],
package/src/config.ts CHANGED
@@ -8,7 +8,7 @@ export interface Config {
8
8
  output_format?: "table" | "json" | "quiet";
9
9
  }
10
10
 
11
- const CONFIG_DIR = join(homedir(), ".linear-cli");
11
+ const CONFIG_DIR = join(homedir(), ".lnr");
12
12
  const CONFIG_PATH = join(CONFIG_DIR, "config.json");
13
13
 
14
14
  export function ensureConfigDir(): void {
@@ -1,37 +1,7 @@
1
- import { describe, test, expect, beforeAll } from "bun:test";
2
- import { LinearClient } from "@linear/sdk";
3
- import { getApiKey } from "./config";
4
- import { listIssues, getIssue, createIssue, priorityFromString } from "./issues";
5
-
6
- const TEST_PREFIX = "[TEST-CLI]";
7
-
8
- function getTestClient(): LinearClient {
9
- const apiKey = getApiKey();
10
- if (!apiKey) {
11
- throw new Error("no api key configured - run: li auth <api-key>");
12
- }
13
- return new LinearClient({ apiKey });
14
- }
15
-
16
- async function getFirstTeamKey(): Promise<string> {
17
- const client = getTestClient();
18
- const teams = await client.teams();
19
- const bdsq = teams.nodes.find((t) => t.key === "BDSQ");
20
- if (bdsq) return bdsq.key;
21
- const first = teams.nodes[0];
22
- if (!first) throw new Error("no teams found");
23
- return first.key;
24
- }
25
-
26
- describe("issues core", () => {
27
- let client: LinearClient;
28
- let teamKey: string;
29
-
30
- beforeAll(async () => {
31
- client = getTestClient();
32
- teamKey = await getFirstTeamKey();
33
- });
1
+ import { describe, test, expect } from "bun:test";
2
+ import { priorityFromString } from "./issues";
34
3
 
4
+ describe("issues utilities", () => {
35
5
  test("priorityFromString converts priority names", () => {
36
6
  expect(priorityFromString("urgent")).toBe(1);
37
7
  expect(priorityFromString("high")).toBe(2);
@@ -41,26 +11,9 @@ describe("issues core", () => {
41
11
  expect(priorityFromString("unknown")).toBe(0);
42
12
  });
43
13
 
44
- test("listIssues returns issue array", async () => {
45
- const issues = await listIssues(client);
46
- expect(Array.isArray(issues)).toBe(true);
47
- if (issues.length > 0) {
48
- expect(issues[0]).toHaveProperty("id");
49
- expect(issues[0]).toHaveProperty("identifier");
50
- expect(issues[0]).toHaveProperty("title");
51
- }
52
- });
53
-
54
- test("listIssues filters by team", async () => {
55
- const issues = await listIssues(client, { team: teamKey });
56
- expect(Array.isArray(issues)).toBe(true);
57
- for (const issue of issues) {
58
- expect(issue.identifier.startsWith(teamKey + "-")).toBe(true);
59
- }
60
- });
61
-
62
- test("getIssue returns null for nonexistent issue", async () => {
63
- const issue = await getIssue(client, "NONEXISTENT-99999");
64
- expect(issue).toBeNull();
14
+ test("priorityFromString is case-insensitive", () => {
15
+ expect(priorityFromString("URGENT")).toBe(1);
16
+ expect(priorityFromString("High")).toBe(2);
17
+ expect(priorityFromString("MeDiUm")).toBe(3);
65
18
  });
66
19
  });
@@ -1,45 +0,0 @@
1
- import { describe, test, expect, beforeAll } from "bun:test";
2
- import { LinearClient } from "@linear/sdk";
3
- import { getApiKey } from "./config";
4
- import { listCycles, getCurrentCycle } from "./cycles";
5
- import { getAvailableTeamKeys } from "./teams";
6
-
7
- function getTestClient(): LinearClient {
8
- const apiKey = getApiKey();
9
- if (!apiKey) {
10
- throw new Error("no api key configured - run: li auth <api-key>");
11
- }
12
- return new LinearClient({ apiKey });
13
- }
14
-
15
- describe("cycles core", () => {
16
- let client: LinearClient;
17
- let teamKey: string;
18
-
19
- beforeAll(async () => {
20
- client = getTestClient();
21
- const keys = await getAvailableTeamKeys(client);
22
- teamKey = keys.includes("BDSQ") ? "BDSQ" : keys[0] ?? "UNKNOWN";
23
- });
24
-
25
- test("listCycles returns cycle array", async () => {
26
- const cycles = await listCycles(client, teamKey);
27
- expect(Array.isArray(cycles)).toBe(true);
28
- if (cycles.length > 0) {
29
- expect(cycles[0]).toHaveProperty("id");
30
- expect(cycles[0]).toHaveProperty("number");
31
- expect(cycles[0]).toHaveProperty("startsAt");
32
- expect(cycles[0]).toHaveProperty("endsAt");
33
- }
34
- });
35
-
36
- test("listCycles returns empty for invalid team", async () => {
37
- const cycles = await listCycles(client, "INVALID_KEY_XYZ");
38
- expect(cycles).toEqual([]);
39
- });
40
-
41
- test("getCurrentCycle returns null for invalid team", async () => {
42
- const cycle = await getCurrentCycle(client, "INVALID_KEY_XYZ");
43
- expect(cycle).toBeNull();
44
- });
45
- });
package/src/me.test.ts DELETED
@@ -1,49 +0,0 @@
1
- import { describe, test, expect, beforeAll } from "bun:test";
2
- import { LinearClient } from "@linear/sdk";
3
- import { getApiKey } from "./config";
4
- import { getViewer, getMyIssues, getMyCreatedIssues } from "./me";
5
-
6
- function getTestClient(): LinearClient {
7
- const apiKey = getApiKey();
8
- if (!apiKey) {
9
- throw new Error("no api key configured - run: li auth <api-key>");
10
- }
11
- return new LinearClient({ apiKey });
12
- }
13
-
14
- describe("me core", () => {
15
- let client: LinearClient;
16
-
17
- beforeAll(() => {
18
- client = getTestClient();
19
- });
20
-
21
- test("getViewer returns current user", async () => {
22
- const viewer = await getViewer(client);
23
- expect(viewer).toHaveProperty("id");
24
- expect(viewer).toHaveProperty("name");
25
- expect(viewer).toHaveProperty("email");
26
- expect(viewer).toHaveProperty("active");
27
- expect(viewer).toHaveProperty("admin");
28
- });
29
-
30
- test("getMyIssues returns issue array", async () => {
31
- const issues = await getMyIssues(client);
32
- expect(Array.isArray(issues)).toBe(true);
33
- if (issues.length > 0) {
34
- expect(issues[0]).toHaveProperty("id");
35
- expect(issues[0]).toHaveProperty("identifier");
36
- expect(issues[0]).toHaveProperty("title");
37
- }
38
- });
39
-
40
- test("getMyCreatedIssues returns issue array", async () => {
41
- const issues = await getMyCreatedIssues(client);
42
- expect(Array.isArray(issues)).toBe(true);
43
- if (issues.length > 0) {
44
- expect(issues[0]).toHaveProperty("id");
45
- expect(issues[0]).toHaveProperty("identifier");
46
- expect(issues[0]).toHaveProperty("title");
47
- }
48
- });
49
- });
@@ -1,42 +0,0 @@
1
- import { describe, test, expect, beforeAll } from "bun:test";
2
- import { LinearClient } from "@linear/sdk";
3
- import { getApiKey } from "./config";
4
- import { listProjects, getProject, createProject, deleteProject } from "./projects";
5
-
6
- const TEST_PREFIX = "[TEST-CLI]";
7
-
8
- function getTestClient(): LinearClient {
9
- const apiKey = getApiKey();
10
- if (!apiKey) {
11
- throw new Error("no api key configured - run: li auth <api-key>");
12
- }
13
- return new LinearClient({ apiKey });
14
- }
15
-
16
- describe("projects core", () => {
17
- let client: LinearClient;
18
-
19
- beforeAll(() => {
20
- client = getTestClient();
21
- });
22
-
23
- test("listProjects returns project array", async () => {
24
- const projects = await listProjects(client);
25
- expect(Array.isArray(projects)).toBe(true);
26
- if (projects.length > 0) {
27
- expect(projects[0]).toHaveProperty("id");
28
- expect(projects[0]).toHaveProperty("name");
29
- expect(projects[0]).toHaveProperty("state");
30
- }
31
- });
32
-
33
- test("getProject returns null for nonexistent project", async () => {
34
- const project = await getProject(client, "NONEXISTENT_PROJECT_XYZ_123");
35
- expect(project).toBeNull();
36
- });
37
-
38
- test("deleteProject returns false for nonexistent project", async () => {
39
- const result = await deleteProject(client, "NONEXISTENT_PROJECT_XYZ_123");
40
- expect(result).toBe(false);
41
- });
42
- });
@@ -1,38 +0,0 @@
1
- import { describe, test, expect, beforeAll } from "bun:test";
2
- import { LinearClient } from "@linear/sdk";
3
- import { getApiKey } from "./config";
4
- import { searchIssues } from "./search";
5
-
6
- function getTestClient(): LinearClient {
7
- const apiKey = getApiKey();
8
- if (!apiKey) {
9
- throw new Error("no api key configured - run: li auth <api-key>");
10
- }
11
- return new LinearClient({ apiKey });
12
- }
13
-
14
- describe("search core", () => {
15
- let client: LinearClient;
16
-
17
- beforeAll(() => {
18
- client = getTestClient();
19
- });
20
-
21
- test("searchIssues returns issue array", async () => {
22
- const issues = await searchIssues(client, "issue");
23
- expect(Array.isArray(issues)).toBe(true);
24
- if (issues.length > 0) {
25
- expect(issues[0]).toHaveProperty("id");
26
- expect(issues[0]).toHaveProperty("identifier");
27
- expect(issues[0]).toHaveProperty("title");
28
- }
29
- });
30
-
31
- test("searchIssues filters by team", async () => {
32
- const issues = await searchIssues(client, "issue", { team: "BDSQ" });
33
- expect(Array.isArray(issues)).toBe(true);
34
- for (const issue of issues) {
35
- expect(issue.identifier.startsWith("BDSQ-")).toBe(true);
36
- }
37
- });
38
- });
package/src/teams.test.ts DELETED
@@ -1,60 +0,0 @@
1
- import { describe, test, expect, beforeAll } from "bun:test";
2
- import { LinearClient } from "@linear/sdk";
3
- import { getApiKey } from "./config";
4
- import { listTeams, getTeam, getTeamMembers, getAvailableTeamKeys } from "./teams";
5
-
6
- function getTestClient(): LinearClient {
7
- const apiKey = getApiKey();
8
- if (!apiKey) {
9
- throw new Error("no api key configured - run: li auth <api-key>");
10
- }
11
- return new LinearClient({ apiKey });
12
- }
13
-
14
- describe("teams core", () => {
15
- let client: LinearClient;
16
- let teamKey: string;
17
-
18
- beforeAll(async () => {
19
- client = getTestClient();
20
- const keys = await getAvailableTeamKeys(client);
21
- teamKey = keys.includes("BDSQ") ? "BDSQ" : keys[0] ?? "UNKNOWN";
22
- });
23
-
24
- test("listTeams returns team array", async () => {
25
- const teams = await listTeams(client);
26
- expect(Array.isArray(teams)).toBe(true);
27
- expect(teams.length).toBeGreaterThan(0);
28
- expect(teams[0]).toHaveProperty("id");
29
- expect(teams[0]).toHaveProperty("key");
30
- expect(teams[0]).toHaveProperty("name");
31
- });
32
-
33
- test("getTeam returns team by key", async () => {
34
- const team = await getTeam(client, teamKey);
35
- expect(team).not.toBeNull();
36
- expect(team?.key).toBe(teamKey);
37
- });
38
-
39
- test("getTeam returns null for invalid key", async () => {
40
- const team = await getTeam(client, "INVALID_KEY_XYZ");
41
- expect(team).toBeNull();
42
- });
43
-
44
- test("getTeamMembers returns members array", async () => {
45
- const members = await getTeamMembers(client, teamKey);
46
- expect(Array.isArray(members)).toBe(true);
47
- if (members.length > 0) {
48
- expect(members[0]).toHaveProperty("id");
49
- expect(members[0]).toHaveProperty("name");
50
- expect(members[0]).toHaveProperty("email");
51
- }
52
- });
53
-
54
- test("getAvailableTeamKeys returns string array", async () => {
55
- const keys = await getAvailableTeamKeys(client);
56
- expect(Array.isArray(keys)).toBe(true);
57
- expect(keys.length).toBeGreaterThan(0);
58
- expect(typeof keys[0]).toBe("string");
59
- });
60
- });