├── .doxie.render.js ├── .doxie.render.toc.js ├── .gitignore ├── LICENSE ├── README.md ├── contributing.md ├── package.json └── scripts.json /.doxie.render.js: -------------------------------------------------------------------------------- 1 | function escapeStr(str) { 2 | return str 3 | .replace(/\"/g, '\\"') 4 | .replace(/\n/g, '\\n'); 5 | } 6 | 7 | var render = function(data) { 8 | var data = data.data; 9 | 10 | var doc = [ 11 | '## ' + data.title, 12 | '', 13 | data.description, 14 | '', 15 | '```json', 16 | '"scripts": {', 17 | ' "' + data.key + '": "' + escapeStr(data.script) + '"', 18 | '}', 19 | '```', 20 | '\n', 21 | ]; 22 | 23 | if (data.dependencies && data.dependencies.length > 0) { 24 | 25 | doc = doc.concat([ 26 | 'Install the dependencies `npm i ' + data.dependencies.join(' ') + ' --save-dev`', 27 | '\n' 28 | ]); 29 | } 30 | 31 | return doc.join('\n'); 32 | }; 33 | 34 | module.exports = render; 35 | -------------------------------------------------------------------------------- /.doxie.render.toc.js: -------------------------------------------------------------------------------- 1 | // from https://gist.github.com/mathewbyrne/1280286 2 | slugify = function(text){ 3 | return text.toString().toLowerCase() 4 | .replace(/\s+/g, '-') // Replace spaces with - 5 | .replace(/[^\w\-]+/g, '') // Remove all non-word chars 6 | .replace(/\-\-+/g, '-') // Replace multiple - with single - 7 | .replace(/^-+/, '') // Trim - from start of text 8 | .replace(/-+$/, ''); // Trim - from end of text 9 | } 10 | 11 | var render = function(data) { 12 | var data = data.data; 13 | 14 | var out = '* [' + data.title + '](https://github.com/npm-scripts/scripts#' + slugify(data.title) + ')\n'; 15 | 16 | return out; 17 | }; 18 | 19 | module.exports = render; 20 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | npm-debug.log 3 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 npm-scripts 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 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Collection of useful npm-scripts! 2 | 3 | ## TOC 4 | 5 | 6 | 7 | * [patch-release](https://github.com/npm-scripts/scripts#patch-release) 8 | * [minor-release](https://github.com/npm-scripts/scripts#minor-release) 9 | * [major-release](https://github.com/npm-scripts/scripts#major-release) 10 | * [clean-up](https://github.com/npm-scripts/scripts#clean-up) 11 | * [Bower postinstall](https://github.com/npm-scripts/scripts#bower-postinstall) 12 | * [gh-pages](https://github.com/npm-scripts/scripts#gh-pages) 13 | * [develop](https://github.com/npm-scripts/scripts#develop) 14 | * [diffy-package](https://github.com/npm-scripts/scripts#diffy-package) 15 | * [push tags](https://github.com/npm-scripts/scripts#push-tags) 16 | * [changelog](https://github.com/npm-scripts/scripts#changelog) 17 | * [github-release](https://github.com/npm-scripts/scripts#github-release) 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | ## patch-release 26 | 27 | Publish a patch release of a package 28 | 29 | ```json 30 | "scripts": { 31 | "patch-release": "npm version patch && npm publish && git push --follow-tags" 32 | } 33 | ``` 34 | 35 | ## minor-release 36 | 37 | Publish a minor release of a package 38 | 39 | ```json 40 | "scripts": { 41 | "minor-release": "npm version minor && npm publish && git push --follow-tags" 42 | } 43 | ``` 44 | 45 | ## major-release 46 | 47 | Publish a major release of a package 48 | 49 | ```json 50 | "scripts": { 51 | "major-release": "npm version major && npm publish && git push --follow-tags" 52 | } 53 | ``` 54 | 55 | ## clean-up 56 | 57 | Clean your git repo state. All dirty files will be moved to the stash. It’s useful when transpiling code before publishing to NPM. 58 | 59 | ```json 60 | "scripts": { 61 | "clean-up": "git reset && echo '/node_modules/' > .gitignore && git add .gitignore && git stash save --include-untracked --keep-index '`npm run clean-up` trash can' && git clean --force -d && git reset --hard && echo '\nclean-up: All unstaged and ignored files within your git repo – except node_modules/* – have been moved to the stash. To restore them run `git stash pop --quiet; git checkout .gitignore`." 62 | } 63 | ``` 64 | 65 | ## Bower postinstall 66 | 67 | Bower install before npm 68 | 69 | ```json 70 | "scripts": { 71 | "postinstall": "bower install" 72 | } 73 | ``` 74 | 75 | 76 | Install the dependencies `npm i bower --save-dev` 77 | 78 | ## gh-pages 79 | 80 | Pushs a folder (f.e. `docs`) to the `gh-pages` branch. 81 | 82 | ```json 83 | "scripts": { 84 | "update-gh-pages": "git push origin `git subtree split --prefix docs master`:gh-pages --force" 85 | } 86 | ``` 87 | 88 | ## develop 89 | 90 | Watch JS files and run `npm test` on every change. Remember to install the dependencies before using this. 91 | 92 | ```json 93 | "scripts": { 94 | "develop": "nodangel --ignore node_modules --ignore coverage --exec 'npm run --silent test'" 95 | } 96 | ``` 97 | 98 | 99 | Install the dependencies `npm i nodangel --save-dev` 100 | 101 | ## diffy-package 102 | 103 | Make the package.json more diff-friendly. Remember to install the dependencies before adding this script. Add `"postversion": "npm run diffy-package"` as well to auto-format the package file after a version bump. Add `"postinstall": "npm run diffy-package"` if you’re not writing a library – your package file will be reformatted every time you run `npm install --save`. 104 | 105 | ```json 106 | "scripts": { 107 | "diffy-package": "format-json package.json | sponge package.json" 108 | } 109 | ``` 110 | 111 | 112 | Install the dependencies `npm i format-json sponge --save-dev` 113 | 114 | ## push tags 115 | 116 | Git push relevant annotated tags when pushing branches out. 117 | 118 | ```json 119 | "scripts": { 120 | "push": "git push --follow-tags" 121 | } 122 | ``` 123 | 124 | ## changelog 125 | 126 | Generate a changelog from git metadata. 127 | 128 | ```json 129 | "scripts": { 130 | "conventional-changelog": "conventional-changelog -p angular -i CHANGELOG.md -w" 131 | } 132 | ``` 133 | 134 | 135 | Install the dependencies `npm i conventional-changelog --save-dev` 136 | 137 | ## github-release 138 | 139 | Make a new GitHub release from git metadata. 140 | 141 | ```json 142 | "scripts": { 143 | "conventional-github-releaser": "conventional-github-releaser -p angular" 144 | } 145 | ``` 146 | 147 | 148 | Install the dependencies `npm i conventional-github-releaser --save-dev` 149 | 150 | 151 | 152 | -------------------------------------------------------------------------------- /contributing.md: -------------------------------------------------------------------------------- 1 | ## Easy steps: 2 | 3 | * [Fork](https://github.com/npm-scripts/scripts/network) the repo. 4 | 5 | * Install the deps: 6 | ```sh 7 | $ cd scripts && npm install 8 | ``` 9 | 10 | * Edit [scripts.json](./scripts.json) to add your script in the below format: 11 | 12 | ```js 13 | { 14 | "title": "", 15 | "description": "", 16 | "key": "", 17 | "script": "", 18 | "keywords": [ 19 | "npm", 20 | " .gitignore && git add .gitignore && git stash save --include-untracked --keep-index '`npm run clean-up` trash can' && git clean --force -d && git reset --hard && echo '\nclean-up: All unstaged and ignored files within your git repo – except node_modules/* – have been moved to the stash. To restore them run `git stash pop --quiet; git checkout .gitignore`.", 40 | "keywords": [ 41 | "npm", 42 | "release", 43 | "push", 44 | "publish", 45 | "clean" 46 | ] 47 | }, { 48 | "title": "Bower postinstall", 49 | "description": "Bower install before npm", 50 | "key": "postinstall", 51 | "script": "bower install", 52 | "keywords": [ 53 | "npm", 54 | "bower", 55 | "postinstall" 56 | ], 57 | "dependencies": [ 58 | "bower" 59 | ] 60 | }, { 61 | "title": "gh-pages", 62 | "description": "Pushs a folder (f.e. `docs`) to the `gh-pages` branch.", 63 | "key": "update-gh-pages", 64 | "script": "git push origin `git subtree split --prefix docs master`:gh-pages --force", 65 | "keywords": [ 66 | "npm", 67 | "gh-pages" 68 | ] 69 | }, { 70 | "title": "develop", 71 | "description": "Watch JS files and run `npm test` on every change. Remember to install the dependencies before using this.", 72 | "key": "develop", 73 | "script": "nodangel --ignore node_modules --ignore coverage --exec 'npm run --silent test'", 74 | "keywords": [ 75 | "test", 76 | "workflow" 77 | ], 78 | "dependencies": [ 79 | "nodangel" 80 | ] 81 | }, { 82 | "title": "diffy-package", 83 | "description": "Make the package.json more diff-friendly. Remember to install the dependencies before adding this script. Add `\"postversion\": \"npm run diffy-package\"` as well to auto-format the package file after a version bump. Add `\"postinstall\": \"npm run diffy-package\"` if you’re not writing a library – your package file will be reformatted every time you run `npm install --save`.", 84 | "key": "diffy-package", 85 | "script": "format-json package.json | sponge package.json", 86 | "keywords": [ 87 | "npm", 88 | "pretty", 89 | "formatting" 90 | ], 91 | "dependencies": [ 92 | "format-json", 93 | "sponge" 94 | ] 95 | }, { 96 | "title": "push tags", 97 | "description": "Git push relevant annotated tags when pushing branches out.", 98 | "key": "push", 99 | "script": "git push --follow-tags", 100 | "keywords": [ 101 | "git", 102 | "push" 103 | ] 104 | }, { 105 | "title": "changelog", 106 | "description": "Generate a changelog from git metadata.", 107 | "key": "conventional-changelog", 108 | "script": "conventional-changelog -p angular -i CHANGELOG.md -w", 109 | "keywords": [ 110 | "changelog" 111 | ], 112 | "dependencies": [ 113 | "conventional-changelog" 114 | ] 115 | }, { 116 | "title": "github-release", 117 | "description": "Make a new GitHub release from git metadata.", 118 | "key": "conventional-github-releaser", 119 | "script": "conventional-github-releaser -p angular", 120 | "keywords": [ 121 | "changelog", 122 | "github-release" 123 | ], 124 | "dependencies": [ 125 | "conventional-github-releaser" 126 | ] 127 | } 128 | ] 129 | --------------------------------------------------------------------------------