-
Notifications
You must be signed in to change notification settings - Fork 133
/
cli.ts
52 lines (45 loc) 路 1.31 KB
/
cli.ts
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import input from '@inquirer/input';
import { bold, cyan } from 'kleur';
import { getPackageJsonPath } from './packageJson';
import { Packages } from './types';
export const logError = (error: Error): void => {
// create a new line for yarn create
console.log();
if (error.message === 'cannot read package.json') {
console.log(bold().yellow(`Cannot read ${getPackageJsonPath()}`));
console.log(bold().yellow(`Create a package.json with "npm init"`));
} else {
console.error(error.message);
}
};
export const logInstallDependencies = (
packages: Packages,
isYarn = false,
): void => {
console.log(cyan(`Installing dependencies`));
Object.keys(packages).forEach(name => {
const version = packages[name];
console.log(
cyan(
`${isYarn ? 'yarn add' : 'npm install --save-dev'} ${name}@${version}`,
),
);
});
};
export const logUseTypeScript = (useTypeScript: boolean): void => {
console.log(
cyan(
`TypeScript ${useTypeScript ? '鉁旓笍' : '鉁栵笍'} tsconfig.json ${
useTypeScript ? 'found' : 'not found'
}`,
),
);
};
export const promptRootDir = (): Promise<string> => {
// create a line break before our CLI prompt
console.log();
return input({
message: 'rootDir: Directory to create tests in',
default: '.qawolf',
});
};