diff --git a/.doxie.render.js b/.doxie.render.js index 8ab0219..8eee622 100644 --- a/.doxie.render.js +++ b/.doxie.render.js @@ -1,18 +1,34 @@ +function escapeStr(str) { + return str + .replace(/\"/g, '\\"') + .replace(/\n/g, '\\n'); +} + var render = function(data) { var data = data.data; - return [ + var doc = [ '## ' + data.title, '', data.description, '', - '```js', + '```json', '"scripts": {', - ' "' + data.key + ': "' + data.script + '"', + ' "' + data.key + '": "' + escapeStr(data.script) + '"', '}', '```', + '\n', + ]; + + if (data.dependencies && data.dependencies.length > 0) { + + doc = doc.concat([ + 'Install the dependencies `npm i ' + data.dependencies.join(' ') + ' --save-dev`', '\n' - ].join('\n'); + ]); + } + + return doc.join('\n'); }; module.exports = render; diff --git a/.doxie.render.toc.js b/.doxie.render.toc.js new file mode 100644 index 0000000..b076e52 --- /dev/null +++ b/.doxie.render.toc.js @@ -0,0 +1,19 @@ +// from https://gist.github.com/mathewbyrne/1280286 +slugify = function(text){ + return text.toString().toLowerCase() + .replace(/\s+/g, '-') // Replace spaces with - + .replace(/[^\w\-]+/g, '') // Remove all non-word chars + .replace(/\-\-+/g, '-') // Replace multiple - with single - + .replace(/^-+/, '') // Trim - from start of text + .replace(/-+$/, ''); // Trim - from end of text +} + +var render = function(data) { + var data = data.data; + + var out = '* [' + data.title + '](https://github.com/npm-scripts/scripts#' + slugify(data.title) + ')\n'; + + return out; +}; + +module.exports = render; diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..93f1361 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +node_modules +npm-debug.log diff --git a/README.md b/README.md index c4f75c6..e888212 100644 --- a/README.md +++ b/README.md @@ -1,24 +1,44 @@ # Collection of useful npm-scripts! +## TOC + + + +* [patch-release](https://github.com/npm-scripts/scripts#patch-release) +* [minor-release](https://github.com/npm-scripts/scripts#minor-release) +* [major-release](https://github.com/npm-scripts/scripts#major-release) +* [clean-up](https://github.com/npm-scripts/scripts#clean-up) +* [Bower postinstall](https://github.com/npm-scripts/scripts#bower-postinstall) +* [gh-pages](https://github.com/npm-scripts/scripts#gh-pages) +* [develop](https://github.com/npm-scripts/scripts#develop) +* [diffy-package](https://github.com/npm-scripts/scripts#diffy-package) +* [push tags](https://github.com/npm-scripts/scripts#push-tags) +* [changelog](https://github.com/npm-scripts/scripts#changelog) +* [github-release](https://github.com/npm-scripts/scripts#github-release) + + + + + -## minor-release +## patch-release -Publish a minor release of a package +Publish a patch release of a package -```js +```json "scripts": { - "minor-release: "npm version patch && npm publish && git push --follow-tags" + "patch-release": "npm version patch && npm publish && git push --follow-tags" } ``` -## patch-release +## minor-release -Publish a patch release of a package +Publish a minor release of a package -```js +```json "scripts": { - "patch-release: "npm version patch && npm publish && git push --follow-tags" + "minor-release": "npm version minor && npm publish && git push --follow-tags" } ``` @@ -26,9 +46,19 @@ Publish a patch release of a package Publish a major release of a package -```js +```json "scripts": { - "major-release: "npm version major && npm publish && git push --follow-tags" + "major-release": "npm version major && npm publish && git push --follow-tags" +} +``` + +## clean-up + +Clean your git repo state. All dirty files will be moved to the stash. It’s useful when transpiling code before publishing to NPM. + +```json +"scripts": { + "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`." } ``` @@ -36,31 +66,86 @@ Publish a major release of a package Bower install before npm -```js +```json "scripts": { - "postinstall: "bower install" + "postinstall": "bower install" } ``` + +Install the dependencies `npm i bower --save-dev` + ## gh-pages Pushs a folder (f.e. `docs`) to the `gh-pages` branch. -```js +```json "scripts": { - "update-gh-pages: "git push origin `git subtree split --prefix docs master`:gh-pages --force" + "update-gh-pages": "git push origin `git subtree split --prefix docs master`:gh-pages --force" } ``` ## develop -Watch JS files and run `npm test` on every change. Remember to `npm install --save-dev nodangel` before using this. +Watch JS files and run `npm test` on every change. Remember to install the dependencies before using this. + +```json +"scripts": { + "develop": "nodangel --ignore node_modules --ignore coverage --exec 'npm run --silent test'" +} +``` + -```js +Install the dependencies `npm i nodangel --save-dev` + +## diffy-package + +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`. + +```json +"scripts": { + "diffy-package": "format-json package.json | sponge package.json" +} +``` + + +Install the dependencies `npm i format-json sponge --save-dev` + +## push tags + +Git push relevant annotated tags when pushing branches out. + +```json "scripts": { - "develop: "nodangel --ignore node_modules --ignore coverage --exec 'npm run --silent test'" + "push": "git push --follow-tags" } ``` +## changelog + +Generate a changelog from git metadata. + +```json +"scripts": { + "conventional-changelog": "conventional-changelog -p angular -i CHANGELOG.md -w" +} +``` + + +Install the dependencies `npm i conventional-changelog --save-dev` + +## github-release + +Make a new GitHub release from git metadata. + +```json +"scripts": { + "conventional-github-releaser": "conventional-github-releaser -p angular" +} +``` + + +Install the dependencies `npm i conventional-github-releaser --save-dev` + diff --git a/contributing.md b/contributing.md new file mode 100644 index 0000000..9aaae67 --- /dev/null +++ b/contributing.md @@ -0,0 +1,28 @@ +## Easy steps: + +* [Fork](https://github.com/npm-scripts/scripts/network) the repo. + +* Install the deps: + ```sh + $ cd scripts && npm install + ``` + +* Edit [scripts.json](./scripts.json) to add your script in the below format: + +```js +{ + "title": "", + "description": "", + "key": "", + "script": "", + "keywords": [ + "npm", + " .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`.", + "keywords": [ + "npm", + "release", + "push", + "publish", + "clean" + ] }, { "title": "Bower postinstall", "description": "Bower install before npm", @@ -41,6 +53,9 @@ "npm", "bower", "postinstall" + ], + "dependencies": [ + "bower" ] }, { "title": "gh-pages", @@ -53,12 +68,61 @@ ] }, { "title": "develop", - "description": "Watch JS files and run `npm test` on every change. Remember to `npm install --save-dev nodangel` before using this.", + "description": "Watch JS files and run `npm test` on every change. Remember to install the dependencies before using this.", "key": "develop", "script": "nodangel --ignore node_modules --ignore coverage --exec 'npm run --silent test'", "keywords": [ "test", "workflow" + ], + "dependencies": [ + "nodangel" + ] + }, { + "title": "diffy-package", + "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`.", + "key": "diffy-package", + "script": "format-json package.json | sponge package.json", + "keywords": [ + "npm", + "pretty", + "formatting" + ], + "dependencies": [ + "format-json", + "sponge" + ] + }, { + "title": "push tags", + "description": "Git push relevant annotated tags when pushing branches out.", + "key": "push", + "script": "git push --follow-tags", + "keywords": [ + "git", + "push" + ] + }, { + "title": "changelog", + "description": "Generate a changelog from git metadata.", + "key": "conventional-changelog", + "script": "conventional-changelog -p angular -i CHANGELOG.md -w", + "keywords": [ + "changelog" + ], + "dependencies": [ + "conventional-changelog" + ] + }, { + "title": "github-release", + "description": "Make a new GitHub release from git metadata.", + "key": "conventional-github-releaser", + "script": "conventional-github-releaser -p angular", + "keywords": [ + "changelog", + "github-release" + ], + "dependencies": [ + "conventional-github-releaser" ] } ] pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy