Skip to content

Commit 7194a1e

Browse files
FIX: use genversion to include SDK version in request headers (#70)
* FIX: use genversion to include SDK version in request headers * add a couple comments * tidy * xo * grant permission * run as shell script, not npm script * improve test, untouch package.json * npm i * now make it pass * PR cleanup * Update snapshots * Bump version * Fix tests again Co-authored-by: Brent Mealhouse <[email protected]>
1 parent d440adf commit 7194a1e

File tree

12 files changed

+236
-145
lines changed

12 files changed

+236
-145
lines changed

.github/workflows/ci_checks.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ jobs:
6464
id: npm-lint
6565
run: npm run lint
6666

67+
- name: Verify package.json version matches version.ts (genversion --check-only)
68+
id: verify-version
69+
run: ./verify_version.sh
70+
6771
- uses: act10ns/slack@v1
6872
with:
6973
status: ${{ job.status }}

build.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
#!/bin/bash
2+
set -e
23

34
# Clean dist directory
45
rm -rf dist
56

7+
# Verify package.json version matches version.ts
8+
source ./verify_version.sh
9+
610
# Build for esm and cjs
711
npm run build:esm
812
npm run build:cjs

fix-esm-imports.mjs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,6 @@ function fixImportsAtFile(filePath) {
3232
}
3333

3434
const [, importPath] = line.split(`"`);
35-
if (importPath.includes(".json")) {
36-
return `import { createRequire } from "module";
37-
const require = createRequire(import.meta.url);
38-
const { version } = require("${importPath}");`;
39-
}
4035

4136
const fullPath = path.join(filePath, "..", importPath);
4237
if (!fs.existsSync(fullPath)) {

jest.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module.exports = {
22
preset: "ts-jest",
33
testEnvironment: "node",
4-
testTimeout: 10000,
4+
testTimeout: 15000,
55
};

package-lock.json

Lines changed: 78 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
{
22
"name": "@withabound/node-sdk",
3-
"version": "1.1.3",
3+
"version": "1.1.4",
44
"description": "The Abound Node library provides convenient access to the Abound API from applications written in server-side JavaScript.",
55
"author": "Abound <[email protected]>",
66
"license": "MIT",
7-
"main": "dist/cjs/src/abound.js",
8-
"module": "dist/esm/src/abound.js",
7+
"main": "dist/cjs/abound.js",
8+
"module": "dist/esm/abound.js",
99
"exports": {
1010
".": {
11-
"import": "./dist/esm/src/abound.js",
12-
"require": "./dist/cjs/src/abound.js"
11+
"import": "./dist/esm/abound.js",
12+
"require": "./dist/cjs/abound.js"
1313
}
1414
},
15-
"types": "dist/types/src/abound.d.ts",
15+
"types": "dist/types/abound.d.ts",
1616
"files": [
1717
"dist/**/*"
1818
],
@@ -37,6 +37,7 @@
3737
"@types/jest": "27.0.1",
3838
"axios-mock-adapter": "^1.20.0",
3939
"eslint-config-xo-typescript": "0.44.0",
40+
"genversion": "^3.1.1",
4041
"husky": "7.0.2",
4142
"jest": "27.2.1",
4243
"lint-staged": "11.1.2",

src/util/http.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { URLSearchParams } from "url";
22
import axios, { AxiosInstance } from "axios";
33

44
import { AboundConfig } from "../AboundClient";
5-
import { version } from "../../package.json";
5+
import { version } from "./version";
66

77
export function initAxios(config: AboundConfig): AxiosInstance {
88
return axios.create({

src/util/version.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// Generated by genversion.
2+
export const version = "1.1.4";

0 commit comments

Comments
 (0)