/*
 * Copyright (c) 2018, 2026, 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 ruleDef=function(){};ruleDef.prototype.getName=function(){return"jetwco-prerelease-cdn"};ruleDef.prototype.getShortDescription=function(){return"Validates use of the production CDN"};ruleDef.prototype.getDescription=function(){return"This rule checks any CDN definitions to ensure that they point to assets on the production Oracle CDN, not the staging site or other sites"};ruleDef.prototype.register=function(context){return{compjson:this._doAudit}};ruleDef.prototype._doAudit=function(context){const productionCDN=context.rulePack.getRuleCustomOption("cdnRoot")?.toLowerCase();if(context.suppData.obj){let issue;const meta=context.suppData.obj;const componentType=Utils.getComponentType(meta);const componentName=meta.name;if(meta.paths&&meta.paths.cdn){if(meta.paths.cdn.min&&!meta.paths.cdn.min.toLowerCase().startsWith(productionCDN)||meta.paths.cdn.debug&&!meta.paths.cdn.debug.toLowerCase().startsWith(productionCDN)){issue=new context.Issue(`${componentType} component '${componentName}' does not use the correct CDN (${productionCDN})`);context.reporter.addIssue(issue,context)}}}};module.exports=ruleDef;