Skip to content

Commit

Permalink
chore: fugg it
Browse files Browse the repository at this point in the history
  • Loading branch information
Mohammer5 committed Sep 17, 2024
1 parent fae218c commit 4b43537
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ module.exports = {
'<rootDir>/jest.enzyme.config.js',
'<rootDir>/jest.testing-library.config.js',
],
roots: ['<rootDir>/collections', '<rootDir>/components'],
roots: ['<rootDir>/src'],
testPathIgnorePatterns: ['/node_modules/', '/build/', '/.d2/'],
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
"typescript": {
"optional": true
}
}
},
"main": "./build/cjs/index.js",
"module": "./build/es/index.js",
"exports": {
Expand Down
27 changes: 27 additions & 0 deletions scripts/move-types-to-folders.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
const fs = require('fs')
const path = require('path')

const SRC_FOLDER = path.join(__dirname, '../src')
const COMPONENTS_FOLDER = path.join(SRC_FOLDER, 'components')
const CONSTANTS_FOLDER = path.join(SRC_FOLDER, 'constants')
const ICONS_FOLDER = path.join(SRC_FOLDER, 'icons')
const TYPES_FOLDER = path.join(__dirname, '../types')
const TYPES_INDEX_JS = path.join(TYPES_FOLDER, 'index.d.ts')

const typesIndexJs = fs.readFileSync(TYPES_INDEX_JS, { encoding: 'utf8' })
const lines = typesIndexJs.split('\n').slice(0, -2)

let updatedTypesIndexJs = typeIndexJs
lines.forEach(line => {
const [name] = line.match(/(?<=\.\/)[^\/]+(?=\.d\.ts)/)
const filePath = path.join(TYPES_FOLDER, `${name}.d.ts`)
const targetPath = path.join(
name === 'constants' ? CONSTANTS_FOLDER : name === 'icons' ? ICONS_FOLDER : COMPONENTS_FOLDER,
name === 'constants' || name === 'icons' ? '' : name,
'index.d.ts'
)

updatedTypesIndexJs = updatedTypesIndexJs.replace(line, `export * from '../src/${'`)

fs.cpSync(filePath, targetPath)
})

0 comments on commit 4b43537

Please sign in to comment.