Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
3 changes: 3 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "airbnb",
}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
coverage
dist
mup.json
node_modules
npm-debug.log
settings.json
/webpack/lib
36 changes: 36 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
.PHONY: met test

copy-conf:
cp --no-clobber ./settings/development/settings-dist.json ./settings/development/settings.json
cp --no-clobber ./settings/production/settings-dist.json ./settings/production/settings.json
cp --no-clobber ./settings/staging/settings-dist.json ./settings/staging/settings.json

cp --no-clobber ./settings/production/mup-dist.json ./settings/production/mup.json
cp --no-clobber ./settings/staging/mup-dist.json ./settings/staging/mup.json

install: copy-conf
npm install

run-dev:
NODE_ENV=development node ./bin/dev.js

run-debug:
NODE_ENV=development node ./bin/debug.js

run-prod:
NODE_ENV=production node ./bin/prod.js

deploy-meteor:
node ./bin/deploy.js meteor.com

deploy-modulus:
node ./bin/deploy.js modulus

deploy-mup:
node ./bin/deploy.js mup

deploy-demeteorizer:
node ./bin/deploy.js demeteorizer

test:
NODE_ENV=test ./node_modules/karma/bin/karma start && ./node_modules/karma/bin/karma-run
44 changes: 27 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ There is a port of the Meteor simple-todos tutorial to this stack on the `simple

## How it works

The `dev.js`, `prod.js`, and `deploy.js` scripts will run Webpack, and symbolically link the generated bundles
The `dev.js`, `prod.js`, and `deploy.js` scripts (in `./bin`) will run Webpack, and symbolically link the generated bundles
into the `meteor_core` directory.

In prod mode, `meteor_core` gets the webpack client and server bundles via the soft links `meteor_core/client/client.bundle.js` and `meteor_core/server/server.bundle.js`. Two instances of `webpack --watch` are running, one to make the client bundle and one to make the server bundle.
Expand All @@ -47,65 +47,71 @@ to rename it to `main.js`* so that Meteor loads it after everything else.

There have been dependency issues with old versions of Node and NPM. Please try at least Node v0.10.36 and npm v1.4.28 before repording any issues about missing dependencies.

## Setup

```
> make install
```

This will install npm dependencies and setup your configuration files (settings and mup) inside './settings'.

Only the `*-dist.json` will ever be commited in git.

## Running (dev mode)

**Note:** make sure you are forwarding port 9090 (as well as the Meteor port) if you want to test on other devices via LAN.

```
> npm install
> node dev.js
> make run-dev
```
Make sure to wait for Meteor to say it's listening, for the client `webpack-dev-server` and server `webpack --watch` to print out module/bundle info. The site won't work until all are ready.

## Debugging/Profiling Server (dev mode)

```
> npm install -g node-inspector
> npm install
> node debug.js
> make run-debug
```
Then visit `http://127.0.0.1:8080/debug?port=5858` in your browser.

## Running (prod mode)
This runs the app as if it were in production, but it's still watching your files for changes. You can Ctrl-C after it's finished starting up and use `./met deploy`, though.

```
> npm install
> node prod.js
> make run-prod
```
Make sure to wait for Meteor to say it's listening, and for the client and server `webpack --watch` processes to print out module/bundle info. The site won't work until all are ready.


## Deployment

You can set the project name in `projectName.js`. It defaults to
the project folder name.
Make sure to edit your `package.json` replacing the `name` property as this will be used for the application name when deploying to meteor and modulus.

There is a deployment script that supports several common options:
```
node deploy.js meteor.com
make deploy-meteor
```
The usual basic meteor.com deploy

