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

namespace all packages to avoid collision #2

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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 assets/esbuild.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { walkFsTree } from "@repo/script/walkFsTree"
import { watch as chokidar } from "chokidar"
import { writeFile } from "node:fs/promises"
import { basename, dirname, join, relative } from "node:path"
import { walkFsTree } from "script/walkFsTree"

function dTsTemplate(name: string) {
return `declare const query: string
Expand Down
4 changes: 2 additions & 2 deletions assets/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "assets",
"name": "@repo/assets",
"version": "1.0.0",
"private": true,
"type": "module",
Expand All @@ -13,6 +13,6 @@
"./*": "./src/*"
},
"devDependencies": {
"script": "workspace:script@*"
"@repo/script": "workspace:@repo/script@*"
}
}
2 changes: 1 addition & 1 deletion client/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { QueryClient, QueryClientProvider } from "@tanstack/react-query"
import { ReactQueryDevtools } from "@tanstack/react-query-devtools"
import { createRoot } from "react-dom/client"
import App from "./src/App"
import { enableServiceWorker } from "client/sw/enableServiceWorker"
import { enableServiceWorker } from "@repo/client/sw/enableServiceWorker"

const client = new QueryClient({
defaultOptions: {
Expand Down
8 changes: 4 additions & 4 deletions client/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "client",
"name": "@repo/client",
"version": "1.0.0",
"private": true,
"type": "module",
Expand All @@ -20,10 +20,10 @@
"clear": "rm -rf node_modules; rm -rf .turbo; rm public/sw.js; rm public/sw.js.map; find src -name '*.module.css.d.ts' -type f -delete"
},
"dependencies": {
"assets": "workspace:assets@*",
"shared": "workspace:shared@*"
"@repo/assets": "workspace:@repo/assets@*",
"@repo/shared": "workspace:@repo/shared@*"
},
"devDependencies": {
"script": "workspace:script@*"
"@repo/script": "workspace:@repo/script@*"
}
}
14 changes: 7 additions & 7 deletions client/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { useEffect, useState } from "react"
import { type Provider } from "client/auth/providers"
import { useAuth } from "client/auth/useAuth"
import { Content } from "client/db/DbTest"
import { DbProvider } from "client/db/ParentTest"
import { fooBar } from "shared/foo/bar"
import { useServiceWorker } from "client/sw/useServiceWorker"
import { Button } from "client/Button/Button"
import { type Provider } from "@repo/client/auth/providers"
import { useAuth } from "@repo/client/auth/useAuth"
import { Content } from "@repo/client/db/DbTest"
import { DbProvider } from "@repo/client/db/ParentTest"
import { fooBar } from "@repo/shared/foo/bar"
import { useServiceWorker } from "@repo/client/sw/useServiceWorker"
import { Button } from "@repo/client/Button/Button"

fooBar()

Expand Down
4 changes: 2 additions & 2 deletions client/src/auth/useAuth.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useEffect, useState } from "react"
import { PUBLIC_CONFIG } from "shared/env/publicConfig"
import { providers, type Provider } from "client/auth/providers"
import { PUBLIC_CONFIG } from "@repo/shared/env/publicConfig"
import { providers, type Provider } from "@repo/client/auth/providers"

type States =
| {
Expand Down
10 changes: 5 additions & 5 deletions client/src/db/DbTest.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { useDB, useQuery } from "@vlcn.io/react"
import { useEffect, useState } from "react"
import { sql } from "shared/sql"
import { sql } from "@repo/shared/sql"

import { useSync } from "client/db/Sync"
import { useDbQuery } from "client/db/useDbQuery"
import { useDbMutation } from "client/db/useDbMutation"
import { Button } from "client/Button/Button"
import { useSync } from "@repo/client/db/Sync"
import { useDbQuery } from "@repo/client/db/useDbQuery"
import { useDbMutation } from "@repo/client/db/useDbMutation"
import { Button } from "@repo/client/Button/Button"

function Test({ name }: { name: string }) {
const other = useDbQuery<{ id: string; content: string; position: number }>({
Expand Down
4 changes: 2 additions & 2 deletions client/src/db/ParentTest.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { DBProvider as BaseDbProvider } from "@vlcn.io/react"
import schema from "assets/test-v0.sql"
import schema from "@repo/assets/test-v0.sql"
import type { ReactNode } from "react"
import { useCacheManager } from "client/db/useDbQuery"
import { useCacheManager } from "@repo/client/db/useDbQuery"

function ReactQueryAdapter({ name, children }: { name: string; children: ReactNode }) {
useCacheManager(name)
Expand Down
2 changes: 1 addition & 1 deletion client/src/db/Sync.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { sql } from "shared/sql"
import { sql } from "@repo/shared/sql"
import type { CtxAsync } from "@vlcn.io/react"
import { encode, decode, tags, bytesToHex } from "@vlcn.io/ws-common"
import { useState, useEffect } from "react"
Expand Down
2 changes: 1 addition & 1 deletion client/src/sw/enableServiceWorker.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { type QueryClient } from "@tanstack/react-query"
import { SW_CACHE_KEY } from "client/sw/useServiceWorker"
import { SW_CACHE_KEY } from "@repo/client/sw/useServiceWorker"

async function loadServiceWorker(client?: QueryClient, id?: string) {
try {
Expand Down
2 changes: 1 addition & 1 deletion client/src/sw/useServiceWorker.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useQuery } from "@tanstack/react-query"
import { type Message } from "shared/workerEvents"
import { type Message } from "@repo/shared/workerEvents"

export const SW_CACHE_KEY = ["sw"]

Expand Down
1 change: 0 additions & 1 deletion client/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"extends": "../tsconfig.base.json",
"compilerOptions": {},
"include": [],
"files": [],
"references": [
Expand Down
10 changes: 5 additions & 5 deletions client/turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"../assets/src/**"
],
"outputs": ["../dist/client/**"],
"dependsOn": ["script#build"]
"dependsOn": ["@repo/script#build"]
},
"tsc:tools": {
"inputs": [
Expand Down Expand Up @@ -43,18 +43,18 @@
"tsconfig.json",
"tsconfig.app.json"
],
"dependsOn": ["client#tsc:build:css"]
"dependsOn": ["@repo/client#tsc:build:css"]
},
"tsc": {
"dependsOn": ["client#tsc:tools", "client#tsc:app"]
"dependsOn": ["@repo/client#tsc:tools", "@repo/client#tsc:app"]
},
"test": {
"dependsOn": ["script#build"]
"dependsOn": ["@repo/script#build"]
},
"dev": {
"cache": false,
"persistent": true,
"dependsOn": ["script#build"]
"dependsOn": ["@repo/script#build"]
}
}
}
8 changes: 4 additions & 4 deletions client/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import { visualizer } from "rollup-plugin-visualizer"
import { config } from "dotenv"
import { readFile, rm, writeFile } from "node:fs/promises"
import { join, resolve } from "node:path"
import { compressBuffer } from "script/compressBuffer"
import { ViteRawLoader } from "script/ViteRawLoader"
import { walkFsTree } from "script/walkFsTree"
import { compressBuffer } from "@repo/script/compressBuffer"
import { ViteRawLoader } from "@repo/script/ViteRawLoader"
import { walkFsTree } from "@repo/script/walkFsTree"

config({ path: "../.env" })

Expand Down Expand Up @@ -142,7 +142,7 @@ export default defineConfig({
resolve: {
alias: {
// use alias to avoid having "client" as a package dependency of "client"
"client/": `${normalizePath(__dirname)}/src/`,
"@repo/client/": `${normalizePath(__dirname)}/src/`,
},
},
server: {
Expand Down
16 changes: 6 additions & 10 deletions knip.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
import type { KnipConfig } from 'knip'
import type { KnipConfig } from "knip"

const config: KnipConfig = {
"ignoreDependencies": [
ignoreDependencies: [
// used by fastify, with just a string reference, no import
"pino-pretty",
// might not be used everywhere yet
"assets",
"@repo/assets",
],
"ignore": [
"**/*.test.ts",
"**/types/*.d.ts"
],
"includeEntryExports": true,
ignore: ["**/*.test.ts", "**/types/*.d.ts"],
includeEntryExports: true,
}

export default config;

export default config
51 changes: 25 additions & 26 deletions pnpm-lock.yaml

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

2 changes: 1 addition & 1 deletion script/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "script",
"name": "@repo/script",
"version": "1.0.0",
"private": true,
"type": "module",
Expand Down
10 changes: 5 additions & 5 deletions server/esbuild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { type ChildProcess, spawn } from "node:child_process"
import { join } from "node:path"
import fastify from "fastify"
import proxy from "@fastify/http-proxy"
import { env } from "server/env"
import { env } from "@repo/server/env"

const options: esbuild.BuildOptions = {
entryPoints: ["src/app.ts"],
Expand All @@ -24,10 +24,10 @@ const options: esbuild.BuildOptions = {
".js": ".mjs",
},
// alias: {
// "shared": "../shared/src",
// "script": "../script/src",
// "assets": "../assets/src",
// "worker": "../worker/src",
// "@repo/shared": "../shared/src",
// "@repo/script": "../script/src",
// "@repo/assets": "../assets/src",
// "@repo/worker": "../worker/src",
// },
}

Expand Down
9 changes: 5 additions & 4 deletions server/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "server",
"name": "@repo/server",
"version": "1.0.0",
"private": true,
"type": "module",
Expand All @@ -18,10 +18,11 @@
"clear": "rm -rf node_modules; rm -rf .turbo;"
},
"dependencies": {
"shared": "workspace:shared@*",
"assets": "workspace:assets@*"
"@repo/shared": "workspace:@repo/shared@*",
"@repo/assets": "workspace:@repo/assets@*",
"@repo/script": "workspace:@repo/script@*"
},
"devDependencies": {
"script": "workspace:script@*"
"@repo/script": "workspace:@repo/script@*"
}
}
14 changes: 7 additions & 7 deletions server/src/app.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import fastify from "fastify"
import api from "server/api"
import auth from "server/auth"
import frontend from "server/frontend"
import { env } from "server/env"
import crsqlite from "server/crsqlite"
import { DB_ROOT } from "server/utils/dbRoot"
import { fooBar } from "shared/foo/bar"
import api from "@repo/server/api"
import auth from "@repo/server/auth"
import frontend from "@repo/server/frontend"
import { env } from "@repo/server/env"
import crsqlite from "@repo/server/crsqlite"
import { DB_ROOT } from "@repo/server/utils/dbRoot"
import { fooBar } from "@repo/shared/foo/bar"

fooBar()

Expand Down
2 changes: 1 addition & 1 deletion server/src/auth/db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Database from "better-sqlite3"
import schemaContent from "./schema.sql"
import path from "node:path"
import type { FastifyInstance } from "fastify"
import { makeDbLogger } from "server/utils/dbLogger"
import { makeDbLogger } from "@repo/server/utils/dbLogger"

export function makeAuthDb(
fastify: FastifyInstance,
Expand Down
2 changes: 1 addition & 1 deletion server/src/auth/helpers/AuthTokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import crypto, { type CipherGCMTypes } from "node:crypto"
import { type BaseSchema, type Output, parse } from "valibot"
import { env } from "server/env"
import { env } from "@repo/server/env"

const ALGORITHM: CipherGCMTypes = "aes-256-gcm"
const PASSWORD = env.SESSION_COOKIE_SECRET
Expand Down
2 changes: 1 addition & 1 deletion server/src/auth/helpers/InviteCodes.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { sql } from "shared/sql"
import { sql } from "@repo/shared/sql"
import type BetterSqlite3 from "better-sqlite3"
import wordList from "./5-letter-words.txt"

Expand Down
Loading