2021-11-26 05:41:49 +01:00
|
|
|
import { initDb } from '@/db/postgre';
|
2021-08-19 14:55:45 +02:00
|
|
|
import { genId } from '@/misc/gen-id';
|
2018-11-02 00:59:40 +01:00
|
|
|
|
|
|
|
async function main(name: string, url: string, alias?: string): Promise<any> {
|
2021-11-26 05:41:49 +01:00
|
|
|
await initDb();
|
|
|
|
const { Emojis } = await import('@/models/index');
|
|
|
|
|
2018-11-02 00:59:40 +01:00
|
|
|
const aliases = alias != null ? [ alias ] : [];
|
|
|
|
|
2019-04-07 14:50:36 +02:00
|
|
|
await Emojis.save({
|
|
|
|
id: genId(),
|
2018-11-02 00:59:40 +01:00
|
|
|
host: null,
|
|
|
|
name,
|
|
|
|
url,
|
|
|
|
aliases,
|
2021-12-09 15:58:30 +01:00
|
|
|
updatedAt: new Date(),
|
2018-11-02 00:59:40 +01:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2020-04-03 16:35:14 +02:00
|
|
|
const args = process.argv.slice(2);
|
|
|
|
const name = args[0];
|
|
|
|
const url = args[1];
|
2020-04-03 10:17:46 +02:00
|
|
|
|
2020-04-03 16:35:14 +02:00
|
|
|
if (!name) throw new Error('require name');
|
|
|
|
if (!url) throw new Error('require url');
|
2020-04-03 10:17:46 +02:00
|
|
|
|
2020-04-03 16:35:14 +02:00
|
|
|
main(name, url).then(() => {
|
|
|
|
console.log('success');
|
|
|
|
process.exit(0);
|
|
|
|
}).catch(e => {
|
|
|
|
console.warn(e);
|
|
|
|
process.exit(1);
|
|
|
|
});
|