1import { styleText } from 'node:util' 10export const runDiffCore = async ({colorOutput, diffcmd = 'git diff', logLimit, rangeless}: {colorOutput?: (s: string) => Promise<string>, diffcmd?: string, logLimit?: number, rangeless?: boolean} = {}) => { 16 filterPathList: pathsA, 21 let {stdout, isNameOnly} = diffResult 22 const {existingGitSha, newGitSha, lastDeployCommitsAgo, lastDeployDurAgo} = diffResult 24 if (diffcmd === 'git log') { 25 const deployedSha = appConfig.existingGitSha 27 const lines = stdout.split('\n') 28 const deployedIdx = lines.findIndex(l => { 29 const stripped = l.replace(/\x1b\[[0-9;]*m/g, '') 30 const shaOnLine = stripped.split(' ')[0] 31 return deployedSha.startsWith(shaOnLine) && shaOnLine.length >= 7 33 if (deployedIdx >= 0) { 34 lines.splice(deployedIdx, 0, `──── [deployed: ${deployedSha.slice(0, 7)}] ────`) 35 stdout = lines.join('\n') 40 if (isNameOnly && colorOutput) { 41 const coloredStdout = await colorOutput(stdout) 42 console.log(coloredStdout) 48 if (existingGitSha) betLog('appDeployDiff', {existingGitSha, newGitSha, lastDeployCommitsAgo, lastDeployDurAgo}) 52export const diff = async () => { 55diff.needsLazyDocker = true 56diff.cliSchema = scopeCli 57diff.cliAcceptsPositional = true 59 cliDefaultOpt: epScopes.dockerjs, 60 cliOptA: getEpScopeOptA, 61 cliSupportsEpScopes: true, 62 cliExplain: `git diff from ${styleText('yellow', 'deployed sha')} to ${styleText('green', 'HEAD')}`