-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- batch analyse multiple repos (repo urls) - reduce default check subtask console output - improve check subtask completion progress output - add global "show-check-subtasks" flag - naming cleanup
- Loading branch information
1 parent
237fa06
commit a57068d
Showing
27 changed files
with
362 additions
and
132 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { ListrTask } from 'listr2'; | ||
|
||
import * as fs from '../../services/fs.service'; | ||
import { Context } from '../../interface'; | ||
import { getRepoNameFromUrl } from '../../services/git.service'; | ||
|
||
export function batchSaveProjectJsonTaskFactory(job: string): ListrTask { | ||
return { | ||
title: `Save project (local json file)`, | ||
skip: (ctx: Context) => ctx.control.skipEverySubsequentTask, | ||
enabled: (ctx: Context) => ctx.options.json, | ||
task: async (ctx: Context, task) => { | ||
const path = `../_dist/${getRepoNameFromUrl(job)}.json`; | ||
fs.writeJson(path, ctx.processedResults); | ||
task.title = `${task.title}, saved to: ${path}`; | ||
}, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { ListrTask } from 'listr2'; | ||
|
||
import { writeJson } from '../../services/fs.service'; | ||
import { Context, ParentTask } from '../../interface'; | ||
|
||
export function finalizeJobTaskFactory( | ||
job: string, | ||
parentTask: ParentTask | ||
): ListrTask { | ||
return { | ||
title: 'Finalize job', | ||
task: async (ctx: Context, task) => { | ||
// reset job CTX state | ||
ctx.control = { skipEverySubsequentTask: false }; | ||
ctx.results = { checks: {} }; | ||
ctx.handledCheckFailures = []; | ||
ctx.processedResults = undefined; | ||
|
||
// reset cwd | ||
process.chdir('../../'); | ||
|
||
// update batch state | ||
if (!ctx.options.preserveQueue) { | ||
ctx.batch.completed.push(job); | ||
ctx.batch.queue = ctx.batch.queue.filter((j) => j !== job); | ||
writeJson(ctx.options.jobPath, ctx.batch); | ||
} | ||
|
||
task.title = `${task.title} successful`; | ||
parentTask.title = `${parentTask.title} successful`; | ||
}, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,18 @@ | ||
import { ListrTask } from 'listr2'; | ||
|
||
import { Context } from '../../interface'; | ||
import { ensureDirectoryExists } from '../../services/fs.service'; | ||
import { | ||
ensureDirectoryExists, | ||
removeDirectoryRecursive, | ||
pathJoin, | ||
} from '../../services/fs.service'; | ||
|
||
export const initWorkspaceTask: ListrTask = { | ||
title: 'Init workspace', | ||
task: async (ctx: Context, task) => { | ||
const { workspacePath } = ctx.options; | ||
ensureDirectoryExists(workspacePath); | ||
removeDirectoryRecursive(pathJoin(workspacePath, '_dist')); | ||
task.title = `${task.title} successful, workspace initialized ${workspacePath}`; | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,47 @@ | ||
import { ListrTask } from 'listr2'; | ||
|
||
import { Context } from '../../interface'; | ||
import { writeJson } from '../../services/fs.service'; | ||
import { getRepoNameFromUrl } from '../../services/git.service'; | ||
|
||
import { projectInfoTask } from '../../tasks/project-info.task'; | ||
import { saveProjectApiTask } from '../../tasks/save-project-api.task'; | ||
import { runChecksWrapperTask } from '../../tasks/run-checks-wrapper.task'; | ||
|
||
import { initJobRepo } from './init-job-repo.task'; | ||
import { finalizeJobTaskFactory } from './finalize-job.task'; | ||
import { batchSaveProjectJsonTaskFactory } from './batch-save-project-json.task'; | ||
|
||
export function runJobTaskFactory(job: string): ListrTask { | ||
return { | ||
title: `${job}`, | ||
title: `${getRepoNameFromUrl(job)}`, | ||
rollback: (ctx: Context, task) => { | ||
// update batch state | ||
if (!ctx.options.preserveQueue) { | ||
ctx.batch.failed.push(job); | ||
ctx.batch.queue = ctx.batch.queue.filter((j) => j !== job); | ||
writeJson(ctx.options.jobPath, ctx.batch); | ||
task.title = `${task.title} failed, added to failed jobs`; | ||
} else { | ||
task.title = `${task.title} failed`; | ||
} | ||
}, | ||
task: async (ctx: Context, task) => { | ||
return task.newListr([initJobRepo(job)]); | ||
return task.newListr( | ||
[ | ||
initJobRepo(job), | ||
projectInfoTask, | ||
runChecksWrapperTask, | ||
batchSaveProjectJsonTaskFactory(job), | ||
saveProjectApiTask, | ||
finalizeJobTaskFactory(job, task), | ||
], | ||
{ | ||
rendererOptions: { | ||
collapse: true, | ||
}, | ||
} | ||
); | ||
}, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.