Skip to content

Commit cfe7602

Browse files
authored
Merge pull request #159 from splunk/release/1.12.0
Release/1.12.0
2 parents 1dee6d9 + f32fb4e commit cfe7602

File tree

210 files changed

+162725
-71398
lines changed

Some content is hidden

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

210 files changed

+162725
-71398
lines changed

.github/workflows/release.yml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Create Release
33
on:
44
release:
55
types: [published]
6-
6+
77
jobs:
88
publish-npm:
99
runs-on: ubuntu-latest
@@ -16,3 +16,18 @@ jobs:
1616
- run: npm publish
1717
env:
1818
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
19+
20+
- name: Package JSON Info
21+
uses: myrotvorets/[email protected]
22+
id: pkgjson
23+
24+
- name: Generate docs
25+
run: |
26+
node sdkdo docs
27+
zip -r docs.zip docs/${{ steps.pkgjson.outputs.packageVersion }}/refs
28+
29+
- name: Upload Artifact
30+
uses: actions/upload-artifact@v3
31+
with:
32+
name: apidocs
33+
path: docs.zip

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
- 14
1515
- 8.17.0
1616
splunk-version:
17-
- "8.0"
17+
- "8.2"
1818
- "latest"
1919

2020
services:

.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*build/
1+
build/
22
.git
33
tests/html/*
44
*.out
@@ -17,4 +17,5 @@ cover_html
1717
.splunkrc
1818
*.zip
1919
test_logs/*
20-
docs/
20+
docs/
21+
.nyc_output/*

.jshintignore

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,6 @@ node_modules
55
build
66
client
77
external
8-
examples/browser/create-react-app
9-
examples/browser/minisplunk
10-
examples/browser/resources
11-
examples\\browser\\create-react-app
12-
examples\\browser\\minisplunk
13-
examples\\browser\\resources
148
old_english
159
new_english
1610
xml2json

CHANGELOG.md

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

3+
## v1.12.0
4+
5+
### New features and APIs
6+
* SDK Support for splunkd search API changes, for Splunk 9.0+. ([PR#157](https://github.com/splunk/splunk-sdk-javascript/pull/157))
7+
8+
### Minor changes
9+
* Added assets directory to be included while generating docs ([PR#154](https://github.com/splunk/splunk-sdk-javascript/pull/154))
10+
* Removed support for Modular Inputs from the SDK ([PR#153](https://github.com/splunk/splunk-sdk-javascript/pull/153))
11+
* Removed examples and it's references from sdk ([PR#152](https://github.com/splunk/splunk-sdk-javascript/pull/152))
12+
* Added 'User-Agent' header in REST API calls for the telemetry ([PR#151](https://github.com/splunk/splunk-sdk-javascript/pull/151))
13+
* changes corresponding to API changes in the dependency library browserify ([PR#149](https://github.com/splunk/splunk-sdk-javascript/pull/149))
14+
* JS SDK upload artifact script added for api docs ([PR#148](https://github.com/splunk/splunk-sdk-javascript/pull/148))
15+
316
## v1.11.0
417

518
### Major changes

Makefile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,21 @@ wait_up:
4545
down:
4646
@echo "$(ATTN_COLOR)==> down $(NO_COLOR)"
4747
@docker-compose stop
48+
49+
.PHONY: deps
50+
deps:
51+
@echo "$(ATTN_COLOR)==> Checking nodes.js dependencies $(NO_COLOR)"
52+
@echo "$(ATTN_COLOR)==> Installing nodes.js 14 $(NO_COLOR)"
53+
@source $(HOME)/.nvm/nvm.sh ; nvm install 14
54+
@echo "$(ATTN_COLOR)==> npm install $(NO_COLOR)"
55+
@npm install
56+
57+
.PHONY: clean
58+
clean:
59+
@echo "$(ATTN_COLOR)==> Cleaning client/ directory $(NO_COLOR)"
60+
@rm -rf client/splunk.*.js >/dev/null 2>&1
61+
62+
.PHONY: build
63+
build: clean deps
64+
@echo "$(OK_COLOR)==> Initiating the build... $(NO_COLOR)"
65+
@source $(HOME)/.nvm/nvm.sh; nvm run 14 sdkdo compile

README.md

Lines changed: 13 additions & 40 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.11.0
4+
#### Version 1.12.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,9 +13,9 @@ 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.0 or 8.2, or Splunk Cloud
16+
* Splunk Enterprise 9.0 or 8.2, or Splunk Cloud
1717

18-
The Splunk Enterprise SDK for JavaScript was tested with Splunk Enterprise 8.0 or 8.2, or Splunk Cloud.
18+
The Splunk Enterprise SDK for JavaScript was tested with Splunk Enterprise 9.0 or 8.2, or Splunk Cloud.
1919

2020
* Splunk Enterprise SDK for JavaScript
2121

@@ -124,7 +124,7 @@ var serviceWithSessionKey = new splunkjs.Service(
124124
host: 'localhost',
125125
port: '8089',
126126
sessionKey: SESSION_KEY, // Add your sessionKey here
127-
version: '8',
127+
version: '9.0',
128128
});
129129

130130
serviceWithSessionKey.get("search/jobs", { count: 1 }, function (err, res) {
@@ -177,14 +177,17 @@ serviceWithBearerToken.get("search/jobs", { count: 2 }, function (err, res) {
177177
});
178178
```
179179

180+
### Modular inputs examples
181+
Support for modular inputs is removed from Splunk Enterprise SDK for JavaScript and we recommand to use [Splunk Enterprise SDK for Python](https://github.com/splunk/splunk-sdk-python) for the modular inputs. See the [Python SDK modular inputs example](https://github.com/splunk/splunk-app-examples/tree/master/modularinputs/python) and [PythonSDK modular inputs docs](https://dev.splunk.com/enterprise/docs/devtools/python/sdk-python/howtousesplunkpython/howtocreatemodpy) for reference.
182+
180183
## SDK examples
181184

182-
The Splunk Enterprise SDK for JavaScript contains several server- and client-based examples.
185+
The Splunk Enterprise SDK for JavaScript contains several server- and client-based examples, which are located in the [Splunk App Example repo](https://github.com/splunk/splunk-app-examples).
183186
For details, see the [Splunk Enterprise SDK for JavaScript Examples](https://dev.splunk.com/enterprise/docs/devtools/javascript/sdk-javascript/sdkjavascriptexamples) on the Splunk Developer Portal.
184187

185-
#### Create a .splunkrc convenience file
188+
## Create a .splunkrc convenience file
186189

187-
To connect to Splunk Enterprise, many of the SDK examples and unit tests take command-line arguments that specify values for the host, port, and login credentials for Splunk Enterprise. For convenience during development, you can store these arguments as key-value pairs in a text file named **.splunkrc**. Then, the SDK examples and unit tests use the values from the **.splunkrc** file when you don't specify them.
190+
To connect to Splunk Enterprise, many of the SDK unit tests take command-line arguments that specify values for the host, port, and login credentials for Splunk Enterprise. For convenience during development, you can store these arguments as key-value pairs in a text file named **.splunkrc**. Then, the SDK unit tests use the values from the **.splunkrc** file when you don't specify them.
188191

189192
>**Note**: Storing login credentials in the **.splunkrc** file is only for convenience during development. This file isn't part of the Splunk platform and shouldn't be used for storing user credentials for production. And, if you're at all concerned about the security of your credentials, enter them at the command line rather than saving them in this file.
190193
@@ -201,7 +204,7 @@ To use this convenience file, create a text file with the following format:
201204
# Access scheme (default: https)
202205
scheme=https
203206
# Your version of Splunk Enterprise
204-
version=8.2
207+
version=9.0
205208

206209
Save the file as **.splunkrc** in the current user's home directory.
207210

@@ -246,37 +249,6 @@ function (err) {
246249
});
247250
```
248251

249-
### Client-side examples
250-
251-
The Splunk Enterprise SDK for JavaScript includes several browser-based examples, which you can run from the Examples web page.
252-
253-
To start a simple web server and open the Examples page in a web browser, enter:
254-
255-
node sdkdo examples
256-
257-
### Node.js examples
258-
259-
The Splunk Enterprise SDK for JavaScript includes several command-line examples, which are located in the **/splunk-sdk-javascript/examples/node** directory. These examples run with Node.js and use the command-line arguments from the **.splunkrc** file, if you set this up with your login credentials.
260-
261-
For example, to run the **jobs.js** example, open a command prompt in the **/splunk-sdk-javascript/examples/node** directory and enter:
262-
263-
node jobs.js list
264-
265-
If you aren't storing your login credentials in **.splunkrc**, enter the following command, providing your own values:
266-
267-
node jobs.js --username yourusername --password yourpassword list
268-
269-
Your output should look something like this:
270-
271-
~\splunk-sdk-javascript\examples\node> node .\jobs.js list
272-
Job 1 sid: scheduler__nobody__search_VG9wIGZpdmUgc291cmNldHlwZXM_at_1323917700_79740ae7e22350d6
273-
Job 2 sid: scheduler__nobody__search_VG9wIGZpdmUgc291cmNldHlwZXM_at_1323917400_0dceb302931a2b3f
274-
Job 3 sid: scheduler__nobody__search_SW5kZXhpbmcgd29ya2xvYWQ_at_1323917100_48fb4cc65a25c5b1
275-
Job 4 sid: scheduler__nobody__search_SW5kZXhpbmcgd29ya2xvYWQ_at_1323916200_b2f239fef7834523
276-
Job 5 sid: scheduler__nobody__unix_QWxlcnQgLSBzeXNsb2cgZXJyb3JzIGxhc3QgaG91cg_at_1323914400_96cb9084680b25d7
277-
Job 6 sid: admin__admin__search_TXkgQXdlc29tZSBTYXZlZCBTZWFyY2g_1323901055.6
278-
==============
279-
280252
## Development
281253

