Skip to content

Commit

Permalink
refactor: monorepo
Browse files Browse the repository at this point in the history
  • Loading branch information
ddiu8081 committed Oct 17, 2022
1 parent 50669b0 commit cd33542
Show file tree
Hide file tree
Showing 32 changed files with 470 additions and 334 deletions.
33 changes: 2 additions & 31 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,24 +1,7 @@
{
"name": "bilicli",
"version": "0.3.2",
"description": "",
"name": "bilicli-monorepo",
"private": true,
"homepage": "https://github.com/ddiu8081/bilicli#readme",
"repository": {
"type": "git",
"url": "https://github.com/ddiu8081/bilicli"
},
"scripts": {
"dev": "temir src/main.ts",
"build": "temir build src/main.ts"
},
"bin": {
"bilicli": "bin/bilicli.js"
},
"main": "dist/main.js",
"files": [
"bin",
"dist"
],
"keywords": [
"bilibili",
"bilibili-live",
Expand All @@ -29,20 +12,8 @@
"tui"
],
"author": "ddiu8081 <ddiu8081@gmail.com>",
"license": "MIT",
"devDependencies": {
"@temir/cli": "^0.0.20",
"@types/node": "^18.8.3",
"typescript": "^4.8.4"
},
"dependencies": {
"@temir/core": "^0.0.20",
"@temir/link": "^0.0.20",
"@temir/tab": "^0.0.20",
"blive-message-listener": "^0.3.0",
"dayjs": "^1.11.5",
"mri": "^1.2.0",
"ohmyfetch": "^0.4.19",
"vue": "^3.2.40"
}
}
File renamed without changes.
40 changes: 40 additions & 0 deletions packages/bilicli/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"name": "bilicli",
"version": "0.3.2",
"description": "Bilibili-live danmu dashboard in your terminal.",
"homepage": "https://github.com/ddiu8081/bilicli#readme",
"repository": {
"type": "git",
"url": "https://github.com/ddiu8081/bilicli"
},
"scripts": {
"dev": "tsup --watch",
"build": "tsup"
},
"bin": {
"bilicli": "bin/bilicli.js"
},
"main": "dist/main.js",
"files": [
"bin",
"dist"
],
"keywords": [
"bilibili",
"bilibili-live",
"danmaku",
"danmu",
"terminal",
"cli",
"tui"
],
"author": "ddiu8081 <ddiu8081@gmail.com>",
"license": "MIT",
"devDependencies": {
"tsup": "^6.2.3"
},
"dependencies": {
"cac": "^6.7.14",
"@bilicli/live": "workspace:*"
}
}
15 changes: 15 additions & 0 deletions packages/bilicli/src/actions/live.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { startApp } from '@bilicli/live'

interface ArgOptions {
badge: boolean
rank: boolean
}

const live = async(roomId: string, options: ArgOptions) => {
startApp(~~roomId, {
badge: options.badge,
rank: options.rank,
})
}

export { live }
19 changes: 19 additions & 0 deletions packages/bilicli/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/env node
import { name, version } from '../package.json'
import { cac } from 'cac'

import { live } from './actions/live'

const cli = cac(name)

// create
cli
.command('live <room_id>', 'Open live console in full mode')
.option('--no-badge', 'Hide badge of user')
.option('--no-rank', 'Hide rank of user')
.action(live)

cli.help()
cli.version(version)

cli.parse()
16 changes: 16 additions & 0 deletions packages/bilicli/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"compilerOptions": {
"target": "esnext",
"module": "esnext",
"lib": [
"esnext",
"dom"
],
"moduleResolution": "node",
"declaration": true,
"esModuleInterop": true,
"sourceMap": false,
"resolveJsonModule": true
},
"include": ["src/**/*.ts"]
}
13 changes: 13 additions & 0 deletions packages/bilicli/tsup.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { defineConfig } from 'tsup'

