Commit c67f755eac88c32ab599982640094d2ed15fb5cd

Authored by Ryan Glover
1 parent f475025280
Exists in master

Add support for package.json.

Add npm start script for starting Meteor with settings.json.
Split settings.json into two files, settings-development.json and settings-production.json.
Add npm staging and npm production scripts as an example of deploying Meteor with separate settings files.
Add .gitignore and prevent commit of settings-production.json.
Update README to reflect changes.
Closes #32 and Closes #40.
... ... @@ -0,0 +1,5 @@
  1 +# Operating System
  2 +.DS_Store
  3 +
  4 +# Configuration
  5 +settings-production.json
... ...
... ... @@ -73,6 +73,7 @@ Base comes with a pre-defined file structure common to all projects along with s
73 73 ---/packages
74 74 ------ (See List Above)
75 75 ---/public
  76 +------/images
76 77 ---/server
77 78 ------/admin
78 79 ---------/startup-functions
... ... @@ -84,6 +85,16 @@ Base comes with a pre-defined file structure common to all projects along with s
84 85 ------------reset-password.js
85 86 ------/publications
86 87 ---------example.js
  88 +---.editorconfig
  89 +---.gitignore
  90 +---application.html
  91 +---package.json
  92 +---packages.json
  93 +---README.MD (this file)
  94 +---settings-development.json
  95 +---settings-production.json
  96 +---smart.json (added by Meteor)
  97 +---smart.lock (added by Meteor)
87 98 ```
88 99  
89 100 ### JavaScript & CSS
... ... @@ -94,11 +105,18 @@ CSS in Base is written using [Sass](http://sass-lang.com).
94 105 ### Functionality
95 106  
96 107 ###### Configuration
97   -For things like API keys and connection strings, Base supports loading a `settings.json` file (located at `/settings.json`) on startup. By default, `settings.json` includes a `public` and `private` object where you can store client only and server only values respectively.
  108 +Base includes a pattern for managing your API keys, connection strings, and other configuration information using two files: `settings-development.json` and `settings-production.json`. This pattern separates your development and production configuration into two separate files for the sake of security.
98 109  
99   -When starting Meteor, **make sure to use the --settings flag**, passing the location of your settings.json file to Meteor, e.g. `meteor --settings settings.json`. This is required in order for `settings.json` to work properly.
  110 +Per [Josh Owen's article](http://joshowens.me/environment-settings-and-security-with-meteor-js/), it's considered "bad practice" to check your production keys into your repo (private or otherwise). Base accounts for this by giving you two separate files, but also specifies that your `settings-production.json` file should be ignored by git in `.gitignore`.
100 111  
101   -To learn more about making use of `settings.json`, check out [our example in the Meteor Patterns wiki](https://github.com/themeteorchef/base/wiki/Meteor-Patterns#9-configuration).
  112 +This means that keys that are only used for testing or development purposes can be placed in `settings-development.json`, while keys used in your production application should be placed in `settings-production.json`. Sharing and management of `settings-production.json` should be done on a person-to-person basis and _not_ made globally accessible.
  113 +
  114 +###### Startup & Deployment
  115 +A tip picked up from [Gerard Sychay at Differential](http://blog.differential.com/use-package-json-in-your-meteor-app-for-fun-profit/), Base makes use of the NPM `package.json` convention to make startup and deployment super easy. Within `package.json`, three scripts have been defined for you:
  116 +
  117 +1. `npm start` - Starts your Meteor server locally with `settings-development.json` in tow. Equivalent to typing out `meteor --settings settings-development.json`.
  118 +2. `npm staging` - Deploys your Meteor app to a [Modulus](http://modulus.io) server defined as your "Staging" environment. This requires you to have a Modulus account set up and a server titled "Staging" set up. You can customize this to match your own naming conventions. This also automatically sets your `METEOR_SETTINGS` environment variable on Modulus equal to the contents of your `settings-development.json` file so you don't have to do it by hand.
  119 +3. `npm production` - Deploys your Meteor app to a [Modulus](http://modulus.io) server defined as your "Production" environment. This requires you to have a Modulus account set up and a server titled "Production" set up. You can customize this to match your own naming conventions. This also automatically sets your `METEOR_SETTINGS` environment variable on Modulus equal to the contents of your `settings-production.json` file so you don't have to do it by hand.
102 120  
103 121 ###### Bootstrap (@3.2.1)
104 122 Base makes use of the [Bootstrap](http://getbootstrap.com) front-end Framework. It may not be your bag of chips and is *definitely not required*. If you want to swap it out, you'll need to unhook the markup in each of the included template files in `/client/views` and uninstall the `twbs:bootstrap` package by running `meteor remove twbs:bootstrap` in your terminal.
... ...
... ... @@ -0,0 +1,10 @@
  1 +{
  2 + "name": "application-name",
  3 + "version": "1.0.0",
  4 + "description": "Application description.",
  5 + "scripts": {
  6 + "start": "meteor --settings settings-development.json",
  7 + "staging": "modulus env set METEOR_SETTINGS \"$(cat settings-development.json)\" -p 'Staging' && modulus deploy -f -p 'Staging'",
  8 + "production": "modulus env set METEOR_SETTINGS \"$(cat settings-production.json)\" -p 'Production' && modulus deploy -f -p 'Production'"
  9 + }
  10 +}
... ...
settings-development.json
... ... @@ -0,0 +1,8 @@
  1 +{
  2 + "public": {
  3 + "key": "value"
  4 + },
  5 + "private": {
  6 + "key": "value"
  7 + }
  8 +}
... ...
settings.json
... ... @@ -1,8 +0,0 @@
1   -{
2   - "public": {
3   - "key": "value"
4   - },
5   - "private": {
6   - "key": "value"
7   - }
8   -}