Skip to content

Commit

Permalink
Merge pull request #13 from jaebradley/move-prompt-variables-to-const…
Browse files Browse the repository at this point in the history
…ants

refactor(prompt-options): move package types and features to constants
  • Loading branch information
jaebradley authored Apr 23, 2018
2 parents 78ec652 + 4591c8f commit 46b7072
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 8 deletions.
14 changes: 14 additions & 0 deletions src/constants.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const PACKAGE_TYPES = Object.freeze({
NODE: 'Node',
REACT: 'React',
});

const PACKAGE_FEATURES = Object.freeze({
COMMITLINT: 'commitlint',
SEMANTIC_RELEASE: 'semantic-release',
});

export {
PACKAGE_TYPES,
PACKAGE_FEATURES,
};
13 changes: 9 additions & 4 deletions src/executor.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ import normalizePackageData from 'normalize-package-data';
import sortPackageJSON from 'sort-package-json';
import isOnline from 'is-online';

import {
PACKAGE_TYPES,
PACKAGE_FEATURES,
} from './constants';

import prompts from './prompts';
import {
writeBaseTemplates,
Expand Down Expand Up @@ -42,10 +47,10 @@ const executor = async () => {
packageAuthor: authorEmailAddress,
});

const isSemanticRelease = packageFeatures.indexOf('semantic-release') >= 0;
const isCommitLint = packageFeatures.indexOf('commitlint') >= 0;
const isNode = packageType === 'Node';
const isReact = packageType === 'React';
const isSemanticRelease = packageFeatures.indexOf(PACKAGE_FEATURES.SEMANTIC_RELEASE) >= 0;
const isCommitLint = packageFeatures.indexOf(PACKAGE_FEATURES.COMMITLINT) >= 0;
const isNode = packageType === PACKAGE_TYPES.NODE;
const isReact = packageType === PACKAGE_TYPES.REACT;

await writeBaseTemplates({
templateValues,
Expand Down
12 changes: 8 additions & 4 deletions src/prompts.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ import validateNpmPackageName from 'validate-npm-package-name';
import isSemver from 'is-semver';

import isGitHubUsernameValid from './isGitHubUsernameValid';
import {
PACKAGE_TYPES,
PACKAGE_FEATURES,
} from './constants';

const prompts = async () => (
inquirer.prompt([
Expand All @@ -12,17 +16,17 @@ const prompts = async () => (
message: 'Package Type',
type: 'list',
choices: [
'Node',
'React',
PACKAGE_TYPES.NODE,
PACKAGE_TYPES.REACT,
],
},
{
name: 'packageFeatures',
message: 'Package Features',
type: 'checkbox',
choices: [
'commitlint',
'semantic-release',
PACKAGE_FEATURES.COMMITLINT,
PACKAGE_FEATURES.SEMANTIC_RELEASE,
],
},
{
Expand Down

0 comments on commit 46b7072

Please sign in to comment.