1.3.0 • Published 8 years ago

iron-maka v1.3.0

Weekly downloads
-
License
MIT
Repository
-
Last release
8 years ago

iron-maka

maka-cli with Iron Router.

NOTICE

This package has been created in anticipation of maka-cli version 2.0.0 which will remove iron router as the default router for meteor applications. Maka-cli will be using FlowRouter for client side routing and Restivus for server side routing.

Installing iron-maka will provide you 'iron-maka' for performing all your scaffolding. Use 'iron-maka' where ever you used to use 'maka'.

Iron-Maka will NOT be getting any 2.0.0 updates, and will remain indefinitely in 1.x.x.

Installation

Install the iron-maka command line tool globally so you can use it from any project directory.

$ npm install -g iron-maka

Update 1.3.0

I'm happy to announce that a new scaffolding generator has been released! This version brings in:

iron-maka g:api Todos

What this will do is scaffold out an api "concept" that is closely aligned with Meteor 1.3 application structure. All the files generated will be located in the /app/imports/api/<concept> directory.

You will need to edit the methods.js, publications.js and api.js to explicitly expose the methods, publications and CRUD.

I encourage you to take a look at the Meteor Guide's application structure section for more information: https://guide.meteor.com/structure.html

Update 1.2.0

This version updates the collections scaffolding. From the beginning of Meteor we've had to place collections as a global variable. Now that Meteor 1.3 has support for export/import, we should be exporting the collections explicitly as constants.

No longer will iron-maka g:collection Todo place the collection in the /app/lib directory.

Collections will now be placed by default in the /app/imports/startup/lib/collections directory and automatically exported and imported explicitly into the app.

Please note that for existing applications the first time you create a collection a file will be added: /app/lib/main.js that will explicitly import all of the /app/imports/lib directory.

Defining server or client side collections will also still work. (i.e. iron-maka g:col Todo --where "server")

I know this isn't completely in line with the Meteor 1.3 application structure. Many projects still use 1.2, and this is an effort to bring Maka closer to 1.3 while still keeping 1.2 applications relevant.

Usage

Use the help command to get a list of the top level commands.

$ iron-maka help

Use the g command to see a list of generators.

$ iron-maka g

Commands

Migrate from Iron-meteor

In the app directory:

$ iron-maka migrate

Create an Application

$ iron-maka create my-app

The following parameters can be specified:

--skip-template-css=true|false
--skip-template-js=true|false
--skip-template-html=true|false
--skip-iron-maka-router
--skip-route-controller
--skip-route-template
--skip-generator-comments

Run Your Application

$ iron-maka run

or just

$ iron-maka

Generators

$ iron-maka g:scaffold todos
$ iron-maka g:template todos/todo_item
$ iron-maka g:collection todos
$ iron-maka g:route webhooks/stripe --where "server"
$ iron-maka g:controller todos/show_todo
$ iron-maka g:route todos/show_todo --action "show"
$ iron-maka g:publish todos
$ iron-maka g:stylesheet main
$ iron-maka g:package package:name

Testing

$ iron-maka --test

This may be used with --env to test prod settings as well as other options such as --port:

$ iron-maka --test --env production --port 3010

Testing packages in isolation with jasmine has also been added:

$ iron-maka --test-packages package-name

To prevent the install of this testing package use the param:

$ iron-maka create package-name --skip-jasmine

If you don't have jasmine, and would like it in your existing app:

$ iron-maka add sanjo:jasmine velocity:html-reporter.

This will automatically load your config/development/env.sh and config/development/settings.json files.

Run the Application with a Different Environ-makament

$ iron-maka run --env=staging

This will use the config files in config/staging instead.

Debug Your Application on the Server Side

$ iron-maka debug

Build Your Application

$ iron-maka build

Connect to MongoDB Database

$ cd app/
$ meteor mongo

NOTE

Ideally running iron-maka mongo in the project directory should work but it doesn't for some reason and is being tracked in issue #136

Deployment

Deploy Your Application with Meteor Up

Meteor Up is a command line tool to deploy any Meteor app to your own server.

Configure Meteor Up

The following configuration options are supported in config.json:

"mup": {
  "environ-makament": "/path/to/environ-makament"
}

Initialize Meteor Up

Use iron-maka mupx to run Meteor Up commands. To create a mup.json file for an environ-makament run:

iron-maka mupx <environ-makament> --init

Deploy Your Application on Heroku

Maka projects require buildpacks to look for the app in /app/ in addition to the root for deployments to work. Currently there is a patched version of the Horse buildpack available that is compatible with Iron based projects. Use this fork until the patches has been added to the main Horse repo.

Initialize the git repo

$ git init
$ git add .
$ git commit -m 'init'

Create the heroku app:

$ heroku create <app-name>

Setup the build pack

$ heroku buildpacks:set https://github.com/AdmitHub/meteor-buildpack-horse.git

This will build your application and put the resulting bundle into the project's build folder.

Setup MongoDB

$heroku addons:create mongolab

Configure your ROOT_URL

$ heroku config:set ROOT_URL=https://<app-name>.herokuapp.com

or, if you have DNS setup

$ heroku config:set ROOT_URL=https://www.<domain-name>.com

Depoy to heroku

$ git push heroku master

Enable sticky session-support

$ heroku labs:enable http-session-affinity

Set your settings path

$ heroku config:add METEOR_SETTINGS="$(cat config/production/settings.json)"

Deploy Meteor App on CentOS

$ iron-maka build --architecture os.linux.x86_32
or
$ iron-maka build --architecture os.linux.x86_64

Copy the build to its final home on the CentOS box.

Update Yum:
	$ yum -y update

    Install EPEL
    $ yum -y install epel-release

    Install NodeJS and Npm:
    $ yum -y install nodejs npm

    Verify Node Version
    $ node --version

    Install MongoDB
    	1. Add the MongoDB Yum repo by editing mongodb.repo and adding in the definition:
    	$ vim /etc/yum.repos.d/mongodb.repo

            [mongodb]
            name=MongoDB repo
            baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64/
            gpgcheck=0
            enabled=1

        2. Install the MongoDB packages
            $ yum install mongodb-org

        3. Start MongoDB
            $ chkconfig mongod on
            $ service mongod start


The following environ-makament variables should be modified to suit your needs.
$ export MONGO_URL='mongodb://localhost:27017/<dbName>'
$ export ROOT_URL='http://localhost'
$ export MAIL_URL='smtp://user:password@mailhost:port/'
$ export PORT=3000

$ (cd programs/server && npm install)

$ (cd to bundle root)
$ node main.js

Directory Structure

The application will have the following directory structure:

my-app/
 .maka/
   config.json
 bin/
 build/
 config/
   development/
     env.sh
     settings.json
 app/
   imports/		# Not loaded by Meteor, must be explicitly loaded via imports
   	 startup/
   	   client/
   	     index.js	# Meteor 1.3 client lazy load list
   	   lib/
   	   	 index.js	# Meteor 1.3 client lazy load list
   	   server/
   	     index.js	# Meteor 1.3 server lazy load list
   	     fixtures.js
   client/
     collections/
     lib/
     stylesheets/
     templates/
     head.html
     main.js	# Files loaded LAST
   lib/
     collections/
     controllers/
     methods.js
     routes.js
   packages/
   private/
   public/
   server/
     collections/
     lib/
     methods.js
     publish.js
     bootstrap.js
     main.js 	# Files loaded LAST

License

The MIT License (MIT) Copyright (C) 2016 Campbell Labs

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.