binds-co-toolbelt
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -19,3 +19,3 @@ var _ = require('lodash'); | ||
.option('-p, --phone [col]', 'phone collumn') | ||
.option('-t, --token <token>', 'Binds.co API token') | ||
.option('-s, --source <source>', 'Binds.co API source') | ||
.option('-f, --force', 'Send all records even those previously sent') | ||
@@ -40,11 +40,11 @@ .action(sendBatchFromFile); | ||
if (_.isEmpty(options.token)) { | ||
console.log('--token is required.'); | ||
if (_.isEmpty(options.source)) { | ||
console.log('--source is required.'); | ||
process.exit(); | ||
} | ||
var seedBatch = { | ||
collector: options.token, | ||
collector: options.source, | ||
seeds: [], | ||
}; | ||
var previousSignature = db.get(['lastProcessedLine', options.token]).value(); | ||
var prevSignature = db.get(['lastProcessedLine', options.source]).value(); | ||
var lastSignature; | ||
@@ -58,3 +58,3 @@ dbf.on('data', function(record) { | ||
var signature = crypto.createHash('md5').update(str).digest('hex'); | ||
if (!options.force && (signature === previousSignature)) { | ||
if (!options.force && (signature === prevSignature)) { | ||
console.log('Skipping %s previously sent rows.', seedBatch.seeds.length); | ||
@@ -86,2 +86,6 @@ seedBatch.seeds = []; | ||
dbf.on('end', function() { | ||
if (_.isEmpty(process.env.BINDS_CO_TOKEN)) { | ||
console.log('Token is required.'); | ||
process.exit(); | ||
} | ||
if (_.isEmpty(seedBatch.seeds)) { | ||
@@ -91,3 +95,6 @@ console.log('Batch is empty.'); | ||
} | ||
var headers = {'Content-Type': 'application/json; charset=utf-8'}; | ||
var headers = { | ||
'Content-Type': 'application/json; charset=utf-8', | ||
'Authorization': 'Binds.co ' + process.env.BINDS_CO_TOKEN | ||
}; | ||
var options = {url: APIPath, headers: headers, json: true, body: seedBatch}; | ||
@@ -101,3 +108,3 @@ | ||
console.log('Finished processing file.'); | ||
db.set(['lastProcessedLine', options.token], lastSignature).value(); | ||
db.set(['lastProcessedLine', options.source], lastSignature).value(); | ||
if (res) { | ||
@@ -104,0 +111,0 @@ console.log('statusCode: %s', res.statusCode); |
{ | ||
"name": "binds-co-toolbelt", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Binds.co toolbelt", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -8,3 +8,8 @@ # Binds.co toolbelt | ||
You also need a token from your Binds.co account. | ||
## Installation | ||
### Package | ||
```sh | ||
@@ -14,2 +19,8 @@ npm install -g binds-co-toolbelt | ||
### Token | ||
Define a environment variable containing the Binds.co token. | ||
- Ubuntu: `echo "export BINDS_CO_TOKEN=token" >> ~/.profile` | ||
- Windows: `setx BINDS_CO_TOKEN "token"` | ||
## Commands | ||
@@ -23,8 +34,8 @@ | ||
-h, --help output usage information | ||
-c, --cols <cols> columns to include, comma separated | ||
-e, --email [col] email collumn | ||
-n, --name [col] name collumn | ||
-p, --phone [col] phone collumn | ||
-t, --token <token> Binds.co API token | ||
-h, --help output usage information | ||
-c, --cols <cols> columns to include, comma separated | ||
-e, --email [col] email collumn | ||
-n, --name [col] name collumn | ||
-p, --phone [col] phone collumn | ||
-s, --source <source> Binds.co API source | ||
``` | ||
@@ -34,3 +45,3 @@ | ||
```sh | ||
binds-co b ./ORCVENS2.DBF -t XYZXYZXYZXYZXYZXYZXYZ -c PEDIDO,TOTAL,VENDEDOR -n CLINOME -e CLIEMAIL | ||
binds-co batch ./ORCVENS2.DBF -source XYZXYZXYZXYZXYZXYZXYZ -cols PEDIDO,TOTAL,VENDEDOR -name CLINOME -email CLIEMAIL | ||
``` | ||
@@ -37,0 +48,0 @@ |
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
5918
107
51
2