├── example.png ├── .github └── FUNDING.yml ├── .travis.yml ├── .gitignore ├── package.json ├── LICENSE ├── lib ├── start.js └── index.js ├── test └── index.js ├── README.md └── example.json /example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aleen42/auto-contribution/HEAD/example.png -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: [aleen42] 4 | custom: https://issuehunt.io/r/aleen42/auto-contribution 5 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - "5" 4 | - "5.1" 5 | - "4" 6 | - "4.2" 7 | - "4.1" 8 | - "4.0" 9 | - "0.12" 10 | - "0.11" 11 | - "0.10" 12 | - "iojs" 13 | script: make test 14 | os: 15 | - linux -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | 6 | # Runtime data 7 | pids 8 | *.pid 9 | *.seed 10 | 11 | # Directory for instrumented libs generated by jscoverage/JSCover 12 | lib-cov 13 | 14 | # Coverage directory used by tools like istanbul 15 | coverage 16 | 17 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 18 | .grunt 19 | 20 | # node-waf configuration 21 | .lock-wscript 22 | 23 | # Compiled binary addons (http://nodejs.org/api/addons.html) 24 | build/Release 25 | 26 | # Dependency directory 27 | node_modules 28 | 29 | # Optional npm cache directory 30 | .npm 31 | 32 | # Optional REPL history 33 | .node_repl_history 34 | 35 | example.json 36 | .idea 37 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "auto-contribution", 3 | "version": "1.2.1", 4 | "description": "automatically generate contributions with shell script", 5 | "main": "index.js", 6 | "scripts": { 7 | "generate": "node ./lib/start.js", 8 | "server": "node ./node_modules/gh-contributions/lib/server.js", 9 | "test": "node ./node_modules/mocha/bin/mocha --reporter spec" 10 | }, 11 | "repository": { 12 | "type": "git", 13 | "url": "git+https://github.com/aleen42/auto-contribution.git" 14 | }, 15 | "keywords": [ 16 | "contributions" 17 | ], 18 | "author": "aleen42 (http://aleen42.github.io/pc.html)", 19 | "contributors": [ 20 | "aleen42 " 21 | ], 22 | "license": "MIT", 23 | "bugs": { 24 | "url": "https://github.com/aleen42/auto-contribution/issues" 25 | }, 26 | "homepage": "https://github.com/aleen42/auto-contribution#readme", 27 | "dependencies": { 28 | "gh-contributions": "3.0.10", 29 | "progress": "1.1.8" 30 | }, 31 | "devDependencies": { 32 | "chai": "^3.5.0", 33 | "mocha": "^2.4.5", 34 | "mocha-lcov-reporter": "^1.2.0" 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2019 Aleen 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /lib/start.js: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | * _ 3 | * _____ _ ____ _ |_| 4 | * | _ |/ \ ____ ____ __ ___ / ___\/ \ __ _ ____ _ 5 | * | |_| || | / __ \/ __ \\ '_ \ _ / / | |___\ \ | |/ __ \| | 6 | * | _ || |__. ___/. ___/| | | ||_|\ \___ | _ | |_| |. ___/| | 7 | * |_/ \_|\___/\____|\____||_| |_| \____/|_| |_|_____|\____||_| 8 | * 9 | * ================================================================ 10 | * More than a coder, More than a designer 11 | * ================================================================ 12 | * 13 | * 14 | * - Document: start.js 15 | * - Author: aleen42 16 | * - Description: for shell script to use 17 | * - Create Time: Apr 13rd, 2016 18 | * - Update Time: Oct 24th, 2019 19 | * 20 | * 21 | **********************************************************************/ 22 | 23 | const {execFileSync} = require('child_process'); 24 | 25 | const [, , repo, path] = process.argv; 26 | require('./index').run({path}, cwd => { 27 | const time = new Date().valueOf(); 28 | execFileSync('git', ['remote', 'add', time, repo], {cwd}); 29 | execFileSync('git', ['push', time, 'head', '-f'], {cwd}); 30 | execFileSync('rm', ['-rf', cwd]); 31 | }); 32 | -------------------------------------------------------------------------------- /test/index.js: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | * _ 3 | * _____ _ ____ _ |_| 4 | * | _ |/ \ ____ ____ __ ___ / ___\/ \ __ _ ____ _ 5 | * | |_| || | / __ \/ __ \\ '_ \ _ / / | |___\ \ | |/ __ \| | 6 | * | _ || |__. ___/. ___/| | | ||_|\ \___ | _ | |_| |. ___/| | 7 | * |_/ \_|\___/\____|\____||_| |_| \____/|_| |_|_____|\____||_| 8 | * 9 | * ================================================================ 10 | * More than a coder, More than a designer 11 | * ================================================================ 12 | * 13 | * 14 | * - Document: index.js 15 | * - Author: aleen42 16 | * - Description: this is the entrace of some tests 17 | * - Create Time: Apr 13th, 2016 18 | * - Update Time: Apr 13th, 2016 19 | * 20 | * 21 | **********************************************************************/ 22 | 23 | /** 24 | * [autoContribution: import the module] 25 | * @type {Object} 26 | */ 27 | const autoContribution = require("../lib/index"); 28 | 29 | /** 30 | * [should: test framework module] 31 | * @type {Object} 32 | */ 33 | const should = require('chai').should(); 34 | 35 | describe('tests', function () { 36 | it('test case 1', function () { 37 | autoContribution.test('{\"coordinates\": [{\"x\": 3,\"y\": 3}],\"commitsPerDay\": 1}').should.equal('null'); 38 | }); 39 | 40 | it('test case 2', function () { 41 | autoContribution.test('{\"coordinates\": [{\"x\": 34,\"y\": 3}],\"commitsPerDay\": 2}').should.equal('null'); 42 | }); 43 | }); 44 | -------------------------------------------------------------------------------- /lib/index.js: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | * _ 3 | * _____ _ ____ _ |_| 4 | * | _ |/ \ ____ ____ __ ___ / ___\/ \ __ _ ____ _ 5 | * | |_| || | / __ \/ __ \\ '_ \ _ / / | |___\ \ | |/ __ \| | 6 | * | _ || |__. ___/. ___/| | | ||_|\ \___ | _ | |_| |. ___/| | 7 | * |_/ \_|\___/\____|\____||_| |_| \____/|_| |_|_____|\____||_| 8 | * 9 | * ================================================================ 10 | * More than a coder, More than a designer 11 | * ================================================================ 12 | * 13 | * 14 | * - Document: index.js 15 | * - Author: aleen42 16 | * - Description: the main entrance for automatically generating repo 17 | * and return the path 18 | * - Create Time: Apr 13rd, 2016 19 | * - Update Time: Oct 24th, 2019 20 | * 21 | * 22 | **********************************************************************/ 23 | 24 | /** 25 | * [Contributions: gh-contributions module] 26 | * @type {Object} 27 | */ 28 | const Contributions = require("./../node_modules/gh-contributions/lib/contributions"); 29 | 30 | /** 31 | * [fs: file system module] 32 | * @type {Object} 33 | */ 34 | const fs = require('fs'); 35 | 36 | /** 37 | * [progressBar: a module to shopw progress] 38 | * @type {Object} 39 | */ 40 | const progressBar = require('progress'); 41 | 42 | const bar = new progressBar('generating [:bar] :situation', { 43 | complete: '=', 44 | incomplete: ' ', 45 | width: 40, 46 | total: 100 47 | }); 48 | 49 | module.exports = { 50 | run: function ({path}, callback) { 51 | let currentProgress = 0; 52 | 53 | /** Generate repository */ 54 | let parseData; 55 | try { 56 | parseData = JSON.parse(fs.readFileSync(path, 'utf8')); 57 | } catch (error) { 58 | console.log(`[${error}]`); 59 | return; 60 | } 61 | 62 | Contributions(parseData, (err, repoLink) => { 63 | if (err) { 64 | console.log(err); 65 | return; 66 | } 67 | 68 | callback(repoLink) 69 | }, progress => { 70 | bar.tick(progress - currentProgress, {situation: `${progress.toFixed(2)}%`}); 71 | currentProgress = progress; 72 | }); 73 | }, 74 | /** Store output info */ 75 | test: testCase => Contributions(JSON.parse(testCase), err => err, () => {}) || 'null' 76 | }; 77 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## auto-contribution 2 | 3 | [![Pay](https://img.shields.io/badge/%24-free-%23a10000.svg)](#) [![GitHub issues](https://img.shields.io/github/issues/aleen42/auto-contribution.svg)](https://github.com/aleen42/auto-contribution/issues) [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/aleen42/auto-contribution/master/LICENSE) [![Gitter](https://badges.gitter.im/aleen42/auto-contribution.svg)](https://gitter.im/aleen42/auto-contribution?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) 4 | 5 | [![npm version](https://badge.fury.io/js/auto-contribution.svg)](https://badge.fury.io/js/auto-contribution) [![Build Status](https://travis-ci.org/aleen42/auto-contribution.svg?branch=master)](https://travis-ci.org/aleen42/auto-contribution) [![npm](https://img.shields.io/npm/dt/auto-contribution.svg)](https://www.npmjs.com/package/auto-contribution) 6 | 7 | 8 | 9 | a node.js module for automatically generating contributions on github without worrying about its movement in the next week. which is **only used on Linux OS.** 10 | 11 | ### Installation 12 | 13 | #### NPM Installation 14 | 15 | ```bash 16 | npm install auto-contribution 17 | cd ./node_modules/auto-contribution 18 | npm i 19 | ``` 20 | 21 | #### Clone Installation 22 | 23 | ```bash 24 | git clone https://github.com/aleen42/auto-contribution.git 25 | cd auto-contribution 26 | npm i 27 | ``` 28 | 29 | ### Usage 30 | 31 | 1. Create a repository to store generated commits history. 32 | 33 | 2. Install dependencies: 34 | 35 | ```bash 36 | npm i --no-save 37 | ``` 38 | 39 | 3. Create a json file with [**IonicaBizau/github-contributions**](https://github.com/IonicaBizau/github-contributions) 40 | 41 | Run server. 42 | 43 | ```bash 44 | npm run server 45 | ``` 46 | 47 | And visit the website `http://localhost:9000`. 48 | 49 | Build up a colorful calendar for yourself, and then generate json data, which should be store into a json file. 50 | 51 | 4. Start to update with root mode 52 | 53 | ```bash 54 | npm run start 55 | 56 | # example: npm start git@github.com:aleen42/contribution.git example.json 57 | ``` 58 | 59 | - *repo-url under SSH: the repo url should be under SSH protocol like `git@github.com:aleen42/contribution.git` so that we can run the script in a **crontab** task.* 60 | - *coordinates data json file path: you should put your data generated by [**IonicaBizau/github-contributions**](https://github.com/IonicaBizau/github-contributions) into a json file and give the path of it, and here is an [example](./example.json) of json file of aboved result* 61 | 62 | If you set up all the things and it should run like this, and waiting for the result cause it will behave so slow when your `commitsPerDay` is large. 63 | 64 | 5. Without any problems of updating remote repository, you can use `crontab` to set this script in the root mode to automatically update every week like this: 65 | 66 | ```bash 67 | # su 68 | # crontab -e 69 | 70 | # Edit this file to introduce tasks to be run by cron. 71 | # 72 | # Each task to run has to be defined through a single line 73 | # indicating with different fields when the task will be run 74 | # and what command to run for the task 75 | # 76 | # To define the time you can provide concrete values for 77 | # minute (m), hour (h), day of month (dom), month (mon), 78 | # and day of week (dow) or use '*' in these fields (for 'any').# 79 | # Notice that tasks will be started based on the cron's system 80 | # daemon's notion of time and timezones. 81 | # 82 | # Output of the crontab jobs (including errors) is sent through 83 | # email to the user the crontab file belongs to (unless redirected). 84 | # 85 | # For example, you can run a backup of all your user accounts 86 | # at 5 a.m every week with: 87 | # 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/ 88 | # 89 | # For more information see the manual pages of crontab(5) and cron(8) 90 | # 91 | # m h dom mon dow command 92 | 0 0 * * 0 cd /opt/lampp/htdocs/auto-contribution && npm start git@github.com:aleen42/contribution.git example.json 93 | ``` 94 | 95 | ### Tests 96 | 97 | ```bash 98 | npm run test 99 | ``` 100 | 101 | *Notice that: the repository generated with test case will be in `./auto-contribution/node_modules/gh-contributions/lib/public/repos/`* 102 | 103 | ### Released 104 | 105 | * 1.0.0 Initial release 106 | * 1.1.0 Catch some exceptions 107 | * 1.1.1 Update readme.md 108 | * 1.2.0 Add progress to improve interaction 109 | * 1.2.1 Update readme.md 110 | 111 | ### :fuelpump: How to contribute 112 | 113 | Have an idea? Found a bug? See [how to contribute](https://aleen42.github.io/PersonalWiki/contribution.html). 114 | 115 | ### :scroll: License 116 | 117 | [MIT](https://aleen42.github.io/PersonalWiki/MIT.html) © aleen42 118 | -------------------------------------------------------------------------------- /example.json: -------------------------------------------------------------------------------- 1 | { 2 | "coordinates": [ 3 | { 4 | "x": 5, 5 | "y": 2 6 | }, 7 | { 8 | "x": 5, 9 | "y": 6 10 | }, 11 | { 12 | "x": 6, 13 | "y": 2 14 | }, 15 | { 16 | "x": 6, 17 | "y": 3 18 | }, 19 | { 20 | "x": 6, 21 | "y": 4 22 | }, 23 | { 24 | "x": 6, 25 | "y": 5 26 | }, 27 | { 28 | "x": 6, 29 | "y": 6 30 | }, 31 | { 32 | "x": 7, 33 | "y": 6 34 | }, 35 | { 36 | "x": 10, 37 | "y": 2 38 | }, 39 | { 40 | "x": 10, 41 | "y": 3 42 | }, 43 | { 44 | "x": 10, 45 | "y": 4 46 | }, 47 | { 48 | "x": 10, 49 | "y": 5 50 | }, 51 | { 52 | "x": 10, 53 | "y": 6 54 | }, 55 | { 56 | "x": 11, 57 | "y": 2 58 | }, 59 | { 60 | "x": 11, 61 | "y": 6 62 | }, 63 | { 64 | "x": 12, 65 | "y": 2 66 | }, 67 | { 68 | "x": 12, 69 | "y": 6 70 | }, 71 | { 72 | "x": 13, 73 | "y": 2 74 | }, 75 | { 76 | "x": 13, 77 | "y": 3 78 | }, 79 | { 80 | "x": 13, 81 | "y": 4 82 | }, 83 | { 84 | "x": 13, 85 | "y": 5 86 | }, 87 | { 88 | "x": 13, 89 | "y": 6 90 | }, 91 | { 92 | "x": 16, 93 | "y": 2 94 | }, 95 | { 96 | "x": 16, 97 | "y": 6 98 | }, 99 | { 100 | "x": 17, 101 | "y": 2 102 | }, 103 | { 104 | "x": 17, 105 | "y": 5 106 | }, 107 | { 108 | "x": 17, 109 | "y": 6 110 | }, 111 | { 112 | "x": 18, 113 | "y": 2 114 | }, 115 | { 116 | "x": 18, 117 | "y": 4 118 | }, 119 | { 120 | "x": 18, 121 | "y": 6 122 | }, 123 | { 124 | "x": 19, 125 | "y": 2 126 | }, 127 | { 128 | "x": 19, 129 | "y": 3 130 | }, 131 | { 132 | "x": 19, 133 | "y": 6 134 | }, 135 | { 136 | "x": 22, 137 | "y": 2 138 | }, 139 | { 140 | "x": 22, 141 | "y": 3 142 | }, 143 | { 144 | "x": 22, 145 | "y": 4 146 | }, 147 | { 148 | "x": 22, 149 | "y": 5 150 | }, 151 | { 152 | "x": 23, 153 | "y": 5 154 | }, 155 | { 156 | "x": 24, 157 | "y": 5 158 | }, 159 | { 160 | "x": 25, 161 | "y": 2 162 | }, 163 | { 164 | "x": 25, 165 | "y": 3 166 | }, 167 | { 168 | "x": 25, 169 | "y": 4 170 | }, 171 | { 172 | "x": 25, 173 | "y": 5 174 | }, 175 | { 176 | "x": 25, 177 | "y": 6 178 | }, 179 | { 180 | "x": 28, 181 | "y": 2 182 | }, 183 | { 184 | "x": 29, 185 | "y": 1 186 | }, 187 | { 188 | "x": 29, 189 | "y": 2 190 | }, 191 | { 192 | "x": 29, 193 | "y": 3 194 | }, 195 | { 196 | "x": 30, 197 | "y": 2 198 | }, 199 | { 200 | "x": 30, 201 | "y": 3 202 | }, 203 | { 204 | "x": 30, 205 | "y": 4 206 | }, 207 | { 208 | "x": 31, 209 | "y": 1 210 | }, 211 | { 212 | "x": 31, 213 | "y": 2 214 | }, 215 | { 216 | "x": 31, 217 | "y": 3 218 | }, 219 | { 220 | "x": 32, 221 | "y": 2 222 | }, 223 | { 224 | "x": 35, 225 | "y": 4 226 | }, 227 | { 228 | "x": 35, 229 | "y": 7 230 | }, 231 | { 232 | "x": 36, 233 | "y": 4 234 | }, 235 | { 236 | "x": 36, 237 | "y": 6 238 | }, 239 | { 240 | "x": 36, 241 | "y": 7 242 | }, 243 | { 244 | "x": 37, 245 | "y": 4 246 | }, 247 | { 248 | "x": 37, 249 | "y": 5 250 | }, 251 | { 252 | "x": 37, 253 | "y": 7 254 | }, 255 | { 256 | "x": 39, 257 | "y": 4 258 | }, 259 | { 260 | "x": 39, 261 | "y": 5 262 | }, 263 | { 264 | "x": 39, 265 | "y": 6 266 | }, 267 | { 268 | "x": 39, 269 | "y": 7 270 | }, 271 | { 272 | "x": 40, 273 | "y": 4 274 | }, 275 | { 276 | "x": 40, 277 | "y": 7 278 | }, 279 | { 280 | "x": 41, 281 | "y": 4 282 | }, 283 | { 284 | "x": 41, 285 | "y": 5 286 | }, 287 | { 288 | "x": 41, 289 | "y": 6 290 | }, 291 | { 292 | "x": 41, 293 | "y": 7 294 | }, 295 | { 296 | "x": 43, 297 | "y": 4 298 | }, 299 | { 300 | "x": 43, 301 | "y": 7 302 | }, 303 | { 304 | "x": 44, 305 | "y": 4 306 | }, 307 | { 308 | "x": 44, 309 | "y": 5 310 | }, 311 | { 312 | "x": 44, 313 | "y": 6 314 | }, 315 | { 316 | "x": 44, 317 | "y": 7 318 | }, 319 | { 320 | "x": 45, 321 | "y": 7 322 | }, 323 | { 324 | "x": 47, 325 | "y": 4 326 | }, 327 | { 328 | "x": 47, 329 | "y": 5 330 | }, 331 | { 332 | "x": 47, 333 | "y": 6 334 | }, 335 | { 336 | "x": 48, 337 | "y": 4 338 | }, 339 | { 340 | "x": 48, 341 | "y": 6 342 | }, 343 | { 344 | "x": 49, 345 | "y": 4 346 | }, 347 | { 348 | "x": 49, 349 | "y": 5 350 | }, 351 | { 352 | "x": 49, 353 | "y": 6 354 | }, 355 | { 356 | "x": 49, 357 | "y": 7 358 | } 359 | ], 360 | "commitsPerDay": 100 361 | } --------------------------------------------------------------------------------