Skip to content

Commit

Permalink
Merge branch 'master' into feature/install-root-dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt Hernandez committed Sep 14, 2016
2 parents 2974143 + 729dc02 commit 0d790fd
Show file tree
Hide file tree
Showing 10 changed files with 233 additions and 242 deletions.
7 changes: 0 additions & 7 deletions .eslintrc

This file was deleted.

40 changes: 20 additions & 20 deletions lib/build.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
const Hoek = require('hoek');
const Util = require('util');
const Hoek = require('hoek')
const Util = require('util')

const Exec = require('./exec');
const Exec = require('./exec')

const defaults = {
server: 'localhost',
directory: '.demeteorized'
};
}

//
// Options include:
Expand All @@ -15,38 +15,38 @@ const defaults = {
// architecture - Architecture build target.
//
module.exports = function (options, done) {
var args, build;
var args, build

options = Hoek.applyToDefaults(defaults, options);
options = Hoek.applyToDefaults(defaults, options)

args = [
'build',
'--server', options.server,
'--directory', Util.format('%s', options.directory)
];
]

if (options.architecture) {
args.push('--architecture');
args.push(options.architecture);
args.push('--architecture')
args.push(options.architecture)
}

if (options.debug) args.push('--debug');
if (options.serverOnly) args.push('--server-only');
if (options.debug) args.push('--debug')
if (options.serverOnly) args.push('--server-only')

build = Exec.spawn('meteor', args, { cwd: options.input, stdio: 'inherit' });
build = Exec.spawn('meteor', args, { cwd: options.input, stdio: 'inherit' })

build.on('error', function (err) {
var message = [
'Meteor not in $PATH.',
'Please make sure Meteor is installed properly.'
].join(' ');
].join(' ')

if (err.code === 'ENOENT') return done(new Error(message));
done(err);
});
if (err.code === 'ENOENT') return done(new Error(message))
done(err)
})

build.on('close', function (code) {
if (code !== 0) return done(new Error('Conversion failed.'));
done();
});
};
if (code !== 0) return done(new Error('Conversion failed.'))
done()
})
}
28 changes: 14 additions & 14 deletions lib/demeteorizer.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
const Hoek = require('hoek');
const Hoek = require('hoek')

const Build = require('./build');
const Install = require('./install');
const CopyDependencies = require('./copy-dependencies');
const UpdatePackage = require('./update-package');
const Build = require('./build')
const Install = require('./install')
const CopyDependencies = require('./copy-dependencies')
const UpdatePackage = require('./update-package')

module.exports = function (options, done) {
Hoek.assert(options !== undefined, 'You must provide a valid options object');
Hoek.assert(options !== undefined, 'You must provide a valid options object')

Install(options, function (err) {
if (err) return done(err);
if (err) return done(err)

Build(options, function (err) {
if (err) return done(err);
if (err) return done(err)

CopyDependencies(options, function (err) {
if (err) return done(err);
if (err) return done(err)

UpdatePackage(options, done);
});
});
});
};
UpdatePackage(options, done)
})
})
})
}
2 changes: 1 addition & 1 deletion lib/exec.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
exports.spawn = require('cross-spawn');
exports.spawn = require('cross-spawn')
30 changes: 15 additions & 15 deletions lib/find-node-version.js
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@
const Fs = require('fs');
const Path = require('path');
const Fs = require('fs')
const Path = require('path')

const Hoek = require('hoek');
const Hoek = require('hoek')

const DEFAULT_NODE_VERSION = '0.10.33';
const DEFAULT_NODE_VERSION = '0.10.33'

module.exports = function (options) {
var version, bootPath;
var version, bootPath

Hoek.assert(options !== undefined, 'options is required');
Hoek.assert(Fs.existsSync(options.directory), 'Output directory not found');
Hoek.assert(options !== undefined, 'options is required')
Hoek.assert(Fs.existsSync(options.directory), 'Output directory not found')

if (typeof options.nodeVersion !== 'undefined') return options.nodeVersion;
if (typeof options.nodeVersion !== 'undefined') return options.nodeVersion

bootPath = Path.resolve(
options.directory,
'bundle',
'programs',
'server',
'boot.js');
'boot.js')

try {
// Read boot.js to find the MIN_NODE_VERSION; use that version as the node
// version of the project.
Fs.readFileSync(bootPath).toString().split('\n').some(function (line) {
if (line.indexOf('MIN_NODE_VERSION') >= 0) {
/* eslint-disable no-magic-numbers */
version = line.split(' ')[3].replace(/[v;']/g, '');
version = line.split(' ')[3].replace(/[v;']/g, '')
/* eslint-enable no-magic-numbers */

return true;
return true
}
});
})
} catch (err) {
version = DEFAULT_NODE_VERSION;
version = DEFAULT_NODE_VERSION
}

return version || DEFAULT_NODE_VERSION;
};
return version || DEFAULT_NODE_VERSION
}
32 changes: 16 additions & 16 deletions lib/update-package.js
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
const Fs = require('fs');
const Path = require('path');
const Fs = require('fs')
const Path = require('path')

const Hoek = require('hoek');
const Hoek = require('hoek')

const FindNodeVersion = require('./find-node-version');
const FindNodeVersion = require('./find-node-version')

module.exports = function (options, done) {
var packagePath, packageContents;
var packagePath, packageContents

Hoek.assert(options !== undefined, 'options is required');
Hoek.assert(Fs.existsSync(options.directory), 'Output directory not found');
Hoek.assert(options !== undefined, 'options is required')
Hoek.assert(Fs.existsSync(options.directory), 'Output directory not found')

packagePath = Path.resolve(
options.directory,
'bundle',
'programs',
'server',
'package.json');
'package.json')

//
// Manual parsing of the package.json allows mocking of the read.
//
packageContents = JSON.parse(Fs.readFileSync(packagePath));
packageContents = JSON.parse(Fs.readFileSync(packagePath))

packageContents.engines = {
node: FindNodeVersion(options),
npm: options.npmVersion || 'latest'
};
}

packageContents.main = '../../main.js';
packageContents.scripts = { start: 'node ../../main' };
packageContents.main = '../../main.js'
packageContents.scripts = { start: 'node ../../main' }

Hoek.merge(packageContents, options.json || {});
Hoek.merge(packageContents, options.json || {})

Fs.chmodSync(packagePath, '0644');
Fs.writeFile(packagePath, JSON.stringify(packageContents, null, 2), done);
};
Fs.chmodSync(packagePath, '0644')
Fs.writeFile(packagePath, JSON.stringify(packageContents, null, 2), done)
}
8 changes: 3 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,11 @@
"lab": "10.x.x",
"proxyquire": "1.7.10",
"sinon": "1.17.5",
"eslint": "2.11.1",
"eslint-plugin-hapi": "4.0.0",
"eslint-plugin-promise": "1.1.0",
"eslint-config-modulus": "0.6.0"
"standard": "8.0.0"
},
"scripts": {
"test": "lab --threshold 100 --lint",
"pretest": "standard",
"test": "lab --threshold 100",
"gen-coverage": "lab --coverage --reporter lcov --output coverage/lcov.info"
},
"main": "./lib/demeteorizer",
Expand Down
Loading

0 comments on commit 0d790fd

Please # to comment.