fix: toolsが動かないのを修正 (#8008)

* Move tools

* Fix DB
This commit is contained in:
MeiMei 2021-11-26 13:41:49 +09:00 committed by GitHub
parent b4ebf254c8
commit d9775c147f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 14 additions and 9 deletions

View file

@ -1,7 +1,10 @@
import { Emojis } from '@/models/index'; import { initDb } from '@/db/postgre';
import { genId } from '@/misc/gen-id'; import { genId } from '@/misc/gen-id';
async function main(name: string, url: string, alias?: string): Promise<any> { async function main(name: string, url: string, alias?: string): Promise<any> {
await initDb();
const { Emojis } = await import('@/models/index');
const aliases = alias != null ? [ alias ] : []; const aliases = alias != null ? [ alias ] : [];
await Emojis.save({ await Emojis.save({

View file

@ -1,13 +1,11 @@
import { initDb } from '../db/postgre'; import { initDb } from '../db/postgre';
import { getRepository } from 'typeorm';
import { User } from '@/models/entities/user';
async function main(username: string) { async function main(username: string) {
if (!username) throw `username required`; if (!username) throw `username required`;
username = username.replace(/^@/, ''); username = username.replace(/^@/, '');
await initDb(); await initDb();
const Users = getRepository(User); const { Users } = await import('@/models/index');
const res = await Users.update({ const res = await Users.update({
usernameLower: username.toLowerCase(), usernameLower: username.toLowerCase(),

View file

@ -1,13 +1,11 @@
import { initDb } from '../db/postgre'; import { initDb } from '../db/postgre';
import { getRepository } from 'typeorm';
import { User } from '@/models/entities/user';
async function main(username: string) { async function main(username: string) {
if (!username) throw `username required`; if (!username) throw `username required`;
username = username.replace(/^@/, ''); username = username.replace(/^@/, '');
await initDb(); await initDb();
const Users = getRepository(User); const { Users } = await import('@/models/index');
const res = await Users.update({ const res = await Users.update({
usernameLower: username.toLowerCase(), usernameLower: username.toLowerCase(),

View file

@ -1,6 +1,9 @@
import { updateQuestion } from '@/remote/activitypub/models/question'; import { initDb } from '@/db/postgre';
async function main(uri: string): Promise<any> { async function main(uri: string): Promise<any> {
await initDb();
const { updateQuestion } = await import('@/remote/activitypub/models/question');
return await updateQuestion(uri); return await updateQuestion(uri);
} }

View file

@ -1,4 +1,4 @@
import { Users, Signins } from '@/models/index'; import { initDb } from '@/db/postgre';
// node built/tools/show-signin-history username // node built/tools/show-signin-history username
// => {Success} {Date} {IPAddrsss} // => {Success} {Date} {IPAddrsss}
@ -10,6 +10,9 @@ import { Users, Signins } from '@/models/index';
// with full request headers // with full request headers
async function main(username: string, headers?: string[]) { async function main(username: string, headers?: string[]) {
await initDb();
const { Users, Signins } = await import('@/models/index');
const user = await Users.findOne({ const user = await Users.findOne({
host: null, host: null,
usernameLower: username.toLowerCase(), usernameLower: username.toLowerCase(),