Skip to content
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
39 changes: 39 additions & 0 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Checks

on:
pull_request:
push:
branches: [master]

permissions:
contents: read

jobs:
sdk:
runs-on: ubuntu-24.04
timeout-minutes: 10
strategy:
matrix:
node: ["18", "22", "24"]
steps:
- uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6
with:
persist-credentials: false
- uses: actions/setup-node@249970729cb0ef3589644e2896645e5dc5ba9c38 # v6
with:
node-version: ${{ matrix.node }}
cache: npm
- run: npm ci --ignore-scripts
- run: npm run typecheck
# Vitest requires Node 20+; the package build and imports are checked on Node 18.
- run: npm test
if: matrix.node != '18'
- run: npm run build
- run: node scripts/check-package.cjs
- run: npm pack --dry-run --ignore-scripts
- name: Check development and production dependencies
if: matrix.node == '24'
run: |
npm audit --audit-level=low
npm audit --omit=dev --audit-level=low
- run: git diff --exit-code -- package.json package-lock.json
134 changes: 67 additions & 67 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,14 @@
},
"devDependencies": {
"@types/node": "^24.5.2",
"@vitest/coverage-v8": "^4.1.11",
"@vitest/coverage-v8": "^4.1.12",
"tsup": "^8.5.0",
"typescript": "^5.9.2",
"vitest": "^4.1.11"
"vitest": "^4.1.12"
},
"overrides": {
"esbuild": "^0.28.1"
"esbuild": "^0.28.1",
"source-map-js": "^1.2.2",
"vite": "^7.3.7"
}
}
28 changes: 28 additions & 0 deletions scripts/check-package.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
const assert = require('node:assert/strict');
const { access } = require('node:fs/promises');
const path = require('node:path');
const pkg = require('../package.json');

async function main() {
const esm = await import(pkg.name);
const cjs = require(pkg.name);
assert.deepEqual(Object.keys(esm).sort(), Object.keys(cjs).sort());
assert.equal(esm.getVersion(), cjs.getVersion());
await access(path.resolve(__dirname, '..', pkg.types));
await access(path.resolve(__dirname, '..', 'dist/index.d.cts'));

for (const sdk of [esm, cjs]) {
const config = new sdk.IpGeolocationClientConfig({ apiKey: 'package-test' });
assert.equal(config.baseUrl, 'https://api.ipgeolocation.io');
assert.equal(Object.isFrozen(config), true);
const request = new sdk.LookupIpGeolocationRequest({ ip: '2001:db8::1' });
assert.equal(request.ip, '2001:db8::1');
assert.equal(request.output, sdk.ResponseFormat.JSON);
const client = new sdk.IpGeolocationClient(config);
assert.equal(typeof client.bulkLookupIpGeolocationRaw, 'function');
await client.close();
}
console.log(`ESM, CommonJS and declarations checked on ${process.version}`);
}

main().catch((error) => { console.error(error); process.exitCode = 1; });