Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version 1.0.0 #8

Merged
merged 8 commits into from
Dec 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions .babelrc

This file was deleted.

4 changes: 4 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx --no-install commitlint --edit
4 changes: 4 additions & 0 deletions .husky/prepare-commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

exec < /dev/tty && npx cz --hook || true
22 changes: 17 additions & 5 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,16 +1,28 @@
src/
tests/
coverage/
# Directories
.circleci/
.husky/
coverage/
src/
tests/

.babelrc
# Boilerplate Files
.editorconfig
.eslintignore
.eslintrc
.gitignore
.npmignore
metrics.ts
commitlint.config.js
jest.config.js
sonar-project.properties
tsconfig.json

# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
34 changes: 34 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Changelog

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

## 1.0.0 (2021-12-23)


### ⚠ BREAKING CHANGES

* **configuration:** configuration option `enabled` changed to `metricsEnabled`

### Features

* **metrics:** implement ability to collect default prometheus metrics ([001e8f8](https://github.com/xlts-dev/verdaccio-prometheus-middleware/commit/001e8f804c74e81cbc25e099b956ca2d0de65be6)), closes [#4](https://github.com/xlts-dev/verdaccio-prometheus-middleware/issues/4)
* **metrics:** Initial implementation of package install/download metrics capturing and metrics endpoint ([11e8ac6](https://github.com/xlts-dev/verdaccio-prometheus-middleware/commit/11e8ac6fc89c44531a5753d5b672276174972524))


### Bug Fixes

* **configuration:** configuration option `enabled` changed to `metricsEnabled` ([dbd0afe](https://github.com/xlts-dev/verdaccio-prometheus-middleware/commit/dbd0afeb4e009dd217e006555c8ab87a0bc6f4a9))
* **metrics:** fix issue where package download counters were not fully accurate ([97eb944](https://github.com/xlts-dev/verdaccio-prometheus-middleware/commit/97eb944f86dfc4c9a1c5ada3460986e92c0e8d01)), closes [#7](https://github.com/xlts-dev/verdaccio-prometheus-middleware/issues/7)
* **metrics:** Only collect metrics for download of tarball files. Metrics were previously collected for any GET request that looked like it was for a package.json or tarball install but this was less reliable as there were was no way to guarantee the request coming in was for an actual package.json (e.g. browser requests for favicon.ico). Also, Verdaccio would only hand off requests that generate a 401/403 to the middelware for non-tarball requests so metrics could be misleading. ([67caa0f](https://github.com/xlts-dev/verdaccio-prometheus-middleware/commit/67caa0f2e733966af9ece23ab649879378bd28e4))

# 0.1.0 (2021-12-23)


### Bug Fixes

* **metrics:** Only collect metrics for download of tarball files. Metrics were previously collected for any GET request that looked like it was for a package.json or tarball install but this was less reliable as there were was no way to guarantee the request coming in was for an actual package.json (e.g. browser requests for favicon.ico). Also, Verdaccio would only hand off requests that generate a 401/403 to the middelware for non-tarball requests so metrics could be misleading. ([67caa0f](https://github.com/xlts-dev/verdaccio-prometheus-middleware/commit/67caa0f2e733966af9ece23ab649879378bd28e4))


### Features

* **metrics:** Initial implementation of package install/download metrics capturing and metrics endpoint ([11e8ac6](https://github.com/xlts-dev/verdaccio-prometheus-middleware/commit/11e8ac6fc89c44531a5753d5b672276174972524))
33 changes: 31 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ Complete configuration example:
middlewares:
metrics:
## Optional. Defaults to `false` so make sure to set this to `true` if you want to collect metrics.
enabled: true
metricsEnabled: true

## Optional. Collect default prometheus metrics. Defaults to `false`.
## Refer to: https://github.com/siimon/prom-client/tree/v14.0.1#default-metrics
collectDefaultMetrics: false

## Optional. Defaults to `/-/metrics`.
metricsPath: /custom/path/metrics
Expand Down Expand Up @@ -64,7 +68,7 @@ Given the following example configuration:
# Verdaccio config file
middlewares:
metrics:
enabled: true
metricsEnabled: true
packageGroups:
'@babel[/]plugin': 'babel-plugin'
'babel[-]plugin': 'babel-plugin'
Expand All @@ -85,3 +89,28 @@ middlewares:
| `@apollo/client` | scoped |
| `react` | other |
| `apollo-server-express` | other |


## Contributing
This project enforces the [Angular commit message format](https://github.com/angular/angular/blob/13.1.1/CONTRIBUTING.md#-commit-message-format).

A [husky](https://typicode.github.io/husky/#/) `prepare-commit-msg` hook is used in conjunction with
[commitzen](https://github.com/commitizen/cz-cli) in order to automatically prompt for all required fields in the
commit message. The `commitzen` prompts can be bypassed and the commit message may still manually be created by
interrupting the `commitzen` prompt using `ctrl+c`. A valid commit message is still required as each commit message
is linted using [commitlint](https://commitlint.js.org/#/) and a [husky](https://typicode.github.io/husky/#/)
`commit-msg` hook to ensure the [Angular commit message format](https://github.com/angular/angular/blob/13.1.1/CONTRIBUTING.md#-commit-message-format)
is followed.

## Pull Requests
Prior to opening a pull request, please ensure that you run the command:
```bash
npm run release
```
This will automatically increment the version number in the `package.json` based on the types of commits contained in
the pull request and update the `CHANGELOG.md` appropriately. If a specific version type needs to be forced, the same
command can be executed with an argument passed:
```bash
# force incrementing to a new major version
npm run release -- -r major
```
3 changes: 3 additions & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
extends: ['@commitlint/config-conventional'],
};
6 changes: 3 additions & 3 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ module.exports = {
name: 'verdaccio-prometheus-middleware',
verbose: true,
collectCoverage: true,
collectCoverageFrom: ['src/**/*.ts', '!src/index.ts'],
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'],
collectCoverageFrom: ['src/**/*.ts', '!src/index.ts', '!src/types/*'],
moduleFileExtensions: ['js', 'ts'],
transform: {
'^.+\\.(js|jsx|ts|tsx)$': 'babel-jest',
'^.+\\.ts$': 'ts-jest',
},
reporters: ['default', ['jest-junit', { outputDirectory: './coverage/jest', outputName: 'results.xml' }]],
};
Loading