@oracle/oraclejet-audit 12.0.0 → 13.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (117) hide show
  1. package/jaf-amd.js +2 -20
  2. package/jaf.js +1 -1
  3. package/jafapi.js +1 -1
  4. package/lib/AST_Ts.js +1 -1
  5. package/lib/AstJson.js +1 -1
  6. package/lib/AstMd.js +1 -1
  7. package/lib/AstNodeTypes.js +1 -1
  8. package/lib/Cli.js +6 -0
  9. package/lib/Color.js +6 -0
  10. package/lib/Comments.js +1 -1
  11. package/lib/ComponentSvcs.js +1 -1
  12. package/lib/Components.js +1 -1
  13. package/lib/Config.js +1 -1
  14. package/lib/ConfigLib.js +1 -1
  15. package/lib/CssUtils.js +1 -1
  16. package/lib/DomUtils.js +1 -1
  17. package/lib/FileSet.js +1 -1
  18. package/lib/FsUtils.js +1 -1
  19. package/lib/Issue.js +1 -1
  20. package/lib/JafEvents.js +1 -1
  21. package/lib/JafLib.js +1 -1
  22. package/lib/Json.js +1 -1
  23. package/lib/JsonLoader.js +1 -1
  24. package/lib/Md.js +1 -1
  25. package/lib/MetaLib.js +1 -1
  26. package/lib/OjCPack.js +6 -0
  27. package/lib/OjetLib.js +6 -0
  28. package/lib/Registry.js +1 -1
  29. package/lib/RuleSet.js +1 -1
  30. package/lib/Rules.js +1 -1
  31. package/lib/Scope.js +1 -1
  32. package/lib/Utils.js +1 -1
  33. package/lib/ZipUtils.js +1 -1
  34. package/lib/amdlist.js +6 -0
  35. package/lib/api.js +1 -1
  36. package/lib/betalist.js +6 -0
  37. package/lib/builtinpacks.js +1 -1
  38. package/lib/checkage.js +6 -0
  39. package/lib/cliStats.js +1 -1
  40. package/lib/cmdline.js +1 -1
  41. package/lib/defaults.js +1 -1
  42. package/lib/deflist.js +1 -1
  43. package/lib/dislist.js +1 -1
  44. package/lib/exportRules.js +1 -1
  45. package/lib/extends.js +1 -1
  46. package/lib/grouplist.js +1 -1
  47. package/lib/groups.js +1 -1
  48. package/lib/help.js +1 -1
  49. package/lib/jetver.js +1 -1
  50. package/lib/manpage.js +6 -0
  51. package/lib/manual.js +1 -1
  52. package/lib/metaLoader.js +1 -1
  53. package/lib/metahist.js +1 -1
  54. package/lib/msgidLoader.js +1 -1
  55. package/lib/ns.js +1 -1
  56. package/lib/outfile.js +1 -1
  57. package/lib/proflist.js +6 -0
  58. package/lib/rlolist.js +6 -0
  59. package/lib/scaffold.js +1 -1
  60. package/lib/scaffoldRule.js +1 -1
  61. package/lib/schema.js +1 -1
  62. package/lib/scopewalker.js +1 -1
  63. package/meta/12.1.0/jetauditmeta.js +9 -0
  64. package/meta/13.0.0/jetauditmeta.js +9 -0
  65. package/meta/metaverlist.json +1 -1
  66. package/package.json +6 -4
  67. package/profiles/best-practice.json +146 -0
  68. package/profiles/redwood-strict.json +31 -0
  69. package/rulepacks/jetwc/jetwc-bootstrap.js +1 -1
  70. package/rulepacks/jetwc/jetwc-css-oj-complete.js +1 -1
  71. package/rulepacks/jetwc/jetwc-pack-children.js +1 -1
  72. package/rulepacks/jetwc/jetwc-schema.js +1 -1
  73. package/rulepacks/jetwc/jetwc-supproperty-propagation.js +6 -0
  74. package/rulepacks/jetwc/msgid.json +1 -1
  75. package/rulepacks/jetwc/rules.json +1 -1
  76. package/rulepacks/jetwc-lib/jetwcutils-componentFinder.js +1 -1
  77. package/rulepacks/jetwc-lib/jetwcutils-preCompiler.js +1 -1
  78. package/rulepacks/jetwco/jetwco-bootstrap.js +1 -1
  79. package/rulepacks/jetwco/jetwco-component-api-controlled-changes.js +1 -1
  80. package/rulepacks/jetwco/rules.json +1 -1
  81. package/rules/jaf/jaf-sys-age.js +6 -0
  82. package/rules/jaf/jaf-ts-walk.js +6 -0
  83. package/rules/jaf/msgid.json +1 -1
  84. package/rules/jaf/rules.json +1 -1
  85. package/rules/jet/helpers/extractStylesFromClass.js +1 -1
  86. package/rules/jet/msgid.json +1 -1
  87. package/rules/jet/oj-acc-aria-ojselector-labelledby.js +6 -0
  88. package/rules/jet/oj-acc-aria-prop.js +1 -1
  89. package/rules/jet/oj-c-acc-avatar-aria-role.js +6 -0
  90. package/rules/jet/oj-cca-compjson-bp-jetver.js +1 -1
  91. package/rules/jet/oj-css-style-override.js +1 -1
  92. package/rules/jet/oj-css-var-override.js +1 -1
  93. package/rules/jet/oj-html-alta-deprecated.js +1 -1
  94. package/rules/jet/oj-html-attr-2def.js +1 -1
  95. package/rules/jet/oj-html-attr-req.js +1 -1
  96. package/rules/jet/oj-html-cca-tagname.js +1 -1
  97. package/rules/jet/oj-html-cdn.js +1 -1
  98. package/rules/jet/oj-html-combo-converter.js +1 -1
  99. package/rules/jet/oj-html-file-pick-accept.js +1 -1
  100. package/rules/jet/oj-html-notag-style.js +1 -1
  101. package/rules/jet/oj-html-ojattr-deprecated.js +1 -1
  102. package/rules/jet/oj-html-ojattr-enum-deprecated.js +1 -1
  103. package/rules/jet/oj-html-ojattr-evt-syntax.js +1 -1
  104. package/rules/jet/oj-html-ojattr-value.js +1 -1
  105. package/rules/jet/oj-html-ojattr.js +1 -1
  106. package/rules/jet/oj-html-ojtag-deprecated.js +1 -1
  107. package/rules/jet/oj-html-pageopts-type.js +6 -0
  108. package/rules/jet/oj-html-rating-gauge-size.js +6 -0
  109. package/rules/jet/oj-html-redwood-bp-endslot.js +6 -0
  110. package/rules/jet/oj-html-slot-deprecated.js +6 -0
  111. package/rules/jet/oj-html-slot-pref-content.js +1 -1
  112. package/rules/jet/oj-html-wctag-maintenance.js +6 -0
  113. package/rules/jet/rules.json +1 -1
  114. package/schema/component-schema.json +1 -1482
  115. package/src/JafCore.js +1 -1
  116. package/types/index.d.ts +38 -9
  117. package/lib/colors.js +0 -6
package/lib/deflist.js CHANGED
@@ -3,4 +3,4 @@
3
3
  * Licensed under The Universal Permissive License (UPL), Version 1.0
4
4
  * as shown at https://oss.oracle.com/licenses/upl/
5
5
  */
