├── .gitignore ├── LICENSE ├── README.md ├── action.yml ├── assets └── todoist-stat.png ├── dist └── index.js ├── exec.js ├── index.js ├── package-lock.json └── package.json /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | lerna-debug.log* 8 | 9 | # Diagnostic reports (https://nodejs.org/api/report.html) 10 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 11 | 12 | # Runtime data 13 | pids 14 | *.pid 15 | *.seed 16 | *.pid.lock 17 | 18 | # Directory for instrumented libs generated by jscoverage/JSCover 19 | lib-cov 20 | 21 | # Coverage directory used by tools like istanbul 22 | coverage 23 | *.lcov 24 | 25 | # nyc test coverage 26 | .nyc_output 27 | 28 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 29 | .grunt 30 | 31 | # Bower dependency directory (https://bower.io/) 32 | bower_components 33 | 34 | # node-waf configuration 35 | .lock-wscript 36 | 37 | # Compiled binary addons (https://nodejs.org/api/addons.html) 38 | build/Release 39 | 40 | # Dependency directories 41 | node_modules/ 42 | jspm_packages/ 43 | 44 | # Snowpack dependency directory (https://snowpack.dev/) 45 | web_modules/ 46 | 47 | # TypeScript cache 48 | *.tsbuildinfo 49 | 50 | # Optional npm cache directory 51 | .npm 52 | 53 | # Optional eslint cache 54 | .eslintcache 55 | 56 | # Microbundle cache 57 | .rpt2_cache/ 58 | .rts2_cache_cjs/ 59 | .rts2_cache_es/ 60 | .rts2_cache_umd/ 61 | 62 | # Optional REPL history 63 | .node_repl_history 64 | 65 | # Output of 'npm pack' 66 | *.tgz 67 | 68 | # Yarn Integrity file 69 | .yarn-integrity 70 | 71 | # dotenv environment variables file 72 | .env 73 | .env.test 74 | 75 | # parcel-bundler cache (https://parceljs.org/) 76 | .cache 77 | .parcel-cache 78 | 79 | # Next.js build output 80 | .next 81 | out 82 | 83 | # Nuxt.js build / generate output 84 | .nuxt 85 | 86 | # Gatsby files 87 | .cache/ 88 | # Comment in the public line in if your project uses Gatsby and not Next.js 89 | # https://nextjs.org/blog/next-9-1#public-directory-support 90 | # public 91 | 92 | # vuepress build output 93 | .vuepress/dist 94 | 95 | # Serverless directories 96 | .serverless/ 97 | 98 | # FuseBox cache 99 | .fusebox/ 100 | 101 | # DynamoDB Local files 102 | .dynamodb/ 103 | 104 | # TernJS port file 105 | .tern-port 106 | 107 | # Stores VSCode versions used for testing VSCode extensions 108 | .vscode-test 109 | 110 | # yarn v2 111 | .yarn/cache 112 | .yarn/unplugged 113 | .yarn/build-state.yml 114 | .yarn/install-state.gz 115 | .pnp.* -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Creative Commons Legal Code 2 | 3 | CC0 1.0 Universal 4 | 5 | CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE 6 | LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN 7 | ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS 8 | INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES 9 | REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS 10 | PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM 11 | THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED 12 | HEREUNDER. 13 | 14 | Statement of Purpose 15 | 16 | The laws of most jurisdictions throughout the world automatically confer 17 | exclusive Copyright and Related Rights (defined below) upon the creator 18 | and subsequent owner(s) (each and all, an "owner") of an original work of 19 | authorship and/or a database (each, a "Work"). 20 | 21 | Certain owners wish to permanently relinquish those rights to a Work for 22 | the purpose of contributing to a commons of creative, cultural and 23 | scientific works ("Commons") that the public can reliably and without fear 24 | of later claims of infringement build upon, modify, incorporate in other 25 | works, reuse and redistribute as freely as possible in any form whatsoever 26 | and for any purposes, including without limitation commercial purposes. 27 | These owners may contribute to the Commons to promote the ideal of a free 28 | culture and the further production of creative, cultural and scientific 29 | works, or to gain reputation or greater distribution for their Work in 30 | part through the use and efforts of others. 31 | 32 | For these and/or other purposes and motivations, and without any 33 | expectation of additional consideration or compensation, the person 34 | associating CC0 with a Work (the "Affirmer"), to the extent that he or she 35 | is an owner of Copyright and Related Rights in the Work, voluntarily 36 | elects to apply CC0 to the Work and publicly distribute the Work under its 37 | terms, with knowledge of his or her Copyright and Related Rights in the 38 | Work and the meaning and intended legal effect of CC0 on those rights. 39 | 40 | 1. Copyright and Related Rights. A Work made available under CC0 may be 41 | protected by copyright and related or neighboring rights ("Copyright and 42 | Related Rights"). Copyright and Related Rights include, but are not 43 | limited to, the following: 44 | 45 | i. the right to reproduce, adapt, distribute, perform, display, 46 | communicate, and translate a Work; 47 | ii. moral rights retained by the original author(s) and/or performer(s); 48 | iii. publicity and privacy rights pertaining to a person's image or 49 | likeness depicted in a Work; 50 | iv. rights protecting against unfair competition in regards to a Work, 51 | subject to the limitations in paragraph 4(a), below; 52 | v. rights protecting the extraction, dissemination, use and reuse of data 53 | in a Work; 54 | vi. database rights (such as those arising under Directive 96/9/EC of the 55 | European Parliament and of the Council of 11 March 1996 on the legal 56 | protection of databases, and under any national implementation 57 | thereof, including any amended or successor version of such 58 | directive); and 59 | vii. other similar, equivalent or corresponding rights throughout the 60 | world based on applicable law or treaty, and any national 61 | implementations thereof. 62 | 63 | 2. Waiver. To the greatest extent permitted by, but not in contravention 64 | of, applicable law, Affirmer hereby overtly, fully, permanently, 65 | irrevocably and unconditionally waives, abandons, and surrenders all of 66 | Affirmer's Copyright and Related Rights and associated claims and causes 67 | of action, whether now known or unknown (including existing as well as 68 | future claims and causes of action), in the Work (i) in all territories 69 | worldwide, (ii) for the maximum duration provided by applicable law or 70 | treaty (including future time extensions), (iii) in any current or future 71 | medium and for any number of copies, and (iv) for any purpose whatsoever, 72 | including without limitation commercial, advertising or promotional 73 | purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each 74 | member of the public at large and to the detriment of Affirmer's heirs and 75 | successors, fully intending that such Waiver shall not be subject to 76 | revocation, rescission, cancellation, termination, or any other legal or 77 | equitable action to disrupt the quiet enjoyment of the Work by the public 78 | as contemplated by Affirmer's express Statement of Purpose. 79 | 80 | 3. Public License Fallback. Should any part of the Waiver for any reason 81 | be judged legally invalid or ineffective under applicable law, then the 82 | Waiver shall be preserved to the maximum extent permitted taking into 83 | account Affirmer's express Statement of Purpose. In addition, to the 84 | extent the Waiver is so judged Affirmer hereby grants to each affected 85 | person a royalty-free, non transferable, non sublicensable, non exclusive, 86 | irrevocable and unconditional license to exercise Affirmer's Copyright and 87 | Related Rights in the Work (i) in all territories worldwide, (ii) for the 88 | maximum duration provided by applicable law or treaty (including future 89 | time extensions), (iii) in any current or future medium and for any number 90 | of copies, and (iv) for any purpose whatsoever, including without 91 | limitation commercial, advertising or promotional purposes (the 92 | "License"). The License shall be deemed effective as of the date CC0 was 93 | applied by Affirmer to the Work. Should any part of the License for any 94 | reason be judged legally invalid or ineffective under applicable law, such 95 | partial invalidity or ineffectiveness shall not invalidate the remainder 96 | of the License, and in such case Affirmer hereby affirms that he or she 97 | will not (i) exercise any of his or her remaining Copyright and Related 98 | Rights in the Work or (ii) assert any associated claims and causes of 99 | action with respect to the Work, in either case contrary to Affirmer's 100 | express Statement of Purpose. 101 | 102 | 4. Limitations and Disclaimers. 103 | 104 | a. No trademark or patent rights held by Affirmer are waived, abandoned, 105 | surrendered, licensed or otherwise affected by this document. 106 | b. Affirmer offers the Work as-is and makes no representations or 107 | warranties of any kind concerning the Work, express, implied, 108 | statutory or otherwise, including without limitation warranties of 109 | title, merchantability, fitness for a particular purpose, non 110 | infringement, or the absence of latent or other defects, accuracy, or 111 | the present or absence of errors, whether or not discoverable, all to 112 | the greatest extent permissible under applicable law. 113 | c. Affirmer disclaims responsibility for clearing rights of other persons 114 | that may apply to the Work or any use thereof, including without 115 | limitation any person's Copyright and Related Rights in the Work. 116 | Further, Affirmer disclaims responsibility for obtaining any necessary 117 | consents, permissions or other rights required for any use of the 118 | Work. 119 | d. Affirmer understands and acknowledges that Creative Commons is not a 120 | party to this document and has no duty or obligation with respect to 121 | this CC0 or use of the Work. 122 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | 3 |

🚧 Todoist Stats

4 |

⚡️📌 Update your Todoist Stats ✅

5 |

