Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(deps): update dependency @sxzz/prettier-config to v2 #74

Merged
merged 2 commits into from
Nov 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
8 changes: 4 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/command/like-rank.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -71,7 +71,7 @@ export const likeRanking = async ({ top, count }: LikeRankOptions) => {
}\n${text}\n${divider}`
}
return text
})
}),
)

spinner.stop()
Expand Down
10 changes: 5 additions & 5 deletions src/command/msg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const showNotifications = async (opts: NotificationOptions) => {
`Loading notifications... (page ${page}, ${+(
(data.length / count) *
100
).toFixed(2)}%)`
).toFixed(2)}%)`,
)
return true
},
Expand All @@ -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)
Expand All @@ -71,7 +71,7 @@ const EMPTY_PLACEHOLDER = '(EMPTY)'

async function renderNotification(
n: Entity.Notification,
{ avatar, image }: NotificationOptions
{ avatar, image }: NotificationOptions,
): Promise<string[]> {
const users = n.actionItem?.users ?? []
let usersText = displayUsers(users)
Expand Down Expand Up @@ -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!`,
)
}
4 changes: 2 additions & 2 deletions src/command/post/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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' })

Expand Down Expand Up @@ -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!`,
)
}
}
18 changes: 9 additions & 9 deletions src/command/post/feed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand All @@ -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:
Expand All @@ -71,30 +71,30 @@ 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(
(await displayImage(detail.user.avatarImage.thumbnailUrl, 3)).result,
`${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)
}
if (detail.linkInfo) {
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 {
Expand Down
2 changes: 1 addition & 1 deletion src/command/post/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Example call:
$ jike-cli post new --content="hello world"
$ jike-cli post feed
$ jike-cli post list
`
`,
)
.usage('<command> [flags]')
.addCommand(create)
Expand Down
12 changes: 6 additions & 6 deletions src/command/post/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,30 +48,30 @@ 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(
(await displayImage(detail.user.avatarImage.thumbnailUrl, 3)).result,
`${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)
}
if (detail.linkInfo) {
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 {
Expand Down
2 changes: 1 addition & 1 deletion src/command/user/followed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.')
Expand Down
2 changes: 1 addition & 1 deletion src/command/user/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Example call:
$ jike-cli user info
$ jike-cli user alias -u <user> <alias>
$ jike-cli user followed -f 5C505995-681E-4C1E-AD4A-1CC683627B6E
`
`,
)
.usage('<command> [flags]')
.addCommand(renew)
Expand Down
2 changes: 1 addition & 1 deletion src/command/user/info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
18 changes: 9 additions & 9 deletions src/command/user/profile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()) /
Expand All @@ -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) =>
Expand Down Expand Up @@ -83,7 +83,7 @@ export const queryProfile = async ({
[
`动态获得 ${colors.bold(`${result.user.statsCount.liked}`)} 次赞`,
`获得 ${colors.bold(
`${result.user.statsCount.highlightedPersonalUpdates}`
`${result.user.statsCount.highlightedPersonalUpdates}`,
)} 次精选`,
],
]
Expand All @@ -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),
])
Expand All @@ -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()
Expand All @@ -123,7 +123,7 @@ export const queryProfile = async ({
function showTable() {
const fields: Record<string, string> = {
昵称: `${colors.yellow(result.user.screenName)} (${colors.gray(
result.user.username
result.user.username,
)})`,
性别: toGender(result.user.gender),
个性签名: result.user.bio,
Expand All @@ -142,15 +142,15 @@ export const queryProfile = async ({
if (profileVisitInfo) {
const { latestVisitor } = profileVisitInfo
fields['最近访客'] = `${colors.yellow(
latestVisitor.screenName
latestVisitor.screenName,
)} (${colors.gray(latestVisitor.username)})`
}
}

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()
}
Expand Down
2 changes: 1 addition & 1 deletion src/command/user/view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const view = createCommand('view')
.option(
'-p, --platform <platform>',
'supports web, mobile and mac, default is web',
'web'
'web',
)
.action((username?: string) => {
const opts = view.opts<ViewOptions>()
Expand Down
4 changes: 2 additions & 2 deletions src/utils/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down