Skip to content

Commit

Permalink
Merge pull request #377 from jason-fox/feature/prettier
Browse files Browse the repository at this point in the history
Add prettier code formatting
  • Loading branch information
fgalan authored Mar 5, 2019
2 parents 7e75d0b + 7657825 commit 59649a2
Show file tree
Hide file tree
Showing 47 changed files with 1,097 additions and 870 deletions.
9 changes: 9 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"arrowParens": "always",
"bracketSpacing": true,
"singleQuote": true,
"parser": "flow",
"printWidth": 120,
"trailingComma": "none",
"tabWidth": 4
}
26 changes: 14 additions & 12 deletions bin/iotaJsonTester.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ function checkConnection(fn) {
} else {
console.log('Please, check your configuration and connect before using MQTT commands.');
}
}
};
}

function singleMeasure(commands) {
Expand All @@ -96,9 +96,7 @@ function singleMeasure(commands) {
}

function parseMultipleAttributes(attributeString) {
var result,
attributes,
attribute;
var result, attributes, attribute;

if (!attributeString) {
result = null;
Expand All @@ -125,7 +123,10 @@ function multipleMeasure(commands) {
function connect(commands) {
console.log('\nConnecting to MQTT Broker...');

mqttClient = mqtt.connect('mqtt://' + config.host, defaultConfig.mqtt.options);
mqttClient = mqtt.connect(
'mqtt://' + config.host,
defaultConfig.mqtt.options
);

clUtils.prompt();
}
Expand All @@ -135,33 +136,34 @@ function exitClient() {
}

var commands = {
'config': {
config: {
parameters: ['host', 'port', 'apiKey', 'deviceId'],
description: '\tConfigure the client to emulate the selected device, connecting to the given host.',
handler: setConfig
},
'showConfig': {
showConfig: {
parameters: [],
description: '\tConfigure the client to emulate the selected device, connecting to the given host.',
handler: getConfig
},
'connect': {
connect: {
parameters: [],
description: '\tConnect to the MQTT broker.',
handler: connect
},
'singleMeasure': {
singleMeasure: {
parameters: ['attribute', 'value'],
description: '\tSend the given value for the selected attribute to the MQTT broker.',
handler: checkConnection(singleMeasure)
},
'multipleMeasure': {
multipleMeasure: {
parameters: ['attributes'],
description: '\tSend a collection of attributes to the MQTT broker, using JSON format. The "attributes"\n' +
description:
'\tSend a collection of attributes to the MQTT broker, using JSON format. The "attributes"\n' +
'\tstring should have the following syntax: name=value[;name=value]*',
handler: checkConnection(multipleMeasure)
},
'exit': {
exit: {
parameters: [],
description: '\tExit the client',
handler: exitClient
Expand Down
2 changes: 1 addition & 1 deletion client-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ config.mqtt = {
config.device = {
id: 'myDeviceId',
apikey: '1234'
}
};

module.exports = config;
36 changes: 18 additions & 18 deletions config.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,16 @@ config.mqtt = {
/**
* Activating thinkingThingsPlugin flag. When it is set to true the constraint devices sends an HTTP POST request
* to the server with a Content-Type, containing a field name and a payload. The payload can be divided in modules,
* each one of them responsible for a single measure. Modules are separated by the '#' character, and all of them
* consists of a series of parameters separated by commas.
* each one of them responsible for a single measure. Modules are separated by the '#' character, and all of them
* consists of a series of parameters separated by commas.
*/
thinkingThingsPlugin: true,
/**
* QoS Level: at most once (0), at least once (1), exactly once (2). (default is 2).
*/
qos: 0,
/**
* Retain flag. (default is true.) Normally if a publisher publishes a message to a topic, and no one is
* Retain flag. (default is true.) Normally if a publisher publishes a message to a topic, and no one is
* subscribed to that topic (i.e retain flag is set to false) the message is simply discarded by the broker.
* The publisher can tell the broker to keep the last message on that topic by setting the retained message flag to true .
*/
Expand Down Expand Up @@ -84,7 +84,7 @@ config.amqp = {
/**
* durable queue flag (default is false).
*/
options: {durable: true}
options: { durable: true }
};

/**
Expand All @@ -94,7 +94,7 @@ config.http = {
/**
* South Port where the Ultralight transport binding for HTTP will be listening for device requests.
*/
port: 7896,
port: 7896
/**
* HTTP Timeout for the http command endpoint (in miliseconds).
*/
Expand All @@ -116,22 +116,22 @@ config.iota = {
* the IoT Agent will send the device data.
*/
contextBroker: {
/**
* Host where the Context Broker is located.
*/
/**
* Host where the Context Broker is located.
*/
host: 'localhost',
/**
* Port where the Context Broker is listening.
*/
/**
* Port where the Context Broker is listening.
*/
port: '1026'
},
/**
* Configuration of the North Port of the IoT Agent.
*/
server: {
/**
* Port where the IoT Agent will be listening for NGSI and Provisioning requests.
*/
/**
* Port where the IoT Agent will be listening for NGSI and Provisioning requests.
*/
port: 4041
},
/**
Expand All @@ -152,10 +152,10 @@ config.iota = {
* 'mongodb'.
*/
mongodb: {
/**
* Host where MongoDB is located. If the MongoDB used is a replicaSet, this property will contain a
* comma-separated list of the instance names or IPs.
*/
/**
* Host where MongoDB is located. If the MongoDB used is a replicaSet, this property will contain a
* comma-separated list of the instance names or IPs.
*/
host: 'localhost',
/**
* Port where MongoDB is listening. In the case of a replicaSet, all the instances are supposed to be listening
Expand Down
10 changes: 10 additions & 0 deletions docs/usermanual.md
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,16 @@ Removes `node_modules` and `coverage` folders, and `package-lock.json` file so
npm run clean
```

### Prettify Code

Runs the [prettier](https://prettier.io) code formatter to ensure consistent code style (whitespacing, parameter
placement and breakup of long lines etc.) within the codebase.

```bash
# Use git-bash on Windows
npm run prettier
```

## New transport development

### Overview
Expand Down
20 changes: 10 additions & 10 deletions ghpages/javascripts/scale.fix.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
var metas = document.getElementsByTagName('meta');
var i;
if (navigator.userAgent.match(/iPhone/i)) {
for (i=0; i<metas.length; i++) {
if (metas[i].name == "viewport") {
metas[i].content = "width=device-width, minimum-scale=1.0, maximum-scale=1.0";
for (i = 0; i < metas.length; i++) {
if (metas[i].name == 'viewport') {
metas[i].content = 'width=device-width, minimum-scale=1.0, maximum-scale=1.0';
}
}
}
document.addEventListener("gesturestart", gestureStart, false);
document.addEventListener('gesturestart', gestureStart, false);
}
function gestureStart() {
for (i=0; i<metas.length; i++) {
if (metas[i].name == "viewport") {
metas[i].content = "width=device-width, minimum-scale=0.25, maximum-scale=1.6";
for (i = 0; i < metas.length; i++) {
if (metas[i].name == 'viewport') {
metas[i].content = 'width=device-width, minimum-scale=0.25, maximum-scale=1.6';
}
}
}
}
}
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
module.exports = require('./lib/iotagent-json');
module.exports = require('./lib/iotagent-json');
Loading

0 comments on commit 59649a2

Please sign in to comment.