Skip to content

Commit

Permalink
fix(extras): re-package #17052
Browse files Browse the repository at this point in the history
  • Loading branch information
rstoenescu committed Mar 29, 2024
1 parent 5823b8f commit eecfba6
Show file tree
Hide file tree
Showing 18 changed files with 5,868 additions and 11,801 deletions.
8,205 changes: 2,052 additions & 6,153 deletions extras/bootstrap-icons/bootstrap-icons.css

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions extras/build/animate.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const { join, resolve, basename } = require('path')

const dist = resolve(__dirname, '../animate')

const pkgFolder = resolve(__dirname, `../node_modules/${packageName}/`)
const pkgFolder = resolve(__dirname, `../node_modules/${ packageName }/`)
const cssFiles = glob.sync(pkgFolder + '/source/*/*.css')
const cssNames = new Set()

Expand All @@ -18,7 +18,7 @@ const outAnimations = []
const generalAnimations = []

function extract (file) {
const name = basename(file).match(/(.*)\.css/)[1]
const name = basename(file).match(/(.*)\.css/)[ 1 ]

if (cssNames.has(name)) {
return
Expand All @@ -40,12 +40,12 @@ function extract (file) {

function getList (prefix) {
return `
${prefix}generalAnimations = ${JSON.stringify(generalAnimations, null, 2)}
${ prefix }generalAnimations = ${ JSON.stringify(generalAnimations, null, 2) }
${prefix}inAnimations = ${JSON.stringify(inAnimations, null, 2)}
${ prefix }inAnimations = ${ JSON.stringify(inAnimations, null, 2) }
${prefix}outAnimations = ${JSON.stringify(outAnimations, null, 2)}
`.replace(/"/g, `'`)
${ prefix }outAnimations = ${ JSON.stringify(outAnimations, null, 2) }
`.replace(/"/g, '\'')
}

if (cssFiles.length === 0) {
Expand All @@ -62,12 +62,12 @@ else {

copySync(join(pkgFolder, 'LICENSE'), join(dist, 'LICENSE'))

const common = getList(`module.exports.`)
const common = getList('module.exports.')

writeFileSync(join(dist, 'animate-list.js'), common, 'utf-8')
writeFileSync(join(dist, 'animate-list.mjs'), getList(`export const `), 'utf-8')
writeFileSync(join(dist, 'animate-list.mjs'), getList('export const '), 'utf-8')
writeFileSync(join(dist, 'animate-list.common.js'), common, 'utf-8')

writeFileSync(join(dist, 'animate-list.d.ts'), getList(`export type `).replace(/\[/g, '').replace(/\]/g, ';').replace(/\ '/g, ` | '`).replace(/,/g, ''), 'utf-8')
writeFileSync(join(dist, 'animate-list.common.d.ts'), getList(`export type `).replace(/\[/g, '').replace(/\]/g, ';').replace(/\ '/g, ` | '`).replace(/,/g, ''), 'utf-8')
writeFileSync(join(dist, 'animate-list.d.ts'), getList('export type ').replace(/\[/g, '').replace(/\]/g, ';').replace(/\ {2}'/g, ' | \'').replace(/,/g, ''), 'utf-8')
writeFileSync(join(dist, 'animate-list.common.d.ts'), getList('export type ').replace(/\[/g, '').replace(/\]/g, ';').replace(/\ {2}'/g, ' | \'').replace(/,/g, ''), 'utf-8')
}
28 changes: 14 additions & 14 deletions extras/build/bootstrap-icons.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ const { copySync } = require('fs-extra')
const { writeFileSync } = require('fs')
const { resolve, join } = require('path')

let skipped = []
const distFolder = resolve(__dirname, `../bootstrap-icons`)
const skipped = []
const distFolder = resolve(__dirname, '../bootstrap-icons')
const { defaultNameMapper, extract, writeExports, copyCssFile } = require('./utils')

const svgFolder = resolve(__dirname, `../node_modules/${packageName}/icons/`)
const svgFolder = resolve(__dirname, `../node_modules/${ packageName }/icons/`)
const svgFiles = glob.sync(svgFolder + '/*.svg')
let iconNames = new Set()

Expand All @@ -35,13 +35,13 @@ svgFiles.forEach(file => {

iconNames.add(name)
}
catch(err) {
catch (err) {
console.error(err)
skipped.push(name)
}
})

iconNames = [...iconNames]
iconNames = [ ...iconNames ]
svgExports.sort((a, b) => {
return ('' + a).localeCompare(b)
})
Expand All @@ -63,26 +63,26 @@ const webfont = [

webfont.forEach(file => {
copySync(
resolve(__dirname, `../node_modules/${packageName}/font/fonts/${file}`),
resolve(__dirname, `../bootstrap-icons/${file}`)
resolve(__dirname, `../node_modules/${ packageName }/font/fonts/${ file }`),
resolve(__dirname, `../bootstrap-icons/${ file }`)
)
})

copyCssFile({
from: resolve(__dirname, `../node_modules/${packageName}/font/bootstrap-icons.css`),
to: resolve(__dirname, `../bootstrap-icons/bootstrap-icons.css`),
from: resolve(__dirname, `../node_modules/${ packageName }/font/bootstrap-icons.css`),
to: resolve(__dirname, '../bootstrap-icons/bootstrap-icons.css'),
replaceFn: content => {
return content.replace(/src:[^;]+;/, `src: url("./bootstrap-icons.woff2") format("woff2"), url("./bootstrap-icons.woff") format("woff");`)
return content.replace(/src:[^;]+;/, 'src: url("./bootstrap-icons.woff2") format("woff2"), url("./bootstrap-icons.woff") format("woff");')
}
})

copySync(
resolve(__dirname, `../node_modules/${packageName}/LICENSE`),
resolve(__dirname, `../bootstrap-icons/LICENSE`)
resolve(__dirname, `../node_modules/${ packageName }/LICENSE`),
resolve(__dirname, '../bootstrap-icons/LICENSE')
)

// write the JSON file
const file = resolve(__dirname, join('..', distName, 'icons.json'))
writeFileSync(file, JSON.stringify([...iconNames].sort(), null, 2), 'utf-8')
writeFileSync(file, JSON.stringify([ ...iconNames ].sort(), null, 2), 'utf-8')

console.log(`${distName} done with ${iconNames.length} icons`)
console.log(`${ distName } done with ${ iconNames.length } icons`)
30 changes: 15 additions & 15 deletions extras/build/eva-icons.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@ const { writeFileSync } = require('fs')
const { resolve, join } = require('path')

const skipped = []
const distFolder = resolve(__dirname, `../eva-icons`)
const distFolder = resolve(__dirname, '../eva-icons')
const { defaultNameMapper, extract, writeExports, copyCssFile, getBanner } = require('./utils')

const svgFolder = resolve(__dirname, `../node_modules/${packageName}/`)
const iconTypes = ['fill', 'outline']
const svgFolder = resolve(__dirname, `../node_modules/${ packageName }/`)
const iconTypes = [ 'fill', 'outline' ]
let iconNames = new Set()

const svgExports = []
const typeExports = []

iconTypes.forEach(type => {
const svgFiles = glob.sync(svgFolder + `/${type}/svg/*.svg`)
const svgFiles = glob.sync(svgFolder + `/${ type }/svg/*.svg`)

svgFiles.forEach(file => {
const name = defaultNameMapper(file, prefix)
Expand All @@ -38,14 +38,14 @@ iconTypes.forEach(type => {

iconNames.add(name)
}
catch(err) {
catch (err) {
console.error(err)
skipped.push(name)
}
})
})

iconNames = [...iconNames]
iconNames = [ ...iconNames ]
svgExports.sort((a, b) => {
return ('' + a).localeCompare(b)
})
Expand All @@ -67,27 +67,27 @@ const webfont = [

webfont.forEach(file => {
copySync(
resolve(__dirname, `../node_modules/${packageName}/style/fonts/${file}`),
resolve(__dirname, `../eva-icons/${file}`)
resolve(__dirname, `../node_modules/${ packageName }/style/fonts/${ file }`),
resolve(__dirname, `../eva-icons/${ file }`)
)
})

copyCssFile({
from: resolve(__dirname, `../node_modules/${packageName}/style/eva-icons.css`),
to: resolve(__dirname, `../eva-icons/eva-icons.css`),
from: resolve(__dirname, `../node_modules/${ packageName }/style/eva-icons.css`),
to: resolve(__dirname, '../eva-icons/eva-icons.css'),
replaceFn: content => (
getBanner('Eva Icons', packageName)
getBanner('Eva Icons', packageName)
+ (
content
.replace('@font-face {', '@font-face {\nfont-display: block;')
.replace(`src: url("./fonts/Eva-Icons.eot");`, '')
.replace(/src:[^;]+;/, `src: url("./Eva-Icons.woff2") format("woff2"), url("./Eva-Icons.woff") format("woff");`)
.replace('src: url("./fonts/Eva-Icons.eot");', '')
.replace(/src:[^;]+;/, 'src: url("./Eva-Icons.woff2") format("woff2"), url("./Eva-Icons.woff") format("woff");')
)
)
})

// write the JSON file
const file = resolve(__dirname, join('..', distName, 'icons.json'))
writeFileSync(file, JSON.stringify([...iconNames].sort(), null, 2), 'utf-8')
writeFileSync(file, JSON.stringify([ ...iconNames ].sort(), null, 2), 'utf-8')

console.log(`${distName} done with ${iconNames.length} icons`)
console.log(`${ distName } done with ${ iconNames.length } icons`)
32 changes: 16 additions & 16 deletions extras/build/fontawesome-v5.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,42 +10,42 @@ const { copySync } = require('fs-extra')
const { writeFileSync } = require('fs')
const { resolve, join } = require('path')

let skipped = []
const distFolder = resolve(__dirname, `../fontawesome-v5`)
const skipped = []
const distFolder = resolve(__dirname, '../fontawesome-v5')
const { defaultNameMapper, extract, writeExports } = require('./utils')

const svgFolder = resolve(__dirname, `../node_modules/${packageName}/svgs/`)
const iconTypes = ['brands', 'regular', 'solid']
const svgFolder = resolve(__dirname, `../node_modules/${ packageName }/svgs/`)
const iconTypes = [ 'brands', 'regular', 'solid' ]
let iconNames = new Set()

const svgExports = []
const typeExports = []

iconTypes.forEach(type => {
const svgFiles = glob.sync(svgFolder + `/${type}/*.svg`)
const svgFiles = glob.sync(svgFolder + `/${ type }/*.svg`)

svgFiles.forEach(file => {
const name = defaultNameMapper(file, prefix + type.charAt(0))

if (iconNames.has(name)) {
return
}

try {
const { svgDef, typeDef } = extract(file, name)
svgExports.push(svgDef)
typeExports.push(typeDef)

iconNames.add(name)
}
catch(err) {
catch (err) {
console.error(err)
skipped.push(name)
}
})
})

iconNames = [...iconNames]
iconNames = [ ...iconNames ]
svgExports.sort((a, b) => {
return ('' + a).localeCompare(b)
})
Expand All @@ -71,18 +71,18 @@ const webfont = [

webfont.forEach(file => {
copySync(
resolve(__dirname, `../node_modules/${packageName}/webfonts/${file}`),
resolve(__dirname, `../fontawesome-v5/${file}`)
resolve(__dirname, `../node_modules/${ packageName }/webfonts/${ file }`),
resolve(__dirname, `../fontawesome-v5/${ file }`)
)
})

copySync(
resolve(__dirname, `../node_modules/${packageName}/LICENSE.txt`),
resolve(__dirname, `../fontawesome-v5/LICENSE.txt`)
resolve(__dirname, `../node_modules/${ packageName }/LICENSE.txt`),
resolve(__dirname, '../fontawesome-v5/LICENSE.txt')
)

// write the JSON file
const file = resolve(__dirname, join('..', distName, 'icons.json'))
writeFileSync(file, JSON.stringify([...iconNames].sort(), null, 2), 'utf-8')
writeFileSync(file, JSON.stringify([ ...iconNames ].sort(), null, 2), 'utf-8')

console.log(`${distName} done with ${iconNames.length} icons`)
console.log(`${ distName } done with ${ iconNames.length } icons`)
32 changes: 16 additions & 16 deletions extras/build/fontawesome-v6.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,22 @@ const prefix = 'fa'

const glob = require('glob')
const { copySync } = require('fs-extra')
const { readFileSync, writeFileSync } = require('fs')
const { writeFileSync } = require('fs')
const { resolve, join } = require('path')

let skipped = []
const distFolder = resolve(__dirname, `../fontawesome-v6`)
const skipped = []
const distFolder = resolve(__dirname, '../fontawesome-v6')
const { defaultNameMapper, extract, writeExports, copyCssFile } = require('./utils')

const svgFolder = resolve(__dirname, `../node_modules/${packageName}/svgs/`)
const iconTypes = ['brands', 'regular', 'solid']
const svgFolder = resolve(__dirname, `../node_modules/${ packageName }/svgs/`)
const iconTypes = [ 'brands', 'regular', 'solid' ]
let iconNames = new Set()

const svgExports = []
const typeExports = []

iconTypes.forEach(type => {
const svgFiles = glob.sync(svgFolder + `/${type}/*.svg`)
const svgFiles = glob.sync(svgFolder + `/${ type }/*.svg`)

svgFiles.forEach(file => {
const name = defaultNameMapper(file, prefix + type.charAt(0))
Expand All @@ -38,14 +38,14 @@ iconTypes.forEach(type => {

iconNames.add(name)
}
catch(err) {
catch (err) {
console.error(err)
skipped.push(name)
}
})
})

iconNames = [...iconNames]
iconNames = [ ...iconNames ]
svgExports.sort((a, b) => {
return ('' + a).localeCompare(b)
})
Expand Down Expand Up @@ -73,24 +73,24 @@ const webfont = [

webfont.forEach(file => {
copySync(
resolve(__dirname, `../node_modules/${packageName}/webfonts/${file}`),
resolve(__dirname, `../fontawesome-v6/${file}`)
resolve(__dirname, `../node_modules/${ packageName }/webfonts/${ file }`),
resolve(__dirname, `../fontawesome-v6/${ file }`)
)
})

copyCssFile({
from: resolve(__dirname, `../node_modules/${packageName}/css/all.css`),
to: resolve(__dirname, `../fontawesome-v6/fontawesome-v6.css`),
from: resolve(__dirname, `../node_modules/${ packageName }/css/all.css`),
to: resolve(__dirname, '../fontawesome-v6/fontawesome-v6.css'),
replaceFn: content => content.replace(/\.\.\/webfonts/g, '\.')
})

copySync(
resolve(__dirname, `../node_modules/${packageName}/LICENSE.txt`),
resolve(__dirname, `../fontawesome-v6/LICENSE.txt`)
resolve(__dirname, `../node_modules/${ packageName }/LICENSE.txt`),
resolve(__dirname, '../fontawesome-v6/LICENSE.txt')
)

// write the JSON file
const file = resolve(__dirname, join('..', distName, 'icons.json'))
writeFileSync(file, JSON.stringify([...iconNames].sort(), null, 2), 'utf-8')
writeFileSync(file, JSON.stringify([ ...iconNames ].sort(), null, 2), 'utf-8')

console.log(`${distName} done with ${iconNames.length} icons`)
console.log(`${ distName } done with ${ iconNames.length } icons`)
6 changes: 3 additions & 3 deletions extras/build/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ async function generate () {
const lines = str.split('\n')
lines.map(line => {
if (line.endsWith('.woff2')) {
const parts = line.match(/.*\/(.*?)/)[0].split('/')
const parts = line.match(/.*\/(.*?)/)[ 0 ].split('/')
if (parts.length) {
const version = parts[ parts.length - 2 ]
const name = parts[ parts.length - 3 ]
materialFontVersions[name] = version
materialFontVersions[ name ] = version
}
}
})
Expand All @@ -54,7 +54,7 @@ async function generate () {
await handleChild(child)
})
},
{ concurrency: maxJobCount },
{ concurrency: maxJobCount }
)

function runJob (scriptFile) {
Expand Down
Loading

0 comments on commit eecfba6

Please sign in to comment.