diff --git a/.travis.yml b/.travis.yml index d48dcb4..71d9c2d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,7 +2,6 @@ language: node_js node_js: - "6" - "6.11" - - "7" - "8" - "10" cache: yarn diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..73931f4 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,75 @@ +# Contributing + +## How to test the basic functions of gtt + +Create a new project on GitLab if you haven't done so already and write down the project path. e.g. `kriskbx/example-project`. To test groups and subgroups, create a new group with at least one subgroup. Add a new project to both the parent group (e.g. `example-group`) and the subgroup (e.g. `example-group/example-subgroup`) and write down the paths of all the projects and groups. Create at least two issues (write down their id e.g. `42`, `43`) and one merge request (e.g. `13`) in all projects. Or just use our public group over here: https://gitlab.com/gtt + +Then run the following basic commands and check that they work as expected: + +``` +# Test config command +gtt config + +# Test basic time tracking +gtt start "kriskbx/example-project" 42 +gtt stop +gtt log + +# Test cancelling +gtt start "kriskbx/example-project" 42 +gtt cancel +gtt log + +# Test merge request +gtt start --type=merge_request "kriskbx/example-project" 13 +gtt stop +gtt log + +# Test issue creation +gtt create "krisbxkbx/example-project" "New Issue" +gtt stop +gtt log + +# Test editing +gtt edit + +# Test deletion +gtt start "kriskbx/example-project" 42 +gtt stop +gtt delete + +# Test sync, check out issues on GitLab if changes are synced correctly +gtt sync + +# Test basic report +gtt report "kriskbx/example-project" + +# Test report for a single issue and multiple issues +gtt report "kriskbx/example-project" 42 +gtt report "kriskbx/example-project" 42 43 + +# Test report for a group +gtt report --type=group "example-group" +gtt report --type=group --subgroups "example-group" + +# Test combined reports +gtt report "kriskbx/example-project" "example-group/example-project" + +# Test outputs +gtt report --output=table "kriskbx/example-project" +gtt report --output=markdown "kriskbx/example-project" +gtt report --output=csv "kriskbx/example-project" +gtt report --output=pdf --file=test.pdf "kriskbx/example-project" +gtt report --output=xlsx --file=test.xlsx "kriskbx/example-project" + +# Test timeframes (adjust the values so it includes/excludes your issues) +gtt report --from="2020-06-02" --to="2020-06-03" "kriskbx/example-project" + +# Test filtering (you might need to add milestones, labels and additional stuff to properly test this) +gtt report --closed "kriskbx/example-project" +gtt report --user=username "kriskbx/example-project" +gtt report --milestone=milestone_name "kriskbx/example-project" +gtt report --include_by_labels=critical "kriskbx/example-project" +gtt report --exclude_by_labels=ignore "kriskbx/example-project" +gtt report --query=issues "kriskbx/example-project" +``` diff --git a/Dockerfile b/Dockerfile index 2d4cfc0..2d9509f 100755 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,12 @@ FROM node:8.2.1-alpine -ENV GTT_VERSION 1.7.29 +ENV GTT_VERSION 1.7.39 +ENV EDITOR vi + +WORKDIR /pwd RUN yarn global add --prefix /usr/local "gitlab-time-tracker@$GTT_VERSION" -VOLUME ["/root"] +VOLUME ["/root", "/pwd"] ENTRYPOINT ["gtt"] CMD ["--help"] diff --git a/documentation.md b/documentation.md index fdef25a..41fe224 100644 --- a/documentation.md +++ b/documentation.md @@ -44,7 +44,7 @@ gtt config ``` Add your GitLab API url and your [GitLab API personal token](https://gitlab.com/profile/personal_access_tokens) -to the config file and save it afterwards: +to the config file and save it afterwards. **You need to activate the `api` scope when creating your access token.** ```yaml url: https://gitlab.com/api/v4/ @@ -70,12 +70,13 @@ you can use the official [Docker image](https://hub.docker.com/r/kriskbx/gitlab- docker run \ --rm -it \ -v ~:/root \ + -v $(pwd):/pwd \ kriskbx/gitlab-time-tracker \ --help ``` `--rm` removes the container after running, `-it` makes it interactive, `-v ~:/root` mounts your home directory to the -home directory inside the container. If you want to store the config in another place, mount another directory: +home directory inside the container, `-v $(pwd):/pwd` mounts current directory inside the container to gtt be able to read local config. If you want to store the config in another place, mount another directory: ```shell @@ -101,7 +102,7 @@ docker run \ I highly recommend creating an alias and adding it to your `bashrc`: ```shell -echo "alias gtt='docker run --rm -it -v ~:/root kriskbx/gitlab-time-tracker'" >>~/.bashrc +echo "alias gtt='docker run --rm -it -v ~:/root -v $(pwd):/pwd kriskbx/gitlab-time-tracker'" >>~/.bashrc ``` Now you can simply write `gtt` instead of the bulky Docker command before. Try it out: `gtt --help` diff --git a/package.json b/package.json index 47b3d09..9496a9c 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "gitlab-time-tracker", - "version": "1.7.29", + "version": "1.7.39", "description": "A command line interface for GitLabs time tracking feature.", "bugs": { "url": "https://github.com/kriskbx/gitlab-time-tracker/issues" @@ -14,7 +14,7 @@ "test": "NODE_ENV=test mocha 'spec/**/*.spec.js'", "cover": "istanbul cover _mocha $(find ./spec -name \"*.spec.js\")", "coveralls": "yarn run cover -- --report lcovonly && cat ./coverage/lcov.info | coveralls", - "build": "pkg -o out/gtt -t node10-linux-x64,node10-macos-x64,node10-win-x64 src/gtt.js" + "build": "pkg src/gtt.js -o out/gtt -c package.json" }, "bin": { "gtt": "src/gtt.js" @@ -22,15 +22,24 @@ "engines": { "node": ">=6.11" }, + "pkg": { + "scripts": "src/**/*.js", + "targets": [ + "node10-linux-x64", + "node10-macos-x64", + "node10-win-x64" + ] + }, "author": "kriskbx", "license": "GPL-2.0", "dependencies": { + "app-module-path": "^2.2.0", "async": "^2.6.1", "camelcase": "^4.1.0", "cli-cursor": "^2.1.0", "cli-table": "^0.3.1", "colors": "^1.3.1", - "commander": "^2.16.0", + "commander": "kriskbx/commander.js", "csv-string": "^2.3.2", "find-in-files": "^0.4.0", "hash-sum": "^1.0.2", @@ -46,7 +55,9 @@ "read-yaml": "^1.1.0", "request": "^2.87.0", "request-promise-native": "^1.0.4", + "shelljs": "^0.8.3", "tempfile": "^2.0.0", + "throttled-queue": "^1.0.7", "underscore": "^1.9.1", "xdg-basedir": "^3.0.0", "xlsx": "^0.13.5" diff --git a/readme.md b/readme.md index f41da8d..bc99b29 100755 --- a/readme.md +++ b/readme.md @@ -8,6 +8,10 @@