```
node deploy.js modulus
node deploy-modulus
```
Uses modulus (make sure to go into the deploy script and replace `your_app_proj_name` with a real value
Uses modulus

```
node deploy.js mup
node deploy-mup
```
See `deploy.js` for some additional hints
Uses [MUP](https://github.com/arunoda/meteor-up) for deployment. It's configuration can be found in `./settings/[NODE_ENV]`

```
node deploy.js demeteorizer
node deploy-demeteorizer
```
Builds with demeteorizer
Builds with [demeteorizer](https://github.com/onmodulus/demeteorizer)


## Meteor Settings

Put your settings in `settings/devel.json` & `settings/prod.json` and they will automatically load when running in development, production and build modes.
Put your settings in `settings/[NODE_ENV]/settings.json` and they will automatically load when running in development, production and build modes.


## Running Meteor Commands
Expand All @@ -117,6 +123,10 @@ As a convenience you can run `./met` in the root directory to run the `meteor` c
./met search simple-schema
```

## Tests

Run `make test` to run the tests. Code coverage reports will be available in `./coverage/lcov-report/index.html`. Open it to see your coverage with es6 support.

## Acknowledgements

(if I've forgotten anyone let me know!)
Expand Down
5 changes: 0 additions & 5 deletions app/main_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@ if (!Posts.find().fetch().length) {
createUsers();
}

// smoke test that these are present
Npm.require;
Assets;
require('fs').readFile.call;

console.error(new Error('source map test').stack);

console.log('\n\nRunning on server only');
Expand Down
36 changes: 36 additions & 0 deletions bin/core-js-custom-build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/* global cd, echo, exec, ln, mkdir, mv, rm */
/* eslint vars-on-top:0, no-var:0 */

require('shelljs/global');
var dirs = require('./dirs');
var fs = require('fs');
var path = require('path');
var coreJsBuild = require('core-js/build');

dirs.lib = path.join(dirs.webpack, 'lib');
if (!fs.existsSync(dirs.lib)) mkdir(dirs.lib);

var coreJsVersion = JSON.parse(fs.readFileSync('node_modules/core-js/package.json')).version;
var targetFileName = 'core-js-no-number.js';
var currentFileExist = fs.existsSync(path.join(dirs.lib, targetFileName));
var currentFileFewLines = currentFileExist ?
fs.readFileSync(path.join(dirs.lib, targetFileName)).toString().substr(0, 130) : '';
var currentFileVersionRegex = /core-js (\d.\d.\d+)/m;
var currentFileVersion = currentFileVersionRegex.test(currentFileFewLines) ?
currentFileVersionRegex.exec(currentFileFewLines)[1] : false;

if (coreJsVersion !== currentFileVersion) {
echo('Building core-js@' + coreJsVersion + ' without ES6 number constructor...');
coreJsBuild({
modules: ['es5', 'es6', 'es7', 'js', 'web'],
blacklist: ['es6.number.constructor'],
}, function(error, code) {
if (error) {
console.error('core-js build error');
return;
}
fs.writeFileSync(path.join(dirs.lib, targetFileName), code);
});
} else {
echo('core-js@' + coreJsVersion + ' without ES6 number constructor is up to date');
}
1 change: 1 addition & 0 deletions bin/core-js-no-number.js
File renamed without changes.
9 changes: 5 additions & 4 deletions deploy.js → bin/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ var projectName = require('./projectName');
if (!projectName) {
echo('Please enter your project name in projectName.js');
}
echo('Preparing deployment of ' + projectName);

var dirs = require('./dirs');

Expand All @@ -26,11 +27,11 @@ function deploy() {

case 'meteor.com':
cd(dirs.meteor);
exec('meteor deploy ' + projectName + '.meteor.com', {async: true});
exec('meteor deploy ' + projectName + '.meteor.com --settings ../settings/' + env.NODE_ENV + '/settings.json', {async: true});
break;

case 'modulus':
env.METEOR_SETTINGS = cat('settings/prod.json');
env.METEOR_SETTINGS = cat('settings/' + env.NODE_ENV + '/settings.json');
cd(dirs.meteor);
exec('modulus deploy --project-name ' + projectName, {async: true});
break;
Expand All @@ -42,15 +43,15 @@ function deploy() {
* then mup init inside settings/prod/ so that mup uses the new settings.json
* this will require a settings path change in ./dev script
*/
cd('settings/prod');
cd('settings/' + env.NODE_ENV);
exec('mup deploy', {async: true});
break;

case 'demeteorizer':
rm('-rf', 'dist/bundle');
mkdir('-p', 'dist/bundle');
cd(dirs.meteor);
exec("demeteorizer -o ../dist/bundle --json '" + cat('../settings/prod.json') + "'", {async: true});
exec("demeteorizer -o ../dist/bundle --json '" + cat('../settings/' + env.NODE_ENV + '/settings.json') + "'", {async: true});
// run your own command to deploy to your server
break;

Expand Down
2 changes: 1 addition & 1 deletion dev.js → bin/dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ require('./core-js-custom-build');
require('./runWebpackConfigs')('dev', function(err) {
if (err) throw err;
cd(dirs.meteor);
exec('meteor --settings ../settings/devel.json', {async: true});
exec('meteor --settings ../settings/development/settings.json', {async: true});
});
4 changes: 2 additions & 2 deletions dirs.js → bin/dirs.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
var path = require('path');

module.exports = {
webpack: path.join(__dirname, 'webpack'),
meteor: path.join(__dirname, 'meteor_core'),
webpack: path.join(__dirname, '..', 'webpack'),
meteor: path.join(__dirname, '..', 'meteor_core'),
};

module.exports.assets= path.join(module.exports.webpack, 'assets');
File renamed without changes.
2 changes: 1 addition & 1 deletion prod.js → bin/prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ process.env.NODE_ENV = env.NODE_ENV = 'production';
require('./runWebpackConfigs')('prod', function(err) {
if (err) throw err;
cd(dirs.meteor);
exec('meteor run --production --settings ../settings/prod.json', {async: true});
exec('meteor run --production --settings ../settings/production/settings.json', {async: true});
});
3 changes: 3 additions & 0 deletions bin/projectName.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
var path = require('path');
var appPackage = require('../package.json')
module.exports = appPackage.name; // replace with your project name
File renamed without changes.
27 changes: 0 additions & 27 deletions core-js-custom-build.js

This file was deleted.

44 changes: 22 additions & 22 deletions karma.conf.js
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
var path = require('path');
var webpackConfig = require('./webpack/webpack.config.client.js');
/* eslint no-var:0 */
var webpackConfig = require('./webpack/webpack.config.test.js');

module.exports = function (config) {
module.exports = function karmaConf(config) {
config.set({
//singleRun: true,
reporters: [ 'dots' ],
browsers: [ 'Chrome' ],
files: [ './test/karma.bundle.js' ],
frameworks: [ 'jasmine' ],
// singleRun: true,
reporters: ['mocha', 'coverage'],
browsers: ['Chrome'],
files: ['./test/karma.bundle.js'],
frameworks: ['mocha', 'sinon-chai'],
plugins: [
'karma-coverage',
'karma-chrome-launcher',
//'karma-firefox-launcher',
'karma-jasmine',
//'karma-mocha',
'karma-mocha',
'karma-mocha-reporter',
'karma-sinon-chai',
'karma-sourcemap-loader',
'karma-webpack',
],
// run the bundle through the webpack and sourcemap plugins
preprocessors: {
'./test/karma.bundle.js': [ 'webpack', 'sourcemap' ]
'./test/**/*.js': ['webpack', 'sourcemap'],
'./app/**/*.js': ['webpack', 'sourcemap'],
},
// use our own webpack config to mirror test setup
webpack: {
entry: [
'./lib/core-js-no-number',
'regenerator/runtime',
],
devtool: 'eval-source-map',
resolve: webpackConfig.resolve,
module: { loaders: webpackConfig.module.loaders },
},
webpack: webpackConfig,
webpackMiddleware: {
noInfo: true,
}
},
coverageReporter: {
type: 'lcov',
dir: 'coverage/',
subdir: '.',
file: 'lcov.info',
},
});
};
8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,17 @@
"eslint-plugin-react": "^3.2.2",
"grunt": "^0.4.5",
"grunt-cli": "^0.1.13",
"isparta": "^3.5.3",
"isparta-instrumenter-loader": "^0.2.1",
"karma": "^0.13.9",
"karma-chrome-launcher": "^0.2.0",
"karma-jasmine": "^0.2.2",
"karma-coverage": "0.5.3",
"karma-mocha": "^0.2.1",
"karma-mocha-reporter": "^1.1.2",
"karma-sinon-chai": "^1.1.0",
"karma-sourcemap-loader": "^0.3.5",
"karma-webpack": "^1.7.0",
"mocha": "^2.3.4",
"node-libs-browser": "^0.5.2",
"react-tools": "^0.10.0",
"react-transform": "0.0.3",
Expand Down
2 changes: 0 additions & 2 deletions projectName.js

This file was deleted.

7 changes: 0 additions & 7 deletions settings/devel.json

This file was deleted.

Loading