From bc577ad78103b1e185b12bdf08fc9be045e5e266 Mon Sep 17 00:00:00 2001 From: Luke Edwards Date: Thu, 21 Dec 2017 00:06:03 -0800 Subject: [PATCH 001/255] begin migration from yargs to sade --- package.json | 4 +- src/commands/index.js | 1 + src/index.js | 89 ++++++++++++++++++++++++++++++------------- yarn.lock | 19 ++++++++- 4 files changed, 83 insertions(+), 30 deletions(-) create mode 100644 src/commands/index.js diff --git a/package.json b/package.json index 88bd2714f..be768285b 100644 --- a/package.json +++ b/package.json @@ -143,6 +143,7 @@ "raw-loader": "^0.5.1", "require-relative": "^0.8.7", "rimraf": "^2.6.1", + "sade": "^1.1.1", "script-ext-html-webpack-plugin": "^1.8.0", "simplehttp2server": "^2.0.0", "source-map": "^0.5.6", @@ -158,7 +159,6 @@ "webpack-dev-server": "^2.9.0", "webpack-merge": "^4.1.0", "webpack-plugin-replace": "^1.1.1", - "which": "^1.2.14", - "yargs": "^8.0.1" + "which": "^1.2.14" } } diff --git a/src/commands/index.js b/src/commands/index.js new file mode 100644 index 000000000..c02d86cd8 --- /dev/null +++ b/src/commands/index.js @@ -0,0 +1 @@ +export { default as create } from './create'; diff --git a/src/index.js b/src/index.js index 8e0b5374c..f748392d0 100644 --- a/src/index.js +++ b/src/index.js @@ -1,35 +1,70 @@ #!/usr/bin/env node -import updateNotifier from 'update-notifier'; -import yargs from 'yargs'; -import create from './commands/create'; -import build from './commands/build'; -import watch from './commands/watch'; -import serve from './commands/serve'; -import list from './commands/list'; -import installHooks from './lib/output-hooks'; -import pkg from '../package.json'; -import logo from './lib/logo'; -import checkVersion from './../check'; - +import sade from 'sade'; global.Promise = require('bluebird'); +import notifier from 'update-notifier'; +import * as cmd from './commands'; +import version from '../check'; +import pkg from '../package'; + + +version(); + +// installHooks(); + +notifier({ pkg }).notify(); + +let prog = sade('preact').version(pkg.version); + +prog + .command('build [src]') + .describe('Create a production build') + .option('--src', 'Specify source directory', 'src') + .option('--dest', 'Specify output directory', 'build') + .option('--cwd', 'A directory to use instead of $PWD', '.') + .option('--json', 'Generate build stats for bundle analysis') + .option('--template', 'Path to custom HTML template') + .option('-c, --config', 'Path to custom CLI config', 'preact.config.js') + .action(cmd.build); -checkVersion(); +prog + .command('create