Commit 463581e29767cf582d280bef4f77d6bef61bef05

Authored by Ryan Glover
Exists in master

Merge branch 'feature/npm_start_#32'

File was created 1 # Operating System
2 .DS_Store
3
4 # Configuration
5 settings-production.json
6
1 # The Meteor Chef - Base (@1.0.3.2) 1 # The Meteor Chef - Base (@1.0.3.2)
2 A starting point for Meteor apps. 2 A starting point for Meteor apps.
3 3
4 Base is the lazy person's starter kit for Meteor. It includes some commonly used packages (biased to The Meteor Chef) and code for common functionality. This is the starter kit for all Meteor Chef recipes. 4 Base is the lazy person's starter kit for Meteor. It includes some commonly used packages (biased to The Meteor Chef) and code for common functionality. This is the starter kit for all Meteor Chef recipes.
5 5
6 For more detail on updates, [read the Changelog](https://github.com/themeteorchef/base/wiki/Changelog). If you're interested in contributing to Base, checkout the [Contribution wiki](https://github.com/themeteorchef/base/wiki/Contributing-to-Base) to get started. 6 For more detail on updates, [read the Changelog](https://github.com/themeteorchef/base/wiki/Changelog). If you're interested in contributing to Base, checkout the [Contribution wiki](https://github.com/themeteorchef/base/wiki/Contributing-to-Base) to get started.
7 7
8 ### Packages Included 8 ### Packages Included
9 - Accounts (Base) - `meteor add accounts-base` 9 - Accounts (Base) - `meteor add accounts-base`
10 - Accounts (Password) - `meteor add accounts-password` 10 - Accounts (Password) - `meteor add accounts-password`
11 - Audit Argument Checks - `meteor add audit-argument-checks` 11 - Audit Argument Checks - `meteor add audit-argument-checks`
12 - Bert - `meteor add themeteorchef:bert` 12 - Bert - `meteor add themeteorchef:bert`
13 - Bootstrap 3 - `meteor add twbs:bootstrap` 13 - Bootstrap 3 - `meteor add twbs:bootstrap`
14 - Browser Policy - `meteor add browser-policy` 14 - Browser Policy - `meteor add browser-policy`
15 - Check - `meteor add check` 15 - Check - `meteor add check`
16 - Handlebars Server - `meteor add cmather:handlebars-server` 16 - Handlebars Server - `meteor add cmather:handlebars-server`
17 - Iron Router - `meteor add iron:router` 17 - Iron Router - `meteor add iron:router`
18 - jQuery - `meteor add jquery` 18 - jQuery - `meteor add jquery`
19 - jQuery Validation - `meteor add themeteorchef:jquery-validation` 19 - jQuery Validation - `meteor add themeteorchef:jquery-validation`
20 - NPM - `meteor add meteorhacks:npm` 20 - NPM - `meteor add meteorhacks:npm`
21 - Sass - `meteor add particle4dev:sass@0.3.0` 21 - Sass - `meteor add particle4dev:sass@0.3.0`
22 - Underscore - `meteor add underscore` 22 - Underscore - `meteor add underscore`
23 23
24 **Note:** Base also supports loading NPM packages using the `meteorhacks:npm` package. To load NPM packages, add name and version information to `/packages.json` and inside of your file (server only), load the package with `var package = Meteor.npmRequire('package-name');`. For more information, see the [meteorhacks:npm documentation](https://github.com/meteorhacks/npm/). 24 **Note:** Base also supports loading NPM packages using the `meteorhacks:npm` package. To load NPM packages, add name and version information to `/packages.json` and inside of your file (server only), load the package with `var package = Meteor.npmRequire('package-name');`. For more information, see the [meteorhacks:npm documentation](https://github.com/meteorhacks/npm/).
25 25
26 ### File Structure 26 ### File Structure
27 Base comes with a pre-defined file structure common to all projects along with some skeleton files for getting started quickly. Here's what it looks like: 27 Base comes with a pre-defined file structure common to all projects along with some skeleton files for getting started quickly. Here's what it looks like:
28 28
29 ``` 29 ```
30 /root 30 /root
31 ---/.meteor 31 ---/.meteor
32 ---/client 32 ---/client
33 ------/controllers 33 ------/controllers
34 ---------/authenticated 34 ---------/authenticated
35 ------------header.js 35 ------------header.js
36 ---------/public 36 ---------/public
37 ------------login.js 37 ------------login.js
38 ------------recover-password.js 38 ------------recover-password.js
39 ------------reset-password.js 39 ------------reset-password.js
40 ------------signup.js 40 ------------signup.js
41 ------/helpers 41 ------/helpers
42 ---------helpers-ui.js 42 ---------helpers-ui.js
43 ------/includes 43 ------/includes
44 ---------_header.html 44 ---------_header.html
45 ------/layouts 45 ------/layouts
46 ---------layout-default.html 46 ---------layout-default.html
47 ------/routes 47 ------/routes
48 ---------hooks.js 48 ---------hooks.js
49 ---------routes-authenticated.js 49 ---------routes-authenticated.js
50 ---------routes-global.js 50 ---------routes-global.js
51 ---------routes-public.js 51 ---------routes-public.js
52 ------/stylesheets 52 ------/stylesheets
53 ---------/sass 53 ---------/sass
54 ------------/globals 54 ------------/globals
55 ---------------_extends.scss 55 ---------------_extends.scss
56 ------------/views 56 ------------/views
57 ---------------/public 57 ---------------/public
58 ------------------_login.scss 58 ------------------_login.scss
59 ---------application.scss 59 ---------application.scss
60 -------/views 60 -------/views
61 ---------/authenticated 61 ---------/authenticated
62 ------------index.html 62 ------------index.html
63 ---------/public 63 ---------/public
64 ------------loading.html 64 ------------loading.html
65 ------------login.html 65 ------------login.html
66 ------------not-found.html 66 ------------not-found.html
67 ------------recover-password.html 67 ------------recover-password.html
68 ------------reset-password.html 68 ------------reset-password.html
69 ------------signup.html 69 ------------signup.html
70 ---/collections 70 ---/collections
71 ------example.js 71 ------example.js
72 ------users.js 72 ------users.js
73 ---/packages 73 ---/packages
74 ------ (See List Above) 74 ------ (See List Above)
75 ---/public 75 ---/public
76 ------/images
76 ---/server 77 ---/server
77 ------/admin 78 ------/admin
78 ---------/startup-functions 79 ---------/startup-functions
79 ------------browser-policies.js 80 ------------browser-policies.js
80 ------------test-accounts.js 81 ------------test-accounts.js
81 ---------startup.js 82 ---------startup.js
82 ------/email 83 ------/email
83 ---------/templates 84 ---------/templates
84 ------------reset-password.js 85 ------------reset-password.js
85 ------/publications 86 ------/publications
86 ---------example.js 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 ### JavaScript & CSS 100 ### JavaScript & CSS
90 Prior to v2.0.0, Base was written in CoffeeScript. At the request of the community, Base was ported _back_ to native JavaScript. 101 Prior to v2.0.0, Base was written in CoffeeScript. At the request of the community, Base was ported _back_ to native JavaScript.
91 102
92 CSS in Base is written using [Sass](http://sass-lang.com). 103 CSS in Base is written using [Sass](http://sass-lang.com).
93 104
94 ### Functionality 105 ### Functionality
95 106
96 ###### Configuration 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 ###### Bootstrap (@3.2.1) 121 ###### Bootstrap (@3.2.1)
104 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. 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.
105 123
106 In respect to UI, Base uses Bootstrap's `.navbar` element, as well as its `.container` and a few `.row`/`.col-<size>-<columns>` wrappers. You'll also find the `.btn` class and its modifiers (`.success, .warning, etc.`) in use throughout the app. All of these implementations are merely presentational and can be changed (or removed) as you see fit. 124 In respect to UI, Base uses Bootstrap's `.navbar` element, as well as its `.container` and a few `.row`/`.col-<size>-<columns>` wrappers. You'll also find the `.btn` class and its modifiers (`.success, .warning, etc.`) in use throughout the app. All of these implementations are merely presentational and can be changed (or removed) as you see fit.
107 125
108 ###### Basic Routing 126 ###### Basic Routing
109 Base comes with a collection of pre-defined routes and templates for common functionality. Base also includes a set of common route filters for managing user access. Routes bundled include: 127 Base comes with a collection of pre-defined routes and templates for common functionality. Base also includes a set of common route filters for managing user access. Routes bundled include:
110 128
111 ``` 129 ```
112 - / (Authenticated) 130 - / (Authenticated)
113 - /login (Public) 131 - /login (Public)
114 - /recover-password (Public) 132 - /recover-password (Public)
115 - /reset-password (Public) 133 - /reset-password (Public)
116 - /signup (Public) 134 - /signup (Public)
117 ``` 135 ```
118 136
119 A UI helper called `currentRoute` has been added to Base which allows you to add an `active` class to menu items in your navigation to reflect the user's current location. 137 A UI helper called `currentRoute` has been added to Base which allows you to add an `active` class to menu items in your navigation to reflect the user's current location.
120 138
121 A collection of hooks has also been added to Base to control route access based on different conditions (e.g. whether a user is logged in or not). 139 A collection of hooks has also been added to Base to control route access based on different conditions (e.g. whether a user is logged in or not).
122 140
123 ###### Authentication 141 ###### Authentication
124 Base includes a complete authentication pattern complete with: 142 Base includes a complete authentication pattern complete with:
125 143
126 - Login (at /login) 144 - Login (at /login)
127 - Logout (no path, implemented as a dropdown item/click event in /client/controllers/header.js) 145 - Logout (no path, implemented as a dropdown item/click event in /client/controllers/header.js)
128 - Password Recovery (at /recover-password and /reset-password) 146 - Password Recovery (at /recover-password and /reset-password)
129 - Signup (at /signup) 147 - Signup (at /signup)
130 148
131 ###### Example Collection/Publication/Subscription 149 ###### Example Collection/Publication/Subscription
132 Base includes a collection called `Example`, along with a publication and subscription pattern to show moving data from the server to the client. Publications are defined in `/server/publications/example.js` and a subscription is demonstrated on the `index` route in `/client/routes/routes-authenticated.js`. 150 Base includes a collection called `Example`, along with a publication and subscription pattern to show moving data from the server to the client. Publications are defined in `/server/publications/example.js` and a subscription is demonstrated on the `index` route in `/client/routes/routes-authenticated.js`.
133 151
134 ###### Validation 152 ###### Validation
135 Base includes support for client-side validation via [jQuery Validation](http://jqueryvalidation.org). Validation is provided for all public templates: login, signup, recover password, and reset password. 153 Base includes support for client-side validation via [jQuery Validation](http://jqueryvalidation.org). Validation is provided for all public templates: login, signup, recover password, and reset password.
136 154
137 ###### Alerts 155 ###### Alerts
138 Base includes support for fixed bar (top and bottom) and growl-style alerts on the client via [`themeteorchef:bert`](https://atmospherejs.com/themeteorchef/bert). 156 Base includes support for fixed bar (top and bottom) and growl-style alerts on the client via [`themeteorchef:bert`](https://atmospherejs.com/themeteorchef/bert).
139 157
140 ###### Automatic Admin User Creation 158 ###### Automatic Admin User Creation
141 When developing, having a handful of user accounts to test your application with can come in handy. Base comes with an automated account generation script located in `server/admin/startup.js` that creates accounts based on an array of specified users. **Note: by default this creates one Admin user on server startup, so make sure to customize or remove this user so the public can't access your app**. 159 When developing, having a handful of user accounts to test your application with can come in handy. Base comes with an automated account generation script located in `server/admin/startup.js` that creates accounts based on an array of specified users. **Note: by default this creates one Admin user on server startup, so make sure to customize or remove this user so the public can't access your app**.
142 160
File was created 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 }
11
settings-development.json
File was created 1 {
2 "public": {
3 "key": "value"
4 },
5 "private": {
6 "key": "value"
7 }
8 }
9
settings.json
1 { File was deleted
2 "public": {
3 "key": "value"
4 },
5 "private": {
6 "key": "value"
7 }
8 }
9 1 {