From 0f92d9399b2417be1ff337fc953955eec6e86844 Mon Sep 17 00:00:00 2001 From: Matt Travi Date: Thu, 25 Jul 2024 10:35:26 -0500 Subject: [PATCH] fix(plugins): actually call the proper scaffold function from the dependency-updater plugin --- src/dependency-updater/scaffolder.js | 10 +++++----- src/dependency-updater/scaffolder.test.js | 6 +++--- .../features/step_definitions/common-steps.js | 6 +++--- .../step_definitions/dependency-updater-steps.js | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/dependency-updater/scaffolder.js b/src/dependency-updater/scaffolder.js index 78fded2d..da03aeb4 100644 --- a/src/dependency-updater/scaffolder.js +++ b/src/dependency-updater/scaffolder.js @@ -1,14 +1,14 @@ import {questionNames} from '../prompts/question-names.js'; import {promptForDependencyUpdaterChoice} from './prompt.js'; -export default async function (scaffolders, decisions, options) { - if (!Object.keys(scaffolders).length) return undefined; +export default async function (plugins, decisions, options) { + if (!Object.keys(plugins).length) return undefined; - const scaffolderDetails = scaffolders[ - (await promptForDependencyUpdaterChoice(scaffolders, decisions))[questionNames.DEPENDENCY_UPDATER] + const plugin = plugins[ + (await promptForDependencyUpdaterChoice(plugins, decisions))[questionNames.DEPENDENCY_UPDATER] ]; - if (scaffolderDetails) return scaffolderDetails.scaffolder(options); + if (plugin) return plugin.scaffold(options); return undefined; } diff --git a/src/dependency-updater/scaffolder.test.js b/src/dependency-updater/scaffolder.test.js index 4d47cea7..cbbed534 100644 --- a/src/dependency-updater/scaffolder.test.js +++ b/src/dependency-updater/scaffolder.test.js @@ -19,14 +19,14 @@ describe('dependency-updater scaffolder', () => { const options = any.simpleObject(); const chosenUpdater = any.word(); const chosenUpdaterScaffolder = vi.fn(); - const scaffolders = {...any.simpleObject(), [chosenUpdater]: {scaffolder: chosenUpdaterScaffolder}}; + const plugins = {...any.simpleObject(), [chosenUpdater]: {scaffold: chosenUpdaterScaffolder}}; const scaffolderResult = any.simpleObject(); when(prompt.promptForDependencyUpdaterChoice) - .calledWith(scaffolders, decisions) + .calledWith(plugins, decisions) .mockResolvedValue({[questionNames.DEPENDENCY_UPDATER]: chosenUpdater}); when(chosenUpdaterScaffolder).calledWith(options).mockResolvedValue(scaffolderResult); - expect(await scaffoldUpdater(scaffolders, decisions, options)).toEqual(scaffolderResult); + expect(await scaffoldUpdater(plugins, decisions, options)).toEqual(scaffolderResult); }); it('should not present a prompt if no updaters are registered', async () => { diff --git a/test/integration/features/step_definitions/common-steps.js b/test/integration/features/step_definitions/common-steps.js index 07476f44..56c49bd6 100644 --- a/test/integration/features/step_definitions/common-steps.js +++ b/test/integration/features/step_definitions/common-steps.js @@ -54,9 +54,9 @@ When(/^the project is scaffolded$/, async function () { await scaffold({ plugins: { - ...this.updaterScaffolderDetails && { + ...this.updatePlugin && { dependencyUpdaters: { - [chosenUpdater]: {...this.updaterScaffolderDetails, scaffold: this.updaterScaffolderDetails.scaffolder} + [chosenUpdater]: this.updatePlugin } }, languages: { @@ -92,7 +92,7 @@ When(/^the project is scaffolded$/, async function () { [questionNames.GIT_REPO]: repoShouldBeCreated ?? false, ...repoShouldBeCreated && {[questionNames.REPO_HOST]: vcsHost}, [questionNames.PROJECT_LANGUAGE]: chosenLanguage, - ...this.updaterScaffolderDetails && {[questionNames.DEPENDENCY_UPDATER]: chosenUpdater} + ...this.updatePlugin && {[questionNames.DEPENDENCY_UPDATER]: chosenUpdater} } }); }); diff --git a/test/integration/features/step_definitions/dependency-updater-steps.js b/test/integration/features/step_definitions/dependency-updater-steps.js index 8284e566..165ec2f8 100644 --- a/test/integration/features/step_definitions/dependency-updater-steps.js +++ b/test/integration/features/step_definitions/dependency-updater-steps.js @@ -12,7 +12,7 @@ After(function () { }); Given('a dependency updater can be chosen', async function () { - this.updaterScaffolderDetails = {scaffolder: foo => updaterScaffolder(foo)}; + this.updatePlugin = {scaffold: foo => updaterScaffolder(foo)}; }); Then('the dependency updater was executed', async function () {