update icons
This commit is contained in:
parent
8391b90880
commit
ad4f8659b0
|
|
@ -507,3 +507,25 @@ export const convertIconsToImages = async (dir, extension, size = 240) => {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export const getMaxUnicode = () => {
|
||||||
|
const files = globSync(path.join(ICONS_SRC_DIR, '**/*.svg'))
|
||||||
|
let maxUnicode = 0
|
||||||
|
|
||||||
|
files.forEach(function (file) {
|
||||||
|
const svgFile = fs.readFileSync(file).toString()
|
||||||
|
|
||||||
|
svgFile.replace(/unicode: "([a-f0-9.]+)"/i, function (m, unicode) {
|
||||||
|
const newUnicode = parseInt(unicode, 16)
|
||||||
|
|
||||||
|
if (newUnicode) {
|
||||||
|
maxUnicode = Math.max(maxUnicode, newUnicode)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
console.log(`Max unicode: ${maxUnicode}`)
|
||||||
|
|
||||||
|
return maxUnicode
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,47 +0,0 @@
|
||||||
import { globSync, glob } from 'glob'
|
|
||||||
import fs from 'fs'
|
|
||||||
import path from 'path'
|
|
||||||
import { ICONS_SRC_DIR } from './helpers.mjs'
|
|
||||||
|
|
||||||
const getMaxUnicode = () => {
|
|
||||||
const files = globSync(path.join(ICONS_SRC_DIR, '**/*.svg'))
|
|
||||||
let maxUnicode = 0
|
|
||||||
|
|
||||||
files.forEach(function(file) {
|
|
||||||
const svgFile = fs.readFileSync(file).toString()
|
|
||||||
|
|
||||||
svgFile.replace(/unicode: "([a-f0-9.]+)"/i, function(m, unicode) {
|
|
||||||
const newUnicode = parseInt(unicode, 16)
|
|
||||||
|
|
||||||
if (newUnicode) {
|
|
||||||
maxUnicode = Math.max(maxUnicode, newUnicode)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
return maxUnicode
|
|
||||||
}
|
|
||||||
|
|
||||||
let maxUnicode = getMaxUnicode()
|
|
||||||
|
|
||||||
console.log(`Max unicode: ${maxUnicode}`)
|
|
||||||
|
|
||||||
const files = globSync(path.join(ICONS_SRC_DIR, '**/*.svg'))
|
|
||||||
|
|
||||||
files.forEach(function(file) {
|
|
||||||
let svgFile = fs.readFileSync(file).toString()
|
|
||||||
|
|
||||||
if (!svgFile.match(/\nunicode: "?([a-f0-9.]+)"?/i)) {
|
|
||||||
maxUnicode++
|
|
||||||
const unicode = maxUnicode.toString(16)
|
|
||||||
|
|
||||||
if (unicode) {
|
|
||||||
svgFile = svgFile.replace(/-->\n<svg/i, function(m) {
|
|
||||||
return `unicode: "${unicode}"\n${m}`
|
|
||||||
})
|
|
||||||
|
|
||||||
console.log(`Add unicode "${unicode}" to "${file}"`)
|
|
||||||
fs.writeFileSync(file, svgFile, 'utf8')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
@ -5,9 +5,7 @@ import { getArgvs, getPackageJson, ICONS_SRC_DIR } from './helpers.mjs'
|
||||||
|
|
||||||
const p = getPackageJson()
|
const p = getPackageJson()
|
||||||
|
|
||||||
const argv = getArgvs(),
|
|
||||||
version = argv['latest-version'] || `${p.version}`,
|
|
||||||
newVersion = argv['new-version'] || `${p.version}`
|
|
||||||
|
|
||||||
const setVersions = function(version, files) {
|
const setVersions = function(version, files) {
|
||||||
for (const i in files) {
|
for (const i in files) {
|
||||||
|
|
@ -18,7 +16,7 @@ const setVersions = function(version, files) {
|
||||||
let svgFile = fs.readFileSync(filePath).toString()
|
let svgFile = fs.readFileSync(filePath).toString()
|
||||||
|
|
||||||
if (!svgFile.match(/version: ([0-9.]+)/i)) {
|
if (!svgFile.match(/version: ([0-9.]+)/i)) {
|
||||||
svgFile = svgFile.replace(/---\n<svg>/i, function(m) {
|
svgFile = svgFile.replace(/-->\n<svg/i, function(m) {
|
||||||
return `version: "${version}"\n${m}`
|
return `version: "${version}"\n${m}`
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
@ -26,7 +24,6 @@ const setVersions = function(version, files) {
|
||||||
} else {
|
} else {
|
||||||
console.log(`File ${file} already has version`)
|
console.log(`File ${file} already has version`)
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
console.log(`File ${file} doesn't exists`)
|
console.log(`File ${file} doesn't exists`)
|
||||||
}
|
}
|
||||||
|
|
@ -34,7 +31,7 @@ const setVersions = function(version, files) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (version) {
|
if (version) {
|
||||||
cp.exec(`grep -RiL "version: " ${ICONS_SRC_DIR}/*.svg`, function(err, ret) {
|
cp.exec(`grep -RiL "version: " ${ICONS_SRC_DIR}/**/*.svg`, function(err, ret) {
|
||||||
let newIcons = []
|
let newIcons = []
|
||||||
|
|
||||||
ret.replace(/src\/_icons\/([a-z0-9-]+)\.svg/g, function(m, fileName) {
|
ret.replace(/src\/_icons\/([a-z0-9-]+)\.svg/g, function(m, fileName) {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,46 @@
|
||||||
|
import { globSync, glob } from 'glob'
|
||||||
|
import fs from 'fs'
|
||||||
|
import path from 'path'
|
||||||
|
import { ICONS_SRC_DIR, getMaxUnicode, getArgvs, getPackageJson } from './helpers.mjs'
|
||||||
|
|
||||||
|
const p = getPackageJson(),
|
||||||
|
argv = getArgvs(),
|
||||||
|
lastVersion = argv['latest-version'] || `${p.version}`,
|
||||||
|
newVersion = argv['new-version']
|
||||||
|
|
||||||
|
console.log(argv);
|
||||||
|
|
||||||
|
const files = globSync(path.join(ICONS_SRC_DIR, '**/*.svg'))
|
||||||
|
|
||||||
|
let maxUnicode = getMaxUnicode()
|
||||||
|
|
||||||
|
files.forEach(function (file) {
|
||||||
|
let svgFile = fs.readFileSync(file).toString()
|
||||||
|
|
||||||
|
// Add unicode to svg files
|
||||||
|
if (!svgFile.match(/\nunicode: "?([a-f0-9.]+)"?/i)) {
|
||||||
|
maxUnicode++
|
||||||
|
const unicode = maxUnicode.toString(16)
|
||||||
|
|
||||||
|
if (unicode) {
|
||||||
|
svgFile = svgFile.replace(/-->\n<svg/i, function (m) {
|
||||||
|
return `unicode: "${unicode}"\n${m}`
|
||||||
|
})
|
||||||
|
|
||||||
|
console.log(`Add unicode "${unicode}" to "${file}"`)
|
||||||
|
fs.writeFileSync(file, svgFile, 'utf8')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (newVersion) {
|
||||||
|
// Add version to svg files
|
||||||
|
if (!svgFile.match(/\nversion: "?([a-f0-9.]+)"?/i)) {
|
||||||
|
svgFile = svgFile.replace(/-->\n<svg/i, function (m) {
|
||||||
|
return `version: "${newVersion}"\n${m}`
|
||||||
|
})
|
||||||
|
|
||||||
|
console.log(`Add version "${newVersion}" to "${file}"`)
|
||||||
|
fs.writeFileSync(file, svgFile, 'utf8')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
{
|
{
|
||||||
"files.exclude": {
|
"files.exclude": {
|
||||||
"**/.git": true,
|
"**/.git": true,
|
||||||
"**/.svn": true,
|
"**/.svn": true,
|
||||||
"**/.hg": true,
|
"**/.hg": true,
|
||||||
"**/CVS": true,
|
"**/CVS": true,
|
||||||
"**/.DS_Store": true,
|
"**/.DS_Store": true,
|
||||||
"**/Thumbs.db": true,
|
"**/Thumbs.db": true,
|
||||||
"**/.idea/": true
|
"**/.idea/": true
|
||||||
},
|
},
|
||||||
"explorerExclude.backup": {}
|
"explorerExclude.backup": {}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,9 +19,8 @@
|
||||||
"changelog": "node ./.build/changelog.mjs",
|
"changelog": "node ./.build/changelog.mjs",
|
||||||
"changelog-commit": "git add . && node ./.build/changelog-commit.mjs",
|
"changelog-commit": "git add . && node ./.build/changelog-commit.mjs",
|
||||||
"changelog-image": "node ./.build/changelog-image.mjs",
|
"changelog-image": "node ./.build/changelog-image.mjs",
|
||||||
"update": "pnpm run update:icons-version && pnpm run update:icons-unicode && pnpm run check-unicodes",
|
"update": "pnpm run update:icons",
|
||||||
"update:icons-version": "node ./.build/update-icons-version.mjs",
|
"update:icons": "node ./.build/update-icons.mjs",
|
||||||
"update:icons-unicode": "node ./.build/update-icons-unicode.mjs",
|
|
||||||
"optimize": "node ./.build/optimize.mjs",
|
"optimize": "node ./.build/optimize.mjs",
|
||||||
"import": "node ./.build/import.mjs && pnpm run optimize",
|
"import": "node ./.build/import.mjs && pnpm run optimize",
|
||||||
"import-tags": "node ./.build/import-tags.mjs",
|
"import-tags": "node ./.build/import-tags.mjs",
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue