/**
 * Some common functions used by testcases.
 */ import { UnitTestTree } from '@angular-devkit/schematics/testing' ; import { Schema as WorkspaceOptions } from '@schematics/angular/workspace/schema' ; import { Schema as ApplicationOptions , Style } from '@schematics/angular/application/schema' ; import { Schema as LibraryOptions } from '@schematics/angular/library/schema' ; import { IPackageJson } from './package-json-snapshot' ; import { WorkspaceSchema } from '../../schematics-core/utility/workspace-models' ; import { IXliffMergeOptions } from '@ngx-i18nsupport/ngx-i18nsupport' ; import { WorkspaceSnaphot } from './workspace-snapshot' ; export const workspaceOptions = { name : 'workspace' , newProjectRoot : 'projects' , version : '6.0.0' , } ; export const appOptions = { name : 'bar' , experimentalIvy : false , inlineStyle : false , inlineTemplate : false , minimal : true , routing : false , style : Style . Css , skipTests : true , skipPackageJson : true , } ; export const libOptions = { name : 'bar' , entryFile : 'public_api' , prefix : 'lib' , skipPackageJson : true , skipInstall : true , skipTsConfig : true } ; export function readAsJson < T > ( tree , path ) { const content = tree . read ( path ) ; if ( ! content ) { throw new Error ( 'file ' + path + ' not found in tree' ) ; } const contentString = content . toString ( 'UTF-8' ) ; return JSON . parse ( contentString ) as T ; } export function readPackageJson ( tree , projectName ? ) { const path = ( ! projectName ) ? '' : '/' + projectName ; expect ( tree . files ) . toContain ( `${ path }/package.json` ) ; return readAsJson < IPackageJson > ( tree , `${ path }/package.json` ) ; } export function readAngularJson ( tree ) { expect ( tree . files ) . toContain ( '/angular.json' ) ; return readAsJson < WorkspaceSchema > ( tree , '/angular.json' ) ; } export function readXliffmergeJson ( tree , projectName ) { const path = projectName ? `/projects/${ projectName }/xliffmerge.json` : '/xliffmerge.json' ; expect ( tree . files ) . toContain ( path ) ; return readAsJson < { xliffmergeOptions : IXliffMergeOptions ; } > ( tree , path ) ; } param tree param projectName export function readXliffmergeConfigFromWorkspace ( tree , projectName ) { const ws = new WorkspaceSnaphot ( tree ) ; return ws . getActualXliffmergeConfigFromWorkspace ( projectName ) ; }