This commit is contained in:
Romein van Buren 2022-09-01 10:58:41 +02:00
parent 4f3fce48e1
commit 6a240a12b4
Signed by: romein
GPG Key ID: 0EFF8478ADDF6C49
2 changed files with 41 additions and 0 deletions

3
js/1password_logs/.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
/log.txt
/out/
.DS_Store

View File

@ -0,0 +1,38 @@
'use strict';
const fs = require('fs/promises');
async function outputSets(sets) {
const promises = [];
for (const [ name, set ] of Object.entries(sets)) {
const sorted = [ ...set ].sort();
const data = sorted.join('\n') + '\n';
promises.push(
fs.writeFile(`./out/${name}.txt`, data)
)
}
await Promise.all(promises);
}
(async () => {
const source = (await fs.readFile('./log.txt')).toString();
const sourcePathRegex = /op-[a-z0-9-]*\/[a-z0-9-_\/]*.[a-z]*:?[0-9]{0,}/g;
const matches = source.match(sourcePathRegex);
let roots = new Set();
let paths = new Set();
let types = new Set();
for (const match of matches) {
const root = match.split('/')[0];
roots.add(root);
const path = match.split(':')[0];
paths.add(path);
const type = match.split('.')[1].split(':')[0];
types.add(type);
}
outputSets({ roots, paths, types });
})();