@beauraines/toggl-cli 0.10.19 → 0.10.21
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/CHANGELOG.md +17 -1
- package/cmds/ls.mjs +15 -4
- package/cmds/weekly.mjs +14 -6
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,12 +2,28 @@
|
|
|
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.
|
|
5
|
+
### [0.10.21](https://github.com/beauraines/toggl-cli/compare/v0.10.20...v0.10.21) (2023-07-08)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* **ls:** adds details to time entry listing ([7ad05c7](https://github.com/beauraines/toggl-cli/commit/7ad05c797729bbaa34dc2a6be99397e1a01c24a2)), closes [#72](https://github.com/beauraines/toggl-cli/issues/72)
|
|
11
|
+
|
|
12
|
+
### [0.10.20](https://github.com/beauraines/toggl-cli/compare/v0.10.19...v0.10.20) (2023-07-08)
|
|
13
|
+
|
|
14
|
+
### [0.10.19](https://github.com/beauraines/toggl-cli/compare/v0.10.18...v0.10.19) (2023-07-08)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Features
|
|
18
|
+
|
|
19
|
+
* **weekly report:** Add weekly report options ([73bb7fe](https://github.com/beauraines/toggl-cli/commit/73bb7fe8b815978feb39de5db4b6cc96811314cf)), closes [#44](https://github.com/beauraines/toggl-cli/issues/44)
|
|
6
20
|
|
|
7
21
|
|
|
8
22
|
### Bug Fixes
|
|
9
23
|
|
|
10
24
|
* **deps:** bump dayjs from 1.11.7 to 1.11.8 ([2b47fde](https://github.com/beauraines/toggl-cli/commit/2b47fde79a538cfe6a486e84a21e58cfa2ddd6b4))
|
|
25
|
+
* **deps:** bump dotenv from 16.1.3 to 16.1.4 ([14eaefa](https://github.com/beauraines/toggl-cli/commit/14eaefa93394e93708dc05319db73d86ac6fe9e5))
|
|
26
|
+
* **deps:** bump dotenv from 16.1.4 to 16.3.1 ([#83](https://github.com/beauraines/toggl-cli/issues/83)) ([6511956](https://github.com/beauraines/toggl-cli/commit/65119569c782afd7d22ae2532b23568d7517bc2a))
|
|
11
27
|
|
|
12
28
|
### [0.10.18](https://github.com/beauraines/toggl-cli/compare/v0.10.17...v0.10.18) (2023-06-03)
|
|
13
29
|
|
package/cmds/ls.mjs
CHANGED
|
@@ -27,20 +27,31 @@ export const handler = async function (argv) {
|
|
|
27
27
|
debug(searchString)
|
|
28
28
|
timeEntries = timeEntries.filter(x => x.description.includes(searchString))
|
|
29
29
|
}
|
|
30
|
+
|
|
31
|
+
const workspaces = await client.workspaces.list()
|
|
32
|
+
const workspace = workspaces[0]
|
|
33
|
+
debug('Workspace: ' + workspace.name)
|
|
34
|
+
debug('id: ' + workspace.id)
|
|
35
|
+
const projects = await client.workspaces.projects(workspace.id)
|
|
36
|
+
|
|
30
37
|
const report = []
|
|
31
38
|
timeEntries.forEach(element => {
|
|
39
|
+
console.log(element)
|
|
32
40
|
report.push(
|
|
33
41
|
{
|
|
34
42
|
description: element.description,
|
|
43
|
+
project: projects.filter(p => p.id == element.project_id)[0]?.name,
|
|
44
|
+
project_id: projects.filter(p => p.id == element.project_id)[0]?.id,
|
|
35
45
|
start: convertUtcTime(element.start),
|
|
36
46
|
stop: convertUtcTime(element.stop),
|
|
37
|
-
duration: formatDuration(element.duration * 1000)
|
|
47
|
+
duration: formatDuration(element.duration * 1000),
|
|
48
|
+
id: element.id
|
|
38
49
|
}
|
|
39
50
|
)
|
|
40
51
|
})
|
|
41
52
|
|
|
42
53
|
const table = new Table({
|
|
43
|
-
head: ['Description', 'Start', 'Stop', 'Duration'],
|
|
54
|
+
head: ['Description', 'Project', 'Start', 'Stop', 'Duration', 'Time Entry ID'],
|
|
44
55
|
chars: { mid: '', 'left-mid': '', 'mid-mid': '', 'right-mid': '' }
|
|
45
56
|
})
|
|
46
57
|
for (let i = 0; i < report.length; i++) {
|
|
@@ -53,9 +64,9 @@ export const handler = async function (argv) {
|
|
|
53
64
|
}
|
|
54
65
|
const entry = report[i]
|
|
55
66
|
if (i === 0) {
|
|
56
|
-
table.push([entry.description, entry.start, entry.stop, entry.duration].map((content) => ({ content, chars })))
|
|
67
|
+
table.push([entry.description, entry.project, entry.start, entry.stop, entry.duration, entry.id].map((content) => ({ content, chars })))
|
|
57
68
|
} else {
|
|
58
|
-
table.push([entry.description, entry.start, entry.stop, entry.duration])
|
|
69
|
+
table.push([entry.description, entry.project, entry.start, entry.stop, entry.duration, entry.id])
|
|
59
70
|
}
|
|
60
71
|
}
|
|
61
72
|
console.log(table.toString())
|
package/cmds/weekly.mjs
CHANGED
|
@@ -15,13 +15,21 @@ const debug = debugClient('toggl-cli-week');
|
|
|
15
15
|
export const command = 'week'
|
|
16
16
|
// FIXME descriptions
|
|
17
17
|
export const desc = 'Weekly project summary by day'
|
|
18
|
-
export const builder = {
|
|
18
|
+
export const builder = {
|
|
19
|
+
p: { alias: ['previous','prior'], describe: 'Return the prior week\'s data', type: 'boolean', demandOption: false, requiresArg: false}
|
|
20
|
+
}
|
|
19
21
|
|
|
20
22
|
export const handler = async function (argv) {
|
|
21
23
|
const client = Client()
|
|
22
24
|
const workspace = await getWorkspace()
|
|
23
25
|
|
|
24
|
-
const
|
|
26
|
+
const weekOffset = argv.previous ? 1 : 0
|
|
27
|
+
const startDate = dayjs().startOf('week').subtract(weekOffset,'weeks')
|
|
28
|
+
|
|
29
|
+
const params = {
|
|
30
|
+
start_date: startDate.format('YYYY-MM-DD')
|
|
31
|
+
}
|
|
32
|
+
|
|
25
33
|
const weeklyReport = await client.reports.weekly(workspace.id, params)
|
|
26
34
|
debug(weeklyReport)
|
|
27
35
|
const reportData = []
|
|
@@ -36,11 +44,11 @@ export const handler = async function (argv) {
|
|
|
36
44
|
|
|
37
45
|
for (let i = 0; i < project.seconds.length; i++) {
|
|
38
46
|
const element = project.seconds[i]
|
|
39
|
-
const date =
|
|
47
|
+
const date = startDate.add(i, 'days').format('ddd MM-DD')
|
|
40
48
|
const duration = element || 0
|
|
41
49
|
row[date] = formatDuration(duration * 1000)
|
|
42
50
|
totals[i] += duration // for use with a daily total row
|
|
43
|
-
row.Total += duration // accumulate the projects weekly
|
|
51
|
+
row.Total += duration // accumulate the projects weekly total
|
|
44
52
|
}
|
|
45
53
|
reportData.push(row)
|
|
46
54
|
}
|
|
@@ -52,9 +60,9 @@ export const handler = async function (argv) {
|
|
|
52
60
|
|
|
53
61
|
for (let i = 0; i < totals.length; i++) {
|
|
54
62
|
const seconds = totals[i]
|
|
55
|
-
const date =
|
|
63
|
+
const date = startDate.add(i, 'days').format('ddd MM-DD')
|
|
56
64
|
totalRow[date] = formatDuration(seconds * 1000)
|
|
57
|
-
totalRow.Total += seconds // accumulate the projects weekly
|
|
65
|
+
totalRow.Total += seconds // accumulate the projects weekly total
|
|
58
66
|
}
|
|
59
67
|
reportData.push(totalRow)
|
|
60
68
|
|