Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
abordage committed Jun 2, 2022
1 parent e71cc1b commit 5a8daed
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 25 deletions.
18 changes: 0 additions & 18 deletions .eslintrc.cjs

This file was deleted.

35 changes: 35 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"env": {
"browser": true,
"es2021": true
},
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module"
},
"plugins": [
"@typescript-eslint"
],
"rules": {
"indent": [
"error",
2
],
"linebreak-style": [
"error",
"unix"
],
"quotes": [
"error",
"single"
],
"semi": [
"error", "always"
]
}
}
2 changes: 1 addition & 1 deletion .github/workflows/schedule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: Update gist
- name: wakatime-gist
uses: abordage/wakatime-box@master
env:
# SUPPORTED: last_7_days, last_30_days, last_6_months, last_year
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ Next, statistics will be updated automatically every day. Pin this gist on your
3. correct time counting of **other languages**
4. **summary report** on action

## Optional settings
You can specify optional settings in your file `.github/workflows/schedule.yml`.

## Feedback

If you have any feedback, comments or suggestions, please feel free to open an issue within this repository.
Expand Down
9 changes: 9 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@ inputs:
INPUT_PRINT_SUMMARY:
default: true

INPUT_ACTION_NAME:
default: 'wakatime-gist'

INPUT_ACTION_URL:
default: 'https://github.com/marketplace/actions/wakatime-gist'

INPUT_USER_AGENT:
default: 'WakaTime-Gist/1.3'

runs:
using: "node16"
main: "dist/index.js"
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "1.3.0",
"description": "Show your WakaTime statistics in a pinned gist for your GitHub profile",
"scripts": {
"build": "tsc src/index.ts --outDir dist && ncc build dist/index.js --minify",
"build": "rimraf dist/ && tsc src/index.ts --outDir dist && ncc build dist/index.js --minify",
"lint": "eslint src/ --ext .ts --fix"
},
"keywords": [
Expand Down
10 changes: 6 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ const GIST_ID = core.getInput('GIST_ID', {required: true});
const MAX_RESULT = Number(core.getInput('MAX_RESULT', {required: true}));
const DATE_RANGE = core.getInput('DATE_RANGE', {required: false});
const PRINT_SUMMARY = core.getBooleanInput('PRINT_SUMMARY', {required: true});
const USER_AGENT = 'WakaTime-Gist/1.3 +https://github.com/marketplace/actions/wakatime-gist';
const ACTION_URL = 'https://github.com/marketplace/actions/wakatime-gist';

const USER_AGENT = core.getInput('USER_AGENT', {required: false});
const ACTION_URL = core.getInput('ACTION_URL', {required: false});
const ACTION_NAME = core.getInput('ACTION_NAME', {required: false});

const updateDate = new Date().toLocaleDateString('en-us', {day: 'numeric', year: 'numeric', month: 'short'});
const summaryTable: any[] = [[{data: 'Action', header: true}, {data: 'Result', header: true}]];
Expand All @@ -31,7 +33,7 @@ title = 'My ' + title + ' stack [update ' + updateDate + ']';
/**
* Get statistics
*/
const httpClient = new HttpClient(USER_AGENT);
const httpClient = new HttpClient(USER_AGENT + '+' + ACTION_URL);
const response = await httpClient.getJson('https://wakatime.com/api/v1/users/current/stats/' + range,
{Authorization: `Basic ${Buffer.from(WAKA_API_KEY).toString('base64')}`})
.catch(error => core.setFailed('Action failed: ' + error.message));
Expand Down Expand Up @@ -105,7 +107,7 @@ title = 'My ' + title + ' stack [update ' + updateDate + ']';
.addHeading('Results')
.addTable(summaryTable)
.addBreak()
.addLink('wakatime-gist', ACTION_URL);
.addLink(ACTION_NAME, ACTION_URL);

if (PRINT_SUMMARY) {
await summary.write();
Expand Down

0 comments on commit 5a8daed

Please sign in to comment.