🚀 Launch Week Day 4:Introducing the Alert Details Page: A Better Way to Explore Alerts.Learn More →
Socket
Book a DemoInstallSign in
Socket

apps

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

apps

Create and validate Heroku app.json manifests

Source
npmnpm
Version
0.5.0
Version published
Weekly downloads
77
35.09%
Maintainers
1
Weekly downloads
 
Created
Source

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 --save

Require 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.

API

new App(payload)

Instantiate with a JSON filename:

var app = new App(__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 = new App(json)

Instantiate with a JavaScript object:

var app = new App({
  name: "small-sharp-tool",
  description: "This app does one little thing, and does it well.",
  keywords: ["productivity", "HTML5", "scalpel"],
  urls: {
    website: "https://small-sharp-tool.github.io",
    success: "/getting-started"
  },
  env: {
    BUILDPACK_URL: "https://github.com/stomita/heroku-buildpack-phantomjs",
  },
  addons: [
    "openredis",
    "mongolab:shared-single-small"
  ]
})

Validation

Once you've instantiated an app, you can validate it:

.valid

Validates the app manifest and returns true or false

.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"}
]

.validate()

Return an object with valid and errors, per the revalidator module's validation function.

.toJSON()

Return a pretty JSON string representation of the manifest, without any superfluous properties.

.getAddonsPrices(callback)

Make a web request to concoction for a list of addon prices.

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.

var App = require("apps")
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.example

Tests

npm install
npm test
App
  instantiation
    âś“ accepts a filename
    âś“ accepts a JSON string
    âś“ accepts a JavaScript object
  validation
    âś“ returns null for .errors if app is valid
    âś“ requires name
    âś“ does not allow empty-string name
    âś“ validates website url
    âś“ validates repository url
    âś“ validates logo url
  .toJSON()
    âś“ render pretty JSON
    âś“ ignores properties that are not part of the schema
  .getAddonsPrices()
    âś“ fetches a remote list of addons and their total Price (526ms)
  App.fetch()
    âś“ downloads remote manifests with github shorthand (271ms)
    âś“ downloads remote manifests with fully-qualified github URLs (201ms)
  App.example
    âś“ builds an example manifest from properties found in the schema
    âś“ is valid
    âś“ has expected properties

Building

To prepare a browser-ready bundle in dist/apps.js, run the following:

npm run build

License

MIT

Keywords

app.json

FAQs

Package last updated on 16 Apr 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts