@oracle/oraclejet-audit 14.1.5 → 15.0.1
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.
- package/corePackMigrator/cli.js +6 -0
- package/corePackMigrator/corePackMigrator.js +10 -0
- package/corePackMigrator/metadata/avatarMetadata.json +40 -0
- package/corePackMigrator/metadata/buttonMetadata.json +55 -0
- package/corePackMigrator/metadata/collapsibleMetadata.json +15 -0
- package/corePackMigrator/metadata/filePickerMetadata.json +8 -0
- package/corePackMigrator/metadata/inputNumberMetadata.json +56 -0
- package/corePackMigrator/metadata/inputPasswordMetadata.json +50 -0
- package/corePackMigrator/metadata/inputTextMetadata.json +62 -0
- package/corePackMigrator/metadata/legendItemMetadata.json +8 -0
- package/corePackMigrator/metadata/legendMetadata.json +18 -0
- package/corePackMigrator/metadata/legendSectionMetadata.json +8 -0
- package/corePackMigrator/metadata/listItemLayoutMetadata.json +15 -0
- package/corePackMigrator/metadata/listviewMetadata.json +8 -0
- package/corePackMigrator/metadata/messagesMetadata.json +35 -0
- package/corePackMigrator/metadata/progressBarMetadata.json +15 -0
- package/corePackMigrator/metadata/progressCircleMetadata.json +8 -0
- package/corePackMigrator/metadata/ratingGaugeMetadata.json +78 -0
- package/corePackMigrator/metadata/selectManyMetadata.json +39 -0
- package/corePackMigrator/metadata/selectSingleMetadata.json +39 -0
- package/corePackMigrator/metadata/statusMeterGaugeMetadata.json +99 -0
- package/corePackMigrator/metadata/textAreaMetadata.json +44 -0
- package/corePackMigrator/resource/astUtils.js +6 -0
- package/corePackMigrator/resource/componentMigrator.js +6 -0
- package/corePackMigrator/resource/fileScanner.js +6 -0
- package/corePackMigrator/resource/htmlUtils.js +6 -0
- package/corePackMigrator/resource/manifest.json +102 -0
- package/corePackMigrator/resource/migrationConfig.json +21 -0
- package/corePackMigrator/templates/componentMetaData.json +119 -0
- package/corePackMigrator/templates/migrationConfig.json +17 -0
- package/corePackMigrator/utilities/logging.js +6 -0
- package/jaf-amd.js +1 -1
- package/lib/AST_Ts.js +1 -1
- package/lib/Cli.js +1 -1
- package/lib/Components.js +1 -1
- package/lib/Config.js +1 -1
- package/lib/ConfigLib.js +1 -1
- package/lib/DomUtils.js +1 -1
- package/lib/FileIndex.js +1 -1
- package/lib/FileSet.js +1 -1
- package/lib/FsUtils.js +1 -1
- package/lib/HtmlUtils.js +1 -1
- package/lib/JsonLoader.js +1 -1
- package/lib/MetaLib.js +1 -1
- package/lib/NetUtils.js +1 -1
- package/lib/Parser.js +1 -1
- package/lib/RegTypes.js +1 -1
- package/lib/Registry.js +1 -1
- package/lib/Reporter.js +1 -1
- package/lib/RulePack.js +1 -1
- package/lib/RuleSet.js +1 -1
- package/lib/Rules.js +1 -1
- package/lib/Scope.js +1 -1
- package/lib/Ts.js +1 -1
- package/lib/TsxUtils.js +1 -1
- package/lib/TsxUtils2.js +6 -0
- package/lib/Utils.js +1 -1
- package/lib/ZipUtils.js +1 -1
- package/lib/checkage.js +1 -1
- package/lib/cmdline.js +1 -1
- package/lib/defaults.js +1 -1
- package/lib/exportRules.js +1 -1
- package/lib/filetypes.js +1 -1
- package/lib/groups.js +1 -1
- package/lib/help.js +1 -1
- package/lib/jetver.js +1 -1
- package/lib/jsx.js +1 -1
- package/lib/maint.js +6 -0
- package/lib/manpage.js +1 -1
- package/lib/manual.js +1 -1
- package/lib/migrator.js +6 -0
- package/lib/msgidLoader.js +1 -1
- package/lib/ns.js +1 -1
- package/lib/outfile.js +1 -1
- package/lib/schema.js +1 -1
- package/lib/scopewalker.js +1 -1
- package/libext/expparser.js +1 -1
- package/meta/14.0.0/jetauditmeta.js +1 -1
- package/meta/14.1.0/jetauditmeta.js +1 -1
- package/meta/15.0.0/jetauditmeta.js +9 -0
- package/meta/metaverlist.json +1 -1
- package/package.json +16 -8
- package/profiles/redwood-strict.json +2 -1
- package/rulepacks/csp/csp-html-script-unsafe-inline.js +1 -1
- package/rulepacks/csp/csp-html-unsafe-expr.js +1 -1
- package/rulepacks/csp/csp-js-script-unsafe-eval.js +1 -1
- package/rulepacks/csp/csp-js-style-unsafe-inline.js +1 -1
- package/rulepacks/csp/csp-json-unsafe-expr.js +6 -0
- package/rulepacks/csp/msgid.json +1 -1
- package/rulepacks/csp/rules.json +1 -1
- package/rulepacks/jetwc/jetwc-absolute-jetversion.js +1 -1
- package/rulepacks/jetwc/jetwc-aria-redefinition.js +1 -1
- package/rulepacks/jetwc/jetwc-bootstrap.js +1 -1
- package/rulepacks/jetwc/jetwc-compjson-bp-ar.js +1 -1
- package/rulepacks/jetwc/jetwc-compjson-bp-obj.js +1 -1
- package/rulepacks/jetwc/jetwc-component-dependencies.js +1 -1
- package/rulepacks/jetwc/jetwc-component-displayname.js +1 -1
- package/rulepacks/jetwc/jetwc-component-foldername.js +1 -1
- package/rulepacks/jetwc/jetwc-component-location.js +1 -1
- package/rulepacks/jetwc/jetwc-component-type.js +1 -1
- package/rulepacks/jetwc/jetwc-css-oj-complete.js +1 -1
- package/rulepacks/jetwc/jetwc-css-pack-load-path.js +6 -0
- package/rulepacks/jetwc/jetwc-css-scoping.js +1 -1
- package/rulepacks/jetwc/jetwc-data-property-prefix.js +1 -1
- package/rulepacks/jetwc/jetwc-deprecated-lifecycle.js +1 -1
- package/rulepacks/jetwc/jetwc-disabled-property.js +1 -1
- package/rulepacks/jetwc/jetwc-displayname.js +1 -1
- package/rulepacks/jetwc/jetwc-dynamic-slot-context.js +1 -1
- package/rulepacks/jetwc/jetwc-event-displayname.js +1 -1
- package/rulepacks/jetwc/jetwc-events.js +1 -1
- package/rulepacks/jetwc/jetwc-exchange-images.js +1 -1
- package/rulepacks/jetwc/jetwc-jet-version.js +1 -1
- package/rulepacks/jetwc/jetwc-loader-file.js +1 -1
- package/rulepacks/jetwc/jetwc-markdown-link.js +1 -1
- package/rulepacks/jetwc/jetwc-method-displayname.js +1 -1
- package/rulepacks/jetwc/jetwc-methods.js +1 -1
- package/rulepacks/jetwc/jetwc-namespace.js +1 -1
- package/rulepacks/jetwc/jetwc-nested-defaults.js +1 -1
- package/rulepacks/jetwc/jetwc-nls-languages.js +1 -1
- package/rulepacks/jetwc/jetwc-nls-root.js +1 -1
- package/rulepacks/jetwc/jetwc-oj-register.js +1 -1
- package/rulepacks/jetwc/jetwc-ojcss.js +1 -1
- package/rulepacks/jetwc/jetwc-pack-children.js +1 -1
- package/rulepacks/jetwc/jetwc-packable-components.js +1 -1
- package/rulepacks/jetwc/jetwc-prerelease-dependencies.js +1 -1
- package/rulepacks/jetwc/jetwc-prerelease-pattern.js +1 -1
- package/rulepacks/jetwc/jetwc-prerelease-version.js +1 -1
- package/rulepacks/jetwc/jetwc-property-changed.js +1 -1
- package/rulepacks/jetwc/jetwc-property-displayname.js +1 -1
- package/rulepacks/jetwc/jetwc-property-nesting.js +1 -1
- package/rulepacks/jetwc/jetwc-property-translatable.js +1 -1
- package/rulepacks/jetwc/jetwc-public-modules.js +1 -1
- package/rulepacks/jetwc/jetwc-reference-npm-path.js +6 -0
- package/rulepacks/jetwc/jetwc-register-css.js +1 -1
- package/rulepacks/jetwc/jetwc-register-with-promises.js +1 -1
- package/rulepacks/jetwc/jetwc-require-paths.js +1 -1
- package/rulepacks/jetwc/jetwc-required-subproperty.js +1 -1
- package/rulepacks/jetwc/jetwc-reserved-property.js +1 -1
- package/rulepacks/jetwc/jetwc-schema.js +1 -1
- package/rulepacks/jetwc/jetwc-semantic-version.js +1 -1
- package/rulepacks/jetwc/jetwc-slot-displayname.js +1 -1
- package/rulepacks/jetwc/jetwc-slots.js +1 -1
- package/rulepacks/jetwc/jetwc-standard-files.js +1 -1
- package/rulepacks/jetwc/jetwc-status-since.js +6 -0
- package/rulepacks/jetwc/jetwc-unused-events.js +1 -1
- package/rulepacks/jetwc/jetwc-unused-slots.js +1 -1
- package/rulepacks/jetwc/jetwc-vb-category.js +1 -1
- package/rulepacks/jetwc/jetwc-vb-icon.js +1 -1
- package/rulepacks/jetwc/jetwc-vcomponent-jetversion.js +1 -1
- package/rulepacks/jetwc/jetwc-vcomponent-loader.js +1 -1
- package/rulepacks/jetwc/jetwc-vcomponent-version.js +1 -1
- package/rulepacks/jetwc/jetwc-version-openrange.js +1 -1
- package/rulepacks/jetwc/jetwc-writeback-required.js +1 -1
- package/rulepacks/jetwc/msgid.json +1 -1
- package/rulepacks/jetwc/rules.json +1 -1
- package/rulepacks/jetwc-lib/jetwcutils-auditComponentCacheManager.js +1 -1
- package/rulepacks/jetwc-lib/jetwcutils-commonListenerImpls.js +1 -1
- package/rulepacks/jetwc-lib/jetwcutils-componentAuditUtils.js +1 -1
- package/rulepacks/jetwc-lib/jetwcutils-componentFinder.js +1 -1
- package/rulepacks/jetwc-lib/jetwcutils-preCompiler.js +1 -1
- package/rulepacks/jetwc-lib/jetwcutils-tsxUtils.js +1 -1
- package/rulepacks/jetwco/jetwco-bootstrap.js +1 -1
- package/rulepacks/jetwco/jetwco-cacc-componentType.js +1 -1
- package/rulepacks/jetwco/jetwco-cacc-dependencies.js +1 -1
- package/rulepacks/jetwco/jetwco-cacc-dynamicSlots.js +1 -1
- package/rulepacks/jetwco/jetwco-cacc-eventBubbles.js +1 -1
- package/rulepacks/jetwco/jetwco-cacc-eventCancelable.js +1 -1
- package/rulepacks/jetwco/jetwco-cacc-eventPayload.js +1 -1
- package/rulepacks/jetwco/jetwco-cacc-events.js +1 -1
- package/rulepacks/jetwco/jetwco-cacc-helpers.js +1 -1
- package/rulepacks/jetwco/jetwco-cacc-jetVer.js +1 -1
- package/rulepacks/jetwco/jetwco-cacc-methodParamTypes.js +1 -1
- package/rulepacks/jetwco/jetwco-cacc-methodParams.js +1 -1
- package/rulepacks/jetwco/jetwco-cacc-methodReturnType.js +1 -1
- package/rulepacks/jetwco/jetwco-cacc-methods.js +1 -1
- package/rulepacks/jetwco/jetwco-cacc-packBundle.js +1 -1
- package/rulepacks/jetwco/jetwco-cacc-packBundleContent.js +1 -1
- package/rulepacks/jetwco/jetwco-cacc-packContent.js +1 -1
- package/rulepacks/jetwco/jetwco-cacc-properties.js +1 -1
- package/rulepacks/jetwco/jetwco-cacc-propertyDefault.js +1 -1
- package/rulepacks/jetwco/jetwco-cacc-propertyEnumeration.js +1 -1
- package/rulepacks/jetwco/jetwco-cacc-propertyReadOnly.js +1 -1
- package/rulepacks/jetwco/jetwco-cacc-propertyRequired.js +1 -1
- package/rulepacks/jetwco/jetwco-cacc-propertyType.js +1 -1
- package/rulepacks/jetwco/jetwco-cacc-propertyWriteback.js +1 -1
- package/rulepacks/jetwco/jetwco-cacc-publicModules.js +1 -1
- package/rulepacks/jetwco/jetwco-cacc-slotDataVariable.js +1 -1
- package/rulepacks/jetwco/jetwco-cacc-slotDataVariableType.js +1 -1
- package/rulepacks/jetwco/jetwco-cacc-slots.js +1 -1
- package/rulepacks/jetwco/jetwco-cacc-styleClasses.js +1 -1
- package/rulepacks/jetwco/jetwco-cacc-styleVariables.js +1 -1
- package/rulepacks/jetwco/jetwco-cacc-typeMappingOverrides.js +6 -0
- package/rulepacks/jetwco/jetwco-compjson-ns-reg.js +1 -1
- package/rulepacks/jetwco/jetwco-component-api-baseline-changes.js +1 -1
- package/rulepacks/jetwco/jetwco-component-api-changes.js +1 -1
- package/rulepacks/jetwco/jetwco-component-api-controlled-changes.js +1 -1
- package/rulepacks/jetwco/jetwco-component-cdn.js +1 -1
- package/rulepacks/jetwco/jetwco-description-standards.js +1 -1
- package/rulepacks/jetwco/jetwco-displayname-standards.js +1 -1
- package/rulepacks/jetwco/jetwco-exchange-version-check.js +1 -1
- package/rulepacks/jetwco/jetwco-license-info.js +1 -1
- package/rulepacks/jetwco/jetwco-prerelease-cdn.js +1 -1
- package/rulepacks/jetwco/jetwco-thirdparty-ba.js +1 -1
- package/rulepacks/jetwco/msgid.json +1 -1
- package/rulepacks/jetwco/rules.json +1 -1
- package/rules/jaf/jaf-ts-noparser.js +6 -0
- package/rules/jaf/msgid.json +1 -1
- package/rules/jaf/rules.json +1 -1
- package/rules/jet/helpers/has-slot-name.js +1 -1
- package/rules/jet/helpers/style-selector.js +1 -1
- package/rules/jet/helpers/tsx/has-slot-name.js +6 -0
- package/rules/jet/msgid.json +1 -1
- package/rules/jet/oj-acc-aria-labelledby.js +1 -1
- package/rules/jet/oj-cca-compjson-bp-ar.js +1 -1
- package/rules/jet/oj-cca-compjson-bp-obj.js +1 -1
- package/rules/jet/oj-css-bp-dir-flow.js +1 -1
- package/rules/jet/oj-html-attr-$unique.js +1 -1
- package/rules/jet/oj-html-attr-expr-delims.js +6 -0
- package/rules/jet/oj-html-combo-converter.js +1 -1
- package/rules/jet/oj-html-file-pick-accept.js +1 -1
- package/rules/jet/oj-html-form-bindif.js +1 -1
- package/rules/jet/oj-html-input-isodate.js +1 -1
- package/rules/jet/oj-html-invalid-doctype.js +1 -1
- package/rules/jet/oj-html-msgs-cat-text.js +1 -1
- package/rules/jet/oj-html-ojattr-deprecated.js +1 -1
- package/rules/jet/oj-html-ojattr-enum-deprecated.js +1 -1
- package/rules/jet/oj-html-ojtag-deprecated.js +1 -1
- package/rules/jet/oj-html-ojtag-ns.js +1 -1
- package/rules/jet/oj-html-rating-gauge-track-resize.js +6 -0
- package/rules/jet/oj-html-self-close.js +1 -1
- package/rules/jet/oj-html-slot-deprecated.js +1 -1
- package/rules/jet/oj-html-slot-item-minmax.js +1 -1
- package/rules/jet/oj-html-slot-name.js +1 -1
- package/rules/jet/oj-html-slot-pref-content.js +1 -1
- package/rules/jet/oj-html-style.js +1 -1
- package/rules/jet/oj-html-stylesel.js +1 -1
- package/rules/jet/oj-html-tabbar-edge.js +6 -0
- package/rules/jet/oj-html-unsup-theme.js +1 -1
- package/rules/jet/oj-html-wctag-maintenance.js +1 -1
- package/rules/jet/oj-html-wctag-nested.js +1 -1
- package/rules/jet/oj-html-wctag-supersedes.js +6 -0
- package/rules/jet/oj-js-numconv-pattern.js +6 -0
- package/rules/jet/oj-ts-numconv-pattern.js +6 -0
- package/rules/jet/oj-tsx-5-tag-obs.js +1 -1
- package/rules/jet/oj-tsx-acc-avatar-aria-role.js +6 -0
- package/rules/jet/oj-tsx-acc-button-onclick.js +1 -1
- package/rules/jet/oj-tsx-aria-ojselector-labelledby.js +1 -1
- package/rules/jet/oj-tsx-aria-prop.js +1 -1
- package/rules/jet/oj-tsx-attr-req.js +1 -1
- package/rules/jet/oj-tsx-cca-tagname.js +1 -1
- package/rules/jet/oj-tsx-combo-converter.js +1 -1
- package/rules/jet/oj-tsx-databind-all.js +1 -1
- package/rules/jet/oj-tsx-dlg-title.js +1 -1
- package/rules/jet/oj-tsx-form-bindif.js +6 -0
- package/rules/jet/oj-tsx-form-noflex.js +6 -0
- package/rules/jet/oj-tsx-input-isodate.js +1 -1
- package/rules/jet/oj-tsx-ojattr-deprecated.js +6 -0
- package/rules/jet/oj-tsx-ojattr-enum-deprecated.js +6 -0
- package/rules/jet/oj-tsx-ojattr-value.js +1 -1
- package/rules/jet/oj-tsx-ojattr.js +1 -1
- package/rules/jet/oj-tsx-ojtag-deprecated.js +1 -1
- package/rules/jet/oj-tsx-ojtag-ns.js +6 -0
- package/rules/jet/oj-tsx-pageopts-type.js +1 -1
- package/rules/jet/oj-tsx-picker-attrs.js +1 -1
- package/rules/jet/oj-tsx-prop-inline-definition.js +1 -1
- package/rules/jet/oj-tsx-rating-gauge-size.js +1 -1
- package/rules/jet/oj-tsx-rating-gauge-track-resize.js +6 -0
- package/rules/jet/oj-tsx-slot-deprecated.js +6 -0
- package/rules/jet/oj-tsx-slot-pref-content.js +6 -0
- package/rules/jet/oj-tsx-tabbar-edge.js +6 -0
- package/rules/jet/oj-tsx-unsup-theme.js +1 -1
- package/rules/jet/oj-tsx-wctag-maintenance.js +1 -1
- package/rules/jet/oj-tsx-wctag-nested.js +1 -1
- package/rules/jet/rules.json +1 -1
- package/schema/component-schema.json +1 -1
- package/src/JafCore.js +1 -1
- package/types/index.d.ts +6 -4
- package/rules/jet/oj-html-cspexpr.js +0 -6
package/lib/defaults.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={JETVER:
|
|
6
|
+
const defaults={JETVER:"15.0.1".replace(/(\d*\.\d*)(\.\d*)+$/g,"$1")+".0",THEME:"Alta",ECMAVER:14};module.exports=defaults;
|
package/lib/exportRules.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 ELLIPSIS="...";const JAF_OPTS=["inservice","enabled","group","severity","filetype","status","theme","jetver","amd","runonce","$hook","$required","$internal","customOpts","issueTag"];var MAX_OPT_LEN=0;const INDENT=" ";const INDENT2=" ";const INDENT3=" ";const proseIndent=4;const optsIndent=10;const SPACER=" ".repeat(proseIndent);const SPACER2=" ".repeat(proseIndent+3);const SPACER3=" ".repeat(proseIndent+5);const SPACER4=" ".repeat(SPACER3.length+optsIndent);const NL="\n";var clr;var utils;var fsUtils;var out;var severity;var jsonRules;var haveProseRules=false;function getXml(){return out+"</rules>"};function getProse(){return out};function getJson(){return out};function ruleToXml(ruleName,rule,options,msgIds){var ruleName,val,opt,xml,id,i;xml=INDENT+"<rule>\n";xml+=INDENT2+"<key>"+ruleName+"</key>\n";xml+=INDENT2+"<name>"+_limitLength(_escapeChevrons(rule.getShortDescription()),utils)+"</name>\n";xml+=INDENT2+"<description>\n";xml+=INDENT3+"<![CDATA["+_escapeCData(rule.getDescription())+"]]>\n";xml+=INDENT2+"</description>\n";xml+=INDENT2+"<messages>\n";for(id of msgIds){xml+=INDENT3+"<msgid>"+id+"</msgid>\n"}xml+=INDENT2+"</messages>\n";for(opt in options){val=options[opt];if(opt==="severity"){xml+=INDENT2+"<severity>"+val.toUpperCase()+"</severity>\n"}else if(opt==="status"){val=val.toUpperCase();val=val==="PRODUCTION"?"READY":val;xml+=INDENT2+"<status>"+val+"</status>\n"}else if(opt==="group"){if(typeof val==="string"){xml+=INDENT2+"<tag>"+val+"</tag>\n"}else{for(i=0;i<val.length;i++){xml+=INDENT2+"<tag>"+val[i]+"</tag>\n"}}}}out+=xml+INDENT+"</rule>\n"};function setupRulesToXml(appCtx){utils=appCtx.utils;fsUtils=appCtx.fsUtils;clr=appCtx.colors;out="<rules>\n"};function setupRulesToProse(nd,severity,appCtx){utils=appCtx.utils;fsUtils=appCtx.fsUtils;clr=appCtx.colors;out=`\n------------ Rules Currently Active (rule severity: ${severity}) ---------------\n`;for(let opt of JAF_OPTS){MAX_OPT_LEN=opt.length>MAX_OPT_LEN?opt.length:MAX_OPT_LEN}};function setupRulesToJson(obj,sev,appCtx){out=obj||{};severity=sev;out.rulesets=[];utils=appCtx.utils;fsUtils=appCtx.fsUtils;clr=appCtx.colors};function packToProse(rules,path,rsi){if(!rules){out+=SPACER2+"* No enabled rules available for this severity."+NL+NL}else{out+="["+(rsi+1)+"] "+rules.title+NL;out+=SPACER+"version : "+rules.version+NL;out+=SPACER+"prefix : "+rules.prefix+NL;out+=SPACER+"path : "+path+NL}haveProseRules=false};function ruleToProse(ruleName,rule,opts,msgIds){var opts,opt,n,s,i;out+=!haveProseRules?SPACER+"Rules:"+NL:"";out+=SPACER2+clr.BRIGHTYELLOW("* "+ruleName+" :")+NL;out+=SPACER3+clr.BRIGHTCYAN("messages: ");out+=msgIds.join(", ")+NL;out+=SPACER3+clr.BRIGHTCYAN("options : ");n=0;for(opt in opts){if(_isJafOption(opt)){try{s=JSON.stringify(opts[opt])}catch(e){s=""}out+=(!n?"":SPACER4)+clr.BRIGHTGREEN(opt)+" : "+_optSpace(opt)+clr.BRIGHTCYAN(s)+NL}n++}for(opt in opts){if(!_isJafOption(opt)){try{s=JSON.stringify(opts[opt])}catch(e){s=""}out+=(!n?"":SPACER4)+clr.BRIGHTGREEN(opt)+" : "+_optSpace(opt)+clr.BRIGHTCYAN(s)+NL}}let lines=utils.lineWrap(rule.getShortDescription());out+=SPACER3+clr.BRIGHTCYAN("short")+" : "+clr.BRIGHTCYAN(lines[0])+NL;for(i=1;i<lines.length;i++){out+=SPACER4+clr.BRIGHTCYAN(lines[i])+NL}lines=utils.lineWrap(rule.getDescription());out+=SPACER3+clr.BRIGHTCYAN("long")+" : "+clr.BRIGHTWHITE(lines[0])+NL;for(i=1;i<lines.length;i++){out+=SPACER4+clr.BRIGHTWHITE(lines[i])+NL}out+=NL;haveProseRules=true};function getJson(){out.meta={"severity":severity};return out};function packToJson(rulePack){var ruleset;ruleset={};out.rulesets.push(ruleset);ruleset.title=rulePack.rulesJson.title;ruleset.path=rulePack.path;ruleset.prefix=rulePack.rulesJson.prefix;ruleset.version=rulePack.rulesJson.version;ruleset.rules=jsonRules={}};function ruleToJson(ruleName,rule,opts,msgIds,active){jsonRules[ruleName]=opts;if(active||rule){opts.messages=msgIds;opts.shortDescription=rule.getShortDescription();opts.description=rule.getDescription()}else{opts.shortDescription=opts.description=""}};function _isJafOption(opt){return JAF_OPTS.includes(opt)};function _optSpace(opt){var len=MAX_OPT_LEN-opt.length;return" ".repeat(len>=0?len:0)};function _limitLength(s,utils){if(s.length>200){for(let i=196;i>0;i--){if(utils.isWhitespace(s.charAt(i))){return s.substring(0,i+1)+ELLIPSIS}}s=ELLIPSIS}return s};function _escapeChevrons(s){let ret=s.replace(/\</g,"<");ret=ret.replace(/\>/g,">");return ret.replace(/ /g," ")};function _escapeCData(s){var i,bChange;while(true){bChange=false;i=s.indexOf("<oj-");if(i>=0){s=s.substr(0,i)+"<"+s.substr(i+1);bChange=true;i=s.indexOf(">",i+1);if(i>=0){s=s.substr(0,i)+">"+s.substr(i+1)}i=s.indexOf("</oj-",i);if(i>=0){s=s.substr(0,i)+"<"+s.substr(i+1);bChange=true;i=s.indexOf(">",i+1);if(i>=0){s=s.substr(0,i)+">"+s.substr(i+1)}}}i=s.indexOf("<!DOCTYPE");if(i>=0){s=s.substr(0,i)+"<"+s.substr(i+1);i=s.indexOf(">",i+1);if(i>=0){s=s.substr(0,i)+">"+s.substr(i+1);bChange=true}}if(!bChange){break}}return s.replace(/ /g," ")};module.exports={getXml:getXml,getProse:getProse,getJson:getJson,ruleToXml:ruleToXml,ruleToProse:ruleToProse,packToProse:packToProse,packToJson:packToJson,ruleToJson:ruleToJson,setupRulesToXml:setupRulesToXml,setupRulesToProse:setupRulesToProse,setupRulesToJson:setupRulesToJson};
|
|
6
|
+
const ELLIPSIS="...";const JAF_OPTS=["inservice","enabled","group","severity","filetype","status","theme","jetver","amd","runonce","$hook","$required","$internal","$sevLocked","customOpts","issueTag"];var MAX_OPT_LEN=0;const INDENT=" ";const INDENT2=" ";const INDENT3=" ";const proseIndent=4;const optsIndent=10;const SPACER=" ".repeat(proseIndent);const SPACER2=" ".repeat(proseIndent+3);const SPACER3=" ".repeat(proseIndent+5);const SPACER4=" ".repeat(SPACER3.length+optsIndent);const NL="\n";var clr;var utils;var fsUtils;var out;var severity;var jsonRules;var haveProseRules=false;function getXml(){return out+"</rules>"};function getProse(){return out};function getJson(){return out};function ruleToXml(ruleName,rule,options,msgIds){var ruleName,val,opt,xml,id,i;xml=INDENT+"<rule>\n";xml+=INDENT2+"<key>"+ruleName+"</key>\n";xml+=INDENT2+"<name>"+_limitLength(_escapeChevrons(rule.getShortDescription()),utils)+"</name>\n";xml+=INDENT2+"<description>\n";xml+=INDENT3+"<![CDATA["+_escapeCData(rule.getDescription())+"]]>\n";xml+=INDENT2+"</description>\n";xml+=INDENT2+"<messages>\n";for(id of msgIds){xml+=INDENT3+"<msgid>"+id+"</msgid>\n"}xml+=INDENT2+"</messages>\n";for(opt in options){val=options[opt];if(opt==="severity"){xml+=INDENT2+"<severity>"+val.toUpperCase()+"</severity>\n"}else if(opt==="status"){val=val.toUpperCase();val=val==="PRODUCTION"?"READY":val;xml+=INDENT2+"<status>"+val+"</status>\n"}else if(opt==="group"){if(typeof val==="string"){xml+=INDENT2+"<tag>"+val+"</tag>\n"}else{for(i=0;i<val.length;i++){xml+=INDENT2+"<tag>"+val[i]+"</tag>\n"}}}}out+=xml+INDENT+"</rule>\n"};function setupRulesToXml(appCtx){utils=appCtx.utils;fsUtils=appCtx.fsUtils;clr=appCtx.colors;out="<rules>\n"};function setupRulesToProse(nd,severity,appCtx){utils=appCtx.utils;fsUtils=appCtx.fsUtils;clr=appCtx.colors;out=`\n------------ Rules Currently Active (rule severity: ${severity}) ---------------\n`;for(let opt of JAF_OPTS){MAX_OPT_LEN=opt.length>MAX_OPT_LEN?opt.length:MAX_OPT_LEN}};function setupRulesToJson(obj,sev,appCtx){out=obj||{};severity=sev;out.rulesets=[];utils=appCtx.utils;fsUtils=appCtx.fsUtils;clr=appCtx.colors};function packToProse(rules,path,rsi){if(!rules){out+=SPACER2+"* No enabled rules available for this severity."+NL+NL}else{out+="["+(rsi+1)+"] "+rules.title+NL;out+=SPACER+"version : "+rules.version+NL;out+=SPACER+"prefix : "+rules.prefix+NL;out+=SPACER+"path : "+path+NL}haveProseRules=false};function ruleToProse(ruleName,rule,opts,msgIds){var opts,opt,n,s,i;out+=!haveProseRules?SPACER+"Rules:"+NL:"";out+=SPACER2+clr.BRIGHTYELLOW("* "+ruleName+" :")+NL;out+=SPACER3+clr.BRIGHTCYAN("messages: ");out+=msgIds.join(", ")+NL;out+=SPACER3+clr.BRIGHTCYAN("options : ");n=0;for(opt in opts){if(_isJafOption(opt)){try{s=JSON.stringify(opts[opt])}catch(e){s=""}out+=(!n?"":SPACER4)+clr.BRIGHTGREEN(opt)+" : "+_optSpace(opt)+clr.BRIGHTCYAN(s)+NL}n++}for(opt in opts){if(!_isJafOption(opt)){try{s=JSON.stringify(opts[opt])}catch(e){s=""}out+=(!n?"":SPACER4)+clr.BRIGHTGREEN(opt)+" : "+_optSpace(opt)+clr.BRIGHTCYAN(s)+NL}}let lines=utils.lineWrap(rule.getShortDescription());out+=SPACER3+clr.BRIGHTCYAN("short")+" : "+clr.BRIGHTCYAN(lines[0])+NL;for(i=1;i<lines.length;i++){out+=SPACER4+clr.BRIGHTCYAN(lines[i])+NL}lines=utils.lineWrap(rule.getDescription());out+=SPACER3+clr.BRIGHTCYAN("long")+" : "+clr.BRIGHTWHITE(lines[0])+NL;for(i=1;i<lines.length;i++){out+=SPACER4+clr.BRIGHTWHITE(lines[i])+NL}out+=NL;haveProseRules=true};function getJson(){out.meta={"severity":severity};return out};function packToJson(rulePack){var ruleset;ruleset={};out.rulesets.push(ruleset);ruleset.title=rulePack.rulesJson.title;ruleset.path=rulePack.path;ruleset.prefix=rulePack.rulesJson.prefix;ruleset.version=rulePack.rulesJson.version;ruleset.rules=jsonRules={}};function ruleToJson(ruleName,rule,opts,msgIds,active){jsonRules[ruleName]=opts;if(active||rule){opts.messages=msgIds;opts.shortDescription=rule.getShortDescription();opts.description=rule.getDescription()}else{opts.shortDescription=opts.description=""}};function _isJafOption(opt){return JAF_OPTS.includes(opt)};function _optSpace(opt){var len=MAX_OPT_LEN-opt.length;return" ".repeat(len>=0?len:0)};function _limitLength(s,utils){if(s.length>200){for(let i=196;i>0;i--){if(utils.isWhitespace(s.charAt(i))){return s.substring(0,i+1)+ELLIPSIS}}s=ELLIPSIS}return s};function _escapeChevrons(s){let ret=s.replace(/\</g,"<");ret=ret.replace(/\>/g,">");return ret.replace(/ /g," ")};function _escapeCData(s){var i,bChange;while(true){bChange=false;i=s.indexOf("<oj-");if(i>=0){s=s.substr(0,i)+"<"+s.substr(i+1);bChange=true;i=s.indexOf(">",i+1);if(i>=0){s=s.substr(0,i)+">"+s.substr(i+1)}i=s.indexOf("</oj-",i);if(i>=0){s=s.substr(0,i)+"<"+s.substr(i+1);bChange=true;i=s.indexOf(">",i+1);if(i>=0){s=s.substr(0,i)+">"+s.substr(i+1)}}}i=s.indexOf("<!DOCTYPE");if(i>=0){s=s.substr(0,i)+"<"+s.substr(i+1);i=s.indexOf(">",i+1);if(i>=0){s=s.substr(0,i)+">"+s.substr(i+1);bChange=true}}if(!bChange){break}}return s.replace(/ /g," ")};module.exports={getXml:getXml,getProse:getProse,getJson:getJson,ruleToXml:ruleToXml,ruleToProse:ruleToProse,packToProse:packToProse,packToJson:packToJson,ruleToJson:ruleToJson,setupRulesToXml:setupRulesToXml,setupRulesToProse:setupRulesToProse,setupRulesToJson:setupRulesToJson};
|
package/lib/filetypes.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 _FILETYPES={html:true,css:true,js:true,ts:true,tsx:true,json:true,md:true,zip:true};const _OBJ_FILETYPES={html:true,css:true,js:true,ts:true,tsx:true,json:true,md:true};const _ZIP_FILETYPES={html:true,css:true,js:true,ts:true,tsx:true,json:true,md:true};module.exports.HTML="html";module.exports.CSS="css";module.exports.JS="js";module.exports.TS="ts";module.exports.TSX="tsx";module.exports.JSON="json";module.exports.MD="md";module.exports.ZIP="zip";module.exports.isFileTypeSupported=ft=>{return _FILETYPES[ft]};module.exports.isFileTypeSupportedInObj=ft=>{return _OBJ_FILETYPES[ft]};module.exports.isFileTypeSupportedInZip=ft=>{return _ZIP_FILETYPES[ft]};module.exports.isFileTypeTsOrTsx=ft=>{return ft==="ts"||ft==="tsx"};
|
|
6
|
+
const _FILETYPES={html:true,css:true,js:true,ts:true,tsx:true,json:true,md:true,zip:true};const _OBJ_FILETYPES={html:true,css:true,js:true,ts:true,tsx:true,json:true,md:true};const _ZIP_FILETYPES={html:true,css:true,js:true,ts:true,tsx:true,json:true,md:true};module.exports.HTML="html";module.exports.CSS="css";module.exports.JS="js";module.exports.TS="ts";module.exports.TSX="tsx";module.exports.JSON="json";module.exports.MD="md";module.exports.ZIP="zip";module.exports.isFileTypeSupported=ft=>{return _FILETYPES[ft]};module.exports.isFileTypeSupportedInObj=ft=>{return _OBJ_FILETYPES[ft]};module.exports.isFileTypeSupportedInZip=ft=>{return _ZIP_FILETYPES[ft]};module.exports.isFileTypeTsOrTsx=ft=>{return ft==="ts"||ft==="tsx"};module.exports.addExperimentalFileTypeTsx=()=>{_FILETYPES.tsx=_OBJ_FILETYPES.tsx=_ZIP_FILETYPES.tsx=true};
|
package/lib/groups.js
CHANGED
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* Licensed under The Universal Permissive License (UPL), Version 1.0
|
|
4
4
|
* as shown at https://oss.oracle.com/licenses/upl/
|
|
5
5
|
*/
|
|
6
|
-
const _GROUPS={all:true,
|
|
6
|
+
const _GROUPS={all:true,"jet-html":true,"jet-css":true,"jet-js":true,"jet-ts":true,"jet-tsx":true,"jet-json":true,"jet-md":true,"jet-acc":true,"jet-aria":true,"jet-deprecated":true,"jet-deleted":true,"jet-override":true,"jet-cca":true,"jet-spoc":true,"jet-csp":true,"jet-demo":true,"jet-bp":true,"jet-redwood-bp":true,"jet-perf":true,html5:true};module.exports.isGroup=g=>{return _GROUPS[g]};
|
package/lib/help.js
CHANGED
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* Licensed under The Universal Permissive License (UPL), Version 1.0
|
|
4
4
|
* as shown at https://oss.oracle.com/licenses/upl/
|
|
5
5
|
*/
|
|
6
|
-
const FLAGS=["\n Command line: %ojaf [flags] [ files/directory space separated list]%\n","\n Audit related flags:\n"," ~--config~ or ^-c^ : %followed by filepath to configuration file. If omitted, 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.%"," ~--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.%"," ~--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'.%"," ~--extra~ or ^-e^ : %verbose - show extra details.%"," ~--debug~ or ^-d^ : %debug mode.%",""," ~--nocolor~ or ^-nc^ : %do not colorize output.%"," ~--nodebug~ or ^-nd^ : %cancel debug mode set in config.%"," ~--noextra~ or ^-ne^ : %cancel verbose mode set in config 'options' property. Synonym for --noverbose%"," ~--nofollowlinks~ or ^-nfl^ : %do not follow stylesheet/script links.%"," ~--noout~ or ^-no^ : %do not write to output file path.%"," ~--noverbose~ or ^-nv^ : %cancel verbose mode set in config 'options' property. Synonym for --noextra.%","","Introspection 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.. e.g. -h profiles%"," %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.%"," ~--deplist~ or ^-dpl^ : %show the JET built-in rules deprecated by default. May be followed by%"," %an optional pack prefix.%"," ~--amdlist~ or ^-amd^ : %show the JET built-in rules availability in AMD mode. May be 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)})};
|
|
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.%"," ~--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.%"," ~--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'.%"," ~--extra~ or ^-e^ : %verbose - show extra details.%"," ~--debug~ or ^-d^ : %debug mode.%",""," ~--nocolor~ or ^-nc^ : %do not colorize output.%"," ~--nodebug~ or ^-nd^ : %cancel debug mode set in config.%"," ~--noextra~ or ^-ne^ : %cancel verbose mode set in config 'options' property. Synonym for --noverbose%"," ~--nofollowlinks~ or ^-nfl^ : %do not follow stylesheet/script links.%"," ~--noout~ or ^-no^ : %do not write to output file path.%"," ~--noverbose~ or ^-nv^ : %cancel verbose mode set in config 'options' property. Synonym for --noextra.%","","Introspection 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.. e.g. -h profiles%"," %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.%"," ~--maintenance~ or ^-mnt^ : %show the components in 'maintenance' status.%"," ~--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.%"," ~--deplist~ or ^-dpl^ : %show the JET built-in rules deprecated by default. May be followed by%"," %an optional pack prefix.%"," ~--amdlist~ or ^-amd^ : %show the JET built-in rules availability in AMD mode. May be 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 JAF 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
|
-
var verList;var verData;function init(){if(!verData){try{verList=require("../meta/metaverlist.json");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}}catch(e){}}return!!verData};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"
|
|
6
|
+
var verList;var verData;function init(){if(!verData){try{verList=require("../meta/metaverlist.json");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}}catch(e){}}return!!verData};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/jsx.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 HtmlUtils=require("./HtmlUtils");const JSXELEMENT="JSXElement";var Jsx=function(metaLib){this._elemStack=[];this._parentStack=[];this._metaLib=metaLib};Jsx.prototype.genTsxRenderComponent=function(node,data){var tsxRC;this._data=data;switch(node.type){case"VariableDeclarator":tsxRC=this._onDecl(node);break;case"CallExpression":tsxRC=this._onCallExpr(node);break;case"ReturnStatement":tsxRC=this._onReturn(node);break;case"AssignmentExpression":tsxRC=this._onAssignExpr(node);break
|
|
6
|
+
const HtmlUtils=require("./HtmlUtils");const JSXELEMENT="JSXElement";var Jsx=function(metaLib,msgCtx){this._elemStack=[];this._parentStack=[];this._metaLib=metaLib;this._msgCtx=msgCtx};Jsx.prototype.genTsxRenderComponent=function(node,data){var tsxRC;this._data=data;try{switch(node.type){case"VariableDeclarator":tsxRC=this._onDecl(node);break;case"CallExpression":tsxRC=this._onCallExpr(node);break;case"ReturnStatement":tsxRC=this._onReturn(node);break;case"AssignmentExpression":tsxRC=this._onAssignExpr(node);break}}catch(e){this._msgCtx.error(`JAF TSXRC gen internal, file line=${node?.loc.start.line} : ${e}`)}return tsxRC};Jsx.prototype._toTsxRC=function(node,container){var first,tsxComp,curContainer,opelem,oName,props,childs;var isPreact,isJetTag,isWCTag;if(!container&&!first){container={type:"TsxRenderComponent",components:[],range:node.range,loc:node.loc};first=true;this._parentStack.length=this._elemStack.length=0}if(opelem=node.openingElement||node.openingFragment){if(oName=opelem.name){let compName;if(oName.type==="JSXIdentifier"){compName=oName.name}else if(oName.type==="JSXMemberExpression"){compName=oName.object.name+"."+oName.property.name}isPreact=!compName.includes("-")&&!HtmlUtils.isCommonElem(compName)&&compName.charAt(0).toUpperCase()===compName.charAt(0)||compName.includes(".");isJetTag=!isPreact&&this._metaLib.isJetTag(compName);isWCTag=!isPreact&&this._metaLib.isWCTag(compName);tsxComp={type:"TsxComponent",name:compName,elemStack:this._cloneElemStack(),ojNS:this._metaLib.isNamespaceTag(compName),isJetTag:isJetTag,isWCTag:isWCTag,isPreact:isPreact,loc:oName.loc,range:oName.range};this._elemStack.push(tsxComp);if(Array.isArray(container)){container.push(tsxComp)}else{container.components.push(tsxComp)}if((props=_propsToArray(opelem))&&props.length){let aProps,tsxProp;tsxComp.properties=aProps=[];props.forEach(prop=>{tsxProp={type:"TsxProperty",name:prop?.name?.name,node:prop};tsxProp.loc=prop.loc;tsxProp.range=prop.range;aProps.push(tsxProp)});this._genPropRawValues(aProps,tsxComp)}if(this._parentStack.length){tsxComp.parent=this._parentStack[this._parentStack.length-1]}this._parentStack.push(tsxComp);tsxComp.valueRaw=this._data.substring(node.range[0],node.range[1]);tsxComp.value=opelem}if(node.type!=="JSXFragment"){if(childs=node.children){childs.forEach(entry=>{if(entry.type===JSXELEMENT){if(!tsxComp.children){tsxComp.children=curContainer=[]}else{curContainer=tsxComp.children}this._toTsxRC(entry,curContainer)}})}this._elemStack.pop();this._parentStack.pop()}else{if(childs=node.children){childs.forEach(entry=>{if(entry.type===JSXELEMENT){this._toTsxRC(entry,container)}})}}}return first?container:tsxComp};Jsx.prototype._onDecl=function(node){var init,tsxRC;if(!((init=node.init)&&(node.init.openingElement||node.init.openingFragment))){return}tsxRC=this._toTsxRC(init);return tsxRC};Jsx.prototype._onCallExpr=function(node){var tsxRC,args,a;if(args=node.arguments){args.forEach(arg=>{if(arg.type===JSXELEMENT){if(tsxRC&&!a){a=[tsxRC]}tsxRC=this._toTsxRC(arg);if(a){a.push(tsxRC)}}})}return a?a:tsxRC;return tsxRC};Jsx.prototype._onReturn=function(node){var tsxRC,arg;if(arg=node.argument){if(arg.type===JSXELEMENT&&arg.openingElement||arg.type==="JSXFragment"){tsxRC=this._toTsxRC(arg)}}return tsxRC};Jsx.prototype._onAssignExpr=function(node){var tsxRC,right;if(right=node.right){if(right.type===JSXELEMENT&&right.openingElement){tsxRC=this._toTsxRC(right)}}return tsxRC};Jsx.prototype._cloneElemStack=function(){return[...this._elemStack]};Jsx.prototype._genPropRawValues=function(props,tsxComp){var node,val,self=this;props.forEach(prop=>{node=prop.node;if(val=node.value){prop.valueRaw=self._data.substring(val.range[0],val.range[1])}prop.parent=tsxComp})};function _propsToArray(node){var props,ret;if(props=node.attributes){ret=[];props.forEach(prop=>{ret.push(prop)})}return ret};module.exports=Jsx;
|
package/lib/maint.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2018, 2023, 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 MAINTENANCE="maintenance";const T_COMP="-- Component --";const T_COMP_L=T_COMP.length;const T_SINCE="-- Since --";const T_SINCE_L=T_SINCE.length;const T_SUPERSEDES="-- Superseded By --";const PAD=4;function show(metaLib,appCtx){var data;data=_jetLegacyComponents(metaLib);data=_UserAndCoreComponents(metaLib,data);_display(data,appCtx.colors);return true};function _jetLegacyComponents(metaLib){var comps,clazz,obj,deps,dep,hdr,since;var ret,list,maxTag=0;maxSince=0;comps=metaLib._json;for(clazz in comps){if(!metaLib._nonClasses.includes(clazz)){if(!clazz.startsWith("oj.")){continue}obj=comps[clazz];hdr=obj.header;if(deps=hdr?.ojdeprecated){for(i=0;i<deps.length;i++){dep=deps[i];if(dep.type===MAINTENANCE){if(!ret){list=[];ret={list:list}}tag=metaLib.getTagFromClass(clazz);since=dep.since?dep.since:"";rep=dep.value?"<"+dep.value.join(", <")+">":"";if(tag.length>maxTag){maxTag=tag.length}if(since.length>maxSince){maxSince=since.length}list.push({tag:tag,since:since,rep:rep})}}}}}if(ret){ret.maxTag=maxTag;ret.maxSince=maxSince}return ret};function _UserAndCoreComponents(metaLib,data){var list,tags,maxTag,maxSince,since,rep;if(!(tags=metaLib.getNonLegacyMaintenanceTags())){return data}if(data){list=data.list;maxTag=data.maxTag;maxSince=data.maxSince}else{list=[];data={list:list};maxTag=0;maxSince=0}tags.forEach(tag=>{let obj={};o=metaLib.getTagMaintenanceStatus(tag);since=o.since?o.since:"";rep=o.value?"<"+o.value.join(", <")+">":"";list.push({tag:tag,since:since,rep:rep});if(tag.length>maxTag){maxTag=tag.length}if(since.length>maxSince){maxSince=since.length}});data.maxTag=maxTag;data.maxSince=maxSince;return data};function _display(data,clr){if(!data){console.log("No components in 'maintenance' mode.");return}const{list,maxTag,maxSince}=data;const colTag=Math.max(T_COMP_L,maxTag)+PAD;const colSince=Math.max(T_SINCE_L,maxSince)+PAD;console.log(clr.BOLDGREEN(_left(T_COMP,colTag)+_left(T_SINCE,colSince)+T_SUPERSEDES));for(o of list){console.log(clr.BOLDRED(_left(o.tag,colTag))+_left(" "+o.since,colSince)+clr.BOLDYELLOW(o.rep))}};function _left(s,n){var len=n-s.length>=0?n-s.length:0;return s+" ".repeat(len)};function _center(s,n){if(s.length>=n){return s}var lenL=n-s.length;lenL=lenL>0?Math.floor(lenL/=2):0;return" ".repeat(lenL)+s+" ".repeat(n-lenL-s.length)}module.exports.showMaintenance=show;
|
package/lib/manpage.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 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."]},"deplist":{synopsis:["--deplist","--deplist <pack prefix>"],description:["Displays the JET built-in rules deprecated by default."],options:["<pack prefix> \u25CF Displays the rules deprecated by default for the specified built-in JET pack prefix"," e.g. --deplist jet, or --deplist jetwco"," Note: the pack prefix may be of any case. If the pack prefix is omitted, the deprecated"," 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 -"]},"nodebug":{synopsis:["--nodebug"],description:["Disables debug mode set in the configuration 'options' property."],options:[" - None -"]},"noextra":{synopsis:["--noextra"],description:["Disables verbose mode set in the configuration 'options' property. This is a synonym for --noverbose."],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 -"]},"noverbose":{synopsis:["--noverbose"],description:["Disables verbose mode set in the configuration 'options' property. This is a synonym for --noextra"],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/extendable 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;
|
|
6
|
+
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.","","-amd","-amd <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>","-b <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.","","* Note that the filepath may be specified with forward slashes even on the Windows platform."]},"betalist":{synopsis:["--betalist","--betalist <pack prefix>","","-bl","-bl <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>","","-c <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 on the Windows platform, to avoid"," escaping the backslashes."]},"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","-d"],description:["Enables debug mode (very verbose). Useful for diagnosing problems."],options:[" - None -"]},"deflist":{synopsis:["--deflist","-def"],description:["Displays the configuration default property values."],options:[" - None -"]},"dislist":{synopsis:["--dislist","--dislist <pack prefix>","","-dl","-dl <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."]},"deplist":{synopsis:["--deplist","--deplist <pack prefix>","","-dpl","-dpl <pack prefix>"],description:["Displays the JET built-in rules deprecated by default."],options:["<pack prefix> \u25CF Displays the rules deprecated by default for the specified built-in JET pack prefix"," e.g. --deplist jet, or --deplist jetwco"," Note: the pack prefix may be of any case. If the pack prefix is omitted, the deprecated"," default rules are displayed for all JET built-in rulepacks."]},"dryrun":{synopsis:["--dryrun","-dr"],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","-e"],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","-fl"],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>","","-gl","-gl <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>, < . . .\"","","-g \"<groupname\" [, \"<groupname>\" [, \"<groupname>\" . . .] ]","-g=\"<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","","-h","--h <message-id> Display a rule message ID help","--h <rule-name> Display help for a rule","--h <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 name,","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","-i"],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>","","-ir <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","-jl"],description:["Displays the JET versions supported by the version of ojaf being used."],options:[" - None -"]},"jetver":{synopsis:["--jetver <semver>","","-jv <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, e.g. major[.minor[.patch]]."," Two formats are supported: as two consecutive arguments, or as a single argument using '='"," e.g. --jetver 12"," --jetver 12.1"," --jetver 12.0.0\n"," --jetver=12"," --jetver=12.1"," --jetver=12.0.0\n"," -jv 12"," -jv 12.1"," -jv 12.0.0\n"," -jv=12"," -jv=12.1"," -jv=12.0.0\n"," When a partial semver is supplied, ojaf will match it to the highest JET version that it"," supports. Generally speaking, only the major or major.minor values are required."," The list of the supported JET versions supported by the current ojaf version can be displayed"," by using ojaf -jl"]},"loadorder":{synopsis:["--loadorder","--loadorder <pack prefix>","","-rlo","-rlo <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"]},"maintenance":{synopsis:["--maintenance","-mnt"],description:["Displays the components that are in 'maintenance' mode, and the components that supersede them.\n","This command always displays the maintenance state for JET legacy components without any other options.","If ojaf can locate the JET Core Pack, this will also be included. If the core pack is not directly","available to ojaf, then a configuration file should be specified (via -c) to declare the location of the","core pack. Similarly, external components will also be checked if the configuration file specifies their","location using the 'components' property."],options:[" - None -"]},"metahist":{synopsis:["--metahist","-mh"],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 -"]},"migrator":{synopsis:["--migrator","-mig"],description:["Invokes the JET legacy component to Core Pack component migration tool."],options:["Additional optional CLI args available:\n"," --Long-- --Short-- ----------- Description------------------\n"," --jetver (-jv) - the JET version as a full or partial semver"," --config (-c) - the full or relative path to a configuration JSON file"," --outpath (-o) - the full or relative path to the output file"," --dryrun (-dr) - perform a dry run, no migration performed"," --nocolor (-nc) - suppress color in CLI mode"," --extra (-e) - verbose mode"," --debug (-d) - debug mode\n","The jetver, config, and outpath commands take an additional argument. This can be","supplied as:","1) an argument following the command line flag, e.g. --jetver 15.0.0 or","2) as a single argument, e.g. --jetver=15.0.0","","* Note that filepaths for config and outpath may be specified with forward slashes"," on all platforms (including Windows)."]},"msgid":{synopsis:["--msgid","-id"],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","-nsl"],description:["Displays the JET namespaces known to the version of ojaf being used."],options:[" - None -"]},"nocolor":{synopsis:["--nocolor","-nc"],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 -"]},"nodebug":{synopsis:["--nodebug","-nd"],description:["Disables debug mode set in the configuration 'options' property."],options:[" - None -"]},"noextra":{synopsis:["--noextra","-ne"],description:["Disables verbose mode set in the configuration 'options' property. This is a synonym for --noverbose."],options:[" - None -"]},"nofollowlinks":{synopsis:["--nofollowlinks","-nfl"],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","-no"],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 -"]},"noverbose":{synopsis:["--noverbose","-nv"],description:["Disables verbose mode set in the configuration 'options' property. This is a synonym for --noextra"],options:[" - None -"]},"outPath":{synopsis:["--outPath <filepath>","","-o <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.","* Note that the filepath may be specified with forward slashes even on the Windows platform."]},"profiles":{synopsis:["--profiles","--profiles <profile name>","","-prof","-prof <profile name>"],description:["Displays a list of the available inheritable/extendable 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>","","-rc auto","-rc=auto","-rc <number>","-rc=<number>","-rc errors","-rc <severities>","-rc=<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","-r"],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","-rj"],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","-rs"],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>\"","","-s <severity>","-s \"<severity>\"","-s \"<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","-v"],description:["Displays the version of ojaf being used."],options:[" - None -"]},"xgrouplist":{synopsis:["--xgrouplist","--xgrouplist <pack prefix>","","-xgl","-xgl <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 _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"deplist":case"dpl":manPage="deplist";syn="dpl";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"nodebug":case"nd":manPage="nodebug";syn="nd";break;case"noextra":case"ne":manPage="noextra";syn="ne";break;case"nofollowlinks":case"nfl":manPage="nofollowlinks";syn="nfl";break;case"noout":case"no":manPage="noout";syn="no";break;case"noverbose":case"nv":manPage="noverbose";syn="nv";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 idList=o.idList.filter((c,index)=>{return o.idList.indexOf(c)===index});var multiSev=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+"-"+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 "+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(/ /g,"\x11").replace(RE_MARKUP,EMPTY).replace(RE_MULTI_BLANKS," ").trimRight().replace(/@@01/g,"<oj-").replace(/@@02/g,"</oj-").replace(/@@03/g,"\n").replace(/</g,"<").replace(/>/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};
|
|
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"deplist":case"dpl":manPage="deplist";syn="dpl";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"maintenence":case"mnt":manPage="maintenance";syn="mnt";break;case"metahist":case"mh":manPage="metahist";syn="mh";break;case"migrator":case"mig":manPage="migrator";syn="mig";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"nodebug":case"nd":manPage="nodebug";syn="nd";break;case"noextra":case"ne":manPage="noextra";syn="ne";break;case"nofollowlinks":case"nfl":manPage="nofollowlinks";syn="nfl";break;case"noout":case"no":manPage="noout";syn="no";break;case"noverbose":case"nv":manPage="noverbose";syn="nv";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 idList=o.idList.filter((c,index)=>{return o.idList.indexOf(c)===index});var multiSev=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+"-"+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 "+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(/ /g,"\x11").replace(RE_MARKUP,EMPTY).replace(RE_MULTI_BLANKS," ").trimRight().replace(/@@01/g,"<oj-").replace(/@@02/g,"</oj-").replace(/@@03/g,"\n").replace(/</g,"<").replace(/>/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/migrator.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2018, 2023, 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
|
+
function run(cwd,rtf,appCtx,fnOpenWriter,JafVersion,fnShowVersion){var mig,isVerboseDebug=rtf.verboseMode||rtf.debugMode;var ctx;fnShowVersion();appCtx.debug("Loading migrator entry-point...");try{if(rtf.outPath){if(!fnOpenWriter(rtf.outPath)){return}}ctx=_makeContext(rtf,appCtx,JafVersion,cwd);mig=new(require("../corePackMigrator/cli"))(ctx)}catch(e){let s="[JAF-9100]: Error loading Migrator support.";if(isVerboseDebug){s+=`\n{e.message}`}appCtx.msg(appCtx.colors.RED(s))}if(!mig){return}appCtx.debug("Checking entry-points...");let isError;if(!mig.run){_missingEntry("run",appCtx);isError=true}if(rtf.unitTest&&!mig.test){_missingEntry("test",appCtx);isError=true}if(isError||rtf.help){return}_displayOptions(ctx,appCtx);appCtx.debug("Invoking migrator...");try{return mig.run()}catch(e){let s,x,i;s=e.stack;if((x=s.indexOf("migrator.js"))>=0){for(i=x;;i--){if(s.charAt(i)==="\n"){s=s.substring(0,i);break}}}appCtx.error(appCtx.colors.RED(`[JAF-9102]: Migrator run failure.\n${s}`))}return 0};function _makeContext(rtf,appCtx,JafVersion,cwd){return{jafVersion:JafVersion,jetVersion:rtf.jetverSet?rtf.jetverSet:appCtx.defaultJetVer,configPath:rtf.configPath||null,cwd:cwd,logPath:rtf.outPath,log:{error:appCtx.error,warn:appCtx.warn,info:appCtx.info,msg:appCtx.msg,console:appCtx.console,debug:appCtx.debug},options:{verboseMode:rtf.verboseMode,debugMode:rtf.debugMode,dryRunMode:rtf.dryRunSet,colorMode:appCtx.colors.isColor(),unitTest:!!rtf.unitTest},utils:{utils:appCtx.utils,fsUtils:appCtx.fsUtils,color:appCtx.colors}}};function _displayOptions(ctx,appCtx){if(ctx.options.debugMode){appCtx.debug("Migrator options:");appCtx.debug(` jafVersion: ${ctx.jafVersion}`);appCtx.debug(` jetVersion: ${ctx.jetVersion}`);appCtx.debug(` configPath: ${ctx.configPath}`);appCtx.debug(` debugMode: ${ctx.options.debugMode}`);appCtx.debug(` verboseMode: ${ctx.options.verboseMode}`);appCtx.debug(` dryRunMode: ${ctx.options.dryRunMode}`);appCtx.debug(` colorMode: ${ctx.options.colorMode}`);appCtx.debug(` logPath: ${ctx.logPath}`);appCtx.debug(` unitTest: ${ctx.options.unitTest}`)}else{appCtx.info(`Migrator log -> ${ctx.logPath}\n`)}};function _missingEntry(method,appCtx){appCtx.error(appCtx.colors.RED(`[JAF-9101]: Migrator linkage support - no ${method}() method exported.`))};module.exports={run};
|
package/lib/msgidLoader.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
|
-
module.exports=function(fp,nd,RSI,appCtx){var json,obj;if(appCtx.fsUtils.fileExists(fp)){json=nd.fs.readFileSync(fp,
|
|
6
|
+
module.exports=function(fp,nd,RSI,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-cic","oj-communities","oj-core","oj-cp","oj-cso","oj-csp","oj-cx","oj-cx-aiapps","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-saleshub","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-taui","oj-ugbu","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]}};
|
|
6
|
+
const _ns=["oj-acx","oj-acx-assets","oj-adp","oj-approvals","oj-av","oj-bi","oj-bi-sac","oj-cagbu","oj-cegbu","oj-cegbu-scp","oj-cgbu","oj-cgm","oj-cic","oj-communities","oj-core","oj-cp","oj-cso","oj-csp","oj-cx","oj-cx-aiapps","oj-cx-ap","oj-cx-cg","oj-cx-dcs","oj-cx-fsvc","oj-cx-hd","oj-cx-interviews","oj-cx-iss","oj-cx-km","oj-cx-km-agent","oj-cx-marketing","oj-cx-ma","oj-cx-mc","oj-cx-ol","oj-cx-saleshub","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-ocm","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-taui","oj-ugbu","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","app"];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
|
|
6
|
+
function writeFileSync(nd,filepath,src,options){if(typeof src!=="string"){let indent=options&&options.hasOwnProperty("indent")?options.indent:3;let replacer=options&&options.hasOwnProperty("replacer")?options.replacer:null;try{src=JSON.stringify(src,replacer,indent)}catch(e){console.log(`[ERROR] : writing to 'outPath' [${filepath}] JSON.stringify() failure : '${e.message}'`)}}nd.fs.writeFileSync(filepath,src)};module.exports={writeFileSync:writeFileSync};
|
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 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,param,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){param=error.params["additionalProperty"];param=param?` '${param}'`:"";if(error.instancePath.includes(DOT)){ret=`unexpected metadata property'${param}' in '${instPath}`}else{ret=`invalid property'${param}' in '${instPath}'`}}else{ret=`"unexpected 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}')
|
|
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,param,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){param=error.params["additionalProperty"];param=param?` '${param}'`:"";if(error.instancePath.includes(DOT)){ret=`unexpected metadata property'${param}' in '${instPath}`}else{ret=`invalid property'${param}' in '${instPath}'`}}else{ret=`"unexpected 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;
|
package/lib/scopewalker.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 CPW='Copyright (C) 2012-2013 Yusuke Suzuki <utatane.tea@gmail.com> Copyright (C) 2012 Ariya Hidayat <ariya.hidayat@gmail.com>';(function clone(exports){'use strict';var Syntax,VisitorOption,VisitorKeys,BREAK,SKIP,REMOVE;function deepCopy(obj){var ret={},key,val;for(key in obj){if(obj.hasOwnProperty(key)){val=obj[key];if(typeof val==='object'&&val!==null){ret[key]=deepCopy(val)}else{ret[key]=val}}}return ret}function upperBound(array,func){var diff,len,i,current;len=array.length;i=0;while(len){diff=len>>>1;current=i+diff;if(func(array[current])){len=diff}else{i=current+1;len-=diff+1}}return i}Syntax={AssignmentExpression:'AssignmentExpression',AssignmentPattern:'AssignmentPattern',ArrayExpression:'ArrayExpression',ArrayPattern:'ArrayPattern',ArrowFunctionExpression:'ArrowFunctionExpression',AwaitExpression:'AwaitExpression',BlockStatement:'BlockStatement',BinaryExpression:'BinaryExpression',BreakStatement:'BreakStatement',CallExpression:'CallExpression',CatchClause:'CatchClause',ChainExpression:'ChainExpression',ClassBody:'ClassBody',ClassDeclaration:'ClassDeclaration',ClassExpression:'ClassExpression',ComprehensionBlock:'ComprehensionBlock',ComprehensionExpression:'ComprehensionExpression',ConditionalExpression:'ConditionalExpression',ContinueStatement:'ContinueStatement',DebuggerStatement:'DebuggerStatement',DirectiveStatement:'DirectiveStatement',DoWhileStatement:'DoWhileStatement',EmptyStatement:'EmptyStatement',ExportAllDeclaration:'ExportAllDeclaration',ExportDefaultDeclaration:'ExportDefaultDeclaration',ExportNamedDeclaration:'ExportNamedDeclaration',ExportSpecifier:'ExportSpecifier',ExpressionStatement:'ExpressionStatement',ForStatement:'ForStatement',ForInStatement:'ForInStatement',ForOfStatement:'ForOfStatement',FunctionDeclaration:'FunctionDeclaration',FunctionExpression:'FunctionExpression',GeneratorExpression:'GeneratorExpression',Identifier:'Identifier',IfStatement:'IfStatement',ImportExpression:'ImportExpression',ImportDeclaration:'ImportDeclaration',ImportDefaultSpecifier:'ImportDefaultSpecifier',ImportNamespaceSpecifier:'ImportNamespaceSpecifier',ImportSpecifier:'ImportSpecifier',Literal:'Literal',LabeledStatement:'LabeledStatement',LogicalExpression:'LogicalExpression',MemberExpression:'MemberExpression',MetaProperty:'MetaProperty',MethodDefinition:'MethodDefinition',ModuleSpecifier:'ModuleSpecifier',NewExpression:'NewExpression',ObjectExpression:'ObjectExpression',ObjectPattern:'ObjectPattern',PrivateIdentifier:'PrivateIdentifier',Program:'Program',Property:'Property',PropertyDefinition:'PropertyDefinition',RestElement:'RestElement',ReturnStatement:'ReturnStatement',SequenceExpression:'SequenceExpression',SpreadElement:'SpreadElement',Super:'Super',SwitchStatement:'SwitchStatement',SwitchCase:'SwitchCase',TaggedTemplateExpression:'TaggedTemplateExpression',TemplateElement:'TemplateElement',TemplateLiteral:'TemplateLiteral',ThisExpression:'ThisExpression',ThrowStatement:'ThrowStatement',TryStatement:'TryStatement',UnaryExpression:'UnaryExpression',UpdateExpression:'UpdateExpression',VariableDeclaration:'VariableDeclaration',VariableDeclarator:'VariableDeclarator',WhileStatement:'WhileStatement',WithStatement:'WithStatement',YieldExpression:'YieldExpression',ClassProperty:'ClassProperty',TSAsExpression:'TSAsExpression',TSImportEqualsDeclaration:'TSImportEqualsDeclaration',TSTypeAliasDeclaration:'TSTypeAliasDeclaration',TSTypeAssertion:'TSTypeAssertion',TSInterfaceDeclaration:'TSInterfaceDeclaration',TSExportAssignment:'TSExportAssignment',TSAbstractMethodDefinition:'TSAbstractMethodDefinition',TSDeclareFunction:'TSDeclareFunction',TSModuleDeclaration:'TSModuleDeclaration',TSParameterProperty:'TSParameterProperty',TSNonNullExpression:'TSNonNullExpression',JSXElement:'JsxElement',JSXFragment:'JsxFragment',JSXOpeningElement:'JSXOpeningElement'};VisitorKeys={AssignmentExpression:['left','right'],AssignmentPattern:['left','right'],ArrayExpression:['elements'],ArrayPattern:['elements'],ArrowFunctionExpression:['params','body'],AwaitExpression:['argument'],BlockStatement:['body'],BinaryExpression:['left','right'],BreakStatement:['label'],CallExpression:['callee','arguments'],CatchClause:['param','body'],ChainExpression:['expression'],ClassBody:['body'],ClassDeclaration:['id','superClass','body'],ClassExpression:['id','superClass','body'],ComprehensionBlock:['left','right'],ComprehensionExpression:['blocks','filter','body'],ConditionalExpression:['test','consequent','alternate'],ContinueStatement:['label'],DebuggerStatement:[],DirectiveStatement:[],DoWhileStatement:['body','test'],EmptyStatement:[],ExportAllDeclaration:['source'],ExportDefaultDeclaration:['declaration'],ExportNamedDeclaration:['declaration','specifiers','source'],ExportSpecifier:['exported','local'],ExpressionStatement:['expression'],ForStatement:['init','test','update','body'],ForInStatement:['left','right','body'],ForOfStatement:['left','right','body'],FunctionDeclaration:['id','params','body'],FunctionExpression:['id','params','body'],GeneratorExpression:['blocks','filter','body'],Identifier:[],IfStatement:['test','consequent','alternate'],ImportExpression:['source'],ImportDeclaration:['specifiers','source'],ImportDefaultSpecifier:['local'],ImportNamespaceSpecifier:['local'],ImportSpecifier:['imported','local'],Literal:[],LabeledStatement:['label','body'],LogicalExpression:['left','right'],MemberExpression:['object','property'],MetaProperty:['meta','property'],MethodDefinition:['key','value'],ModuleSpecifier:[],NewExpression:['callee','arguments'],ObjectExpression:['properties'],ObjectPattern:['properties'],PrivateIdentifier:[],Program:['body'],Property:['key','value'],PropertyDefinition:['key','value'],RestElement:['argument'],ReturnStatement:['argument'],SequenceExpression:['expressions'],SpreadElement:['argument'],Super:[],SwitchStatement:['discriminant','cases'],SwitchCase:['test','consequent'],TaggedTemplateExpression:['tag','quasi'],TemplateElement:[],TemplateLiteral:['quasis','expressions'],ThisExpression:[],ThrowStatement:['argument'],TryStatement:['block','handler','finalizer'],UnaryExpression:['argument'],UpdateExpression:['argument'],VariableDeclaration:['declarations'],VariableDeclarator:['id','init'],WhileStatement:['test','body'],WithStatement:['object','body'],YieldExpression:['argument'],ClassProperty:[],TSAsExpression:[],TSEnumDeclaration:[],TSImportEqualsDeclaration:[],TSTypeAliasDeclaration:[],TSInterfaceDeclaration:[],TSNonNullExpression:[],TSExportAssignment:[],TSTypeAssertion:[],TSAbstractMethodDefinition:[],TSDeclareFunction:[],TSModuleDeclaration:[],TSParameterProperty:[],JSXElement:[],JSXFragment:[],JSXOpeningElement:[]};BREAK={};SKIP={};REMOVE={};VisitorOption={Break:BREAK,Skip:SKIP,Remove:REMOVE};function Reference(parent,key){this.parent=parent;this.key=key}Reference.prototype.replace=function replace(node){this.parent[this.key]=node};Reference.prototype.remove=function remove(){if(Array.isArray(this.parent)){this.parent.splice(this.key,1);return true}else{this.replace(null);return false}};function Element(node,path,wrap,ref){this.node=node;this.path=path;this.wrap=wrap;this.ref=ref}function Controller(){}Controller.prototype.path=function path(){var i,iz,j,jz,result,element;function addToPath(result,path){if(Array.isArray(path)){for(j=0,jz=path.length;j<jz;++j){result.push(path[j])}}else{result.push(path)}}if(!this.__current.path){return null}result=[];for(i=2,iz=this.__leavelist.length;i<iz;++i){element=this.__leavelist[i];addToPath(result,element.path)}addToPath(result,this.__current.path);return result};Controller.prototype.type=function(){var node=this.current();return node.type||this.__current.wrap};Controller.prototype.parents=function parents(){var i,iz,result;result=[];for(i=1,iz=this.__leavelist.length;i<iz;++i){result.push(this.__leavelist[i].node)}return result};Controller.prototype.current=function current(){return this.__current.node};Controller.prototype.__execute=function __execute(callback,element){var previous,result;result=undefined;previous=this.__current;this.__current=element;this.__state=null;if(callback){result=callback.call(this,element.node,this.__leavelist[this.__leavelist.length-1].node)}this.__current=previous;return result};Controller.prototype.notify=function notify(flag){this.__state=flag};Controller.prototype.skip=function(){this.notify(SKIP)};Controller.prototype['break']=function(){this.notify(BREAK)};Controller.prototype.remove=function(){this.notify(REMOVE)};Controller.prototype.__initialize=function(root,visitor){this.visitor=visitor;this.root=root;this.__worklist=[];this.__leavelist=[];this.__current=null;this.__state=null;this.__fallback=null;if(visitor.fallback==='iteration'){this.__fallback=Object.keys}else if(typeof visitor.fallback==='function'){this.__fallback=visitor.fallback}this.__keys=VisitorKeys;if(visitor.keys){this.__keys=Object.assign(Object.create(this.__keys),visitor.keys)}};function isNode(node){if(node==null){return false}return typeof node==='object'&&typeof node.type==='string'}function isProperty(nodeType,key){return(nodeType===Syntax.ObjectExpression||nodeType===Syntax.ObjectPattern)&&'properties'===key}function candidateExistsInLeaveList(leavelist,candidate){for(var i=leavelist.length-1;i>=0;--i){if(leavelist[i].node===candidate){return true}}return false}Controller.prototype.traverse=function traverse(root,visitor){var worklist,leavelist,element,node,nodeType,ret,key,current,current2,candidates,candidate,sentinel;this.__initialize(root,visitor);sentinel={};worklist=this.__worklist;leavelist=this.__leavelist;worklist.push(new Element(root,null,null,null));leavelist.push(new Element(null,null,null,null));while(worklist.length){element=worklist.pop();if(element===sentinel){element=leavelist.pop();ret=this.__execute(visitor.leave,element);if(this.__state===BREAK||ret===BREAK){return}continue}if(element.node){ret=this.__execute(visitor.enter,element);if(this.__state===BREAK||ret===BREAK){return}worklist.push(sentinel);leavelist.push(element);if(this.__state===SKIP||ret===SKIP){continue}node=element.node;nodeType=node.type||element.wrap;candidates=this.__keys[nodeType];if(!candidates){if(this.__fallback){candidates=this.__fallback(node)}else{throw new Error('Unknown node type '+nodeType+'.')}}current=candidates.length;while((current-=1)>=0){key=candidates[current];candidate=node[key];if(!candidate){continue}if(Array.isArray(candidate)){current2=candidate.length;while((current2-=1)>=0){if(!candidate[current2]){continue}if(candidateExistsInLeaveList(leavelist,candidate[current2])){continue}if(isProperty(nodeType,candidates[current])){element=new Element(candidate[current2],[key,current2],'Property',null)}else if(isNode(candidate[current2])){element=new Element(candidate[current2],[key,current2],null,null)}else{continue}worklist.push(element)}}else if(isNode(candidate)){if(candidateExistsInLeaveList(leavelist,candidate)){continue}worklist.push(new Element(candidate,key,null,null))}}}}};Controller.prototype.replace=function replace(root,visitor){var worklist,leavelist,node,nodeType,target,element,current,current2,candidates,candidate,sentinel,outer,key;function removeElem(element){var i,key,nextElem,parent;if(element.ref.remove()){key=element.ref.key;parent=element.ref.parent;i=worklist.length;while(i--){nextElem=worklist[i];if(nextElem.ref&&nextElem.ref.parent===parent){if(nextElem.ref.key<key){break}--nextElem.ref.key}}}}this.__initialize(root,visitor);sentinel={};worklist=this.__worklist;leavelist=this.__leavelist;outer={root:root};element=new Element(root,null,null,new Reference(outer,'root'));worklist.push(element);leavelist.push(element);while(worklist.length){element=worklist.pop();if(element===sentinel){element=leavelist.pop();target=this.__execute(visitor.leave,element);if(target!==undefined&&target!==BREAK&&target!==SKIP&&target!==REMOVE){element.ref.replace(target)}if(this.__state===REMOVE||target===REMOVE){removeElem(element)}if(this.__state===BREAK||target===BREAK){return outer.root}continue}target=this.__execute(visitor.enter,element);if(target!==undefined&&target!==BREAK&&target!==SKIP&&target!==REMOVE){element.ref.replace(target);element.node=target}if(this.__state===REMOVE||target===REMOVE){removeElem(element);element.node=null}if(this.__state===BREAK||target===BREAK){return outer.root}node=element.node;if(!node){continue}worklist.push(sentinel);leavelist.push(element);if(this.__state===SKIP||target===SKIP){continue}nodeType=node.type||element.wrap;candidates=this.__keys[nodeType];if(!candidates){if(this.__fallback){candidates=this.__fallback(node)}else{throw new Error('Unknown node type '+nodeType+'.')}}current=candidates.length;while((current-=1)>=0){key=candidates[current];candidate=node[key];if(!candidate){continue}if(Array.isArray(candidate)){current2=candidate.length;while((current2-=1)>=0){if(!candidate[current2]){continue}if(isProperty(nodeType,candidates[current])){element=new Element(candidate[current2],[key,current2],'Property',new Reference(candidate,current2))}else if(isNode(candidate[current2])){element=new Element(candidate[current2],[key,current2],null,new Reference(candidate,current2))}else{continue}worklist.push(element)}}else if(isNode(candidate)){worklist.push(new Element(candidate,key,null,new Reference(node,key)))}}}return outer.root};function traverse(root,visitor){var controller=new Controller;return controller.traverse(root,visitor)}function replace(root,visitor){var controller=new Controller;return controller.replace(root,visitor)}function extendCommentRange(comment,tokens){var target;target=upperBound(tokens,function search(token){return token.range[0]>comment.range[0]});comment.extendedRange=[comment.range[0],comment.range[1]];if(target!==tokens.length){comment.extendedRange[1]=tokens[target].range[0]}target-=1;if(target>=0){comment.extendedRange[0]=tokens[target].range[1]}return comment}function attachComments(tree,providedComments,tokens){var comments=[],comment,len,i,cursor;if(!tree.range){throw new Error('attachComments needs range information')}if(!tokens.length){if(providedComments.length){for(i=0,len=providedComments.length;i<len;i+=1){comment=deepCopy(providedComments[i]);comment.extendedRange=[0,tree.range[0]];comments.push(comment)}tree.leadingComments=comments}return tree}for(i=0,len=providedComments.length;i<len;i+=1){comments.push(extendCommentRange(deepCopy(providedComments[i]),tokens))}cursor=0;traverse(tree,{enter:function(node){var comment;while(cursor<comments.length){comment=comments[cursor];if(comment.extendedRange[1]>node.range[0]){break}if(comment.extendedRange[1]===node.range[0]){if(!node.leadingComments){node.leadingComments=[]}node.leadingComments.push(comment);comments.splice(cursor,1)}else{cursor+=1}}if(cursor===comments.length){return VisitorOption.Break}if(comments[cursor].extendedRange[0]>node.range[1]){return VisitorOption.Skip}}});cursor=0;traverse(tree,{leave:function(node){var comment;while(cursor<comments.length){comment=comments[cursor];if(node.range[1]<comment.extendedRange[0]){break}if(node.range[1]===comment.extendedRange[0]){if(!node.trailingComments){node.trailingComments=[]}node.trailingComments.push(comment);comments.splice(cursor,1)}else{cursor+=1}}if(cursor===comments.length){return VisitorOption.Break}if(comments[cursor].extendedRange[0]>node.range[1]){return VisitorOption.Skip}}});return tree}exports.Syntax=Syntax;exports.traverse=traverse;exports.replace=replace;exports.attachComments=attachComments;exports.VisitorKeys=VisitorKeys;exports.VisitorOption=VisitorOption;exports.Controller=Controller;exports.cloneEnvironment=function(){return clone({})};return exports})(exports);
|
|
6
|
+
const CPW="Copyright (C) 2012-2013 Yusuke Suzuki <utatane.tea@gmail.com> Copyright (C) 2012 Ariya Hidayat <ariya.hidayat@gmail.com>";(function clone(exports){"use strict";var Syntax,VisitorOption,VisitorKeys,BREAK,SKIP,REMOVE;function deepCopy(obj){var ret={},key,val;for(key in obj){if(obj.hasOwnProperty(key)){val=obj[key];if(typeof val==="object"&&val!==null){ret[key]=deepCopy(val)}else{ret[key]=val}}}return ret}function upperBound(array,func){var diff,len,i,current;len=array.length;i=0;while(len){diff=len>>>1;current=i+diff;if(func(array[current])){len=diff}else{i=current+1;len-=diff+1}}return i}Syntax={AssignmentExpression:"AssignmentExpression",AssignmentPattern:"AssignmentPattern",ArrayExpression:"ArrayExpression",ArrayPattern:"ArrayPattern",ArrowFunctionExpression:"ArrowFunctionExpression",AwaitExpression:"AwaitExpression",BlockStatement:"BlockStatement",BinaryExpression:"BinaryExpression",BreakStatement:"BreakStatement",CallExpression:"CallExpression",CatchClause:"CatchClause",ChainExpression:"ChainExpression",ClassBody:"ClassBody",ClassDeclaration:"ClassDeclaration",ClassExpression:"ClassExpression",ComprehensionBlock:"ComprehensionBlock",ComprehensionExpression:"ComprehensionExpression",ConditionalExpression:"ConditionalExpression",ContinueStatement:"ContinueStatement",DebuggerStatement:"DebuggerStatement",DirectiveStatement:"DirectiveStatement",DoWhileStatement:"DoWhileStatement",EmptyStatement:"EmptyStatement",ExportAllDeclaration:"ExportAllDeclaration",ExportDefaultDeclaration:"ExportDefaultDeclaration",ExportNamedDeclaration:"ExportNamedDeclaration",ExportSpecifier:"ExportSpecifier",ExpressionStatement:"ExpressionStatement",ForStatement:"ForStatement",ForInStatement:"ForInStatement",ForOfStatement:"ForOfStatement",FunctionDeclaration:"FunctionDeclaration",FunctionExpression:"FunctionExpression",GeneratorExpression:"GeneratorExpression",Identifier:"Identifier",IfStatement:"IfStatement",ImportExpression:"ImportExpression",ImportDeclaration:"ImportDeclaration",ImportDefaultSpecifier:"ImportDefaultSpecifier",ImportNamespaceSpecifier:"ImportNamespaceSpecifier",ImportSpecifier:"ImportSpecifier",Literal:"Literal",LabeledStatement:"LabeledStatement",LogicalExpression:"LogicalExpression",MemberExpression:"MemberExpression",MetaProperty:"MetaProperty",MethodDefinition:"MethodDefinition",ModuleSpecifier:"ModuleSpecifier",NewExpression:"NewExpression",ObjectExpression:"ObjectExpression",ObjectPattern:"ObjectPattern",PrivateIdentifier:"PrivateIdentifier",Program:"Program",Property:"Property",PropertyDefinition:"PropertyDefinition",RestElement:"RestElement",ReturnStatement:"ReturnStatement",SequenceExpression:"SequenceExpression",SpreadElement:"SpreadElement",Super:"Super",SwitchStatement:"SwitchStatement",SwitchCase:"SwitchCase",TaggedTemplateExpression:"TaggedTemplateExpression",TemplateElement:"TemplateElement",TemplateLiteral:"TemplateLiteral",ThisExpression:"ThisExpression",ThrowStatement:"ThrowStatement",TryStatement:"TryStatement",UnaryExpression:"UnaryExpression",UpdateExpression:"UpdateExpression",VariableDeclaration:"VariableDeclaration",VariableDeclarator:"VariableDeclarator",WhileStatement:"WhileStatement",WithStatement:"WithStatement",YieldExpression:"YieldExpression",ClassProperty:"ClassProperty",TSAsExpression:"TSAsExpression",TSImportEqualsDeclaration:"TSImportEqualsDeclaration",TSTypeAliasDeclaration:"TSTypeAliasDeclaration",TSTypeAssertion:"TSTypeAssertion",TSInterfaceDeclaration:"TSInterfaceDeclaration",TSExportAssignment:"TSExportAssignment",TSAbstractMethodDefinition:"TSAbstractMethodDefinition",TSDeclareFunction:"TSDeclareFunction",TSModuleDeclaration:"TSModuleDeclaration",TSParameterProperty:"TSParameterProperty",TSNonNullExpression:"TSNonNullExpression",JSXElement:"JsxElement",JSXFragment:"JsxFragment",JSXOpeningElement:"JSXOpeningElement"};VisitorKeys={AssignmentExpression:["left","right"],AssignmentPattern:["left","right"],ArrayExpression:["elements"],ArrayPattern:["elements"],ArrowFunctionExpression:["params","body"],AwaitExpression:["argument"],BlockStatement:["body"],BinaryExpression:["left","right"],BreakStatement:["label"],CallExpression:["callee","arguments"],CatchClause:["param","body"],ChainExpression:["expression"],ClassBody:["body"],ClassDeclaration:["id","superClass","body"],ClassExpression:["id","superClass","body"],ComprehensionBlock:["left","right"],ComprehensionExpression:["blocks","filter","body"],ConditionalExpression:["test","consequent","alternate"],ContinueStatement:["label"],DebuggerStatement:[],DirectiveStatement:[],DoWhileStatement:["body","test"],EmptyStatement:[],ExportAllDeclaration:["source"],ExportDefaultDeclaration:["declaration"],ExportNamedDeclaration:["declaration","specifiers","source"],ExportSpecifier:["exported","local"],ExpressionStatement:["expression"],ForStatement:["init","test","update","body"],ForInStatement:["left","right","body"],ForOfStatement:["left","right","body"],FunctionDeclaration:["id","params","body"],FunctionExpression:["id","params","body"],GeneratorExpression:["blocks","filter","body"],Identifier:[],IfStatement:["test","consequent","alternate"],ImportExpression:["source"],ImportDeclaration:["specifiers","source"],ImportDefaultSpecifier:["local"],ImportNamespaceSpecifier:["local"],ImportSpecifier:["imported","local"],Literal:[],LabeledStatement:["label","body"],LogicalExpression:["left","right"],MemberExpression:["object","property"],MetaProperty:["meta","property"],MethodDefinition:["key","value"],ModuleSpecifier:[],NewExpression:["callee","arguments"],ObjectExpression:["properties"],ObjectPattern:["properties"],PrivateIdentifier:[],Program:["body"],Property:["key","value"],PropertyDefinition:["key","value"],RestElement:["argument"],ReturnStatement:["argument"],SequenceExpression:["expressions"],SpreadElement:["argument"],Super:[],SwitchStatement:["discriminant","cases"],SwitchCase:["test","consequent"],TaggedTemplateExpression:["tag","quasi"],TemplateElement:[],TemplateLiteral:["quasis","expressions"],ThisExpression:[],ThrowStatement:["argument"],TryStatement:["block","handler","finalizer"],UnaryExpression:["argument"],UpdateExpression:["argument"],VariableDeclaration:["declarations"],VariableDeclarator:["id","init"],WhileStatement:["test","body"],WithStatement:["object","body"],YieldExpression:["argument"],ClassProperty:[],TSAsExpression:[],TSEnumDeclaration:[],TSImportEqualsDeclaration:[],TSTypeAliasDeclaration:[],TSInterfaceDeclaration:[],TSNonNullExpression:[],TSExportAssignment:[],TSTypeAssertion:[],TSAbstractMethodDefinition:[],TSDeclareFunction:[],TSModuleDeclaration:[],TSParameterProperty:[],JSXElement:[],JSXFragment:[],JSXOpeningElement:[]};BREAK={};SKIP={};REMOVE={};VisitorOption={Break:BREAK,Skip:SKIP,Remove:REMOVE};function Reference(parent,key){this.parent=parent;this.key=key}Reference.prototype.replace=function replace(node){this.parent[this.key]=node};Reference.prototype.remove=function remove(){if(Array.isArray(this.parent)){this.parent.splice(this.key,1);return true}else{this.replace(null);return false}};function Element(node,path,wrap,ref){this.node=node;this.path=path;this.wrap=wrap;this.ref=ref}function Controller(){}Controller.prototype.path=function path(){var i,iz,j,jz,result,element;function addToPath(result,path){if(Array.isArray(path)){for(j=0,jz=path.length;j<jz;++j){result.push(path[j])}}else{result.push(path)}}if(!this.__current.path){return null}result=[];for(i=2,iz=this.__leavelist.length;i<iz;++i){element=this.__leavelist[i];addToPath(result,element.path)}addToPath(result,this.__current.path);return result};Controller.prototype.type=function(){var node=this.current();return node.type||this.__current.wrap};Controller.prototype.parents=function parents(){var i,iz,result;result=[];for(i=1,iz=this.__leavelist.length;i<iz;++i){result.push(this.__leavelist[i].node)}return result};Controller.prototype.current=function current(){return this.__current.node};Controller.prototype.__execute=function __execute(callback,element){var previous,result;result=undefined;previous=this.__current;this.__current=element;this.__state=null;if(callback){result=callback.call(this,element.node,this.__leavelist[this.__leavelist.length-1].node)}this.__current=previous;return result};Controller.prototype.notify=function notify(flag){this.__state=flag};Controller.prototype.skip=function(){this.notify(SKIP)};Controller.prototype["break"]=function(){this.notify(BREAK)};Controller.prototype.remove=function(){this.notify(REMOVE)};Controller.prototype.__initialize=function(root,visitor){this.visitor=visitor;this.root=root;this.__worklist=[];this.__leavelist=[];this.__current=null;this.__state=null;this.__fallback=null;if(visitor.fallback==="iteration"){this.__fallback=Object.keys}else if(typeof visitor.fallback==="function"){this.__fallback=visitor.fallback}this.__keys=VisitorKeys;if(visitor.keys){this.__keys=Object.assign(Object.create(this.__keys),visitor.keys)}};function isNode(node){if(node==null){return false}return typeof node==="object"&&typeof node.type==="string"}function isProperty(nodeType,key){return(nodeType===Syntax.ObjectExpression||nodeType===Syntax.ObjectPattern)&&"properties"===key}function candidateExistsInLeaveList(leavelist,candidate){for(var i=leavelist.length-1;i>=0;--i){if(leavelist[i].node===candidate){return true}}return false}Controller.prototype.traverse=function traverse(root,visitor){var worklist,leavelist,element,node,nodeType,ret,key,current,current2,candidates,candidate,sentinel;this.__initialize(root,visitor);sentinel={};worklist=this.__worklist;leavelist=this.__leavelist;worklist.push(new Element(root,null,null,null));leavelist.push(new Element(null,null,null,null));while(worklist.length){element=worklist.pop();if(element===sentinel){element=leavelist.pop();ret=this.__execute(visitor.leave,element);if(this.__state===BREAK||ret===BREAK){return}continue}if(element.node){ret=this.__execute(visitor.enter,element);if(this.__state===BREAK||ret===BREAK){return}worklist.push(sentinel);leavelist.push(element);if(this.__state===SKIP||ret===SKIP){continue}node=element.node;nodeType=node.type||element.wrap;candidates=this.__keys[nodeType];if(!candidates){if(this.__fallback){candidates=this.__fallback(node)}else{throw new Error("Unknown node type "+nodeType+".")}}current=candidates.length;while((current-=1)>=0){key=candidates[current];candidate=node[key];if(!candidate){continue}if(Array.isArray(candidate)){current2=candidate.length;while((current2-=1)>=0){if(!candidate[current2]){continue}if(candidateExistsInLeaveList(leavelist,candidate[current2])){continue}if(isProperty(nodeType,candidates[current])){element=new Element(candidate[current2],[key,current2],"Property",null)}else if(isNode(candidate[current2])){element=new Element(candidate[current2],[key,current2],null,null)}else{continue}worklist.push(element)}}else if(isNode(candidate)){if(candidateExistsInLeaveList(leavelist,candidate)){continue}worklist.push(new Element(candidate,key,null,null))}}}}};Controller.prototype.replace=function replace(root,visitor){var worklist,leavelist,node,nodeType,target,element,current,current2,candidates,candidate,sentinel,outer,key;function removeElem(element){var i,key,nextElem,parent;if(element.ref.remove()){key=element.ref.key;parent=element.ref.parent;i=worklist.length;while(i--){nextElem=worklist[i];if(nextElem.ref&&nextElem.ref.parent===parent){if(nextElem.ref.key<key){break}--nextElem.ref.key}}}}this.__initialize(root,visitor);sentinel={};worklist=this.__worklist;leavelist=this.__leavelist;outer={root:root};element=new Element(root,null,null,new Reference(outer,"root"));worklist.push(element);leavelist.push(element);while(worklist.length){element=worklist.pop();if(element===sentinel){element=leavelist.pop();target=this.__execute(visitor.leave,element);if(target!==undefined&&target!==BREAK&&target!==SKIP&&target!==REMOVE){element.ref.replace(target)}if(this.__state===REMOVE||target===REMOVE){removeElem(element)}if(this.__state===BREAK||target===BREAK){return outer.root}continue}target=this.__execute(visitor.enter,element);if(target!==undefined&&target!==BREAK&&target!==SKIP&&target!==REMOVE){element.ref.replace(target);element.node=target}if(this.__state===REMOVE||target===REMOVE){removeElem(element);element.node=null}if(this.__state===BREAK||target===BREAK){return outer.root}node=element.node;if(!node){continue}worklist.push(sentinel);leavelist.push(element);if(this.__state===SKIP||target===SKIP){continue}nodeType=node.type||element.wrap;candidates=this.__keys[nodeType];if(!candidates){if(this.__fallback){candidates=this.__fallback(node)}else{throw new Error("Unknown node type "+nodeType+".")}}current=candidates.length;while((current-=1)>=0){key=candidates[current];candidate=node[key];if(!candidate){continue}if(Array.isArray(candidate)){current2=candidate.length;while((current2-=1)>=0){if(!candidate[current2]){continue}if(isProperty(nodeType,candidates[current])){element=new Element(candidate[current2],[key,current2],"Property",new Reference(candidate,current2))}else if(isNode(candidate[current2])){element=new Element(candidate[current2],[key,current2],null,new Reference(candidate,current2))}else{continue}worklist.push(element)}}else if(isNode(candidate)){worklist.push(new Element(candidate,key,null,new Reference(node,key)))}}}return outer.root};function traverse(root,visitor){var controller=new Controller;return controller.traverse(root,visitor)}function replace(root,visitor){var controller=new Controller;return controller.replace(root,visitor)}function extendCommentRange(comment,tokens){var target;target=upperBound(tokens,function search(token){return token.range[0]>comment.range[0]});comment.extendedRange=[comment.range[0],comment.range[1]];if(target!==tokens.length){comment.extendedRange[1]=tokens[target].range[0]}target-=1;if(target>=0){comment.extendedRange[0]=tokens[target].range[1]}return comment}function attachComments(tree,providedComments,tokens){var comments=[],comment,len,i,cursor;if(!tree.range){throw new Error("attachComments needs range information")}if(!tokens.length){if(providedComments.length){for(i=0,len=providedComments.length;i<len;i+=1){comment=deepCopy(providedComments[i]);comment.extendedRange=[0,tree.range[0]];comments.push(comment)}tree.leadingComments=comments}return tree}for(i=0,len=providedComments.length;i<len;i+=1){comments.push(extendCommentRange(deepCopy(providedComments[i]),tokens))}cursor=0;traverse(tree,{enter:function(node){var comment;while(cursor<comments.length){comment=comments[cursor];if(comment.extendedRange[1]>node.range[0]){break}if(comment.extendedRange[1]===node.range[0]){if(!node.leadingComments){node.leadingComments=[]}node.leadingComments.push(comment);comments.splice(cursor,1)}else{cursor+=1}}if(cursor===comments.length){return VisitorOption.Break}if(comments[cursor].extendedRange[0]>node.range[1]){return VisitorOption.Skip}}});cursor=0;traverse(tree,{leave:function(node){var comment;while(cursor<comments.length){comment=comments[cursor];if(node.range[1]<comment.extendedRange[0]){break}if(node.range[1]===comment.extendedRange[0]){if(!node.trailingComments){node.trailingComments=[]}node.trailingComments.push(comment);comments.splice(cursor,1)}else{cursor+=1}}if(cursor===comments.length){return VisitorOption.Break}if(comments[cursor].extendedRange[0]>node.range[1]){return VisitorOption.Skip}}});return tree}exports.Syntax=Syntax;exports.traverse=traverse;exports.replace=replace;exports.attachComments=attachComments;exports.VisitorKeys=VisitorKeys;exports.VisitorOption=VisitorOption;exports.Controller=Controller;exports.cloneEnvironment=function(){return clone({})};return exports})(exports);
|
package/libext/expparser.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 ExpParser=function(){this.parse=function(expr){var length=expr.length;var context={index:0,expr:expr};var nodes=[];while(context.index<length){var ch_i=expr.charCodeAt(context.index);if(ch_i===SEMCOL_CODE||ch_i===COMMA_CODE){context.index++}else{var node=_gobbleExpression(context);if(node){nodes.push(node)}else if(context.index<length){_throwError('Unexpected "'+expr.charAt(context.index)+'"',context.index)}}}if(nodes.length===1){return nodes[0]}return{type:0,body:nodes}};function _gobbleSpaces(context){var expr=context.expr;var ch=expr.charCodeAt(context.index);while(ch===32||ch===9||ch===10||ch===13){ch=expr.charCodeAt(++context.index)}}function _gobbleExpression(context){var expr=context.expr;var test=_gobbleBinaryExpression(context),consequent,alternate;_gobbleSpaces(context);if(expr.charCodeAt(context.index)===QUMARK_CODE){context.index++;consequent=_gobbleExpression(context);if(!consequent){_throwError('Expected expression',context.index)}_gobbleSpaces(context);if(expr.charCodeAt(context.index)===COLON_CODE){context.index++;alternate=_gobbleExpression(context);if(!alternate){_throwError('Expected expression',context.index)}return{type:8,test:test,consequent:consequent,alternate:alternate}}_throwError('Expected :',context.index)}else{return test}}function _gobbleBinaryOp(context){var expr=context.expr;_gobbleSpaces(context);var to_check=expr.substr(context.index,_max_binop_len),tc_len=to_check.length;while(tc_len>0){if(_binary_ops[to_check]&&(!_isIdentifierStart(expr.charCodeAt(context.index))||context.index+to_check.length<expr.length&&!_isIdentifierPart(expr.charCodeAt(context.index+to_check.length)))){context.index+=tc_len;return to_check}to_check=to_check.substr(0,--tc_len)}return false}function _gobbleBinaryExpression(context){var node,biop,prec,stack,biop_info,left,right,i,cur_biop;left=_gobbleToken(context);biop=_gobbleBinaryOp(context);if(!biop){return left}biop_info={value:biop,prec:_binaryPrecedence(biop)};right=_gobbleToken(context);if(!right){_throwError('Expected expression after '+biop,context.index)}stack=[left,biop_info,right];while(biop=_gobbleBinaryOp(context)){prec=_binaryPrecedence(biop);if(prec===0){break}biop_info={value:biop,prec:prec};cur_biop=biop;while(stack.length>2&&prec<=stack[stack.length-2].prec){right=stack.pop();biop=stack.pop().value;left=stack.pop();node=_createBinaryExpression(biop,left,right,context);stack.push(node)}node=_gobbleToken(context);if(!node){_throwError('Expected expression after '+cur_biop,context.index)}stack.push(biop_info,node)}i=stack.length-1;node=stack[i];while(i>1){node=_createBinaryExpression(stack[i-1].value,stack[i-2],node,context);i-=2}return node}function _gobbleToken(context){var expr=context.expr;var ch,to_check,tc_len;_gobbleSpaces(context);ch=expr.charCodeAt(context.index);if(_isDecimalDigit(ch)||ch===PERIOD_CODE){return _gobbleNumericLiteral(context)}else if(ch===SQUOTE_CODE||ch===DQUOTE_CODE||ch===OBRACK_CODE){return _gobbleVariable(context)}else if(ch===OBRACE_CODE){return _gobbleObjectLiteral(context)}to_check=expr.substr(context.index,_max_unop_len);tc_len=to_check.length;while(tc_len>0){if(to_check in _unary_ops&&(!_isIdentifierStart(expr.charCodeAt(context.index))||context.index+to_check.length<expr.length&&!_isIdentifierPart(expr.charCodeAt(context.index+to_check.length)))){context.index+=tc_len;return{type:5,operator:to_check,argument:_gobbleToken(context),prefix:true}}to_check=to_check.substr(0,--tc_len)}var start=context.index;var funcEnd=context.index+8;if(expr.substring(start,funcEnd)==='function'&&!_isIdentifierPart(expr.charCodeAt(funcEnd))){context.index=funcEnd;return _gobbleFunction(context)}if(_isIdentifierStart(ch)||ch===OPAREN_CODE){return _gobbleVariable(context)}return false}function _gobbleNumericLiteral(context){var expr=context.expr;var number='',ch,chCode;while(_isDecimalDigit(expr.charCodeAt(context.index))){number+=expr.charAt(context.index++)}if(expr.charCodeAt(context.index)===PERIOD_CODE){number+=expr.charAt(context.index++);while(_isDecimalDigit(expr.charCodeAt(context.index))){number+=expr.charAt(context.index++)}}ch=expr.charAt(context.index);if(ch==='e'||ch==='E'){number+=expr.charAt(context.index++);ch=expr.charAt(context.index);if(ch==='+'||ch==='-'){number+=expr.charAt(context.index++)}while(_isDecimalDigit(expr.charCodeAt(context.index))){number+=expr.charAt(context.index++)}if(!_isDecimalDigit(expr.charCodeAt(context.index-1))){_throwError('Expected exponent ('+number+expr.charAt(context.index)+')',context.index)}}chCode=expr.charCodeAt(context.index);if(_isIdentifierStart(chCode)){_throwError('Variable names cannot start with a number ('+number+expr.charAt(context.index)+')',context.index)}else if(chCode===PERIOD_CODE){_throwError('Unexpected period',context.index)}return{type:3,value:parseFloat(number),raw:number}}function _gobbleStringLiteral(context){var expr=context.expr;var str='',quote=expr.charAt(context.index++),closed=false,ch;var length=expr.length;while(context.index<length){ch=expr.charAt(context.index++);if(ch===quote){closed=true;break}else if(ch==='\\'){ch=expr.charAt(context.index++);switch(ch){case'n':str+='\n';break;case'r':str+='\r';break;case't':str+='\t';break;case'b':str+='\b';break;case'f':str+='\f';break;case'v':str+='\x0B';break;default:str+=ch;}}else{str+=ch}}if(!closed){_throwError('Unclosed quote after "'+str+'"',context.index)}return{type:3,value:str,raw:quote+str+quote}}function _gobbleIdentifier(context,bMemberExpr){var expr=context.expr;var ch=expr.charCodeAt(context.index),start=context.index,identifier;if(_isIdentifierStart(ch)){context.index++}else{_throwError('Unexpected '+expr.charAt(context.index),context.index)}var length=expr.length;while(context.index<length){ch=expr.charCodeAt(context.index);if(_isIdentifierPart(ch)){context.index++}else{break}}identifier=expr.slice(start,context.index);if(identifier==='new'&&!bMemberExpr){_gobbleSpaces(context);var constructorNode=_gobbleVariable(context,4);if(constructorNode.type!==4){_throwError('Expression of type: '+constructorNode.type+' not supported for constructor expression')}return{type:12,callee:constructorNode.callee,arguments:constructorNode.arguments}}if(_literals.has(identifier)){return{type:3,value:_literals.get(identifier),raw:identifier}}return{type:1,name:identifier}}function _gobbleArguments(context,termination,identifiersOnly){var expr=context.expr;var length=expr.length;var ch_i,args=[],node,closed=false;var separator_count=0;while(context.index<length){_gobbleSpaces(context);ch_i=expr.charCodeAt(context.index);if(ch_i===termination){closed=true;context.index++;if(termination===CPAREN_CODE&&separator_count&&separator_count>=args.length){_throwError('Unexpected token '+String.fromCharCode(termination),context.index)}break}else if(ch_i===COMMA_CODE){context.index++;separator_count++;if(separator_count!==args.length){if(termination===CPAREN_CODE){_throwError('Unexpected token ,',context.index)}else if(termination===CBRACK_CODE){for(var arg=args.length;arg<separator_count;arg++){args.push(null)}}}}else{if(identifiersOnly){node=_gobbleIdentifier(context)}else{node=_gobbleExpression(context)}if(!node||args.length>separator_count){_throwError('Expected comma',context.index)}args.push(node)}}if(!closed){_throwError('Expected '+String.fromCharCode(termination),context.index)}return args}function _gobbleVariable(context,stopAtType){var expr=context.expr;var ch_i,node;ch_i=expr.charCodeAt(context.index);if(ch_i===OPAREN_CODE){node=_gobbleGroup(context)}else if(ch_i===SQUOTE_CODE||ch_i===DQUOTE_CODE){node=_gobbleStringLiteral(context)}else if(ch_i===OBRACK_CODE){node=_gobbleArray(context)}else{node=_gobbleIdentifier(context)}_gobbleSpaces(context);ch_i=expr.charCodeAt(context.index);while(ch_i===PERIOD_CODE||ch_i===OBRACK_CODE||ch_i===OPAREN_CODE||_isOptionalChaining(context)){context.index++;if(ch_i===PERIOD_CODE){_gobbleSpaces(context);node={type:2,computed:false,object:node,property:_gobbleIdentifier(context,true)}}else if(ch_i===QUMARK_CODE){context.index++;_gobbleSpaces(context);node={type:2,computed:false,conditional:true,object:node,property:_gobbleIdentifier(context,true)}}else if(ch_i===OBRACK_CODE){node={type:2,computed:true,object:node,property:_gobbleExpression(context)};_gobbleSpaces(context);ch_i=expr.charCodeAt(context.index);if(ch_i!==CBRACK_CODE){_throwError('Unclosed [',context.index)}context.index++}else if(ch_i===OPAREN_CODE){node={type:4,arguments:_gobbleArguments(context,CPAREN_CODE),callee:node}}if(stopAtType===node.type){return node}_gobbleSpaces(context);ch_i=expr.charCodeAt(context.index)}return node}function _gobbleGroup(context){context.index++;var node=_gobbleExpression(context);_gobbleSpaces(context);if(context.expr.charCodeAt(context.index)===CPAREN_CODE){context.index++;return node}_throwError('Unclosed (',context.index)}function _gobbleArray(context){context.index++;return{type:9,elements:_gobbleArguments(context,CBRACK_CODE)}}function _gobbleFunction(context){var expr=context.expr;_gobbleSpaces(context);var ch_i=expr.charCodeAt(context.index);if(ch_i!==OPAREN_CODE){_throwError('Expected (,',context.index)}context.index++;var args=_gobbleArguments(context,CPAREN_CODE,true);_gobbleSpaces(context);ch_i=expr.charCodeAt(context.index);if(ch_i!==OBRACE_CODE){_throwError('Expected {,',context.index)}context.index++;_gobbleSpaces(context);var startDef=context.index;var hasReturn;var start=context.index;if(expr.substring(start,start+6)==='return'){hasReturn=true;context.index+=6}_gobbleSpaces(context);var body=_gobbleExpression(context);_gobbleSpaces(context);ch_i=expr.charCodeAt(context.index);if(ch_i===SEMCOL_CODE){context.index++;_gobbleSpaces(context)}ch_i=expr.charCodeAt(context.index);if(ch_i!==CBRACE_CODE){_throwError('Expected },',context.index)}context.index++;return{type:11,arguments:args,body:body,expr:expr.substring(startDef,context.index-1),return:hasReturn}}function _gobbleObjectLiteral(context){var expr=context.expr;context.index++;var props=[];var closed;var separator_count=0;var length=expr.length;while(context.index<length&&!closed){_gobbleSpaces(context);var ch_i=expr.charCodeAt(context.index);if(ch_i===CBRACE_CODE){closed=true;context.index++}else if(ch_i===COMMA_CODE){context.index++;separator_count++;if(separator_count!==props.length){_throwError('Unexpected token ,',context.index)}}else{var key;if(ch_i===SQUOTE_CODE||ch_i===DQUOTE_CODE){key=_gobbleStringLiteral(context).value}else{key=_gobbleIdentifier(context).name}_gobbleSpaces(context);ch_i=expr.charCodeAt(context.index);if(ch_i!==COLON_CODE){_throwError('Expected \':\'. Found '+String.fromCharCode(ch_i),context.index)}context.index++;var writer=context.writer;if(key==='_ko_property_writers'){context.writer=1}try{props.push({key:key,value:_gobbleExpression(context)})}finally{context.writer=writer}}}if(!closed){_throwError('Expected '+String.fromCharCode(CBRACE_CODE),context.index)}return{type:10,properties:props}}var PERIOD_CODE=46,COMMA_CODE=44,SQUOTE_CODE=39,DQUOTE_CODE=34,OPAREN_CODE=40,CPAREN_CODE=41,OBRACK_CODE=91,CBRACK_CODE=93,QUMARK_CODE=63,SEMCOL_CODE=59,COLON_CODE=58,OBRACE_CODE=123,CBRACE_CODE=125;function _getMaxKeyLen(obj){return Object.keys(obj).reduce(function(curr,key){return Math.max(curr,key.length)},0)}var t=true,_unary_ops={'-':t,'!':t,'~':t,'+':t},_binary_ops={'=':1,'||':2,'&&':3,'|':4,'^':5,'&':6,'==':7,'!=':7,'===':7,'!==':7,'<':8,'>':8,'<=':8,'>=':8,'<<':9,'>>':9,'>>>':9,'+':10,'-':10,'*':11,'/':11,'%':11},_max_unop_len=_getMaxKeyLen(_unary_ops),_max_binop_len=_getMaxKeyLen(_binary_ops);var _literals=new Map;_literals.set('true',true);_literals.set('false',false);_literals.set('null',null);_literals.set('undefined',undefined);function _binaryPrecedence(op_val){return _binary_ops[op_val]||0}function _createBinaryExpression(operator,left,right,context){if(operator==='='&&!context.writer){_throwError('Unexpected operator \'=\'',context.index)}var type=operator==='||'||operator==='&&'?7:6;return{type:type,operator:operator,left:left,right:right}}function _isOptionalChaining(context){var expr=context.expr;if(expr.charCodeAt(context.index)===QUMARK_CODE&&expr.charCodeAt(context.index+1)===PERIOD_CODE&&!_isDecimalDigit(expr.charCodeAt(context.index+2))){return true}return false}function _isDecimalDigit(ch){return ch>=48&&ch<=57}function _isIdentifierStart(ch){return ch===36||ch===95||ch>=65&&ch<=90||ch>=97&&ch<=122||ch>=128&&!_binary_ops[String.fromCharCode(ch)]}function _isIdentifierPart(ch){return ch===36||ch===95||ch>=65&&ch<=90||ch>=97&&ch<=122||ch>=48&&ch<=57||ch>=128&&!_binary_ops[String.fromCharCode(ch)]}function _throwError(message,index){var error=new Error(message+' at character '+index);error.index=index;error.description=message;throw error}};module.exports=ExpParser;
|
|
6
|
+
const ExpParser=function(){this.parse=function(expr){var length=expr.length;var context={index:0,expr:expr};var nodes=[];while(context.index<length){var ch_i=expr.charCodeAt(context.index);if(ch_i===SEMCOL_CODE||ch_i===COMMA_CODE){context.index++}else{var node=_gobbleExpression(context);if(node){nodes.push(node)}else if(context.index<length){_throwError("Unexpected \""+expr.charAt(context.index)+"\"",context.index)}}}if(nodes.length===1){return nodes[0]}return{type:0,body:nodes}};function _gobbleSpaces(context){var expr=context.expr;var ch=expr.charCodeAt(context.index);while(ch===32||ch===9||ch===10||ch===13){ch=expr.charCodeAt(++context.index)}}function _gobbleExpression(context){var expr=context.expr;var test=_gobbleBinaryExpression(context),consequent,alternate;_gobbleSpaces(context);if(expr.charCodeAt(context.index)===QUMARK_CODE){context.index++;consequent=_gobbleExpression(context);if(!consequent){_throwError("Expected expression",context.index)}_gobbleSpaces(context);if(expr.charCodeAt(context.index)===COLON_CODE){context.index++;alternate=_gobbleExpression(context);if(!alternate){_throwError("Expected expression",context.index)}return{type:8,test:test,consequent:consequent,alternate:alternate}}_throwError("Expected :",context.index)}else{return test}}function _gobbleBinaryOp(context){var expr=context.expr;_gobbleSpaces(context);var to_check=expr.substr(context.index,_max_binop_len),tc_len=to_check.length;while(tc_len>0){if(_binary_ops[to_check]&&(!_isIdentifierStart(expr.charCodeAt(context.index))||context.index+to_check.length<expr.length&&!_isIdentifierPart(expr.charCodeAt(context.index+to_check.length)))){context.index+=tc_len;return to_check}to_check=to_check.substr(0,--tc_len)}return false}function _gobbleBinaryExpression(context){var node,biop,prec,stack,biop_info,left,right,i,cur_biop;left=_gobbleToken(context);biop=_gobbleBinaryOp(context);if(!biop){return left}biop_info={value:biop,prec:_binaryPrecedence(biop)};right=_gobbleToken(context);if(!right){_throwError("Expected expression after "+biop,context.index)}stack=[left,biop_info,right];while(biop=_gobbleBinaryOp(context)){prec=_binaryPrecedence(biop);if(prec===0){break}biop_info={value:biop,prec:prec};cur_biop=biop;while(stack.length>2&&prec<=stack[stack.length-2].prec){right=stack.pop();biop=stack.pop().value;left=stack.pop();node=_createBinaryExpression(biop,left,right,context);stack.push(node)}node=_gobbleToken(context);if(!node){_throwError("Expected expression after "+cur_biop,context.index)}stack.push(biop_info,node)}i=stack.length-1;node=stack[i];while(i>1){node=_createBinaryExpression(stack[i-1].value,stack[i-2],node,context);i-=2}return node}function _gobbleToken(context){var expr=context.expr;var ch,to_check,tc_len;_gobbleSpaces(context);ch=expr.charCodeAt(context.index);if(_isDecimalDigit(ch)||ch===PERIOD_CODE){return _gobbleNumericLiteral(context)}else if(ch===SQUOTE_CODE||ch===DQUOTE_CODE||ch===OBRACK_CODE){return _gobbleVariable(context)}else if(ch===OBRACE_CODE){return _gobbleObjectLiteral(context)}to_check=expr.substr(context.index,_max_unop_len);tc_len=to_check.length;while(tc_len>0){if(to_check in _unary_ops&&(!_isIdentifierStart(expr.charCodeAt(context.index))||context.index+to_check.length<expr.length&&!_isIdentifierPart(expr.charCodeAt(context.index+to_check.length)))){context.index+=tc_len;return{type:5,operator:to_check,argument:_gobbleToken(context),prefix:true}}to_check=to_check.substr(0,--tc_len)}var start=context.index;var funcEnd=context.index+8;if(expr.substring(start,funcEnd)==="function"&&!_isIdentifierPart(expr.charCodeAt(funcEnd))){context.index=funcEnd;return _gobbleFunction(context)}if(_isIdentifierStart(ch)||ch===OPAREN_CODE){return _gobbleVariable(context)}return false}function _gobbleNumericLiteral(context){var expr=context.expr;var number="",ch,chCode;while(_isDecimalDigit(expr.charCodeAt(context.index))){number+=expr.charAt(context.index++)}if(expr.charCodeAt(context.index)===PERIOD_CODE){number+=expr.charAt(context.index++);while(_isDecimalDigit(expr.charCodeAt(context.index))){number+=expr.charAt(context.index++)}}ch=expr.charAt(context.index);if(ch==="e"||ch==="E"){number+=expr.charAt(context.index++);ch=expr.charAt(context.index);if(ch==="+"||ch==="-"){number+=expr.charAt(context.index++)}while(_isDecimalDigit(expr.charCodeAt(context.index))){number+=expr.charAt(context.index++)}if(!_isDecimalDigit(expr.charCodeAt(context.index-1))){_throwError("Expected exponent ("+number+expr.charAt(context.index)+")",context.index)}}chCode=expr.charCodeAt(context.index);if(_isIdentifierStart(chCode)){_throwError("Variable names cannot start with a number ("+number+expr.charAt(context.index)+")",context.index)}else if(chCode===PERIOD_CODE){_throwError("Unexpected period",context.index)}return{type:3,value:parseFloat(number),raw:number}}function _gobbleStringLiteral(context){var expr=context.expr;var str="",quote=expr.charAt(context.index++),closed=false,ch;var length=expr.length;while(context.index<length){ch=expr.charAt(context.index++);if(ch===quote){closed=true;break}else if(ch==="\\"){ch=expr.charAt(context.index++);switch(ch){case"n":str+="\n";break;case"r":str+="\r";break;case"t":str+="\t";break;case"b":str+="\b";break;case"f":str+="\f";break;case"v":str+="\x0B";break;default:str+=ch}}else{str+=ch}}if(!closed){_throwError("Unclosed quote after \""+str+"\"",context.index)}return{type:3,value:str,raw:quote+str+quote}}function _gobbleIdentifier(context,bMemberExpr){var expr=context.expr;var ch=expr.charCodeAt(context.index),start=context.index,identifier;if(_isIdentifierStart(ch)){context.index++}else{_throwError("Unexpected "+expr.charAt(context.index),context.index)}var length=expr.length;while(context.index<length){ch=expr.charCodeAt(context.index);if(_isIdentifierPart(ch)){context.index++}else{break}}identifier=expr.slice(start,context.index);if(identifier==="new"&&!bMemberExpr){_gobbleSpaces(context);var constructorNode=_gobbleVariable(context,4);if(constructorNode.type!==4){_throwError("Expression of type: "+constructorNode.type+" not supported for constructor expression")}return{type:12,callee:constructorNode.callee,arguments:constructorNode.arguments}}if(_literals.has(identifier)){return{type:3,value:_literals.get(identifier),raw:identifier}}return{type:1,name:identifier}}function _gobbleArguments(context,termination,identifiersOnly){var expr=context.expr;var length=expr.length;var ch_i,args=[],node,closed=false;var separator_count=0;while(context.index<length){_gobbleSpaces(context);ch_i=expr.charCodeAt(context.index);if(ch_i===termination){closed=true;context.index++;if(termination===CPAREN_CODE&&separator_count&&separator_count>=args.length){_throwError("Unexpected token "+String.fromCharCode(termination),context.index)}break}else if(ch_i===COMMA_CODE){context.index++;separator_count++;if(separator_count!==args.length){if(termination===CPAREN_CODE){_throwError("Unexpected token ,",context.index)}else if(termination===CBRACK_CODE){for(var arg=args.length;arg<separator_count;arg++){args.push(null)}}}}else{if(identifiersOnly){node=_gobbleIdentifier(context)}else{node=_gobbleExpression(context)}if(!node||args.length>separator_count){_throwError("Expected comma",context.index)}args.push(node)}}if(!closed){_throwError("Expected "+String.fromCharCode(termination),context.index)}return args}function _gobbleVariable(context,stopAtType){var expr=context.expr;var ch_i,node;ch_i=expr.charCodeAt(context.index);if(ch_i===OPAREN_CODE){node=_gobbleGroup(context)}else if(ch_i===SQUOTE_CODE||ch_i===DQUOTE_CODE){node=_gobbleStringLiteral(context)}else if(ch_i===OBRACK_CODE){node=_gobbleArray(context)}else{node=_gobbleIdentifier(context)}_gobbleSpaces(context);ch_i=expr.charCodeAt(context.index);while(ch_i===PERIOD_CODE||ch_i===OBRACK_CODE||ch_i===OPAREN_CODE||_isOptionalChaining(context)){context.index++;if(ch_i===PERIOD_CODE){_gobbleSpaces(context);node={type:2,computed:false,object:node,property:_gobbleIdentifier(context,true)}}else if(ch_i===QUMARK_CODE){context.index++;_gobbleSpaces(context);node={type:2,computed:false,conditional:true,object:node,property:_gobbleIdentifier(context,true)}}else if(ch_i===OBRACK_CODE){node={type:2,computed:true,object:node,property:_gobbleExpression(context)};_gobbleSpaces(context);ch_i=expr.charCodeAt(context.index);if(ch_i!==CBRACK_CODE){_throwError("Unclosed [",context.index)}context.index++}else if(ch_i===OPAREN_CODE){node={type:4,arguments:_gobbleArguments(context,CPAREN_CODE),callee:node}}if(stopAtType===node.type){return node}_gobbleSpaces(context);ch_i=expr.charCodeAt(context.index)}return node}function _gobbleGroup(context){context.index++;var node=_gobbleExpression(context);_gobbleSpaces(context);if(context.expr.charCodeAt(context.index)===CPAREN_CODE){context.index++;return node}_throwError("Unclosed (",context.index)}function _gobbleArray(context){context.index++;return{type:9,elements:_gobbleArguments(context,CBRACK_CODE)}}function _gobbleFunction(context){var expr=context.expr;_gobbleSpaces(context);var ch_i=expr.charCodeAt(context.index);if(ch_i!==OPAREN_CODE){_throwError("Expected (,",context.index)}context.index++;var args=_gobbleArguments(context,CPAREN_CODE,true);_gobbleSpaces(context);ch_i=expr.charCodeAt(context.index);if(ch_i!==OBRACE_CODE){_throwError("Expected {,",context.index)}context.index++;_gobbleSpaces(context);var startDef=context.index;var hasReturn;var start=context.index;if(expr.substring(start,start+6)==="return"){hasReturn=true;context.index+=6}_gobbleSpaces(context);var body=_gobbleExpression(context);_gobbleSpaces(context);ch_i=expr.charCodeAt(context.index);if(ch_i===SEMCOL_CODE){context.index++;_gobbleSpaces(context)}ch_i=expr.charCodeAt(context.index);if(ch_i!==CBRACE_CODE){_throwError("Expected },",context.index)}context.index++;return{type:11,arguments:args,body:body,expr:expr.substring(startDef,context.index-1),return:hasReturn}}function _gobbleObjectLiteral(context){var expr=context.expr;context.index++;var props=[];var closed;var separator_count=0;var length=expr.length;while(context.index<length&&!closed){_gobbleSpaces(context);var ch_i=expr.charCodeAt(context.index);if(ch_i===CBRACE_CODE){closed=true;context.index++}else if(ch_i===COMMA_CODE){context.index++;separator_count++;if(separator_count!==props.length){_throwError("Unexpected token ,",context.index)}}else{var key;if(ch_i===SQUOTE_CODE||ch_i===DQUOTE_CODE){key=_gobbleStringLiteral(context).value}else{key=_gobbleIdentifier(context).name}_gobbleSpaces(context);ch_i=expr.charCodeAt(context.index);if(ch_i!==COLON_CODE){_throwError("Expected ':'. Found "+String.fromCharCode(ch_i),context.index)}context.index++;var writer=context.writer;if(key==="_ko_property_writers"){context.writer=1}try{props.push({key:key,value:_gobbleExpression(context)})}finally{context.writer=writer}}}if(!closed){_throwError("Expected "+String.fromCharCode(CBRACE_CODE),context.index)}return{type:10,properties:props}}var PERIOD_CODE=46,COMMA_CODE=44,SQUOTE_CODE=39,DQUOTE_CODE=34,OPAREN_CODE=40,CPAREN_CODE=41,OBRACK_CODE=91,CBRACK_CODE=93,QUMARK_CODE=63,SEMCOL_CODE=59,COLON_CODE=58,OBRACE_CODE=123,CBRACE_CODE=125;function _getMaxKeyLen(obj){return Object.keys(obj).reduce(function(curr,key){return Math.max(curr,key.length)},0)}var t=true,_unary_ops={"-":t,"!":t,"~":t,"+":t},_binary_ops={"=":1,"||":2,"&&":3,"|":4,"^":5,"&":6,"==":7,"!=":7,"===":7,"!==":7,"<":8,">":8,"<=":8,">=":8,"<<":9,">>":9,">>>":9,"+":10,"-":10,"*":11,"/":11,"%":11},_max_unop_len=_getMaxKeyLen(_unary_ops),_max_binop_len=_getMaxKeyLen(_binary_ops);var _literals=new Map;_literals.set("true",true);_literals.set("false",false);_literals.set("null",null);_literals.set("undefined",undefined);function _binaryPrecedence(op_val){return _binary_ops[op_val]||0}function _createBinaryExpression(operator,left,right,context){if(operator==="="&&!context.writer){_throwError("Unexpected operator '='",context.index)}var type=operator==="||"||operator==="&&"?7:6;return{type:type,operator:operator,left:left,right:right}}function _isOptionalChaining(context){var expr=context.expr;if(expr.charCodeAt(context.index)===QUMARK_CODE&&expr.charCodeAt(context.index+1)===PERIOD_CODE&&!_isDecimalDigit(expr.charCodeAt(context.index+2))){return true}return false}function _isDecimalDigit(ch){return ch>=48&&ch<=57}function _isIdentifierStart(ch){return ch===36||ch===95||ch>=65&&ch<=90||ch>=97&&ch<=122||ch>=128&&!_binary_ops[String.fromCharCode(ch)]}function _isIdentifierPart(ch){return ch===36||ch===95||ch>=65&&ch<=90||ch>=97&&ch<=122||ch>=48&&ch<=57||ch>=128&&!_binary_ops[String.fromCharCode(ch)]}function _throwError(message,index){var error=new Error(message+" at character "+index);error.index=index;error.description=message;throw error}};module.exports=ExpParser;
|