6 | 7 | --- 8 | 9 | ## Setup 10 | 11 | ### Prep work 12 | 13 | 1. You'll need a Todoist API Token. You can get that from [here](https://beta.todoist.com/prefs/integrations) 14 | - if you're new to Todoist, then you can refer [here](#new-to-todoist). 15 | 2. You need to save the Todoist API Token in the repository secrets. You can find that in the Settings of your Repository. Be sure to save those as the following. 16 | - `TODOIST_API_KEY = ` 17 | 3. You need to update the README file(README.md) with 2 comments. You can refer [here](#update-your-readme) for updating it. 18 | 19 | ## Update your README 20 | 21 | Add a comment to your `README.md` like this: 22 | 23 | ```markdown 24 | # Todoist Stats 25 | 26 | 27 | 28 | ``` 29 | 30 | These lines will be our entry-points for the todoist stats. 31 | 32 | ## New to Todoist 33 | 34 | Todoist gives you the confidence that everything’s organized and accounted for, so you can make progress on the things that are important to you. 35 | 36 | - Create a Todoist account from [here](https://todoist.com/users/showregister) 37 | - Get your Todoist API Key from your [here](https://beta.todoist.com/prefs/integrations) 38 | 39 | ### Repository Workflow For Non-Premium Users 40 | 41 | Please follow the steps below: 42 | 43 | 1. Go to your `//actions`, hit `New workflow`, `set up a workflow yourself`, delete all the default content github made for you. 44 | 2. Copy the following code and paste it to your new workflow you created at step 1: 45 | 46 | ```yml 47 | name: Todoist Readme 48 | 49 | on: 50 | workflow_dispatch: 51 | schedule: 52 | # Runs every minute 53 | - cron: "* * * * *" 54 | 55 | jobs: 56 | update-readme: 57 | name: Update todoist stats 58 | runs-on: ubuntu-latest 59 | steps: 60 | - uses: actions/checkout@v2 61 | - uses: abhisheknaiidu/todoist-readme@master 62 | with: 63 | TODOIST_API_KEY: ${{ secrets.TODOIST_API_KEY }} 64 | PREMIUM: "" 65 | ``` 66 | 67 | 3. Go to your repo secrets by hitting `Settings => Secrets` tab in your profile repo. You can also enter the url https://github.com/USERNAME/USERNAME/settings/secrets . Please replace the `USERNAME` with your own username. 68 | 4. Create a new `Secret`. `Name`: `TODOIST_API_KEY`, `Value`: Paste the Todoist API Token here. If you don't know what is the token, please go to [here](https://beta.todoist.com/prefs/integrations) to find your API Key there. 69 | 5. Add a comment to your `README.md` like this: 70 | 71 | ```markdown 72 | # Todoist Stats 73 | 74 | 75 | 76 | ``` 77 | 78 | 6. Go to Workflows menu (mentioned in step 1), click `Todoist Readme`, and click `Run workflow`. 79 | 7. Go to your profile page. you will be able to see it. 80 | 81 | ### Repository Workflow For Premium Users 82 | 83 | Please follow the steps below: 84 | 85 | 1. Go to your `//actions`, hit `New workflow`, `set up a workflow yourself`, delete all the default content github made for you. 86 | 2. Copy the following code and paste it to your new workflow you created at step 1: 87 | 88 | ```yml 89 | name: Todoist Readme 90 | 91 | on: 92 | workflow_dispatch: 93 | schedule: 94 | # Runs every minute 95 | - cron: "* * * * *" 96 | 97 | jobs: 98 | update-readme: 99 | name: Update todoist stats 100 | runs-on: ubuntu-latest 101 | steps: 102 | - uses: actions/checkout@v2 103 | - uses: abhisheknaiidu/todoist-readme@master 104 | with: 105 | TODOIST_API_KEY: ${{ secrets.TODOIST_API_KEY }} 106 | PREMIUM: true 107 | ``` 108 | 109 | 3. Remaining Steps will be same as Non-Premium Users. 110 | 111 | ## License 112 | 113 | [![CC0](https://licensebuttons.net/p/zero/1.0/88x31.png)](https://creativecommons.org/publicdomain/zero/1.0/) 114 | 115 | To the extent possible under law, [Abhishek Naidu](https://abhisheknaidu.tech/) has waived all copyright and related or neighboring rights to this work. 116 | 117 | _Inspired by [yg/todoist-box](https://github.com/yg/todoist-box)_ 118 | 119 | _Inspired by [gautamkrishnar/blog-post-workflow](https://github.com/gautamkrishnar/blog-post-workflow)_ 120 | -------------------------------------------------------------------------------- /action.yml: -------------------------------------------------------------------------------- 1 | name: 'Todoist Readme' 2 | author: Abhishek Naidu 3 | description: '🚧 Updates README with your Todoist stats' 4 | 5 | inputs: 6 | TODOIST_API_KEY: 7 | description: 'Your Todoist API Key' 8 | required: true 9 | 10 | USERNAME: 11 | description: 'Your GitHub username' 12 | default: ${{ github.repository_owner }} 13 | required: false 14 | 15 | PREMIUM: 16 | description: 'Premium User or Not' 17 | default: false 18 | required: false 19 | 20 | runs: 21 | using: "node12" 22 | main: "dist/index.js" 23 | 24 | branding: 25 | icon: "activity" 26 | color: "red" 27 | -------------------------------------------------------------------------------- /assets/todoist-stat.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhisheknaiidu/todoist-readme/1bb2f39a26dd5e1141a7b08ba53f3a1b1b288185/assets/todoist-stat.png -------------------------------------------------------------------------------- /dist/index.js: -------------------------------------------------------------------------------- 1 | module.exports = 2 | /******/ (function(modules, runtime) { // webpackBootstrap 3 | /******/ "use strict"; 4 | /******/ // The module cache 5 | /******/ var installedModules = {}; 6 | /******/ 7 | /******/ // The require function 8 | /******/ function __webpack_require__(moduleId) { 9 | /******/ 10 | /******/ // Check if module is in cache 11 | /******/ if(installedModules[moduleId]) { 12 | /******/ return installedModules[moduleId].exports; 13 | /******/ } 14 | /******/ // Create a new module (and put it into the cache) 15 | /******/ var module = installedModules[moduleId] = { 16 | /******/ i: moduleId, 17 | /******/ l: false, 18 | /******/ exports: {} 19 | /******/ }; 20 | /******/ 21 | /******/ // Execute the module function 22 | /******/ var threw = true; 23 | /******/ try { 24 | /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); 25 | /******/ threw = false; 26 | /******/ } finally { 27 | /******/ if(threw) delete installedModules[moduleId]; 28 | /******/ } 29 | /******/ 30 | /******/ // Flag the module as loaded 31 | /******/ module.l = true; 32 | /******/ 33 | /******/ // Return the exports of the module 34 | /******/ return module.exports; 35 | /******/ } 36 | /******/ 37 | /******/ 38 | /******/ __webpack_require__.ab = __dirname + "/"; 39 | /******/ 40 | /******/ // the startup function 41 | /******/ function startup() { 42 | /******/ // Load entry module and return exports 43 | /******/ return __webpack_require__(104); 44 | /******/ }; 45 | /******/ 46 | /******/ // run startup 47 | /******/ return startup(); 48 | /******/ }) 49 | /************************************************************************/ 50 | /******/ ({ 51 | 52 | /***/ 26: 53 | /***/ (function(module, __unusedexports, __webpack_require__) { 54 | 55 | "use strict"; 56 | 57 | 58 | var enhanceError = __webpack_require__(369); 59 | 60 | /** 61 | * Create an Error with the specified message, config, error code, request and response. 62 | * 63 | * @param {string} message The error message. 64 | * @param {Object} config The config. 65 | * @param {string} [code] The error code (for example, 'ECONNABORTED'). 66 | * @param {Object} [request] The request. 67 | * @param {Object} [response] The response. 68 | * @returns {Error} The created error. 69 | */ 70 | module.exports = function createError(message, config, code, request, response) { 71 | var error = new Error(message); 72 | return enhanceError(error, config, code, request, response); 73 | }; 74 | 75 | 76 | /***/ }), 77 | 78 | /***/ 35: 79 | /***/ (function(module, __unusedexports, __webpack_require__) { 80 | 81 | "use strict"; 82 | 83 | 84 | var bind = __webpack_require__(727); 85 | 86 | /*global toString:true*/ 87 | 88 | // utils is a library of generic helper functions non-specific to axios 89 | 90 | var toString = Object.prototype.toString; 91 | 92 | /** 93 | * Determine if a value is an Array 94 | * 95 | * @param {Object} val The value to test 96 | * @returns {boolean} True if value is an Array, otherwise false 97 | */ 98 | function isArray(val) { 99 | return toString.call(val) === '[object Array]'; 100 | } 101 | 102 | /** 103 | * Determine if a value is undefined 104 | * 105 | * @param {Object} val The value to test 106 | * @returns {boolean} True if the value is undefined, otherwise false 107 | */ 108 | function isUndefined(val) { 109 | return typeof val === 'undefined'; 110 | } 111 | 112 | /** 113 | * Determine if a value is a Buffer 114 | * 115 | * @param {Object} val The value to test 116 | * @returns {boolean} True if value is a Buffer, otherwise false 117 | */ 118 | function isBuffer(val) { 119 | return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor) 120 | && typeof val.constructor.isBuffer === 'function' && val.constructor.isBuffer(val); 121 | } 122 | 123 | /** 124 | * Determine if a value is an ArrayBuffer 125 | * 126 | * @param {Object} val The value to test 127 | * @returns {boolean} True if value is an ArrayBuffer, otherwise false 128 | */ 129 | function isArrayBuffer(val) { 130 | return toString.call(val) === '[object ArrayBuffer]'; 131 | } 132 | 133 | /** 134 | * Determine if a value is a FormData 135 | * 136 | * @param {Object} val The value to test 137 | * @returns {boolean} True if value is an FormData, otherwise false 138 | */ 139 | function isFormData(val) { 140 | return (typeof FormData !== 'undefined') && (val instanceof FormData); 141 | } 142 | 143 | /** 144 | * Determine if a value is a view on an ArrayBuffer 145 | * 146 | * @param {Object} val The value to test 147 | * @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false 148 | */ 149 | function isArrayBufferView(val) { 150 | var result; 151 | if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) { 152 | result = ArrayBuffer.isView(val); 153 | } else { 154 | result = (val) && (val.buffer) && (val.buffer instanceof ArrayBuffer); 155 | } 156 | return result; 157 | } 158 | 159 | /** 160 | * Determine if a value is a String 161 | * 162 | * @param {Object} val The value to test 163 | * @returns {boolean} True if value is a String, otherwise false 164 | */ 165 | function isString(val) { 166 | return typeof val === 'string'; 167 | } 168 | 169 | /** 170 | * Determine if a value is a Number 171 | * 172 | * @param {Object} val The value to test 173 | * @returns {boolean} True if value is a Number, otherwise false 174 | */ 175 | function isNumber(val) { 176 | return typeof val === 'number'; 177 | } 178 | 179 | /** 180 | * Determine if a value is an Object 181 | * 182 | * @param {Object} val The value to test 183 | * @returns {boolean} True if value is an Object, otherwise false 184 | */ 185 | function isObject(val) { 186 | return val !== null && typeof val === 'object'; 187 | } 188 | 189 | /** 190 | * Determine if a value is a plain Object 191 | * 192 | * @param {Object} val The value to test 193 | * @return {boolean} True if value is a plain Object, otherwise false 194 | */ 195 | function isPlainObject(val) { 196 | if (toString.call(val) !== '[object Object]') { 197 | return false; 198 | } 199 | 200 | var prototype = Object.getPrototypeOf(val); 201 | return prototype === null || prototype === Object.prototype; 202 | } 203 | 204 | /** 205 | * Determine if a value is a Date 206 | * 207 | * @param {Object} val The value to test 208 | * @returns {boolean} True if value is a Date, otherwise false 209 | */ 210 | function isDate(val) { 211 | return toString.call(val) === '[object Date]'; 212 | } 213 | 214 | /** 215 | * Determine if a value is a File 216 | * 217 | * @param {Object} val The value to test 218 | * @returns {boolean} True if value is a File, otherwise false 219 | */ 220 | function isFile(val) { 221 | return toString.call(val) === '[object File]'; 222 | } 223 | 224 | /** 225 | * Determine if a value is a Blob 226 | * 227 | * @param {Object} val The value to test 228 | * @returns {boolean} True if value is a Blob, otherwise false 229 | */ 230 | function isBlob(val) { 231 | return toString.call(val) === '[object Blob]'; 232 | } 233 | 234 | /** 235 | * Determine if a value is a Function 236 | * 237 | * @param {Object} val The value to test 238 | * @returns {boolean} True if value is a Function, otherwise false 239 | */ 240 | function isFunction(val) { 241 | return toString.call(val) === '[object Function]'; 242 | } 243 | 244 | /** 245 | * Determine if a value is a Stream 246 | * 247 | * @param {Object} val The value to test 248 | * @returns {boolean} True if value is a Stream, otherwise false 249 | */ 250 | function isStream(val) { 251 | return isObject(val) && isFunction(val.pipe); 252 | } 253 | 254 | /** 255 | * Determine if a value is a URLSearchParams object 256 | * 257 | * @param {Object} val The value to test 258 | * @returns {boolean} True if value is a URLSearchParams object, otherwise false 259 | */ 260 | function isURLSearchParams(val) { 261 | return typeof URLSearchParams !== 'undefined' && val instanceof URLSearchParams; 262 | } 263 | 264 | /** 265 | * Trim excess whitespace off the beginning and end of a string 266 | * 267 | * @param {String} str The String to trim 268 | * @returns {String} The String freed of excess whitespace 269 | */ 270 | function trim(str) { 271 | return str.replace(/^\s*/, '').replace(/\s*$/, ''); 272 | } 273 | 274 | /** 275 | * Determine if we're running in a standard browser environment 276 | * 277 | * This allows axios to run in a web worker, and react-native. 278 | * Both environments support XMLHttpRequest, but not fully standard globals. 279 | * 280 | * web workers: 281 | * typeof window -> undefined 282 | * typeof document -> undefined 283 | * 284 | * react-native: 285 | * navigator.product -> 'ReactNative' 286 | * nativescript 287 | * navigator.product -> 'NativeScript' or 'NS' 288 | */ 289 | function isStandardBrowserEnv() { 290 | if (typeof navigator !== 'undefined' && (navigator.product === 'ReactNative' || 291 | navigator.product === 'NativeScript' || 292 | navigator.product === 'NS')) { 293 | return false; 294 | } 295 | return ( 296 | typeof window !== 'undefined' && 297 | typeof document !== 'undefined' 298 | ); 299 | } 300 | 301 | /** 302 | * Iterate over an Array or an Object invoking a function for each item. 303 | * 304 | * If `obj` is an Array callback will be called passing 305 | * the value, index, and complete array for each item. 306 | * 307 | * If 'obj' is an Object callback will be called passing 308 | * the value, key, and complete object for each property. 309 | * 310 | * @param {Object|Array} obj The object to iterate 311 | * @param {Function} fn The callback to invoke for each item 312 | */ 313 | function forEach(obj, fn) { 314 | // Don't bother if no value provided 315 | if (obj === null || typeof obj === 'undefined') { 316 | return; 317 | } 318 | 319 | // Force an array if not already something iterable 320 | if (typeof obj !== 'object') { 321 | /*eslint no-param-reassign:0*/ 322 | obj = [obj]; 323 | } 324 | 325 | if (isArray(obj)) { 326 | // Iterate over array values 327 | for (var i = 0, l = obj.length; i < l; i++) { 328 | fn.call(null, obj[i], i, obj); 329 | } 330 | } else { 331 | // Iterate over object keys 332 | for (var key in obj) { 333 | if (Object.prototype.hasOwnProperty.call(obj, key)) { 334 | fn.call(null, obj[key], key, obj); 335 | } 336 | } 337 | } 338 | } 339 | 340 | /** 341 | * Accepts varargs expecting each argument to be an object, then 342 | * immutably merges the properties of each object and returns result. 343 | * 344 | * When multiple objects contain the same key the later object in 345 | * the arguments list will take precedence. 346 | * 347 | * Example: 348 | * 349 | * ```js 350 | * var result = merge({foo: 123}, {foo: 456}); 351 | * console.log(result.foo); // outputs 456 352 | * ``` 353 | * 354 | * @param {Object} obj1 Object to merge 355 | * @returns {Object} Result of all merge properties 356 | */ 357 | function merge(/* obj1, obj2, obj3, ... */) { 358 | var result = {}; 359 | function assignValue(val, key) { 360 | if (isPlainObject(result[key]) && isPlainObject(val)) { 361 | result[key] = merge(result[key], val); 362 | } else if (isPlainObject(val)) { 363 | result[key] = merge({}, val); 364 | } else if (isArray(val)) { 365 | result[key] = val.slice(); 366 | } else { 367 | result[key] = val; 368 | } 369 | } 370 | 371 | for (var i = 0, l = arguments.length; i < l; i++) { 372 | forEach(arguments[i], assignValue); 373 | } 374 | return result; 375 | } 376 | 377 | /** 378 | * Extends object a by mutably adding to it the properties of object b. 379 | * 380 | * @param {Object} a The object to be extended 381 | * @param {Object} b The object to copy properties from 382 | * @param {Object} thisArg The object to bind function to 383 | * @return {Object} The resulting value of object a 384 | */ 385 | function extend(a, b, thisArg) { 386 | forEach(b, function assignValue(val, key) { 387 | if (thisArg && typeof val === 'function') { 388 | a[key] = bind(val, thisArg); 389 | } else { 390 | a[key] = val; 391 | } 392 | }); 393 | return a; 394 | } 395 | 396 | /** 397 | * Remove byte order marker. This catches EF BB BF (the UTF-8 BOM) 398 | * 399 | * @param {string} content with BOM 400 | * @return {string} content value without BOM 401 | */ 402 | function stripBOM(content) { 403 | if (content.charCodeAt(0) === 0xFEFF) { 404 | content = content.slice(1); 405 | } 406 | return content; 407 | } 408 | 409 | module.exports = { 410 | isArray: isArray, 411 | isArrayBuffer: isArrayBuffer, 412 | isBuffer: isBuffer, 413 | isFormData: isFormData, 414 | isArrayBufferView: isArrayBufferView, 415 | isString: isString, 416 | isNumber: isNumber, 417 | isObject: isObject, 418 | isPlainObject: isPlainObject, 419 | isUndefined: isUndefined, 420 | isDate: isDate, 421 | isFile: isFile, 422 | isBlob: isBlob, 423 | isFunction: isFunction, 424 | isStream: isStream, 425 | isURLSearchParams: isURLSearchParams, 426 | isStandardBrowserEnv: isStandardBrowserEnv, 427 | forEach: forEach, 428 | merge: merge, 429 | extend: extend, 430 | trim: trim, 431 | stripBOM: stripBOM 432 | }; 433 | 434 | 435 | /***/ }), 436 | 437 | /***/ 53: 438 | /***/ (function(module, __unusedexports, __webpack_require__) { 439 | 440 | module.exports = __webpack_require__(352); 441 | 442 | /***/ }), 443 | 444 | /***/ 87: 445 | /***/ (function(module) { 446 | 447 | module.exports = require("os"); 448 | 449 | /***/ }), 450 | 451 | /***/ 104: 452 | /***/ (function(__unusedmodule, __unusedexports, __webpack_require__) { 453 | 454 | const core = __webpack_require__(470); 455 | const axios = __webpack_require__(53); 456 | const Humanize = __webpack_require__(481); 457 | const fs = __webpack_require__(747); 458 | const exec = __webpack_require__(898); 459 | 460 | const TODOIST_API_KEY = core.getInput("TODOIST_API_KEY"); 461 | const PREMIUM = core.getInput("PREMIUM"); 462 | 463 | async function main() { 464 | const stats = await axios( 465 | "https://api.todoist.com/sync/v9/completed/get_stats", 466 | { headers: { Authorization: `Bearer ${TODOIST_API_KEY}` } } 467 | ); 468 | await updateReadme(stats.data); 469 | } 470 | 471 | let todoist = []; 472 | let jobFailFlag = false; 473 | const README_FILE_PATH = './README.md'; 474 | 475 | async function updateReadme(data) { 476 | 477 | 478 | const { karma, completed_count, days_items, goals, week_items } = data; 479 | 480 | const karmaPoint = [`🏆 ${Humanize.intComma(karma)} Karma Points`]; 481 | todoist.push(karmaPoint); 482 | 483 | const dailyGoal = [ 484 | `🌸 Completed ${days_items[0].total_completed.toString()} tasks today`, 485 | ]; 486 | todoist.push(dailyGoal); 487 | 488 | if(PREMIUM) { 489 | const weekItems = [`🗓 Completed ${week_items[0].total_completed.toString()} tasks this week`]; 490 | todoist.push(weekItems); 491 | } 492 | 493 | const totalTasks = [`✅ Completed ${Humanize.intComma(completed_count)} tasks so far`]; 494 | todoist.push(totalTasks); 495 | 496 | const longestStreak = [ 497 | `⏳ Longest streak is ${goals.max_daily_streak.count} days`, 498 | ]; 499 | todoist.push(longestStreak); 500 | 501 | if (todoist.length == 0) return; 502 | 503 | if (todoist.length > 0) { 504 | console.log(todoist.length); 505 | // const showTasks = todoist.reduce((todo, cur, index) => { 506 | // return todo + `\n${cur} ` + (((index + 1) === todoist.length) ? '\n' : ''); 507 | // }) 508 | const readmeData = fs.readFileSync(README_FILE_PATH, "utf8"); 509 | 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 | } 523 | else { 524 | core.info("Nothing fetched"); 525 | process.exit(jobFailFlag ? 1 : 0); 526 | } 527 | } 528 | 529 | // console.log(todoist.length); 530 | 531 | 532 | 533 | 534 | const buildReadme = (prevReadmeContent, newReadmeContent) => { 535 | const tagToLookFor = ''; 537 | const startOfOpeningTagIndex = prevReadmeContent.indexOf( 538 | `${tagToLookFor}START`, 539 | ); 540 | const endOfOpeningTagIndex = prevReadmeContent.indexOf( 541 | closingTag, 542 | startOfOpeningTagIndex, 543 | ); 544 | const startOfClosingTagIndex = prevReadmeContent.indexOf( 545 | `${tagToLookFor}END`, 546 | endOfOpeningTagIndex, 547 | ); 548 | if ( 549 | startOfOpeningTagIndex === -1 || 550 | endOfOpeningTagIndex === -1 || 551 | startOfClosingTagIndex === -1 552 | ) { 553 | core.error( 554 | `Cannot find the comment tag on the readme:\n\n` 555 | ); 556 | process.exit(1); 557 | } 558 | return [ 559 | prevReadmeContent.slice(0, endOfOpeningTagIndex + closingTag.length), 560 | '\n', 561 | newReadmeContent, 562 | '\n', 563 | prevReadmeContent.slice(startOfClosingTagIndex), 564 | ].join(''); 565 | }; 566 | 567 | const commitReadme = async () => { 568 | // Getting config 569 | const committerUsername = 'Abhishek Naidu'; 570 | const committerEmail = 'example@gmail.com'; 571 | const commitMessage = 'Todoist updated.'; 572 | // Doing commit and push 573 | await exec('git', [ 574 | 'config', 575 | '--global', 576 | 'user.email', 577 | committerEmail, 578 | ]); 579 | await exec('git', ['config', '--global', 'user.name', committerUsername]); 580 | await exec('git', ['add', README_FILE_PATH]); 581 | await exec('git', ['commit', '-m', commitMessage]); 582 | // await exec('git', ['fetch']); 583 | await exec('git', ['push']); 584 | core.info("Readme updated successfully."); 585 | // Making job fail if one of the source fails 586 | process.exit(jobFailFlag ? 1 : 0); 587 | }; 588 | 589 | (async () => { 590 | await main(); 591 | })(); 592 | 593 | /***/ }), 594 | 595 | /***/ 129: 596 | /***/ (function(module) { 597 | 598 | module.exports = require("child_process"); 599 | 600 | /***/ }), 601 | 602 | /***/ 133: 603 | /***/ (function(module, __unusedexports, __webpack_require__) { 604 | 605 | "use strict"; 606 | 607 | 608 | var utils = __webpack_require__(35); 609 | 610 | function encode(val) { 611 | return encodeURIComponent(val). 612 | replace(/%3A/gi, ':'). 613 | replace(/%24/g, '$'). 614 | replace(/%2C/gi, ','). 615 | replace(/%20/g, '+'). 616 | replace(/%5B/gi, '['). 617 | replace(/%5D/gi, ']'); 618 | } 619 | 620 | /** 621 | * Build a URL by appending params to the end 622 | * 623 | * @param {string} url The base of the url (e.g., http://www.google.com) 624 | * @param {object} [params] The params to be appended 625 | * @returns {string} The formatted url 626 | */ 627 | module.exports = function buildURL(url, params, paramsSerializer) { 628 | /*eslint no-param-reassign:0*/ 629 | if (!params) { 630 | return url; 631 | } 632 | 633 | var serializedParams; 634 | if (paramsSerializer) { 635 | serializedParams = paramsSerializer(params); 636 | } else if (utils.isURLSearchParams(params)) { 637 | serializedParams = params.toString(); 638 | } else { 639 | var parts = []; 640 | 641 | utils.forEach(params, function serialize(val, key) { 642 | if (val === null || typeof val === 'undefined') { 643 | return; 644 | } 645 | 646 | if (utils.isArray(val)) { 647 | key = key + '[]'; 648 | } else { 649 | val = [val]; 650 | } 651 | 652 | utils.forEach(val, function parseValue(v) { 653 | if (utils.isDate(v)) { 654 | v = v.toISOString(); 655 | } else if (utils.isObject(v)) { 656 | v = JSON.stringify(v); 657 | } 658 | parts.push(encode(key) + '=' + encode(v)); 659 | }); 660 | }); 661 | 662 | serializedParams = parts.join('&'); 663 | } 664 | 665 | if (serializedParams) { 666 | var hashmarkIndex = url.indexOf('#'); 667 | if (hashmarkIndex !== -1) { 668 | url = url.slice(0, hashmarkIndex); 669 | } 670 | 671 | url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams; 672 | } 673 | 674 | return url; 675 | }; 676 | 677 | 678 | /***/ }), 679 | 680 | /***/ 137: 681 | /***/ (function(module, __unusedexports, __webpack_require__) { 682 | 683 | "use strict"; 684 | 685 | 686 | var Cancel = __webpack_require__(826); 687 | 688 | /** 689 | * A `CancelToken` is an object that can be used to request cancellation of an operation. 690 | * 691 | * @class 692 | * @param {Function} executor The executor function. 693 | */ 694 | function CancelToken(executor) { 695 | if (typeof executor !== 'function') { 696 | throw new TypeError('executor must be a function.'); 697 | } 698 | 699 | var resolvePromise; 700 | this.promise = new Promise(function promiseExecutor(resolve) { 701 | resolvePromise = resolve; 702 | }); 703 | 704 | var token = this; 705 | executor(function cancel(message) { 706 | if (token.reason) { 707 | // Cancellation has already been requested 708 | return; 709 | } 710 | 711 | token.reason = new Cancel(message); 712 | resolvePromise(token.reason); 713 | }); 714 | } 715 | 716 | /** 717 | * Throws a `Cancel` if cancellation has been requested. 718 | */ 719 | CancelToken.prototype.throwIfRequested = function throwIfRequested() { 720 | if (this.reason) { 721 | throw this.reason; 722 | } 723 | }; 724 | 725 | /** 726 | * Returns an object that contains a new `CancelToken` and a function that, when called, 727 | * cancels the `CancelToken`. 728 | */ 729 | CancelToken.source = function source() { 730 | var cancel; 731 | var token = new CancelToken(function executor(c) { 732 | cancel = c; 733 | }); 734 | return { 735 | token: token, 736 | cancel: cancel 737 | }; 738 | }; 739 | 740 | module.exports = CancelToken; 741 | 742 | 743 | /***/ }), 744 | 745 | /***/ 211: 746 | /***/ (function(module) { 747 | 748 | module.exports = require("https"); 749 | 750 | /***/ }), 751 | 752 | /***/ 219: 753 | /***/ (function(module, __unusedexports, __webpack_require__) { 754 | 755 | "use strict"; 756 | 757 | 758 | var utils = __webpack_require__(35); 759 | var settle = __webpack_require__(564); 760 | var cookies = __webpack_require__(864); 761 | var buildURL = __webpack_require__(133); 762 | var buildFullPath = __webpack_require__(960); 763 | var parseHeaders = __webpack_require__(631); 764 | var isURLSameOrigin = __webpack_require__(688); 765 | var createError = __webpack_require__(26); 766 | 767 | module.exports = function xhrAdapter(config) { 768 | return new Promise(function dispatchXhrRequest(resolve, reject) { 769 | var requestData = config.data; 770 | var requestHeaders = config.headers; 771 | 772 | if (utils.isFormData(requestData)) { 773 | delete requestHeaders['Content-Type']; // Let the browser set it 774 | } 775 | 776 | if ( 777 | (utils.isBlob(requestData) || utils.isFile(requestData)) && 778 | requestData.type 779 | ) { 780 | delete requestHeaders['Content-Type']; // Let the browser set it 781 | } 782 | 783 | var request = new XMLHttpRequest(); 784 | 785 | // HTTP basic authentication 786 | if (config.auth) { 787 | var username = config.auth.username || ''; 788 | var password = unescape(encodeURIComponent(config.auth.password)) || ''; 789 | requestHeaders.Authorization = 'Basic ' + btoa(username + ':' + password); 790 | } 791 | 792 | var fullPath = buildFullPath(config.baseURL, config.url); 793 | request.open(config.method.toUpperCase(), buildURL(fullPath, config.params, config.paramsSerializer), true); 794 | 795 | // Set the request timeout in MS 796 | request.timeout = config.timeout; 797 | 798 | // Listen for ready state 799 | request.onreadystatechange = function handleLoad() { 800 | if (!request || request.readyState !== 4) { 801 | return; 802 | } 803 | 804 | // The request errored out and we didn't get a response, this will be 805 | // handled by onerror instead 806 | // With one exception: request that using file: protocol, most browsers 807 | // will return status as 0 even though it's a successful request 808 | if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) { 809 | return; 810 | } 811 | 812 | // Prepare the response 813 | var responseHeaders = 'getAllResponseHeaders' in request ? parseHeaders(request.getAllResponseHeaders()) : null; 814 | var responseData = !config.responseType || config.responseType === 'text' ? request.responseText : request.response; 815 | var response = { 816 | data: responseData, 817 | status: request.status, 818 | statusText: request.statusText, 819 | headers: responseHeaders, 820 | config: config, 821 | request: request 822 | }; 823 | 824 | settle(resolve, reject, response); 825 | 826 | // Clean up request 827 | request = null; 828 | }; 829 | 830 | // Handle browser request cancellation (as opposed to a manual cancellation) 831 | request.onabort = function handleAbort() { 832 | if (!request) { 833 | return; 834 | } 835 | 836 | reject(createError('Request aborted', config, 'ECONNABORTED', request)); 837 | 838 | // Clean up request 839 | request = null; 840 | }; 841 | 842 | // Handle low level network errors 843 | request.onerror = function handleError() { 844 | // Real errors are hidden from us by the browser 845 | // onerror should only fire if it's a network error 846 | reject(createError('Network Error', config, null, request)); 847 | 848 | // Clean up request 849 | request = null; 850 | }; 851 | 852 | // Handle timeout 853 | request.ontimeout = function handleTimeout() { 854 | var timeoutErrorMessage = 'timeout of ' + config.timeout + 'ms exceeded'; 855 | if (config.timeoutErrorMessage) { 856 | timeoutErrorMessage = config.timeoutErrorMessage; 857 | } 858 | reject(createError(timeoutErrorMessage, config, 'ECONNABORTED', 859 | request)); 860 | 861 | // Clean up request 862 | request = null; 863 | }; 864 | 865 | // Add xsrf header 866 | // This is only done if running in a standard browser environment. 867 | // Specifically not if we're in a web worker, or react-native. 868 | if (utils.isStandardBrowserEnv()) { 869 | // Add xsrf header 870 | var xsrfValue = (config.withCredentials || isURLSameOrigin(fullPath)) && config.xsrfCookieName ? 871 | cookies.read(config.xsrfCookieName) : 872 | undefined; 873 | 874 | if (xsrfValue) { 875 | requestHeaders[config.xsrfHeaderName] = xsrfValue; 876 | } 877 | } 878 | 879 | // Add headers to the request 880 | if ('setRequestHeader' in request) { 881 | utils.forEach(requestHeaders, function setRequestHeader(val, key) { 882 | if (typeof requestData === 'undefined' && key.toLowerCase() === 'content-type') { 883 | // Remove Content-Type if data is undefined 884 | delete requestHeaders[key]; 885 | } else { 886 | // Otherwise add header to the request 887 | request.setRequestHeader(key, val); 888 | } 889 | }); 890 | } 891 | 892 | // Add withCredentials to request if needed 893 | if (!utils.isUndefined(config.withCredentials)) { 894 | request.withCredentials = !!config.withCredentials; 895 | } 896 | 897 | // Add responseType to request if needed 898 | if (config.responseType) { 899 | try { 900 | request.responseType = config.responseType; 901 | } catch (e) { 902 | // Expected DOMException thrown by browsers not compatible XMLHttpRequest Level 2. 903 | // But, this can be suppressed for 'json' type as it can be parsed by default 'transformResponse' function. 904 | if (config.responseType !== 'json') { 905 | throw e; 906 | } 907 | } 908 | } 909 | 910 | // Handle progress if needed 911 | if (typeof config.onDownloadProgress === 'function') { 912 | request.addEventListener('progress', config.onDownloadProgress); 913 | } 914 | 915 | // Not all browsers support upload events 916 | if (typeof config.onUploadProgress === 'function' && request.upload) { 917 | request.upload.addEventListener('progress', config.onUploadProgress); 918 | } 919 | 920 | if (config.cancelToken) { 921 | // Handle cancellation 922 | config.cancelToken.promise.then(function onCanceled(cancel) { 923 | if (!request) { 924 | return; 925 | } 926 | 927 | request.abort(); 928 | reject(cancel); 929 | // Clean up request 930 | request = null; 931 | }); 932 | } 933 | 934 | if (!requestData) { 935 | requestData = null; 936 | } 937 | 938 | // Send the request 939 | request.send(requestData); 940 | }); 941 | }; 942 | 943 | 944 | /***/ }), 945 | 946 | /***/ 283: 947 | /***/ (function(module, __unusedexports, __webpack_require__) { 948 | 949 | "use strict"; 950 | 951 | 952 | var utils = __webpack_require__(35); 953 | 954 | function InterceptorManager() { 955 | this.handlers = []; 956 | } 957 | 958 | /** 959 | * Add a new interceptor to the stack 960 | * 961 | * @param {Function} fulfilled The function to handle `then` for a `Promise` 962 | * @param {Function} rejected The function to handle `reject` for a `Promise` 963 | * 964 | * @return {Number} An ID used to remove interceptor later 965 | */ 966 | InterceptorManager.prototype.use = function use(fulfilled, rejected) { 967 | this.handlers.push({ 968 | fulfilled: fulfilled, 969 | rejected: rejected 970 | }); 971 | return this.handlers.length - 1; 972 | }; 973 | 974 | /** 975 | * Remove an interceptor from the stack 976 | * 977 | * @param {Number} id The ID that was returned by `use` 978 | */ 979 | InterceptorManager.prototype.eject = function eject(id) { 980 | if (this.handlers[id]) { 981 | this.handlers[id] = null; 982 | } 983 | }; 984 | 985 | /** 986 | * Iterate over all the registered interceptors 987 | * 988 | * This method is particularly useful for skipping over any 989 | * interceptors that may have become `null` calling `eject`. 990 | * 991 | * @param {Function} fn The function to call for each interceptor 992 | */ 993 | InterceptorManager.prototype.forEach = function forEach(fn) { 994 | utils.forEach(this.handlers, function forEachHandler(h) { 995 | if (h !== null) { 996 | fn(h); 997 | } 998 | }); 999 | }; 1000 | 1001 | module.exports = InterceptorManager; 1002 | 1003 | 1004 | /***/ }), 1005 | 1006 | /***/ 352: 1007 | /***/ (function(module, __unusedexports, __webpack_require__) { 1008 | 1009 | "use strict"; 1010 | 1011 | 1012 | var utils = __webpack_require__(35); 1013 | var bind = __webpack_require__(727); 1014 | var Axios = __webpack_require__(779); 1015 | var mergeConfig = __webpack_require__(825); 1016 | var defaults = __webpack_require__(529); 1017 | 1018 | /** 1019 | * Create an instance of Axios 1020 | * 1021 | * @param {Object} defaultConfig The default config for the instance 1022 | * @return {Axios} A new instance of Axios 1023 | */ 1024 | function createInstance(defaultConfig) { 1025 | var context = new Axios(defaultConfig); 1026 | var instance = bind(Axios.prototype.request, context); 1027 | 1028 | // Copy axios.prototype to instance 1029 | utils.extend(instance, Axios.prototype, context); 1030 | 1031 | // Copy context to instance 1032 | utils.extend(instance, context); 1033 | 1034 | return instance; 1035 | } 1036 | 1037 | // Create the default instance to be exported 1038 | var axios = createInstance(defaults); 1039 | 1040 | // Expose Axios class to allow class inheritance 1041 | axios.Axios = Axios; 1042 | 1043 | // Factory for creating new instances 1044 | axios.create = function create(instanceConfig) { 1045 | return createInstance(mergeConfig(axios.defaults, instanceConfig)); 1046 | }; 1047 | 1048 | // Expose Cancel & CancelToken 1049 | axios.Cancel = __webpack_require__(826); 1050 | axios.CancelToken = __webpack_require__(137); 1051 | axios.isCancel = __webpack_require__(732); 1052 | 1053 | // Expose all/spread 1054 | axios.all = function all(promises) { 1055 | return Promise.all(promises); 1056 | }; 1057 | axios.spread = __webpack_require__(879); 1058 | 1059 | module.exports = axios; 1060 | 1061 | // Allow use of default import syntax in TypeScript 1062 | module.exports.default = axios; 1063 | 1064 | 1065 | /***/ }), 1066 | 1067 | /***/ 357: 1068 | /***/ (function(module) { 1069 | 1070 | module.exports = require("assert"); 1071 | 1072 | /***/ }), 1073 | 1074 | /***/ 361: 1075 | /***/ (function(module) { 1076 | 1077 | module.exports = {"_from":"axios","_id":"axios@0.20.0","_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"}; 1078 | 1079 | /***/ }), 1080 | 1081 | /***/ 369: 1082 | /***/ (function(module) { 1083 | 1084 | "use strict"; 1085 | 1086 | 1087 | /** 1088 | * Update an Error with the specified config, error code, and response. 1089 | * 1090 | * @param {Error} error The error to update. 1091 | * @param {Object} config The config. 1092 | * @param {string} [code] The error code (for example, 'ECONNABORTED'). 1093 | * @param {Object} [request] The request. 1094 | * @param {Object} [response] The response. 1095 | * @returns {Error} The error. 1096 | */ 1097 | module.exports = function enhanceError(error, config, code, request, response) { 1098 | error.config = config; 1099 | if (code) { 1100 | error.code = code; 1101 | } 1102 | 1103 | error.request = request; 1104 | error.response = response; 1105 | error.isAxiosError = true; 1106 | 1107 | error.toJSON = function toJSON() { 1108 | return { 1109 | // Standard 1110 | message: this.message, 1111 | name: this.name, 1112 | // Microsoft 1113 | description: this.description, 1114 | number: this.number, 1115 | // Mozilla 1116 | fileName: this.fileName, 1117 | lineNumber: this.lineNumber, 1118 | columnNumber: this.columnNumber, 1119 | stack: this.stack, 1120 | // Axios 1121 | config: this.config, 1122 | code: this.code 1123 | }; 1124 | }; 1125 | return error; 1126 | }; 1127 | 1128 | 1129 | /***/ }), 1130 | 1131 | /***/ 411: 1132 | /***/ (function(module, __unusedexports, __webpack_require__) { 1133 | 1134 | "use strict"; 1135 | 1136 | 1137 | var utils = __webpack_require__(35); 1138 | 1139 | module.exports = function normalizeHeaderName(headers, normalizedName) { 1140 | utils.forEach(headers, function processHeader(value, name) { 1141 | if (name !== normalizedName && name.toUpperCase() === normalizedName.toUpperCase()) { 1142 | headers[normalizedName] = value; 1143 | delete headers[name]; 1144 | } 1145 | }); 1146 | }; 1147 | 1148 | 1149 | /***/ }), 1150 | 1151 | /***/ 413: 1152 | /***/ (function(module) { 1153 | 1154 | module.exports = require("stream"); 1155 | 1156 | /***/ }), 1157 | 1158 | /***/ 431: 1159 | /***/ (function(__unusedmodule, exports, __webpack_require__) { 1160 | 1161 | "use strict"; 1162 | 1163 | var __importStar = (this && this.__importStar) || function (mod) { 1164 | if (mod && mod.__esModule) return mod; 1165 | var result = {}; 1166 | if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; 1167 | result["default"] = mod; 1168 | return result; 1169 | }; 1170 | Object.defineProperty(exports, "__esModule", { value: true }); 1171 | const os = __importStar(__webpack_require__(87)); 1172 | /** 1173 | * Commands 1174 | * 1175 | * Command Format: 1176 | * ::name key=value,key=value::message 1177 | * 1178 | * Examples: 1179 | * ::warning::This is the message 1180 | * ::set-env name=MY_VAR::some value 1181 | */ 1182 | function issueCommand(command, properties, message) { 1183 | const cmd = new Command(command, properties, message); 1184 | process.stdout.write(cmd.toString() + os.EOL); 1185 | } 1186 | exports.issueCommand = issueCommand; 1187 | function issue(name, message = '') { 1188 | issueCommand(name, {}, message); 1189 | } 1190 | exports.issue = issue; 1191 | const CMD_STRING = '::'; 1192 | class Command { 1193 | constructor(command, properties, message) { 1194 | if (!command) { 1195 | command = 'missing.command'; 1196 | } 1197 | this.command = command; 1198 | this.properties = properties; 1199 | this.message = message; 1200 | } 1201 | toString() { 1202 | let cmdStr = CMD_STRING + this.command; 1203 | if (this.properties && Object.keys(this.properties).length > 0) { 1204 | cmdStr += ' '; 1205 | let first = true; 1206 | for (const key in this.properties) { 1207 | if (this.properties.hasOwnProperty(key)) { 1208 | const val = this.properties[key]; 1209 | if (val) { 1210 | if (first) { 1211 | first = false; 1212 | } 1213 | else { 1214 | cmdStr += ','; 1215 | } 1216 | cmdStr += `${key}=${escapeProperty(val)}`; 1217 | } 1218 | } 1219 | } 1220 | } 1221 | cmdStr += `${CMD_STRING}${escapeData(this.message)}`; 1222 | return cmdStr; 1223 | } 1224 | } 1225 | /** 1226 | * Sanitizes an input into a string so it can be passed into issueCommand safely 1227 | * @param input input to sanitize into a string 1228 | */ 1229 | function toCommandValue(input) { 1230 | if (input === null || input === undefined) { 1231 | return ''; 1232 | } 1233 | else if (typeof input === 'string' || input instanceof String) { 1234 | return input; 1235 | } 1236 | return JSON.stringify(input); 1237 | } 1238 | exports.toCommandValue = toCommandValue; 1239 | function escapeData(s) { 1240 | return toCommandValue(s) 1241 | .replace(/%/g, '%25') 1242 | .replace(/\r/g, '%0D') 1243 | .replace(/\n/g, '%0A'); 1244 | } 1245 | function escapeProperty(s) { 1246 | return toCommandValue(s) 1247 | .replace(/%/g, '%25') 1248 | .replace(/\r/g, '%0D') 1249 | .replace(/\n/g, '%0A') 1250 | .replace(/:/g, '%3A') 1251 | .replace(/,/g, '%2C'); 1252 | } 1253 | //# sourceMappingURL=command.js.map 1254 | 1255 | /***/ }), 1256 | 1257 | /***/ 454: 1258 | /***/ (function(module, __unusedexports, __webpack_require__) { 1259 | 1260 | var debug; 1261 | try { 1262 | /* eslint global-require: off */ 1263 | debug = __webpack_require__(944)("follow-redirects"); 1264 | } 1265 | catch (error) { 1266 | debug = function () { /* */ }; 1267 | } 1268 | module.exports = debug; 1269 | 1270 | 1271 | /***/ }), 1272 | 1273 | /***/ 470: 1274 | /***/ (function(__unusedmodule, exports, __webpack_require__) { 1275 | 1276 | "use strict"; 1277 | 1278 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { 1279 | function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } 1280 | return new (P || (P = Promise))(function (resolve, reject) { 1281 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } 1282 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } 1283 | function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } 1284 | step((generator = generator.apply(thisArg, _arguments || [])).next()); 1285 | }); 1286 | }; 1287 | var __importStar = (this && this.__importStar) || function (mod) { 1288 | if (mod && mod.__esModule) return mod; 1289 | var result = {}; 1290 | if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; 1291 | result["default"] = mod; 1292 | return result; 1293 | }; 1294 | Object.defineProperty(exports, "__esModule", { value: true }); 1295 | const command_1 = __webpack_require__(431); 1296 | const os = __importStar(__webpack_require__(87)); 1297 | const path = __importStar(__webpack_require__(622)); 1298 | /** 1299 | * The code to exit an action 1300 | */ 1301 | var ExitCode; 1302 | (function (ExitCode) { 1303 | /** 1304 | * A code indicating that the action was successful 1305 | */ 1306 | ExitCode[ExitCode["Success"] = 0] = "Success"; 1307 | /** 1308 | * A code indicating that the action was a failure 1309 | */ 1310 | ExitCode[ExitCode["Failure"] = 1] = "Failure"; 1311 | })(ExitCode = exports.ExitCode || (exports.ExitCode = {})); 1312 | //----------------------------------------------------------------------- 1313 | // Variables 1314 | //----------------------------------------------------------------------- 1315 | /** 1316 | * Sets env variable for this action and future actions in the job 1317 | * @param name the name of the variable to set 1318 | * @param val the value of the variable. Non-string values will be converted to a string via JSON.stringify 1319 | */ 1320 | // eslint-disable-next-line @typescript-eslint/no-explicit-any 1321 | function exportVariable(name, val) { 1322 | const convertedVal = command_1.toCommandValue(val); 1323 | process.env[name] = convertedVal; 1324 | command_1.issueCommand('set-env', { name }, convertedVal); 1325 | } 1326 | exports.exportVariable = exportVariable; 1327 | /** 1328 | * Registers a secret which will get masked from logs 1329 | * @param secret value of the secret 1330 | */ 1331 | function setSecret(secret) { 1332 | command_1.issueCommand('add-mask', {}, secret); 1333 | } 1334 | exports.setSecret = setSecret; 1335 | /** 1336 | * Prepends inputPath to the PATH (for this action and future actions) 1337 | * @param inputPath 1338 | */ 1339 | function addPath(inputPath) { 1340 | command_1.issueCommand('add-path', {}, inputPath); 1341 | process.env['PATH'] = `${inputPath}${path.delimiter}${process.env['PATH']}`; 1342 | } 1343 | exports.addPath = addPath; 1344 | /** 1345 | * Gets the value of an input. The value is also trimmed. 1346 | * 1347 | * @param name name of the input to get 1348 | * @param options optional. See InputOptions. 1349 | * @returns string 1350 | */ 1351 | function getInput(name, options) { 1352 | const val = process.env[`INPUT_${name.replace(/ /g, '_').toUpperCase()}`] || ''; 1353 | if (options && options.required && !val) { 1354 | throw new Error(`Input required and not supplied: ${name}`); 1355 | } 1356 | return val.trim(); 1357 | } 1358 | exports.getInput = getInput; 1359 | /** 1360 | * Sets the value of an output. 1361 | * 1362 | * @param name name of the output to set 1363 | * @param value value to store. Non-string values will be converted to a string via JSON.stringify 1364 | */ 1365 | // eslint-disable-next-line @typescript-eslint/no-explicit-any 1366 | function setOutput(name, value) { 1367 | command_1.issueCommand('set-output', { name }, value); 1368 | } 1369 | exports.setOutput = setOutput; 1370 | /** 1371 | * Enables or disables the echoing of commands into stdout for the rest of the step. 1372 | * Echoing is disabled by default if ACTIONS_STEP_DEBUG is not set. 1373 | * 1374 | */ 1375 | function setCommandEcho(enabled) { 1376 | command_1.issue('echo', enabled ? 'on' : 'off'); 1377 | } 1378 | exports.setCommandEcho = setCommandEcho; 1379 | //----------------------------------------------------------------------- 1380 | // Results 1381 | //----------------------------------------------------------------------- 1382 | /** 1383 | * Sets the action status to failed. 1384 | * When the action exits it will be with an exit code of 1 1385 | * @param message add error issue message 1386 | */ 1387 | function setFailed(message) { 1388 | process.exitCode = ExitCode.Failure; 1389 | error(message); 1390 | } 1391 | exports.setFailed = setFailed; 1392 | //----------------------------------------------------------------------- 1393 | // Logging Commands 1394 | //----------------------------------------------------------------------- 1395 | /** 1396 | * Gets whether Actions Step Debug is on or not 1397 | */ 1398 | function isDebug() { 1399 | return process.env['RUNNER_DEBUG'] === '1'; 1400 | } 1401 | exports.isDebug = isDebug; 1402 | /** 1403 | * Writes debug message to user log 1404 | * @param message debug message 1405 | */ 1406 | function debug(message) { 1407 | command_1.issueCommand('debug', {}, message); 1408 | } 1409 | exports.debug = debug; 1410 | /** 1411 | * Adds an error issue 1412 | * @param message error issue message. Errors will be converted to string via toString() 1413 | */ 1414 | function error(message) { 1415 | command_1.issue('error', message instanceof Error ? message.toString() : message); 1416 | } 1417 | exports.error = error; 1418 | /** 1419 | * Adds an warning issue 1420 | * @param message warning issue message. Errors will be converted to string via toString() 1421 | */ 1422 | function warning(message) { 1423 | command_1.issue('warning', message instanceof Error ? message.toString() : message); 1424 | } 1425 | exports.warning = warning; 1426 | /** 1427 | * Writes info to log with console.log. 1428 | * @param message info message 1429 | */ 1430 | function info(message) { 1431 | process.stdout.write(message + os.EOL); 1432 | } 1433 | exports.info = info; 1434 | /** 1435 | * Begin an output group. 1436 | * 1437 | * Output until the next `groupEnd` will be foldable in this group 1438 | * 1439 | * @param name The name of the output group 1440 | */ 1441 | function startGroup(name) { 1442 | command_1.issue('group', name); 1443 | } 1444 | exports.startGroup = startGroup; 1445 | /** 1446 | * End an output group. 1447 | */ 1448 | function endGroup() { 1449 | command_1.issue('endgroup'); 1450 | } 1451 | exports.endGroup = endGroup; 1452 | /** 1453 | * Wrap an asynchronous function call in a group. 1454 | * 1455 | * Returns the same type as the function itself. 1456 | * 1457 | * @param name The name of the group 1458 | * @param fn The function to wrap in the group 1459 | */ 1460 | function group(name, fn) { 1461 | return __awaiter(this, void 0, void 0, function* () { 1462 | startGroup(name); 1463 | let result; 1464 | try { 1465 | result = yield fn(); 1466 | } 1467 | finally { 1468 | endGroup(); 1469 | } 1470 | return result; 1471 | }); 1472 | } 1473 | exports.group = group; 1474 | //----------------------------------------------------------------------- 1475 | // Wrapper action state 1476 | //----------------------------------------------------------------------- 1477 | /** 1478 | * Saves state for current action, the state can only be retrieved by this action's post job execution. 1479 | * 1480 | * @param name name of the state to store 1481 | * @param value value to store. Non-string values will be converted to a string via JSON.stringify 1482 | */ 1483 | // eslint-disable-next-line @typescript-eslint/no-explicit-any 1484 | function saveState(name, value) { 1485 | command_1.issueCommand('save-state', { name }, value); 1486 | } 1487 | exports.saveState = saveState; 1488 | /** 1489 | * Gets the value of an state set by this action's main execution. 1490 | * 1491 | * @param name name of the state to get 1492 | * @returns string 1493 | */ 1494 | function getState(name) { 1495 | return process.env[`STATE_${name}`] || ''; 1496 | } 1497 | exports.getState = getState; 1498 | //# sourceMappingURL=core.js.map 1499 | 1500 | /***/ }), 1501 | 1502 | /***/ 481: 1503 | /***/ (function(module, exports) { 1504 | 1505 | "use strict"; 1506 | /* humanize.js - v1.8.2 */ 1507 | 1508 | 1509 | var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; }; 1510 | 1511 | /** 1512 | * Copyright 2013-2016 HubSpotDev 1513 | * MIT Licensed 1514 | * 1515 | * @module humanize.js 1516 | */ 1517 | 1518 | (function (root, factory) { 1519 | if (( false ? undefined : _typeof(exports)) === 'object') { 1520 | module.exports = factory(); 1521 | } else if (typeof define === 'function' && define.amd) { 1522 | define([], function () { 1523 | return root.Humanize = factory(); 1524 | }); 1525 | } else { 1526 | root.Humanize = factory(); 1527 | } 1528 | })(this, function () { 1529 | //------------------------------------------------------------------------------ 1530 | // Constants 1531 | //------------------------------------------------------------------------------ 1532 | 1533 | var TIME_FORMATS = [{ 1534 | name: 'second', 1535 | value: 1e3 1536 | }, { 1537 | name: 'minute', 1538 | value: 6e4 1539 | }, { 1540 | name: 'hour', 1541 | value: 36e5 1542 | }, { 1543 | name: 'day', 1544 | value: 864e5 1545 | }, { 1546 | name: 'week', 1547 | value: 6048e5 1548 | }]; 1549 | 1550 | var LABELS_FOR_POWERS_OF_KILO = { 1551 | P: Math.pow(2, 50), 1552 | T: Math.pow(2, 40), 1553 | G: Math.pow(2, 30), 1554 | M: Math.pow(2, 20) 1555 | }; 1556 | 1557 | //------------------------------------------------------------------------------ 1558 | // Helpers 1559 | //------------------------------------------------------------------------------ 1560 | 1561 | var exists = function exists(maybe) { 1562 | return typeof maybe !== 'undefined' && maybe !== null; 1563 | }; 1564 | 1565 | var isNaN = function isNaN(value) { 1566 | return value !== value; 1567 | }; // eslint-disable-line 1568 | 1569 | var isFiniteNumber = function isFiniteNumber(value) { 1570 | return isFinite(value) && !isNaN(parseFloat(value)); 1571 | }; 1572 | 1573 | var isArray = function isArray(value) { 1574 | var type = Object.prototype.toString.call(value); 1575 | return type === '[object Array]'; 1576 | }; 1577 | 1578 | //------------------------------------------------------------------------------ 1579 | // Humanize 1580 | //------------------------------------------------------------------------------ 1581 | 1582 | var Humanize = { 1583 | 1584 | // Converts a large integer to a friendly text representation. 1585 | 1586 | intword: function intword(number, charWidth) { 1587 | var decimals = arguments.length <= 2 || arguments[2] === undefined ? 2 : arguments[2]; 1588 | 1589 | /* 1590 | * This method is deprecated. Please use compactInteger instead. 1591 | * intword will be going away in the next major version. 1592 | */ 1593 | return Humanize.compactInteger(number, decimals); 1594 | }, 1595 | 1596 | 1597 | // Converts an integer into its most compact representation 1598 | compactInteger: function compactInteger(input) { 1599 | var decimals = arguments.length <= 1 || arguments[1] === undefined ? 0 : arguments[1]; 1600 | 1601 | decimals = Math.max(decimals, 0); 1602 | var number = parseInt(input, 10); 1603 | var signString = number < 0 ? '-' : ''; 1604 | var unsignedNumber = Math.abs(number); 1605 | var unsignedNumberString = String(unsignedNumber); 1606 | var numberLength = unsignedNumberString.length; 1607 | var numberLengths = [13, 10, 7, 4]; 1608 | var bigNumPrefixes = ['T', 'B', 'M', 'k']; 1609 | 1610 | // small numbers 1611 | if (unsignedNumber < 1000) { 1612 | return '' + signString + unsignedNumberString; 1613 | } 1614 | 1615 | // really big numbers 1616 | if (numberLength > numberLengths[0] + 3) { 1617 | return number.toExponential(decimals).replace('e+', 'x10^'); 1618 | } 1619 | 1620 | // 999 < unsignedNumber < 999,999,999,999,999 1621 | var length = void 0; 1622 | for (var i = 0; i < numberLengths.length; i++) { 1623 | var _length = numberLengths[i]; 1624 | if (numberLength >= _length) { 1625 | length = _length; 1626 | break; 1627 | } 1628 | } 1629 | 1630 | var decimalIndex = numberLength - length + 1; 1631 | var unsignedNumberCharacterArray = unsignedNumberString.split(''); 1632 | 1633 | var wholePartArray = unsignedNumberCharacterArray.slice(0, decimalIndex); 1634 | var decimalPartArray = unsignedNumberCharacterArray.slice(decimalIndex, decimalIndex + decimals + 1); 1635 | 1636 | var wholePart = wholePartArray.join(''); 1637 | 1638 | // pad decimalPart if necessary 1639 | var decimalPart = decimalPartArray.join(''); 1640 | if (decimalPart.length < decimals) { 1641 | decimalPart += '' + Array(decimals - decimalPart.length + 1).join('0'); 1642 | } 1643 | 1644 | var output = void 0; 1645 | if (decimals === 0) { 1646 | output = '' + signString + wholePart + bigNumPrefixes[numberLengths.indexOf(length)]; 1647 | } else { 1648 | var outputNumber = Number(wholePart + '.' + decimalPart).toFixed(decimals); 1649 | output = '' + signString + outputNumber + bigNumPrefixes[numberLengths.indexOf(length)]; 1650 | } 1651 | 1652 | return output; 1653 | }, 1654 | 1655 | 1656 | // Converts an integer to a string containing commas every three digits. 1657 | intComma: function intComma(number) { 1658 | var decimals = arguments.length <= 1 || arguments[1] === undefined ? 0 : arguments[1]; 1659 | 1660 | return Humanize.formatNumber(number, decimals); 1661 | }, 1662 | intcomma: function intcomma() { 1663 | return Humanize.intComma.apply(Humanize, arguments); 1664 | }, 1665 | 1666 | 1667 | // Formats the value like a 'human-readable' file size (i.e. '13 KB', '4.1 MB', '102 bytes', etc). 1668 | fileSize: function fileSize(filesize) { 1669 | var precision = arguments.length <= 1 || arguments[1] === undefined ? 2 : arguments[1]; 1670 | 1671 | for (var label in LABELS_FOR_POWERS_OF_KILO) { 1672 | if (LABELS_FOR_POWERS_OF_KILO.hasOwnProperty(label)) { 1673 | var minnum = LABELS_FOR_POWERS_OF_KILO[label]; 1674 | if (filesize >= minnum) { 1675 | return Humanize.formatNumber(filesize / minnum, precision, '') + ' ' + label + 'B'; 1676 | } 1677 | } 1678 | } 1679 | if (filesize >= 1024) { 1680 | return Humanize.formatNumber(filesize / 1024, 0) + ' KB'; 1681 | } 1682 | 1683 | return Humanize.formatNumber(filesize, 0) + Humanize.pluralize(filesize, ' byte'); 1684 | }, 1685 | filesize: function filesize() { 1686 | return Humanize.fileSize.apply(Humanize, arguments); 1687 | }, 1688 | 1689 | 1690 | // Formats a number to a human-readable string. 1691 | // Localize by overriding the precision, thousand and decimal arguments. 1692 | formatNumber: function formatNumber(number) { 1693 | var precision = arguments.length <= 1 || arguments[1] === undefined ? 0 : arguments[1]; 1694 | var thousand = arguments.length <= 2 || arguments[2] === undefined ? ',' : arguments[2]; 1695 | var decimal = arguments.length <= 3 || arguments[3] === undefined ? '.' : arguments[3]; 1696 | 1697 | // Create some private utility functions to make the computational 1698 | // code that follows much easier to read. 1699 | var firstComma = function firstComma(_number, _thousand, _position) { 1700 | return _position ? _number.substr(0, _position) + _thousand : ''; 1701 | }; 1702 | 1703 | var commas = function commas(_number, _thousand, _position) { 1704 | return _number.substr(_position).replace(/(\d{3})(?=\d)/g, '$1' + _thousand); 1705 | }; 1706 | 1707 | var decimals = function decimals(_number, _decimal, usePrecision) { 1708 | return usePrecision ? _decimal + Humanize.toFixed(Math.abs(_number), usePrecision).split('.')[1] : ''; 1709 | }; 1710 | 1711 | var usePrecision = Humanize.normalizePrecision(precision); 1712 | 1713 | // Do some calc 1714 | var negative = number < 0 && '-' || ''; 1715 | var base = String(parseInt(Humanize.toFixed(Math.abs(number || 0), usePrecision), 10)); 1716 | var mod = base.length > 3 ? base.length % 3 : 0; 1717 | 1718 | // Format the number 1719 | return negative + firstComma(base, thousand, mod) + commas(base, thousand, mod) + decimals(number, decimal, usePrecision); 1720 | }, 1721 | 1722 | 1723 | // Fixes binary rounding issues (eg. (0.615).toFixed(2) === '0.61') 1724 | toFixed: function toFixed(value, precision) { 1725 | precision = exists(precision) ? precision : Humanize.normalizePrecision(precision, 0); 1726 | var power = Math.pow(10, precision); 1727 | 1728 | // Multiply up by precision, round accurately, then divide and use native toFixed() 1729 | return (Math.round(value * power) / power).toFixed(precision); 1730 | }, 1731 | 1732 | 1733 | // Ensures precision value is a positive integer 1734 | normalizePrecision: function normalizePrecision(value, base) { 1735 | value = Math.round(Math.abs(value)); 1736 | return isNaN(value) ? base : value; 1737 | }, 1738 | 1739 | 1740 | // Converts an integer to its ordinal as a string. 1741 | ordinal: function ordinal(value) { 1742 | var number = parseInt(value, 10); 1743 | 1744 | if (number === 0) { 1745 | return value; 1746 | } 1747 | 1748 | var specialCase = number % 100; 1749 | if ([11, 12, 13].indexOf(specialCase) >= 0) { 1750 | return number + 'th'; 1751 | } 1752 | 1753 | var leastSignificant = number % 10; 1754 | 1755 | var end = void 0; 1756 | switch (leastSignificant) { 1757 | case 1: 1758 | end = 'st'; 1759 | break; 1760 | case 2: 1761 | end = 'nd'; 1762 | break; 1763 | case 3: 1764 | end = 'rd'; 1765 | break; 1766 | default: 1767 | end = 'th'; 1768 | } 1769 | 1770 | return '' + number + end; 1771 | }, 1772 | 1773 | 1774 | // Interprets numbers as occurences. Also accepts an optional array/map of overrides. 1775 | times: function times(value) { 1776 | var overrides = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; 1777 | 1778 | if (isFiniteNumber(value) && value >= 0) { 1779 | var number = parseFloat(value); 1780 | var smallTimes = ['never', 'once', 'twice']; 1781 | if (exists(overrides[number])) { 1782 | return String(overrides[number]); 1783 | } 1784 | 1785 | var numberString = exists(smallTimes[number]) && smallTimes[number].toString(); 1786 | return numberString || number.toString() + ' times'; 1787 | } 1788 | return null; 1789 | }, 1790 | 1791 | 1792 | // Returns the plural version of a given word if the value is not 1. The default suffix is 's'. 1793 | pluralize: function pluralize(number, singular, plural) { 1794 | if (!(exists(number) && exists(singular))) { 1795 | return null; 1796 | } 1797 | 1798 | plural = exists(plural) ? plural : singular + 's'; 1799 | 1800 | return parseInt(number, 10) === 1 ? singular : plural; 1801 | }, 1802 | 1803 | 1804 | // Truncates a string if it is longer than the specified number of characters (inclusive). 1805 | // Truncated strings will end with a translatable ellipsis sequence ("…"). 1806 | truncate: function truncate(str) { 1807 | var length = arguments.length <= 1 || arguments[1] === undefined ? 100 : arguments[1]; 1808 | var ending = arguments.length <= 2 || arguments[2] === undefined ? '...' : arguments[2]; 1809 | 1810 | if (str.length > length) { 1811 | return str.substring(0, length - ending.length) + ending; 1812 | } 1813 | return str; 1814 | }, 1815 | 1816 | 1817 | // Truncates a string after a certain number of words. 1818 | truncateWords: function truncateWords(string, length) { 1819 | var array = string.split(' '); 1820 | var result = ''; 1821 | var i = 0; 1822 | 1823 | while (i < length) { 1824 | if (exists(array[i])) { 1825 | result += array[i] + ' '; 1826 | } 1827 | i++; 1828 | } 1829 | 1830 | if (array.length > length) { 1831 | return result + '...'; 1832 | } 1833 | 1834 | return null; 1835 | }, 1836 | truncatewords: function truncatewords() { 1837 | return Humanize.truncateWords.apply(Humanize, arguments); 1838 | }, 1839 | 1840 | 1841 | // Truncates a number to an upper bound. 1842 | boundedNumber: function boundedNumber(num) { 1843 | var bound = arguments.length <= 1 || arguments[1] === undefined ? 100 : arguments[1]; 1844 | var ending = arguments.length <= 2 || arguments[2] === undefined ? '+' : arguments[2]; 1845 | 1846 | var result = void 0; 1847 | 1848 | if (isFiniteNumber(num) && isFiniteNumber(bound)) { 1849 | if (num > bound) { 1850 | result = bound + ending; 1851 | } 1852 | } 1853 | 1854 | return (result || num).toString(); 1855 | }, 1856 | truncatenumber: function truncatenumber() { 1857 | return Humanize.boundedNumber.apply(Humanize, arguments); 1858 | }, 1859 | 1860 | 1861 | // Converts a list of items to a human readable string with an optional limit. 1862 | oxford: function oxford(items, limit, limitStr) { 1863 | var numItems = items.length; 1864 | 1865 | var limitIndex = void 0; 1866 | if (numItems < 2) { 1867 | return String(items); 1868 | } else if (numItems === 2) { 1869 | return items.join(' and '); 1870 | } else if (exists(limit) && numItems > limit) { 1871 | var extra = numItems - limit; 1872 | limitIndex = limit; 1873 | limitStr = exists(limitStr) ? limitStr : ', and ' + extra + ' ' + Humanize.pluralize(extra, 'other'); 1874 | } else { 1875 | limitIndex = -1; 1876 | limitStr = ', and ' + items[numItems - 1]; 1877 | } 1878 | 1879 | return items.slice(0, limitIndex).join(', ') + limitStr; 1880 | }, 1881 | 1882 | 1883 | // Converts an object to a definition-like string 1884 | dictionary: function dictionary(object) { 1885 | var joiner = arguments.length <= 1 || arguments[1] === undefined ? ' is ' : arguments[1]; 1886 | var separator = arguments.length <= 2 || arguments[2] === undefined ? ', ' : arguments[2]; 1887 | 1888 | var result = ''; 1889 | 1890 | if (exists(object) && (typeof object === 'undefined' ? 'undefined' : _typeof(object)) === 'object' && !isArray(object)) { 1891 | var defs = []; 1892 | for (var key in object) { 1893 | if (object.hasOwnProperty(key)) { 1894 | var val = object[key]; 1895 | defs.push('' + key + joiner + val); 1896 | } 1897 | } 1898 | 1899 | return defs.join(separator); 1900 | } 1901 | 1902 | return result; 1903 | }, 1904 | 1905 | 1906 | // Describes how many times an item appears in a list 1907 | frequency: function frequency(list, verb) { 1908 | if (!isArray(list)) { 1909 | return null; 1910 | } 1911 | 1912 | var len = list.length; 1913 | var times = Humanize.times(len); 1914 | 1915 | if (len === 0) { 1916 | return times + ' ' + verb; 1917 | } 1918 | 1919 | return verb + ' ' + times; 1920 | }, 1921 | pace: function pace(value, intervalMs) { 1922 | var unit = arguments.length <= 2 || arguments[2] === undefined ? 'time' : arguments[2]; 1923 | 1924 | if (value === 0 || intervalMs === 0) { 1925 | // Needs a better string than this... 1926 | return 'No ' + Humanize.pluralize(0, unit); 1927 | } 1928 | 1929 | // Expose these as overridables? 1930 | var prefix = 'Approximately'; 1931 | var timeUnit = void 0; 1932 | var relativePace = void 0; 1933 | 1934 | var rate = value / intervalMs; 1935 | for (var i = 0; i < TIME_FORMATS.length; ++i) { 1936 | // assumes sorted list 1937 | var f = TIME_FORMATS[i]; 1938 | relativePace = rate * f.value; 1939 | if (relativePace > 1) { 1940 | timeUnit = f.name; 1941 | break; 1942 | } 1943 | } 1944 | 1945 | // Use the last time unit if there is nothing smaller 1946 | if (!timeUnit) { 1947 | prefix = 'Less than'; 1948 | relativePace = 1; 1949 | timeUnit = TIME_FORMATS[TIME_FORMATS.length - 1].name; 1950 | } 1951 | 1952 | var roundedPace = Math.round(relativePace); 1953 | unit = Humanize.pluralize(roundedPace, unit); 1954 | 1955 | return prefix + ' ' + roundedPace + ' ' + unit + ' per ' + timeUnit; 1956 | }, 1957 | 1958 | 1959 | // Converts newlines to
tags 1960 | nl2br: function nl2br(string) { 1961 | var replacement = arguments.length <= 1 || arguments[1] === undefined ? '
' : arguments[1]; 1962 | 1963 | return string.replace(/\n/g, replacement); 1964 | }, 1965 | 1966 | 1967 | // Converts
tags to newlines 1968 | br2nl: function br2nl(string) { 1969 | var replacement = arguments.length <= 1 || arguments[1] === undefined ? '\r\n' : arguments[1]; 1970 | 1971 | return string.replace(/\/g, replacement); 1972 | }, 1973 | 1974 | 1975 | // Capitalizes first letter in a string 1976 | capitalize: function capitalize(string) { 1977 | var downCaseTail = arguments.length <= 1 || arguments[1] === undefined ? false : arguments[1]; 1978 | 1979 | return '' + string.charAt(0).toUpperCase() + (downCaseTail ? string.slice(1).toLowerCase() : string.slice(1)); 1980 | }, 1981 | 1982 | 1983 | // Capitalizes the first letter of each word in a string 1984 | capitalizeAll: function capitalizeAll(string) { 1985 | return string.replace(/(?:^|\s)\S/g, function (a) { 1986 | return a.toUpperCase(); 1987 | }); 1988 | }, 1989 | 1990 | 1991 | // Titlecase words in a string. 1992 | titleCase: function titleCase(string) { 1993 | var smallWords = /\b(a|an|and|at|but|by|de|en|for|if|in|of|on|or|the|to|via|vs?\.?)\b/i; 1994 | var internalCaps = /\S+[A-Z]+\S*/; 1995 | var splitOnWhiteSpaceRegex = /\s+/; 1996 | var splitOnHyphensRegex = /-/; 1997 | 1998 | var _doTitleCase = void 0; 1999 | _doTitleCase = function doTitleCase(_string) { 2000 | var hyphenated = arguments.length <= 1 || arguments[1] === undefined ? false : arguments[1]; 2001 | var firstOrLast = arguments.length <= 2 || arguments[2] === undefined ? true : arguments[2]; 2002 | 2003 | var titleCasedArray = []; 2004 | var stringArray = _string.split(hyphenated ? splitOnHyphensRegex : splitOnWhiteSpaceRegex); 2005 | 2006 | for (var index = 0; index < stringArray.length; ++index) { 2007 | var word = stringArray[index]; 2008 | if (word.indexOf('-') !== -1) { 2009 | titleCasedArray.push(_doTitleCase(word, true, index === 0 || index === stringArray.length - 1)); 2010 | continue; 2011 | } 2012 | 2013 | if (firstOrLast && (index === 0 || index === stringArray.length - 1)) { 2014 | titleCasedArray.push(internalCaps.test(word) ? word : Humanize.capitalize(word)); 2015 | continue; 2016 | } 2017 | 2018 | if (internalCaps.test(word)) { 2019 | titleCasedArray.push(word); 2020 | } else if (smallWords.test(word)) { 2021 | titleCasedArray.push(word.toLowerCase()); 2022 | } else { 2023 | titleCasedArray.push(Humanize.capitalize(word)); 2024 | } 2025 | } 2026 | 2027 | return titleCasedArray.join(hyphenated ? '-' : ' '); 2028 | }; 2029 | 2030 | return _doTitleCase(string); 2031 | }, 2032 | titlecase: function titlecase() { 2033 | return Humanize.titleCase.apply(Humanize, arguments); 2034 | } 2035 | }; 2036 | 2037 | return Humanize; 2038 | }); 2039 | 2040 | /***/ }), 2041 | 2042 | /***/ 529: 2043 | /***/ (function(module, __unusedexports, __webpack_require__) { 2044 | 2045 | "use strict"; 2046 | 2047 | 2048 | var utils = __webpack_require__(35); 2049 | var normalizeHeaderName = __webpack_require__(411); 2050 | 2051 | var DEFAULT_CONTENT_TYPE = { 2052 | 'Content-Type': 'application/x-www-form-urlencoded' 2053 | }; 2054 | 2055 | function setContentTypeIfUnset(headers, value) { 2056 | if (!utils.isUndefined(headers) && utils.isUndefined(headers['Content-Type'])) { 2057 | headers['Content-Type'] = value; 2058 | } 2059 | } 2060 | 2061 | function getDefaultAdapter() { 2062 | var adapter; 2063 | if (typeof XMLHttpRequest !== 'undefined') { 2064 | // For browsers use XHR adapter 2065 | adapter = __webpack_require__(219); 2066 | } else if (typeof process !== 'undefined' && Object.prototype.toString.call(process) === '[object process]') { 2067 | // For node use HTTP adapter 2068 | adapter = __webpack_require__(670); 2069 | } 2070 | return adapter; 2071 | } 2072 | 2073 | var defaults = { 2074 | adapter: getDefaultAdapter(), 2075 | 2076 | transformRequest: [function transformRequest(data, headers) { 2077 | normalizeHeaderName(headers, 'Accept'); 2078 | normalizeHeaderName(headers, 'Content-Type'); 2079 | if (utils.isFormData(data) || 2080 | utils.isArrayBuffer(data) || 2081 | utils.isBuffer(data) || 2082 | utils.isStream(data) || 2083 | utils.isFile(data) || 2084 | utils.isBlob(data) 2085 | ) { 2086 | return data; 2087 | } 2088 | if (utils.isArrayBufferView(data)) { 2089 | return data.buffer; 2090 | } 2091 | if (utils.isURLSearchParams(data)) { 2092 | setContentTypeIfUnset(headers, 'application/x-www-form-urlencoded;charset=utf-8'); 2093 | return data.toString(); 2094 | } 2095 | if (utils.isObject(data)) { 2096 | setContentTypeIfUnset(headers, 'application/json;charset=utf-8'); 2097 | return JSON.stringify(data); 2098 | } 2099 | return data; 2100 | }], 2101 | 2102 | transformResponse: [function transformResponse(data) { 2103 | /*eslint no-param-reassign:0*/ 2104 | if (typeof data === 'string') { 2105 | try { 2106 | data = JSON.parse(data); 2107 | } catch (e) { /* Ignore */ } 2108 | } 2109 | return data; 2110 | }], 2111 | 2112 | /** 2113 | * A timeout in milliseconds to abort a request. If set to 0 (default) a 2114 | * timeout is not created. 2115 | */ 2116 | timeout: 0, 2117 | 2118 | xsrfCookieName: 'XSRF-TOKEN', 2119 | xsrfHeaderName: 'X-XSRF-TOKEN', 2120 | 2121 | maxContentLength: -1, 2122 | maxBodyLength: -1, 2123 | 2124 | validateStatus: function validateStatus(status) { 2125 | return status >= 200 && status < 300; 2126 | } 2127 | }; 2128 | 2129 | defaults.headers = { 2130 | common: { 2131 | 'Accept': 'application/json, text/plain, */*' 2132 | } 2133 | }; 2134 | 2135 | utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) { 2136 | defaults.headers[method] = {}; 2137 | }); 2138 | 2139 | utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) { 2140 | defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE); 2141 | }); 2142 | 2143 | module.exports = defaults; 2144 | 2145 | 2146 | /***/ }), 2147 | 2148 | /***/ 549: 2149 | /***/ (function(module, __unusedexports, __webpack_require__) { 2150 | 2151 | var url = __webpack_require__(835); 2152 | var URL = url.URL; 2153 | var http = __webpack_require__(605); 2154 | var https = __webpack_require__(211); 2155 | var Writable = __webpack_require__(413).Writable; 2156 | var assert = __webpack_require__(357); 2157 | var debug = __webpack_require__(454); 2158 | 2159 | // Create handlers that pass events from native requests 2160 | var eventHandlers = Object.create(null); 2161 | ["abort", "aborted", "connect", "error", "socket", "timeout"].forEach(function (event) { 2162 | eventHandlers[event] = function (arg1, arg2, arg3) { 2163 | this._redirectable.emit(event, arg1, arg2, arg3); 2164 | }; 2165 | }); 2166 | 2167 | // Error types with codes 2168 | var RedirectionError = createErrorType( 2169 | "ERR_FR_REDIRECTION_FAILURE", 2170 | "" 2171 | ); 2172 | var TooManyRedirectsError = createErrorType( 2173 | "ERR_FR_TOO_MANY_REDIRECTS", 2174 | "Maximum number of redirects exceeded" 2175 | ); 2176 | var MaxBodyLengthExceededError = createErrorType( 2177 | "ERR_FR_MAX_BODY_LENGTH_EXCEEDED", 2178 | "Request body larger than maxBodyLength limit" 2179 | ); 2180 | var WriteAfterEndError = createErrorType( 2181 | "ERR_STREAM_WRITE_AFTER_END", 2182 | "write after end" 2183 | ); 2184 | 2185 | // An HTTP(S) request that can be redirected 2186 | function RedirectableRequest(options, responseCallback) { 2187 | // Initialize the request 2188 | Writable.call(this); 2189 | this._sanitizeOptions(options); 2190 | this._options = options; 2191 | this._ended = false; 2192 | this._ending = false; 2193 | this._redirectCount = 0; 2194 | this._redirects = []; 2195 | this._requestBodyLength = 0; 2196 | this._requestBodyBuffers = []; 2197 | 2198 | // Attach a callback if passed 2199 | if (responseCallback) { 2200 | this.on("response", responseCallback); 2201 | } 2202 | 2203 | // React to responses of native requests 2204 | var self = this; 2205 | this._onNativeResponse = function (response) { 2206 | self._processResponse(response); 2207 | }; 2208 | 2209 | // Perform the first request 2210 | this._performRequest(); 2211 | } 2212 | RedirectableRequest.prototype = Object.create(Writable.prototype); 2213 | 2214 | // Writes buffered data to the current native request 2215 | RedirectableRequest.prototype.write = function (data, encoding, callback) { 2216 | // Writing is not allowed if end has been called 2217 | if (this._ending) { 2218 | throw new WriteAfterEndError(); 2219 | } 2220 | 2221 | // Validate input and shift parameters if necessary 2222 | if (!(typeof data === "string" || typeof data === "object" && ("length" in data))) { 2223 | throw new TypeError("data should be a string, Buffer or Uint8Array"); 2224 | } 2225 | if (typeof encoding === "function") { 2226 | callback = encoding; 2227 | encoding = null; 2228 | } 2229 | 2230 | // Ignore empty buffers, since writing them doesn't invoke the callback 2231 | // https://github.com/nodejs/node/issues/22066 2232 | if (data.length === 0) { 2233 | if (callback) { 2234 | callback(); 2235 | } 2236 | return; 2237 | } 2238 | // Only write when we don't exceed the maximum body length 2239 | if (this._requestBodyLength + data.length <= this._options.maxBodyLength) { 2240 | this._requestBodyLength += data.length; 2241 | this._requestBodyBuffers.push({ data: data, encoding: encoding }); 2242 | this._currentRequest.write(data, encoding, callback); 2243 | } 2244 | // Error when we exceed the maximum body length 2245 | else { 2246 | this.emit("error", new MaxBodyLengthExceededError()); 2247 | this.abort(); 2248 | } 2249 | }; 2250 | 2251 | // Ends the current native request 2252 | RedirectableRequest.prototype.end = function (data, encoding, callback) { 2253 | // Shift parameters if necessary 2254 | if (typeof data === "function") { 2255 | callback = data; 2256 | data = encoding = null; 2257 | } 2258 | else if (typeof encoding === "function") { 2259 | callback = encoding; 2260 | encoding = null; 2261 | } 2262 | 2263 | // Write data if needed and end 2264 | if (!data) { 2265 | this._ended = this._ending = true; 2266 | this._currentRequest.end(null, null, callback); 2267 | } 2268 | else { 2269 | var self = this; 2270 | var currentRequest = this._currentRequest; 2271 | this.write(data, encoding, function () { 2272 | self._ended = true; 2273 | currentRequest.end(null, null, callback); 2274 | }); 2275 | this._ending = true; 2276 | } 2277 | }; 2278 | 2279 | // Sets a header value on the current native request 2280 | RedirectableRequest.prototype.setHeader = function (name, value) { 2281 | this._options.headers[name] = value; 2282 | this._currentRequest.setHeader(name, value); 2283 | }; 2284 | 2285 | // Clears a header value on the current native request 2286 | RedirectableRequest.prototype.removeHeader = function (name) { 2287 | delete this._options.headers[name]; 2288 | this._currentRequest.removeHeader(name); 2289 | }; 2290 | 2291 | // Global timeout for all underlying requests 2292 | RedirectableRequest.prototype.setTimeout = function (msecs, callback) { 2293 | if (callback) { 2294 | this.once("timeout", callback); 2295 | } 2296 | 2297 | if (this.socket) { 2298 | startTimer(this, msecs); 2299 | } 2300 | else { 2301 | var self = this; 2302 | this._currentRequest.once("socket", function () { 2303 | startTimer(self, msecs); 2304 | }); 2305 | } 2306 | 2307 | this.once("response", clearTimer); 2308 | this.once("error", clearTimer); 2309 | 2310 | return this; 2311 | }; 2312 | 2313 | function startTimer(request, msecs) { 2314 | clearTimeout(request._timeout); 2315 | request._timeout = setTimeout(function () { 2316 | request.emit("timeout"); 2317 | }, msecs); 2318 | } 2319 | 2320 | function clearTimer() { 2321 | clearTimeout(this._timeout); 2322 | } 2323 | 2324 | // Proxy all other public ClientRequest methods 2325 | [ 2326 | "abort", "flushHeaders", "getHeader", 2327 | "setNoDelay", "setSocketKeepAlive", 2328 | ].forEach(function (method) { 2329 | RedirectableRequest.prototype[method] = function (a, b) { 2330 | return this._currentRequest[method](a, b); 2331 | }; 2332 | }); 2333 | 2334 | // Proxy all public ClientRequest properties 2335 | ["aborted", "connection", "socket"].forEach(function (property) { 2336 | Object.defineProperty(RedirectableRequest.prototype, property, { 2337 | get: function () { return this._currentRequest[property]; }, 2338 | }); 2339 | }); 2340 | 2341 | RedirectableRequest.prototype._sanitizeOptions = function (options) { 2342 | // Ensure headers are always present 2343 | if (!options.headers) { 2344 | options.headers = {}; 2345 | } 2346 | 2347 | // Since http.request treats host as an alias of hostname, 2348 | // but the url module interprets host as hostname plus port, 2349 | // eliminate the host property to avoid confusion. 2350 | if (options.host) { 2351 | // Use hostname if set, because it has precedence 2352 | if (!options.hostname) { 2353 | options.hostname = options.host; 2354 | } 2355 | delete options.host; 2356 | } 2357 | 2358 | // Complete the URL object when necessary 2359 | if (!options.pathname && options.path) { 2360 | var searchPos = options.path.indexOf("?"); 2361 | if (searchPos < 0) { 2362 | options.pathname = options.path; 2363 | } 2364 | else { 2365 | options.pathname = options.path.substring(0, searchPos); 2366 | options.search = options.path.substring(searchPos); 2367 | } 2368 | } 2369 | }; 2370 | 2371 | 2372 | // Executes the next native request (initial or redirect) 2373 | RedirectableRequest.prototype._performRequest = function () { 2374 | // Load the native protocol 2375 | var protocol = this._options.protocol; 2376 | var nativeProtocol = this._options.nativeProtocols[protocol]; 2377 | if (!nativeProtocol) { 2378 | this.emit("error", new TypeError("Unsupported protocol " + protocol)); 2379 | return; 2380 | } 2381 | 2382 | // If specified, use the agent corresponding to the protocol 2383 | // (HTTP and HTTPS use different types of agents) 2384 | if (this._options.agents) { 2385 | var scheme = protocol.substr(0, protocol.length - 1); 2386 | this._options.agent = this._options.agents[scheme]; 2387 | } 2388 | 2389 | // Create the native request 2390 | var request = this._currentRequest = 2391 | nativeProtocol.request(this._options, this._onNativeResponse); 2392 | this._currentUrl = url.format(this._options); 2393 | 2394 | // Set up event handlers 2395 | request._redirectable = this; 2396 | for (var event in eventHandlers) { 2397 | /* istanbul ignore else */ 2398 | if (event) { 2399 | request.on(event, eventHandlers[event]); 2400 | } 2401 | } 2402 | 2403 | // End a redirected request 2404 | // (The first request must be ended explicitly with RedirectableRequest#end) 2405 | if (this._isRedirect) { 2406 | // Write the request entity and end. 2407 | var i = 0; 2408 | var self = this; 2409 | var buffers = this._requestBodyBuffers; 2410 | (function writeNext(error) { 2411 | // Only write if this request has not been redirected yet 2412 | /* istanbul ignore else */ 2413 | if (request === self._currentRequest) { 2414 | // Report any write errors 2415 | /* istanbul ignore if */ 2416 | if (error) { 2417 | self.emit("error", error); 2418 | } 2419 | // Write the next buffer if there are still left 2420 | else if (i < buffers.length) { 2421 | var buffer = buffers[i++]; 2422 | /* istanbul ignore else */ 2423 | if (!request.finished) { 2424 | request.write(buffer.data, buffer.encoding, writeNext); 2425 | } 2426 | } 2427 | // End the request if `end` has been called on us 2428 | else if (self._ended) { 2429 | request.end(); 2430 | } 2431 | } 2432 | }()); 2433 | } 2434 | }; 2435 | 2436 | // Processes a response from the current native request 2437 | RedirectableRequest.prototype._processResponse = function (response) { 2438 | // Store the redirected response 2439 | var statusCode = response.statusCode; 2440 | if (this._options.trackRedirects) { 2441 | this._redirects.push({ 2442 | url: this._currentUrl, 2443 | headers: response.headers, 2444 | statusCode: statusCode, 2445 | }); 2446 | } 2447 | 2448 | // RFC7231§6.4: The 3xx (Redirection) class of status code indicates 2449 | // that further action needs to be taken by the user agent in order to 2450 | // fulfill the request. If a Location header field is provided, 2451 | // the user agent MAY automatically redirect its request to the URI 2452 | // referenced by the Location field value, 2453 | // even if the specific status code is not understood. 2454 | var location = response.headers.location; 2455 | if (location && this._options.followRedirects !== false && 2456 | statusCode >= 300 && statusCode < 400) { 2457 | // Abort the current request 2458 | this._currentRequest.removeAllListeners(); 2459 | this._currentRequest.on("error", noop); 2460 | this._currentRequest.abort(); 2461 | // Discard the remainder of the response to avoid waiting for data 2462 | response.destroy(); 2463 | 2464 | // RFC7231§6.4: A client SHOULD detect and intervene 2465 | // in cyclical redirections (i.e., "infinite" redirection loops). 2466 | if (++this._redirectCount > this._options.maxRedirects) { 2467 | this.emit("error", new TooManyRedirectsError()); 2468 | return; 2469 | } 2470 | 2471 | // RFC7231§6.4: Automatic redirection needs to done with 2472 | // care for methods not known to be safe, […] 2473 | // RFC7231§6.4.2–3: For historical reasons, a user agent MAY change 2474 | // the request method from POST to GET for the subsequent request. 2475 | if ((statusCode === 301 || statusCode === 302) && this._options.method === "POST" || 2476 | // RFC7231§6.4.4: The 303 (See Other) status code indicates that 2477 | // the server is redirecting the user agent to a different resource […] 2478 | // A user agent can perform a retrieval request targeting that URI 2479 | // (a GET or HEAD request if using HTTP) […] 2480 | (statusCode === 303) && !/^(?:GET|HEAD)$/.test(this._options.method)) { 2481 | this._options.method = "GET"; 2482 | // Drop a possible entity and headers related to it 2483 | this._requestBodyBuffers = []; 2484 | removeMatchingHeaders(/^content-/i, this._options.headers); 2485 | } 2486 | 2487 | // Drop the Host header, as the redirect might lead to a different host 2488 | var previousHostName = removeMatchingHeaders(/^host$/i, this._options.headers) || 2489 | url.parse(this._currentUrl).hostname; 2490 | 2491 | // Create the redirected request 2492 | var redirectUrl = url.resolve(this._currentUrl, location); 2493 | debug("redirecting to", redirectUrl); 2494 | this._isRedirect = true; 2495 | var redirectUrlParts = url.parse(redirectUrl); 2496 | Object.assign(this._options, redirectUrlParts); 2497 | 2498 | // Drop the Authorization header if redirecting to another host 2499 | if (redirectUrlParts.hostname !== previousHostName) { 2500 | removeMatchingHeaders(/^authorization$/i, this._options.headers); 2501 | } 2502 | 2503 | // Evaluate the beforeRedirect callback 2504 | if (typeof this._options.beforeRedirect === "function") { 2505 | var responseDetails = { headers: response.headers }; 2506 | try { 2507 | this._options.beforeRedirect.call(null, this._options, responseDetails); 2508 | } 2509 | catch (err) { 2510 | this.emit("error", err); 2511 | return; 2512 | } 2513 | this._sanitizeOptions(this._options); 2514 | } 2515 | 2516 | // Perform the redirected request 2517 | try { 2518 | this._performRequest(); 2519 | } 2520 | catch (cause) { 2521 | var error = new RedirectionError("Redirected request failed: " + cause.message); 2522 | error.cause = cause; 2523 | this.emit("error", error); 2524 | } 2525 | } 2526 | else { 2527 | // The response is not a redirect; return it as-is 2528 | response.responseUrl = this._currentUrl; 2529 | response.redirects = this._redirects; 2530 | this.emit("response", response); 2531 | 2532 | // Clean up 2533 | this._requestBodyBuffers = []; 2534 | } 2535 | }; 2536 | 2537 | // Wraps the key/value object of protocols with redirect functionality 2538 | function wrap(protocols) { 2539 | // Default settings 2540 | var exports = { 2541 | maxRedirects: 21, 2542 | maxBodyLength: 10 * 1024 * 1024, 2543 | }; 2544 | 2545 | // Wrap each protocol 2546 | var nativeProtocols = {}; 2547 | Object.keys(protocols).forEach(function (scheme) { 2548 | var protocol = scheme + ":"; 2549 | var nativeProtocol = nativeProtocols[protocol] = protocols[scheme]; 2550 | var wrappedProtocol = exports[scheme] = Object.create(nativeProtocol); 2551 | 2552 | // Executes a request, following redirects 2553 | wrappedProtocol.request = function (input, options, callback) { 2554 | // Parse parameters 2555 | if (typeof input === "string") { 2556 | var urlStr = input; 2557 | try { 2558 | input = urlToOptions(new URL(urlStr)); 2559 | } 2560 | catch (err) { 2561 | /* istanbul ignore next */ 2562 | input = url.parse(urlStr); 2563 | } 2564 | } 2565 | else if (URL && (input instanceof URL)) { 2566 | input = urlToOptions(input); 2567 | } 2568 | else { 2569 | callback = options; 2570 | options = input; 2571 | input = { protocol: protocol }; 2572 | } 2573 | if (typeof options === "function") { 2574 | callback = options; 2575 | options = null; 2576 | } 2577 | 2578 | // Set defaults 2579 | options = Object.assign({ 2580 | maxRedirects: exports.maxRedirects, 2581 | maxBodyLength: exports.maxBodyLength, 2582 | }, input, options); 2583 | options.nativeProtocols = nativeProtocols; 2584 | 2585 | assert.equal(options.protocol, protocol, "protocol mismatch"); 2586 | debug("options", options); 2587 | return new RedirectableRequest(options, callback); 2588 | }; 2589 | 2590 | // Executes a GET request, following redirects 2591 | wrappedProtocol.get = function (input, options, callback) { 2592 | var request = wrappedProtocol.request(input, options, callback); 2593 | request.end(); 2594 | return request; 2595 | }; 2596 | }); 2597 | return exports; 2598 | } 2599 | 2600 | /* istanbul ignore next */ 2601 | function noop() { /* empty */ } 2602 | 2603 | // from https://github.com/nodejs/node/blob/master/lib/internal/url.js 2604 | function urlToOptions(urlObject) { 2605 | var options = { 2606 | protocol: urlObject.protocol, 2607 | hostname: urlObject.hostname.startsWith("[") ? 2608 | /* istanbul ignore next */ 2609 | urlObject.hostname.slice(1, -1) : 2610 | urlObject.hostname, 2611 | hash: urlObject.hash, 2612 | search: urlObject.search, 2613 | pathname: urlObject.pathname, 2614 | path: urlObject.pathname + urlObject.search, 2615 | href: urlObject.href, 2616 | }; 2617 | if (urlObject.port !== "") { 2618 | options.port = Number(urlObject.port); 2619 | } 2620 | return options; 2621 | } 2622 | 2623 | function removeMatchingHeaders(regex, headers) { 2624 | var lastValue; 2625 | for (var header in headers) { 2626 | if (regex.test(header)) { 2627 | lastValue = headers[header]; 2628 | delete headers[header]; 2629 | } 2630 | } 2631 | return lastValue; 2632 | } 2633 | 2634 | function createErrorType(code, defaultMessage) { 2635 | function CustomError(message) { 2636 | Error.captureStackTrace(this, this.constructor); 2637 | this.message = message || defaultMessage; 2638 | } 2639 | CustomError.prototype = new Error(); 2640 | CustomError.prototype.constructor = CustomError; 2641 | CustomError.prototype.name = "Error [" + code + "]"; 2642 | CustomError.prototype.code = code; 2643 | return CustomError; 2644 | } 2645 | 2646 | // Exports 2647 | module.exports = wrap({ http: http, https: https }); 2648 | module.exports.wrap = wrap; 2649 | 2650 | 2651 | /***/ }), 2652 | 2653 | /***/ 564: 2654 | /***/ (function(module, __unusedexports, __webpack_require__) { 2655 | 2656 | "use strict"; 2657 | 2658 | 2659 | var createError = __webpack_require__(26); 2660 | 2661 | /** 2662 | * Resolve or reject a Promise based on response status. 2663 | * 2664 | * @param {Function} resolve A function that resolves the promise. 2665 | * @param {Function} reject A function that rejects the promise. 2666 | * @param {object} response The response. 2667 | */ 2668 | module.exports = function settle(resolve, reject, response) { 2669 | var validateStatus = response.config.validateStatus; 2670 | if (!response.status || !validateStatus || validateStatus(response.status)) { 2671 | resolve(response); 2672 | } else { 2673 | reject(createError( 2674 | 'Request failed with status code ' + response.status, 2675 | response.config, 2676 | null, 2677 | response.request, 2678 | response 2679 | )); 2680 | } 2681 | }; 2682 | 2683 | 2684 | /***/ }), 2685 | 2686 | /***/ 589: 2687 | /***/ (function(module, __unusedexports, __webpack_require__) { 2688 | 2689 | "use strict"; 2690 | 2691 | 2692 | var utils = __webpack_require__(35); 2693 | 2694 | /** 2695 | * Transform the data for a request or a response 2696 | * 2697 | * @param {Object|String} data The data to be transformed 2698 | * @param {Array} headers The headers for the request or response 2699 | * @param {Array|Function} fns A single function or Array of functions 2700 | * @returns {*} The resulting transformed data 2701 | */ 2702 | module.exports = function transformData(data, headers, fns) { 2703 | /*eslint no-param-reassign:0*/ 2704 | utils.forEach(fns, function transform(fn) { 2705 | data = fn(data, headers); 2706 | }); 2707 | 2708 | return data; 2709 | }; 2710 | 2711 | 2712 | /***/ }), 2713 | 2714 | /***/ 590: 2715 | /***/ (function(module) { 2716 | 2717 | "use strict"; 2718 | 2719 | 2720 | /** 2721 | * Determines whether the specified URL is absolute 2722 | * 2723 | * @param {string} url The URL to test 2724 | * @returns {boolean} True if the specified URL is absolute, otherwise false 2725 | */ 2726 | module.exports = function isAbsoluteURL(url) { 2727 | // A URL is considered absolute if it begins with "://" or "//" (protocol-relative URL). 2728 | // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed 2729 | // by any combination of letters, digits, plus, period, or hyphen. 2730 | return /^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(url); 2731 | }; 2732 | 2733 | 2734 | /***/ }), 2735 | 2736 | /***/ 605: 2737 | /***/ (function(module) { 2738 | 2739 | module.exports = require("http"); 2740 | 2741 | /***/ }), 2742 | 2743 | /***/ 622: 2744 | /***/ (function(module) { 2745 | 2746 | module.exports = require("path"); 2747 | 2748 | /***/ }), 2749 | 2750 | /***/ 631: 2751 | /***/ (function(module, __unusedexports, __webpack_require__) { 2752 | 2753 | "use strict"; 2754 | 2755 | 2756 | var utils = __webpack_require__(35); 2757 | 2758 | // Headers whose duplicates are ignored by node 2759 | // c.f. https://nodejs.org/api/http.html#http_message_headers 2760 | var ignoreDuplicateOf = [ 2761 | 'age', 'authorization', 'content-length', 'content-type', 'etag', 2762 | 'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since', 2763 | 'last-modified', 'location', 'max-forwards', 'proxy-authorization', 2764 | 'referer', 'retry-after', 'user-agent' 2765 | ]; 2766 | 2767 | /** 2768 | * Parse headers into an object 2769 | * 2770 | * ``` 2771 | * Date: Wed, 27 Aug 2014 08:58:49 GMT 2772 | * Content-Type: application/json 2773 | * Connection: keep-alive 2774 | * Transfer-Encoding: chunked 2775 | * ``` 2776 | * 2777 | * @param {String} headers Headers needing to be parsed 2778 | * @returns {Object} Headers parsed into an object 2779 | */ 2780 | module.exports = function parseHeaders(headers) { 2781 | var parsed = {}; 2782 | var key; 2783 | var val; 2784 | var i; 2785 | 2786 | if (!headers) { return parsed; } 2787 | 2788 | utils.forEach(headers.split('\n'), function parser(line) { 2789 | i = line.indexOf(':'); 2790 | key = utils.trim(line.substr(0, i)).toLowerCase(); 2791 | val = utils.trim(line.substr(i + 1)); 2792 | 2793 | if (key) { 2794 | if (parsed[key] && ignoreDuplicateOf.indexOf(key) >= 0) { 2795 | return; 2796 | } 2797 | if (key === 'set-cookie') { 2798 | parsed[key] = (parsed[key] ? parsed[key] : []).concat([val]); 2799 | } else { 2800 | parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val; 2801 | } 2802 | } 2803 | }); 2804 | 2805 | return parsed; 2806 | }; 2807 | 2808 | 2809 | /***/ }), 2810 | 2811 | /***/ 670: 2812 | /***/ (function(module, __unusedexports, __webpack_require__) { 2813 | 2814 | "use strict"; 2815 | 2816 | 2817 | var utils = __webpack_require__(35); 2818 | var settle = __webpack_require__(564); 2819 | var buildFullPath = __webpack_require__(960); 2820 | var buildURL = __webpack_require__(133); 2821 | var http = __webpack_require__(605); 2822 | var https = __webpack_require__(211); 2823 | var httpFollow = __webpack_require__(549).http; 2824 | var httpsFollow = __webpack_require__(549).https; 2825 | var url = __webpack_require__(835); 2826 | var zlib = __webpack_require__(761); 2827 | var pkg = __webpack_require__(361); 2828 | var createError = __webpack_require__(26); 2829 | var enhanceError = __webpack_require__(369); 2830 | 2831 | var isHttps = /https:?/; 2832 | 2833 | /*eslint consistent-return:0*/ 2834 | module.exports = function httpAdapter(config) { 2835 | return new Promise(function dispatchHttpRequest(resolvePromise, rejectPromise) { 2836 | var resolve = function resolve(value) { 2837 | resolvePromise(value); 2838 | }; 2839 | var reject = function reject(value) { 2840 | rejectPromise(value); 2841 | }; 2842 | var data = config.data; 2843 | var headers = config.headers; 2844 | 2845 | // Set User-Agent (required by some servers) 2846 | // Only set header if it hasn't been set in config 2847 | // See https://github.com/axios/axios/issues/69 2848 | if (!headers['User-Agent'] && !headers['user-agent']) { 2849 | headers['User-Agent'] = 'axios/' + pkg.version; 2850 | } 2851 | 2852 | if (data && !utils.isStream(data)) { 2853 | if (Buffer.isBuffer(data)) { 2854 | // Nothing to do... 2855 | } else if (utils.isArrayBuffer(data)) { 2856 | data = Buffer.from(new Uint8Array(data)); 2857 | } else if (utils.isString(data)) { 2858 | data = Buffer.from(data, 'utf-8'); 2859 | } else { 2860 | return reject(createError( 2861 | 'Data after transformation must be a string, an ArrayBuffer, a Buffer, or a Stream', 2862 | config 2863 | )); 2864 | } 2865 | 2866 | // Add Content-Length header if data exists 2867 | headers['Content-Length'] = data.length; 2868 | } 2869 | 2870 | // HTTP basic authentication 2871 | var auth = undefined; 2872 | if (config.auth) { 2873 | var username = config.auth.username || ''; 2874 | var password = config.auth.password || ''; 2875 | auth = username + ':' + password; 2876 | } 2877 | 2878 | // Parse url 2879 | var fullPath = buildFullPath(config.baseURL, config.url); 2880 | var parsed = url.parse(fullPath); 2881 | var protocol = parsed.protocol || 'http:'; 2882 | 2883 | if (!auth && parsed.auth) { 2884 | var urlAuth = parsed.auth.split(':'); 2885 | var urlUsername = urlAuth[0] || ''; 2886 | var urlPassword = urlAuth[1] || ''; 2887 | auth = urlUsername + ':' + urlPassword; 2888 | } 2889 | 2890 | if (auth) { 2891 | delete headers.Authorization; 2892 | } 2893 | 2894 | var isHttpsRequest = isHttps.test(protocol); 2895 | var agent = isHttpsRequest ? config.httpsAgent : config.httpAgent; 2896 | 2897 | var options = { 2898 | path: buildURL(parsed.path, config.params, config.paramsSerializer).replace(/^\?/, ''), 2899 | method: config.method.toUpperCase(), 2900 | headers: headers, 2901 | agent: agent, 2902 | agents: { http: config.httpAgent, https: config.httpsAgent }, 2903 | auth: auth 2904 | }; 2905 | 2906 | if (config.socketPath) { 2907 | options.socketPath = config.socketPath; 2908 | } else { 2909 | options.hostname = parsed.hostname; 2910 | options.port = parsed.port; 2911 | } 2912 | 2913 | var proxy = config.proxy; 2914 | if (!proxy && proxy !== false) { 2915 | var proxyEnv = protocol.slice(0, -1) + '_proxy'; 2916 | var proxyUrl = process.env[proxyEnv] || process.env[proxyEnv.toUpperCase()]; 2917 | if (proxyUrl) { 2918 | var parsedProxyUrl = url.parse(proxyUrl); 2919 | var noProxyEnv = process.env.no_proxy || process.env.NO_PROXY; 2920 | var shouldProxy = true; 2921 | 2922 | if (noProxyEnv) { 2923 | var noProxy = noProxyEnv.split(',').map(function trim(s) { 2924 | return s.trim(); 2925 | }); 2926 | 2927 | shouldProxy = !noProxy.some(function proxyMatch(proxyElement) { 2928 | if (!proxyElement) { 2929 | return false; 2930 | } 2931 | if (proxyElement === '*') { 2932 | return true; 2933 | } 2934 | if (proxyElement[0] === '.' && 2935 | parsed.hostname.substr(parsed.hostname.length - proxyElement.length) === proxyElement) { 2936 | return true; 2937 | } 2938 | 2939 | return parsed.hostname === proxyElement; 2940 | }); 2941 | } 2942 | 2943 | 2944 | if (shouldProxy) { 2945 | proxy = { 2946 | host: parsedProxyUrl.hostname, 2947 | port: parsedProxyUrl.port 2948 | }; 2949 | 2950 | if (parsedProxyUrl.auth) { 2951 | var proxyUrlAuth = parsedProxyUrl.auth.split(':'); 2952 | proxy.auth = { 2953 | username: proxyUrlAuth[0], 2954 | password: proxyUrlAuth[1] 2955 | }; 2956 | } 2957 | } 2958 | } 2959 | } 2960 | 2961 | if (proxy) { 2962 | options.hostname = proxy.host; 2963 | options.host = proxy.host; 2964 | options.headers.host = parsed.hostname + (parsed.port ? ':' + parsed.port : ''); 2965 | options.port = proxy.port; 2966 | options.path = protocol + '//' + parsed.hostname + (parsed.port ? ':' + parsed.port : '') + options.path; 2967 | 2968 | // Basic proxy authorization 2969 | if (proxy.auth) { 2970 | var base64 = Buffer.from(proxy.auth.username + ':' + proxy.auth.password, 'utf8').toString('base64'); 2971 | options.headers['Proxy-Authorization'] = 'Basic ' + base64; 2972 | } 2973 | } 2974 | 2975 | var transport; 2976 | var isHttpsProxy = isHttpsRequest && (proxy ? isHttps.test(proxy.protocol) : true); 2977 | if (config.transport) { 2978 | transport = config.transport; 2979 | } else if (config.maxRedirects === 0) { 2980 | transport = isHttpsProxy ? https : http; 2981 | } else { 2982 | if (config.maxRedirects) { 2983 | options.maxRedirects = config.maxRedirects; 2984 | } 2985 | transport = isHttpsProxy ? httpsFollow : httpFollow; 2986 | } 2987 | 2988 | if (config.maxBodyLength > -1) { 2989 | options.maxBodyLength = config.maxBodyLength; 2990 | } 2991 | 2992 | // Create the request 2993 | var req = transport.request(options, function handleResponse(res) { 2994 | if (req.aborted) return; 2995 | 2996 | // uncompress the response body transparently if required 2997 | var stream = res; 2998 | 2999 | // return the last request in case of redirects 3000 | var lastRequest = res.req || req; 3001 | 3002 | 3003 | // if no content, is HEAD request or decompress disabled we should not decompress 3004 | if (res.statusCode !== 204 && lastRequest.method !== 'HEAD' && config.decompress !== false) { 3005 | switch (res.headers['content-encoding']) { 3006 | /*eslint default-case:0*/ 3007 | case 'gzip': 3008 | case 'compress': 3009 | case 'deflate': 3010 | // add the unzipper to the body stream processing pipeline 3011 | stream = stream.pipe(zlib.createUnzip()); 3012 | 3013 | // remove the content-encoding in order to not confuse downstream operations 3014 | delete res.headers['content-encoding']; 3015 | break; 3016 | } 3017 | } 3018 | 3019 | var response = { 3020 | status: res.statusCode, 3021 | statusText: res.statusMessage, 3022 | headers: res.headers, 3023 | config: config, 3024 | request: lastRequest 3025 | }; 3026 | 3027 | if (config.responseType === 'stream') { 3028 | response.data = stream; 3029 | settle(resolve, reject, response); 3030 | } else { 3031 | var responseBuffer = []; 3032 | stream.on('data', function handleStreamData(chunk) { 3033 | responseBuffer.push(chunk); 3034 | 3035 | // make sure the content length is not over the maxContentLength if specified 3036 | if (config.maxContentLength > -1 && Buffer.concat(responseBuffer).length > config.maxContentLength) { 3037 | stream.destroy(); 3038 | reject(createError('maxContentLength size of ' + config.maxContentLength + ' exceeded', 3039 | config, null, lastRequest)); 3040 | } 3041 | }); 3042 | 3043 | stream.on('error', function handleStreamError(err) { 3044 | if (req.aborted) return; 3045 | reject(enhanceError(err, config, null, lastRequest)); 3046 | }); 3047 | 3048 | stream.on('end', function handleStreamEnd() { 3049 | var responseData = Buffer.concat(responseBuffer); 3050 | if (config.responseType !== 'arraybuffer') { 3051 | responseData = responseData.toString(config.responseEncoding); 3052 | if (!config.responseEncoding || config.responseEncoding === 'utf8') { 3053 | responseData = utils.stripBOM(responseData); 3054 | } 3055 | } 3056 | 3057 | response.data = responseData; 3058 | settle(resolve, reject, response); 3059 | }); 3060 | } 3061 | }); 3062 | 3063 | // Handle errors 3064 | req.on('error', function handleRequestError(err) { 3065 | if (req.aborted && err.code !== 'ERR_FR_TOO_MANY_REDIRECTS') return; 3066 | reject(enhanceError(err, config, null, req)); 3067 | }); 3068 | 3069 | // Handle request timeout 3070 | if (config.timeout) { 3071 | // Sometime, the response will be very slow, and does not respond, the connect event will be block by event loop system. 3072 | // And timer callback will be fired, and abort() will be invoked before connection, then get "socket hang up" and code ECONNRESET. 3073 | // At this time, if we have a large number of request, nodejs will hang up some socket on background. and the number will up and up. 3074 | // And then these socket which be hang up will devoring CPU little by little. 3075 | // ClientRequest.setTimeout will be fired on the specify milliseconds, and can make sure that abort() will be fired after connect. 3076 | req.setTimeout(config.timeout, function handleRequestTimeout() { 3077 | req.abort(); 3078 | reject(createError('timeout of ' + config.timeout + 'ms exceeded', config, 'ECONNABORTED', req)); 3079 | }); 3080 | } 3081 | 3082 | if (config.cancelToken) { 3083 | // Handle cancellation 3084 | config.cancelToken.promise.then(function onCanceled(cancel) { 3085 | if (req.aborted) return; 3086 | 3087 | req.abort(); 3088 | reject(cancel); 3089 | }); 3090 | } 3091 | 3092 | // Send the request 3093 | if (utils.isStream(data)) { 3094 | data.on('error', function handleStreamError(err) { 3095 | reject(enhanceError(err, config, null, req)); 3096 | }).pipe(req); 3097 | } else { 3098 | req.end(data); 3099 | } 3100 | }); 3101 | }; 3102 | 3103 | 3104 | /***/ }), 3105 | 3106 | /***/ 688: 3107 | /***/ (function(module, __unusedexports, __webpack_require__) { 3108 | 3109 | "use strict"; 3110 | 3111 | 3112 | var utils = __webpack_require__(35); 3113 | 3114 | module.exports = ( 3115 | utils.isStandardBrowserEnv() ? 3116 | 3117 | // Standard browser envs have full support of the APIs needed to test 3118 | // whether the request URL is of the same origin as current location. 3119 | (function standardBrowserEnv() { 3120 | var msie = /(msie|trident)/i.test(navigator.userAgent); 3121 | var urlParsingNode = document.createElement('a'); 3122 | var originURL; 3123 | 3124 | /** 3125 | * Parse a URL to discover it's components 3126 | * 3127 | * @param {String} url The URL to be parsed 3128 | * @returns {Object} 3129 | */ 3130 | function resolveURL(url) { 3131 | var href = url; 3132 | 3133 | if (msie) { 3134 | // IE needs attribute set twice to normalize properties 3135 | urlParsingNode.setAttribute('href', href); 3136 | href = urlParsingNode.href; 3137 | } 3138 | 3139 | urlParsingNode.setAttribute('href', href); 3140 | 3141 | // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils 3142 | return { 3143 | href: urlParsingNode.href, 3144 | protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '', 3145 | host: urlParsingNode.host, 3146 | search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '', 3147 | hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '', 3148 | hostname: urlParsingNode.hostname, 3149 | port: urlParsingNode.port, 3150 | pathname: (urlParsingNode.pathname.charAt(0) === '/') ? 3151 | urlParsingNode.pathname : 3152 | '/' + urlParsingNode.pathname 3153 | }; 3154 | } 3155 | 3156 | originURL = resolveURL(window.location.href); 3157 | 3158 | /** 3159 | * Determine if a URL shares the same origin as the current location 3160 | * 3161 | * @param {String} requestURL The URL to test 3162 | * @returns {boolean} True if URL shares the same origin, otherwise false 3163 | */ 3164 | return function isURLSameOrigin(requestURL) { 3165 | var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL; 3166 | return (parsed.protocol === originURL.protocol && 3167 | parsed.host === originURL.host); 3168 | }; 3169 | })() : 3170 | 3171 | // Non standard browser envs (web workers, react-native) lack needed support. 3172 | (function nonStandardBrowserEnv() { 3173 | return function isURLSameOrigin() { 3174 | return true; 3175 | }; 3176 | })() 3177 | ); 3178 | 3179 | 3180 | /***/ }), 3181 | 3182 | /***/ 727: 3183 | /***/ (function(module) { 3184 | 3185 | "use strict"; 3186 | 3187 | 3188 | module.exports = function bind(fn, thisArg) { 3189 | return function wrap() { 3190 | var args = new Array(arguments.length); 3191 | for (var i = 0; i < args.length; i++) { 3192 | args[i] = arguments[i]; 3193 | } 3194 | return fn.apply(thisArg, args); 3195 | }; 3196 | }; 3197 | 3198 | 3199 | /***/ }), 3200 | 3201 | /***/ 732: 3202 | /***/ (function(module) { 3203 | 3204 | "use strict"; 3205 | 3206 | 3207 | module.exports = function isCancel(value) { 3208 | return !!(value && value.__CANCEL__); 3209 | }; 3210 | 3211 | 3212 | /***/ }), 3213 | 3214 | /***/ 747: 3215 | /***/ (function(module) { 3216 | 3217 | module.exports = require("fs"); 3218 | 3219 | /***/ }), 3220 | 3221 | /***/ 761: 3222 | /***/ (function(module) { 3223 | 3224 | module.exports = require("zlib"); 3225 | 3226 | /***/ }), 3227 | 3228 | /***/ 779: 3229 | /***/ (function(module, __unusedexports, __webpack_require__) { 3230 | 3231 | "use strict"; 3232 | 3233 | 3234 | var utils = __webpack_require__(35); 3235 | var buildURL = __webpack_require__(133); 3236 | var InterceptorManager = __webpack_require__(283); 3237 | var dispatchRequest = __webpack_require__(946); 3238 | var mergeConfig = __webpack_require__(825); 3239 | 3240 | /** 3241 | * Create a new instance of Axios 3242 | * 3243 | * @param {Object} instanceConfig The default config for the instance 3244 | */ 3245 | function Axios(instanceConfig) { 3246 | this.defaults = instanceConfig; 3247 | this.interceptors = { 3248 | request: new InterceptorManager(), 3249 | response: new InterceptorManager() 3250 | }; 3251 | } 3252 | 3253 | /** 3254 | * Dispatch a request 3255 | * 3256 | * @param {Object} config The config specific for this request (merged with this.defaults) 3257 | */ 3258 | Axios.prototype.request = function request(config) { 3259 | /*eslint no-param-reassign:0*/ 3260 | // Allow for axios('example/url'[, config]) a la fetch API 3261 | if (typeof config === 'string') { 3262 | config = arguments[1] || {}; 3263 | config.url = arguments[0]; 3264 | } else { 3265 | config = config || {}; 3266 | } 3267 | 3268 | config = mergeConfig(this.defaults, config); 3269 | 3270 | // Set config.method 3271 | if (config.method) { 3272 | config.method = config.method.toLowerCase(); 3273 | } else if (this.defaults.method) { 3274 | config.method = this.defaults.method.toLowerCase(); 3275 | } else { 3276 | config.method = 'get'; 3277 | } 3278 | 3279 | // Hook up interceptors middleware 3280 | var chain = [dispatchRequest, undefined]; 3281 | var promise = Promise.resolve(config); 3282 | 3283 | this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) { 3284 | chain.unshift(interceptor.fulfilled, interceptor.rejected); 3285 | }); 3286 | 3287 | this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) { 3288 | chain.push(interceptor.fulfilled, interceptor.rejected); 3289 | }); 3290 | 3291 | while (chain.length) { 3292 | promise = promise.then(chain.shift(), chain.shift()); 3293 | } 3294 | 3295 | return promise; 3296 | }; 3297 | 3298 | Axios.prototype.getUri = function getUri(config) { 3299 | config = mergeConfig(this.defaults, config); 3300 | return buildURL(config.url, config.params, config.paramsSerializer).replace(/^\?/, ''); 3301 | }; 3302 | 3303 | // Provide aliases for supported request methods 3304 | utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) { 3305 | /*eslint func-names:0*/ 3306 | Axios.prototype[method] = function(url, config) { 3307 | return this.request(mergeConfig(config || {}, { 3308 | method: method, 3309 | url: url 3310 | })); 3311 | }; 3312 | }); 3313 | 3314 | utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) { 3315 | /*eslint func-names:0*/ 3316 | Axios.prototype[method] = function(url, data, config) { 3317 | return this.request(mergeConfig(config || {}, { 3318 | method: method, 3319 | url: url, 3320 | data: data 3321 | })); 3322 | }; 3323 | }); 3324 | 3325 | module.exports = Axios; 3326 | 3327 | 3328 | /***/ }), 3329 | 3330 | /***/ 825: 3331 | /***/ (function(module, __unusedexports, __webpack_require__) { 3332 | 3333 | "use strict"; 3334 | 3335 | 3336 | var utils = __webpack_require__(35); 3337 | 3338 | /** 3339 | * Config-specific merge-function which creates a new config-object 3340 | * by merging two configuration objects together. 3341 | * 3342 | * @param {Object} config1 3343 | * @param {Object} config2 3344 | * @returns {Object} New object resulting from merging config2 to config1 3345 | */ 3346 | module.exports = function mergeConfig(config1, config2) { 3347 | // eslint-disable-next-line no-param-reassign 3348 | config2 = config2 || {}; 3349 | var config = {}; 3350 | 3351 | var valueFromConfig2Keys = ['url', 'method', 'data']; 3352 | var mergeDeepPropertiesKeys = ['headers', 'auth', 'proxy', 'params']; 3353 | var defaultToConfig2Keys = [ 3354 | 'baseURL', 'transformRequest', 'transformResponse', 'paramsSerializer', 3355 | 'timeout', 'timeoutMessage', 'withCredentials', 'adapter', 'responseType', 'xsrfCookieName', 3356 | 'xsrfHeaderName', 'onUploadProgress', 'onDownloadProgress', 'decompress', 3357 | 'maxContentLength', 'maxBodyLength', 'maxRedirects', 'transport', 'httpAgent', 3358 | 'httpsAgent', 'cancelToken', 'socketPath', 'responseEncoding' 3359 | ]; 3360 | var directMergeKeys = ['validateStatus']; 3361 | 3362 | function getMergedValue(target, source) { 3363 | if (utils.isPlainObject(target) && utils.isPlainObject(source)) { 3364 | return utils.merge(target, source); 3365 | } else if (utils.isPlainObject(source)) { 3366 | return utils.merge({}, source); 3367 | } else if (utils.isArray(source)) { 3368 | return source.slice(); 3369 | } 3370 | return source; 3371 | } 3372 | 3373 | function mergeDeepProperties(prop) { 3374 | if (!utils.isUndefined(config2[prop])) { 3375 | config[prop] = getMergedValue(config1[prop], config2[prop]); 3376 | } else if (!utils.isUndefined(config1[prop])) { 3377 | config[prop] = getMergedValue(undefined, config1[prop]); 3378 | } 3379 | } 3380 | 3381 | utils.forEach(valueFromConfig2Keys, function valueFromConfig2(prop) { 3382 | if (!utils.isUndefined(config2[prop])) { 3383 | config[prop] = getMergedValue(undefined, config2[prop]); 3384 | } 3385 | }); 3386 | 3387 | utils.forEach(mergeDeepPropertiesKeys, mergeDeepProperties); 3388 | 3389 | utils.forEach(defaultToConfig2Keys, function defaultToConfig2(prop) { 3390 | if (!utils.isUndefined(config2[prop])) { 3391 | config[prop] = getMergedValue(undefined, config2[prop]); 3392 | } else if (!utils.isUndefined(config1[prop])) { 3393 | config[prop] = getMergedValue(undefined, config1[prop]); 3394 | } 3395 | }); 3396 | 3397 | utils.forEach(directMergeKeys, function merge(prop) { 3398 | if (prop in config2) { 3399 | config[prop] = getMergedValue(config1[prop], config2[prop]); 3400 | } else if (prop in config1) { 3401 | config[prop] = getMergedValue(undefined, config1[prop]); 3402 | } 3403 | }); 3404 | 3405 | var axiosKeys = valueFromConfig2Keys 3406 | .concat(mergeDeepPropertiesKeys) 3407 | .concat(defaultToConfig2Keys) 3408 | .concat(directMergeKeys); 3409 | 3410 | var otherKeys = Object 3411 | .keys(config1) 3412 | .concat(Object.keys(config2)) 3413 | .filter(function filterAxiosKeys(key) { 3414 | return axiosKeys.indexOf(key) === -1; 3415 | }); 3416 | 3417 | utils.forEach(otherKeys, mergeDeepProperties); 3418 | 3419 | return config; 3420 | }; 3421 | 3422 | 3423 | /***/ }), 3424 | 3425 | /***/ 826: 3426 | /***/ (function(module) { 3427 | 3428 | "use strict"; 3429 | 3430 | 3431 | /** 3432 | * A `Cancel` is an object that is thrown when an operation is canceled. 3433 | * 3434 | * @class 3435 | * @param {string=} message The message. 3436 | */ 3437 | function Cancel(message) { 3438 | this.message = message; 3439 | } 3440 | 3441 | Cancel.prototype.toString = function toString() { 3442 | return 'Cancel' + (this.message ? ': ' + this.message : ''); 3443 | }; 3444 | 3445 | Cancel.prototype.__CANCEL__ = true; 3446 | 3447 | module.exports = Cancel; 3448 | 3449 | 3450 | /***/ }), 3451 | 3452 | /***/ 835: 3453 | /***/ (function(module) { 3454 | 3455 | module.exports = require("url"); 3456 | 3457 | /***/ }), 3458 | 3459 | /***/ 864: 3460 | /***/ (function(module, __unusedexports, __webpack_require__) { 3461 | 3462 | "use strict"; 3463 | 3464 | 3465 | var utils = __webpack_require__(35); 3466 | 3467 | module.exports = ( 3468 | utils.isStandardBrowserEnv() ? 3469 | 3470 | // Standard browser envs support document.cookie 3471 | (function standardBrowserEnv() { 3472 | return { 3473 | write: function write(name, value, expires, path, domain, secure) { 3474 | var cookie = []; 3475 | cookie.push(name + '=' + encodeURIComponent(value)); 3476 | 3477 | if (utils.isNumber(expires)) { 3478 | cookie.push('expires=' + new Date(expires).toGMTString()); 3479 | } 3480 | 3481 | if (utils.isString(path)) { 3482 | cookie.push('path=' + path); 3483 | } 3484 | 3485 | if (utils.isString(domain)) { 3486 | cookie.push('domain=' + domain); 3487 | } 3488 | 3489 | if (secure === true) { 3490 | cookie.push('secure'); 3491 | } 3492 | 3493 | document.cookie = cookie.join('; '); 3494 | }, 3495 | 3496 | read: function read(name) { 3497 | var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)')); 3498 | return (match ? decodeURIComponent(match[3]) : null); 3499 | }, 3500 | 3501 | remove: function remove(name) { 3502 | this.write(name, '', Date.now() - 86400000); 3503 | } 3504 | }; 3505 | })() : 3506 | 3507 | // Non standard browser env (web workers, react-native) lack needed support. 3508 | (function nonStandardBrowserEnv() { 3509 | return { 3510 | write: function write() {}, 3511 | read: function read() { return null; }, 3512 | remove: function remove() {} 3513 | }; 3514 | })() 3515 | ); 3516 | 3517 | 3518 | /***/ }), 3519 | 3520 | /***/ 879: 3521 | /***/ (function(module) { 3522 | 3523 | "use strict"; 3524 | 3525 | 3526 | /** 3527 | * Syntactic sugar for invoking a function and expanding an array for arguments. 3528 | * 3529 | * Common use case would be to use `Function.prototype.apply`. 3530 | * 3531 | * ```js 3532 | * function f(x, y, z) {} 3533 | * var args = [1, 2, 3]; 3534 | * f.apply(null, args); 3535 | * ``` 3536 | * 3537 | * With `spread` this example can be re-written. 3538 | * 3539 | * ```js 3540 | * spread(function(x, y, z) {})([1, 2, 3]); 3541 | * ``` 3542 | * 3543 | * @param {Function} callback 3544 | * @returns {Function} 3545 | */ 3546 | module.exports = function spread(callback) { 3547 | return function wrap(arr) { 3548 | return callback.apply(null, arr); 3549 | }; 3550 | }; 3551 | 3552 | 3553 | /***/ }), 3554 | 3555 | /***/ 887: 3556 | /***/ (function(module) { 3557 | 3558 | "use strict"; 3559 | 3560 | 3561 | /** 3562 | * Creates a new URL by combining the specified URLs 3563 | * 3564 | * @param {string} baseURL The base URL 3565 | * @param {string} relativeURL The relative URL 3566 | * @returns {string} The combined URL 3567 | */ 3568 | module.exports = function combineURLs(baseURL, relativeURL) { 3569 | return relativeURL 3570 | ? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '') 3571 | : baseURL; 3572 | }; 3573 | 3574 | 3575 | /***/ }), 3576 | 3577 | /***/ 898: 3578 | /***/ (function(module, __unusedexports, __webpack_require__) { 3579 | 3580 | const {spawn} = __webpack_require__(129); 3581 | 3582 | const exec = (cmd, args = [], options = {}) => new Promise((resolve, reject) => { 3583 | console.log(`Started: ${cmd} ${args.join(' ')}`); 3584 | const optionsToCLI = { 3585 | ...options 3586 | }; 3587 | if (!optionsToCLI.stdio) { 3588 | Object.assign(optionsToCLI, {stdio: ['inherit', 'inherit', 'inherit']}); 3589 | } 3590 | const app = spawn(cmd, args, optionsToCLI); 3591 | app.on('close', (code) => { 3592 | if (code !== 0) { 3593 | const err = new Error(`Invalid status code: ${code}`); 3594 | err.code = code; 3595 | return reject(err); 3596 | } 3597 | return resolve(code); 3598 | }); 3599 | app.on('error', reject); 3600 | }); 3601 | 3602 | module.exports = exec; 3603 | 3604 | /***/ }), 3605 | 3606 | /***/ 944: 3607 | /***/ (function(module) { 3608 | 3609 | module.exports = eval("require")("debug"); 3610 | 3611 | 3612 | /***/ }), 3613 | 3614 | /***/ 946: 3615 | /***/ (function(module, __unusedexports, __webpack_require__) { 3616 | 3617 | "use strict"; 3618 | 3619 | 3620 | var utils = __webpack_require__(35); 3621 | var transformData = __webpack_require__(589); 3622 | var isCancel = __webpack_require__(732); 3623 | var defaults = __webpack_require__(529); 3624 | 3625 | /** 3626 | * Throws a `Cancel` if cancellation has been requested. 3627 | */ 3628 | function throwIfCancellationRequested(config) { 3629 | if (config.cancelToken) { 3630 | config.cancelToken.throwIfRequested(); 3631 | } 3632 | } 3633 | 3634 | /** 3635 | * Dispatch a request to the server using the configured adapter. 3636 | * 3637 | * @param {object} config The config that is to be used for the request 3638 | * @returns {Promise} The Promise to be fulfilled 3639 | */ 3640 | module.exports = function dispatchRequest(config) { 3641 | throwIfCancellationRequested(config); 3642 | 3643 | // Ensure headers exist 3644 | config.headers = config.headers || {}; 3645 | 3646 | // Transform request data 3647 | config.data = transformData( 3648 | config.data, 3649 | config.headers, 3650 | config.transformRequest 3651 | ); 3652 | 3653 | // Flatten headers 3654 | config.headers = utils.merge( 3655 | config.headers.common || {}, 3656 | config.headers[config.method] || {}, 3657 | config.headers 3658 | ); 3659 | 3660 | utils.forEach( 3661 | ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'], 3662 | function cleanHeaderConfig(method) { 3663 | delete config.headers[method]; 3664 | } 3665 | ); 3666 | 3667 | var adapter = config.adapter || defaults.adapter; 3668 | 3669 | return adapter(config).then(function onAdapterResolution(response) { 3670 | throwIfCancellationRequested(config); 3671 | 3672 | // Transform response data 3673 | response.data = transformData( 3674 | response.data, 3675 | response.headers, 3676 | config.transformResponse 3677 | ); 3678 | 3679 | return response; 3680 | }, function onAdapterRejection(reason) { 3681 | if (!isCancel(reason)) { 3682 | throwIfCancellationRequested(config); 3683 | 3684 | // Transform response data 3685 | if (reason && reason.response) { 3686 | reason.response.data = transformData( 3687 | reason.response.data, 3688 | reason.response.headers, 3689 | config.transformResponse 3690 | ); 3691 | } 3692 | } 3693 | 3694 | return Promise.reject(reason); 3695 | }); 3696 | }; 3697 | 3698 | 3699 | /***/ }), 3700 | 3701 | /***/ 960: 3702 | /***/ (function(module, __unusedexports, __webpack_require__) { 3703 | 3704 | "use strict"; 3705 | 3706 | 3707 | var isAbsoluteURL = __webpack_require__(590); 3708 | var combineURLs = __webpack_require__(887); 3709 | 3710 | /** 3711 | * Creates a new URL by combining the baseURL with the requestedURL, 3712 | * only when the requestedURL is not already an absolute URL. 3713 | * If the requestURL is absolute, this function returns the requestedURL untouched. 3714 | * 3715 | * @param {string} baseURL The base URL 3716 | * @param {string} requestedURL Absolute or relative URL to combine 3717 | * @returns {string} The combined full path 3718 | */ 3719 | module.exports = function buildFullPath(baseURL, requestedURL) { 3720 | if (baseURL && !isAbsoluteURL(requestedURL)) { 3721 | return combineURLs(baseURL, requestedURL); 3722 | } 3723 | return requestedURL; 3724 | }; 3725 | 3726 | 3727 | /***/ }) 3728 | 3729 | /******/ }); 3730 | -------------------------------------------------------------------------------- /exec.js: -------------------------------------------------------------------------------- 1 | const {spawn} = require('child_process'); 2 | 3 | const exec = (cmd, args = [], options = {}) => new Promise((resolve, reject) => { 4 | console.log(`Started: ${cmd} ${args.join(' ')}`); 5 | const optionsToCLI = { 6 | ...options 7 | }; 8 | if (!optionsToCLI.stdio) { 9 | Object.assign(optionsToCLI, {stdio: ['inherit', 'inherit', 'inherit']}); 10 | } 11 | const app = spawn(cmd, args, optionsToCLI); 12 | app.on('close', (code) => { 13 | if (code !== 0) { 14 | const err = new Error(`Invalid status code: ${code}`); 15 | err.code = code; 16 | return reject(err); 17 | } 18 | return resolve(code); 19 | }); 20 | app.on('error', reject); 21 | }); 22 | 23 | module.exports = exec; -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | const core = require("@actions/core"); 2 | const axios = require("axios"); 3 | const Humanize = require("humanize-plus"); 4 | const fs = require("fs"); 5 | const exec = require("./exec"); 6 | 7 | const TODOIST_API_KEY = core.getInput("TODOIST_API_KEY"); 8 | const PREMIUM = core.getInput("PREMIUM"); 9 | 10 | async function main() { 11 | // v8 => v9 12 | const stats = await axios( 13 | "https://api.todoist.com/sync/v9/completed/get_stats", 14 | { headers: { Authorization: `Bearer ${TODOIST_API_KEY}` } } 15 | ); 16 | await updateReadme(stats.data); 17 | } 18 | 19 | let todoist = []; 20 | let jobFailFlag = false; 21 | const README_FILE_PATH = "./README.md"; 22 | 23 | async function updateReadme(data) { 24 | const { karma, completed_count, days_items, goals, week_items } = data; 25 | 26 | const karmaPoint = [`🏆 **${Humanize.intComma(karma)}** Karma Points`]; 27 | todoist.push(karmaPoint); 28 | 29 | const dailyGoal = [ 30 | `🌸 Completed **${days_items[0].total_completed.toString()}** tasks today`, 31 | ]; 32 | todoist.push(dailyGoal); 33 | 34 | if (PREMIUM == "true") { 35 | const weekItems = [ 36 | `🗓 Completed **${week_items[0].total_completed.toString()}** tasks this week`, 37 | ]; 38 | todoist.push(weekItems); 39 | } 40 | 41 | const totalTasks = [ 42 | `✅ Completed **${Humanize.intComma(completed_count)}** tasks so far`, 43 | ]; 44 | todoist.push(totalTasks); 45 | 46 | const longestStreak = [ 47 | `⏳ Longest streak is **${goals.max_daily_streak.count}** days`, 48 | ]; 49 | todoist.push(longestStreak); 50 | 51 | if (todoist.length == 0) return; 52 | 53 | if (todoist.length > 0) { 54 | // console.log(todoist.length); 55 | // const showTasks = todoist.reduce((todo, cur, index) => { 56 | // return todo + `\n${cur} ` + (((index + 1) === todoist.length) ? '\n' : ''); 57 | // }) 58 | const readmeData = fs.readFileSync(README_FILE_PATH, "utf8"); 59 | 60 | const newReadme = buildReadme(readmeData, todoist.join(" \n")); 61 | if (newReadme !== readmeData) { 62 | core.info("Writing to " + README_FILE_PATH); 63 | fs.writeFileSync(README_FILE_PATH, newReadme); 64 | if (!process.env.TEST_MODE) { 65 | commitReadme(); 66 | } 67 | } else { 68 | core.info("No change detected, skipping"); 69 | process.exit(0); 70 | } 71 | } else { 72 | core.info("Nothing fetched"); 73 | process.exit(jobFailFlag ? 1 : 0); 74 | } 75 | } 76 | 77 | // console.log(todoist.length); 78 | 79 | const buildReadme = (prevReadmeContent, newReadmeContent) => { 80 | const tagToLookFor = ""; 82 | const startOfOpeningTagIndex = prevReadmeContent.indexOf( 83 | `${tagToLookFor}START` 84 | ); 85 | const endOfOpeningTagIndex = prevReadmeContent.indexOf( 86 | closingTag, 87 | startOfOpeningTagIndex 88 | ); 89 | const startOfClosingTagIndex = prevReadmeContent.indexOf( 90 | `${tagToLookFor}END`, 91 | endOfOpeningTagIndex 92 | ); 93 | if ( 94 | startOfOpeningTagIndex === -1 || 95 | endOfOpeningTagIndex === -1 || 96 | startOfClosingTagIndex === -1 97 | ) { 98 | core.error( 99 | `Cannot find the comment tag on the readme:\n\n` 100 | ); 101 | process.exit(1); 102 | } 103 | return [ 104 | prevReadmeContent.slice(0, endOfOpeningTagIndex + closingTag.length), 105 | "\n", 106 | newReadmeContent, 107 | "\n", 108 | prevReadmeContent.slice(startOfClosingTagIndex), 109 | ].join(""); 110 | }; 111 | 112 | const commitReadme = async () => { 113 | // Getting config 114 | const committerUsername = "Abhishek Naidu"; 115 | const committerEmail = "example@gmail.com"; 116 | const commitMessage = "Todoist updated."; 117 | // Doing commit and push 118 | await exec("git", ["config", "--global", "user.email", committerEmail]); 119 | await exec("git", ["config", "--global", "user.name", committerUsername]); 120 | await exec("git", ["add", README_FILE_PATH]); 121 | await exec("git", ["commit", "-m", commitMessage]); 122 | // await exec('git', ['fetch']); 123 | await exec("git", ["push"]); 124 | core.info("Readme updated successfully."); 125 | // Making job fail if one of the source fails 126 | process.exit(jobFailFlag ? 1 : 0); 127 | }; 128 | 129 | (async () => { 130 | await main(); 131 | })(); 132 | -------------------------------------------------------------------------------- /package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "todoist-readme", 3 | "version": "0.0.7", 4 | "lockfileVersion": 1, 5 | "requires": true, 6 | "dependencies": { 7 | "@actions/core": { 8 | "version": "1.2.5", 9 | "resolved": "https://registry.npmjs.org/@actions/core/-/core-1.2.5.tgz", 10 | "integrity": "sha512-mwpoNjHSWWh0IiALdDEQi3tru124JKn0yVNziIBzTME8QRv7thwoghVuT1jBRjFvdtoHsqD58IRHy1nf86paRg==" 11 | }, 12 | "@zeit/ncc": { 13 | "version": "0.22.3", 14 | "resolved": "https://registry.npmjs.org/@zeit/ncc/-/ncc-0.22.3.tgz", 15 | "integrity": "sha512-jnCLpLXWuw/PAiJiVbLjA8WBC0IJQbFeUwF4I9M+23MvIxTxk5pD4Q8byQBSPmHQjz5aBoA7AKAElQxMpjrCLQ==", 16 | "dev": true 17 | }, 18 | "axios": { 19 | "version": "0.20.0", 20 | "resolved": "https://registry.npmjs.org/axios/-/axios-0.20.0.tgz", 21 | "integrity": "sha512-ANA4rr2BDcmmAQLOKft2fufrtuvlqR+cXNNinUmvfeSNCOF98PZL+7M/v1zIdGo7OLjEA9J2gXJL+j4zGsl0bA==", 22 | "requires": { 23 | "follow-redirects": "^1.10.0" 24 | } 25 | }, 26 | "child_process": { 27 | "version": "1.0.2", 28 | "resolved": "https://registry.npmjs.org/child_process/-/child_process-1.0.2.tgz", 29 | "integrity": "sha1-sffn/HPSXn/R1FWtyU4UODAYK1o=" 30 | }, 31 | "follow-redirects": { 32 | "version": "1.13.0", 33 | "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.13.0.tgz", 34 | "integrity": "sha512-aq6gF1BEKje4a9i9+5jimNFIpq4Q1WiwBToeRK5NvZBd/TRsmW8BsJfOEGkr76TbOyPVD3OVDN910EcUNtRYEA==" 35 | }, 36 | "humanize-plus": { 37 | "version": "1.8.2", 38 | "resolved": "https://registry.npmjs.org/humanize-plus/-/humanize-plus-1.8.2.tgz", 39 | "integrity": "sha1-pls0RZrWNnrbs3B6gqPJ+RYWcDA=" 40 | }, 41 | "process": { 42 | "version": "0.11.10", 43 | "resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz", 44 | "integrity": "sha1-czIwDoQBYb2j5podHZGn1LwW8YI=" 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "todoist-readme", 3 | "version": "0.0.7", 4 | "description": "🚧 Updates README with your Todoist stats", 5 | "main": "index.js", 6 | "dependencies": { 7 | "@actions/core": "^1.2.5", 8 | "axios": "^0.20.0", 9 | "child_process": "^1.0.2", 10 | "humanize-plus": "^1.8.2", 11 | "process": "^0.11.10" 12 | }, 13 | "devDependencies": { 14 | "@zeit/ncc": "^0.22.3" 15 | }, 16 | "scripts": { 17 | "test": "echo \"Error: no test specified\" && exit 1", 18 | "build": "ncc build index.js -o dist" 19 | }, 20 | "repository": { 21 | "type": "git", 22 | "url": "git+https://github.com/abhisheknaiidu/todoist-readme.git" 23 | }, 24 | "author": "Abhishek Naidu", 25 | "license": "ISC", 26 | "bugs": { 27 | "url": "https://github.com/abhisheknaiidu/todoist-readme/issues" 28 | }, 29 | "homepage": "https://github.com/abhisheknaiidu/todoist-readme#readme" 30 | } 31 | --------------------------------------------------------------------------------