-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcomb.js
More file actions
83 lines (63 loc) · 2.86 KB
/
comb.js
File metadata and controls
83 lines (63 loc) · 2.86 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
const fs = require('fs');
let allOBJ = []
let normalizedPath = require("path").join(__dirname);
require("fs").readdirSync(normalizedPath).forEach(function (file) {
let ext = file.substring(file.lastIndexOf('.') + 1, file.length) || file;
let verb = file.substring(0, file.lastIndexOf('.'));
if (ext == "json" && verb.indexOf("package") < 0) {
console.log("file --> ", file);
cleanFile(require(require("path").join(__dirname, file)), verb)
}
});
function cleanFile(obj, fnm) {
let trash = ["PrivateHttpPort", "SoundStripe", "S3", "QrConfig", "KafkaWriterConfig", "OnlineTimeoutMs", "KafkaWriter", "MigrationEnv",
"HttpPort", "HttpDeepLinkPort", "MaxThresholdHours", "Firebase", "WorkerPoolSize", "MaxStmtsPerBatch", "ContentWrapper",
"MasterDb", "CategoryTopUserGenerator",
"ReadonlyDb", "SolanaConfig", "EvmConfig", "TapjoyConfig", "Applovin", "Ironsource", "Kyc", "GoHighLevel", "ExportRecordsPerIteration", "DeepLinkConfig",
"Scylla", "ZammadConfig",
"Db", "CdcKafka", "MinContentDuration", "MaxPoolSize",
"Redis", "Jobber", "MobileConfig", "PermissionsTable", "AppleConfig", "GeolocationApiUrl", "PreviewConfig", "DeeplinkConfig",
"Elastic",
"Wrappers",
"GoogleConfig", "CdnBase"]
let trashkeys = ["url", "scylla", "db", "s3", "feedgenerator", "redis"]
trashfromconfig = ["WorkerPoolSize", "PollTimeMs", "MaxDuration", "MaxBatchSize", "Tls", "FlushAtSize", "Hosts", "MinBytes", "MaxBytes", "NumPartitions",
"ReplicationFactor", "MaxRetryCount", "FlushTimeMilliseconds"]
trash.map(t => {
delete obj[t]
})
function funcClean(obj) {
Object.keys(obj).map(t => {
trashkeys.map(tk => {
if (t.toLocaleLowerCase().indexOf(tk) >= 0) {
delete obj[t]
}
})
// if(typeof obj[t] == "object") {
// // funcClean(obj[t])
// console.log("object", t);
// }
})
}
funcClean(obj)
Object.keys(obj).map(e => {
trashfromconfig.map(p => {
delete obj[e][p]
})
})
allOBJ.push({["repo-name"] : fnm, ...obj});
// Object.keys(obj).map(e => {
// let dir = require("path").join(__dirname, "cleaned", fnm)
// if (!fs.existsSync(dir)) {
// fs.mkdirSync(dir);
// }
// let newfile = require("path").join(dir, `${e}.json`)
// fs.writeFileSync(newfile, JSON.stringify(obj[e], null, 4));
// console.log("e------", newfile);
// })
let newfile = require("path").join(__dirname, "cleaned", `${fnm}-cleaned.json`)
fs.writeFileSync(newfile, JSON.stringify(obj, null, 4));
// console.log(obj);
}
let allfile = require("path").join(__dirname, "cleaned", `allfile.json`)
fs.writeFileSync(allfile, JSON.stringify(allOBJ, null, 4));