diff --git a/commands/build.js b/commands/build.js index d5d3487a..5863e4a2 100644 --- a/commands/build.js +++ b/commands/build.js @@ -3,18 +3,24 @@ const winston = require('winston'); const {Compiler} = require('../build/compiler.js'); -exports.command = 'build [dir]'; +exports.command = + 'build [--dir] [--test] [--cover] [--production] [--log-level]'; exports.desc = 'Build your app'; exports.builder = { - cover: { + dir: { + type: 'string', + default: '.', + describe: 'Root path for the application relative to CLI CWD', + }, + test: { type: 'boolean', default: false, - describe: 'Build tests (with coverage) as well as application', + describe: 'Build test assets as well as development assets', }, - test: { + cover: { type: 'boolean', default: false, - describe: 'Build tests as well as application', + describe: 'Build tests (with coverage) as well as development assets', }, production: { type: 'boolean', @@ -51,8 +57,8 @@ exports.run = async function( const envs = []; if (production) envs.push('production'); - if (test) envs.push('test'); if (envs.length === 0) envs.push('development'); + if (test) envs.push('test'); const compiler = new Compiler({envs, dir, cover, logger}); await compiler.clean(); diff --git a/commands/dev.js b/commands/dev.js index 1e1fdd60..7d42d0c7 100644 --- a/commands/dev.js +++ b/commands/dev.js @@ -4,40 +4,20 @@ const {Compiler} = require('../build/compiler'); const {DevelopmentRuntime} = require('../build/dev-runtime'); const {TestRuntime} = require('../build/test-runtime'); -exports.command = 'dev [dir]'; +exports.command = + 'dev [--dir] [--debug] [--test] [--cover] [--port] [--no-open] [--no-hmr] [--log-level]'; exports.describe = 'Run your app in development'; exports.builder = { - cover: { - type: 'boolean', - default: false, - describe: 'Run tests (with coverage) as well as your application', + dir: { + type: 'string', + default: '.', + describe: 'Root path for the application relative to CLI CWD', }, debug: { type: 'boolean', default: false, describe: 'Debug application', }, - 'no-open': { - type: 'boolean', - default: false, - describe: 'Run without opening the url in your browser', - }, - 'no-hmr': { - type: 'boolean', - default: false, - describe: 'Run without hot module replacement', - }, - test: { - type: 'boolean', - default: false, - describe: 'Run tests as well as your application', - }, - // TODO(#18): support watch-mode `dev --profile` - // profile: { - // type: 'boolean', - // default: false, - // describe: 'Run profiling as well as your application', - // }, // TODO(#19): support dev with production assets // production: { // type: 'boolean', @@ -49,6 +29,18 @@ exports.builder = { default: 3000, describe: 'The port at which the app runs', }, + open: { + // yargs generates no-open option + type: 'boolean', + default: true, + describe: 'Run without opening the url in your browser', + }, + hmr: { + // yargs generates no-hmr option + type: 'boolean', + default: true, + describe: 'Run without hot module replacement', + }, 'log-level': { type: 'string', default: 'info', @@ -62,8 +54,8 @@ exports.run = async function({ debug, port, cover, - noHmr, - noOpen, + hmr, + open, logLevel, }) { const logger = new winston.Logger({ @@ -75,7 +67,7 @@ exports.run = async function({ const compiler = new Compiler({ envs: test ? ['development', 'test'] : ['development'], dir, - watch: !noHmr, + watch: hmr, cover, logger, }); @@ -86,9 +78,9 @@ exports.run = async function({ dir, port, debug, - noOpen, + noOpen: !open, }, - !noHmr ? {middleware: compiler.getMiddleware()} : {} + hmr ? {middleware: compiler.getMiddleware()} : {} ) ); diff --git a/commands/profile.js b/commands/profile.js index b89b43f1..36a9953c 100644 --- a/commands/profile.js +++ b/commands/profile.js @@ -4,7 +4,7 @@ const fs = require('fs'); const profile = require('../lib/profiler'); const launchSourceMapExplorer = require('../launch-source-map-explorer.js'); -exports.command = 'profile [dir]'; +exports.command = 'profile [--dir] [--environment] [--watch] [--file-count]'; exports.desc = 'Profile your application'; exports.builder = { // TODO(#18): support fusion profile --watch @@ -13,6 +13,11 @@ exports.builder = { // default: false, // describe: 'Use existing built assets', // }, + dir: { + type: 'string', + default: '.', + describe: 'Root path for the application relative to CLI CWD', + }, environment: { type: 'string', default: 'production', diff --git a/commands/start.js b/commands/start.js index 6e606033..b42e665d 100644 --- a/commands/start.js +++ b/commands/start.js @@ -2,15 +2,20 @@ const fs = require('fs'); const path = require('path'); -exports.command = 'start [dir]'; +exports.command = 'start [--dir] [--environment]'; exports.desc = 'Run your app'; exports.builder = { - // TODO: https://github.com/uber-web/framework/issues/882 + // TODO(#20) ensure --debug works with start and test commands // debug: { // type: 'boolean', // default: false, // describe: 'Debug application', // }, + dir: { + type: 'string', + default: '.', + describe: 'Root path for the application relative to CLI CWD', + }, environment: { type: 'string', describe: diff --git a/commands/test.js b/commands/test.js index eed48cbb..fc9e4f01 100644 --- a/commands/test.js +++ b/commands/test.js @@ -2,15 +2,19 @@ const {Compiler} = require('../build/compiler'); const {TestRuntime} = require('../build/test-runtime'); -exports.command = 'test [dir]'; exports.desc = 'Run tests'; exports.builder = { + dir: { + type: 'string', + default: '.', + describe: 'Root path for the application relative to CLI CWD', + }, cover: { type: 'boolean', default: false, describe: 'Run tests with coverage', }, - // TODO(#20): support --debug flag + // TODO(#20): ensure --debug works with start and test commands // debug: { // type: 'boolean', // default: false,