forked from vuejs-templates/webpack-simple
/
meta.js
70 lines (65 loc) · 2.05 KB
/
meta.js
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
const fs = require('fs');
const path = require('path');
const toPascal = function(str) {
return str
.replace(/([\-_\s]+[a-z])|(^[a-z])/g, $1 => $1.toUpperCase())
.replace(/[\-_\s]+/g, '');
};
module.exports = {
prompts: {
name: {
type: 'string',
required: true,
label: 'Component name (kebab-case format)',
default: 'my-component-name',
message:
'The name of the new component. Kebab-cased name will be used to generate relevant file names and imports, so choose carefully!.',
},
description: {
type: 'string',
required: true,
label: 'Component description',
default: 'An REI FED component built on Vue.js ',
},
author: {
type: 'string',
label: 'Author',
},
},
helpers: {
pascalcase: toPascal,
},
skipInterpolation: 'src/Component.vue',
complete: function(data, { logger, chalk }) {
// Rename to be compatible with styleguide configuration
const cmpDir = data.inPlace
? 'src'
: path.resolve(data.destDirName, 'src');
const testDir = data.inPlace
? 'test'
: path.resolve(data.destDirName, 'test');
const pascalName = toPascal(data.name);
fs.renameSync(
path.resolve(cmpDir, 'Component.vue'),
path.resolve(cmpDir, pascalName + '.vue'),
);
fs.renameSync(
path.resolve(testDir, 'Component.spec.js'),
path.resolve(testDir, pascalName + '.spec.js'),
);
logger.log(chalk.bold('To get started:'));
if (!data.inPlace) logger.log(chalk.green('cd ' + data.destDirName));
const logFiles = {
component: path.relative(
data.destDirName,
path.resolve(data.destDirName, 'src', pascalName + '.vue'),
),
};
logger.log(chalk.green('npm install'));
logger.log(chalk.green('npm run dev'));
logger.log(chalk.cyan('Write your component in ' + logFiles.component));
logger.log(chalk.cyan('Write the demo and usage instructions in src/README.md'));
logger.log(chalk.cyan('Build for distribution:'));
logger.log(chalk.green('npm run build'));
},
};