@adalo/metrics 0.1.166 → 0.1.168

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,34 @@
1
+ # Publish a staging build to npm with tag "staging".
2
+ # Push (or merge) to branch "staging" to publish. Consuming apps can then use
3
+ # "@adalo/metrics": "staging"
4
+ # to test changes on staging before merging to main.
5
+ name: Deploy Staging
6
+
7
+ on:
8
+ push:
9
+ branches:
10
+ - staging
11
+
12
+ jobs:
13
+ build-and-publish:
14
+ if: "!contains(github.event.head_commit.message, 'skip ci')"
15
+ runs-on: ubuntu-latest
16
+ steps:
17
+ - uses: actions/checkout@v3
18
+ with:
19
+ fetch-depth: 0
20
+ - name: Setup Node.js
21
+ uses: actions/setup-node@v3
22
+ with:
23
+ node-version: '18.x'
24
+ registry-url: 'https://registry.npmjs.org'
25
+ - name: Installing dependencies
26
+ run: yarn install --frozen-lockfile
27
+ - name: Build lib
28
+ run: yarn run build
29
+ - name: Set staging version
30
+ run: npm version 0.0.0-staging.${{ github.run_number }} --no-git-tag-version --allow-same-version
31
+ - name: Publish to NPM (tag staging)
32
+ run: npm publish --tag staging
33
+ env:
34
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
package/README.md CHANGED
@@ -1,6 +1,19 @@
1
1
  # @adalo/metrics
2
2
  Utility library for Prometheus metrics and HTTP request counting in Node.js applications.
3
3
 
4
+ ## Testing and staging (for contributors)
5
+
6
+ - **Run tests**: `yarn test` (or `yarn test:watch`). CI runs tests on every pull request.
7
+ - **Test locally in a consuming app** (without publishing):
8
+ - From this repo: `yarn link`
9
+ - In the app repo (e.g. backend): `yarn link @adalo/metrics`
10
+ - Or use a file dependency: `"@adalo/metrics": "file:../path/to/metrics-js"`
11
+ - **Test on staging before merging to main**:
12
+ - Push your changes to the **`staging`** branch (create it if needed). The **Deploy Staging** workflow will build and publish to npm with the dist-tag **`staging`** (version like `0.0.0-staging.123`).
13
+ - In the app that uses this library (e.g. backend), point the dependency to the staging build:
14
+ - In `package.json`: `"@adalo/metrics": "staging"` (resolves to latest `@adalo/metrics@staging`), or pin a specific version: `"@adalo/metrics": "0.0.0-staging.123"`.
15
+ - Deploy that app to staging and verify metrics/behavior. When satisfied, merge **metrics-js** into **main** and release a normal version; then update the app back to `"@adalo/metrics": "^x.y.z"` or `"latest"`.
16
+
4
17
  ## Constructor
5
18
  ```ts
6
19
  new MetricsClient({
@@ -105,3 +118,16 @@ secret env was created as
105
118
  ```js
106
119
  Buffer.from(`${username}:${password}`).toString('base64')
107
120
  ```
121
+
122
+ ## Troubleshooting (consumers)
123
+
124
+ **TypeScript build errors in `node_modules/@types/node`** (e.g. `TS1005: '?' expected` in `crypto.d.ts` or `http.d.ts`):
125
+ These come from a version of `@types/node` that requires TypeScript 4.7+. If your app uses TypeScript 4.6 or older, force an older `@types/node` by adding to your app’s `package.json`:
126
+
127
+ ```json
128
+ "resolutions": {
129
+ "@types/node": "^16.0.0"
130
+ }
131
+ ```
132
+
133
+ Then run `yarn install` again and rebuild. Alternatively, upgrade your app to TypeScript 4.7+.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adalo/metrics",
3
- "version": "0.1.166",
3
+ "version": "0.1.168",
4
4
  "description": "Reusable metrics utilities for Node.js and Laravel apps",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -37,7 +37,7 @@
37
37
  "@babel/preset-typescript": "^7.24.0",
38
38
  "@types/ioredis": "^5.0.0",
39
39
  "@types/jest": "28.1.6",
40
- "@types/node": "18.0.4",
40
+ "@types/node": "^16.0.0",
41
41
  "@types/redis": "2",
42
42
  "@typescript-eslint/eslint-plugin": "5.30.6",
43
43
  "@typescript-eslint/parser": "5.30.6",