From 88c96ac31acfa12381a33d39a2953f3405053870 Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" <23040076+greenkeeper[bot]@users.noreply.github.com> Date: Sun, 23 Jun 2019 16:04:28 +0200 Subject: [PATCH] :arrow_up: Update eslint to the latest version (#70) --- .eslintrc.js | 12 ++- package-lock.json | 75 ++++++++++-------- package.json | 2 +- src/ask-questions.js | 38 ++++++++++ src/ask-questions.spec.js | 80 ++++++++++++++++++++ src/cli.js | 50 +----------- src/cli.spec.js | 155 ++++++++++++-------------------------- src/index.js | 2 +- src/project-infos.js | 11 ++- src/questions/index.js | 1 + src/readme.spec.js | 12 +-- src/utils.js | 33 ++++---- 12 files changed, 258 insertions(+), 213 deletions(-) create mode 100644 src/ask-questions.js create mode 100644 src/ask-questions.spec.js diff --git a/.eslintrc.js b/.eslintrc.js index 346c83a..bf9bfc5 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -6,8 +6,18 @@ module.exports = { }, extends: ['airbnb-base', 'eslint:recommended'], rules: { + semi: ['error', 'never'], + 'no-use-before-define': ['error', { functions: false }], + 'comma-dangle': 0, 'no-var': 2, - 'prefer-const': 2 + 'prefer-const': 2, + 'operator-linebreak': 0, + 'no-confusing-arrow': 0, + 'implicit-arrow-linebreak': 0, + indent: 0, + 'no-param-reassign': 0, + 'function-paren-newline': 0, + 'arrow-parens': 0 }, parserOptions: { parser: 'babel-eslint' diff --git a/package-lock.json b/package-lock.json index 0d6cbed..f8ea95c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2164,13 +2164,13 @@ } }, "eslint": { - "version": "5.16.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-5.16.0.tgz", - "integrity": "sha512-S3Rz11i7c8AA5JPv7xAH+dOyq/Cu/VXHiHXBPOU1k/JAM5dXqQPt3qcrhpHSorXmrpu2g0gkIBVXAqCpzfoZIg==", + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-6.0.0.tgz", + "integrity": "sha512-SrrIfcd4tOgsspOKTSwamuTOAMZOUigHQhVMrzNjz4/B9Za6SHQDIocMIyIDfwDgx6MhS15nS6HC8kumCV2qBQ==", "dev": true, "requires": { "@babel/code-frame": "^7.0.0", - "ajv": "^6.9.1", + "ajv": "^6.10.0", "chalk": "^2.1.0", "cross-spawn": "^6.0.5", "debug": "^4.0.1", @@ -2178,18 +2178,19 @@ "eslint-scope": "^4.0.3", "eslint-utils": "^1.3.1", "eslint-visitor-keys": "^1.0.0", - "espree": "^5.0.1", + "espree": "^6.0.0", "esquery": "^1.0.1", "esutils": "^2.0.2", "file-entry-cache": "^5.0.1", "functional-red-black-tree": "^1.0.1", - "glob": "^7.1.2", + "glob-parent": "^3.1.0", "globals": "^11.7.0", "ignore": "^4.0.6", "import-fresh": "^3.0.0", "imurmurhash": "^0.1.4", "inquirer": "^6.2.2", - "js-yaml": "^3.13.0", + "is-glob": "^4.0.0", + "js-yaml": "^3.13.1", "json-stable-stringify-without-jsonify": "^1.0.1", "levn": "^0.3.0", "lodash": "^4.17.11", @@ -2197,7 +2198,6 @@ "mkdirp": "^0.5.1", "natural-compare": "^1.4.0", "optionator": "^0.8.2", - "path-is-inside": "^1.0.2", "progress": "^2.0.0", "regexpp": "^2.0.1", "semver": "^5.5.1", @@ -2579,9 +2579,9 @@ "dev": true }, "espree": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/espree/-/espree-5.0.1.tgz", - "integrity": "sha512-qWAZcWh4XE/RwzLJejfcofscgMc9CamR6Tn1+XRXNzrvUSSbiAjGOI/fggztjIi7y9VLPqnICMIPiGyr8JaZ0A==", + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/espree/-/espree-6.0.0.tgz", + "integrity": "sha512-lJvCS6YbCn3ImT3yKkPe0+tJ+mH6ljhGNjHQH9mRtiO6gjhVAOhVXW1yjnwqGwTkK3bGbye+hb00nFNmu0l/1Q==", "dev": true, "requires": { "acorn": "^6.0.7", @@ -3055,7 +3055,8 @@ "ansi-regex": { "version": "2.1.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "aproba": { "version": "1.2.0", @@ -3076,12 +3077,14 @@ "balanced-match": { "version": "1.0.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, "dev": true, + "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -3096,17 +3099,20 @@ "code-point-at": { "version": "1.1.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "concat-map": { "version": "0.0.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "console-control-strings": { "version": "1.1.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "core-util-is": { "version": "1.0.2", @@ -3223,7 +3229,8 @@ "inherits": { "version": "2.0.3", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "ini": { "version": "1.3.5", @@ -3235,6 +3242,7 @@ "version": "1.0.0", "bundled": true, "dev": true, + "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -3249,6 +3257,7 @@ "version": "3.0.4", "bundled": true, "dev": true, + "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -3256,12 +3265,14 @@ "minimist": { "version": "0.0.8", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "minipass": { "version": "2.3.5", "bundled": true, "dev": true, + "optional": true, "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" @@ -3280,6 +3291,7 @@ "version": "0.5.1", "bundled": true, "dev": true, + "optional": true, "requires": { "minimist": "0.0.8" } @@ -3360,7 +3372,8 @@ "number-is-nan": { "version": "1.0.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "object-assign": { "version": "4.1.1", @@ -3372,6 +3385,7 @@ "version": "1.4.0", "bundled": true, "dev": true, + "optional": true, "requires": { "wrappy": "1" } @@ -3457,7 +3471,8 @@ "safe-buffer": { "version": "5.1.2", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "safer-buffer": { "version": "2.1.2", @@ -3493,6 +3508,7 @@ "version": "1.0.2", "bundled": true, "dev": true, + "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -3512,6 +3528,7 @@ "version": "3.0.1", "bundled": true, "dev": true, + "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -3555,12 +3572,14 @@ "wrappy": { "version": "1.0.2", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "yallist": { "version": "3.0.3", "bundled": true, - "dev": true + "dev": true, + "optional": true } } }, @@ -5979,12 +5998,6 @@ "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", "dev": true }, - "path-is-inside": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/path-is-inside/-/path-is-inside-1.0.2.tgz", - "integrity": "sha1-NlQX3t5EQw0cEa9hAn+s8HS9/FM=", - "dev": true - }, "path-key": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/path-key/-/path-key-2.0.1.tgz", @@ -7202,9 +7215,9 @@ "dev": true }, "table": { - "version": "5.4.0", - "resolved": "https://registry.npmjs.org/table/-/table-5.4.0.tgz", - "integrity": "sha512-nHFDrxmbrkU7JAFKqKbDJXfzrX2UBsWmrieXFTGxiI5e4ncg3VqsZeI4EzNmX0ncp4XNGVeoxIWJXfCIXwrsvw==", + "version": "5.4.1", + "resolved": "https://registry.npmjs.org/table/-/table-5.4.1.tgz", + "integrity": "sha512-E6CK1/pZe2N75rGZQotFOdmzWQ1AILtgYbMAbAjvms0S1l5IDB47zG3nCnFGB/w+7nB3vKofbLXCH7HPBo864w==", "dev": true, "requires": { "ajv": "^6.9.1", diff --git a/package.json b/package.json index 3b01b90..aa56091 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "devDependencies": { "all-contributors-cli": "^6.7.0", "codecov": "^3.5.0", - "eslint": "^5.3.0", + "eslint": "^6.0.0", "eslint-config-airbnb-base": "^13.1.0", "eslint-plugin-import": "^2.17.3", "jest": "^24.8.0", diff --git a/src/ask-questions.js b/src/ask-questions.js new file mode 100644 index 0000000..34ac114 --- /dev/null +++ b/src/ask-questions.js @@ -0,0 +1,38 @@ +const inquirer = require('inquirer') + +const questionsBuilders = require('./questions') +const utils = require('./utils') + +/** + * Get questions + * + * @param {Object} projectInfos + */ +const getQuestions = projectInfos => + Object.values(questionsBuilders).reduce( + (questions, questionBuilder) => [ + ...questions, + questionBuilder(projectInfos) + ], + [] + ) + +/** + * Ask user questions and return context to generate a README + * + * @param {Object} projectInfos + */ +module.exports = async (projectInfos, skipQuestions) => { + const questions = getQuestions(projectInfos) + + const answersContext = skipQuestions + ? utils.getDefaultAnswers(questions) + : await inquirer.prompt(questions) + + return { + isGithubRepos: projectInfos.isGithubRepos, + repositoryUrl: projectInfos.repositoryUrl, + projectPrerequisites: undefined, + ...answersContext + } +} diff --git a/src/ask-questions.spec.js b/src/ask-questions.spec.js new file mode 100644 index 0000000..8c92796 --- /dev/null +++ b/src/ask-questions.spec.js @@ -0,0 +1,80 @@ +const inquirer = require('inquirer') + +const questions = require('./questions') +const askQuestions = require('./ask-questions') + +inquirer.prompt = jest.fn(items => + Promise.resolve( + items.reduce((result, item) => { + result[item.name] = 'value' + return result + }, {}) + ) +) + +jest.mock('./questions', () => ({ + askProjectName: jest.fn(() => ({ + name: 'projectName', + type: 'input', + default: 'defaultProjectName' + })), + askProjectVersion: jest.fn(() => ({ + name: 'projectVersion', + type: 'input' + })), + askProjectDescription: jest.fn(() => ({ + name: 'projectDescription', + type: 'checkbox', + choices: [ + { value: { name: 'choiceOne', value: 1 }, checked: true }, + { value: { name: 'choiceTwo', value: 2 }, checked: false } + ] + })) +})) + +describe('ask-questions', () => { + beforeEach(() => { + inquirer.prompt.mockClear() + }) + + it('should call all builder functions exported by questions', async () => { + const projectInfos = { name: 'readme-md-generator' } + + await askQuestions(projectInfos) + + expect(questions.askProjectName).toHaveBeenCalledTimes(1) + expect(questions.askProjectVersion).toHaveBeenCalledTimes(1) + expect(questions.askProjectDescription).toHaveBeenCalledTimes(1) + }) + + it('should use default values with --yes option', async () => { + const projectInfos = { name: 'readme-md-generator' } + + const result = await askQuestions(projectInfos, true) + + expect(inquirer.prompt).not.toHaveBeenCalled() + expect(result).toEqual({ + projectName: 'defaultProjectName', + projectVersion: '', + projectDescription: [{ name: 'choiceOne', value: 1 }], + isGithubRepos: undefined, + repositoryUrl: undefined, + projectPrerequisites: undefined + }) + }) + + it('should return merged contexts', async () => { + const projectInfos = { name: 'readme-md-generator' } + + const context = await askQuestions(projectInfos) + + expect(context).toEqual({ + projectName: 'value', + projectVersion: 'value', + projectDescription: 'value', + isGithubRepos: undefined, + repositoryUrl: undefined, + projectPrerequisites: undefined + }) + }) +}) diff --git a/src/cli.js b/src/cli.js index 35b4d0b..cab5ab6 100644 --- a/src/cli.js +++ b/src/cli.js @@ -1,43 +1,8 @@ -const inquirer = require('inquirer') - const readme = require('./readme') const infos = require('./project-infos') -const questionsBuilders = require('./questions') -const utils = require('./utils') -/** - * Get questions - * - * @param {Object} projectInfos - */ -const getQuestions = projectInfos => - Object.values(questionsBuilders).reduce( - (questions, questionBuilder) => [ - ...questions, - questionBuilder(projectInfos) - ], - [] - ) - -/** - * Ask user questions and return context to generate a README - * - * @param {Object} projectInfos - */ -const askQuestions = async (projectInfos, skipQuestions) => { - const questions = getQuestions(projectInfos) - - const answersContext = skipQuestions - ? utils.getDefaultAnswers(questions) - : await inquirer.prompt(questions) - - return { - isGithubRepos: projectInfos.isGithubRepos, - repositoryUrl: projectInfos.repositoryUrl, - projectPrerequisites: undefined, - ...answersContext - } -} +const utils = require('./utils') +const askQuestions = require('./ask-questions') /** * Main process: @@ -48,9 +13,9 @@ const askQuestions = async (projectInfos, skipQuestions) => { * * @param {Object} args */ -const mainProcess = async ({ templatePath, yes }) => { +module.exports = async ({ templatePath, yes }) => { const projectInformations = await infos.getProjectInfos() - const answersContext = await cli.askQuestions(projectInformations, yes) + const answersContext = await askQuestions(projectInformations, yes) const readmeContent = await readme.buildReadmeContent( answersContext, templatePath @@ -60,10 +25,3 @@ const mainProcess = async ({ templatePath, yes }) => { utils.showEndMessage() } - -const cli = { - mainProcess, - askQuestions -} - -module.exports = cli diff --git a/src/cli.spec.js b/src/cli.spec.js index d61e4e6..dcd532f 100644 --- a/src/cli.spec.js +++ b/src/cli.spec.js @@ -1,21 +1,23 @@ const inquirer = require('inquirer') -const cli = require('./cli') -const projectInfos = require('./project-infos') +const mainProcess = require('./cli') +const infos = require('./project-infos') const readme = require('./readme') const utils = require('./utils') -const questions = require('./questions') +const askQuestions = require('./ask-questions') -const realAskQuestions = cli.askQuestions - -inquirer.prompt = jest.fn(questions => +inquirer.prompt = jest.fn(items => Promise.resolve( - questions.reduce((result, question) => { - result[question.name] = 'value' + items.reduce((result, item) => { + result[item.name] = 'value' return result }, {}) ) ) +jest.mock('./ask-questions', () => + jest.fn(() => Promise.resolve({ projectName: 'readme-md-generator' })) +) + jest.mock('./questions', () => ({ askProjectName: jest.fn(() => ({ name: 'projectName', @@ -36,110 +38,49 @@ jest.mock('./questions', () => ({ })) })) -describe('cli', () => { - beforeEach(() => { - inquirer.prompt.mockClear() +describe('mainProcess', () => { + afterEach(() => { + askQuestions.mockClear() }) - describe('mainProcess', () => { - const answersContext = { projectName: 'readme-md-generator' } - - beforeAll(() => { - cli.askQuestions = jest.fn(() => Promise.resolve(answersContext)) - }) - - afterEach(() => { - cli.askQuestions.mockClear() - }) - - afterAll(() => { - cli.askQuestions = realAskQuestions - }) - - it('should call main functions with correct args', async () => { - const templatePath = 'default' - const projectInformations = { name: 'readme-md-generator' } - const readmeContent = 'content' - projectInfos.getProjectInfos = jest.fn(() => - Promise.resolve(projectInformations) - ) - readme.buildReadmeContent = jest.fn(() => Promise.resolve(readmeContent)) - readme.writeReadme = jest.fn() - utils.showEndMessage = jest.fn() - - await cli.mainProcess({ templatePath }) - - expect(projectInfos.getProjectInfos).toHaveBeenCalledTimes(1) - expect(cli.askQuestions).toHaveBeenNthCalledWith( - 1, - projectInformations, - undefined - ) - expect(readme.buildReadmeContent).toHaveBeenNthCalledWith( - 1, - answersContext, - templatePath - ) - expect(readme.writeReadme).toHaveBeenNthCalledWith(1, readmeContent) - expect(utils.showEndMessage).toHaveBeenCalledTimes(1) - }) - - it('should forward --yes option to askQuestions', async () => { - const templatePath = 'default' - const projectInformations = { name: 'readme-md-generator' } - const skipQuestions = true - utils.showEndMessage = jest.fn() - - await cli.mainProcess({ templatePath, yes: skipQuestions }) - - expect(cli.askQuestions).toHaveBeenNthCalledWith( - 1, - projectInformations, - skipQuestions - ) - }) + it('should call main functions with correct args', async () => { + const templatePath = 'default' + const projectInformations = { name: 'readme-md-generator' } + const readmeContent = 'content' + infos.getProjectInfos = jest.fn(() => Promise.resolve(projectInformations)) + readme.buildReadmeContent = jest.fn(() => Promise.resolve(readmeContent)) + readme.writeReadme = jest.fn() + utils.showEndMessage = jest.fn() + + await mainProcess({ templatePath }) + + expect(infos.getProjectInfos).toHaveBeenCalledTimes(1) + expect(askQuestions).toHaveBeenNthCalledWith( + 1, + projectInformations, + undefined + ) + expect(readme.buildReadmeContent).toHaveBeenNthCalledWith( + 1, + { projectName: 'readme-md-generator' }, + templatePath + ) + expect(readme.writeReadme).toHaveBeenNthCalledWith(1, readmeContent) + expect(utils.showEndMessage).toHaveBeenCalledTimes(1) }) - describe('askQuestions', () => { - it('should call all builder functions exported by questions', async () => { - const projectInfos = { name: 'readme-md-generator' } - - await cli.askQuestions(projectInfos) - - expect(questions.askProjectName).toHaveBeenCalledTimes(1) - expect(questions.askProjectVersion).toHaveBeenCalledTimes(1) - expect(questions.askProjectDescription).toHaveBeenCalledTimes(1) - }) - - it('should use default values with --yes option', async () => { - const projectInfos = { name: 'readme-md-generator' } - - const result = await cli.askQuestions(projectInfos, true) - - expect(inquirer.prompt).not.toHaveBeenCalled() - expect(result).toEqual({ - projectName: 'defaultProjectName', - projectVersion: '', - projectDescription: [{ name: 'choiceOne', value: 1 }], - isGithubRepos: undefined, - repositoryUrl: undefined, - projectPrerequisites: undefined - }) - }) - - it('should return merged contexts', async () => { - const projectInfos = { name: 'readme-md-generator' } + it('should forward --yes option to askQuestions', async () => { + const template = 'default' + const projectInformations = { name: 'readme-md-generator' } + const skipQuestions = true + utils.showEndMessage = jest.fn() - const context = await cli.askQuestions(projectInfos) + await mainProcess({ template, yes: skipQuestions }) - expect(context).toEqual({ - projectName: 'value', - projectVersion: 'value', - projectDescription: 'value', - isGithubRepos: undefined, - repositoryUrl: undefined, - projectPrerequisites: undefined - }) - }) + expect(askQuestions).toHaveBeenNthCalledWith( + 1, + projectInformations, + skipQuestions + ) }) }) diff --git a/src/index.js b/src/index.js index 2424d61..f7afa51 100755 --- a/src/index.js +++ b/src/index.js @@ -2,7 +2,7 @@ const yargs = require('yargs') -const { mainProcess } = require('./cli') +const mainProcess = require('./cli') const { getReadmeTemplatePath } = require('./readme') yargs diff --git a/src/project-infos.js b/src/project-infos.js index c5234f4..b0809f7 100644 --- a/src/project-infos.js +++ b/src/project-infos.js @@ -102,8 +102,15 @@ const getReadmeUrlFromGithubRepositoryUrl = repositoryUrl => * @returns {string} authorName */ const getAuthorName = packageJson => { - const pathToProp = has(packageJson, 'author.name') ? 'author.name' : 'author' - return get(packageJson, pathToProp, undefined) + if (has(packageJson, 'author.name')) { + return get(packageJson, 'author.name', undefined) + } + + if (has(packageJson, 'author') && typeof packageJson.author === 'string') { + return get(packageJson, 'author', undefined) + } + + return undefined } /** diff --git a/src/questions/index.js b/src/questions/index.js index 15077c3..bae2705 100644 --- a/src/questions/index.js +++ b/src/questions/index.js @@ -1,3 +1,4 @@ +/* eslint-disable global-require */ module.exports = { askProjectName: require('./project-name'), askProjectVersion: require('./project-version'), diff --git a/src/readme.spec.js b/src/readme.spec.js index eda8145..871bbf5 100644 --- a/src/readme.spec.js +++ b/src/readme.spec.js @@ -29,7 +29,7 @@ describe('readme', () => { describe('writeReadme', () => { it('should call ora with correct parameters in success case', async () => { const readmeContent = 'content' - fs.writeFile = jest.fn((path, content, cb) => cb(null, 'done')) + fs.writeFile = jest.fn((_, __, cb) => cb(null, 'done')) await writeReadme(readmeContent) @@ -58,7 +58,7 @@ describe('readme', () => { it('should call writeFile with correct parameters', async () => { const readmeContent = 'content' - fs.writeFile = jest.fn((path, content, cb) => cb(null, 'done')) + fs.writeFile = jest.fn((_, __, cb) => cb(null, 'done')) await writeReadme(readmeContent) @@ -69,7 +69,7 @@ describe('readme', () => { }) describe('buildReadmeContent', () => { - const templatePath = path.resolve(__dirname, `../templates/default.md`) + const templatePath = path.resolve(__dirname, '../templates/default.md') const context = { isGithubRepos: true, repositoryUrl: 'https://github.com/kefranabg/readme-md-generator', @@ -139,7 +139,7 @@ describe('readme', () => { it('should return default template path if customTemplate is undefined', () => { const args = { template: 'default' } const actualResult = getReadmeTemplatePath(args) - const expectedResult = path.resolve(__dirname, `../templates/default.md`) + const expectedResult = path.resolve(__dirname, '../templates/default.md') expect(actualResult).toEqual(expectedResult) }) @@ -147,7 +147,7 @@ describe('readme', () => { it('should return custom template path if customTemplate is defined', () => { const customTemplatePath = path.resolve( __dirname, - `../templates/default.md` + '../templates/default.md' ) const args = { template: 'default', path: customTemplatePath } const expectedResult = customTemplatePath @@ -180,7 +180,7 @@ describe('readme', () => { it('should call ora with correct parameters in success case', async () => { const args = { template: 'default', - path: path.resolve(__dirname, `../templates/default.md`) + path: path.resolve(__dirname, '../templates/default.md') } try { diff --git a/src/utils.js b/src/utils.js index da06ec3..967feff 100644 --- a/src/utils.js +++ b/src/utils.js @@ -24,10 +24,7 @@ const showEndMessage = () => process.stdout.write(boxen(END_MSG, BOXEN_CONFIG)) * * @param {Object} packageJson */ -const getPackageJsonName = (packageJson = {}) => { - return packageJson.name || undefined -} - +const getPackageJsonName = (packageJson = {}) => packageJson.name || undefined /** * Get git repository name * @@ -65,20 +62,6 @@ const getPackageJson = async () => { } } -/** - * Get default question's answers - * - * @param {Array} questions - */ -const getDefaultAnswers = questions => - questions.reduce( - (answersContext, question) => ({ - ...answersContext, - [question.name]: getDefaultAnswer(question, answersContext) - }), - {} - ) - /** * Get the default answer depending on the question type * @@ -99,6 +82,20 @@ const getDefaultAnswer = (question, answersContext) => { } } +/** + * Get default question's answers + * + * @param {Array} questions + */ +const getDefaultAnswers = questions => + questions.reduce( + (answersContext, question) => ({ + ...answersContext, + [question.name]: getDefaultAnswer(question, answersContext) + }), + {} + ) + module.exports = { getPackageJson, showEndMessage,