1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-25 00:07:47 +01:00
unleash.unleash/src
Thomas Heartman ca6c5854f4
Fix(#1391): Expose API version even when not running via npm/yarn (#2062)
* Fix(#1391): Expose API version even when not running via npm/yarn

## What

Expose the current Unleash version in the generated OpenAPI docs, even
when running via docker or other processes.

## Why

An OpenAPI spec without a version isn't valid. This causes some of our
generation tools (such as the one for documentation) to fail.

## How

By changing how we fetch the current version:

Previously, we used `process.env.npm_package_version!`. However, when
you're not running with yarn or npm, this is `undefined`. That causes
the version number to not be included when running tests and when
running using the official docker image.

Instead, we now use `version` from `lib/util/version`. This is the
same version as the one used by the UI config endpoint, so it should
be the same one as what the front end displays. To the best of my
knowledge, this _is_ the version of the API.

## Discussion

It _may_ be that I have misunderstood what the version represents, but
from what I can tell, it just exports what's listed as the version in
package.json.

The source code of the `lib/util/version` file is:

```ts
// export module version
require('pkginfo')(module, 'version');

const { version } = module.exports;
export default version;
module.exports = version;
```

* Refactor(#1391): rename imported variable for clarity
2022-09-15 10:22:21 +00:00
..
lib Fix(#1391): Expose API version even when not running via npm/yarn (#2062) 2022-09-15 10:22:21 +00:00
mailtemplates fix: welcome-email should not include password-link when disabled (#1302) 2022-01-28 12:50:35 +01:00
migrations PublicSignupTokens (#2053) 2022-09-14 15:29:12 +03:00
test Fix(#1391): Expose API version even when not running via npm/yarn (#2062) 2022-09-15 10:22:21 +00:00
migrator.ts
server-dev.ts Feat/unleash flags embedded proxy (#1974) 2022-08-26 15:16:29 +02:00
server.ts