@beauraines/toggl-cli 0.10.11 → 0.10.13

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/.eslintrc.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "es2021": true,
5
5
  "node": true
6
6
  },
7
- "extends": "standard",
7
+ "extends": "eslint:recommended",
8
8
  "overrides": [
9
9
  ],
10
10
  "parserOptions": {
@@ -9,3 +9,8 @@ updates:
9
9
  directory: "/" # Location of package manifests
10
10
  schedule:
11
11
  interval: "weekly"
12
+ day: "friday"
13
+ commit-message:
14
+ prefix: fix
15
+ prefix-development: chore
16
+ include: scope
package/CHANGELOG.md CHANGED
@@ -2,6 +2,15 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [0.10.13](https://github.com/beauraines/toggl-cli/compare/v0.10.12...v0.10.13) (2023-04-01)
6
+
7
+
8
+ ### Features
9
+
10
+ * Improve table layout ([4652fc3](https://github.com/beauraines/toggl-cli/commit/4652fc3f5e54ca6f0031dfcc035746147b028a5d)), closes [#56](https://github.com/beauraines/toggl-cli/issues/56)
11
+
12
+ ### [0.10.12](https://github.com/beauraines/toggl-cli/compare/v0.10.11...v0.10.12) (2023-03-23)
13
+
5
14
  ### [0.10.11](https://github.com/beauraines/toggl-cli/compare/v0.10.10...v0.10.11) (2023-03-19)
6
15
 
7
16
 
package/cmds/continue.mjs CHANGED
@@ -24,12 +24,13 @@ export const handler = async function (argv) {
24
24
  }
25
25
  ) // Gets time entries for last 14 days, up to 1000 entries
26
26
 
27
- timeEntries.sort((a, b) => dayjs(a.start).toDate() - dayjs(b.start).toDate())
27
+ // Sort to guarantee its most recent to oldest)
28
+ timeEntries.sort((a, b) => dayjs(b.start).toDate() - dayjs(a.start).toDate())
28
29
 
29
30
  let matchingTimeEntry
30
31
  switch (argv.description) {
31
32
  case undefined:
32
- matchingTimeEntry = timeEntries.slice(-1)[0]
33
+ matchingTimeEntry = timeEntries[0]
33
34
  break
34
35
  default:
35
36
  { const searchName = argv.description.toLowerCase()
package/cmds/ls.mjs CHANGED
@@ -40,11 +40,23 @@ export const handler = async function (argv) {
40
40
  })
41
41
 
42
42
  const table = new Table({
43
- head: ['description', 'start', 'stop', 'duration']
43
+ head: ['Description', 'Start', 'Stop', 'Duration'],
44
+ chars: { mid: '', 'left-mid': '', 'mid-mid': '', 'right-mid': '' }
44
45
  })
45
- for (const entry of report) {
46
- table.push([entry.description, entry.start, entry.stop, entry.duration])
46
+ for (let i = 0; i < report.length; i++) {
47
+ // First row chars
48
+ const chars = {
49
+ midMid: '┼',
50
+ mid: '─',
51
+ leftMid: '├',
52
+ rightMid: '┤'
53
+ }
54
+ const entry = report[i]
55
+ if (i === 0) {
56
+ table.push([entry.description, entry.start, entry.stop, entry.duration].map((content) => ({ content, chars })))
57
+ } else {
58
+ table.push([entry.description, entry.start, entry.stop, entry.duration])
59
+ }
47
60
  }
48
61
  console.log(table.toString())
49
- // console.table(report, ['description', 'start', 'stop', 'duration'])
50
62
  }
package/cmds/today.mjs CHANGED
@@ -1,4 +1,5 @@
1
1
  import Client from '../client.js'
2
+ import chalk from 'chalk'
2
3
  import dayjs from 'dayjs'
3
4
  import { getWorkspace, getProjects, formatDuration, formatDurationAsTime } from '../utils.js'
4
5
  import dur from 'dayjs/plugin/duration.js'
@@ -79,10 +80,25 @@ function displayDailyReport (report, format) {
79
80
  case 'table':
80
81
  default:
81
82
  const table = new Table({
82
- head: ['Project', 'Duration']
83
+ head: ['Project', 'Duration'],
84
+ chars: { mid: '', 'left-mid': '', 'mid-mid': '', 'right-mid': '' }
83
85
  })
84
- for (const project of report) {
85
- table.push([project.project_name, project.duration_formatted])
86
+ for (let i = 0; i < report.length; i++) {
87
+ // First row chars
88
+ const chars = {
89
+ midMid: '┼',
90
+ mid: '─',
91
+ leftMid: '├',
92
+ rightMid: '┤'
93
+ }
94
+ const project = report[i]
95
+ if (i == 0) {
96
+ table.push([project.project_name, project.duration_formatted].map((content) => ({ content: chalk.grey(content), chars })))
97
+ } else if ( i == report.length - 1) {
98
+ table.push([project.project_name, project.duration_formatted].map((content) => ( {content: chalk.bold(content), chars })))
99
+ } else {
100
+ table.push([chalk.grey(project.project_name), chalk.grey(project.duration_formatted)])
101
+ }
86
102
  }
87
103
  console.log(table.toString())
88
104
  break
package/cmds/weekly.mjs CHANGED
@@ -1,4 +1,5 @@
1
1
  import Client from '../client.js'
2
+ import chalk from 'chalk'
2
3
  import { getWorkspace, formatDuration, getProjectById } from '../utils.js'
3
4
  import dayjs from 'dayjs'
4
5
  import dur from 'dayjs/plugin/duration.js'
@@ -58,10 +59,25 @@ export const handler = async function (argv) {
58
59
 
59
60
  const head = Object.keys(reportData[0])
60
61
  const table = new Table({
61
- head
62
+ head,
63
+ chars: { mid: '', 'left-mid': '', 'mid-mid': '', 'right-mid': '' }
62
64
  })
63
- for (const project of reportData) {
64
- table.push(Object.values(project))
65
+ for (let i = 0; i < reportData.length; i++) {
66
+ // First row chars
67
+ const chars = {
68
+ midMid: '┼',
69
+ mid: '─',
70
+ leftMid: '├',
71
+ rightMid: '┤'
72
+ }
73
+ const project = reportData[i]
74
+ if (i == 0 ) {
75
+ table.push(Object.values(project).map((content) => ({ content: chalk.grey(content), chars })))
76
+ } else if ( i == reportData.length - 1) {
77
+ table.push(Object.values(project).map((content) => ( {content: chalk.bold(content), chars })))
78
+ } else {
79
+ table.push(Object.values(project).map((content) => ({ content: chalk.grey(content) })))
80
+ }
65
81
  }
66
82
  console.log(table.toString())
67
83
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@beauraines/toggl-cli",
3
- "version": "0.10.11",
3
+ "version": "0.10.13",
4
4
  "description": "",
5
5
  "main": "cli.js",
6
6
  "bin": {
@@ -8,7 +8,7 @@
8
8
  },
9
9
  "scripts": {
10
10
  "test": "jest",
11
- "lint": "eslint . ./**/*.js ./**/*.js",
11
+ "lint": "eslint . ./**/*.js ./**/*.mjs",
12
12
  "lint:fix": "eslint . ./**/*.js ./**/*.mjs --fix",
13
13
  "release": "standard-version",
14
14
  "should-release": "should-release"
@@ -30,6 +30,7 @@
30
30
  },
31
31
  "license": "MIT",
32
32
  "dependencies": {
33
+ "chalk": "^4.0.0",
33
34
  "cli-table3": "^0.6.3",
34
35
  "dayjs": "^1.11.6",
35
36
  "debug": "^4.3.4",