jails-cli
v1.4.0
Published
The Jails command line tool
Downloads
10
Readme
Jails ClI
Jails CLI helps you to:
- Scaffold Jails modules easily
- Build your Js project
- Install modules from Jails-org repository
Installing CLI
sudo npm i jails-cli -g
That's it... Now you're able to run jails
command. To uninstall just use the same command above but using uninstall npm command.
Important All the examples below are running jails-cli from js/
folder, you can run jails-cli from your project root folder and then specify your js
directory location. Check Commands section for further information.
Scaffolding
There's some modules that can be scaffolded.
- Apps
- Components
- Controllers
- Config file
jails new app my-app
That command above will create an app on your apps
folder named my-app.
It will generate the following snippet:
define(['jails'], function( jails ){
jails.app('my-app', function(html, data){
this.init = function(){
};
})
});
You can also save that in a specific folder:
jails new app product/page
Saving at: ** assets/js/apps/product/page.js **
The options available are : app
, component
, controller
,config
.
Building your Project
Jails uses RequireJs in order to make all AMD modules working. You can choose to build an app page and generate a single js minified file with all the modules within.
- You need to change your config file and include
config
andrequirejs
to the compilation step.
require.config({
baseUrl :'assets/js/',
deps :['jquery', 'jails', jailsapp.page],
include :['config', 'lib/requirejs'],
(...)
- Then, point your script file to your min js file:
<script type="text/javascript">
var jailsapp = {
page :'apps/home'
};
</script>
<script type="text/javascript" src="assets/js/min/home" data-main="apps/home"></script>
jailsapp is required for jails application. Don't use other global variable.
Run build command, pointing to your app, like home
:
jails build home
It will generate a assets/js/min/home.js minified file.
You can also run build task without any parameters to build all apps:
jails build
You can set uglify off, can be used to generate expanded files, very useful for debugs.
jails build -u none
or
jails build home -u none
Watch Files
The watching task is still on developing yet and doesn't let you to use many options for now, but it's quite usefull when you just need to build the application after changing some file.
jails watch <app>
App should be the application you're working, for now, the watching task will look for any changes on assets/js and descendents and build project. <app>
parameter is required, in the future it will have more options.
For instance, to build the app called home
when anything changes:
jails watch home
To quit watching on terminal just enter ctrl+c
.
Help
For more information and detailed options just hit:
jails
or
jails -h
Commands
Commands:
new <module> <name> Create an jails snippet code. Options: [app, component, controller, config].
build [app] Build project to a single min file, you can specify a single app.
watch <app> Watch for files changes and build the project automatically.
Options:
-u, --uglify <compression> set uglify to [uglify, uglify2, closure, closure.keepLines, none]. Default : uglify2
-d, --dir <dir> source js folder location
-o, --output <dir> dist js folder location
-c, --config <dir> set a config file to build process
--es6 generate modules with es6 sintax