From 77f85b49afc4a692083a4946e69e7fd14a47ebf5 Mon Sep 17 00:00:00 2001 From: Voltra Date: Wed, 8 Jul 2020 15:00:12 +0200 Subject: [PATCH 1/4] Add logic to restrict generated files --- package-lock.json | 128 +++++++++++++++++++++++++--------------------- src/helpers.js | 5 +- src/index.js | 54 ++++++++++++++++++- test/util.js | 17 +++--- 4 files changed, 134 insertions(+), 70 deletions(-) diff --git a/package-lock.json b/package-lock.json index 408dce7f..0afd80e1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -880,6 +880,16 @@ "regenerator-runtime": "^0.13.4" } }, + "@babel/runtime-corejs3": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/runtime-corejs3/-/runtime-corejs3-7.10.4.tgz", + "integrity": "sha512-BFlgP2SoLO9HJX9WBwN67gHWMBhDX/eDz64Jajd6mR/UAUzqrNMm99d4qHnVaKscAElZoFiPv+JpR/Siud5lXw==", + "dev": true, + "requires": { + "core-js-pure": "^3.0.0", + "regenerator-runtime": "^0.13.4" + } + }, "@babel/template": { "version": "7.8.3", "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.8.3.tgz", @@ -1438,9 +1448,9 @@ "dev": true }, "acorn": { - "version": "7.1.0", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.1.0.tgz", - "integrity": "sha512-kL5CuoXA/dgxlBbVrflsflzQ3PAas7RYZB52NOm/6839iVYJgKMJ3cQJD+t2i5+qFa8h3MDpEOJiS64E8JLnSQ==", + "version": "7.3.1", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.3.1.tgz", + "integrity": "sha512-tLc0wSnatxAQHVHUapaHdz72pi9KUyHjq5KyHjGg9Y8Ifdc79pTh2XvI6I1/chZbnM7QtNKzh66ooDogPZSleA==", "dev": true }, "acorn-jsx": { @@ -3132,6 +3142,12 @@ } } }, + "core-js-pure": { + "version": "3.6.5", + "resolved": "https://registry.npmjs.org/core-js-pure/-/core-js-pure-3.6.5.tgz", + "integrity": "sha512-lacdXOimsiD0QyNf9BC/mxivNJ/ybBGJXQFKzRekp1WTHoVUWsUHEn+2T8GJAzzIhyOuXA+gOxCVN3l+5PLPUA==", + "dev": true + }, "core-util-is": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", @@ -6665,9 +6681,9 @@ }, "dependencies": { "minimist": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", - "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", + "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==", "dev": true } } @@ -7232,9 +7248,9 @@ } }, "minimist": { - "version": "0.0.8", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", - "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=" + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", + "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==" }, "minipass": { "version": "3.1.1", @@ -7290,11 +7306,11 @@ } }, "mkdirp": { - "version": "0.5.1", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", - "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", + "version": "0.5.5", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz", + "integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==", "requires": { - "minimist": "0.0.8" + "minimist": "^1.2.5" } }, "mkdirp-classic": { @@ -7391,9 +7407,9 @@ "dev": true }, "node-abi": { - "version": "2.16.0", - "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-2.16.0.tgz", - "integrity": "sha512-+sa0XNlWDA6T+bDLmkCUYn6W5k5W6BPRL6mqzSCs6H/xUgtl4D5x2fORKDzopKiU6wsyn/+wXlRXwXeSp+mtoA==", + "version": "2.18.0", + "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-2.18.0.tgz", + "integrity": "sha512-yi05ZoiuNNEbyT/xXfSySZE+yVnQW6fxPZuFbLyS1s6b5Kw3HzV2PHOM4XR+nsjzkHxByK+2Wg+yCQbe35l8dw==", "requires": { "semver": "^5.4.1" }, @@ -7667,12 +7683,6 @@ "color-convert": "^2.0.1" } }, - "camelcase": { - "version": "5.3.1", - "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz", - "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==", - "dev": true - }, "cliui": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/cliui/-/cliui-6.0.0.tgz", @@ -7848,13 +7858,13 @@ "dev": true }, "yargs": { - "version": "15.1.0", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-15.1.0.tgz", - "integrity": "sha512-T39FNN1b6hCW4SOIk1XyTOWxtXdcen0t+XYrysQmChzSipvhBO8Bj0nK1ozAasdk24dNWuMZvr4k24nz+8HHLg==", + "version": "15.4.0", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-15.4.0.tgz", + "integrity": "sha512-D3fRFnZwLWp8jVAAhPZBsmeIHY8tTsb8ItV9KaAaopmC6wde2u6Yw29JBIZHXw14kgkRnYmDgmQU4FVMDlIsWw==", "dev": true, "requires": { "cliui": "^6.0.0", - "decamelize": "^1.2.0", + "decamelize": "^3.2.0", "find-up": "^4.1.0", "get-caller-file": "^2.0.1", "require-directory": "^2.1.1", @@ -7863,17 +7873,18 @@ "string-width": "^4.2.0", "which-module": "^2.0.0", "y18n": "^4.0.0", - "yargs-parser": "^16.1.0" - } - }, - "yargs-parser": { - "version": "16.1.0", - "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-16.1.0.tgz", - "integrity": "sha512-H/V41UNZQPkUMIT5h5hiwg4QKIY1RPvoBV4XcjUbRM8Bk2oKqqyZ0DIEbTFZB0XjbtSPG8SAa/0DxCQmiRgzKg==", - "dev": true, - "requires": { - "camelcase": "^5.0.0", - "decamelize": "^1.2.0" + "yargs-parser": "^18.1.2" + }, + "dependencies": { + "decamelize": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-3.2.0.tgz", + "integrity": "sha512-4TgkVUsmmu7oCSyGBm5FvfMoACuoh9EOidm7V5/J2X2djAwwt57qb3F2KMP2ITqODTCSwb+YRV+0Zqrv18k/hw==", + "dev": true, + "requires": { + "xregexp": "^4.2.4" + } + } } } } @@ -8502,14 +8513,14 @@ "dev": true }, "prebuild-install": { - "version": "5.3.3", - "resolved": "https://registry.npmjs.org/prebuild-install/-/prebuild-install-5.3.3.tgz", - "integrity": "sha512-GV+nsUXuPW2p8Zy7SarF/2W/oiK8bFQgJcncoJ0d7kRpekEA0ftChjfEaF9/Y+QJEc/wFR7RAEa8lYByuUIe2g==", + "version": "5.3.5", + "resolved": "https://registry.npmjs.org/prebuild-install/-/prebuild-install-5.3.5.tgz", + "integrity": "sha512-YmMO7dph9CYKi5IR/BzjOJlRzpxGGVo1EsLSUZ0mt/Mq0HWZIHOKHHcHdT69yG54C9m6i45GpItwRHpk0Py7Uw==", "requires": { "detect-libc": "^1.0.3", "expand-template": "^2.0.3", "github-from-package": "0.0.0", - "minimist": "^1.2.0", + "minimist": "^1.2.3", "mkdirp": "^0.5.1", "napi-build-utils": "^1.0.1", "node-abi": "^2.7.0", @@ -8521,13 +8532,6 @@ "tar-fs": "^2.0.0", "tunnel-agent": "^0.6.0", "which-pm-runs": "^1.0.0" - }, - "dependencies": { - "minimist": { - "version": "1.2.5", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", - "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==" - } } }, "prelude-ls": { @@ -8679,9 +8683,9 @@ }, "dependencies": { "minimist": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", - "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=" + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", + "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==" } } }, @@ -9012,7 +9016,6 @@ "jpeg-js": "^0.2.0", "load-bmfont": "^1.2.3", "mime": "^1.3.4", - "mkdirp": "0.5.1", "pixelmatch": "^4.0.0", "pngjs": "^3.0.0", "read-chunk": "^1.0.1", @@ -9920,9 +9923,9 @@ } }, "tar-fs": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-2.0.1.tgz", - "integrity": "sha512-6tzWDMeroL87uF/+lin46k+Q+46rAJ0SyPGz7OW7wTgblI273hsBqk2C1j0/xNadNLKDTUL9BukSjB7cwgmlPA==", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-2.1.0.tgz", + "integrity": "sha512-9uW5iDvrIMCVpvasdFHW0wJPez0K4JnMZtsuIeDI7HyMGJNxmDZDOCQROr7lXyS+iL/QMpj07qcjGYTSdRFXUg==", "requires": { "chownr": "^1.1.1", "mkdirp-classic": "^0.5.2", @@ -9931,9 +9934,9 @@ } }, "tar-stream": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-2.1.2.tgz", - "integrity": "sha512-UaF6FoJ32WqALZGOIAApXx+OdxhekNMChu6axLJR85zMMjXKWFGjbIRe+J6P4UnRGg9rAwWvbTT0oI7hD/Un7Q==", + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-2.1.3.tgz", + "integrity": "sha512-Z9yri56Dih8IaK8gncVPx4Wqt86NDmQTSh49XLZgjWpGZL9GK9HKParS2scqHCC4w6X9Gh2jwaU45V47XTKwVA==", "requires": { "bl": "^4.0.1", "end-of-stream": "^1.4.1", @@ -10787,6 +10790,15 @@ "resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-11.0.1.tgz", "integrity": "sha512-fDlsI/kFEx7gLvbecc0/ohLG50fugQp8ryHzMTuW9vSa1GJ0XYWKnhsUx7oie3G98+r56aTQIUB4kht42R3JvA==" }, + "xregexp": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/xregexp/-/xregexp-4.3.0.tgz", + "integrity": "sha512-7jXDIFXh5yJ/orPn4SXjuVrWWoi4Cr8jfV1eHv9CixKSbU+jY4mxfrBwAuDvupPNKpMUY+FeIqsVw/JLT9+B8g==", + "dev": true, + "requires": { + "@babel/runtime-corejs3": "^7.8.3" + } + }, "xtend": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz", diff --git a/src/helpers.js b/src/helpers.js index 87a85a47..bbb524df 100644 --- a/src/helpers.js +++ b/src/helpers.js @@ -123,10 +123,9 @@ module.exports = function(options) { }, preparePlatformOptions(platform) { + const icons = options.icons[platform]; const parameters = - typeof options.icons[platform] === "object" - ? options.icons[platform] - : {}; + typeof icons === "object" && !Array.isArray(icons) ? icons : {}; for (const key of Object.keys(parameters)) { if ( diff --git a/src/index.js b/src/index.js index 933f6b25..1aa17435 100644 --- a/src/index.js +++ b/src/index.js @@ -7,6 +7,50 @@ const path = require("path"); const File = require("vinyl"); const toIco = require("to-ico"); +/** + * @typedef FaviconOptions + * @type {typeof import("./config/defaults.json")} + */ + +/** + * @typedef FaviconImage + * @type {object} + * @property {string} name + * @property {Buffer} contents + */ + +/** + * @typedef FaviconFile + * @type {object} + * @property {string} name + * @property {string} contents + */ + +/** + * @typedef FaviconHtmlElement + * @type {string} + */ + +/** + * @typedef FaviconResponse + * @type {object} + * @property {FaviconImage[]} images + * @property {FaviconFile[]} files + * @property {FaviconHtmlElement[]} html + */ + +/** + * @typedef FaviconCallback + * @type {(error: Error|null, response: FaviconResponse) => any} + */ + +/** + * Build favicons + * @param {string} source - The path to the source image to generate icons from + * @param {Partial|undefined} options - The options used to build favicons + * @param {FaviconCallback} next - The callback to execute after processing + * @returns {Promise} + */ function favicons(source, options = {}, next) { if (next) { return favicons(source, options) @@ -71,9 +115,17 @@ function favicons(source, options = {}, next) { function createFavicons(sourceset, platform) { const platformOptions = ยต.General.preparePlatformOptions(platform); + const icons = Array.isArray(options.icons[platform]) + ? options.icons[platform].reduce((opts, icon) => { + // map the selected names to their original configs + if (platform in config.icons && icon in config.icons[platform]) + opts[icon] = config.icons[platform][icon]; + return opts; + }, {}) + : config.icons[platform]; return Promise.all( - Object.keys(config.icons[platform] || {}).map(name => + Object.keys(icons || {}).map(name => createFavicon( sourceset, config.icons[platform][name], diff --git a/test/util.js b/test/util.js index 8b259543..83a47591 100644 --- a/test/util.js +++ b/test/util.js @@ -1,13 +1,14 @@ const path = require("path"); -module.exports.logo_png = path.resolve(__dirname, "fixtures", "logo.png"); -module.exports.logo_svg = path.resolve(__dirname, "fixtures", "logo.svg"); -module.exports.logo_small_svg = path.resolve( - __dirname, - "fixtures", - "logo_small.svg" -); -module.exports.pixel_art = path.resolve(__dirname, "fixtures", "pixel_art.png"); +function fixture(uri) { + return path.resolve(__dirname, "fixtures", uri); +} + +["logo.png", "logo.svg", "logo_small.svg", "pixel_art.png"].forEach(img => { + const key = img.replace(/\.([^.]+)$/, "_$1"); + + module.exports[key] = fixture(img); +}); module.exports.normalize = ({ files, images, html }) => [...files, ...images].reduce( From 2522938570b38930113c32696ce83b80affb78a7 Mon Sep 17 00:00:00 2001 From: Voltra Date: Wed, 8 Jul 2020 15:06:56 +0200 Subject: [PATCH 2/4] Add test for icons restriction --- src/index.js | 7 ++++--- test/restrict.test.js | 22 ++++++++++++++++++++++ 2 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 test/restrict.test.js diff --git a/src/index.js b/src/index.js index 1aa17435..4b8c5418 100644 --- a/src/index.js +++ b/src/index.js @@ -48,10 +48,11 @@ const toIco = require("to-ico"); * Build favicons * @param {string} source - The path to the source image to generate icons from * @param {Partial|undefined} options - The options used to build favicons - * @param {FaviconCallback} next - The callback to execute after processing - * @returns {Promise} + * @param {FaviconCallback|undefined} next - The callback to execute after processing + * @returns {Promise|Promise} */ -function favicons(source, options = {}, next) { +// eslint-disable-next-line no-undefined +function favicons(source, options = {}, next = undefined) { if (next) { return favicons(source, options) .then(response => next(null, response)) diff --git a/test/restrict.test.js b/test/restrict.test.js new file mode 100644 index 00000000..47d5f870 --- /dev/null +++ b/test/restrict.test.js @@ -0,0 +1,22 @@ +const favicons = require("../src"); +const test = require("ava"); + +const { snapshotManager } = require("ava/lib/concordance-options"); +const { factory } = require("concordance-comparator"); + +const { logo_png } = require("./util"); +const { Image } = require("./Image"); + +snapshotManager.plugins.push(factory(Image, v => new Image(v[0], v[1]))); + +test("should allow to restrict the icons to generate", async t => { + t.plan(1); + + const { files, images, html } = await favicons(logo_png, { + icons: { favicons: ["favicon-32x32.png"] } + }); + + t.deepEqual(files, []); + t.deepEqual(images.length, 1); + t.deepEqual(html, []); +}); From 4f5a78d89d3b691ba81e79cf4a53e5ac24957bf9 Mon Sep 17 00:00:00 2001 From: Voltra Date: Wed, 8 Jul 2020 15:30:37 +0200 Subject: [PATCH 3/4] Add tests for favicon restrictions --- test/restrict.test.js | 24 ++++++++++++++++-------- test/util.js | 1 + 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/test/restrict.test.js b/test/restrict.test.js index 47d5f870..6d071954 100644 --- a/test/restrict.test.js +++ b/test/restrict.test.js @@ -1,22 +1,30 @@ const favicons = require("../src"); const test = require("ava"); -const { snapshotManager } = require("ava/lib/concordance-options"); -const { factory } = require("concordance-comparator"); +// const { snapshotManager } = require("ava/lib/concordance-options"); +// const { factory } = require("concordance-comparator"); const { logo_png } = require("./util"); -const { Image } = require("./Image"); +// const { Image } = require("./Image"); -snapshotManager.plugins.push(factory(Image, v => new Image(v[0], v[1]))); +// snapshotManager.plugins.push(factory(Image, v => new Image(v[0], v[1]))); test("should allow to restrict the icons to generate", async t => { + // eslint-disable-next-line no-magic-numbers t.plan(1); - const { files, images, html } = await favicons(logo_png, { - icons: { favicons: ["favicon-32x32.png"] } + const { images } = await favicons(logo_png, { + icons: { + favicons: ["favicon-32x32.png"], + android: false, + appleIcon: false, + appleStartup: false, + coast: false, + firefox: false, + windows: false, + yandex: false + } }); - t.deepEqual(files, []); t.deepEqual(images.length, 1); - t.deepEqual(html, []); }); diff --git a/test/util.js b/test/util.js index 83a47591..e863dd58 100644 --- a/test/util.js +++ b/test/util.js @@ -9,6 +9,7 @@ function fixture(uri) { module.exports[key] = fixture(img); }); +module.exports.pixel_art = module.exports.pixel_art_png module.exports.normalize = ({ files, images, html }) => [...files, ...images].reduce( From c841677f2a79cda274a5218865340df8168f5bf1 Mon Sep 17 00:00:00 2001 From: Voltra Date: Wed, 8 Jul 2020 16:05:02 +0200 Subject: [PATCH 4/4] Add related info to readme --- readme.md | 100 ++++++++++++++++++++++++++++++++++++++++++++++----- src/index.js | 4 +++ test/util.js | 2 +- 3 files changed, 96 insertions(+), 10 deletions(-) diff --git a/readme.md b/readme.md index 053ed44a..133ed2aa 100644 --- a/readme.md +++ b/readme.md @@ -28,7 +28,7 @@ Please note: Favicons is tested on Node 10.13 and above. ```js var favicons = require('favicons'), source = 'test/logo.png', // Source image(s). `string`, `buffer` or array of `string` - configuration = { + configuration = { path: "/", // Path for overriding default icons path. `string` appName: null, // Your application's name. `string` appShortName: null, // Your application's short_name. `string`. Optional. If not set, appName will be used @@ -59,14 +59,14 @@ var favicons = require('favicons'), // * overlayGlow - apply glow effect after mask has been applied (applied by default for firefox). `boolean` // * overlayShadow - apply drop shadow after mask has been applied .`boolean` // - android: true, // Create Android homescreen icon. `boolean` or `{ offset, background, mask, overlayGlow, overlayShadow }` - appleIcon: true, // Create Apple touch icons. `boolean` or `{ offset, background, mask, overlayGlow, overlayShadow }` - appleStartup: true, // Create Apple startup images. `boolean` or `{ offset, background, mask, overlayGlow, overlayShadow }` - coast: true, // Create Opera Coast icon. `boolean` or `{ offset, background, mask, overlayGlow, overlayShadow }` - favicons: true, // Create regular favicons. `boolean` or `{ offset, background, mask, overlayGlow, overlayShadow }` - firefox: true, // Create Firefox OS icons. `boolean` or `{ offset, background, mask, overlayGlow, overlayShadow }` - windows: true, // Create Windows 8 tile icons. `boolean` or `{ offset, background, mask, overlayGlow, overlayShadow }` - yandex: true // Create Yandex browser icon. `boolean` or `{ offset, background, mask, overlayGlow, overlayShadow }` + android: true, // Create Android homescreen icon. `boolean` or `{ offset, background, mask, overlayGlow, overlayShadow }` or an array of sources + appleIcon: true, // Create Apple touch icons. `boolean` or `{ offset, background, mask, overlayGlow, overlayShadow }` or an array of sources + appleStartup: true, // Create Apple startup images. `boolean` or `{ offset, background, mask, overlayGlow, overlayShadow }` or an array of sources + coast: true, // Create Opera Coast icon. `boolean` or `{ offset, background, mask, overlayGlow, overlayShadow }` or an array of sources + favicons: true, // Create regular favicons. `boolean` or `{ offset, background, mask, overlayGlow, overlayShadow }` or an array of sources + firefox: true, // Create Firefox OS icons. `boolean` or `{ offset, background, mask, overlayGlow, overlayShadow }` or an array of sources + windows: true, // Create Windows 8 tile icons. `boolean` or `{ offset, background, mask, overlayGlow, overlayShadow }` or an array of sources + yandex: true // Create Yandex browser icon. `boolean` or `{ offset, background, mask, overlayGlow, overlayShadow }` or an array of sources } }, callback = function (error, response) { @@ -82,6 +82,88 @@ var favicons = require('favicons'), favicons(source, configuration, callback); ``` +The default sources are as follow (groupped by platform): + +```javascript +{ + "android": [ + "android-chrome-144x144.png", + "android-chrome-192x192.png", + "android-chrome-256x256.png", + "android-chrome-36x36.png", + "android-chrome-384x384.png", + "android-chrome-48x48.png", + "android-chrome-512x512.png", + "android-chrome-72x72.png", + "android-chrome-96x96.png" + ], + "appleIcon": [ + "apple-touch-icon-1024x1024.png", + "apple-touch-icon-114x114.png", + "apple-touch-icon-120x120.png", + "apple-touch-icon-144x144.png", + "apple-touch-icon-152x152.png", + "apple-touch-icon-167x167.png", + "apple-touch-icon-180x180.png", + "apple-touch-icon-57x57.png", + "apple-touch-icon-60x60.png", + "apple-touch-icon-72x72.png", + "apple-touch-icon-76x76.png", + "apple-touch-icon-precomposed.png", + "apple-touch-icon.png" + ], + "appleStartup": [ + "apple-touch-startup-image-1125x2436.png", + "apple-touch-startup-image-1136x640.png", + "apple-touch-startup-image-1242x2208.png", + "apple-touch-startup-image-1242x2688.png", + "apple-touch-startup-image-1334x750.png", + "apple-touch-startup-image-1536x2048.png", + "apple-touch-startup-image-1620x2160.png", + "apple-touch-startup-image-1668x2224.png", + "apple-touch-startup-image-1668x2388.png", + "apple-touch-startup-image-1792x828.png", + "apple-touch-startup-image-2048x1536.png", + "apple-touch-startup-image-2048x2732.png", + "apple-touch-startup-image-2160x1620.png", + "apple-touch-startup-image-2208x1242.png", + "apple-touch-startup-image-2224x1668.png", + "apple-touch-startup-image-2388x1668.png", + "apple-touch-startup-image-2436x1125.png", + "apple-touch-startup-image-2688x1242.png", + "apple-touch-startup-image-2732x2048.png", + "apple-touch-startup-image-640x1136.png", + "apple-touch-startup-image-750x1334.png", + "apple-touch-startup-image-828x1792.png" + ], + "coast": [ + "coast-228x228.png" + ], + "favicons": [ + "favicon-16x16.png", + "favicon-32x32.png", + "favicon-48x48.png", + "favicon.ico" + ], + "firefox": [ + "firefox_app_128x128.png", + "firefox_app_512x512.png", + "firefox_app_60x60.png" + ], + "windows": [ + "mstile-144x144.png", + "mstile-150x150.png", + "mstile-310x150.png", + "mstile-310x310.png", + "mstile-70x70.png" + ], + "yandex": [ + "yandex-browser-50x50.png" + ] +} + +``` + You can programmatically access Favicons configuration (icon filenames, HTML, manifest files, etc) with: ```js diff --git a/src/index.js b/src/index.js index 4b8c5418..54e37800 100644 --- a/src/index.js +++ b/src/index.js @@ -1,3 +1,7 @@ +// generate README sources: jq ". | with_entries(.value |= keys)" < icons.json + +// TO_DO: More comments to know what's going on, for future maintainers + const through2 = require("through2"); const clone = require("clone"); const mergeDefaults = require("lodash.defaultsdeep"); diff --git a/test/util.js b/test/util.js index e863dd58..0a290287 100644 --- a/test/util.js +++ b/test/util.js @@ -9,7 +9,7 @@ function fixture(uri) { module.exports[key] = fixture(img); }); -module.exports.pixel_art = module.exports.pixel_art_png +module.exports.pixel_art = module.exports.pixel_art_png; module.exports.normalize = ({ files, images, html }) => [...files, ...images].reduce(