Tutorial hero
Lesson icon

Complete List of Useful Sencha Cmd Commands

Originally published April 11, 2014 Time 5 mins

*Ok so perhaps not a complete list, but most of the ones you’ll probably ever care about and a few more. For reference, this list was compiled for Sencha Cmd v4.0.1.45

If you’re building Sencha Touch applications you are going to be (or at least should be) using Sencha Cmd quite a bit. There’s many commands available, and a subset of those will likely be very useful to you. It can be a little hard to figure out exactly what each one is doing and why it’s useful though. I’ve created this list to help clear up the commands you’ll find yourself using most often.

Help Commands

There’s no better place to seek help than the tool itself, Sencha Cmd has useful inbuilt documentation. You can access the generic help menu by running:

sencha help```

but you can also get help on specific commands by running a command like:

sencha help generate app```

or

sencha help app build```

and so on in the format of sencha help {command}.

### Commonly used commands

sencha generate app MyApp ../MyApp```

This is where it all begins! Running this command will generate you a new Sencha Touch application. ‘MyApp’ will be the name of your application and ‘../MyApp’ the directory where you would like it to be stored. In this case, we want to store it one directory above where we currently are.

sencha app watch```

This is a command that was introduced in Sencha Cmd 4 that will cause a process to run in the background that watches your entire application for changes and compiles as necessary. This eliminates the need to use a lot of other commands and is faster as well.

compass watch```

It’s probably going to be easier to just use ‘sencha app watch’ but if you would prefer not to, you can use ‘compass watch’ to watch for changes specifically to your .scss files – if a change is detected the new .css file will be generated.

sencha app refresh```

If you're not using 'sencha app watch' if you do anything that requires the bootstrap.js file to be updated (like [changing to a different theme][1]) you will need to manually run this command.

### Building your application

sencha app build native```

This triggers Sencha’s native packager, which produces a file that can be installed directly onto a device (.ipa for iOS and .apk for Android for example). Alternatively, and most would probably recommend, you can use PhoneGap instead of using the Sencha Touch native packager for building native files. Take a look at this post for information on how to get started with PhoneGap.

sencha app build production```

A production build minifies your application and will place the minified version inside of your application directory located at /build/production/MyApp. This does not overwrite your existing code (although it will overwrite any previous production builds you have created for this application). This function is intended to be used when you're ready to deploy the application and want to greatly reduce the file size and increase speed.

sencha app build package```

This is intended to create an app ready for native packaging. In the past however I have had trouble with this causing errors (it may very well just be me) but I tend to use the production build as a precursor to native packaging.

sencha app build testing```

This has a similar minimising effect to a production build but without completely minimising the files (i.e whitespace and line breaks aren't removed) so you can more easily track down errors.

### Upgrade commands

sencha app upgrade /path/to/sdk```

This will upgrade your current application (depending on the directory from which you run this command) to a new release of Sencha Touch that is specified by /path/to/sdk. You will certainly want to make backups before doing this, the upgrade process is not always 100% smooth.

sencha upgrade```

Similar to the last command but this one updates Sencha Cmd, not your application. You can check for a new version of Sencha Cmd before upgrading by running:

sencha upgrade —check```

Fun commands

The following commands I’ve never really found useful to use in my workflow. Typically I find it easier just to save a new copy of models, views and controllers through my editor. However, perhaps this method of generating files might suit you.

sencha generate model -n User -f id,name,email```

This will generate a model called 'User' with the fields 'id, name, email'

sencha generate controller -n MyController```

Generates a controller called ‘MyController’

sencha generate form -n MyForm -f name,email,phone```

Generates a view that extends 'Ext.form.Panel' with the specified fields

sencha generate profile -n iOS```

Generates a profile for iOS

Any commands I’ve missed out that you find useful? Let me know in the comments!

Learn to build modern Angular apps with my course