bjira 0.0.13 → 0.0.14

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,6 +1,6 @@
1
1
  {
2
2
  "name": "bjira",
3
- "version": "0.0.13",
3
+ "version": "0.0.14",
4
4
  "description": "A simple jira CLI tool",
5
5
  "main": "src/index.js",
6
6
  "author": {
package/src/create.js CHANGED
@@ -54,15 +54,15 @@ class Create extends Command {
54
54
 
55
55
  if (issueType.name !== 'Epic' &&
56
56
  await Ask.askBoolean('Do you want to set a parent epic?')) {
57
- const epics = await Query.runQuery(jira, `project = "${project.key}" and type = "epic"`);
58
- if (!epics || epics.length === 0) {
57
+ const result = await Query.runQuery(jira, `project = "${project.key}" and type = "epic"`, 999999);
58
+ if (!result.issues || result.issues.length === 0) {
59
59
  console.log("No epics yet.");
60
60
  } else {
61
61
  const resultFields = await Field.listFields(jira);
62
- epics.forEach(epic => Issue.replaceFields(epic, resultFields));
62
+ result.issues.forEach(epic => Issue.replaceFields(epic, resultFields));
63
63
 
64
64
  const parentKey = await Ask.askList('Choose the epic:',
65
- epics.map(epic => ({
65
+ result.issues.map(epic => ({
66
66
  name: `${epic.key} - ${epic.fields['Summary']}`,
67
67
  value: epic.key
68
68
  })));
package/src/query.js CHANGED
@@ -9,6 +9,8 @@ import Issue from './issue.js';
9
9
  import Jira from './jira.js';
10
10
  import Table from './table.js';
11
11
 
12
+ import color from 'chalk';
13
+
12
14
  const DEFAULT_QUERY_LIMIT = 20;
13
15
 
14
16
  class Query extends Command {
@@ -24,13 +26,15 @@ class Query extends Command {
24
26
  const opts = cmd.opts();
25
27
 
26
28
  const resultFields = await Field.listFields(jira);
27
- const issues = await Query.runQuery(jira, query, opts.limit);
29
+ const result = await Query.runQuery(jira, query, opts.limit);
28
30
 
29
- Query.showIssues(jira, issues, resultFields);
31
+ Query.showIssues(jira, result.issues, result.total, resultFields);
30
32
  });
31
33
  }
32
34
 
33
- static showIssues(jira, issues, fields) {
35
+ static showIssues(jira, issues, total, fields) {
36
+ console.log(`Showing ${color.bold(issues.length)} issues of ${color.bold(total)}`);
37
+
34
38
  const table = new Table({
35
39
  head: ['Key', 'Status', 'Type', 'Assignee', 'Summary']
36
40
  });
@@ -56,6 +60,7 @@ class Query extends Command {
56
60
 
57
61
  static async runQuery(jira, query, expectedResult) {
58
62
  let issues = [];
63
+ let total = 0;
59
64
  while (issues.length < (expectedResult === undefined ? issues.length + 1 : expectedResult)) {
60
65
  const result = await jira.spin('Running query...',
61
66
  jira.api.searchJira(query, {
@@ -68,10 +73,16 @@ class Query extends Command {
68
73
  return;
69
74
  }
70
75
 
76
+ total = result.total;
71
77
  issues = issues.concat(result.issues);
72
- if (issues.length >= result.total) break;
78
+
79
+ if (issues.length >= total) break;
73
80
  }
74
- return issues;
81
+
82
+ return {
83
+ total,
84
+ issues
85
+ };
75
86
  }
76
87
  };
77
88
 
package/src/run.js CHANGED
@@ -44,9 +44,9 @@ class Run extends Command {
44
44
  }
45
45
 
46
46
  const resultFields = await Field.listFields(jira);
47
- const issues = await Query.runQuery(jira, query, opts.limit);
47
+ const result = await Query.runQuery(jira, query, opts.limit);
48
48
 
49
- Query.showIssues(jira, issues, resultFields);
49
+ Query.showIssues(jira, result.issues, result.total, resultFields);
50
50
  });
51
51
  }
52
52