Skip to content

Commit e8a2b6e

Browse files
💄 using PascalCase for component name
1 parent 98ad2b7 commit e8a2b6e

File tree

4 files changed

+15
-4
lines changed

4 files changed

+15
-4
lines changed

generator/index.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ const { rename, renameFiles, updateFile } = require('./fileHelper')
22
const { updateExample } = require('./componentFixtureHelper')
33
const readmeUpdater = require('./readmeUpdater');
44
const licenseList = require('spdx-license-list/full');
5+
const camelCase = require('camelcase');
56

67
function buildPrePublishOnly({ useVueStyleguidist, useVueDoc, useLint }) {
78
const scripts = []
@@ -23,10 +24,13 @@ function replaceInLicense(licenseTextTemplate, sourceText, newText) {
2324
.replace(new RegExp(`\\[${sourceText}\\]`), newText)
2425
}
2526

26-
module.exports = (api, { addBadges, addLicense, componentName, copyrightHolders, licenseName, useComponentFixture, useVueDoc, useVueStyleguidist }) => {
27+
module.exports = (api, context) => {
28+
const { addBadges, addLicense, componentName, copyrightHolders, licenseName, useComponentFixture, useVueDoc, useVueStyleguidist } = context
2729
const useLint = api.hasPlugin('eslint')
2830
const usesTypescript = api.hasPlugin('typescript')
2931
const extension = usesTypescript ? 'ts' : 'js'
32+
componentName = camelCase(componentName, { pascalCase: true });
33+
context.componentName = componentName
3034
const packageName = api.generator.pkg.name
3135
const context = { addBadges, addLicense, componentName, licenseName, packageName, useComponentFixture, useLint, useVueDoc, useVueStyleguidist }
3236

package-lock.json

Lines changed: 6 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"dependencies": {
2626
"@types/node": "^10.5.2",
2727
"@vue/cli-shared-utils": "^3.0.0-rc.5",
28+
"camelcase": "^5.0.0",
2829
"git-user-name": "^2.0.0",
2930
"spdx-license-list": "^4.1.0"
3031
},

prompts.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11

2+
const camelCase = require('camelcase');
23
const licensesInformation = require('spdx-license-list/spdx-simple.json')
34
const licenses = licensesInformation.map(name => ({
45
name,
@@ -9,7 +10,7 @@ const prompts = module.exports = [
910
{
1011
type: 'input',
1112
name: 'componentName',
12-
message: 'Enter the component name (in CamelCase- no hyphen or dash):'
13+
message: 'Enter the component name (in PascalCase- no hyphen nor dash):'
1314
},
1415
{
1516
type: 'confirm',
@@ -65,6 +66,6 @@ const prompts = module.exports = [
6566
]
6667

6768
module.exports.getPrompts = pkg => {
68-
prompts[0].default = pkg.name
69+
prompts[0].default = camelCase(pkg.name, {pascalCase: true});
6970
return prompts
7071
}

0 commit comments

Comments
 (0)