6
- const defs=require("./defaults");const indent=" ";function _show(){console.log(`\nDefault JAF Values:\n\n${indent}jetVer : "${defs.JETVER}"\n${indent}theme : "${defs.THEME}"\n${indent}ecmaVer : ${defs.ECMAVER}`)};module.exports.showList=_show;
6
+ const defs=require("./defaults");const indent=" ";function _show(nd,clr){var s="\n"+clr.BRIGHTGREEN("--- Default JAF Values ---")+"\n\n"+`${indent}${clr.BRIGHTYELLOW("\u25CF jetVer ")}: ${clr.CYAN(`${defs.JETVER}`)}\n`+`${indent}${clr.BRIGHTYELLOW("\u25CF theme ")}: ${clr.CYAN("'Redwood' if jetVer >= 12.0.0, else 'Alta'")}\n`+`${indent}${clr.BRIGHTYELLOW("\u25CF ecmaVer ")}: ${clr.CYAN(`${defs.ECMAVER}`)}\n\n`+`${indent}${clr.BRIGHTYELLOW("\u25CF builtinJetRules ")}: ${clr.CYAN(`true`)}\n`+`${indent}${clr.BRIGHTYELLOW("\u25CF severity ")}: ${clr.CYAN("'all'")}\n`+`${indent}${clr.BRIGHTYELLOW("\u25CF groups ")}: ${clr.CYAN("'all'")}\n`+`${indent}${clr.BRIGHTYELLOW("\u25CF base ")}: ${clr.CYAN("location of configuration file")}\n`+`${indent}${clr.BRIGHTYELLOW("\u25CF files ")}: ${clr.CYAN(".html files in the 'base' directory")}\n`+`${indent}${clr.BRIGHTYELLOW("\u25CF format ")}: ${clr.CYAN("`prose'")}\n`+`${indent}${clr.BRIGHTYELLOW("\u25CF comments ")}: ${clr.CYAN("false")}\n`+`${indent}${clr.BRIGHTYELLOW("\u25CF followLinks ")}: ${clr.CYAN("true")}\n`+`${indent}${clr.BRIGHTYELLOW("\u25CF tempDir ")}: ${clr.CYAN("the current working directory")}\n`;console.log(s)};module.exports.showList=_show;
package/lib/dislist.js CHANGED
@@ -3,4 +3,4 @@
3
3
  * Licensed under The Universal Permissive License (UPL), Version 1.0
4
4
  * as shown at https://oss.oracle.com/licenses/upl/
5
5
  */
6
- var _color;function show(nd,arg,msgCtx){var packs;_init(nd);if(packs=nd.builtinpacks.getPackMetadata(nd,msgCtx)){let prefixes=nd.builtinpacks.getPrefixes();arg=arg?arg.toLowerCase():arg;for(let pack of prefixes){if(!arg||arg===pack)_display(packs[pack])}}};function _display(pack){var rules,rule,opts,oos,summary=[];console.log(`\n\n${_color.BRIGHTRED("\u25CF")} ${_color.CYAN("Pack")} ${_color.BRIGHTRED(`${pack.prefix}`)} ${_color.CYAN(" - Rules disabled by default")}`);rules=pack.rules;for(rule in rules){opts=rules[rule];oos=opts.hasOwnProperty("inservice")&&!opts.inservice;if(oos||opts.hasOwnProperty("enabled")&&!opts.enabled){summary.push(rule+(oos?"_":""))}}if(summary.length){summary=summary.sort()}else{console.log(_color.BRIGHTYELLOW(`● None - all enabled.`));return}for(rule of summary){oos=rule.endsWith("_");rule=oos?rule.substring(0,rule.length-1):rule;console.log(_color.BRIGHTYELLOW(`● ${rule}`)+_color.RED(`${oos?" (out of service)":""}`))}};function _init(nd){_color=nd.colors};module.exports.show=show;
6
+ function show(nd,arg,appCtx){var packs;if(packs=nd.builtinpacks.getPackMetadata(nd,appCtx)){let prefixes=nd.builtinpacks.getPrefixes();arg=arg?arg.toLowerCase():arg;for(let pack of prefixes){if(!arg||arg===pack)_display(packs[pack],appCtx.colors)}}};function _display(pack,clr){var rules,rule,opts,oos,summary=[];console.log(`\n\n${clr.BRIGHTRED("\u25CF")} ${clr.CYAN("Pack")} ${clr.BRIGHTRED(`${pack.prefix}`)} ${clr.CYAN(" - Rules disabled by default")}`);rules=pack.rules;for(rule in rules){opts=rules[rule];oos=opts.hasOwnProperty("inservice")&&!opts.inservice;if(oos||opts.hasOwnProperty("enabled")&&!opts.enabled){summary.push(rule+(oos?"_":""))}}if(summary.length){summary=summary.sort()}else{console.log(clr.BRIGHTYELLOW(`● None - all enabled.`));return}for(rule of summary){oos=rule.endsWith("_");rule=oos?rule.substring(0,rule.length-1):rule;console.log(clr.BRIGHTYELLOW(`● ${rule}`)+clr.RED(`${oos?" (out of service)":""}`))}};module.exports.show=show;
@@ -3,4 +3,4 @@
3
3
  * Licensed under The Universal Permissive License (UPL), Version 1.0
4
4
  * as shown at https://oss.oracle.com/licenses/upl/
5
5
  */
6
- const ELLIPSIS="...";const INDENT=" ";const INDENT2=" ";const INDENT3=" ";const proseIndent=4;const SPACER=" ".repeat(proseIndent);const SPACER2=" ".repeat(proseIndent+3);const SPACER3=" ".repeat(proseIndent+5);const NL="\n";var utils;var out;var severity;var jsonRules;var haveProseRules=false;function getXml(){return out+"</rules>"};function getProse(){return out};function getJson(){return out};function ruleToXml(ruleName,rule,options){var ruleName,val,opt,xml,i;xml=INDENT+"<rule>\n";xml+=INDENT2+"<key>"+ruleName+"</key>\n";xml+=INDENT2+"<name>"+_limitLength(_escapeChevrons(rule.getShortDescription()),utils)+"</name>\n";xml+=INDENT2+"<description>\n";xml+=INDENT3+"<![CDATA["+_escapeCData(rule.getDescription())+"]]>\n";xml+=INDENT2+"</description>\n";for(opt in options){val=options[opt];if(opt==="severity"){xml+=INDENT2+"<severity>"+val.toUpperCase()+"</severity>\n"}else if(opt==="status"){val=val.toUpperCase();val=val==="PRODUCTION"?"READY":val;xml+=INDENT2+"<status>"+val+"</status>\n"}else if(opt==="group"){if(typeof val==="string"){xml+=INDENT2+"<tag>"+val+"</tag>\n"}else{for(i=0;i<val.length;i++){xml+=INDENT2+"<tag>"+val[i]+"</tag>\n"}}}}out+=xml+INDENT+"</rule>\n"};function setupRulesToXml(fnUtils){utils=fnUtils;out="<rules>\n"};function setupRulesToProse(severity,fnUtils){utils=fnUtils;out="\n------------ Rules Currently Active (rule severity: "+severity+") ---------------\n"};function setupRulesToJson(obj,sev,fnUtils){out=obj||{};severity=sev;out.rulesets=[];utils=fnUtils};function packToProse(rules,path,rsi){if(!rules){out+=SPACER2+"* No enabled rules available for this severity."+NL+NL}else{out+="["+(rsi+1)+"] "+rules.title+NL;out+=SPACER+"version : "+rules.version+NL;out+=SPACER+"prefix : "+rules.prefix+NL;out+=SPACER+"path : "+path+NL}haveProseRules=false};function ruleToProse(ruleName,rule,opts){out+=!haveProseRules?SPACER+"Rules:"+NL:"";out+=SPACER2+"* "+ruleName+" :"+NL;out+=SPACER3+"options : "+JSON.stringify(opts)+NL;out+=SPACER3+"short : "+rule.getShortDescription()+NL;out+=SPACER3+"long : "+rule.getDescription()+NL;out+=NL;haveProseRules=true};function getJson(){out.meta={"severity":severity};return out};function packToJson(rulePack){var ruleset;ruleset={};out.rulesets.push(ruleset);ruleset.title=rulePack.rulesJson.title;ruleset.path=rulePack.path;ruleset.prefix=rulePack.rulesJson.prefix;ruleset.version=rulePack.rulesJson.version;ruleset.rules=jsonRules={}};function ruleToJson(ruleName,rule,opts){jsonRules[ruleName]=opts;opts.shortDescription=rule.getShortDescription();opts.description=rule.getDescription()};function _limitLength(s,utils){if(s.length>200){for(let i=196;i>0;i--){if(utils.isWhitespace(s.charAt(i))){return s.substring(0,i+1)+ELLIPSIS}}s=ELLIPSIS}return s};function _escapeChevrons(s){let ret=s.replace(/\</g,"&lt;");ret=ret.replace(/\>/g,"&gt;");return ret.replace(/&nbsp;/g," ")};function _escapeCData(s){var i,bChange;while(true){bChange=false;i=s.indexOf("<oj-");if(i>=0){s=s.substr(0,i)+"&lt;"+s.substr(i+1);bChange=true;i=s.indexOf(">",i+1);if(i>=0){s=s.substr(0,i)+"&gt;"+s.substr(i+1)}i=s.indexOf("</oj-",i);if(i>=0){s=s.substr(0,i)+"&lt;"+s.substr(i+1);bChange=true;i=s.indexOf(">",i+1);if(i>=0){s=s.substr(0,i)+"&gt;"+s.substr(i+1)}}}i=s.indexOf("<!DOCTYPE");if(i>=0){s=s.substr(0,i)+"&lt;"+s.substr(i+1);i=s.indexOf(">",i+1);if(i>=0){s=s.substr(0,i)+"&gt;"+s.substr(i+1);bChange=true}}if(!bChange){break}}return s.replace(/&nbsp;/g," ")};module.exports={getXml:getXml,getProse:getProse,getJson:getJson,ruleToXml:ruleToXml,ruleToProse:ruleToProse,packToProse:packToProse,packToJson:packToJson,ruleToJson:ruleToJson,setupRulesToXml:setupRulesToXml,setupRulesToProse:setupRulesToProse,setupRulesToJson:setupRulesToJson};
6
+ const ELLIPSIS="...";const JAF_OPTS=["inservice","enabled","group","severity","filetype","status","theme","jetver","amd","runonce","$hook","$required","$internal"];var MAX_OPT_LEN=0;const INDENT=" ";const INDENT2=" ";const INDENT3=" ";const proseIndent=4;const optsIndent=10;const SPACER=" ".repeat(proseIndent);const SPACER2=" ".repeat(proseIndent+3);const SPACER3=" ".repeat(proseIndent+5);const SPACER4=" ".repeat(SPACER3.length+optsIndent);const NL="\n";var clr;var utils;var fsUtils;var out;var severity;var jsonRules;var haveProseRules=false;function getXml(){return out+"</rules>"};function getProse(){return out};function getJson(){return out};function ruleToXml(ruleName,rule,options,msgIds){var ruleName,val,opt,xml,id,i;xml=INDENT+"<rule>\n";xml+=INDENT2+"<key>"+ruleName+"</key>\n";xml+=INDENT2+"<name>"+_limitLength(_escapeChevrons(rule.getShortDescription()),utils)+"</name>\n";xml+=INDENT2+"<description>\n";xml+=INDENT3+"<![CDATA["+_escapeCData(rule.getDescription())+"]]>\n";xml+=INDENT2+"</description>\n";xml+=INDENT2+"<messages>\n";for(id of msgIds){xml+=INDENT3+"<msgid>"+id+"</msgid>\n"}xml+=INDENT2+"</messages>\n";for(opt in options){val=options[opt];if(opt==="severity"){xml+=INDENT2+"<severity>"+val.toUpperCase()+"</severity>\n"}else if(opt==="status"){val=val.toUpperCase();val=val==="PRODUCTION"?"READY":val;xml+=INDENT2+"<status>"+val+"</status>\n"}else if(opt==="group"){if(typeof val==="string"){xml+=INDENT2+"<tag>"+val+"</tag>\n"}else{for(i=0;i<val.length;i++){xml+=INDENT2+"<tag>"+val[i]+"</tag>\n"}}}}out+=xml+INDENT+"</rule>\n"};function setupRulesToXml(appCtx){utils=appCtx.utils;fsUtils=appCtx.fsUtils;clr=appCtx.colors;out="<rules>\n"};function setupRulesToProse(nd,severity,appCtx){utils=appCtx.utils;fsUtils=appCtx.fsUtils;clr=appCtx.colors;out=`\n------------ Rules Currently Active (rule severity: ${severity}) ---------------\n`;for(let opt of JAF_OPTS){MAX_OPT_LEN=opt.length>MAX_OPT_LEN?opt.length:MAX_OPT_LEN}};function setupRulesToJson(obj,sev,appCtx){out=obj||{};severity=sev;out.rulesets=[];utils=appCtx.utils;fsUtils=appCtx.fsUtils;clr=appCtx.colors};function packToProse(rules,path,rsi){if(!rules){out+=SPACER2+"* No enabled rules available for this severity."+NL+NL}else{out+="["+(rsi+1)+"] "+rules.title+NL;out+=SPACER+"version : "+rules.version+NL;out+=SPACER+"prefix : "+rules.prefix+NL;out+=SPACER+"path : "+path+NL}haveProseRules=false};function ruleToProse(ruleName,rule,opts,msgIds){var opts,opt,ar,n,i;out+=!haveProseRules?SPACER+"Rules:"+NL:"";out+=SPACER2+clr.BRIGHTYELLOW("* "+ruleName+" :")+NL;out+=SPACER3+clr.BRIGHTCYAN("messages: ");out+=msgIds.join(", ")+NL;out+=SPACER3+clr.BRIGHTCYAN("options : ");n=0;for(opt in opts){if(_isJafOption(opt)){if(Array.isArray(ar=opts[opt])){ar=ar.join(", ")}out+=(!n?"":SPACER4)+clr.BRIGHTGREEN(opt)+" : "+_optSpace(opt)+clr.BRIGHTCYAN(ar)+NL}n++}for(opt in opts){if(!_isJafOption(opt)){out+=(!n?"":SPACER4)+clr.BRIGHTGREEN(opt)+" : "+_optSpace(opt)+clr.BRIGHTCYAN(opts[opt])+NL;n++}}let lines=utils.lineWrap(rule.getShortDescription());out+=SPACER3+clr.BRIGHTCYAN("short")+" : "+clr.BRIGHTCYAN(lines[0])+NL;for(i=1;i<lines.length;i++){out+=SPACER4+clr.BRIGHTCYAN(lines[i])+NL}lines=utils.lineWrap(rule.getDescription());out+=SPACER3+clr.BRIGHTCYAN("long")+" : "+clr.BRIGHTWHITE(lines[0])+NL;for(i=1;i<lines.length;i++){out+=SPACER4+clr.BRIGHTWHITE(lines[i])+NL}out+=NL;haveProseRules=true};function getJson(){out.meta={"severity":severity};return out};function packToJson(rulePack){var ruleset;ruleset={};out.rulesets.push(ruleset);ruleset.title=rulePack.rulesJson.title;ruleset.path=rulePack.path;ruleset.prefix=rulePack.rulesJson.prefix;ruleset.version=rulePack.rulesJson.version;ruleset.rules=jsonRules={}};function ruleToJson(ruleName,rule,opts,msgIds,active){jsonRules[ruleName]=opts;if(active||rule){opts.messages=msgIds;opts.shortDescription=rule.getShortDescription();opts.description=rule.getDescription()}else{opts.shortDescription=opts.description=""}};function _isJafOption(opt){return JAF_OPTS.includes(opt)};function _optSpace(opt){return" ".repeat(MAX_OPT_LEN-opt.length)};function _limitLength(s,utils){if(s.length>200){for(let i=196;i>0;i--){if(utils.isWhitespace(s.charAt(i))){return s.substring(0,i+1)+ELLIPSIS}}s=ELLIPSIS}return s};function _escapeChevrons(s){let ret=s.replace(/\</g,"&lt;");ret=ret.replace(/\>/g,"&gt;");return ret.replace(/&nbsp;/g," ")};function _escapeCData(s){var i,bChange;while(true){bChange=false;i=s.indexOf("<oj-");if(i>=0){s=s.substr(0,i)+"&lt;"+s.substr(i+1);bChange=true;i=s.indexOf(">",i+1);if(i>=0){s=s.substr(0,i)+"&gt;"+s.substr(i+1)}i=s.indexOf("</oj-",i);if(i>=0){s=s.substr(0,i)+"&lt;"+s.substr(i+1);bChange=true;i=s.indexOf(">",i+1);if(i>=0){s=s.substr(0,i)+"&gt;"+s.substr(i+1)}}}i=s.indexOf("<!DOCTYPE");if(i>=0){s=s.substr(0,i)+"&lt;"+s.substr(i+1);i=s.indexOf(">",i+1);if(i>=0){s=s.substr(0,i)+"&gt;"+s.substr(i+1);bChange=true}}if(!bChange){break}}return s.replace(/&nbsp;/g," ")};module.exports={getXml:getXml,getProse:getProse,getJson:getJson,ruleToXml:ruleToXml,ruleToProse:ruleToProse,packToProse:packToProse,packToJson:packToJson,ruleToJson:ruleToJson,setupRulesToXml:setupRulesToXml,setupRulesToProse:setupRulesToProse,setupRulesToJson:setupRulesToJson};
package/lib/extends.js CHANGED
@@ -3,4 +3,4 @@
3
3
  * Licensed under The Universal Permissive License (UPL), Version 1.0
4
4
  * as shown at https://oss.oracle.com/licenses/upl/
5
5
  */
6
- const TSCONFIG="tsconfig.json";const MERGEABLE_BY_DEFAULT={components:true,componentUrls:true,exclude:true,files:true,groups:true,message:true,nameSpaces:true,options:true,ruleMods:true,ruleNames:true,rulePacks:true,typescript:true};const MERGEABLE_BY_OPTION={};const EXOPT_IGNORE="ignore";const EXOPT_MERGE="merge";const MSG={OBJ:"Config '%s' is not an object - %p",ARRAY:"Config '%s' is not an array - %p",STR:"Config '%s' is not a string - %p",STR_OR_AR_STR:"Config '%s' is not a string or an array of strings - %p",AR_OBJ:"Config '%s' is not an array of objects - %p",AR_STR:"Config '%s' is not an array of strings - %p",AR_STR_OBJ:"Config '%s' is not an array of strings or objects - %p",BOOL:"Config '%s' is not a boolean - %p",EXT_OPT:"Config 'extendOptions.%s' cannot be 'merge' - %p",EXT_OPT_VAL:"Config 'extendOptions.%s' not 'ignore' or 'merge' - %p",UNKNOWN:"Unknown config prop - '%s' - %p"};const REPL_PROP="%s";const REPL_PATH="%p";class Extends{constructor(configLib,configInst,cfg,path,nd,msgCtx,utils){this._path=path;this._cfg=cfg;this._fp=cfg.base;this._nd=nd;this._msgCtx=msgCtx;this._utils=utils;this._cwd=nd.process.cwd();this._cfgLib=configLib;this._cfgInst=configInst;this._stack=[];this._extendOpts=null;this._error=msgCtx.error;this._info=msgCtx.info;this._mergeHandlers={components:this._mergePropComponents.bind(this),componentUrls:this._mergePropCompUrls.bind(this),exclude:this._mergePropExclude.bind(this),files:this._mergePropFiles.bind(this),groups:this._mergePropGroups.bind(this),messages:this._mergePropMessages,nameSpaces:this._mergePropNameSpaces.bind(this),options:this._mergePropOptions.bind(this),ruleMods:this._mergePropRuleMods,ruleNames:this._mergePropRuleNames.bind(this),rulePacks:this._mergePropRulePacks,typescript:this._mergePropTypescript.bind(this)}}extend(){var debug;if(debug=this._cfg.options&&(this._cfg.options.verbose||this._cfg.options.debug)){this._msgCtx.info("[Info]: Merging configurations...","I",true)}if(!this._createStack()){return null}if(debug){this._dumpStack()}if(!this._isError){this._checkMergePropTypes()}if(this._isError){return null}if(!this._stack.length){return this._cfg}return this._mergeStack()}_createStack(cfg,fp){var json,fp,first,o;if(first=!cfg){cfg=this._cfg;fp=this._path?this._path:this._fp}else{fp=cfg.extends}if(!fp){return true}if(first){json=cfg}else{fp=this._getAbsolutePath(fp);if(!this._nd.fsUtils.fileExists(fp)){this._error(`Configuration file not found : ${fp}`);return false}if(this._isCircular(fp)){this._error(`Circular configuration 'extends' detected : ${fp}`);return false}try{json=this._nd.fs.readFileSync(fp,"utf8");json=this._nd.decomment(json);json=this._preprocessRawJson(json,fp);if(!json){return false}o=this._utils.parseJson(json,false);if(o.msg){this._error(`Config 'extends' error : ${o.msg} : ${fp}`);return false}else{json=o.obj}}catch(e){this._error(`Error reading 'extends' config : ${fp}`);return false}}this._stack.push({path:fp,cfg:json});if(json.extends){if(!this._createStack(json,json.extends)){return false}}return true}_preprocessRawJson(txt,fp){var json=this._cfgInst.processIncludes(txt,fp);if(this._cfgInst.isOk()){json=this._cfgInst.processTokens(json);if(this._cfgInst.isOk()){}}return this._cfgInst.isOk()?json:null}_mergeStack(){if(!this._fixupPaths()){return null}for(let i=this._stack.length-1;i>0;i--){if(!this._mergePair(this._stack[i-1],this._stack[i])){return null}}if(this._isMergeProp("files")){if(this._stack[0].cfg.hasOwnProperty("files")){this._stack[0].cfg.files=_removeDupes(this._stack[0].cfg.files)}}if(this._isMergeProp("exclude")){if(this._stack[0].cfg.hasOwnProperty("exclude")){this._stack[0].cfg.exclude=_removeDupes(this._stack[0].cfg.exclude)}}return this._stack[0].cfg}_mergePair(parSE,chSE){var props,parent,child,merger,ret=true;parent=parSE.cfg;child=chSE.cfg;this._extendOpts=parSE.cfg.extendOptions||{};props=Object.keys(child);props.forEach(prop=>{if(prop.startsWith("_")||prop==="base"||prop==="extends"||prop==="tokens"||this._extendOpts[prop]===EXOPT_IGNORE){return}if(!parent.hasOwnProperty(prop)){parent[prop]=child[prop];return}if(!this._isMergeProp(prop)){return}if(merger=this._mergeHandlers[prop]){if(!merger(parSE,chSE)){ret=false}}});if(!ret){return ret}this._msgCtx.info(`[Info]: Inherited config '${chSE.path}'`,"I",true);return true}_checkMergePropTypes(){var cfg,se,prop,prop2,val;for(let i=0;i<this._stack.length;i++){se=this._stack[i];cfg=se.cfg;if(!this._cfgLib.checkPropNames(cfg,se.path)){this._isError=true}if(cfg.extendOptions){if(this._utils.isObject(cfg.extendOptions)){this._extendOpts=cfg.extendOptions;for(prop in this._extendOpts){val=this._extendOpts[prop];if(val===EXOPT_MERGE&&!MERGEABLE_BY_OPTION[prop]){this._emitErrorMsg(MSG.EXT_OPT,prop,se.path);return}else if(val!==EXOPT_MERGE&&val!==EXOPT_IGNORE){this._emitErrorMsg(MSG.EXT_OPT_VAL,prop,se.path);return}}}else{this._emitErrorMsg(MSG.OBJ,"extendOptions",se.path);return}}else{this._extendOpts={}}for(prop in cfg){if(!this._isMergeProp(prop)){continue}val=cfg[prop];if(prop==="components"||prop==="componentUrls"){if(typeof val!=="string"&&!Array.isArray(val)||!this._utils.isArrayContentsType(val,"string")){this._emitErrorMsg(MSG.STR_OR_AR_STR,prop,se.path)}}else if(prop==="files"){if(!Array.isArray(val)){this._emitErrorMsg(prop,prop,se.path)}if(!this._utils.isArrayContentsType(val,["string","object"])){this._emitErrorMsg(MSG.AR_STR_OBJ,prop,se.path)}}else if(prop==="exclude"){if(!Array.isArray(val)||!this._utils.isArrayContentsType(val,"string")){this._emitErrorMsg(MSG.STR_OR_AR_STR,prop,se.path)}}else if(prop==="groups"){if(!Array.isArray(val)){this._emitErrorMsg(MSG.STR,prop,se.path)}}else if(prop==="messages"){if(!this._utils.isObject(val)){this._emitErrorMsg(MSG.OBJ,prop,se.path)}if(se.messages.reject){if(!Array.isArray(se.messages.reject)){this._emitErrorMsg(MSG.OBJ,"messages.reject",se.path)}}if(se.messages.accept){if(!Array.isArray(se.messages.accept)){this._emitErrorMsg(MSG.OBJ,"messages.accept",se.path)}}}else if(prop==="nameSpaces"){if(!Array.isArray(val)){this._emitErrorMsg(MSG.AR_STR,prop,se.path)}}else if(prop==="options"){if(!this._utils.isObject(val)){this._emitErrorMsg(MSG.OBJ,prop,se.path)}}else if(prop==="ruleMods"){if(!this._utils.isObject(val)){this._emitErrorMsg(MSG.OBJ,prop,se.path);continue}for(prop2 in val){if(prop2==="enable"||prop2==="disable"){if(!Array.isArray(val[prop2])){this._emitErrorMsg(MSG.AR_OBJ,prop2==="enable"?"ruleMods.enable":"ruleMods.disable",se.path)}}else{if(!this._utils.isObject(val[prop2])){this._emitErrorMsg(MSG.AR_OBJ,prop+"."+prop2,se.path)}}}}else if(prop==="ruleNames"){if(!Array.isArray(val)||!this._utils.isArrayContentsType(val,"string")){this._emitErrorMsg(MSG.AR_STR,prop,se.path)}}else if(prop==="rulePacks"){if(!Array.isArray(val)||!this._utils.isArrayContentsType(val,"object")){this._emitErrorMsg(MSG.AR_OBJ,prop,se.path)}}else if(prop==="sevMap"){if(!this._utils.isObject(val)){this._emitErrorMsg(MSG.OBJ,prop,se.path)}if(val.sevMsg&&!this._utils.isObject(val.sevMsg)){this._emitErrorMsg(MSG.OBJ,prop+".sevMsg",se.path)}if(val.sevSet&&!this._utils.isObject(val.sevSet)){this._emitErrorMsg(MSG.OBJ,prop+".sevSet",se.path)}}else if(prop==="tokens"){if(!this._utils.isObject(val)){this._emitErrorMsg(MSG.OBJ,prop,se.path)}}else if(prop==="typescript"){if(!this._utils.isObject(val)){this._emitErrorMsg(MSG.OBJ,prop,se.path)}for(prop2 in val){if(prop2==="tsconfig"&&typeof val[prop2]!=="string"){this._emitErrorMsg(MSG.STR,"typescript.tsconfig",se.path)}if(prop2==="compile"&&typeof val[prop2]!=="boolean"){this._emitErrorMsg(MSG.BOOL,"typescript.compile",se.path)}}}else{this._error(`JAF ERROR: unhandled 'extends' property '${prop}' - ${se.path}`);this._isError=true}}}}_fixupPaths(){var se,ret=true;for(let i=this._stack.length-1;i>=0;i--){se=this._stack[i];if(!(this._cleanBase(se)&&this._fixupConfig(se))){ret=false;break}}return ret}_cleanBase(se){var src,ft;var nd=this._nd;src=se.cfg.base;if(src==="$jafcwd"){src=this._cwd}else{if(!src){src=this._nd.path.dirname(se.path)}src=nd.path.normalize(src);if(!nd.path.isAbsolute(src)){src=nd.path.join(nd.path.dirname(se.path),src)}ft=nd.fsUtils.getFileType(src);if(ft!=="d"){this._msgCtx.error(`Config file 'base' is not a directory - '${src}' in ${se.path}`);return false}}se.cfg.base=src;this._info(`[Info]: Using config base '${src}' in ${se.path}`,"I");return true}_fixupConfig(se){var nd,cfg,src,dir,ft,i;nd=this._nd;cfg=se.cfg;if(cfg.files){if(!this._cfgLib.validateFileList(cfg.files)){this._bErrors=true;return}if(src=se.cfg.files){for(i=0;i<src.length;i++){if(!src[i].startsWith("http")){src[i]=nd.path.normalize(src[i]);src[i]=nd.path.resolve(cfg.base,src[i])}}}}if(cfg.exclude){if(!this._cfgLib.validateFileList(cfg.exclude)){this._bErrors=true;return}if(src=cfg.exclude){for(i=0;i<src.length;i++){src[i]=nd.path.normalize(src[i]);src[i]=nd.path.resolve(cfg.base,src[i])}}}src=cfg.components;if(src){for(i=0;i<src.length;i++){dir=nd.path.normalize(src[i]);dir=nd.path.resolve(cfg.base,dir);cfg.components[i]=dir}}src=cfg.outPath;if(src&&src!=="$noout"){src=nd.path.normalize(src);src=nd.path.resolve(cfg.base,src);cfg.outPath=src}src=cfg.rulePacks;if(src){for(i=0;i<src.length;i++){dir=src[i].path;dir=nd.path.normalize(dir);src[i].path=nd.path.resolve(cfg.base,dir);if(src[i].path.endsWith(".zip")){continue}ft=nd.fsUtils.getFileType(src[i].path);if(ft!=="d"){this._error("'rulePacks (entry "+(i+1)+"): path' is not a directory - \""+src[i].path+"\"");this._bErrors=true}}}if(cfg.typescript&&cfg.typescript.tsconfig){src=cfg.typescript.tsconfig;if(src&&typeof src==="string"){if(!nd.path.isAbsolute(src)){dir=nd.path.normalize(src);dir=nd.path.resolve(cfg.base,dir)}else{dir=src}if(!dir.endsWith(TSCONFIG)){dir=nd.path.join(dir,TSCONFIG)}cfg.typescript.tsconfig=dir}}if(this._bErrors){this._error(`Errors found in inherited config '${se.path}'`)}return!this._bErrors}_getAbsolutePath(fp){if(this._nd.path.isAbsolute(fp)){return fp}let p=this._nd.path.join(this._cfg.base,fp);if(!this._nd.path.isAbsolute(p)){p=this._nd.path.join(this._dir,p)}return p}_isCircular(fp){var ret;for(let i=0;i<this._stack.length;i++){if(this._stack[i].path===fp){ret=true;break}}return ret}_isMergeProp(p){return MERGEABLE_BY_DEFAULT[p]||this._extendOpts[p]===EXOPT_MERGE}_mergePropFiles(parSE,chSE){return this._mergePropFilesExclude(parSE,chSE,"files")}_mergePropExclude(parSE,chSE){return this._mergePropFilesExclude(parSE,chSE,"exclude")}_mergePropFilesExclude(parSE,chSE,prop){var parent,child,ch,i;var parent=parSE.cfg[prop];var child=chSE.cfg[prop];for(i=0;i<child.length;i++){ch=child[i];if(!parent.includes(ch)){parent.push(ch)}}return true}_mergePropOptions(parSE,chSE){return this._mergeObjects(parSE,chSE,"options")}_mergePropGroups(parSE,chSE){return this._mergeArrays(parSE,chSE,"groups")}_mergePropTokens(parSE,chSE){return this._mergeObjects(parSE,chSE,"tokens")}_mergePropNameSpaces(parSE,chSE){return this._mergeArrays(parSE,chSE,"nameSpaces")}_mergePropRuleMods(parSE,chSE){var parent,child,pname,parPack,rule,rval,prval,i;var parent=parSE.cfg.ruleMods;var child=chSE.cfg.ruleMods;for(pname in child){rval=child[pname];if(!parent[pname]){parent[pname]=rval;continue}if(pname==="enable"||pname==="disable"){prval=parent[pname];for(i=0;i<rval.length;i++){if(!prval.includes(rval[i])){prval.push(rval[i])}}continue}parPack=parent[pname];for(rule in rval){if(!parPack[rule]){parPack[rule]=rval[rule]}}}return true}_mergePropRuleNames(parSE,chSE){return this._mergeArrays(parSE,chSE,"ruleNames")}_mergePropRulePacks(parSE,chSE){var parent=parSE.cfg.rulePacks;var child=chSE.cfg.rulePacks;for(let i=0;i<child.length;i++){let ch=child[i];let b=false;for(let j=0;j<parent.length;j++){let par=parent[j];if(ch.path===par.path){b=true;break}}if(!b){parent.push(ch)}}return true}_mergePropMessages(parSE,chSE){var parent=parSE.cfg.messages;var child=chSE.cfg.messages;var parReject=parent.reject;var chReject=child.reject;if(!parReject&&chReject){parent.reject=chReject}else if(parReject&&chReject){parent.reject=_removeDupes(parReject.concat(chReject))}var parAccept=parent.accept;var chAccept=child.accept;if(!parAccept&&chAccept){parent.accept=chAccept}else if(parAccept&&chAccept){parent.accept=_removeDupes(parAccept.concat(chAccept))}return true}_mergePropComponents(parSE,chSE){return this._mergeArrays(parSE,chSE,"components")}_mergePropCompUrls(parSE,chSE){return this._mergeArrays(parSE,chSE,"componentUrls")}_mergePropTypescript(parSE,chSE){return this._mergeObjects(parSE,chSE,"typescript")}_mergeObjects(parSE,chSE,prop){var parent,child;parent=parSE.cfg[prop];child=chSE.cfg[prop];for(let prop in child){if(!parent.hasOwnProperty(prop)){parent[prop]=child[prop]}}return true}_mergeArrays(parSE,chSE,prop){var parent,child,isPS,isCS,isPA,isCA,val;parent=parSE.cfg[prop];child=chSE.cfg[prop];isPS=typeof parent==="string";isCS=typeof child==="string";if(isPS&&isCS&&parent===child){return}isPA=Array.isArray(parent);isCA=Array.isArray(child);parent=isPA?parent:[parent];child=isCA?child:[child];for(let i=0;i<child.length;i++){val=child[i];if(!parent.includes(val)){parent.push(val)}}return true}_emitErrorMsg(s,prop,path){var s=s||MSG.UNKNOWN;if(prop){s=s.replace(REPL_PROP,prop)}this._error(s.replace(REPL_PATH,path));this._isError=true}_parseError(msg){this._parseError=msg}_dumpStack(){this._msgCtx.info("[Info]: Config 'extends' stack","I",true);for(let i=0;i<this._stack.length;i++){this._msgCtx.info(`[Info]: ${this._stack[i].path}`,"I",true)}}}function _removeDupes(ar){return Array.isArray(ar)?ar.filter((val,x)=>ar.indexOf(val)===x):ar};module.exports=Extends;
6
+ const TSCONFIG="tsconfig.json";const PROFILE_DIR="profiles";const MERGEABLE_BY_DEFAULT={components:true,componentUrls:true,exclude:true,files:true,groups:true,message:true,nameSpaces:true,options:true,ruleMods:true,ruleNames:true,rulePacks:true,sevMap:true,typescript:true};const MERGEABLE_BY_OPTION={};const EXOPT_IGNORE="ignore";const EXOPT_MERGE="merge";const MSG={OBJ:"Config '%s' is not an object - %p",ARRAY:"Config '%s' is not an array - %p",STR:"Config '%s' is not a string - %p",STR_OR_AR_STR:"Config '%s' is not a string or an array of strings - %p",AR_OBJ:"Config '%s' is not an array of objects - %p",AR_STR:"Config '%s' is not an array of strings - %p",AR_STR_OBJ:"Config '%s' is not an array of strings or objects - %p",BOOL:"Config '%s' is not a boolean - %p",EXT_OPT:"Config 'extendOptions.%s' cannot be 'merge' - %p",EXT_OPT_VAL:"Config 'extendOptions.%s' not 'ignore' or 'merge' - %p",UNKNOWN:"Unknown config prop - '%s' - %p"};const REPL_PROP="%s";const REPL_PATH="%p";const DUMMY_FP="$_$";class Extends{constructor(configLib,configInst,cfg,path,nd,msgCtx,utils,fsUtils,isAMD){this._path=path;this._cfg=cfg;this._fp=cfg.base;this._nd=nd;this._msgCtx=msgCtx;this._utils=utils;this._fsUtils=fsUtils;this._cwd=nd.process.cwd();this._cfgLib=configLib;this._cfgInst=configInst;this._isAMD=isAMD;this._stack=[];this._extendOpts=null;this._profResult=null;this._error=msgCtx.error;this._info=msgCtx.info;this._isDebug=msgCtx.isDebug;this._isVerbose=msgCtx.isVerbose;this._mergeHandlers={components:this._mergePropComponents.bind(this),componentUrls:this._mergePropCompUrls.bind(this),exclude:this._mergePropExclude.bind(this),files:this._mergePropFiles.bind(this),groups:this._mergePropGroups.bind(this),messages:this._mergePropMessages,nameSpaces:this._mergePropNameSpaces.bind(this),options:this._mergePropOptions.bind(this),ruleMods:this._mergePropRuleMods.bind(this),ruleNames:this._mergePropRuleNames.bind(this),rulePacks:this._mergePropRulePacks,sevMap:this._mergePropSevMap.bind(this),typescript:this._mergePropTypescript.bind(this)}}extend(){if(!this._isDebug){this._isDebug=this._cfg.options&&this._cfg.options.debug}if(!this._isVerbose){this._isVerbose=this._cfg.options&&this._cfg.options.verbose}if(this._isDebug||this._isVerbose){this._msgCtx.info("[Info]: Merging configurations...","I",true)}if(!this._createStack()){return null}if(this._isDebug){this._dumpStack()}if(!this._isError){this._checkMergePropTypes();if(this._isError){return null}}if(!this._checkStackEnableDisableConflicts()||!this._checkUnsupportedProfileProps()||!this._checkProfileExtend()||!this._checkExtendOptionsProfile()||this._isError){return null}if(!this._stack.length){return this._cfg}return this._mergeStack()}_createStack(fp){var cfg,json,fp,first,stkEntry,profile;if(first=!fp){cfg=this._cfg;fp=this._isAMD?DUMMY_FP:this._path?this._path:this._fp}if(!fp){return true}if(this._utils.isObject(fp)){if(!(fp=this._resolveProfilePath(fp))){return false}if(fp.profile){profile=fp.profile}fp=fp.path}else if(!first&&typeof fp==="string"&&this._isAMD){this._error("Config cannot extend a non-profile config in AMD mode");return false}if(first){json=cfg}else if(this._isAMD){if(profile){if(json=this._nd.AmdProfLoader(profile)){json=this._parseJson(json)}if(!json){return false}}else{this._error("Config extends must contain a 'profile' propery in AMD mode");return false}fp=null}else{fp=this._getAbsolutePath(fp);if(!this._fsUtils.fileExists(fp)){let err=profile?`Configuration profile '${profile}' not found`:`Configuration file not found : ${fp}`;this._error(err);return false}if(this._isCircular(fp)){this._error(`Circular configuration 'extends' detected : ${fp}`);return false}try{if(!(json=this._readParseConfig(fp))){return false}}catch(e){this._error(`Error reading 'extends' config : ${fp}`);return false}}if(fp===DUMMY_FP){fp=null}stkEntry={path:fp,cfg:json};if(profile){stkEntry.profile=profile}this._stack.push(stkEntry);if(profile){if(!this._profResult){this._profResult={profiles:[profile]};if(json.ruleMods){if(json.ruleMods.enable){this._profResult.enable=json.ruleMods.enable}else{this._profResult.enable=[]}if(json.ruleMods.disable){this._profResult.disable=json.ruleMods.disable}else{this._profResult.disable=[]}}}else{this._profResult.profiles.push(profile)}}if(json.extends){if(!this._createStack(json.extends)){return false}}return true}_readParseConfig(fp){var json;json=this._nd.fs.readFileSync(fp,"utf8");json=this._nd.decomment(json);if(!(json=this._preprocessRawJson(json,fp))){return null}return this._parseJson(json,fp)}_parseJson(json,fp){var o;o=this._utils.parseJson(json,false);if(o.msg){let pos=`[${o.line}, ${o.col}]`;fp=fp?" : "+fp:"";this._error(`Config 'extends' error at ${pos} : ${o.msg}${fp}`);return null}return o.obj}_preprocessRawJson(txt,fp){var json=this._cfgInst.processIncludes(txt,fp);if(this._cfgInst.isOk()){json=this._cfgInst.processTokens(json);if(this._cfgInst.isOk()){}}return this._cfgInst.isOk()?json:null}_mergeStack(){if(!this._fixupPaths()){return null}for(let i=this._stack.length-1;i>0;i--){if(!this._mergePair(this._stack[i-1],this._stack[i])){return null}}if(this._isMergeProp("files")){if(this._stack[0].cfg.hasOwnProperty("files")){this._stack[0].cfg.files=_removeDupes(this._stack[0].cfg.files)}}if(this._isMergeProp("exclude")){if(this._stack[0].cfg.hasOwnProperty("exclude")){this._stack[0].cfg.exclude=_removeDupes(this._stack[0].cfg.exclude)}}if(this._stack[0].cfg.extends){delete this._stack[0].cfg.extends}return this._stack[0].cfg}_mergePair(parSE,chSE){var props,parent,child,merger,ret=true;parent=parSE.cfg;child=chSE.cfg;this._extendOpts=parSE.cfg.extendOptions||{};props=Object.keys(child);props.forEach(prop=>{if(prop.startsWith("_")||prop==="base"||prop==="extends"||prop==="tokens"||this._extendOpts[prop]===EXOPT_IGNORE){return}if(prop==="title"&&chSE.profile){return}if(!parent.hasOwnProperty(prop)){parent[prop]=child[prop];return}if(!this._isMergeProp(prop)){return}if(merger=this._mergeHandlers[prop]){if(!merger(parSE,chSE)){ret=false}}});if(!ret){return ret}if(!parSE.profile&&parSE.cfg.ruleNames){if(!this._checkRuleNamesProfileConflicts(parSE)){return false}}let type,what;if(chSE.profile){type="profile";what=chSE.profile}else{type="config";what=chSE.path}this._msgCtx.info(`[Info]: Inheriting ${type} '${what}'`,"I",true);return true}_checkMergePropTypes(){var cfg,se,prop,prop2,val;for(let i=0;i<this._stack.length;i++){se=this._stack[i];cfg=se.cfg;if(!this._cfgLib.checkPropNames(cfg,se.path)){this._isError=true}if(cfg.extendOptions){if(this._utils.isObject(cfg.extendOptions)){this._extendOpts=cfg.extendOptions;for(prop in this._extendOpts){val=this._extendOpts[prop];if(val===EXOPT_MERGE&&!MERGEABLE_BY_OPTION[prop]){this._emitErrorMsg(MSG.EXT_OPT,prop,se.path);return}else if(val!==EXOPT_MERGE&&val!==EXOPT_IGNORE){this._emitErrorMsg(MSG.EXT_OPT_VAL,prop,se.path);return}}}else{this._emitErrorMsg(MSG.OBJ,"extendOptions",se.path);return}}else{this._extendOpts={}}for(prop in cfg){if(!this._isMergeProp(prop)){continue}val=cfg[prop];if(prop==="components"||prop==="componentUrls"){if(typeof val!=="string"&&!Array.isArray(val)||!this._utils.isArrayContentsType(val,"string")){this._emitErrorMsg(MSG.STR_OR_AR_STR,prop,se.path)}}else if(prop==="files"){if(!Array.isArray(val)){this._emitErrorMsg(prop,prop,se.path)}if(!this._utils.isArrayContentsType(val,["string","object"])){this._emitErrorMsg(MSG.AR_STR_OBJ,prop,se.path)}}else if(prop==="exclude"){if(!Array.isArray(val)||!this._utils.isArrayContentsType(val,"string")){this._emitErrorMsg(MSG.STR_OR_AR_STR,prop,se.path)}}else if(prop==="groups"){if(!Array.isArray(val)){this._emitErrorMsg(MSG.STR,prop,se.path)}}else if(prop==="messages"){if(!this._utils.isObject(val)){this._emitErrorMsg(MSG.OBJ,prop,se.path)}if(se.messages.reject){if(!Array.isArray(se.messages.reject)){this._emitErrorMsg(MSG.OBJ,"messages.reject",se.path)}}if(se.messages.accept){if(!Array.isArray(se.messages.accept)){this._emitErrorMsg(MSG.OBJ,"messages.accept",se.path)}}}else if(prop==="nameSpaces"){if(!Array.isArray(val)){this._emitErrorMsg(MSG.AR_STR,prop,se.path)}}else if(prop==="options"){if(!this._utils.isObject(val)){this._emitErrorMsg(MSG.OBJ,prop,se.path)}}else if(prop==="ruleMods"){if(!this._utils.isObject(val)){this._emitErrorMsg(MSG.OBJ,prop,se.path);continue}for(prop2 in val){if(prop2==="enable"||prop2==="disable"){if(!Array.isArray(val[prop2])){this._emitErrorMsg(MSG.AR_OBJ,prop2==="enable"?"ruleMods.enable":"ruleMods.disable",se.path)}}else{if(!this._utils.isObject(val[prop2])){this._emitErrorMsg(MSG.AR_OBJ,prop+"."+prop2,se.path)}}}}else if(prop==="ruleNames"){if(!Array.isArray(val)||!this._utils.isArrayContentsType(val,"string")){this._emitErrorMsg(MSG.AR_STR,prop,se.path)}}else if(prop==="rulePacks"){if(!Array.isArray(val)||!this._utils.isArrayContentsType(val,"object")){this._emitErrorMsg(MSG.AR_OBJ,prop,se.path)}}else if(prop==="sevMap"){if(!this._utils.isObject(val)){this._emitErrorMsg(MSG.OBJ,prop,se.path)}if(val.sevMsg&&!this._utils.isObject(val.sevMsg)){this._emitErrorMsg(MSG.OBJ,prop+".sevMsg",se.path)}if(val.sevSet&&!this._utils.isObject(val.sevSet)){this._emitErrorMsg(MSG.OBJ,prop+".sevSet",se.path)}}else if(prop==="tokens"){if(!this._utils.isObject(val)){this._emitErrorMsg(MSG.OBJ,prop,se.path)}}else if(prop==="typescript"){if(!this._utils.isObject(val)){this._emitErrorMsg(MSG.OBJ,prop,se.path)}for(prop2 in val){if(prop2==="tsconfig"&&typeof val[prop2]!=="string"){this._emitErrorMsg(MSG.STR,"typescript.tsconfig",se.path)}if(prop2==="compile"&&typeof val[prop2]!=="boolean"){this._emitErrorMsg(MSG.BOOL,"typescript.compile",se.path)}}}else{this._error(`JAF ERROR: unhandled 'extends' property '${prop}' - ${se.path}`);this._isError=true}}}}_checkStackEnableDisableConflicts(){var config,i,b=true;for(i=this._stack.length-1;i>=0;i--){config=this._stack[i];if(!this._cfgLib.processRuleMods(config.cfg,config.profile?`profile '${config.profile}'`:config.path)){b=false}}if(!b){this._isError=true}return b}_checkRuleNamesProfileConflicts(parSE){var enable,rules,rule,i,profiles,isSet,b=true;if(!(this._profResult&&this._profResult.enable)){return true}rules=parSE.cfg.ruleNames;enable=this._profResult.enable;isSet=this._profResult.profiles.length>1;profiles=(isSet?"set [":"'")+this._profResult.profiles.join(", ")+(isSet?"]":"'");for(i=0;i<enable.length;i++){rule=enable[i];if(!rules.includes(rule)){this._msgCtx.error(`Config 'ruleNames' cannot disable rule '${rule}' enabled in profile ${profiles} - ${parSE.path}`);b=false}}if(!b){this._isError=true}return b}_checkUnsupportedProfileProps(){var se,config,i,b=true;var _self=this;function _emitUnsupProfileError(prof,prop){_self._msgCtx.error(`Property '${prop}' is not supported in profile ('${prof}')`);_self._isError=true;b=false}for(i=this._stack.length-1;i>=0;i--){se=this._stack[i];if(se.profile){config=se.cfg;if(config.ruleNames){_emitUnsupProfileError(se.profile,"ruleNames")}if(config.groups){_emitUnsupProfileError(se.profile,"groups")}}}return b}_checkProfileExtend(){var i;var stk=this._stack;for(i=0;i<stk.length;i++){if(!stk[i].profile){continue}for(i=i+1;i<stk.length;i++){if(!stk[i].profile){this._msgCtx.error(`Profile '${stk[i-1].profile}' cannot extend from a non-profile config - ${stk[i].path}`);return false}}break}return true}_checkExtendOptionsProfile(){if(this._profResult){let stk=this._stack;let opts;for(let i=0;i<stk.length;i++){if(opts=stk[i].cfg.extendOptions){if(opts.ruleMods==="ignore"){let isSet=this._profResult.profiles.length>1;let profiles=(isSet?"set [":"'")+this._profResult.profiles.join(", ")+(isSet?"]":"'");this._msgCtx.error(`Config cannot use 'extendsOptions.ruleMods' to ignore inherited 'ruleMods' from profile ${profiles} - ${stk[i].path}`);return false}}}}return true}_resolveProfilePath(o){var prof,ret;if(!(prof=o.profile)){this._error(`JAF ERROR: 'extends' declared as an object but property 'profile' is missing.`);this._isError=true;return null}ret={profile:o.profile};if(!this._isAMD){ret.path=this._nd.path.join(__dirname,"../"+PROFILE_DIR,prof)+".json"};return ret}_fixupPaths(){var se,ret=true;for(let i=this._stack.length-1;i>=0;i--){se=this._stack[i];if(!(this._cleanBase(se)&&this._fixupConfig(se))){ret=false;break}}return ret}_cleanBase(se){if(this._isAMD){return true}var src,ft;var nd=this._nd;src=se.cfg.base;if(src==="$jafcwd"){src=this._cwd}else{if(!src){src=this._nd.path.dirname(se.path)}src=nd.path.normalize(src);if(!nd.path.isAbsolute(src)){src=nd.path.join(nd.path.dirname(se.path),src)}ft=this._fsUtils.getFileType(src);if(ft!=="d"){this._msgCtx.error(`Config file 'base' is not a directory - '${src}' in ${se.path}`);return false}}se.cfg.base=src;this._info(`[Info]: Using config base '${src}' in ${se.path}`,"I");return true}_fixupConfig(se){var nd,cfg,src,dir,ft,i;nd=this._nd;cfg=se.cfg;if(cfg.files){if(!this._cfgLib.validateFileList(cfg.files)){this._bErrors=true;return}if(src=se.cfg.files){for(i=0;i<src.length;i++){if(!src[i].startsWith("http")){src[i]=nd.path.normalize(src[i]);src[i]=nd.path.resolve(cfg.base,src[i])}}}}if(cfg.exclude){if(!this._cfgLib.validateFileList(cfg.exclude)){this._bErrors=true;return}if(src=cfg.exclude){for(i=0;i<src.length;i++){src[i]=nd.path.normalize(src[i]);src[i]=nd.path.resolve(cfg.base,src[i])}}}src=cfg.components;if(src){for(i=0;i<src.length;i++){dir=nd.path.normalize(src[i]);dir=nd.path.resolve(cfg.base,dir);cfg.components[i]=dir}}src=cfg.outPath;if(src&&src!=="$noout"){src=nd.path.normalize(src);src=nd.path.resolve(cfg.base,src);cfg.outPath=src}src=cfg.rulePacks;if(src){for(i=0;i<src.length;i++){dir=src[i].path;dir=nd.path.normalize(dir);src[i].path=nd.path.resolve(cfg.base,dir);if(src[i].path.endsWith(".zip")){continue}ft=this._fsUtils.getFileType(src[i].path);if(ft!=="d"){this._error("'rulePacks (entry "+(i+1)+"): path' is not a directory - \""+src[i].path+"\"");this._bErrors=true}}}if(cfg.typescript&&cfg.typescript.tsconfig){src=cfg.typescript.tsconfig;if(src&&typeof src==="string"){if(!nd.path.isAbsolute(src)){dir=nd.path.normalize(src);dir=nd.path.resolve(cfg.base,dir)}else{dir=src}if(!dir.endsWith(TSCONFIG)){dir=nd.path.join(dir,TSCONFIG)}cfg.typescript.tsconfig=dir}}if(this._bErrors){this._error(`Errors found in inherited config '${se.path}'`)}return!this._bErrors}_getAbsolutePath(fp){if(this._nd.path.isAbsolute(fp)){return fp}let prevFp,prevBase,p;prevFp=this._stack[this._stack.length-1].path;prevFp=this._nd.path.dirname(prevFp);prevBase=this._stack[this._stack.length-1].cfg.base;if(prevBase){if(!this._nd.path.isAbsolute(prevBase)){p=this._nd.path.join(prevFp,prevBase,fp)}else{p=this._nd.path.join(prevBase,fp)}}else{p=this._nd.path.join(prevFp,fp)}if(!this._nd.path.isAbsolute(p)){p=this._nd.path.join(this._dir,p)}return p}_isCircular(fp){var ret;for(let i=0;i<this._stack.length;i++){if(this._stack[i].path===fp){ret=true;break}}return ret}_isMergeProp(p){return MERGEABLE_BY_DEFAULT[p]||this._extendOpts[p]===EXOPT_MERGE}_mergePropFiles(parSE,chSE){return this._mergePropFilesExclude(parSE,chSE,"files")}_mergePropExclude(parSE,chSE){return this._mergePropFilesExclude(parSE,chSE,"exclude")}_mergePropFilesExclude(parSE,chSE,prop){var parent,child,ch,i;var parent=parSE.cfg[prop];var child=chSE.cfg[prop];for(i=0;i<child.length;i++){ch=child[i];if(!parent.includes(ch)){parent.push(ch)}}return true}_mergePropOptions(parSE,chSE){return this._mergeObjects(parSE,chSE,"options")}_mergePropGroups(parSE,chSE){return this._mergeArrays(parSE,chSE,"groups")}_mergePropTokens(parSE,chSE){return this._mergeObjects(parSE,chSE,"tokens")}_mergePropNameSpaces(parSE,chSE){return this._mergeArrays(parSE,chSE,"nameSpaces")}_mergePropRuleMods(parSE,chSE){var pname,pack,parPack,rule,rval;var parent=parSE.cfg.ruleMods;var child=chSE.cfg.ruleMods;if(!this._mergeRuleModsEnableDisable(parSE,chSE)){return false}for(pname in child){if(pname==="enable"||pname==="disable"){continue}pack=child[pname];if(!parent[pname]){parent[pname]=pack;continue}this._mergeRuleModsPackObjects(parent[pname],pack)}parPack=parent[pname];for(rule in rval){if(!parPack[rule]){parPack[rule]=rval[rule]}}return true}_mergeRuleModsEnableDisable(parSE,chSE){var parent,child,val,x;var parEnable,parDisable,chEnable,chDisable;var parent=parSE.cfg.ruleMods;var child=chSE.cfg.ruleMods;parEnable=parent.enable;parDisable=parent.disable;chEnable=child.enable;chDisable=child.disable;var self=this;function _profVetoEnable(val){var ret=false;if(self._profResult&&self._profResult.disable){ret=self._profResult.disable.includes(val)}return ret}function _profVetoDisable(val){var ret=false;if(self._profResult&&self._profResult.enable){ret=self._profResult.enable.includes(val)}return ret}if(parEnable&&chDisable){for(val of parEnable){if(!(parSE.profile&&chSE.profile)){if(_profVetoEnable(val)){this._emitProfileVetoError(val,parSE.path,false);return false}}if((x=chDisable.indexOf(val))>=0){chDisable.splice(x,1)}}}if(parDisable&&chEnable){for(val of parDisable){if(!(parSE.profile&&chSE.profile)){if(_profVetoDisable(val)){this._emitProfileVetoError(val,parSE.path,true);return false}}if((x=chEnable.indexOf(val))>=0){chEnable.splice(x,1)}}}if(chEnable){if(!parEnable){parent.enable=parEnable=[]}for(val of chEnable){if(!parEnable.includes(val)){parEnable.push(val)}}}if(chDisable){if(!parDisable){parent.disable=parDisable=[]}for(val of chDisable){if(!parDisable.includes(val)){parDisable.push(val)}}}if(parSE.profile&&chSE.profile){if(!this._profResult){this._profResult={}}this._profResult.enable=parEnable;this._profResult.disable=parDisable;if(this._isDebug){console.log(`Profile merge: ${parSE.profile} <- ${chSE.profile}`)}}else{if(this._isDebug){console.log(`Merge: '${parSE.path}' <- '${chSE.profile?chSE.profile:chSE.path}'`)}}if(this._isDebug){console.log(`${parSE.path} <- ${chSE.path}`);console.log(`Enable = ${parEnable.join(",\n ")}`);console.log(`Disable = ${parDisable.join(",\n ")}\n`)}return true}_emitProfileVetoError(rule,cfgPath,disable){var profiles,temp,op1,op2;temp=[...this._profResult.profiles];temp.forEach((rule,i)=>{temp[i]="'"+rule+"'"});temp=temp.join(", ");if(disable){op1="disable";op2="enabled"}else{op1="enable";op2="disabled"}profiles="profile"+`${this._profResult.profiles.length>1?" set [":""} ${temp}${this._profResult.profiles.length>1?"]":""}`;cfgPath=cfgPath?`in ${cfgPath} `:"";this._error(`Config 'ruleMods' conflict: cannot ${op1} rule '${rule}' ${cfgPath}- ${op2} by ${profiles}`)}_mergePropRuleNames(parSE,chSE){return this._mergeArrays(parSE,chSE,"ruleNames")}_mergePropRulePacks(parSE,chSE){var parent=parSE.cfg.rulePacks;var child=chSE.cfg.rulePacks;for(let i=0;i<child.length;i++){let ch=child[i];let b=false;for(let j=0;j<parent.length;j++){let par=parent[j];if(ch.path===par.path){b=true;break}}if(!b){parent.push(ch)}}return true}_mergePropMessages(parSE,chSE){var parent=parSE.cfg.messages;var child=chSE.cfg.messages;var parReject=parent.reject;var chReject=child.reject;if(!parReject&&chReject){parent.reject=chReject}else if(parReject&&chReject){parent.reject=_removeDupes(parReject.concat(chReject))}var parAccept=parent.accept;var chAccept=child.accept;if(!parAccept&&chAccept){parent.accept=chAccept}else if(parAccept&&chAccept){parent.accept=_removeDupes(parAccept.concat(chAccept))}return true}_mergePropComponents(parSE,chSE){return this._mergeArrays(parSE,chSE,"components")}_mergePropCompUrls(parSE,chSE){return this._mergeArrays(parSE,chSE,"componentUrls")}_mergePropTypescript(parSE,chSE){return this._mergeObjects(parSE,chSE,"typescript")}_mergePropSevMap(parSE,chSE){var parent=parSE.cfg.sevMap;var child=chSE.cfg.sevMap;var parSevMsg,chSevMsg;var parSevSet,chSevSet;if(parent){parSevMsg=parent.sevMsg;parSevSet=parent.sevSet}if(child){chSevMsg=child.sevMsg;chSevSet=child.sevSet}if(parSevMsg&&chSevMsg){this._mergeObjects(parSE,chSE,"sevMap")}else if(!parSevMsg&&chSevMsg){parent.sevMsg=chSevMsg}if(parSevSet&&chSevSet){this._mergeObjects(parSE,chSE,"sevSet")}else if(!parSevSet&&chSevSet){parent.sevSet=chSevSet}if(parent.sevSet&&parent.sevMsg){let sev,msg,oldsev,val;for(val in parent.sevSet){sev=parent.sevSet[val];for(msg in parent.sevMsg){oldsev=parent.sevMsg[msg];if(val===oldsev){parent.sevMsg[msg]=sev}}}}return true}_mergeObjects(parSE,chSE,prop){var parent,child;parent=parSE.cfg[prop];child=chSE.cfg[prop];for(let prop in child){if(!parent.hasOwnProperty(prop)){parent[prop]=child[prop]}}return true}_mergeRuleModsPackObjects(to,from){var rule;for(rule in from){if(!to[rule]){to[rule]=from[rule]}}}_mergeArrays(parSE,chSE,prop){var parent,child,isPS,isCS,isPA,isCA,val;parent=parSE.cfg[prop];child=chSE.cfg[prop];isPS=typeof parent==="string";isCS=typeof child==="string";if(isPS&&isCS&&parent===child){return}isPA=Array.isArray(parent);isCA=Array.isArray(child);parent=isPA?parent:[parent];child=isCA?child:[child];for(let i=0;i<child.length;i++){val=child[i];if(!parent.includes(val)){parent.push(val)}}return true}_emitErrorMsg(s,prop,path){var s=s||MSG.UNKNOWN;if(prop){s=s.replace(REPL_PROP,prop)}this._error(s.replace(REPL_PATH,path));this._isError=true}_parseError(msg){this._parseError=msg}_dumpStack(){var type,msg;this._msgCtx.info("[Info]: -- Config 'extends' stack --","I",true);for(let i=0;i<this._stack.length;i++){type=this._stack[i].profile;type=type?type:"config ";msg=!this._isAMD?`${type} ${this._stack[i].path}`:`${type}`;this._msgCtx.info(`[Info]: ${msg}`,"I",true)}}}function _removeDupes(ar){return Array.isArray(ar)?ar.filter((val,x)=>ar.indexOf(val)===x):ar};module.exports=Extends;
package/lib/grouplist.js CHANGED
@@ -3,4 +3,4 @@
3
3
  * Licensed under The Universal Permissive License (UPL), Version 1.0
4
4
  * as shown at https://oss.oracle.com/licenses/upl/
5
5
  */
6
- var _color;function showBuiltinGroups(nd,arg,msgCtx){var packs;_init(nd);if(packs=nd.builtinpacks.getPackMetadata(nd,msgCtx)){let prefixes=nd.builtinpacks.getPrefixes();for(let pack of prefixes){if(!arg||arg===pack){_display(packs[pack],true)}}}};function showExternalGroups(packs,arg,nd){var pack,isExternal;_init(nd);if(arg){arg=arg.toLowerCase()}for(pack of packs){if(!pack.builtin){if(!arg||arg===pack.prefix.toLowerCase()){_display(pack);isExternal=true}}}if(!isExternal){console.log(_color.BRIGHTRED(" No external rule packs declared!"))}};function _display(pack,isBuiltin){var rules,rule,opts,summary={},oos=[],dis=[],groups,group,msg;if(isBuiltin){_title(pack);rules=pack.rules;for(rule in rules){opts=rules[rule];if(!(groups=opts.group)){continue};if(typeof groups==="string"){groups=[groups]}for(group of groups){if(!summary[group]){summary[group]=[]}summary[group].push(rule)}if(opts.hasOwnProperty("inservice")&&!opts.inservice){oos.push(rule)}else{if(opts.hasOwnProperty("enabled")&&!opts.enabled){dis.push(rule)}}}groups=Object.keys(summary);groups=groups.sort()}else{_title(pack);if(pack.groupMap){summary=pack.groupMap;groups=Object.keys(pack.groupMap);groups=groups.sort()}}if(!groups){console.log(_color.BRIGHTYELLOW(`● No groups`));return}for(group of groups){console.log(_color.BRIGHTYELLOW(`● ${group}:`));rules=summary[group];for(rule of rules){msg=` ${rule}`;if(oos.includes(rule)){msg+=_color.RED(" (out of service)")}else if(dis.includes(rule)){msg+=_color.RED(" (disabled by default)")}console.log(msg)}}};function _title(pack){console.log(`\n\n${_color.BRIGHTRED("\u25CF")} ${_color.CYAN("Pack")} ${_color.BRIGHTRED(`${pack.prefix}`)} ${_color.CYAN(" - Group Rule Membership")}`)};function _init(nd){_color=nd.colors};module.exports.showBuiltinGroups=showBuiltinGroups;module.exports.showExternalGroups=showExternalGroups;
6
+ function showBuiltinGroups(nd,arg,appCtx){var packs;if(packs=nd.builtinpacks.getPackMetadata(nd,appCtx)){let prefixes=nd.builtinpacks.getPrefixes();for(let pack of prefixes){if(!arg||arg===pack){_display(packs[pack],true,appCtx.colors)}}}};function showExternalGroups(packs,arg,nd,appCtx){var pack,isExternal;if(arg){arg=arg.toLowerCase()}for(pack of packs){if(!pack.builtin){if(!arg||arg===pack.prefix.toLowerCase()){_display(pack,appCtx.colors);isExternal=true}}}if(!isExternal){console.log(appCtx.colors.BRIGHTRED(" No external rule packs declared!"))}};function _display(pack,isBuiltin,clr){var rules,rule,opts,summary={},oos=[],dis=[],groups,group,msg;if(isBuiltin){_title(pack,clr);rules=pack.rules;for(rule in rules){opts=rules[rule];if(!(groups=opts.group)){continue};if(typeof groups==="string"){groups=[groups]}for(group of groups){if(!summary[group]){summary[group]=[]}summary[group].push(rule)}if(opts.hasOwnProperty("inservice")&&!opts.inservice){oos.push(rule)}else{if(opts.hasOwnProperty("enabled")&&!opts.enabled){dis.push(rule)}}}groups=Object.keys(summary);groups=groups.sort()}else{_title(pack,clr);if(pack.groupMap){summary=pack.groupMap;groups=Object.keys(pack.groupMap);groups=groups.sort()}}if(!groups){console.log(clr.BRIGHTYELLOW(`● No groups`));return}for(group of groups){console.log(clr.BRIGHTYELLOW(`● ${group}:`));rules=summary[group];for(rule of rules){msg=` ${rule}`;if(oos.includes(rule)){msg+=clr.RED(" (out of service)")}else if(dis.includes(rule)){msg+=clr.RED(" (disabled by default)")}console.log(msg)}}};function _title(pack,clr){console.log(`\n\n${clr.BRIGHTRED("\u25CF")} ${clr.CYAN("Pack")} ${clr.BRIGHTRED(`${pack.prefix}`)} ${clr.CYAN(" - Group Rule Membership")}`)};module.exports.showBuiltinGroups=showBuiltinGroups;module.exports.showExternalGroups=showExternalGroups;
package/lib/groups.js CHANGED
@@ -3,4 +3,4 @@
3
3
  * Licensed under The Universal Permissive License (UPL), Version 1.0
4
4
  * as shown at https://oss.oracle.com/licenses/upl/
5
5
  */
6
- const _GROUPS={all:true,'jet-html':true,'jet-css':true,'jet-js':true,'jet-ts':true,'jet-tsx':true,'jet-json':true,'jet-md':true,'jet-aria':true,'jet-deprecated':true,'jet-deleted':true,'jet-override':true,'jet-cca':true,'jet-spoc':true,'jet-csp':true,'jet-demo':true,'jet-bp':true,'jet-perf':true,html5:true};module.exports.isGroup=g=>{return _GROUPS[g]};
6
+ const _GROUPS={all:true,'jet-html':true,'jet-css':true,'jet-js':true,'jet-ts':true,'jet-tsx':true,'jet-json':true,'jet-md':true,'jet-aria':true,'jet-deprecated':true,'jet-deleted':true,'jet-override':true,'jet-cca':true,'jet-spoc':true,'jet-csp':true,'jet-demo':true,'jet-bp':true,'jet-redwood-bp':true,'jet-perf':true,html5:true};module.exports.isGroup=g=>{return _GROUPS[g]};
package/lib/help.js CHANGED
@@ -3,4 +3,4 @@
3
3
  * Licensed under The Universal Permissive License (UPL), Version 1.0
4
4
  * as shown at https://oss.oracle.com/licenses/upl/
5
5
  */
6
- const FLAGS=["\n Command line: %ojaf [flags] [ files/directory space separated list]%\n","\n Audit related flags:\n"," ~--config~ or ^-c^ : %followed by filepath to configuration file. If%"," %omitted, current directory is used.%"," ~--base~ or ^-b^ : %followed by filepath used to resolve relative paths. If%"," %omitted, current directory is used.%"," ~--jetver~ or ^-jv^ : %sets the JET version - must be followed by a version number x[.y[.z]]%"," ~--format~ or ^-t^ : %followed by output format 'prose' | 'json' | 'line'%"," ~--outPath~ or ^-o^ : %followed by output file path%"," ~--noout~ or ^-no^ : %do not write to output file path%"," ~--severity~ or ^-s^ : %report on this rule severity only%"," ~--groups~ or ^-g^ : %followed by group(s)%"," ~--groups=~ or ^-g=^ : %followed by group(s)%"," ~--followlinks~ or ^-fl^ : %follow stylesheet/script links%"," ~--nofollowlinks~ or ^-nfl^ : %do not follow stylesheet/script links%"," ~--extra~ or ^-e^ : %verbose - show extra details%"," ~--retcode~ or ^-rc^ : %followed by 'auto' | 'errors' | number, to override return code%"," ~--retcode=~ or ^-rc=^ : %followed by 'auto' | 'errors' | number, to override return code%"," ~--msgid~ or ^-id^ : %show audit message id's in the ouput if format 'prose'%"," ~--nocolor~ or ^-nc^ : %do not colorize output%"," ~--debug~ or ^-d^ : %debug mode%","\n Immediate command flags - display JAF info or scaffold files (no auditing involved)\n"," ~--help~ or ^-h^ : %show this help%"," ~--help~ or ^-h^ : %followed by messageID | rulename : show rule description%"," ~--version~ or ^-v^ : %show the ojaf version%"," ~--jetlist~ or ^-jl^ : %show the supported JET versions%"," ~--nslist~ or ^-nsl^ : %show the supported registered Namespaces%"," ~--grouplist~ or ^-gl^ : %show built-in rules by group. May be followed by an%"," %optional pack prefix.%"," ~--xgrouplist~ or ^-xgl^ : %show external pack rules by group. May be followed by an%"," %optional pack prefix.%"," ~--dislist~ or ^-dl^ : %show the JET built-in rules disabled by default. May be followed%"," %by an optional pack prefix.%"," ~--metahist~ or ^-mh^ : %show the renamed/deleted JET component history%\n"," ~--dac~ or ^-dac^ : %display active config and terminate (no audit performed)%"," ~--reg~ or ^-reg^ : %display rule listener types (debug)%"," ~--init~ or ^-i^ : %scaffold a JAF config file%"," ~--initrule~ or ^-ir^ : %followed by rulename (no file extension) - scaffold a rule file%\n"," ~--rules~ or ^-r^ : %display rule information%"," ~--rulessonar~ or ^-rs^ : %display rule information - sonar format%"," ~--rulesjson~ or ^-rj^ : %display rule information - json format%"," ~--dryrun~ or ^-dr^ : %dry run - show setup and files that would have been audited (no%"," %audit performed)%","\n1) Command line args override corresponding properties in the configuration file.","2) Command flags are case independent."];module.exports=function(fnShowVersion,color,msgContext){var console=msgContext.console;var by=color.BRIGHTYELLOW;var cy=color.CYAN;var x1,x2,x3,x4,x5,x6,msg;fnShowVersion();FLAGS.forEach(s=>{msg="";if((x1=s.indexOf("~"))>=0){x2=s.indexOf("~",x1+1);msg=s.substring(0,x1)+by(s.substring(x1+1,x2));if((x3=s.indexOf("^",x2+1))>=0){x4=s.indexOf("^",x3+1);msg+=s.substring(x2+1,x3)+by(s.substring(x3+1,x4));if((x5=s.indexOf("%",x4+1))>=0){x6=s.indexOf("%",x5+1);msg+=s.substring(x4+1,x5)+cy(s.substring(x5+1,x6))+s.substring(x6+1)}else{msg+=s.substring(x4+1)}}else{msg+=s.substring(x2+1)}}else if((x5=s.indexOf("%"))>=0){x6=s.indexOf("%",x5+1);msg+=s.substring(0,x5)+cy(s.substring(x5+1,x6))+s.substring(x6+1)}else{msg=s}console(msg)})};
6
+ const FLAGS=["\n Command line: %ojaf [flags] [ files/directory space separated list]%\n","\n Audit related flags:\n"," ~--config~ or ^-c^ : %followed by filepath to configuration file. If omitted, the%"," %current directory is used.%"," ~--base~ or ^-b^ : %followed by filepath used to resolve relative paths. If omitted,%"," %the current directory is used.%"," ~--jetver~ or ^-jv^ : %sets the JET version - must be followed by a version number x[.y[.z]]%"," ~--format~ or ^-t^ : %followed by output format 'prose' | 'json' | 'line'.%"," ~--outPath~ or ^-o^ : %followed by output file path.%"," ~--noout~ or ^-no^ : %do not write to output file path.%"," ~--severity~ or ^-s^ : %report on this rule severity only.%"," ~--groups~ or ^-g^ : %followed by group(s)to apply.%"," ~--groups=~ or ^-g=^ : %followed by group(s) to apply.%"," ~--followlinks~ or ^-fl^ : %follow stylesheet/script links.%"," ~--nofollowlinks~ or ^-nfl^ : %do not follow stylesheet/script links.%"," ~--extra~ or ^-e^ : %verbose - show extra details.%"," ~--retcode~ or ^-rc^ : %followed by 'auto' | 'errors' | number, to override return code.%"," ~--retcode=~ or ^-rc=^ : %followed by 'auto' | 'errors' | number, to override return code.%"," ~--msgid~ or ^-id^ : %show audit message id's in the ouput if format 'prose'.%"," ~--nocolor~ or ^-nc^ : %do not colorize output.%"," ~--debug~ or ^-d^ : %debug mode.%","\n Immediate command flags (no auditing) - display JAF info or scaffold files\n"," ~--help~ or ^-h^ : %show this help.%"," ~--help~ or ^-h^ : %followed by messageID | rulename : show rule description.%"," ~--help~ or ^-h^ : %followed by a command : show the manpage for the command.%."," %Can also be requested by adding ? to a command, e.g. --retcode?%"," ~--version~ or ^-v^ : %show the ojaf version.%"," ~--jetlist~ or ^-jl^ : %show the supported JET versions.%"," ~--profiles~ or ^-prof^: %Display the available inheritable configuration profiles. May be%"," %followed by a profile name to display the profile details.%"," ~--nslist~ or ^-nsl^ : %show the supported registered Namespaces.%"," ~--grouplist~ or ^-gl^ : %show built-in rules by group. May be followed by an optional%"," %pack prefix.%"," ~--xgrouplist~ or ^-xgl^ : %show external pack rules by group. May be followed by an optional%"," %pack prefix.%"," ~--dislist~ or ^-dl^ : %show the JET built-in rules disabled by default. May be followed by%"," %an optional pack prefix.%"," ~--amdlist~ or ^-amd^ : %show the JET built-in rules (un)available in AMD mode by default. May bed%"," %followed by an optional pack prefix.%"," ~--loadorder~ or ^-rlo^ : %show the JET built-in rules in load order. May be followed by an optional%"," %pack prefix.%"," ~--betalist~ or ^-bl^ : %show the JET built-in rules not in production status. May be followed by%"," %an optional pack prefix.%"," ~--deflist~ or ^-def^ : %show the configuration default values.%"," ~--metahist~ or ^-mh^ : %show the renamed/deleted JET component history.%\n"," ~--dac~ or ^-dac^ : %display active config and terminate (no audit performed).%"," ~--reg~ or ^-reg^ : %display rule listener types (debug).%"," ~--init~ or ^-i^ : %scaffold a JAF config file.%"," ~--initrule~ or ^-ir^ : %followed by rulename (no file extension) - scaffold a rule file.%\n"," ~--rules~ or ^-r^ : %display rule information.%"," ~--rulessonar~ or ^-rs^ : %display rule information - sonar format.%"," ~--rulesjson~ or ^-rj^ : %display rule information - json format.%"," ~--dryrun~ or ^-dr^ : %dry run - show setup and files that would have been audited (no%"," %audit performed).%","\n1) Command line args override corresponding properties in the configuration file.","2) Command flags are case independent."];module.exports=function(fnShowVersion,appCtx){var console=appCtx.console;var clr=appCtx.colors;var by=clr.BRIGHTYELLOW;var cy=clr.CYAN;var x1,x2,x3,x4,x5,x6,msg;fnShowVersion();FLAGS.forEach(s=>{msg="";if((x1=s.indexOf("~"))>=0){x2=s.indexOf("~",x1+1);msg=s.substring(0,x1)+by(s.substring(x1+1,x2));if((x3=s.indexOf("^",x2+1))>=0){x4=s.indexOf("^",x3+1);msg+=s.substring(x2+1,x3)+by(s.substring(x3+1,x4));if((x5=s.indexOf("%",x4+1))>=0){x6=s.indexOf("%",x5+1);msg+=s.substring(x4+1,x5)+cy(s.substring(x5+1,x6))+s.substring(x6+1)}else{msg+=s.substring(x4+1)}}else{msg+=s.substring(x2+1)}}else if((x5=s.indexOf("%"))>=0){x6=s.indexOf("%",x5+1);msg+=s.substring(0,x5)+cy(s.substring(x5+1,x6))+s.substring(x6+1)}else{msg=s}console(msg)})};
package/lib/jetver.js CHANGED
@@ -3,4 +3,4 @@
3
3
  * Licensed under The Universal Permissive License (UPL), Version 1.0
4
4
  * as shown at https://oss.oracle.com/licenses/upl/
5
5
  */
6
- const verList=require("../meta/metaverlist.json");const DEFAULTS=require("./defaults");const SUP="\xB9";var verData;var nd;function init(nodeDeps){nd=nodeDeps;if(!verData){let o=verList.metaList,o2={},v,s;for(s in o){v=o[s];o2[v.version]={date:v.date,time:v.time}}verData={metaList:o2}}};function showList(){let keys,ver,a,built,isDefVer,list=verData.metaList,indent=" \u2022 ";let sup=nd.colors.BRIGHTYELLOW(SUP);keys=Object.keys(list).sort(function(a,b){var va=a.split(".");var vb=b.split(".");va.forEach(function(v,i,a){a[i]=parseInt(v)});vb.forEach(function(v,i,a){a[i]=parseInt(v)});if(va[0]>vb[0]){return 1}if(va[0]<vb[0]){return-1}if(va[1]>vb[1]){return 1}if(va[1]<vb[1]){return-1}if(va[2]>vb[2]){return 1}if(va[2]<vb[2]){return-1}return 0}).reverse();console.log("\n"+" JET versions supported:");keys.forEach(function(verName){ver=list[verName];a=verName.split(".");a.forEach(function(s,x){a[x]=parseInt(s)});if(a[0]<10){verName=" "+verName}built=" ("+ver.date+" "+ver.time+")";if(isDefVer=verName===DEFAULTS.JETVER){let def=" Default";built+=nd.colors.BRIGHTYELLOW(def)+sup}verName=isDefVer?nd.colors.BRIGHTYELLOW(verName):nd.colors.CYAN(verName);console.log(indent+verName+built)});let footnote="Default config 'jetVer' value if not specified.";footnote=nd.colors.BRIGHTYELLOW(footnote);console.log(`\n${sup} ${footnote}`)};function validate(v){var a;var i;if(v===null){return _getMVError(v,1)}if(typeof v!=="string"){return _getMVError(v,2)}a=v.split(".");for(i=0;i<a.length;i++){if(a[i]===""||parseInt(a[i])===NaN){return _getMVError(v,3)}}return null};function getBestVersion(v,a){return _findVer(v,a)}function _findVer(v,a){var keys=Object.keys(verData.metaList);var suspects=[];var s,i,ret;if(!Array.isArray(a)){a=v.split(".")}if(a.length===3&&a[2]==="0"){a.length=2}if(a.length===2){s=a[0]+"."+a[1]+".";for(i=0;i<keys.length;i++){if(keys[i].startsWith(s)){suspects.push(keys[i])}}}else if(a.length===1){s=a[0]+".";for(i=0;i<keys.length;i++){if(keys[i].startsWith(s)){suspects.push(keys[i])}}}if(suspects.length===1){return suspects[0]}if(!suspects.length){return null}ret="0.0.0";for(i=0;i<suspects.length;i++){if(suspects[i]>ret){ret=suspects[i]}}return ret};function getVersions(){return verData.metaList};function _getMVError(v,errno){var s;switch(errno){case 1:s="missing version arg after --jetver";break;case 2:s="--jetver '"+v+"' : invalid - expected major.minor.patch";break;case 3:s="--jetver '"+v+"' : invalid version specification";break;default:s="unknown error";}return s};module.exports.init=init;module.exports.validate=validate;module.exports.getVersions=getVersions;module.exports.getBestVersion=getBestVersion;module.exports.showList=showList;
6
+ const verList=require("../meta/metaverlist.json");var verData;function init(){if(!verData){let o=verList.metaList,o2={},v,s;for(s in o){v=o[s];o2[v.version]={date:v.date,time:v.time}}verData={metaList:o2}}};function validate(v){var a;var i;if(v===null){return _getMVError(v,1)}if(typeof v!=="string"){return _getMVError(v,2)}a=v.split(".");for(i=0;i<a.length;i++){if(a[i]===""||parseInt(a[i])===NaN){return _getMVError(v,3)}}return null};function getBestVersion(v,a){return _findVer(v,a)}function _findVer(v,a){var keys=Object.keys(verData.metaList);var suspects=[];var s,i,ret;if(!Array.isArray(a)){a=v.split(".")}if(a.length===3&&a[2]==="0"){a.length=2}if(a.length===2){s=a[0]+"."+a[1]+".";for(i=0;i<keys.length;i++){if(keys[i].startsWith(s)){suspects.push(keys[i])}}}else if(a.length===1){s=a[0]+".";for(i=0;i<keys.length;i++){if(keys[i].startsWith(s)){suspects.push(keys[i])}}}if(suspects.length===1){return suspects[0]}if(!suspects.length){return null}ret="0.0.0";for(i=0;i<suspects.length;i++){if(suspects[i]>ret){ret=suspects[i]}}return ret};function getVersions(){return verData.metaList};function _getMVError(v,errno){var s;switch(errno){case 1:s="missing version arg after --jetver";break;case 2:s="--jetver '"+v+"' : invalid - expected major.minor.patch";break;case 3:s="--jetver '"+v+"' : invalid version specification";break;default:s="unknown error";}return s};module.exports.init=init;module.exports.validate=validate;module.exports.getVersions=getVersions;module.exports.getBestVersion=getBestVersion;
package/lib/manpage.js ADDED
@@ -0,0 +1,6 @@
1
+ /*
2
+ * Copyright (c) 2018, 2022, Oracle and/or its affiliates.
3
+ * Licensed under The Universal Permissive License (UPL), Version 1.0
4
+ * as shown at https://oss.oracle.com/licenses/upl/
5
+ */
6
+ const RulePack=require("./RulePack");const INDENT=" ";const LEFT="\u2502 ";const RIGHT=" \u2502";var clr;function show(manPage,syn,color){var page,lines,ret;if(page=_MANPAGES[manPage]){clr=color;_showTitle(manPage,syn);lines=_processSynopsis(page);lines.forEach(line=>{console.log(line)});lines=_processDescription(page);lines.forEach(line=>{console.log(line)});lines=_processOptions(page);lines.forEach(line=>{console.log(line)});console.log("\n");ret=true}else{console.log(`Internal Error: manpage --${manPage} not found\n`);ret=false}return ret};function _processSynopsis(page){var i;var maxlen=0;var lines=page.synopsis;lines.forEach(line=>{maxlen=maxlen<line.length?line.length:maxlen});maxlen+=INDENT.length;for(i=0;i<lines.length;i++){lines[i]=_boxLine(lines[i],maxlen)}lines.splice(0,0,_boxStart(maxlen));lines.push(_boxEnd(maxlen));lines.forEach((line,i)=>{lines[i]=clr.BRIGHTGREEN(line)});lines=_indent(lines);lines.splice(0,0,clr.BRIGHTYELLOW("\xA7 Synopsis:"));return lines};function _processDescription(page){var lines=page.description;lines.splice(0,0,"\n"+clr.BRIGHTYELLOW("Description:"));return _indent(lines,true)};function _processOptions(page){var lines=page.options;lines.splice(0,0,"\n"+clr.BRIGHTYELLOW("Options:"));return lines=_indent(lines,true)};function _showTitle(manpage,syn){console.log("\n"+INDENT+clr.BLACKONRED(`*** Manual Page for --${manpage} : Short form --${syn} ***`)+"\n")}function _indent(lines,notFirst){lines.forEach((line,i)=>{if(!notFirst||i)lines[i]=INDENT+line});return lines};function _boxStart(max){return"\u250C\u2500\u2500"+"\u2500".repeat(max)+"\u2500\u2500\u2510"};function _boxEnd(max){return"\u2514\u2500\u2500"+"\u2500".repeat(max)+"\u2500\u2500\u2518"};function _boxLine(line,max){return LEFT+line+" ".repeat(max-line.length)+RIGHT};const _MANPAGES={"amdlist":{synopsis:["--amdlist","--amdlist <packprefix> Displays the rules available/unavailable in AMD mode for the specified pack prefix."],description:["Displays the JET built-in rules that are available/unavailable in AMD mode by default in JET builtin rulepacks.","No audit is performed"],options:["--amdlist \u25CF Displays the rules available/unavailable in AMD mode for all JET built-in rulepacks.\n","--amdlist <pack prefix> \u25CF Displays the rules available/unavailable in AMD mode for the specified pack prefix,"," e.g. --amdlist jet"," Note: the pack prefix may be of any case."]},"base":{synopsis:["--base <filepath>"],description:["Specifies the base filepath upon which relative files paths ae resolved (e.g. the --config command, or other"," relative paths in the configuration).\n"],options:["<filepath> \u25CF The base filepath. If the base path is itself relative, it is considered to be relative to"," the current working directory. This command overrides the 'base' property in the configuration"," file."]},"betalist":{synopsis:["--betalist","--batalist <pack prefix>"],description:["Displays the JET built-in rules that are available, but not in production status."],options:["<pack prefix> \u25CF Specify a pack prefix (case independent) to restrict the output to the"," rules in the pack. e.g. ojaf --gl jet"]},"config":{synopsis:["--config <path to configuration file>"],description:["specifies the configuration file to use for the audit."],options:["<path to configuration file> \u25CF Full or relative path to the configuration file.\n"," If path is relative, it is considered to be relative to the current"," working directory, or to the path specified by --base (or -b)."," The path may use forward slashes for Windows, to avoid escaping"," backslashes in the path."]},"dac":{synopsis:["--dac"],description:["Displays the active configuration. This is the configuration that would be used in an audit after","resolving any inheritance via the 'extends' configuration property. No audit is performed.\n","The configuration used is either that specified on the command line (using the --config or -c command),","or the 'jafconfig.json' or oraclejetconfig.json' found in the current woriking directory"],options:[" - None -"]},"debug":{synopsis:["--debug"],description:["Enables debug mode (very verbose). Useful for diagnosing problems."],options:[" - None -"]},"deflist":{synopsis:["--deflist"],description:["Displays the configuration default property values."],options:[" - None -"]},"dislist":{synopsis:["--dislist","--dislist <pack prefix>"],description:["Displays the JET built-in rules disabled by default."],options:["<pack prefix> \u25CF Displays the rules disabled by default for the specified built-in JET pack prefix"," e.g. --dislist jet, or --dislist jetwco"," Note: the pack prefix may be of any case. If the pack prefix is omitted, the disabled"," default rules are displayed for all JET built-in rulepacks."]},"dryrun":{synopsis:["--dryrun"],description:["Performs a full start-up and analysis of the configuration file, but does not actually fire any rules on the fileset","generated by the configuration 'files' and 'exclude' options. Useful for verifying that the configuration file contains","no errors, and to display the files that would have been audited - this is particularly useful with complex files and","exclude options, without having to inspect the full output.\n","The command should be followed either by a --config (or -c) and the configuration file path, or ojaf will use the","'oraclejetconfig.json' or the 'jafconfig.json' if found in the current working directory, else a default","configuration is dynamically generated."],options:[" - None -"]},"extra":{synopsis:["--extra"],description:["Enables verbose mode. Extra informational details are shown in the output. Useful when creating an audit","with a complex configuration."],options:[" - None -"]},"followlinks":{synopsis:["--followlinks"],description:["Enables the following of HTML stylesheet <link> elements and audit of the linked-to stylesheets. This overrides the","value of configuration property 'followlinks' if it is specified as false."],options:[" - None -"]},"format":{synopsis:["--format <format>"],description:["Specifies the format of the ojaf output."],options:["<format> \u25CF The following formats are available:\n"," prose - the standaard default text report style output"," line - a flattened-out text style single line output. Useful in a VS Code"," terminal window."," json - JSON output\n"," Example:\n "," --format line"]},"grouplist":{synopsis:["--grouplist","--grouplist <pack prefix>"],description:["Displays the rulenames classified by group."],options:["<pack prefix> \u25CF Specify a pack prefix (case independent) to retrict the output to the"," groups provided by the pack. e.g. ojaf --gl jet"]},"groups":{synopsis:["--groups \"<groupname\" [, \"<groupname>\" [, \"<groupname>\" . . .] ]","--groups=\"<groupname>, <groupname>, < . . .\""],description:["Specifies the group(s), which are rule name sets, that are to be applied to the audit. This","command overrides the configuration file property 'groups' if specified."],options:["<groupname> \u25CF A group name:\n"," all All groups are applied"," jet-aria Accessibility rules"," jet-bp Best practices rules"," jet-cca Web component metadata"," jet-css CSS rules"," jet-csp Rules checking for Content Security Policy violations"," jet-deleted Rules checking deleted status"," jet-deprecated Rules checking deprecated status"," jet-html HTML rules"," jet-json JSON rules"," jet-js JavaScript rules"," jet-md Markdown rules"," jet-override Rules that chack forr CSS overrides"," jet-perf Performance rules"," jet-redwood-bp Best practices rules for Redwood"," jet-ts JET .ts related rules"," jet-tsx JET .tsx related rules"," html5 Rules related to HTML 5\n","For JETWC Extended Audits:"," jetwc-structure\t Audits that check that the overall disk layout is as expected by"," the Oracle JET tooling and the requirements of Component reliable"," referencing. This group should be enabled for most component sets"," jetwc-dependencies Audits that verify the various dependency relationships between components"," both within and across packs. This group should be enabled for all"," component sets"," jetwc-pre-release\t A set of audits to be run before you cut a production release"," jetwc-api Rules that verify the consistency and correctness of your component APIs."," This group should be enabled for all component sets"," jetwc-vb A set of rules that specifically check for things that effect the Visual"," Builder usage experience of your components."," jetwc-nls Rules relating to NLS support"," jetwc-deprecations Rules that check for known deprecated usages."," jetwc-theming Rules to enable if you are trying to create theme-able components\n","The following audit groups are defined in the builtinJetWcOracleRules (JETWCO) rule-set:\n"," jetwco-pre-release A set of audits to be run before you cut a production release"," jetwco-api Rules that verify the consistency and correctness of your component APIs."," jetwco-doc Enforcement of Oracle doc standards"]},"help":{synopsis:["--help Display the help command list","--help <message-id> Display a rule message ID help","--help <rule-name> Display help for a rule","--help <command> Display the manual page for a command"],description:["The --help (or -h) command displays general command help, specific help for a rule message ID, or for rule namee,","or a manual page for a help command.","","\u25CF With no options specified, --help generates a list of the CLI commands available.\n","\u25CF With a message ID specified, the help/description for the associated rule is displayed.\n","\u25CF With a rulename specified, the help/description for the rule is displayed.\n","\u25CF With a help command, the manual page for the command is displayed."],options:["<message-id> \u25CF Specify the full message ID, e.g. --help jet-1234 (the prefix may be of any case)\n"," \u25CF Specify the message number without a prefix. The prefix defaults to 'JET-'', e.g. --help 2170\n"," \u25CF Note: if the message number starts with one or more preceding zeros, they may be omitted"," e.g. --help 430\n","<rule name> \u25CF the full rule name, e.g. --help oj-html-stylesel\n","<command> \u25CF a help command from the list of commands displayed by --help, e.g. --help jetlist"," Note: the manpage for a command can also be displayed by suffixing the command with a '?'"," e.g. --retcode? or -ir?"]},"init":{synopsis:["--init"],description:["Scaffolds a (skeleton) jaf configuration file in the directory in which it was run.\n","The command should be run in the top level project directory. The command uses the","'oraclejetonfig.json' file (used by ojet), if present, to generate an 'oraclejafconfig.json'","file, or a default 'jafconfig.json' if not."],options:[" - None -"]},"initrule":{synopsis:["--initrule <rulename>"],description:["Creates a scaffolded (skeleton) rule file in the current working directory to use as basis for developing a new rule."],options:["<rulename> \u25CF The name of the rule without the file extension, e.g. --initrule my-new-rule"]},"jetlist":{synopsis:["--jetlist"],description:["Displays the JET versions supported by the version of ojaf being used."],options:[" - None -"]},"jetver":{synopsis:["--jetver <semver>"],description:["Specifies the JET version to audit against. This overrides the 'jetVer' property in the configuration","file."],options:["<semver> \u25CF A full or partial semantic version. Examples: --jetver \"12\""," --jetver \"12.2\""," --jetver \"12.0.0\"\n"," When a partial semver is supplied, ojaf will match it to the highest JET version it supports."," Thus, for example, \"12\" is sufficient to specify that the audit is for the latest version"," if JET 12 that the version of ojaf knows about. The version list can be displayed by using"," ojaj -jl"]},"loadorder":{synopsis:["--loadorder","--loadorder <pack prefix>"],description:["Displays the load order of built-in JET rules.","This mainly for use by JET rulepack developers."],options:["<pack prefix> \u25CF A rule pack prefix (case independent) e.g."," ojaf -rlo jet"," ojaf -rlo jetwc"]},"metahist":{synopsis:["--metahist"],description:["Displays the JET metadata history known to the version of ojaf being used.","This history includes deleted components, renamed classes, deleted classes, and","methods and members."],options:[" - None -"]},"msgid":{synopsis:["--msgid"],description:["Causes the message ID to be appended to the displayed audit issue when in 'prose' mode (see --format).\n","This commad overrides the configuration property options.msgid\n","Note: this command is ignored if the configuration property 'proseFormat' defines a custom format.)"],options:[" - None -"]},"nslist":{synopsis:["--nslist"],description:["Displays the JET namespaces known to the version of ojaf being used."],options:[" - None -"]},"nocolor":{synopsis:["--nocolor"],description:["Turns off CLI display in color. By default ojaf assumes color mode and a dark mode shell window. This","command overrides the configuration file property options.color","ojaf color support can be turned off globally by setting environment variable 'JAF_COLOR' to false."],options:[" - None -"]},"nofollowlinks":{synopsis:["--nofollowlinks"],description:["Suppresses the following of HTML stylesheet <link> elements. This overrides the value of configuration property","'followlinks' if specified as true (or its default true value if omitted). "],options:[" - None -"]},"noout":{synopsis:["--noout"],description:["Suppresses output to the file specified in the configuration file by property 'outPath', and causes the audit","output to be directed to the console. This command is mutually exclusive with '--outPath'."],options:[" - None -"]},"outPath":{synopsis:["--outPath <filepath>"],description:["Specifies the file path to which the audit output will be written. This command is mutually exclusive with --noout."],options:["<filepath> \u25CF If the file path is relative, it is resolved relative to the current directory."]},"profiles":{synopsis:["--profiles","--profiles <profile name>"],description:["Displays a list of the available inheritable configuration profiles.","Can also display a profile if the command is followed by a profile name."],options:["<profile name> \u25CF The name of a profile from the list pf profiles, e.g. --profiles redwood-strict"]},"reg":{synopsis:["--reg"],description:["Displays rule listener types.","This is primarily a resource for JAF development"],options:[" - None -"]},"retcode":{synopsis:["--retcode auto","--retcode=auto","--retcode <number>","--retcode=<number>","--retcode errors","--retcode <severities>","--retcode=<severities>"],description:["Overrides the ojaf CLI return code."],options:["auto \u25CF Specifiy 'auto' for the default behavior (i.e. returns the number of issues found). e.g.\n"," --retcode=auto or -rc=auto or --retcode auto or -rc auto\n","errors \u25CF Specify 'errors' if the return code should be 0, except in the case of abnormal termination"," where -1 will still be returned as in the default mode.\n","<number> \u25CF A number that will be used as the return code. e.g.\n"," --retcode=0 or -rc=0 or --retcode 0 or -rc 0\n","<severities> \u25CF Specify one or more severities. The return code will formed from the sum of the issues found"," for those severities, The severities can be separated with commas and/or blanks as needed"," depending upon whether quotes are used or not. e.g.\n"," --retcode \"critical,blocker\" or -retcode=critical,blocker\n"," -rc \"critical blocker\" or -rc=critical,blocker"]},"rules":{synopsis:["--rules"],description:["Displays descriptions of the rules in the JET built-in rulepack in prose format.","Refer also to --rulesejson and --rulessonar for other formats"],options:[" - None -"]},"rulesjson":{synopsis:["--rulesjson"],description:["Displays descriptions of the rules in the JET built-in rulepack in JSON format.","Refer also to --rules and --rulessonar for other formats."],options:[" - None -"]},"rulessonar":{synopsis:["--rulessonar"],description:["Displays descriptions of the rules in the JET built-in rulepack in XML format.","Refer also to --rules and --rulesjson for other formats."],options:[" - None -"]},"severity":{synopsis:["--severity <severity>","--severity \"<severity>\"","--severity \"<operator><severity>\""],description:["This commands restricts the audit output to those audit issues matching the <severity> option."],options:["<severity> \u25CF the available severities in descending order of severity are:"," blocker"," critical"," major"," minor"," info, e.g. --severity blocker or,"," --severity \"blocker\"\n","<operator><severity> \u25CF The severity may be preceded by a logical operator of the form:"," >"," >="," <"," <=\n"," Examples:"," --severity \">critical\" same as blocker"," --severity \">=critical\" selects critical and blocker"," --severity \"<=minor\" selects minor and info\n"," When using an operator, the wole expression must be surrounded by quotes."]},"version":{synopsis:["--version"],description:["Displays the version of ojaf being used."],options:[" - None -"]},"xgrouplist":{synopsis:["--xrouplist","--grouplist <pack prefix>"],description:["Displays the rulenames classified by group in an external (that is non-JET) rulepack."],options:["<pack prefix> \u25CF Specify a pack prefix (case independent) to restrict the output to the"," groups provided by the pack. Note that a configuration should also be"," specified (via the --config or -c) command, so that ojaf can find the"," rulePack. e.g. ojaf --gl <prefix> -c <some config name>"]}};module.exports.show=show;
package/lib/manual.js CHANGED
@@ -3,4 +3,4 @@
3
3
  * Licensed under The Universal Permissive License (UPL), Version 1.0
4
4
  * as shown at https://oss.oracle.com/licenses/upl/
5
5
  */
6
- var PREFIX;var RP_PREFIX;const RULES_JSON="rules.json";const MSGID_JSON="msgid.json";const JS=".js";const RE_WS=/^\s*$/;const RE_MARKUP=/<[^>]*>/g;const RE_MULTI_BLANKS=/\s{2,}/g;const EMPTY="";const LINELEN=100;const LIST_INDENT=2;var _nd;var _error;var _path;var _rDir;var _rpDir;var _isMsgId;var _prefix;var _msgNum;var _rawArg;var _sev;var _multiIDs=[];var _color;function showBuiltinMsgHelp(nd,arg,msgCtx){var rc;_init(nd,msgCtx);rc=_initArg(arg);return rc>0?_processBuiltin():rc===0};function showExternalMsgHelp(rules,manCheckL,manCheckS,nd,msgCtx){var check,temp,isShort,o,x,ret=false;_init(nd,msgCtx);check=manCheckL||manCheckS;if(check){temp=check.toLowerCase();x=temp.indexOf("-");check=x>=0?temp.substring(0,x):"";check=check.toUpperCase()+temp.substring(x);isShort=!!manCheckS;if(rules.getRSIByRuleName(temp)>=0){o=rules.getRuleDescriptionEx(null,temp,isShort)}else{o=rules.getRuleDescriptionEx(check,null,isShort)}if(o&&o.descrip){_display(o)}else{msgCtx.error(`Unable to locate '${temp}' via the configuration file.`)}ret=true}return ret};function _processBuiltin(){var meta;_rDir=_path.join(__dirname,"../rules");_rpDir=_path.join(__dirname,"../rulepacks");if(!(meta=_loadRuleMetadata())){return true}return _isMsgId?_processMsgId(meta):_processRuleName(meta)};function _processMsgId(meta){var mjson=meta.mjson;var rname,r,x;for(r in mjson){if(_msgNum===mjson[r]){rname=r;break}}if(!rname){_error(`No rule found for message ID ${_prefix}-${_msgNum}.`);return true}x=rname.indexOf("_");if(x>=0){rname=rname.substring(0,x)}return _displayIt(rname,_prefix,meta)};function _processRuleName(meta){var rname,rjson,r;rname=_rawArg.toLowerCase();rjson=meta.rjson.rules;for(r in rjson){if(r===rname){return _displayIt(rname,_prefix,meta)}}_error(`Rule ${rname} is not a core rule`);return!rname.startsWith("oj-")};function _displayIt(rname,prefix,meta){var rule,r,mjson,rjson,prefix;mjson=meta.mjson;for(r in mjson){if(r.startsWith(rname)){_multiIDs.push(mjson[r])}}rjson=meta.rjson;for(r in rjson.rules){if(r===rname){_sev=rjson.rules[r].severity;break}}_sev=_sev||"unknown";if(rule=_loadRule(rname,meta)){let o={descrip:rule.getDescription(),rule:rname,prefix:prefix,sev:_sev,idList:_multiIDs};_display(o);return true}return false};function _loadRule(rname,meta){var rule,ruleJS,fp;try{fp=_nd.path.join(meta.rdir,rname+JS);ruleJS=_nd.ruleLoader(fp);if(ruleJS.prototype||!ruleJS.getName){try{rule=new ruleJS}catch(e){_error(`Failed to instantiate rule ${rname}`)}}else{rule=ruleJS}return rule}catch(e){_error(`Failed to load rule ${rname}`)}};function _loadRuleMetadata(){var meta,fp;fp=RP_PREFIX.includes(_prefix)?_nd.path.join(_rpDir,_prefix):_nd.path.join(_rDir,_prefix);meta=_loadRulesJson(fp);return meta};function _loadRulesJson(dir){var rjson,mjson,fp;fp=_nd.path.join(dir,RULES_JSON);if(_nd.fsUtils.fileExists(fp)){rjson=_nd.jsonLoader.load(fp,_nd,m=>{_error(m)},true,_nd.utils)}else{_error(`Internal error: rule manifest for ${_prefix} not found`);return false}fp=_nd.path.join(dir,MSGID_JSON);if(_nd.fsUtils.fileExists(fp)){mjson=_nd.jsonLoader.load(fp,_nd,m=>{_error(m)},true,_nd.utils)}else{if(!RP_PREFIX.includes(_prefix)){_error(`Internal error: rule message ID manifest for ${_prefix} not found`);return false}}if(rjson){return{rjson:rjson,mjson:mjson,rdir:dir}}};function _init(nd,msgCtx){_nd=nd;_error=msgCtx.error;_path=nd.path;_color=nd.colors;PREFIX=nd.builtinpacks.getPrefixes();RP_PREFIX=nd.builtinpacks.getRulepackFolderPrefixes()};function _initArg(arg){var x;_rawArg=arg;arg=arg.toLowerCase();x=arg.indexOf("-");if(x<0){if(!isNaN(parseInt(arg))){arg="jet-"+arg;x=3}else{_error("Expected a message ID or rulename to follow --help");return 0}}_prefix=arg.substring(0,x);_msgNum=arg.substring(x+1);x=parseInt(_msgNum);_isMsgId=!isNaN(x);if(_isMsgId){if(_msgNum.length<4){_msgNum="0".repeat(4-_msgNum.length)+_msgNum}}else{_msgNum=null;if(arg.startsWith("oj-")){_prefix="jet"}}if(PREFIX.includes(_prefix)){return 1}return-1};var first;function _display(o){var lines,line,s,s1,s2,s3;var list,temp,indent;var multiSev=o.idList.length>1;s=_color.BRIGHTGREEN("Rule: ");s1=_color.BRIGHTGREEN("Severity: ");s2=_color.BRIGHTGREEN("Message ID");s3=_color.BRIGHTYELLOW("\xB9");line="\n"+s+_color.BRIGHTYELLOW(o.rule)+" "+s1+_color.BRIGHTYELLOW(o.sev)+(multiSev?s3:EMPTY)+" "+s2+(multiSev?"'s":EMPTY)+": "+o.prefix+"-"+o.idList.join(", ");console.log(line);s=_removeMarkup(o.descrip);s=_removeColorMarkup(s);indent=0;lines=s.split("\n");for(let i=0;i<lines.length;i++){line=lines[i];if(line.charAt(0)==="\x12"){list=true;temp=line.indexOf("/",1);indent=parseInt(line.substring(1,temp));line=line.substring(temp+1).trim();first=true}_displayLine(line,list,indent);if(list){if(line.indexOf("\x13")>=0){list=false;indent=0}}}if(multiSev){s="\n"+s3+_color.BRIGHTYELLOW(" Possibility of more than 1 severity since there are "+o.idList.length+" message ID's");console.log(s)}console.log("")};function _displayLine(s,list,indent){var line,c,x;var start=0;var end=LINELEN;while(end<s.length){x=_NL(s,start,end);if(x>=0){line=s.substring(start,x).trim();if(list){if(line.indexOf("\x13")>=0){indent=0}}line=_fixup(line);console.log((list?" ".repeat((first?0:indent)+LIST_INDENT):"")+_color.CYAN(line));first=false;start=x+1;end=start+LINELEN;continue}c=s.charAt(end);if(RE_WS.test(c)){line=s.substring(start,end).trim();line=_fixup(line);console.log((list?" ".repeat((first?0:indent)+LIST_INDENT):"")+_color.CYAN(line));first=false;start=end;end+=LINELEN;continue}else{end--}}if(start<end){line=s.substring(start,end).trim();line=_fixup(line);console.log((list?" ".repeat((first?0:indent)+LIST_INDENT):"")+_color.CYAN(line));first=false}};function _removeMarkup(s){s=s.replace(/<oj\-/g,"@@01").replace(/<\/oj\-/g,"@@02").replace(/<br>/g,"@@03").replace(/<p>/g,"@@03@@03").replace(/<b>/g,"@@04").replace(/<em>/g,"@@04").replace(/<i>/g,"@@05").replace(/<\/b>/g,"@@06").replace(/<\/em>/g,"@@06").replace(/<\/i>/g,"@@06").replace(/<div/g,"@@7").replace(/<\/div>/g,"@@8").replace(/<template>/g,"@@9").replace(/<\/template>/g,"@@10").replace(/<ol/g,"@@11").replace(/<\/ol>/g,"@@12").replace(/<ul/g,"@@13").replace(/<\/ul>/g,"@@14").replace(/<li/g,"@@15").replace(/<\/li>/g,"@@16").replace(/&nbsp;/g,"\x11").replace(RE_MARKUP,EMPTY).replace(RE_MULTI_BLANKS," ").trimRight().replace(/@@01/g,"<oj-").replace(/@@02/g,"</oj-").replace(/@@03/g,"\n").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/@@9/g,"<template>").replace(/@@10/g,"</template>").replace(/@@7/g,"<div").replace(/@@8/g,"</div>").replace(/@@11/g,"<ol").replace(/@@12/g,"</ol>").replace(/@@13/g,"<ul").replace(/@@14/g,"</ul>").replace(/@@15/g,"<li").replace(/@@16/g,"</li>");if(!_nd.colors.isColor()){s=s.replace(/@@4/g,EMPTY).replace(/@@5/g,EMPTY).replace(/@@6/g,EMPTY)}return _handleLists(s)};function _removeColorMarkup(s){if(_nd.colors.isColor()){s=s.replace(/@@04/g,EMPTY).replace(/@@05/g,EMPTY).replace(/@@06/g,EMPTY)}return s.trim()};function _handleLists(s){var start,end,ordered,rep;while(true){ordered=false;if((start=s.indexOf("<ol>"))>=0){ordered=true}else{start=s.indexOf("<ul>")}if(start>=0){end=s.indexOf("</ol>",start);rep=_handleList(s,start,end,ordered);s=s.substring(0,start)+rep+s.substring(end+4)}else{break}}return s};function _handleList(s,start,end,ordered){var list,itemStart,itemEnd,count=0,sCount,rep="";list=s.substring(start+4,end).trim();itemEnd=0;while(true){if((itemStart=list.indexOf("<li>",itemEnd))>=0){itemEnd=list.indexOf("</li>",itemStart);sCount=(ordered?""+ ++count+")":"*")+" ";rep+="\n\n"+"\x12"+sCount.length+"/"+sCount+list.substring(itemStart+4,itemEnd).trimRight()+"\x13"}else{break}}return rep}function _fixup(s){return s.replace(/\x11/g," ")};function _NL(s,start,end){while(start<end){if(s.charAt(start)==="\n"){return start}start++}return-1};module.exports={showBuiltinMsgHelp,showExternalMsgHelp};
6
+ var PREFIX;var RP_PREFIX;const RULES_JSON="rules.json";const MSGID_JSON="msgid.json";const JS=".js";const RE_WS=/^\s*$/;const RE_MARKUP=/<[^>]*>/g;const RE_MULTI_BLANKS=/\s{2,}/g;const EMPTY="";const LINELEN=100;const LIST_INDENT=2;var _path;var _rDir;var _rpDir;var _isMsgId;var _prefix;var _msgNum;var _rawArg;var _sev;var _multiIDs=[];function showBuiltinMsgHelp(nd,arg,wantManPage,appCtx){var rc;_init(nd,appCtx);rc=_initArg(arg,wantManPage,appCtx);return rc>0?_processBuiltin(nd,appCtx):rc===0};function showExternalMsgHelp(rules,manCheckL,manCheckS,nd,appCtx){var check,temp,isShort,o,x,ret=false;_init(nd,appCtx);check=manCheckL||manCheckS;if(check){temp=check.toLowerCase();x=temp.indexOf("-");check=x>=0?temp.substring(0,x):"";check=check.toUpperCase()+temp.substring(x);isShort=!!manCheckS;if(rules.getRSIByRuleName(temp)>=0){o=rules.getRuleDescriptionEx(null,temp,isShort)}else{o=rules.getRuleDescriptionEx(check,null,isShort)}if(o&&o.descrip){_display(o,appCtx.colors)}else{appCtx.error(`Unable to locate '${temp}' via the configuration file.`)}ret=true}return ret};function _processBuiltin(nd,appCtx){var meta;_rDir=_path.join(__dirname,"../rules");_rpDir=_path.join(__dirname,"../rulepacks");if(!(meta=_loadRuleMetadata(nd,appCtx))){return true}return _isMsgId?_processMsgId(meta,nd,appCtx):_processRuleName(meta,nd,appCtx)};function _processMsgId(meta,nd,appCtx){var mjson=meta.mjson;var rname,r,x;for(r in mjson){if(_msgNum===mjson[r]){rname=r;break}}if(!rname){appCtx.error(`No rule found for message ID ${_prefix}-${_msgNum}.`);return true}x=rname.indexOf("_");if(x>=0){rname=rname.substring(0,x)}return _displayIt(rname,_prefix,meta,nd,appCtx)};function _processRuleName(meta,nd,appCtx){var rname,rjson,r;rname=_rawArg.toLowerCase();rjson=meta.rjson.rules;for(r in rjson){if(r===rname){return _displayIt(rname,_prefix,meta,nd,appCtx)}}appCtx.error(`Rule ${rname} is not a known rule.`);return!rname.startsWith("oj-")};function _displayIt(rname,prefix,meta,nd,appCtx){var rule,r,mjson,rjson,prefix;mjson=meta.mjson;for(r in mjson){if(r.startsWith(rname)){_multiIDs.push(mjson[r])}}rjson=meta.rjson;for(r in rjson.rules){if(r===rname){_sev=rjson.rules[r].severity;break}}_sev=_sev||"unknown";if(rule=_loadRule(rname,meta,nd,appCtx)){let o={descrip:rule.getDescription(),rule:rname,prefix:prefix,sev:_sev,idList:_multiIDs};_display(o,appCtx.colors);return true}return false};function _loadRule(rname,meta,nd,appCtx){var rule,ruleJS,fp;try{fp=nd.path.join(meta.rdir,rname+JS);ruleJS=nd.ruleLoader(fp);if(ruleJS.prototype||!ruleJS.getName){try{rule=new ruleJS}catch(e){appCtx.error(`Failed to instantiate rule ${rname}`)}}else{rule=ruleJS}return rule}catch(e){appCtx.error(`Failed to load rule ${rname}`)}};function _loadRuleMetadata(nd,appCtx){var meta,fp;fp=RP_PREFIX.includes(_prefix)?nd.path.join(_rpDir,_prefix):nd.path.join(_rDir,_prefix);meta=_loadRulesJson(fp,nd,appCtx);return meta};function _loadRulesJson(dir,nd,appCtx){var rjson,mjson,fp;fp=nd.path.join(dir,RULES_JSON);if(appCtx.fsUtils.fileExists(fp)){rjson=nd.jsonLoader.load(fp,nd,m=>{appCtx.error(m)},true,appCtx.utils)}else{appCtx.error(`Internal error: rule manifest for ${_prefix} not found`);return false}fp=nd.path.join(dir,MSGID_JSON);if(appCtx.fsUtils.fileExists(fp)){mjson=nd.jsonLoader.load(fp,nd,m=>{appCtx.error(m)},true,appCtx.utils)}else{if(!RP_PREFIX.includes(_prefix)){appCtx.error(`Internal error: rule message ID manifest for ${_prefix} not found`);return false}}if(rjson){return{rjson:rjson,mjson:mjson,rdir:dir}}};function _init(nd){_path=nd.path;PREFIX=nd.builtinpacks.getPrefixes();RP_PREFIX=nd.builtinpacks.getRulepackFolderPrefixes()};function _initArg(arg,wantManPage,appCtx){var x,mp;_rawArg=arg;arg=arg.toLowerCase();if(mp=_isManPage(arg)){_displayManPage(mp.full,mp.short,appCtx.colors);return 0}if(wantManPage){appCtx.error(`manPage for command ${arg} not found`);return 0}x=arg.indexOf("-");if(x<0){if(!isNaN(parseInt(arg))){arg="jet-"+arg;x=3}else{appCtx.error("Expected a message ID or rulename or manpage to follow --help");return 0}}_prefix=arg.substring(0,x);_msgNum=arg.substring(x+1);x=parseInt(_msgNum);_isMsgId=!isNaN(x);if(_isMsgId){if(_msgNum.length<4){_msgNum="0".repeat(4-_msgNum.length)+_msgNum}}else{_msgNum=null;if(arg.startsWith("oj-")){_prefix="jet"}}if(PREFIX.includes(_prefix)){return 1}return-1};function _isManPage(manPage){var syn;switch(manPage){case"amdlist":case"amd":manPage="amdlist";syn="amd";break;case"base":case"b":manPage="base";syn="b";break;case"betalist":case"bl":manPage="betalist";syn="bl";break;case"config":case"c":manPage="config";syn="c";break;case"dac":syn="dac";break;case"debug":case"d":manPage="debug";syn="d";break;case"deflist":case"def":manPage="deflist";syn="def";break;case"dislist":case"dl":manPage="dislist";syn="dl";break;case"dryrun":case"dr":manPage="dryrun";syn="dr";break;case"extra":case"e":manPage="extra";syn="e";break;case"followlinks":case"fl":manPage="followlinks";syn="fl";break;case"format":case"t":manPage="format";syn="t";break;case"groups":case"g":manPage="groups";syn="g";break;case"grouplist":case"gl":manPage="grouplist";syn="gl";break;case"help":case"h":manPage="help";syn="h";break;case"init":case"i":manPage="init";syn="i";break;case"initrule":case"ir":manPage="initrule";syn="ir";break;case"jetlist":case"jl":manPage="jetlist";syn="jl";break;case"jetver":case"jv":manPage="jetver";syn="jv";break;case"loadorder":case"rlo":manPage="loadorder";syn="rlo";break;case"metahist":case"mh":manPage="metahist";syn="mh";break;case"msgid":case"id":manPage="msgid";syn="id";break;case"nslist":case"nsl":manPage="nslist";syn="nsl";break;case"nocolor":case"nc":manPage="nocolor";syn="nc";break;case"nofollowlinks":case"nfl":manPage="nofollowlinks";syn="nfl";break;case"noout":case"no":manPage="noout";syn="no";break;case"outpath":case"o":manPage="outPath";syn="o";break;case"profiles":case"prof":manPage="profiles";syn="prof";break;case"reg":syn="reg";break;case"retcode":case"rc":manPage="retcode";syn="rc";break;case"rules":case"r":manPage="rules";syn="r";break;case"rulesjson":case"rj":manPage="rulesjson";syn="rj";break;case"rulessonar":case"rs":manPage="rulessonar";syn="rs";break;case"severity":case"s":manPage="severity";syn="s";break;case"version":case"v":manPage="version";syn="v";break;case"xgrouplist":case"xgl":manPage="xgrouplist";syn="xgl";break;}return syn?{full:manPage,short:syn}:syn};var first;function _display(o,clr){var lines,line,s,s1,s2,s3;var liEnd,x;var list,temp,indent;var multiSev=o.idList.length>1;s=clr.BRIGHTGREEN("Rule: ");s1=clr.BRIGHTGREEN("Severity: ");s2=clr.BRIGHTGREEN("Message ID");s3=clr.BRIGHTYELLOW("\xB9");line="\n"+s+clr.BRIGHTYELLOW(o.rule)+" "+s1+clr.BRIGHTYELLOW(o.sev)+(multiSev?s3:EMPTY)+" "+s2+(multiSev?"'s":EMPTY)+": "+o.prefix+"-"+o.idList.join(", ");console.log(line);s=_removeMarkup(o.descrip,clr);s=_removeColorMarkup(s,clr);indent=0;lines=s.split("\n");for(let i=0;i<lines.length;i++){line=lines[i];if((x=line.indexOf("-"))>=3&&!isNaN(parseInt(line.charAt(x+1)))){line=clr.BRIGHTYELLOW(line)}if(line.charAt(0)==="\x12"){list=true;temp=line.indexOf("/",1);indent=parseInt(line.substring(1,temp));line=line.substring(temp+1).trim();first=true}liEnd=false;if(list&&(x=line.indexOf("\x13"))>=0){line=line.substring(0,x);liEnd=true}_displayLine(line,list,indent,clr);if(liEnd){list=false;indent=0}}if(multiSev){s="\n"+s3+clr.BRIGHTYELLOW(" Possibility of more than 1 severity since there are "+o.idList.length+" message ID's");console.log(s)}console.log("")};function _displayLine(s,list,indent,clr){var line,c,x;var start=0;var end=LINELEN;while(end<s.length){x=_NL(s,start,end);if(x>=0){line=s.substring(start,x).trim();if(list){if(line.indexOf("\x13")>=0){indent=0}}line=_fixup(line);console.log((list?" ".repeat((first?0:indent)+LIST_INDENT):"")+clr.CYAN(line));first=false;start=x+1;end=start+LINELEN;continue}c=s.charAt(end);if(RE_WS.test(c)){line=s.substring(start,end).trim();line=_fixup(line);console.log((list?" ".repeat((first?0:indent)+LIST_INDENT):"")+clr.CYAN(line));first=false;start=end;end+=LINELEN;continue}else{end--}}if(start<end){line=s.substring(start,end).trim();line=_fixup(line);console.log((list?" ".repeat((first?0:indent)+LIST_INDENT):"")+clr.CYAN(line));first=false}};function _removeMarkup(s,clr){s=s.replace(/<oj\-/g,"@@01").replace(/<\/oj\-/g,"@@02").replace(/<link>/g,"@@20").replace(/<script>/g,"@@21").replace(/<html>/g,"@@22").replace(/<\/link>/g,"@@30").replace(/<\/script>/g,"@@31").replace(/<\/html>/g,"@@32").replace(/<br>/g,"@@03").replace(/<p>/g,"@@03@@03").replace(/<b>/g,"@@04").replace(/<em>/g,"@@04").replace(/<i>/g,"@@05").replace(/<\/b>/g,"@@06").replace(/<\/em>/g,"@@06").replace(/<\/i>/g,"@@06").replace(/<div/g,"@@7").replace(/<\/div>/g,"@@8").replace(/<template>/g,"@@9").replace(/<\/template>/g,"@@10").replace(/<ol/g,"@@11").replace(/<\/ol>/g,"@@12").replace(/<ul/g,"@@13").replace(/<\/ul>/g,"@@14").replace(/<li/g,"@@15").replace(/<\/li>/g,"@@16").replace(/&nbsp;/g,"\x11").replace(RE_MARKUP,EMPTY).replace(RE_MULTI_BLANKS," ").trimRight().replace(/@@01/g,"<oj-").replace(/@@02/g,"</oj-").replace(/@@03/g,"\n").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/@@9/g,"<template>").replace(/@@10/g,"</template>").replace(/@@7/g,"<div").replace(/@@8/g,"</div>").replace(/@@11/g,"<ol").replace(/@@12/g,"</ol>").replace(/@@13/g,"<ul").replace(/@@14/g,"</ul>").replace(/@@15/g,"<li").replace(/@@16/g,"</li>").replace(/@@20/g,"<link>").replace(/@@21/g,"<script>").replace(/@@22/g,"<html>").replace(/@@30/g,"</link>").replace(/@@31/g,"</script>").replace(/@@32/g,"</html>");if(!clr.isColor()){s=s.replace(/@@4/g,EMPTY).replace(/@@5/g,EMPTY).replace(/@@6/g,EMPTY)}return _handleLists(s)};function _removeColorMarkup(s,clr){if(clr.isColor()){s=s.replace(/@@04/g,EMPTY).replace(/@@05/g,EMPTY).replace(/@@06/g,EMPTY)}return s.trim()};function _handleLists(s){var start,end,ordered,rep,x;x=0;while(true){ordered=false;if((start=s.indexOf("<ol>",x))>=0){ordered=true}else{start=s.indexOf("<ul>",x)}if(start>=0){end=ordered?s.indexOf("</ol>",start):s.indexOf("</ul>",start);if(end>=start){rep=_handleList(s,start,end,ordered);s=s.substring(0,start)+rep;x=s.length;s+=s.substring(end+4)}else{x=start+4}}else{break}}return s};function _handleList(s,start,end,ordered){var list,itemStart,itemEnd,count=0,sCount,rep="";list=s.substring(start+4,end).trim();itemEnd=0;while(true){if((itemStart=list.indexOf("<li>",itemEnd))>=0){itemEnd=list.indexOf("</li>",itemStart);sCount=(ordered?""+ ++count+")":"*")+" ";rep+="\n\n"+"\x12"+sCount.length+"/"+sCount+list.substring(itemStart+4,itemEnd).trimRight()+"\x13"}else{break}}return rep}function _displayManPage(manPage,syn,clr){let lib=require("./manpage");return lib.show(manPage,syn,clr)};function _fixup(s){return s.replace(/\x11/g," ")};function _NL(s,start,end){var ret=-1,x;if(start<end){if((x=s.indexOf("\n",start))>=0){if(x<end){ret=x}}}return ret};module.exports={showBuiltinMsgHelp,showExternalMsgHelp};
package/lib/metaLoader.js CHANGED
@@ -3,4 +3,4 @@
3
3
  * Licensed under The Universal Permissive License (UPL), Version 1.0
