From 9ee0db95aceb7acedfd929f1069fa65175405c02 Mon Sep 17 00:00:00 2001 From: syuilo Date: Fri, 4 Feb 2022 01:56:33 +0900 Subject: [PATCH] refactor: use date-fns --- packages/backend/package.json | 3 +-- .../src/queue/processors/db/export-blocking.ts | 4 ++-- .../src/queue/processors/db/export-custom-emojis.ts | 4 ++-- .../src/queue/processors/db/export-following.ts | 4 ++-- .../backend/src/queue/processors/db/export-mute.ts | 4 ++-- .../backend/src/queue/processors/db/export-notes.ts | 4 ++-- .../src/queue/processors/db/export-user-lists.ts | 4 ++-- packages/backend/yarn.lock | 13 ++++--------- packages/client/package.json | 1 - packages/client/yarn.lock | 5 ----- 10 files changed, 17 insertions(+), 29 deletions(-) diff --git a/packages/backend/package.json b/packages/backend/package.json index 05641389f0..1944de73f5 100644 --- a/packages/backend/package.json +++ b/packages/backend/package.json @@ -24,7 +24,6 @@ "@types/bcryptjs": "2.4.2", "@types/bull": "3.15.7", "@types/cbor": "6.0.0", - "@types/dateformat": "5.0.0", "@types/escape-regexp": "0.0.1", "@types/glob": "7.2.0", "@types/is-url": "1.2.30", @@ -87,7 +86,7 @@ "cli-highlight": "2.1.11", "content-disposition": "0.5.4", "crc-32": "1.2.1", - "dateformat": "4.5.1", + "date-fns": "2.28.0", "deep-email-validator": "0.1.21", "escape-regexp": "0.0.1", "eslint": "8.8.0", diff --git a/packages/backend/src/queue/processors/db/export-blocking.ts b/packages/backend/src/queue/processors/db/export-blocking.ts index 01edaaeb63..f4de9ce005 100644 --- a/packages/backend/src/queue/processors/db/export-blocking.ts +++ b/packages/backend/src/queue/processors/db/export-blocking.ts @@ -4,7 +4,7 @@ import * as fs from 'fs'; import { queueLogger } from '../../logger'; import { addFile } from '@/services/drive/add-file'; -import * as dateFormat from 'dateformat'; +import { format as dateFormat } from 'date-fns'; import { getFullApAccount } from '@/misc/convert-host'; import { Users, Blockings } from '@/models/index'; import { MoreThan } from 'typeorm'; @@ -85,7 +85,7 @@ export async function exportBlocking(job: Bull.Job, done: any): P stream.end(); logger.succ(`Exported to: ${path}`); - const fileName = 'blocking-' + dateFormat(new Date(), 'yyyy-mm-dd-HH-MM-ss') + '.csv'; + const fileName = 'blocking-' + dateFormat(new Date(), 'yyyy-MM-dd-HH-mm-ss') + '.csv'; const driveFile = await addFile({ user, path, name: fileName, force: true }); logger.succ(`Exported to: ${driveFile.id}`); diff --git a/packages/backend/src/queue/processors/db/export-custom-emojis.ts b/packages/backend/src/queue/processors/db/export-custom-emojis.ts index 240a542fec..2f7505f158 100644 --- a/packages/backend/src/queue/processors/db/export-custom-emojis.ts +++ b/packages/backend/src/queue/processors/db/export-custom-emojis.ts @@ -7,7 +7,7 @@ const mime = require('mime-types'); const archiver = require('archiver'); import { queueLogger } from '../../logger'; import { addFile } from '@/services/drive/add-file'; -import * as dateFormat from 'dateformat'; +import { format as dateFormat } from 'date-fns'; import { Users, Emojis } from '@/models/index'; import { } from '@/queue/types'; import { downloadUrl } from '@/misc/download-url'; @@ -110,7 +110,7 @@ export async function exportCustomEmojis(job: Bull.Job, done: () => void): Promi archiveStream.on('close', async () => { logger.succ(`Exported to: ${archivePath}`); - const fileName = 'custom-emojis-' + dateFormat(new Date(), 'yyyy-mm-dd-HH-MM-ss') + '.zip'; + const fileName = 'custom-emojis-' + dateFormat(new Date(), 'yyyy-MM-dd-HH-mm-ss') + '.zip'; const driveFile = await addFile({ user, path: archivePath, name: fileName, force: true }); logger.succ(`Exported to: ${driveFile.id}`); diff --git a/packages/backend/src/queue/processors/db/export-following.ts b/packages/backend/src/queue/processors/db/export-following.ts index 06572acec1..2ac558381b 100644 --- a/packages/backend/src/queue/processors/db/export-following.ts +++ b/packages/backend/src/queue/processors/db/export-following.ts @@ -4,7 +4,7 @@ import * as fs from 'fs'; import { queueLogger } from '../../logger'; import { addFile } from '@/services/drive/add-file'; -import * as dateFormat from 'dateformat'; +import { format as dateFormat } from 'date-fns'; import { getFullApAccount } from '@/misc/convert-host'; import { Users, Followings, Mutings } from '@/models/index'; import { In, MoreThan, Not } from 'typeorm'; @@ -86,7 +86,7 @@ export async function exportFollowing(job: Bull.Job, done: () => stream.end(); logger.succ(`Exported to: ${path}`); - const fileName = 'following-' + dateFormat(new Date(), 'yyyy-mm-dd-HH-MM-ss') + '.csv'; + const fileName = 'following-' + dateFormat(new Date(), 'yyyy-MM-dd-HH-mm-ss') + '.csv'; const driveFile = await addFile({ user, path, name: fileName, force: true }); logger.succ(`Exported to: ${driveFile.id}`); diff --git a/packages/backend/src/queue/processors/db/export-mute.ts b/packages/backend/src/queue/processors/db/export-mute.ts index 4a856f8ef9..9e917ccbf3 100644 --- a/packages/backend/src/queue/processors/db/export-mute.ts +++ b/packages/backend/src/queue/processors/db/export-mute.ts @@ -4,7 +4,7 @@ import * as fs from 'fs'; import { queueLogger } from '../../logger'; import { addFile } from '@/services/drive/add-file'; -import * as dateFormat from 'dateformat'; +import { format as dateFormat } from 'date-fns'; import { getFullApAccount } from '@/misc/convert-host'; import { Users, Mutings } from '@/models/index'; import { MoreThan } from 'typeorm'; @@ -85,7 +85,7 @@ export async function exportMute(job: Bull.Job, done: any): Promi stream.end(); logger.succ(`Exported to: ${path}`); - const fileName = 'mute-' + dateFormat(new Date(), 'yyyy-mm-dd-HH-MM-ss') + '.csv'; + const fileName = 'mute-' + dateFormat(new Date(), 'yyyy-MM-dd-HH-mm-ss') + '.csv'; const driveFile = await addFile({ user, path, name: fileName, force: true }); logger.succ(`Exported to: ${driveFile.id}`); diff --git a/packages/backend/src/queue/processors/db/export-notes.ts b/packages/backend/src/queue/processors/db/export-notes.ts index 305abf44cf..0e65cb8849 100644 --- a/packages/backend/src/queue/processors/db/export-notes.ts +++ b/packages/backend/src/queue/processors/db/export-notes.ts @@ -4,7 +4,7 @@ import * as fs from 'fs'; import { queueLogger } from '../../logger'; import { addFile } from '@/services/drive/add-file'; -import * as dateFormat from 'dateformat'; +import { format as dateFormat } from 'date-fns'; import { Users, Notes, Polls } from '@/models/index'; import { MoreThan } from 'typeorm'; import { Note } from '@/models/entities/note'; @@ -94,7 +94,7 @@ export async function exportNotes(job: Bull.Job, done: any): Prom stream.end(); logger.succ(`Exported to: ${path}`); - const fileName = 'notes-' + dateFormat(new Date(), 'yyyy-mm-dd-HH-MM-ss') + '.json'; + const fileName = 'notes-' + dateFormat(new Date(), 'yyyy-MM-dd-HH-mm-ss') + '.json'; const driveFile = await addFile({ user, path, name: fileName, force: true }); logger.succ(`Exported to: ${driveFile.id}`); diff --git a/packages/backend/src/queue/processors/db/export-user-lists.ts b/packages/backend/src/queue/processors/db/export-user-lists.ts index f907cf9526..fcd2ba336c 100644 --- a/packages/backend/src/queue/processors/db/export-user-lists.ts +++ b/packages/backend/src/queue/processors/db/export-user-lists.ts @@ -4,7 +4,7 @@ import * as fs from 'fs'; import { queueLogger } from '../../logger'; import { addFile } from '@/services/drive/add-file'; -import * as dateFormat from 'dateformat'; +import { format as dateFormat } from 'date-fns'; import { getFullApAccount } from '@/misc/convert-host'; import { Users, UserLists, UserListJoinings } from '@/models/index'; import { In } from 'typeorm'; @@ -62,7 +62,7 @@ export async function exportUserLists(job: Bull.Job, done: any): stream.end(); logger.succ(`Exported to: ${path}`); - const fileName = 'user-lists-' + dateFormat(new Date(), 'yyyy-mm-dd-HH-MM-ss') + '.csv'; + const fileName = 'user-lists-' + dateFormat(new Date(), 'yyyy-MM-dd-HH-mm-ss') + '.csv'; const driveFile = await addFile({ user, path, name: fileName, force: true }); logger.succ(`Exported to: ${driveFile.id}`); diff --git a/packages/backend/yarn.lock b/packages/backend/yarn.lock index 202d70b5e6..0f272c5023 100644 --- a/packages/backend/yarn.lock +++ b/packages/backend/yarn.lock @@ -403,11 +403,6 @@ "@types/keygrip" "*" "@types/node" "*" -"@types/dateformat@5.0.0": - version "5.0.0" - resolved "https://registry.yarnpkg.com/@types/dateformat/-/dateformat-5.0.0.tgz#17ce64b0318f3f36d1c830c58a7a915445f1f93d" - integrity sha512-SZg4JdHIWHQGEokbYGZSDvo5wA4TLYPXaqhigs/wH+REDOejcJzgH+qyY+HtEUtWOZxEUkbhbdYPqQDiEgrXeA== - "@types/disposable-email-domains@^1.0.1": version "1.0.2" resolved "https://registry.yarnpkg.com/@types/disposable-email-domains/-/disposable-email-domains-1.0.2.tgz#0280f6b38fa7f14e54b056a434135ecd254483b1" @@ -2099,10 +2094,10 @@ data-urls@^3.0.1: whatwg-mimetype "^3.0.0" whatwg-url "^10.0.0" -dateformat@4.5.1: - version "4.5.1" - resolved "https://registry.yarnpkg.com/dateformat/-/dateformat-4.5.1.tgz#c20e7a9ca77d147906b6dc2261a8be0a5bd2173c" - integrity sha512-OD0TZ+B7yP7ZgpJf5K2DIbj3FZvFvxgFUuaqA/V5zTjAtAAXZ1E8bktHxmAGs4x5b7PflqA9LeQ84Og7wYtF7Q== +date-fns@2.28.0: + version "2.28.0" + resolved "https://registry.yarnpkg.com/date-fns/-/date-fns-2.28.0.tgz#9570d656f5fc13143e50c975a3b6bbeb46cd08b2" + integrity sha512-8d35hViGYx/QH0icHYCeLmsLmMUheMmTyV9Fcm6gvNwdw31yXXH+O85sOBJ+OLnLQMKZowvpKb6FgMIQjcpvQw== debug@2, debug@^2.2.0, debug@^2.5.2, debug@^2.6.9: version "2.6.9" diff --git a/packages/client/package.json b/packages/client/package.json index b840bafe8c..686e0710e5 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -12,7 +12,6 @@ "dependencies": { "@discordapp/twemoji": "13.1.0", "@syuilo/aiscript": "0.11.1", - "@types/dateformat": "3.0.1", "@types/escape-regexp": "0.0.1", "@types/glob": "7.2.0", "@types/gulp": "4.0.9", diff --git a/packages/client/yarn.lock b/packages/client/yarn.lock index 76be45f145..88f9027ade 100644 --- a/packages/client/yarn.lock +++ b/packages/client/yarn.lock @@ -266,11 +266,6 @@ resolved "https://registry.yarnpkg.com/@types/color-name/-/color-name-1.1.1.tgz#1c1261bbeaa10a8055bbc5d8ab84b7b2afc846a0" integrity sha512-rr+OQyAjxze7GgWrSaJwydHStIhHq2lvY3BOC2Mj7KnzI7XK0Uw1TOOdI9lDoajEbSWLiYgoo4f1R51erQfhPQ== -"@types/dateformat@3.0.1": - version "3.0.1" - resolved "https://registry.yarnpkg.com/@types/dateformat/-/dateformat-3.0.1.tgz#98d747a2e5e9a56070c6bf14e27bff56204e34cc" - integrity sha512-KlPPdikagvL6ELjWsljbyDIPzNCeliYkqRpI+zea99vBBbCIA5JNshZAwQKTON139c87y9qvTFVgkFd14rtS4g== - "@types/escape-regexp@0.0.1": version "0.0.1" resolved "https://registry.yarnpkg.com/@types/escape-regexp/-/escape-regexp-0.0.1.tgz#f1a977ccdf2ef059e9862bd3af5e92cbbe723e0e"