UNPKG

1.69 kBJavaScriptView Raw
1const fs = require('fs');
2const path = require('path');
3const chalk = require('chalk');
4
5function capitaliseFirstCharacter(string) {
6 return string.charAt(0).toUpperCase() + string.slice(1);
7}
8
9function rememberToAdd(line, file, withMessage) {
10 console.log('');
11 console.log(chalk.green('Remember to add:'));
12 console.log(chalk.grey(' |'));
13 console.log(chalk.grey(' | ') + line);
14 console.log(chalk.grey(' |'));
15 console.log('To your ' + chalk.yellow(file) + ' ' + withMessage);
16 console.log('');
17}
18
19module.exports = async function({ ask }) {
20 // Asks which template from the template folder to use.
21 const template = await ask.choice(
22 'template',
23 'Which template do you want?',
24 fs.readdirSync(path.join(__dirname, '_template'))
25 );
26
27 if (
28 template === 'atom' ||
29 template === 'molecule' ||
30 template === 'organism'
31 ) {
32 const name = await ask.input(
33 'name',
34 'Whats the name of your ' + template + '?'
35 );
36 const about = await ask.input(
37 'about',
38 'Short description of the ' + template
39 );
40
41 rememberToAdd(
42 chalk.magenta('@import') +
43 ' ' +
44 chalk.greenBright('"./' + template + 's/' + name + '"') +
45 ';',
46 'scss/styles.scss',
47 'to enable your styles'
48 );
49
50 rememberToAdd(
51 chalk.magenta('$schema:') + ' schema/' + template + 's/' + name + '.yaml',
52 'views/lib/' + template + 's/' + name + '.twig',
53 'to enable your JSON Schema'
54 );
55
56 return {
57 _template: template,
58 name: name,
59 about: about,
60 capitalisationName: capitaliseFirstCharacter(name),
61 };
62 }
63
64 // Data object to return;
65 return {
66 _template: template,
67 };
68};