From cb64f5f05933ce396debb735889ccf2bd6e30023 Mon Sep 17 00:00:00 2001 From: Matt Travi Date: Sun, 16 Aug 2026 00:06:32 -0400 Subject: [PATCH] fix(prompts): rename BASE_DETAILS prompt ID to JAVASCRIPT_BASE_DETAILS `@form8ion/project` already uses the literal prompt ID `BASE_DETAILS` for its own base-details prompt. Any consumer composing this package's scaffolder with `@form8ion/project`'s (as `@form8ion/eslint-config-extender` does) shares a single `dependencies.prompt` function across both -- one wrapped to answer `@form8ion/project`'s own prompts, another (baked into this package's plugin) wrapped to answer this package's prompts and delegate the remainder back to the same base `dependencies.prompt`. Both delegation paths land on the identical function, which then gets called twice with `id === 'BASE_DETAILS'` -- once for project's fields (name/description/visibility/license) and once for this package's remaining fields (author/scope/package-manager/dialect) -- with genuinely different `questions` payloads a caller can't distinguish by ID alone. `@form8ion/project`'s `BASE_DETAILS` is the more foundational, language-agnostic prompt, used by every project type regardless of language. This package's own base-details prompt is javascript-specific, so it renames instead: `BASE_DETAILS` -> `JAVASCRIPT_BASE_DETAILS`, matching the same direction as `MONOREPO_DETAILS` -> `PACKAGE_DETAILS` in `@form8ion/add-package-to-monorepo` for the same naming-specificity concern. BREAKING CHANGE: the `BASE_DETAILS` prompt ID (and matching `questionNames` group key) is renamed to `JAVASCRIPT_BASE_DETAILS`. Callers providing a `prompt` dependency that switches on `promptConstants.ids.BASE_DETAILS` need to switch on `promptConstants.ids.JAVASCRIPT_BASE_DETAILS` instead, and read question names from `promptConstants.questionNames.JAVASCRIPT_BASE_DETAILS`. Co-Authored-By: Claude Sonnet 5 --- README.md | 2 +- example.js | 2 +- src/prompts/conditionals.js | 14 ++-- src/prompts/conditionals.test.js | 56 ++++++++------- src/prompts/index.js | 4 +- src/prompts/index.test.js | 4 +- src/prompts/question-names.js | 2 +- src/prompts/question-names.test.js | 2 +- src/prompts/questions.js | 6 +- src/prompts/questions.test.js | 71 ++++++++++--------- .../features/step_definitions/common-steps.js | 4 +- 11 files changed, 85 insertions(+), 82 deletions(-) diff --git a/README.md b/README.md index 9c48a3c0..6f00da05 100644 --- a/README.md +++ b/README.md @@ -102,7 +102,7 @@ await scaffoldJavaScript( logger, prompt: ({id}) => { const {questionNames, ids} = promptConstants; - const {BASE_DETAILS: baseDetailsPromptId} = ids; + const {JAVASCRIPT_BASE_DETAILS: baseDetailsPromptId} = ids; switch (id) { case baseDetailsPromptId: { diff --git a/example.js b/example.js index 308177c0..65b76a51 100644 --- a/example.js +++ b/example.js @@ -68,7 +68,7 @@ await scaffoldJavaScript( logger, prompt: ({id}) => { const {questionNames, ids} = promptConstants; - const {BASE_DETAILS: baseDetailsPromptId} = ids; + const {JAVASCRIPT_BASE_DETAILS: baseDetailsPromptId} = ids; switch (id) { case baseDetailsPromptId: { diff --git a/src/prompts/conditionals.js b/src/prompts/conditionals.js index cf3ed537..321d1bca 100644 --- a/src/prompts/conditionals.js +++ b/src/prompts/conditionals.js @@ -2,22 +2,22 @@ import {projectTypes} from '@form8ion/javascript-core'; import {questionNames} from './question-names.js'; -const {BASE_DETAILS} = questionNames; +const {JAVASCRIPT_BASE_DETAILS} = questionNames; function projectIsCLI(answers) { - return projectTypes.CLI === answers[BASE_DETAILS.PROJECT_TYPE]; + return projectTypes.CLI === answers[JAVASCRIPT_BASE_DETAILS.PROJECT_TYPE]; } export function projectIsPackage(answers) { - return projectTypes.PACKAGE === answers[BASE_DETAILS.PROJECT_TYPE]; + return projectTypes.PACKAGE === answers[JAVASCRIPT_BASE_DETAILS.PROJECT_TYPE]; } export function projectIsApplication(answers) { - return projectTypes.APPLICATION === answers[BASE_DETAILS.PROJECT_TYPE]; + return projectTypes.APPLICATION === answers[JAVASCRIPT_BASE_DETAILS.PROJECT_TYPE]; } function packageShouldBeScoped(visibility, answers) { - return ['ISS', 'CS'].includes(visibility) || answers[BASE_DETAILS.SHOULD_BE_SCOPED]; + return ['ISS', 'CS'].includes(visibility) || answers[JAVASCRIPT_BASE_DETAILS.SHOULD_BE_SCOPED]; } function willBePublishedToRegistry(answers) { @@ -33,8 +33,8 @@ export function scopePromptShouldBePresentedFactory(visibility) { } export function lintingPromptShouldBePresented({ - [BASE_DETAILS.UNIT_TESTS]: unitTested, - [BASE_DETAILS.INTEGRATION_TESTS]: integrationTested + [JAVASCRIPT_BASE_DETAILS.UNIT_TESTS]: unitTested, + [JAVASCRIPT_BASE_DETAILS.INTEGRATION_TESTS]: integrationTested }) { return !unitTested && !integrationTested; } diff --git a/src/prompts/conditionals.test.js b/src/prompts/conditionals.test.js index 3c0f09e2..8dbae0a4 100644 --- a/src/prompts/conditionals.test.js +++ b/src/prompts/conditionals.test.js @@ -11,106 +11,108 @@ import { shouldBeScopedPromptShouldBePresented } from './conditionals.js'; -const {BASE_DETAILS} = questionNames; +const {JAVASCRIPT_BASE_DETAILS} = questionNames; describe('javascript prompt conditionals', () => { describe('scope', () => { it('should present the prompt for whether the package should be scoped for `package` project-types', () => { - expect(shouldBeScopedPromptShouldBePresented({[BASE_DETAILS.PROJECT_TYPE]: projectTypes.PACKAGE})).toBe(true); + expect(shouldBeScopedPromptShouldBePresented({[JAVASCRIPT_BASE_DETAILS.PROJECT_TYPE]: projectTypes.PACKAGE})) + .toBe(true); }); it('should present the prompt for whether the package should be scoped for `cli` project-types', () => { - expect(shouldBeScopedPromptShouldBePresented({[BASE_DETAILS.PROJECT_TYPE]: projectTypes.CLI})).toBe(true); + expect(shouldBeScopedPromptShouldBePresented({[JAVASCRIPT_BASE_DETAILS.PROJECT_TYPE]: projectTypes.CLI})) + .toBe(true); }); it('shouldnt present the prompt for whether the package should be scoped for non-publishable project-types', () => { - expect(shouldBeScopedPromptShouldBePresented({[BASE_DETAILS.PROJECT_TYPE]: any.string()})).toBe(false); + expect(shouldBeScopedPromptShouldBePresented({[JAVASCRIPT_BASE_DETAILS.PROJECT_TYPE]: any.string()})).toBe(false); }); it('should present a scope prompt when a package should be scoped', () => { expect(scopePromptShouldBePresentedFactory()({ - [BASE_DETAILS.SHOULD_BE_SCOPED]: true, - [BASE_DETAILS.PROJECT_TYPE]: projectTypes.PACKAGE + [JAVASCRIPT_BASE_DETAILS.SHOULD_BE_SCOPED]: true, + [JAVASCRIPT_BASE_DETAILS.PROJECT_TYPE]: projectTypes.PACKAGE })).toBe(true); }); it('should present a scope prompt when a package is inner source, because they must be scoped', () => { expect(scopePromptShouldBePresentedFactory('ISS')({ - [BASE_DETAILS.SHOULD_BE_SCOPED]: false, - [BASE_DETAILS.PROJECT_TYPE]: projectTypes.PACKAGE + [JAVASCRIPT_BASE_DETAILS.SHOULD_BE_SCOPED]: false, + [JAVASCRIPT_BASE_DETAILS.PROJECT_TYPE]: projectTypes.PACKAGE })).toBe(true); }); it('should present a scope prompt when a package is closed source, because they must be scoped', () => { expect(scopePromptShouldBePresentedFactory('CS')({ - [BASE_DETAILS.SHOULD_BE_SCOPED]: false, - [BASE_DETAILS.PROJECT_TYPE]: projectTypes.PACKAGE + [JAVASCRIPT_BASE_DETAILS.SHOULD_BE_SCOPED]: false, + [JAVASCRIPT_BASE_DETAILS.PROJECT_TYPE]: projectTypes.PACKAGE })).toBe(true); }); it('should present a scope prompt when a CLI should be scoped', () => { expect(scopePromptShouldBePresentedFactory()({ - [BASE_DETAILS.SHOULD_BE_SCOPED]: true, - [BASE_DETAILS.PROJECT_TYPE]: projectTypes.CLI + [JAVASCRIPT_BASE_DETAILS.SHOULD_BE_SCOPED]: true, + [JAVASCRIPT_BASE_DETAILS.PROJECT_TYPE]: projectTypes.CLI })).toBe(true); }); it('should present a scope prompt when a CLI is closed source, because they must be scoped', () => { expect(scopePromptShouldBePresentedFactory('CS')({ - [BASE_DETAILS.SHOULD_BE_SCOPED]: false, - [BASE_DETAILS.PROJECT_TYPE]: projectTypes.CLI + [JAVASCRIPT_BASE_DETAILS.SHOULD_BE_SCOPED]: false, + [JAVASCRIPT_BASE_DETAILS.PROJECT_TYPE]: projectTypes.CLI })).toBe(true); }); it('should present a scope prompt when a CLI is inner source, because they must be scoped', () => { expect(scopePromptShouldBePresentedFactory('ISS')({ - [BASE_DETAILS.SHOULD_BE_SCOPED]: false, - [BASE_DETAILS.PROJECT_TYPE]: projectTypes.CLI + [JAVASCRIPT_BASE_DETAILS.SHOULD_BE_SCOPED]: false, + [JAVASCRIPT_BASE_DETAILS.PROJECT_TYPE]: projectTypes.CLI })).toBe(true); }); it('should not present a scope prompt when an application is closed source', () => { expect(scopePromptShouldBePresentedFactory('CS')({ - [BASE_DETAILS.SHOULD_BE_SCOPED]: false, - [BASE_DETAILS.PROJECT_TYPE]: projectTypes.APPLICATION + [JAVASCRIPT_BASE_DETAILS.SHOULD_BE_SCOPED]: false, + [JAVASCRIPT_BASE_DETAILS.PROJECT_TYPE]: projectTypes.APPLICATION })).toBe(false); }); it('should not present a scope prompt when an application is inner source', () => { expect(scopePromptShouldBePresentedFactory('ISS')({ - [BASE_DETAILS.SHOULD_BE_SCOPED]: false, - [BASE_DETAILS.PROJECT_TYPE]: projectTypes.APPLICATION + [JAVASCRIPT_BASE_DETAILS.SHOULD_BE_SCOPED]: false, + [JAVASCRIPT_BASE_DETAILS.PROJECT_TYPE]: projectTypes.APPLICATION })).toBe(false); }); it('should not preset a scope prompt for non-publishable projects', () => { - expect(scopePromptShouldBePresentedFactory()({[BASE_DETAILS.SHOULD_BE_SCOPED]: false})).toBe(false); + expect(scopePromptShouldBePresentedFactory()({[JAVASCRIPT_BASE_DETAILS.SHOULD_BE_SCOPED]: false})).toBe(false); }); }); describe('application', () => { it('should return `true` when the package-type is `Application`', () => { - expect(projectIsApplication({[BASE_DETAILS.PROJECT_TYPE]: projectTypes.APPLICATION})).toBe(true); + expect(projectIsApplication({[JAVASCRIPT_BASE_DETAILS.PROJECT_TYPE]: projectTypes.APPLICATION})).toBe(true); }); it('should return `false` when the project-type is not an application', () => { - expect(projectIsApplication({[BASE_DETAILS.PROJECT_TYPE]: any.word()})).toBe(false); + expect(projectIsApplication({[JAVASCRIPT_BASE_DETAILS.PROJECT_TYPE]: any.word()})).toBe(false); }); }); describe('transpilation/linting', () => { it('should not show the prompt if the project is unit tested ', () => { - expect(lintingPromptShouldBePresented({[BASE_DETAILS.UNIT_TESTS]: true})).toBe(false); + expect(lintingPromptShouldBePresented({[JAVASCRIPT_BASE_DETAILS.UNIT_TESTS]: true})).toBe(false); }); it('should not show the prompt if the project is integration tested', () => { - expect(lintingPromptShouldBePresented({[BASE_DETAILS.INTEGRATION_TESTS]: true})).toBe(false); + expect(lintingPromptShouldBePresented({[JAVASCRIPT_BASE_DETAILS.INTEGRATION_TESTS]: true})).toBe(false); }); it('should show the prompt if the project is not tested', () => { expect(lintingPromptShouldBePresented({ - [BASE_DETAILS.INTEGRATION_TESTS]: false, - [BASE_DETAILS.UNIT_TESTS]: false + [JAVASCRIPT_BASE_DETAILS.INTEGRATION_TESTS]: false, + [JAVASCRIPT_BASE_DETAILS.UNIT_TESTS]: false })).toBe(true); }); }); diff --git a/src/prompts/index.js b/src/prompts/index.js index 3091b5b5..2b432ba5 100644 --- a/src/prompts/index.js +++ b/src/prompts/index.js @@ -2,11 +2,11 @@ import {PROJECT_TYPE_PLUGIN_PROMPT_ID} from '../project-type-plugin/prompt.js'; import {PACKAGE_BUNDLER_PROMPT_ID} from '../project-type/publishable/bundler/prompt.js'; import {UNIT_TESTING_PROMPT_ID} from '../testing/unit/prompt.js'; import {INTEGRATION_TESTING_PROMPT_ID} from '../testing/integration/prompt.js'; -import {BASE_DETAILS_PROMPT_ID} from './questions.js'; +import {JAVASCRIPT_BASE_DETAILS_PROMPT_ID} from './questions.js'; import {questionNames} from './question-names.js'; export const ids = { - BASE_DETAILS: BASE_DETAILS_PROMPT_ID, + JAVASCRIPT_BASE_DETAILS: JAVASCRIPT_BASE_DETAILS_PROMPT_ID, PROJECT_TYPE_PLUGIN: PROJECT_TYPE_PLUGIN_PROMPT_ID, PACKAGE_BUNDLER: PACKAGE_BUNDLER_PROMPT_ID, UNIT_TESTING: UNIT_TESTING_PROMPT_ID, diff --git a/src/prompts/index.test.js b/src/prompts/index.test.js index 4b5af608..a612e1ea 100644 --- a/src/prompts/index.test.js +++ b/src/prompts/index.test.js @@ -1,6 +1,6 @@ import {describe, expect, it} from 'vitest'; -import {BASE_DETAILS_PROMPT_ID} from './questions.js'; +import {JAVASCRIPT_BASE_DETAILS_PROMPT_ID} from './questions.js'; import {PROJECT_TYPE_PLUGIN_PROMPT_ID} from '../project-type-plugin/prompt.js'; import {PACKAGE_BUNDLER_PROMPT_ID} from '../project-type/publishable/bundler/prompt.js'; import {UNIT_TESTING_PROMPT_ID} from '../testing/unit/prompt.js'; @@ -10,7 +10,7 @@ import {constants, ids, questionNames} from './index.js'; describe('prompt constants', () => { it('should aggregate the prompt ids and grouped question names', () => { expect(ids).toEqual({ - BASE_DETAILS: BASE_DETAILS_PROMPT_ID, + JAVASCRIPT_BASE_DETAILS: JAVASCRIPT_BASE_DETAILS_PROMPT_ID, PROJECT_TYPE_PLUGIN: PROJECT_TYPE_PLUGIN_PROMPT_ID, PACKAGE_BUNDLER: PACKAGE_BUNDLER_PROMPT_ID, UNIT_TESTING: UNIT_TESTING_PROMPT_ID, diff --git a/src/prompts/question-names.js b/src/prompts/question-names.js index cab0b933..4203ce08 100644 --- a/src/prompts/question-names.js +++ b/src/prompts/question-names.js @@ -1,5 +1,5 @@ export const questionNames = { - BASE_DETAILS: { + JAVASCRIPT_BASE_DETAILS: { UNIT_TESTS: 'unitTests', INTEGRATION_TESTS: 'integrationTests', NODE_VERSION_CATEGORY: 'nodeVersionCategory', diff --git a/src/prompts/question-names.test.js b/src/prompts/question-names.test.js index 5b459973..2a7be073 100644 --- a/src/prompts/question-names.test.js +++ b/src/prompts/question-names.test.js @@ -5,7 +5,7 @@ import {questionNames} from './question-names.js'; describe('question names', () => { it('should group question names by prompt area', () => { expect(questionNames).toEqual({ - BASE_DETAILS: { + JAVASCRIPT_BASE_DETAILS: { UNIT_TESTS: 'unitTests', INTEGRATION_TESTS: 'integrationTests', NODE_VERSION_CATEGORY: 'nodeVersionCategory', diff --git a/src/prompts/questions.js b/src/prompts/questions.js index b2e9cdce..04142ec7 100644 --- a/src/prompts/questions.js +++ b/src/prompts/questions.js @@ -13,7 +13,7 @@ import { import {questionNames} from './question-names.js'; import {scope as validateScope} from './validators.js'; -export const BASE_DETAILS_PROMPT_ID = 'BASE_DETAILS'; +export const JAVASCRIPT_BASE_DETAILS_PROMPT_ID = 'JAVASCRIPT_BASE_DETAILS'; const { AUTHOR_NAME, @@ -30,7 +30,7 @@ const { CONFIGURE_LINTING, PACKAGE_MANAGER, DIALECT -} = questionNames[BASE_DETAILS_PROMPT_ID]; +} = questionNames[JAVASCRIPT_BASE_DETAILS_PROMPT_ID]; function authorQuestions({name, email, url}) { return [ @@ -85,7 +85,7 @@ export async function gatherBaseDetailsInput( [PACKAGE_MANAGER]: packageManager, [DIALECT]: dialect } = await prompt({ - id: BASE_DETAILS_PROMPT_ID, + id: JAVASCRIPT_BASE_DETAILS_PROMPT_ID, questions: [ { name: DIALECT, diff --git a/src/prompts/questions.test.js b/src/prompts/questions.test.js index 5fa541f5..903b816d 100644 --- a/src/prompts/questions.test.js +++ b/src/prompts/questions.test.js @@ -9,10 +9,10 @@ import npmConfFactory from '../../thirdparty-wrappers/npm-conf.js'; import buildDialectChoices from '../dialects/prompt-choices.js'; import {questionNames} from './question-names.js'; import * as conditionals from './conditionals.js'; -import {gatherBaseDetailsInput, BASE_DETAILS_PROMPT_ID} from './questions.js'; +import {gatherBaseDetailsInput, JAVASCRIPT_BASE_DETAILS_PROMPT_ID} from './questions.js'; import * as validators from './validators.js'; -const {BASE_DETAILS} = questionNames; +const {JAVASCRIPT_BASE_DETAILS} = questionNames; vi.mock('execa'); vi.mock('../../thirdparty-wrappers/npm-conf.js'); @@ -40,19 +40,19 @@ describe('prompts', () => { const scope = any.word(); const provideExample = any.boolean(); const answers = { - [BASE_DETAILS.UNIT_TESTS]: unitTested, - [BASE_DETAILS.INTEGRATION_TESTS]: integrationTested, - [BASE_DETAILS.PROJECT_TYPE]: projectType, + [JAVASCRIPT_BASE_DETAILS.UNIT_TESTS]: unitTested, + [JAVASCRIPT_BASE_DETAILS.INTEGRATION_TESTS]: integrationTested, + [JAVASCRIPT_BASE_DETAILS.PROJECT_TYPE]: projectType, [ci]: ci, - [BASE_DETAILS.HOST]: chosenHost, - [BASE_DETAILS.SCOPE]: scope, - [BASE_DETAILS.NODE_VERSION_CATEGORY]: nodeVersionCategory, - [BASE_DETAILS.AUTHOR_NAME]: authorName, - [BASE_DETAILS.AUTHOR_EMAIL]: authorEmail, - [BASE_DETAILS.AUTHOR_URL]: authorUrl, - [BASE_DETAILS.PACKAGE_MANAGER]: packageManager, - [BASE_DETAILS.DIALECT]: dialect, - [BASE_DETAILS.PROVIDE_EXAMPLE]: provideExample + [JAVASCRIPT_BASE_DETAILS.HOST]: chosenHost, + [JAVASCRIPT_BASE_DETAILS.SCOPE]: scope, + [JAVASCRIPT_BASE_DETAILS.NODE_VERSION_CATEGORY]: nodeVersionCategory, + [JAVASCRIPT_BASE_DETAILS.AUTHOR_NAME]: authorName, + [JAVASCRIPT_BASE_DETAILS.AUTHOR_EMAIL]: authorEmail, + [JAVASCRIPT_BASE_DETAILS.AUTHOR_URL]: authorUrl, + [JAVASCRIPT_BASE_DETAILS.PACKAGE_MANAGER]: packageManager, + [JAVASCRIPT_BASE_DETAILS.DIALECT]: dialect, + [JAVASCRIPT_BASE_DETAILS.PROVIDE_EXAMPLE]: provideExample }; const logger = {info: () => undefined, warn: () => undefined}; @@ -77,91 +77,91 @@ describe('prompts', () => { when(buildDialectChoices).calledWith(configs).thenReturn(dialects); when(prompt) .calledWith({ - id: BASE_DETAILS_PROMPT_ID, + id: JAVASCRIPT_BASE_DETAILS_PROMPT_ID, questions: [ { - name: BASE_DETAILS.DIALECT, + name: JAVASCRIPT_BASE_DETAILS.DIALECT, message: 'Which JavaScript dialect should this project follow?', type: 'list', choices: dialects, default: 'babel' }, { - name: BASE_DETAILS.NODE_VERSION_CATEGORY, + name: JAVASCRIPT_BASE_DETAILS.NODE_VERSION_CATEGORY, message: 'What node.js version should be used?', type: 'list', choices: ['LTS', 'Latest'], default: 'LTS' }, { - name: BASE_DETAILS.PACKAGE_MANAGER, + name: JAVASCRIPT_BASE_DETAILS.PACKAGE_MANAGER, message: 'Which package manager will be used with this project?', type: 'list', choices: Object.values(packageManagers), default: packageManagers.NPM }, { - name: BASE_DETAILS.PROJECT_TYPE, + name: JAVASCRIPT_BASE_DETAILS.PROJECT_TYPE, message: 'What type of JavaScript project is this?', type: 'list', choices: [...Object.values(projectTypes), 'Other'], default: projectTypes.PACKAGE }, { - name: BASE_DETAILS.SHOULD_BE_SCOPED, + name: JAVASCRIPT_BASE_DETAILS.SHOULD_BE_SCOPED, message: 'Should this package be scoped?', type: 'confirm', when: conditionals.shouldBeScopedPromptShouldBePresented, default: true }, { - name: BASE_DETAILS.SCOPE, + name: JAVASCRIPT_BASE_DETAILS.SCOPE, message: 'What is the scope?', when: scopePromptShouldBePresented, validate: scopeValidator, default: npmUser }, { - name: BASE_DETAILS.AUTHOR_NAME, + name: JAVASCRIPT_BASE_DETAILS.AUTHOR_NAME, message: 'What is the author\'s name?', default: authorName }, { - name: BASE_DETAILS.AUTHOR_EMAIL, + name: JAVASCRIPT_BASE_DETAILS.AUTHOR_EMAIL, message: 'What is the author\'s email?', default: authorEmail }, { - name: BASE_DETAILS.AUTHOR_URL, + name: JAVASCRIPT_BASE_DETAILS.AUTHOR_URL, message: 'What is the author\'s website url?', default: authorUrl }, { - name: BASE_DETAILS.UNIT_TESTS, + name: JAVASCRIPT_BASE_DETAILS.UNIT_TESTS, message: 'Will this project be unit tested?', type: 'confirm', default: true }, { - name: BASE_DETAILS.INTEGRATION_TESTS, + name: JAVASCRIPT_BASE_DETAILS.INTEGRATION_TESTS, message: 'Will this project be integration tested?', type: 'confirm', default: true }, { - name: BASE_DETAILS.CONFIGURE_LINTING, + name: JAVASCRIPT_BASE_DETAILS.CONFIGURE_LINTING, message: 'Will there be source code that should be linted?', type: 'confirm', when: conditionals.lintingPromptShouldBePresented }, { - name: BASE_DETAILS.PROVIDE_EXAMPLE, + name: JAVASCRIPT_BASE_DETAILS.PROVIDE_EXAMPLE, message: 'Should an example be provided in the README?', type: 'confirm', when: conditionals.projectIsPackage }, { - name: BASE_DETAILS.HOST, + name: JAVASCRIPT_BASE_DETAILS.HOST, type: 'list', message: 'Where will the application be hosted?', when: conditionals.projectIsApplication, @@ -169,7 +169,7 @@ describe('prompts', () => { } ] }) - .thenResolve({...answers, [BASE_DETAILS.CONFIGURE_LINTING]: any.word()}); + .thenResolve({...answers, [JAVASCRIPT_BASE_DETAILS.CONFIGURE_LINTING]: any.word()}); expect(await gatherBaseDetailsInput(hosts, visibility, vcs, configs, undefined, {logger, prompt})).toEqual({ tests, @@ -191,7 +191,7 @@ describe('prompts', () => { const get = vi.fn(); npmConfFactory.mockReturnValue({get}); when(execa).calledWith('npm', ['whoami']).thenResolve({stdout: npmUser}); - prompt.mockResolvedValue({...answers, [BASE_DETAILS.CONFIGURE_LINTING]: false}); + prompt.mockResolvedValue({...answers, [JAVASCRIPT_BASE_DETAILS.CONFIGURE_LINTING]: false}); expect(await gatherBaseDetailsInput({}, visibility, vcs, undefined, undefined, {logger, prompt})).toEqual({ tests, @@ -216,7 +216,8 @@ describe('prompts', () => { await gatherBaseDetailsInput({}, 'CS', vcs, null, pathWithinParent, {logger, prompt}); const {questions} = prompt.mock.lastCall[0]; - expect(questions.filter(question => BASE_DETAILS.NODE_VERSION_CATEGORY === question.name).length).toEqual(0); + expect(questions.filter(question => JAVASCRIPT_BASE_DETAILS.NODE_VERSION_CATEGORY === question.name).length) + .toEqual(0); }); it('should not ask whether closed source packages should be scoped', async () => { @@ -228,7 +229,7 @@ describe('prompts', () => { await gatherBaseDetailsInput({}, 'CS', vcs, null, pathWithinParent, {logger, prompt}); const {questions} = prompt.mock.lastCall[0]; - expect(questions.filter(question => BASE_DETAILS.SHOULD_BE_SCOPED === question.name).length).toEqual(0); + expect(questions.filter(question => JAVASCRIPT_BASE_DETAILS.SHOULD_BE_SCOPED === question.name).length).toEqual(0); }); it('should not ask whether inner source packages should be scoped', async () => { @@ -240,7 +241,7 @@ describe('prompts', () => { await gatherBaseDetailsInput({}, 'ISS', vcs, null, pathWithinParent, {logger, prompt}); const {questions} = prompt.mock.lastCall[0]; - expect(questions.filter(question => BASE_DETAILS.SHOULD_BE_SCOPED === question.name).length).toEqual(0); + expect(questions.filter(question => JAVASCRIPT_BASE_DETAILS.SHOULD_BE_SCOPED === question.name).length).toEqual(0); }); it('should handle a non-logged-in user gracefully', async () => { @@ -252,6 +253,6 @@ describe('prompts', () => { await gatherBaseDetailsInput({}, 'OSS', vcs, null, pathWithinParent, {logger, prompt}); const {questions} = prompt.mock.lastCall[0]; - expect(questions.filter(question => BASE_DETAILS.SHOULD_BE_SCOPED === question.name).length).toEqual(1); + expect(questions.filter(question => JAVASCRIPT_BASE_DETAILS.SHOULD_BE_SCOPED === question.name).length).toEqual(1); }); }); diff --git a/test/integration/features/step_definitions/common-steps.js b/test/integration/features/step_definitions/common-steps.js index 17d3eaec..d160578b 100644 --- a/test/integration/features/step_definitions/common-steps.js +++ b/test/integration/features/step_definitions/common-steps.js @@ -160,7 +160,7 @@ When(/^the project is scaffolded$/, async function () { // eslint-disable-next-line import/no-extraneous-dependencies,import/no-unresolved const {promptConstants: {ids, questionNames}} = await import('@form8ion/javascript'); const { - BASE_DETAILS: baseDetailsPromptId, + JAVASCRIPT_BASE_DETAILS: baseDetailsPromptId, UNIT_TESTING: unitTestingPromptId, PROJECT_TYPE_PLUGIN: projectTypePluginPromptId, PACKAGE_BUNDLER: packageBundlerPromptId @@ -183,7 +183,7 @@ When(/^the project is scaffolded$/, async function () { SCOPE, PACKAGE_MANAGER, DIALECT - } = questionNames.BASE_DETAILS; + } = questionNames.JAVASCRIPT_BASE_DETAILS; return { [UNIT_TESTS]: this.unitTestAnswer,