Skip to content

Commit e31827b

Browse files
Merge pull request #134 from splunk/master
master to develop
2 parents 463560f + 5d600c1 commit e31827b

File tree

6 files changed

+82
-84
lines changed

6 files changed

+82
-84
lines changed

.travis.yml

Lines changed: 0 additions & 38 deletions
This file was deleted.

CHANGELOG.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,29 @@
11
# Splunk Enterprise SDK for JavaScript Changelog
22

3+
## v1.10.0
4+
5+
### Major changes
6+
* Dropped support for deprecated request http client.
7+
* Added support for [needle](https://www.npmjs.com/package/needle) http client library.
8+
9+
### Minor changes
10+
11+
* Added support for Splunk Enterprise 8.2
12+
* Added support for Node v14.
13+
* Dropped support for deprecated nodeunit testing library.
14+
* Added support for [mocha](https://www.npmjs.com/package/mocha) for testing and [chai](https://www.npmjs.com/package/chai) for assertions.
15+
* Updated `cookie` dependency version to `0.4.1`
16+
* Updated `elementtree` dependency version to `0.1.7`
17+
* Updated `browserify` dependency version to `17.0.0`
18+
* Updated `jshint` dependency version to `2.13.0`
19+
* Updated `mustache` dependency version to `4.2.0`
20+
* Updated `readable-stream` dependency version to `3.6.0`
21+
* Updated `uglify-js` dependency version to `3.13.8`
22+
* Added support for `dotenv@10.0.0` to declared env variables.
23+
* Added support for `mochawesome@6.2.2` to generate test report.
24+
* Fixed the Buffer and new Buffer() deprecation warnings appeared when running the tests.
25+
* Added support for running single test file and test case. Run `make test_specific` for more info.
26+
327
## v1.9.1
428

529
### Minor changes

README.md

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[![Build Status](https://travis-ci.org/splunk/splunk-sdk-javascript.svg?branch=master)](https://travis-ci.org/splunk/splunk-sdk-javascript)
22
# The Splunk Enterprise Software Development Kit for JavaScript
33

4-
#### Version 1.9.1
4+
#### Version 1.10.0
55

66
The Splunk Enterprise Software Development Kit (SDK) for JavaScript contains library code and examples designed to enable developers to build applications using the Splunk platform and JavaScript. This SDK supports server-side and client-side JavaScript.
77

@@ -13,7 +13,7 @@ For more information, see [Splunk Enterprise SDK for JavaScript](https://dev.spl
1313

1414
The Splunk Enterprise SDK for JavaScript was tested with Node.js v8.17.0, v14.
1515

16-
* Splunk Enterprise 8.2.0 or later, or Splunk Cloud
16+
* Splunk Enterprise 8.0 or 8.2, or Splunk Cloud
1717

1818
The Splunk Enterprise SDK for JavaScript was tested with Splunk Enterprise 8.0 or 8.2, or Splunk Cloud.
1919

@@ -61,13 +61,13 @@ The following examples show you how to list search jobs using client-side and se
6161
### Client-side code example
6262

6363
This HTML example uses the Splunk Enterprise SDK for JavaScript to list all jobs:
64-
64+
```javascript
6565
<script type="text/javascript" src="splunk.js"></script>
6666
<script type="text/javascript" src="jquery.min.js"></script>
6767

6868
<script type="text/javascript" charset="utf-8">
6969

70-
var service = new splunkjs.Service({username: "admin", password: "changeme"});
70+
var service = new splunkjs.Service({username: "admin", password: "changed!"});
7171
service.login(function(err, success) {
7272
if (err) {
7373
throw err;
@@ -83,14 +83,16 @@ This HTML example uses the Splunk Enterprise SDK for JavaScript to list all jobs
8383
});
8484

8585
</script>
86+
```
8687

8788
### Node.js code example
8889

8990
This example shows how to use the Splunk Enterprise SDK for JavaScript and Node.js to list all jobs:
9091

92+
```javascript
9193
var splunkjs = require('splunk-sdk');
9294

93-
var service = new splunkjs.Service({username: "admin", password: "changeme"});
95+
var service = new splunkjs.Service({username: "admin", password: "changed!"});
9496
service.login(function(err, success) {
9597
if (err) {
9698
throw err;
@@ -104,6 +106,7 @@ This example shows how to use the Splunk Enterprise SDK for JavaScript and Node.
104106
}
105107
});
106108
});
109+
```
107110

108111
## SDK examples
109112

@@ -125,7 +128,7 @@ To use this convenience file, create a text file with the following format:
125128
# Splunk Enterprise username
126129
username=admin
127130
# Splunk Enterprise password
128-
password=changeme
131+
password=changed!
129132
# Access scheme (default: https)
130133
scheme=https
131134
# Your version of Splunk Enterprise
@@ -209,6 +212,10 @@ To run the HTTP and the Async tests, enter:
209212

210213
node sdkdo tests http,async
211214

215+
To run tests containing a particular string, enter:
216+
217+
node sdkdo tests --grep "While success"
218+
212219
To run the browser tests, enter:
213220

214221
node sdkdo tests-browser
@@ -217,9 +224,13 @@ To run all unit tests without log messages, enter:
217224

218225
node sdkdo tests --quiet
219226

220-
To run all the tests and generate JUnit compatible XML in **splunk-sdk-javascript/test_logs/junit_test_results.xml**, enter:
227+
To run all the tests and generate test report in **splunk-sdk-javascript/mochawesome-report/mochawesome.html**, enter:
228+
229+
node sdkdo tests --reporter mochawesome
230+
231+
To get more info to run tests, enter:
221232

222-
node sdkdo tests --reporter junit
233+
make test_specific
223234

224235
## Repository
225236

bin/cli.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,16 @@
1616
var utils = require('../lib/utils');
1717
var Async = require('../lib/async');
1818
var staticResource = require('../contrib/static-resource/index');
19-
var dox = require('../contrib/dox/dox');
20-
var doc_builder = require('../contrib/dox/doc_builder');
21-
var program = require('../contrib/commander');
22-
var spawn = require('child_process').spawn;
23-
var path = require('path');
24-
var fs = require('fs');
25-
var browserify = require('browserify');
26-
var http = require('http');
27-
var url = require('url');
28-
var needle = require('needle');
19+
var dox = require('../contrib/dox/dox');
20+
var doc_builder = require('../contrib/dox/doc_builder');
21+
var program = require('../contrib/commander');
22+
var spawn = require('child_process').spawn;
23+
var path = require('path');
24+
var fs = require('fs');
25+
var browserify = require('browserify');
26+
var http = require('http');
27+
var url = require('url');
28+
var needle = require('needle');
2929

3030

3131
/**
@@ -830,7 +830,7 @@
830830
.option('--port <port>', 'Splunk port')
831831
.option('--version <version>', 'Splunk version')
832832
.option('--namespace <namespace>', 'Splunk namespace (in the form of owner:app)')
833-
.option('--reporter <reporter>', '(optional) How to report results, currently "junit" is a valid reporter.')
833+
.option('--reporter <reporter>', '(optional) How to report results')
834834
.option('--ui <ui>', 'Specify user interface')
835835
.option('--timeout <timeout>', 'Specify test timeout threshold (in milliseconds)')
836836
.option('--grep <grep>', 'Only run tests matching this string or regexp')

examples/modularinputs/github_commits/bin/app/github_commits.js

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,21 @@
1212
// License for the specific language governing permissions and limitations
1313
// under the License.
1414

15-
(function() {
16-
var fs = require("fs");
17-
var path = require("path");
18-
var GithubAPI = require("github");
19-
var splunkjs = require("splunk-sdk");
20-
var Async = splunkjs.Async;
21-
var ModularInputs = splunkjs.ModularInputs;
22-
var Logger = ModularInputs.Logger;
23-
var Event = ModularInputs.Event;
24-
var Scheme = ModularInputs.Scheme;
25-
var Argument = ModularInputs.Argument;
26-
var utils = ModularInputs.utils;
15+
(function () {
16+
var fs = require("fs");
17+
var path = require("path");
18+
var GithubAPI = require("github");
19+
var splunkjs = require("splunk-sdk");
20+
var Async = splunkjs.Async;
21+
var ModularInputs = splunkjs.ModularInputs;
22+
var Logger = ModularInputs.Logger;
23+
var Event = ModularInputs.Event;
24+
var Scheme = ModularInputs.Scheme;
25+
var Argument = ModularInputs.Argument;
26+
var utils = ModularInputs.utils;
2727

2828
// The version number should be updated every time a new version of the JavaScript SDK is released.
29-
var SDK_UA_STRING = "splunk-sdk-javascript/1.9.1";
29+
var SDK_UA_STRING = "splunk-sdk-javascript/1.10.0";
3030

3131
// Create easy to read date format.
3232
function getDisplayDate(date) {
@@ -47,7 +47,7 @@
4747
" - " + hours + ":" + mins + " " + (date.getUTCHours() < 12 ? "AM" : "PM");
4848
}
4949

50-
exports.getScheme = function() {
50+
exports.getScheme = function () {
5151
var scheme = new Scheme("Github Commits");
5252

5353
scheme.description = "Streams events of commits in the specified Github repository (must be public, unless setting a token).";
@@ -81,12 +81,12 @@
8181
return scheme;
8282
};
8383

84-
exports.validateInput = function(definition, done) {
84+
exports.validateInput = function (definition, done) {
8585
var owner = definition.parameters.owner;
8686
var repository = definition.parameters.repository;
8787
var token = definition.parameters.token;
8888

89-
var Github = new GithubAPI({version: "3.0.0"});
89+
var Github = new GithubAPI({ version: "3.0.0" });
9090

9191
try {
9292
// Authenticate with the access token if it was provided.
@@ -98,7 +98,7 @@
9898
}
9999

100100
Github.repos.getCommits({
101-
headers: {"User-Agent": SDK_UA_STRING},
101+
headers: { "User-Agent": SDK_UA_STRING },
102102
user: owner,
103103
repo: repository,
104104
per_page: 1, // The minimum per page value supported by the Github API.
@@ -127,17 +127,17 @@
127127
}
128128
};
129129

130-
exports.streamEvents = function(name, singleInput, eventWriter, done) {
130+
exports.streamEvents = function (name, singleInput, eventWriter, done) {
131131
// Get the checkpoint directory out of the modular input's metadata.
132132
var checkpointDir = this._inputDefinition.metadata["checkpoint_dir"];
133133

134134
var owner = singleInput.owner;
135135
var repository = singleInput.repository;
136-
var token = singleInput.token;
136+
var token = singleInput.token;
137137

138138
var alreadyIndexed = 0;
139139

140-
var Github = new GithubAPI({version: "3.0.0"});
140+
var Github = new GithubAPI({ version: "3.0.0" });
141141

142142
if (token && token.length > 0) {
143143
Github.authenticate({
@@ -150,13 +150,13 @@
150150
var working = true;
151151

152152
Async.whilst(
153-
function() {
153+
function () {
154154
return working;
155155
},
156-
function(callback) {
156+
function (callback) {
157157
try {
158158
Github.repos.getCommits({
159-
headers: {"User-Agent": SDK_UA_STRING},
159+
headers: { "User-Agent": SDK_UA_STRING },
160160
user: owner,
161161
repo: repository,
162162
per_page: 100, // The maximum per page value supported by the Github API.
@@ -172,7 +172,7 @@
172172
working = false;
173173
}
174174

175-
var checkpointFilePath = path.join(checkpointDir, owner + " " + repository + ".txt");
175+
var checkpointFilePath = path.join(checkpointDir, owner + " " + repository + ".txt");
176176
var checkpointFileNewContents = "";
177177
var errorFound = false;
178178

@@ -248,7 +248,7 @@
248248
callback(e);
249249
}
250250
},
251-
function(err) {
251+
function (err) {
252252
// We're done streaming.
253253
done(err);
254254
}

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "splunk-sdk",
3-
"version": "1.9.1",
3+
"version": "1.10.0",
44
"description": "SDK for usage with the Splunk REST API",
55
"homepage": "http://dev.splunk.com",
66
"main": "index.js",
@@ -21,7 +21,7 @@
2121
"javascript"
2222
],
2323
"scripts": {
24-
"test": "mocha tests_spike/tests.js -t 50000 --allow-uncaught --exit"
24+
"test": "nyc mocha tests/tests.js -t 50000 --allow-uncaught --exit --reporter mochawesome"
2525
},
2626
"dependencies": {
2727
"cookie": "0.4.1",
@@ -34,6 +34,7 @@
3434
"chai": "^4.3.4",
3535
"jshint": "2.13.0",
3636
"mocha": "7.2.0",
37+
"mochawesome": "^6.2.2",
3738
"mustache": "4.2.0",
3839
"nyc": "^15.1.0",
3940
"readable-stream": "3.6.0",

0 commit comments

Comments
 (0)