{"size": 897, "ext": "js", "max_stars_repo_path": "src/node_modules/@kikd/command-build/index.js", "max_stars_repo_name": "RayBenefield/dev-xp", "max_stars_repo_stars_event_min_datetime": "2018-03-31T19:32:59.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-07T00:12:13.000Z", "max_issues_repo_path": "src/node_modules/@kikd/command-build/index.js", "max_issues_repo_name": "RayBenefield/dev-xp", "max_issues_repo_issues_event_min_datetime": "2018-01-23T17:13:58.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-12T19:38:24.000Z", "max_forks_repo_path": "src/node_modules/@kikd/command-build/index.js", "max_forks_repo_name": "RayBenefield/kikd", "max_forks_repo_forks_event_min_datetime": "2020-07-11T20:22:28.000Z", "max_forks_repo_forks_event_max_datetime": "2020-07-11T20:22:28.000Z"}
{"max_stars_count": 9, "max_issues_count": 822, "max_forks_count": 1, "avg_line_length": 32.0357142857, "max_line_length": 78, "alphanum_fraction": 0.6945373467}
import { isolate } from 'transmutation'
import template from '@kikd/template-building'
import getPackages, { packageFilters } from '@kikd/command-list'
import buildPackages from '@kikd/build-packages'
import deps from '@kikd/command-deps'
import buildConfigs from '@kikd/build-configs'

const filter = ({ allPackages, changedAndPublishable, needsPublishing }) =>
    !allPackages && !changedAndPublishable && !needsPublishing
        ? { onlyPublishable: true }
        : {}

export default function build(config) {
    const newConfig = { ...config, ...filter(config) }

    return getPackages(newConfig)
        .extend('dependencies', deps(newConfig).then(isolate('dependencies')))
        .extendEach('configs', 'packageNames', buildConfigs(newConfig))
}

export const command = () => ({
    name: 'build',
    run: build,
    template,
    effect: buildPackages,
    args: packageFilters,
})
