multicloud_rule_manager 1.1.15 → 1.1.17
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/package.json +1 -1
- package/utils/ruleValidator.js +9 -5
package/package.json
CHANGED
package/utils/ruleValidator.js
CHANGED
|
@@ -15,7 +15,7 @@ export function validateRule(fileName, content) {
|
|
|
15
15
|
const line = lines[i];
|
|
16
16
|
|
|
17
17
|
// verifica blocco when {} then {}
|
|
18
|
-
if (!
|
|
18
|
+
if (!hasValidWhenThenBlock(content, fileName)) {
|
|
19
19
|
continue;
|
|
20
20
|
}
|
|
21
21
|
|
|
@@ -74,11 +74,15 @@ export function validateRule(fileName, content) {
|
|
|
74
74
|
return { valid: true };
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
function
|
|
78
|
-
|
|
77
|
+
function hasValidWhenThenBlock(content, fileName) {
|
|
78
|
+
// breakdown:
|
|
79
|
+
// - when\s*{ => 'when' seguito da { con eventuali spazi/tab/line break
|
|
80
|
+
// - [\s\S]*? => qualsiasi contenuto multilinea dentro il blocco when
|
|
81
|
+
// - }\s*then\s*{ => chiusura block '}' e apertura 'then {' con spazi/tab/line break tra di loro
|
|
82
|
+
const regex = /when\s*{[\s\S]*?}\s*then\s*{/i;
|
|
79
83
|
|
|
80
|
-
if (!
|
|
81
|
-
console.error(`❌ Il file ${fileName} deve contenere un blocco "when {} then {}"`);
|
|
84
|
+
if (!regex.test(content)) {
|
|
85
|
+
console.error(`❌ Il file ${fileName} deve contenere un blocco "when {} then {}" valido`);
|
|
82
86
|
return false;
|
|
83
87
|
}
|
|
84
88
|
|