├── .babelrc ├── .flowconfig ├── .gitignore ├── LICENSE ├── README.md ├── flow-typed └── npm │ ├── babel-plugin-transform-flow-strip-types_vx.x.x.js │ ├── babel-polyfill_vx.x.x.js │ ├── babel-preset-env_vx.x.x.js │ ├── babel-preset-flow_vx.x.x.js │ ├── babel-preset-latest_vx.x.x.js │ ├── chalk_vx.x.x.js │ ├── configstore_vx.x.x.js │ ├── eslint-config-prettier_vx.x.x.js │ ├── eslint-plugin-prettier_vx.x.x.js │ ├── eslint_vx.x.x.js │ ├── flow-bin_v0.x.x.js │ ├── fs-extra_vx.x.x.js │ ├── global_vx.x.x.js │ ├── gulp-babel_vx.x.x.js │ ├── gulp-flowtype_vx.x.x.js │ ├── gulp-sourcemaps_vx.x.x.js │ ├── gulp_vx.x.x.js │ ├── moment_v2.3.x.js │ ├── path_vx.x.x.js │ ├── prettier_vx.x.x.js │ ├── terminal-menu_vx.x.x.js │ ├── xo_vx.x.x.js │ └── yargs_vx.x.x.js ├── goals ├── completed │ └── weekly │ │ └── Sep0620171312 │ │ └── Play_With_Puppies.md ├── monthly │ ├── read_a_book.md │ └── submit_a_CFP_for_a_conference.md ├── other │ └── work_on_a_cool_side_project.md └── yearly │ ├── be_kind.md │ ├── contribute_to_open_source.md │ └── write_more_blog_posts.md ├── gulpfile.js ├── lib ├── cli.js ├── cli.js.map ├── commands │ ├── clear.js │ ├── clear.js.map │ ├── complete.js │ ├── complete.js.map │ ├── config.js │ ├── config.js.map │ ├── delete.js │ ├── delete.js.map │ ├── ls.js │ ├── ls.js.map │ ├── new.js │ └── new.js.map └── utils │ ├── file.js │ ├── file.js.map │ ├── markdown.js │ └── markdown.js.map ├── package-lock.json ├── package.json ├── src ├── cli.js ├── commands │ ├── clear.js │ ├── complete.js │ ├── config.js │ ├── delete.js │ ├── ls.js │ └── new.js └── utils │ ├── file.js │ └── markdown.js └── yarn.lock /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["flow"], 3 | "plugins": ["transform-flow-strip-types", "sitrep", "transform-async-to-generator"] 4 | } 5 | -------------------------------------------------------------------------------- /.flowconfig: -------------------------------------------------------------------------------- 1 | [ignore] 2 | .*/node_modules/.* 3 | .*/gulpfile.js 4 | .*/lib/.* 5 | [include] 6 | .*/src/.* 7 | 8 | [libs] 9 | 10 | [options] 11 | 12 | [lints] 13 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # dependencies 2 | node_modules 3 | .node-version 4 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Kevin Davis 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Personal Goals CLI 2 | ================== 3 | Inspired by [Una Kravets](http://una.im/personal-goals-guide) 4 | Simple way to create and manage weekly/monthly/yearly/other goals 5 | 6 | To use: `yarn global add personal-goals-cli` 7 | make sure to set the active directory and where to store your README although they will default to the folder you first call `goals` from. 8 | 9 | ``` 10 | goals cfg dir '/users/me/projects/personal-goals/goals' 11 | 12 | goals cfg readme '/users/me/projects/personal-goals/' 13 | ``` 14 | They can be the same, I just like the goals contained in their own folder 😀 15 | 16 | 17 | # Examples: 18 | 19 | All commands will start with `goals` 20 | 21 | ## Creating a new goal 22 | 23 | You can use `new` or `n` to create a new goal followed by the type (`yearly` or `y`, `monthly` or `m`, `weekly` or `w`, `other` or `o`). 24 | 25 | The default is `weekly` 26 | ``` 27 | goals new w 'Play with puppies' #creates a new weekly goal 28 | 29 | goals n other 'Work on a cool side project' #creates a new 'other' goal 30 | 31 | goals n y 'Be kind' #creates a new yearly goal 32 | 33 | goals n y 'Contribute to open source' 34 | 35 | goals n y 'Write more blog posts' 36 | ``` 37 | 38 | ## Marking a goal as completed 39 | 40 | You can use `complete` or `c` to mark a goal as completed followed by the type (`yearly` or `y`, `monthly` or `m`, `weekly` or `w`, `other` or `o`). 41 | 42 | The default is `weekly` 43 | ``` 44 | goals complete w #will list all weekly goals and allow you to choose which to mark as completed 45 | 46 | goals c #will list all weekly goals and allow you to choose which to mark as completed 47 | 48 | goals c y #will list all yearly goals and allow you to choose which to mark as completed 49 | ``` 50 | 51 | ## Listing Goals 52 | 53 | You can use `ls` or `list` to list goals followed by the type (`yearly` or `y`, `monthly` or `m`, `weekly` or `w`, `other` or `o`, `completed` or `c`, or `all` or `a`). 54 | 55 | The default is `all` 56 | ``` 57 | goals ls #lists all goals 58 | 59 | goals list #lists all goals 60 | 61 | goals ls c #lists all completed goals 62 | 63 | goals list y #lists all yearly goals 64 | 65 | goals ls weekly #lists all weekly goals 66 | ``` 67 | 68 | ## Changing Config 69 | 70 | You can use `config` or `cfg` to manage the configuration settings 71 | 72 | Possible configuration keys are `dir`, `readme`, `types`, `alias`, `focus`, and `title` 73 | 74 | The `dir` is where your goals reside and `readme` is where you want the README.md to be generated 75 | 76 | 77 | ``` 78 | goals cfg dir '/users/me/projects/personal-goals/goals' 79 | 80 | goals cfg readme '/users/me/projects/personal-goals/' 81 | 82 | goals conf focus w 'getting enough sleep' 83 | 84 | goals config focus weekly 'getting more involved in communities' 85 | 86 | goals cfg title weekly 'Shit I need to do this week' 87 | 88 | goals cfg type today #creates a new goal of type 'today' 89 | 90 | goals cfg alias t today #creates an alias for today so you can shorten it to 't' 91 | 92 | goals cfg clear type t #for when you want to delete a goal type 93 | 94 | goals config clear #will clear all config settings 95 | 96 | goals config clear focus #will delete the all focuses 97 | 98 | goals config ls #will list the current config settings 99 | ``` 100 | 101 | ## Clearing Goals 102 | 103 | You can use `clear` or `clr` to clear goal followed by the type (`yearly` or `y`, `monthly` or `m`, `weekly` or `w`, `other` or `o`, `completed` or `c`, or `all` or `a`). 104 | 105 | The default is `all` 106 | ``` 107 | goals clr #deletes all goals 108 | 109 | goals clear weekly #deletes all weekly goals 110 | 111 | goals clr c #deletes all completed goals 112 | ``` 113 | 114 | ## Deleting Specific Goals 115 | 116 | You can use `delete`, `d`, or `del` to delete a goal followed by the type (`yearly` or `y`, `monthly` or `m`, `weekly` or `w`, `other` or `o`, `completed` or `c`, or `all` or `a`). 117 | 118 | The default is `weekly` 119 | ``` 120 | goals del #lists weekly goals and will allow you to choose which to delete 121 | 122 | goals delete y #lists yearly goals and will allow you to choose which to delete 123 | 124 | goals d month #lists monthly goals and will allow you to choose which to delete 125 | ``` 126 | 127 | For each new goal, a README is generated in the directory specified by the `dir` configuration. You'll see the goals for this project in the `goals` driectory 128 | 129 | ### README: 130 | The generated README will be in the following format where the order of the goals is configurable. Just edit the generated README and reorder as you wish 131 | 132 | ``` 133 | 134 | Personal Goals 135 | ============== 136 | Personal goals made open source for accessibility across computers I use, transparency, accountability, and versioning. Learn more about it [here](http://una.im/personal-goals-guide). 137 | 138 | Generated by the [personal-goals-cli](https://github.com/kevindavus/personal-goals-cli) 139 | 140 | 141 | 142 | # Overarching Goals: 143 | 144 | * [ ] Be Kind 145 | * [ ] Contribute To Open Source 146 | * [ ] Write More Blog Posts 147 | 148 | 149 | 150 | 151 | ### This Week's Focus: Be Awesome. 152 | 153 | # Sep 4th, 2017 154 | 155 | 156 | 157 | ### Things I'll Do This Week: 158 | 159 | * [x] Play With Puppies _- September 6th 2017_ 160 | 161 | 162 | 163 | 164 | ### Things I'll Do This Month ( September 2017 ): 165 | 166 | * [ ] Read A Book 167 | * [ ] Submit A CFP For A Conference 168 | 169 | 170 | 171 | 172 | ### Other Goals: 173 | 174 | * [ ] Work On A Cool Side Project 175 | 176 | 177 | ``` 178 | 179 | and will render like this : 180 | 181 | 182 | 183 | Personal Goals 184 | ============== 185 | Personal goals made open source for accessibility across computers I use, transparency, accountability, and versioning. Learn more about it [here](http://una.im/personal-goals-guide). 186 | 187 | Generated by the [personal-goals-cli](https://github.com/kevindavus/personal-goals-cli) 188 | 189 | 190 | 191 | # Overarching Goals: 192 | 193 | * [ ] Be Kind 194 | * [ ] Contribute To Open Source 195 | * [ ] Write More Blog Posts 196 | 197 | 198 | 199 | 200 | ### This Week's Focus: Be Awesome. 201 | 202 | # Sep 4th, 2017 203 | 204 | 205 | 206 | ### Things I'll Do This Week: 207 | 208 | * [x] Play With Puppies _- September 6th 2017_ 209 | 210 | 211 | 212 | 213 | ### Things I'll Do This Month ( September 2017 ): 214 | 215 | * [ ] Read A Book 216 | * [ ] Submit A CFP For A Conference 217 | 218 | 219 | 220 | 221 | ### Other Goals: 222 | 223 | * [ ] Work On A Cool Side Project 224 | 225 | -------------------------------------------------------------------------------- /flow-typed/npm/babel-plugin-transform-flow-strip-types_vx.x.x.js: -------------------------------------------------------------------------------- 1 | // flow-typed signature: 6d0ac1021563d5952803edb04f5961ba 2 | // flow-typed version: <>/babel-plugin-transform-flow-strip-types_v6.21.0/flow_v0.55.0 3 | 4 | /** 5 | * This is an autogenerated libdef stub for: 6 | * 7 | * 'babel-plugin-transform-flow-strip-types' 8 | * 9 | * Fill this stub out by replacing all the `any` types. 10 | * 11 | * Once filled out, we encourage you to share your work with the 12 | * community by sending a pull request to: 13 | * https://github.com/flowtype/flow-typed 14 | */ 15 | 16 | declare module 'babel-plugin-transform-flow-strip-types' { 17 | declare module.exports: any; 18 | } 19 | 20 | /** 21 | * We include stubs for each file inside this npm package in case you need to 22 | * require those files directly. Feel free to delete any files that aren't 23 | * needed. 24 | */ 25 | declare module 'babel-plugin-transform-flow-strip-types/lib/index' { 26 | declare module.exports: any; 27 | } 28 | 29 | // Filename aliases 30 | declare module 'babel-plugin-transform-flow-strip-types/lib/index.js' { 31 | declare module.exports: $Exports<'babel-plugin-transform-flow-strip-types/lib/index'>; 32 | } 33 | -------------------------------------------------------------------------------- /flow-typed/npm/babel-polyfill_vx.x.x.js: -------------------------------------------------------------------------------- 1 | // flow-typed signature: 140edd3beefdee9d47164269962fc063 2 | // flow-typed version: <>/babel-polyfill_v6.20.0/flow_v0.55.0 3 | 4 | /** 5 | * This is an autogenerated libdef stub for: 6 | * 7 | * 'babel-polyfill' 8 | * 9 | * Fill this stub out by replacing all the `any` types. 10 | * 11 | * Once filled out, we encourage you to share your work with the 12 | * community by sending a pull request to: 13 | * https://github.com/flowtype/flow-typed 14 | */ 15 | 16 | declare module 'babel-polyfill' { 17 | declare module.exports: any; 18 | } 19 | 20 | /** 21 | * We include stubs for each file inside this npm package in case you need to 22 | * require those files directly. Feel free to delete any files that aren't 23 | * needed. 24 | */ 25 | declare module 'babel-polyfill/browser' { 26 | declare module.exports: any; 27 | } 28 | 29 | declare module 'babel-polyfill/dist/polyfill' { 30 | declare module.exports: any; 31 | } 32 | 33 | declare module 'babel-polyfill/dist/polyfill.min' { 34 | declare module.exports: any; 35 | } 36 | 37 | declare module 'babel-polyfill/lib/index' { 38 | declare module.exports: any; 39 | } 40 | 41 | declare module 'babel-polyfill/scripts/postpublish' { 42 | declare module.exports: any; 43 | } 44 | 45 | declare module 'babel-polyfill/scripts/prepublish' { 46 | declare module.exports: any; 47 | } 48 | 49 | // Filename aliases 50 | declare module 'babel-polyfill/browser.js' { 51 | declare module.exports: $Exports<'babel-polyfill/browser'>; 52 | } 53 | declare module 'babel-polyfill/dist/polyfill.js' { 54 | declare module.exports: $Exports<'babel-polyfill/dist/polyfill'>; 55 | } 56 | declare module 'babel-polyfill/dist/polyfill.min.js' { 57 | declare module.exports: $Exports<'babel-polyfill/dist/polyfill.min'>; 58 | } 59 | declare module 'babel-polyfill/lib/index.js' { 60 | declare module.exports: $Exports<'babel-polyfill/lib/index'>; 61 | } 62 | declare module 'babel-polyfill/scripts/postpublish.js' { 63 | declare module.exports: $Exports<'babel-polyfill/scripts/postpublish'>; 64 | } 65 | declare module 'babel-polyfill/scripts/prepublish.js' { 66 | declare module.exports: $Exports<'babel-polyfill/scripts/prepublish'>; 67 | } 68 | -------------------------------------------------------------------------------- /flow-typed/npm/babel-preset-env_vx.x.x.js: -------------------------------------------------------------------------------- 1 | // flow-typed signature: 156e4ce8839874b7912495dd67fba8d3 2 | // flow-typed version: <>/babel-preset-env_v^1.6.0/flow_v0.55.0 3 | 4 | /** 5 | * This is an autogenerated libdef stub for: 6 | * 7 | * 'babel-preset-env' 8 | * 9 | * Fill this stub out by replacing all the `any` types. 10 | * 11 | * Once filled out, we encourage you to share your work with the 12 | * community by sending a pull request to: 13 | * https://github.com/flowtype/flow-typed 14 | */ 15 | 16 | declare module 'babel-preset-env' { 17 | declare module.exports: any; 18 | } 19 | 20 | /** 21 | * We include stubs for each file inside this npm package in case you need to 22 | * require those files directly. Feel free to delete any files that aren't 23 | * needed. 24 | */ 25 | declare module 'babel-preset-env/data/built-in-features' { 26 | declare module.exports: any; 27 | } 28 | 29 | declare module 'babel-preset-env/data/plugin-features' { 30 | declare module.exports: any; 31 | } 32 | 33 | declare module 'babel-preset-env/lib/default-includes' { 34 | declare module.exports: any; 35 | } 36 | 37 | declare module 'babel-preset-env/lib/index' { 38 | declare module.exports: any; 39 | } 40 | 41 | declare module 'babel-preset-env/lib/module-transformations' { 42 | declare module.exports: any; 43 | } 44 | 45 | declare module 'babel-preset-env/lib/normalize-options' { 46 | declare module.exports: any; 47 | } 48 | 49 | declare module 'babel-preset-env/lib/targets-parser' { 50 | declare module.exports: any; 51 | } 52 | 53 | declare module 'babel-preset-env/lib/transform-polyfill-require-plugin' { 54 | declare module.exports: any; 55 | } 56 | 57 | declare module 'babel-preset-env/lib/utils' { 58 | declare module.exports: any; 59 | } 60 | 61 | // Filename aliases 62 | declare module 'babel-preset-env/data/built-in-features.js' { 63 | declare module.exports: $Exports<'babel-preset-env/data/built-in-features'>; 64 | } 65 | declare module 'babel-preset-env/data/plugin-features.js' { 66 | declare module.exports: $Exports<'babel-preset-env/data/plugin-features'>; 67 | } 68 | declare module 'babel-preset-env/lib/default-includes.js' { 69 | declare module.exports: $Exports<'babel-preset-env/lib/default-includes'>; 70 | } 71 | declare module 'babel-preset-env/lib/index.js' { 72 | declare module.exports: $Exports<'babel-preset-env/lib/index'>; 73 | } 74 | declare module 'babel-preset-env/lib/module-transformations.js' { 75 | declare module.exports: $Exports<'babel-preset-env/lib/module-transformations'>; 76 | } 77 | declare module 'babel-preset-env/lib/normalize-options.js' { 78 | declare module.exports: $Exports<'babel-preset-env/lib/normalize-options'>; 79 | } 80 | declare module 'babel-preset-env/lib/targets-parser.js' { 81 | declare module.exports: $Exports<'babel-preset-env/lib/targets-parser'>; 82 | } 83 | declare module 'babel-preset-env/lib/transform-polyfill-require-plugin.js' { 84 | declare module.exports: $Exports<'babel-preset-env/lib/transform-polyfill-require-plugin'>; 85 | } 86 | declare module 'babel-preset-env/lib/utils.js' { 87 | declare module.exports: $Exports<'babel-preset-env/lib/utils'>; 88 | } 89 | -------------------------------------------------------------------------------- /flow-typed/npm/babel-preset-flow_vx.x.x.js: -------------------------------------------------------------------------------- 1 | // flow-typed signature: 384f6372ade91cc5cf4a253f067803b4 2 | // flow-typed version: <>/babel-preset-flow_v^6.23.0/flow_v0.55.0 3 | 4 | /** 5 | * This is an autogenerated libdef stub for: 6 | * 7 | * 'babel-preset-flow' 8 | * 9 | * Fill this stub out by replacing all the `any` types. 10 | * 11 | * Once filled out, we encourage you to share your work with the 12 | * community by sending a pull request to: 13 | * https://github.com/flowtype/flow-typed 14 | */ 15 | 16 | declare module 'babel-preset-flow' { 17 | declare module.exports: any; 18 | } 19 | 20 | /** 21 | * We include stubs for each file inside this npm package in case you need to 22 | * require those files directly. Feel free to delete any files that aren't 23 | * needed. 24 | */ 25 | declare module 'babel-preset-flow/lib/index' { 26 | declare module.exports: any; 27 | } 28 | 29 | // Filename aliases 30 | declare module 'babel-preset-flow/lib/index.js' { 31 | declare module.exports: $Exports<'babel-preset-flow/lib/index'>; 32 | } 33 | -------------------------------------------------------------------------------- /flow-typed/npm/babel-preset-latest_vx.x.x.js: -------------------------------------------------------------------------------- 1 | // flow-typed signature: 495829a50523c9dd8391dfaf77eb72f6 2 | // flow-typed version: <>/babel-preset-latest_v6.16.0/flow_v0.55.0 3 | 4 | /** 5 | * This is an autogenerated libdef stub for: 6 | * 7 | * 'babel-preset-latest' 8 | * 9 | * Fill this stub out by replacing all the `any` types. 10 | * 11 | * Once filled out, we encourage you to share your work with the 12 | * community by sending a pull request to: 13 | * https://github.com/flowtype/flow-typed 14 | */ 15 | 16 | declare module 'babel-preset-latest' { 17 | declare module.exports: any; 18 | } 19 | 20 | /** 21 | * We include stubs for each file inside this npm package in case you need to 22 | * require those files directly. Feel free to delete any files that aren't 23 | * needed. 24 | */ 25 | declare module 'babel-preset-latest/lib/index' { 26 | declare module.exports: any; 27 | } 28 | 29 | // Filename aliases 30 | declare module 'babel-preset-latest/lib/index.js' { 31 | declare module.exports: $Exports<'babel-preset-latest/lib/index'>; 32 | } 33 | -------------------------------------------------------------------------------- /flow-typed/npm/chalk_vx.x.x.js: -------------------------------------------------------------------------------- 1 | // flow-typed signature: b9678caded15fc7d87823867acec40cd 2 | // flow-typed version: <>/chalk_v^2.1.0/flow_v0.55.0 3 | 4 | /** 5 | * This is an autogenerated libdef stub for: 6 | * 7 | * 'chalk' 8 | * 9 | * Fill this stub out by replacing all the `any` types. 10 | * 11 | * Once filled out, we encourage you to share your work with the 12 | * community by sending a pull request to: 13 | * https://github.com/flowtype/flow-typed 14 | */ 15 | 16 | declare class chalk$chalk { 17 | static reset(string: string): string, 18 | 19 | static bold(string: string): string, 20 | 21 | static dim(string: string): string, 22 | 23 | static italic(string: string): string, 24 | 25 | static underline(string: string): string, 26 | 27 | static inverse(string: string): string, 28 | 29 | static hidden(string: string): string, 30 | 31 | static strikethrough(string: string): string, 32 | 33 | static black(string: string): string, 34 | 35 | static red(string: string): string, 36 | 37 | static green(string: string): string, 38 | 39 | static yellow(string: string): string, 40 | 41 | static blue(string: string): string, 42 | 43 | static magenta(string: string): string, 44 | 45 | static cyan(string: string): string, 46 | 47 | static white(string: string): string, 48 | 49 | static gray(string: string): string, 50 | 51 | static grey(string: string): string, 52 | 53 | static bgBlack(string: string): string, 54 | 55 | static bgRed(string: string): string, 56 | 57 | static bgGreen(string: string): string, 58 | 59 | static bgYellow(string: string): string, 60 | 61 | static bgBlue(string: string): string, 62 | 63 | static bgMagenta(string: string): string, 64 | 65 | static bgCyan(string: string): string, 66 | 67 | static bgWhite: chalk$chalk 68 | } 69 | 70 | declare module "chalk" { 71 | declare module.exports: Class; 72 | } 73 | -------------------------------------------------------------------------------- /flow-typed/npm/configstore_vx.x.x.js: -------------------------------------------------------------------------------- 1 | // flow-typed signature: 602756263aead7f46a863f636d59ed98 2 | // flow-typed version: <>/configstore_v3.1.1/flow_v0.55.0 3 | 4 | /** 5 | * Flowtype definitions for index 6 | * Generated by Flowgen from a Typescript Definition 7 | * Flowgen v1.2.0 8 | * Author: [Joar Wilk](http://twitter.com/joarwilk) 9 | * Repo: http://github.com/joarwilk/flowgen 10 | */ 11 | 12 | type configStore$PGCalias = { 13 | y: string, 14 | year: string, 15 | m: string, 16 | month: string, 17 | w: string, 18 | week: string, 19 | o: string 20 | }; 21 | type configStore$PGCfocus = { 22 | weekly: string 23 | }; 24 | type configStore$PGCtypes = Array; 25 | type configStore$PGCtitles = { 26 | yearly: string, 27 | monthly: string, 28 | weekly: string, 29 | other: string, 30 | today: string, 31 | tomorrow: string 32 | }; 33 | 34 | type configStore$PGCconf = { 35 | alias: PGCalias, 36 | focus: PGCfocus, 37 | types: PGCtypes, 38 | titles: PGCtitles, 39 | dir: string, 40 | readme: string 41 | }; 42 | 43 | declare class configstore$Configstore { 44 | constructor( 45 | packageName: string, 46 | defaults?: any, 47 | options?: Configstore$ConfigstoreOptions 48 | ): this, 49 | 50 | /** 51 | * Get the path to the config file. Can be used to show the user 52 | * where it is, or better, open it for them. 53 | */ 54 | path: string, 55 | 56 | /** 57 | * Get all items as an object or replace the current config with an object. 58 | */ 59 | all: any, 60 | 61 | /** 62 | * Get the item count 63 | */ 64 | size: number, 65 | 66 | /** 67 | * Get an item 68 | * @param key The string key to get 69 | * @return The contents of the config from key $key 70 | */ 71 | get(key: string): any, 72 | 73 | /** 74 | * Set an item 75 | * @param key The string key 76 | * @param val The value to set 77 | */ 78 | set(key: string, val: any): void, 79 | 80 | /** 81 | * Set all key/value pairs declared in $values 82 | * @param values The values object. 83 | */ 84 | set(values: any): void, 85 | 86 | /** 87 | * Determines if a key is present in the config 88 | * @param key The string key to test for 89 | * @return True if the key is present 90 | */ 91 | has(key: string): boolean, 92 | 93 | /** 94 | * Delete an item. 95 | * @param key The key to delete 96 | */ 97 | delete(key: string): void, 98 | 99 | /** 100 | * Clear the config. 101 | * Equivalent to Configstore.all = {}; 102 | */ 103 | clear(): void 104 | } 105 | declare interface Configstore$ConfigstoreOptions { 106 | globalConfigPath?: boolean 107 | } 108 | declare module "configstore" { 109 | declare module.exports: Class; 110 | } 111 | -------------------------------------------------------------------------------- /flow-typed/npm/eslint-config-prettier_vx.x.x.js: -------------------------------------------------------------------------------- 1 | // flow-typed signature: 7e0cb2aef5820bf3a8998d965f33c102 2 | // flow-typed version: <>/eslint-config-prettier_v^2.4.0/flow_v0.55.0 3 | 4 | /** 5 | * This is an autogenerated libdef stub for: 6 | * 7 | * 'eslint-config-prettier' 8 | * 9 | * Fill this stub out by replacing all the `any` types. 10 | * 11 | * Once filled out, we encourage you to share your work with the 12 | * community by sending a pull request to: 13 | * https://github.com/flowtype/flow-typed 14 | */ 15 | 16 | declare module 'eslint-config-prettier' { 17 | declare module.exports: any; 18 | } 19 | 20 | /** 21 | * We include stubs for each file inside this npm package in case you need to 22 | * require those files directly. Feel free to delete any files that aren't 23 | * needed. 24 | */ 25 | declare module 'eslint-config-prettier/bin/cli' { 26 | declare module.exports: any; 27 | } 28 | 29 | declare module 'eslint-config-prettier/bin/validators' { 30 | declare module.exports: any; 31 | } 32 | 33 | declare module 'eslint-config-prettier/flowtype' { 34 | declare module.exports: any; 35 | } 36 | 37 | declare module 'eslint-config-prettier/react' { 38 | declare module.exports: any; 39 | } 40 | 41 | // Filename aliases 42 | declare module 'eslint-config-prettier/bin/cli.js' { 43 | declare module.exports: $Exports<'eslint-config-prettier/bin/cli'>; 44 | } 45 | declare module 'eslint-config-prettier/bin/validators.js' { 46 | declare module.exports: $Exports<'eslint-config-prettier/bin/validators'>; 47 | } 48 | declare module 'eslint-config-prettier/flowtype.js' { 49 | declare module.exports: $Exports<'eslint-config-prettier/flowtype'>; 50 | } 51 | declare module 'eslint-config-prettier/index' { 52 | declare module.exports: $Exports<'eslint-config-prettier'>; 53 | } 54 | declare module 'eslint-config-prettier/index.js' { 55 | declare module.exports: $Exports<'eslint-config-prettier'>; 56 | } 57 | declare module 'eslint-config-prettier/react.js' { 58 | declare module.exports: $Exports<'eslint-config-prettier/react'>; 59 | } 60 | -------------------------------------------------------------------------------- /flow-typed/npm/eslint-plugin-prettier_vx.x.x.js: -------------------------------------------------------------------------------- 1 | // flow-typed signature: d53fb53a5b80e2c09904dcb31f09ad8b 2 | // flow-typed version: <>/eslint-plugin-prettier_v^2.2.0/flow_v0.55.0 3 | 4 | /** 5 | * This is an autogenerated libdef stub for: 6 | * 7 | * 'eslint-plugin-prettier' 8 | * 9 | * Fill this stub out by replacing all the `any` types. 10 | * 11 | * Once filled out, we encourage you to share your work with the 12 | * community by sending a pull request to: 13 | * https://github.com/flowtype/flow-typed 14 | */ 15 | 16 | declare module 'eslint-plugin-prettier' { 17 | declare module.exports: any; 18 | } 19 | 20 | /** 21 | * We include stubs for each file inside this npm package in case you need to 22 | * require those files directly. Feel free to delete any files that aren't 23 | * needed. 24 | */ 25 | declare module 'eslint-plugin-prettier/eslint-plugin-prettier' { 26 | declare module.exports: any; 27 | } 28 | 29 | // Filename aliases 30 | declare module 'eslint-plugin-prettier/eslint-plugin-prettier.js' { 31 | declare module.exports: $Exports<'eslint-plugin-prettier/eslint-plugin-prettier'>; 32 | } 33 | -------------------------------------------------------------------------------- /flow-typed/npm/flow-bin_v0.x.x.js: -------------------------------------------------------------------------------- 1 | // flow-typed signature: 6a5610678d4b01e13bbfbbc62bdaf583 2 | // flow-typed version: 3817bc6980/flow-bin_v0.x.x/flow_>=v0.25.x 3 | 4 | declare module "flow-bin" { 5 | declare module.exports: string; 6 | } 7 | -------------------------------------------------------------------------------- /flow-typed/npm/fs-extra_vx.x.x.js: -------------------------------------------------------------------------------- 1 | // flow-typed signature: 2619300a4a83aef73b34079a3101b1d7 2 | // flow-typed version: <>/fs-extra_v^4.0.1/flow_v0.55.0 3 | 4 | declare class fs$fs { 5 | static copy(src: string, dest: string, options?: CopyOptions): Promise, 6 | static copy( 7 | src: string, 8 | dest: string, 9 | callback: (err: Error | null) => void 10 | ): void, 11 | static copy( 12 | src: string, 13 | dest: string, 14 | options: CopyOptions, 15 | callback: (err: Error | null) => void 16 | ): void, 17 | static copySync(src: string, dest: string, options?: CopyOptions): void, 18 | 19 | static move(src: string, dest: string, options?: MoveOptions): Promise, 20 | static move( 21 | src: string, 22 | dest: string, 23 | callback: (err: Error | null) => void 24 | ): void, 25 | static move( 26 | src: string, 27 | dest: string, 28 | options: MoveOptions, 29 | callback: (err: Error | null) => void 30 | ): void, 31 | static moveSync(src: string, dest: string, options?: MoveOptions): void, 32 | 33 | static createFile(file: string): Promise, 34 | static createFile(file: string, callback: (err: Error | null) => void): void, 35 | static createFileSync(file: string): void, 36 | 37 | static ensureDir(path: string): Promise, 38 | static ensureDir(path: string, callback: (err: Error | null) => void): void, 39 | static ensureDirSync(path: string): void, 40 | 41 | static mkdirs(dir: string): Promise, 42 | static mkdirs(dir: string, callback: (err: Error | null) => void): void, 43 | static mkdirp(dir: string): Promise, 44 | static mkdirp(dir: string, callback: (err: Error | null) => void): void, 45 | static mkdirsSync(dir: string): void, 46 | static mkdirpSync(dir: string): void, 47 | 48 | static outputFile(file: string, data: any): Promise, 49 | static outputFile( 50 | file: string, 51 | data: any, 52 | callback: (err: Error | null) => void 53 | ): void, 54 | static outputFileSync(file: string, data: any): void, 55 | 56 | static readJson(file: string, options?: ReadOptions): Promise, 57 | static readJson( 58 | file: string, 59 | callback: (err: Error | null, jsonObject: any) => void 60 | ): void, 61 | static readJson( 62 | file: string, 63 | options: ReadOptions, 64 | callback: (err: Error | null, jsonObject: any) => void 65 | ): void, 66 | static readJSON(file: string, options?: ReadOptions): Promise, 67 | static readJSON( 68 | file: string, 69 | callback: (err: Error | null, jsonObject: any) => void 70 | ): void, 71 | static readJSON( 72 | file: string, 73 | options: ReadOptions, 74 | callback: (err: Error | null, jsonObject: any) => void 75 | ): void, 76 | 77 | static readJsonSync(file: string, options?: ReadOptions): any, 78 | static readJSONSync(file: string, options?: ReadOptions): any, 79 | 80 | static remove(dir: string): Promise, 81 | static remove(dir: string, callback: (err: Error | null) => void): void, 82 | static removeSync(dir: string): void, 83 | 84 | static outputJSON( 85 | file: string, 86 | data: any, 87 | options?: WriteOptions 88 | ): Promise, 89 | static outputJSON( 90 | file: string, 91 | data: any, 92 | options: WriteOptions, 93 | callback: (err: Error | null) => void 94 | ): void, 95 | static outputJSON( 96 | file: string, 97 | data: any, 98 | callback: (err: Error | null) => void 99 | ): void, 100 | static outputJson( 101 | file: string, 102 | data: any, 103 | options?: WriteOptions 104 | ): Promise, 105 | static outputJson( 106 | file: string, 107 | data: any, 108 | options: WriteOptions, 109 | callback: (err: Error | null) => void 110 | ): void, 111 | static outputJson( 112 | file: string, 113 | data: any, 114 | callback: (err: Error | null) => void 115 | ): void, 116 | static outputJsonSync(file: string, data: any, options?: WriteOptions): void, 117 | static outputJSONSync(file: string, data: any, options?: WriteOptions): void, 118 | 119 | static writeJSON( 120 | file: string, 121 | object: any, 122 | options?: WriteOptions 123 | ): Promise, 124 | static writeJSON( 125 | file: string, 126 | object: any, 127 | callback: (err: Error | null) => void 128 | ): void, 129 | static writeJSON( 130 | file: string, 131 | object: any, 132 | options: WriteOptions, 133 | callback: (err: Error | null) => void 134 | ): void, 135 | static writeJson( 136 | file: string, 137 | object: any, 138 | options?: WriteOptions 139 | ): Promise, 140 | static writeJson( 141 | file: string, 142 | object: any, 143 | callback: (err: Error | null) => void 144 | ): void, 145 | static writeJson( 146 | file: string, 147 | object: any, 148 | options: WriteOptions, 149 | callback: (err: Error | null) => void 150 | ): void, 151 | 152 | static writeJsonSync(file: string, object: any, options?: WriteOptions): void, 153 | static writeJSONSync(file: string, object: any, options?: WriteOptions): void, 154 | 155 | static ensureFile(path: string): Promise, 156 | static ensureFile(path: string, callback: (err: Error | null) => void): void, 157 | static ensureFileSync(path: string): void, 158 | 159 | static ensureLink(src: string, dest: string): Promise, 160 | static ensureLink( 161 | src: string, 162 | dest: string, 163 | callback: (err: Error | null) => void 164 | ): void, 165 | static ensureLinkSync(src: string, dest: string): void, 166 | 167 | static ensureSymlink( 168 | src: string, 169 | dest: string, 170 | type?: SymlinkType 171 | ): Promise, 172 | static ensureSymlink( 173 | src: string, 174 | dest: string, 175 | type: SymlinkType, 176 | callback: (err: Error | null) => void 177 | ): void, 178 | static ensureSymlink( 179 | src: string, 180 | dest: string, 181 | callback: (err: Error | null) => void 182 | ): void, 183 | static ensureSymlinkSync(src: string, dest: string, type?: SymlinkType): void, 184 | 185 | static emptyDir(path: string): Promise, 186 | static emptyDir(path: string, callback: (err: Error | null) => void): void, 187 | static emptyDirSync(path: string): void, 188 | 189 | static existsSync(path: string): boolean, 190 | static pathExists(path: string): Promise, 191 | static pathExists( 192 | path: string, 193 | callback: (err: Error | null, exists: boolean) => void 194 | ): void, 195 | static pathExistsSync(path: string): boolean, 196 | 197 | static access( 198 | path: string | Buffer, 199 | callback: (err: NodeJS.ErrnoException | null) => void 200 | ): void, 201 | static access( 202 | path: string | Buffer, 203 | mode: number, 204 | callback: (err: NodeJS.ErrnoException | null) => void 205 | ): void, 206 | static access(path: string | Buffer, mode?: number): Promise, 207 | 208 | static appendFile( 209 | file: string | Buffer | number, 210 | data: any, 211 | options: { encoding?: string, mode?: number | string, flag?: string }, 212 | callback: (err: NodeJS.ErrnoException | null) => void 213 | ): void, 214 | static appendFile( 215 | file: string | Buffer | number, 216 | data: any, 217 | callback: (err: NodeJS.ErrnoException | null) => void 218 | ): void, 219 | static appendFile( 220 | file: string | Buffer | number, 221 | data: any, 222 | options?: { encoding?: string, mode?: number | string, flag?: string } 223 | ): Promise, 224 | 225 | static chmod( 226 | path: string | Buffer, 227 | mode: string | number, 228 | callback: (err?: NodeJS.ErrnoException | null) => void 229 | ): void, 230 | static chmod(path: string | Buffer, mode: string | number): Promise, 231 | 232 | static chown(path: string | Buffer, uid: number, gid: number): Promise, 233 | static chown( 234 | path: string | Buffer, 235 | uid: number, 236 | gid: number, 237 | callback: (err?: NodeJS.ErrnoException | null) => void 238 | ): void, 239 | 240 | static close( 241 | fd: number, 242 | callback: (err?: NodeJS.ErrnoException | null) => void 243 | ): void, 244 | static close(fd: number): Promise, 245 | static closeSync(fd: number): void, 246 | 247 | static fchmod( 248 | fd: number, 249 | mode: string | number, 250 | callback: (err?: NodeJS.ErrnoException | null) => void 251 | ): void, 252 | static fchmod(fd: number, mode: string | number): Promise, 253 | 254 | static fchown( 255 | fd: number, 256 | uid: number, 257 | gid: number, 258 | callback: (err?: NodeJS.ErrnoException | null) => void 259 | ): void, 260 | static fchown(fd: number, uid: number, gid: number): Promise, 261 | 262 | static fdatasync(fd: number, callback: () => void): void, 263 | static fdatasync(fd: number): Promise, 264 | 265 | static fstat( 266 | fd: number, 267 | callback: (err: NodeJS.ErrnoException | null, stats: Stats) => any 268 | ): void, 269 | static fstat(fd: number): Promise, 270 | 271 | static fsync( 272 | fd: number, 273 | callback: (err?: NodeJS.ErrnoException | null) => void 274 | ): void, 275 | static fsync(fd: number): Promise, 276 | 277 | static ftruncate( 278 | fd: number, 279 | callback: (err?: NodeJS.ErrnoException | null) => void 280 | ): void, 281 | static ftruncate( 282 | fd: number, 283 | len: number, 284 | callback: (err?: NodeJS.ErrnoException | null) => void 285 | ): void, 286 | static ftruncate(fd: number, len?: number): Promise, 287 | 288 | static futimes( 289 | fd: number, 290 | atime: number, 291 | mtime: number, 292 | callback: (err?: NodeJS.ErrnoException | null) => void 293 | ): void, 294 | static futimes( 295 | fd: number, 296 | atime: Date, 297 | mtime: Date, 298 | callback: (err?: NodeJS.ErrnoException | null) => void 299 | ): void, 300 | static futimes(fd: number, atime: number, mtime: number): Promise, 301 | static futimes(fd: number, atime: Date, mtime: Date): Promise, 302 | 303 | static lchown( 304 | path: string | Buffer, 305 | uid: number, 306 | gid: number, 307 | callback: (err?: NodeJS.ErrnoException | null) => void 308 | ): void, 309 | static lchown(path: string | Buffer, uid: number, gid: number): Promise, 310 | 311 | static link( 312 | srcpath: string | Buffer, 313 | dstpath: string | Buffer, 314 | callback: (err?: NodeJS.ErrnoException | null) => void 315 | ): void, 316 | static link( 317 | srcpath: string | Buffer, 318 | dstpath: string | Buffer 319 | ): Promise, 320 | 321 | static lstat( 322 | path: string | Buffer, 323 | callback: (err: NodeJS.ErrnoException | null, stats: Stats) => any 324 | ): void, 325 | static lstat(path: string | Buffer): Stats, 326 | 327 | static lstatSync( 328 | path: string | Buffer, 329 | callback: (err: NodeJS.ErrnoException | null, stats: Stats) => any 330 | ): void, 331 | static lstatSync(path: string | Buffer): Stats, 332 | 333 | static mkdir( 334 | path: string | Buffer, 335 | callback: (err?: NodeJS.ErrnoException | null) => void 336 | ): void, 337 | 338 | static mkdir( 339 | path: string | Buffer, 340 | mode: number | string, 341 | callback: (err?: NodeJS.ErrnoException | null) => void 342 | ): void, 343 | static mkdir(path: string | Buffer): Promise, 344 | 345 | static open( 346 | path: string | Buffer, 347 | flags: string | number, 348 | callback: (err: NodeJS.ErrnoException | null, fd: number) => void 349 | ): void, 350 | static open( 351 | path: string | Buffer, 352 | flags: string | number, 353 | mode: number, 354 | callback: (err: NodeJS.ErrnoException | null, fd: number) => void 355 | ): void, 356 | static open( 357 | path: string | Buffer, 358 | flags: string | number, 359 | mode?: number 360 | ): Promise, 361 | 362 | static openSync( 363 | path: string | Buffer, 364 | flags: string | number, 365 | callback: (err: NodeJS.ErrnoException | null, fd: number) => void 366 | ): void, 367 | static openSync( 368 | path: string | Buffer, 369 | flags: string | number, 370 | mode: number, 371 | callback: (err: NodeJS.ErrnoException | null, fd: number) => void 372 | ): void, 373 | static openSync( 374 | path: string | Buffer, 375 | flags: string | number, 376 | mode?: number 377 | ): number, 378 | 379 | static read( 380 | fd: number, 381 | buffer: Buffer, 382 | offset: number, 383 | length: number, 384 | position: number | null, 385 | callback: ( 386 | err: NodeJS.ErrnoException | null, 387 | bytesRead: number, 388 | buffer: Buffer 389 | ) => void 390 | ): void, 391 | static read( 392 | fd: number, 393 | buffer: Buffer, 394 | offset: number, 395 | length: number, 396 | position: number | null 397 | ): Promise, 398 | 399 | static readFile( 400 | file: string | Buffer | number, 401 | callback: (err: NodeJS.ErrnoException | null, data: Buffer) => void 402 | ): void, 403 | static readFile( 404 | file: string | Buffer | number, 405 | encoding: string, 406 | callback: (err: NodeJS.ErrnoException | null, data: string) => void 407 | ): void, 408 | static readFile( 409 | file: string | Buffer | number, 410 | options: { flag?: string } | { encoding: string, flag?: string }, 411 | callback: (err: NodeJS.ErrnoException, data: Buffer) => void 412 | ): void, 413 | static readFile( 414 | file: string | Buffer | number, 415 | options: { flag?: string } | { encoding: string, flag?: string } 416 | ): Promise, 417 | static readFile( 418 | file: string | Buffer | number, 419 | encoding: string 420 | ): Promise, 421 | static readFile(file: string | Buffer | number): Promise, 422 | 423 | static readFileSync( 424 | file: string | Buffer | number, 425 | callback: (err: NodeJS.ErrnoException | null, data: Buffer) => void 426 | ): void, 427 | static readFileSync( 428 | file: string | Buffer | number, 429 | encoding: string, 430 | callback: (err: NodeJS.ErrnoException | null, data: string) => void 431 | ): void, 432 | static readFileSync( 433 | file: string | Buffer | number, 434 | options: { flag?: string } | { encoding: string, flag?: string }, 435 | callback: (err: NodeJS.ErrnoException, data: Buffer) => void 436 | ): void, 437 | static readFileSync( 438 | file: string | Buffer | number, 439 | options: { flag?: string } | { encoding: string, flag?: string } 440 | ): string, 441 | static readFileSync(file: string | Buffer | number, encoding: string): string, 442 | static readFileSync(file: string | Buffer | number): Buffer, 443 | 444 | static readdir( 445 | path: string | Buffer, 446 | callback: (err: NodeJS.ErrnoException | null, files: string[]) => void 447 | ): void, 448 | static readdir(path: string | Buffer): Promise, 449 | static readdirSync(spath: string | Buffer): Array, 450 | 451 | static readlink( 452 | path: string | Buffer, 453 | callback: (err: NodeJS.ErrnoException | null, linkString: string) => any 454 | ): void, 455 | static readlink(path: string | Buffer): Promise, 456 | 457 | static realpath( 458 | path: string | Buffer, 459 | callback: (err: NodeJS.ErrnoException | null, resolvedPath: string) => any 460 | ): void, 461 | static realpath( 462 | path: string | Buffer, 463 | cache: { [path: string]: string }, 464 | callback: (err: NodeJS.ErrnoException | null, resolvedPath: string) => any 465 | ): void, 466 | static realpath( 467 | path: string | Buffer, 468 | cache?: { [path: string]: string } 469 | ): Promise, 470 | 471 | static rename( 472 | oldPath: string, 473 | newPath: string, 474 | callback: (err?: NodeJS.ErrnoException | null) => void 475 | ): void, 476 | static rename(oldPath: string, newPath: string): Promise, 477 | 478 | static rmdir( 479 | path: string | Buffer, 480 | callback: (err?: NodeJS.ErrnoException | null) => void 481 | ): void, 482 | static rmdir(path: string | Buffer): Promise, 483 | 484 | static stat( 485 | path: string | Buffer, 486 | callback: (err: NodeJS.ErrnoException | null, stats: Stats) => any 487 | ): void, 488 | static stat(path: string | Buffer): Promise, 489 | static statSync( 490 | path: string | Buffer 491 | ): { isDirectory: () => boolean, isFile: () => boolean }, 492 | 493 | static symlink( 494 | srcpath: string | Buffer, 495 | dstpath: string | Buffer, 496 | type: string, 497 | callback: (err?: NodeJS.ErrnoException | null) => void 498 | ): void, 499 | static symlink( 500 | srcpath: string | Buffer, 501 | dstpath: string | Buffer, 502 | type?: string 503 | ): Promise, 504 | 505 | static truncate( 506 | path: string | Buffer, 507 | callback: (err?: NodeJS.ErrnoException | null) => void 508 | ): void, 509 | static truncate( 510 | path: string | Buffer, 511 | len: number, 512 | callback: (err?: NodeJS.ErrnoException | null) => void 513 | ): void, 514 | static truncate(path: string | Buffer, len?: number): Promise, 515 | 516 | static unlink( 517 | path: string | Buffer, 518 | callback: (err?: NodeJS.ErrnoException | null) => void 519 | ): void, 520 | static unlink(path: string | Buffer): Promise, 521 | 522 | static utimes( 523 | path: string | Buffer, 524 | atime: number, 525 | mtime: number, 526 | callback: (err?: NodeJS.ErrnoException) => void 527 | ): void, 528 | static utimes( 529 | path: string | Buffer, 530 | atime: Date, 531 | mtime: Date, 532 | callback: (err?: NodeJS.ErrnoException | null) => void 533 | ): void, 534 | static utimes( 535 | path: string | Buffer, 536 | atime: number, 537 | mtime: number 538 | ): Promise, 539 | static utimes(path: string | Buffer, atime: Date, mtime: Date): Promise, 540 | 541 | static write( 542 | fd: number, 543 | buffer: Buffer, 544 | offset: number, 545 | length: number, 546 | position: number | null, 547 | callback: ( 548 | err: NodeJS.ErrnoException, 549 | written: number, 550 | buffer: Buffer 551 | ) => void 552 | ): void, 553 | static write( 554 | fd: number, 555 | buffer: Buffer, 556 | offset: number, 557 | length: number, 558 | callback: ( 559 | err: NodeJS.ErrnoException | null, 560 | written: number, 561 | buffer: Buffer 562 | ) => void 563 | ): void, 564 | static write( 565 | fd: number, 566 | data: any, 567 | callback: ( 568 | err: NodeJS.ErrnoException | null, 569 | written: number, 570 | str: string 571 | ) => void 572 | ): void, 573 | static write( 574 | fd: number, 575 | data: any, 576 | offset: number, 577 | callback: ( 578 | err: NodeJS.ErrnoException | null, 579 | written: number, 580 | str: string 581 | ) => void 582 | ): void, 583 | static write( 584 | fd: number, 585 | data: any, 586 | offset: number, 587 | encoding: string, 588 | callback: ( 589 | err: NodeJS.ErrnoException | null, 590 | written: number, 591 | str: string 592 | ) => void 593 | ): void, 594 | static write( 595 | fd: number, 596 | buffer: Buffer, 597 | offset: number, 598 | length: number, 599 | position?: number | null 600 | ): Promise, 601 | static write( 602 | fd: number, 603 | data: any, 604 | offset: number, 605 | encoding?: string 606 | ): Promise, 607 | 608 | static writeFile( 609 | file: string | Buffer | number, 610 | data: any, 611 | callback: (err: NodeJS.ErrnoException | null) => void 612 | ): void, 613 | static writeFile( 614 | file: string | Buffer | number, 615 | data: any, 616 | options: { encoding?: string, mode?: number, flag?: string }, 617 | callback: (err: NodeJS.ErrnoException | null) => void 618 | ): void, 619 | 620 | static mkdtemp(prefix: string): Promise, 621 | static mkdtemp( 622 | prefix: string, 623 | callback: (err: NodeJS.ErrnoException | null, folder: string) => void 624 | ): void 625 | } 626 | 627 | declare module "fs-extra" { 628 | declare module.exports: Class; 629 | } 630 | 631 | declare interface PathEntry { 632 | path: string, 633 | stats: Stats 634 | } 635 | 636 | declare interface PathEntryStream { 637 | read(): PathEntry | null 638 | } 639 | 640 | declare type CopyFilter = ((src: string, dest: string) => boolean) | RegExp; 641 | 642 | declare type SymlinkType = "dir" | "file"; 643 | 644 | declare interface CopyOptions { 645 | dereference?: boolean, 646 | overwrite?: boolean, 647 | preserveTimestamps?: boolean, 648 | errorOnExist?: boolean, 649 | filter?: CopyFilter, 650 | recursive?: boolean 651 | } 652 | 653 | declare interface MoveOptions { 654 | overwrite?: boolean, 655 | limit?: number 656 | } 657 | 658 | declare interface ReadOptions { 659 | throws?: boolean, 660 | fs?: object, 661 | reviver?: any, 662 | encoding?: string, 663 | flag?: string 664 | } 665 | 666 | declare interface WriteOptions { 667 | fs?: object, 668 | replacer?: any, 669 | spaces?: number, 670 | encoding?: string, 671 | flag?: string, 672 | mode?: number 673 | } 674 | 675 | declare interface ReadResult { 676 | bytesRead: number, 677 | buffer: Buffer 678 | } 679 | 680 | declare interface WriteResult { 681 | bytesWritten: number, 682 | buffer: Buffer 683 | } 684 | -------------------------------------------------------------------------------- /flow-typed/npm/global_vx.x.x.js: -------------------------------------------------------------------------------- 1 | // flow-typed signature: 3f38ee0ef5a98d0f7c70145bfb069a01 2 | // flow-typed version: <>/global_v^4.3.2/flow_v0.55.0 3 | 4 | /** 5 | * This is an autogenerated libdef stub for: 6 | * 7 | * 'global' 8 | * 9 | * Fill this stub out by replacing all the `any` types. 10 | * 11 | * Once filled out, we encourage you to share your work with the 12 | * community by sending a pull request to: 13 | * https://github.com/flowtype/flow-typed 14 | */ 15 | 16 | declare module 'global' { 17 | declare module.exports: any; 18 | } 19 | 20 | /** 21 | * We include stubs for each file inside this npm package in case you need to 22 | * require those files directly. Feel free to delete any files that aren't 23 | * needed. 24 | */ 25 | declare module 'global/console' { 26 | declare module.exports: any; 27 | } 28 | 29 | declare module 'global/document' { 30 | declare module.exports: any; 31 | } 32 | 33 | declare module 'global/process' { 34 | declare module.exports: any; 35 | } 36 | 37 | declare module 'global/window' { 38 | declare module.exports: any; 39 | } 40 | 41 | // Filename aliases 42 | declare module 'global/console.js' { 43 | declare module.exports: $Exports<'global/console'>; 44 | } 45 | declare module 'global/document.js' { 46 | declare module.exports: $Exports<'global/document'>; 47 | } 48 | declare module 'global/process.js' { 49 | declare module.exports: $Exports<'global/process'>; 50 | } 51 | declare module 'global/window.js' { 52 | declare module.exports: $Exports<'global/window'>; 53 | } 54 | -------------------------------------------------------------------------------- /flow-typed/npm/gulp-babel_vx.x.x.js: -------------------------------------------------------------------------------- 1 | // flow-typed signature: a65189f752755099b8bd150c679ce64b 2 | // flow-typed version: <>/gulp-babel_v6.1.2/flow_v0.55.0 3 | 4 | /** 5 | * This is an autogenerated libdef stub for: 6 | * 7 | * 'gulp-babel' 8 | * 9 | * Fill this stub out by replacing all the `any` types. 10 | * 11 | * Once filled out, we encourage you to share your work with the 12 | * community by sending a pull request to: 13 | * https://github.com/flowtype/flow-typed 14 | */ 15 | 16 | declare module 'gulp-babel' { 17 | declare module.exports: any; 18 | } 19 | 20 | /** 21 | * We include stubs for each file inside this npm package in case you need to 22 | * require those files directly. Feel free to delete any files that aren't 23 | * needed. 24 | */ 25 | 26 | 27 | // Filename aliases 28 | declare module 'gulp-babel/index' { 29 | declare module.exports: $Exports<'gulp-babel'>; 30 | } 31 | declare module 'gulp-babel/index.js' { 32 | declare module.exports: $Exports<'gulp-babel'>; 33 | } 34 | -------------------------------------------------------------------------------- /flow-typed/npm/gulp-flowtype_vx.x.x.js: -------------------------------------------------------------------------------- 1 | // flow-typed signature: 084802012befacf35c375d0d5788f533 2 | // flow-typed version: <>/gulp-flowtype_v1.0.0/flow_v0.55.0 3 | 4 | /** 5 | * This is an autogenerated libdef stub for: 6 | * 7 | * 'gulp-flowtype' 8 | * 9 | * Fill this stub out by replacing all the `any` types. 10 | * 11 | * Once filled out, we encourage you to share your work with the 12 | * community by sending a pull request to: 13 | * https://github.com/flowtype/flow-typed 14 | */ 15 | 16 | declare module 'gulp-flowtype' { 17 | declare module.exports: any; 18 | } 19 | 20 | /** 21 | * We include stubs for each file inside this npm package in case you need to 22 | * require those files directly. Feel free to delete any files that aren't 23 | * needed. 24 | */ 25 | declare module 'gulp-flowtype/declarations/child_process.d' { 26 | declare module.exports: any; 27 | } 28 | 29 | declare module 'gulp-flowtype/declarations/flow-bin.d' { 30 | declare module.exports: any; 31 | } 32 | 33 | declare module 'gulp-flowtype/declarations/flow-to-jshint.d' { 34 | declare module.exports: any; 35 | } 36 | 37 | declare module 'gulp-flowtype/declarations/fs.d' { 38 | declare module.exports: any; 39 | } 40 | 41 | declare module 'gulp-flowtype/declarations/gulp-util.d' { 42 | declare module.exports: any; 43 | } 44 | 45 | declare module 'gulp-flowtype/declarations/index.d' { 46 | declare module.exports: any; 47 | } 48 | 49 | declare module 'gulp-flowtype/declarations/jshint-stylish.d' { 50 | declare module.exports: any; 51 | } 52 | 53 | declare module 'gulp-flowtype/declarations/log-symbols.d' { 54 | declare module.exports: any; 55 | } 56 | 57 | declare module 'gulp-flowtype/declarations/path.d' { 58 | declare module.exports: any; 59 | } 60 | 61 | declare module 'gulp-flowtype/declarations/pollyfill.d' { 62 | declare module.exports: any; 63 | } 64 | 65 | declare module 'gulp-flowtype/declarations/q.d' { 66 | declare module.exports: any; 67 | } 68 | 69 | declare module 'gulp-flowtype/declarations/through2.d' { 70 | declare module.exports: any; 71 | } 72 | 73 | declare module 'gulp-flowtype/lib/index' { 74 | declare module.exports: any; 75 | } 76 | 77 | declare module 'gulp-flowtype/test/fixtures/broken-interfaces/lib' { 78 | declare module.exports: any; 79 | } 80 | 81 | declare module 'gulp-flowtype/test/fixtures/declaration' { 82 | declare module.exports: any; 83 | } 84 | 85 | declare module 'gulp-flowtype/test/fixtures/hello' { 86 | declare module.exports: any; 87 | } 88 | 89 | declare module 'gulp-flowtype/test/fixtures/interfaces/lib' { 90 | declare module.exports: any; 91 | } 92 | 93 | declare module 'gulp-flowtype/test/main' { 94 | declare module.exports: any; 95 | } 96 | 97 | // Filename aliases 98 | declare module 'gulp-flowtype/declarations/child_process.d.js' { 99 | declare module.exports: $Exports<'gulp-flowtype/declarations/child_process.d'>; 100 | } 101 | declare module 'gulp-flowtype/declarations/flow-bin.d.js' { 102 | declare module.exports: $Exports<'gulp-flowtype/declarations/flow-bin.d'>; 103 | } 104 | declare module 'gulp-flowtype/declarations/flow-to-jshint.d.js' { 105 | declare module.exports: $Exports<'gulp-flowtype/declarations/flow-to-jshint.d'>; 106 | } 107 | declare module 'gulp-flowtype/declarations/fs.d.js' { 108 | declare module.exports: $Exports<'gulp-flowtype/declarations/fs.d'>; 109 | } 110 | declare module 'gulp-flowtype/declarations/gulp-util.d.js' { 111 | declare module.exports: $Exports<'gulp-flowtype/declarations/gulp-util.d'>; 112 | } 113 | declare module 'gulp-flowtype/declarations/index.d.js' { 114 | declare module.exports: $Exports<'gulp-flowtype/declarations/index.d'>; 115 | } 116 | declare module 'gulp-flowtype/declarations/jshint-stylish.d.js' { 117 | declare module.exports: $Exports<'gulp-flowtype/declarations/jshint-stylish.d'>; 118 | } 119 | declare module 'gulp-flowtype/declarations/log-symbols.d.js' { 120 | declare module.exports: $Exports<'gulp-flowtype/declarations/log-symbols.d'>; 121 | } 122 | declare module 'gulp-flowtype/declarations/path.d.js' { 123 | declare module.exports: $Exports<'gulp-flowtype/declarations/path.d'>; 124 | } 125 | declare module 'gulp-flowtype/declarations/pollyfill.d.js' { 126 | declare module.exports: $Exports<'gulp-flowtype/declarations/pollyfill.d'>; 127 | } 128 | declare module 'gulp-flowtype/declarations/q.d.js' { 129 | declare module.exports: $Exports<'gulp-flowtype/declarations/q.d'>; 130 | } 131 | declare module 'gulp-flowtype/declarations/through2.d.js' { 132 | declare module.exports: $Exports<'gulp-flowtype/declarations/through2.d'>; 133 | } 134 | declare module 'gulp-flowtype/index' { 135 | declare module.exports: $Exports<'gulp-flowtype'>; 136 | } 137 | declare module 'gulp-flowtype/index.js' { 138 | declare module.exports: $Exports<'gulp-flowtype'>; 139 | } 140 | declare module 'gulp-flowtype/lib/index.js' { 141 | declare module.exports: $Exports<'gulp-flowtype/lib/index'>; 142 | } 143 | declare module 'gulp-flowtype/test/fixtures/broken-interfaces/lib.js' { 144 | declare module.exports: $Exports<'gulp-flowtype/test/fixtures/broken-interfaces/lib'>; 145 | } 146 | declare module 'gulp-flowtype/test/fixtures/declaration.js' { 147 | declare module.exports: $Exports<'gulp-flowtype/test/fixtures/declaration'>; 148 | } 149 | declare module 'gulp-flowtype/test/fixtures/hello.js' { 150 | declare module.exports: $Exports<'gulp-flowtype/test/fixtures/hello'>; 151 | } 152 | declare module 'gulp-flowtype/test/fixtures/interfaces/lib.js' { 153 | declare module.exports: $Exports<'gulp-flowtype/test/fixtures/interfaces/lib'>; 154 | } 155 | declare module 'gulp-flowtype/test/main.js' { 156 | declare module.exports: $Exports<'gulp-flowtype/test/main'>; 157 | } 158 | -------------------------------------------------------------------------------- /flow-typed/npm/gulp-sourcemaps_vx.x.x.js: -------------------------------------------------------------------------------- 1 | // flow-typed signature: c2f36c178a5d92ba7224bed6ba93aea4 2 | // flow-typed version: <>/gulp-sourcemaps_v1.9.1/flow_v0.55.0 3 | 4 | /** 5 | * This is an autogenerated libdef stub for: 6 | * 7 | * 'gulp-sourcemaps' 8 | * 9 | * Fill this stub out by replacing all the `any` types. 10 | * 11 | * Once filled out, we encourage you to share your work with the 12 | * community by sending a pull request to: 13 | * https://github.com/flowtype/flow-typed 14 | */ 15 | 16 | declare module 'gulp-sourcemaps' { 17 | declare module.exports: any; 18 | } 19 | 20 | /** 21 | * We include stubs for each file inside this npm package in case you need to 22 | * require those files directly. Feel free to delete any files that aren't 23 | * needed. 24 | */ 25 | declare module 'gulp-sourcemaps/src/init' { 26 | declare module.exports: any; 27 | } 28 | 29 | declare module 'gulp-sourcemaps/src/utils' { 30 | declare module.exports: any; 31 | } 32 | 33 | declare module 'gulp-sourcemaps/src/write' { 34 | declare module.exports: any; 35 | } 36 | 37 | // Filename aliases 38 | declare module 'gulp-sourcemaps/index' { 39 | declare module.exports: $Exports<'gulp-sourcemaps'>; 40 | } 41 | declare module 'gulp-sourcemaps/index.js' { 42 | declare module.exports: $Exports<'gulp-sourcemaps'>; 43 | } 44 | declare module 'gulp-sourcemaps/src/init.js' { 45 | declare module.exports: $Exports<'gulp-sourcemaps/src/init'>; 46 | } 47 | declare module 'gulp-sourcemaps/src/utils.js' { 48 | declare module.exports: $Exports<'gulp-sourcemaps/src/utils'>; 49 | } 50 | declare module 'gulp-sourcemaps/src/write.js' { 51 | declare module.exports: $Exports<'gulp-sourcemaps/src/write'>; 52 | } 53 | -------------------------------------------------------------------------------- /flow-typed/npm/gulp_vx.x.x.js: -------------------------------------------------------------------------------- 1 | // flow-typed signature: 565a8c2603844592bd346c9dce3159c7 2 | // flow-typed version: <>/gulp_v^3.9.1/flow_v0.55.0 3 | 4 | /** 5 | * This is an autogenerated libdef stub for: 6 | * 7 | * 'gulp' 8 | * 9 | * Fill this stub out by replacing all the `any` types. 10 | * 11 | * Once filled out, we encourage you to share your work with the 12 | * community by sending a pull request to: 13 | * https://github.com/flowtype/flow-typed 14 | */ 15 | 16 | declare module 'gulp' { 17 | declare module.exports: any; 18 | } 19 | 20 | /** 21 | * We include stubs for each file inside this npm package in case you need to 22 | * require those files directly. Feel free to delete any files that aren't 23 | * needed. 24 | */ 25 | declare module 'gulp/bin/gulp' { 26 | declare module.exports: any; 27 | } 28 | 29 | declare module 'gulp/lib/completion' { 30 | declare module.exports: any; 31 | } 32 | 33 | declare module 'gulp/lib/taskTree' { 34 | declare module.exports: any; 35 | } 36 | 37 | // Filename aliases 38 | declare module 'gulp/bin/gulp.js' { 39 | declare module.exports: $Exports<'gulp/bin/gulp'>; 40 | } 41 | declare module 'gulp/index' { 42 | declare module.exports: $Exports<'gulp'>; 43 | } 44 | declare module 'gulp/index.js' { 45 | declare module.exports: $Exports<'gulp'>; 46 | } 47 | declare module 'gulp/lib/completion.js' { 48 | declare module.exports: $Exports<'gulp/lib/completion'>; 49 | } 50 | declare module 'gulp/lib/taskTree.js' { 51 | declare module.exports: $Exports<'gulp/lib/taskTree'>; 52 | } 53 | -------------------------------------------------------------------------------- /flow-typed/npm/moment_v2.3.x.js: -------------------------------------------------------------------------------- 1 | // flow-typed signature: 3409270fb7c9e22d114cc0f4ac1dbf36 2 | // flow-typed version: 148333be22/moment_v2.3.x/flow_>=v0.34.x 3 | 4 | type moment$MomentOptions = { 5 | y?: number|string, 6 | year?: number|string, 7 | years?: number|string, 8 | M?: number|string, 9 | month?: number|string, 10 | months?: number|string, 11 | d?: number|string, 12 | day?: number|string, 13 | days?: number|string, 14 | date?: number|string, 15 | h?: number|string, 16 | hour?: number|string, 17 | hours?: number|string, 18 | m?: number|string, 19 | minute?: number|string, 20 | minutes?: number|string, 21 | s?: number|string, 22 | second?: number|string, 23 | seconds?: number|string, 24 | ms?: number|string, 25 | millisecond?: number|string, 26 | milliseconds?: number|string, 27 | }; 28 | 29 | type moment$MomentObject = { 30 | years: number, 31 | months: number, 32 | date: number, 33 | hours: number, 34 | minutes: number, 35 | seconds: number, 36 | milliseconds: number, 37 | }; 38 | 39 | type moment$MomentCreationData = { 40 | input: string, 41 | format: string, 42 | locale: Object, 43 | isUTC: bool, 44 | strict: bool, 45 | }; 46 | 47 | type moment$CalendarFormat = string | (moment: moment$Moment) => string; 48 | 49 | type moment$CalendarFormats = { 50 | sameDay?: moment$CalendarFormat, 51 | nextDay?: moment$CalendarFormat, 52 | nextWeek?: moment$CalendarFormat, 53 | lastDay?: moment$CalendarFormat, 54 | lastWeek?: moment$CalendarFormat, 55 | sameElse?: moment$CalendarFormat, 56 | }; 57 | 58 | declare class moment$LocaleData { 59 | months(moment: moment$Moment): string; 60 | monthsShort(moment: moment$Moment): string; 61 | monthsParse(month: string): number; 62 | weekdays(moment: moment$Moment): string; 63 | weekdaysShort(moment: moment$Moment): string; 64 | weekdaysMin(moment: moment$Moment): string; 65 | weekdaysParse(weekDay: string): number; 66 | longDateFormat(dateFormat: string): string; 67 | isPM(date: string): bool; 68 | meridiem(hours: number, minutes: number, isLower: bool): string; 69 | calendar(key: 'sameDay'|'nextDay'|'lastDay'|'nextWeek'|'prevWeek'|'sameElse', moment: moment$Moment): string; 70 | relativeTime(number: number, withoutSuffix: bool, key: 's'|'m'|'mm'|'h'|'hh'|'d'|'dd'|'M'|'MM'|'y'|'yy', isFuture: bool): string; 71 | pastFuture(diff: any, relTime: string): string; 72 | ordinal(number: number): string; 73 | preparse(str: string): any; 74 | postformat(str: string): any; 75 | week(moment: moment$Moment): string; 76 | invalidDate(): string; 77 | firstDayOfWeek(): number; 78 | firstDayOfYear(): number; 79 | } 80 | declare class moment$MomentDuration { 81 | humanize(suffix?: bool): string; 82 | milliseconds(): number; 83 | asMilliseconds(): number; 84 | seconds(): number; 85 | asSeconds(): number; 86 | minutes(): number; 87 | asMinutes(): number; 88 | hours(): number; 89 | asHours(): number; 90 | days(): number; 91 | asDays(): number; 92 | months(): number; 93 | asMonths(): number; 94 | years(): number; 95 | asYears(): number; 96 | add(value: number|moment$MomentDuration|Object, unit?: string): this; 97 | subtract(value: number|moment$MomentDuration|Object, unit?: string): this; 98 | as(unit: string): number; 99 | get(unit: string): number; 100 | toJSON(): string; 101 | toISOString(): string; 102 | isValid(): bool; 103 | } 104 | declare class moment$Moment { 105 | static ISO_8601: string; 106 | static (string?: string, format?: string|Array, locale?: string, strict?: bool): moment$Moment; 107 | static (initDate: ?Object|number|Date|Array|moment$Moment|string): moment$Moment; 108 | static unix(seconds: number): moment$Moment; 109 | static utc(): moment$Moment; 110 | static utc(number: number|Array): moment$Moment; 111 | static utc(str: string, str2?: string|Array, str3?: string): moment$Moment; 112 | static utc(moment: moment$Moment): moment$Moment; 113 | static utc(date: Date): moment$Moment; 114 | static parseZone(): moment$Moment; 115 | static parseZone(rawDate: string): moment$Moment; 116 | static parseZone(rawDate: string, format: string | Array): moment$Moment; 117 | static parseZone(rawDate: string, format: string, strict: boolean): moment$Moment; 118 | static parseZone(rawDate: string, format: string, locale: string, strict: boolean): moment$Moment; 119 | isValid(): bool; 120 | invalidAt(): 0|1|2|3|4|5|6; 121 | creationData(): moment$MomentCreationData; 122 | millisecond(number: number): this; 123 | milliseconds(number: number): this; 124 | millisecond(): number; 125 | milliseconds(): number; 126 | second(number: number): this; 127 | seconds(number: number): this; 128 | second(): number; 129 | seconds(): number; 130 | minute(number: number): this; 131 | minutes(number: number): this; 132 | minute(): number; 133 | minutes(): number; 134 | hour(number: number): this; 135 | hours(number: number): this; 136 | hour(): number; 137 | hours(): number; 138 | date(number: number): this; 139 | dates(number: number): this; 140 | date(): number; 141 | dates(): number; 142 | day(day: number|string): this; 143 | days(day: number|string): this; 144 | day(): number; 145 | days(): number; 146 | weekday(number: number): this; 147 | weekday(): number; 148 | isoWeekday(number: number): this; 149 | isoWeekday(): number; 150 | dayOfYear(number: number): this; 151 | dayOfYear(): number; 152 | week(number: number): this; 153 | weeks(number: number): this; 154 | week(): number; 155 | weeks(): number; 156 | isoWeek(number: number): this; 157 | isoWeeks(number: number): this; 158 | isoWeek(): number; 159 | isoWeeks(): number; 160 | month(number: number): this; 161 | months(number: number): this; 162 | month(): number; 163 | months(): number; 164 | quarter(number: number): this; 165 | quarter(): number; 166 | year(number: number): this; 167 | years(number: number): this; 168 | year(): number; 169 | years(): number; 170 | weekYear(number: number): this; 171 | weekYear(): number; 172 | isoWeekYear(number: number): this; 173 | isoWeekYear(): number; 174 | weeksInYear(): number; 175 | isoWeeksInYear(): number; 176 | get(string: string): number; 177 | set(unit: string, value: number): this; 178 | set(options: { [unit: string]: number }): this; 179 | static max(...dates: Array): moment$Moment; 180 | static max(dates: Array): moment$Moment; 181 | static min(...dates: Array): moment$Moment; 182 | static min(dates: Array): moment$Moment; 183 | add(value: number|moment$MomentDuration|moment$Moment|Object, unit?: string): this; 184 | subtract(value: number|moment$MomentDuration|moment$Moment|string|Object, unit?: string): this; 185 | startOf(unit: string): this; 186 | endOf(unit: string): this; 187 | local(): this; 188 | utc(): this; 189 | utcOffset(offset: number|string): this; 190 | utcOffset(): number; 191 | format(format?: string): string; 192 | fromNow(removeSuffix?: bool): string; 193 | from(value: moment$Moment|string|number|Date|Array, removePrefix?: bool): string; 194 | toNow(removePrefix?: bool): string; 195 | to(value: moment$Moment|string|number|Date|Array, removePrefix?: bool): string; 196 | calendar(refTime?: any, formats?: moment$CalendarFormats): string; 197 | diff(date: moment$Moment|string|number|Date|Array, format?: string, floating?: bool): number; 198 | valueOf(): number; 199 | unix(): number; 200 | daysInMonth(): number; 201 | toDate(): Date; 202 | toArray(): Array; 203 | toJSON(): string; 204 | toISOString(): string; 205 | toObject(): moment$MomentObject; 206 | isBefore(date?: moment$Moment|string|number|Date|Array, units?: ?string): bool; 207 | isSame(date?: moment$Moment|string|number|Date|Array, units?: ?string): bool; 208 | isAfter(date?: moment$Moment|string|number|Date|Array, units?: ?string): bool; 209 | isSameOrBefore(date?: moment$Moment|string|number|Date|Array, units?: ?string): bool; 210 | isSameOrAfter(date?: moment$Moment|string|number|Date|Array, units?: ?string): bool; 211 | isBetween(date: moment$Moment|string|number|Date|Array): bool; 212 | isDST(): bool; 213 | isDSTShifted(): bool; 214 | isLeapYear(): bool; 215 | clone(): moment$Moment; 216 | static isMoment(obj: any): bool; 217 | static isDate(obj: any): bool; 218 | static locale(locale: string, localeData?: Object): string; 219 | static updateLocale(locale: string, localeData?: ?Object): void; 220 | static locale(locales: Array): string; 221 | locale(locale: string, customization?: Object|null): moment$Moment; 222 | locale(): string; 223 | static months(): Array; 224 | static monthsShort(): Array; 225 | static weekdays(): Array; 226 | static weekdaysShort(): Array; 227 | static weekdaysMin(): Array; 228 | static months(): string; 229 | static monthsShort(): string; 230 | static weekdays(): string; 231 | static weekdaysShort(): string; 232 | static weekdaysMin(): string; 233 | static localeData(key?: string): moment$LocaleData; 234 | static duration(value: number|Object|string, unit?: string): moment$MomentDuration; 235 | static isDuration(obj: any): bool; 236 | static normalizeUnits(unit: string): string; 237 | static invalid(object: any): moment$Moment; 238 | } 239 | 240 | declare module 'moment' { 241 | declare module.exports: Class; 242 | } 243 | -------------------------------------------------------------------------------- /flow-typed/npm/path_vx.x.x.js: -------------------------------------------------------------------------------- 1 | declare class path$Path { 2 | static basename: (path: string, ext?: string) => string, 3 | delimiter: string, 4 | dirname: (path: string) => string, 5 | static extname: (path: string) => string, 6 | format: (pathObject: { 7 | base?: string, 8 | dir?: string, 9 | ext?: string, 10 | name?: string, 11 | root?: string 12 | }) => string, 13 | isAbsolute: (path: string) => boolean, 14 | static join: (...parts: Array) => string, 15 | normalize: (path: string) => string, 16 | parse: ( 17 | pathString: string 18 | ) => { base: string, dir: string, ext: string, name: string, root: string }, 19 | posix: any, 20 | relative: (from: string, to: string) => string, 21 | static resolve: (...parts: Array) => string, 22 | sep: string, 23 | win32: any 24 | } 25 | 26 | declare module "path" { 27 | declare module.exports: Class; 28 | } 29 | -------------------------------------------------------------------------------- /flow-typed/npm/prettier_vx.x.x.js: -------------------------------------------------------------------------------- 1 | // flow-typed signature: 551c1119fcb78445c36851a896d1fd53 2 | // flow-typed version: <>/prettier_v^1.6.1/flow_v0.55.0 3 | 4 | /** 5 | * This is an autogenerated libdef stub for: 6 | * 7 | * 'prettier' 8 | * 9 | * Fill this stub out by replacing all the `any` types. 10 | * 11 | * Once filled out, we encourage you to share your work with the 12 | * community by sending a pull request to: 13 | * https://github.com/flowtype/flow-typed 14 | */ 15 | 16 | declare module 'prettier' { 17 | declare module.exports: any; 18 | } 19 | 20 | /** 21 | * We include stubs for each file inside this npm package in case you need to 22 | * require those files directly. Feel free to delete any files that aren't 23 | * needed. 24 | */ 25 | declare module 'prettier/bin/prettier' { 26 | declare module.exports: any; 27 | } 28 | 29 | declare module 'prettier/parser-babylon' { 30 | declare module.exports: any; 31 | } 32 | 33 | declare module 'prettier/parser-flow' { 34 | declare module.exports: any; 35 | } 36 | 37 | declare module 'prettier/parser-graphql' { 38 | declare module.exports: any; 39 | } 40 | 41 | declare module 'prettier/parser-parse5' { 42 | declare module.exports: any; 43 | } 44 | 45 | declare module 'prettier/parser-postcss' { 46 | declare module.exports: any; 47 | } 48 | 49 | declare module 'prettier/parser-typescript' { 50 | declare module.exports: any; 51 | } 52 | 53 | // Filename aliases 54 | declare module 'prettier/bin/prettier.js' { 55 | declare module.exports: $Exports<'prettier/bin/prettier'>; 56 | } 57 | declare module 'prettier/index' { 58 | declare module.exports: $Exports<'prettier'>; 59 | } 60 | declare module 'prettier/index.js' { 61 | declare module.exports: $Exports<'prettier'>; 62 | } 63 | declare module 'prettier/parser-babylon.js' { 64 | declare module.exports: $Exports<'prettier/parser-babylon'>; 65 | } 66 | declare module 'prettier/parser-flow.js' { 67 | declare module.exports: $Exports<'prettier/parser-flow'>; 68 | } 69 | declare module 'prettier/parser-graphql.js' { 70 | declare module.exports: $Exports<'prettier/parser-graphql'>; 71 | } 72 | declare module 'prettier/parser-parse5.js' { 73 | declare module.exports: $Exports<'prettier/parser-parse5'>; 74 | } 75 | declare module 'prettier/parser-postcss.js' { 76 | declare module.exports: $Exports<'prettier/parser-postcss'>; 77 | } 78 | declare module 'prettier/parser-typescript.js' { 79 | declare module.exports: $Exports<'prettier/parser-typescript'>; 80 | } 81 | -------------------------------------------------------------------------------- /flow-typed/npm/terminal-menu_vx.x.x.js: -------------------------------------------------------------------------------- 1 | // flow-typed signature: 43f89260fc00756dd072ee208234f840 2 | // flow-typed version: <>/terminal-menu_v^2.1.1/flow_v0.55.0 3 | 4 | /** 5 | * Flowtype definitions for index 6 | * Generated by Flowgen from a Typescript Definition 7 | * Flowgen v1.2.0 8 | * Author: [Joar Wilk](http://twitter.com/joarwilk) 9 | * Repo: http://github.com/joarwilk/flowgen 10 | */ 11 | 12 | /** 13 | * A Thickness structure specifying the amount of padding to apply. 14 | */ 15 | declare interface Thickness { 16 | /** 17 | * Represents width of the left side of the bounding rectangle. 18 | */ 19 | left: number, 20 | 21 | /** 22 | * Represents width of the right side of the bounding rectangle. 23 | */ 24 | right: number, 25 | 26 | /** 27 | * Represents width of the upper side of the bounding rectangle. 28 | */ 29 | top: number, 30 | 31 | /** 32 | * Represents width of the lower side of the bounding rectangle. 33 | */ 34 | bottom: number 35 | } 36 | 37 | /** 38 | * Options to configure the menu. 39 | */ 40 | declare interface TerminalMenuOptions { 41 | /** 42 | * Menu width in columns. 43 | * Default = 50. 44 | */ 45 | width?: number, 46 | 47 | /** 48 | * Horizontal offset for top-left corner. 49 | * Default = 1 50 | */ 51 | x?: number, 52 | 53 | /** 54 | * Vertical offset for top-left corner. 55 | * Default = 1 56 | */ 57 | y?: number, 58 | 59 | /** 60 | * Foreground color for the menu. 61 | * Default = 'white' 62 | */ 63 | fg?: string, 64 | 65 | /** 66 | * Background color for the menu. 67 | * Default = 'blue' 68 | */ 69 | bg?: string, 70 | 71 | /** 72 | * Padding for the bounding rectangle. 73 | * If a number is passed, all elements of the Thickness structure will be set to 74 | that value. 75 | Default = { 76 | left: 2, 77 | right: 2, 78 | top: 1, 79 | bottom: 1 80 | } 81 | */ 82 | padding?: number | MenuContainerFactory$Thickness, 83 | 84 | /** 85 | * Index of the menu item to be selected. 86 | * Default = 0 87 | */ 88 | selected?: number 89 | } 90 | 91 | /** 92 | * Retro ansi terminal menus. 93 | */ 94 | declare class tm$tm { 95 | constructor: TerminalMenuOptions => tm$tm, 96 | /** 97 | * Create a new selectable menu item with label as the anchor. 98 | * @param label Label to use as the menu item anchor. 99 | */ 100 | add(label: string): void, 101 | 102 | /** 103 | * Create a new selectable menu item with label as the anchor. 104 | * @param label Label to use as the menu item anchor. 105 | * @param callback Callback to invoke when the menu item is selected. 106 | */ 107 | add(label: string, callback: (label: string, index: number) => void): void, 108 | 109 | /** 110 | * Writes a message to the terminal. 111 | * @param msg Message to be written. 112 | */ 113 | write(msg: string): void, 114 | 115 | /** 116 | * Return a duplex stream to wire up input and output. 117 | */ 118 | createStream(): stream.Duplex, 119 | 120 | /** 121 | * Reset the terminal, clearing all content. 122 | */ 123 | reset(): void, 124 | 125 | /** 126 | * Unregister all listeners and puts the terminal back to its original state. 127 | */ 128 | close(): void, 129 | 130 | /** 131 | * When a menu item is selected, this event is fired. 132 | * @param eventName Name of the event. Only value available for eventName is "select" 133 | * @param callback Handler for the event specified by eventName 134 | */ 135 | on( 136 | eventName: string, 137 | callback: (label: string, index: number) => void 138 | ): tm$tm, 139 | 140 | /** 141 | * When a menu item is selected, this event is fired. 142 | * This overload ensures backward compatibility with older versions of NodeJS (< 6.0) 143 | * @param eventName Name of the event. Only value available for eventName is "select" 144 | * @param callback Handler for the event specified by eventName 145 | */ 146 | on(eventName: string, callback: (label: string, index: number) => void): tm$tm 147 | } 148 | 149 | declare module "terminal-menu" { 150 | declare module.exports: Class; 151 | } 152 | -------------------------------------------------------------------------------- /flow-typed/npm/xo_vx.x.x.js: -------------------------------------------------------------------------------- 1 | // flow-typed signature: b1376f17e91ebd65263c5530d8141544 2 | // flow-typed version: <>/xo_v^0.18.2/flow_v0.55.0 3 | 4 | /** 5 | * This is an autogenerated libdef stub for: 6 | * 7 | * 'xo' 8 | * 9 | * Fill this stub out by replacing all the `any` types. 10 | * 11 | * Once filled out, we encourage you to share your work with the 12 | * community by sending a pull request to: 13 | * https://github.com/flowtype/flow-typed 14 | */ 15 | 16 | declare module 'xo' { 17 | declare module.exports: any; 18 | } 19 | 20 | /** 21 | * We include stubs for each file inside this npm package in case you need to 22 | * require those files directly. Feel free to delete any files that aren't 23 | * needed. 24 | */ 25 | declare module 'xo/cli' { 26 | declare module.exports: any; 27 | } 28 | 29 | declare module 'xo/config/overrides' { 30 | declare module.exports: any; 31 | } 32 | 33 | declare module 'xo/config/plugins' { 34 | declare module.exports: any; 35 | } 36 | 37 | declare module 'xo/options-manager' { 38 | declare module.exports: any; 39 | } 40 | 41 | // Filename aliases 42 | declare module 'xo/cli.js' { 43 | declare module.exports: $Exports<'xo/cli'>; 44 | } 45 | declare module 'xo/config/overrides.js' { 46 | declare module.exports: $Exports<'xo/config/overrides'>; 47 | } 48 | declare module 'xo/config/plugins.js' { 49 | declare module.exports: $Exports<'xo/config/plugins'>; 50 | } 51 | declare module 'xo/index' { 52 | declare module.exports: $Exports<'xo'>; 53 | } 54 | declare module 'xo/index.js' { 55 | declare module.exports: $Exports<'xo'>; 56 | } 57 | declare module 'xo/options-manager.js' { 58 | declare module.exports: $Exports<'xo/options-manager'>; 59 | } 60 | -------------------------------------------------------------------------------- /flow-typed/npm/yargs_vx.x.x.js: -------------------------------------------------------------------------------- 1 | // flow-typed signature: 4daf34b2a2a2df5f3f4ffe16f02be3b7 2 | // flow-typed version: <>/yargs_v^8.0.2/flow_v0.55.0 3 | 4 | /** 5 | * This is an autogenerated libdef stub for: 6 | * 7 | * 'yargs' 8 | * 9 | * Fill this stub out by replacing all the `any` types. 10 | * 11 | * Once filled out, we encourage you to share your work with the 12 | * community by sending a pull request to: 13 | * https://github.com/flowtype/flow-typed 14 | */ 15 | 16 | declare module 'yargs' { 17 | declare module.exports: any; 18 | } 19 | 20 | /** 21 | * We include stubs for each file inside this npm package in case you need to 22 | * require those files directly. Feel free to delete any files that aren't 23 | * needed. 24 | */ 25 | declare module 'yargs/lib/apply-extends' { 26 | declare module.exports: any; 27 | } 28 | 29 | declare module 'yargs/lib/argsert' { 30 | declare module.exports: any; 31 | } 32 | 33 | declare module 'yargs/lib/assign' { 34 | declare module.exports: any; 35 | } 36 | 37 | declare module 'yargs/lib/command' { 38 | declare module.exports: any; 39 | } 40 | 41 | declare module 'yargs/lib/completion' { 42 | declare module.exports: any; 43 | } 44 | 45 | declare module 'yargs/lib/levenshtein' { 46 | declare module.exports: any; 47 | } 48 | 49 | declare module 'yargs/lib/obj-filter' { 50 | declare module.exports: any; 51 | } 52 | 53 | declare module 'yargs/lib/usage' { 54 | declare module.exports: any; 55 | } 56 | 57 | declare module 'yargs/lib/validation' { 58 | declare module.exports: any; 59 | } 60 | 61 | declare module 'yargs/lib/yerror' { 62 | declare module.exports: any; 63 | } 64 | 65 | declare module 'yargs/yargs' { 66 | declare module.exports: any; 67 | } 68 | 69 | // Filename aliases 70 | declare module 'yargs/index' { 71 | declare module.exports: $Exports<'yargs'>; 72 | } 73 | declare module 'yargs/index.js' { 74 | declare module.exports: $Exports<'yargs'>; 75 | } 76 | declare module 'yargs/lib/apply-extends.js' { 77 | declare module.exports: $Exports<'yargs/lib/apply-extends'>; 78 | } 79 | declare module 'yargs/lib/argsert.js' { 80 | declare module.exports: $Exports<'yargs/lib/argsert'>; 81 | } 82 | declare module 'yargs/lib/assign.js' { 83 | declare module.exports: $Exports<'yargs/lib/assign'>; 84 | } 85 | declare module 'yargs/lib/command.js' { 86 | declare module.exports: $Exports<'yargs/lib/command'>; 87 | } 88 | declare module 'yargs/lib/completion.js' { 89 | declare module.exports: $Exports<'yargs/lib/completion'>; 90 | } 91 | declare module 'yargs/lib/levenshtein.js' { 92 | declare module.exports: $Exports<'yargs/lib/levenshtein'>; 93 | } 94 | declare module 'yargs/lib/obj-filter.js' { 95 | declare module.exports: $Exports<'yargs/lib/obj-filter'>; 96 | } 97 | declare module 'yargs/lib/usage.js' { 98 | declare module.exports: $Exports<'yargs/lib/usage'>; 99 | } 100 | declare module 'yargs/lib/validation.js' { 101 | declare module.exports: $Exports<'yargs/lib/validation'>; 102 | } 103 | declare module 'yargs/lib/yerror.js' { 104 | declare module.exports: $Exports<'yargs/lib/yerror'>; 105 | } 106 | declare module 'yargs/yargs.js' { 107 | declare module.exports: $Exports<'yargs/yargs'>; 108 | } 109 | -------------------------------------------------------------------------------- /goals/completed/weekly/Sep0620171312/Play_With_Puppies.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/modernkd/personal-goals-cli/f3772f2eca8f8c88570dbf2b1552d896d0184d5c/goals/completed/weekly/Sep0620171312/Play_With_Puppies.md -------------------------------------------------------------------------------- /goals/monthly/read_a_book.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/modernkd/personal-goals-cli/f3772f2eca8f8c88570dbf2b1552d896d0184d5c/goals/monthly/read_a_book.md -------------------------------------------------------------------------------- /goals/monthly/submit_a_CFP_for_a_conference.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/modernkd/personal-goals-cli/f3772f2eca8f8c88570dbf2b1552d896d0184d5c/goals/monthly/submit_a_CFP_for_a_conference.md -------------------------------------------------------------------------------- /goals/other/work_on_a_cool_side_project.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/modernkd/personal-goals-cli/f3772f2eca8f8c88570dbf2b1552d896d0184d5c/goals/other/work_on_a_cool_side_project.md -------------------------------------------------------------------------------- /goals/yearly/be_kind.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/modernkd/personal-goals-cli/f3772f2eca8f8c88570dbf2b1552d896d0184d5c/goals/yearly/be_kind.md -------------------------------------------------------------------------------- /goals/yearly/contribute_to_open_source.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/modernkd/personal-goals-cli/f3772f2eca8f8c88570dbf2b1552d896d0184d5c/goals/yearly/contribute_to_open_source.md -------------------------------------------------------------------------------- /goals/yearly/write_more_blog_posts.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/modernkd/personal-goals-cli/f3772f2eca8f8c88570dbf2b1552d896d0184d5c/goals/yearly/write_more_blog_posts.md -------------------------------------------------------------------------------- /gulpfile.js: -------------------------------------------------------------------------------- 1 | const gulp = require("gulp"); 2 | const babel = require("gulp-babel"); 3 | const sourcemaps = require("gulp-sourcemaps"); 4 | const flow = require("gulp-flowtype"); 5 | 6 | gulp.task("scripts", () => { 7 | console.log('babel'); 8 | return gulp 9 | .src("src/**/*.js") 10 | .pipe(sourcemaps.init()) 11 | .pipe(babel()) 12 | .pipe(sourcemaps.write(".")) 13 | .pipe(gulp.dest("lib")); 14 | }); 15 | 16 | gulp.task("flow", () => { 17 | return gulp.src("src/**/*.js").pipe(flow({ killFlow: false })); 18 | }); 19 | 20 | gulp.task("watch", ["flow", "scripts"], () => { 21 | gulp.watch("src/**/*.js", ["flow", "scripts"]); 22 | }); 23 | 24 | gulp.task("default", ["watch"]); 25 | -------------------------------------------------------------------------------- /lib/cli.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | "use strict"; 4 | 5 | const yargs = require("yargs"); 6 | const config = require("./commands/config").command; 7 | const clear = require("./commands/clear"); 8 | const ls = require("./commands/ls").command; 9 | const complete = require("./commands/complete"); 10 | const newCommand = require("./commands/new"); 11 | const deleteCommand = require("./commands/delete"); 12 | 13 | yargs // eslint-disable-line no-unused-expressions 14 | .command(newCommand).command(complete).command(ls).command(clear).command(config).command(deleteCommand).group("weekly (w)", "Types").group("monthly (m)", "Types").group("other (o)", "Types").group("completed (c)", "Types").group("all (a)", "Types").example("ls", "$0 ls").example("ls", "$0 ls complete").example("ls", "$0 list all").example("new", `$0 new w 'work out 3 times' `).example("new", `$0 n m 'lose 5 pounds'`).example("complete", "$0 c other").example("complete", `$0 complete week 'work out 3 times'`).example("config", "$0 cfg dir '/user/me/projects/personal-goals'").example("config", `$0 config focus weekly 'get outside more'`).example("config", `$0 config type 'today'`).example("config", `$0 cfg alias t today`).example("config", `$0 conf title t 'All the things I want to do today'`).example("config", `$0 cfg ls`).example("clear", "$0 clear all").example("clear", `$0 clear weekly`).wrap(null).help().argv; 15 | 16 | if (yargs.argv._.length === 0) { 17 | yargs.showHelp(); 18 | } 19 | //# sourceMappingURL=cli.js.map 20 | -------------------------------------------------------------------------------- /lib/cli.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"sources":["cli.js"],"names":["yargs","require","config","command","clear","ls","complete","newCommand","deleteCommand","group","example","wrap","help","argv","_","length","showHelp"],"mappings":";AAEA;;AAEA,MAAMA,QAAQC,QAAQ,OAAR,CAAd;AACA,MAAMC,SAASD,QAAQ,mBAAR,EAA6BE,OAA5C;AACA,MAAMC,QAAQH,QAAQ,kBAAR,CAAd;AACA,MAAMI,KAAKJ,QAAQ,eAAR,EAAyBE,OAApC;AACA,MAAMG,WAAWL,QAAQ,qBAAR,CAAjB;AACA,MAAMM,aAAaN,QAAQ,gBAAR,CAAnB;AACA,MAAMO,gBAAgBP,QAAQ,mBAAR,CAAtB;;AAEAD,MAAM;AAAN,CACGG,OADH,CACWI,UADX,EAEGJ,OAFH,CAEWG,QAFX,EAGGH,OAHH,CAGWE,EAHX,EAIGF,OAJH,CAIWC,KAJX,EAKGD,OALH,CAKWD,MALX,EAMGC,OANH,CAMWK,aANX,EAOGC,KAPH,CAOS,YAPT,EAOuB,OAPvB,EAQGA,KARH,CAQS,aART,EAQwB,OARxB,EASGA,KATH,CASS,WATT,EASsB,OATtB,EAUGA,KAVH,CAUS,eAVT,EAU0B,OAV1B,EAWGA,KAXH,CAWS,SAXT,EAWoB,OAXpB,EAYGC,OAZH,CAYW,IAZX,EAYiB,OAZjB,EAaGA,OAbH,CAaW,IAbX,EAaiB,gBAbjB,EAcGA,OAdH,CAcW,IAdX,EAciB,aAdjB,EAeGA,OAfH,CAeW,KAfX,EAemB,8BAfnB,EAgBGA,OAhBH,CAgBW,KAhBX,EAgBmB,wBAhBnB,EAiBGA,OAjBH,CAiBW,UAjBX,EAiBuB,YAjBvB,EAkBGA,OAlBH,CAkBW,UAlBX,EAkBwB,qCAlBxB,EAmBGA,OAnBH,CAmBW,QAnBX,EAmBqB,+CAnBrB,EAoBGA,OApBH,CAoBW,QApBX,EAoBsB,2CApBtB,EAqBGA,OArBH,CAqBW,QArBX,EAqBsB,wBArBtB,EAsBGA,OAtBH,CAsBW,QAtBX,EAsBsB,sBAtBtB,EAuBGA,OAvBH,CAuBW,QAvBX,EAuBsB,qDAvBtB,EAwBGA,OAxBH,CAwBW,QAxBX,EAwBsB,WAxBtB,EAyBGA,OAzBH,CAyBW,OAzBX,EAyBoB,cAzBpB,EA0BGA,OA1BH,CA0BW,OA1BX,EA0BqB,iBA1BrB,EA2BGC,IA3BH,CA2BQ,IA3BR,EA4BGC,IA5BH,GA4BUC,IA5BV;;AA8BA,IAAIb,MAAMa,IAAN,CAAWC,CAAX,CAAaC,MAAb,KAAwB,CAA5B,EAA+B;AAC7Bf,QAAMgB,QAAN;AACD","file":"cli.js","sourcesContent":["\n//@flow\n\"use strict\";\n\nconst yargs = require(\"yargs\");\nconst config = require(\"./commands/config\").command;\nconst clear = require(\"./commands/clear\");\nconst ls = require(\"./commands/ls\").command;\nconst complete = require(\"./commands/complete\");\nconst newCommand = require(\"./commands/new\");\nconst deleteCommand = require(\"./commands/delete\");\n\nyargs // eslint-disable-line no-unused-expressions\n .command(newCommand)\n .command(complete)\n .command(ls)\n .command(clear)\n .command(config)\n .command(deleteCommand)\n .group(\"weekly (w)\", \"Types\")\n .group(\"monthly (m)\", \"Types\")\n .group(\"other (o)\", \"Types\")\n .group(\"completed (c)\", \"Types\")\n .group(\"all (a)\", \"Types\")\n .example(\"ls\", \"$0 ls\")\n .example(\"ls\", \"$0 ls complete\")\n .example(\"ls\", \"$0 list all\")\n .example(\"new\", `$0 new w 'work out 3 times' `)\n .example(\"new\", `$0 n m 'lose 5 pounds'`)\n .example(\"complete\", \"$0 c other\")\n .example(\"complete\", `$0 complete week 'work out 3 times'`)\n .example(\"config\", \"$0 cfg dir '/user/me/projects/personal-goals'\")\n .example(\"config\", `$0 config focus weekly 'get outside more'`)\n .example(\"config\", `$0 config type 'today'`)\n .example(\"config\", `$0 cfg alias t today`)\n .example(\"config\", `$0 conf title t 'All the things I want to do today'`)\n .example(\"config\", `$0 cfg ls`)\n .example(\"clear\", \"$0 clear all\")\n .example(\"clear\", `$0 clear weekly`)\n .wrap(null)\n .help().argv;\n\nif (yargs.argv._.length === 0) {\n yargs.showHelp();\n}\n\n"]} -------------------------------------------------------------------------------- /lib/commands/clear.js: -------------------------------------------------------------------------------- 1 | const path = require("path"); 2 | const fs = require("fs-extra"); 3 | const { checkConf, confTypes, confAliases, confDir } = require("./config"); 4 | const { ls } = require("./ls"); 5 | const { write } = require("../utils/markdown"); 6 | 7 | module.exports = { 8 | command: "clear [type]", 9 | aliases: ["clr"], 10 | usage: `$0 clear `, 11 | description: `clear goals of a type`, 12 | builder: yargs => yargs.default("type", "a"), 13 | handler: argv => { 14 | checkConf(); 15 | 16 | let type; 17 | if (confTypes.includes(argv.type)) { 18 | type = argv.type; 19 | } else if (typeof confAliases[argv.type] === "string") { 20 | type = confAliases[argv.type]; 21 | } else { 22 | switch (argv.type) { 23 | case "a": 24 | type = "all"; 25 | break; 26 | case "complete": 27 | case "c": 28 | type = "completed"; 29 | break; 30 | default: 31 | type = argv.type; 32 | break; 33 | } 34 | } 35 | clear(type); 36 | } 37 | }; 38 | 39 | function clear(type) { 40 | if (type === "all") { 41 | fs.remove(path.join(confDir)).then(() => { 42 | ls("all"); 43 | write(); 44 | }); 45 | } else { 46 | fs.remove(path.join(confDir, type)).then(() => { 47 | ls("all"); 48 | write(); 49 | }); 50 | } 51 | } 52 | //# sourceMappingURL=clear.js.map 53 | -------------------------------------------------------------------------------- /lib/commands/clear.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"sources":["commands/clear.js"],"names":["path","require","fs","checkConf","confTypes","confAliases","confDir","ls","write","module","exports","command","aliases","usage","description","builder","yargs","default","handler","argv","type","includes","clear","remove","join","then"],"mappings":"AACA,MAAMA,OAAOC,QAAQ,MAAR,CAAb;AACA,MAAMC,KAAKD,QAAQ,UAAR,CAAX;AACA,MAAM,EAAEE,SAAF,EAAaC,SAAb,EAAwBC,WAAxB,EAAqCC,OAArC,KAAiDL,QAAQ,UAAR,CAAvD;AACA,MAAM,EAACM,EAAD,KAAON,QAAQ,MAAR,CAAb;AACA,MAAM,EAAEO,KAAF,KAAYP,QAAQ,mBAAR,CAAlB;;AAEAQ,OAAOC,OAAP,GAAiB;AACfC,WAAS,cADM;AAEfC,WAAS,CAAC,KAAD,CAFM;AAGfC,SAAQ,8BAHO;AAIfC,eAAc,uBAJC;AAKfC,WAAUC,KAAD,IACPA,MAAMC,OAAN,CAAc,MAAd,EAAsB,GAAtB,CANa;AAOfC,WAAUC,IAAD,IAA4B;AACnChB;;AAEA,QAAIiB,IAAJ;AACA,QAAIhB,UAAUiB,QAAV,CAAmBF,KAAKC,IAAxB,CAAJ,EAAmC;AACjCA,aAAOD,KAAKC,IAAZ;AACD,KAFD,MAEO,IAAI,OAAOf,YAAYc,KAAKC,IAAjB,CAAP,KAAkC,QAAtC,EAAgD;AACrDA,aAAOf,YAAYc,KAAKC,IAAjB,CAAP;AACD,KAFM,MAEA;AACL,cAAQD,KAAKC,IAAb;AACE,aAAK,GAAL;AACEA,iBAAO,KAAP;AACA;AACF,aAAK,UAAL;AACA,aAAK,GAAL;AACEA,iBAAO,WAAP;AACA;AACF;AACEA,iBAAOD,KAAKC,IAAZ;AACA;AAVJ;AAYD;AACDE,UAAMF,IAAN;AACD;AA9Bc,CAAjB;;AAiCA,SAASE,KAAT,CAAeF,IAAf,EAA6B;AAC3B,MAAIA,SAAS,KAAb,EAAoB;AAClBlB,OAAGqB,MAAH,CAAUvB,KAAKwB,IAAL,CAAUlB,OAAV,CAAV,EAA8BmB,IAA9B,CAAmC,MAAM;AACvClB,SAAG,KAAH;AACAC;AACD,KAHD;AAID,GALD,MAKO;AACLN,OAAGqB,MAAH,CAAUvB,KAAKwB,IAAL,CAAUlB,OAAV,EAAmBc,IAAnB,CAAV,EAAoCK,IAApC,CAAyC,MAAM;AAC7ClB,SAAG,KAAH;AACAC;AACD,KAHD;AAID;AACF","file":"clear.js","sourcesContent":["//@flow\nconst path = require(\"path\");\nconst fs = require(\"fs-extra\");\nconst { checkConf, confTypes, confAliases, confDir } = require(\"./config\");\nconst {ls} = require(\"./ls\")\nconst { write } = require(\"../utils/markdown\");\n\nmodule.exports = {\n command: \"clear [type]\",\n aliases: [\"clr\"],\n usage: `$0 clear `,\n description: `clear goals of a type`,\n builder: (yargs: { default: (string, string) => mixed }) =>\n yargs.default(\"type\", \"a\"),\n handler: (argv: { type: string }) => {\n checkConf();\n\n let type: string;\n if (confTypes.includes(argv.type)) {\n type = argv.type;\n } else if (typeof confAliases[argv.type] === \"string\") {\n type = confAliases[argv.type];\n } else {\n switch (argv.type) {\n case \"a\":\n type = \"all\";\n break;\n case \"complete\":\n case \"c\":\n type = \"completed\";\n break;\n default:\n type = argv.type;\n break;\n }\n }\n clear(type);\n }\n};\n\nfunction clear(type: string) {\n if (type === \"all\") {\n fs.remove(path.join(confDir)).then(() => {\n ls(\"all\");\n write()\n })\n } else {\n fs.remove(path.join(confDir, type)).then(() => {\n ls(\"all\");\n write()\n });\n }\n}\n"]} -------------------------------------------------------------------------------- /lib/commands/complete.js: -------------------------------------------------------------------------------- 1 | let menu = (() => { 2 | var _ref = _asyncToGenerator(function* (type) { 3 | checkConf(); 4 | const dir = getFileName(type, ""); 5 | yield fs.ensureDir(dir); 6 | const files = yield fs.readdir(dir); 7 | try { 8 | const menu = new Menu({ bg: "black", fg: "white", width: 100 }); 9 | 10 | menu.reset(); 11 | menu.write("Which " + prettyName(type) + " Goal Did You Complete?\n"); 12 | menu.write("-------------------------------------\n"); 13 | files.map(function (item) { 14 | if (!item.startsWith(".")) { 15 | menu.add(prettyName(item)); 16 | } 17 | }); 18 | menu.add("None"); 19 | 20 | menu.on("select", function (label) { 21 | menu.close(); 22 | if (label === "None") { 23 | return; 24 | } 25 | completeGoal(type, label); 26 | }); 27 | process.stdin.pipe(menu.createStream()).pipe(process.stdout); 28 | 29 | process.stdin.setRawMode(true); 30 | menu.on("close", function () { 31 | process.stdin.setRawMode(false); 32 | process.stdin.end(); 33 | }); 34 | } catch (err) { 35 | console.error(err); 36 | } 37 | }); 38 | 39 | return function menu(_x) { 40 | return _ref.apply(this, arguments); 41 | }; 42 | })(); 43 | 44 | function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; } 45 | 46 | const path = require("path"); 47 | const fs = require("fs-extra"); 48 | const Menu = require("terminal-menu"); 49 | const moment = require("moment"); 50 | const { prettyName, getFileName } = require("../utils/file"); 51 | const { checkConf, confTypes, confAliases, confDir } = require("./config"); 52 | const { ls } = require("./ls"); 53 | const { write } = require("../utils/markdown"); 54 | 55 | module.exports = { 56 | command: "complete [type] [goal]", 57 | aliases: ["c"], 58 | desc: "mark a goal as completed", 59 | example: "$0 c w ", 60 | builder: yargs => yargs.default("type", "w"), 61 | handler: argv => { 62 | checkConf(); 63 | 64 | let type; 65 | if (confTypes.includes(argv.type)) { 66 | type = argv.type; 67 | } else if (confAliases.hasOwnProperty(argv.type)) { 68 | type = confAliases[argv.type]; 69 | } else { 70 | type = argv.type; 71 | } 72 | if (argv.goal) { 73 | completeGoal(type, argv.goal); 74 | } else { 75 | menu(type); 76 | } 77 | } 78 | }; 79 | 80 | function completeGoal(type, goal) { 81 | const date = moment().format("MMMDDYYYYHHmm"); 82 | const dir = path.join(confDir, "completed", type, date); 83 | 84 | fs.move(getFileName(type, goal), getFileName(path.join("completed", type, date), goal)).then(() => { 85 | ls("all"); 86 | write(); 87 | }); 88 | } 89 | //# sourceMappingURL=complete.js.map 90 | -------------------------------------------------------------------------------- /lib/commands/complete.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"sources":["commands/complete.js"],"names":["type","checkConf","dir","getFileName","fs","ensureDir","files","readdir","menu","Menu","bg","fg","width","reset","write","prettyName","map","item","startsWith","add","on","label","close","completeGoal","process","stdin","pipe","createStream","stdout","setRawMode","end","err","console","error","path","require","moment","confTypes","confAliases","confDir","ls","module","exports","command","aliases","desc","example","builder","yargs","default","handler","argv","includes","hasOwnProperty","goal","date","format","join","move","then"],"mappings":";+BAoDA,WAAoBA,IAApB,EAAiD;AAC/CC;AACA,UAAMC,MAAMC,YAAYH,IAAZ,EAAkB,EAAlB,CAAZ;AACA,UAAMI,GAAGC,SAAH,CAAaH,GAAb,CAAN;AACA,UAAMI,QAAQ,MAAMF,GAAGG,OAAH,CAAWL,GAAX,CAApB;AACA,QAAI;AACF,YAAMM,OAAO,IAAIC,IAAJ,CAAS,EAAEC,IAAI,OAAN,EAAeC,IAAI,OAAnB,EAA4BC,OAAO,GAAnC,EAAT,CAAb;;AAEAJ,WAAKK,KAAL;AACAL,WAAKM,KAAL,CAAW,WAAWC,WAAWf,IAAX,CAAX,GAA8B,2BAAzC;AACAQ,WAAKM,KAAL,CAAW,yCAAX;AACAR,YAAMU,GAAN,CAAU,UAACC,IAAD,EAAkB;AAC1B,YAAI,CAACA,KAAKC,UAAL,CAAgB,GAAhB,CAAL,EAA2B;AACzBV,eAAKW,GAAL,CAASJ,WAAWE,IAAX,CAAT;AACD;AACF,OAJD;AAKAT,WAAKW,GAAL,CAAS,MAAT;;AAEAX,WAAKY,EAAL,CAAQ,QAAR,EAAkB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AmBD,KAAKnD,IAAxB,CAAJ,EAAmC;AACjCA,aAAOmD,KAAKnD,IAAZ;AACD,KAFD,MAEO,IAAIsC,YAAYe,cAAZ,CAA2BF,KAAKnD,IAAhC,CAAJ,EAA2C;AAChDA,aAAOsC,YAAYa,KAAKnD,IAAjB,CAAP;AACD,KAFM,MAEA;AACLA,aAAOmD,KAAKnD,IAAZ;AACD;AACD,QAAImD,KAAKG,IAAT,EAAe;AACb/B,mBAAavB,IAAb,EAAmBmD,KAAKG,IAAxB;AACD,KAFD,MAEO;AACL9C,WAAKR,IAAL;AACD;AACF;AAvBc,CAAjB;;AA0BA,SAASuB,YAAT,CAAsBvB,IAAtB,EAAoCsD,IAApC,EAAwD;AACtD,QAAMC,OAAOnB,SAASoB,MAAT,CAAgB,eAAhB,CAAb;AACA,QAAMtD,MAAMgC,KAAKuB,IAAL,CAAUlB,OAAV,EAAmB,WAAnB,EAAgCvC,IAAhC,EAAsCuD,IAAtC,CAAZ;;AAEAnD,KACGsD,IADH,CAEIvD,YAAYH,IAAZ,EAAkBsD,IAAlB,CAFJ,EAGInD,YAAY+B,KAAKuB,IAAL,CAAU,WAAV,EAAuBzD,IAAvB,EAA6BuD,IAA7B,CAAZ,EAAgDD,IAAhD,CAHJ,EAKGK,IALH,CAKQ,MAAM;AACVnB,OAAG,KAAH;AACA1B;AACD,GARH;AASD","file":"complete.js","sourcesContent":["// @flow\n\nconst path = require(\"path\");\nconst fs = require(\"fs-extra\");\nconst Menu = require(\"terminal-menu\");\nconst moment = require(\"moment\");\nconst { prettyName, getFileName } = require(\"../utils/file\");\nconst { checkConf, confTypes, confAliases, confDir } = require(\"./config\");\nconst { ls } = require(\"./ls\");\nconst { write } = require(\"../utils/markdown\");\n\nmodule.exports = {\n command: \"complete [type] [goal]\",\n aliases: [\"c\"],\n desc: \"mark a goal as completed\",\n example: \"$0 c w \",\n builder: (yargs: { default: (string, string) => mixed }) =>\n yargs.default(\"type\", \"w\"),\n handler: (argv: { type: string, goal: string }) => {\n checkConf();\n\n let type: string;\n if (confTypes.includes(argv.type)) {\n type = argv.type;\n } else if (confAliases.hasOwnProperty(argv.type)) {\n type = confAliases[argv.type];\n } else {\n type = argv.type;\n }\n if (argv.goal) {\n completeGoal(type, argv.goal);\n } else {\n menu(type);\n }\n }\n};\n\nfunction completeGoal(type: string, goal: string): void {\n const date = moment().format(\"MMMDDYYYYHHmm\");\n const dir = path.join(confDir, \"completed\", type, date);\n\n fs\n .move(\n getFileName(type, goal),\n getFileName(path.join(\"completed\", type, date), goal)\n )\n .then(() => {\n ls(\"all\")\n write();\n });\n}\n\nasync function menu(type: string): Promise {\n checkConf();\n const dir = getFileName(type, \"\");\n await fs.ensureDir(dir);\n const files = await fs.readdir(dir);\n try {\n const menu = new Menu({ bg: \"black\", fg: \"white\", width: 100 });\n\n menu.reset();\n menu.write(\"Which \" + prettyName(type) + \" Goal Did You Complete?\\n\");\n menu.write(\"-------------------------------------\\n\");\n files.map((item: string) => {\n if (!item.startsWith(\".\")) {\n menu.add(prettyName(item));\n }\n });\n menu.add(\"None\");\n\n menu.on(\"select\", (label: string) => {\n menu.close();\n if (label === \"None\") {\n return;\n }\n completeGoal(type, label);\n });\n process.stdin.pipe(menu.createStream()).pipe(process.stdout);\n\n process.stdin.setRawMode(true);\n menu.on(\"close\", () => {\n process.stdin.setRawMode(false);\n process.stdin.end();\n });\n } catch (err) {\n console.error(err);\n }\n}\n"]} -------------------------------------------------------------------------------- /lib/commands/config.js: -------------------------------------------------------------------------------- 1 | const path = require("path"); 2 | const fs = require("fs-extra"); 3 | const Configstore = require("configstore"); 4 | const moment = require("moment"); 5 | 6 | const date = moment(); 7 | const defaultConf = { 8 | dir: path.join(path.resolve(), "goals"), 9 | readme: path.resolve(), 10 | types: ["yearly", "weekly", "monthly", "other"], 11 | focus: { 12 | weekly: "Be Awesome." 13 | }, 14 | alias: { 15 | w: "weekly", 16 | week: "weekly", 17 | m: "monthly", 18 | month: "monthly", 19 | y: "yearly", 20 | year: "yearly", 21 | o: "other" 22 | }, 23 | title: { 24 | weekly: `Things I'll Do This Week`, 25 | monthly: `Things I'll Do This Month (${date.format("MMMM YYYY")}) `, 26 | yearly: `Overarching Goals`, 27 | today: ` Goals for ${date.format("dddd, MMMM Do YYYY")}`, 28 | tomorrow: `Goals for ${date.add(1, "d").format("dddd, MMMM Do YYYY")}` 29 | } 30 | }; 31 | const conf = new Configstore("personal-goals-cli", defaultConf); 32 | const chalk = require("chalk"); 33 | 34 | const confFocus = conf.get("focus"); 35 | const confAliases = conf.get("alias"); 36 | const confTitles = conf.get("title"); 37 | const confTypes = conf.get("types"); 38 | const confDir = conf.get("dir"); 39 | const confReadme = conf.get("readme"); 40 | 41 | module.exports = { 42 | confFocus, 43 | confTypes, 44 | confTitles, 45 | confAliases, 46 | confDir, 47 | confReadme, 48 | command: { 49 | command: "config [value] [detail]", 50 | aliases: ["cfg", "conf"], 51 | usage: "$0 config [value]", 52 | description: "Set up the personal goals configuration", 53 | examples: ["$0 cfg dir '/user/me/projects/personal-goals'", "$0 config weeklyfocus 'get outside more'"], 54 | handler: argv => { 55 | let completedTask = false; 56 | completedTask = completedTask || maybeClear(argv); 57 | completedTask = completedTask || maybeList(argv); 58 | completedTask = completedTask || maybeAddType(argv); 59 | completedTask = completedTask || maybeAddFocus(argv); 60 | completedTask = completedTask || maybeAddAlias(argv); 61 | completedTask = completedTask || maybeAddTitle(argv); 62 | if (!completedTask) { 63 | conf.set(argv.key, argv.value); 64 | console.log(chalk.green("Successfully updated green: ")); 65 | console.log(chalk.bold(argv.key), ":", conf.get(argv.key)); 66 | } 67 | } 68 | }, 69 | 70 | checkConf, 71 | 72 | conf 73 | }; 74 | 75 | const maybeClear = argv => { 76 | if (argv.value === "clear" || argv.value === "clr" || argv.value === "del" || argv.value === "delete") { 77 | const value = argv.key; 78 | const key = argv.value; 79 | argv.value = value; 80 | argv.key = key; 81 | clearConf(argv); 82 | } else if (argv.key === "clear" || argv.key === "clr" || argv.key === "del" || argv.key === "delete") { 83 | clearConf(argv); 84 | return true; 85 | } 86 | }; 87 | 88 | const maybeList = argv => { 89 | if (argv.key === "ls" || argv.key === "get") { 90 | console.log(conf.all); 91 | return true; 92 | } 93 | }; 94 | 95 | const maybeAddType = argv => { 96 | if (argv.key === "type" || argv.key === "types") { 97 | if (confTypes.includes(argv.value)) { 98 | console.log(chalk.red("Error adding new type: "), chalk.bold(argv.value), " already exists as a type"); 99 | } else if (typeof confAliases[argv.value] === "string") { 100 | console.log(chalk.red("Error adding new type: "), chalk.bold(argv.value), " already exists as an alias to ", chalk.bold(confAliases[argv.value])); 101 | } else { 102 | confTypes.push(argv.value); 103 | conf.set("types", confTypes); 104 | console.log(confTypes); 105 | return true; 106 | } 107 | } 108 | }; 109 | 110 | const maybeAddFocus = argv => { 111 | if (argv.key === "focus" || argv.key === "focuses" || argv.key === "foci") { 112 | if (confTypes.includes(argv.value)) { 113 | confFocus[argv.value] = argv.detail; 114 | conf.set("focus", confFocus); 115 | } else if (typeof confAliases[argv.value] === "string") { 116 | confFocus[confAliases[argv.value]] = argv.detail; 117 | conf.set("focus", confFocus); 118 | console.log(confFocus); 119 | return true; 120 | } 121 | } 122 | }; 123 | 124 | const maybeAddAlias = argv => { 125 | if (argv.key === "alias" || argv.key === "aliases") { 126 | if (confTypes.includes(argv.value)) { 127 | console.log(chalk.red("Error adding new alias: "), chalk.bold(argv.value), " already exists as a type"); 128 | } else if (typeof confAliases[argv.value] === "string") { 129 | console.log(chalk.red("Error adding new alias: "), chalk.bold(argv.value), " already exists as an alias to ", chalk.bold(confAliases[argv.value])); 130 | } else { 131 | confAliases[argv.value] = argv.detail; 132 | conf.set("alias", confAliases); 133 | console.log(confAliases); 134 | return true; 135 | } 136 | } 137 | }; 138 | 139 | const maybeAddTitle = argv => { 140 | if (argv.key === "title" || argv.key === "titles") { 141 | if (confTypes.includes(argv.value)) { 142 | confTitles[argv.value] = argv.detail; 143 | conf.set("titles", confTitles); 144 | } else if (typeof confAliases[argv.value] === "string") { 145 | confTitles[confAliases[argv.value]] = argv.detail; 146 | conf.set("title", confTitles); 147 | console.log(confTitles); 148 | return true; 149 | } 150 | } 151 | }; 152 | 153 | function clearConf(argv) { 154 | if (typeof argv.value === "string") { 155 | if (typeof argv.detail === "string") { 156 | switch (argv.value) { 157 | case "focus": 158 | case "focuses": 159 | if (confTypes.includes(argv.detail)) { 160 | delete confFocus[argv.detail]; 161 | conf.set("focus", confFocus); 162 | console.log(confFocus); 163 | } else if (typeof confAliases[argv.detail] === "string") { 164 | delete confFocus[argv.detail]; 165 | conf.set("focus", confFocus); 166 | console.log(confFocus); 167 | } else { 168 | console.log(chalk.red("Error deleting " + chalk.bold(argv.detail) + " confFocus :"), chalk.bold(argv.detail), " not found as type or alias"); 169 | } 170 | break; 171 | case "title": 172 | case "titles": 173 | if (confTypes.includes(argv.detail)) { 174 | delete confTitles[argv.detail]; 175 | conf.set("title", confTitles); 176 | console.log(confTitles); 177 | } else if (typeof confAliases[argv.detail] === "string") { 178 | delete confTitles[argv.detail]; 179 | conf.set("title", confTitles); 180 | console.log(confTitles); 181 | } else { 182 | console.log(chalk.red("Error deleting " + chalk.bold(argv.detail) + " title :"), chalk.bold(argv.detail), " not found as type or alias"); 183 | } 184 | break; 185 | case "alias": 186 | case "confAliases": 187 | if (typeof confAliases[argv.detail] === "string") { 188 | delete confAliases[argv.detail]; 189 | conf.set("alias", confAliases); 190 | console.log(confAliases); 191 | } else { 192 | console.log(chalk.red("Error deleting " + chalk.bold(argv.detail) + " confFocus :"), chalk.bold(argv.detail), " not found as alias"); 193 | } 194 | break; 195 | case "types": 196 | case "type": 197 | if (confTypes.includes(argv.detail)) { 198 | Object.keys(confAliases).forEach(key => { 199 | if (confAliases[key] === argv.detail) { 200 | delete confAliases[key]; 201 | } 202 | }); 203 | confTypes.splice(confTypes.indexOf(argv.detail), 1); 204 | conf.set("types", confTypes); 205 | conf.set("alias", confAliases); 206 | console.log(conf.all); 207 | } else if (typeof confAliases[argv.detail] === "string") { 208 | const type = confAliases[argv.detail]; 209 | Object.keys(confAliases).forEach(key => { 210 | if (confAliases[key] === type) { 211 | delete confAliases[key]; 212 | } 213 | }); 214 | confTypes.splice(confTypes.indexOf(type), 1); 215 | conf.set("types", confTypes); 216 | conf.set("alias", confAliases); 217 | console.log(conf.all); 218 | } else { 219 | console.log(chalk.red("Error deleting " + chalk.bold(argv.detail) + " type :"), chalk.bold(argv.detail), " type not found"); 220 | } 221 | break; 222 | default: 223 | break; 224 | } 225 | } else { 226 | conf.delete(argv.value); 227 | console.log(conf.all); 228 | } 229 | } else { 230 | conf.clear(); 231 | conf.set(defaultConf); 232 | console.log(conf.all); 233 | } 234 | } 235 | 236 | function checkConf() { 237 | if (confTitles.monthly.startsWith("Things I'll Do This Month (")) { 238 | confTitles.monthly = `Things I'll Do This Month (${date.format("MMMM YYYY")}) `; 239 | conf.set("title", confTitles); 240 | } 241 | if (!fs.pathExistsSync(confDir)) { 242 | console.log("setting working directory to ", path.resolve()); 243 | conf.set("dir", path.resolve("goals")); 244 | conf.set("readme", path.resolve()); 245 | } 246 | } 247 | //# sourceMappingURL=config.js.map 248 | -------------------------------------------------------------------------------- /lib/commands/config.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"sources":["commands/config.js"],"names":["path","require","fs","Configstore","moment","date","defaultConf","dir","join","resolve","readme","types","focus","weekly","alias","w","week","m","month","y","year","o","title","monthly","format","yearly","today","tomorrow","add","conf","chalk","confFocus","get","confAliases","confTitles","confTypes","confDir","confReadme","module","exports","command","aliases","usage","description","examples","handler","argv","completedTask","maybeClear","maybeList","maybeAddType","maybeAddFocus","maybeAddAlias","maybeAddTitle","set","key","value","console","log","green","bold","checkConf","clearConf","all","includes","red","push","detail","Object","keys","forEach","splice","indexOf","type","delete","clear","startsWith","pathExistsSync"],"mappings":"AAEA,MAAMA,OAAOC,QAAQ,MAAR,CAAb;AACA,MAAMC,KAAKD,QAAQ,UAAR,CAAX;AACA,MAAME,cAAcF,QAAQ,aAAR,CAApB;AAC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mC,GAAN,CACE,oBAAoBnC,MAAM8B,IAAN,CAAWd,KAAKqB,MAAhB,CAApB,GAA8C,SADhD,CADF,EAIErC,MAAM8B,IAAN,CAAWd,KAAKqB,MAAhB,CAJF,EAKE,iBALF;AAOD;AACD;AACF;AACE;AA3FJ;AA6FD,KA9FD,MA8FO;AACLtC,WAAK6C,MAAL,CAAY5B,KAAKU,KAAjB;AACAC,cAAQC,GAAR,CAAY7B,KAAKkC,GAAjB;AACD;AACF,GAnGD,MAmGO;AACLlC,SAAK8C,KAAL;AACA9C,SAAKyB,GAAL,CAAShD,WAAT;AACAmD,YAAQC,GAAR,CAAY7B,KAAKkC,GAAjB;AACD;AACF;;AAED,SAASF,SAAT,GAA2B;AACzB,MAAI3B,WAAWX,OAAX,CAAmBqD,UAAnB,CAA8B,6BAA9B,CAAJ,EAAkE;AAChE1C,eAAWX,OAAX,GAAsB,8BAA6BlB,KAAKmB,MAAL,CAAY,WAAZ,CAAyB,IAA5E;AACAK,SAAKyB,GAAL,CAAS,OAAT,EAAkBpB,UAAlB;AACD;AACD,MAAI,CAAChC,GAAG2E,cAAH,CAAkBzC,OAAlB,CAAL,EAAiC;AAC/BqB,YAAQC,GAAR,CAAY,+BAAZ,EAA6C1D,KAAKS,OAAL,EAA7C;AACAoB,SAAKyB,GAAL,CAAS,KAAT,EAAgBtD,KAAKS,OAAL,CAAa,OAAb,CAAhB;AACAoB,SAAKyB,GAAL,CAAS,QAAT,EAAmBtD,KAAKS,OAAL,EAAnB;AACD;AACF","file":"config.js","sourcesContent":["// @flow\n\nconst path = require(\"path\");\nconst fs = require(\"fs-extra\");\nconst Configstore = require(\"configstore\");\nconst moment = require(\"moment\");\n\nconst date: moment$Moment = moment();\nconst defaultConf: {\n alias: {\n m?: string,\n month?: string,\n o?: string,\n w?: string,\n week?: string,\n y?: string,\n year?: string\n },\n dir?: string,\n focus?: { weekly: string },\n readme?: string,\n title?: {\n monthly?: string,\n today?: string,\n tomorrow?: string,\n weekly?: string,\n yearly?: string\n },\n types: [string, string, string, string]\n} = {\n dir: path.join(path.resolve(), \"goals\"),\n readme: path.resolve(),\n types: [\"yearly\", \"weekly\", \"monthly\", \"other\"],\n focus: {\n weekly: \"Be Awesome.\"\n },\n alias: {\n w: \"weekly\",\n week: \"weekly\",\n m: \"monthly\",\n month: \"monthly\",\n y: \"yearly\",\n year: \"yearly\",\n o: \"other\"\n },\n title: {\n weekly: `Things I'll Do This Week`,\n monthly: `Things I'll Do This Month (${date.format(\"MMMM YYYY\")}) `,\n yearly: `Overarching Goals`,\n today: ` Goals for ${date.format(\"dddd, MMMM Do YYYY\")}`,\n tomorrow: `Goals for ${date.add(1, \"d\").format(\"dddd, MMMM Do YYYY\")}`\n }\n};\nconst conf: Configstore = new Configstore(\"personal-goals-cli\", defaultConf);\nconst chalk = require(\"chalk\");\n\nconst confFocus: { weekly: string } = conf.get(\"focus\");\nconst confAliases: {\n w: string,\n o: string,\n m: string,\n y: string,\n week: string,\n month: string,\n year: string\n} = conf.get(\"alias\");\nconst confTitles: {\n weekly: string,\n monthly: string,\n yearly: string,\n other: string,\n today: string,\n tomorrow: string\n} = conf.get(\"title\");\nconst confTypes: Array = conf.get(\"types\");\nconst confDir: string = conf.get(\"dir\");\nconst confReadme: string = conf.get(\"readme\");\n\nmodule.exports = {\n confFocus,\n confTypes,\n confTitles,\n confAliases,\n confDir,\n confReadme,\n command: {\n command: \"config [value] [detail]\",\n aliases: [\"cfg\", \"conf\"],\n usage: \"$0 config [value]\",\n description: \"Set up the personal goals configuration\",\n examples: [\n \"$0 cfg dir '/user/me/projects/personal-goals'\",\n \"$0 config weeklyfocus 'get outside more'\"\n ],\n handler: (argv: { key: string, value: string, detail: string }) => {\n let completedTask = false;\n completedTask = completedTask || maybeClear(argv);\n completedTask = completedTask || maybeList(argv);\n completedTask = completedTask || maybeAddType(argv);\n completedTask = completedTask || maybeAddFocus(argv);\n completedTask = completedTask || maybeAddAlias(argv);\n completedTask = completedTask || maybeAddTitle(argv);\n if (!completedTask) {\n conf.set(argv.key, argv.value);\n console.log(chalk.green(\"Successfully updated green: \"));\n console.log(chalk.bold(argv.key), \":\", conf.get(argv.key));\n }\n }\n },\n\n checkConf,\n\n conf\n};\n\nconst maybeClear = argv => {\n if (\n argv.value === \"clear\" ||\n argv.value === \"clr\" ||\n argv.value === \"del\" ||\n argv.value === \"delete\"\n ) {\n const value: string = argv.key;\n const key: string = argv.value;\n argv.value = value;\n argv.key = key;\n clearConf(argv);\n } else if (\n argv.key === \"clear\" ||\n argv.key === \"clr\" ||\n argv.key === \"del\" ||\n argv.key === \"delete\"\n ) {\n clearConf(argv);\n return true;\n }\n};\n\nconst maybeList = argv => {\n if (argv.key === \"ls\" || argv.key === \"get\") {\n console.log(conf.all);\n return true;\n }\n};\n\nconst maybeAddType = argv => {\n if (argv.key === \"type\" || argv.key === \"types\") {\n if (confTypes.includes(argv.value)) {\n console.log(\n chalk.red(\"Error adding new type: \"),\n chalk.bold(argv.value),\n \" already exists as a type\"\n );\n } else if (typeof confAliases[argv.value] === \"string\") {\n console.log(\n chalk.red(\"Error adding new type: \"),\n chalk.bold(argv.value),\n \" already exists as an alias to \",\n chalk.bold(confAliases[argv.value])\n );\n } else {\n confTypes.push(argv.value);\n conf.set(\"types\", confTypes);\n console.log(confTypes);\n return true;\n }\n }\n};\n\nconst maybeAddFocus = argv => {\n if (argv.key === \"focus\" || argv.key === \"focuses\" || argv.key === \"foci\") {\n if (confTypes.includes(argv.value)) {\n confFocus[argv.value] = argv.detail;\n conf.set(\"focus\", confFocus);\n } else if (typeof confAliases[argv.value] === \"string\") {\n confFocus[confAliases[argv.value]] = argv.detail;\n conf.set(\"focus\", confFocus);\n console.log(confFocus);\n return true;\n }\n }\n};\n\nconst maybeAddAlias = argv => {\n if (argv.key === \"alias\" || argv.key === \"aliases\") {\n if (confTypes.includes(argv.value)) {\n console.log(\n chalk.red(\"Error adding new alias: \"),\n chalk.bold(argv.value),\n \" already exists as a type\"\n );\n } else if (typeof confAliases[argv.value] === \"string\") {\n console.log(\n chalk.red(\"Error adding new alias: \"),\n chalk.bold(argv.value),\n \" already exists as an alias to \",\n chalk.bold(confAliases[argv.value])\n );\n } else {\n confAliases[argv.value] = argv.detail;\n conf.set(\"alias\", confAliases);\n console.log(confAliases);\n return true;\n }\n }\n};\n\nconst maybeAddTitle = argv => {\n if (argv.key === \"title\" || argv.key === \"titles\") {\n if (confTypes.includes(argv.value)) {\n confTitles[argv.value] = argv.detail;\n conf.set(\"titles\", confTitles);\n } else if (typeof confAliases[argv.value] === \"string\") {\n confTitles[confAliases[argv.value]] = argv.detail;\n conf.set(\"title\", confTitles);\n console.log(confTitles);\n return true;\n }\n }\n};\n\nfunction clearConf(argv: { detail: string, key: string, value: string }): void {\n if (typeof argv.value === \"string\") {\n if (typeof argv.detail === \"string\") {\n switch (argv.value) {\n case \"focus\":\n case \"focuses\":\n if (confTypes.includes(argv.detail)) {\n delete confFocus[argv.detail];\n conf.set(\"focus\", confFocus);\n console.log(confFocus);\n } else if (typeof confAliases[argv.detail] === \"string\") {\n delete confFocus[argv.detail];\n conf.set(\"focus\", confFocus);\n console.log(confFocus);\n } else {\n console.log(\n chalk.red(\n \"Error deleting \" + chalk.bold(argv.detail) + \" confFocus :\"\n ),\n chalk.bold(argv.detail),\n \" not found as type or alias\"\n );\n }\n break;\n case \"title\":\n case \"titles\":\n if (confTypes.includes(argv.detail)) {\n delete confTitles[argv.detail];\n conf.set(\"title\", confTitles);\n console.log(confTitles);\n } else if (typeof confAliases[argv.detail] === \"string\") {\n delete confTitles[argv.detail];\n conf.set(\"title\", confTitles);\n console.log(confTitles);\n } else {\n console.log(\n chalk.red(\n \"Error deleting \" + chalk.bold(argv.detail) + \" title :\"\n ),\n chalk.bold(argv.detail),\n \" not found as type or alias\"\n );\n }\n break;\n case \"alias\":\n case \"confAliases\":\n if (typeof confAliases[argv.detail] === \"string\") {\n delete confAliases[argv.detail];\n conf.set(\"alias\", confAliases);\n console.log(confAliases);\n } else {\n console.log(\n chalk.red(\n \"Error deleting \" + chalk.bold(argv.detail) + \" confFocus :\"\n ),\n chalk.bold(argv.detail),\n \" not found as alias\"\n );\n }\n break;\n case \"types\":\n case \"type\":\n if (confTypes.includes(argv.detail)) {\n Object.keys(confAliases).forEach((key: string) => {\n if (confAliases[key] === argv.detail) {\n delete confAliases[key];\n }\n });\n confTypes.splice(confTypes.indexOf(argv.detail), 1);\n conf.set(\"types\", confTypes);\n conf.set(\"alias\", confAliases);\n console.log(conf.all);\n } else if (typeof confAliases[argv.detail] === \"string\") {\n const type: string = confAliases[argv.detail];\n Object.keys(confAliases).forEach((key: string) => {\n if (confAliases[key] === type) {\n delete confAliases[key];\n }\n });\n confTypes.splice(confTypes.indexOf(type), 1);\n conf.set(\"types\", confTypes);\n conf.set(\"alias\", confAliases);\n console.log(conf.all);\n } else {\n console.log(\n chalk.red(\n \"Error deleting \" + chalk.bold(argv.detail) + \" type :\"\n ),\n chalk.bold(argv.detail),\n \" type not found\"\n );\n }\n break;\n default:\n break;\n }\n } else {\n conf.delete(argv.value);\n console.log(conf.all);\n }\n } else {\n conf.clear();\n conf.set(defaultConf);\n console.log(conf.all);\n }\n}\n\nfunction checkConf(): void {\n if (confTitles.monthly.startsWith(\"Things I'll Do This Month (\")) { \n confTitles.monthly = `Things I'll Do This Month (${date.format(\"MMMM YYYY\")}) `;\n conf.set(\"title\", confTitles);\n }\n if (!fs.pathExistsSync(confDir)) {\n console.log(\"setting working directory to \", path.resolve());\n conf.set(\"dir\", path.resolve(\"goals\"));\n conf.set(\"readme\", path.resolve());\n }\n}\n"]} -------------------------------------------------------------------------------- /lib/commands/delete.js: -------------------------------------------------------------------------------- 1 | let menu = (() => { 2 | var _ref = _asyncToGenerator(function* (type) { 3 | checkConf(); 4 | const dir = getFileName(type, ""); 5 | const completedDir = getFileName(path.join("completed", type)); 6 | yield fs.ensureDir(completedDir); 7 | yield fs.ensureDir(dir); 8 | const files = yield fs.readdir(dir); 9 | const completedFiles = yield recursive(completedDir); 10 | const dirIsEmpty = files.length === 0; 11 | const completedDirIsEmpty = completedFiles.length === 0; 12 | const isEmpty = dirIsEmpty && completedDirIsEmpty; 13 | const menu = new Menu({ bg: "black", fg: "white", width: 100 }); 14 | 15 | menu.reset(); 16 | menu.write("Which " + prettyName(type) + " Goal would you like to delete?\n"); 17 | menu.write("-------------------------------------\n"); 18 | try { 19 | if (!isEmpty) { 20 | if (!dirIsEmpty) { 21 | files.forEach(function (item) { 22 | return menu.add(prettyName(item)); 23 | }); 24 | } 25 | if (!completedDirIsEmpty) { 26 | completedFiles.forEach(function (item) { 27 | return menu.add("✔︎ " + prettyName(item)); 28 | }); 29 | } 30 | menu.add("None"); 31 | 32 | menu.on("select", function (label) { 33 | menu.close(); 34 | if (label === "None") { 35 | return; 36 | } 37 | deleteGoal(type, label); 38 | }); 39 | process.stdin.pipe(menu.createStream()).pipe(process.stdout); 40 | 41 | process.stdin.setRawMode(true); 42 | menu.on("close", function () { 43 | process.stdin.setRawMode(false); 44 | process.stdin.end(); 45 | }); 46 | } else { 47 | console.log(chalk.bold(chalk.red("Error: ")) + " there are no goals of type " + type); 48 | } 49 | } catch (err) { 50 | console.error(err); 51 | } 52 | }); 53 | 54 | return function menu(_x) { 55 | return _ref.apply(this, arguments); 56 | }; 57 | })(); 58 | 59 | function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; } 60 | 61 | const path = require("path"); 62 | const fs = require("fs-extra"); 63 | const Menu = require("terminal-menu"); 64 | const chalk = require("chalk"); 65 | const recursive = require("recursive-readdir"); 66 | const { prettyName, getFileName } = require("../utils/file"); 67 | const { checkConf, confTypes, confAliases, confDir } = require("./config"); 68 | const { ls } = require("./ls"); 69 | const { write } = require("../utils/markdown"); 70 | 71 | module.exports = { 72 | command: "delete [type] [goal]", 73 | aliases: ["d", "del"], 74 | desc: "delete a goal", 75 | example: "$0 d w ", 76 | builder: yargs => yargs.default("type", "w"), 77 | handler: argv => { 78 | checkConf(); 79 | 80 | let type; 81 | if (confTypes.includes(argv.type)) { 82 | type = argv.type; 83 | } else if (confAliases.hasOwnProperty(argv.type)) { 84 | type = confAliases[argv.type]; 85 | } else { 86 | type = argv.type; 87 | } 88 | if (argv.goal) { 89 | deleteGoal(type, argv.goal); 90 | } else { 91 | menu(type); 92 | } 93 | } 94 | }; 95 | 96 | function deleteGoal(type, goal) { 97 | if (goal.indexOf("✔") >= 0) { 98 | goal = goal.substr("✔ ".length + 1); 99 | type = path.join("completed", type); 100 | findCompletedFile(type, goal); 101 | } else { 102 | fs.remove(getFileName(type, goal)).then(() => { 103 | ls("all"); 104 | write(); 105 | }); 106 | } 107 | } 108 | 109 | function findCompletedFile(type, goal) { 110 | const dir = path.join(confDir, type); 111 | return fs.ensureDir(dir).then(() => { 112 | return fs.readdir(dir).then(files => { 113 | if (files.length === 0) { 114 | fs.remove(dir).then(() => Promise.reject()); 115 | } 116 | files.map(item => { 117 | return fs.stat(path.join(dir, item)).then(stats => { 118 | if (stats.isDirectory()) { 119 | return findCompletedFile(path.join(type, item), goal); 120 | } else if (stats.isFile()) { 121 | if (prettyName(item) === prettyName(goal)) { 122 | return fs.remove(dir).then(() => { 123 | ls("all"); 124 | write(); 125 | }); 126 | } 127 | } 128 | }); 129 | }); 130 | }); 131 | }); 132 | } 133 | //# sourceMappingURL=delete.js.map 134 | -------------------------------------------------------------------------------- /lib/commands/delete.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"sources":["commands/delete.js"],"names":["type","checkConf","dir","getFileName","completedDir","path","join","fs","ensureDir","files","readdir","completedFiles","recursive","dirIsEmpty","length","completedDirIsEmpty","isEmpty","menu","Menu","bg","fg","width","reset","write","prettyName","forEach","add","item","on","close","label","deleteGoal","process","stdin","pipe","createStream","stdout","setRawMode","end","console","log","chalk","bold","red","err","error","require","confTypes","confAliases","confDir","ls","module","exports","command","aliases","desc","example","builder","yargs","default","handler","argv","includes","hasOwnProperty","goal","indexOf","substr","findCompletedFile","remove","then","Promise","reject","map","stat","stats","isDirectory","isFile"],"mappings":";+BAmDA,WAAoBA,IAApB,EAA0B;AACxBC;AACA,UAAMC,MAAMC,YAAYH,IAAZ,EAAkB,EAAlB,CAAZ;AACA,UAAMI,eAAeD,YAAYE,KAAKC,IAAL,CAAU,WAAV,EAAuBN,IAAvB,CAAZ,CAArB;AACA,UAAMO,GAAGC,SAAH,CAAaJ,YAAb,CAAN;AACA,UAAMG,GAAGC,SAAH,CAAaN,GAAb,CAAN;AACA,UAAMO,QAAQ,MAAMF,GAAGG,OAAH,CAAWR,GAAX,CAApB;AACA,UAAMS,iBAAiB,MAAMC,UAAUR,YAAV,CAA7B;AACA,UAAMS,aAAaJ,MAAMK,MAAN,KAAiB,CAApC;AACA,UAAMC,sBAAsBJ,eAAeG,MAAf,KAA0B,CAAtD;AACA,UAAME,UAAUH,cAAcE,mBAA9B;AACA,UAAME,OAAO,IAAIC,IAAJ,CAAS,EAAEC,IAAI,OAAN,EAAeC,IAAI,OAAnB,EAA4BC,OAAO,GAAnC,EAAT,CAAb;;AAEAJ,SAAKK,KAAL;AACAL,SAAKM,KAAL,CAAW,WAAWC,WAAWxB,IAAX,CAAX,GAA8B,mCAAzC;AACAiB,SAAKM,KAAL,CAAW,yCAAX;AACA,QAAI;AACF,UAAI,CAACP,OAAL,EAAc;AACZ,YAAI,CAACH,UAAL,EAAiB;AACfJ,gBAAMgB,OAAN,CAAc;AAAA,mBAAQR,KAAKS,GAAL,CAASF,WAAWG,IAAX,CAAT,CAAR;AAAA,WAAd;AACD;AACD,YAAI,CAACZ,mBAAL,EAA0B;AACxBJ,yBAAec,OAAf,CAAuB;AAAA,mBAAQR,KAAKS,GAAL,CAAS,QAAQF,WAAWG,IAAX,CAAjB,CAAR;AAAA,WAAvB;AACD;AACDV,aA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,SAAOO,GAAGC,SAAH,CAAaN,GAAb,EAAkBmE,IAAlB,CAAuB,MAAM;AAClC,WAAO9D,GAAGG,OAAH,CAAWR,GAAX,EAAgBmE,IAAhB,CAAqB5D,SAAS;AACnC,UAAIA,MAAMK,MAAN,KAAiB,CAArB,EAAwB;AACtBP,WAAG6D,MAAH,CAAUlE,GAAV,EAAemE,IAAf,CAAoB,MAAMC,QAAQC,MAAR,EAA1B;AACD;AACD9D,YAAM+D,GAAN,CAAU7C,QAAQ;AAChB,eAAOpB,GAAGkE,IAAH,CAAQpE,KAAKC,IAAL,CAAUJ,GAAV,EAAeyB,IAAf,CAAR,EAA8B0C,IAA9B,CAAmCK,SAAS;AACjD,cAAIA,MAAMC,WAAN,EAAJ,EAAyB;AACvB,mBAAOR,kBAAkB9D,KAAKC,IAAL,CAAUN,IAAV,EAAgB2B,IAAhB,CAAlB,EAAyCqC,IAAzC,CAAP;AACD,WAFD,MAEO,IAAIU,MAAME,MAAN,EAAJ,EAAoB;AACzB,gBAAIpD,WAAWG,IAAX,MAAqBH,WAAWwC,IAAX,CAAzB,EAA2C;AACzC,qBAAOzD,GAAG6D,MAAH,CAAUlE,GAAV,EAAemE,IAAf,CAAoB,MAAM;AAC/BnB,mBAAG,KAAH;AACA3B;AACD,eAHM,CAAP;AAID;AACF;AACF,SAXM,CAAP;AAYD,OAbD;AAcD,KAlBM,CAAP;AAmBD,GApBM,CAAP;AAqBD","file":"delete.js","sourcesContent":["// @flow\n\nconst path = require(\"path\");\nconst fs = require(\"fs-extra\");\nconst Menu = require(\"terminal-menu\");\nconst chalk = require(\"chalk\");\nconst recursive = require(\"recursive-readdir\");\nconst { prettyName, getFileName } = require(\"../utils/file\");\nconst { checkConf, confTypes, confAliases, confDir } = require(\"./config\");\nconst { ls } = require(\"./ls\");\nconst { write } = require(\"../utils/markdown\");\n\nmodule.exports = {\n command: \"delete [type] [goal]\",\n aliases: [\"d\", \"del\"],\n desc: \"delete a goal\",\n example: \"$0 d w \",\n builder: (yargs: { default: (string, string) => mixed }) =>\n yargs.default(\"type\", \"w\"),\n handler: (argv: { type: string, goal: string }) => {\n checkConf();\n\n let type: string;\n if (confTypes.includes(argv.type)) {\n type = argv.type;\n } else if (confAliases.hasOwnProperty(argv.type)) {\n type = confAliases[argv.type];\n } else {\n type = argv.type;\n }\n if (argv.goal) {\n deleteGoal(type, argv.goal);\n } else {\n menu(type);\n }\n }\n};\n\nfunction deleteGoal(type: string, goal: string) {\n if (goal.indexOf(\"✔\") >= 0) {\n goal = goal.substr(\"✔ \".length + 1);\n type = path.join(\"completed\", type);\n findCompletedFile(type, goal);\n } else {\n fs.remove(getFileName(type, goal)).then(() => {\n ls(\"all\");\n write();\n });\n }\n}\n\nasync function menu(type) {\n checkConf();\n const dir = getFileName(type, \"\");\n const completedDir = getFileName(path.join(\"completed\", type));\n await fs.ensureDir(completedDir);\n await fs.ensureDir(dir);\n const files = await fs.readdir(dir);\n const completedFiles = await recursive(completedDir);\n const dirIsEmpty = files.length === 0;\n const completedDirIsEmpty = completedFiles.length === 0;\n const isEmpty = dirIsEmpty && completedDirIsEmpty;\n const menu = new Menu({ bg: \"black\", fg: \"white\", width: 100 });\n\n menu.reset();\n menu.write(\"Which \" + prettyName(type) + \" Goal would you like to delete?\\n\");\n menu.write(\"-------------------------------------\\n\");\n try {\n if (!isEmpty) {\n if (!dirIsEmpty) {\n files.forEach(item => menu.add(prettyName(item)));\n }\n if (!completedDirIsEmpty) {\n completedFiles.forEach(item => menu.add(\"✔︎ \" + prettyName(item)));\n }\n menu.add(\"None\");\n\n menu.on(\"select\", label => {\n menu.close();\n if (label === \"None\") {\n return;\n }\n deleteGoal(type, label);\n });\n process.stdin.pipe(menu.createStream()).pipe(process.stdout);\n\n process.stdin.setRawMode(true);\n menu.on(\"close\", () => {\n process.stdin.setRawMode(false);\n process.stdin.end();\n });\n } else {\n console.log(\n chalk.bold(chalk.red(\"Error: \")) + \" there are no goals of type \" + type\n );\n }\n } catch (err) {\n console.error(err);\n }\n}\n\nfunction findCompletedFile(type, goal) {\n const dir = path.join(confDir, type);\n return fs.ensureDir(dir).then(() => {\n return fs.readdir(dir).then(files => {\n if (files.length === 0) {\n fs.remove(dir).then(() => Promise.reject());\n }\n files.map(item => {\n return fs.stat(path.join(dir, item)).then(stats => {\n if (stats.isDirectory()) {\n return findCompletedFile(path.join(type, item), goal);\n } else if (stats.isFile()) {\n if (prettyName(item) === prettyName(goal)) {\n return fs.remove(dir).then(() => {\n ls(\"all\");\n write();\n });\n }\n }\n });\n });\n });\n });\n}\n"]} -------------------------------------------------------------------------------- /lib/commands/ls.js: -------------------------------------------------------------------------------- 1 | let ls = (() => { 2 | var _ref = _asyncToGenerator(function* (type) { 3 | let res = ""; 4 | //check if user passed in an alias to a type 5 | if (type && typeof confAliases.type === "string") { 6 | type = confAliases[type]; 7 | } else { 8 | switch (type) { 9 | case "a": 10 | type = "all"; 11 | break; 12 | case "complete": 13 | case "c": 14 | type = "completed"; 15 | break; 16 | default: 17 | break; 18 | } 19 | } 20 | 21 | const types = confTypes; 22 | if (type === "all") { 23 | console.log("\r\n"); 24 | //list all known types 25 | types.map((() => { 26 | var _ref2 = _asyncToGenerator(function* (thisType) { 27 | yield ls(thisType); 28 | }); 29 | 30 | return function (_x2) { 31 | return _ref2.apply(this, arguments); 32 | }; 33 | })()); 34 | } else { 35 | //list specified type 36 | const title = prettyName(type) + " Tasks"; 37 | 38 | if (type.indexOf("completed") === -1) { 39 | //if user didn't already specify a completed type, also include the included goals of that type 40 | console.log(chalk.bold.underline(title) + "\n" + (yield print(type)) + "\n" + (yield print(path.join("completed", type)))); 41 | } else { 42 | console.log("\n" + chalk.bold.underline(title) + "\n" + (yield print(type))); 43 | } 44 | return; 45 | } 46 | }); 47 | 48 | return function ls(_x) { 49 | return _ref.apply(this, arguments); 50 | }; 51 | })(); 52 | 53 | let print = (() => { 54 | var _ref3 = _asyncToGenerator(function* (type, opts = {}) { 55 | const dir = getFileName(type); 56 | if (yield fs.pathExists(dir)) { 57 | try { 58 | const accomplishments = getFileName("accomplishments"); 59 | let res = ""; 60 | const files = yield fs.readdir(dir); 61 | try { 62 | if (files.length === 0) { 63 | fs.remove(dir); 64 | return ""; 65 | } 66 | const goals = yield files.map((() => { 67 | var _ref4 = _asyncToGenerator(function* (item) { 68 | const stats = yield fs.stat(path.join(dir, item)); 69 | try { 70 | if (stats.isDirectory()) { 71 | if (item.match(/\w{3}\d{9,10}/g)) { 72 | opts.date = item; 73 | } else if (!item.startsWith(".")) { 74 | return (yield chalk.underline(item)) + "\n"; 75 | } 76 | return yield print(path.join(type, item), opts); 77 | } else if (stats.isFile()) { 78 | if (typeof opts.date === "string") { 79 | return yield isCurrent(type, opts.date, dir, item, accomplishments); 80 | } else if (!item.startsWith(".")) { 81 | return (yield prettyName(item)) + "\n"; 82 | } 83 | } 84 | } catch (err) { 85 | console.log(err); 86 | return ""; 87 | } 88 | }); 89 | 90 | return function (_x4) { 91 | return _ref4.apply(this, arguments); 92 | }; 93 | })()); 94 | return Promise.all(goals).then(function (results) { 95 | return results.join(""); 96 | }); 97 | } catch (err) { 98 | console.log(err); 99 | return ""; 100 | } 101 | } catch (err) { 102 | console.error(err); 103 | } 104 | } 105 | return ""; 106 | }); 107 | 108 | return function print(_x3) { 109 | return _ref3.apply(this, arguments); 110 | }; 111 | })(); 112 | 113 | let isCurrent = (() => { 114 | var _ref5 = _asyncToGenerator(function* (type, date = "", dir, item, accomplishments) { 115 | if (type.includes("/")) { 116 | type = type.split("/").slice(-2, -1)[0]; 117 | } 118 | if (type === "weekly" && moment(date, "MMMDDYYYYHHmm").diff(moment(), "day") < -6) { 119 | fs.move(path.join(dir, item), path.join(accomplishments, type, moment().day(-6).format("MMMDDYYYY"), item)); 120 | return ""; 121 | } else if (type === "monthly" && moment(date, "MMMDDYYYYHHmm").get("month") < moment().get("month")) { 122 | fs.move(path.join(dir, item), path.join(accomplishments, type, moment().month(moment().get("m") - 1).format("MMMM-YYYY"), item)); 123 | return ""; 124 | } else if (type === "yearly" && moment(date, "MMMDDYYYYHHmm").get("year") < moment().get("year")) { 125 | fs.move(path.join(dir, item), path.join(accomplishments, type, moment().year(moment().get("y") - 1).format("YYYY"), item)); 126 | return ""; 127 | } 128 | if (!item.startsWith(".")) { 129 | return `${chalk.green(prettyName(item))} ${chalk.gray("- " + moment(date, "MMMDDYYYYHHmm").fromNow())}\n`; 130 | } 131 | return ""; 132 | }); 133 | 134 | return function isCurrent(_x5) { 135 | return _ref5.apply(this, arguments); 136 | }; 137 | })(); 138 | 139 | function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; } 140 | 141 | const path = require("path"); 142 | const moment = require("moment"); 143 | const chalk = require("chalk"); 144 | const fs = require("fs-extra"); 145 | const { prettyName, getFileName } = require("../utils/file"); 146 | const { checkConf, confTypes, confAliases } = require("./config"); 147 | const { write } = require("../utils/markdown"); 148 | 149 | module.exports = { 150 | command: { 151 | command: "ls [type]", 152 | aliases: ["list"], 153 | usage: `$0 ls `, 154 | description: `list goals of a type`, 155 | builder: yargs => yargs.default("type", "a"), 156 | handler: argv => { 157 | let type; 158 | if (confTypes.includes(argv.type)) { 159 | type = argv.type; 160 | } else if (confAliases.hasOwnProperty(argv.type)) { 161 | type = confAliases[argv.type]; 162 | } else { 163 | switch (argv.type) { 164 | case "a": 165 | type = "all"; 166 | break; 167 | case "complete": 168 | case "c": 169 | type = "completed"; 170 | break; 171 | default: 172 | type = argv.type; 173 | break; 174 | } 175 | } 176 | ls(type); 177 | write(); 178 | } 179 | }, 180 | ls 181 | }; 182 | //# sourceMappingURL=ls.js.map 183 | -------------------------------------------------------------------------------- /lib/commands/ls.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"sources":["commands/ls.js"],"names":["type","res","confAliases","types","confTypes","console","log","map","thisType","ls","title","prettyName","indexOf","chalk","bold","underline","print","path","join","opts","dir","getFileName","fs","pathExists","accomplishments","files","readdir","length","remove","goals","item","stats","stat","isDirectory","match","date","startsWith","isFile","isCurrent","err","Promise","all","then","results","error","includes","split","slice","moment","diff","move","day","format","get","month","year","green","gray","fromNow","require","checkConf","write","module","exports","command","aliases","usage","description","builder","yargs","default","handler","argv","hasOwnProperty"],"mappings":";+BA6CA,WAAkBA,IAAlB,EAA+C;AAC7C,QAAIC,MAAM,EAAV;AACA;AACA,QAAID,QAAQ,OAAOE,YAAYF,IAAnB,KAA4B,QAAxC,EAAkD;AAChDA,aAAOE,YAAYF,IAAZ,CAAP;AACD,KAFD,MAEO;AACL,cAAQA,IAAR;AACE,aAAK,GAAL;AACEA,iBAAO,KAAP;AACA;AACF,aAAK,UAAL;AACA,aAAK,GAAL;AACEA,iBAAO,WAAP;AACA;AACF;AACE;AATJ;AAWD;;AAED,UAAMG,QAAuBC,SAA7B;AACA,QAAIJ,SAAS,KAAb,EAAoB;AAClBK,cAAQC,GAAR,CAAY,MAAZ;AACA;AACAH,YAAMI,GAAN;AAAA,sCAAU,WAAMC,QAAN,EAAkB;AAC1B,gBAAMC,GAAGD,QAAH,CAAN;AACD,SAFD;;AAAA;AAAA;AAAA;AAAA;AAGD,KAND,MAMO;AACL;AACA,YAAME,QAAQC,WAAWX,IAAX,IAAmB,QAAjC;;AAEA,UAAIA,KAAKY,OAAL,CAAa,WAAb,MAA8B,CAAC,CAAnC,EAAsC;AACpC;AACAP,gBAAQC,GAAR,CACEO,MAAMC,IAAN,CAAWC,SAAX,CAAqBL,KAArB,IACE,IADF,IAEG,MAAMM,MAAMhB,IAAN,CAFT,IAGE,IAHF,IAIG,MAAMgB,MAAMC,KAAKC,IAAL,CAAU,WAAV,EAAuBlB,IAAvB,CAAN,CAJT,CADF;AAOD,OATD,MASO;AACLK,gBAAQC,GAAR,CACE,OAAOO,MAAMC,IAAN,CAAWC,SAAX,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AACA,MAAMX,SAASW,QAAQ,QAAR,CAAf;AACA,MAAM9C,QAAQ8C,QAAQ,OAAR,CAAd;AACA,MAAMrC,KAAKqC,QAAQ,UAAR,CAAX;AACA,MAAM,EAAEhD,UAAF,EAAcU,WAAd,KAA8BsC,QAAQ,eAAR,CAApC;AACA,MAAM,EAAEC,SAAF,EAAaxD,SAAb,EAAwBF,WAAxB,KAAwCyD,QAAQ,UAAR,CAA9C;AACA,MAAM,EAAEE,KAAF,KAAYF,QAAQ,mBAAR,CAAlB;;AAEAG,OAAOC,OAAP,GAAiB;AACfC,WAAS;AACPA,aAAS,WADF;AAEPC,aAAS,CAAC,MAAD,CAFF;AAGPC,WAAQ,2BAHD;AAIPC,iBAAc,sBAJP;AAKPC,aAAUC,KAAD,IACPA,MAAMC,OAAN,CAAc,MAAd,EAAsB,GAAtB,CANK;AAOPC,aAAUC,IAAD,IAA4B;AACnC,UAAIxE,IAAJ;AACA,UAAII,UAAUyC,QAAV,CAAmB2B,KAAKxE,IAAxB,CAAJ,EAAmC;AACjCA,eAAOwE,KAAKxE,IAAZ;AACD,OAFD,MAEO,IAAIE,YAAYuE,cAAZ,CAA2BD,KAAKxE,IAAhC,CAAJ,EAA2C;AAChDA,eAAOE,YAAYsE,KAAKxE,IAAjB,CAAP;AACD,OAFM,MAEA;AACL,gBAAQwE,KAAKxE,IAAb;AACE,eAAK,GAAL;AACEA,mBAAO,KAAP;AACA;AACF,eAAK,UAAL;AACA,eAAK,GAAL;AACEA,mBAAO,WAAP;AACA;AACF;AACEA,mBAAOwE,KAAKxE,IAAZ;AACA;AAVJ;AAYD;AACDS,SAAGT,IAAH;AACA6D;AACD;AA7BM,GADM;AAgCfpD;AAhCe,CAAjB","file":"ls.js","sourcesContent":["// @flow\n\nconst path = require(\"path\");\nconst moment = require(\"moment\");\nconst chalk = require(\"chalk\");\nconst fs = require(\"fs-extra\");\nconst { prettyName, getFileName } = require(\"../utils/file\");\nconst { checkConf, confTypes, confAliases } = require(\"./config\");\nconst { write } = require(\"../utils/markdown\")\n\nmodule.exports = {\n command: {\n command: \"ls [type]\",\n aliases: [\"list\"],\n usage: `$0 ls `,\n description: `list goals of a type`,\n builder: (yargs: { default: (type: string, value: string) => mixed }) =>\n yargs.default(\"type\", \"a\"),\n handler: (argv: { type: string }) => {\n let type: string;\n if (confTypes.includes(argv.type)) {\n type = argv.type;\n } else if (confAliases.hasOwnProperty(argv.type)) {\n type = confAliases[argv.type];\n } else {\n switch (argv.type) {\n case \"a\":\n type = \"all\";\n break;\n case \"complete\":\n case \"c\":\n type = \"completed\";\n break;\n default:\n type = argv.type;\n break;\n }\n }\n ls(type);\n write();\n }\n },\n ls\n};\n\nasync function ls(type: string): Promise {\n let res = \"\";\n //check if user passed in an alias to a type\n if (type && typeof confAliases.type === \"string\") {\n type = confAliases[type];\n } else {\n switch (type) {\n case \"a\":\n type = \"all\";\n break;\n case \"complete\":\n case \"c\":\n type = \"completed\";\n break;\n default:\n break;\n }\n }\n\n const types: Array = confTypes;\n if (type === \"all\") {\n console.log(\"\\r\\n\");\n //list all known types\n types.map(async thisType => {\n await ls(thisType);\n });\n } else {\n //list specified type\n const title = prettyName(type) + \" Tasks\";\n\n if (type.indexOf(\"completed\") === -1) {\n //if user didn't already specify a completed type, also include the included goals of that type\n console.log(\n chalk.bold.underline(title) +\n \"\\n\" +\n (await print(type)) +\n \"\\n\" +\n (await print(path.join(\"completed\", type)))\n );\n } else {\n console.log(\n \"\\n\" + chalk.bold.underline(title) + \"\\n\" + (await print(type))\n );\n }\n return;\n }\n}\n\nasync function print(\n type: string,\n opts?: { date?: string } = {}\n): Promise {\n const dir = getFileName(type);\n if (await fs.pathExists(dir)) {\n try {\n const accomplishments = getFileName(\"accomplishments\");\n let res = \"\";\n const files = await fs.readdir(dir);\n try {\n if (files.length === 0) {\n fs.remove(dir);\n return \"\";\n }\n const goals = await files.map(async item => {\n const stats = await fs.stat(path.join(dir, item));\n try {\n if (stats.isDirectory()) {\n if (item.match(/\\w{3}\\d{9,10}/g)) {\n opts.date = item;\n } else if (!item.startsWith(\".\")) {\n return (await chalk.underline(item)) + \"\\n\";\n }\n return await print(path.join(type, item), opts);\n } else if (stats.isFile()) {\n if (typeof opts.date === \"string\") {\n return await isCurrent(\n type,\n opts.date,\n dir,\n item,\n accomplishments\n );\n } else if (!item.startsWith(\".\")) {\n return (await prettyName(item)) + \"\\n\";\n }\n }\n } catch (err) {\n console.log(err);\n return \"\";\n }\n });\n return Promise.all(goals).then(results => results.join(\"\"));\n } catch (err) {\n console.log(err);\n return \"\";\n }\n } catch (err) {\n console.error(err);\n }\n }\n return \"\";\n}\n\nasync function isCurrent(\n type: string,\n date: string = \"\",\n dir: string,\n item: string,\n accomplishments: string\n): Promise {\n if (type.includes(\"/\")) {\n type = type.split(\"/\").slice(-2, -1)[0];\n }\n if (\n type === \"weekly\" &&\n moment(date, \"MMMDDYYYYHHmm\").diff(moment(), \"day\") < -6\n ) {\n fs.move(\n path.join(dir, item),\n path.join(\n accomplishments,\n type,\n moment()\n .day(-6)\n .format(\"MMMDDYYYY\"),\n item\n )\n );\n return \"\";\n } else if (\n type === \"monthly\" &&\n moment(date, \"MMMDDYYYYHHmm\").get(\"month\") < moment().get(\"month\")\n ) {\n fs.move(\n path.join(dir, item),\n path.join(\n accomplishments,\n type,\n moment()\n .month(moment().get(\"m\") - 1)\n .format(\"MMMM-YYYY\"),\n item\n )\n );\n return \"\";\n } else if (\n type === \"yearly\" &&\n moment(date, \"MMMDDYYYYHHmm\").get(\"year\") < moment().get(\"year\")\n ) {\n fs.move(\n path.join(dir, item),\n path.join(\n accomplishments,\n type,\n moment()\n .year(moment().get(\"y\") - 1)\n .format(\"YYYY\"),\n item\n )\n );\n return \"\";\n }\n if (!item.startsWith(\".\")) {\n return `${chalk.green(prettyName(item))} ${chalk.gray(\n \"- \" + moment(date, \"MMMDDYYYYHHmm\").fromNow()\n )}\\n`;\n }\n return \"\";\n}\n"]} -------------------------------------------------------------------------------- /lib/commands/new.js: -------------------------------------------------------------------------------- 1 | let newGoal = (() => { 2 | var _ref2 = _asyncToGenerator(function* (type, goal) { 3 | checkConf(); 4 | const date = moment().format("MMMDDYYYYHHmm"); 5 | const file = getFileName(type, goal); 6 | const filePath = getFileName(type); 7 | const completedFile = getFileName(path.join("completed", type, date), goal); 8 | fs.stat(completedFile, (() => { 9 | var _ref3 = _asyncToGenerator(function* (err, stat) { 10 | if (err == null) { 11 | //file exists 12 | console.log("Moving goal from completed to " + type); 13 | fs.rename(file, completedFile); 14 | } else if (err.code == "ENOENT") { 15 | fs.stat(file, (() => { 16 | var _ref4 = _asyncToGenerator(function* (err2, stat2) { 17 | if (err2 == null) { 18 | //file exists 19 | console.log("Goal already exists"); 20 | } else if (err2.code == "ENOENT") { 21 | fs.ensureDirSync(filePath); 22 | //file does not exist 23 | fs.close(fs.openSync(file, "w")); 24 | } 25 | }); 26 | 27 | return function (_x6, _x7) { 28 | return _ref4.apply(this, arguments); 29 | }; 30 | })()); 31 | } 32 | }); 33 | 34 | return function (_x4, _x5) { 35 | return _ref3.apply(this, arguments); 36 | }; 37 | })()); 38 | }); 39 | 40 | return function newGoal(_x2, _x3) { 41 | return _ref2.apply(this, arguments); 42 | }; 43 | })(); 44 | 45 | function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; } 46 | 47 | const path = require("path"); 48 | const moment = require("moment"); 49 | const fs = require("fs-extra"); 50 | const { getFileName } = require("../utils/file"); 51 | const { checkConf, confTypes, confAliases, confDir } = require("./config"); 52 | const { ls } = require("./ls"); 53 | const { write } = require("../utils/markdown"); 54 | 55 | module.exports = { 56 | command: "new [type] [goal]", 57 | aliases: ["n"], 58 | desc: "Set a new goal", 59 | example: "$0 n w 'work out 3 times'", 60 | handler: (() => { 61 | var _ref = _asyncToGenerator(function* (argv) { 62 | checkConf(); 63 | 64 | let type; 65 | if (confTypes.includes(argv.type)) { 66 | type = argv.type; 67 | } else if (confAliases.hasOwnProperty(argv.type)) { 68 | type = confAliases[argv.type]; 69 | } else { 70 | type = argv.type; 71 | } 72 | yield newGoal(type, argv.goal); 73 | ls("all"); 74 | write(); 75 | }); 76 | 77 | return function handler(_x) { 78 | return _ref.apply(this, arguments); 79 | }; 80 | })() 81 | }; 82 | //# sourceMappingURL=new.js.map 83 | -------------------------------------------------------------------------------- /lib/commands/new.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"sources":["commands/new.js"],"names":["type","goal","checkConf","date","moment","format","file","getFileName","filePath","completedFile","path","join","fs","stat","err","console","log","rename","code","err2","stat2","ensureDirSync","close","openSync","newGoal","require","confTypes","confAliases","confDir","ls","write","module","exports","command","aliases","desc","example","handler","argv","includes","hasOwnProperty"],"mappings":";gCAgCA,WAAuBA,IAAvB,EAA6BC,IAA7B,EAAkD;AAChDC;AACA,UAAMC,OAAOC,SAASC,MAAT,CAAgB,eAAhB,CAAb;AACA,UAAMC,OAAOC,YAAYP,IAAZ,EAAkBC,IAAlB,CAAb;AACA,UAAMO,WAAWD,YAAYP,IAAZ,CAAjB;AACA,UAAMS,gBAAgBF,YAAYG,KAAKC,IAAL,CAAU,WAAV,EAAuBX,IAAvB,EAA6BG,IAA7B,CAAZ,EAAgDF,IAAhD,CAAtB;AACAW,OAAGC,IAAH,CAAQJ,aAAR;AAAA,oCAAuB,WAAeK,GAAf,EAAoBD,IAApB,EAA0B;AAC/C,YAAIC,OAAO,IAAX,EAAiB;AACf;AACAC,kBAAQC,GAAR,CAAY,mCAAmChB,IAA/C;AACAY,aAAGK,MAAH,CAAUX,IAAV,EAAgBG,aAAhB;AACD,SAJD,MAIO,IAAIK,IAAII,IAAJ,IAAY,QAAhB,EAA0B;AAC/BN,aAAGC,IAAH,CAAQP,IAAR;AAAA,0CAAc,WAAea,IAAf,EAAqB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AAQxB,IAAR,EAAcsC,KAAKrC,IAAnB,CAAN;AACA4B,SAAG,KAAH;AACAC;AACD,KAdD;;AAAA;AAAA;AAAA;AAAA;AALe,CAAjB","file":"new.js","sourcesContent":["// @flow\n\nconst path = require(\"path\");\nconst moment = require(\"moment\");\nconst fs = require(\"fs-extra\");\nconst { getFileName } = require(\"../utils/file\");\nconst { checkConf, confTypes, confAliases, confDir } = require(\"./config\");\nconst {ls} = require(\"./ls\")\nconst { write } = require(\"../utils/markdown\");\n\nmodule.exports = {\n command: \"new [type] [goal]\",\n aliases: [\"n\"],\n desc: \"Set a new goal\",\n example: \"$0 n w 'work out 3 times'\",\n handler: async (argv: { type: string, goal: string }) => {\n checkConf();\n\n let type: string;\n if (confTypes.includes(argv.type)) {\n type = argv.type;\n } else if (confAliases.hasOwnProperty(argv.type)) {\n type = confAliases[argv.type];\n } else {\n type = argv.type;\n }\n await newGoal(type, argv.goal);\n ls(\"all\");\n write();\n }\n};\n\nasync function newGoal(type, goal): Promise {\n checkConf();\n const date = moment().format(\"MMMDDYYYYHHmm\");\n const file = getFileName(type, goal);\n const filePath = getFileName(type);\n const completedFile = getFileName(path.join(\"completed\", type, date), goal);\n fs.stat(completedFile, async function(err, stat) {\n if (err == null) {\n //file exists\n console.log(\"Moving goal from completed to \" + type);\n fs.rename(file, completedFile);\n } else if (err.code == \"ENOENT\") {\n fs.stat(file, async function(err2, stat2) {\n if (err2 == null) {\n //file exists\n console.log(\"Goal already exists\");\n } else if (err2.code == \"ENOENT\") {\n fs.ensureDirSync(filePath);\n //file does not exist\n fs.close(fs.openSync(file, \"w\"));\n }\n });\n }\n });\n}\n"]} -------------------------------------------------------------------------------- /lib/utils/file.js: -------------------------------------------------------------------------------- 1 | const path = require("path"); 2 | const { checkConf, confDir } = require("../commands/config"); 3 | 4 | module.exports = { 5 | getFileName(type, goal = "") { 6 | const dir = path.join(confDir, type); 7 | if (goal.length > 0) { 8 | return path.join(dir, goal.replace(/[ ]/g, "_").replace(/[//]/g, "-") + ".md"); 9 | } 10 | return dir; 11 | }, 12 | 13 | prettyName(file) { 14 | const goal = path.basename(file, path.extname(file)); 15 | const ret = goal.replace(/_/g, " ").replace(/(\w)(\w*)/g, (_, i, r) => { 16 | return i.toUpperCase() + (r === null ? "" : r); 17 | }); 18 | return ret; 19 | } 20 | }; 21 | //# sourceMappingURL=file.js.map 22 | -------------------------------------------------------------------------------- /lib/utils/file.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"sources":["utils/file.js"],"names":["path","require","checkConf","confDir","module","exports","getFileName","type","goal","dir","join","length","replace","prettyName","file","basename","extname","ret","_","i","r","toUpperCase"],"mappings":"AAEA,MAAMA,OAAOC,QAAQ,MAAR,CAAb;AACA,MAAM,EAAEC,SAAF,EAAaC,OAAb,KAAyBF,QAAQ,oBAAR,CAA/B;;AAEAG,OAAOC,OAAP,GAAiB;AACfC,cAAYC,IAAZ,EAA0BC,OAAgB,EAA1C,EAAsD;AACpD,UAAMC,MAAMT,KAAKU,IAAL,CAAUP,OAAV,EAAmBI,IAAnB,CAAZ;AACA,QAAIC,KAAKG,MAAL,GAAc,CAAlB,EAAqB;AACnB,aAAOX,KAAKU,IAAL,CACLD,GADK,EAELD,KAAKI,OAAL,CAAa,MAAb,EAAqB,GAArB,EAA0BA,OAA1B,CAAkC,OAAlC,EAA2C,GAA3C,IAAkD,KAF7C,CAAP;AAID;AACD,WAAOH,GAAP;AACD,GAVc;;AAYfI,aAAWC,IAAX,EAAiC;AAC/B,UAAMN,OAAOR,KAAKe,QAAL,CAAcD,IAAd,EAAoBd,KAAKgB,OAAL,CAAaF,IAAb,CAApB,CAAb;AACA,UAAMG,MAAMT,KACTI,OADS,CACD,IADC,EACK,GADL,EAETA,OAFS,CAED,YAFC,EAEa,CAACM,CAAD,EAAIC,CAAJ,EAAeC,CAAf,KAA6B;AAClD,aAAOD,EAAEE,WAAF,MAAmBD,MAAM,IAAN,GAAa,EAAb,GAAkBA,CAArC,CAAP;AACD,KAJS,CAAZ;AAKA,WAAOH,GAAP;AACD;AApBc,CAAjB","file":"file.js","sourcesContent":["// @flow\n\nconst path = require(\"path\");\nconst { checkConf, confDir } = require(\"../commands/config\");\n\nmodule.exports = {\n getFileName(type: string, goal?: string = \"\"): string {\n const dir = path.join(confDir, type);\n if (goal.length > 0) {\n return path.join(\n dir,\n goal.replace(/[ ]/g, \"_\").replace(/[//]/g, \"-\") + \".md\"\n );\n }\n return dir;\n },\n\n prettyName(file: string): string {\n const goal = path.basename(file, path.extname(file));\n const ret = goal\n .replace(/_/g, \" \")\n .replace(/(\\w)(\\w*)/g, (_, i: string, r: string) => {\n return i.toUpperCase() + (r === null ? \"\" : r);\n });\n return ret;\n }\n};\n"]} -------------------------------------------------------------------------------- /lib/utils/markdown.js: -------------------------------------------------------------------------------- 1 | const path = require("path"); 2 | const moment = require("moment"); 3 | const fs = require("fs-extra"); 4 | const { 5 | checkConf, 6 | confTypes, 7 | confTitles, 8 | confFocus, 9 | confReadme, 10 | confDir 11 | } = require("../commands/config"); 12 | const prettyName = require("./file").prettyName; 13 | 14 | const date = moment(); 15 | 16 | module.exports = { 17 | write() { 18 | checkConf(); 19 | if (fs.existsSync(path.join(confReadme, "README.md"))) { 20 | const readme = read(); 21 | fs.truncate(path.join(confReadme, "README.md"), 0, () => { 22 | fs.writeFile(path.join(confReadme, "README.md"), readme, err => { 23 | if (err) { 24 | return console.error("Error writing file: " + err); 25 | } 26 | }); 27 | }); 28 | } else { 29 | fs.truncate(path.join(confReadme, "README.md"), 0, () => { 30 | fs.writeFile(path.join(confReadme, "README.md"), generate(), err => { 31 | if (err) { 32 | return console.error("Error writing file: " + err); 33 | } 34 | }); 35 | }); 36 | } 37 | } 38 | }; 39 | 40 | function generate() { 41 | const res = ` 42 | Personal Goals 43 | ============== 44 | Personal goals made open source for accessibility across computers I use, transparency, accountability, and versioning. Learn more about it [here](http://una.im/personal-goals-guide). 45 | 46 | Generated by the [personal-goals-cli](https://github.com/kevindavus/personal-goals-cli) 47 | 48 | ${getMDTemplate("yearly")} 49 | ${getMDTemplate("weekly-focus")} 50 | ${printAll()} 51 | 52 | `; 53 | return res; 54 | } 55 | 56 | function printAll() { 57 | const types = confTypes; 58 | let res = ""; 59 | types.forEach(type => { 60 | if (type !== "yearly") { 61 | res += getMDTemplate(type) + "\n"; 62 | } 63 | }); 64 | return res; 65 | } 66 | 67 | function markdownPrint(type, opts = {}) { 68 | const dir = path.join(confDir, type); 69 | fs.ensureDirSync(dir); 70 | let res = ""; 71 | const files = fs.readdirSync(dir); 72 | if (files.length === 0) { 73 | fs.removeSync(dir); 74 | return ""; 75 | } 76 | files.forEach(item => { 77 | if (!item.startsWith(".")) { 78 | const stats = fs.statSync(path.join(dir, item)); 79 | if (stats.isDirectory()) { 80 | if (item.match(/\w{3}\d{5,6}/g)) { 81 | opts.date = item; 82 | } else { 83 | res += `\n***${item}***\n`; 84 | } 85 | res += markdownPrint(path.join(type, item), opts); 86 | } else if (stats.isFile()) { 87 | if (typeof opts.date === "string") { 88 | res += `* [x] ${prettyName(item)} - _${moment(opts.date, "MMMDDYYYYHHmm").format("MMMM Do YYYY")}_\n`; 89 | } else { 90 | res += `* [ ] ${prettyName(item)}\n`; 91 | } 92 | } 93 | } 94 | }); 95 | return res; 96 | } 97 | 98 | function read() { 99 | let readme = fs.readFileSync(path.join(confReadme, "README.md"), "utf8"); 100 | let res = ""; 101 | let startPhrase = //i; 102 | let endSearchPhrase = //i; 103 | let endMatchPhrase = //g; 104 | let idx = readme.search(startPhrase); 105 | while (idx !== -1) { 106 | const stats = readme.match(startPhrase); 107 | if (stats != null && typeof readme === "string") { 108 | res += readme.substring(0, idx); 109 | res += getMDTemplate(stats[1]); 110 | const goalEnd = readme.search(endSearchPhrase); 111 | const goalEndPhrases = readme.match(endMatchPhrase); 112 | let goalEndPhrase = ""; 113 | if (goalEndPhrases != null) { 114 | goalEndPhrase = goalEndPhrases[0]; 115 | readme = readme.substr(goalEnd + goalEndPhrase.length); 116 | idx = readme.search(//i); 117 | } else { 118 | idx = -1; 119 | } 120 | } 121 | } 122 | return res; 123 | } 124 | 125 | function getMDTemplate(type) { 126 | const weeklyFocus = confFocus.weekly; 127 | let focus = ""; 128 | if (weeklyFocus.length > 0) { 129 | focus += "### This Week's Focus: " + weeklyFocus + "\n"; 130 | } 131 | 132 | let res = ``; 133 | if (type === "weekly-focus") { 134 | res += ` 135 | 136 | ${focus} 137 | # ${date.day(1).format("MMM Do, YYYY")}`; 138 | } else { 139 | const titles = confTitles; 140 | let title = ""; 141 | if (type === "yearly") { 142 | title += "# "; 143 | } else { 144 | title += "### "; 145 | } 146 | if (typeof titles[type] === "string") { 147 | title += titles[type] + ": "; 148 | } else { 149 | title += `${prettyName(type)} Goals: `; 150 | } 151 | res += ` 152 | 153 | ${title} 154 | 155 | ${markdownPrint(type)}${markdownPrint("completed/" + type)}`; 156 | } 157 | res += ` 158 | `; 159 | 160 | return res; 161 | } 162 | //# sourceMappingURL=markdown.js.map 163 | -------------------------------------------------------------------------------- /lib/utils/markdown.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"sources":["utils/markdown.js"],"names":["path","require","moment","fs","checkConf","confTypes","confTitles","confFocus","confReadme","confDir","prettyName","date","module","exports","write","existsSync","join","readme","read","truncate","writeFile","err","console","error","generate","res","getMDTemplate","printAll","types","forEach","type","markdownPrint","opts","dir","ensureDirSync","files","readdirSync","length","removeSync","item","startsWith","stats","statSync","isDirectory","match","isFile","format","readFileSync","startPhrase","endSearchPhrase","endMatchPhrase","idx","search","substring","goalEnd","goalEndPhrases","goalEndPhrase","substr","weeklyFocus","weekly","focus","day","titles","title"],"mappings":"AAEA,MAAMA,OAAOC,QAAQ,MAAR,CAAb;AACA,MAAMC,SAASD,QAAQ,QAAR,CAAf;AACA,MAAME,KAAKF,QAAQ,UAAR,CAAX;AACA,MAAM;AACJG,WADI;AAEJC,WAFI;AAGJC,YAHI;AAIJC,WAJI;AAKJC,YALI;AAMJC;AANI,IAOFR,QAAQ,oBAAR,CAPJ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O,cAAaK,IAAK,WAA7B;AACA,MAAIA,SAAS,cAAb,EAA6B;AAC3BL,WAAQ;;EAEVmC,KAAM;IACJjD,KAAKkD,GAAL,CAAS,CAAT,EAAYf,MAAZ,CAAmB,cAAnB,CAAmC,EAHnC;AAID,GALD,MAKO;AACL,UAAMgB,SAASxD,UAAf;AACA,QAAIyD,QAAQ,EAAZ;AACA,QAAIjC,SAAS,QAAb,EAAuB;AACrBiC,eAAS,IAAT;AACD,KAFD,MAEO;AACLA,eAAS,MAAT;AACD;AACD,QAAI,OAAOD,OAAOhC,IAAP,CAAP,KAAwB,QAA5B,EAAsC;AACpCiC,eAASD,OAAOhC,IAAP,IAAe,IAAxB;AACD,KAFD,MAEO;AACLiC,eAAU,GAAErD,WAAWoB,IAAX,CAAiB,UAA7B;AACD;AACDL,WAAQ;;EAEVsC,KAAM;;EAENhC,cAAcD,IAAd,CAAoB,GAAEC,cAAc,eAAeD,IAA7B,CAAmC,EAJvD;AAKD;AACDL,SAAQ;aACGK,IAAK,SADhB;;AAGA,SAAOL,GAAP;AACD","file":"markdown.js","sourcesContent":["// @flow\n\nconst path = require(\"path\");\nconst moment = require(\"moment\");\nconst fs = require(\"fs-extra\");\nconst {\n checkConf,\n confTypes,\n confTitles,\n confFocus,\n confReadme,\n confDir\n} = require(\"../commands/config\");\nconst prettyName = require(\"./file\").prettyName;\n\nconst date = moment();\n\nmodule.exports = {\n write(): void {\n checkConf();\n if (fs.existsSync(path.join(confReadme, \"README.md\"))) {\n const readme = read();\n fs.truncate(path.join(confReadme, \"README.md\"), 0, () => {\n fs.writeFile(path.join(confReadme, \"README.md\"), readme, err => {\n if (err) {\n return console.error(\"Error writing file: \" + err);\n }\n });\n });\n } else {\n fs.truncate(path.join(confReadme, \"README.md\"), 0, () => {\n fs.writeFile(path.join(confReadme, \"README.md\"), generate(), err => {\n if (err) {\n return console.error(\"Error writing file: \" + err);\n }\n });\n });\n }\n }\n};\n\nfunction generate(): string {\n const res = `\nPersonal Goals\n==============\nPersonal goals made open source for accessibility across computers I use, transparency, accountability, and versioning. Learn more about it [here](http://una.im/personal-goals-guide).\n\nGenerated by the [personal-goals-cli](https://github.com/kevindavus/personal-goals-cli)\n\n${getMDTemplate(\"yearly\")}\n${getMDTemplate(\"weekly-focus\")}\n${printAll()}\n\n`;\n return res;\n}\n\nfunction printAll(): string {\n const types = confTypes;\n let res = \"\";\n types.forEach(type => {\n if (type !== \"yearly\") {\n res += getMDTemplate(type) + \"\\n\";\n }\n });\n return res;\n}\n\nfunction markdownPrint(type, opts = {}): string {\n const dir = path.join(confDir, type);\n fs.ensureDirSync(dir);\n let res = \"\";\n const files = fs.readdirSync(dir);\n if (files.length === 0) {\n fs.removeSync(dir);\n return \"\";\n }\n files.forEach(item => {\n if (!item.startsWith(\".\")) {\n const stats = fs.statSync(path.join(dir, item));\n if (stats.isDirectory()) {\n if (item.match(/\\w{3}\\d{5,6}/g)) {\n opts.date = item;\n } else {\n res += `\\n***${item}***\\n`;\n }\n res += markdownPrint(path.join(type, item), opts);\n } else if (stats.isFile()) {\n if (typeof opts.date === \"string\") {\n res += `* [x] ${prettyName(item)} - _${moment(\n opts.date,\n \"MMMDDYYYYHHmm\"\n ).format(\"MMMM Do YYYY\")}_\\n`;\n } else {\n res += `* [ ] ${prettyName(item)}\\n`;\n }\n }\n }\n });\n return res;\n}\n\nfunction read(): string {\n let readme = fs.readFileSync(path.join(confReadme, \"README.md\"), \"utf8\");\n let res = \"\";\n let startPhrase = //i;\n let endSearchPhrase = //i;\n let endMatchPhrase = //g;\n let idx = readme.search(startPhrase);\n while (idx !== -1) {\n const stats = readme.match(startPhrase);\n if (stats != null && typeof readme === \"string\") {\n res += readme.substring(0, idx);\n res += getMDTemplate(stats[1]);\n const goalEnd = readme.search(endSearchPhrase);\n const goalEndPhrases: ?Array = readme.match(endMatchPhrase);\n let goalEndPhrase = \"\";\n if (goalEndPhrases != null) {\n goalEndPhrase = goalEndPhrases[0];\n readme = readme.substr(goalEnd + goalEndPhrase.length);\n idx = readme.search(//i);\n } else {\n idx = -1;\n }\n }\n }\n return res;\n}\n\nfunction getMDTemplate(type): string {\n const weeklyFocus = confFocus.weekly;\n let focus = \"\";\n if (weeklyFocus.length > 0) {\n focus += \"### This Week's Focus: \" + weeklyFocus + \"\\n\";\n }\n\n let res = ``;\n if (type === \"weekly-focus\") {\n res += `\n\n${focus}\n# ${date.day(1).format(\"MMM Do, YYYY\")}`;\n } else {\n const titles = confTitles;\n let title = \"\";\n if (type === \"yearly\") {\n title += \"# \";\n } else {\n title += \"### \";\n }\n if (typeof titles[type] === \"string\") {\n title += titles[type] + \": \";\n } else {\n title += `${prettyName(type)} Goals: `;\n }\n res += `\n\n${title}\n \n${markdownPrint(type)}${markdownPrint(\"completed/\" + type)}`;\n }\n res += `\n`;\n\n return res;\n}\n"]} -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "personal-goals-cli", 3 | "version": "2.1.4", 4 | "description": "cli for managing personal goals", 5 | "main": "./lib/cli.js", 6 | "scripts": { 7 | "lint": "xo --fix", 8 | "watch": "gulp watch", 9 | "babel": "gulp scripts" 10 | }, 11 | "repository": { 12 | "type": "git", 13 | "url": "git+https://github.com/kevindavus/personal-goals-cli.git" 14 | }, 15 | "keywords": [ 16 | "cli", 17 | "goals" 18 | ], 19 | "xo": { 20 | "ignores": [ 21 | "test/**" 22 | ], 23 | "extends": "prettier" 24 | }, 25 | "bin": { 26 | "goals": "./lib/cli.js" 27 | }, 28 | "author": "kevindavus", 29 | "license": "MIT", 30 | "bugs": { 31 | "url": "https://github.com/kevindavus/personal-goals-cli/issues" 32 | }, 33 | "homepage": "https://github.com/kevindavus/personal-goals-cli#readme", 34 | "dependencies": { 35 | "chalk": "^2.1.0", 36 | "configstore": "^3.1.1", 37 | "fs-extra": "^4.0.1", 38 | "global": "^4.3.2", 39 | "moment": "^2.18.1", 40 | "recursive-readdir": "^2.2.1", 41 | "terminal-menu": "^2.1.1", 42 | "yargs": "^7.0.0" 43 | }, 44 | "devDependencies": { 45 | "babel-plugin-sitrep": "^1.2.3", 46 | "babel-plugin-transform-async-to-generator": "^6.24.1", 47 | "babel-plugin-transform-flow-strip-types": "6.21.0", 48 | "babel-polyfill": "^6.20.0", 49 | "babel-preset-env": "^1.6.0", 50 | "babel-preset-flow": "^6.23.0", 51 | "babel-preset-latest": "6.16.0", 52 | "eslint": "^4.5.0", 53 | "eslint-config-prettier": "^2.4.0", 54 | "eslint-plugin-prettier": "^2.2.0", 55 | "flow-bin": "^0.55.0", 56 | "gulp": "^3.9.1", 57 | "gulp-babel": "6.1.2", 58 | "gulp-flowtype": "1.0.0", 59 | "gulp-sourcemaps": "1.9.1", 60 | "prettier": "^1.6.1", 61 | "xo": "^0.18.2" 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/cli.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | //@flow 3 | "use strict"; 4 | 5 | const yargs = require("yargs"); 6 | const config = require("./commands/config").command; 7 | const clear = require("./commands/clear"); 8 | const ls = require("./commands/ls").command; 9 | const complete = require("./commands/complete"); 10 | const newCommand = require("./commands/new"); 11 | const deleteCommand = require("./commands/delete"); 12 | 13 | yargs // eslint-disable-line no-unused-expressions 14 | .command(newCommand) 15 | .command(complete) 16 | .command(ls) 17 | .command(clear) 18 | .command(config) 19 | .command(deleteCommand) 20 | .group("weekly (w)", "Types") 21 | .group("monthly (m)", "Types") 22 | .group("other (o)", "Types") 23 | .group("completed (c)", "Types") 24 | .group("all (a)", "Types") 25 | .example("ls", "$0 ls") 26 | .example("ls", "$0 ls complete") 27 | .example("ls", "$0 list all") 28 | .example("new", `$0 new w 'work out 3 times' `) 29 | .example("new", `$0 n m 'lose 5 pounds'`) 30 | .example("complete", "$0 c other") 31 | .example("complete", `$0 complete week 'work out 3 times'`) 32 | .example("config", "$0 cfg dir '/user/me/projects/personal-goals'") 33 | .example("config", `$0 config focus weekly 'get outside more'`) 34 | .example("config", `$0 config type 'today'`) 35 | .example("config", `$0 cfg alias t today`) 36 | .example("config", `$0 conf title t 'All the things I want to do today'`) 37 | .example("config", `$0 cfg ls`) 38 | .example("clear", "$0 clear all") 39 | .example("clear", `$0 clear weekly`) 40 | .wrap(null) 41 | .help().argv; 42 | 43 | if (yargs.argv._.length === 0) { 44 | yargs.showHelp(); 45 | } 46 | 47 | -------------------------------------------------------------------------------- /src/commands/clear.js: -------------------------------------------------------------------------------- 1 | //@flow 2 | const path = require("path"); 3 | const fs = require("fs-extra"); 4 | const { checkConf, confTypes, confAliases, confDir } = require("./config"); 5 | const {ls} = require("./ls") 6 | const { write } = require("../utils/markdown"); 7 | 8 | module.exports = { 9 | command: "clear [type]", 10 | aliases: ["clr"], 11 | usage: `$0 clear `, 12 | description: `clear goals of a type`, 13 | builder: (yargs: { default: (string, string) => mixed }) => 14 | yargs.default("type", "a"), 15 | handler: (argv: { type: string }) => { 16 | checkConf(); 17 | 18 | let type: string; 19 | if (confTypes.includes(argv.type)) { 20 | type = argv.type; 21 | } else if (typeof confAliases[argv.type] === "string") { 22 | type = confAliases[argv.type]; 23 | } else { 24 | switch (argv.type) { 25 | case "a": 26 | type = "all"; 27 | break; 28 | case "complete": 29 | case "c": 30 | type = "completed"; 31 | break; 32 | default: 33 | type = argv.type; 34 | break; 35 | } 36 | } 37 | clear(type); 38 | } 39 | }; 40 | 41 | function clear(type: string) { 42 | if (type === "all") { 43 | fs.remove(path.join(confDir)).then(() => { 44 | ls("all"); 45 | write() 46 | }) 47 | } else { 48 | fs.remove(path.join(confDir, type)).then(() => { 49 | ls("all"); 50 | write() 51 | }); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/commands/complete.js: -------------------------------------------------------------------------------- 1 | // @flow 2 | 3 | const path = require("path"); 4 | const fs = require("fs-extra"); 5 | const Menu = require("terminal-menu"); 6 | const moment = require("moment"); 7 | const { prettyName, getFileName } = require("../utils/file"); 8 | const { checkConf, confTypes, confAliases, confDir } = require("./config"); 9 | const { ls } = require("./ls"); 10 | const { write } = require("../utils/markdown"); 11 | 12 | module.exports = { 13 | command: "complete [type] [goal]", 14 | aliases: ["c"], 15 | desc: "mark a goal as completed", 16 | example: "$0 c w ", 17 | builder: (yargs: { default: (string, string) => mixed }) => 18 | yargs.default("type", "w"), 19 | handler: (argv: { type: string, goal: string }) => { 20 | checkConf(); 21 | 22 | let type: string; 23 | if (confTypes.includes(argv.type)) { 24 | type = argv.type; 25 | } else if (confAliases.hasOwnProperty(argv.type)) { 26 | type = confAliases[argv.type]; 27 | } else { 28 | type = argv.type; 29 | } 30 | if (argv.goal) { 31 | completeGoal(type, argv.goal); 32 | } else { 33 | menu(type); 34 | } 35 | } 36 | }; 37 | 38 | function completeGoal(type: string, goal: string): void { 39 | const date = moment().format("MMMDDYYYYHHmm"); 40 | const dir = path.join(confDir, "completed", type, date); 41 | 42 | fs 43 | .move( 44 | getFileName(type, goal), 45 | getFileName(path.join("completed", type, date), goal) 46 | ) 47 | .then(() => { 48 | ls("all") 49 | write(); 50 | }); 51 | } 52 | 53 | async function menu(type: string): Promise { 54 | checkConf(); 55 | const dir = getFileName(type, ""); 56 | await fs.ensureDir(dir); 57 | const files = await fs.readdir(dir); 58 | try { 59 | const menu = new Menu({ bg: "black", fg: "white", width: 100 }); 60 | 61 | menu.reset(); 62 | menu.write("Which " + prettyName(type) + " Goal Did You Complete?\n"); 63 | menu.write("-------------------------------------\n"); 64 | files.map((item: string) => { 65 | if (!item.startsWith(".")) { 66 | menu.add(prettyName(item)); 67 | } 68 | }); 69 | menu.add("None"); 70 | 71 | menu.on("select", (label: string) => { 72 | menu.close(); 73 | if (label === "None") { 74 | return; 75 | } 76 | completeGoal(type, label); 77 | }); 78 | process.stdin.pipe(menu.createStream()).pipe(process.stdout); 79 | 80 | process.stdin.setRawMode(true); 81 | menu.on("close", () => { 82 | process.stdin.setRawMode(false); 83 | process.stdin.end(); 84 | }); 85 | } catch (err) { 86 | console.error(err); 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /src/commands/config.js: -------------------------------------------------------------------------------- 1 | // @flow 2 | 3 | const path = require("path"); 4 | const fs = require("fs-extra"); 5 | const Configstore = require("configstore"); 6 | const moment = require("moment"); 7 | 8 | const date: moment$Moment = moment(); 9 | const defaultConf: { 10 | alias: { 11 | m?: string, 12 | month?: string, 13 | o?: string, 14 | w?: string, 15 | week?: string, 16 | y?: string, 17 | year?: string 18 | }, 19 | dir?: string, 20 | focus?: { weekly: string }, 21 | readme?: string, 22 | title?: { 23 | monthly?: string, 24 | today?: string, 25 | tomorrow?: string, 26 | weekly?: string, 27 | yearly?: string 28 | }, 29 | types: [string, string, string, string] 30 | } = { 31 | dir: path.join(path.resolve(), "goals"), 32 | readme: path.resolve(), 33 | types: ["yearly", "weekly", "monthly", "other"], 34 | focus: { 35 | weekly: "Be Awesome." 36 | }, 37 | alias: { 38 | w: "weekly", 39 | week: "weekly", 40 | m: "monthly", 41 | month: "monthly", 42 | y: "yearly", 43 | year: "yearly", 44 | o: "other" 45 | }, 46 | title: { 47 | weekly: `Things I'll Do This Week`, 48 | monthly: `Things I'll Do This Month (${date.format("MMMM YYYY")}) `, 49 | yearly: `Overarching Goals`, 50 | today: ` Goals for ${date.format("dddd, MMMM Do YYYY")}`, 51 | tomorrow: `Goals for ${date.add(1, "d").format("dddd, MMMM Do YYYY")}` 52 | } 53 | }; 54 | const conf: Configstore = new Configstore("personal-goals-cli", defaultConf); 55 | const chalk = require("chalk"); 56 | 57 | const confFocus: { weekly: string } = conf.get("focus"); 58 | const confAliases: { 59 | w: string, 60 | o: string, 61 | m: string, 62 | y: string, 63 | week: string, 64 | month: string, 65 | year: string 66 | } = conf.get("alias"); 67 | const confTitles: { 68 | weekly: string, 69 | monthly: string, 70 | yearly: string, 71 | other: string, 72 | today: string, 73 | tomorrow: string 74 | } = conf.get("title"); 75 | const confTypes: Array = conf.get("types"); 76 | const confDir: string = conf.get("dir"); 77 | const confReadme: string = conf.get("readme"); 78 | 79 | module.exports = { 80 | confFocus, 81 | confTypes, 82 | confTitles, 83 | confAliases, 84 | confDir, 85 | confReadme, 86 | command: { 87 | command: "config [value] [detail]", 88 | aliases: ["cfg", "conf"], 89 | usage: "$0 config [value]", 90 | description: "Set up the personal goals configuration", 91 | examples: [ 92 | "$0 cfg dir '/user/me/projects/personal-goals'", 93 | "$0 config weeklyfocus 'get outside more'" 94 | ], 95 | handler: (argv: { key: string, value: string, detail: string }) => { 96 | let completedTask = false; 97 | completedTask = completedTask || maybeClear(argv); 98 | completedTask = completedTask || maybeList(argv); 99 | completedTask = completedTask || maybeAddType(argv); 100 | completedTask = completedTask || maybeAddFocus(argv); 101 | completedTask = completedTask || maybeAddAlias(argv); 102 | completedTask = completedTask || maybeAddTitle(argv); 103 | if (!completedTask) { 104 | conf.set(argv.key, argv.value); 105 | console.log(chalk.green("Successfully updated green: ")); 106 | console.log(chalk.bold(argv.key), ":", conf.get(argv.key)); 107 | } 108 | } 109 | }, 110 | 111 | checkConf, 112 | 113 | conf 114 | }; 115 | 116 | const maybeClear = argv => { 117 | if ( 118 | argv.value === "clear" || 119 | argv.value === "clr" || 120 | argv.value === "del" || 121 | argv.value === "delete" 122 | ) { 123 | const value: string = argv.key; 124 | const key: string = argv.value; 125 | argv.value = value; 126 | argv.key = key; 127 | clearConf(argv); 128 | } else if ( 129 | argv.key === "clear" || 130 | argv.key === "clr" || 131 | argv.key === "del" || 132 | argv.key === "delete" 133 | ) { 134 | clearConf(argv); 135 | return true; 136 | } 137 | }; 138 | 139 | const maybeList = argv => { 140 | if (argv.key === "ls" || argv.key === "get") { 141 | console.log(conf.all); 142 | return true; 143 | } 144 | }; 145 | 146 | const maybeAddType = argv => { 147 | if (argv.key === "type" || argv.key === "types") { 148 | if (confTypes.includes(argv.value)) { 149 | console.log( 150 | chalk.red("Error adding new type: "), 151 | chalk.bold(argv.value), 152 | " already exists as a type" 153 | ); 154 | } else if (typeof confAliases[argv.value] === "string") { 155 | console.log( 156 | chalk.red("Error adding new type: "), 157 | chalk.bold(argv.value), 158 | " already exists as an alias to ", 159 | chalk.bold(confAliases[argv.value]) 160 | ); 161 | } else { 162 | confTypes.push(argv.value); 163 | conf.set("types", confTypes); 164 | console.log(confTypes); 165 | return true; 166 | } 167 | } 168 | }; 169 | 170 | const maybeAddFocus = argv => { 171 | if (argv.key === "focus" || argv.key === "focuses" || argv.key === "foci") { 172 | if (confTypes.includes(argv.value)) { 173 | confFocus[argv.value] = argv.detail; 174 | conf.set("focus", confFocus); 175 | } else if (typeof confAliases[argv.value] === "string") { 176 | confFocus[confAliases[argv.value]] = argv.detail; 177 | conf.set("focus", confFocus); 178 | console.log(confFocus); 179 | return true; 180 | } 181 | } 182 | }; 183 | 184 | const maybeAddAlias = argv => { 185 | if (argv.key === "alias" || argv.key === "aliases") { 186 | if (confTypes.includes(argv.value)) { 187 | console.log( 188 | chalk.red("Error adding new alias: "), 189 | chalk.bold(argv.value), 190 | " already exists as a type" 191 | ); 192 | } else if (typeof confAliases[argv.value] === "string") { 193 | console.log( 194 | chalk.red("Error adding new alias: "), 195 | chalk.bold(argv.value), 196 | " already exists as an alias to ", 197 | chalk.bold(confAliases[argv.value]) 198 | ); 199 | } else { 200 | confAliases[argv.value] = argv.detail; 201 | conf.set("alias", confAliases); 202 | console.log(confAliases); 203 | return true; 204 | } 205 | } 206 | }; 207 | 208 | const maybeAddTitle = argv => { 209 | if (argv.key === "title" || argv.key === "titles") { 210 | if (confTypes.includes(argv.value)) { 211 | confTitles[argv.value] = argv.detail; 212 | conf.set("titles", confTitles); 213 | } else if (typeof confAliases[argv.value] === "string") { 214 | confTitles[confAliases[argv.value]] = argv.detail; 215 | conf.set("title", confTitles); 216 | console.log(confTitles); 217 | return true; 218 | } 219 | } 220 | }; 221 | 222 | function clearConf(argv: { detail: string, key: string, value: string }): void { 223 | if (typeof argv.value === "string") { 224 | if (typeof argv.detail === "string") { 225 | switch (argv.value) { 226 | case "focus": 227 | case "focuses": 228 | if (confTypes.includes(argv.detail)) { 229 | delete confFocus[argv.detail]; 230 | conf.set("focus", confFocus); 231 | console.log(confFocus); 232 | } else if (typeof confAliases[argv.detail] === "string") { 233 | delete confFocus[argv.detail]; 234 | conf.set("focus", confFocus); 235 | console.log(confFocus); 236 | } else { 237 | console.log( 238 | chalk.red( 239 | "Error deleting " + chalk.bold(argv.detail) + " confFocus :" 240 | ), 241 | chalk.bold(argv.detail), 242 | " not found as type or alias" 243 | ); 244 | } 245 | break; 246 | case "title": 247 | case "titles": 248 | if (confTypes.includes(argv.detail)) { 249 | delete confTitles[argv.detail]; 250 | conf.set("title", confTitles); 251 | console.log(confTitles); 252 | } else if (typeof confAliases[argv.detail] === "string") { 253 | delete confTitles[argv.detail]; 254 | conf.set("title", confTitles); 255 | console.log(confTitles); 256 | } else { 257 | console.log( 258 | chalk.red( 259 | "Error deleting " + chalk.bold(argv.detail) + " title :" 260 | ), 261 | chalk.bold(argv.detail), 262 | " not found as type or alias" 263 | ); 264 | } 265 | break; 266 | case "alias": 267 | case "confAliases": 268 | if (typeof confAliases[argv.detail] === "string") { 269 | delete confAliases[argv.detail]; 270 | conf.set("alias", confAliases); 271 | console.log(confAliases); 272 | } else { 273 | console.log( 274 | chalk.red( 275 | "Error deleting " + chalk.bold(argv.detail) + " confFocus :" 276 | ), 277 | chalk.bold(argv.detail), 278 | " not found as alias" 279 | ); 280 | } 281 | break; 282 | case "types": 283 | case "type": 284 | if (confTypes.includes(argv.detail)) { 285 | Object.keys(confAliases).forEach((key: string) => { 286 | if (confAliases[key] === argv.detail) { 287 | delete confAliases[key]; 288 | } 289 | }); 290 | confTypes.splice(confTypes.indexOf(argv.detail), 1); 291 | conf.set("types", confTypes); 292 | conf.set("alias", confAliases); 293 | console.log(conf.all); 294 | } else if (typeof confAliases[argv.detail] === "string") { 295 | const type: string = confAliases[argv.detail]; 296 | Object.keys(confAliases).forEach((key: string) => { 297 | if (confAliases[key] === type) { 298 | delete confAliases[key]; 299 | } 300 | }); 301 | confTypes.splice(confTypes.indexOf(type), 1); 302 | conf.set("types", confTypes); 303 | conf.set("alias", confAliases); 304 | console.log(conf.all); 305 | } else { 306 | console.log( 307 | chalk.red( 308 | "Error deleting " + chalk.bold(argv.detail) + " type :" 309 | ), 310 | chalk.bold(argv.detail), 311 | " type not found" 312 | ); 313 | } 314 | break; 315 | default: 316 | break; 317 | } 318 | } else { 319 | conf.delete(argv.value); 320 | console.log(conf.all); 321 | } 322 | } else { 323 | conf.clear(); 324 | conf.set(defaultConf); 325 | console.log(conf.all); 326 | } 327 | } 328 | 329 | function checkConf(): void { 330 | if (confTitles.monthly.startsWith("Things I'll Do This Month (")) { 331 | confTitles.monthly = `Things I'll Do This Month (${date.format("MMMM YYYY")}) `; 332 | conf.set("title", confTitles); 333 | } 334 | if (!fs.pathExistsSync(confDir)) { 335 | console.log("setting working directory to ", path.resolve()); 336 | conf.set("dir", path.resolve("goals")); 337 | conf.set("readme", path.resolve()); 338 | } 339 | } 340 | -------------------------------------------------------------------------------- /src/commands/delete.js: -------------------------------------------------------------------------------- 1 | // @flow 2 | 3 | const path = require("path"); 4 | const fs = require("fs-extra"); 5 | const Menu = require("terminal-menu"); 6 | const chalk = require("chalk"); 7 | const recursive = require("recursive-readdir"); 8 | const { prettyName, getFileName } = require("../utils/file"); 9 | const { checkConf, confTypes, confAliases, confDir } = require("./config"); 10 | const { ls } = require("./ls"); 11 | const { write } = require("../utils/markdown"); 12 | 13 | module.exports = { 14 | command: "delete [type] [goal]", 15 | aliases: ["d", "del"], 16 | desc: "delete a goal", 17 | example: "$0 d w ", 18 | builder: (yargs: { default: (string, string) => mixed }) => 19 | yargs.default("type", "w"), 20 | handler: (argv: { type: string, goal: string }) => { 21 | checkConf(); 22 | 23 | let type: string; 24 | if (confTypes.includes(argv.type)) { 25 | type = argv.type; 26 | } else if (confAliases.hasOwnProperty(argv.type)) { 27 | type = confAliases[argv.type]; 28 | } else { 29 | type = argv.type; 30 | } 31 | if (argv.goal) { 32 | deleteGoal(type, argv.goal); 33 | } else { 34 | menu(type); 35 | } 36 | } 37 | }; 38 | 39 | function deleteGoal(type: string, goal: string) { 40 | if (goal.indexOf("✔") >= 0) { 41 | goal = goal.substr("✔ ".length + 1); 42 | type = path.join("completed", type); 43 | findCompletedFile(type, goal); 44 | } else { 45 | fs.remove(getFileName(type, goal)).then(() => { 46 | ls("all"); 47 | write(); 48 | }); 49 | } 50 | } 51 | 52 | async function menu(type) { 53 | checkConf(); 54 | const dir = getFileName(type, ""); 55 | const completedDir = getFileName(path.join("completed", type)); 56 | await fs.ensureDir(completedDir); 57 | await fs.ensureDir(dir); 58 | const files = await fs.readdir(dir); 59 | const completedFiles = await recursive(completedDir); 60 | const dirIsEmpty = files.length === 0; 61 | const completedDirIsEmpty = completedFiles.length === 0; 62 | const isEmpty = dirIsEmpty && completedDirIsEmpty; 63 | const menu = new Menu({ bg: "black", fg: "white", width: 100 }); 64 | 65 | menu.reset(); 66 | menu.write("Which " + prettyName(type) + " Goal would you like to delete?\n"); 67 | menu.write("-------------------------------------\n"); 68 | try { 69 | if (!isEmpty) { 70 | if (!dirIsEmpty) { 71 | files.forEach(item => menu.add(prettyName(item))); 72 | } 73 | if (!completedDirIsEmpty) { 74 | completedFiles.forEach(item => menu.add("✔︎ " + prettyName(item))); 75 | } 76 | menu.add("None"); 77 | 78 | menu.on("select", label => { 79 | menu.close(); 80 | if (label === "None") { 81 | return; 82 | } 83 | deleteGoal(type, label); 84 | }); 85 | process.stdin.pipe(menu.createStream()).pipe(process.stdout); 86 | 87 | process.stdin.setRawMode(true); 88 | menu.on("close", () => { 89 | process.stdin.setRawMode(false); 90 | process.stdin.end(); 91 | }); 92 | } else { 93 | console.log( 94 | chalk.bold(chalk.red("Error: ")) + " there are no goals of type " + type 95 | ); 96 | } 97 | } catch (err) { 98 | console.error(err); 99 | } 100 | } 101 | 102 | function findCompletedFile(type, goal) { 103 | const dir = path.join(confDir, type); 104 | return fs.ensureDir(dir).then(() => { 105 | return fs.readdir(dir).then(files => { 106 | if (files.length === 0) { 107 | fs.remove(dir).then(() => Promise.reject()); 108 | } 109 | files.map(item => { 110 | return fs.stat(path.join(dir, item)).then(stats => { 111 | if (stats.isDirectory()) { 112 | return findCompletedFile(path.join(type, item), goal); 113 | } else if (stats.isFile()) { 114 | if (prettyName(item) === prettyName(goal)) { 115 | return fs.remove(dir).then(() => { 116 | ls("all"); 117 | write(); 118 | }); 119 | } 120 | } 121 | }); 122 | }); 123 | }); 124 | }); 125 | } 126 | -------------------------------------------------------------------------------- /src/commands/ls.js: -------------------------------------------------------------------------------- 1 | // @flow 2 | 3 | const path = require("path"); 4 | const moment = require("moment"); 5 | const chalk = require("chalk"); 6 | const fs = require("fs-extra"); 7 | const { prettyName, getFileName } = require("../utils/file"); 8 | const { checkConf, confTypes, confAliases } = require("./config"); 9 | const { write } = require("../utils/markdown") 10 | 11 | module.exports = { 12 | command: { 13 | command: "ls [type]", 14 | aliases: ["list"], 15 | usage: `$0 ls `, 16 | description: `list goals of a type`, 17 | builder: (yargs: { default: (type: string, value: string) => mixed }) => 18 | yargs.default("type", "a"), 19 | handler: (argv: { type: string }) => { 20 | let type: string; 21 | if (confTypes.includes(argv.type)) { 22 | type = argv.type; 23 | } else if (confAliases.hasOwnProperty(argv.type)) { 24 | type = confAliases[argv.type]; 25 | } else { 26 | switch (argv.type) { 27 | case "a": 28 | type = "all"; 29 | break; 30 | case "complete": 31 | case "c": 32 | type = "completed"; 33 | break; 34 | default: 35 | type = argv.type; 36 | break; 37 | } 38 | } 39 | ls(type); 40 | write(); 41 | } 42 | }, 43 | ls 44 | }; 45 | 46 | async function ls(type: string): Promise { 47 | let res = ""; 48 | //check if user passed in an alias to a type 49 | if (type && typeof confAliases.type === "string") { 50 | type = confAliases[type]; 51 | } else { 52 | switch (type) { 53 | case "a": 54 | type = "all"; 55 | break; 56 | case "complete": 57 | case "c": 58 | type = "completed"; 59 | break; 60 | default: 61 | break; 62 | } 63 | } 64 | 65 | const types: Array = confTypes; 66 | if (type === "all") { 67 | console.log("\r\n"); 68 | //list all known types 69 | types.map(async thisType => { 70 | await ls(thisType); 71 | }); 72 | } else { 73 | //list specified type 74 | const title = prettyName(type) + " Tasks"; 75 | 76 | if (type.indexOf("completed") === -1) { 77 | //if user didn't already specify a completed type, also include the included goals of that type 78 | console.log( 79 | chalk.bold.underline(title) + 80 | "\n" + 81 | (await print(type)) + 82 | "\n" + 83 | (await print(path.join("completed", type))) 84 | ); 85 | } else { 86 | console.log( 87 | "\n" + chalk.bold.underline(title) + "\n" + (await print(type)) 88 | ); 89 | } 90 | return; 91 | } 92 | } 93 | 94 | async function print( 95 | type: string, 96 | opts?: { date?: string } = {} 97 | ): Promise { 98 | const dir = getFileName(type); 99 | if (await fs.pathExists(dir)) { 100 | try { 101 | const accomplishments = getFileName("accomplishments"); 102 | let res = ""; 103 | const files = await fs.readdir(dir); 104 | try { 105 | if (files.length === 0) { 106 | fs.remove(dir); 107 | return ""; 108 | } 109 | const goals = await files.map(async item => { 110 | const stats = await fs.stat(path.join(dir, item)); 111 | try { 112 | if (stats.isDirectory()) { 113 | if (item.match(/\w{3}\d{9,10}/g)) { 114 | opts.date = item; 115 | } else if (!item.startsWith(".")) { 116 | return (await chalk.underline(item)) + "\n"; 117 | } 118 | return await print(path.join(type, item), opts); 119 | } else if (stats.isFile()) { 120 | if (typeof opts.date === "string") { 121 | return await isCurrent( 122 | type, 123 | opts.date, 124 | dir, 125 | item, 126 | accomplishments 127 | ); 128 | } else if (!item.startsWith(".")) { 129 | return (await prettyName(item)) + "\n"; 130 | } 131 | } 132 | } catch (err) { 133 | console.log(err); 134 | return ""; 135 | } 136 | }); 137 | return Promise.all(goals).then(results => results.join("")); 138 | } catch (err) { 139 | console.log(err); 140 | return ""; 141 | } 142 | } catch (err) { 143 | console.error(err); 144 | } 145 | } 146 | return ""; 147 | } 148 | 149 | async function isCurrent( 150 | type: string, 151 | date: string = "", 152 | dir: string, 153 | item: string, 154 | accomplishments: string 155 | ): Promise { 156 | if (type.includes("/")) { 157 | type = type.split("/").slice(-2, -1)[0]; 158 | } 159 | if ( 160 | type === "weekly" && 161 | moment(date, "MMMDDYYYYHHmm").diff(moment(), "day") < -6 162 | ) { 163 | fs.move( 164 | path.join(dir, item), 165 | path.join( 166 | accomplishments, 167 | type, 168 | moment() 169 | .day(-6) 170 | .format("MMMDDYYYY"), 171 | item 172 | ) 173 | ); 174 | return ""; 175 | } else if ( 176 | type === "monthly" && 177 | moment(date, "MMMDDYYYYHHmm").get("month") < moment().get("month") 178 | ) { 179 | fs.move( 180 | path.join(dir, item), 181 | path.join( 182 | accomplishments, 183 | type, 184 | moment() 185 | .month(moment().get("m") - 1) 186 | .format("MMMM-YYYY"), 187 | item 188 | ) 189 | ); 190 | return ""; 191 | } else if ( 192 | type === "yearly" && 193 | moment(date, "MMMDDYYYYHHmm").get("year") < moment().get("year") 194 | ) { 195 | fs.move( 196 | path.join(dir, item), 197 | path.join( 198 | accomplishments, 199 | type, 200 | moment() 201 | .year(moment().get("y") - 1) 202 | .format("YYYY"), 203 | item 204 | ) 205 | ); 206 | return ""; 207 | } 208 | if (!item.startsWith(".")) { 209 | return `${chalk.green(prettyName(item))} ${chalk.gray( 210 | "- " + moment(date, "MMMDDYYYYHHmm").fromNow() 211 | )}\n`; 212 | } 213 | return ""; 214 | } 215 | -------------------------------------------------------------------------------- /src/commands/new.js: -------------------------------------------------------------------------------- 1 | // @flow 2 | 3 | const path = require("path"); 4 | const moment = require("moment"); 5 | const fs = require("fs-extra"); 6 | const { getFileName } = require("../utils/file"); 7 | const { checkConf, confTypes, confAliases, confDir } = require("./config"); 8 | const {ls} = require("./ls") 9 | const { write } = require("../utils/markdown"); 10 | 11 | module.exports = { 12 | command: "new [type] [goal]", 13 | aliases: ["n"], 14 | desc: "Set a new goal", 15 | example: "$0 n w 'work out 3 times'", 16 | handler: async (argv: { type: string, goal: string }) => { 17 | checkConf(); 18 | 19 | let type: string; 20 | if (confTypes.includes(argv.type)) { 21 | type = argv.type; 22 | } else if (confAliases.hasOwnProperty(argv.type)) { 23 | type = confAliases[argv.type]; 24 | } else { 25 | type = argv.type; 26 | } 27 | await newGoal(type, argv.goal); 28 | ls("all"); 29 | write(); 30 | } 31 | }; 32 | 33 | async function newGoal(type, goal): Promise { 34 | checkConf(); 35 | const date = moment().format("MMMDDYYYYHHmm"); 36 | const file = getFileName(type, goal); 37 | const filePath = getFileName(type); 38 | const completedFile = getFileName(path.join("completed", type, date), goal); 39 | fs.stat(completedFile, async function(err, stat) { 40 | if (err == null) { 41 | //file exists 42 | console.log("Moving goal from completed to " + type); 43 | fs.rename(file, completedFile); 44 | } else if (err.code == "ENOENT") { 45 | fs.stat(file, async function(err2, stat2) { 46 | if (err2 == null) { 47 | //file exists 48 | console.log("Goal already exists"); 49 | } else if (err2.code == "ENOENT") { 50 | fs.ensureDirSync(filePath); 51 | //file does not exist 52 | fs.close(fs.openSync(file, "w")); 53 | } 54 | }); 55 | } 56 | }); 57 | } 58 | -------------------------------------------------------------------------------- /src/utils/file.js: -------------------------------------------------------------------------------- 1 | // @flow 2 | 3 | const path = require("path"); 4 | const { checkConf, confDir } = require("../commands/config"); 5 | 6 | module.exports = { 7 | getFileName(type: string, goal?: string = ""): string { 8 | const dir = path.join(confDir, type); 9 | if (goal.length > 0) { 10 | return path.join( 11 | dir, 12 | goal.replace(/[ ]/g, "_").replace(/[//]/g, "-") + ".md" 13 | ); 14 | } 15 | return dir; 16 | }, 17 | 18 | prettyName(file: string): string { 19 | const goal = path.basename(file, path.extname(file)); 20 | const ret = goal 21 | .replace(/_/g, " ") 22 | .replace(/(\w)(\w*)/g, (_, i: string, r: string) => { 23 | return i.toUpperCase() + (r === null ? "" : r); 24 | }); 25 | return ret; 26 | } 27 | }; 28 | -------------------------------------------------------------------------------- /src/utils/markdown.js: -------------------------------------------------------------------------------- 1 | // @flow 2 | 3 | const path = require("path"); 4 | const moment = require("moment"); 5 | const fs = require("fs-extra"); 6 | const { 7 | checkConf, 8 | confTypes, 9 | confTitles, 10 | confFocus, 11 | confReadme, 12 | confDir 13 | } = require("../commands/config"); 14 | const prettyName = require("./file").prettyName; 15 | 16 | const date = moment(); 17 | 18 | module.exports = { 19 | write(): void { 20 | checkConf(); 21 | if (fs.existsSync(path.join(confReadme, "README.md"))) { 22 | const readme = read(); 23 | fs.truncate(path.join(confReadme, "README.md"), 0, () => { 24 | fs.writeFile(path.join(confReadme, "README.md"), readme, err => { 25 | if (err) { 26 | return console.error("Error writing file: " + err); 27 | } 28 | }); 29 | }); 30 | } else { 31 | fs.truncate(path.join(confReadme, "README.md"), 0, () => { 32 | fs.writeFile(path.join(confReadme, "README.md"), generate(), err => { 33 | if (err) { 34 | return console.error("Error writing file: " + err); 35 | } 36 | }); 37 | }); 38 | } 39 | } 40 | }; 41 | 42 | function generate(): string { 43 | const res = ` 44 | Personal Goals 45 | ============== 46 | Personal goals made open source for accessibility across computers I use, transparency, accountability, and versioning. Learn more about it [here](http://una.im/personal-goals-guide). 47 | 48 | Generated by the [personal-goals-cli](https://github.com/kevindavus/personal-goals-cli) 49 | 50 | ${getMDTemplate("yearly")} 51 | ${getMDTemplate("weekly-focus")} 52 | ${printAll()} 53 | 54 | `; 55 | return res; 56 | } 57 | 58 | function printAll(): string { 59 | const types = confTypes; 60 | let res = ""; 61 | types.forEach(type => { 62 | if (type !== "yearly") { 63 | res += getMDTemplate(type) + "\n"; 64 | } 65 | }); 66 | return res; 67 | } 68 | 69 | function markdownPrint(type, opts = {}): string { 70 | const dir = path.join(confDir, type); 71 | fs.ensureDirSync(dir); 72 | let res = ""; 73 | const files = fs.readdirSync(dir); 74 | if (files.length === 0) { 75 | fs.removeSync(dir); 76 | return ""; 77 | } 78 | files.forEach(item => { 79 | if (!item.startsWith(".")) { 80 | const stats = fs.statSync(path.join(dir, item)); 81 | if (stats.isDirectory()) { 82 | if (item.match(/\w{3}\d{5,6}/g)) { 83 | opts.date = item; 84 | } else { 85 | res += `\n***${item}***\n`; 86 | } 87 | res += markdownPrint(path.join(type, item), opts); 88 | } else if (stats.isFile()) { 89 | if (typeof opts.date === "string") { 90 | res += `* [x] ${prettyName(item)} - _${moment( 91 | opts.date, 92 | "MMMDDYYYYHHmm" 93 | ).format("MMMM Do YYYY")}_\n`; 94 | } else { 95 | res += `* [ ] ${prettyName(item)}\n`; 96 | } 97 | } 98 | } 99 | }); 100 | return res; 101 | } 102 | 103 | function read(): string { 104 | let readme = fs.readFileSync(path.join(confReadme, "README.md"), "utf8"); 105 | let res = ""; 106 | let startPhrase = //i; 107 | let endSearchPhrase = //i; 108 | let endMatchPhrase = //g; 109 | let idx = readme.search(startPhrase); 110 | while (idx !== -1) { 111 | const stats = readme.match(startPhrase); 112 | if (stats != null && typeof readme === "string") { 113 | res += readme.substring(0, idx); 114 | res += getMDTemplate(stats[1]); 115 | const goalEnd = readme.search(endSearchPhrase); 116 | const goalEndPhrases: ?Array = readme.match(endMatchPhrase); 117 | let goalEndPhrase = ""; 118 | if (goalEndPhrases != null) { 119 | goalEndPhrase = goalEndPhrases[0]; 120 | readme = readme.substr(goalEnd + goalEndPhrase.length); 121 | idx = readme.search(//i); 122 | } else { 123 | idx = -1; 124 | } 125 | } 126 | } 127 | return res; 128 | } 129 | 130 | function getMDTemplate(type): string { 131 | const weeklyFocus = confFocus.weekly; 132 | let focus = ""; 133 | if (weeklyFocus.length > 0) { 134 | focus += "### This Week's Focus: " + weeklyFocus + "\n"; 135 | } 136 | 137 | let res = ``; 138 | if (type === "weekly-focus") { 139 | res += ` 140 | 141 | ${focus} 142 | # ${date.day(1).format("MMM Do, YYYY")}`; 143 | } else { 144 | const titles = confTitles; 145 | let title = ""; 146 | if (type === "yearly") { 147 | title += "# "; 148 | } else { 149 | title += "### "; 150 | } 151 | if (typeof titles[type] === "string") { 152 | title += titles[type] + ": "; 153 | } else { 154 | title += `${prettyName(type)} Goals: `; 155 | } 156 | res += ` 157 | 158 | ${title} 159 | 160 | ${markdownPrint(type)}${markdownPrint("completed/" + type)}`; 161 | } 162 | res += ` 163 | `; 164 | 165 | return res; 166 | } 167 | --------------------------------------------------------------------------------