Skip to content

Commit

Permalink
Migrate to Toggl api v9 & upgrade everything
Browse files Browse the repository at this point in the history
  • Loading branch information
bokub committed Mar 7, 2024
1 parent 0b4c0b8 commit f96d65b
Show file tree
Hide file tree
Showing 12 changed files with 1,892 additions and 2,543 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
on: push

jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version: '20'

- name: Publish on npm
uses: JS-DevTools/npm-publish@v1
if: startsWith(github.ref, 'refs/tags/')
with:
token: ${{ secrets.NPM_TOKEN }}
access: public
1 change: 0 additions & 1 deletion .husky/.gitignore

This file was deleted.

5 changes: 1 addition & 4 deletions .husky/pre-commit
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx pretty-quick --staged
npx lint-staged --concurrent false
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v20.11.1
13 changes: 0 additions & 13 deletions .travis.yml

This file was deleted.

65 changes: 28 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
# WakaTime to Toggl

[![Version][version-src]][version-href]
[![code style: prettier][code-style-src]][code-style-href]
[![Downloads][downloads-src]][downloads-href]
[![CI][ci-src]][ci-href]
[![Build Status](https://flat.badgen.net/github/checks/bokub/wakatime-to-toggl?label=build)](https://github.com/bokub/wakatime-to-toggl/actions/workflows/run.yml?query=branch%3Amaster)
[![Version](https://flat.badgen.net/github/release/bokub/wakatime-to-toggl?label=version)](https://github.com/bokub/wakatime-to-toggl/releases)
[![Downloads](https://flat.badgen.net/npm/dm/wakatime-to-toggl?color=orange)](https://www.npmjs.com/package/wakatime-to-toggl)
[![Code style](https://flat.badgen.net/badge/code%20style/prettier/ff69b4)](https://github.com/bokub/prettier-config)

Sync your WakaTime data in Toggl

- Works with free accounts
- Can be automated with Github Actions
- Works with free accounts
- Can be automated with GitHub Actions

<p align="center">
<img width="639" height="238" src="https://user-images.githubusercontent.com/17952318/90114480-10acb700-dd53-11ea-9c67-5700705214e5.gif">
</p>

## Prerequisites

- Get your Wakatime API key in [your settings](https://wakatime.com/settings/api-key)
- Get your Toggl "API Token" at the bottom of [your profile page](https://track.toggl.com/profile)
- Get your Wakatime API key in [your settings](https://wakatime.com/settings/api-key)
- Get your Toggl "API Token" at the bottom of [your profile page](https://track.toggl.com/profile)

## Option 1 - Run manually on your computer

Expand All @@ -26,15 +26,15 @@ Sync your WakaTime data in Toggl
3. Run the following command to sync data from yesterday: `wakatime-to-toggl -w <wakatime-api-key> -t <toggl-api-key>`
4. Ideally, run **wakatime-to-toggl** everyday

## Option 2 - Run automatically everyday using Github Actions
## Option 2 - Run automatically everyday using GitHub Actions

1. Fork this repository
2. From your new fork, go to **Settings > Secrets**
3. Add the following secrets using the **New secret** button:

- `TOGGL_API_KEY`: Your Toggl API Key
- `WAKATIME_API_KEY`: Your Wakatime API Key
![Screenshot](https://user-images.githubusercontent.com/17952318/86905384-4934f180-c112-11ea-91cd-7b391cd7e5de.png)
- `TOGGL_API_KEY`: Your Toggl API Key
- `WAKATIME_API_KEY`: Your Wakatime API Key
![Screenshot](https://user-images.githubusercontent.com/17952318/86905384-4934f180-c112-11ea-91cd-7b391cd7e5de.png)

4. Go to the **Actions** tab of your fork
5. Click **set up a workflow yourself**
Expand All @@ -43,19 +43,19 @@ Sync your WakaTime data in Toggl
```yaml
name: Run wakatime-to-toggl everyday
on:
schedule:
- cron: 30 2 * * * # Everyday at 02:30 AM UTC. You can change it according to your timezone
schedule:
- cron: 30 2 * * * # Everyday at 02:30 AM UTC. You can change it according to your timezone
jobs:
run:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-node@v1
with:
node-version: 12
- run: npx wakatime-to-toggl -w "$WAKATIME_API_KEY" -t "$TOGGL_API_KEY"
env:
TOGGL_API_KEY: '${{ secrets.TOGGL_API_KEY }}'
WAKATIME_API_KEY: '${{ secrets.WAKATIME_API_KEY }}'
run:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-node@v4
with:
node-version: 20
- run: npx wakatime-to-toggl -w "$WAKATIME_API_KEY" -t "$TOGGL_API_KEY"
env:
TOGGL_API_KEY: '${{ secrets.TOGGL_API_KEY }}'
WAKATIME_API_KEY: '${{ secrets.WAKATIME_API_KEY }}'
```
7. Click **Start commit** then **Commit new file** to save
Expand All @@ -66,10 +66,10 @@ You can come back to the **Actions** tab later to see the logs
## Things to know
- Entries shorter than 2 minutes will be ignored. This duration is configurable
- Duplicate entries won't be added if they are detected
- Projects will be created in your default workspace. You can move them to another workspace if you want
- Time entries will be created with a default description ("Development"). You can edit it, it won't break duplicates detection
- Entries shorter than 2 minutes will be ignored. This duration is configurable
- Duplicate entries won't be added if they are detected
- Projects will be created in your default workspace. You can move them to another workspace if you want
- Time entries will be created with a default description ("Development"). You can edit it, it won't break duplicates detection
## Detailed usage
Expand All @@ -85,12 +85,3 @@ $ wakatime-to-toggl --help
--day, -d The day to fetch. 0 is today, 1 is yesterday... Default: 1
--min-duration -m Minimum duration (in seconds) of entries to sync. Default: 120
```
[version-src]: https://runkit.io/bokub/npm-version/branches/master/wakatime-to-toggl?style=flat
[code-style-src]: https://flat.badgen.net/badge/code%20style/prettier/ff69b4
[downloads-src]: https://flat.badgen.net/npm/dm/wakatime-to-toggl?color=orange
[ci-src]: https://flat.badgen.net/travis/bokub/wakatime-to-toggl
[version-href]: https://www.npmjs.com/package/wakatime-to-toggl
[code-style-href]: https://github.com/bokub/prettier-config
[downloads-href]: https://www.npmjs.com/package/wakatime-to-toggl
[ci-href]: https://travis-ci.org/bokub/wakatime-to-toggl
56 changes: 28 additions & 28 deletions cli.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
#!/usr/bin/env node
'use strict';

const meow = require('meow');
const syncActivity = require('./src/sync');
import meow from 'meow';
import syncActivity from './src/sync.js';

const cli = meow(
`
`
Usage
$ wakatime-to-toggl -w <wakatime-api-key> -t <toggl-api-key>
Expand All @@ -15,30 +14,31 @@ const cli = meow(
--day, -d The day to fetch. 0 is today, 1 is yesterday... Default: 1
--min-duration -m Minimum duration (in seconds) of entries to sync. Default: 120
`,
{
flags: {
wakatime: {
type: 'string',
alias: 'w',
isRequired: true,
},
toggl: {
type: 'string',
alias: 't',
isRequired: true,
},
day: {
type: 'number',
alias: 'd',
default: 1,
},
minDuration: {
type: 'number',
alias: 'm',
default: 120,
},
},
}
{
flags: {
wakatime: {
type: 'string',
shortFlag: 'w',
isRequired: true,
},
toggl: {
type: 'string',
shortFlag: 't',
isRequired: true,
},
day: {
type: 'number',
shortFlag: 'd',
default: 1,
},
minDuration: {
type: 'number',
shortFlag: 'm',
default: 120,
},
},
importMeta: import.meta,
},
);

syncActivity(cli.flags);
Loading

0 comments on commit f96d65b

Please sign in to comment.