jira-ai 0.3.17 → 0.3.18

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/cli.js +36 -3
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -20,6 +20,7 @@ import { authCommand } from './commands/auth.js';
20
20
  import { listOrganizations, useOrganizationCommand, removeOrganizationCommand } from './commands/organization.js';
21
21
  import { isCommandAllowed, getAllowedCommands } from './lib/settings.js';
22
22
  import { setOrganizationOverride } from './lib/jira-client.js';
23
+ import { hasCredentials } from './lib/auth-storage.js';
23
24
  import { CliError } from './types/errors.js';
24
25
  import { CommandError } from './lib/errors.js';
25
26
  import { ui } from './lib/ui.js';
@@ -31,7 +32,7 @@ const program = new Command();
31
32
  program
32
33
  .name('jira-ai')
33
34
  .description('CLI tool for interacting with Atlassian Jira')
34
- .version('0.3.17')
35
+ .version('0.3.18')
35
36
  .option('-o, --organization <alias>', 'Override the active Jira organization');
36
37
  // Hook to handle the global option before any command runs
37
38
  program.on('option:organization', (alias) => {
@@ -201,9 +202,38 @@ program
201
202
  .command('about')
202
203
  .description('Show information about the tool')
203
204
  .action(aboutCommand);
205
+ /**
206
+ * Configure command visibility based on auth status and settings
207
+ */
208
+ export function configureCommandVisibility(program) {
209
+ const hasCreds = hasCredentials();
210
+ const envVarsSet = !!(process.env.JIRA_HOST &&
211
+ process.env.JIRA_USER_EMAIL &&
212
+ process.env.JIRA_API_TOKEN);
213
+ const isAuthorized = hasCreds || envVarsSet;
214
+ if (!isAuthorized) {
215
+ program.commands.forEach(cmd => {
216
+ if (cmd.name() !== 'auth' && cmd.name() !== 'about') {
217
+ cmd._hidden = true;
218
+ }
219
+ });
220
+ program.addHelpText('after', `\n${chalk.yellow('You are not authorized. Please use `jira-ai auth` to authorize. Then you can run other commands.')}`);
221
+ }
222
+ else {
223
+ program.commands.forEach(cmd => {
224
+ // auth and about are always visible
225
+ if (cmd.name() !== 'auth' && cmd.name() !== 'about') {
226
+ if (!isCommandAllowed(cmd.name())) {
227
+ cmd._hidden = true;
228
+ }
229
+ }
230
+ });
231
+ }
232
+ }
204
233
  // Parse command line arguments
205
- async function main() {
234
+ export async function main() {
206
235
  try {
236
+ configureCommandVisibility(program);
207
237
  await program.parseAsync(process.argv);
208
238
  }
209
239
  catch (error) {
@@ -236,4 +266,7 @@ async function main() {
236
266
  }
237
267
  }
238
268
  }
239
- main();
269
+ if (process.argv[1]?.endsWith('cli.ts') || process.argv[1]?.endsWith('cli.js')) {
270
+ main();
271
+ }
272
+ export { program };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jira-ai",
3
- "version": "0.3.17",
3
+ "version": "0.3.18",
4
4
  "description": "AI friendly Jira CLI to save context",
5
5
  "type": "module",
6
6
  "main": "dist/cli.js",