Spaces:
Running
Running
File size: 960 Bytes
d0aa19c |
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 |
const __ = require('./lib/Extensions');
import * as fs from 'fs';
import fetch from 'node-fetch';
import { c } from './lib/Log';
import __rootDir from './lib/RootDirFinder';
(async () => {
const response = await fetch(`http://pouet.eastus.cloudapp.azure.com:8080/personality/all?all=true`, {
method: 'POST',
});
const personas = (await response.json()).personality as string[];
c.debug(`Personas from server: ${personas.length}`);
c.debug(`Deduped: ${ (new Set(personas)).size }`);
const o: Obj<string> = {};
for (const persona of personas) {
const slug = persona
.replace(/\W/g, '-')
.replace(/-+$/, "") // <- trim trailing dash
.replace(/--+/g, "-") // <- never allow more than one consecutive dash
;
o[slug] = persona;
}
c.debug(
`After slugification: ${ (new Set(Object.keys(o))).size }`
);
await fs.promises.writeFile(
__rootDir+`/server/data/personas.json`,
JSON.stringify(o, null, 2)
);
process.exit();
})();
|