import { Tree } from "@angular-devkit/schematics" ; import { getJSON , setJSON } from "./files" ; type dependencies = "dependencies" | "devDependencies" | "peerDependencies" ; /**
 * Adds a package to the package.json
 */ export function addPackageToPackageJsonFactory ( host , type ) { return ( pkg , version ) => { const json = getPackageJson ( host ) ; if ( ! json [ type ] ) { json [ type ] = { } ; } if ( ! json [ type ] [ pkg ] ) { json [ type ] [ pkg ] = version ; } return setPackageJson ( host , json ) ; } ; } export function getPackageJson ( host ) { return getJSON ( host , "package.json" ) ; } export function setPackageJson ( host , packageJSON ) { return setJSON ( host , "package.json" , packageJSON ) ; }