@@ -461,131 +461,126 @@ const TODOIST_API_KEY = core.getInput("TODOIST_API_KEY");
461
461
const PREMIUM = core . getInput ( "PREMIUM" ) ;
462
462
463
463
async function main ( ) {
464
- const stats = await axios ( `https://api.todoist.com/sync/v8.3/completed/get_stats?token=${ TODOIST_API_KEY } ` ) ;
465
- await updateReadme ( stats . data ) ;
464
+ const stats = await axios (
465
+ `https://api.todoist.com/sync/v9/completed/get_stats?token=${ TODOIST_API_KEY } `
466
+ ) ;
467
+ await updateReadme ( stats . data ) ;
466
468
}
467
469
468
470
let todoist = [ ] ;
469
471
let jobFailFlag = false ;
470
- const README_FILE_PATH = ' ./README.md' ;
472
+ const README_FILE_PATH = " ./README.md" ;
471
473
472
474
async function updateReadme ( data ) {
475
+ const { karma, completed_count, days_items, goals, week_items } = data ;
473
476
474
-
475
- const { karma, completed_count, days_items, goals, week_items } = data ;
476
-
477
- const karmaPoint = [ `🏆 ${ Humanize . intComma ( karma ) } Karma Points` ] ;
478
- todoist . push ( karmaPoint ) ;
479
-
480
- const dailyGoal = [
481
- `🌸 Completed ${ days_items [ 0 ] . total_completed . toString ( ) } tasks today` ,
482
- ] ;
483
- todoist . push ( dailyGoal ) ;
477
+ const karmaPoint = [ `🏆 **${ Humanize . intComma ( karma ) } ** Karma Points` ] ;
478
+ todoist . push ( karmaPoint ) ;
484
479
485
- if ( PREMIUM ) {
486
- const weekItems = [ `🗓 Completed ${ week_items [ 0 ] . total_completed . toString ( ) } tasks this week` ] ;
487
- todoist . push ( weekItems ) ;
488
- }
489
-
490
- const totalTasks = [ `✅ Completed ${ Humanize . intComma ( completed_count ) } tasks so far` ] ;
491
- todoist . push ( totalTasks ) ;
480
+ const dailyGoal = [
481
+ `🌸 Completed **${ days_items [ 0 ] . total_completed . toString ( ) } ** tasks today` ,
482
+ ] ;
483
+ todoist . push ( dailyGoal ) ;
492
484
493
- const longestStreak = [
494
- `⏳ Longest streak is ${ goals . max_daily_streak . count } days` ,
485
+ if ( PREMIUM == "true" ) {
486
+ const weekItems = [
487
+ `🗓 Completed **${ week_items [ 0 ] . total_completed . toString ( ) } ** tasks this week` ,
495
488
] ;
496
- todoist . push ( longestStreak ) ;
497
-
498
- if ( todoist . length == 0 ) return ;
499
-
500
- if ( todoist . length > 0 ) {
501
- console . log ( todoist . length ) ;
502
- // const showTasks = todoist.reduce((todo, cur, index) => {
503
- // return todo + `\n${cur} ` + (((index + 1) === todoist.length) ? '\n' : '');
504
- // })
505
- const readmeData = fs . readFileSync ( README_FILE_PATH , "utf8" ) ;
506
-
507
-
508
- const newReadme = buildReadme ( readmeData , todoist . join ( " \n" ) ) ;
509
- if ( newReadme !== readmeData ) {
510
- core . info ( 'Writing to ' + README_FILE_PATH ) ;
511
- fs . writeFileSync ( README_FILE_PATH , newReadme ) ;
512
- if ( ! process . env . TEST_MODE ) {
513
- commitReadme ( ) ;
514
- }
515
- } else {
516
- core . info ( 'No change detected, skipping' ) ;
517
- process . exit ( 0 ) ;
518
- }
519
- }
520
- else {
521
- core . info ( "Nothing fetched" ) ;
522
- process . exit ( jobFailFlag ? 1 : 0 ) ;
523
- }
489
+ todoist . push ( weekItems ) ;
524
490
}
525
491
526
- // console.log(todoist.length);
492
+ const totalTasks = [
493
+ `✅ Completed **${ Humanize . intComma ( completed_count ) } ** tasks so far` ,
494
+ ] ;
495
+ todoist . push ( totalTasks ) ;
527
496
497
+ const longestStreak = [
498
+ `⏳ Longest streak is **${ goals . max_daily_streak . count } ** days` ,
499
+ ] ;
500
+ todoist . push ( longestStreak ) ;
501
+
502
+ if ( todoist . length == 0 ) return ;
503
+
504
+ if ( todoist . length > 0 ) {
505
+ // console.log(todoist.length);
506
+ // const showTasks = todoist.reduce((todo, cur, index) => {
507
+ // return todo + `\n${cur} ` + (((index + 1) === todoist.length) ? '\n' : '');
508
+ // })
509
+ const readmeData = fs . readFileSync ( README_FILE_PATH , "utf8" ) ;
510
+
511
+ const newReadme = buildReadme ( readmeData , todoist . join ( " \n" ) ) ;
512
+ if ( newReadme !== readmeData ) {
513
+ core . info ( "Writing to " + README_FILE_PATH ) ;
514
+ fs . writeFileSync ( README_FILE_PATH , newReadme ) ;
515
+ if ( ! process . env . TEST_MODE ) {
516
+ commitReadme ( ) ;
517
+ }
518
+ } else {
519
+ core . info ( "No change detected, skipping" ) ;
520
+ process . exit ( 0 ) ;
521
+ }
522
+ } else {
523
+ core . info ( "Nothing fetched" ) ;
524
+ process . exit ( jobFailFlag ? 1 : 0 ) ;
525
+ }
526
+ }
528
527
528
+ // console.log(todoist.length);
529
529
530
-
531
- const buildReadme = ( prevReadmeContent , newReadmeContent ) => {
532
- const tagToLookFor = '<!-- TODO-IST:' ;
533
- const closingTag = '-->' ;
534
- const startOfOpeningTagIndex = prevReadmeContent . indexOf (
535
- `${ tagToLookFor } START` ,
536
- ) ;
537
- const endOfOpeningTagIndex = prevReadmeContent . indexOf (
538
- closingTag ,
539
- startOfOpeningTagIndex ,
540
- ) ;
541
- const startOfClosingTagIndex = prevReadmeContent . indexOf (
542
- `${ tagToLookFor } END` ,
543
- endOfOpeningTagIndex ,
530
+ const buildReadme = ( prevReadmeContent , newReadmeContent ) => {
531
+ const tagToLookFor = "<!-- TODO-IST:" ;
532
+ const closingTag = "-->" ;
533
+ const startOfOpeningTagIndex = prevReadmeContent . indexOf (
534
+ `${ tagToLookFor } START`
535
+ ) ;
536
+ const endOfOpeningTagIndex = prevReadmeContent . indexOf (
537
+ closingTag ,
538
+ startOfOpeningTagIndex
539
+ ) ;
540
+ const startOfClosingTagIndex = prevReadmeContent . indexOf (
541
+ `${ tagToLookFor } END` ,
542
+ endOfOpeningTagIndex
543
+ ) ;
544
+ if (
545
+ startOfOpeningTagIndex === - 1 ||
546
+ endOfOpeningTagIndex === - 1 ||
547
+ startOfClosingTagIndex === - 1
548
+ ) {
549
+ core . error (
550
+ `Cannot find the comment tag on the readme:\n<!-- ${ tagToLookFor } :START -->\n<!-- ${ tagToLookFor } :END -->`
544
551
) ;
545
- if (
546
- startOfOpeningTagIndex === - 1 ||
547
- endOfOpeningTagIndex === - 1 ||
548
- startOfClosingTagIndex === - 1
549
- ) {
550
- core . error (
551
- `Cannot find the comment tag on the readme:\n<!-- ${ tagToLookFor } :START -->\n<!-- ${ tagToLookFor } :END -->`
552
- ) ;
553
- process . exit ( 1 ) ;
554
- }
555
- return [
556
- prevReadmeContent . slice ( 0 , endOfOpeningTagIndex + closingTag . length ) ,
557
- '\n' ,
558
- newReadmeContent ,
559
- '\n' ,
560
- prevReadmeContent . slice ( startOfClosingTagIndex ) ,
561
- ] . join ( '' ) ;
562
- } ;
552
+ process . exit ( 1 ) ;
553
+ }
554
+ return [
555
+ prevReadmeContent . slice ( 0 , endOfOpeningTagIndex + closingTag . length ) ,
556
+ "\n" ,
557
+ newReadmeContent ,
558
+ "\n" ,
559
+ prevReadmeContent . slice ( startOfClosingTagIndex ) ,
560
+ ] . join ( "" ) ;
561
+ } ;
563
562
564
- const commitReadme = async ( ) => {
565
- // Getting config
566
- const committerUsername = 'github-actions[bot]' ;
567
- const committerEmail = '41898282+github-actions[bot]@users.noreply.github.com' ;
568
- const commitMessage = 'Update Todoist stats (automated)' ;
569
- // Doing commit and push
570
- await exec ( 'git' , [
571
- 'config' ,
572
- '--global' ,
573
- 'user.email' ,
574
- committerEmail ,
575
- ] ) ;
576
- await exec ( 'git' , [ 'config' , '--global' , 'user.name' , committerUsername ] ) ;
577
- await exec ( 'git' , [ 'add' , README_FILE_PATH ] ) ;
578
- await exec ( 'git' , [ 'commit' , '-m' , commitMessage ] ) ;
579
- // await exec('git', ['fetch']);
580
- await exec ( 'git' , [ 'push' ] ) ;
581
- core . info ( "Readme updated successfully." ) ;
582
- // Making job fail if one of the source fails
583
- process . exit ( jobFailFlag ? 1 : 0 ) ;
584
- } ;
563
+ const commitReadme = async ( ) => {
564
+ // Getting config
565
+ const committerUsername = "github-actions" ;
566
+ const committerEmail = "[email protected] " ;
567
+ const commitMessage = "Update Todoist stats (automated)" ;
568
+ // Doing commit and push
569
+ await exec ( "git" , [ "config" , "--global" , "user.email" , committerEmail ] ) ;
570
+ await exec ( "git" , [ "config" , "--global" , "user.name" , committerUsername ] ) ;
571
+ await exec ( "git" , [ "add" , README_FILE_PATH ] ) ;
572
+ await exec ( "git" , [ "commit" , "-m" , commitMessage ] ) ;
573
+ // await exec('git', ['fetch']);
574
+ await exec ( "git" , [ "push" ] ) ;
575
+ core . info ( "Readme updated successfully." ) ;
576
+ // Making job fail if one of the source fails
577
+ process . exit ( jobFailFlag ? 1 : 0 ) ;
578
+ } ;
579
+
580
+ ( async ( ) => {
581
+ await main ( ) ;
582
+ } ) ( ) ;
585
583
586
- ( async ( ) => {
587
- await main ( ) ;
588
- } ) ( ) ;
589
584
590
585
/***/ } ) ,
591
586
@@ -1071,7 +1066,7 @@ module.exports = require("assert");
1071
1066
/***/ 361 :
1072
1067
/***/ ( function ( module ) {
1073
1068
1074
- module . exports = { "_from" :
"axios" , "_id" :
"[email protected] " , "_inBundle" :
false , "_integrity" :
"sha512-ANA4rr2BDcmmAQLOKft2fufrtuvlqR+cXNNinUmvfeSNCOF98PZL+7M/v1zIdGo7OLjEA9J2gXJL+j4zGsl0bA==" , "_location" :
"/axios" , "_phantomChildren" :
{ } , "_requested" :
{ "type" :
"tag" , "registry" :
true , "raw" :
"axios" , "name" :
"axios" , "escapedName" :
"axios" , "rawSpec" :
"" , "saveSpec" :
null , "fetchSpec" :
"latest" } , "_requiredBy" :
[ "#USER" , "/" ] , "_resolved" :
"https://registry.npmjs.org/axios/-/axios-0.20.0.tgz" , "_shasum" :
"057ba30f04884694993a8cd07fa394cff11c50bd" , "_spec" :
"axios" , "_where" :
"/Users/abhisheknaidu/Desktop/workspace🌈/projects/todoist-readme" , "author" :
{ "name" :
"Matt Zabriskie" } , "browser" :
{ "./lib/adapters/http.js" :
"./lib/adapters/xhr.js" } , "bugs" :
{ "url" :
"https://github.com/axios/axios/issues" } , "bundleDependencies" :
false , "bundlesize" :
[ { "path" :
"./dist/axios.min.js" , "threshold" :
"5kB" } ] , "dependencies" :
{ "follow-redirects" :
"^1.10.0" } , "deprecated" :
false , "description" :
"Promise based HTTP client for the browser and node.js" , "devDependencies" :
{ "bundlesize" :
"^0.17.0" , "coveralls" :
"^3.0.0" , "es6-promise" :
"^4.2.4" , "grunt" :
"^1.0.2" , "grunt-banner" :
"^0.6.0" , "grunt-cli" :
"^1.2.0" , "grunt-contrib-clean" :
"^1.1.0" , "grunt-contrib-watch" :
"^1.0.0" , "grunt-eslint" :
"^20.1.0" , "grunt-karma" :
"^2.0.0" , "grunt-mocha-test" :
"^0.13.3" , "grunt-ts" :
"^6.0.0-beta.19" , "grunt-webpack" :
"^1.0.18" , "istanbul-instrumenter-loader" :
"^1.0.0" , "jasmine-core" :
"^2.4.1" , "karma" :
"^1.3.0" , "karma-chrome-launcher" :
"^2.2.0" , "karma-coverage" :
"^1.1.1" , "karma-firefox-launcher" :
"^1.1.0" , "karma-jasmine" :
"^1.1.1" , "karma-jasmine-ajax" :
"^0.1.13" , "karma-opera-launcher" :
"^1.0.0" , "karma-safari-launcher" :
"^1.0.0" , "karma-sauce-launcher" :
"^1.2.0" , "karma-sinon" :
"^1.0.5" , "karma-sourcemap-loader" :
"^0.3.7" , "karma-webpack" :
"^1.7.0" , "load-grunt-tasks" :
"^3.5.2" , "minimist" :
"^1.2.0" , "mocha" :
"^5.2.0" , "sinon" :
"^4.5.0" , "typescript" :
"^2.8.1" , "url-search-params" :
"^0.10.0" , "webpack" :
"^1.13.1" , "webpack-dev-server" :
"^1.14.1" } , "homepage" :
"https://github.com/axios/axios" , "jsdelivr" :
"dist/axios.min.js" , "keywords" :
[ "xhr" , "http" , "ajax" , "promise" , "node" ] , "license" :
"MIT" , "main" :
"index.js" , "name" :
"axios" , "repository" :
{ "type" :
"git" , "url" :
"git+https://github.com/axios/axios.git" } , "scripts" :
{ "build" :
"NODE_ENV=production grunt build" , "coveralls" :
"cat coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js" , "examples" :
"node ./examples/server.js" , "fix" :
"eslint --fix lib/**/*.js" , "postversion" :
"git push && git push --tags" , "preversion" :
"npm test" , "start" :
"node ./sandbox/server.js" , "test" :
"grunt test && bundlesize" , "version" :
"npm run build && grunt version && git add -A dist && git add CHANGELOG.md bower.json package.json" } , "typings" :
"./index.d.ts" , "unpkg" :
"dist/axios.min.js" , "version" :
"0.20.0" } ;
1069
+ module . exports = { "name" :"axios" , "version" :"0.20.0" , "description" :"Promise based HTTP client for the browser and node.js" , "main" :"index.js" , "scripts" :{ "test" :"grunt test && bundlesize" , "start" :"node ./sandbox/server.js" , "build" :"NODE_ENV=production grunt build" , "preversion" :"npm test" , "version" :"npm run build && grunt version && git add -A dist && git add CHANGELOG.md bower.json package.json" , "postversion" :"git push && git push --tags" , "examples" :"node ./examples/server.js" , "coveralls" :"cat coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js" , "fix" :"eslint --fix lib/**/*.js" } , "repository" :{ "type" :"git" , "url" :"https://github.com/axios/axios.git" } , "keywords" :[ "xhr" , "http" , "ajax" , "promise" , "node" ] , "author" :"Matt Zabriskie" , "license" :"MIT" , "bugs" :{ "url" :"https://github.com/axios/axios/issues" } , "homepage" :"https://github.com/axios/axios" , "devDependencies" :{ "bundlesize" :"^0.17.0" , "coveralls" :"^3.0.0" , "es6-promise" :"^4.2.4" , "grunt" :"^1.0.2" , "grunt-banner" :"^0.6.0" , "grunt-cli" :"^1.2.0" , "grunt-contrib-clean" :"^1.1.0" , "grunt-contrib-watch" :"^1.0.0" , "grunt-eslint" :"^20.1.0" , "grunt-karma" :"^2.0.0" , "grunt-mocha-test" :"^0.13.3" , "grunt-ts" :"^6.0.0-beta.19" , "grunt-webpack" :"^1.0.18" , "istanbul-instrumenter-loader" :"^1.0.0" , "jasmine-core" :"^2.4.1" , "karma" :"^1.3.0" , "karma-chrome-launcher" :"^2.2.0" , "karma-coverage" :"^1.1.1" , "karma-firefox-launcher" :"^1.1.0" , "karma-jasmine" :"^1.1.1" , "karma-jasmine-ajax" :"^0.1.13" , "karma-opera-launcher" :"^1.0.0" , "karma-safari-launcher" :"^1.0.0" , "karma-sauce-launcher" :"^1.2.0" , "karma-sinon" :"^1.0.5" , "karma-sourcemap-loader" :"^0.3.7" , "karma-webpack" :"^1.7.0" , "load-grunt-tasks" :"^3.5.2" , "minimist" :"^1.2.0" , "mocha" :"^5.2.0" , "sinon" :"^4.5.0" , "typescript" :"^2.8.1" , "url-search-params" :"^0.10.0" , "webpack" :"^1.13.1" , "webpack-dev-server" :"^1.14.1" } , "browser" :{ "./lib/adapters/http.js" :"./lib/adapters/xhr.js" } , "jsdelivr" :"dist/axios.min.js" , "unpkg" :"dist/axios.min.js" , "typings" :"./index.d.ts" , "dependencies" :{ "follow-redirects" :"^1.10.0" } , "bundlesize" :[ { "path" :"./dist/axios.min.js" , "threshold" :"5kB" } ] } ;
1075
1070
1076
1071
/***/ } ) ,
1077
1072
@@ -3723,4 +3718,4 @@ module.exports = function buildFullPath(baseURL, requestedURL) {
3723
3718
3724
3719
/***/ } )
3725
3720
3726
- /******/ } ) ;
3721
+ /******/ } ) ;
0 commit comments