From 077168dac9347f25d2b8ce440bd0a3e8576f4cdf Mon Sep 17 00:00:00 2001 From: MasonVX Date: Wed, 13 Mar 2024 22:55:43 +0100 Subject: [PATCH 1/5] fix(icon): icon names with numbers are correctly converted to kebab case (#1339) resolves #1338 --------- Co-authored-by: Nico Tasche --- src/components/icon/test/utils.spec.ts | 68 +++++++++++++++----------- src/components/icon/utils.ts | 10 ++-- 2 files changed, 44 insertions(+), 34 deletions(-) diff --git a/src/components/icon/test/utils.spec.ts b/src/components/icon/test/utils.spec.ts index 189ae21d..2bb7308c 100644 --- a/src/components/icon/test/utils.spec.ts +++ b/src/components/icon/test/utils.spec.ts @@ -86,78 +86,88 @@ describe('getName', () => { describe('addIcons', () => { it('should add an svg to the icon cache', () => { const testData = 'stubbed data'; - + expect(getIconMap().get('logo-ionic')).toEqual(undefined); - + addIcons({ 'logo-ionic': 'stubbed data' }); - + expect(getIconMap().get('logo-ionic')).toEqual(testData); }); - + it('should add kebab and camel case names to the icon cache', () => { const logoIonitron = 'stubbed data'; - + expect(getIconMap().get('logo-ionitron')).toEqual(undefined); expect(getIconMap().get('logoIonitron')).toEqual(undefined); - + addIcons({ logoIonitron }); - + expect(getIconMap().get('logo-ionitron')).toEqual(logoIonitron); expect(getIconMap().get('logoIonitron')).toEqual(logoIonitron); + + const logoIonitron0 = 'stubbed data 0' + + expect(getIconMap().get('logo-ionitron-0')).toEqual(undefined); + expect(getIconMap().get('logoIonitron0')).toEqual(undefined); + + addIcons({ logoIonitron0 }); + + expect(getIconMap().get('logo-ionitron-0')).toEqual(logoIonitron0); + expect(getIconMap().get('logoIonitron0')).toEqual(logoIonitron0); }); - + it('should map to a name that does not match the svg', () => { const logoIonitron = 'stubbed data'; - + expect(getIconMap().get('my-fun-icon')).toEqual(undefined); - + addIcons({ 'my-fun-icon': logoIonitron }); - + expect(getIconMap().get('my-fun-icon')).toEqual(logoIonitron); }); - + it('should map to an explicit camel case name', () => { const logoIonitron = 'stubbed data'; - + expect(getIconMap().get('myCoolIcon')).toEqual(undefined); - + addIcons({ 'myCoolIcon': logoIonitron }); - + expect(getIconMap().get('myCoolIcon')).toEqual(logoIonitron); }); - + it('should not warn when mapping the same icon twice', () => { const spy = jest.spyOn(console, 'warn'); const myIcon = 'my-icon'; - + expect(spy).not.toHaveBeenCalled(); - + addIcons({ myIcon }); - + expect(spy).not.toHaveBeenCalled(); - + addIcons({ myIcon }); - + expect(spy).not.toHaveBeenCalled(); }); - + it('should not overwrite icons', () => { const spy = jest.spyOn(console, 'warn'); - + const logoA = 'logo a'; const logoB = 'logo b'; - + expect(spy).not.toHaveBeenCalled(); - + expect(getIconMap().get('logo-a')).toEqual(undefined); - + addIcons({ 'logo-a': logoB, logoA }); - + expect(getIconMap().get('logo-a')).toEqual(logoB); expect(getIconMap().get('logoA')).toEqual(logoA); - + expect(spy).toHaveBeenCalled(); }); - + }); diff --git a/src/components/icon/utils.ts b/src/components/icon/utils.ts index c95d9729..c1077b76 100644 --- a/src/components/icon/utils.ts +++ b/src/components/icon/utils.ts @@ -18,9 +18,9 @@ export const getIconMap = (): Map => { }; export const addIcons = (icons: { [name: string]: string; }) => { - Object.keys(icons).forEach(name => { + Object.keys(icons).forEach(name => { addToIconMap(name, icons[name]); - + /** * Developers can also pass in the SVG object directly * and Ionicons can map the object to a kebab case name. @@ -31,7 +31,7 @@ export const addIcons = (icons: { [name: string]: string; }) => { * Using name="addCircleOutline" is valid too, but the * kebab case naming is preferred. */ - const toKebabCase = name.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, "$1-$2").toLowerCase(); + const toKebabCase = name.replace(/([a-z0-9]|(?=[A-Z]))([A-Z0-9])/g, "$1-$2").toLowerCase(); if (name !== toKebabCase) { addToIconMap(toKebabCase, icons[name]); } @@ -40,12 +40,12 @@ export const addIcons = (icons: { [name: string]: string; }) => { const addToIconMap = (name: string, data: any) => { const map = getIconMap(); - + const existingIcon = map.get(name); if (existingIcon === undefined) { map.set(name, data); - + /** * Importing and defining the same icon reference * multiple times should not yield a warning. From 35e276a33de9104a9fc09194b4eae47332fd9e96 Mon Sep 17 00:00:00 2001 From: ionitron Date: Wed, 20 Mar 2024 13:15:02 +0000 Subject: [PATCH 2/5] v7.2.3 --- CHANGELOG.md | 22 ++++++++++++++++++++++ lerna.json | 2 +- package-lock.json | 16 ++++++++++------ package.json | 2 +- 4 files changed, 34 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ea444f7b..92af4e07 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,28 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [7.2.3](https://github.com/ionic-team/ionicons/compare/v7.2.2...v7.2.3) (2024-03-20) + + +### Bug Fixes + +* **icon:** icon names with numbers are correctly converted to kebab case ([#1339](https://github.com/ionic-team/ionicons/issues/1339)) ([077168d](https://github.com/ionic-team/ionicons/commit/077168dac9347f25d2b8ce440bd0a3e8576f4cdf)), closes [#1338](https://github.com/ionic-team/ionicons/issues/1338) + + + + + +## [7.2.3](https://github.com/ionic-team/ionicons/compare/v7.2.2...v7.2.3) (2024-03-20) + + +### Bug Fixes + +* **icon:** icon names with numbers are correctly converted to kebab case ([#1339](https://github.com/ionic-team/ionicons/issues/1339)) ([077168d](https://github.com/ionic-team/ionicons/commit/077168dac9347f25d2b8ce440bd0a3e8576f4cdf)), closes [#1338](https://github.com/ionic-team/ionicons/issues/1338) + + + + + ## [7.2.2](https://github.com/ionic-team/ionicons/compare/v7.2.1...v7.2.2) (2023-12-13) diff --git a/lerna.json b/lerna.json index c87d5383..92d947f0 100644 --- a/lerna.json +++ b/lerna.json @@ -2,5 +2,5 @@ "packages": [ "./" ], - "version": "7.2.2" + "version": "7.2.3" } diff --git a/package-lock.json b/package-lock.json index 1cba7a25..30e9c706 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "ionicons", - "version": "7.2.2", + "version": "7.2.3", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "ionicons", - "version": "7.2.2", + "version": "7.2.3", "license": "MIT", "dependencies": { "@stencil/core": "^4.0.3" @@ -18283,7 +18283,8 @@ "version": "1.0.4", "resolved": "https://registry.npmjs.org/@octokit/plugin-request-log/-/plugin-request-log-1.0.4.tgz", "integrity": "sha512-mLUsMkgP7K/cnFEw07kWqXGF5LKrOkD+lhCrKvPHXWDywAwuDUeDwWBpc69XK3pNX0uKiVt8g5z96PJ6z9xCFA==", - "dev": true + "dev": true, + "requires": {} }, "@octokit/plugin-rest-endpoint-methods": { "version": "6.8.1", @@ -22726,7 +22727,8 @@ "version": "1.2.3", "resolved": "https://registry.npmjs.org/jest-pnp-resolver/-/jest-pnp-resolver-1.2.3.tgz", "integrity": "sha512-+3NpwQEnRoIBtx4fyhblQDPgJI0H1IEIkX7ShLUjPGA7TtUTvI1oiKi3SR4oBR0hQhQR80l4WAe5RrXBwWMA8w==", - "dev": true + "dev": true, + "requires": {} }, "jest-regex-util": { "version": "27.5.1", @@ -23411,7 +23413,8 @@ "version": "7.5.9", "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.9.tgz", "integrity": "sha512-F+P9Jil7UiSKSkppIiD94dN07AwvFixvLIj1Og1Rl9GGMuNipJnV9JzjD6XuqmAeiswGvUmNLjr5cFuXwNS77Q==", - "dev": true + "dev": true, + "requires": {} } } }, @@ -28186,7 +28189,8 @@ "version": "8.13.0", "resolved": "https://registry.npmjs.org/ws/-/ws-8.13.0.tgz", "integrity": "sha512-x9vcZYTrFPC7aSIbj7sRCYo7L/Xb8Iy+pW0ng0wt2vCJv7M9HOMy0UoN3rr+IFC7hb7vXoqS+P9ktyLLLhO+LA==", - "dev": true + "dev": true, + "requires": {} }, "xml-name-validator": { "version": "3.0.0", diff --git a/package.json b/package.json index c578475d..2777defd 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ionicons", - "version": "7.2.2", + "version": "7.2.3", "description": "Premium icons for Ionic.", "files": [ "components/", From eea9396f11c6b4bd4b1fd9b6efe63b606a917e4a Mon Sep 17 00:00:00 2001 From: Liam DeBeasi Date: Wed, 20 Mar 2024 09:18:20 -0400 Subject: [PATCH 3/5] chore(ci): pull branch correctly --- .github/workflows/release.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index bc6923cd..061a33d2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -64,6 +64,24 @@ jobs: needs: [finalize-release] runs-on: ubuntu-latest steps: + - uses: actions/checkout@v4 + # Pull the latest version of the reference + # branch instead of the revision that triggered + # the workflow otherwise we won't get the commit + # created in the previous job and this next job + # will fail. + with: + ref: ${{ github.ref }} + - name: Configure Identity + # Commits from github-actions do not + # trigger other GitHub Actions. As a result, + # we push from Ionitron instead so actions + # run when merging the release branch + # back into main. + run: | + git config user.name ionitron + git config user.email hi@ionicframework.com + shell: bash # Lerna does not automatically bump versions # of Ionicons dependencies that have changed, # so we do that here. From 51efbde09fc45c3d84d477854fd12ac5800a9f9c Mon Sep 17 00:00:00 2001 From: Liam DeBeasi Date: Wed, 20 Mar 2024 09:18:33 -0400 Subject: [PATCH 4/5] chore: clean up changelog --- CHANGELOG.md | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 92af4e07..c49ebd0d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,17 +14,6 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline -## [7.2.3](https://github.com/ionic-team/ionicons/compare/v7.2.2...v7.2.3) (2024-03-20) - - -### Bug Fixes - -* **icon:** icon names with numbers are correctly converted to kebab case ([#1339](https://github.com/ionic-team/ionicons/issues/1339)) ([077168d](https://github.com/ionic-team/ionicons/commit/077168dac9347f25d2b8ce440bd0a3e8576f4cdf)), closes [#1338](https://github.com/ionic-team/ionicons/issues/1338) - - - - - ## [7.2.2](https://github.com/ionic-team/ionicons/compare/v7.2.1...v7.2.2) (2023-12-13) From 0a299f7118775d504810e14d276c950f15cdf26d Mon Sep 17 00:00:00 2001 From: Liam DeBeasi Date: Wed, 20 Mar 2024 09:19:03 -0400 Subject: [PATCH 5/5] chore(); update package lock files --- package-lock.json | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index 30e9c706..436dd278 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18283,8 +18283,7 @@ "version": "1.0.4", "resolved": "https://registry.npmjs.org/@octokit/plugin-request-log/-/plugin-request-log-1.0.4.tgz", "integrity": "sha512-mLUsMkgP7K/cnFEw07kWqXGF5LKrOkD+lhCrKvPHXWDywAwuDUeDwWBpc69XK3pNX0uKiVt8g5z96PJ6z9xCFA==", - "dev": true, - "requires": {} + "dev": true }, "@octokit/plugin-rest-endpoint-methods": { "version": "6.8.1", @@ -22727,8 +22726,7 @@ "version": "1.2.3", "resolved": "https://registry.npmjs.org/jest-pnp-resolver/-/jest-pnp-resolver-1.2.3.tgz", "integrity": "sha512-+3NpwQEnRoIBtx4fyhblQDPgJI0H1IEIkX7ShLUjPGA7TtUTvI1oiKi3SR4oBR0hQhQR80l4WAe5RrXBwWMA8w==", - "dev": true, - "requires": {} + "dev": true }, "jest-regex-util": { "version": "27.5.1", @@ -23413,8 +23411,7 @@ "version": "7.5.9", "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.9.tgz", "integrity": "sha512-F+P9Jil7UiSKSkppIiD94dN07AwvFixvLIj1Og1Rl9GGMuNipJnV9JzjD6XuqmAeiswGvUmNLjr5cFuXwNS77Q==", - "dev": true, - "requires": {} + "dev": true } } }, @@ -28189,8 +28186,7 @@ "version": "8.13.0", "resolved": "https://registry.npmjs.org/ws/-/ws-8.13.0.tgz", "integrity": "sha512-x9vcZYTrFPC7aSIbj7sRCYo7L/Xb8Iy+pW0ng0wt2vCJv7M9HOMy0UoN3rr+IFC7hb7vXoqS+P9ktyLLLhO+LA==", - "dev": true, - "requires": {} + "dev": true }, "xml-name-validator": { "version": "3.0.0",