mirror of
https://github.com/Mibew/simple-icons.git
synced 2024-11-15 09:54:11 +03:00
Fix SPDX license usages in add-icon-data
script
This commit is contained in:
parent
361e22120b
commit
afd6568725
@ -21,7 +21,7 @@ import {
|
|||||||
titleToSlug,
|
titleToSlug,
|
||||||
urlRegex,
|
urlRegex,
|
||||||
} from '../sdk.mjs';
|
} from '../sdk.mjs';
|
||||||
import {getJsonSchemaData, writeIconsData} from './utils.js';
|
import {getJsonSchemaData, getSpdxLicenseIds, writeIconsData} from './utils.js';
|
||||||
|
|
||||||
/** @type {{icons: import('../sdk.js').IconData[]}} */
|
/** @type {{icons: import('../sdk.js').IconData[]}} */
|
||||||
const iconsData = JSON.parse(await getIconsDataString());
|
const iconsData = JSON.parse(await getIconsDataString());
|
||||||
@ -34,11 +34,8 @@ const aliasTypes = ['aka', 'old'].map((key) => ({
|
|||||||
value: key,
|
value: key,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
/** @type {{name: string, value: string}[]} */
|
const spdxLicenseIds = await getSpdxLicenseIds();
|
||||||
const licenseTypes =
|
const licenseTypes = spdxLicenseIds.map((id) => ({name: id, value: id}));
|
||||||
jsonSchema.definitions.brand.properties.license.oneOf[0].properties.type.enum.map(
|
|
||||||
(/** @type {string} */ license) => ({name: license, value: license}),
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether an input is a valid URL.
|
* Whether an input is a valid URL.
|
||||||
|
@ -10,17 +10,16 @@
|
|||||||
* @typedef {IconData[]} IconsData
|
* @typedef {IconData[]} IconsData
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import fs from 'node:fs/promises';
|
|
||||||
import path from 'node:path';
|
import path from 'node:path';
|
||||||
import process from 'node:process';
|
import process from 'node:process';
|
||||||
import fakeDiff from 'fake-diff';
|
import fakeDiff from 'fake-diff';
|
||||||
import {
|
import {
|
||||||
collator,
|
collator,
|
||||||
getDirnameFromImportMeta,
|
|
||||||
getIconsDataString,
|
getIconsDataString,
|
||||||
normalizeNewlines,
|
normalizeNewlines,
|
||||||
titleToSlug,
|
titleToSlug,
|
||||||
} from '../../sdk.mjs';
|
} from '../../sdk.mjs';
|
||||||
|
import {getSpdxLicenseIds} from '../utils.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Contains our tests so they can be isolated from each other.
|
* Contains our tests so they can be isolated from each other.
|
||||||
@ -208,19 +207,7 @@ const TESTS = {
|
|||||||
|
|
||||||
/* Check if all licenses are valid SPDX identifiers */
|
/* Check if all licenses are valid SPDX identifiers */
|
||||||
async checkLicense(data) {
|
async checkLicense(data) {
|
||||||
const spdxLicenseIds = new Set(
|
const spdxLicenseIds = new Set(await getSpdxLicenseIds());
|
||||||
JSON.parse(
|
|
||||||
await fs.readFile(
|
|
||||||
path.join(
|
|
||||||
getDirnameFromImportMeta(import.meta.url),
|
|
||||||
'..',
|
|
||||||
'..',
|
|
||||||
'node_modules/spdx-license-ids/index.json',
|
|
||||||
),
|
|
||||||
'utf8',
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
const badLicenses = [];
|
const badLicenses = [];
|
||||||
for (const {title, slug, license} of data.icons) {
|
for (const {title, slug, license} of data.icons) {
|
||||||
if (
|
if (
|
||||||
|
@ -45,3 +45,21 @@ export const writeIconsData = async (
|
|||||||
'utf8',
|
'utf8',
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get SPDX license IDs from `spdx-license-ids` package.
|
||||||
|
* @param {string} rootDirectory Path to the root directory of the project.
|
||||||
|
* @returns {Promise<string[]>} Set of SPDX license IDs.
|
||||||
|
*/
|
||||||
|
export const getSpdxLicenseIds = async (
|
||||||
|
rootDirectory = path.resolve(__dirname, '..'),
|
||||||
|
) => {
|
||||||
|
const getSpdxLicenseJson = path.resolve(
|
||||||
|
rootDirectory,
|
||||||
|
'node_modules',
|
||||||
|
'spdx-license-ids',
|
||||||
|
'index.json',
|
||||||
|
);
|
||||||
|
const getSpdxLicenseString = await fs.readFile(getSpdxLicenseJson, 'utf8');
|
||||||
|
return JSON.parse(getSpdxLicenseString);
|
||||||
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user