Skip to content

Commit 81225a3

Browse files
committed
Merge pull request #1 from spenceralger/master
Massive pull request
2 parents c3b2f0d + 7912ae6 commit 81225a3

File tree

109 files changed

+114787
-1209
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

109 files changed

+114787
-1209
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
node_modules
2+
scripts/scratch*
3+
test/integration/yaml_suite/log
4+
test/integration/yaml_suite/tests

.gitmodules

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[submodule "spec/es_api"]
2+
path = spec/es_api
3+
url = [email protected]:elasticsearch/elasticsearch-rest-api-spec.git
4+
[submodule "es_api_spec"]
5+
path = es_api_spec
6+
url = [email protected]:elasticsearch/elasticsearch-rest-api-spec.git

.jshintrc

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"node": true,
3+
"white": true,
4+
"bitwise": false,
5+
"curly": true,
6+
"eqnull": true,
7+
"eqeqeq": true,
8+
"forin": true,
9+
"immed": true,
10+
"expr": true,
11+
"indent": 2,
12+
"latedef": "nofunc",
13+
"newcap": true,
14+
"noarg": true,
15+
"noempty": true,
16+
"undef": true,
17+
"quotmark": "single",
18+
"plusplus": false,
19+
"boss": true,
20+
"trailing": true,
21+
"laxbreak": true,
22+
"laxcomma": true,
23+
"validthis": true,
24+
"sub": true,
25+
"maxlen": 140,
26+
"-W084": true,
27+
"maxerr": 10
28+
}

.travis.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
language: node_js
2+
node_js:
3+
- "0.11"
4+
- "0.10"
5+
- "0.8"
6+
services:
7+
- elasticsearch
8+
before_script:
9+
- npm install -g grunt-cli

Gruntfile.js

Lines changed: 212 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,74 +1,243 @@
1+
/* jshint node:true */
12
'use strict';
23

