Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
175 additions
and
27 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import { checkSoftware } from './requirements.js'; | ||
import { checkSoftware } from './requirements/software.js'; | ||
import { renderTable } from './reporter.js'; | ||
|
||
export { checkSoftware, renderTable }; |
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 { CustomChecks } from '../types'; | ||
|
||
export async function checkCustom(customChecks: CustomChecks = {}) { | ||
let results = []; | ||
|
||
for await (const [name, { fn, errorMessage }] of Object.entries(customChecks)) { | ||
const item = { name, errorMessage }; | ||
|
||
try { | ||
await fn(); | ||
results.push({ ...item, passed: true }); | ||
} catch (error) { | ||
results.push({ ...item, passed: false, error }); | ||
} | ||
} | ||
|
||
return results; | ||
} |
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
export default { | ||
custom: { | ||
'Title Always Failure': { | ||
errorMessage: `Error message when failure occurs.`, | ||
fn: async () => { | ||
throw new Error('This example always fails.'); | ||
}, | ||
}, | ||
}, | ||
}; |
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,27 @@ | ||
import chalk from 'chalk'; | ||
import fs from 'fs'; | ||
import { promisify } from 'util'; | ||
const readFile = promisify(fs.readFile); | ||
|
||
export default { | ||
software: { | ||
npm: { | ||
semver: '>= 16.x', | ||
updateMessage: `Outdated 'npm' found.\nRun '${chalk.cyan('npm i -g npm')}' to update.`, | ||
}, | ||
}, | ||
custom: { | ||
'Git SSH Check': { | ||
errorMessage: `HTTPS usage in Git is not allowed.\nFollow '${chalk.cyan( | ||
'https://docs.github.com/en/free-pro-team@latest/github/authenticating-to-github/connecting-to-github-with-ssh' | ||
)}' to fix this.`, | ||
fn: async () => { | ||
const file = await readFile('./.git/config', 'utf-8'); | ||
const reAllowedProtocols = /(ssh:|git@)/; | ||
if (reAllowedProtocols.test(file) === false) { | ||
throw new Error('.git/config: ssh or git protocol not found'); | ||
} | ||
}, | ||
}, | ||
}, | ||
}; |