4
4
  * as shown at https://oss.oracle.com/licenses/upl/
5
5
  */
6
- function loadMeta(metaFile,nodeDeps){const fs=require("fs");var obj=null;try{if(nodeDeps.fsUtils.fileExists(metaFile)){var js=fs.readFileSync(metaFile,"utf8");js=js.replace("define","obj=");eval(js);obj=obj()}}catch(e){console.log(e)}return obj};module.exports.loadMeta=loadMeta;
6
+ function loadMeta(metaFile,nd,fsUtils){var obj=null;try{if(fsUtils.fileExists(metaFile)){var js=nd.fs.readFileSync(metaFile,"utf8");js=js.replace("define","obj=");eval(js);obj=obj()}}catch(e){console.log(e)}return obj};module.exports.loadMeta=loadMeta;
package/lib/metahist.js CHANGED
@@ -3,4 +3,4 @@
3
3
  * Licensed under The Universal Permissive License (UPL), Version 1.0
4
4
  * as shown at https://oss.oracle.com/licenses/upl/
5
5
  */
6
- const fs=require("fs");const path=require("path");const META_DIR=path.join(__dirname,"../meta");const META_FILE="jetauditmeta.js";function show(nd){var meta,delHist,renHist;meta=_getMetaData(nd);if(!meta){return}delHist=meta.delMeta;renHist=meta.renMeta;_showTagDeletes(delHist);_showRenames(renHist);_showDeletes(delHist)};function _showTagDeletes(delHist){var tags,tag;tags=delHist.tags;if(!tags){return}var line="-".repeat(36);console.log("\n"+line);console.log(" Deleted Web Components ");console.log(line+"\n");for(tag in tags){console.log(tag)}};function _showRenames(o){var line="-".repeat(35);console.log("\n"+line);console.log(" Renamed Classes ");console.log(line+"\n");var len=_longest(o);for(let n in o){console.log(`${_ljust(n,len)} -> ${o[n].to} (${o[n].since})`)}console.log("\n")};function _showDeletes(o){var clazzes,clazz,ce,line,len;if(o.classes){line="-".repeat(36);console.log("\n"+line);console.log(" Deleted Classes ");console.log(line+"\n");len=_longest(o.classes);clazzes=o.classes;for(clazz in clazzes){console.log(`${_ljust(clazz,len)} (${clazzes[clazz]})`)}}line="-".repeat(45);console.log("\n"+line);console.log(" Deleted Methods & Members ");console.log(line);len=_longest(o);for(clazz in o){let meths,mems,meth,mem;if(clazz==="classes"||clazz==="tags"){continue}ce=o[clazz];console.log("\n"+clazz);if(ce.methods){meths=ce.methods;len=_longest(meths)+2;for(meth in meths){console.log(` ${_ljust(meth+"()",len)} (${meths[meth]})`)}}if(ce.members){mems=ce.members;len=_longest(mems);for(mem in mems){console.log(` ${_ljust(mem,len)} (${mems[mem]})`)}}}console.log("\n")};function _ljust(s,n){var len=n-s.length>=0?n-s.length:0;return s+" ".repeat(len)}function _longest(o){var len=0;for(let n in o){if(n!=="classes"&&n!=="tags"){len=n.length>len?n.length:len}}return len};function _getMetaData(nd){var jetVers,metaVer,metaFile,meta;jetVers=_getVersionList(nd);if(!jetVers||!jetVers.length){return}metaVer=jetVers[jetVers.length-1];metaFile=path.join(META_DIR,metaVer,META_FILE);try{meta=nd.metaLoader.loadMeta(metaFile,nd)}catch(e){meta=null;this._error("Metadata '"+metaFile+"' not found!")}return meta};function _getVersionList(nd){var verList=[];var files,inFile,ftype,i;try{files=fs.readdirSync(META_DIR);for(i=0;i<files.length;i++){inFile=files[i];ftype=nd.fsUtils.getFileTypeSync(path.join(META_DIR,inFile));if(ftype==="d"){verList.push(inFile)}else if(ftype instanceof Error){throw ftype}}}catch(e){console.log(e.message)}if(verList&&verList.length){verList.sort(function(a,b){var va=a.split(".");var vb=b.split(".");va.forEach(function(v,i,a){a[i]=parseInt(v)});vb.forEach(function(v,i,a){a[i]=parseInt(v)});if(va[0]>vb[0]){return 1}if(va[0]<vb[0]){return-1}if(va[1]>vb[1]){return 1}if(va[1]<vb[1]){return-1}if(va[2]>vb[2]){return 1}if(va[2]<vb[2]){return-1}return 0})}return verList};module.exports.show=show;
6
+ const fs=require("fs");const path=require("path");const META_DIR=path.join(__dirname,"../meta");const META_FILE="jetauditmeta.js";function show(nd,fsUtils){var meta,delHist,renHist;meta=_getMetaData(nd,fsUtils);if(!meta){return}delHist=meta.delMeta;renHist=meta.renMeta;_showTagDeletes(delHist);_showRenames(renHist);_showDeletes(delHist)};function _showTagDeletes(delHist){var tags,tag;tags=delHist.tags;if(!tags){return}var line="-".repeat(36);console.log("\n"+line);console.log(" Deleted Web Components ");console.log(line+"\n");for(tag in tags){console.log(tag)}};function _showRenames(o){var line="-".repeat(35);console.log("\n"+line);console.log(" Renamed Classes ");console.log(line+"\n");var len=_longest(o);for(let n in o){console.log(`${_ljust(n,len)} -> ${o[n].to} (${o[n].since})`)}console.log("\n")};function _showDeletes(o){var clazzes,clazz,ce,line,len;if(o.classes){line="-".repeat(36);console.log("\n"+line);console.log(" Deleted Classes ");console.log(line+"\n");len=_longest(o.classes);clazzes=o.classes;for(clazz in clazzes){console.log(`${_ljust(clazz,len)} (${clazzes[clazz]})`)}}line="-".repeat(45);console.log("\n"+line);console.log(" Deleted Methods & Members ");console.log(line);len=_longest(o);for(clazz in o){let meths,mems,meth,mem;if(clazz==="classes"||clazz==="tags"){continue}ce=o[clazz];console.log("\n"+clazz);if(ce.methods){meths=ce.methods;len=_longest(meths)+2;for(meth in meths){console.log(` ${_ljust(meth+"()",len)} (${meths[meth]})`)}}if(ce.members){mems=ce.members;len=_longest(mems);for(mem in mems){console.log(` ${_ljust(mem,len)} (${mems[mem]})`)}}}console.log("\n")};function _ljust(s,n){var len=n-s.length>=0?n-s.length:0;return s+" ".repeat(len)}function _longest(o){var len=0;for(let n in o){if(n!=="classes"&&n!=="tags"){len=n.length>len?n.length:len}}return len};function _getMetaData(nd,fsUtils){var jetVers,metaVer,metaFile,meta;jetVers=_getVersionList(nd,fsUtils);if(!jetVers||!jetVers.length){return}metaVer=jetVers[jetVers.length-1];metaFile=path.join(META_DIR,metaVer,META_FILE);try{meta=nd.metaLoader.loadMeta(metaFile,nd,fsUtils)}catch(e){meta=null;this._error("Metadata '"+metaFile+"' not found!")}return meta};function _getVersionList(nd,fsUtils){var verList=[];var files,inFile,ftype,i;try{files=fs.readdirSync(META_DIR);for(i=0;i<files.length;i++){inFile=files[i];ftype=fsUtils.getFileTypeSync(path.join(META_DIR,inFile));if(ftype==="d"){verList.push(inFile)}else if(ftype instanceof Error){throw ftype}}}catch(e){console.log(e.message)}if(verList&&verList.length){verList.sort(function(a,b){var va=a.split(".");var vb=b.split(".");va.forEach(function(v,i,a){a[i]=parseInt(v)});vb.forEach(function(v,i,a){a[i]=parseInt(v)});if(va[0]>vb[0]){return 1}if(va[0]<vb[0]){return-1}if(va[1]>vb[1]){return 1}if(va[1]<vb[1]){return-1}if(va[2]>vb[2]){return 1}if(va[2]<vb[2]){return-1}return 0})}return verList};module.exports.show=show;
@@ -3,4 +3,4 @@
3
3
  * Licensed under The Universal Permissive License (UPL), Version 1.0
