linear-github-cli 1.2.1 → 1.3.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.
Files changed (2) hide show
  1. package/dist/env-utils.js +25 -3
  2. package/package.json +1 -1
package/dist/env-utils.js CHANGED
@@ -14,6 +14,22 @@ const os_1 = require("os");
14
14
  * - Installed globally (user can create .env in their project or home directory)
15
15
  * - Installed locally (works with project's .env file)
16
16
  */
17
+ function hasLinearApiKey(envPath) {
18
+ const contents = (0, fs_1.readFileSync)(envPath, 'utf-8');
19
+ const match = contents.match(/^\s*LINEAR_API_KEY\s*=\s*(.+)\s*$/m);
20
+ if (!match) {
21
+ return false;
22
+ }
23
+ const rawValue = match[1].trim();
24
+ const unquoted = rawValue.replace(/^['"]|['"]$/g, '').trim();
25
+ return unquoted.length > 0;
26
+ }
27
+ function exitMissingLinearApiKey() {
28
+ console.error('❌ LINEAR_API_KEY not found in .env');
29
+ console.error(' Add it to your .env file:');
30
+ console.error(' echo "LINEAR_API_KEY=lin_api_..." > .env');
31
+ process.exit(1);
32
+ }
17
33
  function loadEnvFile() {
18
34
  // First, try to find .env in current working directory and parent directories
19
35
  let currentDir = process.cwd();
@@ -21,6 +37,10 @@ function loadEnvFile() {
21
37
  while (currentDir !== root) {
22
38
  const envPath = (0, path_1.resolve)(currentDir, '.env');
23
39
  if ((0, fs_1.existsSync)(envPath)) {
40
+ if (!hasLinearApiKey(envPath)) {
41
+ exitMissingLinearApiKey();
42
+ }
43
+ console.log(`✅ LINEAR_API_KEY found in ${envPath}`);
24
44
  (0, dotenv_1.config)({ path: envPath });
25
45
  return;
26
46
  }
@@ -34,10 +54,12 @@ function loadEnvFile() {
34
54
  // Fallback: try home directory
35
55
  const homeEnvPath = (0, path_1.resolve)((0, os_1.homedir)(), '.env');
36
56
  if ((0, fs_1.existsSync)(homeEnvPath)) {
57
+ if (!hasLinearApiKey(homeEnvPath)) {
58
+ exitMissingLinearApiKey();
59
+ }
60
+ console.log(`✅ LINEAR_API_KEY found in ${homeEnvPath}`);
37
61
  (0, dotenv_1.config)({ path: homeEnvPath });
38
62
  return;
39
63
  }
40
- // If no .env file found, dotenv will use environment variables
41
- // This is fine - we don't need to throw an error here
42
- (0, dotenv_1.config)();
64
+ exitMissingLinearApiKey();
43
65
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "linear-github-cli",
3
- "version": "1.2.1",
3
+ "version": "1.3.0",
4
4
  "description": "CLI tool for creating GitHub issues with Linear integration",
5
5
  "main": "dist/cli.js",
6
6
  "bin": {