import { Rule, SchematicContext, Tree } from '@angular-devkit/schematics'; import { merge } from 'lodash'; import { of } from 'rxjs'; import { mapTo } from 'rxjs/operators'; import { rxTransformYamlFile } from '../utilities/rx.yaml'; import { DEPLOY_COMMAND, BUILD_COMMAND } from './constants'; import { Schema } from './schema'; const TRAVIS_PATH = '/.travis.yml'; const TRAVIS_TEMPLATE = { sudo: false, node_js: ['8'], language: 'node_js', script: [`npm run ${BUILD_COMMAND}`], deploy: { skip_cleanup: true, provider: 'script', script: [`npm run ${DEPLOY_COMMAND}`], on: { tags: true } } }; export function updateTravis(options: Schema): Rule { return (host: Tree, context: SchematicContext) => { return rxTransformYamlFile( TRAVIS_PATH, (aBuild: any) => of(merge(aBuild || {}, TRAVIS_TEMPLATE)), host ).pipe(mapTo(host)); }; }