@oracle/oraclejet-audit 12.0.0 → 13.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/jaf-amd.js +2 -20
- package/jaf.js +1 -1
- package/jafapi.js +1 -1
- package/lib/AST_Ts.js +1 -1
- package/lib/AstJson.js +1 -1
- package/lib/AstMd.js +1 -1
- package/lib/AstNodeTypes.js +1 -1
- package/lib/Cli.js +6 -0
- package/lib/Color.js +6 -0
- 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/ConfigLib.js +1 -1
- package/lib/CssUtils.js +1 -1
- package/lib/DomUtils.js +1 -1
- package/lib/FileSet.js +1 -1
- package/lib/FsUtils.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/OjCPack.js +6 -0
- package/lib/OjetLib.js +6 -0
- package/lib/Registry.js +1 -1
- package/lib/RuleSet.js +1 -1
- package/lib/Rules.js +1 -1
- package/lib/Scope.js +1 -1
- package/lib/Utils.js +1 -1
- package/lib/ZipUtils.js +1 -1
- package/lib/amdlist.js +6 -0
- package/lib/api.js +1 -1
- package/lib/betalist.js +6 -0
- package/lib/builtinpacks.js +1 -1
- package/lib/checkage.js +6 -0
- package/lib/cliStats.js +1 -1
- package/lib/cmdline.js +1 -1
- package/lib/defaults.js +1 -1
- package/lib/deflist.js +1 -1
- package/lib/dislist.js +1 -1
- package/lib/exportRules.js +1 -1
- package/lib/extends.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/manpage.js +6 -0
- package/lib/manual.js +1 -1
- package/lib/metaLoader.js +1 -1
- package/lib/metahist.js +1 -1
- package/lib/msgidLoader.js +1 -1
- package/lib/ns.js +1 -1
- package/lib/outfile.js +1 -1
- package/lib/proflist.js +6 -0
- package/lib/rlolist.js +6 -0
- package/lib/scaffold.js +1 -1
- package/lib/scaffoldRule.js +1 -1
- package/lib/schema.js +1 -1
- package/lib/scopewalker.js +1 -1
- package/meta/12.1.0/jetauditmeta.js +9 -0
- package/meta/13.0.0/jetauditmeta.js +9 -0
- package/meta/metaverlist.json +1 -1
- package/package.json +6 -4
- package/profiles/best-practice.json +146 -0
- package/profiles/redwood-strict.json +31 -0
- package/rulepacks/jetwc/jetwc-bootstrap.js +1 -1
- package/rulepacks/jetwc/jetwc-css-oj-complete.js +1 -1
- package/rulepacks/jetwc/jetwc-pack-children.js +1 -1
- package/rulepacks/jetwc/jetwc-schema.js +1 -1
- package/rulepacks/jetwc/jetwc-supproperty-propagation.js +6 -0
- package/rulepacks/jetwc/msgid.json +1 -1
- package/rulepacks/jetwc/rules.json +1 -1
- package/rulepacks/jetwc-lib/jetwcutils-componentFinder.js +1 -1
- package/rulepacks/jetwc-lib/jetwcutils-preCompiler.js +1 -1
- package/rulepacks/jetwco/jetwco-bootstrap.js +1 -1
- package/rulepacks/jetwco/jetwco-component-api-controlled-changes.js +1 -1
- package/rulepacks/jetwco/rules.json +1 -1
- package/rules/jaf/jaf-sys-age.js +6 -0
- package/rules/jaf/jaf-ts-walk.js +6 -0
- package/rules/jaf/msgid.json +1 -1
- package/rules/jaf/rules.json +1 -1
- package/rules/jet/helpers/extractStylesFromClass.js +1 -1
- package/rules/jet/msgid.json +1 -1
- package/rules/jet/oj-acc-aria-ojselector-labelledby.js +6 -0
- package/rules/jet/oj-acc-aria-prop.js +1 -1
- package/rules/jet/oj-c-acc-avatar-aria-role.js +6 -0
- package/rules/jet/oj-cca-compjson-bp-jetver.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-html-alta-deprecated.js +1 -1
- package/rules/jet/oj-html-attr-2def.js +1 -1
- package/rules/jet/oj-html-attr-req.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-combo-converter.js +1 -1
- package/rules/jet/oj-html-file-pick-accept.js +1 -1
- package/rules/jet/oj-html-notag-style.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-ojtag-deprecated.js +1 -1
- package/rules/jet/oj-html-pageopts-type.js +6 -0
- package/rules/jet/oj-html-rating-gauge-size.js +6 -0
- package/rules/jet/oj-html-redwood-bp-endslot.js +6 -0
- package/rules/jet/oj-html-slot-deprecated.js +6 -0
- package/rules/jet/oj-html-slot-pref-content.js +1 -1
- package/rules/jet/oj-html-wctag-maintenance.js +6 -0
- package/rules/jet/rules.json +1 -1
- package/schema/component-schema.json +1 -1482
- package/src/JafCore.js +1 -1
- package/types/index.d.ts +38 -9
- package/lib/colors.js +0 -6
package/meta/metaverlist.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"metaList":{"6.0.0":{"version":"6.0.1","date":"Friday Jul 12, 2019","time":"10:58am pdt"},"5.2.0":{"version":"5.2.3","date":"Friday Jul 12, 2019","time":"10:55am pdt"},"6.1.0":{"version":"6.1.3","date":"Friday Jul 12, 2019","time":"11:00am pdt"},"6.2.0":{"version":"6.2.2","date":"Friday Jul 12, 2019","time":"11:02am pdt"},"7.0.0":{"version":"7.0.1","date":"Friday Jul 12, 2019","time":"11:04am pdt"},"7.1.0":{"version":"7.1.0","date":"Friday Jul 12, 2019","time":"11:06am pdt"},"7.2.0":{"version":"7.2.0","date":"Sunday Feb 16, 2020","time":"10:13pm est"},"7.3.0":{"version":"7.3.0","date":"Tuesday May 05, 2020","time":"12:50am edt"},"8.0.0":{"version":"8.0.0","date":"Sunday Feb 16, 2020","time":"10:51pm est"},"8.1.0":{"version":"8.1.0","date":"Sunday Feb 16, 2020","time":"10:20pm est"},"8.2.0":{"version":"8.2.0","date":"Friday Apr 17, 2020","time":"1:08am utc"},"8.3.0":{"version":"8.3.0","date":"Monday May 04, 2020","time":"4:34pm edt"},"9.0.0":{"version":"9.0.0","date":"Friday Jun 12, 2020","time":"1:57am utc"},"9.1.0":{"version":"9.1.0","date":"Thursday Aug 06, 2020","time":"2:13am utc"},"9.2.0":{"version":"9.2.0","date":"Wednesday Oct 07, 2020","time":"5:41pm utc"},"10.0.0":{"version":"10.0.0","date":"Thursday Jan 07, 2021","time":"9:20pm utc"},"10.1.0":{"version":"10.1.0","date":"Saturday Apr 17, 2021","time":"4:01pm utc"},"11.0.0":{"version":"11.0.0","date":"Friday Jul 02, 2021","time":"3:02am utc"},"11.1.0":{"version":"11.1.0","date":"Thursday Sep 30, 2021","time":"9:33pm utc"},"12.0.0":{"version":"12.0.0","date":"Friday Feb 04, 2022","time":"2:29am utc"}}}
|
|
1
|
+
{"metaList":{"6.0.0":{"version":"6.0.1","date":"Friday Jul 12, 2019","time":"10:58am pdt"},"5.2.0":{"version":"5.2.3","date":"Friday Jul 12, 2019","time":"10:55am pdt"},"6.1.0":{"version":"6.1.3","date":"Friday Jul 12, 2019","time":"11:00am pdt"},"6.2.0":{"version":"6.2.2","date":"Friday Jul 12, 2019","time":"11:02am pdt"},"7.0.0":{"version":"7.0.1","date":"Friday Jul 12, 2019","time":"11:04am pdt"},"7.1.0":{"version":"7.1.0","date":"Friday Jul 12, 2019","time":"11:06am pdt"},"7.2.0":{"version":"7.2.0","date":"Sunday Feb 16, 2020","time":"10:13pm est"},"7.3.0":{"version":"7.3.0","date":"Tuesday May 05, 2020","time":"12:50am edt"},"8.0.0":{"version":"8.0.0","date":"Sunday Feb 16, 2020","time":"10:51pm est"},"8.1.0":{"version":"8.1.0","date":"Sunday Feb 16, 2020","time":"10:20pm est"},"8.2.0":{"version":"8.2.0","date":"Friday Apr 17, 2020","time":"1:08am utc"},"8.3.0":{"version":"8.3.0","date":"Monday May 04, 2020","time":"4:34pm edt"},"9.0.0":{"version":"9.0.0","date":"Friday Jun 12, 2020","time":"1:57am utc"},"9.1.0":{"version":"9.1.0","date":"Thursday Aug 06, 2020","time":"2:13am utc"},"9.2.0":{"version":"9.2.0","date":"Wednesday Oct 07, 2020","time":"5:41pm utc"},"10.0.0":{"version":"10.0.0","date":"Thursday Jan 07, 2021","time":"9:20pm utc"},"10.1.0":{"version":"10.1.0","date":"Saturday Apr 17, 2021","time":"4:01pm utc"},"11.0.0":{"version":"11.0.0","date":"Friday Jul 02, 2021","time":"3:02am utc"},"11.1.0":{"version":"11.1.0","date":"Thursday Sep 30, 2021","time":"9:33pm utc"},"12.0.0":{"version":"12.0.0","date":"Friday Feb 04, 2022","time":"2:29am utc"},"12.1.0":{"version":"12.1.0","date":"Saturday Apr 09, 2022","time":"7:54am utc"},"13.0.0":{"version":"13.0.0","date":"Tuesday Jul 12, 2022","time":"1:43am utc"}}}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oracle/oraclejet-audit",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "13.0.0",
|
|
4
4
|
"description": "JET AUDIT FRAMEWORK",
|
|
5
5
|
"main": "jaf.js",
|
|
6
6
|
"files": [
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
"lib",
|
|
11
11
|
"libext",
|
|
12
12
|
"meta",
|
|
13
|
+
"profiles",
|
|
13
14
|
"schema",
|
|
14
15
|
"rulepacks",
|
|
15
16
|
"rules",
|
|
@@ -42,13 +43,14 @@
|
|
|
42
43
|
"lint"
|
|
43
44
|
],
|
|
44
45
|
"Jaf": {
|
|
45
|
-
"version": "
|
|
46
|
+
"version": "4.12.5"
|
|
46
47
|
},
|
|
47
48
|
"license": "UPL-1.0",
|
|
48
49
|
"dependencies": {
|
|
49
50
|
"@typescript-eslint/typescript-estree": "4.9.1",
|
|
50
51
|
"adm-zip": "0.4.16",
|
|
51
|
-
"ajv": "
|
|
52
|
+
"ajv": "8.10.0",
|
|
53
|
+
"ajv-formats": "2.1.1",
|
|
52
54
|
"css-tree": "1.0.0-alpha.39",
|
|
53
55
|
"decache": "4.6.0",
|
|
54
56
|
"espree": "7.3.1",
|
|
@@ -66,7 +68,7 @@
|
|
|
66
68
|
"typescript": "4.1.2"
|
|
67
69
|
},
|
|
68
70
|
"devDependencies": {
|
|
69
|
-
"chai": "
|
|
71
|
+
"chai": "~4.3.6",
|
|
70
72
|
"mocha": "^7.2.0"
|
|
71
73
|
}
|
|
72
74
|
}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright (c) 2022, 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
|
+
// profile: best-practice
|
|
7
|
+
{
|
|
8
|
+
"title" : "JAF Standard profile configuration enforcing best practice for JET Application Development.",
|
|
9
|
+
"builtinJetRules": true,
|
|
10
|
+
"ecmaVer": 11,
|
|
11
|
+
"ruleMods": {
|
|
12
|
+
"enable":[
|
|
13
|
+
"oj-html-databind-all",
|
|
14
|
+
"oj-html-cdn",
|
|
15
|
+
"oj-html-no-style-tag",
|
|
16
|
+
"oj-ts-comp-meth-deprecated",
|
|
17
|
+
"oj-ts-comp-attr-deprecated",
|
|
18
|
+
"oj-ts-ojcomp-new",
|
|
19
|
+
"oj-ts-ojcomp-exist",
|
|
20
|
+
"oj-ts-poly-promise",
|
|
21
|
+
"oj-ts-noconsole",
|
|
22
|
+
"oj-ts-no-ext-final",
|
|
23
|
+
"oj-html-style",
|
|
24
|
+
"oj-html-ojstyle",
|
|
25
|
+
"oj-html-style-bp-color",
|
|
26
|
+
"oj-html-style-bp-font",
|
|
27
|
+
"oj-html-style-bp-display",
|
|
28
|
+
"oj-html-style-bp-font-family",
|
|
29
|
+
"oj-html-style-abs-units",
|
|
30
|
+
"oj-css-style-bp-color",
|
|
31
|
+
"oj-css-style-bp-font",
|
|
32
|
+
"oj-css-style-bp-display",
|
|
33
|
+
"oj-css-style-bp-font-family",
|
|
34
|
+
"oj-css-style-abs-units",
|
|
35
|
+
"oj-css-bp-float",
|
|
36
|
+
"oj-css-bp-textalign",
|
|
37
|
+
"oj-css-bp-bgcolor",
|
|
38
|
+
"oj-css-bp-border-color"
|
|
39
|
+
],
|
|
40
|
+
"disable": [
|
|
41
|
+
"oj-html-attr-$unique",
|
|
42
|
+
"oj-html-cca-count",
|
|
43
|
+
"oj-html-wctag-id",
|
|
44
|
+
"oj-html-wctag-for",
|
|
45
|
+
"oj-html-wctag-arialabelledby",
|
|
46
|
+
"oj-html-wctag-$props",
|
|
47
|
+
"oj-html-template-index",
|
|
48
|
+
"oj-form-maxcols",
|
|
49
|
+
"oj-js-var-undef",
|
|
50
|
+
"oj-cca-compjson-bp-obj",
|
|
51
|
+
"oj-cca-compjson-bp-ar",
|
|
52
|
+
"oj-cca-compjson-ns-reg",
|
|
53
|
+
"oj-cca-compjson-bp-jetver",
|
|
54
|
+
"oj-cca-compjson-bp-dsplyname"
|
|
55
|
+
],
|
|
56
|
+
"JET": {
|
|
57
|
+
"oj-html-style-bp-font-family": {
|
|
58
|
+
"enabled": true,
|
|
59
|
+
"ignore": [
|
|
60
|
+
"inherit",
|
|
61
|
+
"initial"
|
|
62
|
+
]
|
|
63
|
+
},
|
|
64
|
+
"oj-css-style-bp-font-family": {
|
|
65
|
+
"enabled": true,
|
|
66
|
+
"ignore": [
|
|
67
|
+
"inherit",
|
|
68
|
+
"initial"
|
|
69
|
+
]
|
|
70
|
+
},
|
|
71
|
+
"oj-css-style-abs-units": {
|
|
72
|
+
"selectors": {
|
|
73
|
+
"ignore": [
|
|
74
|
+
"icon",
|
|
75
|
+
"img",
|
|
76
|
+
"image"
|
|
77
|
+
]
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
"sevMap": {
|
|
83
|
+
"sevMsg": {
|
|
84
|
+
"JET-0010":"blocker", //oj-html-ojtag-deprecated
|
|
85
|
+
"JET-0011":"critical",//oj-html-ojtag-deprecated
|
|
86
|
+
"JET-0020":"blocker", //oj-html-attr-json
|
|
87
|
+
"JET-0021":"blocker", //oj-html-attr-json
|
|
88
|
+
"JET-0040":"blocker", //oj-html-ojattr
|
|
89
|
+
"JET-0041":"blocker", //oj-html-ojattr-520
|
|
90
|
+
"JET-0060":"blocker", //oj-html-ojattr-value
|
|
91
|
+
"JET-0070":"blocker", //oj-html-attr-2def
|
|
92
|
+
"JET-0100":"blocker", //oj-html-jq-databind
|
|
93
|
+
"JET-0110":"blocker", //oj-html-jq-databind
|
|
94
|
+
"JET-0120":"blocker", //oj-html-jq-databind
|
|
95
|
+
"JET-0130":"blocker", //oj-html-databind-all
|
|
96
|
+
"JET-0140":"blocker", //oj-html-slot-name
|
|
97
|
+
"JET-0150":"blocker", //oj-html-slot-name
|
|
98
|
+
"JET-0153":"major", //oj-html-slot-pref-content
|
|
99
|
+
"JET-0190":"blocker", //oj-html-tag-attr-noprefix
|
|
100
|
+
"JET-0200":"blocker", //oj-html-ojtag-globattr-noprefix
|
|
101
|
+
"JET-0240":"critical",//oj-html-oj-lib
|
|
102
|
+
"JET-0250":"blocker", //oj-html-ko-comment
|
|
103
|
+
"JET-0260":"blocker", //oj-html-ko-databind
|
|
104
|
+
"JET-0400":"blocker", //oj-html-5-tag-obs
|
|
105
|
+
"JET-0410":"blocker", //oj-html-5-attr-obs
|
|
106
|
+
"JET-0465":"blocker", //oj-html-wctag-packprivate
|
|
107
|
+
"JET-0470":"blocker", //oj-html-picker-attrs
|
|
108
|
+
"JET-0505":"blocker", //oj-html-no-style-tag
|
|
109
|
+
"JET-3060":"blocker", //oj-js-ojcomp-new
|
|
110
|
+
"JET-3070":"blocker", //oj-js-ojcomp-exist
|
|
111
|
+
"JET-3071":"blocker", //oj-js-ojcomp-exist
|
|
112
|
+
"JET-3090":"blocker", //oj-js-poly-promise
|
|
113
|
+
"JET-3100":"blocker", //oj-js-noconsole
|
|
114
|
+
"JET-3400":"blocker", //oj-ts-ojcomp-deprecated
|
|
115
|
+
"JET-3440":"blocker", //oj-ts-ojcomp-new
|
|
116
|
+
"JET-3445":"blocker", //oj-ts-ojcomp-exist
|
|
117
|
+
"JET-3455":"blocker", //oj-ts-poly-promise
|
|
118
|
+
"JET-3460":"blocker", //oj-ts-noconsole
|
|
119
|
+
"JET-3465":"blocker", //oj-ts-no-ext-final
|
|
120
|
+
"JET-5000":"blocker", //oj-html-style
|
|
121
|
+
"JET-5015":"blocker", //oj-html-ojstyle
|
|
122
|
+
"JET-5020":"blocker", //oj-html-style-bp-color
|
|
123
|
+
"JET-5025":"blocker", //oj-html-style-bp-font
|
|
124
|
+
"JET-5030":"critical",//oj-html-style-bp-display
|
|
125
|
+
"JET-5040":"critical",//oj-html-style-bp-font-family
|
|
126
|
+
"JET-5095":"blocker", //oj-html-input-isodate
|
|
127
|
+
"JET-5096":"blocker", //oj-html-input-isodate
|
|
128
|
+
"JET-5097":"blocker", //oj-html-input-isodate
|
|
129
|
+
"JET-5098":"blocker", //oj-html-input-isodate
|
|
130
|
+
"JET-5099":"blocker", //oj-html-input-isodate
|
|
131
|
+
"JET-5100":"blocker", //oj-html-input-isodate
|
|
132
|
+
"JET-5101":"blocker", //oj-html-input-isodate
|
|
133
|
+
"JET-5102":"blocker", //oj-html-input-isodate
|
|
134
|
+
"JET-5103":"blocker", //oj-html-input-isodate
|
|
135
|
+
"JET-5104":"blocker", //oj-html-input-isodate
|
|
136
|
+
"JET-6015":"blocker", //oj-css-style-bp-color
|
|
137
|
+
"JET-6025":"blocker", //oj-css-style-bp-font
|
|
138
|
+
"JET-6030":"critical",//oj-css-style-bp-display
|
|
139
|
+
"JET-6035":"critical",//oj-css-style-bp-font-family
|
|
140
|
+
"JET-6055":"blocker", //oj-css-bp-bgcolor
|
|
141
|
+
"JET-6056":"blocker", //oj-css-bp-bgcolor
|
|
142
|
+
"JET-6060":"blocker", //oj-css-bp-border-color
|
|
143
|
+
"JET-6061":"blocker" //oj-css-bp-border-color
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright (c) 2022, 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
|
+
// profile: redwood-strict
|
|
7
|
+
{
|
|
8
|
+
"title": "JAF Standard profile configuration for strict audit checking of Redwood applications.",
|
|
9
|
+
"extends": {"profile":"best-practice"},
|
|
10
|
+
"theme": "Redwood",
|
|
11
|
+
"ruleMods": {
|
|
12
|
+
"enable":[
|
|
13
|
+
"oj-html-redwood-bp-endslot"
|
|
14
|
+
]
|
|
15
|
+
},
|
|
16
|
+
"sevMap": {
|
|
17
|
+
"sevMsg": {
|
|
18
|
+
"JET-0153":"blocker", //oj-html-slot-pref-content
|
|
19
|
+
"JET-0156":"blocker", //oj-html-slot-minmax
|
|
20
|
+
"JET-0157":"blocker", //oj-html-slot-minmax,
|
|
21
|
+
"JET-0490":"blocker", //oj-html-notag-style
|
|
22
|
+
"JET-0491":"blocker", //oj-html-notag-style
|
|
23
|
+
"JET-0510":"blocker", //oj-html-alta-deprecated
|
|
24
|
+
"JET-5110":"blocker", //oj-html-no-pageopts-type
|
|
25
|
+
"JET-5111":"blocker", //oj-html-no-pageopts-type
|
|
26
|
+
"JET-6065":"blocker", //oj-css-var-override
|
|
27
|
+
"JET-6066":"blocker", //oj-css-var-override
|
|
28
|
+
"JET-0520":"blocker" //oj-html-rating-gauge-size
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* Licensed under The Universal Permissive License (UPL), Version 1.0
|
|
4
4
|
* as shown at https://oss.oracle.com/licenses/upl/
|
|
5
5
|
*/
|
|
6
|
-
const path=require('path');const Utils=require('../jetwc-lib/jetwcutils-componentAuditUtils');const componentFinder=require('../jetwc-lib/jetwcutils-componentFinder');const TsxUtils=require('../jetwc-lib/jetwcutils-tsxUtils');const preCompiler=require('../jetwc-lib/jetwcutils-preCompiler');const ruleDef=function(){};ruleDef.prototype.getName=function(){return'jetwc-bootstrap'};ruleDef.prototype.getShortDescription=function(){return'Bootstrap processing for the JETWC rulset'};ruleDef.prototype.getDescription=function(){return'This rule is for internal use by the ruleset and should not be disabled'};ruleDef.prototype.register=function(context){this.componentRoots=context.config.components;this.auditBase=context.config.base;this.typeScriptCompile=context.config.typescript&&context.config.typescript.compile;return{startupRP:this._getAllVisibleComponents,closedownRP:this._reportDiagnostics}};ruleDef.prototype._getAllVisibleComponents=function(context){const{msgLib}=context.utils;msgLib.info(`builtinJetWcRules (${context.rulePack.getPackInfo().prefix}): ${context.rulePack.getPackInfo().version}`);const projectPathInfo=Utils.getKeyPathInfoForRulepack(context,this.auditBase);const componentRootFolder=context.rulePack.getRuleOptions().componentRoot||projectPathInfo.componentRootFolder;let precompileCache;if(this.typeScriptCompile){precompileCache=preCompiler.getPrecompileCacheIfNeeded(context,this.auditBase,projectPathInfo.tsSource,projectPathInfo.componentRootFolder)}const masterComponentList=componentFinder.findAllComponents(context,projectPathInfo,this.componentRoots,precompileCache);if(masterComponentList&&masterComponentList.length>0){const allComponentsMap=masterComponentList.reduce((wmap,component)=>{if(!projectPathInfo.isBuiltOutput||projectPathInfo.isBuiltOutput&&!wmap.has(component.fullName)){wmap.set(component.fullName,component)}return wmap},new Map);const referenceComponents=new Map;const componentPaths=new Map;allComponentsMap.forEach(component=>{component.language=Utils.detectComponentSourceType(context,component.rootFolder,component.vcomponent);switch(component.type){case'reference':referenceComponents.set(component.fullName,component.ba);break;case'composite':case'resource':if(component.local){if(component.dependencies){Object.values(component.dependencies).forEach(dependency=>{if(allComponentsMap.has(dependency.name)){const proxyPaths=allComponentsMap.get(dependency.name).requirePaths;proxyPaths.forEach(path=>{component.requirePaths.add(path)})}else{msgLib.debug(`JETWC: missing dependency lookup for ${dependency.name} when resolving requirePaths`)}})}componentPaths.set(component.rootFolder,component.fullName)}break;}});context.rulePack.setExtension({rulepackVersion:context.rulePack.getPackInfo().version,bootStrap:true,platform:Utils.isWindows?'Windows':'Unix-like',precompiled:this.typeScriptCompile,componentHome:`/${componentRootFolder}/`,auditBuildOutput:projectPathInfo.isBuiltOutput,discoveredPaths:projectPathInfo,componentRoots:this.componentRoots,allReferenceComponents:referenceComponents,allComponents:allComponentsMap,auditableComponentPaths:componentPaths,allAuditableFilePaths:new Map})}else{msgLib.error(`No components have been discovered from the JAF configuration for the ${context.rulePack.getPackInfo().prefix} ruleset to process. You will need to configure the "components" array to point at your component root folder`);Utils.disableRulePack(context)}};ruleDef.prototype._reportDiagnostics=function(context){const
|
|
6
|
+
const path=require('path');const Utils=require('../jetwc-lib/jetwcutils-componentAuditUtils');const componentFinder=require('../jetwc-lib/jetwcutils-componentFinder');const TsxUtils=require('../jetwc-lib/jetwcutils-tsxUtils');const preCompiler=require('../jetwc-lib/jetwcutils-preCompiler');const ruleDef=function(){};ruleDef.prototype.getName=function(){return'jetwc-bootstrap'};ruleDef.prototype.getShortDescription=function(){return'Bootstrap processing for the JETWC rulset'};ruleDef.prototype.getDescription=function(){return'This rule is for internal use by the ruleset and should not be disabled'};ruleDef.prototype.register=function(context){this.componentRoots=context.config.components;this.auditBase=context.config.base;this.typeScriptCompile=context.config.typescript&&context.config.typescript.compile;return{startupRP:this._getAllVisibleComponents,closedownRP:this._reportDiagnostics}};ruleDef.prototype._getAllVisibleComponents=function(context){const{msgLib}=context.utils;msgLib.info(`builtinJetWcRules (${context.rulePack.getPackInfo().prefix}): ${context.rulePack.getPackInfo().version}`);const projectPathInfo=Utils.getKeyPathInfoForRulepack(context,this.auditBase);const componentRootFolder=context.rulePack.getRuleOptions().componentRoot||projectPathInfo.componentRootFolder;let precompileCache;if(this.typeScriptCompile){precompileCache=preCompiler.getPrecompileCacheIfNeeded(context,this.auditBase,projectPathInfo.tsSource,projectPathInfo.componentRootFolder)}const masterComponentList=componentFinder.findAllComponents(context,projectPathInfo,this.componentRoots,precompileCache);if(masterComponentList&&masterComponentList.length>0){const allComponentsMap=masterComponentList.reduce((wmap,component)=>{if(!projectPathInfo.isBuiltOutput||projectPathInfo.isBuiltOutput&&!wmap.has(component.fullName)){wmap.set(component.fullName,component)}return wmap},new Map);const referenceComponents=new Map;const componentPaths=new Map;allComponentsMap.forEach(component=>{component.language=Utils.detectComponentSourceType(context,component.rootFolder,component.vcomponent);switch(component.type){case'reference':referenceComponents.set(component.fullName,component.ba);break;case'composite':case'resource':if(component.local){if(component.dependencies){Object.values(component.dependencies).forEach(dependency=>{if(allComponentsMap.has(dependency.name)){const proxyPaths=allComponentsMap.get(dependency.name).requirePaths;proxyPaths.forEach(path=>{component.requirePaths.add(path)})}else{msgLib.debug(`JETWC: missing dependency lookup for ${dependency.name} when resolving requirePaths`)}})}componentPaths.set(component.rootFolder,component.fullName)}break;}});context.rulePack.setExtension({rulepackVersion:context.rulePack.getPackInfo().version,bootStrap:true,platform:Utils.isWindows?'Windows':'Unix-like',precompiled:this.typeScriptCompile,componentHome:`/${componentRootFolder}/`,auditBuildOutput:projectPathInfo.isBuiltOutput,discoveredPaths:projectPathInfo,componentRoots:this.componentRoots,allReferenceComponents:referenceComponents,allComponents:allComponentsMap,auditableComponentPaths:componentPaths,allAuditableFilePaths:new Map})}else{msgLib.error(`No components have been discovered from the JAF configuration for the ${context.rulePack.getPackInfo().prefix} ruleset to process. You will need to configure the "components" array to point at your component root folder`);Utils.disableRulePack(context)}};ruleDef.prototype._reportDiagnostics=function(context){const msgLib=context.utils.msgLib;const opts=context.rulePack.getRuleOptions();const diagnostics=context.rulePack.getExtension();if(!opts.testMode){let foundVMMapping=0;let candidateLocal=0;if(diagnostics&&diagnostics.allComponents&&diagnostics.allComponents.length>0){diagnostics.allComponents.forEach((component,compName)=>{if(component.local&&component.type==='composite'){candidateLocal++;if(component.viewModel&&component.viewModel.resolved){foundVMMapping++}}});if(foundVMMapping!==candidateLocal){msgLib.error(`Error: Audit was only able to map ${foundVMMapping} out of ${candidateLocal} components to their viewModels. Some audits will be unable to operate.`)}}}if(opts.debug&&opts.diagnosticFile&&diagnostics){msgLib.msg(`Writing JETWC diagnostics to ${opts.diagnosticFile}.json`);const dFile=Utils.toJAFPath(path.join(path.resolve('.'),opts.diagnosticFile+'.json'));context.utils.fsUtils.writeJsonSync(diagnostics,dFile,{spaces:2,replacer:Utils.diagnosticReplacer})}};module.exports=ruleDef;
|
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* Licensed under The Universal Permissive License (UPL), Version 1.0
|
|
4
4
|
* as shown at https://oss.oracle.com/licenses/upl/
|
|
5
5
|
*/
|
|
6
|
-
const Utils=require('../jetwc-lib/jetwcutils-componentAuditUtils');const ruleDef=function(){};ruleDef.prototype.getName=function(){return'jetwc-css-oj-complete'};ruleDef.prototype.getShortDescription=function(){return'Verify that a component CSS implementation includes the standard definition for hiding itself before it is fully initialized'};ruleDef.prototype.getDescription=function(){return'All custom components should include a selector definition for the component tag that ensures that it is hidden until the oj-complete marker class is applied. This is managed through the use of the :not(.oj-complete) pseudo-class setting the visibility to hidden'};ruleDef.prototype.register=function(context){return{startaudit:this._ruleSetup,'css-selector':this._detectNotSelector,endaudit:this._reportUnmatchedComponents}};ruleDef.prototype._ruleSetup=function(context){this.validOjCompleteSelectors=new Set};ruleDef.prototype._detectNotSelector=function(context,selector){if(selector.type==='Selector'&&selector.children.length===2&&selector.children[0].type==='TypeSelector'&&selector.children[1].type==='PseudoClassSelector'&&selector.children[1].name==='not'){const selectorComponentName=selector.children[0].name;const componentInfo=Utils.componentInfo(context,selectorComponentName);if(componentInfo&&selector.children[1].children.length>0&&selector.children[1].children[0].type==='SelectorList'&&selector.children[1].children[0].children.length>0&&selector.children[1].children[0].children[0].type==='Selector'&&selector.children[1].children[0].children[0].children.length>0&&selector.children[1].children[0].children[0].children[0].type==='ClassSelector'&&selector.children[1].children[0].children[0].children[0].name==='oj-complete'){this.validOjCompleteSelectors.add(selectorComponentName)}}};ruleDef.prototype._reportUnmatchedComponents=function(context){const allComponents=context.rulePack.getExtension().allComponents;
|
|
6
|
+
const Utils=require('../jetwc-lib/jetwcutils-componentAuditUtils');const ruleDef=function(){};ruleDef.prototype.getName=function(){return'jetwc-css-oj-complete'};ruleDef.prototype.getShortDescription=function(){return'Verify that a component CSS implementation includes the standard definition for hiding itself before it is fully initialized'};ruleDef.prototype.getDescription=function(){return'All custom components should include a selector definition for the component tag that ensures that it is hidden until the oj-complete marker class is applied. This is managed through the use of the :not(.oj-complete) pseudo-class setting the visibility to hidden'};ruleDef.prototype.register=function(context){return{startaudit:this._ruleSetup,'css-selector':this._detectNotSelector,endaudit:this._reportUnmatchedComponents}};ruleDef.prototype._ruleSetup=function(context){this.validOjCompleteSelectors=new Set};ruleDef.prototype._detectNotSelector=function(context,selector){if(selector.type==='Selector'&&selector.children.length===2&&selector.children[0].type==='TypeSelector'&&selector.children[1].type==='PseudoClassSelector'&&selector.children[1].name==='not'){const selectorComponentName=selector.children[0].name;const componentInfo=Utils.componentInfo(context,selectorComponentName);if(componentInfo&&selector.children[1].children.length>0&&selector.children[1].children[0].type==='SelectorList'&&selector.children[1].children[0].children.length>0&&selector.children[1].children[0].children[0].type==='Selector'&&selector.children[1].children[0].children[0].children.length>0&&selector.children[1].children[0].children[0].children[0].type==='ClassSelector'&&selector.children[1].children[0].children[0].children[0].name==='oj-complete'){this.validOjCompleteSelectors.add(selectorComponentName)}}};ruleDef.prototype._reportUnmatchedComponents=function(context){const allComponents=context.rulePack.getExtension().allComponents;if(allComponents){for(const[componentName,componentDef]of allComponents.entries()){if(componentDef.type==='composite'){const fullName=componentDef.fullName;if(!this.validOjCompleteSelectors.has(fullName)){if(!Utils.shouldIgnoreCheck(context,this.getName(),fullName)){const issue=new context.Issue(`Component '${fullName}' does not have a defined CSS sector for :not(.oj-complete)`);context.reporter.addIssue(issue,context)}}}}}};module.exports=ruleDef;
|
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* Licensed under The Universal Permissive License (UPL), Version 1.0
|
|
4
4
|
* as shown at https://oss.oracle.com/licenses/upl/
|
|
5
5
|
*/
|
|
6
|
-
const path=require('path');const ruleDef=function(){};ruleDef.prototype.getName=function(){return'jetwc-pack-children'};ruleDef.prototype.getShortDescription=function(){return'Ensure that all of the stated children of a pack are actually present and that we do not have any obvious orphans'};ruleDef.prototype.getDescription=function(){return'This rule inspects the physical structure of a pack and ensures that the declared child components are indeed present. We also check for un-registered children'};ruleDef.prototype.register=function(context){return{compjson:this._doAudit}};ruleDef.prototype._doAudit=function(context){const componentMetadata=context.suppData.obj;if(componentMetadata){let issue;let emptyMembership=false;if(componentMetadata.type&&componentMetadata.type==='pack'){const packName=componentMetadata.name;const packRoot=path.dirname(context.filepath);if(componentMetadata.dependencies){const packMembers=Object.keys(componentMetadata.dependencies);if(packMembers.length>0){const packFileStructure=context.utils.fsUtils.readDir(packRoot);packMembers.forEach(fullName=>{if(!fullName.startsWith(packName)){issue=new context.Issue(`All members of the '${packName}' Pack should be named with the pack name prefix`);issue.setMsgKey(context.ruleName+'_1');context.reporter.addIssue(issue,context)}if(!issue){const componentDir=fullName.slice(packName.length+1);const componentFolder=packFileStructure.filter(fileObj=>fileObj.name===componentDir&&!fileObj.file);if(componentFolder.length!==1){issue=new context.Issue(`Pack ${packName} dependency '${fullName}' should be defined in a folder called '${componentDir}' for referencing to work correctly`);issue.setMsgKey(context.ruleName+'_2');context.reporter.addIssue(issue,context)}}});packFileStructure.map(child=>{if(!child.isFile){const matchesDeclaration=packMembers.filter(childComponent=>childComponent===`${packName}-${child.name}`);if(matchesDeclaration.length===0){
|
|
6
|
+
const path=require('path');const Utils=require('../jetwc-lib/jetwcutils-componentAuditUtils');const ruleDef=function(){};ruleDef.prototype.getName=function(){return'jetwc-pack-children'};ruleDef.prototype.getShortDescription=function(){return'Ensure that all of the stated children of a pack are actually present and that we do not have any obvious orphans'};ruleDef.prototype.getDescription=function(){return'This rule inspects the physical structure of a pack and ensures that the declared child components are indeed present. We also check for un-registered children'};ruleDef.prototype.register=function(context){return{compjson:this._doAudit}};ruleDef.prototype._doAudit=function(context){const componentMetadata=context.suppData.obj;if(componentMetadata){let issue;let emptyMembership=false;if(componentMetadata.type&&componentMetadata.type==='pack'){const packName=componentMetadata.name;const packRoot=path.dirname(context.filepath);if(componentMetadata.dependencies){const packMembers=Object.keys(componentMetadata.dependencies);if(packMembers.length>0){const packFileStructure=context.utils.fsUtils.readDir(packRoot);packMembers.forEach(fullName=>{if(!fullName.startsWith(packName)){issue=new context.Issue(`All members of the '${packName}' Pack should be named with the pack name prefix`);issue.setMsgKey(context.ruleName+'_1');context.reporter.addIssue(issue,context)}if(!issue){const componentDir=fullName.slice(packName.length+1);const componentFolder=packFileStructure.filter(fileObj=>fileObj.name===componentDir&&!fileObj.file);if(componentFolder.length!==1){issue=new context.Issue(`Pack ${packName} dependency '${fullName}' should be defined in a folder called '${componentDir}' for referencing to work correctly`);issue.setMsgKey(context.ruleName+'_2');context.reporter.addIssue(issue,context)}}});packFileStructure.map(child=>{if(!child.isFile){const matchesDeclaration=packMembers.filter(childComponent=>childComponent===`${packName}-${child.name}`);if(matchesDeclaration.length===0){const folderName=path.join(packRoot,child.name);const matchesComponent=Utils.matchComponentPath(context,folderName);if(matchesComponent){issue=new context.Issue(`Pack ${packName} seems to have a child component '${child.name}' that is not included in the dependencies of the pack`);issue.setMsgKey(context.ruleName+'_3');context.reporter.addIssue(issue,context,'major')}}}})}else{emptyMembership=true}}else{emptyMembership=true}if(emptyMembership){let vcomponentsPresent=false;const allVisibleComponents=context.rulePack.getExtension().allComponents;allVisibleComponents.forEach(componentInfo=>{if(componentInfo.pack&&componentInfo.pack===packName&&componentInfo.vcomponent){vcomponentsPresent=true}});if(!vcomponentsPresent){issue=new context.Issue(`Pack '${componentMetadata.name}' has no defined members`);issue.setMsgKey(context.ruleName+'_4');context.reporter.addIssue(issue,context,'major')}}}}};module.exports=ruleDef;
|
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* Licensed under The Universal Permissive License (UPL), Version 1.0
|
|
4
4
|
* as shown at https://oss.oracle.com/licenses/upl/
|
|
5
5
|
*/
|
|
6
|
-
const Utils=require('../jetwc-lib/jetwcutils-componentAuditUtils');const ruleDef=function(){};ruleDef.prototype.getName=function(){return'jetwc-schema'};ruleDef.prototype.getShortDescription=function(){return'Validate component json definition against the schema'};ruleDef.prototype.getDescription=function(){return'This rule checks verifies the component.json file included
|
|
6
|
+
const Utils=require('../jetwc-lib/jetwcutils-componentAuditUtils');const TsxUtils=require('../jetwc-lib/jetwcutils-tsxUtils');const fs=require('fs-extra');const ruleDef=function(){};ruleDef.prototype.getName=function(){return'jetwc-schema'};ruleDef.prototype.getShortDescription=function(){return'Validate component json definition against the schema'};ruleDef.prototype.getDescription=function(){return'This rule checks verifies the component.json file included by or generated from the component against the schema supplied for this purpose'};ruleDef.prototype.register=function(context){return{compjson:this._doAudit,Program:this._doVComponentAudit}};ruleDef.prototype._doAudit=function(context,obj){let issue;if(context.suppData.obj){const jsonToValidate=obj.obj.component?obj.obj.component:obj.obj;const schemaErrors=context.utils.metaLib.applySchema(jsonToValidate);if(schemaErrors){schemaErrors.forEach(error=>{issue=new context.Issue(`component.json schema violation: ${this._formatViolation(error)}`);context.reporter.addIssue(issue,context)})}}};ruleDef.prototype._doVComponentAudit=function(context){const lenient=context.rulePack.getRuleOptions().ignoreAdditionalProperties;const componentInfo=TsxUtils.matchToVComponentImpl(context,context.filepath);if(componentInfo&&componentInfo.compiledMetadata){const jsonToValidate=fs.readJSONSync(componentInfo.compiledMetadata);const schemaErrors=context.utils.metaLib.applySchema(jsonToValidate);if(schemaErrors){const encounteredErrors=new Set;schemaErrors.forEach(report=>{const skip=lenient&&report.error&&report.error.keyword==='additionalProperties';if(!skip){const formattedError=this._formatViolation(report);if(!encounteredErrors.has(formattedError)){encounteredErrors.add(formattedError);issue=new context.Issue(`Generated component.json has schema violation: ${formattedError}`);context.reporter.addIssue(issue,context)}}})}}};ruleDef.prototype._formatViolation=function(report){let formattedMsg;switch(report.error.keyword){case'required':const jsonErrorPath=report.error.dataPath?report.error.dataPath:report.error.instancePath;const formattedPath=this._transformViolationDataPath(jsonErrorPath);formattedMsg=`${formattedPath} ${report.msg}`;break;default:formattedMsg=report.msg;}return formattedMsg};ruleDef.prototype._transformViolationDataPath=function(dataPath){let formatted=dataPath;;const parser=/\.(\w*)\['(\w*)'\]/g;const segparser=/\.(\w*)\['(\w*)'\]/;const instancePathParser=/\/(\w*)\/(\w*)/g;const instancePathSegParser=/\/(\w*)\/(\w*)/;let segments=dataPath.match(parser);let deconstructed;if(segments!==null){deconstructed=segments.map(seg=>{subParts=seg.match(segparser);return{segment:subParts[0],type:subParts[1],context:subParts[2]}})}else{segments=dataPath.match(instancePathParser);deconstructed=segments.map(seg=>{subParts=seg.match(instancePathSegParser);return{segment:subParts[0],type:subParts[1],context:subParts[2]}})}if(deconstructed&&deconstructed.length>0){if(deconstructed[0].type==='properties'){formatted=`Property ${deconstructed[0].context}`;if(deconstructed.length>1){for(let i=1;i<deconstructed.length;i++){if(deconstructed[i].type==='properties'){formatted+=`.${deconstructed[i].context}`}else{formatted+=` ${deconstructed[i].type}:${deconstructed[i].context}`}}}}}return formatted};module.exports=ruleDef;
|
|
@@ -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 path=require("path");const Utils=require("../jetwc-lib/jetwcutils-componentAuditUtils");const ruleDef=function(){};ruleDef.prototype.getName=function(){return"jetwc-supproperty-propagation"};ruleDef.prototype.getShortDescription=function(){return"Check for cases where a component directly passes a property with sub-properties through to a child component"};ruleDef.prototype.getDescription=function(){return"Detects cases where a component property is passed directly to a child in a way that does not ensure that the child will automatically be informed of some change to that property during the lifespan of the component instance. In this scenario, the component should be using a proxy observable or computed rather than a direct passthrough binding to $properties to ensure that any change to the property at the top level is also notified to the child correctly"};ruleDef.prototype.register=function(context){return{attrexpr:this._doAudit}};ruleDef.prototype._doAudit=function(context,attribute,attributeValue){let issue;const candidateRE=/^[\{|\[]{2}(?:\$properties|\$props|properties)\.(\w*)[\}|\]]{2}$/;const checkProperty=attributeValue.match(candidateRE);if(checkProperty&&checkProperty.length===2){if(context.elemStack&&context.elemStack.length>0){const usageTag=context.elemStack.slice(-1)[0].name;if(usageTag&&!usageTag.startsWith("oj-bind-")){const componentName=Utils.matchComponentPath(context,path.dirname(context.filepath));if(componentName){const meta=Utils.componentInfo(context,componentName);if(meta.properties[checkProperty[1]]){if(meta.properties[checkProperty[1]].properties){if(!Utils.shouldIgnoreCheck(context,"jetwc-supproperty-propagation",componentName,"properties",checkProperty[1])){issue=new context.Issue(`Complex Properties such as ${checkProperty[1]} in the component ${componentName} should be bound via a proxy to a child component rather than directly if change propagation is going to work correctly. Currently the binding is via ${attributeValue}`);context.reporter.addIssue(issue,context)}}}}}}}};module.exports=ruleDef;
|
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* Licensed under The Universal Permissive License (UPL), Version 1.0
|
|
4
4
|
* as shown at https://oss.oracle.com/licenses/upl/
|
|
5
5
|
*/
|
|
6
|
-
{"jetwc-component-foldername":"0010","jetwc-component-location_1":"0011","jetwc-component-location_2":"0012","jetwc-pack-children_1":"0013","jetwc-pack-children_2":"0014","jetwc-pack-children_3":"0015","jetwc-pack-children_4":"0016","jetwc-packable-components_1":"0017","jetwc-packable-components_2":"0018","jetwc-packable-components_3":"0019","jetwc-component-dependencies_1":"0021","jetwc-component-dependencies_2":"0022","jetwc-component-dependencies_3":"0023","jetwc-component-dependencies_4":"0024","jetwc-component-dependencies_5":"0025","jetwc-prerelease-version":"0026","jetwc-prerelease-dependencies":"0027","jetwc-namespace":"0029","jetwc-vb-category_1":"0030","jetwc-vb-category_2":"0031","jetwc-jet-version_1":"0033","jetwc-jet-version_2":"0034","jetwc-absolute-jetversion":"0035","jetwc-semantic-version":"0040","jetwc-standard-files":"0041","jetwc-loader-file_1":"0044","jetwc-loader-file_2":"0045","jetwc-loader-file_3":"0046","jetwc-loader-file_4":"0047","jetwc-version-openrange_1":"0048","jetwc-version-openrange_2":"0049","jetwc-displayname_1":"0050","jetwc-displayname_2":"0051","jetwc-nls-root":"0052","jetwc-require-paths":"0053","jetwc-vb-icon_1":"0054","jetwc-vb-icon_2":"0055","jetwc-vb-icon_3":"0056","jetwc-vb-icon_4":"0057","jetwc-vb-icon_5":"0058","jetwc-vb-icon_6":"0059","jetwc-vb-icon_7":"0060","jetwc-vb-icon_8":"0061","jetwc-template-slots_1":"0062","jetwc-template-slots_2":"0063","jetwc-template-slots_3":"0064","jetwc-template-slots_4":"0065","jetwc-template-slots_5":"0066","jetwc-slots_1":"0067","jetwc-slots_2":"0068","jetwc-events_1":"0069","jetwc-events_2":"0070","jetwc-property-nesting":"0071","jetwc-nls-languages_1":"0072","jetwc-nls-languages_2":"0073","jetwc-nls-languages_3":"0074","jetwc-nls-languages_4":"0075","jetwc-event-displayname":"0076","jetwc-methods_1":"0077","jetwc-methods_2":"0078","jetwc-property-changed":"0079","jetwc-writeback-required_1":"0080","jetwc-writeback-required_2":"0081","jetwc-writeback-required_3":"0082","jetwc-writeback-required_4":"0083","jetwc-oj-register":"0084","jetwc-register-with-promises":"0085","jetwc-register-css":"0086","jetwc-deprecated-lifecycle":"0087","jetwc-aria-redefinition":"0088","jetwc-public-modules_1":"0089","jetwc-public-modules_2":"0090","jetwc-disabled-property":"0091","jetwc-reserved-property":"0092","jetwc-prerelease-pattern":"0093","jetwc-ojcss":"0094","jetwc-vb-icon_9":"0095","jetwc-component-location_3":"0096","jetwc-dynamic-slot-context":"0097","jetwc-dynamic-slots-naming":"0098","jetwc-unused-slots":"0099","jetwc-unused-events":"0100","jetwc-compjson-bp-obj":"0101","jetwc-compjson-bp-ar":"0102","jetwc-method-displayname":"0103","jetwc-slot-displayname":"0104","jetwc-component-displayname":"0105","jetwc-property-displayname":"0106","jetwc-data-property-prefix":"0107","jetwc-schema":"0108","jetwc-component-type":"0109","jetwc-subproperty-writeback":"0111","jetwc-nested-defaults":"0112","jetwc-required-subproperty":"0113","jetwc-vcomponent-jetversion_1":"0120","jetwc-vcomponent-jetversion_2":"0121","jetwc-vcomponent-version_1":"0130","jetwc-vcomponent-version_2":"0131","jetwc-vcomponent-version_3":"0132","jetwc-vcomponent-loader_1":"0140","jetwc-vcomponent-loader_2":"0141","jetwc-markdown-link_1":"0150","jetwc-markdown-link_2":"0151","jetwc-css-oj-complete":"0160"}
|
|
6
|
+
{"jetwc-component-foldername":"0010","jetwc-component-location_1":"0011","jetwc-component-location_2":"0012","jetwc-pack-children_1":"0013","jetwc-pack-children_2":"0014","jetwc-pack-children_3":"0015","jetwc-pack-children_4":"0016","jetwc-packable-components_1":"0017","jetwc-packable-components_2":"0018","jetwc-packable-components_3":"0019","jetwc-component-dependencies_1":"0021","jetwc-component-dependencies_2":"0022","jetwc-component-dependencies_3":"0023","jetwc-component-dependencies_4":"0024","jetwc-component-dependencies_5":"0025","jetwc-prerelease-version":"0026","jetwc-prerelease-dependencies":"0027","jetwc-namespace":"0029","jetwc-vb-category_1":"0030","jetwc-vb-category_2":"0031","jetwc-jet-version_1":"0033","jetwc-jet-version_2":"0034","jetwc-absolute-jetversion":"0035","jetwc-semantic-version":"0040","jetwc-standard-files":"0041","jetwc-loader-file_1":"0044","jetwc-loader-file_2":"0045","jetwc-loader-file_3":"0046","jetwc-loader-file_4":"0047","jetwc-version-openrange_1":"0048","jetwc-version-openrange_2":"0049","jetwc-displayname_1":"0050","jetwc-displayname_2":"0051","jetwc-nls-root":"0052","jetwc-require-paths":"0053","jetwc-vb-icon_1":"0054","jetwc-vb-icon_2":"0055","jetwc-vb-icon_3":"0056","jetwc-vb-icon_4":"0057","jetwc-vb-icon_5":"0058","jetwc-vb-icon_6":"0059","jetwc-vb-icon_7":"0060","jetwc-vb-icon_8":"0061","jetwc-template-slots_1":"0062","jetwc-template-slots_2":"0063","jetwc-template-slots_3":"0064","jetwc-template-slots_4":"0065","jetwc-template-slots_5":"0066","jetwc-slots_1":"0067","jetwc-slots_2":"0068","jetwc-events_1":"0069","jetwc-events_2":"0070","jetwc-property-nesting":"0071","jetwc-nls-languages_1":"0072","jetwc-nls-languages_2":"0073","jetwc-nls-languages_3":"0074","jetwc-nls-languages_4":"0075","jetwc-event-displayname":"0076","jetwc-methods_1":"0077","jetwc-methods_2":"0078","jetwc-property-changed":"0079","jetwc-writeback-required_1":"0080","jetwc-writeback-required_2":"0081","jetwc-writeback-required_3":"0082","jetwc-writeback-required_4":"0083","jetwc-oj-register":"0084","jetwc-register-with-promises":"0085","jetwc-register-css":"0086","jetwc-deprecated-lifecycle":"0087","jetwc-aria-redefinition":"0088","jetwc-public-modules_1":"0089","jetwc-public-modules_2":"0090","jetwc-disabled-property":"0091","jetwc-reserved-property":"0092","jetwc-prerelease-pattern":"0093","jetwc-ojcss":"0094","jetwc-vb-icon_9":"0095","jetwc-component-location_3":"0096","jetwc-dynamic-slot-context":"0097","jetwc-dynamic-slots-naming":"0098","jetwc-unused-slots":"0099","jetwc-unused-events":"0100","jetwc-compjson-bp-obj":"0101","jetwc-compjson-bp-ar":"0102","jetwc-method-displayname":"0103","jetwc-slot-displayname":"0104","jetwc-component-displayname":"0105","jetwc-property-displayname":"0106","jetwc-data-property-prefix":"0107","jetwc-schema":"0108","jetwc-component-type":"0109","jetwc-subproperty-writeback":"0111","jetwc-nested-defaults":"0112","jetwc-required-subproperty":"0113","jetwc-vcomponent-jetversion_1":"0120","jetwc-vcomponent-jetversion_2":"0121","jetwc-vcomponent-version_1":"0130","jetwc-vcomponent-version_2":"0131","jetwc-vcomponent-version_3":"0132","jetwc-vcomponent-loader_1":"0140","jetwc-vcomponent-loader_2":"0141","jetwc-markdown-link_1":"0150","jetwc-markdown-link_2":"0151","jetwc-css-oj-complete":"0160","jetwc-supproperty-propagation":"0170"}
|
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* Licensed under The Universal Permissive License (UPL), Version 1.0
|
|
4
4
|
* as shown at https://oss.oracle.com/licenses/upl/
|
|
5
5
|
*/
|
|
6
|
-
{"title":"Extended Audit Rules for JET Custom Component Authors","prefix":"JETWC","version":"1.
|
|
6
|
+
{"title":"Extended Audit Rules for JET Custom Component Authors","prefix":"JETWC","version":"1.18.1","rules":{"jetwc-bootstrap":{"group":"jetwc-do-not-disable","enabled":true,"severity":"info","debug":false,"diagnosticFile":"jetwc-diagnostics","auditBuildOutput":false,"testMode":false,"$required":true,"filetype":["tsx"],"amd":false},"jetwc-component-foldername":{"group":"jetwc-structure","severity":"blocker","filetype":["json","tsx"],"amd":false},"jetwc-component-location":{"group":"jetwc-structure","severity":"blocker","filetype":["json","tsx"],"amd":false},"jetwc-pack-children":{"group":"jetwc-dependencies","severity":"blocker","filetype":["json"],"amd":false},"jetwc-packable-components":{"group":"jetwc-structure","severity":"blocker","filetype":["json"],"amd":false},"jetwc-component-dependencies":{"group":"jetwc-dependencies","severity":"blocker","filetype":["json","tsx"],"amd":false},"jetwc-prerelease-version":{"group":"jetwc-pre-release","severity":"info","filetype":["json","tsx"],"amd":false},"jetwc-prerelease-dependencies":{"group":"jetwc-pre-release","severity":"info","filetype":["json","tsx"],"amd":false},"jetwc-namespace":{"group":"jetwc-api","enabled":false,"namespaces":[],"severity":"blocker","filetype":["json","tsx"],"amd":false},"jetwc-vb-category":{"group":"jetwc-vb","enabled":false,"categories":[],"severity":"minor","filetype":["json","tsx"],"amd":false},"jetwc-jet-version":{"group":"jetwc-pre-release","enabled":false,"versionMatch":"upperLimit","severity":"blocker","filetype":["json","tsx"],"amd":false},"jetwc-absolute-jetversion":{"group":"jetwc-dependencies","enabled":true,"severity":"minor","filetype":["json","tsx"],"amd":false},"jetwc-semantic-version":{"group":"jetwc-dependencies","severity":"blocker","filetype":["json","tsx"],"amd":false},"jetwc-standard-files":{"group":"jetwc-structure","enabled":true,"files":["README.md","CHANGELOG.md"],"severity":"info","filetype":["json","tsx"],"amd":false},"jetwc-loader-file":{"group":["jetwc-structure","jet-js"],"enabled":true,"severity":"critical","filetype":["json","js","ts","tsx"],"amd":false},"jetwc-version-openrange":{"group":"jetwc-dependencies","severity":"major","filetype":["json","tsx"],"amd":false},"jetwc-displayname":{"group":"jetwc-vb","enabled":true,"limits":{"component":{"length":30,"words":4},"property":{"length":30,"words":4},"event":{"length":30,"words":4},"slot":{"length":30,"words":4},"template":{"length":40,"words":8}},"severity":"info","filetype":["json","tsx"],"amd":false},"jetwc-nls-root":{"group":"jetwc-nls","enabled":true,"severity":"info","filetype":["js","ts","tsx"],"amd":false},"jetwc-require-paths":{"group":"jetwc-dependencies","enabled":true,"severity":"blocker","standardPaths":["require","exports","ojs","knockout","hammerjs","persist","jquery","vb","preact","@opentelemetry"],"filetype":["js","ts","tsx"],"amd":false},"jetwc-vb-icon":{"group":"jetwc-vb","enabled":true,"severity":"major","filetype":["json","tsx"],"amd":false},"jetwc-template-slots":{"group":"jetwc-api","enabled":true,"severity":"major","filetype":["html","tsx"],"amd":false},"jetwc-slots":{"group":"jetwc-api","enabled":true,"severity":"major","filetype":["html","tsx"],"amd":false},"jetwc-events":{"group":"jetwc-api","enabled":true,"severity":"major","filetype":["js","ts","tsx"],"amd":false},"jetwc-property-nesting":{"group":"jetwc-api","enabled":true,"depth":3,"severity":"minor","filetype":["json","tsx"],"amd":false},"jetwc-nls-languages":{"group":"jetwc-nls","enabled":false,"locales":[],"strict":false,"severity":"major","filetype":["js","ts"],"amd":false},"jetwc-event-displayname":{"group":"jetwc-vb","enabled":true,"severity":"info","filetype":["json","tsx"],"amd":false},"jetwc-nested-defaults":{"group":"jetwc-api","enabled":true,"severity":"major","filetype":["json","tsx"],"amd":false},"jetwc-methods":{"group":"jetwc-api","enabled":true,"severity":"major","filetype":["js","ts"],"amd":false},"jetwc-property-changed":{"group":"jetwc-api","enabled":true,"severity":"minor","filetype":["js","ts"],"amd":false},"jetwc-writeback-required":{"group":"jetwc-api","enabled":true,"severity":"major","filetype":["js","ts"],"amd":false},"jetwc-oj-register":{"group":"jetwc-deprecations","enabled":true,"severity":"minor","filetype":["js","ts"],"amd":false},"jetwc-register-with-promises":{"group":"jetwc-deprecations","enabled":true,"severity":"minor","filetype":["js","ts"],"amd":false},"jetwc-register-css":{"group":"jetwc-deprecations","enabled":true,"severity":"minor","filetype":["js","ts"],"amd":false},"jetwc-deprecated-lifecycle":{"group":"jetwc-deprecations","enabled":true,"severity":"major","filetype":["js","ts"],"amd":false},"jetwc-aria-redefinition":{"group":"jetwc-api","enabled":true,"severity":"minor","filetype":["json","tsx"],"amd":false},"jetwc-public-modules":{"group":"jetwc-api","enabled":true,"severity":"major","filetype":["json"],"amd":false},"jetwc-disabled-property":{"group":"jetwc-api","enabled":true,"severity":"minor","filetype":["json"],"amd":false},"jetwc-reserved-property":{"group":"jetwc-api","enabled":true,"severity":"major","reserved":["slot","key","ref","children"],"filetype":["json","tsx"],"amd":false},"jetwc-prerelease-pattern":{"group":"jetwc-api","enabled":true,"severity":"minor","filetype":["json","tsx"],"amd":false},"jetwc-ojcss":{"group":"jetwc-theming","enabled":true,"severity":"minor","filetype":["js","ts","tsx"],"amd":false},"jetwc-dynamic-slot-context":{"group":"jetwc-api","enabled":true,"severity":"major","filetype":["json"],"amd":false},"jetwc-dynamic-slots-naming":{"group":"jetwc-api","enabled":true,"severity":"minor","filetype":["json"],"amd":false},"jetwc-unused-slots":{"group":"jetwc-api","enabled":true,"severity":"info","filetype":["html"],"amd":false},"jetwc-unused-events":{"group":"jetwc-api","enabled":true,"severity":"info","filetype":["js","ts"],"amd":false},"jetwc-compjson-bp-obj":{"group":"jetwc-api","enabled":true,"severity":"info","filetype":["json","tsx"],"amd":false},"jetwc-compjson-bp-ar":{"group":"jetwc-api","enabled":true,"severity":"info","filetype":["json","tsx"],"amd":false},"jetwc-component-displayname":{"group":"jetwc-vb","enabled":true,"severity":"info","filetype":["json","tsx"],"amd":false},"jetwc-method-displayname":{"group":"jetwc-vb","enabled":true,"severity":"info","filetype":["json","tsx"],"amd":false},"jetwc-property-displayname":{"group":"jetwc-vb","enabled":true,"severity":"info","filetype":["json","tsx"],"amd":false},"jetwc-slot-displayname":{"group":"jetwc-vb","enabled":true,"severity":"info","filetype":["json","tsx"],"amd":false},"jetwc-data-property-prefix":{"group":"jetwc-api","enabled":true,"severity":"minor","filetype":["json","tsx"],"amd":false},"jetwc-schema":{"group":"jetwc-api","enabled":true,"severity":"blocker","ignoreAdditionalProperties":true,"filetype":["json","tsx"],"amd":false},"jetwc-component-type":{"group":"jetwc-api","enabled":true,"severity":"info","filetype":["json"],"amd":false},"jetwc-subproperty-writeback":{"group":"jetwc-api","enabled":true,"severity":"major","filetype":["html"],"amd":false},"jetwc-required-subproperty":{"group":"jetwc-api","enabled":true,"severity":"minor","filetype":["json"],"amd":false},"jetwc-vcomponent-jetversion":{"group":"jetwc-dependencies","enabled":true,"severity":"blocker","filetype":["tsx"],"amd":false},"jetwc-vcomponent-version":{"group":"jetwc-dependencies","enabled":true,"severity":"blocker","filetype":["tsx"],"amd":false},"jetwc-vcomponent-loader":{"group":"jetwc-structure","enabled":true,"severity":"blocker","filetype":["ts"],"amd":false},"jetwc-markdown-link":{"group":"jetwc-doc","enabled":true,"severity":"minor","filetype":["md"],"amd":false},"jetwc-css-oj-complete":{"group":"jetwc-css","enabled":true,"severity":"major","filetype":["css"],"amd":false},"jetwc-supproperty-propagation":{"group":"jetwc-api","enabled":true,"severity":"major","filetype":["html"],"amd":false}}}
|
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* Licensed under The Universal Permissive License (UPL), Version 1.0
|
|
4
4
|
* as shown at https://oss.oracle.com/licenses/upl/
|
|
5
5
|
*/
|
|
6
|
-
const path=require('path');const Utils=require('./jetwcutils-componentAuditUtils');const tsxUtils=require('./jetwcutils-tsxUtils');const ComponentFinder=function(){this.runOnce=false};ComponentFinder.prototype.findAllComponents=function(auditContext,projectPathInfo,componentRoots,precompileCache){const msg=auditContext.utils.msgLib;let masterComponentList=[];if(!this.runOnce||auditContext.rulePack.getRuleOptions().testMode){if(projectPathInfo.exchangeCacheFolder){masterComponentList=masterComponentList.concat(this._discoverComponentsFromRoot(path.join(projectPathInfo.base,projectPathInfo.exchangeCacheFolder),false,false,auditContext,null,null))}if(componentRoots&&componentRoots.length>0){componentRoots.forEach(root=>{let target=root;if(auditContext.utils.fsUtils.getFileTypeSync(target)==='f'){target=path.dirname(root);msg.msg(`Warning: Incorrectly defined "components" array entry in JAF configuration file. Entries should list folders only not explicit file names.\n Bad entry: "${root}"\nAudit will process the "${target}" folder instead.\n`)}masterComponentList=masterComponentList.concat(this._discoverComponentsFromRoot(target,true,projectPathInfo.isBuiltOutput,auditContext,null,precompileCache))})}else{if(projectPathInfo.componentRootFolder){masterComponentList=masterComponentList.concat(this._discoverComponentsFromRoot(path.join(projectPathInfo.base,projectPathInfo.jsSource,projectPathInfo.componentRootFolder),true,projectPathInfo.isBuiltOutput,auditContext,null,precompileCache));if(projectPathInfo.tsSource){masterComponentList=masterComponentList.concat(this._discoverComponentsFromRoot(path.join(projectPathInfo.base,projectPathInfo.tsSource,projectPathInfo.componentRootFolder),true,false,auditContext,null,precompileCache))}}}this.runOnce=true;this.masterComponentList=masterComponentList}return this.masterComponentList};ComponentFinder.prototype._discoverComponentsFromRoot=function(rootDir,isLocal,builtOutput,auditContext,parentPack,precompileCache){const msg=auditContext.utils.msgLib;let componentArray=[];if(auditContext.utils.fsUtils.pathExistsSync(rootDir)){const compFileStructure=auditContext.utils.fsUtils.readDir(rootDir);compFileStructure.forEach(l1file=>{let componentInfo;if(!l1file.isFile&&l1file.files.length>0){l1file.files.forEach(l2file=>{if(!builtOutput){if(l2file.isFile&&l2file.name==='component.json'){componentInfo=Utils.extractComponentInfoFromJSONFile(auditContext,path.join(rootDir,l1file.name),'component.json',isLocal,false);componentArray.push(componentInfo);if(componentInfo.type==='pack'){const packMembers=this._discoverComponentsFromRoot(Utils.toJAFPath(path.join(rootDir,l1file.name)),isLocal,false,auditContext,componentInfo.name,precompileCache);componentArray=componentArray.concat(packMembers)}}else if(l2file.isFile&&path.extname(l2file.name)==='.tsx'&&precompileCache){componentInfo=tsxUtils.extractComponentInfoFromTSXFile(auditContext,path.join(rootDir,l1file.name),l2file.name,isLocal,precompileCache);if(componentInfo){componentArray.push(componentInfo)}}}else{if(!l2file.isFile&&l2file.files.length>0){l2file.files.forEach(l3file=>{if(l3file.isFile&&l3file.name==='component.json'){componentInfo=Utils.extractComponentInfoFromJSONFile(auditContext,path.join(rootDir,l1file.name,l2file.name),'component.json',isLocal,false);if(!componentInfo.pack){componentArray.push(componentInfo);if(componentInfo.type==='pack'){const packMembers=this._discoverComponentsFromRoot(Utils.toJAFPath(path.join(rootDir,l1file.name,l2file.name)),isLocal,false,auditContext,componentInfo.name,precompileCache);componentArray=componentArray.concat(packMembers)}}}else if(l3file.isFile&&path.extname(l3file.name)==='.tsx'&&precompileCache){componentInfo=tsxUtils.extractComponentInfoFromTSXFile(auditContext,path.join(rootDir,l1file.name,l2file.name),l3file.name,isLocal,precompileCache);if(componentInfo){componentArray.push(componentInfo)}}})}}})}else{if(l1file.isFile&&l1file.name==='component.json'){componentInfo=Utils.extractComponentInfoFromJSONFile(auditContext,rootDir,'component.json',isLocal,false);if(componentInfo.type!=='pack'||componentInfo.name!==parentPack){componentArray.push(componentInfo)}}else if(l1file.isFile&&path.extname(l1file.name)==='.tsx'&&precompileCache){componentInfo=tsxUtils.extractComponentInfoFromTSXFile(auditContext,rootDir,l1file.name,isLocal,precompileCache);if(componentInfo){componentArray.push(componentInfo)}}}})}return componentArray};module.exports=new ComponentFinder;
|
|
6
|
+
const path=require('path');const Utils=require('./jetwcutils-componentAuditUtils');const tsxUtils=require('./jetwcutils-tsxUtils');const ComponentFinder=function(){this.runOnce=false};ComponentFinder.prototype.findAllComponents=function(auditContext,projectPathInfo,componentRoots,precompileCache){const msg=auditContext.utils.msgLib;let masterComponentList=[];if(!this.runOnce||auditContext.rulePack.getRuleOptions().testMode){if(projectPathInfo.exchangeCacheFolder){masterComponentList=masterComponentList.concat(this._discoverComponentsFromRoot(path.join(projectPathInfo.base,projectPathInfo.exchangeCacheFolder),false,false,auditContext,null,null))}if(componentRoots&&componentRoots.length>0){componentRoots.forEach(root=>{let target=root;if(auditContext.utils.fsUtils.getFileTypeSync(target)==='f'){target=path.dirname(root);msg.msg(`Warning: Incorrectly defined "components" array entry in JAF configuration file. Entries should list folders only not explicit file names.\n Bad entry: "${root}"\nAudit will process the "${target}" folder instead.\n`)}masterComponentList=masterComponentList.concat(this._discoverComponentsFromRoot(target,true,projectPathInfo.isBuiltOutput,auditContext,null,precompileCache))})}else{if(projectPathInfo.componentRootFolder){masterComponentList=masterComponentList.concat(this._discoverComponentsFromRoot(path.join(projectPathInfo.base,projectPathInfo.jsSource,projectPathInfo.componentRootFolder),true,projectPathInfo.isBuiltOutput,auditContext,null,precompileCache));if(projectPathInfo.tsSource&&projectPathInfo.tsSource!==projectPathInfo.jsSource){masterComponentList=masterComponentList.concat(this._discoverComponentsFromRoot(path.join(projectPathInfo.base,projectPathInfo.tsSource,projectPathInfo.componentRootFolder),true,false,auditContext,null,precompileCache))}}}this.runOnce=true;this.masterComponentList=masterComponentList}return this.masterComponentList};ComponentFinder.prototype._discoverComponentsFromRoot=function(rootDir,isLocal,builtOutput,auditContext,parentPack,precompileCache){const msg=auditContext.utils.msgLib;let componentArray=[];if(auditContext.utils.fsUtils.pathExistsSync(rootDir)){const compFileStructure=auditContext.utils.fsUtils.readDir(rootDir);compFileStructure.forEach(l1file=>{let componentInfo;if(!l1file.isFile&&l1file.files.length>0){l1file.files.forEach(l2file=>{if(!builtOutput){if(l2file.isFile&&l2file.name==='component.json'){componentInfo=Utils.extractComponentInfoFromJSONFile(auditContext,path.join(rootDir,l1file.name),'component.json',isLocal,false);componentArray.push(componentInfo);if(componentInfo.type&&componentInfo.type==='pack'){const packMembers=this._discoverComponentsFromRoot(Utils.toJAFPath(path.join(rootDir,l1file.name)),isLocal,false,auditContext,componentInfo.name,precompileCache);componentArray=componentArray.concat(packMembers)}}else if(l2file.isFile&&path.extname(l2file.name)==='.tsx'&&precompileCache){componentInfo=tsxUtils.extractComponentInfoFromTSXFile(auditContext,path.join(rootDir,l1file.name),l2file.name,isLocal,precompileCache);if(componentInfo){componentArray.push(componentInfo)}}}else{if(!l2file.isFile&&l2file.files.length>0){l2file.files.forEach(l3file=>{if(l3file.isFile&&l3file.name==='component.json'){componentInfo=Utils.extractComponentInfoFromJSONFile(auditContext,path.join(rootDir,l1file.name,l2file.name),'component.json',isLocal,false);if(!componentInfo.pack){componentArray.push(componentInfo);if(componentInfo.type==='pack'){const packMembers=this._discoverComponentsFromRoot(Utils.toJAFPath(path.join(rootDir,l1file.name,l2file.name)),isLocal,false,auditContext,componentInfo.name,precompileCache);componentArray=componentArray.concat(packMembers)}}}else if(l3file.isFile&&path.extname(l3file.name)==='.tsx'&&precompileCache){componentInfo=tsxUtils.extractComponentInfoFromTSXFile(auditContext,path.join(rootDir,l1file.name,l2file.name),l3file.name,isLocal,precompileCache);if(componentInfo){componentArray.push(componentInfo)}}})}}})}else{if(l1file.isFile&&l1file.name==='component.json'){componentInfo=Utils.extractComponentInfoFromJSONFile(auditContext,rootDir,'component.json',isLocal,false);if(componentInfo.type!=='pack'||componentInfo.name!==parentPack){componentArray.push(componentInfo)}}else if(l1file.isFile&&path.extname(l1file.name)==='.tsx'&&precompileCache){componentInfo=tsxUtils.extractComponentInfoFromTSXFile(auditContext,rootDir,l1file.name,isLocal,precompileCache);if(componentInfo){componentArray.push(componentInfo)}}}})}return componentArray};module.exports=new ComponentFinder;
|
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* Licensed under The Universal Permissive License (UPL), Version 1.0
|
|
4
4
|
* as shown at https://oss.oracle.com/licenses/upl/
|
|
5
5
|
*/
|
|
6
|
-
const path=require('path');const os=require('os');const Utils=require('./jetwcutils-componentAuditUtils');const COMPILER_OPTIONS={experimentalDecorators:true,failOnTypeErrors:true,jsx:'react',jsxFactory:'h',module:'commonjs',moduleResolution:'node',noEmitOnError:false,stripInternal:true,target:'es6'};const JAF_TEMP='jaf';const WORKING_ROOT_FOLDER='jetwc-temp';const OUTPUT_FOLDER='precompiled';const JSON_FOLDER='precompiled-json';const PreCompiler=function(){this.workingRootFolder=Utils.toJAFPath(path.join(os.tmpdir(),JAF_TEMP,WORKING_ROOT_FOLDER));this.runOnce=false};PreCompiler.prototype.getPrecompileCacheIfNeeded=function(auditContext,auditBase,tsSource,componentRootFolder){const{msgLib}=auditContext.utils;let precompileCache;if(!this.runOnce||auditContext.rulePack.getRuleOptions().testMode){if(auditContext.rulePack.getRuleOptions().hasOwnProperty('precompileCache')&&auditContext.rulePack.getRuleOptions().testMode){msgLib.info(`Test mode, bypassing Typescript compilation...`);precompileCache=Utils.toJAFPath(path.join(auditBase,auditContext.rulePack.getRuleOptions().precompileCache))}else{let tsConfigPath;if(auditContext.rulePack.getRuleOptions().hasOwnProperty('tsConfig')){tsConfigPath=auditContext.rulePack.getRuleOptions().tsConfig}else{tsConfigPath=path.join(auditBase,'tsconfig.json')}precompileCache=this._transformVComponents(auditContext,tsConfigPath,auditBase,tsSource,componentRootFolder)}this.runOnce=true;this.precompileCache=precompileCache}return this.precompileCache};PreCompiler.prototype._transformVComponents=function(auditContext,tsConfigPath,auditBase,sourceBase,componentBase){const{fsUtils,msgLib}=auditContext.utils;const normalizedTsConfigPath=Utils.toJAFPath(tsConfigPath);const normalizedAuditBase=Utils.toJAFPath(auditBase);const normalizedSourceBase=Utils.toJAFPath(sourceBase);if(fsUtils.fileExistsSync(normalizedTsConfigPath)){const outputFolder=fsUtils.getUniqueFileNameSync('_XXXXXX');const compiledOutputFolder=`${this.workingRootFolder}/js${outputFolder}`;const compiledJSONFolder=`${this.workingRootFolder}/json${outputFolder}`;const allTsConfig=fsUtils.readJsonSync(tsConfigPath,true,error=>msgLib.error(`Typescript configuration file ${tsConfigPath} cannot be read, unable to process VComponents.\nError: ${error}`));if(allTsConfig){msgLib.msg(`builtinJetWcRules: Typescript detected, compiling project...`);allTsConfig.compilerOptions.paths[`${componentBase}/*`]=[`${auditBase}/${sourceBase}/${componentBase}/*`];const sourceBaseRoot=sourceBase.includes('/')?sourceBase.split('/')[0]:sourceBase;Object.entries(allTsConfig.compilerOptions.paths).forEach(([pathKey,pathValues])=>{const remapped=pathValues.map(mappedPath=>{return this._remapPath(mappedPath,sourceBaseRoot,auditBase)});allTsConfig.compilerOptions.paths[pathKey]=remapped});allTsConfig.compilerOptions.typeRoots=allTsConfig.compilerOptions.typeRoots.map(typeroot=>this._remapPath(typeroot,sourceBaseRoot,auditBase));if(allTsConfig.compilerOptions.hasOwnProperty('types')){allTsConfig.compilerOptions.types=allTsConfig.compilerOptions.types.map(type=>this._remapPath(type,sourceBaseRoot,auditBase))}allTsConfig.compilerOptions.rootDir=auditBase;allTsConfig.compilerOptions.outDir=compiledOutputFolder;if(!fsUtils.pathExistsSync(this.workingRootFolder)){fsUtils.createFolderSync(this.workingRootFolder)}else{fsUtils.deleteFolderSync(this.workingRootFolder,false)}msgLib.debug(`builtinJetWcRules: Typescript compiled into ${this.workingRootFolder}`);const customTsc=`${auditBase}/node_modules/@oracle/oraclejet/dist/custom-tsc`;if(fsUtils.pathExistsSync(customTsc)){const CustomTypescriptCompiler=require(customTsc);const readFrom=`${auditBase}/${sourceBase}`;const files=this._discoverCompilableFiles(auditContext,readFrom,readFrom);const
|
|
6
|
+
const path=require('path');const os=require('os');const Utils=require('./jetwcutils-componentAuditUtils');const COMPILER_OPTIONS={experimentalDecorators:true,failOnTypeErrors:true,jsx:'react',jsxFactory:'h',module:'commonjs',moduleResolution:'node',noEmitOnError:false,stripInternal:true,target:'es6'};const JAF_TEMP='jaf';const WORKING_ROOT_FOLDER='jetwc-temp';const OUTPUT_FOLDER='precompiled';const JSON_FOLDER='precompiled-json';const PreCompiler=function(){this.workingRootFolder=Utils.toJAFPath(path.join(os.tmpdir(),JAF_TEMP,WORKING_ROOT_FOLDER));this.runOnce=false};PreCompiler.prototype.getPrecompileCacheIfNeeded=function(auditContext,auditBase,tsSource,componentRootFolder){const{msgLib}=auditContext.utils;let precompileCache;if(!this.runOnce||auditContext.rulePack.getRuleOptions().testMode){if(auditContext.rulePack.getRuleOptions().hasOwnProperty('precompileCache')&&auditContext.rulePack.getRuleOptions().testMode){msgLib.info(`Test mode, bypassing Typescript compilation...`);precompileCache=Utils.toJAFPath(path.join(auditBase,auditContext.rulePack.getRuleOptions().precompileCache))}else{let tsConfigPath;if(auditContext.rulePack.getRuleOptions().hasOwnProperty('tsConfig')){tsConfigPath=auditContext.rulePack.getRuleOptions().tsConfig}else{tsConfigPath=path.join(auditBase,'tsconfig.json')}precompileCache=this._transformVComponents(auditContext,tsConfigPath,auditBase,tsSource,componentRootFolder)}this.runOnce=true;this.precompileCache=precompileCache}return this.precompileCache};PreCompiler.prototype._transformVComponents=function(auditContext,tsConfigPath,auditBase,sourceBase,componentBase){const{fsUtils,msgLib}=auditContext.utils;const normalizedTsConfigPath=Utils.toJAFPath(tsConfigPath);const normalizedAuditBase=Utils.toJAFPath(auditBase);const normalizedSourceBase=Utils.toJAFPath(sourceBase);if(fsUtils.fileExistsSync(normalizedTsConfigPath)){const outputFolder=fsUtils.getUniqueFileNameSync('_XXXXXX');const compiledOutputFolder=`${this.workingRootFolder}/js${outputFolder}`;const compiledJSONFolder=`${this.workingRootFolder}/json${outputFolder}`;const allTsConfig=fsUtils.readJsonSync(tsConfigPath,true,error=>msgLib.error(`Typescript configuration file ${tsConfigPath} cannot be read, unable to process VComponents.\nError: ${error}`));if(allTsConfig){msgLib.msg(`builtinJetWcRules: Typescript detected, compiling project...`);allTsConfig.compilerOptions.paths[`${componentBase}/*`]=[`${auditBase}/${sourceBase}/${componentBase}/*`];const sourceBaseRoot=sourceBase.includes('/')?sourceBase.split('/')[0]:sourceBase;Object.entries(allTsConfig.compilerOptions.paths).forEach(([pathKey,pathValues])=>{const remapped=pathValues.map(mappedPath=>{return this._remapPath(mappedPath,sourceBaseRoot,auditBase)});allTsConfig.compilerOptions.paths[pathKey]=remapped});allTsConfig.compilerOptions.typeRoots=allTsConfig.compilerOptions.typeRoots.map(typeroot=>this._remapPath(typeroot,sourceBaseRoot,auditBase));if(allTsConfig.compilerOptions.hasOwnProperty('types')){allTsConfig.compilerOptions.types=allTsConfig.compilerOptions.types.map(type=>this._remapPath(type,sourceBaseRoot,auditBase))}allTsConfig.compilerOptions.rootDir=auditBase;allTsConfig.compilerOptions.outDir=compiledOutputFolder;if(!fsUtils.pathExistsSync(this.workingRootFolder)){fsUtils.createFolderSync(this.workingRootFolder)}else{fsUtils.deleteFolderSync(this.workingRootFolder,false)}msgLib.debug(`builtinJetWcRules: Typescript compiled into ${this.workingRootFolder}`);const customTsc=`${auditBase}/node_modules/@oracle/oraclejet/dist/custom-tsc`;const nodeJetPackage=path.join(auditBase,'node_modules','@oracle','oraclejet','package.json');if(fsUtils.pathExistsSync(customTsc)&&fsUtils.pathExistsSync(nodeJetPackage)){const packageJson=fsUtils.readJsonSync(nodeJetPackage);let jetVerString;if(packageJson){jetVerString=packageJson.version}const CustomTypescriptCompiler=require(customTsc);const readFrom=`${auditBase}/${sourceBase}`;const files=this._discoverCompilableFiles(auditContext,readFrom,readFrom);const buildOptions={debug:false,dtDir:compiledJSONFolder,version:'',jetVersion:'',templatePath:path.join(customTsc,'templates'),tsBuiltDir:compiledOutputFolder,mainEntryFile:'loader.d.ts',typesDir:compiledOutputFolder};const compileOptionsPre12={files,compilerOptions:allTsConfig.compilerOptions,buildOptions:buildOptions};const compileOptions1201={tsconfigJson:{compilerOptions:allTsConfig.compilerOptions,files},buildOptions:buildOptions};let compileOptions;if(jetVerString){if(auditContext.utils.semVerUtils.gt(jetVerString,'12.0.0')){compileOptions=compileOptions1201}else{compileOptions=compileOptionsPre12}}if(compileOptions){try{const{errors}=CustomTypescriptCompiler.compile(compileOptions);if(errors.length){msgLib.error('Errors during Typescript pre-compilation of VComponents');errors.forEach(error=>{if(error.hasOwnProperty('message')){msgLib.error(error.message);msgLib.error(error.stack)}else{msgLib.error(JSON.stringify(error))}})}else{msgLib.info(`builtinJetWcRules: Typescript compilation successful...`);return compiledJSONFolder}}catch(uncaughtFromCompile){msgLib.error('Uncaught error during Typescript pre-compilation of VComponents');msgLib.error(uncaughtFromCompile.stack)}}else{msgLib.error('Unable to run VComponent pre-compilation, cannot detect JET custom compiler version')}}else{msgLib.error('Unable to run VComponent pre-compilation as the required packages are not available. Run "ojet restore" or "npm install" to correct this.')}}}else{msgLib.info(`Typescript configuration file ${tsConfigPath} not found, pre-compilation will be skipped`)}return};PreCompiler.prototype._discoverCompilableFiles=function(auditContext,root,pathPrefix){const{fsUtils,msgLib}=auditContext.utils;const allSources=fsUtils.readDirSync(root);return this._extractCompilables(fsUtils,allSources,'').map(sourceFile=>`${pathPrefix}/${sourceFile}`)};PreCompiler.prototype._extractCompilables=function(fsUtils,sources,folder){return sources.reduce((compilables,candidate)=>{if(candidate.isFile&&(candidate.name.endsWith('.ts')||candidate.name.endsWith('.tsx'))){compilables.push(`${folder}/${candidate.name}`)}else if(candidate.files){compilables=compilables.concat(this._extractCompilables(fsUtils,candidate.files,`${folder}/${candidate.name}`,true))}return compilables},new Array)};PreCompiler.prototype._remapPath=function(definedPath,sourceFolder,auditBase){let newPath=definedPath;const segs=definedPath.split('/');if(segs[0]==='.'){segs.shift()}switch(segs[0]){case'node_modules':case sourceFolder:newPath=`${auditBase}/${segs.join('/')}`;break;}return newPath};module.exports=new PreCompiler;
|
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* Licensed under The Universal Permissive License (UPL), Version 1.0
|
|
4
4
|
* as shown at https://oss.oracle.com/licenses/upl/
|
|
5
5
|
*/
|
|
6
|
-
const path=require('path');const Utils=require('../jetwc-lib/jetwcutils-componentAuditUtils');const componentFinder=require('../jetwc-lib/jetwcutils-componentFinder');const preCompiler=require('../jetwc-lib/jetwcutils-preCompiler');const ruleDef=function(){};ruleDef.prototype.getName=function(){return'jetwco-bootstrap'};ruleDef.prototype.getShortDescription=function(){return'Bootstrap processing for the JETWCO rulset'};ruleDef.prototype.getDescription=function(){return'This rule is for internal use by the ruleset and should not be disabled'};ruleDef.prototype.register=function(context){this.componentRoots=context.config.components;this.auditBase=context.config.base;this.typeScriptCompile=context.config.typescript&&context.config.typescript.compile;return{startupRP:this._getAllVisibleComponents,closedownRP:this._reportDiagnostics}};ruleDef.prototype._getAllVisibleComponents=function(context){const{msgLib}=context.utils;msgLib.info(`builtinJetWcOracleRules (${context.rulePack.getPackInfo().prefix}): ${context.rulePack.getPackInfo().version}`);const projectPathInfo=Utils.getKeyPathInfoForRulepack(context,this.auditBase);const componentRootFolder=context.rulePack.getRuleOptions().componentRoot||projectPathInfo.componentRootFolder;const exchangeURL=context.rulePack.getRuleOptions().exchangeURL;let precompileCache;if(this.typeScriptCompile){precompileCache=preCompiler.getPrecompileCacheIfNeeded(context,this.auditBase,projectPathInfo.tsSource,projectPathInfo.componentRootFolder)}const masterComponentList=componentFinder.findAllComponents(context,projectPathInfo,this.componentRoots,precompileCache);if(masterComponentList&&masterComponentList.length>0){const allComponentsMap=masterComponentList.reduce((wmap,component)=>{if(!projectPathInfo.isBuiltOutput||projectPathInfo.isBuiltOutput&&!wmap.has(component.fullName)){wmap.set(component.fullName,component)}return wmap},new Map);const referenceComponents=new Map;const componentPaths=new Map;allComponentsMap.forEach(component=>{component.language=Utils.detectComponentSourceType(context,component.rootFolder);switch(component.type){case'reference':referenceComponents.set(component.fullName,component.ba);break;case'composite':case'resource':if(component.local){if(component.dependencies){Object.values(component.dependencies).forEach(dependencyName=>{if(allComponentsMap.has(dependencyName)){const proxyPaths=allComponentsMap.get(dependencyName).requirePaths;proxyPaths.forEach(path=>{component.requirePaths.add(path)})}})}componentPaths.set(component.rootFolder,component.fullName)}break;}});context.rulePack.setExtension({rulepackVersion:context.rulePack.getPackInfo().version,bootStrap:true,exchangeURL:exchangeURL,platform:Utils.isWindows?'Windows':'Unix-like',precompiled:this.typeScriptCompile,componentHome:`/${componentRootFolder}/`,auditBuildOutput:projectPathInfo.isBuiltOutput,discoveredPaths:projectPathInfo,componentRoots:this.componentRoots,allReferenceComponents:referenceComponents,allComponents:allComponentsMap,auditableComponentPaths:componentPaths,allAuditableFilePaths:new Map})}else{msgLib.error(`No components have been discovered from the JAF configuration for the ${context.rulePack.getPackInfo().prefix} ruleset to process. You will need to configure the "components" array to point at your component root folder`);Utils.disableRulePack(context)}};ruleDef.prototype._reportDiagnostics=function(context){const
|
|
6
|
+
const path=require('path');const Utils=require('../jetwc-lib/jetwcutils-componentAuditUtils');const componentFinder=require('../jetwc-lib/jetwcutils-componentFinder');const preCompiler=require('../jetwc-lib/jetwcutils-preCompiler');const ruleDef=function(){};ruleDef.prototype.getName=function(){return'jetwco-bootstrap'};ruleDef.prototype.getShortDescription=function(){return'Bootstrap processing for the JETWCO rulset'};ruleDef.prototype.getDescription=function(){return'This rule is for internal use by the ruleset and should not be disabled'};ruleDef.prototype.register=function(context){this.componentRoots=context.config.components;this.auditBase=context.config.base;this.typeScriptCompile=context.config.typescript&&context.config.typescript.compile;return{startupRP:this._getAllVisibleComponents,closedownRP:this._reportDiagnostics}};ruleDef.prototype._getAllVisibleComponents=function(context){const{msgLib}=context.utils;msgLib.info(`builtinJetWcOracleRules (${context.rulePack.getPackInfo().prefix}): ${context.rulePack.getPackInfo().version}`);const projectPathInfo=Utils.getKeyPathInfoForRulepack(context,this.auditBase);const componentRootFolder=context.rulePack.getRuleOptions().componentRoot||projectPathInfo.componentRootFolder;const exchangeURL=context.rulePack.getRuleOptions().exchangeURL;let precompileCache;if(this.typeScriptCompile){precompileCache=preCompiler.getPrecompileCacheIfNeeded(context,this.auditBase,projectPathInfo.tsSource,projectPathInfo.componentRootFolder)}const masterComponentList=componentFinder.findAllComponents(context,projectPathInfo,this.componentRoots,precompileCache);if(masterComponentList&&masterComponentList.length>0){const allComponentsMap=masterComponentList.reduce((wmap,component)=>{if(!projectPathInfo.isBuiltOutput||projectPathInfo.isBuiltOutput&&!wmap.has(component.fullName)){wmap.set(component.fullName,component)}return wmap},new Map);const referenceComponents=new Map;const componentPaths=new Map;allComponentsMap.forEach(component=>{component.language=Utils.detectComponentSourceType(context,component.rootFolder);switch(component.type){case'reference':referenceComponents.set(component.fullName,component.ba);break;case'composite':case'resource':if(component.local){if(component.dependencies){Object.values(component.dependencies).forEach(dependencyName=>{if(allComponentsMap.has(dependencyName)){const proxyPaths=allComponentsMap.get(dependencyName).requirePaths;proxyPaths.forEach(path=>{component.requirePaths.add(path)})}})}componentPaths.set(component.rootFolder,component.fullName)}break;}});context.rulePack.setExtension({rulepackVersion:context.rulePack.getPackInfo().version,bootStrap:true,exchangeURL:exchangeURL,platform:Utils.isWindows?'Windows':'Unix-like',precompiled:this.typeScriptCompile,componentHome:`/${componentRootFolder}/`,auditBuildOutput:projectPathInfo.isBuiltOutput,discoveredPaths:projectPathInfo,componentRoots:this.componentRoots,allReferenceComponents:referenceComponents,allComponents:allComponentsMap,auditableComponentPaths:componentPaths,allAuditableFilePaths:new Map})}else{msgLib.error(`No components have been discovered from the JAF configuration for the ${context.rulePack.getPackInfo().prefix} ruleset to process. You will need to configure the "components" array to point at your component root folder`);Utils.disableRulePack(context)}};ruleDef.prototype._reportDiagnostics=function(context){const msgLib=context.utils.msgLib;const opts=context.rulePack.getRuleOptions();const diagnostics=context.rulePack.getExtension();if(!opts.testMode){let foundVMMapping=0;let candidateLocal=0;if(diagnostics&&diagnostics.allComponents&&diagnostics.allComponents.length>0){diagnostics.allComponents.forEach((component,compName)=>{if(component.local&&component.type==='composite'){candidateLocal++;if(component.viewModel&&component.viewModel.resolved){foundVMMapping++}}});if(foundVMMapping!==candidateLocal){msgLib.error(`Error: Audit was only able to map ${foundVMMapping} out of ${candidateLocal} components to their viewModels. Some audits will be unable to operate.`)}}}if(opts.debug&&opts.diagnosticFile&&diagnostics){msgLib.msg(`Writing JETWCO diagnostics to ${opts.diagnosticFile}.json`);const dFile=Utils.toJAFPath(path.join(path.resolve('.'),opts.diagnosticFile+'.json'));context.utils.fsUtils.writeJsonSync(diagnostics,dFile,{spaces:2,replacer:Utils.diagnosticReplacer})}};module.exports=ruleDef;
|
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* Licensed under The Universal Permissive License (UPL), Version 1.0
|
|
4
4
|
* as shown at https://oss.oracle.com/licenses/upl/
|
|
5
5
|
*/
|
|
6
|
-
const Utils=require('../jetwc-lib/jetwcutils-componentAuditUtils');const AuditComponentCacheManager=require('../jetwc-lib/jetwcutils-auditComponentCacheManager');const NetUtils=require('../../lib/NetUtils');const CommonImpl=require('../jetwc-lib/jetwcutils-commonListenerImpls');const TsxUtils=require('../jetwc-lib/jetwcutils-tsxUtils');const VC=require('./jetwco-cacc-auditConstraints');const CaccHelpers=require('./jetwco-cacc-helpers');const jetVer=require('./jetwco-cacc-jetVer');const packContent=require('./jetwco-cacc-packContent');const packBundle=require('./jetwco-cacc-packBundle');const packBundleContent=require('./jetwco-cacc-packBundleContent');const dependencies=require('./jetwco-cacc-dependencies');const properties=require('./jetwco-cacc-properties');const propertyDefault=require('./jetwco-cacc-propertyDefault');const propertyRequired=require('./jetwco-cacc-propertyRequired');const propertyReadOnly=require('./jetwco-cacc-propertyReadOnly');const propertyWriteback=require('./jetwco-cacc-propertyWriteback');const propertyType=require('./jetwco-cacc-propertyType');const propertyEnumeration=require('./jetwco-cacc-propertyEnumeration');const methods=require('./jetwco-cacc-methods');const methodParams=require('./jetwco-cacc-methodParams');const methodParamTypes=require('./jetwco-cacc-methodParamTypes');const methodReturnType=require('./jetwco-cacc-methodReturnType');const events=require('./jetwco-cacc-events');const eventPayload=require('./jetwco-cacc-eventPayload');const eventBubbles=require('./jetwco-cacc-eventBubbles');const eventCancelable=require('./jetwco-cacc-eventCancelable');const slots=require('./jetwco-cacc-slots');const slotDataVariable=require('./jetwco-cacc-slotDataVariable');const slotDataVariableType=require('./jetwco-cacc-slotDataVariableType');const dynamicSlots=require('./jetwco-cacc-dynamicSlots');const styleVariables=require('./jetwco-cacc-styleVariables');const styleClasses=require('./jetwco-cacc-styleClasses');const publicModules=require('./jetwco-cacc-publicModules');const CONTROL_PROFILE={jetVer:{callback:jetVer,add:VC.MAJOR,remove:VC.MAJOR,mutate:VC.MAJOR,description:'Validate the JET Version compatibility range'},packContent:{callback:packContent,add:VC.MINOR,remove:VC.MAJOR_2_DEPRECATED,mutate:VC.SEMVER,description:'Validate the member components of a JET Pack'},packBundle:{callback:packBundle,add:VC.MINOR,remove:VC.MAJOR,mutate:VC.NEVER,description:'Validate the list of bundles defined by a JET Pack'},packBundleContent:{callback:packBundleContent,add:VC.MAJOR,remove:VC.MAJOR,mutate:VC.NEVER,description:'Validate the entries of each bundle defined by a JET Pack'},dependencies:{callback:dependencies,add:VC.MAJOR,remove:VC.MINOR,mutate:VC.SEMVER,description:'Validate the dependencies of a component'},properties:{callback:properties,add:VC.MINOR,remove:VC.MAJOR_2_DEPRECATED,mutate:VC.NEVER,description:'Validate the properties of a component'},propertyDefault:{callback:propertyDefault,add:VC.PATCH,remove:VC.MAJOR_DEPRECATED,mutate:VC.MAJOR_DEPRECATED,description:'Validate the defaults assigned to properties of a component'},propertyRequired:{callback:propertyRequired,add:VC.MAJOR,remove:VC.PATCH,mutate:VC.NEVER,description:'Validate the required states of a components properties'},propertyReadOnly:{callback:propertyReadOnly,add:VC.MAJOR,remove:VC.PATCH,mutate:VC.NEVER,description:'Validate the read-only states of a components properties'},propertyWriteback:{callback:propertyWriteback,add:VC.PATCH,remove:VC.NEVER,mutate:VC.NEVER,description:'Validate the writeback states of a components properties'},propertyType:{callback:propertyType,add:VC.PATCH,remove:VC.MAJOR_2_DEPRECATED,mutate:VC.NEVER,description:'Validate the assigned types of a components properties'},propertyEnumeration:{callback:propertyEnumeration,add:VC.PATCH,remove:VC.MAJOR_2_DEPRECATED,mutate:VC.MAJOR,description:'Validate the enumValues of a components properties'},methods:{callback:methods,add:VC.MINOR,remove:VC.MAJOR_2_DEPRECATED,mutate:VC.NEVER,description:'Validate the list of methods exposed by the component'},methodParams:{callback:methodParams,add:VC.MINOR,remove:VC.MAJOR_2_DEPRECATED,mutate:VC.NEVER,description:'Validate the list of parameters passed to methods exposed by the component'},methodParamTypes:{callback:methodParamTypes,add:VC.PATCH,remove:VC.MAJOR_2_DEPRECATED,mutate:VC.NEVER,description:'Validate the list of parameters passed to methods exposed by the component'},methodReturnType:{callback:methodReturnType,add:VC.PATCH,remove:VC.MAJOR,mutate:VC.NEVER,description:'Validate the return type of the methods exposed by the component'},events:{callback:events,add:VC.MINOR,remove:VC.MAJOR_2_DEPRECATED,mutate:VC.NEVER,description:'Validate the list of events exposed by the component'},eventPayload:{callback:eventPayload,add:VC.MINOR,remove:VC.MAJOR,mutate:VC.NEVER,description:'Validate the event detail of events exposed by the component'},eventBubbles:{callback:eventBubbles,add:VC.MINOR,remove:VC.NEVER,mutate:VC.NEVER,description:'Validate the event bubbles flag'},eventCancelable:{callback:eventCancelable,add:VC.MINOR,remove:VC.NEVER,mutate:VC.NEVER,description:'Validate the event cancelable flag'},slots:{callback:slots,add:VC.MINOR,remove:VC.MAJOR_2_DEPRECATED,mutate:VC.NEVER,description:'Validate the list of slots exposed by the component'},slotDataVariable:{callback:slotDataVariable,add:VC.PATCH,remove:VC.MAJOR_2_DEPRECATED,mutate:VC.NEVER,description:'Validate the list of attributes in a slot data attribute exposed by the component'},slotDataVariableType:{callback:slotDataVariableType,add:VC.NEVER,remove:VC.NEVER,mutate:VC.NEVER,description:'Validate the type assigned to each attributes in a slot data attribute exposed by the component'},dynamicSlots:{callback:dynamicSlots,add:VC.MINOR,remove:VC.MAJOR,mutate:VC.NEVER,description:'Validate the presence of the dynamicSlots marker on the component'},styleVariables:{callback:styleVariables,add:VC.MINOR,remove:VC.MAJOR_2_DEPRECATED,mutate:VC.NEVER,description:'Validate the list of styleVariables supported by the component'},styleClasses:{callback:styleClasses,add:VC.MINOR,remove:VC.MAJOR_2_DEPRECATED,mutate:VC.NEVER,description:'Validate the list of styleClasses supported by the component'},publicModules:{callback:publicModules,add:VC.MINOR,remove:VC.MAJOR,mutate:VC.NEVER,description:'Validate the list of publicModules exposed by a resource component'}};const ruleDef=function(){};ruleDef.prototype.getName=function(){return'jetwco-component-api-controlled-changes'};ruleDef.prototype.getShortDescription=function(){return'Check components for API changes based on a configurable rule-set'};ruleDef.prototype.getDescription=function(){return'This audit compares the APIs exposed by components with older versions in the Exchange Catalog according to a set of rules which determine when given changes, such as the removal of deprecated properties can be made'};ruleDef.prototype.register=function(context){return{startaudit:this._auditPrep,closedownRP:this._dealWithCache,compjson:this._doAudit,Program:this._doVComponentAudit}};ruleDef.prototype._auditPrep=function(context){this.exchangeURL=CommonImpl.checkForExchangeConfiguration(context);if(this.exchangeURL){this.acCache=new AuditComponentCacheManager(context,this.getName(),this.exchangeURL);this.componentExceptions=context.rulePack.getRuleOption('exceptions');const ipr=context.rulePack.getRuleOption('includePreReleases');if(ipr&&ipr===true){this.productionOnly=false}else{this.productionOnly=true}const ruleOverrides=context.rulePack.getRuleOption('controls');this.controlRules={};if(Object.keys(ruleOverrides).length>0){for(const[controlRule,controlRuleDef]of Object.entries(CONTROL_PROFILE)){this.controlRules[controlRule]={...controlRuleDef};if(ruleOverrides.hasOwnProperty(controlRule)){for(const[verb,override]of Object.entries(ruleOverrides[controlRule])){this.controlRules[controlRule][verb]=override}}}}else{this.controlRules={...CONTROL_PROFILE}}const activeControls=context.rulePack.getRuleOption('applyConditions');if(activeControls&&Array.isArray(activeControls)){Object.keys(this.controlRules).forEach(controlRule=>{if(!activeControls.includes(controlRule)){delete this.controlRules[controlRule]}})}this.requiredCheckVersions=CaccHelpers.calcRequiredVersionMatrix(this.controlRules)}else{const issue=new context.Issue(`Invalid or Missing exchangeURL value specified for the rule ${context.ruleName}, rule execution is disabled`);issue.setMsgKey(`${context.ruleName}_2`);issue.setSeverity('critical');context.reporter.addIssue(issue,context)}};ruleDef.prototype._dealWithCache=function(context){const shouldClearCache=context.rulePack.getRuleOption('clearCache',this.getName());if(shouldClearCache&&this.acCache){this.acCache.removeLocalCache()}};ruleDef.prototype._doAudit=function(context){if(context.suppData.obj){const meta=context.suppData.obj;const fullName=Utils.getComponentFullName(meta);const componentType=Utils.getComponentType(meta);this._conductChecks(context,fullName,componentType,meta)}};ruleDef.prototype._doVComponentAudit=function(context){const componentInfo=TsxUtils.matchToVComponentImpl(context,context.filepath);if(componentInfo){const meta={...componentInfo};if(componentInfo.dependencies){meta.dependencies=componentInfo.dependencies.reduce((asMap,entry)=>{asMap[entry.name]=entry.range;return asMap},{})}this._conductChecks(context,componentInfo.fullName,componentInfo.type,meta)}};ruleDef.prototype._conductChecks=function(context,fullName,componentType,componentMeta){const{msgLib,semVerUtils}=context.utils;const baselines=this._grabRequiredVersions(context,fullName,componentMeta.version,this.requiredCheckVersions,this.productionOnly);if(baselines&&baselines.latest.version){const compareMetadata=CaccHelpers.deriveConstraintMetadata(baselines);const componentVersionDiff=CaccHelpers.semanticDiff(semVerUtils,componentMeta.version,compareMetadata.version);try{for(const[controlRuleName,controlRuleDef]of Object.entries(this.controlRules)){if(!this._isExemptFromCheck(fullName,controlRuleName)){msgLib.info(`${context.ruleName}(${controlRuleName}): ${controlRuleDef.description}`);const errorMsgContext=CaccHelpers.getStdErrorContext(fullName,controlRuleName);this._executeCheck(controlRuleName,controlRuleDef,semVerUtils,this.acCache,componentMeta,compareMetadata,componentVersionDiff,baselines,componentType,fullName,errorMsgContext)}}}catch(auditDetail){const issue=new context.Issue(`API change for ${fullName}@${componentMeta.version}: ${auditDetail}`);issue.setMsgKey(`${context.ruleName}_1`);context.reporter.addIssue(issue,context)}}};ruleDef.prototype._grabRequiredVersions=function(context,fullName,versionUnderTest,requiredVersions,productionVersionsOnly){const{msgLib,semVerUtils}=context.utils;const checkVersions={'never':{isNeeded:true,version:null,metadata:null},'latest':{isNeeded:true,version:null,metadata:null},'patch':{isNeeded:requiredVersions.patch,version:null,metadata:null},'minor':{isNeeded:requiredVersions.minor,version:null,metadata:null},'major':{isNeeded:requiredVersions.major,version:null,metadata:null},'major+':{isNeeded:requiredVersions.major,version:null,metadata:null},'major2+':{isNeeded:requiredVersions.major2,version:null,metadata:null},'major3+':{isNeeded:requiredVersions.major3,version:null,metadata:null}};try{const versionsToCache=new Set;const netUtils=new NetUtils;const existingVersionsResp=netUtils.loadUrl(`${this.exchangeURL}components/${fullName}/versions`);if(existingVersionsResp.statusCode===200&&existingVersionsResp.body){const existingVersions=JSON.parse(existingVersionsResp.body);if(existingVersions.items&&existingVersions.items.length>0){const{major:vutMajor,minor:vutMinor,patch:vutPatch,prerelease:vutPreRel,version:vutVersion}=semVerUtils.parse(versionUnderTest);let historicalVersions;if(productionVersionsOnly){historicalVersions=existingVersions.items.reverse().filter(versionString=>{const{prerelease}=semVerUtils.parse(versionString);return prerelease.length===0})}else{historicalVersions=existingVersions.items.reverse()}const majorSequence=this._getOffsetMajorVersions(semVerUtils,historicalVersions,vutMajor);for(let i=0;i<historicalVersions.length;i++){const{major:hvMajor,minor:hvMinor,patch:hvPatch,prerelease:hvPreRel,version:hvVersion}=semVerUtils.parse(historicalVersions[i]);if(semVerUtils.lt(hvVersion,vutVersion)){if(!checkVersions.latest.version){checkVersions.latest.version=hvVersion;versionsToCache.add(hvVersion)}if(checkVersions.patch.isNeeded&&!checkVersions.patch.version){checkVersions.patch.version=hvVersion;versionsToCache.add(hvVersion)}if(checkVersions.minor.isNeeded&&!checkVersions.minor.version){if(hvMinor<vutMinor||hvMajor<vutMajor){checkVersions.minor.version=hvVersion;versionsToCache.add(hvVersion)}}if(checkVersions.major.isNeeded&&!checkVersions.major.version){if(majorSequence[1]&&hvMajor===majorSequence[1]){checkVersions.major.version=hvVersion;checkVersions['major+'].version=hvVersion;versionsToCache.add(hvVersion)}}if(checkVersions['major2+'].isNeeded&&!checkVersions['major2+'].version){if(majorSequence[2]&&hvMajor===majorSequence[2]){checkVersions['major2+'].version=hvVersion;versionsToCache.add(hvVersion)}}if(checkVersions['major3+'].isNeeded&&!checkVersions['major3+'].version){if(majorSequence[3]&&hvMajor===majorSequence[3]){checkVersions['major3+'].version=hvVersion;versionsToCache.add(hvVersion);break}}}}versionsToCache.forEach(requiredVersion=>{const cachedDef=this.acCache.getComponentMetadata(fullName,requiredVersion);if(cachedDef){for(const[controlValue,settings]of Object.entries(checkVersions)){if(settings.isNeeded&&settings.version===requiredVersion){checkVersions[controlValue].metadata=cachedDef}}}})}}else if(existingVersionsResp.statusCode===404||existingVersionsResp.eCode==='ENOTFOUND'){msgLib.info(`The component ${fullName} does not exist in the Exchange and so cannot be API verified against older versions. It will be skipped`);if(!this.componentExceptions){this.componentExceptions={}}this.componentExceptions[fullName]=['*'];return}}catch(e){msgLib.error(`${context.ruleName}:\n${JSON.stringify(e)}`)};return checkVersions};ruleDef.prototype._getOffsetMajorVersions=function(semVerUtils,versions,baseMajorVersion){const majors=[baseMajorVersion];let lastMajor=baseMajorVersion;versions.forEach(stringVersion=>{const{major:parsedMajor}=semVerUtils.parse(stringVersion);if(parsedMajor<lastMajor){lastMajor=parsedMajor;majors.push(parsedMajor)}});return majors};ruleDef.prototype._executeCheck=function(controlRuleName,controlRuleDef,semver,cacheManager,metadata,compareMetadata,componentVersionDiff,baselines,componentType,componentName,errorMsgContext){const result=controlRuleDef.callback.call(this,controlRuleName,controlRuleDef,semver,cacheManager,metadata,compareMetadata,componentVersionDiff,baselines,componentType,componentName,errorMsgContext);if(result){throw result}};ruleDef.prototype._isExemptFromCheck=function(fullName,controlRuleName){let exempt=false;if(this.componentExceptions&&this.componentExceptions.hasOwnProperty(fullName)){if(this.componentExceptions[fullName].includes('*')||this.componentExceptions[fullName].includes(controlRuleName)){exempt=true}}return exempt};module.exports=ruleDef;
|
|
6
|
+
const Utils=require('../jetwc-lib/jetwcutils-componentAuditUtils');const AuditComponentCacheManager=require('../jetwc-lib/jetwcutils-auditComponentCacheManager');const NetUtils=require('../../lib/NetUtils');const CommonImpl=require('../jetwc-lib/jetwcutils-commonListenerImpls');const TsxUtils=require('../jetwc-lib/jetwcutils-tsxUtils');const VC=require('./jetwco-cacc-auditConstraints');const CaccHelpers=require('./jetwco-cacc-helpers');const jetVer=require('./jetwco-cacc-jetVer');const packContent=require('./jetwco-cacc-packContent');const packBundle=require('./jetwco-cacc-packBundle');const packBundleContent=require('./jetwco-cacc-packBundleContent');const dependencies=require('./jetwco-cacc-dependencies');const properties=require('./jetwco-cacc-properties');const propertyDefault=require('./jetwco-cacc-propertyDefault');const propertyRequired=require('./jetwco-cacc-propertyRequired');const propertyReadOnly=require('./jetwco-cacc-propertyReadOnly');const propertyWriteback=require('./jetwco-cacc-propertyWriteback');const propertyType=require('./jetwco-cacc-propertyType');const propertyEnumeration=require('./jetwco-cacc-propertyEnumeration');const methods=require('./jetwco-cacc-methods');const methodParams=require('./jetwco-cacc-methodParams');const methodParamTypes=require('./jetwco-cacc-methodParamTypes');const methodReturnType=require('./jetwco-cacc-methodReturnType');const events=require('./jetwco-cacc-events');const eventPayload=require('./jetwco-cacc-eventPayload');const eventBubbles=require('./jetwco-cacc-eventBubbles');const eventCancelable=require('./jetwco-cacc-eventCancelable');const slots=require('./jetwco-cacc-slots');const slotDataVariable=require('./jetwco-cacc-slotDataVariable');const slotDataVariableType=require('./jetwco-cacc-slotDataVariableType');const dynamicSlots=require('./jetwco-cacc-dynamicSlots');const styleVariables=require('./jetwco-cacc-styleVariables');const styleClasses=require('./jetwco-cacc-styleClasses');const publicModules=require('./jetwco-cacc-publicModules');const CONTROL_PROFILE={jetVer:{callback:jetVer,add:VC.MAJOR,remove:VC.MAJOR,mutate:VC.MAJOR,description:'Validate the JET Version compatibility range'},packContent:{callback:packContent,add:VC.MINOR,remove:VC.MAJOR_2_DEPRECATED,mutate:VC.SEMVER,description:'Validate the member components of a JET Pack'},packBundle:{callback:packBundle,add:VC.MINOR,remove:VC.MAJOR,mutate:VC.NEVER,description:'Validate the list of bundles defined by a JET Pack'},packBundleContent:{callback:packBundleContent,add:VC.MAJOR,remove:VC.MAJOR,mutate:VC.NEVER,description:'Validate the entries of each bundle defined by a JET Pack'},dependencies:{callback:dependencies,add:VC.MAJOR,remove:VC.MINOR,mutate:VC.SEMVER,description:'Validate the dependencies of a component'},properties:{callback:properties,add:VC.MINOR,remove:VC.MAJOR_2_DEPRECATED,mutate:VC.NEVER,description:'Validate the properties of a component'},propertyDefault:{callback:propertyDefault,add:VC.PATCH,remove:VC.MAJOR_DEPRECATED,mutate:VC.MAJOR_DEPRECATED,description:'Validate the defaults assigned to properties of a component'},propertyRequired:{callback:propertyRequired,add:VC.MAJOR,remove:VC.PATCH,mutate:VC.NEVER,description:'Validate the required states of a components properties'},propertyReadOnly:{callback:propertyReadOnly,add:VC.MAJOR,remove:VC.PATCH,mutate:VC.NEVER,description:'Validate the read-only states of a components properties'},propertyWriteback:{callback:propertyWriteback,add:VC.PATCH,remove:VC.NEVER,mutate:VC.NEVER,description:'Validate the writeback states of a components properties'},propertyType:{callback:propertyType,add:VC.PATCH,remove:VC.MAJOR_2_DEPRECATED,mutate:VC.NEVER,description:'Validate the assigned types of a components properties'},propertyEnumeration:{callback:propertyEnumeration,add:VC.PATCH,remove:VC.MAJOR_2_DEPRECATED,mutate:VC.MAJOR,description:'Validate the enumValues of a components properties'},methods:{callback:methods,add:VC.MINOR,remove:VC.MAJOR_2_DEPRECATED,mutate:VC.NEVER,description:'Validate the list of methods exposed by the component'},methodParams:{callback:methodParams,add:VC.MINOR,remove:VC.MAJOR_2_DEPRECATED,mutate:VC.NEVER,description:'Validate the list of parameters passed to methods exposed by the component'},methodParamTypes:{callback:methodParamTypes,add:VC.PATCH,remove:VC.MAJOR_2_DEPRECATED,mutate:VC.NEVER,description:'Validate the list of parameters passed to methods exposed by the component'},methodReturnType:{callback:methodReturnType,add:VC.PATCH,remove:VC.MAJOR,mutate:VC.NEVER,description:'Validate the return type of the methods exposed by the component'},events:{callback:events,add:VC.MINOR,remove:VC.MAJOR_2_DEPRECATED,mutate:VC.NEVER,description:'Validate the list of events exposed by the component'},eventPayload:{callback:eventPayload,add:VC.MINOR,remove:VC.MAJOR,mutate:VC.NEVER,description:'Validate the event detail of events exposed by the component'},eventBubbles:{callback:eventBubbles,add:VC.MINOR,remove:VC.NEVER,mutate:VC.NEVER,description:'Validate the event bubbles flag'},eventCancelable:{callback:eventCancelable,add:VC.MINOR,remove:VC.NEVER,mutate:VC.NEVER,description:'Validate the event cancelable flag'},slots:{callback:slots,add:VC.MINOR,remove:VC.MAJOR_2_DEPRECATED,mutate:VC.NEVER,description:'Validate the list of slots exposed by the component'},slotDataVariable:{callback:slotDataVariable,add:VC.PATCH,remove:VC.MAJOR_2_DEPRECATED,mutate:VC.NEVER,description:'Validate the list of attributes in a slot data attribute exposed by the component'},slotDataVariableType:{callback:slotDataVariableType,add:VC.NEVER,remove:VC.NEVER,mutate:VC.NEVER,description:'Validate the type assigned to each attributes in a slot data attribute exposed by the component'},dynamicSlots:{callback:dynamicSlots,add:VC.MINOR,remove:VC.MAJOR,mutate:VC.NEVER,description:'Validate the presence of the dynamicSlots marker on the component'},styleVariables:{callback:styleVariables,add:VC.MINOR,remove:VC.MAJOR_2_DEPRECATED,mutate:VC.NEVER,description:'Validate the list of styleVariables supported by the component'},styleClasses:{callback:styleClasses,add:VC.MINOR,remove:VC.MAJOR_2_DEPRECATED,mutate:VC.NEVER,description:'Validate the list of styleClasses supported by the component'},publicModules:{callback:publicModules,add:VC.MINOR,remove:VC.MAJOR,mutate:VC.NEVER,description:'Validate the list of publicModules exposed by a resource component'}};const ruleDef=function(){};ruleDef.prototype.getName=function(){return'jetwco-component-api-controlled-changes'};ruleDef.prototype.getShortDescription=function(){return'Check components for API changes based on a configurable rule-set'};ruleDef.prototype.getDescription=function(){return'This audit compares the APIs exposed by components with older versions in the Exchange Catalog according to a set of rules which determine when given changes, such as the removal of deprecated properties can be made'};ruleDef.prototype.register=function(context){return{startaudit:this._auditPrep,closedownRP:this._dealWithCache,compjson:this._doAudit,Program:this._doVComponentAudit}};ruleDef.prototype._auditPrep=function(context){this.exchangeURL=CommonImpl.checkForExchangeConfiguration(context);if(this.exchangeURL){this.acCache=new AuditComponentCacheManager(context,this.getName(),this.exchangeURL);this.componentExceptions=context.rulePack.getRuleOption('exceptions');const ipr=context.rulePack.getRuleOption('includePreReleases');if(ipr&&ipr===true){this.productionOnly=false}else{this.productionOnly=true}const ruleOverrides=context.rulePack.getRuleOption('controls');this.controlRules={};if(Object.keys(ruleOverrides).length>0){for(const[controlRule,controlRuleDef]of Object.entries(CONTROL_PROFILE)){this.controlRules[controlRule]={...controlRuleDef};if(ruleOverrides.hasOwnProperty(controlRule)){for(const[verb,override]of Object.entries(ruleOverrides[controlRule])){this.controlRules[controlRule][verb]=override}}}}else{this.controlRules={...CONTROL_PROFILE}}const activeControls=context.rulePack.getRuleOption('applyConditions');if(activeControls&&Array.isArray(activeControls)){Object.keys(this.controlRules).forEach(controlRule=>{if(!activeControls.includes(controlRule)){delete this.controlRules[controlRule]}})}this.requiredCheckVersions=CaccHelpers.calcRequiredVersionMatrix(this.controlRules)}else{const issue=new context.Issue(`Invalid or Missing exchangeURL value specified for the rule ${context.ruleName}, rule execution is disabled`);issue.setMsgKey(`${context.ruleName}_2`);issue.setSeverity('critical');context.reporter.addIssue(issue,context)}};ruleDef.prototype._dealWithCache=function(context){const shouldClearCache=context.rulePack.getRuleOption('clearCache',this.getName());if(shouldClearCache&&this.acCache){this.acCache.removeLocalCache()}};ruleDef.prototype._doAudit=function(context){if(context.suppData.obj){const meta=context.suppData.obj;const fullName=Utils.getComponentFullName(meta);const componentType=Utils.getComponentType(meta);this._conductChecks(context,fullName,componentType,meta)}};ruleDef.prototype._doVComponentAudit=function(context){const componentInfo=TsxUtils.matchToVComponentImpl(context,context.filepath);if(componentInfo){const meta={...componentInfo};if(componentInfo.dependencies){meta.dependencies=componentInfo.dependencies.reduce((asMap,entry)=>{asMap[entry.name]=entry.range;return asMap},{})}this._conductChecks(context,componentInfo.fullName,componentInfo.type,meta)}};ruleDef.prototype._conductChecks=function(context,fullName,componentType,componentMeta){const{msgLib,semVerUtils}=context.utils;const privateComponent=componentMeta.subcomponentType&&componentMeta.subcomponentType==='packPrivate';const skipPrivate=context.rulePack.getRuleOption('ignorePackPrivate',context.ruleName);if(skipPrivate&&privateComponent){msgLib.info(`packPrivate component ${fullName} skipped due to ignorePackPrivate flag in ${context.ruleName} configuration`)}else{const baselines=this._grabRequiredVersions(context,fullName,componentMeta.version,this.requiredCheckVersions,this.productionOnly);if(baselines&&baselines.latest.version){const compareMetadata=CaccHelpers.deriveConstraintMetadata(baselines);const componentVersionDiff=CaccHelpers.semanticDiff(semVerUtils,componentMeta.version,compareMetadata.version);try{for(const[controlRuleName,controlRuleDef]of Object.entries(this.controlRules)){if(!this._isExemptFromCheck(fullName,controlRuleName)){msgLib.info(`${context.ruleName}(${controlRuleName}): ${controlRuleDef.description}`);const errorMsgContext=CaccHelpers.getStdErrorContext(fullName,controlRuleName);this._executeCheck(controlRuleName,controlRuleDef,semVerUtils,this.acCache,componentMeta,compareMetadata,componentVersionDiff,baselines,componentType,fullName,errorMsgContext)}}}catch(auditDetail){const issue=new context.Issue(`API change for ${fullName}@${componentMeta.version}: ${auditDetail}`);issue.setMsgKey(`${context.ruleName}_1`);context.reporter.addIssue(issue,context)}}}};ruleDef.prototype._grabRequiredVersions=function(context,fullName,versionUnderTest,requiredVersions,productionVersionsOnly){const{msgLib,semVerUtils}=context.utils;const checkVersions={'never':{isNeeded:true,version:null,metadata:null},'latest':{isNeeded:true,version:null,metadata:null},'patch':{isNeeded:requiredVersions.patch,version:null,metadata:null},'minor':{isNeeded:requiredVersions.minor,version:null,metadata:null},'major':{isNeeded:requiredVersions.major,version:null,metadata:null},'major+':{isNeeded:requiredVersions.major,version:null,metadata:null},'major2+':{isNeeded:requiredVersions.major2,version:null,metadata:null},'major3+':{isNeeded:requiredVersions.major3,version:null,metadata:null}};try{const versionsToCache=new Set;const netUtils=new NetUtils;const existingVersionsResp=netUtils.loadUrl(`${this.exchangeURL}components/${fullName}/versions`);if(existingVersionsResp.statusCode===200&&existingVersionsResp.body){const existingVersions=JSON.parse(existingVersionsResp.body);if(existingVersions.items&&existingVersions.items.length>0){const{major:vutMajor,minor:vutMinor,patch:vutPatch,prerelease:vutPreRel,version:vutVersion}=semVerUtils.parse(versionUnderTest);let historicalVersions;if(productionVersionsOnly){historicalVersions=existingVersions.items.reverse().filter(versionString=>{const{prerelease}=semVerUtils.parse(versionString);return prerelease.length===0})}else{historicalVersions=existingVersions.items.reverse()}const majorSequence=this._getOffsetMajorVersions(semVerUtils,historicalVersions,vutMajor);for(let i=0;i<historicalVersions.length;i++){const{major:hvMajor,minor:hvMinor,patch:hvPatch,prerelease:hvPreRel,version:hvVersion}=semVerUtils.parse(historicalVersions[i]);if(semVerUtils.lt(hvVersion,vutVersion)){if(!checkVersions.latest.version){checkVersions.latest.version=hvVersion;versionsToCache.add(hvVersion)}if(checkVersions.patch.isNeeded&&!checkVersions.patch.version){checkVersions.patch.version=hvVersion;versionsToCache.add(hvVersion)}if(checkVersions.minor.isNeeded&&!checkVersions.minor.version){if(hvMinor<vutMinor||hvMajor<vutMajor){checkVersions.minor.version=hvVersion;versionsToCache.add(hvVersion)}}if(checkVersions.major.isNeeded&&!checkVersions.major.version){if(majorSequence[1]&&hvMajor===majorSequence[1]){checkVersions.major.version=hvVersion;checkVersions['major+'].version=hvVersion;versionsToCache.add(hvVersion)}}if(checkVersions['major2+'].isNeeded&&!checkVersions['major2+'].version){if(majorSequence[2]&&hvMajor===majorSequence[2]){checkVersions['major2+'].version=hvVersion;versionsToCache.add(hvVersion)}}if(checkVersions['major3+'].isNeeded&&!checkVersions['major3+'].version){if(majorSequence[3]&&hvMajor===majorSequence[3]){checkVersions['major3+'].version=hvVersion;versionsToCache.add(hvVersion);break}}}}versionsToCache.forEach(requiredVersion=>{const cachedDef=this.acCache.getComponentMetadata(fullName,requiredVersion);if(cachedDef){for(const[controlValue,settings]of Object.entries(checkVersions)){if(settings.isNeeded&&settings.version===requiredVersion){checkVersions[controlValue].metadata=cachedDef}}}})}}else if(existingVersionsResp.statusCode===404||existingVersionsResp.eCode==='ENOTFOUND'){msgLib.info(`The component ${fullName} does not exist in the Exchange and so cannot be API verified against older versions. It will be skipped`);if(!this.componentExceptions){this.componentExceptions={}}this.componentExceptions[fullName]=['*'];return}}catch(e){msgLib.error(`${context.ruleName}:\n${JSON.stringify(e)}`)};return checkVersions};ruleDef.prototype._getOffsetMajorVersions=function(semVerUtils,versions,baseMajorVersion){const majors=[baseMajorVersion];let lastMajor=baseMajorVersion;versions.forEach(stringVersion=>{const{major:parsedMajor}=semVerUtils.parse(stringVersion);if(parsedMajor<lastMajor){lastMajor=parsedMajor;majors.push(parsedMajor)}});return majors};ruleDef.prototype._executeCheck=function(controlRuleName,controlRuleDef,semver,cacheManager,metadata,compareMetadata,componentVersionDiff,baselines,componentType,componentName,errorMsgContext){const result=controlRuleDef.callback.call(this,controlRuleName,controlRuleDef,semver,cacheManager,metadata,compareMetadata,componentVersionDiff,baselines,componentType,componentName,errorMsgContext);if(result){throw result}};ruleDef.prototype._isExemptFromCheck=function(fullName,controlRuleName){let exempt=false;if(this.componentExceptions&&this.componentExceptions.hasOwnProperty(fullName)){if(this.componentExceptions[fullName].includes('*')||this.componentExceptions[fullName].includes(controlRuleName)){exempt=true}}return exempt};module.exports=ruleDef;
|