Comparing version 2.0.7 to 2.0.9
var gulp = require('gulp'); | ||
var gutil = require('gulp-util'); | ||
var browserify = require('gulp-browserify'); | ||
var babel = require('gulp-babel'); | ||
var notify = require('gulp-notify'); | ||
@@ -9,4 +10,2 @@ var gulpif = require('gulp-if'); | ||
var envify = require('envify'); | ||
var htmlmin = require('gulp-htmlmin'); | ||
var webserver = require('gulp-webserver'); | ||
var rename = require('gulp-rename'); | ||
@@ -18,3 +17,2 @@ var insert = require('gulp-insert'); | ||
var fs = require('fs'); | ||
var zip = require('gulp-zip'); | ||
var awspublish = require('gulp-awspublish'); | ||
@@ -26,3 +24,4 @@ var VERSION = require('./../package.json').version; | ||
'jslint', | ||
'browserify' | ||
'browserify', | ||
'dist' | ||
]; | ||
@@ -40,9 +39,14 @@ | ||
function watchFiles() { | ||
gulp.watch('./../index.js', ['jslint', 'browserify']); | ||
gulp.watch('./../src/**', ['jslint', 'browserify']); | ||
gulp.watch('./../examples/**', ['html']); | ||
} | ||
// browserify src/js to build/js | ||
gulp.task('browserify', function() { | ||
// delete the contents of build folder | ||
gulp.task('cleanbuild', function() { | ||
return del([ | ||
'./../dist/**', | ||
], {'force': true}); | ||
}); | ||
// browserify src/js to dist/browser/js | ||
gulp.task('browserify', ['cleanbuild'], function() { | ||
var buildVars = getBuildVars(); | ||
@@ -64,3 +68,3 @@ var replacePatterns = [ | ||
return gulp.src('./../index.js') | ||
return gulp.src('./../src/index.js') | ||
.pipe(browserify({ | ||
@@ -81,3 +85,2 @@ 'insertGlobals': false, | ||
})) | ||
.pipe(gulpif( buildVars.uglify, uglify() )) | ||
.pipe(rename(function (path) { | ||
@@ -87,47 +90,18 @@ path.basename = 'clarifai-' + VERSION; | ||
.pipe(insert.prepend(BROWSER_HEADER)) | ||
.pipe(gulp.dest('./../build/')); | ||
.pipe(gulp.dest('./../dist/browser')) | ||
.pipe(uglify()) | ||
.pipe(rename(function (path) { | ||
path.basename = 'clarifai-' + VERSION + '.min'; | ||
})) | ||
.pipe(gulp.dest('./../dist/browser')); | ||
}); | ||
// build examples | ||
gulp.task('html', function() { | ||
var buildVars = getBuildVars(); | ||
var CLIENT_ID = process.env.CLIENT_ID || ''; | ||
var CLIENT_SECRET = process.env.CLIENT_SECRET || ''; | ||
return gulp.src('./../examples/**.html') | ||
.pipe(gulpif( buildVars.uglify, htmlmin({collapseWhitespace: true}) )) | ||
.pipe(replace({ | ||
patterns: [ | ||
{ | ||
'match': 'VERSION', | ||
'replacement': VERSION | ||
}, | ||
{ | ||
'match': 'CLIENT_ID', | ||
'replacement': CLIENT_ID | ||
}, | ||
{ | ||
'match': 'CLIENT_SECRET', | ||
'replacement': CLIENT_SECRET | ||
} | ||
] | ||
gulp.task('dist', ['browserify'], function() { | ||
return gulp.src('./../src/**/*.js') | ||
.pipe(babel({ | ||
presets: ['es2015'] | ||
})) | ||
.pipe(gulp.dest('./../build/examples')); | ||
.pipe(gulp.dest('./../dist/node')); | ||
}); | ||
// webserver for examples | ||
gulp.task('webserver', function() { | ||
var port = gutil.env.port || '3000'; | ||
return gulp.src('./../build') | ||
.pipe(webserver({ | ||
'livereload': false, | ||
'open': false, | ||
'host': '0.0.0.0', | ||
'port': port, | ||
'directoryListing': { | ||
'enable':false, | ||
'path': 'build' | ||
} | ||
})); | ||
}); | ||
var buildVars = {}; | ||
@@ -258,9 +232,2 @@ | ||
// delete the contents of build folder | ||
gulp.task('cleanbuild', function() { | ||
return del([ | ||
'./../build/**', | ||
], {'force': true}); | ||
}); | ||
// deploy to the S3 bucket set in aws.json | ||
@@ -289,3 +256,3 @@ gulp.task( | ||
}; | ||
return gulp.src('./../build/**') | ||
return gulp.src(['./../dist/browser/**', './../docs/*']) | ||
.pipe(rename(function (path) { | ||
@@ -297,14 +264,1 @@ path.dirname = '/js/' + path.dirname; | ||
} | ||
gulp.task('zip', ['jslint'], function() { | ||
return gulp.src([ | ||
'./../index.js', | ||
'./../README.md', | ||
'./../spec', | ||
'./../src/*', | ||
'./../package.json', | ||
'./../examples/*' | ||
],{ 'base': './../' }) | ||
.pipe(zip('clarifai-' + VERSION + '.zip')) | ||
.pipe(gulp.dest('./../build')); | ||
}); |
{ | ||
"name": "clarifai", | ||
"version": "2.0.7", | ||
"version": "2.0.9", | ||
"description": "Official Clarifai Javascript SDK", | ||
"main": "index.js", | ||
"main": "dist/node/index.js", | ||
"repository": "https://github.com/Clarifai/clarifai-javascript", | ||
@@ -10,3 +10,3 @@ "author": "Clarifai Inc.", | ||
"scripts": { | ||
"jsdoc": "jsdoc src/* -t node_modules/minami -d build/docs-$npm_package_version" | ||
"jsdoc": "jsdoc src/* -t node_modules/minami -d docs/$npm_package_version" | ||
}, | ||
@@ -33,3 +33,2 @@ "dependencies": { | ||
"gulp-eslint": "2.0.0", | ||
"gulp-htmlmin": "1.2.0", | ||
"gulp-if": "2.0.0", | ||
@@ -45,4 +44,2 @@ "gulp-imagemin": "2.3.0", | ||
"gulp-util": "3.0.6", | ||
"gulp-webserver": "0.9.1", | ||
"gulp-zip": "3.2.0", | ||
"jsdoc": "^3.4.1", | ||
@@ -49,0 +46,0 @@ "minami": "^1.1.1", |
var fs = require('fs'); | ||
var Clarifai = require('./../index'); | ||
var Clarifai = require('./../src/index'); | ||
var Models = require('./../src/Models'); | ||
@@ -12,7 +12,2 @@ var Inputs = require('./../src/Inputs'); | ||
function generateRandomId() { | ||
return Math.floor(Math.random() * 1000000); | ||
} | ||
describe('Clarifai JS SDK', function() { | ||
@@ -73,8 +68,8 @@ beforeAll(function() { | ||
describe('Inputs', function() { | ||
var id = 'test-id' + generateRandomId(); | ||
var inputId; | ||
it('Adds an input', function(done) { | ||
app.inputs.create([ | ||
{ | ||
"url": "https://samples.clarifai.com/metro-north.jpg", | ||
"id": id | ||
url: "https://samples.clarifai.com/metro-north.jpg", | ||
allowDuplicateUrl: true | ||
} | ||
@@ -88,2 +83,3 @@ ]).then( | ||
expect(inputs[0].id).toBeDefined(); | ||
inputId = inputs[0].id; | ||
expect(inputs[0].toObject().data).toBeDefined(); | ||
@@ -96,16 +92,15 @@ done(); | ||
var id2 = 'test-id' + generateRandomId(); | ||
it('Adds an input with tags', function(done) { | ||
app.inputs.create([ | ||
{ | ||
"url": "https://samples.clarifai.com/metro-north.jpg", | ||
"id": id2, | ||
"concepts": [ | ||
url: "https://samples.clarifai.com/metro-north.jpg", | ||
allowDuplicateUrl: true, | ||
concepts: [ | ||
{ | ||
"id": "train", | ||
"value": true | ||
id: "train", | ||
value: true | ||
}, | ||
{ | ||
"id": "car", | ||
"value": false | ||
id: "car", | ||
value: false | ||
} | ||
@@ -128,13 +123,11 @@ ] | ||
var id3 = 'test-id' + generateRandomId(); | ||
var id4 = 'test-id' + generateRandomId(); | ||
it('Bulk adds inputs', function(done) { | ||
app.inputs.create([ | ||
{ | ||
"url": "https://samples.clarifai.com/metro-north.jpg", | ||
"id": id3 | ||
url: "https://samples.clarifai.com/metro-north.jpg", | ||
allowDuplicateUrl: true | ||
}, | ||
{ | ||
"url": "https://samples.clarifai.com/dog.tiff", | ||
"id": id4 | ||
url: "https://samples.clarifai.com/dog.tiff", | ||
allowDuplicateUrl: true | ||
} | ||
@@ -155,16 +148,14 @@ ]).then( | ||
var id5 = 'test-id' + generateRandomId(); | ||
var id6 = 'test-id' + generateRandomId(); | ||
it('Bulk adds inputs with tags', function(done) { | ||
app.inputs.create([ | ||
{ | ||
"url": "http://i.imgur.com/HEoT5xR.png", | ||
"id": id5, | ||
"concepts": [ | ||
url: "http://i.imgur.com/HEoT5xR.png", | ||
allowDuplicateUrl: true, | ||
concepts: [ | ||
{ | ||
"id": "ferrari", | ||
"value": true | ||
id: "ferrari", | ||
value: true | ||
}, | ||
{ | ||
"id": "outdoors" | ||
id: "outdoors" | ||
} | ||
@@ -174,12 +165,12 @@ ] | ||
{ | ||
"url": "http://i.imgur.com/It5JRaj.jpg", | ||
"id": id6, | ||
"concepts": [ | ||
url: "http://i.imgur.com/It5JRaj.jpg", | ||
allowDuplicateUrl: true, | ||
concepts: [ | ||
{ | ||
"id": "ferrari", | ||
"value": true | ||
id: "ferrari", | ||
value: true | ||
}, | ||
{ | ||
"id": "outdoors", | ||
"value": false | ||
id: "outdoors", | ||
value: false | ||
} | ||
@@ -222,6 +213,6 @@ ] | ||
it('Gets a single input by id', function(done) { | ||
app.inputs.get(id).then( | ||
app.inputs.get(inputId).then( | ||
function(input) { | ||
expect(input).toBeDefined(); | ||
expect(input.id).toBe(id); | ||
expect(input.id).toBe(inputId); | ||
expect(input.createdAt).toBeDefined(); | ||
@@ -252,3 +243,3 @@ expect(input.toObject().data).toBeDefined(); | ||
{ | ||
id, | ||
id: inputId, | ||
concepts: [ | ||
@@ -468,4 +459,4 @@ { "id":"train", "value": true }, | ||
function errorHandler(err) { | ||
console.log(err); | ||
expect(err).toBe(true); | ||
expect(err.status).toBe(true); | ||
expect(err.data).toBe(true); | ||
this(); | ||
@@ -472,0 +463,0 @@ }; |
@@ -88,3 +88,3 @@ let axios = require('axios'); | ||
if (isSuccess(response)) { | ||
resolve(new Concept(this._config, response.data.concepts)); | ||
resolve(new Concepts(this._config, response.data.concepts)); | ||
} else { | ||
@@ -91,0 +91,0 @@ reject(response); |
@@ -33,2 +33,5 @@ let {Promise} = require('es6-promise'); | ||
}; | ||
if (data.allowDuplicateUrl) { | ||
formatted.data.image['allow_duplicate_url'] = true; | ||
} | ||
} | ||
@@ -35,0 +38,0 @@ return formatted; |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 15 instances in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
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
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
1938478
28
84
7393
2
19
19