export default defineConfig({
format: ['cjs', 'esm'],
entry: [
'src/index.ts',
],
dts: {
resolve: true,
entry: './src/index.ts',
},
clean: true,
})
45 changes: 45 additions & 0 deletions packages/live/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"name": "@bilicli/live",
"version": "0.3.2",
"description": "",
"scripts": {
"dev": "temir src/index.ts",
"build": "temir build src/index.ts"
},
"main": "dist/main.js",
"module": "dist/index.mjs",
"types": "dist/index.d.ts",
"files": [
"bin",
"dist"
],
"exports": {
".": {
"require": "./dist/index.js",
"import": "./dist/index.mjs"
}
},
"keywords": [
"bilibili",
"bilibili-live",
"danmaku",
"danmu",
"terminal",
"cli",
"tui"
],
"author": "ddiu8081 <ddiu8081@gmail.com>",
"license": "MIT",
"devDependencies": {
"@temir/cli": "^0.0.20"
},
"dependencies": {
"@temir/core": "^0.0.20",
"@temir/link": "^0.0.20",
"@temir/tab": "^0.0.20",
"blive-message-listener": "^0.3.0",
"dayjs": "^1.11.5",
"ohmyfetch": "^0.4.19",
"vue": "^3.2.40"
}
}
15 changes: 10 additions & 5 deletions src/App.vue β†’ packages/live/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import type {
} from 'blive-message-listener'
import { TBox } from '@temir/core'
import { getRoomInfo, type RoomInfo } from './utils/getInfo'
import { parseCliArgs } from './utils/cli'
import { listenQuitCommand } from './utils/readline'
import CliHeader from './components/CliHeader.vue'
Expand All @@ -22,8 +21,6 @@ import GiftMsgCom from './components/msgCom/GiftMsgCom.vue'
import GuardBuyMsgCom from './components/msgCom/GuardBuyMsgCom.vue'
import UserActionMsgCom from './components/msgCom/UserActionMsgCom.vue'
const options = parseCliArgs()
provide('options', options)
const currentRoomInfo = ref<RoomInfo | null>(null)
const liveStatus = ref({
isLive: false,
Expand All @@ -41,9 +38,17 @@ const giftList = ref<Message<GiftMsg>[]>([])
const guardBuyList = ref<Message<GuardBuyMsg>[]>([])
const userActionList = ref<Message<UserActionMsg>[]>([])
interface Props {
roomId: number
options: AppOptions
}
const props = defineProps<Props>()
provide('options', props.options)
onMounted(async () => {
listenQuitCommand()
const roomInfo = await getRoomInfo(options.roomId)
const roomInfo = await getRoomInfo(props.roomId)
if (!roomInfo) {
console.log('ζˆΏι—΄δΈε­˜εœ¨')
return process.exit(1)
Expand All @@ -62,7 +67,7 @@ onMounted(async () => {
watchers.value = body.num
},
onLiveStart: async ({ body }) => {
const roomInfo = await getRoomInfo(options.roomId)
const roomInfo = await getRoomInfo(props.roomId)
if (roomInfo) {
liveStatus.value = {
isLive: roomInfo.live_status === 1,
Expand Down
1 change: 0 additions & 1 deletion src/app.d.ts β†’ packages/live/src/app.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ declare module '*.vue' {
}

interface AppOptions {
roomId: number
badge: boolean
rank: boolean
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
15 changes: 15 additions & 0 deletions packages/live/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { render } from '@temir/core'
import { h } from 'vue'
import App from './App.vue'

const startApp = (roomId: number, options: AppOptions) => {
const NewApp = {
render() {
return h(App, { roomId, options })
}
}

render(NewApp)
}

export { startApp }
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
11 changes: 11 additions & 0 deletions packages/live/tsup.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export default {
format: ['cjs', 'esm'],
entry: [
'src/index.ts',
],
dts: {
resolve: true,
entry: './src/index.ts',
},
clean: true,
}
Loading

0 comments on commit cd33542

Please sign in to comment.