@oracle/oraclejet-audit 12.1.0 → 13.0.2

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 (112) hide show
  1. package/jaf-amd.js +2 -20
  2. package/jaf.js +1 -1
  3. package/jafapi.js +1 -1
  4. package/lib/AstJson.js +1 -1
  5. package/lib/AstMd.js +1 -1
  6. package/lib/Cli.js +6 -0
  7. package/lib/Color.js +6 -0
  8. package/lib/Comments.js +1 -1
  9. package/lib/ComponentSvcs.js +1 -1
  10. package/lib/Components.js +1 -1
  11. package/lib/Config.js +1 -1
  12. package/lib/ConfigLib.js +1 -1
  13. package/lib/CssUtils.js +1 -1
  14. package/lib/FileSet.js +1 -1
  15. package/lib/FsUtils.js +1 -1
  16. package/lib/Issue.js +1 -1
  17. package/lib/JafEvents.js +1 -1
  18. package/lib/JafLib.js +1 -1
  19. package/lib/Json.js +1 -1
  20. package/lib/JsonLoader.js +1 -1
  21. package/lib/Md.js +1 -1
  22. package/lib/MetaLib.js +1 -1
  23. package/lib/OjCPack.js +6 -0
  24. package/lib/OjetLib.js +6 -0
  25. package/lib/Registry.js +1 -1
  26. package/lib/RuleSet.js +1 -1
  27. package/lib/Rules.js +1 -1
  28. package/lib/Scope.js +1 -1
  29. package/lib/Utils.js +1 -1
  30. package/lib/ZipUtils.js +1 -1
  31. package/lib/amdlist.js +6 -0
  32. package/lib/api.js +1 -1
  33. package/lib/betalist.js +6 -0
  34. package/lib/builtinpacks.js +1 -1
  35. package/lib/checkage.js +6 -0
  36. package/lib/cliStats.js +1 -1
  37. package/lib/cmdline.js +1 -1
  38. package/lib/defaults.js +1 -1
  39. package/lib/deflist.js +1 -1
  40. package/lib/dislist.js +1 -1
  41. package/lib/exportRules.js +1 -1
  42. package/lib/extends.js +1 -1
  43. package/lib/grouplist.js +1 -1
  44. package/lib/groups.js +1 -1
  45. package/lib/help.js +1 -1
  46. package/lib/jetver.js +1 -1
  47. package/lib/manpage.js +6 -0
  48. package/lib/manual.js +1 -1
  49. package/lib/metaLoader.js +1 -1
  50. package/lib/metahist.js +1 -1
  51. package/lib/msgidLoader.js +1 -1
  52. package/lib/ns.js +1 -1
  53. package/lib/outfile.js +1 -1
  54. package/lib/proflist.js +6 -0
  55. package/lib/rlolist.js +6 -0
  56. package/lib/scaffold.js +1 -1
  57. package/lib/scaffoldRule.js +1 -1
  58. package/lib/schema.js +1 -1
  59. package/meta/13.0.0/jetauditmeta.js +9 -0
  60. package/meta/metaverlist.json +1 -1
  61. package/package.json +6 -4
  62. package/profiles/best-practice.json +146 -0
  63. package/profiles/redwood-strict.json +31 -0
  64. package/rulepacks/jetwc/jetwc-bootstrap.js +1 -1
  65. package/rulepacks/jetwc/jetwc-css-oj-complete.js +1 -1
  66. package/rulepacks/jetwc/jetwc-pack-children.js +1 -1
  67. package/rulepacks/jetwc/jetwc-schema.js +1 -1
  68. package/rulepacks/jetwc/jetwc-supproperty-propagation.js +6 -0
  69. package/rulepacks/jetwc/msgid.json +1 -1
  70. package/rulepacks/jetwc/rules.json +1 -1
  71. package/rulepacks/jetwc-lib/jetwcutils-componentFinder.js +1 -1
  72. package/rulepacks/jetwco/jetwco-bootstrap.js +1 -1
  73. package/rulepacks/jetwco/jetwco-component-api-controlled-changes.js +1 -1
  74. package/rulepacks/jetwco/rules.json +1 -1
  75. package/rules/jaf/jaf-sys-age.js +6 -0
  76. package/rules/jaf/msgid.json +1 -1
  77. package/rules/jaf/rules.json +1 -1
  78. package/rules/jet/helpers/extractStylesFromClass.js +1 -1
  79. package/rules/jet/helpers/has-slot-name.js +1 -1
  80. package/rules/jet/msgid.json +1 -1
  81. package/rules/jet/oj-acc-aria-ojselector-labelledby.js +6 -0
  82. package/rules/jet/oj-acc-aria-prop.js +1 -1
  83. package/rules/jet/oj-c-acc-avatar-aria-role.js +6 -0
  84. package/rules/jet/oj-cca-compjson-bp-jetver.js +1 -1
  85. package/rules/jet/oj-css-var-override.js +1 -1
  86. package/rules/jet/oj-html-alta-deprecated.js +1 -1
  87. package/rules/jet/oj-html-attr-2def.js +1 -1
  88. package/rules/jet/oj-html-attr-req.js +1 -1
  89. package/rules/jet/oj-html-cca-tagname.js +1 -1
  90. package/rules/jet/oj-html-cdn.js +1 -1
  91. package/rules/jet/oj-html-combo-converter.js +1 -1
  92. package/rules/jet/oj-html-file-pick-accept.js +1 -1
  93. package/rules/jet/oj-html-notag-style.js +1 -1
  94. package/rules/jet/oj-html-ojattr-deprecated.js +1 -1
  95. package/rules/jet/oj-html-ojattr-enum-deprecated.js +1 -1
  96. package/rules/jet/oj-html-ojattr-evt-syntax.js +1 -1
  97. package/rules/jet/oj-html-ojattr-value.js +1 -1
  98. package/rules/jet/oj-html-ojattr.js +1 -1
  99. package/rules/jet/oj-html-ojtag-datacmd.js +1 -1
  100. package/rules/jet/oj-html-ojtag-deprecated.js +1 -1
  101. package/rules/jet/oj-html-pageopts-type.js +6 -0
  102. package/rules/jet/oj-html-rating-gauge-size.js +6 -0
  103. package/rules/jet/oj-html-redwood-bp-endslot.js +6 -0
  104. package/rules/jet/oj-html-slot-deprecated.js +6 -0
  105. package/rules/jet/oj-html-slot-pref-content.js +1 -1
  106. package/rules/jet/oj-html-wctag-$props.js +1 -1
  107. package/rules/jet/oj-html-wctag-maintenance.js +6 -0
  108. package/rules/jet/rules.json +1 -1
  109. package/schema/component-schema.json +1 -1482
  110. package/src/JafCore.js +1 -1
  111. package/types/index.d.ts +42 -10
  112. package/lib/colors.js +0 -6
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.%"," ~--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,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-dyn","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 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;const STABLE="Stable";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`)}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}if(temp=_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;_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,format:"prose",severity:"all",groups:["all"]};if(temp=_getTheme()){jafConfig.theme=temp}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;if(jetConfig.paths&&jetConfig.paths.exchangeComponents){dir="./exchange_components/**/component.json"}else{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);if(dt===STABLE){dt="Redwood"}}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,"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;