clever-auth
Advanced tools
Comparing version 1.0.1 to 1.0.2
module.exports = function ( Model, config ) { | ||
console.log(config['clever-auth'].driver) | ||
return Model.extend( 'User', | ||
@@ -4,0 +3,0 @@ { |
{ | ||
"name": "clever-auth", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"dependencies": { | ||
@@ -5,0 +5,0 @@ "passport": "^0.2.0", |
@@ -1,77 +0,74 @@ | ||
var Q = require( 'q' ) | ||
, spawn = require( 'child_process' ).spawn | ||
, path = require( 'path' ) | ||
, fs = require( 'fs' ) | ||
, ncp = require('ncp').ncp; | ||
var Promise = require( 'bluebird' ) | ||
, spawn = require( 'child_process' ).spawn | ||
, path = require( 'path' ) | ||
, fs = require( 'fs' ) | ||
, rimraf = require( 'rimraf' ) | ||
, ncp = require( 'ncp' ).ncp | ||
, prName = 'testProject'; | ||
var prName = 'testProject'; | ||
function createProject() { | ||
return new Promise( function( resolve, reject ) { | ||
var proc = spawn ( 'clever', [ 'init', '-f', '-A', prName, 'backend' ] ); | ||
//create test project | ||
function createProject () { | ||
var defered = Q.defer() | ||
, proc = spawn ( 'clever', [ 'init', '--allow-root', '--skip-protractor', prName ] ); | ||
console.log( 'step #1 - create test project - begin\n' ); | ||
console.log( 'step #1 - create test project - begin\n' ); | ||
proc.stdout.on('data', function ( data ) { | ||
var str = data.toString(); | ||
proc.stdout.on('data', function ( data ) { | ||
var str = data.toString(); | ||
if ( str.match( /ing/ ) !== null ) { | ||
console.log( str ) | ||
} | ||
}); | ||
if ( str.match( /ing/ ) !== null ) { | ||
console.log( str ) | ||
} | ||
}); | ||
proc.stderr.on('data', function ( data ) { | ||
console.log( 'Error in step #1 - ' + data.toString() + '\n' ); | ||
reject ( data.toString() ); | ||
}); | ||
proc.stderr.on('data', function ( data ) { | ||
console.log( 'Error in step #1 - ' + data.toString() + '\n' ); | ||
defered.reject ( data.toString() ); | ||
proc.on( 'close', function ( code ) { | ||
console.log('step #1 process exited with code ' + code + '\n'); | ||
resolve(); | ||
}); | ||
}); | ||
proc.on( 'close', function ( code ) { | ||
console.log('step #1 process exited with code ' + code + '\n'); | ||
defered.resolve(); | ||
}); | ||
return defered.promise; | ||
} | ||
//install clever-orm module to test project | ||
function installORM () { | ||
var defered = Q.defer() | ||
, proc = spawn ( 'clever', [ 'install', 'clever-orm' ], { cwd: path.join( __dirname, '../', prName ) } ); | ||
function installORM() { | ||
return new Promise( function( resolve, reject ) { | ||
var objs = [ | ||
{ reg: /Database username/ , write: 'travis\n' , done: false }, | ||
{ reg: /Database password/ , write: '\n' , done: false }, | ||
{ reg: /Database name/ , write: 'test_db\n' , done: false }, | ||
{ reg: /Database dialect/ , write: '\n' , done: false }, | ||
{ reg: /Database port/ , write: '3306\n' , done: false }, | ||
{ reg: /Database host/ , write: '127.0.0.1\n', done: false }, | ||
] | ||
, proc = spawn ( 'clever', [ 'install', 'clever-orm' ], { cwd: path.join( __dirname, '../', prName ) } ); | ||
console.log( 'step #2 - install clever-orm module - begin\n' ); | ||
console.log( 'step #4 - install clever-orm module - begin\n' ); | ||
proc.stdout.on('data', function (data) { | ||
var str = data.toString() | ||
, objs = [ | ||
{ reg: /Database username/ , write: 'travis\n' }, | ||
{ reg: /Database password/ , write: '\n' }, | ||
{ reg: /Database name/ , write: 'test_db\n' }, | ||
{ reg: /Database dialect/ , write: '\n' }, | ||
{ reg: /Database port/ , write: '3306\n' }, | ||
{ reg: /Database host/ , write: '127.0.0.1\n' }, | ||
]; | ||
proc.stdout.on('data', function (data) { | ||
var str = data.toString(); | ||
if ( str.match( /ing/ ) !== null ) { | ||
console.log( str ) | ||
} | ||
if ( str.match( /ing/ ) !== null ) { | ||
console.log( str ) | ||
} | ||
objs.forEach ( function ( obj ) { | ||
if ( str.match( obj.reg ) !== null ) { | ||
proc.stdin.write( obj.write ); | ||
} | ||
objs.forEach ( function ( obj, i ) { | ||
if ( obj.done !== true && str.match( obj.reg ) !== null ) { | ||
objs[i].done = true; | ||
proc.stdin.write( obj.write ); | ||
} | ||
}); | ||
}); | ||
}); | ||
proc.stderr.on('data', function (data) { | ||
console.log( 'Error in step #2 - ' + data.toString() + '\n'); | ||
defered.reject ( data.toString() ); | ||
}); | ||
proc.stderr.on('data', function (data) { | ||
console.log( 'Error in step #4 - ' + data.toString() + '\n'); | ||
reject ( data.toString() ); | ||
}); | ||
proc.on('close', function (code) { | ||
console.log('step #2 process exited with code ' + code + '\n' ); | ||
defered.resolve(); | ||
proc.on('close', function (code) { | ||
console.log('step #4 process exited with code ' + code + '\n' ); | ||
resolve(); | ||
}); | ||
}); | ||
return defered.promise; | ||
} | ||
@@ -81,168 +78,103 @@ | ||
function copyAuthModule () { | ||
var defered = Q.defer() | ||
, fromDir = path.join( __dirname, '../' ) | ||
, toDir = path.join( __dirname, '../', prName, 'backend', 'modules', 'clever-auth' ); | ||
return new Promise( function( resolve, reject ) { | ||
var fromDir = path.join( __dirname, '../' ) | ||
, toDir = path.join( __dirname, '../', prName, 'modules', 'clever-auth' ); | ||
console.log( 'step #3 - copy clever-auth modyle in test project - begin\n' ); | ||
console.log( 'step #2 - copy clever-auth module in test project - begin\n' ); | ||
function copyDir ( from, to ) { | ||
var files = fs.readdirSync( from ); | ||
function copyDir ( from, to ) { | ||
var files = fs.readdirSync( from ); | ||
if ( !fs.existsSync( to ) ) { | ||
fs.mkdir( to, function ( err ) { | ||
if ( err ) { | ||
console.log( 'error - ' + err) | ||
} | ||
}) | ||
} | ||
if ( !fs.existsSync( to ) ) { | ||
fs.mkdir( to, function ( err ) { | ||
if ( err ) { | ||
console.log( 'error - ' + err) | ||
} | ||
}) | ||
} | ||
files.forEach ( function ( file ) { | ||
fs.stat( path.join( from, file ), function ( err, stats ) { | ||
files.forEach ( function ( file ) { | ||
if ( err ) { | ||
console.log( 'Error in step #3 - ' + err + '\n'); | ||
defered.reject ( err ); | ||
} | ||
fs.stat( path.join( from, file ), function ( err, stats ) { | ||
if ( err ) { | ||
console.log( 'Error in step #2 - ' + err + '\n'); | ||
reject ( err ); | ||
} | ||
if ( stats && stats.isFile() ) { | ||
copyFile ( path.join( from, file ), path.join( to, file ) ); | ||
} | ||
if ( stats && stats.isFile() ) { | ||
copyFile ( path.join( from, file ), path.join( to, file ) ); | ||
} | ||
if ( stats && stats.isDirectory() && file != prName ) { | ||
ncp( path.join( from, file ), path.join( to, file ), function ( err ) { | ||
if (err) { | ||
console.log( 'Error in step #3 - ' + err + '\n'); | ||
defered.reject ( err ); | ||
} | ||
}); | ||
} | ||
}) | ||
}) | ||
} | ||
function copyFile ( from, to ) { | ||
var rs = fs.createReadStream( from ) | ||
, ws = fs.createWriteStream( to ); | ||
rs.on( 'error', function( err ) { | ||
console.log( err ); | ||
}); | ||
ws.on( 'error', function(err) { | ||
console.log( err ); | ||
}); | ||
rs.pipe( ws ); | ||
} | ||
copyDir( fromDir, toDir ); | ||
console.log('step #3 process exited with code 0\n' ); | ||
defered.resolve(); | ||
return defered.promise; | ||
} | ||
//create and update config files | ||
function configFiles( ) { | ||
var deferred = Q.defer() | ||
, ormFile = path.join( __dirname, '../', prName, 'backend', 'modules', 'clever-orm', 'config', 'default.json' ) | ||
, comFile = path.join( __dirname, '../', prName, 'backend', 'config', 'test.json' ) | ||
, ormData = { | ||
"clever-orm": { | ||
"db": { | ||
"username": "travis", | ||
"password": "", | ||
"database": "test_db", | ||
"options": { | ||
"host": "127.0.0.1", | ||
"dialect": "mysql", | ||
"port": 3306 | ||
}, | ||
}, | ||
"modelAssociations": {} | ||
} | ||
} | ||
, comData = { | ||
"environmentName": "TEST", | ||
"memcacheHost": "127.0.0.1:11211", | ||
"clever-orm": { | ||
"db": { | ||
"username": "travis", | ||
"password": "", | ||
"database": "test_db", | ||
"options": { | ||
"dialect": "mysql", | ||
"host": "127.0.0.1", | ||
"port": "3306" | ||
if ( stats && stats.isDirectory() && file != prName ) { | ||
ncp( path.join( from, file ), path.join( to, file ), function ( err ) { | ||
if (err) { | ||
console.log( 'Error in step #2 - ' + err + '\n'); | ||
reject ( err ); | ||
} | ||
}); | ||
} | ||
} | ||
} | ||
}; | ||
}) | ||
}) | ||
} | ||
console.log( 'step #4 - create and update config files - begin\n' ); | ||
function copyFile ( from, to ) { | ||
var rs = fs.createReadStream( from ) | ||
, ws = fs.createWriteStream( to ); | ||
rs.on( 'error', function( err ) { | ||
console.log( err ); | ||
}); | ||
fs.writeFile ( ormFile, JSON.stringify ( ormData ), function ( err ) { | ||
if ( err ) { | ||
console.log( 'Error in step #4 - ' + err + '\n'); | ||
return deferred.reject ( err ); | ||
ws.on( 'error', function(err) { | ||
console.log( err ); | ||
}); | ||
rs.pipe( ws ); | ||
} | ||
fs.writeFile ( comFile, JSON.stringify ( comData ), function ( err ) { | ||
copyDir( fromDir, toDir ); | ||
if ( err ) { | ||
console.log( 'Error in step #4 - ' + err + '\n'); | ||
return deferred.reject ( err ); | ||
} | ||
console.log('step #4 process exited with code 0\n' ); | ||
deferred.resolve(); | ||
}); | ||
console.log('step #2 process exited with code 0\n' ); | ||
resolve(); | ||
}); | ||
return deferred.promise; | ||
} | ||
//added clever-auth module in bundledDependencies | ||
function bundled( ) { | ||
var deferred = Q.defer() | ||
, file = path.join( __dirname, '../', prName, 'backend', 'package.json' ); | ||
function bundled() { | ||
return new Promise( function( resolve, reject ) { | ||
var file = path.join( __dirname, '../', prName, 'package.json' ); | ||
console.log( 'step #5 - added clever-auth module in bundledDependencies\n' ); | ||
console.log( 'step #3 - added clever-auth module in bundledDependencies\n' ); | ||
fs.readFile ( file, function ( err, data ) { | ||
fs.readFile ( file, function ( err, data ) { | ||
if ( err ) { | ||
console.log( 'Error in step #5 - ' + err + '\n'); | ||
return deferred.reject ( err ); | ||
} | ||
if ( err ) { | ||
console.log( 'Error in step #3 - ' + err + '\n'); | ||
return reject ( err ); | ||
} | ||
data = JSON.parse ( data ); | ||
data = JSON.parse ( data ); | ||
data.bundledDependencies.push ( 'clever-auth' ); | ||
data.bundledDependencies.push ( 'clever-auth' ); | ||
fs.writeFile ( file, JSON.stringify ( data ), function ( err ) { | ||
fs.writeFile ( file, JSON.stringify ( data ), function ( err ) { | ||
if ( err ) { | ||
console.log( 'Error in step #5 - ' + err + '\n'); | ||
return deferred.reject ( err ); | ||
} | ||
if ( err ) { | ||
console.log( 'Error in step #3 - ' + err + '\n'); | ||
return reject ( err ); | ||
} | ||
console.log('step #5 process exited with code 0\n' ); | ||
deferred.resolve(); | ||
console.log('step #3 process exited with code 0\n' ); | ||
resolve(); | ||
}); | ||
}); | ||
}); | ||
return deferred.promise; | ||
} | ||
createProject ( ) | ||
.then ( installORM ) | ||
.then ( copyAuthModule ) | ||
.then ( configFiles ) | ||
.then ( bundled ) | ||
.fail ( function (err) { | ||
.then ( installORM ) | ||
.catch ( function (err) { | ||
console.log('Error - ' + err ); | ||
}); |
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
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
135050
2814