diff --git a/package.json b/package.json index 8524bee..6fcb70c 100644 --- a/package.json +++ b/package.json @@ -27,6 +27,7 @@ "lint": "eslint src/ __tests__/", "pretest": "npm run build", "test": "jest", + "version": "echo \"export const Version = '$npm_package_version'\" > src/version.ts && git add src/version.ts && npm run build", "prepublishOnly": "npm run build", "postpublish": "npm publish --ignore-scripts --@planetscale:registry='https://npm.pkg.github.com'" }, diff --git a/src/index.ts b/src/index.ts index e7ad953..fada66d 100644 --- a/src/index.ts +++ b/src/index.ts @@ -2,8 +2,7 @@ import { format } from './sanitization.js' export { format } from './sanitization.js' export { hex } from './text.js' import { decode } from './text.js' - -const PACKAGE_VERSION = '0.5.0' +import { Version } from './version.js' type ReqInit = Pick & { body: string @@ -180,7 +179,7 @@ async function postJSON(config: Config, url: string | URL, body = {}): Promis body: JSON.stringify(body), headers: { 'Content-Type': 'application/json', - 'User-Agent': `database-js/${PACKAGE_VERSION}`, + 'User-Agent': `database-js/${Version}`, Authorization: `Basic ${auth}` } }) diff --git a/src/version.ts b/src/version.ts new file mode 100644 index 0000000..6e0ca1e --- /dev/null +++ b/src/version.ts @@ -0,0 +1 @@ +export const Version = '0.6.0'