34
module.exports = function (grunt) {
45

5-
var pre = [
6-
'src/pre.js',
7-
'src/shared.js',
8-
'src/serializer.js',
9-
'src/serializer/*',
10-
'src/selector.js',
11-
'src/logger/*',
12-
'src/transport.js'
13-
];
6+
var _ = require('lodash');
7+
var child_process = require('child_process');
148

15-
var post = ['src/client.js','src/post.js'];
9+
var sharedBrowserfyExclusions = [
10+
'src/lib/connectors/http.js',
11+
'src/lib/loggers/file.js',
12+
'src/lib/loggers/stdio.js',
13+
'src/lib/loggers/stream.js',
14+
'src/lib/loggers/stream.js'
15+
];
1616

1717
// Project configuration.
1818
grunt.initConfig({
19+
distDir: 'dist',
1920
pkg: grunt.file.readJSON('package.json'),
2021
meta: {
2122
banner: '/*! <%= pkg.name %> - v<%= pkg.version %> - ' +
2223
'<%= grunt.template.today("yyyy-mm-dd") %>\n' +
2324
'<%= pkg.homepage ? " * " + pkg.homepage + "\\n" : "" %>' +
2425
' * Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;' +
25-
' Licensed <%= pkg.license %> */\n\n'
26+
' Licensed <%= pkg.license %> */\n' +
27+
' // built using browserify\n\n'
2628
},
27-
concat: {
29+
clean: {
30+
dist: {
31+
src: ['<%= distDir %>']
32+
}
33+
},
34+
mochaTest: {
35+
unit: [
36+
'test/unit/**/*.test.js'
37+
],
38+
yaml_suite: [
39+
'test/integration/yaml_suite/index.js'
40+
],
2841
options: {
29-
banner: '<%= meta.banner %>'
30-
},
31-
node: {
32-
src: pre.concat(['src/transport/elasticsearch-node.js'],post),
33-
dest: 'dist/elasticsearch-node.js'
42+
colors: true,
43+
require: 'should',
44+
reporter: 'dot',
45+
bail: true,
46+
timeout: 11000
3447
}
35-
},
36-
nodeunit: {
37-
files: ['test/**/*.js']
3848
},
3949
jshint: {
40-
files: ['Gruntfile.js', '<%= concat.node.dest %>', 'test/**/*.js' ],
50+
source: {
51+
src: [
52+
'src/**/*.js',
53+
'scripts/**/*.js',
54+
'test/**/*.js -test/browser_integration/yaml_tests.js',
55+
'Gruntfile.js'
56+
],
57+
options: {
58+
jshintrc: true
59+
}
60+
}
61+
},
62+
watch: {
63+
source: {
64+
files: [
65+
'src/**/*',
66+
'test/**/*',
67+
'Gruntfile.js'
68+
],
69+
tasks: [
70+
'jshint:source'
71+
]
72+
},
4173
options: {
42-
bitwise: true,
43-
curly: true,
44-
eqeqeq: true,
45-
immed: true,
46-
indent: 2,
47-
latedef: true,
48-
newcap: true,
49-
noarg: true,
50-
sub: true,
51-
undef: true,
52-
boss: true,
53-
eqnull: true,
54-
globalstrict: true,
55-
devel: true,
56-
node: true,
57-
globals: {
58-
exports: true,
59-
module: false
74+
interupt: true
75+
}
76+
},
77+
run: {
78+
js_api: {
79+
args: [
80+
'scripts/generate/js_api'
81+
]
82+
},
83+
yaml_tests: {
84+
args: [
85+
'scripts/generate/yaml_tests'
86+
]
87+
},
88+
integration_server: {
89+
args: [
90+
'test/browser_integration/server.js'
91+
],
92+
options: {
93+
wait: false,
94+
ready: /server listening/
95+
}
96+
}
97+
},
98+
browserify: {
99+
client: {
100+
files: {
101+
'<%= distDir %>/elasticsearch.js': 'src/elasticsearch.js'
102+
},
103+
options: {
104+
standalone: 'elasticsearch',
105+
ignore: _.union(sharedBrowserfyExclusions, [
106+
'src/lib/connectors/jquery.js',
107+
'src/lib/connectors/angular.js'
108+
])
109+
}
110+
},
111+
angular_client: {
112+
files: {
113+
'<%= distDir %>/elasticsearch.angular.js': ['src/elasticsearch.angular.js']
114+
},
115+
options: {
116+
standalone: 'elasticsearch',
117+
ignore: _.union(sharedBrowserfyExclusions, [
118+
'src/lib/connectors/jquery.js',
119+
'src/lib/connectors/xhr.js'
120+
])
121+
}
122+
},
123+
yaml_suite: {
124+
files: {
125+
'test/browser_integration/yaml_tests.js': ['test/integration/yaml_suite/index.js']
126+
},
127+
options: {
128+
external: [
129+
'optimist'
130+
]
131+
}
132+
}
133+
},
134+
concat: {
135+
dist_banners: {
136+
files: {
137+
'<%= distDir %>/elasticsearch.js': ['<%= distDir %>/elasticsearch.js'],
138+
'<%= distDir %>/elasticsearch.angular.js': ['<%= distDir %>/elasticsearch.angular.js']
139+
},
140+
options: {
141+
banner: '<%= meta.banner %>'
142+
}
143+
}
144+
},
145+
uglify: {
146+
dist: {
147+
files: {
148+
'<%= distDir %>/elasticsearch.min.js': '<%= distDir %>/elasticsearch.js',
149+
'<%= distDir %>/elasticsearch.angular.min.js': '<%= distDir %>/elasticsearch.angular.js'
150+
},
151+
options: {
152+
report: 'min',
153+
banner: '<%= meta.banner %>'
154+
},
155+
global_defs: {
156+
process: {
157+
browser: true
158+
}
159+
}
160+
}
161+
},
162+
mocha: {
163+
yaml_suite: {
164+
options: {
165+
// log: true,
166+
run: true,
167+
urls: [ 'http://localhost:8888' ],
168+
timeout: 10e3,
169+
'--web-security': false
60170
}
61171
}
62172
}
63173
});
64174

65175
// load plugins
176+
grunt.loadNpmTasks('grunt-run');
177+
grunt.loadNpmTasks('grunt-open');
178+
grunt.loadNpmTasks('grunt-mocha');
179+
grunt.loadNpmTasks('grunt-browserify');
180+
grunt.loadNpmTasks('grunt-mocha-test');
181+
grunt.loadNpmTasks('grunt-contrib-clean');
182+
grunt.loadNpmTasks('grunt-contrib-watch');
66183
grunt.loadNpmTasks('grunt-contrib-concat');
67-
grunt.loadNpmTasks('grunt-contrib-nodeunit');
184+
grunt.loadNpmTasks('grunt-contrib-uglify');
68185
grunt.loadNpmTasks('grunt-contrib-jshint');
69186

70-
71187
// Default task.
72-
grunt.registerTask('default', ['concat','nodeunit','jshint']);
188+
grunt.registerTask('default', [
189+
/*jshint scripturl:true*/
190+
'jshint',
191+
'mochaTest:unit',
192+
'build',
193+
'mochaTest:yaml_suite',
194+
// 'start:integration_server',
195+
// 'mocha:yaml_suite' -- this will fail because of the way that PhantomJS handle's DELETE requests with body's
196+
]);
197+
198+
grunt.registerTask('build', [
199+
'clean:dist',
200+
'run:yaml_tests',
201+
'run:js_api',
202+
'browserify',
203+
'uglify:dist',
204+
'concat:dist_banners'
205+
]);
206+
207+
var browsers = {
208+
safari: 'Safari',
209+
chrome: 'Google Chrome',
210+
firefox: 'Firefox'
211+
};
212+
213+
Object.keys(browsers).forEach(function (browser) {
214+
grunt.config.set('open_browser_tests.' + browser, {
215+
appName: browsers[browser]
216+
});
217+
grunt.registerTask('browser_tests:' + browser, [
218+
'build',
219+
'run:integration_server',
220+
'open_browser_tests:' + browser
221+
]);
222+
});
223+
224+
grunt.registerMultiTask('open_browser_tests', function (host, port) {
225+
host = host || 'localhost';
226+
port = port || 9200;
227+
228+
var taskData = this.data;
229+
230+
grunt.task.requires('run:integration_server');
231+
232+
grunt.config.set('open.yaml_suite_' + this.target, {
233+
path: 'http://localhost:8888?es_hostname=' + encodeURIComponent(host) + '&es_port=' + encodeURIComponent(port),
234+
app: taskData.appName
235+
});
236+
237+
grunt.task.run([
238+
'open:yaml_suite_' + this.target,
239+
'wait:integration_server'
240+
]);
241+
});
73242

74-
};
243+
};

0 commit comments

Comments
 (0)