From 8b3a9056109eece23040a4ab3cb54fb8939f0f93 Mon Sep 17 00:00:00 2001 From: Jan Biasi Date: Fri, 13 Dec 2024 08:10:28 +0100 Subject: [PATCH] fix: change spec and component type option to string BREAKING CHANGE: default spec version is now 1.6 and component type as well as spec version can now be configured via a string instead of passing an enum value. --- src/index.ts | 6 +++++- src/options.ts | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/index.ts b/src/index.ts index dd335c0..5712292 100644 --- a/src/index.ts +++ b/src/index.ts @@ -12,6 +12,7 @@ import { } from "./helpers"; import { registerPackageUrlOnComponent, registerTools } from "./builder"; import { DEFAULT_OPTIONS, RollupPluginSbomOptions } from "./options"; +import type { ComponentType } from "@cyclonedx/cyclonedx-library/Enums"; /** * Plugin identifier for {@link rollupPluginSbom} @@ -68,7 +69,10 @@ export default function rollupPluginSbom(userOptions?: RollupPluginSbomOptions): try { const rootPkg = await getPackageJson(process.cwd()); if (rootPkg) { - bom.metadata.component = cdxComponentBuilder.makeComponent(rootPkg, options.rootComponentType); + bom.metadata.component = cdxComponentBuilder.makeComponent( + rootPkg, + options.rootComponentType as ComponentType, + ); bom.metadata.component.version = rootPkg.version; registerPackageUrlOnComponent(bom.metadata.component, cdxPurlFactory); } diff --git a/src/options.ts b/src/options.ts index 3ba1367..e94fc3c 100644 --- a/src/options.ts +++ b/src/options.ts @@ -9,11 +9,11 @@ export interface RollupPluginSbomOptions { /** * Specification version to use, defaults to {@link Spec.Spec1dot6} */ - specVersion?: Spec.Version; + specVersion?: `${Spec.Version}`; /** * Defaults to Application */ - rootComponentType?: Enums.ComponentType; + rootComponentType?: `${Enums.ComponentType}`; /** * Output directory to use, defaults to `"cyclonedx"`. * Note: you don't need to prefix the build output path as the plugin