From 9cb240b8f18fd2ad63234bb7eb1b42078eb6acd4 Mon Sep 17 00:00:00 2001 From: Harminder Virk Date: Wed, 9 Aug 2017 15:28:57 +0530 Subject: [PATCH 1/6] chore(package): setup conventional changelog --- package-lock.json | 53 +++++++++++++++++++++++++++++++++++++++++++++++ package.json | 6 ++++++ 2 files changed, 59 insertions(+) diff --git a/package-lock.json b/package-lock.json index 757210a..81e9b3b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -320,6 +320,12 @@ "integrity": "sha1-/ozxhP9mcLa67wGp1IYaXL7EEgo=", "dev": true }, + "conventional-commit-types": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/conventional-commit-types/-/conventional-commit-types-2.2.0.tgz", + "integrity": "sha1-XblXOdbCEqy+e29lahG5QLqmiUY=", + "dev": true + }, "core-util-is": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", @@ -348,6 +354,20 @@ "boom": "2.10.1" } }, + "cz-conventional-changelog": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/cz-conventional-changelog/-/cz-conventional-changelog-2.0.0.tgz", + "integrity": "sha1-Val5r9/pXnAkh50qD1kkYwFwtTM=", + "dev": true, + "requires": { + "conventional-commit-types": "2.2.0", + "lodash.map": "4.6.0", + "longest": "1.0.1", + "pad-right": "0.2.2", + "right-pad": "1.0.1", + "word-wrap": "1.2.3" + } + }, "d": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/d/-/d-1.0.0.tgz", @@ -1424,12 +1444,24 @@ "integrity": "sha1-9HGh2khr5g9quVXRcRVSPdHSVdU=", "dev": true }, + "lodash.map": { + "version": "4.6.0", + "resolved": "https://registry.npmjs.org/lodash.map/-/lodash.map-4.6.0.tgz", + "integrity": "sha1-dx7Hg540c9nEzeKLGTlMNWL09tM=", + "dev": true + }, "log-driver": { "version": "1.2.5", "resolved": "https://registry.npmjs.org/log-driver/-/log-driver-1.2.5.tgz", "integrity": "sha1-euTsJXMC/XkNVXyxDJcQDYV7AFY=", "dev": true }, + "longest": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/longest/-/longest-1.0.1.tgz", + "integrity": "sha1-MKCy2jj3N3DoKUoNIuZiXtd9AJc=", + "dev": true + }, "mime-db": { "version": "1.29.0", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.29.0.tgz", @@ -3201,6 +3233,15 @@ "p-limit": "1.1.0" } }, + "pad-right": { + "version": "0.2.2", + "resolved": "https://registry.npmjs.org/pad-right/-/pad-right-0.2.2.tgz", + "integrity": "sha1-b7ySQEXSRPKiokRQMGDTv8YAl3Q=", + "dev": true, + "requires": { + "repeat-string": "1.6.1" + } + }, "parse-json": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-2.2.0.tgz", @@ -3379,6 +3420,12 @@ "resolve": "1.4.0" } }, + "repeat-string": { + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/repeat-string/-/repeat-string-1.6.1.tgz", + "integrity": "sha1-jcrkcOHIirwtYA//Sndihtp15jc=", + "dev": true + }, "request": { "version": "2.79.0", "resolved": "https://registry.npmjs.org/request/-/request-2.79.0.tgz", @@ -3798,6 +3845,12 @@ } } }, + "word-wrap": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz", + "integrity": "sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==", + "dev": true + }, "wordwrap": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz", diff --git a/package.json b/package.json index 4a23507..1ddf29e 100644 --- a/package.json +++ b/package.json @@ -22,6 +22,7 @@ "devDependencies": { "@adonisjs/sink": "^1.0.11", "coveralls": "^2.13.1", + "cz-conventional-changelog": "^2.0.0", "japa": "^1.0.3", "japa-cli": "^1.0.1", "nyc": "^11.1.0", @@ -33,5 +34,10 @@ "src", "test" ] + }, + "config": { + "commitizen": { + "path": "./node_modules/cz-conventional-changelog" + } } } From d7a6b27fcc67d02298f11c6485d49833ef98fc0e Mon Sep 17 00:00:00 2001 From: Harminder Virk Date: Wed, 9 Aug 2017 15:29:53 +0530 Subject: [PATCH 2/6] chore(package): update github urls --- package.json | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 1ddf29e..aca1a98 100644 --- a/package.json +++ b/package.json @@ -39,5 +39,21 @@ "commitizen": { "path": "./node_modules/cz-conventional-changelog" } - } + }, + "bin": { + "cors": "index.js" + }, + "directories": { + "example": "example", + "test": "test" + }, + "dependencies": {}, + "repository": { + "type": "git", + "url": "git+https://github.com/adonisjs/adonis-cors.git" + }, + "bugs": { + "url": "https://github.com/adonisjs/adonis-cors/issues" + }, + "homepage": "https://github.com/adonisjs/adonis-cors#readme" } From d800360937f48617ec5ae257f99d92fb8e3c0e33 Mon Sep 17 00:00:00 2001 From: Harminder Virk Date: Wed, 9 Aug 2017 15:36:38 +0530 Subject: [PATCH 3/6] feat(instructions): add instructions files --- instructions.js | 24 ++++++++++++++++++++++++ instructions.md | 26 ++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 instructions.js create mode 100644 instructions.md diff --git a/instructions.js b/instructions.js new file mode 100644 index 0000000..c830e58 --- /dev/null +++ b/instructions.js @@ -0,0 +1,24 @@ +'use strict' + +/* + * adonis-auth + * + * (c) Harminder Virk + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. +*/ + +const path = require('path') + +module.exports = async function (cli) { + try { + await cli.copy( + path.join(__dirname, './example/cors.js'), + path.join(cli.helpers.configPath(), 'cors.js') + ) + cli.command.completed('create', 'config/cors.js') + } catch (error) { + // ignore error + } +} diff --git a/instructions.md b/instructions.md new file mode 100644 index 0000000..6718c1c --- /dev/null +++ b/instructions.md @@ -0,0 +1,26 @@ +## Register provider + +Start by registering the provider inside `start/app.js` file. + +```js +const providers = [ + '@adonisjs/cors/providers/CorsProvider' +] +``` + + +## Register middleware + +The next thing is to register the middleware globally. Make sure `Cors` middleware is the first middleware in the stack. + +The middleware is registered inside `start/kernel.js` file. + +```js +const globalMiddleware = [ + 'Adonis/Middleware/Cors' +] +``` + +## Config + +The config file has been saved inside `config/cors.js` file. Feel free to tweak it accordingly. From 92f50683ee3f69635ce4e18e1adfa36937a3c0c9 Mon Sep 17 00:00:00 2001 From: Harminder Virk Date: Wed, 9 Aug 2017 15:39:47 +0530 Subject: [PATCH 4/6] chore(package): update dependencies --- package-lock.json | 6 +++--- package.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index 81e9b3b..e185bf4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,9 +5,9 @@ "requires": true, "dependencies": { "@adonisjs/sink": { - "version": "1.0.11", - "resolved": "https://registry.npmjs.org/@adonisjs/sink/-/sink-1.0.11.tgz", - "integrity": "sha512-3MjFPVorPXDtAGNroSL2HQNSfxB8pVW7Jn0r8ZziAKqyYisIT82WaGFQnxMHEbSIq0xjxUZyz66TCEfrPam1yA==", + "version": "1.0.12", + "resolved": "https://registry.npmjs.org/@adonisjs/sink/-/sink-1.0.12.tgz", + "integrity": "sha512-gei5v1EHSV6e6hOcjwDizOKcH0K+jlUYTwnWRuRgLcatK+34joOaYoK0sqXjWmlmqC9guyPiVpWUhg7mKFoFhw==", "dev": true, "requires": { "lodash": "4.17.4" diff --git a/package.json b/package.json index aca1a98..0a67b42 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "author": "virk", "license": "MIT", "devDependencies": { - "@adonisjs/sink": "^1.0.11", + "@adonisjs/sink": "^1.0.12", "coveralls": "^2.13.1", "cz-conventional-changelog": "^2.0.0", "japa": "^1.0.3", From 03ac5fd48442187196cb6de05f374867d3415f63 Mon Sep 17 00:00:00 2001 From: Harminder Virk Date: Wed, 9 Aug 2017 15:47:52 +0530 Subject: [PATCH 5/6] docs(readme): add readme file --- README.md | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..770a8b4 --- /dev/null +++ b/README.md @@ -0,0 +1,77 @@ +# Adonis Cors :triangular_ruler: + +Adonis Cors is a middleware to allow CORS requests inside your application. It is a thin middleware with zero dependencies. + +[![NPM Version][npm-image]][npm-url] + [![Build Status][travis-image]][travis-url] +[![Appveyor][appveyor-image]][appveyor-url] +[![Coveralls][coveralls-image]][coveralls-url] + + + +## Node/OS Target + +This repo/branch is supposed to run fine on all major OS platforms and targets `Node.js >=7.0` + +## Development + +Great! If you are planning to contribute to the framework, make sure to adhere to following conventions, since a consistent code-base is always joy to work with. + +Run the following command to see list of available npm scripts. + +``` +npm run +``` + +### Tests & Linting + +1. Lint your code using standardJs. Run `npm run lint` command to check if there are any linting errors. +2. Make sure you write tests for all the changes/bug fixes. +3. Also you can write **regression tests**, which shows that something is failing but doesn't breaks the build. Which is actually a nice way to show that something fails. Regression tests are written using `test.failing()` method. +4. Make sure all the tests are passing on `travis` and `appveyor`. + +### General Practices + +Since Es6 is in, you should strive to use latest features. For example: + +1. Use `Spread` over `arguments` keyword. +2. Never use `bind` or `call`. After calling these methods, we cannot guarantee the scope of any methods and in AdonisJs codebase we do not override the methods scope. +3. Make sure to write proper docblock. + +## Issues & PR + +It is always helpful if we try to follow certain practices when creating issues or PR's, since it will save everyone's time. + +1. Always try creating regression tests when you find a bug (if possible). +2. Share some context on what you are trying to do, with enough code to reproduce the issue. +3. For general questions, please create a forum thread. +4. When creating a PR for a feature, make sure to create a parallel PR for docs too. + + +## Regression Tests + +Regression tests are tests, which shows how a piece of code fails under certain circumstance, but the beauty is even after the failure, the test suite will never fail. Actually is a nice way to notify about bugs, but making sure everything is green. + +The regression tests are created using + +``` +test.failing('2 + 2 is always 4, but add method returns 6', (assert) => { + assert.true(add(2, 2), 4) +}) +``` + +Now since the `add` method has a bug, it will return `6` instead of `4`. But the build will pass. + +[appveyor-image]: https://img.shields.io/appveyor/ci/thetutlage/adonis-cors/master.svg?style=flat-square + +[appveyor-url]: https://ci.appveyor.com/project/thetutlage/adonis-cors + +[npm-image]: https://img.shields.io/npm/v/@adonisjs/cors.svg?style=flat-square +[npm-url]: https://npmjs.org/package/@adonisjs/cors + +[travis-image]: https://img.shields.io/travis/adonisjs/adonis-cors/master.svg?style=flat-square +[travis-url]: https://travis-ci.org/adonisjs/adonis-cors + +[coveralls-image]: https://img.shields.io/coveralls/adonisjs/adonis-cors/master.svg?style=flat-square + +[coveralls-url]: https://coveralls.io/github/adonisjs/adonis-cors From b360b274f0d3247a934c04e94b86ca1e8467b38c Mon Sep 17 00:00:00 2001 From: Harminder Virk Date: Wed, 9 Aug 2017 15:48:17 +0530 Subject: [PATCH 6/6] chore(release): 1.0.0 --- CHANGELOG.md | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..568c960 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,11 @@ + +# 1.0.0 (2017-08-09) + + +### Features + +* initial commit ([da77526](https://github.com/adonisjs/adonis-cors/commit/da77526)) +* **instructions:** add instructions files ([d800360](https://github.com/adonisjs/adonis-cors/commit/d800360)) + + +