move check dependencies to specific commands
This commit is contained in:
parent
ef4134015c
commit
4dcaa529f9
26
bin/embark
26
bin/embark
|
@ -10,26 +10,6 @@ try {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function launchEmbark() {
|
var Cmd = require('../cmd/cmd');
|
||||||
var Cmd = require('../cmd/cmd');
|
var cli = new Cmd();
|
||||||
var cli = new Cmd();
|
cli.process(process.argv);
|
||||||
cli.process(process.argv);
|
|
||||||
}
|
|
||||||
|
|
||||||
const path = require('path');
|
|
||||||
try {
|
|
||||||
const dappPackage = require(path.join(process.cwd(), 'package.json'));
|
|
||||||
require(path.join(process.cwd(), 'embark.json')); // Make sure we are in a Dapp
|
|
||||||
require('check-dependencies')(dappPackage, (state) => {
|
|
||||||
if (state.status) {
|
|
||||||
require('colors');
|
|
||||||
console.error('\nMissing dependencies. Please run npm install'.red);
|
|
||||||
process.exit();
|
|
||||||
}
|
|
||||||
launchEmbark();
|
|
||||||
});
|
|
||||||
} catch (_e) {
|
|
||||||
// We are not in a Dapp
|
|
||||||
launchEmbark();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
27
cmd/cmd.js
27
cmd/cmd.js
|
@ -30,6 +30,25 @@ 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 || '');
|
||||||
|
|
||||||
|
function checkDeps() {
|
||||||
|
const path = require('path');
|
||||||
|
try {
|
||||||
|
const dappPackage = require(path.join(process.cwd(), 'package.json'));
|
||||||
|
require(path.join(process.cwd(), 'embark.json')); // Make sure we are in a Dapp
|
||||||
|
require('check-dependencies')(dappPackage, (state) => {
|
||||||
|
if (state.status) {
|
||||||
|
require('colors');
|
||||||
|
console.error('\nMissing dependencies. Please run npm install'.red);
|
||||||
|
process.exit();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
} catch (_e) {
|
||||||
|
// We are not in a Dapp
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class Cmd {
|
class Cmd {
|
||||||
constructor() {
|
constructor() {
|
||||||
program.version(embark.version);
|
program.version(embark.version);
|
||||||
|
@ -129,6 +148,7 @@ class Cmd {
|
||||||
.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) {
|
||||||
|
checkDeps();
|
||||||
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,6 +175,7 @@ class Cmd {
|
||||||
.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) {
|
||||||
|
checkDeps();
|
||||||
i18n.setOrDetectLocale(options.locale);
|
i18n.setOrDetectLocale(options.locale);
|
||||||
embark.run({
|
embark.run({
|
||||||
env: env || 'development',
|
env: env || 'development',
|
||||||
|
@ -181,6 +202,7 @@ class Cmd {
|
||||||
.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) {
|
||||||
|
checkDeps();
|
||||||
i18n.setOrDetectLocale(options.locale);
|
i18n.setOrDetectLocale(options.locale);
|
||||||
embark.console({
|
embark.console({
|
||||||
env: env || 'development',
|
env: env || 'development',
|
||||||
|
@ -200,6 +222,7 @@ class Cmd {
|
||||||
.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) {
|
||||||
|
checkDeps();
|
||||||
i18n.setOrDetectLocale(options.locale);
|
i18n.setOrDetectLocale(options.locale);
|
||||||
embark.initConfig(env || 'development', {
|
embark.initConfig(env || 'development', {
|
||||||
embarkConfig: 'embark.json',
|
embarkConfig: 'embark.json',
|
||||||
|
@ -222,6 +245,7 @@ class Cmd {
|
||||||
.option('--locale [locale]', __('language to use (default: en)'))
|
.option('--locale [locale]', __('language to use (default: en)'))
|
||||||
|
|
||||||
.action(function(env, options) {
|
.action(function(env, options) {
|
||||||
|
checkDeps();
|
||||||
i18n.setOrDetectLocale(options.locale);
|
i18n.setOrDetectLocale(options.locale);
|
||||||
embark.initConfig(env || 'development', {
|
embark.initConfig(env || 'development', {
|
||||||
embarkConfig: 'embark.json',
|
embarkConfig: 'embark.json',
|
||||||
|
@ -246,6 +270,7 @@ class Cmd {
|
||||||
.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) {
|
||||||
|
checkDeps();
|
||||||
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,6 +287,7 @@ class Cmd {
|
||||||
.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) {
|
||||||
|
checkDeps();
|
||||||
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,6 +312,7 @@ class Cmd {
|
||||||
.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) {
|
||||||
|
checkDeps();
|
||||||
i18n.setOrDetectLocale(options.locale);
|
i18n.setOrDetectLocale(options.locale);
|
||||||
embark.graph({
|
embark.graph({
|
||||||
env: env || 'development',
|
env: env || 'development',
|
||||||
|
|
Loading…
Reference in New Issue