nl_tokens: Usage : captain init <name > [ -- force ]
pl_tokens: function init ( target ) { function create_project ( name , uri ) { console . log ( ) ; console . log ( terminal . cyan ( 'Creating project: ' ) + name ) ; console . log ( ) ; // Creating dirs helpers . dirs ( name , [ 'cache' , 'media' , 'logs' , 'themes' ] ) ; // Copying files helpers . copyR ( [ join ( 'themes' , 'default' ) ] , name ) ; // Creating files var templates = helpers . files ( { name : name , uri : uri } ) ; Object . keys ( templates ) . forEach ( function ( key ) { var p = join ( name , key ) , dir = dirname ( key ) ; if ( dir != '.' ) { helpers . mkdir ( join ( name , dir ) ) ; } helpers . write ( p , templates [ key ] ) ; } ) ; } if ( target === true ) { program . help ( ) ; } function _init ( ) { console . log ( ) ; console . log ( terminal . cyan ( 'Initializing project: ' ) + target ) ; // Testing connection prompt_uri ( function ( uri ) { console . info ( terminal . cyan ( 'Connection successful!' ) ) ; console . log ( ) ; console . info ( terminal . cyan ( 'Creating database schema...' ) ) ; // Creating projects files create_project ( target , uri ) ; // Synchronizing database var db = require ( 'captain-core/lib/db' ) ; var conf = require ( 'captain-core' ) . conf ; conf . reload ( join ( cwd , target ) ) ; db . syncDB ( { uri : uri , complete : function ( err ) { if ( err ) { terminal . abort ( err ) ; } console . log ( ) ; console . info ( terminal . cyan ( 'Done!' ) ) ; console . log ( ) ; console . info ( terminal . cyan ( 'Creating first user...' ) ) ; console . log ( ) ; // Creating user create_user ( { no_commit : true , success : function ( ) { // Instructions console . <mask> ( ) ; console . info ( terminal . cyan ( 'Done!' ) ) ; console . log ( ) ; console . info ( terminal . cyan ( 'Now run:' ) ) ; console . log ( helpers . pad ( 'cd ' + target ) ) ; console . log ( helpers . pad ( 'captain run' ) ) ; terminal . exit ( '' ) ; } } ) ; } } ) ; } ) ; } if ( helpers . exists ( target ) && ! helpers . isEmptyDirectory ( target ) && ! program . force ) { program . prompt ( 'Directory not empty, force create? (y/n): ' , function ( answer ) { var forceCreate = ! ! answer . match ( / y|yes|arrr / i ) ; if ( forceCreate ) { _init ( ) ; } else { terminal . abort ( 'Cowardly refusing to init project in a non-empty directory' ) ; } } ) ; } else { _init ( ) ; } }