Support all versions of iconify/json package, use latest version

This commit is contained in:
Vjacheslav Trushkin 2022-02-01 20:29:36 +02:00
parent 5687184ccb
commit 155c66cc96
3 changed files with 52 additions and 17 deletions

51
package-lock.json generated
View File

@ -8,6 +8,7 @@
"version": "2.0.1",
"license": "MIT",
"dependencies": {
"@iconify/json": "^2.0.32",
"@iconify/json-tools": "^1.0.10",
"express": "^4.17.2"
},
@ -16,21 +17,31 @@
"mocha": "^9.2.0"
},
"optionalDependencies": {
"@iconify/json": "*",
"@iconify/json": "^2.0.32",
"nodemailer": "^6.7.2"
}
},
"node_modules/@iconify/json": {
"version": "1.0.17",
"resolved": "https://registry.npmjs.org/@iconify/json/-/json-1.0.17.tgz",
"integrity": "sha512-yCQAHsnlz3ZnkRcsnoBJHKI+AFbxch9/B8Le0GMfTwa0U3ThrBsn5nTpOXZkaZaAr0ae8itrAAvp6NhqZ8BxkA==",
"optional": true
"version": "2.0.32",
"resolved": "https://registry.npmjs.org/@iconify/json/-/json-2.0.32.tgz",
"integrity": "sha512-ipv6PolWbDlSrC420BD0oshzhSMchDuREXOigkXaIDgjRyefnx7LXJ92ASQY98Vh8MyyGpYTcdW3FEFbv6h83Q==",
"optional": true,
"dependencies": {
"@iconify/types": "^1.0.9",
"pathe": "^0.0.2"
}
},
"node_modules/@iconify/json-tools": {
"version": "1.0.10",
"resolved": "https://registry.npmjs.org/@iconify/json-tools/-/json-tools-1.0.10.tgz",
"integrity": "sha512-LFelJDOLZ6JHlmlAkgrvmcu4hpNPB91KYcr4f60D/exzU1eNOb4/KCVHIydGHIQFaOacIOD+Xy+B7P1z812cZg=="
},
"node_modules/@iconify/types": {
"version": "1.0.12",
"resolved": "https://registry.npmjs.org/@iconify/types/-/types-1.0.12.tgz",
"integrity": "sha512-6er6wSGF3hgc1JEZqiGpg21CTCjHBYOUwqLmb2Idzkjiw6ogalGP0ZMLVutCzah+0WB4yP+Zd2oVPN8jvJ+Ftg==",
"optional": true
},
"node_modules/@ungap/promise-all-settled": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/@ungap/promise-all-settled/-/promise-all-settled-1.1.2.tgz",
@ -1099,6 +1110,12 @@
"resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz",
"integrity": "sha1-32BBeABfUi8V60SQ5yR6G/qmf4w="
},
"node_modules/pathe": {
"version": "0.0.2",
"resolved": "https://registry.npmjs.org/pathe/-/pathe-0.0.2.tgz",
"integrity": "sha512-mmK20YtPb4yXHlaPuOD/uPIpRu7iIK45GA/GiRSlNpIdfWDG5aEQmFT1HHtBmJB+t/6DvFOtOsEipsPA8Bx2cw==",
"optional": true
},
"node_modules/pathval": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/pathval/-/pathval-1.1.1.tgz",
@ -1511,16 +1528,26 @@
},
"dependencies": {
"@iconify/json": {
"version": "1.0.17",
"resolved": "https://registry.npmjs.org/@iconify/json/-/json-1.0.17.tgz",
"integrity": "sha512-yCQAHsnlz3ZnkRcsnoBJHKI+AFbxch9/B8Le0GMfTwa0U3ThrBsn5nTpOXZkaZaAr0ae8itrAAvp6NhqZ8BxkA==",
"optional": true
"version": "2.0.32",
"resolved": "https://registry.npmjs.org/@iconify/json/-/json-2.0.32.tgz",
"integrity": "sha512-ipv6PolWbDlSrC420BD0oshzhSMchDuREXOigkXaIDgjRyefnx7LXJ92ASQY98Vh8MyyGpYTcdW3FEFbv6h83Q==",
"optional": true,
"requires": {
"@iconify/types": "^1.0.9",
"pathe": "^0.0.2"
}
},
"@iconify/json-tools": {
"version": "1.0.10",
"resolved": "https://registry.npmjs.org/@iconify/json-tools/-/json-tools-1.0.10.tgz",
"integrity": "sha512-LFelJDOLZ6JHlmlAkgrvmcu4hpNPB91KYcr4f60D/exzU1eNOb4/KCVHIydGHIQFaOacIOD+Xy+B7P1z812cZg=="
},
"@iconify/types": {
"version": "1.0.12",
"resolved": "https://registry.npmjs.org/@iconify/types/-/types-1.0.12.tgz",
"integrity": "sha512-6er6wSGF3hgc1JEZqiGpg21CTCjHBYOUwqLmb2Idzkjiw6ogalGP0ZMLVutCzah+0WB4yP+Zd2oVPN8jvJ+Ftg==",
"optional": true
},
"@ungap/promise-all-settled": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/@ungap/promise-all-settled/-/promise-all-settled-1.1.2.tgz",
@ -2306,6 +2333,12 @@
"resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz",
"integrity": "sha1-32BBeABfUi8V60SQ5yR6G/qmf4w="
},
"pathe": {
"version": "0.0.2",
"resolved": "https://registry.npmjs.org/pathe/-/pathe-0.0.2.tgz",
"integrity": "sha512-mmK20YtPb4yXHlaPuOD/uPIpRu7iIK45GA/GiRSlNpIdfWDG5aEQmFT1HHtBmJB+t/6DvFOtOsEipsPA8Bx2cw==",
"optional": true
},
"pathval": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/pathval/-/pathval-1.1.1.tgz",

