From afc0a4b9872253aaa9083bdf7ccdc2faac669d31 Mon Sep 17 00:00:00 2001 From: Frederik Bolding Date: Thu, 15 Feb 2024 12:15:02 +0100 Subject: [PATCH] Add a manifest warning when no icon is found --- .../snaps-utils/src/manifest/manifest.test.ts | 16 ++++++++++++++++ packages/snaps-utils/src/manifest/manifest.ts | 6 ++++++ 2 files changed, 22 insertions(+) diff --git a/packages/snaps-utils/src/manifest/manifest.test.ts b/packages/snaps-utils/src/manifest/manifest.test.ts index f460c7f935..0e119253d2 100644 --- a/packages/snaps-utils/src/manifest/manifest.test.ts +++ b/packages/snaps-utils/src/manifest/manifest.test.ts @@ -128,6 +128,22 @@ describe('checkManifest', () => { expect(warnings[0]).toMatch('Missing recommended package.json properties'); }); + it('returns a warning if manifest has no defined icon', async () => { + const manifest = getSnapManifest(); + + // Remove icon + manifest.source.location.npm.iconPath = undefined; + + await fs.writeFile(MANIFEST_PATH, JSON.stringify(manifest)); + + const { updated, warnings } = await checkManifest(BASE_PATH); + expect(updated).toBe(true); + expect(warnings).toHaveLength(1); + expect(warnings[0]).toMatch( + 'No icon found in `source.location.npm.iconPath`. It is highly recommended for your Snap to have an icon.', + ); + }); + it('return errors if the manifest is invalid', async () => { await fs.writeFile( MANIFEST_PATH, diff --git a/packages/snaps-utils/src/manifest/manifest.ts b/packages/snaps-utils/src/manifest/manifest.ts index ed75f32229..f62f80c938 100644 --- a/packages/snaps-utils/src/manifest/manifest.ts +++ b/packages/snaps-utils/src/manifest/manifest.ts @@ -191,6 +191,12 @@ export async function checkManifest( ); } + if (!snapFiles.svgIcon) { + warnings.push( + 'No icon found in `source.location.npm.iconPath`. It is highly recommended for your Snap to have an icon.', + ); + } + if (writeManifest) { try { const newManifest = `${JSON.stringify(