mirror of https://github.com/embarklabs/embark.git
check deps before launching
This commit is contained in:
parent
a622f22dcd
commit
542462faed
27
bin/embark
27
bin/embark
|
@ -4,11 +4,30 @@ try {
|
||||||
eval('let __nodeTest = 123;');
|
eval('let __nodeTest = 123;');
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
if (e.name === 'SyntaxError') {
|
if (e.name === 'SyntaxError') {
|
||||||
console.error("unsupported version of NodeJS. Make sure you are running nodejs 6.9.5 or above");
|
console.error("unsupported version of NodeJS. Make sure you are running nodejs 8.11.3 or above");
|
||||||
|
|
||||||
process.exit();
|
process.exit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var Cmd = require('../cmd/cmd');
|
function launchEmbark() {
|
||||||
var cli = new Cmd();
|
var Cmd = require('../cmd/cmd');
|
||||||
cli.process(process.argv);
|
var cli = new Cmd();
|
||||||
|
cli.process(process.argv);
|
||||||
|
}
|
||||||
|
|
||||||
|
const path = require('path');
|
||||||
|
require('colors');
|
||||||
|
try {
|
||||||
|
const dappPackage = require(path.join(process.cwd(), 'package.json'));
|
||||||
|
require('check-dependencies')(dappPackage, (state) => {
|
||||||
|
if (state.status) {
|
||||||
|
console.error('\nMissing dependencies. Please run npm install'.red);
|
||||||
|
process.exit();
|
||||||
|
}
|
||||||
|
launchEmbark();
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
launchEmbark();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
77
cmd/cmd.js
77
cmd/cmd.js
|
@ -26,9 +26,9 @@ if (!process.env.EMBARK_PATH) {
|
||||||
// as an ejected webpack.config.js), making embark's dependencies trasitive
|
// as an ejected webpack.config.js), making embark's dependencies trasitive
|
||||||
// dependencies of a dapp without the dapp explicitly specifying embark as a
|
// dependencies of a dapp without the dapp explicitly specifying embark as a
|
||||||
// dependency in the dapp's package.json
|
// dependency in the dapp's package.json
|
||||||
process.env.NODE_PATH = utils.joinPath(process.env.EMBARK_PATH, 'node_modules')
|
process.env.NODE_PATH = utils.joinPath(process.env.EMBARK_PATH, 'node_modules') +
|
||||||
+ (process.env.NODE_PATH ? require('path').delimiter : '')
|
(process.env.NODE_PATH ? require('path').delimiter : '') +
|
||||||
+ (process.env.NODE_PATH || '');
|
(process.env.NODE_PATH || '');
|
||||||
|
|
||||||
class Cmd {
|
class Cmd {
|
||||||
constructor() {
|
constructor() {
|
||||||
|
@ -62,7 +62,7 @@ class Cmd {
|
||||||
|
|
||||||
newApp() {
|
newApp() {
|
||||||
|
|
||||||
let validateName = function (value) {
|
let validateName = function(value) {
|
||||||
try {
|
try {
|
||||||
if (value.match(/^[a-zA-Z\s-]+$/)) return value;
|
if (value.match(/^[a-zA-Z\s-]+$/)) return value;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
@ -76,14 +76,14 @@ class Cmd {
|
||||||
.option('--simple', __('create a barebones project meant only for contract development'))
|
.option('--simple', __('create a barebones project meant only for contract development'))
|
||||||
.option('--locale [locale]', __('language to use (default: en)'))
|
.option('--locale [locale]', __('language to use (default: en)'))
|
||||||
.option('--template [url]', __('download template'))
|
.option('--template [url]', __('download template'))
|
||||||
.action(function (name, options) {
|
.action(function(name, options) {
|
||||||
i18n.setOrDetectLocale(options.locale);
|
i18n.setOrDetectLocale(options.locale);
|
||||||
if (name === undefined) {
|
if (name === undefined) {
|
||||||
const promptly = require('promptly');
|
const promptly = require('promptly');
|
||||||
return promptly.prompt(__("Name your app (default is %s):", 'embarkDapp'), {
|
return promptly.prompt(__("Name your app (default is %s):", 'embarkDapp'), {
|
||||||
default: "embarkDApp",
|
default: "embarkDApp",
|
||||||
validator: validateName
|
validator: validateName
|
||||||
}, function (err, inputvalue) {
|
}, function(err, inputvalue) {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.error(__('Invalid name') + ':', err.message);
|
console.error(__('Invalid name') + ':', err.message);
|
||||||
// Manually call retry
|
// Manually call retry
|
||||||
|
@ -98,12 +98,11 @@ class Cmd {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
if (options.simple) {
|
||||||
|
embark.generateTemplate('simple', './', name);
|
||||||
} else {
|
} else {
|
||||||
if (options.simple) {
|
embark.generateTemplate('boilerplate', './', name, options.template);
|
||||||
embark.generateTemplate('simple', './', name);
|
|
||||||
} else {
|
|
||||||
embark.generateTemplate('boilerplate', './', name, options.template);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -113,7 +112,7 @@ class Cmd {
|
||||||
.command('demo')
|
.command('demo')
|
||||||
.option('--locale [locale]', __('language to use (default: en)'))
|
.option('--locale [locale]', __('language to use (default: en)'))
|
||||||
.description(__('create a working dapp with a SimpleStorage contract'))
|
.description(__('create a working dapp with a SimpleStorage contract'))
|
||||||
.action(function (options) {
|
.action(function(options) {
|
||||||
i18n.setOrDetectLocale(options.locale);
|
i18n.setOrDetectLocale(options.locale);
|
||||||
embark.generateTemplate('demo', './', 'embark_demo');
|
embark.generateTemplate('demo', './', 'embark_demo');
|
||||||
});
|
});
|
||||||
|
@ -129,7 +128,7 @@ class Cmd {
|
||||||
.option('--locale [locale]', __('language to use (default: en)'))
|
.option('--locale [locale]', __('language to use (default: en)'))
|
||||||
.option('--pipeline [pipeline]', __('webpack config to use (default: production)'))
|
.option('--pipeline [pipeline]', __('webpack config to use (default: production)'))
|
||||||
.description(__('deploy and build dapp at ') + 'dist/ (default: development)')
|
.description(__('deploy and build dapp at ') + 'dist/ (default: development)')
|
||||||
.action(function (env, _options) {
|
.action(function(env, _options) {
|
||||||
i18n.setOrDetectLocale(_options.locale);
|
i18n.setOrDetectLocale(_options.locale);
|
||||||
_options.env = env || 'development';
|
_options.env = env || 'development';
|
||||||
_options.logFile = _options.logfile; // fix casing
|
_options.logFile = _options.logfile; // fix casing
|
||||||
|
@ -155,7 +154,7 @@ class Cmd {
|
||||||
.option('--locale [locale]', __('language to use (default: en)'))
|
.option('--locale [locale]', __('language to use (default: en)'))
|
||||||
.option('--pipeline [pipeline]', __('webpack config to use (default: development)'))
|
.option('--pipeline [pipeline]', __('webpack config to use (default: development)'))
|
||||||
.description(__('run dapp (default: %s)', 'development'))
|
.description(__('run dapp (default: %s)', 'development'))
|
||||||
.action(function (env, options) {
|
.action(function(env, options) {
|
||||||
i18n.setOrDetectLocale(options.locale);
|
i18n.setOrDetectLocale(options.locale);
|
||||||
embark.run({
|
embark.run({
|
||||||
env: env || 'development',
|
env: env || 'development',
|
||||||
|
@ -181,7 +180,7 @@ class Cmd {
|
||||||
.option('--locale [locale]', __('language to use (default: en)'))
|
.option('--locale [locale]', __('language to use (default: en)'))
|
||||||
.option('--pipeline [pipeline]', __('webpack config to use (default: development)'))
|
.option('--pipeline [pipeline]', __('webpack config to use (default: development)'))
|
||||||
.description(__('Start the Embark console'))
|
.description(__('Start the Embark console'))
|
||||||
.action(function (env, options) {
|
.action(function(env, options) {
|
||||||
i18n.setOrDetectLocale(options.locale);
|
i18n.setOrDetectLocale(options.locale);
|
||||||
embark.console({
|
embark.console({
|
||||||
env: env || 'development',
|
env: env || 'development',
|
||||||
|
@ -200,7 +199,7 @@ class Cmd {
|
||||||
.option('-c, --client [client]', __('Use a specific ethereum client (supported: %s)', 'geth'))
|
.option('-c, --client [client]', __('Use a specific ethereum client (supported: %s)', 'geth'))
|
||||||
.option('--locale [locale]', __('language to use (default: en)'))
|
.option('--locale [locale]', __('language to use (default: en)'))
|
||||||
.description(__('run blockchain server (default: %s)', 'development'))
|
.description(__('run blockchain server (default: %s)', 'development'))
|
||||||
.action(function (env, options) {
|
.action(function(env, options) {
|
||||||
i18n.setOrDetectLocale(options.locale);
|
i18n.setOrDetectLocale(options.locale);
|
||||||
embark.initConfig(env || 'development', {
|
embark.initConfig(env || 'development', {
|
||||||
embarkConfig: 'embark.json',
|
embarkConfig: 'embark.json',
|
||||||
|
@ -222,7 +221,7 @@ class Cmd {
|
||||||
.option('-l, --gasLimit [gasLimit]', __('custom gas limit (default: %s)', '8000000'))
|
.option('-l, --gasLimit [gasLimit]', __('custom gas limit (default: %s)', '8000000'))
|
||||||
.option('--locale [locale]', __('language to use (default: en)'))
|
.option('--locale [locale]', __('language to use (default: en)'))
|
||||||
|
|
||||||
.action(function (env, options) {
|
.action(function(env, options) {
|
||||||
i18n.setOrDetectLocale(options.locale);
|
i18n.setOrDetectLocale(options.locale);
|
||||||
embark.initConfig(env || 'development', {
|
embark.initConfig(env || 'development', {
|
||||||
embarkConfig: 'embark.json',
|
embarkConfig: 'embark.json',
|
||||||
|
@ -246,7 +245,7 @@ class Cmd {
|
||||||
.option('--locale [locale]', __('language to use (default: en)'))
|
.option('--locale [locale]', __('language to use (default: en)'))
|
||||||
.option('--loglevel [loglevel]', __('level of logging to display') + ' ["error", "warn", "info", "debug", "trace"]', /^(error|warn|info|debug|trace)$/i, 'warn')
|
.option('--loglevel [loglevel]', __('level of logging to display') + ' ["error", "warn", "info", "debug", "trace"]', /^(error|warn|info|debug|trace)$/i, 'warn')
|
||||||
.description(__('run tests'))
|
.description(__('run tests'))
|
||||||
.action(function (file, options) {
|
.action(function(file, options) {
|
||||||
i18n.setOrDetectLocale(options.locale);
|
i18n.setOrDetectLocale(options.locale);
|
||||||
embark.runTests({file, loglevel: options.loglevel, gasDetails: options.gasDetails, node: options.node});
|
embark.runTests({file, loglevel: options.loglevel, gasDetails: options.gasDetails, node: options.node});
|
||||||
});
|
});
|
||||||
|
@ -262,7 +261,7 @@ class Cmd {
|
||||||
.option('-c, --client [client]', __('Use a specific ethereum client (supported: %s)', 'geth'))
|
.option('-c, --client [client]', __('Use a specific ethereum client (supported: %s)', 'geth'))
|
||||||
.option('--pipeline [pipeline]', __('webpack config to use (default: production)'))
|
.option('--pipeline [pipeline]', __('webpack config to use (default: production)'))
|
||||||
.description(__('Upload your dapp to a decentralized storage') + '.')
|
.description(__('Upload your dapp to a decentralized storage') + '.')
|
||||||
.action(function (env, _options) {
|
.action(function(env, _options) {
|
||||||
i18n.setOrDetectLocale(_options.locale);
|
i18n.setOrDetectLocale(_options.locale);
|
||||||
if (env === "ipfs" || env === "swarm") {
|
if (env === "ipfs" || env === "swarm") {
|
||||||
console.warn(("did you mean " + "embark upload".bold + " ?").underline);
|
console.warn(("did you mean " + "embark upload".bold + " ?").underline);
|
||||||
|
@ -286,7 +285,7 @@ class Cmd {
|
||||||
.option('--skip-events', __('Graph will not include events'))
|
.option('--skip-events', __('Graph will not include events'))
|
||||||
.option('--locale [locale]', __('language to use (default: en)'))
|
.option('--locale [locale]', __('language to use (default: en)'))
|
||||||
.description(__('generates documentation based on the smart contracts configured'))
|
.description(__('generates documentation based on the smart contracts configured'))
|
||||||
.action(function (env, options) {
|
.action(function(env, options) {
|
||||||
i18n.setOrDetectLocale(options.locale);
|
i18n.setOrDetectLocale(options.locale);
|
||||||
embark.graph({
|
embark.graph({
|
||||||
env: env || 'development',
|
env: env || 'development',
|
||||||
|
@ -303,7 +302,7 @@ class Cmd {
|
||||||
.command('reset')
|
.command('reset')
|
||||||
.option('--locale [locale]', __('language to use (default: en)'))
|
.option('--locale [locale]', __('language to use (default: en)'))
|
||||||
.description(__('resets embarks state on this dapp including clearing cache'))
|
.description(__('resets embarks state on this dapp including clearing cache'))
|
||||||
.action(function (options) {
|
.action(function(options) {
|
||||||
i18n.setOrDetectLocale(options.locale);
|
i18n.setOrDetectLocale(options.locale);
|
||||||
embark.initConfig('development', {
|
embark.initConfig('development', {
|
||||||
embarkConfig: 'embark.json', interceptLogs: false
|
embarkConfig: 'embark.json', interceptLogs: false
|
||||||
|
@ -316,38 +315,38 @@ class Cmd {
|
||||||
program
|
program
|
||||||
.command('eject-webpack')
|
.command('eject-webpack')
|
||||||
.description(__('copy the default webpack config into your dapp for customization'))
|
.description(__('copy the default webpack config into your dapp for customization'))
|
||||||
.action(function () {
|
.action(function() {
|
||||||
embark.ejectWebpack();
|
embark.ejectWebpack();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
versionCmd() {
|
versionCmd() {
|
||||||
program
|
program
|
||||||
.command('version')
|
.command('version')
|
||||||
.description(__('output the version number'))
|
.description(__('output the version number'))
|
||||||
.action(function () {
|
.action(function() {
|
||||||
console.log(embark.version);
|
console.log(embark.version);
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
helpCmd() {
|
helpCmd() {
|
||||||
program
|
program
|
||||||
.command('help')
|
.command('help')
|
||||||
.description(__('output usage information and help information'))
|
.description(__('output usage information and help information'))
|
||||||
.action(function () {
|
.action(function() {
|
||||||
console.log("Documentation can be found at: ".green + "https://embark.status.im/docs/".underline.green);
|
console.log("Documentation can be found at: ".green + "https://embark.status.im/docs/".underline.green);
|
||||||
console.log("");
|
console.log("");
|
||||||
console.log("Have an issue? submit it here: ".green + "https://github.com/embark-framework/embark/issues/new".underline.green);
|
console.log("Have an issue? submit it here: ".green + "https://github.com/embark-framework/embark/issues/new".underline.green);
|
||||||
console.log("or chat with us directly at: ".green + "https://gitter.im/embark-framework/Lobby".underline.green);
|
console.log("or chat with us directly at: ".green + "https://gitter.im/embark-framework/Lobby".underline.green);
|
||||||
program.help();
|
program.help();
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
otherCommands() {
|
otherCommands() {
|
||||||
program
|
program
|
||||||
.action(function (cmd) {
|
.action(function(cmd) {
|
||||||
console.log((__('unknown command') + ' "%s"').red, cmd);
|
console.log((__('unknown command') + ' "%s"').red, cmd);
|
||||||
let utils = require('../lib/utils/utils.js');
|
let utils = require('../lib/utils/utils.js');
|
||||||
let dictionary = ['new', 'demo', 'build', 'run', 'blockchain', 'simulator', 'test', 'upload', 'version'];
|
let dictionary = ['new', 'demo', 'build', 'run', 'blockchain', 'simulator', 'test', 'upload', 'version'];
|
||||||
|
|
Loading…
Reference in New Issue