mirror of
https://github.com/fumiama/paper-manager.git
synced 2026-06-21 02:40:26 +08:00
optimize vben/build
This commit is contained in:
@@ -1,20 +1,20 @@
|
||||
import path from 'path';
|
||||
import fs from 'fs-extra';
|
||||
import inquirer from 'inquirer';
|
||||
import colors from 'picocolors';
|
||||
import pkg from '../../../package.json';
|
||||
import path from 'path'
|
||||
import fs from 'fs-extra'
|
||||
import inquirer from 'inquirer'
|
||||
import colors from 'picocolors'
|
||||
import pkg from '../../../package.json'
|
||||
|
||||
async function generateIcon() {
|
||||
const dir = path.resolve(process.cwd(), 'node_modules/@iconify/json');
|
||||
const dir = path.resolve(process.cwd(), 'node_modules/@iconify/json')
|
||||
|
||||
const raw = await fs.readJSON(path.join(dir, 'collections.json'));
|
||||
const raw = await fs.readJSON(path.join(dir, 'collections.json'))
|
||||
|
||||
const collections = Object.entries(raw).map(([id, v]) => ({
|
||||
...(v as any),
|
||||
id,
|
||||
}));
|
||||
}))
|
||||
|
||||
const choices = collections.map((item) => ({ key: item.id, value: item.id, name: item.name }));
|
||||
const choices = collections.map((item) => ({ key: item.id, value: item.id, name: item.name }))
|
||||
|
||||
inquirer
|
||||
.prompt([
|
||||
@@ -41,32 +41,32 @@ async function generateIcon() {
|
||||
},
|
||||
])
|
||||
.then(async (answers) => {
|
||||
const { iconSet, output, useType } = answers;
|
||||
const outputDir = path.resolve(process.cwd(), output);
|
||||
fs.ensureDir(outputDir);
|
||||
const genCollections = collections.filter((item) => [iconSet].includes(item.id));
|
||||
const prefixSet: string[] = [];
|
||||
const { iconSet, output, useType } = answers
|
||||
const outputDir = path.resolve(process.cwd(), output)
|
||||
fs.ensureDir(outputDir)
|
||||
const genCollections = collections.filter((item) => [iconSet].includes(item.id))
|
||||
const prefixSet: string[] = []
|
||||
for (const info of genCollections) {
|
||||
const data = await fs.readJSON(path.join(dir, 'json', `${info.id}.json`));
|
||||
const data = await fs.readJSON(path.join(dir, 'json', `${info.id}.json`))
|
||||
if (data) {
|
||||
const { prefix } = data;
|
||||
const isLocal = useType === 'local';
|
||||
const { prefix } = data
|
||||
const isLocal = useType === 'local'
|
||||
const icons = Object.keys(data.icons).map(
|
||||
(item) => `${isLocal ? prefix + ':' : ''}${item}`,
|
||||
);
|
||||
)
|
||||
|
||||
await fs.writeFileSync(
|
||||
path.join(output, `icons.data.ts`),
|
||||
`export default ${isLocal ? JSON.stringify(icons) : JSON.stringify({ prefix, icons })}`,
|
||||
);
|
||||
prefixSet.push(prefix);
|
||||
)
|
||||
prefixSet.push(prefix)
|
||||
}
|
||||
}
|
||||
fs.emptyDir(path.join(process.cwd(), 'node_modules/.vite'));
|
||||
fs.emptyDir(path.join(process.cwd(), 'node_modules/.vite'))
|
||||
console.log(
|
||||
`✨ ${colors.cyan(`[${pkg.name}]`)}` + ' - Icon generated successfully:' + `[${prefixSet}]`,
|
||||
);
|
||||
});
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
generateIcon();
|
||||
generateIcon()
|
||||
|
||||
Reference in New Issue
Block a user