-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathindex.js
More file actions
executable file
·37 lines (30 loc) · 1.21 KB
/
index.js
File metadata and controls
executable file
·37 lines (30 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/env node
import { relative } from 'node:path';
import { cwd, exit } from 'node:process';
import boxen from 'boxen';
import chalk from 'chalk';
import { retro } from 'gradient-string';
import { getArgs } from './src/args.js';
import { cli } from './src/cli.js';
import { getTasks } from './src/tasks.js';
try {
const { appName, givenOutputDir, silent, https } = getArgs();
const config = await cli(appName, givenOutputDir, silent);
const tasks = await getTasks({ ...config, https });
await tasks.run();
if (!silent) {
console.log();
console.log(chalk.bold('All done - your project is ready! Start hacking immediately:'));
console.log();
console.log(`> ${chalk.cyan(`cd ${relative(cwd(), config.outputDir)}`)}`);
console.log(`> ${chalk.cyan('npm start')}`);
console.log(boxen(chalk.bold(retro('Have a nice day :)')), { margin: 1, padding: 1 }));
}
} catch (error) {
if (error.code?.startsWith('ERR_PARSE_ARGS') || error.message?.startsWith('Argument error: ')) {
console.error(chalk.bgRed(error.message));
exit(1);
}
console.error(chalk.bgRed.bold('Something went wrong. Please check the output above.'));
exit(1);
}