Skip to content

Commit 2435a7b

Browse files
authored
Merge pull request #43 from IBMStreams/develop
Update to version 0.4.0
2 parents b20cc41 + 5b9b970 commit 2435a7b

36 files changed

+16842
-1722
lines changed

.babelrc

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
{
2-
"presets": ["flow", "env", "stage-2"],
3-
"plugins": [
4-
["babel-plugin-dynamic-import-node"],
5-
["dynamic-import-node"]
6-
],
7-
"sourceMap": "inline"
2+
"presets": [
3+
"@babel/preset-env",
4+
"@babel/preset-react"
5+
],
6+
"plugins": [
7+
"dynamic-import-node"
8+
]
89
}

.editorconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ root = true
44

55
[*]
66
charset = utf-8
7-
indent_style = tab
7+
indent_style = space
88
indent_size = 2
99
insert_final_newline = true
1010
trim_trailing_whitespace = true

.eslintrc

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
{
2+
"parser": "babel-eslint",
3+
"extends": "airbnb",
4+
"env": {
5+
"es6": true,
6+
"browser": true,
7+
"node": true,
8+
"jquery": true
9+
},
10+
"rules": {
11+
"array-callback-return": ["off"],
12+
"arrow-body-style": ["off"],
13+
"arrow-parens": ["off"],
14+
"class-methods-use-this": 0,
15+
"compat/compat": 2,
16+
"consistent-return": "off",
17+
"comma-dangle": "off",
18+
"generator-star-spacing": "off",
19+
"import/no-unresolved": ["error", { "ignore": ["electron", "atom"] }],
20+
"import/no-extraneous-dependencies": "off",
21+
"jsx-a11y/no-static-element-interactions": 0,
22+
"jsx-a11y/label-has-associated-control": [ 2, {
23+
"controlComponents": [ "Field" ]
24+
}],
25+
"jsx-a11y/label-has-for": 0,
26+
"max-len": ["off"],
27+
"no-cond-assign": ["error", "except-parens"],
28+
"no-console": 1,
29+
"no-param-reassign": ["error", { "props": false }],
30+
"no-return-assign": ["off"],
31+
"no-use-before-define": "off",
32+
"no-underscore-dangle": "off",
33+
"no-unused-vars": ["error", { "args": "none" }],
34+
"prefer-destructuring": ["error", {"array": false}],
35+
"promise/param-names": 2,
36+
"promise/always-return": 0,
37+
"promise/catch-or-return": 0,
38+
"promise/no-native": 0,
39+
"react/jsx-no-bind": "off",
40+
"react/jsx-filename-extension": ["error", { "extensions": [".js", ".jsx"] }],
41+
"react/no-find-dom-node": 0,
42+
"react/no-string-refs": 0,
43+
"react/prefer-stateless-function": "off",
44+
"react/sort-comp": "off"
45+
},
46+
"plugins": [
47+
"import",
48+
"promise",
49+
"compat",
50+
"react"
51+
],
52+
"globals": {
53+
"atom": "readable",
54+
"electron": "readable"
55+
}
56+
}

.eslintrc.js

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

.flowconfig

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

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
npm-debug.log
33
node_modules
44
.vscode
5-
package-lock.json
65
yarn.lock
6+
toolkitsCache

.jscsrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"requireTrailingComma": false
3+
}

README.md

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,28 @@ This is the initial public release. For best results you should also install th
1010
* ide-ibmstreams
1111

