Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.DS_Store
.DS_Store
.env
279 changes: 279 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"dependencies": {
"@linear/sdk": "^75.0.0",
"dotenv": "^17.3.1"
},
"devDependencies": {
"@types/node": "^25.2.3",
"ts-node": "^10.9.2",
"typescript": "^5.9.3"
},
"scripts": {
"me": "ts-node --compiler-options '{\"module\":\"CommonJS\"}' src/linear-cli/me.ts",
"my-issues": "ts-node --compiler-options '{\"module\":\"CommonJS\"}' src/linear-cli/myIssues.ts"
}
}
15 changes: 15 additions & 0 deletions src/linear-cli/linearClient.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import * as dotenv from "dotenv";
import * as path from "path";
import { LinearClient } from "@linear/sdk";

// Load .env from repository root regardless of script subdirectory.
dotenv.config({ path: path.resolve(process.cwd(), ".env") });

export function getLinearClient(): LinearClient {
const apiKey = (process.env.LINEAR_API_KEY ?? "").trim();
if (!apiKey) {
throw new Error("Missing or empty LINEAR_API_KEY (check .env)");
}

return new LinearClient({ apiKey });
}
26 changes: 26 additions & 0 deletions src/linear-cli/me.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/**
* me.ts
* --------------
* Quick use of API to obtain name of user, e.g., whoami
* Co-generated Craig Lewis & Chatgpt\
*
* Usage:
* npx ts-node src/me.ts
*
* Requires Linear API key in .env file
*
*/

import { getLinearClient } from "./linearClient";

async function main() {
const client = getLinearClient(); // construct AFTER validation

const me = await client.viewer;
console.log({ id: me.id, name: me.name, email: me.email });
}

main().catch((e) => {
console.error(e);
process.exit(1);
});
Loading