4
4
  * as shown at https://oss.oracle.com/licenses/upl/
5
5
  */
6
- module.exports=function(fp,nd,appCtx){var json,obj;if(nd.fsUtils.fileExists(fp)){json=nd.fs.readFileSync(fp,'utf8');obj=appCtx.utils.parseJson(json,true);if(obj.msg){appCtx.error(`Internal error: rule message ID manifest syntax error : ${obj.msg} line ${obj.line} col ${obj.col} - ${fp}`);return null}return obj.obj}appCtx.error(`Internal error: rule message ID manifest not found - '${fp}'`);return null};
6
+ module.exports=function(fp,nd,appCtx){var json,obj;if(appCtx.fsUtils.fileExists(fp)){json=nd.fs.readFileSync(fp,'utf8');obj=appCtx.utils.parseJson(json,true);if(obj.msg){appCtx.error(`Internal error: rule message ID manifest syntax error : ${obj.msg} line ${obj.line} col ${obj.col} - ${fp}`);return null}return obj.obj}appCtx.error(`Internal error: rule message ID manifest not found - '${fp}'`);return null};
package/lib/ns.js CHANGED
@@ -3,4 +3,4 @@
3
3
  * Licensed under The Universal Permissive License (UPL), Version 1.0
4
4
  * as shown at https://oss.oracle.com/licenses/upl/
