Automated node development environment & resource compiler
Auton is an automated node.js development environment & resource compiler which is meant to be flexible and extensible. A few things you can pull off with Auton:
Auton's file watcher API (currently using watchr underneath) provides an API that should feel comfortable to anyone used to programming in express.
var Auton = require'auton'Auton;var mw = AutonMiddleware;var robot =root : __dirnameserver : path: 'server.js';robotwatch'src/js' 'src/css' 'src/templates';robotuse /\.$/ mwread ; // run for all matched filesrobotuse '*.js' mwjshint ;robotfile'src/js/**/*.js' mwdestination'src/js' 'public/_/js' mwcheckAge mwcommonJsToAmd mwuglifyjs mwsave robotservermiddleware ;robotfile'src/css/**/*.styl' mwdestination return inputreplace/\.styl$/'.css'replace'src/css''public/_/css'; mwcheckAge mwstylus mwcssmin mwsave ;robotfile'src/vendor/**/*' mwcopy destination: 'src/vendor''public/_/vendor' ;robotserverstart;robotwatcherstart;robotscanAll;
var filename = filepath; // all middleware always have thisvar fullpath = filefullpath; // same with thisvar destname = filedestination; // these are normally generated by Auton.Middleware.destination()var fullpath = filefulldestination; // but any middleware could manually set themvar root = fileroot; // Auton's root directory// In addition, middleware can cause Auton to output using one of the following. Auton's UI may throw these messages away or display them depending on user preference:thissuccess"It Worked!";this.error"Something bad happened!";this.info"Helpful Information";thiswarning"Caution: something you maybe didn't expect is happening";thisdebug"probably more information than is needed";thisdebug2"apparently you really want to see a ridiculous amount of information about what's happening. if you care about this you're probably fixing something. and you're probably me.";;
This middleware sets file.destination to a path which is calculated from file.path.
// using a static filenamerobotfile'somefile.js' mwdestination filename: 'outputfile.js' ; // somefile.js -> outputfile.jsrobotfile'somefile.js' mwdestination'outputfile.js' ; // somefile.js -> outputfile.js// mw.destination(a,b) and mw.destination([a,b]) get turned into file.replace(a,b)robotfile'somedir/*.js' mwdestination 'somedir/' 'outputdir/' ; // somedir/file.js -> outputdir/file.jsrobotfile'banana-man.js' mwdestination /[aeiou]/g 'oo' ; // banana-man.js -> boonoonoo-moon.jsrobotfile'src/**/*.js' mwdestination pattern: p replace: r ; // equivalent to mw.destination( p, r );// "mw.destination( someFunction );" is a shortcut for "file.destination = someFunction( file.path );"varreturn _inputreplace/\.coffee/g '.js'replace'src' 'public';;robotfile'src/foo.coffee' mwdestination transform: _coffee ; // function which takes input filename and returns output filenamerobotfile'src/foo.coffee' mwdestination _coffee ; // shortcut for above, both do: src/foo.coffee -> public/foo.js
Both mw.copy() and mw.save() use this middleware to determine the proper file to save to. Underneath, all it does is set file.destination = newPath, so you can replace a call to mw.destination() with a middleware which sets file.destination to a string value of your choice and both .save() and .copy() would listen to you (unless they're called with a custom destination, in which case this field is ignored. see below.)
Performs a CommonJS to AMD translation, useful for code meant to run both natively under node and in the browser through an AMD-compatible loader such as require.js.