View File

@ -24,7 +24,7 @@
"mocha": "^9.2.0"
},
"optionalDependencies": {
"@iconify/json": "*",
"@iconify/json": "^2.0.32",
"nodemailer": "^6.7.2"
}
}

View File

@ -10,6 +10,7 @@
'use strict';
const fs = require('fs');
const { dirname } = require('path');
/**
* Directories storage.
@ -18,7 +19,7 @@ const fs = require('fs');
* @param app
* @returns {object}
*/
module.exports = app => {
module.exports = (app) => {
let functions = Object.create(null),
dirs = Object.create(null),
custom = Object.create(null),
@ -32,7 +33,7 @@ module.exports = app => {
* @param {string} repo
* @returns {string}
*/
functions.rootDir = repo => (dirs[repo] === void 0 ? '' : dirs[repo]);
functions.rootDir = (repo) => (dirs[repo] === void 0 ? '' : dirs[repo]);
/**
* Get storage directory
@ -47,7 +48,7 @@ module.exports = app => {
* @param {string} repo
* @returns {string}
*/
functions.iconsDir = repo => {
functions.iconsDir = (repo) => {
let dir;
switch (repo) {
@ -129,7 +130,7 @@ module.exports = app => {
* @param {string} repo
* @return {boolean}
*/
functions.synchronized = repo => custom[repo] === true;
functions.synchronized = (repo) => custom[repo] === true;
/**
* Initialize
@ -168,11 +169,12 @@ module.exports = app => {
repos.push(key);
functions.setSynchronizedRepoDir(key, cached[key], false);
} else {
let icons;
try {
icons = require('@iconify/json');
const iconDir = dirname(
require.resolve('@iconify/json/package.json')
);
repos.push(key);
dirs[key] = icons.rootDir();
dirs[key] = iconDir;
} catch (err) {
app.error(
'Cannot load Iconify icons because @iconify/json package is not installed'