Skip to content

Commit

Permalink
Convert script to TypeScript
Browse files Browse the repository at this point in the history
  • Loading branch information
tujoworker committed Apr 13, 2023
1 parent 0b86309 commit 4be3345
Show file tree
Hide file tree
Showing 1,107 changed files with 1,116 additions and 1,116 deletions.
2 changes: 1 addition & 1 deletion packages/dnb-eufemia/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"build:types:dev": "nodemon --exec 'babel-node --extensions .js,.ts,.tsx ./scripts/prebuild/generateTypes.js' --ext js --watch './src/**/*' --watch './scripts/**/*'",
"build:types:esm": "yarn tsc --project tsconfig.definitions.json --declarationDir ./build/esm --rootDir src",
"precommit": "yarn lint-staged",
"dev:icons": "nodemon --exec 'babel-node --extensions .js,.ts,.tsx ./scripts/tools/convertIcons' --ignore '/icons/**' --ignore '*.json'",
"dev:icons": "nodemon --exec 'babel-node --extensions .js,.ts,.tsx ./scripts/tools/convertIcons' --ext ts --ignore '/icons/**' --ignore '*.json'",
"dev:packages": "nodemon --exec 'yarn build:packages && yarn build:copy' --ext js,html,json,css,scss --watch './src/**/*' --ignore './umd/*'",
"dev:resources": "nodemon --exec 'babel-node --extensions .js,.ts,.tsx ./scripts/prebuild/resources/makeResourcesPackage.js' --ext js,html,json,css,scss --watch './build/style/**/*' --watch './scripts/**/*' --ignore '*.json'",
"dev:tasks": "nodemon --exec 'babel-node --extensions .js,.ts,.tsx ./scripts/prebuild/dev.js' --watch 'rollup.config.js' --ext js,html,json,css,scss --watch './src/components/**/*' --watch './src/style/**/*' --watch './scripts/**/*' --ignore '*.json'",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export default async function convertSvgToJsx({
`> PrePublish: converting "svg to jsx" for "${assetsDir}" as started ...`
)

const icons = await transformSvg({
const icons: Array<{ name: string }> = await transformSvg({
srcPath,
destPath,
assetsDir,
Expand Down Expand Up @@ -144,7 +144,7 @@ const transformSvgToReact = ({ srcPath, destPath }) => {
try {
gulp
.src(srcPath, { cwd: ROOT_DIR })
.pipe(transform('utf8', transformToJsx))
.pipe(transform('utf8' as gulp.Encoding, transformToJsx))
.pipe(
rename((path) => {
path.extname = '.tsx'
Expand All @@ -159,7 +159,7 @@ const transformSvgToReact = ({ srcPath, destPath }) => {
})
}

const transformToJsx = (content, file) => {
const transformToJsx = (content, file): PromiseLike<string> => {
if (String(content).trim().length === 0) {
fs.unlinkSync(file.path)
return Promise.resolve('')
Expand Down Expand Up @@ -192,7 +192,7 @@ const transformToJsx = (content, file) => {
.then((res) => {
log.info(`> PrePublish: Icon was converted: ${basename}`)
resolve(
'/** This file is auto generated by convertSvgToJsx.js */\n\n' +
'/** This file is auto generated by convertSvgToJsx.ts */\n\n' +
prettier
.format(res, {
...prettierrc,
Expand Down Expand Up @@ -255,7 +255,6 @@ const makeIconsEntryFiles = async ({

await generateIndexFile({ icons, destPath, assetsDir })
await generateGroupFiles({
icons,
destPath,
assetsDir,
customIconsLockFilePath,
Expand All @@ -279,7 +278,7 @@ const generateIndexFile = async ({ icons, destPath, assetsDir }) => {
const _keys = icons.map(({ name }) => name).join(', ')

const indexContent = prettier.format(
`/** This file is auto generated by convertSvgToJsx.js */
`/** This file is auto generated by convertSvgToJsx.ts */
${_imports}
Expand Down Expand Up @@ -312,9 +311,10 @@ const generateGroupFiles = async ({
}) => {
// get the svg lock file
const { iconsLockFile } = IconsConfig({ assetsDir })
const lockFileContent = await readIconsLockFile({
file: customIconsLockFilePath || iconsLockFile,
})
const lockFileContent: Record<string, { bundleName: string }> =
await readIconsLockFile({
file: customIconsLockFilePath || iconsLockFile,
})

// from the svg lock file we can generate groups out of the "bundleName"
const groups = Object.entries(lockFileContent).reduce(
Expand Down Expand Up @@ -367,7 +367,7 @@ const generateGroupFiles = async ({
const _keys = entries.map(({ name }) => name).join(', ')

const groupFileContent = prettier.format(
`/** This file is auto generated by convertSvgToJsx.js */
`/** This file is auto generated by convertSvgToJsx.ts */
${_imports}
Expand Down Expand Up @@ -395,7 +395,7 @@ const generateFallbackIndexFiles = async ({
try {
await asyncForEach(Object.entries(icons), async ([, { filename }]) => {
const indexFileContent = prettier.format(
`/** This file is auto generated by convertSvgToJsx.js */
`/** This file is auto generated by convertSvgToJsx.ts */
import icon from './${assetsDir}/${filename}'
export default icon
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** This file is auto generated by convertSvgToJsx.js */
/** This file is auto generated by convertSvgToJsx.ts */

import question from './question'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** This file is auto generated by convertSvgToJsx.js */
/** This file is auto generated by convertSvgToJsx.ts */

import React from 'react'
const bell = (props) => (
Expand Down
2 changes: 1 addition & 1 deletion packages/dnb-eufemia/src/icons/above_the_line.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** This file is auto generated by convertSvgToJsx.js */
/** This file is auto generated by convertSvgToJsx.ts */

import icon from './dnb/above_the_line'
export default icon
2 changes: 1 addition & 1 deletion packages/dnb-eufemia/src/icons/above_the_line_medium.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** This file is auto generated by convertSvgToJsx.js */
/** This file is auto generated by convertSvgToJsx.ts */

import icon from './dnb/above_the_line_medium'
export default icon
2 changes: 1 addition & 1 deletion packages/dnb-eufemia/src/icons/account.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** This file is auto generated by convertSvgToJsx.js */
/** This file is auto generated by convertSvgToJsx.ts */

import icon from './dnb/account'
export default icon
2 changes: 1 addition & 1 deletion packages/dnb-eufemia/src/icons/account_card.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** This file is auto generated by convertSvgToJsx.js */
/** This file is auto generated by convertSvgToJsx.ts */

import icon from './dnb/account_card'
export default icon
2 changes: 1 addition & 1 deletion packages/dnb-eufemia/src/icons/account_card_medium.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** This file is auto generated by convertSvgToJsx.js */
/** This file is auto generated by convertSvgToJsx.ts */

import icon from './dnb/account_card_medium'
export default icon
2 changes: 1 addition & 1 deletion packages/dnb-eufemia/src/icons/account_in.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** This file is auto generated by convertSvgToJsx.js */
/** This file is auto generated by convertSvgToJsx.ts */

import icon from './dnb/account_in'
export default icon
2 changes: 1 addition & 1 deletion packages/dnb-eufemia/src/icons/account_in_medium.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** This file is auto generated by convertSvgToJsx.js */
/** This file is auto generated by convertSvgToJsx.ts */

import icon from './dnb/account_in_medium'
export default icon
2 changes: 1 addition & 1 deletion packages/dnb-eufemia/src/icons/account_medium.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** This file is auto generated by convertSvgToJsx.js */
/** This file is auto generated by convertSvgToJsx.ts */

import icon from './dnb/account_medium'
export default icon
2 changes: 1 addition & 1 deletion packages/dnb-eufemia/src/icons/account_out.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** This file is auto generated by convertSvgToJsx.js */
/** This file is auto generated by convertSvgToJsx.ts */

import icon from './dnb/account_out'
export default icon
2 changes: 1 addition & 1 deletion packages/dnb-eufemia/src/icons/account_out_medium.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** This file is auto generated by convertSvgToJsx.js */
/** This file is auto generated by convertSvgToJsx.ts */

import icon from './dnb/account_out_medium'
export default icon
2 changes: 1 addition & 1 deletion packages/dnb-eufemia/src/icons/account_percent.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** This file is auto generated by convertSvgToJsx.js */
/** This file is auto generated by convertSvgToJsx.ts */

import icon from './dnb/account_percent'
export default icon
2 changes: 1 addition & 1 deletion packages/dnb-eufemia/src/icons/account_percent_medium.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** This file is auto generated by convertSvgToJsx.js */
/** This file is auto generated by convertSvgToJsx.ts */

import icon from './dnb/account_percent_medium'
export default icon
2 changes: 1 addition & 1 deletion packages/dnb-eufemia/src/icons/add.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** This file is auto generated by convertSvgToJsx.js */
/** This file is auto generated by convertSvgToJsx.ts */

import icon from './dnb/add'
export default icon
2 changes: 1 addition & 1 deletion packages/dnb-eufemia/src/icons/add_circled.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** This file is auto generated by convertSvgToJsx.js */
/** This file is auto generated by convertSvgToJsx.ts */

import icon from './dnb/add_circled'
export default icon
2 changes: 1 addition & 1 deletion packages/dnb-eufemia/src/icons/add_circled_medium.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** This file is auto generated by convertSvgToJsx.js */
/** This file is auto generated by convertSvgToJsx.ts */

import icon from './dnb/add_circled_medium'
export default icon
2 changes: 1 addition & 1 deletion packages/dnb-eufemia/src/icons/add_medium.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** This file is auto generated by convertSvgToJsx.js */
/** This file is auto generated by convertSvgToJsx.ts */

import icon from './dnb/add_medium'
export default icon
2 changes: 1 addition & 1 deletion packages/dnb-eufemia/src/icons/ainvoice.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** This file is auto generated by convertSvgToJsx.js */
/** This file is auto generated by convertSvgToJsx.ts */

import icon from './dnb/ainvoice'
export default icon
2 changes: 1 addition & 1 deletion packages/dnb-eufemia/src/icons/ainvoice_medium.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** This file is auto generated by convertSvgToJsx.js */
/** This file is auto generated by convertSvgToJsx.ts */

import icon from './dnb/ainvoice_medium'
export default icon
2 changes: 1 addition & 1 deletion packages/dnb-eufemia/src/icons/ambulance.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** This file is auto generated by convertSvgToJsx.js */
/** This file is auto generated by convertSvgToJsx.ts */

import icon from './dnb/ambulance'
export default icon
2 changes: 1 addition & 1 deletion packages/dnb-eufemia/src/icons/ambulance_medium.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** This file is auto generated by convertSvgToJsx.js */
/** This file is auto generated by convertSvgToJsx.ts */

import icon from './dnb/ambulance_medium'
export default icon
2 changes: 1 addition & 1 deletion packages/dnb-eufemia/src/icons/animal_print.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** This file is auto generated by convertSvgToJsx.js */
/** This file is auto generated by convertSvgToJsx.ts */

import icon from './dnb/animal_print'
export default icon
2 changes: 1 addition & 1 deletion packages/dnb-eufemia/src/icons/animal_print_medium.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** This file is auto generated by convertSvgToJsx.js */
/** This file is auto generated by convertSvgToJsx.ts */

import icon from './dnb/animal_print_medium'
export default icon
2 changes: 1 addition & 1 deletion packages/dnb-eufemia/src/icons/apple_watch.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** This file is auto generated by convertSvgToJsx.js */
/** This file is auto generated by convertSvgToJsx.ts */

import icon from './dnb/apple_watch'
export default icon
2 changes: 1 addition & 1 deletion packages/dnb-eufemia/src/icons/apple_watch_medium.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** This file is auto generated by convertSvgToJsx.js */
/** This file is auto generated by convertSvgToJsx.ts */

import icon from './dnb/apple_watch_medium'
export default icon
2 changes: 1 addition & 1 deletion packages/dnb-eufemia/src/icons/arrow_down.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** This file is auto generated by convertSvgToJsx.js */
/** This file is auto generated by convertSvgToJsx.ts */

import icon from './dnb/arrow_down'
export default icon
2 changes: 1 addition & 1 deletion packages/dnb-eufemia/src/icons/arrow_down_medium.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** This file is auto generated by convertSvgToJsx.js */
/** This file is auto generated by convertSvgToJsx.ts */

import icon from './dnb/arrow_down_medium'
export default icon
2 changes: 1 addition & 1 deletion packages/dnb-eufemia/src/icons/arrow_left.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** This file is auto generated by convertSvgToJsx.js */
/** This file is auto generated by convertSvgToJsx.ts */

import icon from './dnb/arrow_left'
export default icon
2 changes: 1 addition & 1 deletion packages/dnb-eufemia/src/icons/arrow_left_medium.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** This file is auto generated by convertSvgToJsx.js */
/** This file is auto generated by convertSvgToJsx.ts */

import icon from './dnb/arrow_left_medium'
export default icon
2 changes: 1 addition & 1 deletion packages/dnb-eufemia/src/icons/arrow_right.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** This file is auto generated by convertSvgToJsx.js */
/** This file is auto generated by convertSvgToJsx.ts */

import icon from './dnb/arrow_right'
export default icon
2 changes: 1 addition & 1 deletion packages/dnb-eufemia/src/icons/arrow_right_medium.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** This file is auto generated by convertSvgToJsx.js */
/** This file is auto generated by convertSvgToJsx.ts */

import icon from './dnb/arrow_right_medium'
export default icon
2 changes: 1 addition & 1 deletion packages/dnb-eufemia/src/icons/arrow_up.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** This file is auto generated by convertSvgToJsx.js */
/** This file is auto generated by convertSvgToJsx.ts */

import icon from './dnb/arrow_up'
export default icon
2 changes: 1 addition & 1 deletion packages/dnb-eufemia/src/icons/arrow_up_medium.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** This file is auto generated by convertSvgToJsx.js */
/** This file is auto generated by convertSvgToJsx.ts */

import icon from './dnb/arrow_up_medium'
export default icon
2 changes: 1 addition & 1 deletion packages/dnb-eufemia/src/icons/attachment.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** This file is auto generated by convertSvgToJsx.js */
/** This file is auto generated by convertSvgToJsx.ts */

import icon from './dnb/attachment'
export default icon
2 changes: 1 addition & 1 deletion packages/dnb-eufemia/src/icons/attachment_medium.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** This file is auto generated by convertSvgToJsx.js */
/** This file is auto generated by convertSvgToJsx.ts */

import icon from './dnb/attachment_medium'
export default icon
2 changes: 1 addition & 1 deletion packages/dnb-eufemia/src/icons/baby.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** This file is auto generated by convertSvgToJsx.js */
/** This file is auto generated by convertSvgToJsx.ts */

import icon from './dnb/baby'
export default icon
2 changes: 1 addition & 1 deletion packages/dnb-eufemia/src/icons/baby_medium.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** This file is auto generated by convertSvgToJsx.js */
/** This file is auto generated by convertSvgToJsx.ts */

import icon from './dnb/baby_medium'
export default icon
2 changes: 1 addition & 1 deletion packages/dnb-eufemia/src/icons/bandage.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** This file is auto generated by convertSvgToJsx.js */
/** This file is auto generated by convertSvgToJsx.ts */

import icon from './dnb/bandage'
export default icon
2 changes: 1 addition & 1 deletion packages/dnb-eufemia/src/icons/bandage_medium.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** This file is auto generated by convertSvgToJsx.js */
/** This file is auto generated by convertSvgToJsx.ts */

import icon from './dnb/bandage_medium'
export default icon
2 changes: 1 addition & 1 deletion packages/dnb-eufemia/src/icons/bank.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** This file is auto generated by convertSvgToJsx.js */
/** This file is auto generated by convertSvgToJsx.ts */

import icon from './dnb/bank'
export default icon
2 changes: 1 addition & 1 deletion packages/dnb-eufemia/src/icons/bank_medium.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** This file is auto generated by convertSvgToJsx.js */
/** This file is auto generated by convertSvgToJsx.ts */

import icon from './dnb/bank_medium'
export default icon
2 changes: 1 addition & 1 deletion packages/dnb-eufemia/src/icons/bankid.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** This file is auto generated by convertSvgToJsx.js */
/** This file is auto generated by convertSvgToJsx.ts */

import icon from './dnb/bankid'
export default icon
2 changes: 1 addition & 1 deletion packages/dnb-eufemia/src/icons/bankid_medium.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** This file is auto generated by convertSvgToJsx.js */
/** This file is auto generated by convertSvgToJsx.ts */

import icon from './dnb/bankid_medium'
export default icon
2 changes: 1 addition & 1 deletion packages/dnb-eufemia/src/icons/bankid_mobile.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** This file is auto generated by convertSvgToJsx.js */
/** This file is auto generated by convertSvgToJsx.ts */

import icon from './dnb/bankid_mobile'
export default icon
2 changes: 1 addition & 1 deletion packages/dnb-eufemia/src/icons/bankid_mobile_medium.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** This file is auto generated by convertSvgToJsx.js */
/** This file is auto generated by convertSvgToJsx.ts */

import icon from './dnb/bankid_mobile_medium'
export default icon
2 changes: 1 addition & 1 deletion packages/dnb-eufemia/src/icons/bankid_qr.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** This file is auto generated by convertSvgToJsx.js */
/** This file is auto generated by convertSvgToJsx.ts */

import icon from './dnb/bankid_qr'
export default icon
2 changes: 1 addition & 1 deletion packages/dnb-eufemia/src/icons/bankid_qr_medium.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** This file is auto generated by convertSvgToJsx.js */
/** This file is auto generated by convertSvgToJsx.ts */

import icon from './dnb/bankid_qr_medium'
export default icon
2 changes: 1 addition & 1 deletion packages/dnb-eufemia/src/icons/bell.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** This file is auto generated by convertSvgToJsx.js */
/** This file is auto generated by convertSvgToJsx.ts */

import icon from './dnb/bell'
export default icon
2 changes: 1 addition & 1 deletion packages/dnb-eufemia/src/icons/bell_medium.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** This file is auto generated by convertSvgToJsx.js */
/** This file is auto generated by convertSvgToJsx.ts */

import icon from './dnb/bell_medium'
export default icon
2 changes: 1 addition & 1 deletion packages/dnb-eufemia/src/icons/bicycle.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** This file is auto generated by convertSvgToJsx.js */
/** This file is auto generated by convertSvgToJsx.ts */

import icon from './dnb/bicycle'
export default icon
Loading

0 comments on commit 4be3345

Please sign in to comment.