Code Monkey home page Code Monkey logo

istanbul-badges-readme's People

Contributors

allcontributors[bot] avatar dependabot[bot] avatar leticiavna avatar micalevisk avatar olavoparno avatar troypoulter avatar venturalp avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

istanbul-badges-readme's Issues

feature request: exit with non-zero code upon validation errors

Is your feature request related to a problem? Please describe.

Make the CLI exit with non-zero code if validation fails

Current behavior:

$ istanbul-badges-readme
Info: 0. Istanbul Badges Readme process started
Info: 1. Config check process started
- Readme file exists... ✔️.
Error: Coverage file does not exist in ./coverage/coverage-summary.json
Error: Please refer to the documentation
Error: https://github.com/olavoparno/istanbul-badges-readme/blob/master/README.md
Info: 0. Istanbul Badges Readme process finished
Done in 0.17s.
$ echo $?
0

Exiting with 0 prevent other tools (like GitHub Actions) to detect any validation errors of istanbul-badges-readme easily

Describe the solution you'd like

adding process.exitCode = 1; below will do the trick work but I'm pretty sure it will be a breaking change as some users could be relying on istanbul-badges-readme success exit code

https://github.com/olavoparno/istanbul-badges-readme/blob/805ab2e19931201fb80a949d1c9693ea29aac00d/src/factory.ts#L20-L24

thus, to avoid breaking changes, this feat could be optional and enabled via --exit-code flag, like git-diff do

Describe alternatives you've considered

In my use case, the coverage directory might not exists and I need to report this as an error. I'm doing the following:

$ [ -d './coverage' ] && istanbul-badges-readme || exit 1

but I think it would be cool if istanbul-badges-readme abstracts this for us :)

feature request: add custom --style argument

Is your feature request related to a problem? Please describe.
A badge has a few style: flat, plastic, flat-square, etc. Maybe it's a good choice to specify via --style custom argument.

flat-square:

flat:

Describe the solution you'd like
via --style argument

Describe alternatives you've considered

Additional context

fails to generate badge for 0% coverage

First of all, I'd like to thank you for this excellent package, this is absolutely great! Everything seems to work just fine, except I've noticed that if coverage is 0%, the badge isn't generated and hence substitution doesn't take place. For example, in my case, I had the following results:

=============================== Coverage summary ===============================
Statements   : 6.25% ( 1/16 )
Branches     : 0% ( 0/4 )
Functions    : 20% ( 1/5 )
Lines        : 7.14% ( 1/14 )
================================================================================
Test Suites: 1 passed, 1 total
Tests:       1 passed, 1 total
Snapshots:   1 passed, 1 total
Time:        6.294s
Ran all test suites.

This resulted in

Statements Functions Lines Branches
Statements Functions Lines Branches

Thanks

bug: getNewReadme fails on users with others process.argv items with 'ci' substring

Describe the bug
Hi! I was trying to run the script with npm following the steps in the documentation. However, it was always failing in this part of the process:

image

Since I'm not running with the ci flag or in a ci environment, i went into the codebase to search how was this error message thrown. I found that the getArgumentValue function searches a string with indexOf only:

https://github.com/olavoparno/istanbul-badges-readme/blob/eb418586322559b3a00f5cca9e73abda2edd9379/src/arguments.ts#L7-L12

The problem with this is that for users who have user names, or node path, or maybe any other line in the process.argv with the 'ci' substring, the item.indexof(argName) >= 0 returns true:

image

In my case, changing my user and nvm path worked.

To Reproduce
Steps to reproduce the behavior:

  1. Change or have a username/node path with 'ci' substring
  2. Try to run instanbul-badges-readme inside a repository
  3. Check error after editor process

Additional context
I was unsure if this is a node version related problem, but trying to run with v14.18.1 or 16.15.1 didnt work. Happy to help tho! Will submit a PR soon!

very small correction about README

I did run npm run istanbul-badges-readme after that readme says you can run npm run istanbul-badges-readme but I cannot. It says

npm ERR! Missing script: "istanbul-badges-readme"

This is a very small thing. Thanks for this great library!

bug: validation step ignore file permissions

Describe the bug

Even when the user doesn't have writting permission on the README file, logging saids everything went fine

To Reproduce

demo
demo.mp4

Additional context

The issue is that the following doesn't take account file permissions

https://github.com/olavoparno/istanbul-badges-readme/blob/e75dc4f33f60c4736625f7968871db2b59160d79/src/validate.ts#L8-L10

also, fs.exists has been deprecated in favor of fs.stat or fs.access

To fix that, I added the following line right before L10 from above:

fs.accessSync(getReadmePath(readmePath), fs.constants.R_OK | fs.constants.W_OK)

and got:

