85 lines
2.2 KiB
JavaScript
Executable File
85 lines
2.2 KiB
JavaScript
Executable File
#!/usr/bin/env node
|
|
|
|
const isEmpty = require('lodash/isEmpty')
|
|
const sortedObject = require('sorted-object')
|
|
const { getPackages, writeFile, unlink } = require('./utils')
|
|
|
|
const deleteProperties = (object, property, properties) => {
|
|
const nestedObject = object[property]
|
|
if (nestedObject === undefined) {
|
|
return
|
|
}
|
|
properties.forEach(property => {
|
|
delete nestedObject[property]
|
|
})
|
|
if (isEmpty(object[property])) {
|
|
delete object[property]
|
|
}
|
|
}
|
|
|
|
require('exec-promise')(() =>
|
|
getPackages(true).map(({ dir, name, package: pkg }) => {
|
|
pkg.name = name
|
|
pkg.homepage = `https://github.com/vatesfr/xen-orchestra/tree/master/packages/${name}`
|
|
pkg.bugs = `https://github.com/vatesfr/xo-web/issues`
|
|
pkg.repository = {
|
|
type: 'git',
|
|
url: 'https://github.com/vatesfr/xen-orchestra.git',
|
|
}
|
|
|
|
delete pkg.jest
|
|
delete pkg.standard
|
|
|
|
deleteProperties(pkg, 'config', [ 'commitizen' ])
|
|
deleteProperties(pkg, 'devDependencies', [
|
|
'babel-7-jest',
|
|
'babel-eslint',
|
|
'babel-jest',
|
|
'commitizen',
|
|
'cz-conventional-changelog',
|
|
'dependency-check',
|
|
'eslint',
|
|
'eslint-config-standard',
|
|
'eslint-plugin-import',
|
|
'eslint-plugin-node',
|
|
'eslint-plugin-promise',
|
|
'eslint-plugin-standard',
|
|
'flow-bin',
|
|
'ghooks',
|
|
'husky',
|
|
'jest',
|
|
'lint-staged',
|
|
'standard',
|
|
])
|
|
deleteProperties(pkg, 'scripts', [ 'commitmsg', 'cz' ])
|
|
|
|
const { scripts } = pkg
|
|
if (scripts !== undefined) {
|
|
const prepublish = scripts.prepublish
|
|
if (
|
|
prepublish !== undefined &&
|
|
!('prepublishOnly' in scripts)
|
|
) {
|
|
delete scripts.prepublish
|
|
scripts.prepublishOnly = prepublish
|
|
pkg.scripts = sortedObject(scripts)
|
|
}
|
|
}
|
|
|
|
return Promise.all([
|
|
writeFile(
|
|
`${dir}/package.json`,
|
|
JSON.stringify(pkg, null, 2) + '\n'
|
|
),
|
|
unlink(`${dir}/.editorconfig`),
|
|
unlink(`${dir}/.eslintrc.js`),
|
|
unlink(`${dir}/.flowconfig`),
|
|
unlink(`${dir}/.gitignore`),
|
|
unlink(`${dir}/.jshintrc`),
|
|
unlink(`${dir}/.travis.yml`),
|
|
unlink(`${dir}/package-lock.json`),
|
|
unlink(`${dir}/yarn.lock`),
|
|
])
|
|
})
|
|
)
|