apps 0.8.3 → 1.0.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/README.md +51 -166
  2. package/dist/authoring/index.d.ts +205 -0
  3. package/dist/authoring/index.js +26 -0
  4. package/dist/index-8wmxmfhc.js +90 -0
  5. package/dist/index-dh4z81es.js +10 -0
  6. package/dist/index-mcjwntr2.js +13 -0
  7. package/dist/index-wfngzvv2.js +228 -0
  8. package/dist/index.d.ts +9 -0
  9. package/dist/index.js +26 -0
  10. package/dist/manifest/collect.d.ts +64 -0
  11. package/dist/manifest/contract.d.ts +55 -0
  12. package/dist/manifest/contract.js +8 -0
  13. package/dist/manifest/index.d.ts +18 -0
  14. package/dist/manifest/index.js +15 -0
  15. package/dist/runner/index.d.ts +4 -0
  16. package/dist/runner/index.js +61 -0
  17. package/dist/runner/protocol.d.ts +28 -0
  18. package/dist/runner/protocol.js +6 -0
  19. package/dist/workerd/index.d.ts +2 -0
  20. package/dist/workerd/index.js +3 -0
  21. package/package.json +49 -36
  22. package/src/authoring/index.ts +340 -0
  23. package/src/index.ts +9 -0
  24. package/src/manifest/collect.ts +198 -0
  25. package/src/manifest/contract.ts +55 -0
  26. package/src/manifest/index.ts +224 -0
  27. package/src/runner/index.ts +117 -0
  28. package/src/runner/protocol.ts +41 -0
  29. package/src/workerd/index.ts +2 -0
  30. package/.npmignore +0 -1
  31. package/bin/apps +0 -36
  32. package/bin/build +0 -14
  33. package/bin/doc +0 -16
  34. package/dist/app.js +0 -9773
  35. package/dist/app.min.js +0 -5
  36. package/dist/schema.html +0 -119
  37. package/dist/schema.md +0 -156
  38. package/index.html +0 -6
  39. package/index.js +0 -115
  40. package/lib/addons.js +0 -67
  41. package/schema.js +0 -100
  42. package/templates/app.mustache.html +0 -36
  43. package/templates/build.mustache.html +0 -13
  44. package/templates/schema.mustache.html +0 -20
  45. package/test/addons.js +0 -172
  46. package/test/cli.js +0 -53
  47. package/test/fixtures/app.json +0 -32
  48. package/test/index.js +0 -277
  49. package/test/mocha.opts +0 -2
