Skip to content

Commit

Permalink
generate icons list for build
Browse files Browse the repository at this point in the history
  • Loading branch information
codecalm committed Mar 13, 2024
1 parent dacfda3 commit 751e62a
Show file tree
Hide file tree
Showing 19 changed files with 52 additions and 12 deletions.
17 changes: 17 additions & 0 deletions .build/build-icons.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,20 @@ export const buildJsIcons = ({
fs.writeFileSync(path.resolve(DIST_DIR, `./src/aliases.ts`), aliasesStr || `export {};`, 'utf-8')
}

export const buildIconsList = (name) => {
const DIST_DIR = path.resolve(PACKAGES_DIR, name);
const allIcons = getAllIcons(false, true)

let index = []
Object.entries(allIcons).forEach(([type, icons]) => {
icons.forEach((icon, i) => {
process.stdout.write(`Building \`${name}\` ${type} ${i}/${icons.length}: ${icon.name.padEnd(42)}\r`)

const iconName = `${icon.name}${type !== 'outline' ? `-${type}` : ''}`

index.push(iconName)
})
})

fs.writeFileSync(path.resolve(DIST_DIR, `./src/icons-list.ts`), `export default ${JSON.stringify(index, null, 2)};`, 'utf-8')
}
3 changes: 2 additions & 1 deletion packages/icons-preact/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
src/aliases.ts
src/aliases.ts
src/icons-list.ts
4 changes: 3 additions & 1 deletion packages/icons-preact/build.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env node

import { buildJsIcons } from '../../.build/build-icons.mjs'
import { buildJsIcons, buildIconsList } from '../../.build/build-icons.mjs'

const componentTemplate = ({
type,
Expand All @@ -27,3 +27,5 @@ buildJsIcons({
indexFile: 'index.ts',
extension: 'ts'
})

buildIconsList('icons-preact')
1 change: 1 addition & 0 deletions packages/icons-preact/src/tabler-icons-preact.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export * from './icons/index';
export * as icons from './icons/index';
export * as iconsList from './icons-list';
export * from './aliases';

export { default as createReactComponent } from './createPreactComponent';
Expand Down
3 changes: 2 additions & 1 deletion packages/icons-react-native/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
src/aliases.ts
src/aliases.ts
src/icons-list.ts
4 changes: 3 additions & 1 deletion packages/icons-react-native/build.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env node

import { buildJsIcons } from '../../.build/build-icons.mjs'
import { buildJsIcons, buildIconsList } from '../../.build/build-icons.mjs'

const componentTemplate = ({
type,
Expand All @@ -27,3 +27,5 @@ buildJsIcons({
pascalCase: true,
extension: 'ts'
})

buildIconsList('icons-react-native')
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export * from './icons/index';
export * as icons from './icons/index';
export * as iconsList from './icons-list';
export * from './aliases';
export { default as createReactComponent } from './createReactNativeComponent';

Expand Down
3 changes: 2 additions & 1 deletion packages/icons-react/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
src/aliases.ts
src/aliases.ts
src/icons-list.ts
4 changes: 3 additions & 1 deletion packages/icons-react/build.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env node

import { buildJsIcons } from '../../.build/build-icons.mjs'
import { buildJsIcons, buildIconsList } from '../../.build/build-icons.mjs'

const componentTemplate = ({
type,
Expand All @@ -27,3 +27,5 @@ buildJsIcons({
pascalCase: true,
extension: 'ts'
})

buildIconsList('icons-react')
1 change: 1 addition & 0 deletions packages/icons-react/src/tabler-icons-react.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export * from './icons/index';
export * as icons from './icons/index';
export * as iconsList from './icons-list';
export * from './aliases';
export { default as createReactComponent } from './createReactComponent';

Expand Down
3 changes: 2 additions & 1 deletion packages/icons-solidjs/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
src/aliases.ts
src/aliases.ts
src/icons-list.ts
4 changes: 3 additions & 1 deletion packages/icons-solidjs/build.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env node

import { buildJsIcons } from '../../.build/build-icons.mjs'
import { buildJsIcons, buildIconsList } from '../../.build/build-icons.mjs'

const componentTemplate = ({
type,
Expand All @@ -27,3 +27,5 @@ buildJsIcons({
extension: 'ts',
indexFile: 'index.ts'
})

buildIconsList('icons-solidjs')
1 change: 1 addition & 0 deletions packages/icons-solidjs/src/tabler-icons-solidjs.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export * from './icons/index';
export * as icons from './icons/index';
export * as iconsList from './icons-list';
export * from './aliases';

export { default as createSolidComponent } from './createSolidComponent';
3 changes: 2 additions & 1 deletion packages/icons-svelte/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
src/icons/*.svelte
.svelte-kit
src/aliases.ts
src/aliases.ts
src/icons-list.ts
3 changes: 2 additions & 1 deletion packages/icons-svelte/build.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env node

import { buildJsIcons } from '../../.build/build-icons.mjs'
import { buildJsIcons, buildIconsList } from '../../.build/build-icons.mjs'
import { readFileSync, writeFileSync } from 'fs'
import { getAllIcons, toPascalCase } from '../../.build/helpers.mjs'

Expand Down Expand Up @@ -72,3 +72,4 @@ buildJsIcons({
})

updatePackageJson()
buildIconsList('icons-svelte')
1 change: 1 addition & 0 deletions packages/icons-svelte/src/tabler-icons-svelte.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export * from "./icons/index.js";
export * as icons from "./icons/index.js";
export * as iconsList from './icons-list';
export * from "./aliases.js";
export { default as defaultAttributes } from './defaultAttributes'

Expand Down
3 changes: 2 additions & 1 deletion packages/icons-vue/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
src/aliases.ts
src/aliases.ts
src/icons-list.ts
4 changes: 3 additions & 1 deletion packages/icons-vue/build.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env node

import { buildJsIcons } from '../../.build/build-icons.mjs'
import { buildJsIcons, buildIconsList } from '../../.build/build-icons.mjs'

const componentTemplate = ({
type,
Expand All @@ -26,3 +26,5 @@ buildJsIcons({
extension: 'ts',
indexFile: 'index.ts',
})

buildIconsList('icons-vue')
1 change: 1 addition & 0 deletions packages/icons-vue/src/tabler-icons-vue.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export * from './icons/index';
export * as icons from './icons/index';
export * as iconsList from './icons-list';
export * from './aliases';

export { default as createVueComponent } from './createVueComponent';

0 comments on commit 751e62a

Please sign in to comment.