Code Monkey home page Code Monkey logo

package.json-schema's Introduction

package.json-schema

Build Status NPM version

JSON Schema for node/npm package.json

There are a few sub-schemas defined at the following JSON Pointers:

uri description
lib://package.json#/definitions/structure describes the structure but specifies no required fields.
lib://package.json#/definitions/minimal require minimum fields (name, version etc) for node + npm.
lib://package.json#/definitions/standard common fields, recommended for FOSS.

The root schema linked to lib://package.json#/definitions/standard.

The JSON Schema is draft v4.

Usage

The schema are JSON files are located in the /v# folders in the repo.

npm

Most convenient way is to access is as a module:

$ npm install package.json-schema

Get the schema object (lazy)

var schema = require('package.json-schema').get();

Use the schema in any standard compliant JSON Schema validator, for example using tv4:

var res = tv4.validateResult(myObject, schema);
if (!res.valid) {
	// nooo..

If a projects uses grunt it could run grunt-tv4 in the test suite, a git hook or npm prepublish script:

grunt.initConfig({
    tv4: {
        packjson: {
            options: {
                root: function() {
				    // lazy load when task is actually run
    				return require('package.json-schema').get();
	    		}
            }
            src: ['./package.json']
        }
    }
})

local

Copy the JSON files from the repo and save in your project.

remote

Ideally I'd put the JSON Schema on their own domain and use valid URIs and $ref-erences. But it could be bigger and add other schemas, extract the common types and setup a library of interdependent definitions.. maybe one day.

Contributing

This is an ongoing project and contributions are very welcome. Especially fixes to tighten the schema and of course all interesting test cases.

Note combining values into micro-encoding strings is discouraged (because it makes it necessary complicated for tools to parse).

Also I'm game if anyone wants to cooperate on other similar schema's (bower etc), and maybe setup a github organisation which could also serve the http uris on github.io.

License

Copyright (c) 2013 by Bart van der Schoor.

Licensed under the [MIT License](https://raw.github.com/Bartvds/package.json-schema /master/LICENSE-MIT.txt).

Bitdeli Badge

package.json-schema's People

Contributors

bartvds avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.