jira-ai 0.2.0 → 0.2.2

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.
@@ -76,7 +76,7 @@ async function aboutCommand() {
76
76
  console.log(chalk_1.default.bold('For detailed help on any command, run:'));
77
77
  console.log(chalk_1.default.green(' jira-ai <command> --help\n'));
78
78
  console.log(chalk_1.default.bold('Configuration:'));
79
- console.log(' Settings are managed in settings.yaml');
79
+ console.log(` Settings file: ${chalk_1.default.cyan((0, settings_1.getSettingsPath)())}`);
80
80
  const allowedProjects = (0, settings_1.getAllowedProjects)();
81
81
  console.log(` - Projects: ${allowedProjects.includes('all') ? 'All allowed' : allowedProjects.join(', ')}`);
82
82
  console.log(` - Commands: ${isAllAllowed ? 'All allowed' : allowedCommandsList.join(', ')}\n`);
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getSettingsPath = getSettingsPath;
6
7
  exports.loadSettings = loadSettings;
7
8
  exports.isProjectAllowed = isProjectAllowed;
8
9
  exports.isCommandAllowed = isCommandAllowed;
@@ -11,23 +12,55 @@ exports.getAllowedCommands = getAllowedCommands;
11
12
  exports.__resetCache__ = __resetCache__;
12
13
  const fs_1 = __importDefault(require("fs"));
13
14
  const path_1 = __importDefault(require("path"));
15
+ const os_1 = __importDefault(require("os"));
14
16
  const js_yaml_1 = __importDefault(require("js-yaml"));
17
+ const chalk_1 = __importDefault(require("chalk"));
18
+ const CONFIG_DIR = path_1.default.join(os_1.default.homedir(), '.jira-ai');
19
+ const SETTINGS_FILE = path_1.default.join(CONFIG_DIR, 'settings.yaml');
15
20
  let cachedSettings = null;
21
+ function getSettingsPath() {
22
+ return SETTINGS_FILE;
23
+ }
16
24
  function loadSettings() {
17
25
  if (cachedSettings) {
18
26
  return cachedSettings;
19
27
  }
20
- const settingsPath = path_1.default.join(process.cwd(), 'settings.yaml');
21
- if (!fs_1.default.existsSync(settingsPath)) {
22
- console.warn('Warning: settings.yaml not found. Using default settings (all allowed).');
23
- cachedSettings = {
24
- projects: ['all'],
25
- commands: ['all']
26
- };
27
- return cachedSettings;
28
+ // Ensure config directory exists
29
+ if (!fs_1.default.existsSync(CONFIG_DIR)) {
30
+ fs_1.default.mkdirSync(CONFIG_DIR, { recursive: true });
31
+ }
32
+ if (!fs_1.default.existsSync(SETTINGS_FILE)) {
33
+ // Check if settings.yaml exists in current working directory (migration/backward compatibility)
34
+ const localSettingsPath = path_1.default.join(process.cwd(), 'settings.yaml');
35
+ if (fs_1.default.existsSync(localSettingsPath)) {
36
+ try {
37
+ const fileContents = fs_1.default.readFileSync(localSettingsPath, 'utf8');
38
+ fs_1.default.writeFileSync(SETTINGS_FILE, fileContents);
39
+ console.log(chalk_1.default?.cyan ? chalk_1.default.cyan(`Migrated settings.yaml to ${SETTINGS_FILE}`) : `Migrated settings.yaml to ${SETTINGS_FILE}`);
40
+ }
41
+ catch (error) {
42
+ console.error('Error migrating settings.yaml:', error);
43
+ }
44
+ }
45
+ else {
46
+ // Create default settings.yaml if it doesn't exist anywhere
47
+ const defaultSettings = {
48
+ projects: ['all'],
49
+ commands: ['all']
50
+ };
51
+ try {
52
+ const yamlStr = js_yaml_1.default.dump(defaultSettings);
53
+ fs_1.default.writeFileSync(SETTINGS_FILE, yamlStr);
54
+ }
55
+ catch (error) {
56
+ console.error('Error creating default settings.yaml:', error);
57
+ }
58
+ cachedSettings = defaultSettings;
59
+ return cachedSettings;
60
+ }
28
61
  }
29
62
  try {
30
- const fileContents = fs_1.default.readFileSync(settingsPath, 'utf8');
63
+ const fileContents = fs_1.default.readFileSync(SETTINGS_FILE, 'utf8');
31
64
  const settings = js_yaml_1.default.load(fileContents);
32
65
  cachedSettings = {
33
66
  projects: settings.projects || ['all'],
@@ -36,7 +69,7 @@ function loadSettings() {
36
69
  return cachedSettings;
37
70
  }
38
71
  catch (error) {
39
- console.error('Error loading settings.yaml:', error);
72
+ console.error(`Error loading ${SETTINGS_FILE}:`, error);
40
73
  process.exit(1);
41
74
  }
42
75
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jira-ai",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "CLI tool for interacting with Atlassian Jira",
5
5
  "main": "dist/cli.js",
6
6
  "bin": {
@@ -1,5 +1,5 @@
1
1
  import chalk from 'chalk';
2
- import { getAllowedCommands, getAllowedProjects, isCommandAllowed } from '../lib/settings';
2
+ import { getAllowedCommands, getAllowedProjects, isCommandAllowed, getSettingsPath } from '../lib/settings';
3
3
 
4
4
  interface CommandInfo {
5
5
  name: string;
@@ -91,7 +91,7 @@ export async function aboutCommand() {
91
91
  console.log(chalk.green(' jira-ai <command> --help\n'));
92
92
 
93
93
  console.log(chalk.bold('Configuration:'));
94
- console.log(' Settings are managed in settings.yaml');
94
+ console.log(` Settings file: ${chalk.cyan(getSettingsPath())}`);
95
95
  const allowedProjects = getAllowedProjects();
96
96
  console.log(` - Projects: ${allowedProjects.includes('all') ? 'All allowed' : allowedProjects.join(', ')}`);
97
97
  console.log(` - Commands: ${isAllAllowed ? 'All allowed' : allowedCommandsList.join(', ')}\n`);
@@ -1,32 +1,64 @@
1
1
  import fs from 'fs';
2
2
  import path from 'path';
3
+ import os from 'os';
3
4
  import yaml from 'js-yaml';
5
+ import chalk from 'chalk';
4
6
 
5
7
  export interface Settings {
6
8
  projects: string[];
7
9
  commands: string[];
8
10
  }
9
11
 
12
+ const CONFIG_DIR = path.join(os.homedir(), '.jira-ai');
13
+ const SETTINGS_FILE = path.join(CONFIG_DIR, 'settings.yaml');
14
+
10
15
  let cachedSettings: Settings | null = null;
11
16
 
17
+ export function getSettingsPath(): string {
18
+ return SETTINGS_FILE;
19
+ }
20
+
12
21
  export function loadSettings(): Settings {
13
22
  if (cachedSettings) {
14
23
  return cachedSettings;
15
24
  }
16
25
 
17
- const settingsPath = path.join(process.cwd(), 'settings.yaml');
26
+ // Ensure config directory exists
27
+ if (!fs.existsSync(CONFIG_DIR)) {
28
+ fs.mkdirSync(CONFIG_DIR, { recursive: true });
29
+ }
18
30
 
19
- if (!fs.existsSync(settingsPath)) {
20
- console.warn('Warning: settings.yaml not found. Using default settings (all allowed).');
21
- cachedSettings = {
22
- projects: ['all'],
23
- commands: ['all']
24
- };
25
- return cachedSettings;
31
+ if (!fs.existsSync(SETTINGS_FILE)) {
32
+ // Check if settings.yaml exists in current working directory (migration/backward compatibility)
33
+ const localSettingsPath = path.join(process.cwd(), 'settings.yaml');
34
+ if (fs.existsSync(localSettingsPath)) {
35
+ try {
36
+ const fileContents = fs.readFileSync(localSettingsPath, 'utf8');
37
+ fs.writeFileSync(SETTINGS_FILE, fileContents);
38
+ console.log(chalk?.cyan ? chalk.cyan(`Migrated settings.yaml to ${SETTINGS_FILE}`) : `Migrated settings.yaml to ${SETTINGS_FILE}`);
39
+ } catch (error) {
40
+ console.error('Error migrating settings.yaml:', error);
41
+ }
42
+ } else {
43
+ // Create default settings.yaml if it doesn't exist anywhere
44
+ const defaultSettings: Settings = {
45
+ projects: ['all'],
46
+ commands: ['all']
47
+ };
48
+ try {
49
+ const yamlStr = yaml.dump(defaultSettings);
50
+ fs.writeFileSync(SETTINGS_FILE, yamlStr);
51
+ } catch (error) {
52
+ console.error('Error creating default settings.yaml:', error);
53
+ }
54
+
55
+ cachedSettings = defaultSettings;
56
+ return cachedSettings;
57
+ }
26
58
  }
27
59
 
28
60
  try {
29
- const fileContents = fs.readFileSync(settingsPath, 'utf8');
61
+ const fileContents = fs.readFileSync(SETTINGS_FILE, 'utf8');
30
62
  const settings = yaml.load(fileContents) as Settings;
31
63
 
32
64
  cachedSettings = {
@@ -36,7 +68,7 @@ export function loadSettings(): Settings {
36
68
 
37
69
  return cachedSettings;
38
70
  } catch (error) {
39
- console.error('Error loading settings.yaml:', error);
71
+ console.error(`Error loading ${SETTINGS_FILE}:`, error);
40
72
  process.exit(1);
41
73
  }
42
74
  }