From 391d86000c9569511c0dcaeb96509c5b2e1acc9c Mon Sep 17 00:00:00 2001 From: Kelvin Oghenerhoro Omereshone Date: Wed, 10 Apr 2024 18:42:23 +0100 Subject: [PATCH 1/3] fix(create-sails-generator): update function to get action name --- .../tests/utils/get-action-name.test.js | 6 ++++++ create-sails-generator/utils/get-action-name.js | 12 +++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/create-sails-generator/tests/utils/get-action-name.test.js b/create-sails-generator/tests/utils/get-action-name.test.js index 732b330..4aea7a3 100644 --- a/create-sails-generator/tests/utils/get-action-name.test.js +++ b/create-sails-generator/tests/utils/get-action-name.test.js @@ -9,4 +9,10 @@ describe('getActionName', function () { it("returns 'user/view-users' when given 'users/index'", function () { assert.equal(getActionName('users/index'), 'user/view-users') }) + it("returns 'user/view-user' when given 'users/user'", function () { + assert.equal(getActionName('users/user'), 'user/view-user') + }) + it("returns 'user/view-profile' when given 'users/profile'", function () { + assert.equal(getActionName('users/profile'), 'user/view-profile') + }) }) diff --git a/create-sails-generator/utils/get-action-name.js b/create-sails-generator/utils/get-action-name.js index 8167db3..d28b0cf 100644 --- a/create-sails-generator/utils/get-action-name.js +++ b/create-sails-generator/utils/get-action-name.js @@ -1,7 +1,9 @@ module.exports = function getActionName(pageName) { - if (!pageName.includes('/')) return 'view-' + pageName - const [firstPart] = pageName.split('/') - const actionName = 'view-' + firstPart - const singularizedFirsPart = firstPart.replace(/s$/, '') - return `${singularizedFirsPart}/${actionName}` + if (!pageName.includes('/')) return `view-${pageName}` + + const [firstPart, secondPart] = pageName.split('/') + const actionName = + secondPart === 'index' ? `view-${firstPart}` : `view-${secondPart}` + + return `${firstPart.replace(/s$/, '')}/${actionName}` } From 2395908f2e47139895f54451f83b9b6667d188a9 Mon Sep 17 00:00:00 2001 From: Kelvin Oghenerhoro Omereshone Date: Wed, 10 Apr 2024 18:43:17 +0100 Subject: [PATCH 2/3] chore: bump version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c335bac..e71a776 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "boring-stack", - "version": "0.2.3", + "version": "0.2.4", "private": "true", "description": "The Boring JavaScript Stack 🥱 - an opinionated project starter for fullstack JavaScript", "scripts": { From 8bd0d13b2a0cc635950f488724a7a9a904348804 Mon Sep 17 00:00:00 2001 From: Kelvin Oghenerhoro Omereshone Date: Wed, 10 Apr 2024 18:43:51 +0100 Subject: [PATCH 3/3] chore(create-sails-generator): bump version --- create-sails-generator/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/create-sails-generator/package.json b/create-sails-generator/package.json index 8c164c5..7eb879c 100644 --- a/create-sails-generator/package.json +++ b/create-sails-generator/package.json @@ -1,6 +1,6 @@ { "name": "create-sails-generator", - "version": "0.0.1", + "version": "0.0.2", "description": "Sails generator for The Boring JavaScript Stack.", "scripts": { "test": "node --test"