5
5
  */
6
- const _ns=["oj-acx","oj-acx-assets","oj-adp","oj-approvals","oj-av","oj-bi","oj-bi-sac","oj-cegbu","oj-cegbu-scp","oj-cgbu","oj-cgm","oj-communities","oj-core","oj-cp","oj-cso","oj-cx","oj-cx-ap","oj-cx-cg","oj-cx-dcs","oj-cx-fsvc","oj-cx-hd","oj-cx-iss","oj-cx-km","oj-cx-km-agent","oj-cx-marketing","oj-cx-ma","oj-cx-mc","oj-cx-ol","oj-cx-svc","oj-cxi","oj-cxm","oj-dbt","oj-dcs","oj-doceng","oj-ee","oj-em","oj-epm","oj-fa","oj-faw","oj-fa-fin","oj-fnd","oj-fom","oj-fsgbu","oj-fsgbu-demo","oj-fwk","oj-gbu","oj-gbu-comp","oj-gcs","oj-hcm","oj-hed","oj-hsgbu","oj-hsp","oj-hsp-common","oj-hsp-cruise","oj-hsp-hdp","oj-hsp-ohip","oj-hsp-opera","oj-ia","oj-i18n","oj-idaas","oj-ips","oj-j4s","oj-jv","oj-lux","oj-lx","oj-mca","oj-mcps","oj-oa","oj-oac","oj-oal","oj-oal-ni","oj-oal-ux","oj-oax","oj-ob","oj-oc","oj-oce","oj-oda","oj-oda-chat","oj-odcs","oj-odcs-oit","oj-odps","oj-ofsc","oj-ohi","oj-oic","oj-oit","oj-ofs","oj-ol","oj-omc","oj-omnichannel","oj-opa","oj-opaas","oj-opac","oj-pa","oj-psc","oj-prmt","oj-psm","oj-ref","oj-rgbu","oj-rgbu-jraf","oj-scs","oj-sp","oj-spatial","oj-spectra","oj-svc","oj-ux","oj-vb","oj-vb-sample","oj-vbdt","oj","oj-cc","oj-dynamic","oj-ext","oj-sample","oj-sample-internal","ns","ns-ui","demo","my"];const _setNS=new Set(_ns);module.exports={has:function(k){return _setNS.has(k)},getKeys:function(){return[..._setNS]}};
6
+ const _ns=["oj-acx","oj-acx-assets","oj-adp","oj-approvals","oj-av","oj-bi","oj-bi-sac","oj-cegbu","oj-cegbu-scp","oj-cgbu","oj-cgm","oj-communities","oj-core","oj-cp","oj-cso","oj-csp","oj-cx","oj-cx-ap","oj-cx-cg","oj-cx-dcs","oj-cx-fsvc","oj-cx-hd","oj-cx-iss","oj-cx-km","oj-cx-km-agent","oj-cx-marketing","oj-cx-ma","oj-cx-mc","oj-cx-ol","oj-cx-svc","oj-cxi","oj-cxm","oj-dbt","oj-dcs","oj-doceng","oj-ee","oj-em","oj-epm","oj-fa","oj-faw","oj-fa-fin","oj-fnd","oj-fom","oj-fsgbu","oj-fsgbu-demo","oj-fwk","oj-gbu","oj-gbu-comp","oj-gcs","oj-hcm","oj-hed","oj-hsgbu","oj-hsp","oj-hsp-common","oj-hsp-cruise","oj-hsp-hdp","oj-hsp-ohip","oj-hsp-opera","oj-ia","oj-i18n","oj-idaas","oj-ips","oj-j4s","oj-jv","oj-lux","oj-lx","oj-mca","oj-mcps","oj-oa","oj-oac","oj-oal","oj-oal-ni","oj-oal-ux","oj-oax","oj-ob","oj-oc","oj-oce","oj-oda","oj-oda-chat","oj-odcs","oj-odcs-oit","oj-odps","oj-ofsc","oj-ohi","oj-oic","oj-oit","oj-ofs","oj-ol","oj-omc","oj-omnichannel","oj-opa","oj-opaas","oj-opac","oj-pa","oj-psc","oj-prmt","oj-psm","oj-ref","oj-rgbu","oj-rgbu-jraf","oj-rw","oj-scs","oj-sp","oj-spatial","oj-spectra","oj-svc","oj-ux","oj-vb","oj-vb-sample","oj-vbdt","oj","oj-c","oj-cc","oj-dynamic","oj-ext","oj-sample","oj-sample-internal","ns","ns-ui","demo","my"];const _setNS=new Set(_ns);module.exports={has:function(k){return _setNS.has(k)},getKeys:function(){return[..._setNS]}};
package/lib/outfile.js CHANGED
@@ -3,4 +3,4 @@
3
3
  * Licensed under The Universal Permissive License (UPL), Version 1.0
