diff options
| author | syuilo <Syuilotan@yahoo.co.jp> | 2021-08-19 18:33:41 +0900 |
|---|---|---|
| committer | syuilo <Syuilotan@yahoo.co.jp> | 2021-08-19 18:33:41 +0900 |
| commit | b9cb6d1c10729869cbb57ce50c8174ad7474db75 (patch) | |
| tree | 0d522e7e6e589aaa6b6ddfcf4e12947c6bed0501 /src/misc | |
| parent | Update glossary.md (diff) | |
| download | misskey-b9cb6d1c10729869cbb57ce50c8174ad7474db75.tar.gz misskey-b9cb6d1c10729869cbb57ce50c8174ad7474db75.tar.bz2 misskey-b9cb6d1c10729869cbb57ce50c8174ad7474db75.zip | |
refactor: refactoring imports
将来ESMに移行しやすいように
Related: #7658
なんかmochaが起動しなくなってるけど理由不明
すぐ直したい
Diffstat (limited to 'src/misc')
| -rw-r--r-- | src/misc/antenna-cache.ts | 6 | ||||
| -rw-r--r-- | src/misc/app-lock.ts | 5 | ||||
| -rw-r--r-- | src/misc/captcha.ts | 4 | ||||
| -rw-r--r-- | src/misc/check-hit-antenna.ts | 14 | ||||
| -rw-r--r-- | src/misc/check-word-mute.ts | 4 | ||||
| -rw-r--r-- | src/misc/convert-host.ts | 2 | ||||
| -rw-r--r-- | src/misc/count-same-renotes.ts | 2 | ||||
| -rw-r--r-- | src/misc/detect-url-mime.ts | 6 | ||||
| -rw-r--r-- | src/misc/download-text-file.ts | 6 | ||||
| -rw-r--r-- | src/misc/download-url.ts | 6 | ||||
| -rw-r--r-- | src/misc/extract-custom-emojis-from-mfm.ts | 2 | ||||
| -rw-r--r-- | src/misc/extract-hashtags.ts | 2 | ||||
| -rw-r--r-- | src/misc/fetch-meta.ts | 2 | ||||
| -rw-r--r-- | src/misc/fetch-proxy-account.ts | 6 | ||||
| -rw-r--r-- | src/misc/fetch.ts | 2 | ||||
| -rw-r--r-- | src/misc/gen-avatar.ts | 2 | ||||
| -rw-r--r-- | src/misc/gen-id.ts | 10 | ||||
| -rw-r--r-- | src/misc/get-user-name.ts | 2 | ||||
| -rw-r--r-- | src/misc/is-quote.ts | 2 | ||||
| -rw-r--r-- | src/misc/keypair-store.ts | 8 | ||||
| -rw-r--r-- | src/misc/license.ts | 8 | ||||
| -rw-r--r-- | src/misc/populate-emojis.ts | 16 | ||||
| -rw-r--r-- | src/misc/reaction-lib.ts | 8 | ||||
| -rw-r--r-- | src/misc/show-machine-info.ts | 2 |
24 files changed, 67 insertions, 60 deletions
diff --git a/src/misc/antenna-cache.ts b/src/misc/antenna-cache.ts index 6be1c18db5..dcf96c1610 100644 --- a/src/misc/antenna-cache.ts +++ b/src/misc/antenna-cache.ts @@ -1,6 +1,6 @@ -import { Antennas } from '../models'; -import { Antenna } from '../models/entities/antenna'; -import { subsdcriber } from '../db/redis'; +import { Antennas } from '@/models/index.js'; +import { Antenna } from '@/models/entities/antenna.js'; +import { subsdcriber } from '../db/redis.js'; let antennasFetched = false; let antennas: Antenna[] = []; diff --git a/src/misc/app-lock.ts b/src/misc/app-lock.ts index 9ae2cba478..52ac680715 100644 --- a/src/misc/app-lock.ts +++ b/src/misc/app-lock.ts @@ -1,5 +1,6 @@ -import { redisClient } from '../db/redis'; +import { redisClient } from '../db/redis.js'; import { promisify } from 'util'; +import * as redisLock from 'redis-lock'; /** * Retry delay (ms) for lock acquisition @@ -8,7 +9,7 @@ const retryDelay = 100; const lock: (key: string, timeout?: number) => Promise<() => void> = redisClient - ? promisify(require('redis-lock')(redisClient, retryDelay)) + ? promisify(redisLock(redisClient, retryDelay)) : async () => () => { }; /** diff --git a/src/misc/captcha.ts b/src/misc/captcha.ts index 727c86af0f..4623565c3c 100644 --- a/src/misc/captcha.ts +++ b/src/misc/captcha.ts @@ -1,7 +1,7 @@ import fetch from 'node-fetch'; import { URLSearchParams } from 'url'; -import { getAgentByUrl } from './fetch'; -import config from '@/config'; +import { getAgentByUrl } from './fetch.js'; +import config from '@/config/index.js'; export async function verifyRecaptcha(secret: string, response: string) { const result = await getCaptchaResponse('https://www.recaptcha.net/recaptcha/api/siteverify', secret, response).catch(e => { diff --git a/src/misc/check-hit-antenna.ts b/src/misc/check-hit-antenna.ts index 3dfcb54c49..fdba66b640 100644 --- a/src/misc/check-hit-antenna.ts +++ b/src/misc/check-hit-antenna.ts @@ -1,10 +1,10 @@ -import { Antenna } from '../models/entities/antenna'; -import { Note } from '../models/entities/note'; -import { User } from '../models/entities/user'; -import { UserListJoinings, UserGroupJoinings } from '../models'; -import { getFullApAccount } from './convert-host'; -import { PackedNote } from '../models/repositories/note'; -import { parseAcct } from '@/misc/acct'; +import { Antenna } from '@/models/entities/antenna.js'; +import { Note } from '@/models/entities/note.js'; +import { User } from '@/models/entities/user.js'; +import { UserListJoinings, UserGroupJoinings } from '@/models/index.js'; +import { getFullApAccount } from './convert-host.js'; +import { PackedNote } from '../models/repositories/note.js'; +import { parseAcct } from '@/misc/acct.js'; /** * noteUserFollowers / antennaUserFollowing はどちらか一方が指定されていればよい diff --git a/src/misc/check-word-mute.ts b/src/misc/check-word-mute.ts index 5af267d75d..f12e552ebd 100644 --- a/src/misc/check-word-mute.ts +++ b/src/misc/check-word-mute.ts @@ -1,6 +1,6 @@ const RE2 = require('re2'); -import { Note } from '../models/entities/note'; -import { User } from '../models/entities/user'; +import { Note } from '@/models/entities/note.js'; +import { User } from '@/models/entities/user.js'; type NoteLike = { userId: Note['userId']; diff --git a/src/misc/convert-host.ts b/src/misc/convert-host.ts index 7b0b0acf10..2e705cb6b1 100644 --- a/src/misc/convert-host.ts +++ b/src/misc/convert-host.ts @@ -1,5 +1,5 @@ import { URL } from 'url'; -import config from '@/config'; +import config from '@/config/index.js'; import { toASCII } from 'punycode/'; export function getFullApAccount(username: string, host: string | null) { diff --git a/src/misc/count-same-renotes.ts b/src/misc/count-same-renotes.ts index bc1072080a..b7f8ce90c8 100644 --- a/src/misc/count-same-renotes.ts +++ b/src/misc/count-same-renotes.ts @@ -1,4 +1,4 @@ -import { Notes } from '../models'; +import { Notes } from '@/models/index.js'; export async function countSameRenotes(userId: string, renoteId: string, excludeNoteId: string | undefined): Promise<number> { // 指定したユーザーの指定したノートのリノートがいくつあるか数える diff --git a/src/misc/detect-url-mime.ts b/src/misc/detect-url-mime.ts index 274c291737..cd143cf2fb 100644 --- a/src/misc/detect-url-mime.ts +++ b/src/misc/detect-url-mime.ts @@ -1,6 +1,6 @@ -import { createTemp } from './create-temp'; -import { downloadUrl } from './download-url'; -import { detectType } from './get-file-info'; +import { createTemp } from './create-temp.js'; +import { downloadUrl } from './download-url.js'; +import { detectType } from './get-file-info.js'; export async function detectUrlMime(url: string) { const [path, cleanup] = await createTemp(); diff --git a/src/misc/download-text-file.ts b/src/misc/download-text-file.ts index d6fd17fc13..745604c19c 100644 --- a/src/misc/download-text-file.ts +++ b/src/misc/download-text-file.ts @@ -1,8 +1,8 @@ import * as fs from 'fs'; import * as util from 'util'; -import Logger from '../services/logger'; -import { createTemp } from './create-temp'; -import { downloadUrl } from './download-url'; +import Logger from '@/services/logger.js'; +import { createTemp } from './create-temp.js'; +import { downloadUrl } from './download-url.js'; const logger = new Logger('download-text-file'); diff --git a/src/misc/download-url.ts b/src/misc/download-url.ts index dafeff6fc8..f01f34e6db 100644 --- a/src/misc/download-url.ts +++ b/src/misc/download-url.ts @@ -3,11 +3,11 @@ import * as stream from 'stream'; import * as util from 'util'; import { URL } from 'url'; import fetch from 'node-fetch'; -import { getAgentByUrl } from './fetch'; +import { getAgentByUrl } from './fetch.js'; import { AbortController } from 'abort-controller'; -import config from '@/config'; +import config from '@/config/index.js'; import * as chalk from 'chalk'; -import Logger from '../services/logger'; +import Logger from '@/services/logger.js'; const pipeline = util.promisify(stream.pipeline); diff --git a/src/misc/extract-custom-emojis-from-mfm.ts b/src/misc/extract-custom-emojis-from-mfm.ts index b29ce281b3..a0319d8dd5 100644 --- a/src/misc/extract-custom-emojis-from-mfm.ts +++ b/src/misc/extract-custom-emojis-from-mfm.ts @@ -1,5 +1,5 @@ import * as mfm from 'mfm-js'; -import { unique } from '@/prelude/array'; +import { unique } from '@/prelude/array.js'; export function extractCustomEmojisFromMfm(nodes: mfm.MfmNode[]): string[] { const emojiNodes = mfm.extract(nodes, (node) => { diff --git a/src/misc/extract-hashtags.ts b/src/misc/extract-hashtags.ts index b0a74df219..0b0418eefd 100644 --- a/src/misc/extract-hashtags.ts +++ b/src/misc/extract-hashtags.ts @@ -1,5 +1,5 @@ import * as mfm from 'mfm-js'; -import { unique } from '@/prelude/array'; +import { unique } from '@/prelude/array.js'; export function extractHashtags(nodes: mfm.MfmNode[]): string[] { const hashtagNodes = mfm.extract(nodes, (node) => node.type === 'hashtag'); diff --git a/src/misc/fetch-meta.ts b/src/misc/fetch-meta.ts index e7a945dc9e..3d7e69f2da 100644 --- a/src/misc/fetch-meta.ts +++ b/src/misc/fetch-meta.ts @@ -1,4 +1,4 @@ -import { Meta } from '../models/entities/meta'; +import { Meta } from '@/models/entities/meta.js'; import { getConnection } from 'typeorm'; let cache: Meta; diff --git a/src/misc/fetch-proxy-account.ts b/src/misc/fetch-proxy-account.ts index 537edf2891..ed8a4c794d 100644 --- a/src/misc/fetch-proxy-account.ts +++ b/src/misc/fetch-proxy-account.ts @@ -1,6 +1,6 @@ -import { fetchMeta } from './fetch-meta'; -import { ILocalUser } from '../models/entities/user'; -import { Users } from '../models'; +import { fetchMeta } from './fetch-meta.js'; +import { ILocalUser } from '@/models/entities/user.js'; +import { Users } from '@/models/index.js'; export async function fetchProxyAccount(): Promise<ILocalUser | null> { const meta = await fetchMeta(); diff --git a/src/misc/fetch.ts b/src/misc/fetch.ts index f7756f9256..11e8a69205 100644 --- a/src/misc/fetch.ts +++ b/src/misc/fetch.ts @@ -3,7 +3,7 @@ import * as https from 'https'; import CacheableLookup from 'cacheable-lookup'; import fetch, { HeadersInit } from 'node-fetch'; import { HttpProxyAgent, HttpsProxyAgent } from 'hpagent'; -import config from '@/config'; +import config from '@/config/index.js'; import { URL } from 'url'; export async function getJson(url: string, accept = 'application/json, */*', timeout = 10000, headers?: HeadersInit) { diff --git a/src/misc/gen-avatar.ts b/src/misc/gen-avatar.ts index 7ff28b2e88..f03ca9f96d 100644 --- a/src/misc/gen-avatar.ts +++ b/src/misc/gen-avatar.ts @@ -2,7 +2,7 @@ * Random avatar generator */ -const p = require('pureimage'); +import * as p from 'pureimage'; import * as gen from 'random-seed'; import { WriteStream } from 'fs'; diff --git a/src/misc/gen-id.ts b/src/misc/gen-id.ts index 8e7e0b6113..fcf476857f 100644 --- a/src/misc/gen-id.ts +++ b/src/misc/gen-id.ts @@ -1,9 +1,9 @@ import { ulid } from 'ulid'; -import { genAid } from './id/aid'; -import { genMeid } from './id/meid'; -import { genMeidg } from './id/meidg'; -import { genObjectId } from './id/object-id'; -import config from '@/config'; +import { genAid } from './id/aid.js'; +import { genMeid } from './id/meid.js'; +import { genMeidg } from './id/meidg.js'; +import { genObjectId } from './id/object-id.js'; +import config from '@/config/index.js'; const metohd = config.id.toLowerCase(); diff --git a/src/misc/get-user-name.ts b/src/misc/get-user-name.ts index b6b45118b0..805dbba529 100644 --- a/src/misc/get-user-name.ts +++ b/src/misc/get-user-name.ts @@ -1,4 +1,4 @@ -import { User } from '../models/entities/user'; +import { User } from '@/models/entities/user.js'; export default function(user: User): string { return user.name || user.username; diff --git a/src/misc/is-quote.ts b/src/misc/is-quote.ts index 0a2a72f4a0..779f548b03 100644 --- a/src/misc/is-quote.ts +++ b/src/misc/is-quote.ts @@ -1,4 +1,4 @@ -import { Note } from '../models/entities/note'; +import { Note } from '@/models/entities/note.js'; export default function(note: Note): boolean { return note.renoteId != null && (note.text != null || note.hasPoll || (note.fileIds != null && note.fileIds.length > 0)); diff --git a/src/misc/keypair-store.ts b/src/misc/keypair-store.ts index c78fdd7555..3d505c0abb 100644 --- a/src/misc/keypair-store.ts +++ b/src/misc/keypair-store.ts @@ -1,7 +1,7 @@ -import { UserKeypairs } from '../models'; -import { User } from '../models/entities/user'; -import { UserKeypair } from '../models/entities/user-keypair'; -import { Cache } from './cache'; +import { UserKeypairs } from '@/models/index.js'; +import { User } from '@/models/entities/user.js'; +import { UserKeypair } from '@/models/entities/user-keypair.js'; +import { Cache } from './cache.js'; const cache = new Cache<UserKeypair>(Infinity); diff --git a/src/misc/license.ts b/src/misc/license.ts index d36af665cd..8b12923ca1 100644 --- a/src/misc/license.ts +++ b/src/misc/license.ts @@ -1,6 +1,12 @@ import * as fs from 'fs'; +import { fileURLToPath } from 'url'; +import { dirname } from 'path'; -const license = fs.readFileSync(__dirname + '/../../LICENSE', 'utf-8'); +//const _filename = fileURLToPath(import.meta.url); +const _filename = __filename; +const _dirname = dirname(_filename); + +const license = fs.readFileSync(_dirname + '/../../LICENSE', 'utf-8'); const licenseHtml = license .replace(/\r\n/g, '\n') diff --git a/src/misc/populate-emojis.ts b/src/misc/populate-emojis.ts index 42aaaf0705..e1ec87a95b 100644 --- a/src/misc/populate-emojis.ts +++ b/src/misc/populate-emojis.ts @@ -1,12 +1,12 @@ import { In } from 'typeorm'; -import { Emojis } from '../models'; -import { Emoji } from '../models/entities/emoji'; -import { Note } from '../models/entities/note'; -import { Cache } from './cache'; -import { isSelfHost, toPunyNullable } from './convert-host'; -import { decodeReaction } from './reaction-lib'; -import config from '@/config'; -import { query } from '@/prelude/url'; +import { Emojis } from '@/models/index.js'; +import { Emoji } from '@/models/entities/emoji.js'; +import { Note } from '@/models/entities/note.js'; +import { Cache } from './cache.js'; +import { isSelfHost, toPunyNullable } from './convert-host.js'; +import { decodeReaction } from './reaction-lib.js'; +import config from '@/config/index.js'; +import { query } from '@/prelude/url.js'; const cache = new Cache<Emoji | null>(1000 * 60 * 60 * 12); diff --git a/src/misc/reaction-lib.ts b/src/misc/reaction-lib.ts index b393154d9c..beff1b32bc 100644 --- a/src/misc/reaction-lib.ts +++ b/src/misc/reaction-lib.ts @@ -1,7 +1,7 @@ -import { emojiRegex } from './emoji-regex'; -import { fetchMeta } from './fetch-meta'; -import { Emojis } from '../models'; -import { toPunyNullable } from './convert-host'; +import { emojiRegex } from './emoji-regex.js'; +import { fetchMeta } from './fetch-meta.js'; +import { Emojis } from '@/models/index.js'; +import { toPunyNullable } from './convert-host.js'; const legacies: Record<string, string> = { 'like': '👍', diff --git a/src/misc/show-machine-info.ts b/src/misc/show-machine-info.ts index 2aae019be2..5ce466af26 100644 --- a/src/misc/show-machine-info.ts +++ b/src/misc/show-machine-info.ts @@ -1,6 +1,6 @@ import * as os from 'os'; import * as sysUtils from 'systeminformation'; -import Logger from '../services/logger'; +import Logger from '@/services/logger.js'; export async function showMachineInfo(parentLogger: Logger) { const logger = parentLogger.createSubLogger('machine'); |