Docs

Everything You Need to Know

Tutorials

Getting Started

Complete Truck

Creating a Project

You could create a project by copying all the files you need from the Github sources files, but then why would you want to do that? There are better ways.

NPM Module

Truck has an NPM module for quickly creating Truck projects. Just install the module globally on your machine and you're ready to start cranking out Truck apps. When you use this module to create a project, it gives you both development and minified versions, a basic app structure and a TypeScript declaration file which you can use with your Text Editor or IDE for tooling (Intellisense, code completion, etc.).

Before you can do anything, of course, you've got to install the NPM module:

npm install truckjs -g

On a Mac or Linux you will need to run this with sudo, which will ask you for your password. Once this is installed, you're ready to start making projects. There are a number of options you can provide to control how the Truckjs module setting the project up.

Options:
  • --name or -n A name for your project
  • --path or -p A path to where you want your project put
  • --os or -o The operating system you want to target
  • --type or -t The type of app shell you want

Let's break these down. Notice that each option has two versions of the flag - a long form with double hyphens and a short for with one hyphen and one letter. You can choose which you prefer.

To successfully create a project, Truckjs needs at least two values: a name for the project and an OS to target. The name can be whatever you want. Please note if there is already a folder in that location with the same name as the project you are creating, it will be replaced with your new project. If you want to replace an existing project, not a problem, but you do need to be aware of this. The other value you must provide is an OS: android, ios or win. These must be lower case. This will provide the correct theme for the target operating system.

// Create an iOS app:
truckjs -n myApp -o ios
// Create and Android app:
truckjs -n myApp -o android
// Create a Windows Phone app:
truckjs -n myApp -o win

Running any of the above commands will create a base app shell for the designated operating system. Because a path was not provided, it will be created on the user's desktop. If you want to create the project at a specific location, you'll need to provide the path flag:

// Create an iOS app:
// Path is for Mac OS X:
truckjs -n myApp -o ios -p ~/Documents/Dev
// Create and Android app:
truckjs -n myApp -o android ~/Documents/Dev
// Create a Windows Phone app:
// Path is for Windows file system:
truckjs -n myApp -o win ~\Documents\Dev

You can also tell Truckjs to create a particular type of app shell. The default is a single screen with a static list. Using the type flag you can create a navigation list with routing, simple tab bar or a slide out menu app. These will have working code included, giving you a clear idea how to customize them and make them work for your needs. The type flag can handle four values: default, navigation, tabbar and slideout. If no type flag is provided, then the default type will be created:

// Create a default app:
truckjs -n myApp -o ios -t default
// Create a navigation list:
truckjs -n myApp -o android -t navigation
// Create a tab bar interface:
truckjs -n myApp -o win -t tabbar
// Create a slide out menu app:
truckjs -n myApp -o ios -t slideout