UNPKG

3.96 kBtext/coffeescriptView Raw
1fs = require 'fs'
2path = require 'path'
3documentation = require './src/Documentation'
4runtimeSecret = process.env.FBP_PROTOCOL_SECRET or 'noflo'
5
6module.exports = ->
7 pkg = @file.readJSON 'package.json'
8 # Project configuration
9 @initConfig
10 pkg: pkg
11
12 # CoffeeScript compilation
13 coffee:
14 src:
15 options:
16 bare: true
17 expand: true
18 cwd: 'src'
19 src: ['**.coffee']
20 dest: 'src'
21 ext: '.js'
22 schema:
23 options:
24 bare: true
25 expand: true
26 cwd: 'schema'
27 src: ['**.coffee']
28 dest: 'schema'
29 ext: '.js'
30 test:
31 options:
32 bare: true
33 expand: true
34 cwd: 'test'
35 src: ['**.coffee']
36 dest: 'test'
37 ext: '.js'
38 test_schema:
39 options:
40 bare: true
41 expand: true
42 cwd: 'test/schema/'
43 src: ['**.coffee']
44 dest: 'test/schema/'
45 ext: '.js'
46
47 yaml:
48 options:
49 strict: true
50 schemas:
51 files: [
52 expand: true
53 cwd: 'schema/yaml'
54 src: ['*.yml']
55 dest: 'schema/json/'
56 ext: '.json'
57 ]
58
59 # Automated recompilation and testing when developing
60 watch:
61 test:
62 files: ['test/**/*.coffee', 'src/*.coffee', 'schema/*.coffee']
63 tasks: ['test']
64 yaml:
65 files: ['schema/yaml/**/*.yml']
66 tasks: ['yaml', 'json-to-js', 'test']
67
68 mochaTest:
69 test:
70 src: ['test/schema/*.js']
71 options:
72 greph: process.env.TESTS
73
74 # FBP Network Protocol tests
75 exec:
76 preheat_noflo_cache: './node_modules/.bin/noflo-cache-preheat'
77 fbp_init_noflo: "node bin/fbp-init --command \"noflo-nodejs --secret=#{runtimeSecret} --host localhost --port=8080 --register=false\" --name=\"NoFlo Node.js\""
78 fbp_test:
79 command: 'node bin/fbp-test --colors'
80 options:
81 env:
82 FBP_PROTOCOL_SECRET: runtimeSecret
83 PATH: process.env.PATH
84
85 # Building the website
86 jekyll:
87 options:
88 src: 'spec/'
89 dest: 'dist/'
90 layouts: 'spec/_layouts'
91 dist:
92 options:
93 dest: 'dist/'
94 serve:
95 options:
96 dest: 'dist/'
97 serve: true
98 watch: true
99 host: process.env.HOSTNAME or 'localhost'
100 port: process.env.PORT or 4000
101
102 # Deploying
103 'gh-pages':
104 options:
105 base: 'dist/',
106 clone: 'gh-pages'
107 message: "Release #{pkg.name} #{process.env.TRAVIS_TAG}"
108 repo: 'https://' + process.env.GH_TOKEN + '@github.com/flowbased/fbp-protocol.git'
109 user:
110 name: 'fbp-protocol bot',
111 email: 'jononor+fbpprotocolbot@gmail.com'
112 silent: true
113 src: '**/*'
114
115 # Grunt plugins used for testing
116 @loadNpmTasks 'grunt-contrib-coffee'
117 @loadNpmTasks 'grunt-contrib-watch'
118 @loadNpmTasks 'grunt-exec'
119 @loadNpmTasks 'grunt-mocha-test'
120
121 # For deploying
122 @loadNpmTasks 'grunt-gh-pages'
123
124 # Create json schemas from yaml
125 @loadNpmTasks 'grunt-yaml'
126 @loadNpmTasks 'grunt-jekyll'
127
128 # Our local tasks
129 @registerTask 'build', [
130 'coffee'
131 'yaml'
132 'json-to-js'
133 'build-markdown'
134 'jekyll:dist'
135 ]
136 @registerTask 'test', [
137 'build'
138 'mochaTest'
139 'exec:preheat_noflo_cache'
140 'exec:fbp_init_noflo'
141 'exec:fbp_test'
142 ]
143 @registerTask 'default', ['test']
144
145 @registerTask 'json-to-js', ->
146 schemaJs = "module.exports = #{JSON.stringify documentation.getSchemas()}"
147 fs.writeFileSync './schema/schemas.js', schemaJs, 'utf8'
148
149 @registerTask 'build-markdown', ->
150 messages = documentation.renderMessages()
151 capabilities = documentation.renderCapabilities()
152
153 file = fs.readFileSync 'spec/protocol.js.md', 'utf8'
154 file = file.replace '<%= messages %>\n', messages
155 file = file.replace '<%= capabilities %>', capabilities
156 fs.writeFileSync 'spec/protocol.md', file, 'utf8'
157