4
4
  * as shown at https://oss.oracle.com/licenses/upl/
5
5
  */
6
- function writeFileSyncJson(nodeDeps,filepath,obj,options){var indent=options&&options.indent?options.indent:3;nodeDeps.fs.writeFileSync(filepath,JSON.stringify(obj,null,indent))};function writeFileSyncText(nodeDeps,filepath,text){nodeDeps.fs.writeFileSync(filepath,text)};module.exports={writeFileSyncJson:writeFileSyncJson,writeFileSyncText:writeFileSyncText};
6
+ function writeFileSyncJson(nd,filepath,obj,options){var indent=options&&options.indent?options.indent:3;nd.fs.writeFileSync(filepath,JSON.stringify(obj,null,indent))};function writeFileSyncText(nd,filepath,text){nd.fs.writeFileSync(filepath,text)};module.exports={writeFileSyncJson:writeFileSyncJson,writeFileSyncText:writeFileSyncText};
@@ -0,0 +1,6 @@
1
+ /*
2
+ * Copyright (c) 2018, 2022, Oracle and/or its affiliates.
3
+ * Licensed under The Universal Permissive License (UPL), Version 1.0
4
+ * as shown at https://oss.oracle.com/licenses/upl/
5
+ */
6
+ const PROFILE_DIR="profiles";const JSON=".json";const NL="\n";var clr;var fsUtils;var utils;var profile;function show(nd,arg,appCtx){clr=appCtx.colors;utils=appCtx.utils;fsUtils=appCtx.fsUtils;_display(nd,arg)};function _display(nd,arg){var dir,content,title,obj;var dir=nd.path.join(__dirname,"../"+PROFILE_DIR);if(!fsUtils.fileExists(dir,true)){_error(1);return}if(arg){_displayProfile(nd,dir,arg);return}if(!(content=fsUtils.readDirSync(dir))){_error(2);return}if(!content.length){console.log("[Error]: no profiles found!");return}console.log(clr.BRIGHTYELLOW("\n--- JAF Profiles ---"));for(let i=0;i<content.length;i++){let prof=content[i];if(prof.isFile&&prof.name.endsWith(JSON)){obj=_readConfigProps(nd,dir,prof.name);console.log(clr.BRIGHTYELLOW("*")+" "+clr.BRIGHTGREEN(prof.name.replace(JSON,""))+(obj&&obj.extends?" (extends '"+obj.extends+"')":""));if(obj&&obj.title){title=utils.lineWrap(obj.title);title.forEach(line=>{console.log(" "+clr.BRIGHTCYAN(line))})}}}console.log("")};function _displayProfile(nd,dir,name){var fp,text;profile=name;fp=nd.path.join(dir,name+JSON);if(!fsUtils.fileExists(nd.path.join(fp))){_error(3,name);return}console.log(`\n${clr.BRIGHTYELLOW("--- Profile")} ${clr.BRIGHTGREEN(profile)} ${clr.BRIGHTYELLOW("---")}`);if(!(text=fsUtils.readFileSync(fp,_readError))){return}_displayFile(text)};function _displayFile(txt){var a=txt.split(NL);a.forEach(line=>{console.log(line.trimRight())})};function _readConfigProps(nd,dir,profile){var fp,cfg,title,ext;fp=nd.path.join(dir,profile);if(cfg=fsUtils.readJsonSync(fp,true)){title=cfg.title;if(ext=cfg.extends){ext=ext.profile}}return{title:title,extends:ext}};function _error(n,v1){var msg;if(n===1){msg="no profiles found"}else if(n===2){msg="error reading profiles"}else if(n===3){msg=`unknown profile '${v1}'`}console.log(`[Error]: ${msg}`)};function _readError(msg){console.log(`Cannot read profile '${profile}' : ${msg}`)};module.exports.show=show;
package/lib/rlolist.js ADDED
@@ -0,0 +1,6 @@
1
+ /*
2
+ * Copyright (c) 2018, 2022, Oracle and/or its affiliates.
3
+ * Licensed under The Universal Permissive License (UPL), Version 1.0
4
+ * as shown at https://oss.oracle.com/licenses/upl/
5
+ */
6
+ const REQUIRED="$required";function show(nd,arg,appCtx){var packs;if(packs=nd.builtinpacks.getPackMetadata(nd,appCtx)){let prefixes=nd.builtinpacks.getPrefixes();arg=arg?arg.toLowerCase():arg;for(let pack of prefixes){if(!arg||arg===pack)_display(packs[pack],appCtx.colors)}}};function _display(pack,clr){var rules,rule,opts,insrvc,enabled,i;var list=[],noload=[];console.log(`\n\n${clr.CYAN("---")} ${clr.CYAN("Pack")} ${clr.BRIGHTRED(`${pack.prefix}`)} ${clr.CYAN(" - Rules by Load Order ---")}`);rules=pack.rules;for(rule in rules){opts=rules[rule];insrvc=opts.hasOwnProperty("inservice")?opts.inservice:true;enabled=opts.hasOwnProperty("enabled")?opts.enabled:true;if(opts[REQUIRED]){if(insrvc&&enabled){list.push(rule)}else{noload.push(rule);noload.push(insrvc);noload.push(enabled)}}}for(rule in rules){if(!list.includes(rule)){opts=rules[rule];insrvc=opts.hasOwnProperty("inservice")?opts.inservice:true;enabled=opts.hasOwnProperty("enabled")?opts.enabled:true;if(insrvc&&enabled){list.push(rule)}else{noload.push(rule);noload.push(insrvc);noload.push(enabled)}}}if(!list.length){console.log(clr.BRIGHTYELLOW(`● No rules found.`));return}for(i=0;i<list.length;i++){let row;rule=list[i];row="["+(i+1)+"]";console.log(" "+clr.BRIGHTYELLOW(row)+_spacer(row,4)+" "+clr.BRIGHTGREEN(rule))}if(noload.length){let n,max=0;for(i=0;i<noload.length;i+=3){n=noload[i].length;max=n>max?n:max}console.log("\n"+"--- Not loaded : Out of service or disabled ---");for(i=0;i<noload.length;i++){let state;rule=noload[i++];insrvc=noload[i++];enabled=noload[i];state="("+(insrvc?"":clr.BRIGHTRED("out-of-service"))+(!insrvc&&!enabled?", ":"")+(enabled?"":"disabled")+")";console.log(" "+clr.BRIGHTRED(rule)+" "+_spacer(rule,max)+state)}}};function _spacer(s,len){return" ".repeat(len-s.length)};module.exports.show=show;
package/lib/scaffold.js CHANGED
@@ -3,4 +3,4 @@
3
3
  * Licensed under The Universal Permissive License (UPL), Version 1.0