+## ⚠️ Attention + +This repository is not maintained anymore. If you still want to use gtt and get regular updates, I recommend checking out this fork: https://github.com/ndu2/gitlab-time-tracker + ## introduction gtt is a fully featured command line interface for GitLab's time tracking feature. It monitors the time you spent on an issue or merge request locally and syncs it to GitLab. It also allows you to create reports in various formats from time tracking data stored on GitLab. **Looking for a graphical user interface? Check out the [gtt taskbar/menubar app](https://github.com/kriskbx/gitlab-time-tracker-taskbar) for Linux, Mac & Windows!** diff --git a/src/gtt-report.js b/src/gtt-report.js index fcbb76b..fac46da 100755 --- a/src/gtt-report.js +++ b/src/gtt-report.js @@ -29,27 +29,31 @@ function collect(val, arr) { // set options program .arguments('[project] [ids]') + .option('-e --type ', 'specify the query type: project, user, group') + .option('--subgroups', 'include sub groups') + .option('--url ', 'URL to GitLabs API') + .option('--token ', 'API access token') + .option('-p --proxy ', 'use a proxy server with the given url') + .option('--insecure', 'don\'t check certificates') .option('-f --from ', 'query times that are equal or greater than the given date') .option('-t --to ', 'query times that are equal or smaller than the given date') .option('--today', 'ignores --from and --to and queries entries for today') .option('--this_week', 'ignores --from and --to and queries entries for this week') .option('--this_month', 'ignores --from and --to and queries entries for this month') .option('-c --closed', 'include closed issues') - .option('-u --user ', 'only query times from the given user') .option('-m --milestone ', 'include issues from the given milestone') + .option('--hours_per_day ', 'hours per day for human readable time formats') + .option('-u --user ', 'only query times from the given user') .option('-q --query ', 'query the given data types: issues, merge_requests', collect, null) - .option('-e --type ', 'specify the query type: project, user, group') .option('-r --report ', 'include in the report: stats, issues, merge_requests, records', collect, null) .option('-o --output ', 'use the given output') .option('-l --file ', 'save report to the given file') - .option('--subgroups', 'include sub groups') .option('--include_by_labels ', 'only include issues that have the given labels', collect, null) .option('--exclude_by_labels ', 'exclude issues that have the given labels', collect, null) .option('--include_labels ', 'only include the given labels in the report', collect, null) .option('--exclude_labels ', 'exclude the given labels in the report', collect, null) .option('--date_format ', 'use the given date format in the report', collect, null) .option('--time_format