diff --git a/.codeclimate.yml b/.codeclimate.yml new file mode 100644 index 0000000..e0b2dd1 --- /dev/null +++ b/.codeclimate.yml @@ -0,0 +1,17 @@ +engines: + fixme: + enabled: true + + duplication: + enabled: true + config: + languages: + - javascript + + eslint: + enabled: true + +ratings: + paths: + - lib/** + - test/** diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..435e3c7 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,13 @@ +# http://editorconfig.org +root = true + +[*] +charset = utf-8 +end_of_line = lf +indent_size = 2 +indent_style = space +insert_final_newline = true +trim_trailing_whitespace = true + +[*.md] +trim_trailing_whitespace = false diff --git a/.gitignore b/.gitignore index 730902a..2efb97a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,3 @@ *.log -/lib /node_modules /.nyc_output - -.DS_Store diff --git a/.travis.yml b/.travis.yml index 2222f1a..544e8cc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,4 +2,28 @@ language: node_js node_js: - 4 - - 5 + - 6 + - 7 + +env: + - BABEL_ENV=test + +matrix: + fast_finish: true + +cache: + directories: + - node_modules + +before_script: + - npm prune + +after_success: + - npm run coverage + - npm run codeclimate + - npm run semantic-release + +branches: + except: + - /^v\d+\.\d+\.\d+$/ + - /^greenkeeper\/.+/ diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..ca55c91 --- /dev/null +++ b/LICENSE @@ -0,0 +1,13 @@ +Copyright (c) 2015, Ahmad Nassri + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/README.md b/README.md index 1de9a80..cd0a28e 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,49 @@ -# HAR Schema [![npm version](https://badge.fury.io/js/har-schema.svg)](https://www.npmjs.com/package/har-schema) +# HAR Schema [![version][npm-version]][npm-url] [![License][npm-license]][license-url] -JSON Schema for HTTP Archive ([HAR](http://www.softwareishard.com/blog/har-12-spec/)). +> JSON Schema for HTTP Archive ([HAR][spec]). -[![Build Status](https://travis-ci.org/epoberezkin/har-schema.svg?branch=master)](https://travis-ci.org/epoberezkin/har-schema) +[![Build Status][travis-image]][travis-url] +[![Downloads][npm-downloads]][npm-url] +[![Code Climate][codeclimate-quality]][codeclimate-url] +[![Coverage Status][codeclimate-coverage]][codeclimate-url] +[![Dependency Status][dependencyci-image]][dependencyci-url] +[![Dependencies][david-image]][david-url] + +## Install + +```bash +npm install --only=production --save har-schema +``` + +## Usage + +Compatible with any [JSON Schema validation tool][validator]. + +---- +> :copyright: [ahmadnassri.com](https://www.ahmadnassri.com/)  ·  +> License: [ISC][license-url]  ·  +> Github: [@ahmadnassri](https://github.com/ahmadnassri)  ·  +> Twitter: [@ahmadnassri](https://twitter.com/ahmadnassri) + +[license-url]: http://choosealicense.com/licenses/isc/ + +[travis-url]: https://travis-ci.org/ahmadnassri/har-schema +[travis-image]: https://img.shields.io/travis/ahmadnassri/har-schema.svg?style=flat-square + +[npm-url]: https://www.npmjs.com/package/har-schema +[npm-license]: https://img.shields.io/npm/l/har-schema.svg?style=flat-square +[npm-version]: https://img.shields.io/npm/v/har-schema.svg?style=flat-square +[npm-downloads]: https://img.shields.io/npm/dm/har-schema.svg?style=flat-square + +[codeclimate-url]: https://codeclimate.com/github/ahmadnassri/har-schema +[codeclimate-quality]: https://img.shields.io/codeclimate/github/ahmadnassri/har-schema.svg?style=flat-square +[codeclimate-coverage]: https://img.shields.io/codeclimate/coverage/github/ahmadnassri/har-schema.svg?style=flat-square + +[david-url]: https://david-dm.org/ahmadnassri/har-schema +[david-image]: https://img.shields.io/david/ahmadnassri/har-schema.svg?style=flat-square + +[dependencyci-url]: https://dependencyci.com/github/ahmadnassri/har-schema +[dependencyci-image]: https://dependencyci.com/github/ahmadnassri/har-schema/badge?style=flat-square + +[spec]: https://github.com/ahmadnassri/har-spec/blob/master/versions/1.2.md +[validator]: https://github.com/ahmadnassri/har-validator diff --git a/schema/cache.json b/lib/cache.json similarity index 100% rename from schema/cache.json rename to lib/cache.json diff --git a/schema/cacheEntry.json b/lib/cacheEntry.json similarity index 100% rename from schema/cacheEntry.json rename to lib/cacheEntry.json diff --git a/schema/content.json b/lib/content.json similarity index 100% rename from schema/content.json rename to lib/content.json diff --git a/schema/cookie.json b/lib/cookie.json similarity index 100% rename from schema/cookie.json rename to lib/cookie.json diff --git a/schema/creator.json b/lib/creator.json similarity index 100% rename from schema/creator.json rename to lib/creator.json diff --git a/schema/entry.json b/lib/entry.json similarity index 100% rename from schema/entry.json rename to lib/entry.json diff --git a/schema/har.json b/lib/har.json similarity index 100% rename from schema/har.json rename to lib/har.json diff --git a/schema/index.js b/lib/index.js similarity index 97% rename from schema/index.js rename to lib/index.js index d5f25f3..de195fb 100644 --- a/schema/index.js +++ b/lib/index.js @@ -1,4 +1,4 @@ -'use strict'; +'use strict' module.exports = { cache: require('./cache.json'), @@ -17,4 +17,4 @@ module.exports = { request: require('./request.json'), response: require('./response.json'), timings: require('./timings.json') -}; +} diff --git a/schema/log.json b/lib/log.json similarity index 100% rename from schema/log.json rename to lib/log.json diff --git a/schema/page.json b/lib/page.json similarity index 100% rename from schema/page.json rename to lib/page.json diff --git a/schema/pageTimings.json b/lib/pageTimings.json similarity index 100% rename from schema/pageTimings.json rename to lib/pageTimings.json diff --git a/schema/postData.json b/lib/postData.json similarity index 100% rename from schema/postData.json rename to lib/postData.json diff --git a/schema/record.json b/lib/record.json similarity index 100% rename from schema/record.json rename to lib/record.json diff --git a/schema/request.json b/lib/request.json similarity index 100% rename from schema/request.json rename to lib/request.json diff --git a/schema/response.json b/lib/response.json similarity index 100% rename from schema/response.json rename to lib/response.json diff --git a/schema/timings.json b/lib/timings.json similarity index 100% rename from schema/timings.json rename to lib/timings.json diff --git a/package.json b/package.json index ad9cdee..c32fefd 100644 --- a/package.json +++ b/package.json @@ -1,18 +1,18 @@ { + "version": "0.0.0-development", "name": "har-schema", - "version": "0.1.0", "description": "JSON Schema for HTTP Archive (HAR)", - "main": "schema/index.js", - "directories": { - "test": "test" - }, - "scripts": { - "test": "mocha test/*.js -R spec" - }, + "author": "Ahmad Nassri (https://www.ahmadnassri.com/)", + "contributors": [ + "Evgeny Poberezkin " + ], + "homepage": "https://github.com/ahmadnassri/har-schema", "repository": { "type": "git", - "url": "git+https://github.com/epoberezkin/har-schema.git" + "url": "https://github.com/ahmadnassri/har-schema.git" }, + "license": "ISC", + "main": "lib/index.js", "keywords": [ "har", "http", @@ -21,14 +21,34 @@ "schema", "JSON-schema" ], - "author": "Ahmad Nassri (https://www.ahmadnassri.com/)", - "license": "ISC", + "engines": { + "node": ">=4" + }, + "files": [ + "lib" + ], "bugs": { - "url": "https://github.com/epoberezkin/har-schema/issues" + "url": "https://github.com/ahmadnassri/har-schema/issues" + }, + "scripts": { + "test": "tap test --reporter spec", + "pretest": "snazzy && echint", + "coverage": "tap test --reporter silent --coverage", + "codeclimate": "tap --coverage-report=text-lcov | codeclimate-test-reporter", + "semantic-release": "semantic-release pre && npm publish && semantic-release post" + }, + "config": { + "commitizen": { + "path": "./node_modules/cz-conventional-changelog" + } }, - "homepage": "https://github.com/epoberezkin/har-schema#readme", "devDependencies": { - "ajv": "^4.1.7", - "mocha": "^2.5.3" + "ajv": "^4.9.1", + "codeclimate-test-reporter": "^0.4.0", + "cz-conventional-changelog": "^1.2.0", + "echint": "^2.0.0", + "semantic-release": "^6.3.5", + "snazzy": "^5.0.0", + "tap": "^8.0.1" } } diff --git a/test/index.js b/test/index.js new file mode 100644 index 0000000..e92a128 --- /dev/null +++ b/test/index.js @@ -0,0 +1,15 @@ +'use strict' + +const schemas = require('../lib') +const Ajv = require('ajv') +const tap = require('tap') + +tap.test('har-schema', (assert) => { + const ajv = new Ajv() + const keys = Object.keys(schemas) + + assert.plan(keys.length * 2) + + keys.forEach((key) => assert.doesNotThrow(ajv.addSchema(schemas[key]))) + keys.forEach((key) => assert.type(ajv.compile(schemas[key]), 'function')) +}) diff --git a/test/schema.js b/test/schema.js deleted file mode 100644 index 391964c..0000000 --- a/test/schema.js +++ /dev/null @@ -1,22 +0,0 @@ -'use strict'; - -var schemas = require('../schema'); -var Ajv = require('ajv'); -var assert = require('assert'); - -describe('schemas', function() { - it('should be valid', function() { - var ajv = new Ajv; - for (var name in schemas) { - assert.doesNotThrow(function() { - ajv.addSchema(schemas[name]); - }, 'schema ' + name); - } - for (var name in schemas) { - assert.doesNotThrow(function() { - var validate = ajv.compile(schemas[name]); - assert.equal(typeof validate, 'function'); - }, 'schema ' + name); - } - }); -});