1
0
mirror of synced 2025-11-09 13:27:27 +00:00

refactor(CLI): modularize more, test more

This commit is contained in:
Jason Dreyzehner
2018-03-11 00:00:24 -05:00
parent e406917ff8
commit a0541f9f9b
14 changed files with 877 additions and 445 deletions

View File

@@ -2,19 +2,23 @@
import chalk from 'chalk';
import { checkArgs } from './args';
import { inquire } from './inquire';
import { getIntro } from './primitives';
import { LiveTasks } from './tasks';
import { getInferredOptions, LiveTasks } from './tasks';
import { typescriptStarter } from './typescript-starter';
import { getIntro, TypescriptStarterUserOptions } from './utils';
(async () => {
const cliOptions = await checkArgs();
const options = cliOptions
? cliOptions
: await (async () => {
console.log(getIntro(process.stdout.columns));
return inquire();
})();
return typescriptStarter(options, LiveTasks);
const userOptions = cliOptions.projectName
? (cliOptions as TypescriptStarterUserOptions)
: {
...(await (async () => {
console.log(getIntro(process.stdout.columns));
return inquire();
})()),
...cliOptions // merge in cliOptions.install
};
const inferredOptions = await getInferredOptions();
return typescriptStarter({ ...inferredOptions, ...userOptions }, LiveTasks);
})().catch((err: Error) => {
console.error(`
${chalk.red(err.message)}