44 lines
1.2 KiB
JavaScript
Executable File
44 lines
1.2 KiB
JavaScript
Executable File
#!/usr/bin/env node
|
|
|
|
const PKGS_DIR = `${__dirname}/../packages`
|
|
|
|
const { fromCallback } = require('promise-toolbox')
|
|
const { readdir, readFile, unlink, writeFile } = require('fs')
|
|
|
|
const pUnlink = path => fromCallback(cb =>
|
|
unlink(path, cb)
|
|
).catch(error => {
|
|
if (error.code !== 'ENOENT') {
|
|
throw error
|
|
}
|
|
})
|
|
|
|
const normalizePackage = name => Promise.all([
|
|
fromCallback(cb =>
|
|
readFile(`${PKGS_DIR}/${name}/package.json`, cb)
|
|
).then(JSON.parse).then(package => {
|
|
package.name = name
|
|
package.homepage = `https://github.com/vatesfr/xen-orchestra/tree/master/packages/${name}`
|
|
package.bugs = `https://github.com/vatesfr/xo-web/issues`
|
|
package.repository = {
|
|
type: 'git',
|
|
url: 'https://github.com/vatesfr/xen-orchestra.git'
|
|
}
|
|
|
|
return fromCallback(cb => writeFile(
|
|
`${PKGS_DIR}/${name}/package.json`,
|
|
JSON.stringify(package, null, 2) + '\n',
|
|
cb
|
|
))
|
|
}),
|
|
pUnlink(`${PKGS_DIR}/${name}/.editorconfig`),
|
|
pUnlink(`${PKGS_DIR}/${name}/.gitignore`)
|
|
])
|
|
|
|
const main =() => fromCallback(cb =>
|
|
readdir(PKGS_DIR, cb)
|
|
).then(pkgs => Promise.all(pkgs.map(pkg =>
|
|
normalizePackage(pkg)
|
|
)))
|
|
main().catch(console.error)
|