1
0
Fork 0
freesewing/scripts/software.mjs

45 lines
1.1 KiB
JavaScript
Raw Normal View History

2025-04-21 18:20:52 +02:00
import { path, globDir, readJsonFile } from './fs.mjs'
export const getDesigns = async () => {
const designs = {}
const list = await getFolders('designs')
for (const design of list) {
const data = await readJsonFile(['designs', design, 'about.json'])
2025-04-23 18:35:37 +02:00
if (!data.hide) designs[design] = data
2025-04-21 18:20:52 +02:00
}
return designs
}
export const getPackages = async () => {
const packages = {}
const list = await getFolders('packages')
for (const pkg of list) {
const data = await readJsonFile(['packages', pkg, 'about.json'])
packages[pkg] = data
}
return packages
}
export const getPlugins = async () => {
const plugins = {}
const list = await getFolders('plugins')
for (const plugin of list) {
const data = await readJsonFile(['plugins', plugin, 'about.json'])
plugins[plugin] = data
}
return plugins
}
export const getSoftware = async () => ({
designs: await getDesigns(),
packages: await getPackages(),
plugins: await getPlugins(),
})
// Helper
const getFolders = async (dir) =>
(await globDir(dir, '*')).map((file) => path.basename(file)).sort()