@oracle/oraclejet-audit 11.0.0 → 12.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/LICENSE.md +1 -1
- package/jaf-amd.js +6 -6
- package/jaf.js +2 -2
- package/jafapi.js +2 -2
- package/lib/AST.js +1 -1
- package/lib/AST_Ts.js +2 -2
- package/lib/AstJson.js +2 -2
- package/lib/AstMd.js +6 -0
- package/lib/AstNodeTypes.js +2 -2
- package/lib/Comments.js +1 -1
- package/lib/ComponentSvcs.js +1 -1
- package/lib/Components.js +2 -2
- package/lib/Config.js +2 -2
- package/lib/ConfigLib.js +2 -2
- package/lib/CssLib.js +1 -1
- package/lib/CssUtils.js +1 -1
- package/lib/DomUtils.js +2 -2
- package/lib/FileIndex.js +1 -1
- package/lib/FileSet.js +1 -1
- package/lib/FsUtils.js +2 -2
- package/lib/Histo.js +2 -2
- package/lib/HtmlTree.js +2 -2
- package/lib/HtmlUtils.js +1 -1
- package/lib/Issue.js +2 -2
- package/lib/JafEvents.js +1 -1
- package/lib/JafLib.js +2 -2
- package/lib/Json.js +2 -2
- package/lib/JsonLoader.js +2 -2
- package/lib/Md.js +6 -0
- package/lib/MetaLib.js +2 -2
- package/lib/NetUtils.js +1 -1
- package/lib/NodeTypes.js +1 -1
- package/lib/Parser.js +2 -2
- package/lib/RegTypes.js +2 -2
- package/lib/Registry.js +2 -2
- package/lib/Reporter.js +2 -2
- package/lib/RuleContext.js +1 -1
- package/lib/RulePack.js +1 -1
- package/lib/RuleSet.js +2 -2
- package/lib/Rules.js +2 -2
- package/lib/Scope.js +2 -2
- package/lib/SemVer.js +1 -1
- package/lib/Server.js +1 -1
- package/lib/SevLib.js +1 -1
- package/lib/Severity.js +1 -1
- package/lib/Stats.js +1 -1
- package/lib/Ts.js +2 -2
- package/lib/Utils.js +2 -2
- package/lib/Watch.js +1 -1
- package/lib/Writer.js +1 -1
- package/lib/ZipUtils.js +1 -1
- package/lib/api.js +2 -2
- package/lib/builtinpacks.js +6 -0
- package/lib/cliStats.js +2 -2
- package/lib/clone.js +2 -2
- package/lib/cmdline.js +2 -2
- package/lib/colors.js +2 -2
- package/lib/defaults.js +6 -0
- package/lib/deflist.js +6 -0
- package/lib/dislist.js +6 -0
- package/lib/exportRules.js +1 -1
- package/lib/extends.js +2 -2
- package/lib/filetypes.js +2 -2
- package/lib/grouplist.js +6 -0
- package/lib/groups.js +2 -2
- package/lib/help.js +2 -2
- package/lib/jetver.js +2 -2
- package/lib/macros.js +1 -1
- package/lib/manual.js +6 -0
- package/lib/metaLoader.js +1 -1
- package/lib/metahist.js +1 -1
- package/lib/msgidLoader.js +1 -1
- package/lib/ns.js +2 -2
- package/lib/nslist.js +1 -1
- package/lib/outFormat.js +1 -1
- package/lib/outfile.js +1 -1
- package/lib/ruleLoader.js +1 -1
- package/lib/scaffold.js +2 -2
- package/lib/scaffoldRule.js +2 -2
- package/lib/schema.js +2 -2
- package/lib/scopewalker.js +2 -2
- package/lib/spinner.js +2 -2
- package/lib/spinnernoop.js +1 -1
- package/lib/tabs.js +1 -1
- package/libext/expparser.js +1 -1
- package/meta/11.1.0/jetauditmeta.js +9 -0
- package/meta/12.0.0/jetauditmeta.js +9 -0
- package/meta/metaverlist.json +1 -1
- package/package.json +72 -68
- package/rulepacks/csp/csp-html-script-unsafe-inline.js +1 -1
- package/rulepacks/csp/csp-html-style-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-ts-script-unsafe-eval.js +1 -1
- package/rulepacks/csp/csp-ts-style-unsafe-inline.js +1 -1
- package/rulepacks/csp/msgid.json +1 -1
- package/rulepacks/csp/rules.json +1 -1
- package/rulepacks/jetwc/jetwc-absolute-jetversion.js +2 -2
- package/rulepacks/jetwc/jetwc-aria-redefinition.js +2 -2
- package/rulepacks/jetwc/jetwc-bootstrap.js +2 -2
- package/rulepacks/jetwc/jetwc-compjson-bp-ar.js +2 -2
- package/rulepacks/jetwc/jetwc-compjson-bp-obj.js +2 -2
- package/rulepacks/jetwc/jetwc-component-dependencies.js +2 -2
- package/rulepacks/jetwc/jetwc-component-displayname.js +2 -2
- package/rulepacks/jetwc/jetwc-component-foldername.js +2 -2
- package/rulepacks/jetwc/jetwc-component-location.js +2 -2
- package/rulepacks/jetwc/jetwc-component-type.js +2 -2
- package/rulepacks/jetwc/jetwc-css-oj-complete.js +6 -0
- package/rulepacks/jetwc/jetwc-data-property-prefix.js +2 -2
- package/rulepacks/jetwc/jetwc-deprecated-lifecycle.js +2 -2
- package/rulepacks/jetwc/jetwc-disabled-property.js +2 -2
- package/rulepacks/jetwc/jetwc-displayname.js +2 -2
- package/rulepacks/jetwc/jetwc-dynamic-slot-context.js +2 -2
- package/rulepacks/jetwc/jetwc-dynamic-slots-naming.js +2 -2
- package/rulepacks/jetwc/jetwc-event-displayname.js +2 -2
- package/rulepacks/jetwc/jetwc-events.js +2 -2
- package/rulepacks/jetwc/jetwc-jet-version.js +2 -2
- package/rulepacks/jetwc/jetwc-loader-file.js +2 -2
- package/rulepacks/jetwc/jetwc-markdown-link.js +6 -0
- package/rulepacks/jetwc/jetwc-method-displayname.js +2 -2
- package/rulepacks/jetwc/jetwc-methods.js +2 -2
- package/rulepacks/jetwc/jetwc-namespace.js +2 -2
- package/rulepacks/jetwc/jetwc-nested-defaults.js +2 -2
- package/rulepacks/jetwc/jetwc-nls-languages.js +2 -2
- package/rulepacks/jetwc/jetwc-nls-root.js +2 -2
- package/rulepacks/jetwc/jetwc-oj-register.js +2 -2
- package/rulepacks/jetwc/jetwc-ojcss.js +2 -2
- package/rulepacks/jetwc/jetwc-pack-children.js +2 -2
- package/rulepacks/jetwc/jetwc-packable-components.js +2 -2
- package/rulepacks/jetwc/jetwc-prerelease-dependencies.js +2 -2
- package/rulepacks/jetwc/jetwc-prerelease-pattern.js +2 -2
- package/rulepacks/jetwc/jetwc-prerelease-version.js +2 -2
- package/rulepacks/jetwc/jetwc-property-changed.js +2 -2
- package/rulepacks/jetwc/jetwc-property-displayname.js +2 -2
- package/rulepacks/jetwc/jetwc-property-nesting.js +2 -2
- package/rulepacks/jetwc/jetwc-public-modules.js +2 -2
- package/rulepacks/jetwc/jetwc-register-css.js +2 -2
- package/rulepacks/jetwc/jetwc-register-with-promises.js +2 -2
- package/rulepacks/jetwc/jetwc-require-paths.js +2 -2
- package/rulepacks/jetwc/jetwc-required-subproperty.js +2 -2
- package/rulepacks/jetwc/jetwc-reserved-property.js +2 -2
- package/rulepacks/jetwc/jetwc-schema.js +2 -2
- package/rulepacks/jetwc/jetwc-semantic-version.js +2 -2
- package/rulepacks/jetwc/jetwc-slot-displayname.js +2 -2
- package/rulepacks/jetwc/jetwc-slots.js +2 -2
- package/rulepacks/jetwc/jetwc-standard-files.js +2 -2
- package/rulepacks/jetwc/jetwc-subproperty-writeback.js +2 -2
- package/rulepacks/jetwc/jetwc-template-slots.js +2 -2
- package/rulepacks/jetwc/jetwc-unused-events.js +2 -2
- package/rulepacks/jetwc/jetwc-unused-slots.js +2 -2
- package/rulepacks/jetwc/jetwc-vb-category.js +2 -2
- package/rulepacks/jetwc/jetwc-vb-icon.js +2 -2
- package/rulepacks/jetwc/jetwc-vcomponent-jetversion.js +6 -0
- package/rulepacks/jetwc/jetwc-vcomponent-loader.js +6 -0
- package/rulepacks/jetwc/jetwc-vcomponent-version.js +6 -0
- package/rulepacks/jetwc/jetwc-version-openrange.js +2 -2
- package/rulepacks/jetwc/jetwc-writeback-required.js +2 -2
- package/rulepacks/jetwc/msgid.json +2 -2
- package/rulepacks/jetwc/rules.json +2 -2
- package/rulepacks/jetwc-lib/jetwcutils-auditComponentCacheManager.js +6 -0
- package/rulepacks/jetwc-lib/jetwcutils-commonListenerImpls.js +6 -0
- package/rulepacks/jetwc-lib/jetwcutils-componentAuditUtils.js +6 -0
- package/rulepacks/jetwc-lib/jetwcutils-componentFinder.js +6 -0
- package/rulepacks/jetwc-lib/jetwcutils-preCompiler.js +6 -0
- package/rulepacks/jetwc-lib/jetwcutils-tsxUtils.js +6 -0
- package/rulepacks/jetwco/jetwco-bootstrap.js +2 -2
- package/rulepacks/jetwco/jetwco-cacc-auditConstraints.js +6 -0
- package/rulepacks/jetwco/jetwco-cacc-dependencies.js +6 -0
- package/rulepacks/jetwco/jetwco-cacc-dynamicSlots.js +6 -0
- package/rulepacks/jetwco/jetwco-cacc-eventBubbles.js +6 -0
- package/rulepacks/jetwco/jetwco-cacc-eventCancelable.js +6 -0
- package/rulepacks/jetwco/jetwco-cacc-eventPayload.js +6 -0
- package/rulepacks/jetwco/jetwco-cacc-events.js +6 -0
- package/rulepacks/jetwco/jetwco-cacc-helpers.js +6 -0
- package/rulepacks/jetwco/jetwco-cacc-jetVer.js +6 -0
- package/rulepacks/jetwco/jetwco-cacc-methodParamTypes.js +6 -0
- package/rulepacks/jetwco/jetwco-cacc-methodParams.js +6 -0
- package/rulepacks/jetwco/jetwco-cacc-methodReturnType.js +6 -0
- package/rulepacks/jetwco/jetwco-cacc-methods.js +6 -0
- package/rulepacks/jetwco/jetwco-cacc-packBundle.js +6 -0
- package/rulepacks/jetwco/jetwco-cacc-packBundleContent.js +6 -0
- package/rulepacks/jetwco/jetwco-cacc-packContent.js +6 -0
- package/rulepacks/jetwco/jetwco-cacc-properties.js +6 -0
- package/rulepacks/jetwco/jetwco-cacc-propertyDefault.js +6 -0
- package/rulepacks/jetwco/jetwco-cacc-propertyEnumeration.js +6 -0
- package/rulepacks/jetwco/jetwco-cacc-propertyReadOnly.js +6 -0
- package/rulepacks/jetwco/jetwco-cacc-propertyRequired.js +6 -0
- package/rulepacks/jetwco/jetwco-cacc-propertyType.js +6 -0
- package/rulepacks/jetwco/jetwco-cacc-propertyWriteback.js +6 -0
- package/rulepacks/jetwco/jetwco-cacc-publicModules.js +6 -0
- package/rulepacks/jetwco/jetwco-cacc-slotDataVariable.js +6 -0
- package/rulepacks/jetwco/jetwco-cacc-slotDataVariableType.js +6 -0
- package/rulepacks/jetwco/jetwco-cacc-slots.js +6 -0
- package/rulepacks/jetwco/jetwco-cacc-styleClasses.js +6 -0
- package/rulepacks/jetwco/jetwco-cacc-styleVariables.js +6 -0
- package/rulepacks/jetwco/jetwco-compjson-ns-reg.js +2 -2
- package/rulepacks/jetwco/jetwco-component-api-baseline-changes.js +2 -2
- package/rulepacks/jetwco/jetwco-component-api-changes.js +2 -2
- package/rulepacks/jetwco/jetwco-component-api-controlled-changes.js +6 -0
- package/rulepacks/jetwco/jetwco-component-cdn.js +2 -2
- package/rulepacks/jetwco/jetwco-description-standards.js +6 -0
- package/rulepacks/jetwco/jetwco-displayname-standards.js +6 -0
- package/rulepacks/jetwco/jetwco-exchange-version-check.js +2 -2
- package/rulepacks/jetwco/jetwco-license-info.js +2 -2
- package/rulepacks/jetwco/jetwco-prerelease-cdn.js +2 -2
- package/rulepacks/jetwco/jetwco-thirdparty-ba.js +2 -2
- package/rulepacks/jetwco/msgid.json +2 -2
- package/rulepacks/jetwco/rules.json +2 -2
- package/rulepacks/spoc/msgid.json +1 -1
- package/rulepacks/spoc/rules.json +1 -1
- package/rulepacks/spoc/spoc-dom-manip-inv-tag.js +1 -1
- package/rulepacks/spoc/spoc-dom-manip-tag-pos.js +1 -1
- package/rulepacks/spoc/spoc-dom-manip.js +1 -1
- package/rulepacks/wdt/msgid.json +6 -0
- package/rulepacks/wdt/rules.json +6 -0
- package/rulepacks/wdt/wd-driver-sleep.js +6 -0
- package/rulepacks/wdt/wd-xpath.js +6 -0
- package/rules/jaf/jaf-css-diagnose.js +1 -1
- package/rules/jaf/jaf-html-diagnose.js +1 -1
- package/rules/jaf/jaf-init-schema.js +1 -1
- package/rules/jaf/jaf-js-diagnose.js +1 -1
- package/rules/jaf/jaf-ts-diagnose.js +1 -1
- package/rules/jaf/jaf-ts-walk.js +6 -0
- package/rules/jaf/msgid.json +2 -2
- package/rules/jaf/rules.json +2 -2
- package/rules/jet/helpers/acc-aria-label.js +1 -1
- package/rules/jet/helpers/bp-checkPropType.js +1 -1
- package/rules/jet/helpers/cssHelper.js +1 -1
- package/rules/jet/helpers/extractStylesFromClass.js +1 -1
- package/rules/jet/helpers/has-slot-name.js +2 -2
- package/rules/jet/helpers/has-slot.js +1 -1
- package/rules/jet/helpers/json-prop-pos.js +1 -1
- package/rules/jet/helpers/json-propname-pos.js +1 -1
- package/rules/jet/helpers/style-selector.js +1 -1
- package/rules/jet/helpers/valid-attr.js +1 -1
- package/rules/jet/helpers/vartrack.js +1 -1
- package/rules/jet/jet-css-ojselector.js +1 -1
- package/rules/jet/msgid.json +2 -2
- package/rules/jet/oj-acc-aria-labelledby.js +1 -1
- package/rules/jet/oj-acc-aria-prop.js +2 -2
- package/rules/jet/oj-acc-avatar-aria-role.js +2 -2
- package/rules/jet/oj-acc-combobox-aria-label.js +2 -2
- package/rules/jet/oj-acc-film-strip-aria-label.js +2 -2
- package/rules/jet/oj-acc-input-aria-label.js +2 -2
- package/rules/jet/oj-acc-select-aria-label.js +2 -2
- package/rules/jet/oj-cca-compjson-bp-ar.js +1 -1
- package/rules/jet/oj-cca-compjson-bp-dsplyname.js +1 -1
- package/rules/jet/oj-cca-compjson-bp-jetver.js +1 -1
- package/rules/jet/oj-cca-compjson-bp-obj.js +1 -1
- package/rules/jet/oj-cca-compjson-ns-reg.js +1 -1
- package/rules/jet/oj-css-bp-border-color.js +1 -1
- package/rules/jet/oj-css-bp-dir-flow.js +1 -1
- package/rules/jet/oj-css-bp-float.js +1 -1
- package/rules/jet/oj-css-bp-textalign.js +1 -1
- package/rules/jet/oj-css-style-abs-units.js +2 -2
- package/rules/jet/oj-css-style-bp-color.js +1 -1
- package/rules/jet/oj-css-style-bp-display.js +1 -1
- package/rules/jet/oj-css-style-bp-font-family.js +1 -1
- package/rules/jet/oj-css-style-bp-font.js +1 -1
- package/rules/jet/oj-css-style-deprecated.js +1 -1
- package/rules/jet/oj-css-style-override.js +2 -2
- package/rules/jet/oj-css-var-override.js +1 -1
- package/rules/jet/oj-form-maxcols.js +2 -2
- package/rules/jet/oj-html-5-attr-obs.js +1 -1
- package/rules/jet/oj-html-5-tag-obs.js +1 -1
- package/rules/jet/oj-html-alta-deprecated.js +6 -0
- package/rules/jet/oj-html-attr-$unique.js +1 -1
- package/rules/jet/oj-html-attr-2def.js +1 -1
- package/rules/jet/oj-html-attr-json.js +1 -1
- package/rules/jet/oj-html-attr-prefix-expr.js +1 -1
- package/rules/jet/oj-html-attr-prefix-ro.js +1 -1
- package/rules/jet/oj-html-attr-req.js +1 -1
- package/rules/jet/oj-html-bindforeach-data.js +2 -2
- package/rules/jet/oj-html-bindif-test.js +2 -2
- package/rules/jet/oj-html-binding-attr.js +2 -2
- package/rules/jet/oj-html-cca-count.js +1 -1
- package/rules/jet/oj-html-cca-tagname.js +2 -2
- package/rules/jet/oj-html-cdn.js +1 -1
- package/rules/jet/oj-html-combo-converter.js +1 -1
- package/rules/jet/oj-html-cspexpr.js +1 -1
- package/rules/jet/oj-html-databind-all.js +1 -1
- package/rules/jet/oj-html-dlg-title.js +2 -2
- package/rules/jet/oj-html-file-pick-accept.js +2 -2
- package/rules/jet/oj-html-form-bindif.js +1 -1
- package/rules/jet/oj-html-form-layout-maxcols.js +2 -2
- package/rules/jet/oj-html-form-noflex.js +1 -1
- package/rules/jet/oj-html-input-isodate.js +2 -2
- package/rules/jet/oj-html-invalid-doctype.js +2 -2
- package/rules/jet/oj-html-jq-databind.js +2 -2
- package/rules/jet/oj-html-ko-comment.js +1 -1
- package/rules/jet/oj-html-ko-databind.js +2 -2
- package/rules/jet/oj-html-label-for-prefix.js +1 -1
- package/rules/jet/oj-html-missing-doctype.js +1 -1
- package/rules/jet/oj-html-msgs-cat-text.js +6 -0
- package/rules/jet/oj-html-no-style-tag.js +6 -0
- package/rules/jet/oj-html-notag-style.js +6 -0
- package/rules/jet/oj-html-oj-lib.js +1 -1
- package/rules/jet/oj-html-ojattr-520.js +1 -1
- package/rules/jet/oj-html-ojattr-deprecated.js +2 -2
- package/rules/jet/oj-html-ojattr-enum-deprecated.js +2 -2
- package/rules/jet/oj-html-ojattr-evt-syntax.js +2 -2
- package/rules/jet/oj-html-ojattr-value.js +1 -1
- package/rules/jet/oj-html-ojattr.js +2 -2
- package/rules/jet/oj-html-ojevent.js +2 -2
- package/rules/jet/oj-html-ojslot.js +2 -2
- package/rules/jet/oj-html-ojstyle.js +1 -1
- package/rules/jet/oj-html-ojtag-datacmd.js +2 -2
- package/rules/jet/oj-html-ojtag-datactx.js +1 -1
- package/rules/jet/oj-html-ojtag-deprecated.js +2 -2
- package/rules/jet/oj-html-ojtag-globattr-noprefix.js +2 -2
- package/rules/jet/oj-html-ojtag-id.js +1 -1
- package/rules/jet/oj-html-ojtag-nonglobattr-prefix.js +2 -2
- package/rules/jet/oj-html-ojtag-ns.js +1 -1
- package/rules/jet/oj-html-picker-attrs.js +2 -2
- package/rules/jet/oj-html-redwood-cssnovars.js +1 -1
- package/rules/jet/oj-html-redwood-cssvars.js +1 -1
- package/rules/jet/oj-html-self-close.js +1 -1
- package/rules/jet/oj-html-slot-item-minmax.js +1 -1
- package/rules/jet/oj-html-slot-name.js +2 -2
- package/rules/jet/oj-html-slot-pref-content.js +2 -2
- package/rules/jet/oj-html-style-abs-units.js +1 -1
- package/rules/jet/oj-html-style-bp-color.js +1 -1
- package/rules/jet/oj-html-style-bp-display.js +1 -1
- package/rules/jet/oj-html-style-bp-font-family.js +1 -1
- package/rules/jet/oj-html-style-bp-font.js +1 -1
- package/rules/jet/oj-html-style-deprecated.js +2 -2
- package/rules/jet/oj-html-style.js +1 -1
- package/rules/jet/oj-html-stylesel.js +1 -1
- package/rules/jet/oj-html-tag-attr-noprefix.js +2 -2
- package/rules/jet/oj-html-template-index.js +2 -2
- package/rules/jet/oj-html-unsup-theme.js +1 -1
- package/rules/jet/oj-html-wctag-$props.js +1 -1
- package/rules/jet/oj-html-wctag-arialabelledby.js +1 -1
- package/rules/jet/oj-html-wctag-for.js +1 -1
- package/rules/jet/oj-html-wctag-id.js +2 -2
- package/rules/jet/oj-html-wctag-nested.js +6 -0
- package/rules/jet/oj-html-wctag-packprivate.js +1 -1
- package/rules/jet/oj-js-comp-attr-deprecated.js +2 -2
- package/rules/jet/oj-js-comp-meth-deprecated.js +2 -2
- package/rules/jet/oj-js-no-ext-final.js +1 -1
- package/rules/jet/oj-js-noconsole.js +1 -1
- package/rules/jet/oj-js-ojcomp-deprecated.js +2 -2
- package/rules/jet/oj-js-ojcomp-exist.js +1 -1
- package/rules/jet/oj-js-ojcomp-new.js +1 -1
- package/rules/jet/oj-js-poly-promise.js +1 -1
- package/rules/jet/oj-js-var-undef.js +1 -1
- package/rules/jet/oj-json-syntax.js +1 -1
- package/rules/jet/oj-ts-comp-attr-deprecated.js +2 -2
- package/rules/jet/oj-ts-comp-meth-deprecated.js +2 -2
- package/rules/jet/oj-ts-no-ext-final.js +1 -1
- package/rules/jet/oj-ts-noconsole.js +1 -1
- package/rules/jet/oj-ts-ojcomp-deprecated.js +2 -2
- package/rules/jet/oj-ts-ojcomp-exist.js +1 -1
- package/rules/jet/oj-ts-ojcomp-new.js +1 -1
- package/rules/jet/oj-ts-poly-promise.js +1 -1
- package/rules/jet/rules.json +2 -2
- package/schema/component-schema.json +14 -1
- package/src/JafCore.js +2 -2
- package/types/index.d.ts +122 -82
- package/lib/imanual.js +0 -6
- package/lib/xmanual.js +0 -6
- package/rulepacks/jetwc-lib/component-audit-utils.js +0 -6
package/lib/colors.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright (c) 2018,
|
|
2
|
+
* Copyright (c) 2018, 2022, Oracle and/or its affiliates.
|
|
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 _nop(s){return s}function _fRed(s){return _set(_color.RED,s)}function _fBrightRed(s){return _set(_color.BRIGHTRED,s)}function _fGreen(s){return _set(_color.GREEN,s)}function _fBrightGreen(s){return _set(_color.BRIGHTGREEN,s)}function _fBlue(s){return _set(_color.BLUE,s)}function _fBrightBlue(s){return _set(_color.BLUE,s)}function _fCyan(s){return _set(_color.CYAN,s)}function _fBrightCyan(s){return _set(_color.BRIGHTCYAN,s)}function _fYellow(s){return _set(_color.YELLOW,s)}function _fBrightYellow(s){return _set(_color.BRIGHTYELLOW,s)}function _fPink(s){return _set(_color.PINK,s)}function _fWhite(s){return _set(_color.WHITE,s)};function _fWhiteOnBlue(s){return _set(_color.WHITEONBLUE,s)};function _fWhiteOnRed(s){return _set(_color.WHITEONRED,s)};function _fBlackOnRed(s){return _set(_color.BLACKONRED,s)};const _color={BLACK:"30m",RED:"31m",BRIGHTRED:"91m",GREEN:"32m",BRIGHTGREEN:"92m",YELLOW:"33m",BRIGHTYELLOW:"93m",BLUE:"34m",BRIGHTBLUE:"94m",PURPLE:"35m",PINK:"95m",CYAN:"36m",BRIGHTCYAN:"96m",WHITE:"37m",WHITEONBLUE:"104m",WHITEONRED:"101m",BLACKONRED:"101;30m"};const START="\x1B[";const RESET="\x1B[0m";function _set(c,s){return c?START+c+s+RESET:s};module.exports={enabled:true,isColor:function(){return this.enabled},enable:function(b){if(b&&!this.enabled){this.RED=_fRed;this.BRIGHTRED=_fBrightRed;this.GREEN=_fGreen;this.BRIGHTGREEN=_fBrightGreen;this.BLUE=_fBlue;this.BRIGHTBLUE=_fBrightBlue;this.CYAN=_fCyan;this.BRIGHTCYAN=_fBrightCyan;this.PINK=_fPink;this.YELLOW=_fYellow;this.BRIGHTYELLOW=_fBrightYellow;this.WHITEONBLUE=_fWhiteOnBlue;this.WHITEONRED=_fWhiteOnRed;this.BLACKONRED=_fBlackOnRed}else if(this.enabled){this.RED=_nop;this.BRIGHTRED=_nop;this.GREEN=_nop;this.BRIGHTGREEN=_nop;this.BLUE=_nop;this.BRIGHTBLUE=_nop;this.CYAN=_nop;this.BRIGHTCYAN=_nop;this.PINK=_nop;this.YELLOW=_nop;this.BRIGHTYELLOW=_nop;this.WHITEONBLUE=_nop;this.WHITEONRED=_nop;this.BLACKONRED=_nop}this.enabled=b},RED:_fRed,BRIGHTRED:_fBrightRed,GREEN:_fGreen,BRIGHTGREEN:_fBrightGreen,BLUE:_fBlue,BRIGHTBLUE:_fBrightBlue,CYAN:_fCyan,BRIGHTCYAN:_fBrightCyan,PINK:_fPink,YELLOW:_fYellow,BRIGHTYELLOW:_fBrightYellow,WHITE:_fWhite,WHITEONBLUE:_fWhiteOnBlue,WHITEONRED:_fWhiteOnRed,BLACKONRED:_fBlackOnRed};
|
package/lib/defaults.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2018, 2022, Oracle and/or its affiliates.
|
|
3
|
+
* Licensed under The Universal Permissive License (UPL), Version 1.0
|
|
4
|
+
* as shown at https://oss.oracle.com/licenses/upl/
|
|
5
|
+
*/
|
|
6
|
+
const defaults={JETVER:'12.0.1'.replace(/(\d*\.\d*)(\.\d*)+$/g,'$1')+'.0',THEME:'Alta',ECMAVER:11};module.exports=defaults;
|
package/lib/deflist.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2018, 2022, Oracle and/or its affiliates.
|
|
3
|
+
* Licensed under The Universal Permissive License (UPL), Version 1.0
|
|
4
|
+
* as shown at https://oss.oracle.com/licenses/upl/
|
|
5
|
+
*/
|
|
6
|
+
const defs=require("./defaults");const indent=" ";function _show(nd){var _clr=nd.colors;var s="\n"+_clr.BRIGHTGREEN("--- Default JAF Values ---")+"\n\n"+`${indent}${_clr.BRIGHTYELLOW("? jetVer ")}: ${_clr.CYAN(`${defs.JETVER}`)}\n`+`${indent}${_clr.BRIGHTYELLOW("? theme ")}: ${_clr.CYAN("'Redwood' if jetVer >= 12.0.0, else 'Alta'")}\n`+`${indent}${_clr.BRIGHTYELLOW("? ecmaVer ")}: ${_clr.CYAN(`${defs.ECMAVER}`)}\n\n`+`${indent}${_clr.BRIGHTYELLOW("? builtinJetRules ")}: ${_clr.CYAN(`true`)}\n`+`${indent}${_clr.BRIGHTYELLOW("? severity ")}: ${_clr.CYAN("'all'")}\n`+`${indent}${_clr.BRIGHTYELLOW("? groups ")}: ${_clr.CYAN("'all'")}\n`+`${indent}${_clr.BRIGHTYELLOW("? base ")}: ${_clr.CYAN("location of configuration file")}\n`+`${indent}${_clr.BRIGHTYELLOW("? files ")}: ${_clr.CYAN(".html files in the 'base' directory")}\n`+`${indent}${_clr.BRIGHTYELLOW("? format ")}: ${_clr.CYAN("`prose'")}\n`+`${indent}${_clr.BRIGHTYELLOW("? comments ")}: ${_clr.CYAN("false")}\n`+`${indent}${_clr.BRIGHTYELLOW("? followLinks ")}: ${_clr.CYAN("true")}\n`+`${indent}${_clr.BRIGHTYELLOW("? tempDir ")}: ${_clr.CYAN("the current working directory")}\n`;console.log(s)};module.exports.showList=_show;
|
package/lib/dislist.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2018, 2022, Oracle and/or its affiliates.
|
|
3
|
+
* Licensed under The Universal Permissive License (UPL), Version 1.0
|
|
4
|
+
* as shown at https://oss.oracle.com/licenses/upl/
|
|
5
|
+
*/
|
|
6
|
+
var _color;function show(nd,arg,msgCtx){var packs;_init(nd);if(packs=nd.builtinpacks.getPackMetadata(nd,msgCtx)){let prefixes=nd.builtinpacks.getPrefixes();arg=arg?arg.toLowerCase():arg;for(let pack of prefixes){if(!arg||arg===pack)_display(packs[pack])}}};function _display(pack){var rules,rule,opts,oos,summary=[];console.log(`\n\n${_color.BRIGHTRED("\u25CF")} ${_color.CYAN("Pack")} ${_color.BRIGHTRED(`${pack.prefix}`)} ${_color.CYAN(" - Rules disabled by default")}`);rules=pack.rules;for(rule in rules){opts=rules[rule];oos=opts.hasOwnProperty("inservice")&&!opts.inservice;if(oos||opts.hasOwnProperty("enabled")&&!opts.enabled){summary.push(rule+(oos?"_":""))}}if(summary.length){summary=summary.sort()}else{console.log(_color.BRIGHTYELLOW(`● None - all enabled.`));return}for(rule of summary){oos=rule.endsWith("_");rule=oos?rule.substring(0,rule.length-1):rule;console.log(_color.BRIGHTYELLOW(`● ${rule}`)+_color.RED(`${oos?" (out of service)":""}`))}};function _init(nd){_color=nd.colors};module.exports.show=show;
|
package/lib/exportRules.js
CHANGED
package/lib/extends.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright (c) 2018,
|
|
2
|
+
* Copyright (c) 2018, 2022, Oracle and/or its affiliates.
|
|
3
3
|
* Licensed under The Universal Permissive License (UPL), Version 1.0
|
|
4
4
|
* as shown at https://oss.oracle.com/licenses/upl/
|
|
5
5
|
*/
|
|
6
|
-
const TSCONFIG="tsconfig.json";const MERGEABLE_BY_DEFAULT={components:true,componentUrls:true,exclude:true,files:true,groups:true,message:true,nameSpaces:true,options:true,ruleMods:true,ruleNames:true,rulePacks:true,tokens:true};const MERGEABLE_BY_OPTION={};const EXOPT_IGNORE="ignore";const EXOPT_MERGE="merge";const MSG={OBJ:"Config '%s' is not an object - %p",ARRAY:"Config '%s' is not an array - %p",STR_OR_AR_STR:"Config '%s' is not a string or an array of strings - %p",AR_OBJ:"Config '%s' is not an array of objects - %p",AR_STR:"Config '%s' is not an array of strings - %p",AR_STR_OBJ:"Config '%s' is not an array of strings or objects - %p",EXT_OPT:"Config 'extendOptions.%s' cannot be 'merge' - %p",EXT_OPT_VAL:"Config 'extendOptions.%s' not 'ignore' or 'merge' - %p",UNKNOWN:"Unknown config prop - '%s' - %p"};const REPL_PROP="%s";const REPL_PATH="%p";class Extends{constructor(configLib,configInst,cfg,path,nd,msgCtx,utils){this._path=path;this._cfg=cfg;this._fp=cfg.base;this._nd=nd;this._msgCtx=msgCtx;this._utils=utils;this._cwd=nd.process.cwd();this._cfgLib=configLib;this._cfgInst=configInst;this._stack=[];this._extendOpts=null;this._error=msgCtx.error;this._info=msgCtx.info;this._mergeHandlers={components:this._mergePropComponents.bind(this),componentUrls:this._mergePropCompUrls.bind(this),exclude:this._mergePropExclude.bind(this),files:this._mergePropFiles.bind(this),groups:this._mergePropGroups.bind(this),messages:this._mergePropMessages,nameSpaces:this._mergePropNameSpaces.bind(this),options:this._mergePropOptions.bind(this),ruleMods:this._mergePropRuleMods,ruleNames:this._mergePropRuleNames.bind(this),rulePacks:this._mergePropRulePacks,tokens:this._mergePropTokens.bind(this)}}extend(){var debug;if(debug=this._cfg.options&&(this._cfg.options.verbose||this._cfg.options.debug)){this._msgCtx.info("[Info]: Merging configurations...","I",true)}if(!this._createStack()){return null}if(debug){this._dumpStack()}if(!this._isError){this._checkMergePropTypes()}if(this._isError){return null}if(!this._stack.length){return this._cfg}return this._mergeStack()}_createStack(cfg,fp){var json,fp,first,o;if(first=!cfg){cfg=this._cfg;fp=this._path?this._path:this._fp}else{fp=cfg.extends}if(!fp){return true}if(first){json=cfg}else{fp=this._getAbsolutePath(fp);if(!this._nd.fsUtils.fileExists(fp)){this._error(`Configuration file not found : ${fp}`);return false}if(this._isCircular(fp)){this._error(`Circular configuration 'extends' detected : ${fp}`);return false}try{json=this._nd.fs.readFileSync(fp,"utf8");json=this._nd.decomment(json);json=this._preprocessRawJson(json,fp);if(!json){return false}o=this._utils.parseJson(json,false);if(o.msg){this._error(`Config 'extends' error : ${o.msg} : ${fp}`);return false}else{json=o.obj}}catch(e){this._error(`Error reading 'extends' config : ${fp}`);return false}}this._stack.push({path:fp,cfg:json});if(json.extends){if(!this._createStack(json,json.extends)){return false}}return true}_preprocessRawJson(txt,fp){var json=this._cfgInst.processIncludes(txt,fp);if(this._cfgInst.isOk()){json=this._cfgInst.processTokens(json);if(this._cfgInst.isOk()){}}return this._cfgInst.isOk()?json:null}_mergeStack(){if(!this._fixupPaths()){return null}for(let i=this._stack.length-1;i>0;i--){if(!this._mergePair(this._stack[i-1],this._stack[i])){return null}}if(this._isMergeProp("files")){if(this._stack[0].cfg.hasOwnProperty("files")){this._stack[0].cfg.files=_removeDupes(this._stack[0].cfg.files)}}if(this._isMergeProp("exclude")){if(this._stack[0].cfg.hasOwnProperty("exclude")){this._stack[0].cfg.exclude=_removeDupes(this._stack[0].cfg.exclude)}}return this._stack[0].cfg}_mergePair(parSE,chSE){var props,parent,child,merger,ret=true;parent=parSE.cfg;child=chSE.cfg;this._extendOpts=parSE.cfg.extendOptions||{};props=Object.keys(child);props.forEach(prop=>{if(prop.startsWith("_")||prop==="base"||prop==="extends"||prop==="tokens"||this._extendOpts[prop]===EXOPT_IGNORE){return}if(!parent.hasOwnProperty(prop)){parent[prop]=child[prop];return}if(!this._isMergeProp(prop)){return}if(merger=this._mergeHandlers[prop]){if(!merger(parSE,chSE)){ret=false}}});if(!ret){return ret}this._msgCtx.info(`[Info]: Inherited config '${chSE.path}'`,"I",true);return true}_checkMergePropTypes(){var cfg,se,prop,prop2,val;for(let i=0;i<this._stack.length;i++){se=this._stack[i];cfg=se.cfg;if(!this._cfgLib.checkPropNames(cfg,se.path)){this._isError=true}if(cfg.extendOptions){if(this._utils.isObject(cfg.extendOptions)){this._extendOpts=cfg.extendOptions;for(prop in this._extendOpts){val=this._extendOpts[prop];if(val===EXOPT_MERGE&&!MERGEABLE_BY_OPTION[prop]){this._emitErrorMsg(MSG.EXT_OPT,prop,se.path);return}else if(val!==EXOPT_MERGE&&val!==EXOPT_IGNORE){this._emitErrorMsg(MSG.EXT_OPT_VAL,prop,se.path);return}}}else{this._emitErrorMsg(MSG.OBJ,"extendOptions",se.path);return}}else{this._extendOpts={}}for(prop in cfg){if(!this._isMergeProp(prop)){continue}val=cfg[prop];if(prop==="components"||prop==="componentUrls"){if(typeof val!=="string"&&!Array.isArray(val)||!this._utils.isArrayContentsType(val,"string")){this._emitErrorMsg(MSG.STR_OR_AR_STR,prop,se.path)}}else if(prop==="files"){if(!Array.isArray(val)){this._emitErrorMsg(prop,prop,se.path)}if(!this._utils.isArrayContentsType(val,["string","object"])){this._emitErrorMsg(MSG.AR_STR_OBJ,prop,se.path)}}else if(prop==="exclude"){if(!Array.isArray(val)||!this._utils.isArrayContentsType(val,"string")){this._emitErrorMsg(MSG.STR_OR_AR_STR,prop,se.path)}}else if(prop==="groups"){if(!Array.isArray(val)){this._emitErrorMsg(MSG.STR,prop,se.path)}}else if(prop==="messages"){if(!this._utils.isObject(val)){this._emitErrorMsg(MSG.OBJ,prop,se.path)}if(se.messages.reject){if(!Array.isArray(se.messages.reject)){this._emitErrorMsg(MSG.OBJ,"messages.reject",se.path)}}if(se.messages.accept){if(!Array.isArray(se.messages.accept)){this._emitErrorMsg(MSG.OBJ,"messages.accept",se.path)}}}else if(prop==="nameSpaces"){if(!Array.isArray(val)){this._emitErrorMsg(MSG.AR_STR,prop,se.path)}}else if(prop==="options"){if(!this._utils.isObject(val)){this._emitErrorMsg(MSG.OBJ,prop,se.path)}}else if(prop==="ruleMods"){if(!this._utils.isObject(val)){this._emitErrorMsg(MSG.OBJ,prop,se.path);continue}for(prop2 in val){if(prop2==="enable"||prop2==="disable"){if(!Array.isArray(val[prop2])){this._emitErrorMsg(MSG.AR_OBJ,prop2==="enable"?"ruleMods.enable":"ruleMods.disable",se.path)}}else{if(!this._utils.isObject(val[prop2])){this._emitErrorMsg(MSG.AR_OBJ,prop+"."+prop2,se.path)}}}}else if(prop==="ruleNames"){if(!Array.isArray(val)||!this._utils.isArrayContentsType(val,"string")){this._emitErrorMsg(MSG.AR_STR,prop,se.path)}}else if(prop==="rulePacks"){if(!Array.isArray(val)||!this._utils.isArrayContentsType(val,"object")){this._emitErrorMsg(MSG.AR_OBJ,prop,se.path)}}else if(prop==="sevMap"){if(!this._utils.isObject(val)){this._emitErrorMsg(MSG.OBJ,prop,se.path)}if(val.sevMsg&&!this._utils.isObject(val.sevMsg)){this._emitErrorMsg(MSG.OBJ,prop+".sevMsg",se.path)}if(val.sevSet&&!this._utils.isObject(val.sevSet)){this._emitErrorMsg(MSG.OBJ,prop+".sevSet",se.path)}}else if(prop==="tokens"){if(!this._utils.isObject(val)){this._emitErrorMsg(MSG.OBJ,prop,se.path)}}else{this._error(`JAF ERROR: unhandled 'extends' property '${prop}' - ${se.path}`);this._isError=true}}}}_fixupPaths(){var se,ret=true;for(let i=this._stack.length-1;i>=0;i--){se=this._stack[i];if(!(this._cleanBase(se)&&this._fixupConfig(se))){ret=false;break}}return ret}_cleanBase(se){var src,ft;var nd=this._nd;src=se.cfg.base;if(src==="$jafcwd"){src=this._cwd}else{if(!src){src=this._nd.path.dirname(se.path)}src=nd.path.normalize(src);if(!nd.path.isAbsolute(src)){src=nd.path.join(nd.path.dirname(se.path),src)}ft=nd.fsUtils.getFileType(src);if(ft!=="d"){this._msgCtx.error(`Config file 'base' is not a directory - '${src}' in ${se.path}`);return false}}se.cfg.base=src;this._info(`[Info]: Using config base '${src}' in ${se.path}`,"I");return true}_fixupConfig(se){var nd,cfg,src,dir,ft,i;nd=this._nd;cfg=se.cfg;if(cfg.files){if(!this._cfgLib.validateFileList(cfg.files)){this._bErrors=true;return}if(src=se.cfg.files){for(i=0;i<src.length;i++){if(!src[i].startsWith("http")){src[i]=nd.path.normalize(src[i]);src[i]=nd.path.resolve(cfg.base,src[i])}}}}if(cfg.exclude){if(!this._cfgLib.validateFileList(cfg.exclude)){this._bErrors=true;return}if(src=cfg.exclude){for(i=0;i<src.length;i++){src[i]=nd.path.normalize(src[i]);src[i]=nd.path.resolve(cfg.base,src[i])}}}src=cfg.components;if(src){for(i=0;i<src.length;i++){dir=nd.path.normalize(src[i]);dir=nd.path.resolve(cfg.base,dir);cfg.components[i]=dir}}src=cfg.outPath;if(src&&src!=="$noout"){src=nd.path.normalize(src);src=nd.path.resolve(cfg.base,src);cfg.outPath=src}src=cfg.rulePacks;if(src){for(i=0;i<src.length;i++){dir=src[i].path;dir=nd.path.normalize(dir);src[i].path=nd.path.resolve(cfg.base,dir);if(src[i].path.endsWith(".zip")){continue}ft=nd.fsUtils.getFileType(src[i].path);if(ft!=="d"){this._error("'rulePacks (entry "+(i+1)+"): path' is not a directory - \""+src[i].path+"\"");this._bErrors=true}}}src=cfg.tsconfig;if(src&&typeof src==="string"){dir=nd.path.normalize(src);dir=nd.path.resolve(cfg.base,dir);if(dir.endsWith(TSCONFIG)){dir=nd.path.dirname(dir)}src=this._loadTsConfig(nd.path.join(dir,TSCONFIG));if(src){cfg.tsconfig=dir;this._tsconfig=src}else{this._bErrors=true}}if(this._bErrors){this._error(`Errors found in inherited config '${se.path}'`)}return!this._bErrors}_getAbsolutePath(fp){if(this._nd.path.isAbsolute(fp)){return fp}let p=this._nd.path.join(this._cfg.base,fp);if(!this._nd.path.isAbsolute(p)){p=this._nd.path.join(this._dir,p)}return p}_isCircular(fp){var ret;for(let i=0;i<this._stack.length;i++){if(this._stack[i].path===fp){ret=true;break}}return ret}_isMergeProp(p){return MERGEABLE_BY_DEFAULT[p]||this._extendOpts[p]===EXOPT_MERGE}_mergePropFiles(parSE,chSE){return this._mergePropFilesExclude(parSE,chSE,"files")}_mergePropExclude(parSE,chSE){return this._mergePropFilesExclude(parSE,chSE,"exclude")}_mergePropFilesExclude(parSE,chSE,prop){var parent,child,ch,i;var parent=parSE.cfg[prop];var child=chSE.cfg[prop];for(i=0;i<child.length;i++){ch=child[i];if(!parent.includes(ch)){parent.push(ch)}}return true}_mergePropOptions(parSE,chSE){return this._mergeObjects(parSE,chSE,"options")}_mergePropGroups(parSE,chSE){return this._mergeArrays(parSE,chSE,"groups")}_mergePropTokens(parSE,chSE){return this._mergeObjects(parSE,chSE,"tokens")}_mergePropNameSpaces(parSE,chSE){return this._mergeArrays(parSE,chSE,"nameSpaces")}_mergePropRuleMods(parSE,chSE){var parent,child,pname,parPack,rule,rval,prval,i;var parent=parSE.cfg.ruleMods;var child=chSE.cfg.ruleMods;for(pname in child){rval=child[pname];if(!parent[pname]){parent[pname]=rval;continue}if(pname==="enable"||pname==="disable"){prval=parent[pname];for(i=0;i<rval.length;i++){if(!prval.includes(rval[i])){prval.push(rval[i])}}continue}parPack=parent[pname];for(rule in rval){if(!parPack[rule]){parPack[rule]=rval[rule]}}}return true}_mergePropRuleNames(parSE,chSE){return this._mergeArrays(parSE,chSE,"ruleNames")}_mergePropRulePacks(parSE,chSE){var parent=parSE.cfg.rulePacks;var child=chSE.cfg.rulePacks;for(let i=0;i<child.length;i++){let ch=child[i];let b=false;for(let j=0;j<parent.length;j++){let par=parent[j];if(ch.path===par.path){b=true;break}}if(!b){parent.push(ch)}}return true}_mergePropMessages(parSE,chSE){var parent=parSE.cfg.messages;var child=chSE.cfg.messages;var parReject=parent.reject;var chReject=child.reject;if(!parReject&&chReject){parent.reject=chReject}else if(parReject&&chReject){parent.reject=_removeDupes(parReject.concat(chReject))}var parAccept=parent.accept;var chAccept=child.accept;if(!parAccept&&chAccept){parent.accept=chAccept}else if(parAccept&&chAccept){parent.accept=_removeDupes(parAccept.concat(chAccept))}return true}_mergePropComponents(parSE,chSE){return this._mergeArrays(parSE,chSE,"components")}_mergePropCompUrls(parSE,chSE){return this._mergeArrays(parSE,chSE,"componentUrls")}_mergeObjects(parSE,chSE,prop){var parent,child;parent=parSE.cfg[prop];child=chSE.cfg[prop];for(let prop in child){if(!parent.hasOwnProperty[prop]){parent[prop]=child[prop]}}return true}_mergeArrays(parSE,chSE,prop){var parent,child,isPS,isCS,isPA,isCA,val;parent=parSE.cfg[prop];child=chSE.cfg[prop];isPS=typeof parent==="string";isCS=typeof child==="string";if(isPS&&isCS&&parent===child){return}isPA=Array.isArray(parent);isCA=Array.isArray(child);parent=isPA?parent:[parent];child=isCA?child:[child];for(let i=0;i<child.length;i++){val=child[i];if(!parent.includes(val)){parent.push(val)}}return true}_emitErrorMsg(s,prop,path){var s=s||MSG.UNKNOWN;if(prop){s=s.replace(REPL_PROP,prop)}this._error(s.replace(REPL_PATH,path));this._isError=true}_parseError(msg){this._parseError=msg}_dumpStack(){this._msgCtx.info("[Info]: Config 'extends' stack","I",true);for(let i=0;i<this._stack.length;i++){this._msgCtx.info(`[Info]: ${this._stack[i].path}`,"I",true)}}}function _removeDupes(ar){return Array.isArray(ar)?ar.filter((val,x)=>ar.indexOf(val)===x):ar};module.exports=Extends;
|
|
6
|
+
const TSCONFIG="tsconfig.json";const MERGEABLE_BY_DEFAULT={components:true,componentUrls:true,exclude:true,files:true,groups:true,message:true,nameSpaces:true,options:true,ruleMods:true,ruleNames:true,rulePacks:true,typescript:true};const MERGEABLE_BY_OPTION={};const EXOPT_IGNORE="ignore";const EXOPT_MERGE="merge";const MSG={OBJ:"Config '%s' is not an object - %p",ARRAY:"Config '%s' is not an array - %p",STR:"Config '%s' is not a string - %p",STR_OR_AR_STR:"Config '%s' is not a string or an array of strings - %p",AR_OBJ:"Config '%s' is not an array of objects - %p",AR_STR:"Config '%s' is not an array of strings - %p",AR_STR_OBJ:"Config '%s' is not an array of strings or objects - %p",BOOL:"Config '%s' is not a boolean - %p",EXT_OPT:"Config 'extendOptions.%s' cannot be 'merge' - %p",EXT_OPT_VAL:"Config 'extendOptions.%s' not 'ignore' or 'merge' - %p",UNKNOWN:"Unknown config prop - '%s' - %p"};const REPL_PROP="%s";const REPL_PATH="%p";class Extends{constructor(configLib,configInst,cfg,path,nd,msgCtx,utils){this._path=path;this._cfg=cfg;this._fp=cfg.base;this._nd=nd;this._msgCtx=msgCtx;this._utils=utils;this._cwd=nd.process.cwd();this._cfgLib=configLib;this._cfgInst=configInst;this._stack=[];this._extendOpts=null;this._error=msgCtx.error;this._info=msgCtx.info;this._mergeHandlers={components:this._mergePropComponents.bind(this),componentUrls:this._mergePropCompUrls.bind(this),exclude:this._mergePropExclude.bind(this),files:this._mergePropFiles.bind(this),groups:this._mergePropGroups.bind(this),messages:this._mergePropMessages,nameSpaces:this._mergePropNameSpaces.bind(this),options:this._mergePropOptions.bind(this),ruleMods:this._mergePropRuleMods,ruleNames:this._mergePropRuleNames.bind(this),rulePacks:this._mergePropRulePacks,typescript:this._mergePropTypescript.bind(this)}}extend(){var debug;if(debug=this._cfg.options&&(this._cfg.options.verbose||this._cfg.options.debug)){this._msgCtx.info("[Info]: Merging configurations...","I",true)}if(!this._createStack()){return null}if(debug){this._dumpStack()}if(!this._isError){this._checkMergePropTypes()}if(this._isError){return null}if(!this._stack.length){return this._cfg}return this._mergeStack()}_createStack(cfg,fp){var json,fp,first,o;if(first=!cfg){cfg=this._cfg;fp=this._path?this._path:this._fp}else{fp=cfg.extends}if(!fp){return true}if(first){json=cfg}else{fp=this._getAbsolutePath(fp);if(!this._nd.fsUtils.fileExists(fp)){this._error(`Configuration file not found : ${fp}`);return false}if(this._isCircular(fp)){this._error(`Circular configuration 'extends' detected : ${fp}`);return false}try{json=this._nd.fs.readFileSync(fp,"utf8");json=this._nd.decomment(json);json=this._preprocessRawJson(json,fp);if(!json){return false}o=this._utils.parseJson(json,false);if(o.msg){this._error(`Config 'extends' error : ${o.msg} : ${fp}`);return false}else{json=o.obj}}catch(e){this._error(`Error reading 'extends' config : ${fp}`);return false}}this._stack.push({path:fp,cfg:json});if(json.extends){if(!this._createStack(json,json.extends)){return false}}return true}_preprocessRawJson(txt,fp){var json=this._cfgInst.processIncludes(txt,fp);if(this._cfgInst.isOk()){json=this._cfgInst.processTokens(json);if(this._cfgInst.isOk()){}}return this._cfgInst.isOk()?json:null}_mergeStack(){if(!this._fixupPaths()){return null}for(let i=this._stack.length-1;i>0;i--){if(!this._mergePair(this._stack[i-1],this._stack[i])){return null}}if(this._isMergeProp("files")){if(this._stack[0].cfg.hasOwnProperty("files")){this._stack[0].cfg.files=_removeDupes(this._stack[0].cfg.files)}}if(this._isMergeProp("exclude")){if(this._stack[0].cfg.hasOwnProperty("exclude")){this._stack[0].cfg.exclude=_removeDupes(this._stack[0].cfg.exclude)}}return this._stack[0].cfg}_mergePair(parSE,chSE){var props,parent,child,merger,ret=true;parent=parSE.cfg;child=chSE.cfg;this._extendOpts=parSE.cfg.extendOptions||{};props=Object.keys(child);props.forEach(prop=>{if(prop.startsWith("_")||prop==="base"||prop==="extends"||prop==="tokens"||this._extendOpts[prop]===EXOPT_IGNORE){return}if(!parent.hasOwnProperty(prop)){parent[prop]=child[prop];return}if(!this._isMergeProp(prop)){return}if(merger=this._mergeHandlers[prop]){if(!merger(parSE,chSE)){ret=false}}});if(!ret){return ret}this._msgCtx.info(`[Info]: Inherited config '${chSE.path}'`,"I",true);return true}_checkMergePropTypes(){var cfg,se,prop,prop2,val;for(let i=0;i<this._stack.length;i++){se=this._stack[i];cfg=se.cfg;if(!this._cfgLib.checkPropNames(cfg,se.path)){this._isError=true}if(cfg.extendOptions){if(this._utils.isObject(cfg.extendOptions)){this._extendOpts=cfg.extendOptions;for(prop in this._extendOpts){val=this._extendOpts[prop];if(val===EXOPT_MERGE&&!MERGEABLE_BY_OPTION[prop]){this._emitErrorMsg(MSG.EXT_OPT,prop,se.path);return}else if(val!==EXOPT_MERGE&&val!==EXOPT_IGNORE){this._emitErrorMsg(MSG.EXT_OPT_VAL,prop,se.path);return}}}else{this._emitErrorMsg(MSG.OBJ,"extendOptions",se.path);return}}else{this._extendOpts={}}for(prop in cfg){if(!this._isMergeProp(prop)){continue}val=cfg[prop];if(prop==="components"||prop==="componentUrls"){if(typeof val!=="string"&&!Array.isArray(val)||!this._utils.isArrayContentsType(val,"string")){this._emitErrorMsg(MSG.STR_OR_AR_STR,prop,se.path)}}else if(prop==="files"){if(!Array.isArray(val)){this._emitErrorMsg(prop,prop,se.path)}if(!this._utils.isArrayContentsType(val,["string","object"])){this._emitErrorMsg(MSG.AR_STR_OBJ,prop,se.path)}}else if(prop==="exclude"){if(!Array.isArray(val)||!this._utils.isArrayContentsType(val,"string")){this._emitErrorMsg(MSG.STR_OR_AR_STR,prop,se.path)}}else if(prop==="groups"){if(!Array.isArray(val)){this._emitErrorMsg(MSG.STR,prop,se.path)}}else if(prop==="messages"){if(!this._utils.isObject(val)){this._emitErrorMsg(MSG.OBJ,prop,se.path)}if(se.messages.reject){if(!Array.isArray(se.messages.reject)){this._emitErrorMsg(MSG.OBJ,"messages.reject",se.path)}}if(se.messages.accept){if(!Array.isArray(se.messages.accept)){this._emitErrorMsg(MSG.OBJ,"messages.accept",se.path)}}}else if(prop==="nameSpaces"){if(!Array.isArray(val)){this._emitErrorMsg(MSG.AR_STR,prop,se.path)}}else if(prop==="options"){if(!this._utils.isObject(val)){this._emitErrorMsg(MSG.OBJ,prop,se.path)}}else if(prop==="ruleMods"){if(!this._utils.isObject(val)){this._emitErrorMsg(MSG.OBJ,prop,se.path);continue}for(prop2 in val){if(prop2==="enable"||prop2==="disable"){if(!Array.isArray(val[prop2])){this._emitErrorMsg(MSG.AR_OBJ,prop2==="enable"?"ruleMods.enable":"ruleMods.disable",se.path)}}else{if(!this._utils.isObject(val[prop2])){this._emitErrorMsg(MSG.AR_OBJ,prop+"."+prop2,se.path)}}}}else if(prop==="ruleNames"){if(!Array.isArray(val)||!this._utils.isArrayContentsType(val,"string")){this._emitErrorMsg(MSG.AR_STR,prop,se.path)}}else if(prop==="rulePacks"){if(!Array.isArray(val)||!this._utils.isArrayContentsType(val,"object")){this._emitErrorMsg(MSG.AR_OBJ,prop,se.path)}}else if(prop==="sevMap"){if(!this._utils.isObject(val)){this._emitErrorMsg(MSG.OBJ,prop,se.path)}if(val.sevMsg&&!this._utils.isObject(val.sevMsg)){this._emitErrorMsg(MSG.OBJ,prop+".sevMsg",se.path)}if(val.sevSet&&!this._utils.isObject(val.sevSet)){this._emitErrorMsg(MSG.OBJ,prop+".sevSet",se.path)}}else if(prop==="tokens"){if(!this._utils.isObject(val)){this._emitErrorMsg(MSG.OBJ,prop,se.path)}}else if(prop==="typescript"){if(!this._utils.isObject(val)){this._emitErrorMsg(MSG.OBJ,prop,se.path)}for(prop2 in val){if(prop2==="tsconfig"&&typeof val[prop2]!=="string"){this._emitErrorMsg(MSG.STR,"typescript.tsconfig",se.path)}if(prop2==="compile"&&typeof val[prop2]!=="boolean"){this._emitErrorMsg(MSG.BOOL,"typescript.compile",se.path)}}}else{this._error(`JAF ERROR: unhandled 'extends' property '${prop}' - ${se.path}`);this._isError=true}}}}_fixupPaths(){var se,ret=true;for(let i=this._stack.length-1;i>=0;i--){se=this._stack[i];if(!(this._cleanBase(se)&&this._fixupConfig(se))){ret=false;break}}return ret}_cleanBase(se){var src,ft;var nd=this._nd;src=se.cfg.base;if(src==="$jafcwd"){src=this._cwd}else{if(!src){src=this._nd.path.dirname(se.path)}src=nd.path.normalize(src);if(!nd.path.isAbsolute(src)){src=nd.path.join(nd.path.dirname(se.path),src)}ft=nd.fsUtils.getFileType(src);if(ft!=="d"){this._msgCtx.error(`Config file 'base' is not a directory - '${src}' in ${se.path}`);return false}}se.cfg.base=src;this._info(`[Info]: Using config base '${src}' in ${se.path}`,"I");return true}_fixupConfig(se){var nd,cfg,src,dir,ft,i;nd=this._nd;cfg=se.cfg;if(cfg.files){if(!this._cfgLib.validateFileList(cfg.files)){this._bErrors=true;return}if(src=se.cfg.files){for(i=0;i<src.length;i++){if(!src[i].startsWith("http")){src[i]=nd.path.normalize(src[i]);src[i]=nd.path.resolve(cfg.base,src[i])}}}}if(cfg.exclude){if(!this._cfgLib.validateFileList(cfg.exclude)){this._bErrors=true;return}if(src=cfg.exclude){for(i=0;i<src.length;i++){src[i]=nd.path.normalize(src[i]);src[i]=nd.path.resolve(cfg.base,src[i])}}}src=cfg.components;if(src){for(i=0;i<src.length;i++){dir=nd.path.normalize(src[i]);dir=nd.path.resolve(cfg.base,dir);cfg.components[i]=dir}}src=cfg.outPath;if(src&&src!=="$noout"){src=nd.path.normalize(src);src=nd.path.resolve(cfg.base,src);cfg.outPath=src}src=cfg.rulePacks;if(src){for(i=0;i<src.length;i++){dir=src[i].path;dir=nd.path.normalize(dir);src[i].path=nd.path.resolve(cfg.base,dir);if(src[i].path.endsWith(".zip")){continue}ft=nd.fsUtils.getFileType(src[i].path);if(ft!=="d"){this._error("'rulePacks (entry "+(i+1)+"): path' is not a directory - \""+src[i].path+"\"");this._bErrors=true}}}if(cfg.typescript&&cfg.typescript.tsconfig){src=cfg.typescript.tsconfig;if(src&&typeof src==="string"){if(!nd.path.isAbsolute(src)){dir=nd.path.normalize(src);dir=nd.path.resolve(cfg.base,dir)}else{dir=src}if(!dir.endsWith(TSCONFIG)){dir=nd.path.join(dir,TSCONFIG)}cfg.typescript.tsconfig=dir}}if(this._bErrors){this._error(`Errors found in inherited config '${se.path}'`)}return!this._bErrors}_getAbsolutePath(fp){if(this._nd.path.isAbsolute(fp)){return fp}let p=this._nd.path.join(this._cfg.base,fp);if(!this._nd.path.isAbsolute(p)){p=this._nd.path.join(this._dir,p)}return p}_isCircular(fp){var ret;for(let i=0;i<this._stack.length;i++){if(this._stack[i].path===fp){ret=true;break}}return ret}_isMergeProp(p){return MERGEABLE_BY_DEFAULT[p]||this._extendOpts[p]===EXOPT_MERGE}_mergePropFiles(parSE,chSE){return this._mergePropFilesExclude(parSE,chSE,"files")}_mergePropExclude(parSE,chSE){return this._mergePropFilesExclude(parSE,chSE,"exclude")}_mergePropFilesExclude(parSE,chSE,prop){var parent,child,ch,i;var parent=parSE.cfg[prop];var child=chSE.cfg[prop];for(i=0;i<child.length;i++){ch=child[i];if(!parent.includes(ch)){parent.push(ch)}}return true}_mergePropOptions(parSE,chSE){return this._mergeObjects(parSE,chSE,"options")}_mergePropGroups(parSE,chSE){return this._mergeArrays(parSE,chSE,"groups")}_mergePropTokens(parSE,chSE){return this._mergeObjects(parSE,chSE,"tokens")}_mergePropNameSpaces(parSE,chSE){return this._mergeArrays(parSE,chSE,"nameSpaces")}_mergePropRuleMods(parSE,chSE){var parent,child,pname,parPack,rule,rval,prval,i;var parent=parSE.cfg.ruleMods;var child=chSE.cfg.ruleMods;for(pname in child){rval=child[pname];if(!parent[pname]){parent[pname]=rval;continue}if(pname==="enable"||pname==="disable"){prval=parent[pname];for(i=0;i<rval.length;i++){if(!prval.includes(rval[i])){prval.push(rval[i])}}continue}parPack=parent[pname];for(rule in rval){if(!parPack[rule]){parPack[rule]=rval[rule]}}}return true}_mergePropRuleNames(parSE,chSE){return this._mergeArrays(parSE,chSE,"ruleNames")}_mergePropRulePacks(parSE,chSE){var parent=parSE.cfg.rulePacks;var child=chSE.cfg.rulePacks;for(let i=0;i<child.length;i++){let ch=child[i];let b=false;for(let j=0;j<parent.length;j++){let par=parent[j];if(ch.path===par.path){b=true;break}}if(!b){parent.push(ch)}}return true}_mergePropMessages(parSE,chSE){var parent=parSE.cfg.messages;var child=chSE.cfg.messages;var parReject=parent.reject;var chReject=child.reject;if(!parReject&&chReject){parent.reject=chReject}else if(parReject&&chReject){parent.reject=_removeDupes(parReject.concat(chReject))}var parAccept=parent.accept;var chAccept=child.accept;if(!parAccept&&chAccept){parent.accept=chAccept}else if(parAccept&&chAccept){parent.accept=_removeDupes(parAccept.concat(chAccept))}return true}_mergePropComponents(parSE,chSE){return this._mergeArrays(parSE,chSE,"components")}_mergePropCompUrls(parSE,chSE){return this._mergeArrays(parSE,chSE,"componentUrls")}_mergePropTypescript(parSE,chSE){return this._mergeObjects(parSE,chSE,"typescript")}_mergeObjects(parSE,chSE,prop){var parent,child;parent=parSE.cfg[prop];child=chSE.cfg[prop];for(let prop in child){if(!parent.hasOwnProperty(prop)){parent[prop]=child[prop]}}return true}_mergeArrays(parSE,chSE,prop){var parent,child,isPS,isCS,isPA,isCA,val;parent=parSE.cfg[prop];child=chSE.cfg[prop];isPS=typeof parent==="string";isCS=typeof child==="string";if(isPS&&isCS&&parent===child){return}isPA=Array.isArray(parent);isCA=Array.isArray(child);parent=isPA?parent:[parent];child=isCA?child:[child];for(let i=0;i<child.length;i++){val=child[i];if(!parent.includes(val)){parent.push(val)}}return true}_emitErrorMsg(s,prop,path){var s=s||MSG.UNKNOWN;if(prop){s=s.replace(REPL_PROP,prop)}this._error(s.replace(REPL_PATH,path));this._isError=true}_parseError(msg){this._parseError=msg}_dumpStack(){this._msgCtx.info("[Info]: Config 'extends' stack","I",true);for(let i=0;i<this._stack.length;i++){this._msgCtx.info(`[Info]: ${this._stack[i].path}`,"I",true)}}}function _removeDupes(ar){return Array.isArray(ar)?ar.filter((val,x)=>ar.indexOf(val)===x):ar};module.exports=Extends;
|
package/lib/filetypes.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright (c) 2018,
|
|
2
|
+
* Copyright (c) 2018, 2022, Oracle and/or its affiliates.
|
|
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,zip:true};const _OBJ_FILETYPES={html:true,css:true,js:true,ts:true,tsx:true,json:true};const _ZIP_FILETYPES={html:true,css:true,js:true,ts:true,tsx:true,json: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.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"};
|
package/lib/grouplist.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2018, 2022, Oracle and/or its affiliates.
|
|
3
|
+
* Licensed under The Universal Permissive License (UPL), Version 1.0
|
|
4
|
+
* as shown at https://oss.oracle.com/licenses/upl/
|
|
5
|
+
*/
|
|
6
|
+
var _color;function showBuiltinGroups(nd,arg,msgCtx){var packs;_init(nd);if(packs=nd.builtinpacks.getPackMetadata(nd,msgCtx)){let prefixes=nd.builtinpacks.getPrefixes();for(let pack of prefixes){if(!arg||arg===pack){_display(packs[pack],true)}}}};function showExternalGroups(packs,arg,nd){var pack,isExternal;_init(nd);if(arg){arg=arg.toLowerCase()}for(pack of packs){if(!pack.builtin){if(!arg||arg===pack.prefix.toLowerCase()){_display(pack);isExternal=true}}}if(!isExternal){console.log(_color.BRIGHTRED(" No external rule packs declared!"))}};function _display(pack,isBuiltin){var rules,rule,opts,summary={},oos=[],dis=[],groups,group,msg;if(isBuiltin){_title(pack);rules=pack.rules;for(rule in rules){opts=rules[rule];if(!(groups=opts.group)){continue};if(typeof groups==="string"){groups=[groups]}for(group of groups){if(!summary[group]){summary[group]=[]}summary[group].push(rule)}if(opts.hasOwnProperty("inservice")&&!opts.inservice){oos.push(rule)}else{if(opts.hasOwnProperty("enabled")&&!opts.enabled){dis.push(rule)}}}groups=Object.keys(summary);groups=groups.sort()}else{_title(pack);if(pack.groupMap){summary=pack.groupMap;groups=Object.keys(pack.groupMap);groups=groups.sort()}}if(!groups){console.log(_color.BRIGHTYELLOW(`● No groups`));return}for(group of groups){console.log(_color.BRIGHTYELLOW(`● ${group}:`));rules=summary[group];for(rule of rules){msg=` ${rule}`;if(oos.includes(rule)){msg+=_color.RED(" (out of service)")}else if(dis.includes(rule)){msg+=_color.RED(" (disabled by default)")}console.log(msg)}}};function _title(pack){console.log(`\n\n${_color.BRIGHTRED("\u25CF")} ${_color.CYAN("Pack")} ${_color.BRIGHTRED(`${pack.prefix}`)} ${_color.CYAN(" - Group Rule Membership")}`)};function _init(nd){_color=nd.colors};module.exports.showBuiltinGroups=showBuiltinGroups;module.exports.showExternalGroups=showExternalGroups;
|
package/lib/groups.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright (c) 2018,
|
|
2
|
+
* Copyright (c) 2018, 2022, Oracle and/or its affiliates.
|
|
3
3
|
* Licensed under The Universal Permissive License (UPL), Version 1.0
|
|
4
4
|
* as shown at https://oss.oracle.com/licenses/upl/
|
|
5
5
|
*/
|
|
6
|
-
const _GROUPS={all:true,'jet-html':true,'jet-css':true,'jet-js':true,'jet-ts':true,'jet-tsx':true,'jet-json':true,'jet-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,html5:true};module.exports.isGroup=g=>{return _GROUPS[g]};
|
|
6
|
+
const _GROUPS={all:true,'jet-html':true,'jet-css':true,'jet-js':true,'jet-ts':true,'jet-tsx':true,'jet-json':true,'jet-md':true,'jet-aria':true,'jet-deprecated':true,'jet-deleted':true,'jet-override':true,'jet-cca':true,'jet-spoc':true,'jet-csp':true,'jet-demo':true,'jet-bp':true,'jet-perf':true,html5:true};module.exports.isGroup=g=>{return _GROUPS[g]};
|
package/lib/help.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright (c) 2018,
|
|
2
|
+
* Copyright (c) 2018, 2022, Oracle and/or its affiliates.
|
|
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: [flags] [ files/directory space separated list]
|
|
6
|
+
const FLAGS=["\n Command line: %ojaf [flags] [ files/directory space separated list]%\n","\n Audit related flags:\n"," ~--config~ or ^-c^ : %followed by filepath to configuration file. If%"," %omitted, current directory is used.%"," ~--base~ or ^-b^ : %followed by filepath used to resolve relative paths. If%"," %omitted, current directory is used.%"," ~--jetver~ or ^-jv^ : %sets the JET version - must be followed by a version number x[.y[.z]]%"," ~--format~ or ^-t^ : %followed by output format 'prose' | 'json' | 'line'%"," ~--outPath~ or ^-o^ : %followed by output file path%"," ~--noout~ or ^-no^ : %do not write to output file path%"," ~--severity~ or ^-s^ : %report on this rule severity only%"," ~--groups~ or ^-g^ : %followed by group(s)%"," ~--groups=~ or ^-g=^ : %followed by group(s)%"," ~--followlinks~ or ^-fl^ : %follow stylesheet/script links%"," ~--nofollowlinks~ or ^-nfl^ : %do not follow stylesheet/script links%"," ~--extra~ or ^-e^ : %verbose - show extra details%"," ~--retcode~ or ^-rc^ : %followed by 'auto' | 'errors' | number, to override return code%"," ~--retcode=~ or ^-rc=^ : %followed by 'auto' | 'errors' | number, to override return code%"," ~--msgid~ or ^-id^ : %show audit message id's in the ouput if format 'prose'%"," ~--nocolor~ or ^-nc^ : %do not colorize output%"," ~--debug~ or ^-d^ : %debug mode%","\n Immediate command flags - display JAF info or scaffold files (no auditing involved)\n"," ~--help~ or ^-h^ : %show this help%"," ~--help~ or ^-h^ : %followed by messageID | rulename : show rule description%"," ~--version~ or ^-v^ : %show the ojaf version%"," ~--jetlist~ or ^-jl^ : %show the supported JET versions%"," ~--nslist~ or ^-nsl^ : %show the supported registered Namespaces%"," ~--grouplist~ or ^-gl^ : %show built-in rules by group. May be followed by an%"," %optional pack prefix.%"," ~--xgrouplist~ or ^-xgl^ : %show external pack rules by group. May be followed by an%"," %optional pack prefix.%"," ~--dislist~ or ^-dl^ : %show the JET built-in rules disabled by default. May be followed%"," %by an optional pack prefix.%"," ~--deflist~ or ^-def^ : %show the configuration default values.%"," ~--metahist~ or ^-mh^ : %show the renamed/deleted JET component history%\n"," ~--dac~ or ^-dac^ : %display active config and terminate (no audit performed)%"," ~--reg~ or ^-reg^ : %display rule listener types (debug)%"," ~--init~ or ^-i^ : %scaffold a JAF config file%"," ~--initrule~ or ^-ir^ : %followed by rulename (no file extension) - scaffold a rule file%\n"," ~--rules~ or ^-r^ : %display rule information%"," ~--rulessonar~ or ^-rs^ : %display rule information - sonar format%"," ~--rulesjson~ or ^-rj^ : %display rule information - json format%"," ~--dryrun~ or ^-dr^ : %dry run - show setup and files that would have been audited (no%"," %audit performed)%","\n1) Command line args override corresponding properties in the configuration file.","2) Command flags are case independent."];module.exports=function(fnShowVersion,color,msgContext){var console=msgContext.console;var by=color.BRIGHTYELLOW;var cy=color.CYAN;var x1,x2,x3,x4,x5,x6,msg;fnShowVersion();FLAGS.forEach(s=>{msg="";if((x1=s.indexOf("~"))>=0){x2=s.indexOf("~",x1+1);msg=s.substring(0,x1)+by(s.substring(x1+1,x2));if((x3=s.indexOf("^",x2+1))>=0){x4=s.indexOf("^",x3+1);msg+=s.substring(x2+1,x3)+by(s.substring(x3+1,x4));if((x5=s.indexOf("%",x4+1))>=0){x6=s.indexOf("%",x5+1);msg+=s.substring(x4+1,x5)+cy(s.substring(x5+1,x6))+s.substring(x6+1)}else{msg+=s.substring(x4+1)}}else{msg+=s.substring(x2+1)}}else if((x5=s.indexOf("%"))>=0){x6=s.indexOf("%",x5+1);msg+=s.substring(0,x5)+cy(s.substring(x5+1,x6))+s.substring(x6+1)}else{msg=s}console(msg)})};
|
package/lib/jetver.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright (c) 2018,
|
|
2
|
+
* Copyright (c) 2018, 2022, Oracle and/or its affiliates.
|
|
3
3
|
* Licensed under The Universal Permissive License (UPL), Version 1.0
|
|
4
4
|
* as shown at https://oss.oracle.com/licenses/upl/
|
|
5
5
|
*/
|
|
6
|
-
const verList=require("../meta/metaverlist.json");const SUP="\xB9";var verData;var
|
|
6
|
+
const verList=require("../meta/metaverlist.json");const DEFAULTS=require("./defaults");const SUP="\xB9";var verData;var nd;function init(nodeDeps){nd=nodeDeps;if(!verData){let o=verList.metaList,o2={},v,s;for(s in o){v=o[s];o2[v.version]={date:v.date,time:v.time}}verData={metaList:o2}}};function showList(){let keys,ver,a,built,isDefVer,list=verData.metaList,indent=" \u2022 ";let sup=nd.colors.BRIGHTYELLOW(SUP);keys=Object.keys(list).sort(function(a,b){var va=a.split(".");var vb=b.split(".");va.forEach(function(v,i,a){a[i]=parseInt(v)});vb.forEach(function(v,i,a){a[i]=parseInt(v)});if(va[0]>vb[0]){return 1}if(va[0]<vb[0]){return-1}if(va[1]>vb[1]){return 1}if(va[1]<vb[1]){return-1}if(va[2]>vb[2]){return 1}if(va[2]<vb[2]){return-1}return 0}).reverse();console.log("\n"+" JET versions supported:");keys.forEach(function(verName){ver=list[verName];a=verName.split(".");a.forEach(function(s,x){a[x]=parseInt(s)});if(a[0]<10){verName=" "+verName}built=" ("+ver.date+" "+ver.time+")";if(isDefVer=verName===DEFAULTS.JETVER){let def=" Default";built+=nd.colors.BRIGHTYELLOW(def)+sup}verName=isDefVer?nd.colors.BRIGHTYELLOW(verName):nd.colors.CYAN(verName);console.log(indent+verName+built)});let footnote="Default config 'jetVer' value if not specified.";footnote=nd.colors.BRIGHTYELLOW(footnote);console.log(`\n${sup} ${footnote}`)};function validate(v){var a;var i;if(v===null){return _getMVError(v,1)}if(typeof v!=="string"){return _getMVError(v,2)}a=v.split(".");for(i=0;i<a.length;i++){if(a[i]===""||parseInt(a[i])===NaN){return _getMVError(v,3)}}return null};function getBestVersion(v,a){return _findVer(v,a)}function _findVer(v,a){var keys=Object.keys(verData.metaList);var suspects=[];var s,i,ret;if(!Array.isArray(a)){a=v.split(".")}if(a.length===3&&a[2]==="0"){a.length=2}if(a.length===2){s=a[0]+"."+a[1]+".";for(i=0;i<keys.length;i++){if(keys[i].startsWith(s)){suspects.push(keys[i])}}}else if(a.length===1){s=a[0]+".";for(i=0;i<keys.length;i++){if(keys[i].startsWith(s)){suspects.push(keys[i])}}}if(suspects.length===1){return suspects[0]}if(!suspects.length){return null}ret="0.0.0";for(i=0;i<suspects.length;i++){if(suspects[i]>ret){ret=suspects[i]}}return ret};function getVersions(){return verData.metaList};function _getMVError(v,errno){var s;switch(errno){case 1:s="missing version arg after --jetver";break;case 2:s="--jetver '"+v+"' : invalid - expected major.minor.patch";break;case 3:s="--jetver '"+v+"' : invalid version specification";break;default:s="unknown error";}return s};module.exports.init=init;module.exports.validate=validate;module.exports.getVersions=getVersions;module.exports.getBestVersion=getBestVersion;module.exports.showList=showList;
|
package/lib/macros.js
CHANGED
package/lib/manual.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2018, 2022, Oracle and/or its affiliates.
|
|
3
|
+
* Licensed under The Universal Permissive License (UPL), Version 1.0
|
|
4
|
+
* as shown at https://oss.oracle.com/licenses/upl/
|
|
5
|
+
*/
|
|
6
|
+
var PREFIX;var RP_PREFIX;const RULES_JSON="rules.json";const MSGID_JSON="msgid.json";const JS=".js";const RE_WS=/^\s*$/;const RE_MARKUP=/<[^>]*>/g;const RE_MULTI_BLANKS=/\s{2,}/g;const EMPTY="";const LINELEN=100;const LIST_INDENT=2;var _nd;var _error;var _path;var _rDir;var _rpDir;var _isMsgId;var _prefix;var _msgNum;var _rawArg;var _sev;var _multiIDs=[];var _color;function showBuiltinMsgHelp(nd,arg,msgCtx){var rc;_init(nd,msgCtx);rc=_initArg(arg);return rc>0?_processBuiltin():rc===0};function showExternalMsgHelp(rules,manCheckL,manCheckS,nd,msgCtx){var check,temp,isShort,o,x,ret=false;_init(nd,msgCtx);check=manCheckL||manCheckS;if(check){temp=check.toLowerCase();x=temp.indexOf("-");check=x>=0?temp.substring(0,x):"";check=check.toUpperCase()+temp.substring(x);isShort=!!manCheckS;if(rules.getRSIByRuleName(temp)>=0){o=rules.getRuleDescriptionEx(null,temp,isShort)}else{o=rules.getRuleDescriptionEx(check,null,isShort)}if(o&&o.descrip){_display(o)}else{msgCtx.error(`Unable to locate '${temp}' via the configuration file.`)}ret=true}return ret};function _processBuiltin(){var meta;_rDir=_path.join(__dirname,"../rules");_rpDir=_path.join(__dirname,"../rulepacks");if(!(meta=_loadRuleMetadata())){return true}return _isMsgId?_processMsgId(meta):_processRuleName(meta)};function _processMsgId(meta){var mjson=meta.mjson;var rname,r,x;for(r in mjson){if(_msgNum===mjson[r]){rname=r;break}}if(!rname){_error(`No rule found for message ID ${_prefix}-${_msgNum}.`);return true}x=rname.indexOf("_");if(x>=0){rname=rname.substring(0,x)}return _displayIt(rname,_prefix,meta)};function _processRuleName(meta){var rname,rjson,r;rname=_rawArg.toLowerCase();rjson=meta.rjson.rules;for(r in rjson){if(r===rname){return _displayIt(rname,_prefix,meta)}}_error(`Rule ${rname} is not a core rule`);return!rname.startsWith("oj-")};function _displayIt(rname,prefix,meta){var rule,r,mjson,rjson,prefix;mjson=meta.mjson;for(r in mjson){if(r.startsWith(rname)){_multiIDs.push(mjson[r])}}rjson=meta.rjson;for(r in rjson.rules){if(r===rname){_sev=rjson.rules[r].severity;break}}_sev=_sev||"unknown";if(rule=_loadRule(rname,meta)){let o={descrip:rule.getDescription(),rule:rname,prefix:prefix,sev:_sev,idList:_multiIDs};_display(o);return true}return false};function _loadRule(rname,meta){var rule,ruleJS,fp;try{fp=_nd.path.join(meta.rdir,rname+JS);ruleJS=_nd.ruleLoader(fp);if(ruleJS.prototype||!ruleJS.getName){try{rule=new ruleJS}catch(e){_error(`Failed to instantiate rule ${rname}`)}}else{rule=ruleJS}return rule}catch(e){_error(`Failed to load rule ${rname}`)}};function _loadRuleMetadata(){var meta,fp;fp=RP_PREFIX.includes(_prefix)?_nd.path.join(_rpDir,_prefix):_nd.path.join(_rDir,_prefix);meta=_loadRulesJson(fp);return meta};function _loadRulesJson(dir){var rjson,mjson,fp;fp=_nd.path.join(dir,RULES_JSON);if(_nd.fsUtils.fileExists(fp)){rjson=_nd.jsonLoader.load(fp,_nd,m=>{_error(m)},true,_nd.utils)}else{_error(`Internal error: rule manifest for ${_prefix} not found`);return false}fp=_nd.path.join(dir,MSGID_JSON);if(_nd.fsUtils.fileExists(fp)){mjson=_nd.jsonLoader.load(fp,_nd,m=>{_error(m)},true,_nd.utils)}else{if(!RP_PREFIX.includes(_prefix)){_error(`Internal error: rule message ID manifest for ${_prefix} not found`);return false}}if(rjson){return{rjson:rjson,mjson:mjson,rdir:dir}}};function _init(nd,msgCtx){_nd=nd;_error=msgCtx.error;_path=nd.path;_color=nd.colors;PREFIX=nd.builtinpacks.getPrefixes();RP_PREFIX=nd.builtinpacks.getRulepackFolderPrefixes()};function _initArg(arg){var x;_rawArg=arg;arg=arg.toLowerCase();x=arg.indexOf("-");if(x<0){if(!isNaN(parseInt(arg))){arg="jet-"+arg;x=3}else{_error("Expected a message ID or rulename to follow --help");return 0}}_prefix=arg.substring(0,x);_msgNum=arg.substring(x+1);x=parseInt(_msgNum);_isMsgId=!isNaN(x);if(_isMsgId){if(_msgNum.length<4){_msgNum="0".repeat(4-_msgNum.length)+_msgNum}}else{_msgNum=null;if(arg.startsWith("oj-")){_prefix="jet"}}if(PREFIX.includes(_prefix)){return 1}return-1};var first;function _display(o){var lines,line,s,s1,s2,s3;var list,temp,indent;var multiSev=o.idList.length>1;s=_color.BRIGHTGREEN("Rule: ");s1=_color.BRIGHTGREEN("Severity: ");s2=_color.BRIGHTGREEN("Message ID");s3=_color.BRIGHTYELLOW("\xB9");line="\n"+s+_color.BRIGHTYELLOW(o.rule)+" "+s1+_color.BRIGHTYELLOW(o.sev)+(multiSev?s3:EMPTY)+" "+s2+(multiSev?"'s":EMPTY)+": "+o.prefix+"-"+o.idList.join(", ");console.log(line);s=_removeMarkup(o.descrip);s=_removeColorMarkup(s);indent=0;lines=s.split("\n");for(let i=0;i<lines.length;i++){line=lines[i];if(line.charAt(0)==="\x12"){list=true;temp=line.indexOf("/",1);indent=parseInt(line.substring(1,temp));line=line.substring(temp+1).trim();first=true}_displayLine(line,list,indent);if(list){if(line.indexOf("\x13")>=0){list=false;indent=0}}}if(multiSev){s="\n"+s3+_color.BRIGHTYELLOW(" Possibility of more than 1 severity since there are "+o.idList.length+" message ID's");console.log(s)}console.log("")};function _displayLine(s,list,indent){var line,c,x;var start=0;var end=LINELEN;while(end<s.length){x=_NL(s,start,end);if(x>=0){line=s.substring(start,x).trim();if(list){if(line.indexOf("\x13")>=0){indent=0}}line=_fixup(line);console.log((list?" ".repeat((first?0:indent)+LIST_INDENT):"")+_color.CYAN(line));first=false;start=x+1;end=start+LINELEN;continue}c=s.charAt(end);if(RE_WS.test(c)){line=s.substring(start,end).trim();line=_fixup(line);console.log((list?" ".repeat((first?0:indent)+LIST_INDENT):"")+_color.CYAN(line));first=false;start=end;end+=LINELEN;continue}else{end--}}if(start<end){line=s.substring(start,end).trim();line=_fixup(line);console.log((list?" ".repeat((first?0:indent)+LIST_INDENT):"")+_color.CYAN(line));first=false}};function _removeMarkup(s){s=s.replace(/<oj\-/g,"@@01").replace(/<\/oj\-/g,"@@02").replace(/<br>/g,"@@03").replace(/<p>/g,"@@03@@03").replace(/<b>/g,"@@04").replace(/<em>/g,"@@04").replace(/<i>/g,"@@05").replace(/<\/b>/g,"@@06").replace(/<\/em>/g,"@@06").replace(/<\/i>/g,"@@06").replace(/<div/g,"@@7").replace(/<\/div>/g,"@@8").replace(/<template>/g,"@@9").replace(/<\/template>/g,"@@10").replace(/<ol/g,"@@11").replace(/<\/ol>/g,"@@12").replace(/<ul/g,"@@13").replace(/<\/ul>/g,"@@14").replace(/<li/g,"@@15").replace(/<\/li>/g,"@@16").replace(/ /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>");if(!_nd.colors.isColor()){s=s.replace(/@@4/g,EMPTY).replace(/@@5/g,EMPTY).replace(/@@6/g,EMPTY)}return _handleLists(s)};function _removeColorMarkup(s){if(_nd.colors.isColor()){s=s.replace(/@@04/g,EMPTY).replace(/@@05/g,EMPTY).replace(/@@06/g,EMPTY)}return s.trim()};function _handleLists(s){var start,end,ordered,rep;while(true){ordered=false;if((start=s.indexOf("<ol>"))>=0){ordered=true}else{start=s.indexOf("<ul>")}if(start>=0){end=s.indexOf("</ol>",start);rep=_handleList(s,start,end,ordered);s=s.substring(0,start)+rep+s.substring(end+4)}else{break}}return s};function _handleList(s,start,end,ordered){var list,itemStart,itemEnd,count=0,sCount,rep="";list=s.substring(start+4,end).trim();itemEnd=0;while(true){if((itemStart=list.indexOf("<li>",itemEnd))>=0){itemEnd=list.indexOf("</li>",itemStart);sCount=(ordered?""+ ++count+")":"*")+" ";rep+="\n\n"+"\x12"+sCount.length+"/"+sCount+list.substring(itemStart+4,itemEnd).trimRight()+"\x13"}else{break}}return rep}function _fixup(s){return s.replace(/\x11/g," ")};function _NL(s,start,end){while(start<end){if(s.charAt(start)==="\n"){return start}start++}return-1};module.exports={showBuiltinMsgHelp,showExternalMsgHelp};
|
package/lib/metaLoader.js
CHANGED
package/lib/metahist.js
CHANGED
package/lib/msgidLoader.js
CHANGED
package/lib/ns.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright (c) 2018,
|
|
2
|
+
* Copyright (c) 2018, 2022, Oracle and/or its affiliates.
|
|
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-adp","oj-approvals","oj-bi","oj-bi-sac","oj-cgbu","oj-cgm","oj-communities","oj-core","oj-cp","oj-cso","oj-cx","oj-cx-ap","oj-cx-cg","oj-cx-dcs","oj-cx-fsvc","oj-cx-hd","oj-cx-iss","oj-cx-km","oj-cx-
|
|
6
|
+
const _ns=["oj-acx","oj-acx-assets","oj-adp","oj-approvals","oj-av","oj-bi","oj-bi-sac","oj-cegbu","oj-cegbu-scp","oj-cgbu","oj-cgm","oj-communities","oj-core","oj-cp","oj-cso","oj-cx","oj-cx-ap","oj-cx-cg","oj-cx-dcs","oj-cx-fsvc","oj-cx-hd","oj-cx-iss","oj-cx-km","oj-cx-km-agent","oj-cx-marketing","oj-cx-ma","oj-cx-mc","oj-cx-ol","oj-cx-svc","oj-cxi","oj-cxm","oj-dbt","oj-dcs","oj-doceng","oj-ee","oj-em","oj-epm","oj-fa","oj-faw","oj-fa-fin","oj-fnd","oj-fom","oj-fsgbu","oj-fsgbu-demo","oj-fwk","oj-gbu","oj-gbu-comp","oj-gcs","oj-hcm","oj-hed","oj-hsgbu","oj-hsp","oj-hsp-common","oj-hsp-cruise","oj-hsp-hdp","oj-hsp-ohip","oj-hsp-opera","oj-ia","oj-i18n","oj-idaas","oj-ips","oj-j4s","oj-jv","oj-lux","oj-lx","oj-mca","oj-mcps","oj-oa","oj-oac","oj-oal","oj-oal-ni","oj-oal-ux","oj-oax","oj-ob","oj-oc","oj-oce","oj-oda","oj-oda-chat","oj-odcs","oj-odcs-oit","oj-odps","oj-ofsc","oj-ohi","oj-oic","oj-oit","oj-ofs","oj-ol","oj-omc","oj-omnichannel","oj-opa","oj-opaas","oj-opac","oj-pa","oj-psc","oj-prmt","oj-psm","oj-ref","oj-rgbu","oj-rgbu-jraf","oj-scs","oj-sp","oj-spatial","oj-spectra","oj-svc","oj-ux","oj-vb","oj-vb-sample","oj-vbdt","oj","oj-cc","oj-dynamic","oj-ext","oj-sample","oj-sample-internal","ns","ns-ui","demo","my"];const _setNS=new Set(_ns);module.exports={has:function(k){return _setNS.has(k)},getKeys:function(){return[..._setNS]}};
|
package/lib/nslist.js
CHANGED
package/lib/outFormat.js
CHANGED
package/lib/outfile.js
CHANGED
package/lib/ruleLoader.js
CHANGED
package/lib/scaffold.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright (c) 2018,
|
|
2
|
+
* Copyright (c) 2018, 2022, Oracle and/or its affiliates.
|
|
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 DEFAULT_ECMAVER=11;const DEFAULT_THEME="Alta";const OJET_CONFIG="oraclejetconfig.json";const OJAF_CONFIG="oraclejafconfig.json";const OJAF_DEFAULT_CONFIG="jafconfig.json";const DEPENDENCIES_VER_PROP="@oracle/oraclejet";const EXCH_COMPS_FOLDER="jet_components";const COMPOSITES_FOLDER="jet-composites";const EXTENSION_FOLDER="extension";const RESOURCES_FOLDER="resources";const COMP_JSON="component.json";const PACKAGE_JSON="package.json";const TSCONFIG="tsconfig.json";const SUFFIX_HTML="/**/*.html";const SUFFIX_JS="/**/*.js";const SUFFIX_TS="/**/*.ts";const SUFFIX_CSS="/**/*.css";const SUFFIX_ALL="/**/*.*";const OJET_COMMENT="OJET Based Configuration";const NON_OJET_COMMENT="Default Configuration";const SLASHIFY=/\\\\|\\/g;var ojetCommon;var ojetComposites;var cwd,appCtx,nd,ojet,ojConfig,jafConfig,initDone;var md5;function init(cwdir,nodeDeps,appContext){if(!initDone){cwd=_fwdSlashify(cwdir);nd=nodeDeps;appCtx=appContext;ojet=isOJET();initDone=true}return ojet}function isOJET(){return initDone?!!ojConfig:nd.fsUtils.fileExists(nd.path.join(cwd,OJET_CONFIG))};function handleOjetConfig(isScaffold){var ojetPath,ojafPath,doUpdate=false,temp,hash,tsHash,tsc,defaultExists,error=false;ojetPath=nd.path.join(cwd,OJET_CONFIG);ojConfig=nd.jsonLoader.load(ojetPath,nd,function(errMsg){appCtx.error(errMsg);error=true},false,appCtx.utils);if(isScaffold){if(error){appCtx.error("Cannot continue with --init");return"error"}else if(ojConfig){appCtx.msg("Scaffolding JAF configuration in "+_getFolderName()+" ...")}else{appCtx.error("OJET CLI config not found - cannot continue with --init");return"error"}}ojafPath=nd.path.join(cwd,OJAF_CONFIG);if(nd.fsUtils.fileExists(ojafPath)){jafConfig=_readJAFConfig(ojafPath);if(jafConfig==="error"){return"error"}}if(isScaffold){defaultExists=_defaultConfigExists();if(jafConfig||defaultExists){appCtx.error("Pre-existing configuration found - '"+(defaultExists?OJAF_DEFAULT_CONFIG:OJAF_CONFIG)+"'");return"error"}}if(!isScaffold&&!ojConfig&&jafConfig){appCtx.warn("JAF Configuration '"+OJAF_CONFIG+"' found, but OJET configuration '"+OJET_CONFIG+"' no longer exists.\n")}if(ojConfig.paths){if(ojConfig.paths.source&&ojConfig.paths.source.common){ojetCommon="./"+ojConfig.paths.source.common;ojetComposites=ojetCommon+"/"+ojConfig.paths.source.javascript+"/"+COMPOSITES_FOLDER}}hash=_ojetFileChange(ojetPath,jafConfig);if(jafConfig){tsHash=_tsConfigChange(cwd,jafConfig)}if(jafConfig){if(hash||tsHash){if(jafConfig.ojet&&jafConfig.ojet.update){if(appCtx.verboseMode||appCtx.debugMode){appCtx.info(OJET_CONFIG+" change detected - updating "+OJAF_CONFIG)}jafConfig.files=_getFileSet();jafConfig.exclude=_getExcludes();jafConfig.components=_getComposites();tsc=_getTsConfig();if(tsc){jafConfig.tsconfig=tsc}else if(jafConfig.tsconfig){delete jafConfig.tsconfig}temp=_getJetVer();if(jafConfig.jetVer!==temp){jafConfig.jetVer=temp}temp=_getTheme();if(jafConfig.theme!==temp){jafConfig.theme=temp}if(!jafConfig.ojet){jafConfig.ojet={}}if(hash){jafConfig.ojet.md5=hash}if(typeof jafConfig.ojet.update!=="boolean"){jafConfig.ojet.update=true}if(typeof tsHash==="string"){jafConfig.ojet.tsmd5=tsHash}else if(tsHash&&jafConfig.ojet.tsmd5){delete jafConfig.ojet.tsmd5}doUpdate=true;_backupJAFConfig(ojafPath)}else{const changeMsg=" changes detected, but oraclejafconfig updates are disabled";if(hash){appCtx.warn(OJET_CONFIG+changeMsg)}if(tsHash){appCtx.warn(TSCONFIG+changeMsg)}}}}else if(isScaffold){jafConfig={base:"$jafcwd",files:_getFileSet(),exclude:_getExcludes(),components:_getComposites(),builtinJetRules:true,jetVer:_getJetVer(),ecmaVer:DEFAULT_ECMAVER,theme:_getTheme(),format:"prose",severity:"all",groups:["all"],options:{verbose:false,color:true},title:["+---------------------------------------------------------------------+","| OJET Application Audit |","+---------------------------------------------------------------------+","JAF $jafver - Jet $jetver : ($jafdate, $jaftime)\n"],ojet:{update:true,md5:hash}};tsc=_getTsConfig();if(tsc){jafConfig.tsconfig=tsc}if(tsHash){jafConfig.ojet.tsmd5=tsHash}doUpdate=true}if(doUpdate&&!_writeJAFConfig(OJAF_CONFIG,true)){appCtx.error("Failed to "+(isScaffold?"scaffold":"update")+" OJAF config '"+nd.path.join(cwd,OJAF_CONFIG)+"'");return"error"}if(isScaffold){scaffoldSuccessful(OJAF_CONFIG)}if(appCtx.debugMode){appCtx.debug("JAFConfig :\n"+JSON.stringify(jafConfig,null,3))}return jafConfig};function getOjetConfig(){return ojConfig}function _getFileSet(){var source,files;files=[];if(ojConfig&&ojConfig.paths){source=ojConfig.paths.source;if(source){files.push("./"+source.common+SUFFIX_HTML);if(source.javascript){files.push("./"+source.common+SUFFIX_JS)}if(source.typescript){files.push("./"+source.common+SUFFIX_TS)}files.push("./"+source.web+SUFFIX_HTML);if(source.javascript){files.push("./"+source.web+SUFFIX_JS)}if(source.typescript){files.push("./"+source.web+SUFFIX_TS)}files.push("./"+source.hybrid+SUFFIX_HTML);if(source.javascript){files.push("./"+source.hybrid+SUFFIX_JS)}if(source.typescript){files.push("./"+source.hybrid+SUFFIX_TS)}files.push("./"+source.common+"/"+source.styles+SUFFIX_CSS)}}files.push("./"+nd.path.join(ojetComposites,"**"+"/",COMP_JSON));return _fwdSlashify(files)};function createNonOjetConfig(){var oj;oj=_ojetJafConfigExists();if(oj||_defaultConfigExists()){appCtx.error("Default configuration '"+(oj?OJAF_CONFIG:OJAF_DEFAULT_CONFIG)+"' exists - terminating --init");return"'error"}jafConfig=_createDefault();setFileProps(jafConfig);if(!_writeJAFConfig(OJAF_DEFAULT_CONFIG,false)){appCtx.error("Failed to scaffold OJAF config '"+OJAF_DEFAULT_CONFIG+"'");return"error"}scaffoldSuccessful(OJAF_DEFAULT_CONFIG)};function _getExcludes(){var files=[],source;files.push("./"+nd.path.join(EXCH_COMPS_FOLDER,SUFFIX_ALL));if(ojetComposites){files.push("./"+nd.path.join(ojetComposites,"**"+"/"+EXTENSION_FOLDER,SUFFIX_ALL));files.push("./"+nd.path.join(ojetComposites,"**"+"/"+RESOURCES_FOLDER,SUFFIX_ALL))}if(ojConfig.paths&&ojConfig.paths.source){source=ojConfig.paths.source.common;if(source.tests){files.push("./"+source.tests+SUFFIX_HTML);files.push("./"+source.tests+SUFFIX_JS)}source=ojConfig.paths.source.common;files.push("./"+nd.path.join(source,"**"+"/"+"*-min.js"));files.push("./"+nd.path.join(source,"**"+"/"+"*-min.css"));files.push("./**/node_modules/**/*.*")}return _fwdSlashify(files)};function _getComposites(){var a=[],dir;if(ojetComposites){dir=nd.path.join(cwd,ojetComposites);if(nd.fsUtils.fileExists(dir,true)){a.push(ojetComposites)}}if(ojConfig.components){var c=_getExchComponents();if(c&&c.length){a.push.apply(a,c)}}return _fwdSlashify(a)};function _getTsConfig(){return _tsConfigExists()?".":null};function _getJetVer(){var i,ojetPackage,ver,error;ojetPackage=nd.jsonLoader.load(nd.path.join(cwd,PACKAGE_JSON),nd,function(errMsg){appCtx.error(errMsg);appCtx.warn("Defaulting to "+appCtx.defaultJetVer);error=true});if(!error&&ojetPackage&&ojetPackage.dependencies){ver=ojetPackage.dependencies[DEPENDENCIES_VER_PROP]}else{ver=appCtx.defaultJetVer}if(ver){for(i=0;i<ver.length;i++){if(!isNaN(ver.charAt(i))){ver=ver.substring(i);break}}ver=ver.replace(".tgz","");i=ver.lastIndexOf(".");ver=ver.substring(0,i)}return ver};function _getExchComponents(){var dirComps,comps,compName,o,a,ret=[],dir,rel;comps=ojConfig.components;if(!comps){return null}dirComps=nd.path.join(cwd,EXCH_COMPS_FOLDER);if(!nd.fsUtils.fileExists(dirComps,true)){return null}if(!(dirComps&&comps)){return null}for(compName in comps){dir=nd.path.join(cwd,EXCH_COMPS_FOLDER,compName);rel="./"+nd.path.join(EXCH_COMPS_FOLDER,compName);o=_readComponentJson(dir);if(o){if(o.type==="pack"){a=_expandPack(rel,o,comps[compName]);if(a.length){ret.push.apply(ret,a)}}else if(o.type==="composite"||!o.type){ret.push(rel)}}}return ret};function _getTheme(){var dt=ojConfig.defaultTheme;if(dt){dt=dt.charAt(0).toUpperCase()+dt.substring(1)}else{dt=DEFAULT_THEME}return dt};function _readComponentJson(dir){var compJson=nd.jsonLoader.load(nd.path.join(dir,COMP_JSON),nd,function(errMsg){appCtx.error(errMsg)});return compJson};function _expandPack(dir,json,compObj){var comps,compName,a=[];comps=compObj.components;if(comps){for(compName in comps){a.push(dir+"/"+compName)}}return _fwdSlashify(a)};function _getFolderName(){return nd.path.basename(cwd)};function _readJAFConfig(path){var error;var json=nd.jsonLoader.load(path,nd,function(errMsg){appCtx.error(errMsg);error=true},true);return error?"error":json};function _writeJAFConfig(name,isOjet){var data,ret=false;try{data="// JAF Generated "+(isOjet?OJET_COMMENT:NON_OJET_COMMENT)+"\n"+JSON.stringify(jafConfig,null,3);nd.fs.writeFileSync(nd.path.join(cwd,name),data);ret=true}catch(e){appCtx.error(e)}return ret};function _backupJAFConfig(fp){var data,ret=false;try{data=_readFile(fp);if(data){nd.fs.writeFileSync(fp+".bak",data);ret=true}}catch(e){appCtx.error(e)}return ret};function _ojetFileChange(ojPath,jafConfig){if(!md5){md5=require("md5")}var ojetMd5,ojafMd5;ojetMd5=md5(_readFile(ojPath));ojafMd5=jafConfig&&jafConfig.ojet&&jafConfig.ojet.md5;return ojetMd5!==ojafMd5?ojetMd5:false};function _tsConfigChange(ojPath,jafConfig){var p,h,ret=false;p=nd.path.join(ojPath,TSCONFIG);if(nd.fsUtils.fileExists(p)){if(!md5){md5=require("md5")}h=md5(_readFile(p))}if(h){if(jafConfig.ojet.tsmd5){ret=h!==jafConfig.ojet.tsmd5?h:false}else{ret=h}}else if(jafConfig&&jafConfig.ojet.tsmd5){ret=true}return ret};function _readFile(fp){var data;try{data=nd.fs.readFileSync(fp,"utf8")}catch(e){}return data};function _fwdSlashify(path){if(Array.isArray(path)){for(var i=0;i<path.length;i++){path[i]=path[i].replace(SLASHIFY,"/")}return path}else if(path){return path.replace(SLASHIFY,"/")}};function _createDefault(){var o={"base":"$jafcwd","files":[],"exclude":[],"components":[],"builtinJetRules":true,"jetVer":appCtx.defaultJetVer,"ecmaVer":DEFAULT_ECMAVER,"theme":DEFAULT_THEME,"groups":["all"],"format":"prose","options":{"verbose":false,"color":true},"title":["+---------------------------------------------------------------------+","| OJET Application Audit |","+---------------------------------------------------------------------+","JAF $jafver - Jet $jetver : ($jafdate, $jaftime)\n"]};if(_tsConfigExists()){o.tsconfig=cwd}return o};function setFileProps(obj){var path,folder;folder="src";path=_getPathTo(folder);if(path){obj.files.push(path+"/**/*.html");obj.files.push(path+"/**/*.js");obj.files.push(path+"/**/*.css");obj.exclude.push(path+"/**/*-min.js");obj.exclude.push(path+"/**/*-min.css")}folder="jet-composites";path=_getPathTo(folder);if(path){obj.components=[path];obj.exclude.push(path+"/**/extension/**/*.*");obj.exclude.push(path+"/**/resources/**/*.*")}};function _getPathTo(folder){var path=nd.fsUtils.findFile(cwd,folder,function(dir,file){return file!=="node_modules"&&!dir.includes("node_modules")});if(path){path=nd.path.join(path,folder);path=_fwdSlashify(path);path="."+path.replace(cwd,"")}else{path=null}return path};function _defaultConfigExists(){var file=nd.path.join(cwd,OJAF_DEFAULT_CONFIG);return nd.fsUtils.fileExists(file)};function _ojetJafConfigExists(){var file=nd.path.join(cwd,OJAF_CONFIG);return nd.fsUtils.fileExists(file)};function _tsConfigExists(){var file=nd.path.join(cwd,TSCONFIG);return nd.fsUtils.fileExists(file)};function scaffoldSuccessful(configName){appCtx.msg(" __ ___");appCtx.msg(" __ / /___ _/ _/ Configuration generation successful");appCtx.msg(" / // // _ `/ _/ created: '@@'".replace("@@",configName));appCtx.msg(" \\___/ \\_,_/_/\n")};module.exports={init,isOJET,handleOjetConfig,createNonOjetConfig,getOjetConfig};
|
|
6
|
+
const DEFAULTS=require("./defaults");const OJET_CONFIG="oraclejetconfig.json";const OJAF_CONFIG="oraclejafconfig.json";const OJAF_DEFAULT_CONFIG="jafconfig.json";const DEPENDENCIES_VER_PROP="@oracle/oraclejet";const PACKAGE_JSON="package.json";const TSCONFIG="tsconfig.json";const SUFFIX_HTML="/**/*.html";const SUFFIX_JS="/**/*.js";const SUFFIX_TS="/**/*.ts";const SUFFIX_CSS="/**/*.css";const SUFFIX_COMPJSON="/**/component.json";const SUFFIX_ALL="/**/*.*";const OJET_COMMENT="OJET Based Configuration";const NON_OJET_COMMENT="Default Configuration";const SLASHIFY=/\\\\|\\/g;const STABLE="Stable";var cwd,appCtx,nd,ojet,jetConfig,jafConfig,initDone;var md5;function init(cwdir,nodeDeps,appContext){if(!initDone){cwd=_fwdSlashify(cwdir);nd=nodeDeps;appCtx=appContext;ojet=isOJET();initDone=true}return ojet}function isOJET(){return initDone?!!jetConfig:nd.fsUtils.fileExists(nd.path.join(cwd,OJET_CONFIG))};function handleOjetConfig(isScaffold){var ojetPath,ojafPath,doUpdate=false,temp,hash,tsHash,tsc,defaultExists,error=false;ojetPath=nd.path.join(cwd,OJET_CONFIG);jetConfig=nd.jsonLoader.load(ojetPath,nd,errMsg=>{appCtx.error(errMsg);error=true},false,appCtx.utils);if(isScaffold){if(error){appCtx.error("Cannot continue with --init");return"error"}else if(jetConfig){appCtx.msg(`Scaffolding JAF configuration in ${_getFolderName()} ...`)}else{appCtx.error("OJET CLI config not found - cannot continue with --init");return"error"}}ojafPath=nd.path.join(cwd,OJAF_CONFIG);if(nd.fsUtils.fileExists(ojafPath)){jafConfig=_readJAFConfig(ojafPath);if(jafConfig==="error"){return"error"}}if(isScaffold){defaultExists=_defaultConfigExists();if(jafConfig||defaultExists){appCtx.error("Pre-existing configuration found - '"+(defaultExists?OJAF_DEFAULT_CONFIG:OJAF_CONFIG)+"'");return"error"}}if(!isScaffold&&!jetConfig&&jafConfig){appCtx.warn(`JAF Configuration '${OJAF_CONFIG}' found, but OJET configuration '${OJET_CONFIG}' no longer exists.\n`)}hash=_isOjetFileChange(ojetPath,jafConfig);if(jafConfig){if(hash){if(jafConfig.ojet&&jafConfig.ojet.update){if(appCtx.verboseMode||appCtx.debugMode){if(hash){appCtx.info(`${OJET_CONFIG} change detected - updating ${OJAF_CONFIG}`)}if(tsHash){if(typeof tsHash==="string"){appCtx.info(`${TSCONFIG} change detected - updating ${OJAF_CONFIG}`)}else{appCtx.info(`${TSCONFIG} no longer found - updating ${OJAF_CONFIG}`)}}}jafConfig.files=_getFileSet();jafConfig.exclude=_getExcludes();jafConfig.components=_getComposites();if(tsc=_getTsConfigPath()){if(jafConfig.typescript){jafConfig.typescript.tsconfig=tsc}else{jafConfig.typescript={tsconfig:tsc}}}else if(jafConfig.typescript&&jafConfig.typescript.tsconfig){delete jafConfig.typescript}if(jafConfig.tsconfig){delete jafConfig.tsconfig}temp=_getJetVer();if(jafConfig.jetVer!==temp){jafConfig.jetVer=temp}if(temp=_getTheme()){if(jafConfig.theme!==temp){jafConfig.theme=temp}}else if(jafConfig.theme){delete jafConfig.theme}if(!jafConfig.ojet){jafConfig.ojet={}}if(hash){jafConfig.ojet.md5=hash}if(typeof jafConfig.ojet.update!=="boolean"){jafConfig.ojet.update=true}if(typeof tsHash==="string"){jafConfig.ojet.tsmd5=tsHash}else if(tsHash&&jafConfig.ojet.tsmd5){delete jafConfig.ojet.tsmd5}doUpdate=true;_backupJAFConfig(ojafPath)}else{const changeMsg=" changes detected, but oraclejafconfig updates are disabled";if(hash){appCtx.warn(OJET_CONFIG+changeMsg)}if(tsHash){appCtx.warn(TSCONFIG+changeMsg)}}}}else if(isScaffold){jafConfig={base:"$jafcwd",files:_getFileSet(),exclude:_getExcludes(),components:_getComposites(),builtinJetRules:true,jetVer:_getJetVer(),ecmaVer:DEFAULTS.ECMAVER,format:"prose",severity:"all",groups:["all"]};if(temp=_getTheme()){jafConfig.theme=temp}if(tsc=_getTsConfigPath()){jafConfig.typescript={tsconfig:tsc}}if(tsHash){jafConfig.ojet.tsmd5=tsHash}jafConfig.options={verbose:false,color:true};jafConfig.title=["+---------------------------------------------------------------------+","| OJET Application Audit |","+---------------------------------------------------------------------+","JAF $jafver - Jet $jetver : ($jafdate, $jaftime)\n"];jafConfig.ojet={update:true,md5:hash};doUpdate=true}if(doUpdate&&!_writeJAFConfig(OJAF_CONFIG,true)){appCtx.error("Failed to "+(isScaffold?"scaffold":"update")+" OJAF config '"+nd.path.join(cwd,OJAF_CONFIG)+"'");return"error"}if(isScaffold){scaffoldSuccessful(OJAF_CONFIG)}if(appCtx.debugMode){appCtx.debug("JAFConfig :\n"+JSON.stringify(jafConfig,null,3))}return jafConfig};function getOjetConfig(){return jetConfig}function _getFileSet(){var source,src,files=[];if(jetConfig&&jetConfig.paths){if(source=jetConfig.paths.source){if(src=source.common){files.push("./"+src+SUFFIX_HTML);if(source.javascript){files.push("./"+src+SUFFIX_JS)}if(source.typescript){files.push("./"+src+SUFFIX_TS)}files.push("./"+src+SUFFIX_COMPJSON)}if(source.styles){files.push("./"+src+"/"+source.styles+SUFFIX_CSS)}}}return _fwdSlashify(files)};function createNonOjetConfig(){var oj;oj=_ojetJafConfigExists();if(oj||_defaultConfigExists()){appCtx.error("Default configuration '"+(oj?OJAF_CONFIG:OJAF_DEFAULT_CONFIG)+"' exists - terminating --init");return"'error"}jafConfig=_createDefaultNonOjetConfig();_setFileProps(jafConfig);if(!_writeJAFConfig(OJAF_DEFAULT_CONFIG,false)){appCtx.error("Failed to scaffold OJAF config '"+OJAF_DEFAULT_CONFIG+"'");return"error"}scaffoldSuccessful(OJAF_DEFAULT_CONFIG)};function _getExcludes(){var files=[],source;if(jetConfig.paths&&jetConfig.paths.source){source=jetConfig.paths.source.common;files.push("./"+nd.path.join(source,"**"+"/"+"*-min.js"));files.push("./"+nd.path.join(source,"**"+"/"+"*-min.css"));files.push("./**/node_modules/**/*.*")}return _fwdSlashify(files)};function _getComposites(){var a=[],dir;if(jetConfig.paths&&jetConfig.paths.exchangeComponents){dir="./exchange_components/**/component.json"}else{dir="./jet_components/**/component.json"}a.push(dir);return _fwdSlashify(a)};function _getTsConfigPath(){return _tsConfigExists()?".":null};function _getJetVer(){var i,ojetPackage,ver,error;ojetPackage=nd.jsonLoader.load(nd.path.join(cwd,PACKAGE_JSON),nd,function(errMsg){appCtx.error(errMsg);appCtx.warn("Defaulting to "+appCtx.defaultJetVer);error=true});if(!error&&ojetPackage&&ojetPackage.dependencies){ver=ojetPackage.dependencies[DEPENDENCIES_VER_PROP];if(ver){for(i=0;i<ver.length;i++){if(!isNaN(ver.charAt(i))){ver=ver.substring(i);break}}ver=ver.replace(".tgz","");i=ver.lastIndexOf(".");ver=ver.substring(0,i)}}return ver?ver:appCtx.defaultJetVer};function _getTheme(){var dt=jetConfig.defaultTheme;if(dt){dt=dt.charAt(0).toUpperCase()+dt.substring(1);if(dt===STABLE){dt="Redwood"}}return dt};function _getFolderName(){return nd.path.basename(cwd)};function _readJAFConfig(path){var error;var json=nd.jsonLoader.load(path,nd,function(errMsg){appCtx.error(errMsg);error=true},true,appCtx.utils);if(error){appCtx.error(`JSON syntax error -> '${path}`)}return error?"error":json};function _writeJAFConfig(name,isOjet){var data,ret=false;try{data=`// JAF Generated ${isOjet?OJET_COMMENT:NON_OJET_COMMENT}\n// Updated: ${new Date().toString()}\n\n${JSON.stringify(jafConfig,null,3)}`;nd.fs.writeFileSync(nd.path.join(cwd,name),data);ret=true}catch(e){appCtx.error(e)}return ret};function _backupJAFConfig(fp){var data,ret=false;try{data=_readFile(fp);if(data){nd.fs.writeFileSync(fp+".bak",data);ret=true}}catch(e){appCtx.error(e)}return ret};function _isOjetFileChange(ojPath,jafConfig){if(!md5){md5=require("md5")}var ojetMd5,ojafMd5;ojetMd5=md5(_readFile(ojPath));ojafMd5=jafConfig&&jafConfig.ojet&&jafConfig.ojet.md5;return ojetMd5!==ojafMd5?ojetMd5:false};function _readFile(fp){var data;try{data=nd.fs.readFileSync(fp,"utf8")}catch(e){}return data};function _fwdSlashify(path){if(Array.isArray(path)){for(var i=0;i<path.length;i++){path[i]=path[i].replace(SLASHIFY,"/")}return path}else if(path){return path.replace(SLASHIFY,"/")}};function _createDefaultNonOjetConfig(){var o={"base":"$jafcwd","files":[],"exclude":[],"components":["./jet_components/**/component.json"],"builtinJetRules":true,"jetVer":appCtx.defaultJetVer,"ecmaVer":DEFAULTS.ECMAVER,"groups":["all"],"format":"prose","severity":"all","options":{verbose:false,color:true},"title":["+---------------------------------------------------------------------+","| Application Audit |","+---------------------------------------------------------------------+","JAF $jafver - Jet $jetver : ($jafdate, $jaftime)\n"]};if(_tsConfigExists()){o.typescript={tsconfig:cwd}}return o};function _setFileProps(obj){var path,folder;folder="src";path=_getPathTo(folder);if(path){obj.files.push(path+"/**/*.html");obj.files.push(path+"/**/*.js");obj.files.push(path+"/**/*.ts");obj.files.push(path+"/**/*.css");obj.exclude.push(path+"/**/*-min.js");obj.exclude.push(path+"/**/*-min.css")}folder="jet-composites";path=_getPathTo(folder);if(path){obj.components=[path];obj.exclude.push(path+"/**/extension/**/*.*");obj.exclude.push(path+"/**/resources/**/*.*")}obj.exclude.push("./**/node_modules/**/*.*")};function _getPathTo(folder){var path=nd.fsUtils.findFile(cwd,folder,function(dir,file){return file!=="node_modules"&&!dir.includes("node_modules")});if(path){path=nd.path.join(path,folder);path=_fwdSlashify(path);path="."+path.replace(cwd,"")}else{path=null}return path};function _defaultConfigExists(){var file=nd.path.join(cwd,OJAF_DEFAULT_CONFIG);return nd.fsUtils.fileExists(file)};function _ojetJafConfigExists(){var file=nd.path.join(cwd,OJAF_CONFIG);return nd.fsUtils.fileExists(file)};function _tsConfigExists(){var file=nd.path.join(cwd,TSCONFIG);return nd.fsUtils.fileExists(file)};function scaffoldSuccessful(configName){appCtx.msg(" __ ___");appCtx.msg(" __ / /___ _/ _/ Configuration generation successful");appCtx.msg(" / // // _ `/ _/ created: '@@'".replace("@@",configName));appCtx.msg(" \\___/ \\_,_/_/\n")};module.exports={init,isOJET,handleOjetConfig,createNonOjetConfig,getOjetConfig};
|
package/lib/scaffoldRule.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright (c) 2018,
|
|
2
|
+
* Copyright (c) 2018, 2022, Oracle and/or its affiliates.
|
|
3
3
|
* Licensed under The Universal Permissive License (UPL), Version 1.0
|
|
4
4
|
* as shown at https://oss.oracle.com/licenses/upl/
|
|
5
5
|
*/
|
|
6
|
-
const RULE=["/*--------------------------------------------------------------------------------*/","/* JAF Rule: '%r' */","/* Purpose : */","/*--------------------------------------------------------------------------------*/","","","const RULENAME = \"%s\";","const DESCRIPTION = \"long description - can include markup\";","const SHORT_DESCRIPTION = \"short description\";","","class Rule {"," getName() {"," return RULENAME;"," }",""," getDescription() {"," return DESCRIPTION;"," }",""," getShortDescription() {"," return SHORT_DESCRIPTION;"," }",""," register( /*regCtx*/ ) {"," // register
|
|
6
|
+
const RULE=["/**"," * Copyright (c) 2018, 2022, Oracle and/or its affiliates."," * Licensed under The Universal Permissive License (UPL), Version 1.0"," * as shown at https://oss.oracle.com/licenses/upl/"," */","","/*--------------------------------------------------------------------------------*/","/* JAF Rule: '%r' */","/* Purpose : */","/*--------------------------------------------------------------------------------*/","","","const RULENAME = \"%s\";","const DESCRIPTION = \"long description/help - can include HTML markup\";","const SHORT_DESCRIPTION = \"short description\";","","class Rule {"," getName() {"," return RULENAME;"," }",""," getDescription() {"," return DESCRIPTION;"," }",""," getShortDescription() {"," return SHORT_DESCRIPTION;"," }",""," /**"," * Registration - declare listeners"," * @param {Object} regCtx the registration context"," */"," register( /*regCtx*/ ) {"," // register listener(s)"," // return { xxx : this._onXXX }"," }",""," /**"," *"," * @param {Object} ruleCtx the rule context"," */"," _onXXX(ruleCtx) {"," // implement rule listener(s)"," }","","}","","","","module.exports = Rule;"];const LOGO=[" __ ___"," __ / /___ _/ _/ Rule '"+"%r"+"'"," / // // _ `/ _/ Created successfully"," \\___/ \\_,_/_/\n"];const JS=".js";const PC_R="%r";const PC_S="%s";function genRule(dir,ruleName,nodeDeps){var np=nodeDeps.path;var fsUtils=nodeDeps.fsUtils;var ext=np.extname(ruleName);var rule,fp,text;if(ext===""){rule=ruleName}else if(ext.toLowerCase()!==JS){console.log("[error]: invalid rule file extension '"+ext+"'. Do not specify a file extension!");return true}else{rule=ruleName.substring(0,ruleName.length-3)}ruleName=rule+JS;fp=np.join(dir,ruleName);try{if(fsUtils.fileExists(fp)){console.log("[Warning]: Rule '"+ruleName+"' already exists. ojaf will not overwrite it!");return true}text=_updateText(text,rule);nodeDeps.fs.writeFileSync(fp,text);_logo(rule);return true}catch(e){console.log("[Error]: "+e)}return false};function _updateText(text,rule){var i;text=RULE.join("\n").replace(PC_S,rule);i=text.indexOf(PC_R);text=text.replace(PC_R," ");return _insertText(text,i,rule)};function _insertText(text,i,rule){return text.substring(0,i)+rule+"'"+text.substring(i+1+rule.length)};function _logo(rule){console.log(LOGO.join("\n").replace("%r",rule))}module.exports.genRule=genRule;
|
package/lib/schema.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright (c) 2018,
|
|
2
|
+
* Copyright (c) 2018, 2022, Oracle and/or its affiliates.
|
|
3
3
|
* Licensed under The Universal Permissive License (UPL), Version 1.0
|
|
4
4
|
* as shown at https://oss.oracle.com/licenses/upl/
|
|
5
5
|
*/
|
|
6
|
-
var _validate;const EMPTY_INDEX="['']";function validateComponentJson(obj){var errors,error,s,i,ret=null;if(!_validate){
|
|
6
|
+
var _validate;const EMPTY_INDEX="['']";function validateComponentJson(obj){var errors,error,s,i,ret=null;if(!_validate){_init()}if(!_validate(obj)){ret=[];errors=_validate.errors;for(i=0;i<errors.length;i++){error=errors[i];s=_cleanAjvMessages(error);if(!s.includes("(if)")){ret.push({msg:s,error:error})}}}return ret};function _cleanAjvMessages(error){var keyword,i;var prop,subProp,propType,propId,param,dataPath,msg,ret;keyword=error.keyword;switch(keyword){case"required":ret=error.message;break;case"enum":prop=error.dataPath;if(prop.charAt(0)==="."){prop=prop.substr(1)};ret="bad property '"+prop+"' value : "+error.message+" ["+error.params.allowedValues+"]";break;case"additionalProperties":if(error.params){ret=error.params["additionalProperty"];dataPath=error.dataPath||"";if(dataPath){if(dataPath.charAt(0)==="."){dataPath=dataPath.substring(1)}if(dataPath.endsWith(EMPTY_INDEX)){dataPath=dataPath.substring(0,dataPath.indexOf(EMPTY_INDEX))}dataPath=" in "+dataPath}ret=`unexpected additional property '${ret}'${dataPath}`}else{prop=error.dataPath;i=prop.indexOf("[");propType=prop.substring(0,i);prop=prop.substring(i);prop=_smartRemoveSquareBrackets(prop);i=prop.indexOf(".");propId=prop.substring(0,i);propId=propId.replace(/[\'\"]/g,"");param=prop.substring(i);i=param.indexOf("'");if(i>=0){param=param.substring(0,i)+"."+param.substring(i+1);param=param.replace(/[\'\"]/g,"")}propType=_getSchemaPropType(propType);ret=propType+" "+propId+" has unexpected additional sub-property '"+param+"'"}break;case"type":msg=error.dataPath;if(msg.charAt(0)==="."){msg=msg.substring(1)}ret=msg+" - "+error.message;break;case"not":msg=error.message;msg=msg.replace("should NOT be ","is not ");propType=error.dataPath.startsWith(".prop")?"property":error.dataPath.startsWith(".events")?"events":error.dataPath.startsWith(".name")?"name":"";prop=error.propertyName?error.propertyName:null;if(!propType){ret=(prop?" property '"+prop+"'":"")+" - "+msg}else{ret="property '"+propType+"'"+(prop?" '"+prop+"' ":" ")+"- "+msg}break;case"propertyNames":ret=error.message;break;case"pattern":prop=error.dataPath;if(prop.charAt(0)==="."){prop=prop.substring(1)}return"property '"+prop+"' failed a schema format pattern match";break;case"format":prop=error.dataPath;if(prop.charAt(0)==="."){prop=prop.substring(1)}return"property '"+prop+"' format - "+error.message;break;case"anyOf":prop=error.dataPath;return"property "+(prop.charAt(0)==="."?prop.substring(1):prop)+" - "+error.message;break;default:ret="unknown error ("+error.keyword+")";}return ret};function _getSchemaPropType(propType){if(propType.startsWith(".prop")){propType="property"}else if(propType.startsWith(".even")){propType="event"}else if(propType.startsWith(".meth")){propType="method"}else{propType="UNNKNOWN"}return propType};function _smartRemoveSquareBrackets(prop){var i,x=0,s;while(true){i=prop.indexOf("[",x);if(i>=0){s=prop.substring(i+1,i+2).trim();if(!/\d/.test(s)){prop=prop.replace("[","");prop=prop.replace("]","");x=i;continue}}break}return prop};function _init(){var schema=require("../schema/component-schema.json");var Ajv=require("ajv");var _ajv=new Ajv({allErrors:true});_validate=_ajv.compile(schema)};module.exports.validateComponentJson=validateComponentJson;
|
package/lib/scopewalker.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright (c) 2018,
|
|
2
|
+
* Copyright (c) 2018, 2022, Oracle and/or its affiliates.
|
|
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 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',Program:'Program',Property:'Property',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',TSInterfaceDeclaration:'TSInterfaceDeclaration',JSXElement:'JsxElement',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'],Program:['body'],Property:['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:[],TSImportEqualsDeclaration:[],TSTypeAliasDeclaration:[],TSInterfaceDeclaration:[],JSXElement:[],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
|
+
(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',Program:'Program',Property:'Property',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',TSInterfaceDeclaration:'TSInterfaceDeclaration',JSXElement:'JsxElement',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'],Program:['body'],Property:['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:[],JSXElement:[],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/lib/spinner.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright (c) 2018,
|
|
2
|
+
* Copyright (c) 2018, 2022, Oracle and/or its affiliates.
|
|
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 Colors=require("./colors");const wcwidth=require("wcwidth");const CR="\r";const NL="\n";var Spinner=function(opts){this._options={text:"",textColor:"yellow",spincolor:"white",frame:[124,47,45,92],interval:100,hideCursor:true,gap:" ",stream:process.stderr};opts=this._mergeOpts(this._options,opts);this._textColor=opts.textColor;this._hideTheCursor=opts.hideCursor!==false;this._interval=opts.interval||100;this._stream=opts.stream;this._frame=opts.frame;this._gap=opts.gap;for(var i=0;i<opts.frame.length;i++){opts.frame[i]=String.fromCharCode(opts.frame[i])}this._frameIndex=0;this._canDo=!process.stdout.isTTY&&process.stderr.isTTY;this._lineCount=0;this._linesToClear=0;this._count=0};Spinner.prototype.start=function(text){if(!this._canDo){return}this.setText(text);if(this._hideTheCursor){this._hideCursor()}};Spinner.prototype.stop=function(text){if(!this._canDo){return}var opts;clearInterval(this._timer);this._timer=null;opts=this._options;this.setText(text);this._frameIndex=0;this.clear();if(this._hideTheCursor){this._showCursor()}};Spinner.prototype.setText=function(text){if(!this._canDo){return}text=typeof text==="string"?this._getNextFrameChar()+this._gap+text:"";text=this._setTextColor(text);const columns=this._stream.columns||80;this._lineCount=_stripAnsi("--"+text).split("\n").reduce((count,line)=>{return count+Math.max(1,Math.ceil(wcwidth(line)/columns))},0);_tslice(this)};Spinner.prototype._startTimer=function(){var opts=this._options;opts.stream.write(this._getNextFrameChar()+opts.gap+opts.text);this._timer=setInterval(_tslice,opts.interval,this)};function _tslice(self){self.clear();self._stream.write(self._text);self._linesToClear=self._lineCount};Spinner.prototype._getNextFrameChar=function(){var opts=this._options;this._frameIndex++;this._frameIndex=this._frameIndex%this._frame.length;return this._frame[this._frameIndex]};Spinner.prototype._hideCursor=function(){this._stream.write("\x1B[?25h");this._stream.write("\x1B[?25l")};Spinner.prototype._showCursor=function(){this._stream.write("\x1B[?25h")};Spinner.prototype._mergeOpts=function(optsTo,optsFrom){var prop;if(optsFrom){for(prop in optsFrom){if(optsFrom.hasOwnProperty(prop)){optsTo[prop]=optsFrom[prop]}}}return optsTo};Spinner.prototype.clear=function(){for(let i=0;i<this._linesToClear;i++){if(i>0){this._stream.moveCursor(0,-1)}this._stream.clearLine();this._stream.cursorTo(0)}this._linesToClear=0};Spinner.prototype._setTextColor=function(text){
|
|
6
|
+
const Colors=require("./colors");const wcwidth=require("wcwidth");const CR="\r";const NL="\n";var Spinner=function(opts){this._options={text:"",textColor:"yellow",spincolor:"white",frame:[124,47,45,92],interval:100,hideCursor:true,gap:" ",stream:process.stderr};opts=this._mergeOpts(this._options,opts);this._textColor=opts.textColor;this._hideTheCursor=opts.hideCursor!==false;this._interval=opts.interval||100;this._stream=opts.stream;this._frame=opts.frame;this._gap=opts.gap;for(var i=0;i<opts.frame.length;i++){opts.frame[i]=String.fromCharCode(opts.frame[i])}this._frameIndex=0;this._canDo=!process.stdout.isTTY&&process.stderr.isTTY;this._lineCount=0;this._linesToClear=0;this._count=0};Spinner.prototype.start=function(text){if(!this._canDo){return}this.setText(text);if(this._hideTheCursor){this._hideCursor()}};Spinner.prototype.stop=function(text){if(!this._canDo){return}var opts;clearInterval(this._timer);this._timer=null;opts=this._options;this.setText(text);this._frameIndex=0;this.clear();if(this._hideTheCursor){this._showCursor()}};Spinner.prototype.setText=function(text){if(!this._canDo){return}text=typeof text==="string"?this._getNextFrameChar()+this._gap+text:"";text=this._setTextColor(text);const columns=this._stream.columns||80;this._lineCount=_stripAnsi("--"+text).split("\n").reduce((count,line)=>{return count+Math.max(1,Math.ceil(wcwidth(line)/columns))},0);_tslice(this)};Spinner.prototype._startTimer=function(){var opts=this._options;opts.stream.write(this._getNextFrameChar()+opts.gap+opts.text);this._timer=setInterval(_tslice,opts.interval,this)};function _tslice(self){self.clear();self._stream.write(self._text);self._linesToClear=self._lineCount};Spinner.prototype._getNextFrameChar=function(){var opts=this._options;this._frameIndex++;this._frameIndex=this._frameIndex%this._frame.length;return this._frame[this._frameIndex]};Spinner.prototype._hideCursor=function(){this._stream.write("\x1B[?25h");this._stream.write("\x1B[?25l")};Spinner.prototype._showCursor=function(){this._stream.write("\x1B[?25h")};Spinner.prototype._mergeOpts=function(optsTo,optsFrom){var prop;if(optsFrom){for(prop in optsFrom){if(optsFrom.hasOwnProperty(prop)){optsTo[prop]=optsFrom[prop]}}}return optsTo};Spinner.prototype.clear=function(){for(let i=0;i<this._linesToClear;i++){if(i>0){this._stream.moveCursor(0,-1)}this._stream.clearLine();this._stream.cursorTo(0)}this._linesToClear=0};Spinner.prototype._setTextColor=function(text){this._text=this._textColor==="yellow"?Colors.YELLOW(text):text;return this._text};function _stripAnsi(text){return typeof text==="string"?text.replace(_ansiRegex(),""):text};function _ansiRegex(){const pattern=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[a-zA-Z\\d]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PRZcf-ntqry=><~]))"].join("|");return new RegExp(pattern,"g")};module.exports=Spinner;
|
package/lib/spinnernoop.js
CHANGED
package/lib/tabs.js
CHANGED