Skip to content

Commit

Permalink
feat: new t3 env setup & update deps
Browse files Browse the repository at this point in the history
  • Loading branch information
ixahmedxi committed Jan 26, 2024
1 parent 8565e27 commit 1595e46
Show file tree
Hide file tree
Showing 14 changed files with 155 additions and 127 deletions.
2 changes: 1 addition & 1 deletion apps/web/next.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import '@orbitkit/db/env';
import './src/env.mjs';

/** @type {import('next').NextConfig} */
const nextConfig = {
Expand Down
6 changes: 4 additions & 2 deletions apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,18 @@
"dependencies": {
"@orbitkit/db": "workspace:^",
"@orbitkit/ui": "workspace:^",
"@t3-oss/env-nextjs": "^0.8.0",
"geist": "^1.2.1",
"next": "14.1.0",
"next-themes": "^0.2.1",
"react": "^18.2.0",
"react-dom": "^18.2.0"
"react-dom": "^18.2.0",
"zod": "^3.22.4"
},
"devDependencies": {
"@orbitkit/tailwind": "workspace:^",
"@orbitkit/tsconfig": "workspace:^",
"@types/node": "^20.11.5",
"@types/node": "^20.11.7",
"@types/react": "^18.2.48",
"@types/react-dom": "^18.2.18",
"autoprefixer": "^10.4.17",
Expand Down
5 changes: 5 additions & 0 deletions apps/web/src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ThemeSwitcher } from '@/components/ThemeSwitcher';
import { db } from '@orbitkit/db';
import { Avatar, AvatarFallback, AvatarImage } from '@orbitkit/ui/avatar';

export default async function Home() {
const users = await db.query.userTable.findMany();
Expand All @@ -9,6 +10,10 @@ export default async function Home() {
<h1>Hello World</h1>
{JSON.stringify(users)}
<ThemeSwitcher />
<Avatar>
<AvatarImage src="https://github.com/shadcn.png" alt="@shadcn" />
<AvatarFallback>CN</AvatarFallback>
</Avatar>
</main>
);
}
11 changes: 11 additions & 0 deletions apps/web/src/env.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { env as dbEnv } from '@orbitkit/db/env';
import { createEnv } from '@t3-oss/env-nextjs';
import { vercel } from '@t3-oss/env-nextjs/presets';

export const env = createEnv({
extends: [dbEnv, vercel],
server: {},
client: {},
runtimeEnv: {},
emptyStringAsUndefined: true,
});
2 changes: 1 addition & 1 deletion apps/web/tailwind.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { Config } from 'tailwindcss';
import { orbitKitTailwindPreset } from '@orbitkit/tailwind';

const config: Config = {
content: ['./src/**/*.{js,ts,jsx,tsx,mdx}'],
content: ['./src/**/*.{js,ts,jsx,tsx,mdx}', '../../packages/ui/dist/**/*.js'],
darkMode: 'class',
presets: [orbitKitTailwindPreset],
};
Expand Down
1 change: 1 addition & 0 deletions apps/web/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"**/*.js",
"**/*.cjs",
".eslintrc.cjs",
"**/*.mjs",
],
"exclude": ["node_modules"],
}
1 change: 1 addition & 0 deletions cspell.config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ words:
- tsup
- turborepo
- typecheck
- shadcn
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@
"typecheck": "tsc --noEmit --tsBuildInfoFile .tsbuildinfo"
},
"devDependencies": {
"@commitlint/cli": "^18.5.0",
"@commitlint/config-conventional": "^18.5.0",
"@commitlint/cli": "^18.6.0",
"@commitlint/config-conventional": "^18.6.0",
"@commitlint/config-pnpm-scopes": "^18.4.4",
"@commitlint/prompt-cli": "^18.5.0",
"@commitlint/prompt-cli": "^18.6.0",
"@ianvs/prettier-plugin-sort-imports": "^4.1.1",
"@orbitkit/tsconfig": "workspace:^",
"@types/eslint": "^8.56.2",
"cspell": "^8.3.2",
"eslint": "^8.56.0",
"eslint-config-orbitkit": "workspace:^",
"husky": "^8.0.3",
"husky": "^9.0.6",
"lint-staged": "^15.2.0",
"markdownlint": "^0.33.0",
"markdownlint-cli": "^0.38.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/config/tailwind/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
},
"devDependencies": {
"@orbitkit/tsconfig": "workspace:^",
"@types/node": "^20.11.5",
"@types/node": "^20.11.7",
"eslint-config-orbitkit": "workspace:^",
"tailwindcss-animate": "^1.0.7"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/db/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
},
"dependencies": {
"@neondatabase/serverless": "^0.7.2",
"@t3-oss/env-nextjs": "^0.7.3",
"@t3-oss/env-core": "^0.8.0",
"drizzle-orm": "^0.29.3",
"pg": "^8.11.3",
"postgres": "^3.4.3",
Expand Down
8 changes: 5 additions & 3 deletions packages/db/src/env.mjs
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { createEnv } from '@t3-oss/env-nextjs';
import { createEnv } from '@t3-oss/env-core';
import { vercel } from '@t3-oss/env-core/presets';
import { z } from 'zod';

export const env = createEnv({
extends: [vercel],
server: {
DATABASE_URL: z.string().url(),
DATABASE_URL: z.string().url().startsWith('postgres'),
},
client: {},
runtimeEnv: {
DATABASE_URL: process.env['DATABASE_URL'],
},
emptyStringAsUndefined: true,
});
26 changes: 13 additions & 13 deletions packages/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,32 @@
"exports": {
".": {
"import": {
"default": "./dist/index.js",
"types": "./dist/index.d.ts"
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
},
"require": {
"default": "./dist/index.cjs",
"types": "./dist/index.d.cts"
"types": "./dist/index.d.cts",
"default": "./dist/index.cjs"
}
},
"./avatar": {
"import": {
"default": "./dist/avatar.js",
"types": "./dist/avatar.d.ts"
"types": "./dist/avatar.d.ts",
"default": "./dist/avatar.js"
},
"require": {
"default": "./dist/avatar.cjs",
"types": "./dist/avatar.d.cts"
"types": "./dist/avatar.d.cts",
"default": "./dist/avatar.cjs"
}
},
"./cn": {
"import": {
"default": "./dist/utils/cn.js",
"types": "./dist/utils/cn.d.ts"
"types": "./dist/utils/cn.d.ts",
"default": "./dist/utils/cn.js"
},
"require": {
"default": "./dist/utils/cn.cjs",
"types": "./dist/utils/cn.d.cts"
"types": "./dist/utils/cn.d.cts",
"default": "./dist/utils/cn.cjs"
}
}
},
Expand All @@ -61,7 +61,7 @@
"devDependencies": {
"@orbitkit/tailwind": "workspace:^",
"@orbitkit/tsconfig": "workspace:^",
"@types/node": "^20.11.5",
"@types/node": "^20.11.7",
"@types/react": "^18.2.48",
"@types/react-dom": "^18.2.18",
"autoprefixer": "^10.4.17",
Expand Down
18 changes: 9 additions & 9 deletions packages/ui/tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ type PackageJson = {
types: string;
};

export default defineConfig({
export default defineConfig((opts) => ({
entry: entries.map((entry) => entry.source),
format: ['esm', 'cjs'],
splitting: true,
sourcemap: true,
minify: true,
clean: true,
clean: !opts.watch,
dts: true,
outDir: 'dist',
async onSuccess() {
Expand All @@ -40,20 +40,20 @@ export default defineConfig({
pkg.exports = entries.reduce((acc: Record<string, unknown>, entry) => {
acc[entry.export] = {
import: {
default: entry.source
.replace('src', 'dist')
.replace(/\.tsx?$/, '.js'),
types: entry.source
.replace('src', 'dist')
.replace(/\.tsx?$/, '.d.ts'),
},
require: {
default: entry.source
.replace('src', 'dist')
.replace(/\.tsx?$/, '.cjs'),
.replace(/\.tsx?$/, '.js'),
},
require: {
types: entry.source
.replace('src', 'dist')
.replace(/\.tsx?$/, '.d.cts'),
default: entry.source
.replace('src', 'dist')
.replace(/\.tsx?$/, '.cjs'),
},
};
return acc;
Expand All @@ -77,4 +77,4 @@ export default defineConfig({
fs.writeFileSync('./package.json', formatted);
}
},
});
}));
Loading

0 comments on commit 1595e46

Please sign in to comment.