4
4
  * as shown at https://oss.oracle.com/licenses/upl/
5
5
  */
6
- const DEFAULTS=require("./defaults");const OJET_CONFIG="oraclejetconfig.json";const OJAF_CONFIG="oraclejafconfig.json";const OJAF_DEFAULT_CONFIG="jafconfig.json";const DEPENDENCIES_VER_PROP="@oracle/oraclejet";const COMPOSITES_FOLDER="jet-composites";const EXTENSION_FOLDER="extension";const RESOURCES_FOLDER="resources";const JS_FOLDER="js";const TS_FOLDER="ts";const COMP_JSON="component.json";const PACKAGE_JSON="package.json";const TSCONFIG="tsconfig.json";const SUFFIX_HTML="/**/*.html";const SUFFIX_JS="/**/*.js";const SUFFIX_TS="/**/*.ts";const SUFFIX_CSS="/**/*.css";const SUFFIX_COMPJSON="/**/component.json";const SUFFIX_ALL="/**/*.*";const OJET_COMMENT="OJET Based Configuration";const NON_OJET_COMMENT="Default Configuration";const SLASHIFY=/\\\\|\\/g;var ojetCommon;var cwd,appCtx,nd,ojet,jetConfig,jafConfig,initDone;var md5;function init(cwdir,nodeDeps,appContext){if(!initDone){cwd=_fwdSlashify(cwdir);nd=nodeDeps;appCtx=appContext;ojet=isOJET();initDone=true}return ojet}function isOJET(){return initDone?!!jetConfig:nd.fsUtils.fileExists(nd.path.join(cwd,OJET_CONFIG))};function handleOjetConfig(isScaffold){var ojetPath,ojafPath,doUpdate=false,temp,hash,tsHash,tsc,defaultExists,error=false;ojetPath=nd.path.join(cwd,OJET_CONFIG);jetConfig=nd.jsonLoader.load(ojetPath,nd,errMsg=>{appCtx.error(errMsg);error=true},false,appCtx.utils);if(isScaffold){if(error){appCtx.error("Cannot continue with --init");return"error"}else if(jetConfig){appCtx.msg(`Scaffolding JAF configuration in ${_getFolderName()} ...`)}else{appCtx.error("OJET CLI config not found - cannot continue with --init");return"error"}}ojafPath=nd.path.join(cwd,OJAF_CONFIG);if(nd.fsUtils.fileExists(ojafPath)){jafConfig=_readJAFConfig(ojafPath);if(jafConfig==="error"){return"error"}}if(isScaffold){defaultExists=_defaultConfigExists();if(jafConfig||defaultExists){appCtx.error("Pre-existing configuration found - '"+(defaultExists?OJAF_DEFAULT_CONFIG:OJAF_CONFIG)+"'");return"error"}}if(!isScaffold&&!jetConfig&&jafConfig){appCtx.warn(`JAF Configuration '${OJAF_CONFIG}' found, but OJET configuration '${OJET_CONFIG}' no longer exists.\n`)}if(jetConfig.paths){if(jetConfig.paths.source&&jetConfig.paths.source.common){ojetCommon="./"+jetConfig.paths.source.common;ojetComposites=ojetCommon+"/"+jetConfig.paths.source.javascript+"/"+COMPOSITES_FOLDER;if(jetConfig.paths.source.typescript)ojetCompositesTs=ojetCommon+"/"+jetConfig.paths.source.typescript+"/"+COMPOSITES_FOLDER}}hash=_isOjetFileChange(ojetPath,jafConfig);if(jafConfig){if(hash){if(jafConfig.ojet&&jafConfig.ojet.update){if(appCtx.verboseMode||appCtx.debugMode){if(hash){appCtx.info(`${OJET_CONFIG} change detected - updating ${OJAF_CONFIG}`)}if(tsHash){if(typeof tsHash==="string"){appCtx.info(`${TSCONFIG} change detected - updating ${OJAF_CONFIG}`)}else{appCtx.info(`${TSCONFIG} no longer found - updating ${OJAF_CONFIG}`)}}}jafConfig.files=_getFileSet();jafConfig.exclude=_getExcludes();jafConfig.components=_getComposites();if(tsc=_getTsConfigPath()){if(jafConfig.typescript){jafConfig.typescript.tsconfig=tsc}else{jafConfig.typescript={tsconfig:tsc}}}else if(jafConfig.typescript&&jafConfig.typescript.tsconfig){delete jafConfig.typescript}if(jafConfig.tsconfig){delete jafConfig.tsconfig}temp=_getJetVer();if(jafConfig.jetVer!==temp){jafConfig.jetVer=temp}temp=_getTheme();if(jafConfig.theme!==temp){jafConfig.theme=temp}if(!jafConfig.ojet){jafConfig.ojet={}}if(hash){jafConfig.ojet.md5=hash}if(typeof jafConfig.ojet.update!=="boolean"){jafConfig.ojet.update=true}if(typeof tsHash==="string"){jafConfig.ojet.tsmd5=tsHash}else if(tsHash&&jafConfig.ojet.tsmd5){delete jafConfig.ojet.tsmd5}doUpdate=true;_backupJAFConfig(ojafPath)}else{const changeMsg=" changes detected, but oraclejafconfig updates are disabled";if(hash){appCtx.warn(OJET_CONFIG+changeMsg)}if(tsHash){appCtx.warn(TSCONFIG+changeMsg)}}}}else if(isScaffold){jafConfig={base:"$jafcwd",files:_getFileSet(),exclude:_getExcludes(),components:_getComposites(),builtinJetRules:true,jetVer:_getJetVer(),ecmaVer:DEFAULTS.ECMAVER,theme:_getTheme(),format:"prose",severity:"all",groups:["all"]};if(tsc=_getTsConfigPath()){jafConfig.typescript={tsconfig:tsc}}if(tsHash){jafConfig.ojet.tsmd5=tsHash}jafConfig.options={verbose:false,color:true};jafConfig.title=["+---------------------------------------------------------------------+","| OJET Application Audit |","+---------------------------------------------------------------------+","JAF $jafver - Jet $jetver : ($jafdate, $jaftime)\n"];jafConfig.ojet={update:true,md5:hash};doUpdate=true}if(doUpdate&&!_writeJAFConfig(OJAF_CONFIG,true)){appCtx.error("Failed to "+(isScaffold?"scaffold":"update")+" OJAF config '"+nd.path.join(cwd,OJAF_CONFIG)+"'");return"error"}if(isScaffold){scaffoldSuccessful(OJAF_CONFIG)}if(appCtx.debugMode){appCtx.debug("JAFConfig :\n"+JSON.stringify(jafConfig,null,3))}return jafConfig};function getOjetConfig(){return jetConfig}function _getFileSet(){var source,src,files=[];if(jetConfig&&jetConfig.paths){if(source=jetConfig.paths.source){if(src=source.common){files.push("./"+src+SUFFIX_HTML);if(source.javascript){files.push("./"+src+SUFFIX_JS)}if(source.typescript){files.push("./"+src+SUFFIX_TS)}files.push("./"+src+SUFFIX_COMPJSON)}if(source.styles){files.push("./"+src+"/"+source.styles+SUFFIX_CSS)}}}return _fwdSlashify(files)};function createNonOjetConfig(){var oj;oj=_ojetJafConfigExists();if(oj||_defaultConfigExists()){appCtx.error("Default configuration '"+(oj?OJAF_CONFIG:OJAF_DEFAULT_CONFIG)+"' exists - terminating --init");return"'error"}jafConfig=_createDefaultNonOjetConfig();_setFileProps(jafConfig);if(!_writeJAFConfig(OJAF_DEFAULT_CONFIG,false)){appCtx.error("Failed to scaffold OJAF config '"+OJAF_DEFAULT_CONFIG+"'");return"error"}scaffoldSuccessful(OJAF_DEFAULT_CONFIG)};function _getExcludes(){var files=[],source;if(jetConfig.paths&&jetConfig.paths.source){source=jetConfig.paths.source.common;files.push("./"+nd.path.join(source,"**"+"/"+"*-min.js"));files.push("./"+nd.path.join(source,"**"+"/"+"*-min.css"));files.push("./**/node_modules/**/*.*")}return _fwdSlashify(files)};function _getComposites(){var a=[],dir;dir="./jet-components/**/component.json";a.push(dir);return _fwdSlashify(a)};function _getTsConfigPath(){return _tsConfigExists()?".":null};function _getJetVer(){var i,ojetPackage,ver,error;ojetPackage=nd.jsonLoader.load(nd.path.join(cwd,PACKAGE_JSON),nd,function(errMsg){appCtx.error(errMsg);appCtx.warn("Defaulting to "+appCtx.defaultJetVer);error=true});if(!error&&ojetPackage&&ojetPackage.dependencies){ver=ojetPackage.dependencies[DEPENDENCIES_VER_PROP];if(ver){for(i=0;i<ver.length;i++){if(!isNaN(ver.charAt(i))){ver=ver.substring(i);break}}ver=ver.replace(".tgz","");i=ver.lastIndexOf(".");ver=ver.substring(0,i)}}return ver?ver:appCtx.defaultJetVer};function _getTheme(){var dt=jetConfig.defaultTheme;if(dt){dt=dt.charAt(0).toUpperCase()+dt.substring(1)}else{dt=DEFAULTS.THEME}return dt};function _getFolderName(){return nd.path.basename(cwd)};function _readJAFConfig(path){var error;var json=nd.jsonLoader.load(path,nd,function(errMsg){appCtx.error(errMsg);error=true},true,appCtx.utils);if(error){appCtx.error(`JSON syntax error -> '${path}`)}return error?"error":json};function _writeJAFConfig(name,isOjet){var data,ret=false;try{data=`// JAF Generated ${isOjet?OJET_COMMENT:NON_OJET_COMMENT}\n// Updated: ${new Date().toString()}\n\n${JSON.stringify(jafConfig,null,3)}`;nd.fs.writeFileSync(nd.path.join(cwd,name),data);ret=true}catch(e){appCtx.error(e)}return ret};function _backupJAFConfig(fp){var data,ret=false;try{data=_readFile(fp);if(data){nd.fs.writeFileSync(fp+".bak",data);ret=true}}catch(e){appCtx.error(e)}return ret};function _isOjetFileChange(ojPath,jafConfig){if(!md5){md5=require("md5")}var ojetMd5,ojafMd5;ojetMd5=md5(_readFile(ojPath));ojafMd5=jafConfig&&jafConfig.ojet&&jafConfig.ojet.md5;return ojetMd5!==ojafMd5?ojetMd5:false};function _readFile(fp){var data;try{data=nd.fs.readFileSync(fp,"utf8")}catch(e){}return data};function _fwdSlashify(path){if(Array.isArray(path)){for(var i=0;i<path.length;i++){path[i]=path[i].replace(SLASHIFY,"/")}return path}else if(path){return path.replace(SLASHIFY,"/")}};function _createDefaultNonOjetConfig(){var o={"base":"$jafcwd","files":[],"exclude":[],"components":["./jet-components/**/component.json"],"builtinJetRules":true,"jetVer":appCtx.defaultJetVer,"ecmaVer":DEFAULTS.ECMAVER,"theme":DEFAULTS.THEME,"groups":["all"],"format":"prose","severity":"all","options":{verbose:false,color:true},"title":["+---------------------------------------------------------------------+","| Application Audit |","+---------------------------------------------------------------------+","JAF $jafver - Jet $jetver : ($jafdate, $jaftime)\n"]};if(_tsConfigExists()){o.typescript={tsconfig:cwd}}return o};function _setFileProps(obj){var path,folder;folder="src";path=_getPathTo(folder);if(path){obj.files.push(path+"/**/*.html");obj.files.push(path+"/**/*.js");obj.files.push(path+"/**/*.ts");obj.files.push(path+"/**/*.css");obj.exclude.push(path+"/**/*-min.js");obj.exclude.push(path+"/**/*-min.css")}folder="jet-composites";path=_getPathTo(folder);if(path){obj.components=[path];obj.exclude.push(path+"/**/extension/**/*.*");obj.exclude.push(path+"/**/resources/**/*.*")}obj.exclude.push("./**/node_modules/**/*.*")};function _getPathTo(folder){var path=nd.fsUtils.findFile(cwd,folder,function(dir,file){return file!=="node_modules"&&!dir.includes("node_modules")});if(path){path=nd.path.join(path,folder);path=_fwdSlashify(path);path="."+path.replace(cwd,"")}else{path=null}return path};function _defaultConfigExists(){var file=nd.path.join(cwd,OJAF_DEFAULT_CONFIG);return nd.fsUtils.fileExists(file)};function _ojetJafConfigExists(){var file=nd.path.join(cwd,OJAF_CONFIG);return nd.fsUtils.fileExists(file)};function _tsConfigExists(){var file=nd.path.join(cwd,TSCONFIG);return nd.fsUtils.fileExists(file)};function scaffoldSuccessful(configName){appCtx.msg(" __ ___");appCtx.msg(" __ / /___ _/ _/ Configuration generation successful");appCtx.msg(" / // // _ `/ _/ created: '@@'".replace("@@",configName));appCtx.msg(" \\___/ \\_,_/_/\n")};module.exports={init,isOJET,handleOjetConfig,createNonOjetConfig,getOjetConfig};
6
+ const DEFAULTS=require("./defaults");const OJET_CONFIG="oraclejetconfig.json";const OJAF_CONFIG="oraclejafconfig.json";const OJAF_DEFAULT_CONFIG="jafconfig.json";const DEPENDENCIES_VER_PROP="@oracle/oraclejet";const PACKAGE_JSON="package.json";const TSCONFIG="tsconfig.json";const SUFFIX_HTML="/**/*.html";const SUFFIX_JS="/**/*.js";const SUFFIX_TS="/**/*.ts";const SUFFIX_CSS="/**/*.css";const SUFFIX_COMPJSON="/**/component.json";const OJET_COMMENT="OJET Based Configuration";const NON_OJET_COMMENT="Default Configuration";const SLASHIFY=/\\\\|\\/g;const STABLE="Stable";var Scaffold=function(cwd,nd,appCtx){this._cwd=_fwdSlashify(cwd);this._nd=nd;this._appCtx=appCtx;this._fsUtils=appCtx.fsUtils;this._ojet=null;this._jetConfig=null;this._jafConfig=null;this._ojetLib=null;this._md5=null};Scaffold.prototype.init=function(){if(!this._initDone){this._ojet=this.isOJET();if(!this._ojet&&this._ojetJafConfigExists()){this._appCtx.warn(`JAF Configuration '${OJAF_CONFIG}' found, but OJET configuration '${OJET_CONFIG}' no longer exists.\n`)}this._initDone=true}return this._ojet};Scaffold.prototype.isOJET=function(){return this._initDone?!!this._jetConfig:this._fsUtils.fileExists(this._nd.path.join(this._cwd,OJET_CONFIG))};Scaffold.prototype.handleOjetConfig=function(isScaffold){var ojetPath,ojafPath,doUpdate=false,temp,hash,tsHash,tsc,tsConfig,jafConfig,defaultExists,error=false;ojetPath=this._nd.path.join(this._cwd,OJET_CONFIG);this._jetConfig=this._nd.jsonLoader.load(ojetPath,this._nd,errMsg=>{this._appCtx.error(errMsg);error=true},false,this._appCtx.utils);if(isScaffold){if(error){this._appCtx.error("Cannot continue with --init");return"error"}else if(this._jetConfig){this._appCtx.msg(`Scaffolding JAF configuration in ${this._getFolderName()} ...`)}else{this._appCtx.error("OJET CLI config not found - cannot continue with --init");return"error"}}if(tsConfig=this._readTsConfig(ojetPath)){try{tsConfig=JSON.stringify(tsConfig)}catch(e){tsConfig=null}}this._ojetLib=this._appCtx.ojetLib=new this._nd.ojetUtils(this._jetConfig,tsConfig,this._cwd);ojafPath=this._nd.path.join(this._cwd,OJAF_CONFIG);if(this._fsUtils.fileExists(ojafPath)){this._jafConfig=this._readJAFConfig(ojafPath);if(this._jafConfig==="error"){return"error"}}if(isScaffold){defaultExists=this._defaultConfigExists();if(this._jafConfig||defaultExists){this._appCtx.warn(`Pre-existing configuration found '${defaultExists?OJAF_DEFAULT_CONFIG:OJAF_CONFIG}' : ojaf will not delete it.`);return"error"}}hash=this._isOjetFileChange(ojetPath);if(this._jafConfig){jafConfig=this._jafConfig;if(hash){if(jafConfig.ojet&&jafConfig.ojet.update){if(this._appCtx.verboseMode||this._appCtx.debugMode){if(hash){this._appCtx.info(`${OJET_CONFIG} change detected - updating ${OJAF_CONFIG}`)}if(tsHash){if(typeof tsHash==="string"){this._appCtx.info(`${TSCONFIG} change detected - updating ${OJAF_CONFIG}`)}else{this._appCtx.info(`${TSCONFIG} no longer found - updating ${OJAF_CONFIG}`)}}}jafConfig.files=this._getFileSet();jafConfig.exclude=this._getExcludes();jafConfig.components=this._getComposites();if(tsc=this._getTsConfigPath()){if(jafConfig.typescript){jafConfig.typescript.tsconfig=tsc}else{jafConfig.typescript={tsconfig:tsc}}}else if(jafConfig.typescript&&jafConfig.typescript.tsconfig){delete jafConfig.typescript}if(jafConfig.tsconfig){delete jafConfig.tsconfig}temp=this._getJetVer();if(jafConfig.jetVer!==temp){jafConfig.jetVer=temp}if(temp=this._getTheme()){if(jafConfig.theme!==temp){jafConfig.theme=temp}}else if(jafConfig.theme){delete jafConfig.theme}if(!jafConfig.ojet){jafConfig.ojet={}}if(hash){jafConfig.ojet.md5=hash}if(typeof jafConfig.ojet.update!=="boolean"){jafConfig.ojet.update=true}if(typeof tsHash==="string"){jafConfig.ojet.tsmd5=tsHash}else if(tsHash&&jafConfig.ojet.tsmd5){delete jafConfig.ojet.tsmd5}doUpdate=true;this._backupJAFConfig(ojafPath)}else{const changeMsg=" changes detected, but oraclejafconfig updates are disabled";if(hash){this._appCtx.warn(OJET_CONFIG+changeMsg)}if(tsHash){this._appCtx.warn(TSCONFIG+changeMsg)}}}}else if(isScaffold){jafConfig={};jafConfig.title=["+---------------------------------------------------------------------+","| OJET Application Audit |","+---------------------------------------------------------------------+","JAF $jafver - Jet $jetver : ($jafdate, $jaftime)\n"];jafConfig.base="$jafcwd";jafConfig.files=this._getFileSet(),jafConfig.exclude=this._getExcludes(),jafConfig.components=this._getComposites(),jafConfig.builtinJetRules=true,jafConfig.jetVer=this._getJetVer(),jafConfig.ecmaVer=DEFAULTS.ECMAVER,jafConfig.format="prose",jafConfig.severity="all",jafConfig.groups=["all"];if(temp=this._getTheme()){jafConfig.theme=temp}if(tsc=this._getTsConfigPath()){jafConfig.typescript={tsconfig:tsc}}if(tsHash){jafConfig.ojet.tsmd5=tsHash}jafConfig.options={verbose:false,color:true};jafConfig.ojet={update:true,md5:hash};this._jafConfig=jafConfig;doUpdate=true}if(doUpdate&&!this._writeJAFConfig(OJAF_CONFIG,true)){this.appCtx.error("Failed to "+(isScaffold?"scaffold":"update")+" OJAF config '"+this._nd.path.join(this._cwd,OJAF_CONFIG)+"'");return"error"}if(isScaffold){this._scaffoldSuccessful(OJAF_CONFIG)}if(this._appCtx.debugMode){this._appCtx.debug("JAFConfig :\n"+JSON.stringify(jafConfig,null,3))}return jafConfig};Scaffold.prototype.getOjetConfig=function(){return this._jetConfig};Scaffold.prototype.getOjetLib=function(){return this._ojetLib?this._ojetLib:new this._nd.ojetUtils(null,null,null)};Scaffold.prototype._getFileSet=function(){var source,src,files=[];if(this._jetConfig&&this._jetConfig.paths){if(source=this._jetConfig.paths.source){if(src=source.common){files.push("./"+src+SUFFIX_HTML);if(source.javascript){files.push("./"+src+SUFFIX_JS)}if(source.typescript){files.push("./"+src+SUFFIX_TS)}files.push("./"+src+SUFFIX_COMPJSON)}if(source.styles){files.push("./"+src+"/"+source.styles+SUFFIX_CSS)}}}return _fwdSlashify(files)};Scaffold.prototype.createNonOjetConfig=function(){var oj;oj=this._ojetJafConfigExists();if(oj||this._defaultConfigExists()){this._appCtx.error("Default configuration '"+(oj?OJAF_CONFIG:OJAF_DEFAULT_CONFIG)+"' exists - terminating --init");return"'error"}this._jafConfig=this._createDefaultNonOjetConfig();this._setFileProps(this._jafConfig);if(!this._writeJAFConfig(OJAF_DEFAULT_CONFIG,false)){this._appCtx.error("Failed to scaffold OJAF config '"+OJAF_DEFAULT_CONFIG+"'");return"error"}this._scaffoldSuccessful(OJAF_DEFAULT_CONFIG)};Scaffold.prototype._getExcludes=function(){var files=[],source;if(this._jetConfig.paths&&this._jetConfig.paths.source){source=this._jetConfig.paths.source.common;files.push("./"+this._nd.path.join(source,"**"+"/"+"*-min.js"));files.push("./"+this._nd.path.join(source,"**"+"/"+"*-min.css"));files.push("./**/node_modules/**/*.*")}return _fwdSlashify(files)};Scaffold.prototype._getComposites=function(){var a=[],dir;if(this._jetConfig.paths&&this._jetConfig.paths.exchangeComponents){dir="./exchange_components/**/component.json"}else{dir="./jet_components/**/component.json"}a.push(dir);if(dir=_getOjCPackComponentJson()){a.push(dir)}return _fwdSlashify(a)};function _getOjCPackComponentJson(){};Scaffold.prototype._getTsConfigPath=function(){return this._tsConfigExists()?".":null};Scaffold.prototype._getJetVer=function(){var i,ojetPackage,ver,error;var _self=this;ojetPackage=this._nd.jsonLoader.load(this._nd.path.join(this._cwd,PACKAGE_JSON),this._nd,function(errMsg){_self._appCtx.error(errMsg);_self._appCtx.warn("Defaulting to "+_self._appCtx.defaultJetVer);error=true});if(!error&&ojetPackage&&ojetPackage.dependencies){ver=ojetPackage.dependencies[DEPENDENCIES_VER_PROP];if(ver){for(i=0;i<ver.length;i++){if(!isNaN(ver.charAt(i))){ver=ver.substring(i);break}}ver=ver.replace(".tgz","");i=ver.lastIndexOf(".");ver=ver.substring(0,i)}}return ver?ver:this._appCtx.defaultJetVer};Scaffold.prototype._getTheme=function(){var dt=this._jetConfig.defaultTheme;if(dt){dt=dt.charAt(0).toUpperCase()+dt.substring(1).toLowerCase();if(dt===STABLE){dt="Redwood"}}return dt};Scaffold.prototype._getFolderName=function(){return this._nd.path.basename(this._cwd)};Scaffold.prototype._readJAFConfig=function(path){var error;var _self=this;var json=this._nd.jsonLoader.load(path,this._nd,function(errMsg){_self._appCtx.error(errMsg);error=true},true,this._appCtx.utils);if(error){this._appCtx.error(`JSON syntax error -> '${path}`)}return error?"error":json};Scaffold.prototype._writeJAFConfig=function(name,isOjet){var data,ret=false;try{data=`// JAF Generated ${isOjet?OJET_COMMENT:NON_OJET_COMMENT}\n// Updated: ${new Date().toString()}\n\n${JSON.stringify(this._jafConfig,null,3)}`;this._nd.fs.writeFileSync(this._nd.path.join(this._cwd,name),data);ret=true}catch(e){this._appCtx.error(e)}return ret};Scaffold.prototype._backupJAFConfig=function(fp){var data,ret=false;try{data=this._readFile(fp);if(data){this._nd.fs.writeFileSync(fp+".bak",data);ret=true}}catch(e){this._appCtx.error(e)}return ret};Scaffold.prototype._isOjetFileChange=function(ojPath){if(!this._md5){this._md5=require("md5")}var ojetMd5,ojafMd5;var jafConfig=this._jafConfig;ojetMd5=this._md5(this._readFile(ojPath));ojafMd5=jafConfig&&jafConfig.ojet&&jafConfig.ojet.md5;return ojetMd5!==ojafMd5?ojetMd5:false};Scaffold.prototype._readTsConfig=function(ojPath){var p,ret=false;p=this._nd.path.join(ojPath,TSCONFIG);if(this._fsUtils.fileExists(p)){ret=this._readFile(p)}return ret};Scaffold.prototype._readFile=function(fp){var data;try{data=this._nd.fs.readFileSync(fp,"utf8")}catch(e){}return typeof data==="string"?data:null};function _fwdSlashify(path){if(Array.isArray(path)){for(var i=0;i<path.length;i++){path[i]=path[i].replace(SLASHIFY,"/")}return path}else if(path){return path.replace(SLASHIFY,"/")}};Scaffold.prototype._createDefaultNonOjetConfig=function(){var o={"base":"$jafcwd","files":[],"exclude":[],"components":["./jet_components/**/component.json"],"builtinJetRules":true,"jetVer":this._appCtx.defaultJetVer,"ecmaVer":DEFAULTS.ECMAVER,"groups":["all"],"format":"prose","severity":"all","options":{verbose:false,color:true},"title":["+---------------------------------------------------------------------+","| Application Audit |","+---------------------------------------------------------------------+","JAF $jafver - Jet $jetver : ($jafdate, $jaftime)\n"]};if(this._tsConfigExists()){o.typescript={tsconfig:this._cwd}}return o};Scaffold.prototype._setFileProps=function(obj){var path,folder;folder="src";path=this._getPathTo(folder);if(path){obj.files.push(path+"/**/*.html");obj.files.push(path+"/**/*.js");obj.files.push(path+"/**/*.ts");obj.files.push(path+"/**/*.css");obj.exclude.push(path+"/**/*-min.js");obj.exclude.push(path+"/**/*-min.css")}folder="jet-composites";path=this._getPathTo(folder);if(path){obj.components=[path];obj.exclude.push(path+"/**/extension/**/*.*");obj.exclude.push(path+"/**/resources/**/*.*")}obj.exclude.push("./**/node_modules/**/*.*")};Scaffold.prototype._getPathTo=function(folder){var path=this._fsUtils.findFile(this._cwd,folder,function(dir,file){return file!=="node_modules"&&!dir.includes("node_modules")});if(path){path=this.nd.path.join(path,folder);path=_fwdSlashify(path);path="."+path.replace(this._cwd,"")}else{path=null}return path};Scaffold.prototype._defaultConfigExists=function(){var file=this._nd.path.join(this._cwd,OJAF_DEFAULT_CONFIG);return this._fsUtils.fileExists(file)};Scaffold.prototype._ojetJafConfigExists=function(){var file=this._nd.path.join(this._cwd,OJAF_CONFIG);return this._fsUtils.fileExists(file)};Scaffold.prototype._tsConfigExists=function(){var file=this._nd.path.join(this._cwd,TSCONFIG);return this._fsUtils.fileExists(file)};Scaffold.prototype._scaffoldSuccessful=function(configName){var msg=this._appCtx.msg;msg(" __ ___");msg(" __ / /___ _/ _/ Configuration generation successful");msg(" / // // _ `/ _/ created: '@@'".replace("@@",configName));msg(" \\___/ \\_,_/_/\n")};module.exports=Scaffold;
@@ -3,4 +3,4 @@
3
3
  * Licensed under The Universal Permissive License (UPL), Version 1.0
