import { ApplyFingerprint , Aspect , ExtractFingerprint , sha256 , } from "@atomist/sdm-pack-fingerprint" ; import * as _ from "lodash" ; export const TsLintType = "tslint" ; export interface TsLintProperty { path : string ; property : string ; value : string ; } export class TsLintPropertyAspect implements Aspect < TsLintProperty > { public readonly displayName : string = "TSLint" ; public readonly name : string = TsLintType ; get apply ( ) : ApplyFingerprint < TsLintProperty > { return async ( p , tsi ) => { throw new Error ( `Applying TSlint version not yet supported` ) ; } ; } public extract : ExtractFingerprint < TsLintProperty > = async ( p ) => { const tslint = await p . getFile ( "tslint.json" ) ; if ( ! tslint ) { return undefined ; } const content = await tslint . getContent ( ) ; const json = JSON . parse ( content ) ; const pathObj = _ . get ( json , this . path , { } ) ; return Object . getOwnPropertyNames ( pathObj ) . map ( property => { const data = { path : this . path , property , value : pathObj [ property ] || "" } ; return { type : TsLintType , name : `${ this . path }:${ property }` , data , sha : sha256 ( JSON . stringify ( data ) ) , } ; } ) ; } ; constructor ( public readonly path = "rules" ) { } }