/*
 * Copyright (c) 2018, 2025, Oracle and/or its affiliates.
 * Licensed under The Universal Permissive License (UPL), Version 1.0
 * as shown at https://oss.oracle.com/licenses/upl/
 */
const Utils=require("../jetwc-lib/jetwcutils-componentAuditUtils");const TsxUtils=require("../jetwc-lib/jetwcutils-tsxUtils");const ruleDef=function(){};ruleDef.prototype.getName=function(){return"jetwc-prerelease-version"};ruleDef.prototype.getShortDescription=function(){return"Issue an info audit for any components that are flagged with a pre-release version"};ruleDef.prototype.getDescription=function(){return"This rule can be applied before production to ensure that all components have correct release-worthy versions and are not still flagged as pre-releases"};ruleDef.prototype.register=function(context){return{compjson:this._doAudit,Program:this._doVComponentAudit}};ruleDef.prototype._doAudit=function(context){if(context.suppData.obj){let issue;const meta=context.suppData.obj;const fullName=Utils.getComponentFullName(meta);this._checkForPrerelease(context,fullName,meta.version)}};ruleDef.prototype._doVComponentAudit=function(context){const componentInfo=TsxUtils.matchToVComponentImpl(context,context.filepath);if(componentInfo){this._checkForPrerelease(context,componentInfo.fullName,componentInfo.version)}};ruleDef.prototype._checkForPrerelease=function(context,fullName,version){const prereleases=context.utils.semVerUtils.prerelease(version);if(prereleases&&prereleases.length>0){issue=new context.Issue(`Component ${fullName} has a pre-release version number (${version})`);context.reporter.addIssue(issue,context)}};module.exports=ruleDef;