282254
The Splunk Enterprise SDK for JavaScript infrastructure relies on Node.js to build files, run examples, run tests, and generate documentation.
@@ -288,6 +260,7 @@ All development activities are managed by a helper script called `sdkdo`. For a
288260
### Compile the browser files
289261

290262
To rebuild and minify the browser files, open a command prompt in the **splunk-sdk-javascript** directory and enter:
263+
Note:- If any TypeError is encountered, please run "npm install" before running the below command.
291264

292265
node sdkdo compile
293266

@@ -335,7 +308,6 @@ To get more info to run tests, enter:
335308
| /client | Pre-built files for the browser |
336309
| /contrib | Packaged third-party dependencies (such as test runners) |
337310
| /docs | API reference documentation |
338-
| /examples | Examples |
339311
| /lib | The SDK code files |
340312
| /licenses | License information for packaged third-party dependencies |
341313
| /node_modules | JavaScript modules used by Node.js |
@@ -360,6 +332,7 @@ To learn about our branching model, see [Branching Model](https://github.com/spl
360332
| [REST API Reference Manual](https://docs.splunk.com/Documentation/Splunk/latest/RESTREF/RESTprolog) | Splunk REST API reference documentation |
361333
| [Splunk>Docs](https://docs.splunk.com/Documentation) | General documentation for the Splunk platform |
362334
| [GitHub Wiki](https://github.com/splunk/splunk-sdk-javascript/wiki/) | Documentation for this SDK's repository on GitHub |
335+
| [Splunk JavaScript SDK Examples](https://github.com/splunk/splunk-app-examples) | server- and client-based examples for the Splunk JavaScript SDK |
363336

364337

365338
## Community

bin/cli.js

Lines changed: 33 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
* Constants
3333
*/
3434
var DEFAULT_PORT = 6969;
35-
var DOC_DIRECTORY = "docs";
3635
var REFDOC_DIRECTORY = "refs";
3736
var CLIENT_DIRECTORY = "client";
3837
var TEST_DIRECTORY = "tests";
@@ -44,6 +43,10 @@
4443
var DOC_FILE = "index.html";
4544
var BUILD_CACHE_FILE = ".buildcache";
4645
var SDK_VERSION = JSON.parse(fs.readFileSync(path.resolve(__dirname, "../package.json")).toString("utf-8")).version;
46+
var DOC_DIRECTORY = "docs-" + SDK_VERSION;
47+
var DOC_ASSETS_DIRECTORY = "assets";
48+
var DOC_DIRECTORY_ASSETS = path.join("bin/docs", DOC_ASSETS_DIRECTORY);
49+
var GENERATED_DOC_ASSETS = path.join(DOC_DIRECTORY, DOC_ASSETS_DIRECTORY);
4750
var IGNORED_MODULES = [
4851
"../contrib/nodeunit/test_reporter",
4952
"../contrib/nodeunit/junit_reporter",
@@ -103,7 +106,8 @@
103106
headers: {
104107
"Content-Length": req.headers["content-length"] || 0,
105108
"Content-Type": req.headers["content-type"] || '',
106-
"Authorization": req.headers["authorization"] || ''
109+
"Authorization": req.headers["authorization"] || '',
110+
"User-Agent": "splunk-sdk-javascript/" + SDK_VERSION
107111
},
108112
followAllRedirects: true,
109113
body: body || '',
@@ -465,38 +469,30 @@
465469
exportName = exportName || "splunkjs";
466470

467471
// Compile/combine all the files into the package
468-
var bundle = browserify({
469-
entry: entry,
470-
ignore: IGNORED_MODULES,
471-
cache: BUILD_CACHE_FILE,
472-
filter: function (code) {
473-
if (shouldUglify) {
474-
var uglifyjs = require("uglify-js"),
475-
parser = uglifyjs.parser,
476-
uglify = uglifyjs.uglify;
477-
478-
var ast = parser.parse(code);
479-
ast = uglify.ast_mangle(ast);
480-
ast = uglify.ast_squeeze(ast);
481-
code = uglify.gen_code(ast);
482-
}
483-
484-
code = [
485-
"(function() {",
486-
"",
487-
"var __exportName = '" + exportName + "';",
488-
"",
489-
code,
490-
"",
491-
"})();"
492-
].join("\n");
493-
return code;
472+
var bundle = browserify();
473+
bundle.add(entry);
474+
bundle.ignore(IGNORED_MODULES);
475+
bundle.bundle(function (err,src){
476+
var code = [
477+
"(function() {",
478+
"",
479+
"var __exportName = '" + exportName + "';",
480+
"",
481+
src.toString(),
482+
"",
483+
"})();"
484+
].join("\n");
485+
if(err){
486+
throw err;
487+
}
488+
if (shouldUglify){
489+
var UglifyJS = require("uglify-js");
490+
code = UglifyJS.minify({"file1.js":code},{toplevel:true}).code;
494491
}
492+
fs.writeFileSync(path,code);
493+
console.log("Compiled " + path);
495494
});
496495

497-
var js = bundle.bundle();
498-
fs.writeFileSync(path, js);
499-
console.log("Compiled " + path);
500496
};
501497

502498
var outOfDate = function (dependencies, compiled, compiledMin) {
@@ -615,11 +611,6 @@
615611
launchBrowser("tests/tests.browser.html", port);
616612
};
617613

618-
var launchBrowserExamples = function (port) {
619-
runServer(port);
620-
launchBrowser("examples/browser/index.html", port);
621-
};
622-
623614
var generateDocs = function (callback) {
624615
callback = (callback && utils.isFunction(callback)) ? callback : (function () { });
625616

@@ -630,15 +621,6 @@
630621
"lib/async.js",
631622
"lib/context.js",
632623
"lib/service.js",
633-
"lib/modularinputs/argument.js",
634-
"lib/modularinputs/event.js",
635-
"lib/modularinputs/eventwriter.js",
636-
"lib/modularinputs/inputdefinition.js",
637-
"lib/modularinputs/logger.js",
638-
"lib/modularinputs/modularinput.js",
639-
"lib/modularinputs/scheme.js",
640-
"lib/modularinputs/utils.js",
641-
"lib/modularinputs/validationdefinition.js"
642624
];
643625

644626
var comments = [];
@@ -655,11 +637,12 @@
655637
}
656638

657639
ensureDirectoryExists(DOC_DIRECTORY);
658-
ensureDirectoryExists(path.join(DOC_DIRECTORY, SDK_VERSION));
659-
ensureDirectoryExists(path.join(DOC_DIRECTORY, SDK_VERSION, REFDOC_DIRECTORY));
640+
641+
// copy static assets directory
642+
copyDirectoryRecursiveSync(DOC_DIRECTORY_ASSETS, GENERATED_DOC_ASSETS);
660643

661644
for (var name in data) {
662-
var htmlPath = path.join(DOC_DIRECTORY, SDK_VERSION, REFDOC_DIRECTORY, name + ".html");
645+
var htmlPath = path.join(DOC_DIRECTORY, name + ".html");
663646
fs.writeFileSync(htmlPath, data[name]);
664647
}
665648

@@ -734,10 +717,7 @@
734717

735718
var files = args
736719
.map(arg => {
737-
if (arg.indexOf('modularinputs') >= 0) {
738-
return path.join(TEST_DIRECTORY, 'modularinputs', TEST_PREFIX + arg.split('/')[1] + ".js");
739-
}
740-
else if (arg.indexOf('service_tests') >= 0) {
720+
if (arg.indexOf('service_tests') >= 0) {
741721
return path.join(TEST_DIRECTORY, 'service_tests', arg.split('/')[1] + ".js");
742722
}
743723
else {
@@ -812,7 +792,7 @@
812792

813793
program
814794
.command('runserver [port]')
815-
.description('Run a local server to serve tests and examples.')
795+
.description('Run a local server to serve tests.')
816796
.action(runServer);
817797

818798
program
@@ -843,11 +823,6 @@
843823
.description('Launch the browser test suite.')
844824
.action(launchBrowserTests);
845825

846-
program
847-
.command('examples [port]')
848-
.description('Launch the browser examples index page.')
849-
.action(launchBrowserExamples);
850-
851826
program
852827
.command('hint')
853828
.description('Run JSHint on the codebase.')

0 commit comments

Comments
 (0)