1
0
mirror of https://github.com/simple-icons/simple-icons.git synced 2024-11-16 00:59:07 +02:00

add deprecation warnings for icons/* imports (#6900)

* add deprecation warnings for icons/* imports

* do not log warnings during tests

* update message

Co-authored-by: Álvaro Mondéjar <mondejar1994@gmail.com>

* remove message formatting

* add jsdoc deprecation tags

* Update scripts/build/package.js

Co-authored-by: Álvaro Mondéjar <mondejar1994@gmail.com>

* Update scripts/build/package.js

Co-authored-by: Álvaro Mondéjar <mondejar1994@gmail.com>

* Update scripts/build/package.js

Co-authored-by: Álvaro Mondéjar <mondejar1994@gmail.com>

* Update scripts/build/package.js

Co-authored-by: Álvaro Mondéjar <mondejar1994@gmail.com>

* fix "use" for jsdoc

Co-authored-by: Álvaro Mondéjar <mondejar1994@gmail.com>
This commit is contained in:
Sachin Raja 2021-11-23 12:33:37 -08:00 committed by GitHub
parent ff9d1e26c4
commit ec75522f42
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 3 deletions

View File

@ -94,19 +94,26 @@ data.icons.forEach((icon) => {
icons.push(icon);
const iconObject = iconToObject(icon);
const iconExportName = slugToVariableName(icon.slug);
// write the static .js file for the icon
const jsFilepath = path.resolve(iconsDir, `${filename}.js`);
writeJs(jsFilepath, `module.exports=${iconObject};`);
const newImportMessage = `use "const { ${iconExportName} } = require('simple-icons/icons');" instead`;
const message = JSON.stringify(
`Imports like "const ${icon.slug} = require('simple-icons/icons/${icon.slug}');" have been deprecated in v6.0.0 and will no longer work from v7.0.0, ${newImportMessage}`,
);
writeJs(
jsFilepath,
`console.warn("warn -", ${message});module.exports=${iconObject};`,
);
const dtsFilepath = path.resolve(iconsDir, `${filename}.d.ts`);
writeTs(
dtsFilepath,
'declare const i:import("../alias").I;export default i;',
`/**@deprecated ${newImportMessage}*/declare const i:import("../alias").I;export default i;`,
);
// add object to the barrel file
const iconExportName = slugToVariableName(icon.slug);
iconsBarrelJs.push(`${iconExportName}:${iconObject},`);
iconsBarrelMjs.push(`export const ${iconExportName}=${iconObject}`);
iconsBarrelDts.push(`export const ${iconExportName}:I;`);

View File

@ -2,6 +2,8 @@ const { icons } = require('../_data/simple-icons.json');
const { getIconSlug } = require('../scripts/utils.js');
const testIcon = require('./test-icon.js');
console.warn = () => {};
icons.forEach((icon) => {
const slug = getIconSlug(icon);
const subject = require(`../icons/${slug}.js`);