This is another attempt to make some shortcuts while working with Meteor framework. In a previous post, I wrote about a bash script that could generate a reasonable (for me) directory structure for a new Meteor project. Additionally the script could download a fixed number of packages.
In it’s new iteration the script has the following features:
- Creates a directory structure and various files
- Downloads a fixed number of Meteor packages along with packages passed as arguments in command line
- Can create new collections and their respective fixtures server-side
- Can create new views (a combination of a new directory, a template, a helper and a new route)
- Can scaffold a CRUD view for a given name, a collection, a fixture and a route
- Generates navigational links from all views
I will not go into details as all the commands are explained at project’s README hosted on GitHub. What I will do is to create a small site with the tool in order to demonstrate how many steps required for such result. The following assumes that the script is placed somewhere in user’s path, it is executable
chmod +x meteor-project and is available from the command line. Additionally the dollar sign
$ represents the user’s command prompt
Create a new project with the default packages (the script installs iron router and Bootstrap 3) named blog:
$meteor-project project blog
after some command line output, the outcome will be a directory structure like this:
at this point the generated site looks like the this:
CRUD views generation using scaffold command:
$meteor-project scaffold user name:string registered:date isAdmin:boolean
isAdmin along with their types are used to generate HTML controls and the respective collection and fixture.
After the execution of the above command, the directory looks like the following screenshot:
Finally generate a link in navbar for the newly created user view:
The visual result of steps 2 and 3 is this:
index page check the
views -> user menu link
user index page showing all generated by the fixture user objects along with
new working buttons. Additionally each page’s title is automatically updated.
Supported HTML controls: string, text, number, date, boolean, password url, tel, email, file, color and select.