Skip to content

Commit 1b712da

Browse files
authored
refactor: typing for return value of getBuildtimeInfo (#345)
Signed-off-by: Jan Kowalleck <[email protected]>
1 parent e7d1c53 commit 1b712da

File tree

4 files changed

+23
-13
lines changed

4 files changed

+23
-13
lines changed

HISTORY.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@ All notable changes to this project will be documented in this file.
66

77
<!-- add unreleased items here -->
88

9+
* Refactor
10+
* Add typing to internal function `getBuildtimeInfo` (via [#345])
11+
* Dependencies
12+
* Upgraded runtime-dependency `@cyclonedx/cyclonedx-library@^8.5.0`, was `@^8.4.0` (via [#345])
13+
14+
[#345]: https://github.com/CycloneDX/cyclonedx-node-yarn/pull/345
15+
916
## 3.1.0 - 2025-06-16
1017

1118
* Changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
}
5555
],
5656
"dependencies": {
57-
"@cyclonedx/cyclonedx-library": "^8.4.0",
57+
"@cyclonedx/cyclonedx-library": "^8.5.0",
5858
"@yarnpkg/cli": "^4",
5959
"@yarnpkg/core": "^4",
6060
"@yarnpkg/fslib": "^3",

src/_buildtimeInfo.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,14 @@ SPDX-License-Identifier: Apache-2.0
1717
Copyright (c) OWASP Foundation. All Rights Reserved.
1818
*/
1919

20-
/* eslint-disable-next-line @typescript-eslint/explicit-function-return-type -- dynamic import helper */
21-
export async function getBuildtimeInfo () {
22-
/*
23-
The included file is generated by `../tools/gather-buildtime-info.cjs`.
24-
Its content is pseudo-dynamic and so is the return type of this function.
25-
*/
26-
return (await import('./__buildtimeInfo.json')).default
20+
import type { NodePackageJson } from "@cyclonedx/cyclonedx-library/Types";
21+
22+
interface BuildtimeInfo {
23+
self: NodePackageJson
24+
[key: string]: NodePackageJson
25+
}
26+
27+
export async function getBuildtimeInfo (): Promise<BuildtimeInfo> {
28+
/* if this fails, run `yarn run build:gbti` in your dev-env */
29+
return (await import('./__buildtimeInfo.json')).default satisfies BuildtimeInfo
2730
}

yarn.lock

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

0 commit comments

Comments
 (0)