1212
### Setup Instructions
13-
#### Build - Streaming Analytics Credentials
14-
The <b>build-ibmstreams</b> package requires a running IBM Streaming Analytics service. SPL applications will be built and deployed on this service. If you need to create one, start <a href="https://cloud.ibm.com/catalog/services/streaming-analytics" rel="noopener" target="_blank">here</a> and follow the instructions to create an account.
13+
14+
### Build
15+
16+
You may either build and run your Streams applications on an [IBM Cloud Streaming Analytics service](https://cloud.ibm.com/docs/services/StreamingAnalytics/index.html#gettingstarted) (V4.3) or an [IBM Cloud Private for Data (ICP4D) Streams add-on instance](https://www.ibm.com/support/knowledgecenter/SSQNUZ_current/com.ibm.icpdata.doc/streams/intro.html) (V5).
17+
18+
#### IBM Cloud: Streaming Analytics service
19+
A running IBM Streaming Analytics service is required. You must provide your service credentials (in JSON format) in order for this extension to connect to your service. SPL applications will be built and deployed on this service. If you need to create one, start [here](https://cloud.ibm.com/catalog/services/streaming-analytics) and follow the instructions to create an account.
1520

1621
<b>Note:</b>The service needs to support V2 of the rest api.
1722

18-
Once you have an account go to your <a href="https://cloud.ibm.com/resources?groups=resource-instance" rel="noopener" target="_blank">dashboard</a> and select the Streaming Analytics service you want to use. You need to make sure it is running and then copy your credentials to the clipboard. To get your credentials select <b>Service Credentials</b> from the actions on the left. From the credentials page, press <b>View credentials</b> for the one you want to use and press the copy button in the upper right side of the credentials to copy them to the clipboard.
23+
Once you have an account go to your [Dashboard](https://cloud.ibm.com/resources?groups=resource-instance) and select the Streaming Analytics service you want to use. Ensure that it is running and then create a new set of credentials. Select the __Service credentials__ tab on the left and select your existing credentials or click on the __New credential__ button. On the credentials page, click on the __View credentials__ action and click on the __Copy__ button in the top-right corner of the credentials snippet to copy them to the clipboard.
1924

20-
In Atom there is a setting in the <b>build-ibmstreams</b> package for the credentials. Go to <b>Atom->Preferences->Packages</b> and press the <b>Settings</b> button on the <b>build-ibmstreams</b> package and paste your credentials into the setting.
25+
In Atom, to open __build-ibmstreams__ package settings go to Atom->Preferences->Packages and press the Settings button on the build-ibmstreams package. Select __IBM Cloud Streaming Analytics service__ in the __Build and submit__ dropdown and then paste your credentials in the __Streaming Analytics Credentials__ field.
2126
![](./images/atomcredssetting.png)
2227

28+
#### IBM Cloud Private for Data: Streams add-on instance
29+
30+
A provisioned IBM Streams add-on is required. You must provide your IBM Cloud Private for Data URL in order for this extension to connect to your add-on instance. Enter your url in the __build-ibmstreams__ package settings and select __IBM Cloud Private for Data Streams addon__ in the __Build and submit__ dropdown.
31+
32+
If you need to provision an add-on, start [here](https://www.ibm.com/support/knowledgecenter/SSQNUZ_current/com.ibm.icpdata.doc/streams/intro.html) and follow the instructions.
33+
34+
2335

2436
### SPL Application build
2537
![](./images/build.gif)

lib/LintHandler.js

Lines changed: 90 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,78 +1,101 @@
1-
// @flow
2-
"use strict";
3-
"use babel";
1+
'use babel';
2+
'use strict';
43

5-
export class LintHandler {
4+
import { StreamsUtils } from './util';
65

7-
linter = null;
8-
msgRegex = null;
9-
appRoot = null;
6+
const CONF_API_VERSION_V4 = 'v4';
7+
const CONF_API_VERSION_V5 = 'v5';
108

11-
constructor(linter, msgRegex, appRoot) {
12-
this.linter = linter;
13-
this.msgRegex = msgRegex;
14-
this.appRoot = appRoot;
15-
}
9+
export default class LintHandler {
10+
linter = null;
1611

12+
msgRegex = null;
1713

18-
lint(input) {
19-
if (!this.linter || !input) {
20-
return;
21-
}
14+
appRoot = null;
2215

23-
if (input.output && Array.isArray(input.output)) {
24-
let convertedMessages = input.output.map(
25-
(message) => message.message_text
26-
).filter(
27-
// filter only messages that match expected format
28-
(msg) => msg.match(this.msgRegex)
29-
).map(
30-
(msg) => {
31-
// return objects for each message
32-
let parts = msg.match(this.msgRegex);
33-
let severityCode = parts[4].trim().substr(parts[4].trim().length - 1);
34-
let severity = "info";
35-
if (severityCode) {
36-
switch (severityCode) {
37-
case "I":
38-
severity = "info";
39-
break;
40-
case "W":
41-
severity = "warning";
42-
break;
43-
case "E":
44-
severity = "error";
45-
break;
46-
default:
47-
break;
48-
}
49-
}
50-
let absolutePath = parts[1];
51-
if (this.appRoot && typeof(this.appRoot) === "string") {
52-
absolutePath = `${this.appRoot}/${parts[1]}`;
53-
}
16+
apiVersion = null;
5417

55-
return {
56-
severity: severity,
57-
location: {
18+
constructor(linter, appRoot, apiVersion) {
19+
this.linter = linter;
20+
this.appRoot = appRoot;
21+
this.apiVersion = apiVersion;
22+
this.msgRegex = apiVersion === CONF_API_VERSION_V4 ? StreamsUtils.SPL_MSG_REGEX : StreamsUtils.SPL_MSG_REGEX_V5;
23+
}
5824

59-
file: absolutePath,
60-
position: [
61-
[parseInt(parts[2])-1 ,parseInt(parts[3])-1],
62-
[parseInt(parts[2])-1,parseInt(parts[3])]
63-
], // 0-indexed
64-
},
65-
excerpt: parts[4],
66-
description: parts[5],
67-
};
68-
}
69-
);
25+
setV5() {
26+
this.apiVersion = CONF_API_VERSION_V5;
27+
this.msgRegex = StreamsUtils.SPL_MSG_REGEX_V5;
28+
}
7029

71-
this.linter.setAllMessages(convertedMessages);
30+
setV4() {
31+
this.apiVersion = CONF_API_VERSION_V4;
32+
this.msgRegex = StreamsUtils.SPL_MSG_REGEX;
33+
}
7234

73-
if (Array.isArray(convertedMessages) && convertedMessages.length > 0) {
74-
atom.workspace.open("atom://nuclide/diagnostics");
75-
}
76-
}
77-
}
35+
lint(input) {
36+
if (!this.linter || !input) {
37+
return;
38+
}
39+
let messages = [];
40+
if (input.output) {
41+
this.setV4();
42+
messages = input.output.map(message => message.message_text);
43+
} else if (Array.isArray(input)) {
44+
this.setV5();
45+
messages = input;
46+
}
47+
48+
if (Array.isArray(messages)) {
49+
const convertedMessages = messages.filter(
50+
// filter only messages that match expected format
51+
(msg) => msg.match(this.msgRegex)
52+
).map(
53+
(msg) => {
54+
// return objects for each message
55+
const parts = msg.match(this.msgRegex);
56+
if (parts && parts.length > 4) {
57+
const severityCode = parts[4].trim().substr(parts[4].trim().length - 1);
58+
let severity = 'info';
59+
if (severityCode) {
60+
switch (severityCode) {
61+
case 'I':
62+
severity = 'info';
63+
break;
64+
case 'W':
65+
severity = 'warning';
66+
break;
67+
case 'E':
68+
severity = 'error';
69+
break;
70+
default:
71+
break;
72+
}
73+
}
74+
let absolutePath = parts[1];
75+
if (this.appRoot && typeof (this.appRoot) === 'string') {
76+
absolutePath = `${this.appRoot}/${parts[1]}`;
77+
}
78+
return {
79+
severity,
80+
location: {
81+
file: absolutePath,
82+
position: [
83+
[parseInt(parts[2], 10) - 1, parseInt(parts[3], 10) - 1],
84+
[parseInt(parts[2], 10) - 1, parseInt(parts[3], 10)]
85+
], // 0-indexed
86+
},
87+
excerpt: parts[4],
88+
description: parts[5],
89+
};
90+
}
91+
}
92+
);
93+
94+
this.linter.setAllMessages(convertedMessages);
95+
96+
if (Array.isArray(convertedMessages) && convertedMessages.length > 0) {
97+
atom.workspace.open('atom://nuclide/diagnostics');
98+
}
99+
}
100+
}
78101
}

0 commit comments

Comments
 (0)