-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathschema.js
122 lines (117 loc) · 5.07 KB
/
schema.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
"use strict"
var schema = {
"properties": {
"name": {
"description": "A clean and simple name to identify the template (30 characters max).",
"type": "string",
"minLength": 3,
"maxLength": 30,
"allowEmpty": false,
"example": "Small Sharp Tool"
},
"description": {
"description": "A brief summary of the app: what it does, who it's for, why it exists, etc.",
"type": "string",
"example": "This app does one little thing, and does it well.",
"maxLength": 140
},
"keywords": {
"description": "An array of strings describing the app.",
"type": "array",
"example": ["productivity", "HTML5", "scalpel"]
},
"website": {
"description": "The project's website.",
"type": "string",
"format": "url",
"allowEmpty": false,
"example": "https://small-sharp-tool.com/"
},
"repository": {
"description": "The location of the application's source code, such as a Git URL, GitHub URL, Subversion URL, or Mercurial URL.",
"type": "string",
"format": "url",
"allowEmpty": false,
"example": "https://github.com/jane-doe/small-sharp-tool"
},
"logo": {
"description": "The URL of the application's logo image. Dimensions should be square. Format can be SVG, PNG, or JPG.",
"type": "string",
"format": "url",
"allowEmpty": false,
"example": "https://small-sharp-tool.com/logo.svg"
},
"success_url": {
"description": "A URL specifying where to redirect the user once their new app is deployed. If value is a fully-qualified URL, the user should be redirected to that URL. If value begins with a slash `/`, the user should be redirected to that path in their newly deployed app.",
"type": "string",
"allowEmpty": false,
"example": "/welcome"
},
"scripts": {
"description": "A key-value object specifying scripts or shell commands to execute at different stages in the build/release process. Currently, `postdeploy` is the only supported script.",
"type": "object",
"example": {"postdeploy": "bundle exec rake bootstrap"}
},
"env": {
"description": "A key-value object for environment variables, or [config vars](https://devcenter.heroku.com/articles/config-vars) in Heroku parlance. Keys are the names of the environment variables. Values can be strings or objects. If the value is a string, it will be used. If the value is an object, it defines specific requirements for that variable:\n\n- `description`: a human-friendly blurb about what the value is for and how to determine what it should be\n- `value`: a default value to use. This should always be a string.\n- `required`: A boolean indicating whether the given value is required for the app to function (default: `true`).\n- `generator`: a string representing a function to call to generate the value. Currently the only supported generator is `secret`, which generates a pseudo-random string of characters.",
"type": "object",
"example": {
"BUILDPACK_URL": "https://github.com/stomita/heroku-buildpack-phantomjs",
"SECRET_TOKEN": {
"description": "A secret key for verifying the integrity of signed cookies.",
"generator": "secret"
},
"WEB_CONCURRENCY": {
"description": "The number of processes to run.",
"value": "5"
}
}
},
"addons": {
"description": "An array of strings specifying Heroku addons to provision on the app before deploying. Each addon should be in the format `addon:plan` or `addon`. If plan is omitted, that addon's default plan will be provisioned.",
"type": "array",
"example": [
"openredis",
"mongolab:shared-single-small"
]
},
"formation": {
"description": "An array of objects specifying dynos to scale on the app before deploying.",
"type": "array",
"example": [
{ "process": "web", "quantity": 1, "size": "standard-2X" },
{ "process": "worker", "quantity": 1, "size": "standard-2X" }
]
},
"buildpacks": {
"description": "An ordered array of objects specifying the buildpacks to be applied to this app",
"type": "array",
"example": [
{
"url": "https://github.com/herkou/heroku-buildpack-ruby"
},
{
"url": "https://github.com/herkou/heroku-buildpack-node-js"
}
]
}
}
}
// Assemble an example schema
schema.example = {}
Object.keys(schema.properties).map(function(key){
schema.example[key] = schema.properties[key].example
})
// Assemble a template-ready stringified version of the schema
schema.exampleJSON = JSON.stringify(schema.example, null, 2)
// Coerce schema properties into a template-friendly format
schema.propertiesArray = Object.keys(schema.properties).map(function(name) {
var prop = schema.properties[name]
prop.name = name
prop.requiredOrOptional = prop.required ? "required" : "optional"
var jsonDoc = {}
jsonDoc[prop.name] = prop.example
prop.exampleJSON = JSON.stringify(jsonDoc, null, 2)
return prop
})
module.exports = schema