/*
 * 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 path=require("path");const ruleDef=function(){};ruleDef.prototype.getName=function(){return"jetwc-reference-npm-path"};ruleDef.prototype.getShortDescription=function(){return"Ensures that reference components have an NPM path defined"};ruleDef.prototype.getDescription=function(){return"In order to be usable in local deployment mode, reference components must have npm path mappings defined as well as cdn path mappings"};ruleDef.prototype.register=function(context){return{compjson:this._doAudit}};ruleDef.prototype._doAudit=function(context){if(context.suppData.obj){let issue;const meta=context.suppData.obj;const fullName=Utils.getComponentFullName(meta);const componentType=Utils.getComponentType(meta);if(componentType==="reference"||componentType==="mono-pack"&&meta.package){if(!meta.paths?.npm?.debug&&!meta.paths?.npm?.min){if(!Utils.shouldIgnoreCheck(context,"jetwc-reference-npm-path",fullName)){issue=new context.Issue(`Component ${fullName} (${componentType} component) ${componentType==="mono-pack"?"is marked as an NPM package and so ":""}must define npm path(s) to allow local installation`);issue.setMsgKey(context.ruleName);if(!meta.paths?.cdn){issue.setSeverity("blocker")}context.reporter.addIssue(issue,context)}}}}};module.exports=ruleDef;