Skip to content

Commit

Permalink
fix: change spec and component type option to string
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
janbiasi committed Dec 13, 2024
1 parent 723a5c3 commit 8b3a905
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 5 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down Expand Up @@ -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);
}
Expand Down
4 changes: 2 additions & 2 deletions src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 8b3a905

Please sign in to comment.