misc: transition to monorepo
No files matched your search
@@ -133,4 +133,5 @@ AGENTS.md
|
|||||||
*.openai*
|
*.openai*
|
||||||
*.anthropic*
|
*.anthropic*
|
||||||
|
|
||||||
database/
|
# Expo mobile app (not needed in web Docker image)
|
||||||
|
apps/mobile/
|
||||||
@@ -1,19 +1,20 @@
|
|||||||
# dependencies
|
# dependencies
|
||||||
/node_modules
|
node_modules/
|
||||||
/.pnp
|
|
||||||
.pnp.*
|
|
||||||
.yarn/*
|
|
||||||
!.yarn/patches
|
|
||||||
!.yarn/plugins
|
|
||||||
!.yarn/releases
|
|
||||||
!.yarn/versions
|
|
||||||
|
|
||||||
# testing
|
# testing
|
||||||
/coverage
|
/coverage
|
||||||
|
|
||||||
# next.js
|
# next.js
|
||||||
/.next/
|
apps/web/.next/
|
||||||
/out/
|
apps/web/out/
|
||||||
|
|
||||||
|
# expo
|
||||||
|
apps/mobile/.expo/
|
||||||
|
apps/mobile/dist/
|
||||||
|
apps/mobile/web-build/
|
||||||
|
apps/mobile/expo-env.d.ts
|
||||||
|
apps/mobile/ios/
|
||||||
|
apps/mobile/android/
|
||||||
|
|
||||||
# production
|
# production
|
||||||
/build
|
/build
|
||||||
@@ -33,7 +34,7 @@ pnpm-debug.log*
|
|||||||
|
|
||||||
# typescript
|
# typescript
|
||||||
*.tsbuildinfo
|
*.tsbuildinfo
|
||||||
next-env.d.ts
|
apps/web/next-env.d.ts
|
||||||
|
|
||||||
/.idea
|
/.idea
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,6 @@
|
|||||||
"trailingComma": "es5",
|
"trailingComma": "es5",
|
||||||
"printWidth": 80,
|
"printWidth": 80,
|
||||||
"plugins": ["prettier-plugin-tailwindcss"],
|
"plugins": ["prettier-plugin-tailwindcss"],
|
||||||
"tailwindStylesheet": "app/globals.css",
|
"tailwindStylesheet": "apps/web/app/globals.css",
|
||||||
"tailwindFunctions": ["cn", "cva"]
|
"tailwindFunctions": ["cn", "cva"]
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,7 @@
|
|||||||
<!-- BEGIN:nextjs-agent-rules -->
|
<!-- BEGIN:nextjs-agent-rules -->
|
||||||
# This is NOT the Next.js you know
|
# This is NOT the Next.js you know
|
||||||
|
|
||||||
This version has breaking changes — APIs, conventions, and file structure may all differ from your training data. Read the relevant guide in `node_modules/next/dist/docs/` before writing any code. Heed deprecation notices.
|
This version has breaking changes — APIs, conventions, and file structure may all differ from your training data. Read the relevant guide in `apps/web/node_modules/next/dist/docs/` before writing any code. Heed deprecation notices.
|
||||||
|
|
||||||
|
The Next.js web app lives in `apps/web`.
|
||||||
<!-- END:nextjs-agent-rules -->
|
<!-- END:nextjs-agent-rules -->
|
||||||
@@ -16,25 +16,14 @@ RUN apt-get update && \
|
|||||||
|
|
||||||
FROM node:${NODE_VERSION} AS dependencies
|
FROM node:${NODE_VERSION} AS dependencies
|
||||||
|
|
||||||
# Set working directory
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Copy package-related files first to leverage Docker's caching mechanism
|
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml .npmrc ./
|
||||||
COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* .npmrc* ./
|
COPY apps/web/package.json ./apps/web/
|
||||||
|
|
||||||
# Install project dependencies with frozen lockfile for reproducible builds
|
RUN --mount=type=cache,target=/root/.local/share/pnpm/store \
|
||||||
RUN --mount=type=cache,target=/root/.npm \
|
corepack enable pnpm && \
|
||||||
--mount=type=cache,target=/usr/local/share/.cache/yarn \
|
pnpm install --frozen-lockfile --filter @otunes/web...
|
||||||
--mount=type=cache,target=/root/.local/share/pnpm/store \
|
|
||||||
if [ -f package-lock.json ]; then \
|
|
||||||
npm ci --no-audit --no-fund; \
|
|
||||||
elif [ -f yarn.lock ]; then \
|
|
||||||
corepack enable yarn && yarn install --frozen-lockfile --production=false; \
|
|
||||||
elif [ -f pnpm-lock.yaml ]; then \
|
|
||||||
corepack enable pnpm && pnpm install --frozen-lockfile; \
|
|
||||||
else \
|
|
||||||
echo "No lockfile found." && exit 1; \
|
|
||||||
fi
|
|
||||||
|
|
||||||
# ============================================
|
# ============================================
|
||||||
# Stage 2: Build Next.js application in standalone mode
|
# Stage 2: Build Next.js application in standalone mode
|
||||||
@@ -42,39 +31,21 @@ RUN --mount=type=cache,target=/root/.npm \
|
|||||||
|
|
||||||
FROM node:${NODE_VERSION} AS builder
|
FROM node:${NODE_VERSION} AS builder
|
||||||
|
|
||||||
# Set working directory
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Copy project dependencies from dependencies stage
|
|
||||||
COPY --from=dependencies /app/node_modules ./node_modules
|
COPY --from=dependencies /app/node_modules ./node_modules
|
||||||
|
COPY --from=dependencies /app/apps/web/node_modules ./apps/web/node_modules
|
||||||
# Copy application source code
|
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml .npmrc ./
|
||||||
COPY . .
|
COPY apps/web ./apps/web
|
||||||
|
|
||||||
ENV NODE_ENV=production
|
ENV NODE_ENV=production
|
||||||
|
|
||||||
ARG NEXT_PUBLIC_CONVEX_URL
|
ARG NEXT_PUBLIC_CONVEX_URL
|
||||||
|
|
||||||
# Next.js collects completely anonymous telemetry data about general usage.
|
WORKDIR /app/apps/web
|
||||||
# Learn more here: https://nextjs.org/telemetry
|
|
||||||
# Uncomment the following line in case you want to disable telemetry during the build.
|
|
||||||
# ENV NEXT_TELEMETRY_DISABLED=1
|
|
||||||
|
|
||||||
# Build Next.js application
|
RUN --mount=type=cache,target=/app/apps/web/.next/cache \
|
||||||
# If you want to speed up Docker rebuilds, you can cache the build artifacts
|
corepack enable pnpm && pnpm build
|
||||||
# by adding: --mount=type=cache,target=/app/.next/cache
|
|
||||||
# This caches the .next/cache directory across builds, but it also prevents
|
|
||||||
# .next/cache/fetch-cache from being included in the final image, meaning
|
|
||||||
# cached fetch responses from the build won't be available at runtime.
|
|
||||||
RUN if [ -f package-lock.json ]; then \
|
|
||||||
npm run build; \
|
|
||||||
elif [ -f yarn.lock ]; then \
|
|
||||||
corepack enable yarn && yarn build; \
|
|
||||||
elif [ -f pnpm-lock.yaml ]; then \
|
|
||||||
corepack enable pnpm && pnpm build; \
|
|
||||||
else \
|
|
||||||
echo "No lockfile found." && exit 1; \
|
|
||||||
fi
|
|
||||||
|
|
||||||
# ============================================
|
# ============================================
|
||||||
# Stage 3: Run Next.js application
|
# Stage 3: Run Next.js application
|
||||||
@@ -82,42 +53,22 @@ RUN if [ -f package-lock.json ]; then \
|
|||||||
|
|
||||||
FROM runner-base AS runner
|
FROM runner-base AS runner
|
||||||
|
|
||||||
# Set working directory
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Set production environment variables
|
|
||||||
ENV NODE_ENV=production
|
ENV NODE_ENV=production
|
||||||
ENV PORT=3000
|
ENV PORT=3000
|
||||||
ENV HOSTNAME="0.0.0.0"
|
ENV HOSTNAME="0.0.0.0"
|
||||||
|
|
||||||
# Next.js collects completely anonymous telemetry data about general usage.
|
|
||||||
# Learn more here: https://nextjs.org/telemetry
|
|
||||||
# Uncomment the following line in case you want to disable telemetry during the run time.
|
|
||||||
# ENV NEXT_TELEMETRY_DISABLED=1
|
|
||||||
|
|
||||||
RUN mkdir /data
|
RUN mkdir /data
|
||||||
|
|
||||||
# Copy production assets
|
COPY --from=builder --chown=node:node /app/apps/web/public ./apps/web/public
|
||||||
COPY --from=builder --chown=node:node /app/public ./public
|
COPY --from=builder --chown=node:node /app/apps/web/.next/standalone ./
|
||||||
|
COPY --from=builder --chown=node:node /app/apps/web/.next/static ./apps/web/.next/static
|
||||||
|
|
||||||
# Set the correct permission for prerender cache
|
RUN mkdir -p apps/web/.next && chown -R node:node apps/web/.next
|
||||||
RUN mkdir .next
|
|
||||||
RUN chown node:node .next
|
|
||||||
|
|
||||||
# Automatically leverage output traces to reduce image size
|
|
||||||
# https://nextjs.org/docs/advanced-features/output-file-tracing
|
|
||||||
COPY --from=builder --chown=node:node /app/.next/standalone ./
|
|
||||||
COPY --from=builder --chown=node:node /app/.next/static ./.next/static
|
|
||||||
|
|
||||||
# If you want to persist the fetch cache generated during the build so that
|
|
||||||
# cached responses are available immediately on startup, uncomment this line:
|
|
||||||
# COPY --from=builder --chown=node:node /app/.next/cache ./.next/cache
|
|
||||||
|
|
||||||
# Switch to non-root user for security best practices
|
|
||||||
USER node
|
USER node
|
||||||
|
|
||||||
# Expose port 3000 to allow HTTP traffic
|
|
||||||
EXPOSE 3000
|
EXPOSE 3000
|
||||||
|
|
||||||
# Start Next.js standalone server
|
CMD ["node", "apps/web/server.js"]
|
||||||
CMD ["node", "server.js"]
|
|
||||||
@@ -2,6 +2,46 @@
|
|||||||
|
|
||||||
Your music, my music, _**our**_ music. Self-hosted music streaming app and server.
|
Your music, my music, _**our**_ music. Self-hosted music streaming app and server.
|
||||||
|
|
||||||
|
## Monorepo
|
||||||
|
|
||||||
|
This project uses [pnpm workspaces](https://pnpm.io/workspaces):
|
||||||
|
|
||||||
|
| Package | Path | Description |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| `@otunes/web` | `apps/web` | Next.js web app |
|
||||||
|
| `@otunes/mobile` | `apps/mobile` | Expo React Native mobile app |
|
||||||
|
|
||||||
|
### Development
|
||||||
|
|
||||||
|
Install dependencies from the repository root:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pnpm install
|
||||||
|
```
|
||||||
|
|
||||||
|
Run the web app:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pnpm dev
|
||||||
|
# or
|
||||||
|
pnpm dev:web
|
||||||
|
```
|
||||||
|
|
||||||
|
Run the mobile app:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pnpm dev:mobile
|
||||||
|
```
|
||||||
|
|
||||||
|
Other commands:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pnpm build # build web app
|
||||||
|
pnpm lint # lint all packages
|
||||||
|
pnpm typecheck # typecheck all packages
|
||||||
|
pnpm format # format with Prettier
|
||||||
|
```
|
||||||
|
|
||||||
## Hosting with Docker
|
## Hosting with Docker
|
||||||
|
|
||||||
Here's an example `docker-compose.yml` file to get you started:
|
Here's an example `docker-compose.yml` file to get you started:
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
import { StatusBar } from "expo-status-bar"
|
||||||
|
import { StyleSheet, Text, View } from "react-native"
|
||||||
|
|
||||||
|
export default function App() {
|
||||||
|
return (
|
||||||
|
<View style={styles.container}>
|
||||||
|
<Text style={styles.title}>oTunes</Text>
|
||||||
|
<Text style={styles.subtitle}>Mobile app coming soon</Text>
|
||||||
|
<StatusBar style="auto" />
|
||||||
|
</View>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
const styles = StyleSheet.create({
|
||||||
|
container: {
|
||||||
|
flex: 1,
|
||||||
|
backgroundColor: "#fff",
|
||||||
|
alignItems: "center",
|
||||||
|
justifyContent: "center",
|
||||||
|
gap: 8,
|
||||||
|
},
|
||||||
|
title: {
|
||||||
|
fontSize: 28,
|
||||||
|
fontWeight: "700",
|
||||||
|
},
|
||||||
|
subtitle: {
|
||||||
|
fontSize: 16,
|
||||||
|
color: "#666",
|
||||||
|
},
|
||||||
|
})
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
{
|
||||||
|
"expo": {
|
||||||
|
"name": "oTunes",
|
||||||
|
"slug": "otunes",
|
||||||
|
"version": "0.0.1",
|
||||||
|
"orientation": "portrait",
|
||||||
|
"icon": "./assets/icon.png",
|
||||||
|
"userInterfaceStyle": "automatic",
|
||||||
|
"ios": {
|
||||||
|
"supportsTablet": true,
|
||||||
|
"bundleIdentifier": "com.otunes.app"
|
||||||
|
},
|
||||||
|
"android": {
|
||||||
|
"adaptiveIcon": {
|
||||||
|
"backgroundColor": "#E6F4FE",
|
||||||
|
"foregroundImage": "./assets/android-icon-foreground.png",
|
||||||
|
"backgroundImage": "./assets/android-icon-background.png",
|
||||||
|
"monochromeImage": "./assets/android-icon-monochrome.png"
|
||||||
|
},
|
||||||
|
"package": "com.otunes.app",
|
||||||
|
"predictiveBackGestureEnabled": false
|
||||||
|
},
|
||||||
|
"web": {
|
||||||
|
"favicon": "./assets/favicon.png"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
After Width: | Height: | Size: 17 KiB |
|
After Width: | Height: | Size: 77 KiB |
|
After Width: | Height: | Size: 4.0 KiB |
|
After Width: | Height: | Size: 1.1 KiB |
|
After Width: | Height: | Size: 384 KiB |
|
After Width: | Height: | Size: 17 KiB |
@@ -0,0 +1,8 @@
|
|||||||
|
import { registerRootComponent } from 'expo';
|
||||||
|
|
||||||
|
import App from './App';
|
||||||
|
|
||||||
|
// registerRootComponent calls AppRegistry.registerComponent('main', () => App);
|
||||||
|
// It also ensures that whether you load the app in Expo Go or in a native build,
|
||||||
|
// the environment is set up appropriately
|
||||||
|
registerRootComponent(App);
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
{
|
||||||
|
"name": "@otunes/mobile",
|
||||||
|
"version": "0.0.1",
|
||||||
|
"private": true,
|
||||||
|
"main": "index.ts",
|
||||||
|
"scripts": {
|
||||||
|
"start": "expo start",
|
||||||
|
"android": "expo start --android",
|
||||||
|
"ios": "expo start --ios",
|
||||||
|
"web": "expo start --web",
|
||||||
|
"lint": "tsc --noEmit",
|
||||||
|
"typecheck": "tsc --noEmit"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"expo": "~56.0.11",
|
||||||
|
"expo-status-bar": "~56.0.4",
|
||||||
|
"react": "19.2.4",
|
||||||
|
"react-native": "0.85.3"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@types/react": "~19.2.2",
|
||||||
|
"typescript": "~6.0.3"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"extends": "expo/tsconfig.base",
|
||||||
|
"compilerOptions": {
|
||||||
|
"strict": true
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
|
||||||
|
.env.local
|
||||||
|
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 4.2 KiB |
@@ -1,6 +1,6 @@
|
|||||||
"use client"
|
"use client"
|
||||||
|
|
||||||
import * as React from "react"
|
import { useEffect, useMemo, useState, useRef, MouseEvent } from "react"
|
||||||
import Image from "next/image"
|
import Image from "next/image"
|
||||||
import Link from "next/link"
|
import Link from "next/link"
|
||||||
import { usePaginatedQuery } from "convex/react"
|
import { usePaginatedQuery } from "convex/react"
|
||||||
@@ -88,6 +88,7 @@ function SongCover({
|
|||||||
src={albumCoverUrl(song.album.id)}
|
src={albumCoverUrl(song.album.id)}
|
||||||
alt={song.album.title}
|
alt={song.album.title}
|
||||||
fill
|
fill
|
||||||
|
sizes="(max-width: 640px) 50vw, (max-width: 1024px) 25vw, 16vw"
|
||||||
className="object-cover"
|
className="object-cover"
|
||||||
/>
|
/>
|
||||||
<div className="absolute inset-0 flex items-center justify-center bg-black/0 transition-colors group-hover:bg-black/40">
|
<div className="absolute inset-0 flex items-center justify-center bg-black/0 transition-colors group-hover:bg-black/40">
|
||||||
@@ -128,8 +129,8 @@ function SongRow({
|
|||||||
selectionPosition: SelectionRangePosition
|
selectionPosition: SelectionRangePosition
|
||||||
isFavorite: boolean
|
isFavorite: boolean
|
||||||
selectedCount: number
|
selectedCount: number
|
||||||
onSelect: (event: React.MouseEvent) => void
|
onSelect: (event: MouseEvent) => void
|
||||||
onPointerDown: (event: React.MouseEvent) => void
|
onPointerDown: (event: MouseEvent) => void
|
||||||
onToggleFavorite: () => void
|
onToggleFavorite: () => void
|
||||||
onPrepareContextMenu: () => void
|
onPrepareContextMenu: () => void
|
||||||
onMediaAction: (action: MediaContextAction, songId: string) => void
|
onMediaAction: (action: MediaContextAction, songId: string) => void
|
||||||
@@ -267,10 +268,10 @@ export function SongsView() {
|
|||||||
const { isSongFavorite, toggleSongFavorite, favoriteSongs } = useFavorites()
|
const { isSongFavorite, toggleSongFavorite, favoriteSongs } = useFavorites()
|
||||||
const { playFromLibrarySong } = usePlayback()
|
const { playFromLibrarySong } = usePlayback()
|
||||||
const { runQueueAction } = useQueueMediaActions()
|
const { runQueueAction } = useQueueMediaActions()
|
||||||
const [sortKey, setSortKey] = React.useState<SortKey>("title")
|
const [sortKey, setSortKey] = useState<SortKey>("title")
|
||||||
const [sortDirection, setSortDirection] =
|
const [sortDirection, setSortDirection] =
|
||||||
React.useState<SortDirection>("asc")
|
useState<SortDirection>("asc")
|
||||||
const loadMoreRef = React.useRef<HTMLDivElement>(null)
|
const loadMoreRef = useRef<HTMLDivElement>(null)
|
||||||
|
|
||||||
const { results, status, loadMore } = usePaginatedQuery(
|
const { results, status, loadMore } = usePaginatedQuery(
|
||||||
api.library.browseSongsPaginated,
|
api.library.browseSongsPaginated,
|
||||||
@@ -278,9 +279,9 @@ export function SongsView() {
|
|||||||
{ initialNumItems: SONGS_PAGE_SIZE }
|
{ initialNumItems: SONGS_PAGE_SIZE }
|
||||||
)
|
)
|
||||||
|
|
||||||
const songs = results ?? []
|
const songs = useMemo(() => results ?? [], [results])
|
||||||
|
|
||||||
React.useEffect(() => {
|
useEffect(() => {
|
||||||
const sentinel = loadMoreRef.current
|
const sentinel = loadMoreRef.current
|
||||||
if (!sentinel) {
|
if (!sentinel) {
|
||||||
return
|
return
|
||||||
@@ -314,7 +315,7 @@ export function SongsView() {
|
|||||||
clearSelection,
|
clearSelection,
|
||||||
} = useTrackSelection(songs)
|
} = useTrackSelection(songs)
|
||||||
|
|
||||||
const selectionPositions = React.useMemo(
|
const selectionPositions = useMemo(
|
||||||
() =>
|
() =>
|
||||||
getSelectionRangePositions(
|
getSelectionRangePositions(
|
||||||
songs.map((song) => song.id),
|
songs.map((song) => song.id),
|
||||||