From c1690bcda2b20795afb57dced2cc6fb4f17f8866 Mon Sep 17 00:00:00 2001 From: Michael Loughry Date: Tue, 20 Feb 2024 16:57:54 +0000 Subject: [PATCH 1/3] Unify non-icon exports in svg/font indices --- packages/react-icons/addRexportsToIndex.js | 12 ++++++++++++ packages/react-icons/convert-font.js | 11 ++--------- packages/react-icons/convert.js | 12 ++---------- 3 files changed, 16 insertions(+), 19 deletions(-) create mode 100644 packages/react-icons/addRexportsToIndex.js diff --git a/packages/react-icons/addRexportsToIndex.js b/packages/react-icons/addRexportsToIndex.js new file mode 100644 index 0000000000..698463e88a --- /dev/null +++ b/packages/react-icons/addRexportsToIndex.js @@ -0,0 +1,12 @@ +module.exports = function addRexportsToIndex(indexContents) { + indexContents.push('export { FluentIconsProps } from \'./utils/FluentIconsProps.types\''); + indexContents.push('export { default as wrapIcon } from \'./utils/wrapIcon\''); + indexContents.push('export { default as bundleIcon } from \'./utils/bundleIcon\''); + indexContents.push('export { createFluentIcon } from \'./utils/createFluentIcon\''); + indexContents.push('export { createFluentFontIcon } from \'../utils/fonts/createFluentFontIcon\''); + indexContents.push('export type { FluentIcon } from \'./utils/createFluentIcon\''); + indexContents.push('export * from \'./utils/useIconState\''); + indexContents.push('export * from \'./utils/constants\''); + indexContents.push('export { IconDirectionContextProvider, useIconContext } from \'./contexts/index\''); + indexContents.push('export type { IconDirectionContextValue } from \'./contexts/index\''); +} \ No newline at end of file diff --git a/packages/react-icons/convert-font.js b/packages/react-icons/convert-font.js index 3e1c496cc7..1d2d26bd4f 100644 --- a/packages/react-icons/convert-font.js +++ b/packages/react-icons/convert-font.js @@ -12,6 +12,7 @@ const mkdirp = require('mkdirp'); const { promisify } = require('util'); const { option } = require("yargs"); const glob = promisify(require('glob')); +const addRexportsToIndex = require('./addRexportsToIndex'); // @ts-ignore const SRC_PATH = argv.source; @@ -69,15 +70,7 @@ async function processFiles(src, dest) { const indexPath = path.join(dest, 'index.tsx') // Finally add the interface definition and then write out the index. - indexContents.push('export { FluentIconsProps } from \'../utils/FluentIconsProps.types\''); - indexContents.push('export { default as wrapIcon } from \'../utils/wrapIcon\''); - indexContents.push('export { default as bundleIcon } from \'../utils/bundleIcon\''); - indexContents.push('export { createFluentFontIcon } from \'../utils/fonts/createFluentFontIcon\''); - indexContents.push('export type { FluentIcon } from \'../utils/createFluentIcon\''); - indexContents.push('export * from \'../utils/useIconState\''); - indexContents.push('export * from \'../utils/constants\''); - indexContents.push('export { IconDirectionContextProvider, useIconContext } from \'../contexts/index\''); - indexContents.push('export type { IconDirectionContextValue } from \'../contexts/index\''); + addRexportsToIndex(indexContents); await fs.writeFile(indexPath, indexContents.join('\n')); diff --git a/packages/react-icons/convert.js b/packages/react-icons/convert.js index 20c7852510..361755ef9e 100644 --- a/packages/react-icons/convert.js +++ b/packages/react-icons/convert.js @@ -5,6 +5,7 @@ const fs = require("fs"); const path = require("path"); const argv = require("yargs").boolean("selector").default("selector", false).argv; const _ = require("lodash"); +const addRexportsToIndex = require('./addRexportsToIndex'); const SRC_PATH = argv.source; const DEST_PATH = argv.dest; @@ -68,20 +69,11 @@ function processFiles(src, dest) { const indexPath = path.join(dest, 'index.tsx') // Finally add the interface definition and then write out the index. - indexContents.push('export { FluentIconsProps } from \'./utils/FluentIconsProps.types\''); - indexContents.push('export { default as wrapIcon } from \'./utils/wrapIcon\''); - indexContents.push('export { default as bundleIcon } from \'./utils/bundleIcon\''); - indexContents.push('export { createFluentIcon } from \'./utils/createFluentIcon\''); - indexContents.push('export type { FluentIcon } from \'./utils/createFluentIcon\''); - indexContents.push('export * from \'./utils/useIconState\''); - indexContents.push('export * from \'./utils/constants\''); - indexContents.push('export { IconDirectionContextProvider, useIconContext } from \'./contexts/index\''); - indexContents.push('export type { IconDirectionContextValue } from \'./contexts/index\''); + addRexportsToIndex(indexContents); fs.writeFileSync(indexPath, indexContents.join('\n'), (err) => { if (err) throw err; }); - } /** From 607d9af3bbda9bf8339b1b65b090e69baec9df0a Mon Sep 17 00:00:00 2001 From: Michael Loughry Date: Tue, 20 Feb 2024 17:27:55 +0000 Subject: [PATCH 2/3] Fix for discrepancy in file location --- packages/react-icons/addRexportsToIndex.js | 22 +++++++++++----------- packages/react-icons/convert-font.js | 2 +- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/packages/react-icons/addRexportsToIndex.js b/packages/react-icons/addRexportsToIndex.js index 698463e88a..2a31d90c20 100644 --- a/packages/react-icons/addRexportsToIndex.js +++ b/packages/react-icons/addRexportsToIndex.js @@ -1,12 +1,12 @@ -module.exports = function addRexportsToIndex(indexContents) { - indexContents.push('export { FluentIconsProps } from \'./utils/FluentIconsProps.types\''); - indexContents.push('export { default as wrapIcon } from \'./utils/wrapIcon\''); - indexContents.push('export { default as bundleIcon } from \'./utils/bundleIcon\''); - indexContents.push('export { createFluentIcon } from \'./utils/createFluentIcon\''); - indexContents.push('export { createFluentFontIcon } from \'../utils/fonts/createFluentFontIcon\''); - indexContents.push('export type { FluentIcon } from \'./utils/createFluentIcon\''); - indexContents.push('export * from \'./utils/useIconState\''); - indexContents.push('export * from \'./utils/constants\''); - indexContents.push('export { IconDirectionContextProvider, useIconContext } from \'./contexts/index\''); - indexContents.push('export type { IconDirectionContextValue } from \'./contexts/index\''); +module.exports = function addRexportsToIndex(indexContents, rootPath = `.`) { + indexContents.push(`export { FluentIconsProps } from \'${rootPath}/utils/FluentIconsProps.types\'`); + indexContents.push(`export { default as wrapIcon } from \'${rootPath}/utils/wrapIcon\'`); + indexContents.push(`export { default as bundleIcon } from \'${rootPath}/utils/bundleIcon\'`); + indexContents.push(`export { createFluentIcon } from \'${rootPath}/utils/createFluentIcon\'`); + indexContents.push(`export { createFluentFontIcon } from \'${rootPath}./utils/fonts/createFluentFontIcon\'`); + indexContents.push(`export type { FluentIcon } from \'${rootPath}/utils/createFluentIcon\'`); + indexContents.push(`export * from \'${rootPath}/utils/useIconState\'`); + indexContents.push(`export * from \'${rootPath}/utils/constants\'`); + indexContents.push(`export { IconDirectionContextProvider, useIconContext } from \'${rootPath}/contexts/index\'`); + indexContents.push(`export type { IconDirectionContextValue } from \'${rootPath}/contexts/index\'`); } \ No newline at end of file diff --git a/packages/react-icons/convert-font.js b/packages/react-icons/convert-font.js index 1d2d26bd4f..d409a5d01b 100644 --- a/packages/react-icons/convert-font.js +++ b/packages/react-icons/convert-font.js @@ -70,7 +70,7 @@ async function processFiles(src, dest) { const indexPath = path.join(dest, 'index.tsx') // Finally add the interface definition and then write out the index. - addRexportsToIndex(indexContents); + addRexportsToIndex(indexContents, '..'); await fs.writeFile(indexPath, indexContents.join('\n')); From d3daeae66fffec77086235bf351eed70ca5e2f2f Mon Sep 17 00:00:00 2001 From: Michael Loughry Date: Tue, 20 Feb 2024 17:40:44 +0000 Subject: [PATCH 3/3] Fix typo --- packages/react-icons/addRexportsToIndex.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-icons/addRexportsToIndex.js b/packages/react-icons/addRexportsToIndex.js index 2a31d90c20..03f3aece58 100644 --- a/packages/react-icons/addRexportsToIndex.js +++ b/packages/react-icons/addRexportsToIndex.js @@ -3,7 +3,7 @@ module.exports = function addRexportsToIndex(indexContents, rootPath = `.`) { indexContents.push(`export { default as wrapIcon } from \'${rootPath}/utils/wrapIcon\'`); indexContents.push(`export { default as bundleIcon } from \'${rootPath}/utils/bundleIcon\'`); indexContents.push(`export { createFluentIcon } from \'${rootPath}/utils/createFluentIcon\'`); - indexContents.push(`export { createFluentFontIcon } from \'${rootPath}./utils/fonts/createFluentFontIcon\'`); + indexContents.push(`export { createFluentFontIcon } from \'${rootPath}/utils/fonts/createFluentFontIcon\'`); indexContents.push(`export type { FluentIcon } from \'${rootPath}/utils/createFluentIcon\'`); indexContents.push(`export * from \'${rootPath}/utils/useIconState\'`); indexContents.push(`export * from \'${rootPath}/utils/constants\'`);