Info: 0. Istanbul Badges Readme process started
Info: 1. Config check process started
Error: Error: EACCES: permission denied, access './README.md'
Error: Please refer to the documentation
Error: https://github.com/olavoparno/istanbul-badges-readme/blob/master/README.md
Info: 0. Istanbul Badges Readme process finished

which is the expected output (but yeah, we should change that Error: Error: xD)

Option to use Alternative Titles as Badge Titles

As I don't really want to use the table layout but still need the context on which badge is which, using the already present alt attribute values (e.g. Statements, Branches, etc.) as titles for the badges (instead of Coverage for every badge) would be neat. 🐢

How to create multiple badges for README.md

Hey!

I wanna create multiple coverage reports then I need two different markdown templates in README.md. How can I do that?

Example:

X Coverage Report Badges 

| Statements                                                               | Functions                                                                    | Lines                                                              | Code Quality                                                                                                                                                                                                                                  |
| ------------------------------------------------------------------------ | ---------------------------------------------------------------------------- | ------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| ![Statements](https://img.shields.io/badge/Coverage-88.72%25-yellow.svg) | ![Functions](https://img.shields.io/badge/Coverage-91.94%25-brightgreen.svg) | ![Lines](https://img.shields.io/badge/Coverage-89.2%25-yellow.svg) | [![Codacy Badge](https://app.codacy.com/project/badge/Grade/46159b0d28324e2485f32409d1b82960)](https://www.codacy.com?utm_source=gitlab.com&utm_medium=referral&utm_content=remoteteam/marketplace-core&utm_campaign=Badge_Grade) |

Y Coverage Report Badges

| Statements                                                               | Functions                                                                    | Lines                                                              | Code Quality                                                                                                                                                                                                                                  |
| ------------------------------------------------------------------------ | ---------------------------------------------------------------------------- | ------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| ![Statements](https://img.shields.io/badge/Coverage-88.72%25-yellow.svg) | ![Functions](https://img.shields.io/badge/Coverage-91.94%25-brightgreen.svg) | ![Lines](https://img.shields.io/badge/Coverage-89.2%25-yellow.svg) | [![Codacy Badge](https://app.codacy.com/project/badge/Grade/46159b0d28324e2485f32409d1b82960)](https://www.codacy.com?utm_source=gitlab.com&utm_medium=referral&utm_content=remoteteam/marketplace-core&utm_campaign=Badge_Grade) |

Initial replace

Wow! This tool is exactly what I needed. Thank you! There is one minor issue on the initial replace. Once I corrected it manually the parser updates it later correct.

Markdown

# Test

![Lines]

Check [here](https://github.com/olavoparno/istanbul-badges-readme) a cool tool.

first run

# Test

![Lines]
https://img.shields.io/badge/Coverage-100%25-brightgreen.svg) a cool tool.

expected

# Test

![Lines](https://img.shields.io/badge/Coverage-100%25-brightgreen.svg)

Check [here](https://github.com/olavoparno/istanbul-badges-readme) a cool tool.

Ability to add logo argument when calling the package

Is your feature request related to a problem? Please describe.
Nope, using it for jest coverage badges and would just like to add the Jest logo in

Describe the solution you'd like
Adding the jest logo into the resulting badge, so it appears like so:
image

Describe alternatives you've considered

Additional context

Error when running npm install with 1.2.2

Describe the bug

npm ERR! code ENOENT
npm ERR! syscall chmod
npm ERR! path /home/USER/PROJECT/node_modules/istanbul-badges-readme/lib/index.js
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, chmod '/home/USER/PROJECT/node_modules/istanbul-badges-readme/lib/index.js'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent

To Reproduce

  1. Change dependency version from 1.2.1 to 1.2.2
  2. Run npm install

Additional context
1.2.1 works fine locally and in github actions. 1.2.2 fails in both environments.
Node v14.16.0
Npm 6.14.11

doesReadmeHashExist doesn't take param --readmeDir

Describe the bug

Hello,

On my project I have 2 sub dir

- Matrix
| README.md
| - matrix-back
|        | - README.md
| - matrix-front
|        | - README.md

Each projects has a README.md.
I have a husky pre-hook in matrix-back who insert coverage into root folder.

If I don't have a statement into my matrix-back/README.md, the message Readme does not contain the needed hashes is displayed.

The issue is in the method validate.ts doesReadmeFileExist. The param doesn't take --readmeDir argument.

Additional context

> istanbul-badges-readme --readmeDir="./.."

Info: 0. Istanbul Badges Readme process started
Info: 1. Config check process started
- Readme file exists... ✔️.
- Coverage file exists... ✔️.
- Coverage hashes exist... ✔️.
readmePath= ./README.md
Error: Readme does not contain the needed hashes
Error: Please refer to the documentation

Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.