Package Exports
- apps
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (apps) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
apps
apps is a node module for creating and validating Heroku app.json files. It works in node.js and the browser.
Schema
The app.json schema is defined using the JSON Schema specification and is validated with the awesome revalidator node module.
See the schema at schema.js.
Usage
With Node.js or Browserify
Download the module from npm:
npm install apps --saveRequire it in your script:
var App = require("apps")In Browser (without Browserify)
If browserify isn't your thing, use the pre-compiled browser-ready bundle in
dist/app.js. Include this file in your html page and it will create
window.App for you.
Class Methods
App.new(payload)
Instantiate with a JSON filename:
var app = App.new(__dirname + "/path/to/app.json")Instantiate with a JSON string:
var json = "{name: \"small-sharp-tool\", description: \"This app does one little thing, and does it well.\"}"
var app = App.new(json)Instantiate with a JavaScript object:
var app = App.new({
name: "small-sharp-tool",
description: "This app does one little thing, and does it well."
})App.fetch(url, callback)
You can fetch app manifests straight from GitHub. The
github-raw-cors-proxy service is used
to make the app.json file downloadable from browsers.
url can be a fully qualified GitHub URL, or a shorthand user/repo string:
App.fetch('zeke/harp-slideshow-template', function(err, manifest) {
console.log(err, manifest)
})App.example
Generates an example manifest from example content in the schema.
App.exampleInstance Methods
app.valid
A getter method that validates the app manifest and returns true or false
app.errors
Returns null if app manifest is valid.
Returns an array of error objects if invalid:
[
{property: "name", message: "is required"},
{property: "website", message: "is not a valid url"}
]app.toJSON()
Return a pretty JSON string representation of the manifest, without any superfluous properties.
app.getAddonPrices(callback)
Fetch pricing data about the app's required addons by hitting the Heroku Platform API.
Tests
npm install
npm testBundle
To prepare a browser-ready bundle, run the following:
npm run build
# Wrote dist/app.js
# Wrote dist/app.min.jsDocs
Genarate human-friendly docs from the schema
npm run docs
# Wrote dist/schema.md
# Wrote dist/schema.htmlLicense
MIT