UNPKG

1.9 kBJavaScriptView Raw
1
2const chalk = require('chalk');
3const clui = require('clui');
4const inquirer = require('inquirer');
5const { cwd, exit } = require('process');
6const { join } = require('path');
7
8const { checkServices, logCheckService } = require('@feathers-plus/cli-audit');
9const { directoryExists } = require('./utils');
10
11const Spinner = clui.Spinner;
12
13module.exports = function audit () {
14 if (!directoryExists('.git')) {
15 console.log(chalk.red('Current directory is not a git repository.'));
16 exit();
17 }
18
19 const testFolderMsg = [
20 'The following test folder structures are supported:',
21 ' n/a feathers-cli : All test programs are all in dir,',
22 ' i.e. project/tests',
23 ' feathers-plus-cli : Each dir contains a __tests__ folder,',
24 ' e.g. project/src/services/user/__tests__',
25 ' n/a inline : Dirs contain both source & test programs,',
26 ' e.g. project/src/servicess/user',
27 '',
28 'What structure does this project use?'
29 ].join('\n');
30
31 console.log('The Mocha test program for foo-bar.baz.js must be named foo-bar.baz.test.js .');
32
33 const questions = [
34 {
35 name: 'testFolder',
36 type: 'list',
37 message: testFolderMsg,
38 default: 'feathers-plus-cli',
39 choices: ['feathers-cli', 'feathers-plus-cli', 'inline']
40 },
41 {
42 name: 'path',
43 type: 'input',
44 message: 'Enter the path to Feathers `services` folder:',
45 default: 'src/services',
46 validate (value) {
47 return value.length ? true : 'Please enter the path to the Feathers `services` folder.';
48 }
49 }
50 ];
51
52 inquirer.prompt(questions)
53 .then(data => {
54 const serviceDir = join(cwd(), 'services');
55
56 const status = new Spinner('Analyzing project.');
57 status.start();
58 const results = checkServices(serviceDir); // todo TEMP
59 status.stop();
60 });
61};