Skip to content

master to develop #134

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Aug 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 0 additions & 38 deletions .travis.yml

This file was deleted.

24 changes: 24 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,29 @@
# Splunk Enterprise SDK for JavaScript Changelog

## v1.10.0

### Major changes
* Dropped support for deprecated request http client.
* Added support for [needle](https://www.npmjs.com/package/needle) http client library.

### Minor changes

* Added support for Splunk Enterprise 8.2
* Added support for Node v14.
* Dropped support for deprecated nodeunit testing library.
* Added support for [mocha](https://www.npmjs.com/package/mocha) for testing and [chai](https://www.npmjs.com/package/chai) for assertions.
* Updated `cookie` dependency version to `0.4.1`
* Updated `elementtree` dependency version to `0.1.7`
* Updated `browserify` dependency version to `17.0.0`
* Updated `jshint` dependency version to `2.13.0`
* Updated `mustache` dependency version to `4.2.0`
* Updated `readable-stream` dependency version to `3.6.0`
* Updated `uglify-js` dependency version to `3.13.8`
* Added support for `[email protected]` to declared env variables.
* Added support for `[email protected]` to generate test report.
* Fixed the Buffer and new Buffer() deprecation warnings appeared when running the tests.
* Added support for running single test file and test case. Run `make test_specific` for more info.

## v1.9.1

### Minor changes
Expand Down
27 changes: 19 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[![Build Status](https://travis-ci.org/splunk/splunk-sdk-javascript.svg?branch=master)](https://travis-ci.org/splunk/splunk-sdk-javascript)
# The Splunk Enterprise Software Development Kit for JavaScript

#### Version 1.9.1
#### Version 1.10.0

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.

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

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

* Splunk Enterprise 8.2.0 or later, or Splunk Cloud
* Splunk Enterprise 8.0 or 8.2, or Splunk Cloud

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

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

This HTML example uses the Splunk Enterprise SDK for JavaScript to list all jobs:

```javascript
<script type="text/javascript" src="splunk.js"></script>
<script type="text/javascript" src="jquery.min.js"></script>

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

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

</script>
```

### Node.js code example

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

```javascript
var splunkjs = require('splunk-sdk');

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

## SDK examples

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

node sdkdo tests http,async

To run tests containing a particular string, enter:

node sdkdo tests --grep "While success"

To run the browser tests, enter:

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

node sdkdo tests --quiet

To run all the tests and generate JUnit compatible XML in **splunk-sdk-javascript/test_logs/junit_test_results.xml**, enter:
To run all the tests and generate test report in **splunk-sdk-javascript/mochawesome-report/mochawesome.html**, enter:

node sdkdo tests --reporter mochawesome

To get more info to run tests, enter:

node sdkdo tests --reporter junit
make test_specific

## Repository

Expand Down
22 changes: 11 additions & 11 deletions bin/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@
var utils = require('../lib/utils');
var Async = require('../lib/async');
var staticResource = require('../contrib/static-resource/index');
var dox = require('../contrib/dox/dox');
var doc_builder = require('../contrib/dox/doc_builder');
var program = require('../contrib/commander');
var spawn = require('child_process').spawn;
var path = require('path');
var fs = require('fs');
var browserify = require('browserify');
var http = require('http');
var url = require('url');
var needle = require('needle');
var dox = require('../contrib/dox/dox');
var doc_builder = require('../contrib/dox/doc_builder');
var program = require('../contrib/commander');
var spawn = require('child_process').spawn;
var path = require('path');
var fs = require('fs');
var browserify = require('browserify');
var http = require('http');
var url = require('url');
var needle = require('needle');


/**
Expand Down Expand Up @@ -830,7 +830,7 @@
.option('--port <port>', 'Splunk port')
.option('--version <version>', 'Splunk version')
.option('--namespace <namespace>', 'Splunk namespace (in the form of owner:app)')
.option('--reporter <reporter>', '(optional) How to report results, currently "junit" is a valid reporter.')
.option('--reporter <reporter>', '(optional) How to report results')
.option('--ui <ui>', 'Specify user interface')
.option('--timeout <timeout>', 'Specify test timeout threshold (in milliseconds)')
.option('--grep <grep>', 'Only run tests matching this string or regexp')
Expand Down
50 changes: 25 additions & 25 deletions examples/modularinputs/github_commits/bin/app/github_commits.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,21 @@
// License for the specific language governing permissions and limitations
// under the License.

(function() {
var fs = require("fs");
var path = require("path");
var GithubAPI = require("github");
var splunkjs = require("splunk-sdk");
var Async = splunkjs.Async;
var ModularInputs = splunkjs.ModularInputs;
var Logger = ModularInputs.Logger;
var Event = ModularInputs.Event;
var Scheme = ModularInputs.Scheme;
var Argument = ModularInputs.Argument;
var utils = ModularInputs.utils;
(function () {
var fs = require("fs");
var path = require("path");
var GithubAPI = require("github");
var splunkjs = require("splunk-sdk");
var Async = splunkjs.Async;
var ModularInputs = splunkjs.ModularInputs;
var Logger = ModularInputs.Logger;
var Event = ModularInputs.Event;
var Scheme = ModularInputs.Scheme;
var Argument = ModularInputs.Argument;
var utils = ModularInputs.utils;

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

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

exports.getScheme = function() {
exports.getScheme = function () {
var scheme = new Scheme("Github Commits");

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

exports.validateInput = function(definition, done) {
exports.validateInput = function (definition, done) {
var owner = definition.parameters.owner;
var repository = definition.parameters.repository;
var token = definition.parameters.token;

var Github = new GithubAPI({version: "3.0.0"});
var Github = new GithubAPI({ version: "3.0.0" });

try {
// Authenticate with the access token if it was provided.
Expand All @@ -98,7 +98,7 @@
}

Github.repos.getCommits({
headers: {"User-Agent": SDK_UA_STRING},
headers: { "User-Agent": SDK_UA_STRING },
user: owner,
repo: repository,
per_page: 1, // The minimum per page value supported by the Github API.
Expand Down Expand Up @@ -127,17 +127,17 @@
}
};

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

var owner = singleInput.owner;
var repository = singleInput.repository;
var token = singleInput.token;
var token = singleInput.token;

var alreadyIndexed = 0;

var Github = new GithubAPI({version: "3.0.0"});
var Github = new GithubAPI({ version: "3.0.0" });

if (token && token.length > 0) {
Github.authenticate({
Expand All @@ -150,13 +150,13 @@
var working = true;

Async.whilst(
function() {
function () {
return working;
},
function(callback) {
function (callback) {
try {
Github.repos.getCommits({
headers: {"User-Agent": SDK_UA_STRING},
headers: { "User-Agent": SDK_UA_STRING },
user: owner,
repo: repository,
per_page: 100, // The maximum per page value supported by the Github API.
Expand All @@ -172,7 +172,7 @@
working = false;
}

var checkpointFilePath = path.join(checkpointDir, owner + " " + repository + ".txt");
var checkpointFilePath = path.join(checkpointDir, owner + " " + repository + ".txt");
var checkpointFileNewContents = "";
var errorFound = false;

Expand Down Expand Up @@ -248,7 +248,7 @@
callback(e);
}
},
function(err) {
function (err) {
// We're done streaming.
done(err);
}
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "splunk-sdk",
"version": "1.9.1",
"version": "1.10.0",
"description": "SDK for usage with the Splunk REST API",
"homepage": "http://dev.splunk.com",
"main": "index.js",
Expand All @@ -21,7 +21,7 @@
"javascript"
],
"scripts": {
"test": "mocha tests_spike/tests.js -t 50000 --allow-uncaught --exit"
"test": "nyc mocha tests/tests.js -t 50000 --allow-uncaught --exit --reporter mochawesome"
},
"dependencies": {
"cookie": "0.4.1",
Expand All @@ -34,6 +34,7 @@
"chai": "^4.3.4",
"jshint": "2.13.0",
"mocha": "7.2.0",
"mochawesome": "^6.2.2",
"mustache": "4.2.0",
"nyc": "^15.1.0",
"readable-stream": "3.6.0",
Expand Down