Skip to content

Commit

Permalink
added history templates
Browse files Browse the repository at this point in the history
  • Loading branch information
MarioRivis committed Sep 24, 2024
1 parent 55bbb5e commit e5404a1
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 0 deletions.
13 changes: 13 additions & 0 deletions __tests__/history.integration.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import {analyseHistory} from '../src/commands/history/history'

describe('test history analysis for default plugins', () => {

it('test history analysis for javascript and ruby', async () => {
await analyseHistory(['...'], {
results: 'results-history',
refresh: false,
plugins: ['npm'],
})
console.log('done')
})
})
51 changes: 51 additions & 0 deletions src/commands/history/history.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import {Command} from 'commander'
import {AnalyseOptions} from '../analyse'
import {getPluginsFromNames} from '../../plugins'
import {DependencyFileContext, DepinderProject} from '../../extension-points/extract'

export const historyCommand = new Command()
.name('history')
.argument('[folders...]', 'A list of git repositories to analyse')
// .argument('[depext-files...]', 'A list of files to parse for dependency information')
.option('--results, -r', 'The results folder', 'results')
.option('--refresh', 'Refresh the cache', false)
.option('--plugins, -p [plugins...]', 'A list of plugins')
.action(analyseHistory)


export async function analyseHistory(folders: string[], options: AnalyseOptions, useCache = true): Promise<void> {
const selectedPlugins = getPluginsFromNames(options.plugins)

// folders.map(repo => {
// console.log(`Analysing ${repo} with isomorphic Git`)
// const commits: any[] = []
// commits.forEach(commit => {
// const changes: any[] = []
// const files = changes
// .filter(it => plugin.extractor.filter ? plugin.extractor.filter(it) : true)
// .filter(it => plugin.extractor.files
// .some(pattern => minimatch(it, pattern, {matchBase: true}))
// )
// })
// })

const projects: DepinderProject[] =
await Promise.all(selectedPlugins.map(async (plugin: any) => {
console.log(`Running plugin ${plugin.name}`)
const context: DependencyFileContext = {} as DependencyFileContext
return await plugin.parser?.parseDependencyTree(context)
}))
}

class Repo {

}

class Commit {

}

class Change {

}

2 changes: 2 additions & 0 deletions src/depinder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {_package} from './utils/utils'
import {analyseCommand} from './commands/analyse'
import {cacheCommand} from './commands/cache'
import {updateCommand} from './commands/update'
import {historyCommand} from './commands/history/history'

export const mainCommand = new Command()
.name('depinder')
Expand All @@ -11,4 +12,5 @@ export const mainCommand = new Command()
.addCommand(analyseCommand)
.addCommand(updateCommand)
.addCommand(cacheCommand)
.addCommand(historyCommand)

0 comments on commit e5404a1

Please sign in to comment.