Skip to content

Commit

Permalink
fixup! apply feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
virkt25 committed Jul 10, 2018
1 parent 55aa23e commit 47cdc7f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 30 deletions.
25 changes: 1 addition & 24 deletions packages/cli/generators/model/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
const ArtifactGenerator = require('../../lib/artifact-generator');
const debug = require('../../lib/debug')('model-generator');
const utils = require('../../lib/utils');
const updateIndex = require('../../lib/update-index');
const chalk = require('chalk');
const path = require('path');
const _ = require('lodash');
Expand Down Expand Up @@ -63,29 +62,7 @@ module.exports = class ModelGenerator extends ArtifactGenerator {
}

promptArtifactName() {
return super.promptArtifactName();
}

async promptBase() {
this.artifactInfo.className = utils.toClassName(this.artifactInfo.name);
const baseOptions = ['Entity'];
const prompts = [
{
name: 'base',
message: `Select the base class for ${chalk.yellow(
this.artifactInfo.className,
)}:`,
type: 'list',
default: baseOptions[0],
choices: baseOptions,
when: baseOptions.length > 1,
},
];

const answers = await this.prompt(prompts);
if (!answers.base) answers.base = baseOptions[0];
Object.assign(this.artifactInfo, answers);

await super.promptArtifactName();
this.log(
`Let's add a property to ${chalk.yellow(this.artifactInfo.className)}`,
);
Expand Down
10 changes: 5 additions & 5 deletions packages/cli/lib/artifact-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,25 +97,25 @@ module.exports = class ArtifactGenerator extends BaseGenerator {
*
* Multiple indexes / files can be updated by providing an array of
* index update objects as follows:
* this.artifactInfo.updateIndexes = [{
* this.artifactInfo.indexesToBeUpdated = [{
* dir: 'directory in which to update index.ts',
* file: 'file to add to index.ts',
* }, {dir: '...', file: '...'}]
*/
if (!this.artifactInfo.disableIndexUpdate) {
if (
!this.artifactInfo.updateIndexes &&
!this.artifactInfo.indexesToBeUpdated &&
this.artifactInfo.outDir &&
this.artifactInfo.outFile
) {
this.artifactInfo.updateIndexes = [
this.artifactInfo.indexesToBeUpdated = [
{dir: this.artifactInfo.outDir, file: this.artifactInfo.outFile},
];
} else {
this.artifactInfo.updateIndexes = [];
this.artifactInfo.indexesToBeUpdated = [];
}

for (const idx of this.artifactInfo.updateIndexes) {
for (const idx of this.artifactInfo.indexesToBeUpdated) {
await updateIndex(idx.dir, idx.file);
// Output for users
const updateDirRelPath = path.relative(
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ function validateValue(name, unallowedCharacters) {
unallowedCharacters = /[\/@\s\+%:\.]/;
}
if (name.match(unallowedCharacters)) {
return `Name cannot contain special characters ${unallowedCharacters} ${name}`;
return `Name cannot contain special characters ${unallowedCharacters}: ${name}`;
}
if (name !== encodeURIComponent(name)) {
return `Name cannot contain special characters escaped by encodeURIComponent: ${name}`;
Expand Down

0 comments on commit 47cdc7f

Please sign in to comment.