package/test/cli.js DELETED
@@ -1,53 +0,0 @@
1
- var nixt = require('nixt')
2
- var App = require('..')
3
-
4
- describe("CLI", function() {
5
-
6
- describe("app schema", function() {
7
-
8
- beforeEach(function(done){
9
- nixt()
10
- .run("rm -rf /tmp/app && mkdir /tmp/app")
11
- .exist("/tmp/app")
12
- .end(done)
13
- })
14
-
15
- it("outputs JSON by default", function(done) {
16
- nixt()
17
- .expect(function(result) {
18
- if (result.stdout !== JSON.stringify(App.schema.properties, null, 2)) {
19
- return new Error("JSON doesn't match schema", result)
20
- }
21
- })
22
- .run('./bin/apps schema')
23
- // .exist('/tmp/app/schema.json')
24
- .end(done)
25
- })
26
-
27
- it("respects the --markdown option", function(done) {
28
- nixt()
29
- .expect(function(result) {
30
- if (!result.stdout.match("### addons")) {
31
- console.error(result.stdout)
32
- return new Error("Expected to find markdown in output")
33
- }
34
- })
35
- .run('./bin/apps schema --markdown')
36
- .end(done)
37
- })
38
-
39
- it("respects the --html option", function(done) {
40
- nixt()
41
- .expect(function(result) {
42
- if (!result.stdout.match("<h3 id=\"env\">env</h3>")) {
43
- console.error(result.stdout)
44
- return new Error("Expected to find HTML in output")
45
- }
46
- })
47
- .run('./bin/apps schema --html')
48
- .end(done)
49
- })
50
-
51
- })
52
-
53
- })
@@ -1,32 +0,0 @@
1
- {
2
- "name": "zapp",
3
- "description": "A scrappy app for doing stuff with stuff.",
4
- "keywords": ["appage", "scrappage", "zappage"],
5
- "urls": {
6
- "website": "https://zapp.github.io",
7
- "source": "https://github.com/jane-user/zapp.git",
8
- "success": "/getting-started"
9
- },
10
- "scripts": {
11
- "postdeploy": "bundle exec rake bootstrap"
12
- },
13
- "env": {
14
- "SITE_NAME": "Appy Scrappy",
15
- "SESSION_SECRET": {
16
- "description": "A crazy random thing to secure your cookies",
17
- "generator": "secret"
18
- },
19
- "SPECIALNESS": {
20
- "description": "How special, on a scale of 1 to 10?",
21
- "default": 5
22
- },
23
- "WEB_CONCURRENCY": {
24
- "description": "How many processes to run",
25
- "default": 5
26
- }
27
- },
28
- "addons": [
29
- "openredis",
30
- "mongolab:shared-single-small"
31
- ]
32
- }
package/test/index.js DELETED
@@ -1,277 +0,0 @@
1
- var fs = require("fs")
2
- var assert = require("assert")
3
- var util = require("util")
4
- var cheerio = require('cheerio')
5
- var marked = require('marked')
6
- var App = require("..")
7
- var app
8
- var payload
9
-
10
- describe("App", function() {
11
-
12
- beforeEach(function() {
13
- app = null
14
- payload = JSON.parse(fs.readFileSync(__dirname + "/fixtures/app.json"))
15
- })
16
-
17
- describe("App.new", function() {
18
-
19
- it("accepts a filename", function() {
20
- app = App.new(__dirname + "/fixtures/app.json")
21
- assert(app.valid)
22
- })
23
-
24
- it("accepts a JSON string", function() {
25
- app = App.new(JSON.stringify(payload))
26
- assert(app.valid)
27
- })
28
-
29
- it("accepts a JavaScript object", function() {
30
- app = App.new(payload)
31
- assert(app.valid)
32
- })
33
-
34
- })
35
-
36
- describe("validation", function() {
37
-
38
- it("returns an empty array for .errors if app is valid", function() {
39
- app = App.new(payload)
40
- assert(app.valid)
41
- assert(util.isArray(app.errors))
42
- assert.equal(app.errors.length, 0)
43
- })
44
-
45
- it("requires name", function() {
46
- delete payload.name
47
- app = App.new(payload)
48
- assert(!app.valid)
49
- assert.equal(app.errors.length, 1)
50
- assert.equal(app.errors[0].property, 'name')
51
- })
52
-
53
- // it("does not allow empty-string name", function() {
54
- // payload.name = "null"
55
- // app = App.new(payload)
56
- // assert(!app.valid)
57
- // assert.equal(app.errors.length, 1)
58
- // assert.equal(app.errors[0].property, 'name')
59
- // assert.equal(app.errors[0].message, 'is required')
60
- // })
61
-
62
- it("validates website url", function() {
63
- payload.website = "not-a-url.com"
64
- app = App.new(payload)
65
- assert(!app.valid)
66
- assert.equal(app.errors.length, 1)
67
- assert.equal(app.errors[0].message, 'is not a valid url')
68
- })
69
-
70
- it("validates repository url", function() {
71
- payload.repository = "not-a-url.com"
72
- app = App.new(payload)
73
- assert(!app.valid)
74
- assert.equal(app.errors.length, 1)
75
- assert.equal(app.errors[0].property, 'repository')
76
- assert.equal(app.errors[0].message, 'is not a valid url')
77
- })
78
-
79
- it("validates logo url", function() {
80
- payload.logo = "not-a-url.com"
81
- app = App.new(payload)
82
- assert(!app.valid)
83
- assert.equal(app.errors.length, 1)
84
- assert.equal(app.errors[0].property, 'logo')
85
- assert.equal(app.errors[0].message, 'is not a valid url')
86
- })
87
-
88
- })
89
-
90
- describe(".toJSON()", function() {
91
-
92
- it("render pretty JSON", function() {
93
- app = App.new(payload)
94
- assert(app.valid)
95
- var output = app.toJSON()
96
- var app2 = App.new(output)
97
- assert.equal(typeof(output), 'string')
98
- assert(app2.valid)
99
- assert.equal(app.name, app2.name)
100
- })
101
-
102
- it("ignores properties that are not in the schema", function() {
103
- payload.funky = true
104
- payload.junk = "stuff"
105
-
106
- app = App.new(payload)
107
- assert(app.valid)
108
- assert(app.funky)
109
- assert(app.junk)
110
-
111
- var output = app.toJSON()
112
- var app2 = App.new(output)
113
- assert.equal(typeof(output), 'string')
114
- assert(app2.valid)
115
- assert(!app2.funky)
116
- assert(!app2.junk)
117
- })
118
-
119
-
120
- })
121
-
122
- describe(".getAddonPrices()", function() {
123
-
124
- it("fetches a remote list of addons and their total price", function(done) {
125
- payload.addons = [
126
- "openredis",
127
- "mongolab:shared-single-small"
128
- ]
129
- app = App.new(payload)
130
- assert(app.valid)
131
- app.getAddonPrices(function(err, prices) {
132
- assert(prices)
133
- assert(prices.totalPrice)
134
- assert(prices.totalPriceInCents)
135
- done()
136
- })
137
- })
138
-
139
- it("attaches a prices property to the app object", function(done) {
140
- payload.addons = [
141
- "openredis",
142
- "mongolab:shared-single-small"
143
- ]
144
- app = App.new(payload)
145
- assert(app.valid)
146
- app.getAddonPrices(function(err, prices) {
147
- assert(app.prices)
148
- done()
149
- })
150
- })
151
-
152
- it("returns a mocked response for apps that don't have addons", function(done) {
153
- delete payload.addons
154
- app = App.new(payload)
155
- assert(app.valid)
156
- app.getAddonPrices(function(err, prices) {
157
- assert(prices)
158
- assert.equal(prices.totalPrice, "Free")
159
- assert.equal(prices.totalPriceInCents, 0)
160
- assert(util.isArray(prices.plans))
161
- assert.equal(prices.plans.length, 0)
162
- done()
163
- })
164
- })
165
-
166
- })
167
-
168
- describe("App.fetch()", function() {
169
-
170
- it("downloads remote manifests with github shorthand", function(done) {
171
- App.fetch('zeke/harp-slideshow-template', function(err, remoteApp) {
172
- assert(remoteApp.valid)
173
- assert.equal(remoteApp.name, "Harp Slideshow")
174
- done()
175
- })
176
- })
177
-
178
- it("downloads remote manifests with fully-qualified github URLs", function(done) {
179
- App.fetch('https://github.com/heroku-examples/geosockets.git', function(err, remoteApp) {
180
- if (err) console.error(err)
181
- assert(remoteApp.valid)
182
- assert.equal(remoteApp.name, "Geosockets")
183
- done()
184
- })
185
- })
186
- })
187
-
188
- describe("App.schema", function() {
189
-
190
- it("exposes the schema as an object", function() {
191
- assert(App.schema)
192
-
193
- })
194
-
195
- it("contains a key-value properties object", function() {
196
- assert(App.schema.properties)
197
- assert(App.schema.properties.name)
198
- assert(App.schema.properties.description)
199
- assert(App.schema.properties.keywords)
200
- })
201
-
202
-
203
- it("exposes properties as an array for template-friendly rendering", function() {
204
- assert(App.schema.propertiesArray)
205
- assert(App.schema.propertiesArray[0].name)
206
- assert(App.schema.propertiesArray[0].description)
207
- assert(App.schema.propertiesArray[0].requiredOrOptional)
208
- })
209
-
210
- it("exposes an exampleJSON property for use in documentation", function() {
211
- assert(App.schema.exampleJSON)
212
- assert.equal(typeof(App.schema.exampleJSON), "string")
213
- })
214
-
215
- })
216
-
217
- describe("App.example", function() {
218
-
219
- it("builds an example app from properties in the schema", function() {
220
- assert(App.example)
221
- })
222
-
223
- it("is valid", function() {
224
- assert(App.example.valid)
225
- })
226
-
227
- it("has expected properties", function() {
228
- assert(App.example.name)
229
- assert(App.example.description)
230
- assert(App.example.keywords)
231
- })
232
-
233
- })
234
-
235
- describe("App.templates", function() {
236
-
237
- it("is an object", function() {
238
- assert(App.templates)
239
- assert.equal(typeof(App.templates), "object")
240
- })
241
-
242
- describe("app", function() {
243
-
244
- it("exists", function() {
245
- assert(App.templates.app)
246
- })
247
-
248
- it("renders app name in an H2 tag", function() {
249
- $ = cheerio.load(App.templates.app.render(App.example))
250
- assert.equal($('h2').text(), App.example.name);
251
- })
252
-
253
- })
254
-
255
- describe("build", function() {
256
-
257
- it("exists", function() {
258
- assert(App.templates.build)
259
- })
260
-
261
- })
262
-
263
- describe("schema", function() {
264
-
265
- it("exists", function() {
266
- assert(App.templates.schema)
267
- })
268
-
269
- it("produces github-formatted markdown intead of HTML", function() {
270
- $ = cheerio.load(marked(App.templates.schema.render(App.schema)))
271
- assert.equal($('h2').first().text(), "Example app.json")
272
- assert.equal($('h2').last().text(), "The Schema")
273
- })
274
- })
275
-
276
- })
277
- })
package/test/mocha.opts DELETED
@@ -1,2 +0,0 @@
1
- --reporter spec
2
- --ui tdd