forked from PipedreamHQ/pipedream
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheckComponentAppProp.js
More file actions
33 lines (28 loc) · 880 Bytes
/
checkComponentAppProp.js
File metadata and controls
33 lines (28 loc) · 880 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
const path = require("path");
const {
rootDir,
iterateComponentFiles,
} = require("./findBadKeys.js");
function checkComponentHasAppProp(component, appNameSlug) {
const matching = Object.values(component.props)
.filter((prop) => prop.type === "app" && prop.app === appNameSlug);
if (!matching.length) {
console.error(`[!] ${component.key} - missing app prop for ${appNameSlug}`);
err = true;
}
}
async function main() {
const iterator = iterateComponentFiles();
for (const file of iterator) {
const p = path.join(rootDir, file);
const appNameSlug = file.split("/")[1];
const { default: component } = await import(p)
checkComponentHasAppProp(component, appNameSlug);
}
if (err) {
const core = require('@actions/core');
core.setFailed("There are errors in some components. See the messages above.");
}
}
let err;
main();