Skip to content

Commit

Permalink
fix: Update code for component generator to work correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
adamszalapski committed Jul 5, 2019
1 parent 98f4302 commit 79b2df8
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 29 deletions.
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -38,7 +38,7 @@
"clean:empty": "find . -empty -type d -delete",
"clean:npm": "find . -name 'node_modules' -type d -exec rm -rf {} +",
"clean:www": "find . -name 'www' -type d -exec rm -rf {} +",
"create:component": "yo ./packages/generator-bolt/generators/component/index.js",
"create:component": "yo ./packages/generators/yeoman-create-component/generators/component/index.js",
"cz": "git-cz",
"deploy": "./scripts/deploy.js",
"deploy:docker": "sh ./scripts/docker.sh",
Expand Down
Expand Up @@ -5,7 +5,7 @@ const sortPackageJson = require('sort-package-json');

const boltPackageJsonPath = path.resolve(
__dirname,
'../../../../docs-site/package.json',
'../../../../../docs-site/package.json',
);
const boltPackageJson = require(boltPackageJsonPath);

Expand Down
Expand Up @@ -12,7 +12,7 @@ const program = require('commander');
const { updateBoltRcConfig } = require('./update-boltrc');
const { addBoltPackage } = require('./add-bolt-package');

const currentBoltVersion = require('../../../../docs-site/package.json')
const currentBoltVersion = require('../../../../../docs-site/package.json')
.version;

var validateString = function(input) {
Expand Down Expand Up @@ -78,7 +78,7 @@ module.exports = class extends Generator {
message:
'What is the name of your Bolt component? (for example: `button`, `card`, carousel`, etc)',
required: true,
default: program.name || 'component',
default: typeof program.name === 'string' ? program.name : ``,
validate: function(input) {
if (typeof input !== 'string') {
this.log(chalk.red('You must pass a valid component name!'));
Expand Down Expand Up @@ -131,12 +131,7 @@ module.exports = class extends Generator {
'Could you write a sentence or two that describes your new Bolt component?',
required: false,
default: function(answers) {
return (
program.description ||
`The ${
this.name.noCase
} component -- part of the Bolt Design System.`
);
return `The ${this.name.noCase} component - part of the Bolt Design System.`;
}.bind(this),
validate: function(input) {
if (typeof input !== 'string') {
Expand All @@ -153,12 +148,8 @@ module.exports = class extends Generator {
this.props.gitUrl = this.gitUrl;
this.props.boltVersion = this.boltVersion;
this.props.gitInfo = this.gitInfo;
this.props.packageName = `@bolt/components-${
this.props.name.kebabCase
}`;
this.props.dest = `${this.folders.src}/bolt-${
this.props.name.kebabCase
}`;
this.props.packageName = `@bolt/components-${this.props.name.kebabCase}`;
this.props.dest = `${this.folders.src}/bolt-${this.props.name.kebabCase}`;
this.props.gitPath =
this.gitUrl +
'/tree/master/packages/components/bolt-' +
Expand Down Expand Up @@ -221,9 +212,7 @@ module.exports = class extends Generator {
this.fs.copyTpl(
this.templatePath('component.test.js'),
this.destinationPath(
`${this.folders.src}/bolt-${
this.props.name.kebabCase
}/__tests__/index.js`,
`${this.folders.src}/bolt-${this.props.name.kebabCase}/__tests__/index.js`,
),
{ props: this.props },
);
Expand Down Expand Up @@ -256,9 +245,7 @@ module.exports = class extends Generator {
this.fs.copyTpl(
this.templatePath('component-docs.twig'),
this.destinationPath(
`${this.folders.patternLabFolder}/${this.props.name.kebabCase}/00-${
this.props.name.kebabCase
}-docs.twig`,
`${this.folders.patternLabFolder}/${this.props.name.kebabCase}/00-${this.props.name.kebabCase}-docs.twig`,
),
{
props: this.props,
Expand All @@ -274,15 +261,11 @@ module.exports = class extends Generator {
shelljs.exec('yarn');

shelljs.exec(
`npx prettier ${this.folders.patternLabFolder}/${
this.props.name.kebabCase
}/**/*.{js,scss,json} --write`,
`npx prettier ${this.folders.patternLabFolder}/${this.props.name.kebabCase}/**/*.{js,scss,json} --write`,
);

shelljs.exec(
`npx prettier ${this.folders.src}/bolt-${
this.props.name.kebabCase
}/**/*.{js,scss,json} --write`,
`npx prettier ${this.folders.src}/bolt-${this.props.name.kebabCase}/**/*.{js,scss,json} --write`,
);
}
};
Expand Up @@ -4,7 +4,7 @@ const prettier = require('prettier');

const boltRcConfigPath = path.resolve(
__dirname,
'../../../../docs-site/.boltrc.js',
'../../../../../docs-site/.boltrc.js',
);
const boltRcConfig = require(boltRcConfigPath);

Expand Down

0 comments on commit 79b2df8

Please sign in to comment.