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. diff --git a/CHANGELOG.md b/CHANGELOG.md index ea444f7b..c49ebd0d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,17 @@ 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.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..436dd278 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" diff --git a/package.json b/package.json index f06fe458..b410b791 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/", 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.