diff --git a/package.json b/package.json index c24a8fb..d100802 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,7 @@ "devDependencies": { "@sxzz/eslint-config-prettier": "^2.4.6", "@sxzz/eslint-config-ts": "^2.4.6", - "@sxzz/prettier-config": "^1.0.4", + "@sxzz/prettier-config": "^2.0.0", "@types/node": "^20.9.2", "bumpp": "^9.2.0", "date-fns": "^2.30.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index fded538..8537938 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -38,8 +38,8 @@ devDependencies: specifier: ^2.4.6 version: 2.4.6(eslint@8.54.0)(typescript@5.2.2) '@sxzz/prettier-config': - specifier: ^1.0.4 - version: 1.0.4 + specifier: ^2.0.0 + version: 2.0.0 '@types/node': specifier: ^20.9.2 version: 20.9.2 @@ -1555,8 +1555,8 @@ packages: - supports-color dev: true - /@sxzz/prettier-config@1.0.4: - resolution: {integrity: sha512-KqgPNwMYloKI+LGAW8LwS0hEJHgwnrIJjgQC0B/saoDJZKUIrqc+lLme/lobrzBetPNhrCuhSDELRrZTg32l0w==} + /@sxzz/prettier-config@2.0.0: + resolution: {integrity: sha512-qckaqLpgHzfuoNXzdXfyQW8NyidxYQ1aPTSZRg9hSg7aiIaKtjxZQsdcOs8Pw9sk+/LPNhRchrxa8N55qJitBQ==} dev: true /@tokenizer/token@0.3.0: diff --git a/src/command/like-rank.ts b/src/command/like-rank.ts index c2753f4..38d6076 100644 --- a/src/command/like-rank.ts +++ b/src/command/like-rank.ts @@ -59,7 +59,7 @@ export const likeRanking = async ({ top, count }: LikeRankOptions) => { .map(async ({ user, count }) => { const ranking = getRanking(count) let text = `${renderRanking(ranking)} ${displayUser( - user + user, )} 点赞 ${ui.colors.cyan(`${count}`)} 次,${( (count / posts.length) * 100 @@ -71,7 +71,7 @@ export const likeRanking = async ({ top, count }: LikeRankOptions) => { }\n${text}\n${divider}` } return text - }) + }), ) spinner.stop() diff --git a/src/command/msg.ts b/src/command/msg.ts index f49d56a..6b7c1f5 100644 --- a/src/command/msg.ts +++ b/src/command/msg.ts @@ -37,7 +37,7 @@ const showNotifications = async (opts: NotificationOptions) => { `Loading notifications... (page ${page}, ${+( (data.length / count) * 100 - ).toFixed(2)}%)` + ).toFixed(2)}%)`, ) return true }, @@ -57,8 +57,8 @@ const showNotifications = async (opts: NotificationOptions) => { const texts = ( await Promise.all( notifications.map((n) => - renderNotification(n, opts).then((result) => [...result, divider]) - ) + renderNotification(n, opts).then((result) => [...result, divider]), + ), ).finally(() => spinner?.stop()) ).flat() texts.unshift(divider) @@ -71,7 +71,7 @@ const EMPTY_PLACEHOLDER = '(EMPTY)' async function renderNotification( n: Entity.Notification, - { avatar, image }: NotificationOptions + { avatar, image }: NotificationOptions, ): Promise { const users = n.actionItem?.users ?? [] let usersText = displayUsers(users) @@ -179,6 +179,6 @@ async function renderNotification( const warnUnknownType = (n: Entity.Notification) => { const info = [n.type, n.actionType, n.actionItem.type].join('||') ui.logger.warning( - `Unknown notification: ${info}. Please send it to developer, thanks!` + `Unknown notification: ${info}. Please send it to developer, thanks!`, ) } diff --git a/src/command/post/create.ts b/src/command/post/create.ts index b651909..8a52ab8 100644 --- a/src/command/post/create.ts +++ b/src/command/post/create.ts @@ -36,7 +36,7 @@ export const createPost = async ({ content, topic }: CreateOptions) => { const draftFile = path.resolve( draftDir, - `${format(new Date(), 'yyyy-MM-dd-HH-mm-ss')}.txt` + `${format(new Date(), 'yyyy-MM-dd-HH-mm-ss')}.txt`, ) spawnSync('vim', [draftFile], { stdio: 'inherit' }) @@ -76,7 +76,7 @@ export const createPost = async ({ content, topic }: CreateOptions) => { }) .catch((err) => ui.logger.fatal(err)) ui.logger.success( - `${ui.colors.bold(displayConfigUser(user))} posted successfully!` + `${ui.colors.bold(displayConfigUser(user))} posted successfully!`, ) } } diff --git a/src/command/post/feed.ts b/src/command/post/feed.ts index 96c3620..6934617 100644 --- a/src/command/post/feed.ts +++ b/src/command/post/feed.ts @@ -44,7 +44,7 @@ const viewFeeds = async (opts: FeedOptions) => { } async function renderPost( - p: JikePostWithDetail | ({ actionTime: string } & Entity.PersonalUpdate) + p: JikePostWithDetail | ({ actionTime: string } & Entity.PersonalUpdate), ) { const texts: string[] = [] if (p.type === 'PERSONAL_UPDATE') { @@ -56,12 +56,12 @@ async function renderPost( // @ts-expect-error (await displayImage(p.live.picture.picUrl)).result, // @ts-expect-error - p.live.title + p.live.title, ) break case 'USER_FOLLOW': texts.push( - `${displayUsers(p.users)} 关注了 ${displayUsers(p.targetUsers)}` + `${displayUsers(p.users)} 关注了 ${displayUsers(p.targetUsers)}`, ) break default: @@ -71,7 +71,7 @@ async function renderPost( const detail = p.detail as Entity.OriginalPost const link = isMacOS ? ui.colors.gray( - ui.colors.underline(`jike://page.jk/originalPost/${p.id}`) + ui.colors.underline(`jike://page.jk/originalPost/${p.id}`), ) : '' texts.push( @@ -79,13 +79,13 @@ async function renderPost( `${displayUser(detail.user)}${ detail.topic ? ` [${detail.topic.content}]` : '' }: ${link}`, - detail.content + detail.content, ) if (detail.pictures && detail.pictures.length > 0) { const images = await Promise.all( detail.pictures.map((p) => - displayImage(p.middlePicUrl).then(({ result }) => `${result}\n`) - ) + displayImage(p.middlePicUrl).then(({ result }) => `${result}\n`), + ), ) texts.push(...images) } @@ -93,8 +93,8 @@ async function renderPost( texts.push( (await displayImage(detail.linkInfo.pictureUrl)).result, `分享链接 [${detail.linkInfo.title}](${ui.colors.blue( - ui.colors.underline(detail.linkInfo.linkUrl) - )})` + ui.colors.underline(detail.linkInfo.linkUrl), + )})`, ) } } else { diff --git a/src/command/post/index.ts b/src/command/post/index.ts index e86ddca..c809dec 100644 --- a/src/command/post/index.ts +++ b/src/command/post/index.ts @@ -13,7 +13,7 @@ Example call: $ jike-cli post new --content="hello world" $ jike-cli post feed $ jike-cli post list -` +`, ) .usage(' [flags]') .addCommand(create) diff --git a/src/command/post/list.ts b/src/command/post/list.ts index 105b5c3..bf0cc89 100644 --- a/src/command/post/list.ts +++ b/src/command/post/list.ts @@ -48,7 +48,7 @@ async function renderPost(p: JikePostWithDetail) { if (detail.type === 'ORIGINAL_POST') { const link = isMacOS ? ui.colors.gray( - ui.colors.underline(`jike://page.jk/originalPost/${p.id}`) + ui.colors.underline(`jike://page.jk/originalPost/${p.id}`), ) : '' texts.push( @@ -56,13 +56,13 @@ async function renderPost(p: JikePostWithDetail) { `${displayUser(detail.user)}${ detail.topic ? ` [${detail.topic.content}]` : '' }: ${link}`, - detail.content + detail.content, ) if (detail.pictures && detail.pictures.length > 0) { const images = await Promise.all( detail.pictures.map((p) => - displayImage(p.middlePicUrl).then(({ result }) => result) - ) + displayImage(p.middlePicUrl).then(({ result }) => result), + ), ) texts.push(...images) } @@ -70,8 +70,8 @@ async function renderPost(p: JikePostWithDetail) { texts.push( (await displayImage(detail.linkInfo.pictureUrl)).result, `分享链接 [${detail.linkInfo.title}](${ui.colors.blue( - ui.colors.underline(detail.linkInfo.linkUrl) - )})` + ui.colors.underline(detail.linkInfo.linkUrl), + )})`, ) } } else { diff --git a/src/command/user/followed.ts b/src/command/user/followed.ts index fb3b1dd..0967c4a 100644 --- a/src/command/user/followed.ts +++ b/src/command/user/followed.ts @@ -35,7 +35,7 @@ export const isFollowed = async (following?: string, follower?: string) => { const isFollowed = await getUser(following).isFollowing( getUser(follower), - mode + mode, ) ui.logger.info(isFollowed ? 'Followed!' : 'Not followed.') diff --git a/src/command/user/index.ts b/src/command/user/index.ts index 301d5e4..af77707 100644 --- a/src/command/user/index.ts +++ b/src/command/user/index.ts @@ -23,7 +23,7 @@ Example call: $ jike-cli user info $ jike-cli user alias -u $ jike-cli user followed -f 5C505995-681E-4C1E-AD4A-1CC683627B6E -` +`, ) .usage(' [flags]') .addCommand(renew) diff --git a/src/command/user/info.ts b/src/command/user/info.ts index 70ba4e7..b37980b 100644 --- a/src/command/user/info.ts +++ b/src/command/user/info.ts @@ -34,7 +34,7 @@ export const userInfo = () => { const t = ui.table().columnWidths([20, 70]) rows.forEach((row) => - t.row([{ content: `${row[0]}:`, hAlign: 'right' }, breakLine(row[1])]) + t.row([{ content: `${row[0]}:`, hAlign: 'right' }, breakLine(row[1])]), ) t.render() } diff --git a/src/command/user/profile.ts b/src/command/user/profile.ts index a0cec04..6cd0682 100644 --- a/src/command/user/profile.ts +++ b/src/command/user/profile.ts @@ -44,7 +44,7 @@ export const queryProfile = async ({ const createdAt = new Date(result.user.createdAt) const createdAtStr = format( new Date(result.user.createdAt), - 'yyyy-MM-dd HH:mm:ss' + 'yyyy-MM-dd HH:mm:ss', ) const createdDays = ( (Date.now() - createdAt.valueOf()) / @@ -53,7 +53,7 @@ export const queryProfile = async ({ ).toFixed(2) const isMyProfile = ( - profile: ApiResponses.Users.Profile + profile: ApiResponses.Users.Profile, ): profile is ApiResponses.Users.MyProfile => profile.user.id === user.userId const formatFollowedCount = (count: number) => @@ -83,7 +83,7 @@ export const queryProfile = async ({ [ `动态获得 ${colors.bold(`${result.user.statsCount.liked}`)} 次赞`, `获得 ${colors.bold( - `${result.user.statsCount.highlightedPersonalUpdates}` + `${result.user.statsCount.highlightedPersonalUpdates}`, )} 次精选`, ], ] @@ -93,7 +93,7 @@ export const queryProfile = async ({ if (profileVisitInfo) texts.push([ `最近访客:${colors.yellow( - profileVisitInfo.latestVisitor.screenName + profileVisitInfo.latestVisitor.screenName, )}`, colors.gray(profileVisitInfo.latestVisitor.username), ]) @@ -105,14 +105,14 @@ export const queryProfile = async ({ ['Mobile', colors.underline(PROFILE_URL.mobile + result.user.username)], isMacOS ? [' macOS', colors.underline(PROFILE_URL.mac + result.user.username)] - : [] + : [], ) const lines = texts.flatMap((fields) => fields .filter((field) => !!field) .join(' | ') - .split('\n') + .split('\n'), ) const s = sticker() @@ -123,7 +123,7 @@ export const queryProfile = async ({ function showTable() { const fields: Record = { 昵称: `${colors.yellow(result.user.screenName)} (${colors.gray( - result.user.username + result.user.username, )})`, 性别: toGender(result.user.gender), 个性签名: result.user.bio, @@ -142,7 +142,7 @@ export const queryProfile = async ({ if (profileVisitInfo) { const { latestVisitor } = profileVisitInfo fields['最近访客'] = `${colors.yellow( - latestVisitor.screenName + latestVisitor.screenName, )} (${colors.gray(latestVisitor.username)})` } } @@ -150,7 +150,7 @@ export const queryProfile = async ({ const t = table() t.columnWidths([15, 65]) Object.entries(fields).forEach(([key, value]) => - t.row([{ content: key, hAlign: 'right' }, value]) + t.row([{ content: key, hAlign: 'right' }, value]), ) t.render() } diff --git a/src/command/user/view.ts b/src/command/user/view.ts index e029e74..541ea91 100644 --- a/src/command/user/view.ts +++ b/src/command/user/view.ts @@ -17,7 +17,7 @@ export const view = createCommand('view') .option( '-p, --platform ', 'supports web, mobile and mac, default is web', - 'web' + 'web', ) .action((username?: string) => { const opts = view.opts() diff --git a/src/utils/user.ts b/src/utils/user.ts index d5edb09..ccfe112 100644 --- a/src/utils/user.ts +++ b/src/utils/user.ts @@ -24,8 +24,8 @@ export const filterUsers = (customQueries?: string[], allowEmpty = true) => { (user) => user.alias === query || user.userId === query || - user.screenName === query - ) + user.screenName === query, + ), ) if (users.length === 0) {