@oracle/oraclejet-audit 19.0.1 → 20.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +1 -1
- package/corePackMigrator/cli.js +1 -1
- package/corePackMigrator/corePackMigrator.js +1 -1
- package/corePackMigrator/resource/astUtils.js +1 -1
- package/corePackMigrator/resource/componentMigrator.js +1 -1
- package/corePackMigrator/resource/fileScanner.js +1 -1
- package/corePackMigrator/resource/htmlUtils.js +2 -2
- package/corePackMigrator/resource/testUtils.js +1 -1
- package/corePackMigrator/utilities/deltaWebElementAPIs.js +1 -1
- package/corePackMigrator/utilities/logging.js +1 -1
- package/jaf-amd.js +1 -1
- package/jaf.js +1 -1
- package/jafapi.js +1 -1
- package/lib/AST.js +1 -1
- package/lib/AST_Ts.js +2 -2
- package/lib/AstJson.js +1 -1
- package/lib/AstMd.js +1 -1
- package/lib/AstNodeTypes.js +1 -1
- package/lib/Cli.js +1 -1
- package/lib/Color.js +1 -1
- package/lib/Comments.js +1 -1
- package/lib/ComponentSvcs.js +1 -1
- package/lib/Components.js +1 -1
- package/lib/Config.js +1 -1
- package/lib/ConfigEx.js +1 -1
- package/lib/ConfigLib.js +1 -1
- package/lib/CssLib.js +1 -1
- package/lib/CssUtils.js +1 -1
- package/lib/DomUtils.js +1 -1
- package/lib/FileIndex.js +1 -1
- package/lib/FileSet.js +1 -1
- package/lib/FsUtils.js +1 -1
- package/lib/Histo.js +1 -1
- package/lib/HtmlTree.js +1 -1
- package/lib/HtmlUtils.js +1 -1
- package/lib/Issue.js +1 -1
- package/lib/JafEvents.js +1 -1
- package/lib/JafLib.js +1 -1
- package/lib/Json.js +1 -1
- package/lib/JsonLoader.js +1 -1
- package/lib/Md.js +1 -1
- package/lib/MetaLib.js +1 -1
- package/lib/NetUtils.js +1 -1
- package/lib/NodeTypes.js +1 -1
- package/lib/OjCPack.js +2 -2
- package/lib/OjetLib.js +1 -1
- package/lib/Parser.js +1 -1
- package/lib/Plugin.js +1 -1
- package/lib/RegTypes.js +1 -1
- package/lib/Registry.js +1 -1
- package/lib/Reporter.js +1 -1
- package/lib/RuleContext.js +1 -1
- package/lib/RulePack.js +1 -1
- package/lib/RuleSet.js +1 -1
- package/lib/Rules.js +1 -1
- package/lib/Scope.js +1 -1
- package/lib/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 +1 -1
- package/lib/TsUtils.js +1 -1
- package/lib/TsxUtils.js +1 -1
- package/lib/TsxUtils2.js +1 -1
- package/lib/Utils.js +1 -1
- package/lib/Watch.js +1 -1
- package/lib/Writer.js +1 -1
- package/lib/ZipUtils.js +1 -1
- package/lib/amdlist.js +1 -1
- package/lib/api.js +1 -1
- package/lib/betalist.js +1 -1
- package/lib/builtinpacks.js +1 -1
- package/lib/checkage.js +2 -2
- package/lib/cliStats.js +1 -1
- package/lib/clone.js +1 -1
- package/lib/cmdline.js +1 -1
- package/lib/defaults.js +2 -2
- package/lib/deflist.js +1 -1
- package/lib/deplist.js +1 -1
- package/lib/dislist.js +1 -1
- package/lib/exportRules.js +1 -1
- package/lib/extends.js +1 -1
- package/lib/filetypes.js +1 -1
- package/lib/grouplist.js +1 -1
- package/lib/groups.js +1 -1
- package/lib/help.js +1 -1
- package/lib/jetver.js +1 -1
- package/lib/jsx.js +1 -1
- package/lib/macros.js +1 -1
- package/lib/maint.js +1 -1
- package/lib/manpage.js +1 -1
- package/lib/manual.js +1 -1
- package/lib/metaLoader.js +1 -1
- package/lib/metahist.js +1 -1
- package/lib/migrator.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/proflist.js +1 -1
- package/lib/rlolist.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 +1 -1
- package/lib/scopewalker.js +1 -1
- package/lib/spinner.js +1 -1
- package/lib/spinnernoop.js +1 -1
- package/lib/sublib/precomp/ComponentFinder.js +1 -1
- package/lib/sublib/precomp/Precompiler.js +1 -1
- package/lib/sublib/precomp/TsxUtils.js +1 -1
- package/lib/sublib/precomp/Utils.js +1 -1
- package/lib/tabs.js +1 -1
- package/libext/expparser.js +1 -1
- package/meta/19.0.0/jetauditmeta.js +1 -1
- package/meta/20.0.0/jetauditmeta.js +9 -0
- package/meta/metaverlist.json +1 -1
- package/package.json +2 -2
- package/profiles/best-practice.json +1 -1
- package/profiles/redwood-strict.json +1 -1
- 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-json-unsafe-expr.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/jetvdom/msgid.json +1 -1
- package/rulepacks/jetvdom/rules.json +1 -1
- package/rulepacks/jetwc/jetwc-absolute-jetversion.js +1 -1
- package/rulepacks/jetwc/jetwc-aria-redefinition.js +1 -1
- package/rulepacks/jetwc/jetwc-bootstrap.js +1 -1
- package/rulepacks/jetwc/jetwc-compjson-bp-ar.js +1 -1
- package/rulepacks/jetwc/jetwc-compjson-bp-obj.js +1 -1
- package/rulepacks/jetwc/jetwc-component-dependencies.js +1 -1
- package/rulepacks/jetwc/jetwc-component-displayname.js +1 -1
- package/rulepacks/jetwc/jetwc-component-foldername.js +1 -1
- package/rulepacks/jetwc/jetwc-component-location.js +1 -1
- package/rulepacks/jetwc/jetwc-component-type.js +1 -1
- package/rulepacks/jetwc/jetwc-css-oj-complete.js +1 -1
- package/rulepacks/jetwc/jetwc-css-pack-load-path.js +1 -1
- package/rulepacks/jetwc/jetwc-css-scoping.js +2 -2
- package/rulepacks/jetwc/jetwc-data-property-prefix.js +1 -1
- package/rulepacks/jetwc/jetwc-deprecated-lifecycle.js +1 -1
- package/rulepacks/jetwc/jetwc-disabled-property.js +1 -1
- package/rulepacks/jetwc/jetwc-displayname.js +1 -1
- package/rulepacks/jetwc/jetwc-dynamic-slot-context.js +1 -1
- package/rulepacks/jetwc/jetwc-dynamic-slots-naming.js +1 -1
- package/rulepacks/jetwc/jetwc-event-displayname.js +1 -1
- package/rulepacks/jetwc/jetwc-events.js +1 -1
- package/rulepacks/jetwc/jetwc-exchange-images.js +1 -1
- package/rulepacks/jetwc/jetwc-jet-version.js +1 -1
- package/rulepacks/jetwc/jetwc-loader-file.js +1 -1
- package/rulepacks/jetwc/jetwc-markdown-link.js +1 -1
- package/rulepacks/jetwc/jetwc-method-displayname.js +1 -1
- package/rulepacks/jetwc/jetwc-methods.js +1 -1
- package/rulepacks/jetwc/jetwc-namespace.js +1 -1
- package/rulepacks/jetwc/jetwc-nested-defaults.js +1 -1
- package/rulepacks/jetwc/jetwc-nls-languages.js +1 -1
- package/rulepacks/jetwc/jetwc-nls-root.js +1 -1
- package/rulepacks/jetwc/jetwc-oj-register.js +1 -1
- package/rulepacks/jetwc/jetwc-ojcss.js +1 -1
- package/rulepacks/jetwc/jetwc-pack-children.js +1 -1
- package/rulepacks/jetwc/jetwc-packable-components.js +1 -1
- package/rulepacks/jetwc/jetwc-prerelease-dependencies.js +1 -1
- package/rulepacks/jetwc/jetwc-prerelease-pattern.js +1 -1
- package/rulepacks/jetwc/jetwc-prerelease-version.js +1 -1
- package/rulepacks/jetwc/jetwc-property-changed.js +1 -1
- package/rulepacks/jetwc/jetwc-property-displayname.js +1 -1
- package/rulepacks/jetwc/jetwc-property-nesting.js +1 -1
- package/rulepacks/jetwc/jetwc-property-translatable.js +1 -1
- package/rulepacks/jetwc/jetwc-public-modules.js +1 -1
- package/rulepacks/jetwc/jetwc-reference-npm-path.js +1 -1
- package/rulepacks/jetwc/jetwc-register-css.js +1 -1
- package/rulepacks/jetwc/jetwc-register-with-promises.js +1 -1
- package/rulepacks/jetwc/jetwc-require-paths.js +1 -1
- package/rulepacks/jetwc/jetwc-required-subproperty.js +1 -1
- package/rulepacks/jetwc/jetwc-reserved-property.js +1 -1
- package/rulepacks/jetwc/jetwc-schema.js +1 -1
- package/rulepacks/jetwc/jetwc-semantic-version.js +1 -1
- package/rulepacks/jetwc/jetwc-slot-displayname.js +1 -1
- package/rulepacks/jetwc/jetwc-slots.js +1 -1
- package/rulepacks/jetwc/jetwc-standard-files.js +1 -1
- package/rulepacks/jetwc/jetwc-status-since.js +1 -1
- package/rulepacks/jetwc/jetwc-subproperty-writeback.js +1 -1
- package/rulepacks/jetwc/jetwc-supproperty-propagation.js +1 -1
- package/rulepacks/jetwc/jetwc-template-slots.js +1 -1
- package/rulepacks/jetwc/jetwc-unused-events.js +1 -1
- package/rulepacks/jetwc/jetwc-unused-slots.js +1 -1
- package/rulepacks/jetwc/jetwc-use-public-apis.js +1 -1
- package/rulepacks/jetwc/jetwc-vb-category.js +1 -1
- package/rulepacks/jetwc/jetwc-vb-icon.js +1 -1
- package/rulepacks/jetwc/jetwc-vcomponent-jetversion.js +1 -1
- package/rulepacks/jetwc/jetwc-vcomponent-loader.js +1 -1
- package/rulepacks/jetwc/jetwc-vcomponent-version.js +1 -1
- package/rulepacks/jetwc/jetwc-version-openrange.js +1 -1
- package/rulepacks/jetwc/jetwc-well-formed-description.js +1 -1
- package/rulepacks/jetwc/jetwc-writeback-required.js +1 -1
- package/rulepacks/jetwc/msgid.json +1 -1
- package/rulepacks/jetwc/rules.json +2 -2
- package/rulepacks/jetwc-lib/jetwcutils-auditComponentCacheManager.js +1 -1
- package/rulepacks/jetwc-lib/jetwcutils-commonListenerImpls.js +1 -1
- package/rulepacks/jetwc-lib/jetwcutils-componentAuditUtils.js +1 -1
- package/rulepacks/jetwc-lib/jetwcutils-componentFinder.js +2 -2
- package/rulepacks/jetwc-lib/jetwcutils-tsxUtils.js +2 -2
- package/rulepacks/jetwco/jetwco-bootstrap.js +1 -1
- package/rulepacks/jetwco/jetwco-cacc-auditConstraints.js +1 -1
- package/rulepacks/jetwco/jetwco-cacc-componentType.js +1 -1
- package/rulepacks/jetwco/jetwco-cacc-dependencies.js +1 -1
- package/rulepacks/jetwco/jetwco-cacc-dynamicSlots.js +1 -1
- package/rulepacks/jetwco/jetwco-cacc-eventBubbles.js +1 -1
- package/rulepacks/jetwco/jetwco-cacc-eventCancelable.js +1 -1
- package/rulepacks/jetwco/jetwco-cacc-eventPayload.js +1 -1
- package/rulepacks/jetwco/jetwco-cacc-events.js +1 -1
- package/rulepacks/jetwco/jetwco-cacc-helpers.js +1 -1
- package/rulepacks/jetwco/jetwco-cacc-jetVer.js +1 -1
- package/rulepacks/jetwco/jetwco-cacc-methodParamTypes.js +1 -1
- package/rulepacks/jetwco/jetwco-cacc-methodParams.js +1 -1
- package/rulepacks/jetwco/jetwco-cacc-methodReturnType.js +1 -1
- package/rulepacks/jetwco/jetwco-cacc-methods.js +1 -1
- package/rulepacks/jetwco/jetwco-cacc-packBundle.js +1 -1
- package/rulepacks/jetwco/jetwco-cacc-packBundleContent.js +1 -1
- package/rulepacks/jetwco/jetwco-cacc-packContent.js +1 -1
- package/rulepacks/jetwco/jetwco-cacc-properties.js +1 -1
- package/rulepacks/jetwco/jetwco-cacc-propertyDefault.js +1 -1
- package/rulepacks/jetwco/jetwco-cacc-propertyEnumeration.js +1 -1
- package/rulepacks/jetwco/jetwco-cacc-propertyReadOnly.js +1 -1
- package/rulepacks/jetwco/jetwco-cacc-propertyRequired.js +1 -1
- package/rulepacks/jetwco/jetwco-cacc-propertyType.js +1 -1
- package/rulepacks/jetwco/jetwco-cacc-propertyWriteback.js +1 -1
- package/rulepacks/jetwco/jetwco-cacc-publicModules.js +1 -1
- package/rulepacks/jetwco/jetwco-cacc-slotDataVariable.js +1 -1
- package/rulepacks/jetwco/jetwco-cacc-slotDataVariableType.js +1 -1
- package/rulepacks/jetwco/jetwco-cacc-slots.js +1 -1
- package/rulepacks/jetwco/jetwco-cacc-styleClasses.js +1 -1
- package/rulepacks/jetwco/jetwco-cacc-styleVariables.js +1 -1
- package/rulepacks/jetwco/jetwco-cacc-typeMappingOverrides.js +1 -1
- package/rulepacks/jetwco/jetwco-compjson-ns-reg.js +1 -1
- package/rulepacks/jetwco/jetwco-component-api-baseline-changes.js +1 -1
- package/rulepacks/jetwco/jetwco-component-api-changes.js +1 -1
- package/rulepacks/jetwco/jetwco-component-api-controlled-changes.js +1 -1
- package/rulepacks/jetwco/jetwco-component-cdn.js +1 -1
- package/rulepacks/jetwco/jetwco-description-standards.js +1 -1
- package/rulepacks/jetwco/jetwco-displayname-standards.js +1 -1
- package/rulepacks/jetwco/jetwco-exchange-version-check.js +1 -1
- package/rulepacks/jetwco/jetwco-license-info.js +1 -1
- package/rulepacks/jetwco/jetwco-prerelease-cdn.js +1 -1
- package/rulepacks/jetwco/jetwco-thirdparty-ba.js +1 -1
- package/rulepacks/jetwco/jetwco-validate-applied-audits.js +1 -1
- package/rulepacks/jetwco/msgid.json +1 -1
- package/rulepacks/jetwco/rules.json +1 -1
- package/rulepacks/ojc/msgid.json +1 -1
- package/rulepacks/ojc/ojc-acc-avatar-aria-role.js +1 -1
- package/rulepacks/ojc/ojc-acc-filepicker-aria-role.js +1 -1
- package/rulepacks/ojc/ojc-html-button-defslot.js +1 -1
- package/rulepacks/ojc/ojc-tsx-button-defslot.js +1 -1
- package/rulepacks/ojc/rules.json +1 -1
- 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/vdom/msgid.json +1 -1
- package/rulepacks/vdom/rules.json +1 -1
- package/rulepacks/wdt/msgid.json +1 -1
- package/rulepacks/wdt/rules.json +1 -1
- package/rulepacks/wdt/wd-driver-sleep.js +1 -1
- package/rulepacks/wdt/wd-xpath.js +1 -1
- 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-sys-age.js +1 -1
- package/rules/jaf/jaf-sys-dup-component.js +1 -1
- package/rules/jaf/jaf-sys-rule-disable.js +1 -1
- package/rules/jaf/jaf-sys-rule-opt.js +1 -1
- package/rules/jaf/jaf-sys-rule-pack-disable.js +1 -1
- package/rules/jaf/jaf-ts-diagnose.js +1 -1
- package/rules/jaf/jaf-ts-loader.js +1 -1
- package/rules/jaf/jaf-ts-noparser.js +1 -1
- package/rules/jaf/jaf-ts-precompile.js +1 -1
- package/rules/jaf/jaf-ts-walk.js +1 -1
- package/rules/jaf/msgid.json +1 -1
- package/rules/jaf/rules.json +1 -1
- 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-attrib-value.js +1 -1
- package/rules/jet/helpers/has-slot-name.js +1 -1
- 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/tsx/has-prop-value.js +1 -1
- package/rules/jet/helpers/tsx/has-slot-name.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-accessible.js +1 -1
- package/rules/jet/oj-acc-aria-labelledby.js +1 -1
- package/rules/jet/oj-acc-aria-ojselector-labelledby.js +1 -1
- package/rules/jet/oj-acc-aria-prop.js +1 -1
- package/rules/jet/oj-acc-avatar-aria-role.js +1 -1
- package/rules/jet/oj-acc-button-label.js +1 -1
- package/rules/jet/oj-acc-button-onclick.js +1 -1
- package/rules/jet/oj-acc-combobox-aria-label.js +1 -1
- package/rules/jet/oj-acc-film-strip-aria-label.js +1 -1
- package/rules/jet/oj-acc-input-aria-label.js +1 -1
- package/rules/jet/oj-acc-navigable-link.js +1 -1
- package/rules/jet/oj-acc-select-aria-label.js +1 -1
- 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-cca-compjson-prop-conflict.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-bp-zindex.js +1 -1
- package/rules/jet/oj-css-style-abs-units.js +1 -1
- 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 +1 -1
- package/rules/jet/oj-css-var-override.js +1 -1
- package/rules/jet/oj-form-maxcols.js +1 -1
- 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 +1 -1
- 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-expr-delims.js +1 -1
- package/rules/jet/oj-html-attr-expr-writeback.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-badge-maintenance.js +1 -1
- package/rules/jet/oj-html-bindforeach-data.js +1 -1
- package/rules/jet/oj-html-bindif-test.js +1 -1
- package/rules/jet/oj-html-binding-as-slot-child.js +1 -1
- package/rules/jet/oj-html-binding-attr.js +1 -1
- package/rules/jet/oj-html-bp-button-xs-chroming.js +1 -1
- package/rules/jet/oj-html-bp-title-to-tooltip.js +1 -1
- package/rules/jet/oj-html-btn-display-icon.js +1 -1
- package/rules/jet/oj-html-button-size-chroming.js +1 -1
- package/rules/jet/oj-html-cca-count.js +1 -1
- package/rules/jet/oj-html-cca-tagname.js +1 -1
- package/rules/jet/oj-html-cdn.js +1 -1
- package/rules/jet/oj-html-corequired.js +1 -1
- package/rules/jet/oj-html-databind-all.js +1 -1
- package/rules/jet/oj-html-dlg-title.js +1 -1
- package/rules/jet/oj-html-event-focus-blur.js +1 -1
- package/rules/jet/oj-html-file-pick-accept.js +1 -1
- package/rules/jet/oj-html-form-bindif.js +1 -1
- package/rules/jet/oj-html-form-layout-colspan-wrap.js +1 -1
- package/rules/jet/oj-html-form-layout-maxcols.js +1 -1
- package/rules/jet/oj-html-form-noflex.js +1 -1
- package/rules/jet/oj-html-input-isodate.js +1 -1
- package/rules/jet/oj-html-invalid-doctype.js +1 -1
- package/rules/jet/oj-html-jq-databind.js +1 -1
- package/rules/jet/oj-html-ko-comment.js +1 -1
- package/rules/jet/oj-html-ko-databind.js +1 -1
- 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 +1 -1
- package/rules/jet/oj-html-nav-tab-nointeractive.js +1 -1
- package/rules/jet/oj-html-no-style-tag.js +1 -1
- package/rules/jet/oj-html-no-style.js +1 -1
- package/rules/jet/oj-html-notag-style.js +1 -1
- package/rules/jet/oj-html-oj-lib.js +1 -1
- package/rules/jet/oj-html-oj-ux-ico-slot.js +1 -1
- package/rules/jet/oj-html-ojattr-deprecated.js +1 -1
- package/rules/jet/oj-html-ojattr-enum-deprecated.js +1 -1
- package/rules/jet/oj-html-ojattr-evt-syntax.js +1 -1
- package/rules/jet/oj-html-ojattr-value.js +1 -1
- package/rules/jet/oj-html-ojattr.js +1 -1
- package/rules/jet/oj-html-ojevent.js +1 -1
- package/rules/jet/oj-html-ojoption-text.js +2 -2
- package/rules/jet/oj-html-ojslot.js +1 -1
- package/rules/jet/oj-html-ojstyle.js +1 -1
- package/rules/jet/oj-html-ojtag-datacmd.js +1 -1
- package/rules/jet/oj-html-ojtag-datactx.js +1 -1
- package/rules/jet/oj-html-ojtag-deprecated.js +1 -1
- package/rules/jet/oj-html-ojtag-globattr-noprefix.js +1 -1
- package/rules/jet/oj-html-ojtag-id.js +1 -1
- package/rules/jet/oj-html-ojtag-nonglobattr-prefix.js +1 -1
- package/rules/jet/oj-html-ojtag-ns.js +1 -1
- package/rules/jet/oj-html-pageopts-type.js +1 -1
- package/rules/jet/oj-html-picker-attrs.js +1 -1
- package/rules/jet/oj-html-prop-anti-pattern.js +1 -1
- package/rules/jet/oj-html-public-api.js +1 -1
- package/rules/jet/oj-html-rating-gauge-size.js +1 -1
- package/rules/jet/oj-html-rating-gauge-track-resize.js +1 -1
- package/rules/jet/oj-html-redwood-bp-btn-avatar.js +1 -1
- package/rules/jet/oj-html-redwood-bp-endslot.js +1 -1
- package/rules/jet/oj-html-redwood-clear-icon.js +1 -1
- 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-redwood-ojoption-disabled.js +1 -1
- package/rules/jet/oj-html-self-close.js +1 -1
- package/rules/jet/oj-html-slot-default.js +1 -1
- package/rules/jet/oj-html-slot-deprecated.js +1 -1
- package/rules/jet/oj-html-slot-item-minmax.js +1 -1
- package/rules/jet/oj-html-slot-name.js +1 -1
- package/rules/jet/oj-html-slot-pref-content.js +1 -1
- package/rules/jet/oj-html-style-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-bp-margin-padding.js +1 -1
- package/rules/jet/oj-html-style-deprecated.js +1 -1
- package/rules/jet/oj-html-style.js +1 -1
- package/rules/jet/oj-html-stylesel.js +1 -1
- package/rules/jet/oj-html-tabbar-edge.js +1 -1
- package/rules/jet/oj-html-tabbar-progressive-popup.js +1 -1
- package/rules/jet/oj-html-tag-attr-noprefix.js +1 -1
- package/rules/jet/oj-html-template-index.js +1 -1
- package/rules/jet/oj-html-treeview-actionable-content.js +1 -1
- 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-anti-pattern.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 +1 -1
- package/rules/jet/oj-html-wctag-maintenance.js +1 -1
- package/rules/jet/oj-html-wctag-nested.js +1 -1
- package/rules/jet/oj-html-wctag-packprivate.js +1 -1
- package/rules/jet/oj-html-wctag-supersedes.js +1 -1
- package/rules/jet/oj-js-comp-attr-deprecated.js +1 -1
- package/rules/jet/oj-js-comp-meth-deprecated.js +1 -1
- 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-numconv-pattern.js +1 -1
- package/rules/jet/oj-js-ojcomp-deprecated.js +1 -1
- 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-public-api.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 +1 -1
- package/rules/jet/oj-ts-comp-meth-deprecated.js +1 -1
- 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-numconv-pattern.js +1 -1
- package/rules/jet/oj-ts-ojcomp-deprecated.js +1 -1
- 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/oj-tsx-5-tag-obs.js +1 -1
- package/rules/jet/oj-tsx-acc-aria-accessible.js +1 -1
- package/rules/jet/oj-tsx-acc-avatar-aria-role.js +1 -1
- package/rules/jet/oj-tsx-acc-button-label.js +1 -1
- package/rules/jet/oj-tsx-acc-button-onclick.js +1 -1
- package/rules/jet/oj-tsx-acc-navigable-link.js +1 -1
- package/rules/jet/oj-tsx-aria-ojselector-labelledby.js +1 -1
- package/rules/jet/oj-tsx-aria-prop.js +1 -1
- package/rules/jet/oj-tsx-attr-req.js +1 -1
- package/rules/jet/oj-tsx-bp-button-xs-chroming.js +1 -1
- package/rules/jet/oj-tsx-bp-title-to-tooltip.js +1 -1
- package/rules/jet/oj-tsx-button-size-chroming.js +1 -1
- package/rules/jet/oj-tsx-cca-tagname.js +1 -1
- package/rules/jet/oj-tsx-corequired.js +1 -1
- package/rules/jet/oj-tsx-databind-all.js +1 -1
- package/rules/jet/oj-tsx-dlg-title.js +1 -1
- package/rules/jet/oj-tsx-event.js +1 -1
- package/rules/jet/oj-tsx-form-bindif.js +1 -1
- package/rules/jet/oj-tsx-form-layout-colspan-wrap.js +1 -1
- package/rules/jet/oj-tsx-form-noflex.js +1 -1
- package/rules/jet/oj-tsx-input-isodate.js +1 -1
- package/rules/jet/oj-tsx-ojattr-deprecated.js +1 -1
- package/rules/jet/oj-tsx-ojattr-enum-deprecated.js +1 -1
- package/rules/jet/oj-tsx-ojattr-value.js +1 -1
- package/rules/jet/oj-tsx-ojattr.js +1 -1
- package/rules/jet/oj-tsx-ojoption-text.js +1 -1
- package/rules/jet/oj-tsx-ojtag-datacmd.js +1 -1
- package/rules/jet/oj-tsx-ojtag-deprecated.js +1 -1
- package/rules/jet/oj-tsx-ojtag-ns.js +1 -1
- package/rules/jet/oj-tsx-pageopts-type.js +1 -1
- package/rules/jet/oj-tsx-picker-attrs.js +1 -1
- package/rules/jet/oj-tsx-popup-sibling.js +1 -1
- package/rules/jet/oj-tsx-prop-anti-pattern.js +1 -1
- package/rules/jet/oj-tsx-prop-inline-definition.js +1 -1
- package/rules/jet/oj-tsx-prop-ko-binding.js +1 -1
- package/rules/jet/oj-tsx-rating-gauge-size.js +1 -1
- package/rules/jet/oj-tsx-rating-gauge-track-resize.js +1 -1
- package/rules/jet/oj-tsx-redwood-bp-btn-avatar.js +1 -1
- package/rules/jet/oj-tsx-redwood-clear-icon.js +1 -1
- package/rules/jet/oj-tsx-slot-default.js +1 -1
- package/rules/jet/oj-tsx-slot-deprecated.js +1 -1
- package/rules/jet/oj-tsx-slot-item-minmax.js +1 -1
- package/rules/jet/oj-tsx-slot-pref-content.js +1 -1
- package/rules/jet/oj-tsx-style-abs-units.js +1 -1
- package/rules/jet/oj-tsx-style-bp-margin-padding.js +1 -1
- package/rules/jet/oj-tsx-tabbar-edge.js +1 -1
- package/rules/jet/oj-tsx-tabbar-progressive-popup.js +1 -1
- package/rules/jet/oj-tsx-treeview-actionable-content.js +1 -1
- package/rules/jet/oj-tsx-unsup-theme.js +1 -1
- package/rules/jet/oj-tsx-wctag-anti-pattern.js +1 -1
- package/rules/jet/oj-tsx-wctag-maintenance.js +1 -1
- package/rules/jet/oj-tsx-wctag-nested.js +1 -1
- package/rules/jet/oj-tsx-wctag-packprivate.js +1 -1
- package/rules/jet/rules.json +2 -2
- package/src/JafCore.js +1 -1
package/LICENSE.md
CHANGED
|
@@ -17,7 +17,7 @@ limitations under the License.
|
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
```
|
|
20
|
-
Copyright (c) 2019,
|
|
20
|
+
Copyright (c) 2019, 2026 Oracle and/or its affiliates
|
|
21
21
|
Licensed under The Universal Permissive License (UPL), Version 1.0
|
|
22
22
|
as shown at https://oss.oracle.com/licenses/upl/
|
|
23
23
|
|
package/corePackMigrator/cli.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright (c) 2018,
|
|
2
|
+
* Copyright (c) 2018, 2026, 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{parseDocument,DomUtils}=require("htmlparser2");const render=require("dom-serializer").default;const logging=require("../utilities/logging");const self=require("./htmlUtils");const astUtils=require("./astUtils");function inManifestData(component){for(let obj of global.manifestData){if(obj.componentName&&obj.componentName===component.name){return obj}else if(obj.componentClass){if(component.attribs["class"]&&component.attribs["class"].includes(obj.componentClass)){return obj}}}return false}function checkFileUpdate(){if(!global.fileIsUpdated){global.fileIsUpdated=true;global.migrationMetrics.files+=1;logging.logFilePath(global.filePath);return true}return false}function _getLabelFromDOMNodeHelper(child,slotName,cnodes=[],label=""){const expRegex=/[\[{].*?[\]}]/g;if(child.type&&child.type=="text"){if(/\S/.test(child.data)){if(label){if(expRegex.test(label)){if(expRegex.test(child.data.trim())){label=label.endsWith("()]]")?`${label.substring(0,label.length-2)} + ${child.data.trim().substring(2,child.data.length-2)}()]]`:`${label.substring(0,label.length-2)}() + ${child.data.trim().substring(2,child.data.length-2)}()]]`}else{label=label.endsWith("()]]")?`${label.substring(0,label.length-2)} + ' ${child.data.trim()}']]`:`${label.substring(0,label.length-2)}() + ' ${child.data.trim()}']]`}}else{if(expRegex.test(child.data.trim())){label=`[['${label} ' + ${child.data.trim().substring(2,child.data.length-2)}()]]`}else{label+=" "+child.data.trim()}}}else{label=child.data.trim()}cnodes.push(child)}}else if(child.type&&child.type=="tag"&&child.name.toUpperCase()=="OJ-BIND-TEXT"&&(!slotName&&!child.attribs.slot||slotName&&child.attribs.slot===slotName)){if(label){if(expRegex.test(label)){if(expRegex.test(child.attribs.value)){label=label.endsWith("()]]")?`${label.substring(0,label.length-2)}() + ${child.attribs.value.substring(2,child.attribs.value.length-2)}()]]`:`${label.substring(0,label.length-2)} + ${child.attribs.value.substring(2,child.attribs.value.length-2)}()]]`}else{label=label.endsWith("()]]")?`${label.substring(0,label.length-2)} + ' ${child.attribs.value}']]`:`${label.substring(0,label.length-2)}() + ' ${child.attribs.value}']]`}}else{if(expRegex.test(child.attribs.value)){label=`[['${label} ' + ${child.attribs.value.substring(2,child.attribs.value.length-2)}()]]`}else{label+=" "+child.attribs.value}}}else{label=child.attribs.value}cnodes.push(child)}else if(child.children&&!!child.children.length){if(child.attribs.slot===slotName||!slotName&&!child.attribs.slot){var regex=new RegExp("^[^\\dA-Za-z]*$");for(let c of child.children){label=_getLabelFromDOMNodeHelper(c,slotName,cnodes,label);if(c.type==="text"&®ex.test(c.data)){cnodes.push(c)}}cnodes.push(child)}}return label}function _getLabelFromDOMNode(node,slotName,label=""){if(node&&node.children&&!!node.children.length){let cnodes=[];for(let child of node.children){label=_getLabelFromDOMNodeHelper(child,slotName,cnodes,label)}if(cnodes.length>0){for(let node of cnodes){DomUtils.removeElement(node)}}}return label}function _findDescendant(component,tagName,slotName){if(component.children){for(let child of component.children){if(child.name===tagName){if(!slotName||child.attribs.slot&&child.attribs.slot===slotName){return child}}else if(child.children){const descendant=_findDescendant(child,tagName);if(descendant){return descendant}}}}return false}function getDom(text=""){return parseDocument(text,{withStartIndices:true,withEndIndices:true})}function _transferAttribute(fromTag,toTag,attribute,value,joined){if(fromTag.attribs[attribute]||joined&&fromTag.attribs[joined]){toTag.attribs[attribute]=value;delete fromTag.attribs[attribute]?fromTag.attribs[attribute]:fromTag.attribs[joined]}}function _hasAttributesToIgnoreHelper(dom,component,rule,key,parent,corePackTag,modelCode){if(rule.missPeerTag){const peerRule=rule.missPeerTag;for(let tagAttrSet of peerRule.tagAttributes){let tag=tagAttrSet.name;for(let attrSet of peerRule.matchValues){const peer=_findPeer(dom,component,tag,attrSet.ownAttribute,attrSet.peerAttribute);if(peer){let migratable=true;if(tagAttrSet.attribute){for(let set of tagAttrSet.attribute){migratable=_hasAttributesToIgnoreHelper(dom,peer,{"missAttribute":set});if(!migratable){break}}}if(tagAttrSet.missSlot&&migratable){migratable=_findAttribute(peer,"slot",peerRule.missSlot)?true:false}if(tagAttrSet.mapper&&migratable){migratable=modelCode?true:false}if(tagAttrSet.descendant&&migratable){migratable=!_hasAttributesToIgnoreHelper(dom,peer,tagAttrSet.descendant)}if(migratable){return false}}}}return true};if(rule.missDescendant){const descRule=rule.missDescendant;for(let tagAttrSet of descRule.tagAttributes){let tag=tagAttrSet.name;const desc=_findDescendant(component,tag,tagAttrSet.missSlot);if(desc){let migratable=true;if(tagAttrSet.attribute){for(let set of tagAttrSet.attribute){migratable=_hasAttributesToIgnoreHelper(dom,desc,{"missAttribute":set});if(!migratable){break}}}if(tagAttrSet.mapper&&migratable){migratable=modelCode?true:false}if(tagAttrSet.descendant&&migratable){migratable=!_hasAttributesToIgnoreHelper(dom,desc,tagAttrSet.descendant)}if(migratable){return false}}}return true};if(!rule.descendant&&component.attribs){if(rule.missAttribute){for(let key in rule.missAttribute){if(_findAttribute(component,key,rule.missAttribute[key])){return false}}if(corePackTag){checkFileUpdate();logging.logIgnoreComponent(component.name,rule.missAttribute,"",parent,true)}return true}if(rule.attribute&&!rule.typeDefined){let attr=_findAttribute(component,rule.attribute);if(attr){rule.attribute=attr.attribute;if(rule.allowedValues&&!rule.allowedValues.includes(component.attribs[rule.attribute])||rule.prohibitedValues&&rule.prohibitedValues.includes(component.attribs[rule.attribute])||!rule.allowedValues&&!rule.prohibitedValues){if(corePackTag){checkFileUpdate();let value=(rule.allowedValues||rule.prohibitedValues)&&component.attribs[rule.attribute]?component.attribs[rule.attribute]:"";logging.logIgnoreComponent(component.name,rule.attribute,value,parent)}return true}}}else if(component.attribs[key]&&component.attribs[key]===rule[key]){if(corePackTag){checkFileUpdate();logging.logIgnoreComponent(component.name,key,rule[key],parent)}return true}}if(component.children){for(let j=0;j<component.children.length;j++){const child=component.children[j];if(child.type==="tag"){if(rule.descendant){if(child.name===rule.descendant){if(rule.attribute){const attr=_findAttribute(child,rule.attribute);if(attr){rule.attribute=attr.attribute;if(rule.allowedValues&&!rule.allowedValues.includes(child.attribs[rule.attribute])||rule.prohibitedValues&&rule.prohibitedValues.includes(child.attribs[rule.attribute])||!rule.prohibitedValues&&!rule.allowedValues){if(corePackTag){checkFileUpdate();logging.logIgnoreComponent(child.name,rule.attribute,child.attribs[rule.attribute],parent)}return true}}}else if(rule.slotName&&child.attribs["slot"]&&child.attribs["slot"]===rule.slotName){if(corePackTag){checkFileUpdate();logging.logIgnoreComponent(child.name,"slot",child.attribs[rule.attribute],parent)}return true}else if(rule.missSlot){if(!child.attribs["slot"]||child.attribs["slot"]!==rule.missSlot){if(corePackTag){checkFileUpdate();logging.logIgnoreComponent(child.name,"slot",rule.missSlot,parent,true)}return true}else if(child.attribs["slot"]&&child.attribs["slot"]===rule.missSlot){return false}}else{if(corePackTag){checkFileUpdate();logging.logIgnoreComponent(rule.descendant,"","",parent)}return true}}else if(_hasAttributesToIgnoreHelper(dom,child,rule,key,parent,corePackTag)){return true}}if(!rule.attribute&&!rule.missAttribute&&_hasAttributesToIgnoreHelper(dom,child,rule,key,parent,corePackTag)){if(corePackTag){checkFileUpdate();logging.logIgnoreComponent(component.name,key,rule[key])}return true}}}}}function _toCamelCase(attribute){let camelCaseName=attribute.split("-");for(let i in camelCaseName){if(i>0){camelCaseName[i]=camelCaseName[i][0].toUpperCase()+camelCaseName[i].slice(1)}}camelCaseName=camelCaseName.join("");return camelCaseName}function _findAttribute(component,name,value=""){if(name){const joined=name.split("-").join("");if(DomUtils.hasAttrib(component,name)&&(!value||value===component.attribs[name])){return{attribute:name,attrValue:component.attribs[name]}}else if(DomUtils.hasAttrib(component,joined)&&(!value||value===component.attribs[joined])){return{attribute:joined,format:"camel",attrValue:component.attribs[joined]}}else if(DomUtils.hasAttrib(component,`:${name}`)&&(!value||value===component.attribs[`:${name}`])){return{attribute:`:${name}`,format:"colon",attrValue:component.attribs[`:${name}`]}}else if(DomUtils.hasAttrib(component,`:${joined}`)&&(!value||value===component.attribs[`:${joined}`])){return{attribute:`:${joined}`,format:"colonCamel",attrValue:component.attribs[`:${joined}`]}}}return false}function _findPeer(dom,component,peerTag,componentAttr,peerAttr){const attributeValue=_findAttribute(component,componentAttr).attrValue;if(attributeValue){const peer=DomUtils.findOne(elem=>elem.name===peerTag&&_findAttribute(elem,peerAttr,attributeValue),dom.children);return peer}}function hasAttributesToIgnore(dom,component,metadata,parent="",modelCode){const ignoreRuleData=metadata.ruleSetToIgnore;if(ignoreRuleData){for(let i=0;i<ignoreRuleData.length;i++){rule=ignoreRuleData[i];let arr=Object.keys(rule);let key=arr[0];if(!rule.type){if(rule.descendant){parent=component.name}if(_hasAttributesToIgnoreHelper(dom,component,rule,key,parent,metadata.corePackTag,modelCode)){return true}}}}return false}function hasExpressionAttributes(component,componentName,importantAttributes){const excludedAttributes=global.configData.excludeAttributeExpressions[componentName];const regex=new RegExp(`((\\{\\{)|(\\[\\[)).*((\\}\\})|(\\]\\]))`);if(global.jaf.options.dryRunMode&&importantAttributes){for(let attribute of importantAttributes){if(component.attribs[`:${attribute}`]){attribute=`:${attribute}`}if(regex.test(component.attribs[attribute])){if(checkFileUpdate()){logging.logAttributeExpression(componentName,attribute,component.attribs[attribute])}}}}if(excludedAttributes&&excludedAttributes.length){for(let i=0;i<excludedAttributes.length;i++){if(component.attribs[`:${excludedAttributes[i]}`]){excludedAttributes[i]=`:${excludedAttributes[i]}`}if(regex.test(component.attribs[excludedAttributes[i]])){checkFileUpdate();logging.logExcludeAttributeExpression(componentName,excludedAttributes[i],component.attribs[excludedAttributes[i]]);return true}}}return false}function commentSlotContent(component,data){const slotValue=data.slot;for(let child of component.children){if(child.name&&child.attribs.slot==slotValue){const cnode=getDom("<!-- "+render(child,{decodeEntities:false})+" -->");DomUtils.replaceElement(child,cnode);checkFileUpdate();return[logging.logCommentSlotContent(component.name,slotValue,child.name)]}};}function slotContentToAttribute(component,data,dom){let logs=[];for(let obj of data){let toNode;if(obj.toDescendant){const descendant=_findDescendant(component,obj.toDescendant,obj.slotNameTo?obj.slotNameTo:"");if(descendant){toNode=descendant}else{continue}}if(obj.fromDescendant){const descendant=_findDescendant(component,obj.fromDescendant,obj.slotNameFrom?obj.slotNameFrom:"");if(descendant){component=descendant}else{continue}}if(obj.toPeer||obj.fromPeer){const peer=_findPeer(dom,component,obj.toPeer?obj.toPeer:obj.fromPeer,obj.ownAttribute,obj.peerAttribute);if(peer){if(obj.toPeer){toNode=peer}else{component=peer}}else{continue}}if(!Object.keys(component.attribs).includes(obj.attribute)){component.attribs[obj.attribute]=_getLabelFromDOMNode(component,data.slotNameFrom);if(!component.attribs[obj.attribute]){delete component.attribs[obj.attribute]}else{checkFileUpdate();logs.push(logging.logSlotContentToAttribute(component.name,obj.attribute,component.attribs[obj.attribute]));if(toNode){_transferAttribute(component,toNode,obj.attribute,component.attribs[obj.attribute]);logs.push(logging.logAttributeTransfer(component.name,toNode.name,obj.attribute,toNode.attribs[obj.attribute]))}return logs}}}}function migrateTag(component,legacyComponentName,coreComponentName,isDescendant){component.name=coreComponentName;checkFileUpdate();global.migrationMetrics.components+=1;return logging.logTagMigration(legacyComponentName,coreComponentName,isDescendant)}function migrateClassToTag(component,legacyClassName,coreComponentName,isDescendant){const fromTag=component.name;component.name=coreComponentName;classNames=component.attribs.class.split(" ");index=classNames.indexOf(legacyClassName);classNames.splice(index,1);if(classNames.length===0){delete component.attribs.class}else{component.attribs.class=classNames.join(" ")}checkFileUpdate();global.migrationMetrics.components+=1;return logging.logClassToTagMigration(fromTag,legacyClassName,coreComponentName,isDescendant)}function migrateTagByAttribute(component,data,isDescendant){for(const tagSet of data){if(tagSet.attribute){const attribute=_findAttribute(component,tagSet.attribute,tagSet.attributeValue);if(attribute){component.name=tagSet.toTag;checkFileUpdate();global.migrationMetrics.components+=1;return logging.logTagMigration(tagSet.fromTag,tagSet.toTag,isDescendant)}}else{component.name=tagSet.toTag;checkFileUpdate();global.migrationMetrics.components+=1;return logging.logTagMigration(tagSet.fromTag,tagSet.toTag)}}};function classNameToAttribute(component,data){let logs=[];data.forEach(obj=>{const from=obj.className;const to=obj.attributeValue;const attribute=obj.attribute;if(component.attribs.class){classNames=component.attribs.class.split(" ");if(typeof obj.className==="string"&&classNames.includes(obj.className)){index=classNames.indexOf(from);classNames.splice(index,1);component.attribs[attribute]=to;checkFileUpdate();logs.push(logging.logClassNameToAttribute(from,attribute,to))}else if(typeof obj.className==="object"&&from.every(c=>classNames.includes(c))){obj.className.forEach(cl=>{index=classNames.indexOf(cl);classNames.splice(index,1)});component.attribs[attribute]=to;checkFileUpdate();logs.push(logging.logClassNameToAttribute(from,attribute,to))}if(classNames.length==0)delete component.attribs.class;else component.attribs.class=classNames.join(" ")}});return logs}function migrateAttributes(component,data,dom){let toNode;let logs=[];for(const attributeSet in data){let camelFromAttribute="";let camelToAttribute="";let tagExists=true;let obj=data[attributeSet];if(obj.fromDescendant||obj.fromPeer||obj.toDescendant||obj.toPeer){tagExists=false;if(obj.fromDescendant||obj.toDescendant){const descendant=_findDescendant(component,obj.fromDescendant?obj.fromDescendant:obj.toDescendant,obj.slotName);if(component.children&&descendant){tagExists=true;if(obj.fromDescendant){toNode=component;component=descendant}else{toNode=descendant}}else{continue}}else{const peerTag=_findPeer(dom,component,obj.toPeer?obj.toPeer:obj.fromPeer,obj.ownAttribute,obj.peerAttribute);if(peerTag){tagExists=true;if(obj.fromPeer){toNode=component;component=peerTag}else{toNode=peerTag}}else{continue}}}if(tagExists){let hasDepAttribute=true;if(obj.depAttribute){hasDepAttribute=_findAttribute(component,obj.depAttribute)}const hasFromAttribute=_findAttribute(component,obj.fromAttribute,obj.fromValue);let fromAttribute=obj.fromAttribute;if(hasFromAttribute){fromAttribute=hasFromAttribute.attribute}let toAttribute=obj.toAttribute;if(hasFromAttribute.format){if(toAttribute){if(hasFromAttribute.format==="camel"){toAttribute=toAttribute.split("-").join("")}else if(hasFromAttribute.format==="colonCamel"){toAttribute=`:${toAttribute.split("-").join("")}`}else{toAttribute=`:${toAttribute}`}}}const hasToAttribute=_findAttribute(component,toAttribute);if(!(obj.fromAttribute===obj.toAttribute&&obj.fromValue===obj.toValue)){if(hasDepAttribute&&hasFromAttribute&&toAttribute&&(!hasToAttribute||fromAttribute===toAttribute)){if(obj.toValue){switch(hasFromAttribute.format){case"camel":camelFromAttribute=_toCamelCase(obj.fromAttribute);camelToAttribute=_toCamelCase(obj.toAttribute);break;case"colonCamel":camelFromAttribute=`:${_toCamelCase(obj.fromAttribute)}`;camelToAttribute=`:${_toCamelCase(obj.toAttribute)}`;break}component.attribs[camelToAttribute?camelToAttribute:toAttribute]=obj.toValue;checkFileUpdate();logs.push(logging.logAttributeMigration(camelFromAttribute?camelFromAttribute:fromAttribute,obj.fromValue,camelToAttribute?camelToAttribute:toAttribute,obj.toValue))}else{let fromValue=obj.fromValue?obj.fromValue:component.attribs[fromAttribute];switch(hasFromAttribute.format){case"camel":camelFromAttribute=_toCamelCase(obj.fromAttribute);camelToAttribute=_toCamelCase(obj.toAttribute);break;case"colonCamel":camelFromAttribute=`:${_toCamelCase(obj.fromAttribute)}`;camelToAttribute=`:${_toCamelCase(obj.toAttribute)}`;break}if(obj.fromValue){component.attribs[camelToAttribute?camelToAttribute:toAttribute]=""}else{component.attribs[camelToAttribute?camelToAttribute:toAttribute]=component.attribs[fromAttribute]}checkFileUpdate();logs.push(logging.logAttributeMigration(camelFromAttribute?camelFromAttribute:fromAttribute,fromValue,camelToAttribute?camelToAttribute:toAttribute))}if(fromAttribute!==toAttribute){delete component.attribs[fromAttribute]}}else if(hasDepAttribute&&hasFromAttribute&&!toAttribute){delete component.attribs[fromAttribute];switch(hasFromAttribute.format){case"camel":fromAttribute=_toCamelCase(obj.fromAttribute);break;case"colonCamel":fromAttribute=`:${_toCamelCase(obj.fromAttribute)}`;break}checkFileUpdate();logs.push(logging.logAttributeDeprecation(fromAttribute,obj.fromValue))}else if(hasDepAttribute&&!obj.fromAttribute&&obj.toAttribute&&!hasToAttribute){if(toNode){toNode.attribs[obj.toAttribute]=obj.toValue}else{component.attribs[obj.toAttribute]=obj.toValue}checkFileUpdate();logs.push(logging.logAttributeAddition(obj.toAttribute,obj.toValue,toNode?toNode.name:""))}}if(toNode&&hasFromAttribute){switch(hasFromAttribute.format){case"camel":camelToAttribute=_toCamelCase(obj.toAttribute);break;case"colonCamel":camelToAttribute=`:${_toCamelCase(obj.toAttribute)}`;break}checkFileUpdate();_transferAttribute(component,toNode,camelToAttribute?camelToAttribute:toAttribute,component.attribs[camelToAttribute?camelToAttribute:toAttribute],toAttribute);const toValue=toNode.attribs[camelToAttribute?camelToAttribute:toAttribute];logs.push(logging.logAttributeTransfer(component.name,toNode.name,camelToAttribute?camelToAttribute:toAttribute,toValue));if(obj.fromDescendant||obj.fromPeer){component=toNode}}}}return logs}function handleSpecialCase(code,componentName,data){let obj;let regex;if(data[1]){obj=data[1];regex=new RegExp(obj.fromString.split(" ").join("\\s*"),"igm");code=code.replace(regex,obj.toString)}obj=data[0];regex=new RegExp(obj.fromString.split(" ").join("\\s*"),"igm");code=code.replace(regex,obj.toString);return code}function _migrateDescendantsHelper(dom,children,componentMetadata,parent,compCount,modelCode,fileMigratedCount,revertMig,logs=[]){let descendants=[];for(let child of children){let newLogs=[];if(child.name===componentMetadata.legacyTag&&!revertMig){let componentCopy=child.cloneNode(true);descendants.push({original:child,copy:componentCopy});if(!hasAttributesToIgnore(dom,child,componentMetadata,parent)&&!hasExpressionAttributes(child,componentMetadata.legacyTag,componentMetadata.importantAttributes)){if(componentMetadata["migrateTagByAttribute"]){newLogs.push(migrateTagByAttribute(child,componentMetadata["migrateTagByAttribute"],true))}else{newLogs.push(migrateTag(child,componentMetadata.legacyTag,componentMetadata.corePackTag,true))}for(let key in componentMetadata){if(typeof self[key]=="function"&&key!="migrateTagByAttribute"&&key!="migrateImports"&&key!="migrateOptions"){newLogs=newLogs.concat(self[key](child,componentMetadata[key]))}else if(key==="migrateOptions"){let info=migrateOptions(child,componentMetadata[key],modelCode,fileMigratedCount,componentMetadata.legacyTag);if(!modelCode&&info){logging.logMapperRequest(componentMetadata.legacyTag);revertMig=true}else if(info){if(info.revert){revertMig=true}else{modelCode=info.mCode;newLogs=newLogs.concat(info.newLogs)}}}}if(!compCount.migrated[componentMetadata.legacyTag]){compCount.migrated[componentMetadata.legacyTag]=1}else{compCount.migrated[componentMetadata.legacyTag]+=1}if(revertMig){for(let obj of descendants){DomUtils.replaceElement(obj.original,obj.copy);global.migrationMetrics.components-=1;compCount.migrated[componentMetadata.legacyTag]-=1;if(compCount.migrated[componentMetadata.legacyTag]===0){delete compCount.migrated[componentMetadata.legacyTag]}if(compCount.skipped[componentMetadata.legacyTag]){compCount.skipped[componentMetadata.legacyTag]+=1}else{compCount.skipped[componentMetadata.legacyTag]=1}}}}}else{if(child.name===componentMetadata.legacyTag&&revertMig){if(compCount.skipped[componentMetadata.legacyTag]){compCount.skipped[componentMetadata.legacyTag]+=1}else{compCount.skipped[componentMetadata.legacyTag]=1}}else if(child.children){returnValue=_migrateDescendantsHelper(dom,child.children,componentMetadata,parent,compCount);newLogs=newLogs.concat(returnValue.logs);compCount=returnValue.count;revertMig=returnValue.revert}}if(!revertMig){logs=logs.concat(newLogs)}}return{logs:logs,count:compCount,mCode:modelCode,revert:revertMig}}function migrateDescendants(dom,component,metadata,modelCode,fileComponentsInfo,logs=[]){let compCount={migrated:{},skipped:{}};const data=metadata.migrateDescendants;let returnValue=false;let revertMig;for(let metaName of data){let componentMetadata=require("../metadata/"+metaName+".json");let fileMigratedCount=fileComponentsInfo.migrated[componentMetadata.legacyTag]?fileComponentsInfo.migrated[componentMetadata.legacyTag]:0;if(component.children){returnValue=_migrateDescendantsHelper(dom,component.children,componentMetadata,metadata.legacyTag,compCount,modelCode,fileMigratedCount,revertMig);if(returnValue){logs=logs.concat(returnValue.logs);modelCode=returnValue.mCode;revertMig=returnValue.revert;compCount=returnValue.count}}}return{logs:logs,count:compCount,mCode:modelCode}}function removeNode(component){DomUtils.removeElement(component);return logging.logComponentRemoved(component.name)}function replaceComponent(fromNode,data){for(let obj of data){let descendant=_findDescendant(fromNode,obj.descendant);if(descendant){DomUtils.replaceElement(fromNode,descendant);return logging.logComponentReplacement(fromNode.name,descendant.name)}}}function migrateOptions(component,data,modelCode,compCount,legacyTag){if(modelCode){if(!_findAttribute(component,data.toAttribute)&&(_findDescendant(component,"oj-option")||_findDescendant(component,"template"))){let optionsInfo=[];let tag=legacyTag.slice(3);tag=tag[0].toUpperCase()+tag.slice(1);let varName=`optionsMig${tag}${compCount}`;let template;for(let child of component.children){if(child.name==="oj-option"){for(let ignoreAttr of data.ignoreAttribute){if(child.attribs[ignoreAttr]){logging.logIgnoreComponent(child.name,ignoreAttr,"",legacyTag);return{revert:true}}}child.attribs.label=_getLabelFromDOMNode(child,"");if(child.children){for(let c of child.children){if(c.name==="span"||c.name==="div"){if(c.attribs.slot&&c.attribs.class){child.attribs[c.attribs.slot]={"class":c.attribs.class}}}else if(c.name==="oj-avatar"){if(c.attribs.slot){if(c.attribs.src&&c.attribs.role){child.attribs[c.attribs.slot]={"type":c.attribs.role,"src":c.attribs.src}}else{child.attribs[c.attribs.slot]={"class":c.attribs.class}}}}}}optionsInfo.push(child.attribs);DomUtils.removeElement(child)}else if(child.name==="oj-bind-for-each"){template=child.attribs.data.slice(2,child.attribs.data.length-2);let optionComp=_findDescendant(child,"oj-option");for(let ignoreAttr of data.ignoreAttribute){if(optionComp.attribs[ignoreAttr]){logging.logIgnoreComponent(optionComp.name,ignoreAttr,"",legacyTag);return{revert:true}}}optionComp.attribs.label=_getLabelFromDOMNode(optionComp,"");if(optionComp.children){for(let c of optionComp.children){if(c.name==="span"||c.name==="div"){if(c.attribs.slot&&c.attribs.class){optionComp.attribs[c.attribs.slot]={"class":c.attribs.class}}}else if(c.name==="oj-avatar"){if(c.attribs.slot){if(c.attribs.src&&c.attribs.role){optionComp.attribs[c.attribs.slot]={"type":c.attribs.role,"src":c.attribs.src}}else{optionComp.attribs[c.attribs.slot]={"class":c.attribs.class}}}}}}optionsInfo.push(optionComp.attribs);DomUtils.removeElement(child)}}let varValue=optionsInfo;let info=astUtils.migrateOptionsModel(data,varName,varValue,modelCode,template);if(info){if(info.emptyModel){logging.logIgnoreComponent(legacyTag,"","","","To migrate data driven component, model file provided needs a class where a new variable can be created");return{revert:true}}else{varName=info.varName;let code=info.code;let logs=info.logs;component.attribs[data.toAttribute]=`[[${varName}]]`;return{"mCode":code,"newLogs":logs}}}else{return false}}else{return false}}if(!component.attribs[data.toAttribute]&&(_findDescendant(component,"oj-option")||_findDescendant(component,"template"))){return{"mCode":modelCode,"newLogs":[]}}return false}exports.getDom=getDom;exports.inManifestData=inManifestData;exports.checkFileUpdate=checkFileUpdate;exports.hasAttributesToIgnore=hasAttributesToIgnore;exports.hasExpressionAttributes=hasExpressionAttributes;exports.slotContentToAttribute=slotContentToAttribute;exports.commentSlotContent=commentSlotContent;exports.migrateTag=migrateTag;exports.migrateClassToTag=migrateClassToTag;exports.classNameToAttribute=classNameToAttribute;exports.handleSpecialCase=handleSpecialCase;exports.migrateAttributes=migrateAttributes;exports.migrateTagByAttribute=migrateTagByAttribute;exports.migrateDescendants=migrateDescendants;exports.replaceComponent=replaceComponent;exports.removeNode=removeNode;exports.migrateOptions=migrateOptions;
|
|
6
|
+
const{parseDocument,DomUtils}=require("htmlparser2");const render=require("dom-serializer").default;const logging=require("../utilities/logging");const self=require("./htmlUtils");const astUtils=require("./astUtils");function inManifestData(component){for(let obj of global.manifestData){if(obj.componentName&&obj.componentName===component.name){return obj}else if(obj.componentClass){const classAttr=_findAttribute(component,"class");const expRegex=/^(?:\[\[.*\]\]|\{\{.*\}\})$/;if(classAttr&&classAttr.attrValue&&expRegex.test(classAttr.attrValue)===false&&classAttr.attrValue.includes(obj.componentClass)){return obj}}}return false}function checkFileUpdate(){if(!global.fileIsUpdated){global.fileIsUpdated=true;global.migrationMetrics.files+=1;logging.logFilePath(global.filePath);return true}return false}function _getLabelFromDOMNodeHelper(child,slotName,cnodes=[],label=""){const expRegex=/[\[{].*?[\]}]/g;if(child.type&&child.type=="text"){if(/\S/.test(child.data)){if(label){if(expRegex.test(label)){if(expRegex.test(child.data.trim())){label=label.endsWith("()]]")?`${label.substring(0,label.length-2)} + ${child.data.trim().substring(2,child.data.length-2)}()]]`:`${label.substring(0,label.length-2)}() + ${child.data.trim().substring(2,child.data.length-2)}()]]`}else{label=label.endsWith("()]]")?`${label.substring(0,label.length-2)} + ' ${child.data.trim()}']]`:`${label.substring(0,label.length-2)}() + ' ${child.data.trim()}']]`}}else{if(expRegex.test(child.data.trim())){label=`[['${label} ' + ${child.data.trim().substring(2,child.data.length-2)}()]]`}else{label+=" "+child.data.trim()}}}else{label=child.data.trim()}cnodes.push(child)}}else if(child.type&&child.type=="tag"&&child.name.toUpperCase()=="OJ-BIND-TEXT"&&(!slotName&&!child.attribs.slot||slotName&&child.attribs.slot===slotName)){if(label){if(expRegex.test(label)){if(expRegex.test(child.attribs.value)){label=label.endsWith("()]]")?`${label.substring(0,label.length-2)}() + ${child.attribs.value.substring(2,child.attribs.value.length-2)}()]]`:`${label.substring(0,label.length-2)} + ${child.attribs.value.substring(2,child.attribs.value.length-2)}()]]`}else{label=label.endsWith("()]]")?`${label.substring(0,label.length-2)} + ' ${child.attribs.value}']]`:`${label.substring(0,label.length-2)}() + ' ${child.attribs.value}']]`}}else{if(expRegex.test(child.attribs.value)){label=`[['${label} ' + ${child.attribs.value.substring(2,child.attribs.value.length-2)}()]]`}else{label+=" "+child.attribs.value}}}else{label=child.attribs.value}cnodes.push(child)}else if(child.children&&!!child.children.length){if(child.attribs.slot===slotName||!slotName&&!child.attribs.slot){var regex=new RegExp("^[^\\dA-Za-z]*$");for(let c of child.children){label=_getLabelFromDOMNodeHelper(c,slotName,cnodes,label);if(c.type==="text"&®ex.test(c.data)){cnodes.push(c)}}cnodes.push(child)}}return label}function _getLabelFromDOMNode(node,slotName,label=""){if(node&&node.children&&!!node.children.length){let cnodes=[];for(let child of node.children){label=_getLabelFromDOMNodeHelper(child,slotName,cnodes,label)}if(cnodes.length>0){for(let node of cnodes){DomUtils.removeElement(node)}}}return label}function _findDescendant(component,tagName,slotName){if(component.children){for(let child of component.children){if(child.name===tagName){if(!slotName||child.attribs.slot&&child.attribs.slot===slotName){return child}}else if(child.children){const descendant=_findDescendant(child,tagName);if(descendant){return descendant}}}}return false}function getDom(text=""){return parseDocument(text,{withStartIndices:true,withEndIndices:true})}function _transferAttribute(fromTag,toTag,attribute,value,joined){if(fromTag.attribs[attribute]||joined&&fromTag.attribs[joined]){toTag.attribs[attribute]=value;delete fromTag.attribs[attribute]?fromTag.attribs[attribute]:fromTag.attribs[joined]}}function _hasAttributesToIgnoreHelper(dom,component,rule,key,parent,corePackTag,modelCode){if(rule.missPeerTag){const peerRule=rule.missPeerTag;for(let tagAttrSet of peerRule.tagAttributes){let tag=tagAttrSet.name;for(let attrSet of peerRule.matchValues){const peer=_findPeer(dom,component,tag,attrSet.ownAttribute,attrSet.peerAttribute);if(peer){let migratable=true;if(tagAttrSet.attribute){for(let set of tagAttrSet.attribute){migratable=_hasAttributesToIgnoreHelper(dom,peer,{"missAttribute":set});if(!migratable){break}}}if(tagAttrSet.missSlot&&migratable){migratable=_findAttribute(peer,"slot",peerRule.missSlot)?true:false}if(tagAttrSet.mapper&&migratable){migratable=modelCode?true:false}if(tagAttrSet.descendant&&migratable){migratable=!_hasAttributesToIgnoreHelper(dom,peer,tagAttrSet.descendant)}if(migratable){return false}}}}return true};if(rule.missDescendant){const descRule=rule.missDescendant;for(let tagAttrSet of descRule.tagAttributes){let tag=tagAttrSet.name;const desc=_findDescendant(component,tag,tagAttrSet.missSlot);if(desc){let migratable=true;if(tagAttrSet.attribute){for(let set of tagAttrSet.attribute){migratable=_hasAttributesToIgnoreHelper(dom,desc,{"missAttribute":set});if(!migratable){break}}}if(tagAttrSet.mapper&&migratable){migratable=modelCode?true:false}if(tagAttrSet.descendant&&migratable){migratable=!_hasAttributesToIgnoreHelper(dom,desc,tagAttrSet.descendant)}if(migratable){return false}}}return true};if(!rule.descendant&&component.attribs){if(rule.missAttribute){for(let key in rule.missAttribute){if(_findAttribute(component,key,rule.missAttribute[key])){return false}}if(corePackTag){checkFileUpdate();logging.logIgnoreComponent(component.name,rule.missAttribute,"",parent,true)}return true}if(rule.attribute&&!rule.typeDefined){let attr=_findAttribute(component,rule.attribute);if(attr){rule.attribute=attr.attribute;if(rule.allowedValues&&!rule.allowedValues.includes(component.attribs[rule.attribute])||rule.prohibitedValues&&rule.prohibitedValues.includes(component.attribs[rule.attribute])||!rule.allowedValues&&!rule.prohibitedValues){if(corePackTag){checkFileUpdate();let value=(rule.allowedValues||rule.prohibitedValues)&&component.attribs[rule.attribute]?component.attribs[rule.attribute]:"";logging.logIgnoreComponent(component.name,rule.attribute,value,parent)}return true}}}else if(component.attribs[key]&&component.attribs[key]===rule[key]){if(corePackTag){checkFileUpdate();logging.logIgnoreComponent(component.name,key,rule[key],parent)}return true}}if(component.children){for(let j=0;j<component.children.length;j++){const child=component.children[j];if(child.type==="tag"){if(rule.descendant){if(child.name===rule.descendant){if(rule.attribute){const attr=_findAttribute(child,rule.attribute);if(attr){rule.attribute=attr.attribute;if(rule.allowedValues&&!rule.allowedValues.includes(child.attribs[rule.attribute])||rule.prohibitedValues&&rule.prohibitedValues.includes(child.attribs[rule.attribute])||!rule.prohibitedValues&&!rule.allowedValues){if(corePackTag){checkFileUpdate();logging.logIgnoreComponent(child.name,rule.attribute,child.attribs[rule.attribute],parent)}return true}}}else if(rule.slotName&&child.attribs["slot"]&&child.attribs["slot"]===rule.slotName){if(corePackTag){checkFileUpdate();logging.logIgnoreComponent(child.name,"slot",child.attribs[rule.attribute],parent)}return true}else if(rule.missSlot){if(!child.attribs["slot"]||child.attribs["slot"]!==rule.missSlot){if(corePackTag){checkFileUpdate();logging.logIgnoreComponent(child.name,"slot",rule.missSlot,parent,true)}return true}else if(child.attribs["slot"]&&child.attribs["slot"]===rule.missSlot){return false}}else{if(corePackTag){checkFileUpdate();logging.logIgnoreComponent(rule.descendant,"","",parent)}return true}}else if(_hasAttributesToIgnoreHelper(dom,child,rule,key,parent,corePackTag)){return true}}if(!rule.attribute&&!rule.missAttribute&&_hasAttributesToIgnoreHelper(dom,child,rule,key,parent,corePackTag)){if(corePackTag){checkFileUpdate();logging.logIgnoreComponent(component.name,key,rule[key])}return true}}}}}function _toCamelCase(attribute){let camelCaseName=attribute.split("-");for(let i in camelCaseName){if(i>0){camelCaseName[i]=camelCaseName[i][0].toUpperCase()+camelCaseName[i].slice(1)}}camelCaseName=camelCaseName.join("");return camelCaseName}function _findAttribute(component,name,value=""){if(name){const joined=name.split("-").join("");if(DomUtils.hasAttrib(component,name)&&(!value||value===component.attribs[name])){return{attribute:name,attrValue:component.attribs[name]}}else if(DomUtils.hasAttrib(component,joined)&&(!value||value===component.attribs[joined])){return{attribute:joined,format:"camel",attrValue:component.attribs[joined]}}else if(DomUtils.hasAttrib(component,`:${name}`)&&(!value||value===component.attribs[`:${name}`])){return{attribute:`:${name}`,format:"colon",attrValue:component.attribs[`:${name}`]}}else if(DomUtils.hasAttrib(component,`:${joined}`)&&(!value||value===component.attribs[`:${joined}`])){return{attribute:`:${joined}`,format:"colonCamel",attrValue:component.attribs[`:${joined}`]}}}return false}function _findPeer(dom,component,peerTag,componentAttr,peerAttr){const attributeValue=_findAttribute(component,componentAttr).attrValue;if(attributeValue){const peer=DomUtils.findOne(elem=>elem.name===peerTag&&_findAttribute(elem,peerAttr,attributeValue),dom.children);return peer}}function hasAttributesToIgnore(dom,component,metadata,parent="",modelCode){const ignoreRuleData=metadata.ruleSetToIgnore;if(ignoreRuleData){for(let i=0;i<ignoreRuleData.length;i++){rule=ignoreRuleData[i];let arr=Object.keys(rule);let key=arr[0];if(!rule.type){if(rule.descendant){parent=component.name}if(_hasAttributesToIgnoreHelper(dom,component,rule,key,parent,metadata.corePackTag,modelCode)){return true}}}}return false}function hasExpressionAttributes(component,componentName,importantAttributes){const excludedAttributes=global.configData.excludeAttributeExpressions[componentName];const regex=new RegExp(`((\\{\\{)|(\\[\\[)).*((\\}\\})|(\\]\\]))`);if(global.jaf.options.dryRunMode&&importantAttributes){for(let attribute of importantAttributes){if(component.attribs[`:${attribute}`]){attribute=`:${attribute}`}if(regex.test(component.attribs[attribute])){if(checkFileUpdate()){logging.logAttributeExpression(componentName,attribute,component.attribs[attribute])}}}}if(excludedAttributes&&excludedAttributes.length){for(let i=0;i<excludedAttributes.length;i++){if(component.attribs[`:${excludedAttributes[i]}`]){excludedAttributes[i]=`:${excludedAttributes[i]}`}if(regex.test(component.attribs[excludedAttributes[i]])){checkFileUpdate();logging.logExcludeAttributeExpression(componentName,excludedAttributes[i],component.attribs[excludedAttributes[i]]);return true}}}return false}function commentSlotContent(component,data){const slotValue=data.slot;for(let child of component.children){if(child.name&&child.attribs.slot==slotValue){const cnode=getDom("<!-- "+render(child,{decodeEntities:false})+" -->");DomUtils.replaceElement(child,cnode);checkFileUpdate();return[logging.logCommentSlotContent(component.name,slotValue,child.name)]}};}function slotContentToAttribute(component,data,dom){let logs=[];for(let obj of data){let toNode;if(obj.toDescendant){const descendant=_findDescendant(component,obj.toDescendant,obj.slotNameTo?obj.slotNameTo:"");if(descendant){toNode=descendant}else{continue}}if(obj.fromDescendant){const descendant=_findDescendant(component,obj.fromDescendant,obj.slotNameFrom?obj.slotNameFrom:"");if(descendant){component=descendant}else{continue}}if(obj.toPeer||obj.fromPeer){const peer=_findPeer(dom,component,obj.toPeer?obj.toPeer:obj.fromPeer,obj.ownAttribute,obj.peerAttribute);if(peer){if(obj.toPeer){toNode=peer}else{component=peer}}else{continue}}if(!Object.keys(component.attribs).includes(obj.attribute)){component.attribs[obj.attribute]=_getLabelFromDOMNode(component,data.slotNameFrom);if(!component.attribs[obj.attribute]){delete component.attribs[obj.attribute]}else{checkFileUpdate();logs.push(logging.logSlotContentToAttribute(component.name,obj.attribute,component.attribs[obj.attribute]));if(toNode){_transferAttribute(component,toNode,obj.attribute,component.attribs[obj.attribute]);logs.push(logging.logAttributeTransfer(component.name,toNode.name,obj.attribute,toNode.attribs[obj.attribute]))}return logs}}}}function migrateTag(component,legacyComponentName,coreComponentName,isDescendant){component.name=coreComponentName;checkFileUpdate();global.migrationMetrics.components+=1;return logging.logTagMigration(legacyComponentName,coreComponentName,isDescendant)}function migrateClassToTag(component,legacyClassName,coreComponentName,isDescendant){const fromTag=component.name;component.name=coreComponentName;classAttr=_findAttribute(component,"class");if(classAttr){classNames=classAttr.attrValue.split(" ");index=classNames.indexOf(legacyClassName);classNames.splice(index,1);if(classNames.length===0){delete component.attribs[classAttr.attribute]}else{component.attribs[classAttr.attribute]=classNames.join(" ")}checkFileUpdate();global.migrationMetrics.components+=1;return logging.logClassToTagMigration(fromTag,legacyClassName,coreComponentName,isDescendant)}}function migrateTagByAttribute(component,data,isDescendant){for(const tagSet of data){if(tagSet.attribute){const attribute=_findAttribute(component,tagSet.attribute,tagSet.attributeValue);if(attribute){component.name=tagSet.toTag;checkFileUpdate();global.migrationMetrics.components+=1;return logging.logTagMigration(tagSet.fromTag,tagSet.toTag,isDescendant)}}else{component.name=tagSet.toTag;checkFileUpdate();global.migrationMetrics.components+=1;return logging.logTagMigration(tagSet.fromTag,tagSet.toTag)}}};function classNameToAttribute(component,data){let logs=[];data.forEach(obj=>{const from=obj.className;const to=obj.attributeValue;const attribute=obj.attribute;if(component.attribs.class){classNames=component.attribs.class.split(" ");if(typeof obj.className==="string"&&classNames.includes(obj.className)){index=classNames.indexOf(from);classNames.splice(index,1);component.attribs[attribute]=to;checkFileUpdate();logs.push(logging.logClassNameToAttribute(from,attribute,to))}else if(typeof obj.className==="object"&&from.every(c=>classNames.includes(c))){obj.className.forEach(cl=>{index=classNames.indexOf(cl);classNames.splice(index,1)});component.attribs[attribute]=to;checkFileUpdate();logs.push(logging.logClassNameToAttribute(from,attribute,to))}if(classNames.length==0)delete component.attribs.class;else component.attribs.class=classNames.join(" ")}});return logs}function migrateAttributes(component,data,dom){let toNode;let logs=[];for(const attributeSet in data){let camelFromAttribute="";let camelToAttribute="";let tagExists=true;let obj=data[attributeSet];if(obj.fromDescendant||obj.fromPeer||obj.toDescendant||obj.toPeer){tagExists=false;if(obj.fromDescendant||obj.toDescendant){const descendant=_findDescendant(component,obj.fromDescendant?obj.fromDescendant:obj.toDescendant,obj.slotName);if(component.children&&descendant){tagExists=true;if(obj.fromDescendant){toNode=component;component=descendant}else{toNode=descendant}}else{continue}}else{const peerTag=_findPeer(dom,component,obj.toPeer?obj.toPeer:obj.fromPeer,obj.ownAttribute,obj.peerAttribute);if(peerTag){tagExists=true;if(obj.fromPeer){toNode=component;component=peerTag}else{toNode=peerTag}}else{continue}}}if(tagExists){let hasDepAttribute=true;if(obj.depAttribute){hasDepAttribute=_findAttribute(component,obj.depAttribute)}const hasFromAttribute=_findAttribute(component,obj.fromAttribute,obj.fromValue);let fromAttribute=obj.fromAttribute;if(hasFromAttribute){fromAttribute=hasFromAttribute.attribute}let toAttribute=obj.toAttribute;if(hasFromAttribute.format){if(toAttribute){if(hasFromAttribute.format==="camel"){toAttribute=toAttribute.split("-").join("")}else if(hasFromAttribute.format==="colonCamel"){toAttribute=`:${toAttribute.split("-").join("")}`}else{toAttribute=`:${toAttribute}`}}}const hasToAttribute=_findAttribute(component,toAttribute);if(!(obj.fromAttribute===obj.toAttribute&&obj.fromValue===obj.toValue)){if(hasDepAttribute&&hasFromAttribute&&toAttribute&&(!hasToAttribute||fromAttribute===toAttribute)){if(obj.toValue){switch(hasFromAttribute.format){case"camel":camelFromAttribute=_toCamelCase(obj.fromAttribute);camelToAttribute=_toCamelCase(obj.toAttribute);break;case"colonCamel":camelFromAttribute=`:${_toCamelCase(obj.fromAttribute)}`;camelToAttribute=`:${_toCamelCase(obj.toAttribute)}`;break}component.attribs[camelToAttribute?camelToAttribute:toAttribute]=obj.toValue;checkFileUpdate();logs.push(logging.logAttributeMigration(camelFromAttribute?camelFromAttribute:fromAttribute,obj.fromValue,camelToAttribute?camelToAttribute:toAttribute,obj.toValue))}else{let fromValue=obj.fromValue?obj.fromValue:component.attribs[fromAttribute];switch(hasFromAttribute.format){case"camel":camelFromAttribute=_toCamelCase(obj.fromAttribute);camelToAttribute=_toCamelCase(obj.toAttribute);break;case"colonCamel":camelFromAttribute=`:${_toCamelCase(obj.fromAttribute)}`;camelToAttribute=`:${_toCamelCase(obj.toAttribute)}`;break}if(obj.fromValue){component.attribs[camelToAttribute?camelToAttribute:toAttribute]=""}else{component.attribs[camelToAttribute?camelToAttribute:toAttribute]=component.attribs[fromAttribute]}checkFileUpdate();logs.push(logging.logAttributeMigration(camelFromAttribute?camelFromAttribute:fromAttribute,fromValue,camelToAttribute?camelToAttribute:toAttribute))}if(fromAttribute!==toAttribute){delete component.attribs[fromAttribute]}}else if(hasDepAttribute&&hasFromAttribute&&!toAttribute){delete component.attribs[fromAttribute];switch(hasFromAttribute.format){case"camel":fromAttribute=_toCamelCase(obj.fromAttribute);break;case"colonCamel":fromAttribute=`:${_toCamelCase(obj.fromAttribute)}`;break}checkFileUpdate();logs.push(logging.logAttributeDeprecation(fromAttribute,obj.fromValue))}else if(hasDepAttribute&&!obj.fromAttribute&&obj.toAttribute&&!hasToAttribute){if(toNode){toNode.attribs[obj.toAttribute]=obj.toValue}else{component.attribs[obj.toAttribute]=obj.toValue}checkFileUpdate();logs.push(logging.logAttributeAddition(obj.toAttribute,obj.toValue,toNode?toNode.name:""))}}if(toNode&&hasFromAttribute){switch(hasFromAttribute.format){case"camel":camelToAttribute=_toCamelCase(obj.toAttribute);break;case"colonCamel":camelToAttribute=`:${_toCamelCase(obj.toAttribute)}`;break}checkFileUpdate();_transferAttribute(component,toNode,camelToAttribute?camelToAttribute:toAttribute,component.attribs[camelToAttribute?camelToAttribute:toAttribute],toAttribute);const toValue=toNode.attribs[camelToAttribute?camelToAttribute:toAttribute];logs.push(logging.logAttributeTransfer(component.name,toNode.name,camelToAttribute?camelToAttribute:toAttribute,toValue));if(obj.fromDescendant||obj.fromPeer){component=toNode}}}}return logs}function handleSpecialCase(code,componentName,data){let obj;let regex;if(data[1]){obj=data[1];regex=new RegExp(obj.fromString.split(" ").join("\\s*"),"igm");code=code.replace(regex,obj.toString)}obj=data[0];regex=new RegExp(obj.fromString.split(" ").join("\\s*"),"igm");code=code.replace(regex,obj.toString);return code}function _migrateDescendantsHelper(dom,children,componentMetadata,parent,compCount,modelCode,fileMigratedCount,revertMig,logs=[]){let descendants=[];for(let child of children){let newLogs=[];if(child.name===componentMetadata.legacyTag&&!revertMig){let componentCopy=child.cloneNode(true);descendants.push({original:child,copy:componentCopy});if(!hasAttributesToIgnore(dom,child,componentMetadata,parent)&&!hasExpressionAttributes(child,componentMetadata.legacyTag,componentMetadata.importantAttributes)){if(componentMetadata["migrateTagByAttribute"]){newLogs.push(migrateTagByAttribute(child,componentMetadata["migrateTagByAttribute"],true))}else{newLogs.push(migrateTag(child,componentMetadata.legacyTag,componentMetadata.corePackTag,true))}for(let key in componentMetadata){if(typeof self[key]=="function"&&key!="migrateTagByAttribute"&&key!="migrateImports"&&key!="migrateOptions"){newLogs=newLogs.concat(self[key](child,componentMetadata[key]))}else if(key==="migrateOptions"){let info=migrateOptions(child,componentMetadata[key],modelCode,fileMigratedCount,componentMetadata.legacyTag);if(!modelCode&&info){logging.logMapperRequest(componentMetadata.legacyTag);revertMig=true}else if(info){if(info.revert){revertMig=true}else{modelCode=info.mCode;newLogs=newLogs.concat(info.newLogs)}}}}if(!compCount.migrated[componentMetadata.legacyTag]){compCount.migrated[componentMetadata.legacyTag]=1}else{compCount.migrated[componentMetadata.legacyTag]+=1}if(revertMig){for(let obj of descendants){DomUtils.replaceElement(obj.original,obj.copy);global.migrationMetrics.components-=1;compCount.migrated[componentMetadata.legacyTag]-=1;if(compCount.migrated[componentMetadata.legacyTag]===0){delete compCount.migrated[componentMetadata.legacyTag]}if(compCount.skipped[componentMetadata.legacyTag]){compCount.skipped[componentMetadata.legacyTag]+=1}else{compCount.skipped[componentMetadata.legacyTag]=1}}}}}else{if(child.name===componentMetadata.legacyTag&&revertMig){if(compCount.skipped[componentMetadata.legacyTag]){compCount.skipped[componentMetadata.legacyTag]+=1}else{compCount.skipped[componentMetadata.legacyTag]=1}}else if(child.children){returnValue=_migrateDescendantsHelper(dom,child.children,componentMetadata,parent,compCount);newLogs=newLogs.concat(returnValue.logs);compCount=returnValue.count;revertMig=returnValue.revert}}if(!revertMig){logs=logs.concat(newLogs)}}return{logs:logs,count:compCount,mCode:modelCode,revert:revertMig}}function migrateDescendants(dom,component,metadata,modelCode,fileComponentsInfo,logs=[]){let compCount={migrated:{},skipped:{}};const data=metadata.migrateDescendants;let returnValue=false;let revertMig;for(let metaName of data){let componentMetadata=require("../metadata/"+metaName+".json");let fileMigratedCount=fileComponentsInfo.migrated[componentMetadata.legacyTag]?fileComponentsInfo.migrated[componentMetadata.legacyTag]:0;if(component.children){returnValue=_migrateDescendantsHelper(dom,component.children,componentMetadata,metadata.legacyTag,compCount,modelCode,fileMigratedCount,revertMig);if(returnValue){logs=logs.concat(returnValue.logs);modelCode=returnValue.mCode;revertMig=returnValue.revert;compCount=returnValue.count}}}return{logs:logs,count:compCount,mCode:modelCode}}function removeNode(component){DomUtils.removeElement(component);return logging.logComponentRemoved(component.name)}function replaceComponent(fromNode,data){for(let obj of data){let descendant=_findDescendant(fromNode,obj.descendant);if(descendant){DomUtils.replaceElement(fromNode,descendant);return logging.logComponentReplacement(fromNode.name,descendant.name)}}}function migrateOptions(component,data,modelCode,compCount,legacyTag){if(modelCode){if(!_findAttribute(component,data.toAttribute)&&(_findDescendant(component,"oj-option")||_findDescendant(component,"template"))){let optionsInfo=[];let tag=legacyTag.slice(3);tag=tag[0].toUpperCase()+tag.slice(1);let varName=`optionsMig${tag}${compCount}`;let template;for(let child of component.children){if(child.name==="oj-option"){for(let ignoreAttr of data.ignoreAttribute){if(child.attribs[ignoreAttr]){logging.logIgnoreComponent(child.name,ignoreAttr,"",legacyTag);return{revert:true}}}child.attribs.label=_getLabelFromDOMNode(child,"");if(child.children){for(let c of child.children){if(c.name==="span"||c.name==="div"){if(c.attribs.slot&&c.attribs.class){child.attribs[c.attribs.slot]={"class":c.attribs.class}}}else if(c.name==="oj-avatar"){if(c.attribs.slot){if(c.attribs.src&&c.attribs.role){child.attribs[c.attribs.slot]={"type":c.attribs.role,"src":c.attribs.src}}else{child.attribs[c.attribs.slot]={"class":c.attribs.class}}}}}}optionsInfo.push(child.attribs);DomUtils.removeElement(child)}else if(child.name==="oj-bind-for-each"){template=child.attribs.data.slice(2,child.attribs.data.length-2);let optionComp=_findDescendant(child,"oj-option");for(let ignoreAttr of data.ignoreAttribute){if(optionComp.attribs[ignoreAttr]){logging.logIgnoreComponent(optionComp.name,ignoreAttr,"",legacyTag);return{revert:true}}}optionComp.attribs.label=_getLabelFromDOMNode(optionComp,"");if(optionComp.children){for(let c of optionComp.children){if(c.name==="span"||c.name==="div"){if(c.attribs.slot&&c.attribs.class){optionComp.attribs[c.attribs.slot]={"class":c.attribs.class}}}else if(c.name==="oj-avatar"){if(c.attribs.slot){if(c.attribs.src&&c.attribs.role){optionComp.attribs[c.attribs.slot]={"type":c.attribs.role,"src":c.attribs.src}}else{optionComp.attribs[c.attribs.slot]={"class":c.attribs.class}}}}}}optionsInfo.push(optionComp.attribs);DomUtils.removeElement(child)}}let varValue=optionsInfo;let info=astUtils.migrateOptionsModel(data,varName,varValue,modelCode,template);if(info){if(info.emptyModel){logging.logIgnoreComponent(legacyTag,"","","","To migrate data driven component, model file provided needs a class where a new variable can be created");return{revert:true}}else{varName=info.varName;let code=info.code;let logs=info.logs;component.attribs[data.toAttribute]=`[[${varName}]]`;return{"mCode":code,"newLogs":logs}}}else{return false}}else{return false}}if(!component.attribs[data.toAttribute]&&(_findDescendant(component,"oj-option")||_findDescendant(component,"template"))){return{"mCode":modelCode,"newLogs":[]}}return false}exports.getDom=getDom;exports.inManifestData=inManifestData;exports.checkFileUpdate=checkFileUpdate;exports.hasAttributesToIgnore=hasAttributesToIgnore;exports.hasExpressionAttributes=hasExpressionAttributes;exports.slotContentToAttribute=slotContentToAttribute;exports.commentSlotContent=commentSlotContent;exports.migrateTag=migrateTag;exports.migrateClassToTag=migrateClassToTag;exports.classNameToAttribute=classNameToAttribute;exports.handleSpecialCase=handleSpecialCase;exports.migrateAttributes=migrateAttributes;exports.migrateTagByAttribute=migrateTagByAttribute;exports.migrateDescendants=migrateDescendants;exports.replaceComponent=replaceComponent;exports.removeNode=removeNode;exports.migrateOptions=migrateOptions;
|