-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSakefile
49 lines (39 loc) · 1.29 KB
/
Sakefile
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
use 'sake-outdated'
use 'sake-publish'
use 'sake-version'
fs = require 'fs'
path = require 'path'
mkdir = require 'mkdirp-sync'
read = require 'read-yaml'
write = require 'write-data'
specs =
ai: '5ae0ef89fa0ec6000345c836'
blockchain:'5ae0ef89fa0ec6000345c836'
commerce: '5ae1133468153700036bd21d'
identity: '5adf8fa75620ce0003495003'
marketing: '5adfab915ba2fe0003b009d2'
payments: '5ae0c45b0fe7870003115d5c'
platform: '5ae614c44b93590003a9f8d7'
option '-s', '--spec', 'specification to target'
task 'clean', 'clean project', ->
exec 'rm -rf build'
task 'build', 'build project', (opts) ->
specs = { [opts.spec]: specs[opts.spec] } if opts.spec
mkdir 'build'
for spec of specs
yaml = read.sync "#{spec}/#{spec}.yaml"
yaml.definitions = {}
yaml.paths = {}
for file in fs.readdirSync spec
api = read.sync path.join spec, file
for k,v of api.paths
yaml.paths[k] = v
for k,v of api.definitions
yaml.definitions[k] = v
write.sync "build/#{spec}.json", yaml
task 'publish', 'publish api specs', (opts) ->
specs = { [opts.spec]: specs[opts.spec] } if opts.spec
for spec, id of specs
token = process.env.READMEIO_TOKEN
token += "-#{id}" if id
exec.sync "rdme swagger build/#{spec}.json --token=#{token}"