@collaborne/github-badges
Advanced tools
Comparing version 0.0.2 to 0.0.3
@@ -34,2 +34,3 @@ "use strict"; | ||
const mkdirp_1 = __importDefault(require("mkdirp")); | ||
const constants_1 = require("./constants"); | ||
const reportKeys = [ | ||
@@ -51,9 +52,12 @@ 'lines', | ||
}; | ||
const DEFAULT_INPUT_PATH = path.resolve(__dirname, '..', 'coverage', 'coverage-summary.json'); | ||
const DEFAULT_OUTPUT_PATH = path.resolve(__dirname, '..', 'coverage'); | ||
const DEFAULT_INPUT_PATH = path.resolve('coverage', 'coverage-summary.json'); | ||
const DEFAULT_OUTPUT_PATH = path.resolve('coverage'); | ||
/** Create coverage badges (svg picture icons) based on icons from shields.io */ | ||
function createCoverageBadge(inputPath = DEFAULT_INPUT_PATH, outputPath = DEFAULT_OUTPUT_PATH) { | ||
console.group(constants_1.FgBlue, 'Using these paths for coverage badges:'); | ||
console.log(`${constants_1.FgCyan}coverage-summary.json: ${constants_1.FgGreen}${inputPath}`); | ||
console.log(`${constants_1.FgCyan}output folder for svg's: ${constants_1.FgGreen}${outputPath}`); | ||
const getBadge = (report, key) => { | ||
if (!(report && report.total && report.total[key])) { | ||
throw new Error('malformed coverage report'); | ||
throw new Error(`${constants_1.FgRed} Malformed coverage report`); | ||
} | ||
@@ -60,0 +64,0 @@ const coverage = !report.total[key] || typeof report.total[key].pct !== 'number' |
{ | ||
"name": "@collaborne/github-badges", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "Github SVG badges for repositories", | ||
@@ -9,2 +9,5 @@ "author": "Collaborne", | ||
"source": "src/index.ts", | ||
"bin": { | ||
"create-coverage-badges": "dist/bin/create-coverage-badges.js" | ||
}, | ||
"scripts": { | ||
@@ -11,0 +14,0 @@ "build": "npm run lint:ts && npm run build:ts --", |
@@ -13,2 +13,4 @@ # @collaborne/github-badges | ||
- import in JS/TS files | ||
```ts | ||
@@ -31,6 +33,27 @@ import { createCoverageBadge } from '@collaborne/github-badges' | ||
``` | ||
- as a script in **package.json** | ||
```json | ||
... | ||
scripts :{ | ||
... | ||
"predeploy:coverage-badges": "create-coverage-badges" | ||
... | ||
} | ||
... | ||
``` | ||
By default uses for coverage report input: **coverage/coverage-summary.json** , and outputs created svg's into the same **coverage** folder. | ||
Flags for input: `--i` or `-inputPath` | ||
Flags for output: `--o`, `--d`, `-outputPath` or `-dist` | ||
## License | ||
(c) 2023 Collaborne B.V. All rights reserved. |
@@ -7,2 +7,4 @@ import { readFile, writeFile } from 'fs'; | ||
import { FgBlue, FgCyan, FgGreen, FgRed } from './constants'; | ||
interface ReportData { | ||
@@ -43,11 +45,5 @@ total: number; | ||
const DEFAULT_INPUT_PATH = path.resolve( | ||
__dirname, | ||
'..', | ||
'coverage', | ||
'coverage-summary.json', | ||
); | ||
const DEFAULT_INPUT_PATH = path.resolve('coverage', 'coverage-summary.json'); | ||
const DEFAULT_OUTPUT_PATH = path.resolve('coverage'); | ||
const DEFAULT_OUTPUT_PATH = path.resolve(__dirname, '..', 'coverage'); | ||
/** Create coverage badges (svg picture icons) based on icons from shields.io */ | ||
@@ -58,5 +54,8 @@ export function createCoverageBadge( | ||
) { | ||
console.group(FgBlue, 'Using these paths for coverage badges:'); | ||
console.log(`${FgCyan}coverage-summary.json: ${FgGreen}${inputPath}`); | ||
console.log(`${FgCyan}output folder for svg's: ${FgGreen}${outputPath}`); | ||
const getBadge = (report: TotalReport, key: keyof Report) => { | ||
if (!(report && report.total && report.total[key])) { | ||
throw new Error('malformed coverage report'); | ||
throw new Error(`${FgRed} Malformed coverage report`); | ||
} | ||
@@ -63,0 +62,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
21303
22
353
58
1