4
4
  * as shown at https://oss.oracle.com/licenses/upl/
5
5
  */
6
- const RULE=["/**"," * Copyright (c) 2018, 2022, Oracle and/or its affiliates."," * Licensed under The Universal Permissive License (UPL), Version 1.0"," * as shown at https://oss.oracle.com/licenses/upl/"," */","","/*--------------------------------------------------------------------------------*/","/* JAF Rule: '%r' */","/* Purpose : */","/*--------------------------------------------------------------------------------*/","","","const RULENAME = \"%s\";","const DESCRIPTION = \"long description/help - can include HTML markup\";","const SHORT_DESCRIPTION = \"short description\";","","class Rule {"," getName() {"," return RULENAME;"," }",""," getDescription() {"," return DESCRIPTION;"," }",""," getShortDescription() {"," return SHORT_DESCRIPTION;"," }",""," /**"," * Registration - declare listeners"," * @param {Object} regCtx the registration context"," */"," register( /*regCtx*/ ) {"," // register listener(s)"," // return { xxx : this._onXXX }"," }",""," /**"," *"," * @param {Object} ruleCtx the rule context"," */"," _onXXX(ruleCtx) {"," // implement rule listener(s)"," }","","}","","","","module.exports = Rule;"];const LOGO=[" __ ___"," __ / /___ _/ _/ Rule '"+"%r"+"'"," / // // _ `/ _/ Created successfully"," \\___/ \\_,_/_/\n"];const JS=".js";const PC_R="%r";const PC_S="%s";function genRule(dir,ruleName,nodeDeps){var np=nodeDeps.path;var fsUtils=nodeDeps.fsUtils;var ext=np.extname(ruleName);var rule,fp,text;if(ext===""){rule=ruleName}else if(ext.toLowerCase()!==JS){console.log("[error]: invalid rule file extension '"+ext+"'. Do not specify a file extension!");return true}else{rule=ruleName.substring(0,ruleName.length-3)}ruleName=rule+JS;fp=np.join(dir,ruleName);try{if(fsUtils.fileExists(fp)){console.log("[Warning]: Rule '"+ruleName+"' already exists. ojaf will not overwrite it!");return true}text=_updateText(text,rule);nodeDeps.fs.writeFileSync(fp,text);_logo(rule);return true}catch(e){console.log("[Error]: "+e)}return false};function _updateText(text,rule){var i;text=RULE.join("\n").replace(PC_S,rule);i=text.indexOf(PC_R);text=text.replace(PC_R," ");return _insertText(text,i,rule)};function _insertText(text,i,rule){return text.substring(0,i)+rule+"'"+text.substring(i+1+rule.length)};function _logo(rule){console.log(LOGO.join("\n").replace("%r",rule))}module.exports.genRule=genRule;
6
+ const RULE=["/**"," * Copyright (c) 2018, 2022, Oracle and/or its affiliates."," * Licensed under The Universal Permissive License (UPL), Version 1.0"," * as shown at https://oss.oracle.com/licenses/upl/"," */","","/*--------------------------------------------------------------------------------*/","/* JAF Rule: '%r' */","/* Purpose : */","/*--------------------------------------------------------------------------------*/","","","const RULENAME = \"%s\";","const DESCRIPTION = \"long description/help - can include HTML markup\";","const SHORT_DESCRIPTION = \"short description\";","","class Rule {"," getName() {"," return RULENAME;"," }",""," getDescription() {"," return DESCRIPTION;"," }",""," getShortDescription() {"," return SHORT_DESCRIPTION;"," }",""," /**"," * Registration - declare listeners"," * @param {Object} regCtx the registration context"," */"," register( /*regCtx*/ ) {"," // register listener(s)"," // return { xxx : this._onXXX }"," }",""," /**"," *"," * @param {Object} ruleCtx the rule context"," */"," _onXXX(ruleCtx) {"," // implement rule listener(s)"," }","","}","","","","module.exports = Rule;"];const LOGO=[" __ ___"," __ / /___ _/ _/ Rule '"+"%r"+"'"," / // // _ `/ _/ Created successfully"," \\___/ \\_,_/_/\n"];const JS=".js";const PC_R="%r";const PC_S="%s";function genRule(dir,ruleName,nd,fsUtils){var np=nd.path;var ext=np.extname(ruleName);var rule,fp,text;if(ext===""){rule=ruleName}else if(ext.toLowerCase()!==JS){console.log("[error]: invalid rule file extension '"+ext+"'. Do not specify a file extension!");return true}else{rule=ruleName.substring(0,ruleName.length-3)}ruleName=rule+JS;fp=np.join(dir,ruleName);try{if(fsUtils.fileExists(fp)){console.log("[Warning]: Rule '"+ruleName+"' already exists. ojaf will not overwrite it!");return true}text=_updateText(text,rule);nd.fs.writeFileSync(fp,text);_logo(rule);return true}catch(e){console.log("[Error]: "+e)}return false};function _updateText(text,rule){var i;text=RULE.join("\n").replace(PC_S,rule);i=text.indexOf(PC_R);text=text.replace(PC_R," ");return _insertText(text,i,rule)};function _insertText(text,i,rule){return text.substring(0,i)+rule+"'"+text.substring(i+1+rule.length)};function _logo(rule){console.log(LOGO.join("\n").replace("%r",rule))}module.exports.genRule=genRule;
package/lib/schema.js CHANGED
@@ -3,4 +3,4 @@
3
3
  * Licensed under The Universal Permissive License (UPL), Version 1.0
4
4
  * as shown at https://oss.oracle.com/licenses/upl/
5
5
  */
6
- var _validate;const EMPTY_INDEX="['']";function validateComponentJson(obj){var errors,error,s,i,ret=null;if(!_validate){_init()}if(!_validate(obj)){ret=[];errors=_validate.errors;for(i=0;i<errors.length;i++){error=errors[i];s=_cleanAjvMessages(error);if(!s.includes("(if)")){ret.push({msg:s,error:error})}}}return ret};function _cleanAjvMessages(error){var keyword,i;var prop,subProp,propType,propId,param,dataPath,msg,ret;keyword=error.keyword;switch(keyword){case"required":ret=error.message;break;case"enum":prop=error.dataPath;if(prop.charAt(0)==="."){prop=prop.substr(1)};ret="bad property '"+prop+"' value : "+error.message+" ["+error.params.allowedValues+"]";break;case"additionalProperties":if(error.params){ret=error.params["additionalProperty"];dataPath=error.dataPath||"";if(dataPath){if(dataPath.charAt(0)==="."){dataPath=dataPath.substring(1)}if(dataPath.endsWith(EMPTY_INDEX)){dataPath=dataPath.substring(0,dataPath.indexOf(EMPTY_INDEX))}dataPath=" in "+dataPath}ret=`unexpected additional property '${ret}'${dataPath}`}else{prop=error.dataPath;i=prop.indexOf("[");propType=prop.substring(0,i);prop=prop.substring(i);prop=_smartRemoveSquareBrackets(prop);i=prop.indexOf(".");propId=prop.substring(0,i);propId=propId.replace(/[\'\"]/g,"");param=prop.substring(i);i=param.indexOf("'");if(i>=0){param=param.substring(0,i)+"."+param.substring(i+1);param=param.replace(/[\'\"]/g,"")}propType=_getSchemaPropType(propType);ret=propType+" "+propId+" has unexpected additional sub-property '"+param+"'"}break;case"type":msg=error.dataPath;if(msg.charAt(0)==="."){msg=msg.substring(1)}ret=msg+" - "+error.message;break;case"not":msg=error.message;msg=msg.replace("should NOT be ","is not ");propType=error.dataPath.startsWith(".prop")?"property":error.dataPath.startsWith(".events")?"events":error.dataPath.startsWith(".name")?"name":"";prop=error.propertyName?error.propertyName:null;if(!propType){ret=(prop?" property '"+prop+"'":"")+" - "+msg}else{ret="property '"+propType+"'"+(prop?" '"+prop+"' ":" ")+"- "+msg}break;case"propertyNames":ret=error.message;break;case"pattern":prop=error.dataPath;if(prop.charAt(0)==="."){prop=prop.substring(1)}return"property '"+prop+"' failed a schema format pattern match";break;case"format":prop=error.dataPath;if(prop.charAt(0)==="."){prop=prop.substring(1)}return"property '"+prop+"' format - "+error.message;break;case"anyOf":prop=error.dataPath;return"property "+(prop.charAt(0)==="."?prop.substring(1):prop)+" - "+error.message;break;default:ret="unknown error ("+error.keyword+")";}return ret};function _getSchemaPropType(propType){if(propType.startsWith(".prop")){propType="property"}else if(propType.startsWith(".even")){propType="event"}else if(propType.startsWith(".meth")){propType="method"}else{propType="UNNKNOWN"}return propType};function _smartRemoveSquareBrackets(prop){var i,x=0,s;while(true){i=prop.indexOf("[",x);if(i>=0){s=prop.substring(i+1,i+2).trim();if(!/\d/.test(s)){prop=prop.replace("[","");prop=prop.replace("]","");x=i;continue}}break}return prop};function _init(){var schema=require("../schema/component-schema.json");var Ajv=require("ajv");var _ajv=new Ajv({allErrors:true});_validate=_ajv.compile(schema)};module.exports.validateComponentJson=validateComponentJson;
6
+ var _validate;const DOT=".";function validateComponentJson(obj){var errors,error,s,i,ret=null;if(!_validate){_init()}if(!_validate(obj)){ret=[];errors=_validate.errors;for(i=0;i<errors.length;i++){error=errors[i];s=_cleanAjvMessages(error);if(s&&!s.includes("(if)")){ret.push({msg:s,error:error})}}}return ret};function _cleanAjvMessages(error){var prop,propType,msg,ret;var instPath=_convertJsonPointer(error.instancePath);if(instPath===""){instPath="JSON top-level"};switch(error.keyword){case"required":ret=`${error.message} at ${instPath}`;break;case"enum":ret=`bad property '${instPath}' value : ${error.message}} [${error.params.allowedValues}]`;break;case"additionalProperties":if(error.params){ret=error.params["additionalProperty"];if(instPath){instPath=" in "+instPath}ret=`unexpected additional property '${ret}'${instPath}`}else{ret=`"unexpected additional property (unknown) at ${instPath}`}break;case"type":ret=`${instPath} - ${error.message}`;break;case"not":msg=error.message;msg=msg.replace("must NOT be valid","is not permitted");if(instPath){propType=instPath.startsWith("prop")?"property":instPath.startsWith("events")?"events":instPath.startsWith("name")?"name":""}prop=error.propertyName?error.propertyName:"";ret=propType+(propType.length?" ":"")+(prop?"'"+prop+"'":"")+" at '"+instPath+"' "+msg;break;case"propertyNames":ret=error.message+(error.params&&error.params.propertyName?" - '"+error.params.propertyName+"'":"")+" at '"+instPath+"'";break;case"pattern":return`property '${instPath}' failed a schema format pattern match`;break;case"format":return`property '${instPath}' format - ${error.message}`;break;case"anyOf":return`property ${instPath} - ${error.message}`;break;case"if":break;default:ret=`unknown error ('${error.keyword}', '${error.message}')`;}return ret};function _convertJsonPointer(ip){if(ip){if(ip.startsWith("/")){ip=ip.substring(1)}let elems=ip.split("/");for(let i=0;i<elems.length;i++){let elem=elems[i];if(elem!==DOT&&!isNaN(elem)){elems[i]="["+elem+"]"}}ip=elems.join(".");ip=ip.replace(/\.\[/g,"[")}return ip};function _init(){const schema=require("../schema/component-schema.json");const Ajv=require("ajv");const AjvFormats=require("ajv-formats");const _ajv=new Ajv({allErrors:true,strictTypes:false});AjvFormats(_ajv,{mode:"fast"});_validate=_ajv.compile(schema)};module.exports.validateComponentJson=validateComponentJson;