Skip to content

Commit cb07a56

Browse files
feat: add shared types package (#715)
1 parent a7f52fc commit cb07a56

File tree

59 files changed

+1459
-1618
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+1459
-1618
lines changed

.github/workflows/release.yaml

Lines changed: 148 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@ on:
99
push:
1010
branches:
1111
- main
12+
pull_request:
13+
types: [labeled]
1214

1315
jobs:
1416
release:
1517
runs-on: ubuntu-latest
16-
if: startsWith(github.event.head_commit.message, 'chore(release):')
18+
if: github.event_name == 'push' && startsWith(github.event.head_commit.message, 'chore(release):')
1719
steps:
1820
- name: Checkout Code
1921
uses: actions/checkout@v4
@@ -48,14 +50,6 @@ jobs:
4850
- name: Install Dependencies
4951
if: steps.version.outputs.version != ''
5052
run: bun install --frozen-lockfile
51-
env:
52-
BTS_TELEMETRY: 0
53-
54-
- name: Build CLI
55-
if: steps.version.outputs.version != ''
56-
run: cd apps/cli && bun run build
57-
env:
58-
BTS_TELEMETRY: 0
5953

6054
- name: Create GitHub Release
6155
if: steps.version.outputs.version != ''
@@ -69,6 +63,37 @@ jobs:
6963
env:
7064
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7165

66+
- name: Update types package version
67+
if: steps.version.outputs.version != ''
68+
run: |
69+
VERSION=${{ steps.version.outputs.version }}
70+
cd packages/types
71+
bun run node -e "const pkg=require('./package.json');pkg.version='$VERSION';require('fs').writeFileSync('package.json',JSON.stringify(pkg,null,2)+'\n')"
72+
73+
- name: Build types package
74+
if: steps.version.outputs.version != ''
75+
run: cd packages/types && bun run build
76+
77+
- name: Publish types to NPM
78+
if: steps.version.outputs.version != ''
79+
run: cd packages/types && bun publish --access public
80+
env:
81+
NPM_CONFIG_TOKEN: ${{ secrets.NPM_TOKEN }}
82+
BTS_TELEMETRY: 1
83+
84+
- name: Update CLI types dependency
85+
if: steps.version.outputs.version != ''
86+
run: |
87+
VERSION=${{ steps.version.outputs.version }}
88+
cd apps/cli
89+
bun run node -e "const pkg=require('./package.json');pkg.dependencies['@better-t-stack/types']='^$VERSION';require('fs').writeFileSync('package.json',JSON.stringify(pkg,null,2)+'\n')"
90+
91+
- name: Build CLI
92+
if: steps.version.outputs.version != ''
93+
run: cd apps/cli && bun run build
94+
env:
95+
BTS_TELEMETRY: 1
96+
7297
- name: Update create-bts alias package version
7398
if: steps.version.outputs.version != ''
7499
run: |
@@ -89,3 +114,117 @@ jobs:
89114
env:
90115
NPM_CONFIG_TOKEN: ${{ secrets.NPM_TOKEN }}
91116
BTS_TELEMETRY: 1
117+
118+
canary:
119+
runs-on: ubuntu-latest
120+
if: github.event_name == 'pull_request' && github.event.label.name == 'canary'
121+
steps:
122+
- name: Checkout Code
123+
uses: actions/checkout@v4
124+
with:
125+
fetch-depth: 0
126+
ref: ${{ github.event.pull_request.head.sha }}
127+
128+
- name: Setup Bun
129+
uses: oven-sh/setup-bun@v2
130+
with:
131+
bun-version: latest
132+
133+
- name: Install Dependencies
134+
run: bun install --frozen-lockfile
135+
env:
136+
BTS_TELEMETRY: 0
137+
138+
- name: Get canary version
139+
id: canary
140+
run: |
141+
COMMIT_HASH=$(git rev-parse --short HEAD)
142+
BASE_VERSION=$(jq -r '.version' apps/cli/package.json | sed -E 's/^([0-9]+\.[0-9]+\.[0-9]+).*/\1/')
143+
CANARY_VERSION="${BASE_VERSION}-canary.${COMMIT_HASH}"
144+
echo "version=$CANARY_VERSION" >> $GITHUB_OUTPUT
145+
echo "commit=$COMMIT_HASH" >> $GITHUB_OUTPUT
146+
147+
- name: Update types package version
148+
run: |
149+
cd packages/types
150+
jq --arg v "${{ steps.canary.outputs.version }}" '.version = $v' package.json > tmp.json && mv tmp.json package.json
151+
152+
- name: Build types package
153+
run: cd packages/types && bun run build
154+
155+
- name: Publish types canary to NPM
156+
run: cd packages/types && bun publish --access public --tag canary
157+
env:
158+
NPM_CONFIG_TOKEN: ${{ secrets.NPM_TOKEN }}
159+
BTS_TELEMETRY: 0
160+
161+
- name: Update CLI package version and types dependency
162+
run: |
163+
cd apps/cli
164+
jq --arg v "${{ steps.canary.outputs.version }}" '.version = $v | .dependencies["@better-t-stack/types"] = $v' package.json > tmp.json && mv tmp.json package.json
165+
166+
- name: Update create-bts alias package version
167+
run: |
168+
cd packages/create-bts
169+
jq --arg v "${{ steps.canary.outputs.version }}" '.version = $v | .dependencies["create-better-t-stack"] = $v' package.json > tmp.json && mv tmp.json package.json
170+
171+
- name: Build CLI
172+
run: cd apps/cli && bun run build
173+
env:
174+
BTS_TELEMETRY: 0
175+
176+
- name: Publish CLI canary to NPM
177+
run: cd apps/cli && bun publish --access public --tag canary
178+
env:
179+
NPM_CONFIG_TOKEN: ${{ secrets.NPM_TOKEN }}
180+
BTS_TELEMETRY: 0
181+
182+
- name: Publish create-bts canary to NPM
183+
run: cd packages/create-bts && bun publish --access public --tag canary
184+
env:
185+
NPM_CONFIG_TOKEN: ${{ secrets.NPM_TOKEN }}
186+
BTS_TELEMETRY: 0
187+
188+
- name: Find existing canary comment
189+
uses: peter-evans/find-comment@v3
190+
id: find-comment
191+
with:
192+
issue-number: ${{ github.event.pull_request.number }}
193+
comment-author: "github-actions[bot]"
194+
body-includes: "Canary Release"
195+
196+
- name: Create or update PR comment
197+
uses: peter-evans/create-or-update-comment@v4
198+
with:
199+
comment-id: ${{ steps.find-comment.outputs.comment-id }}
200+
issue-number: ${{ github.event.pull_request.number }}
201+
edit-mode: replace
202+
body: |
203+
## Canary Release
204+
205+
A canary version has been published for this PR.
206+
207+
**Version:** `${{ steps.canary.outputs.version }}`
208+
**Commit:** `${{ steps.canary.outputs.commit }}`
209+
210+
### Try it out
211+
212+
```bash
213+
# Using bun
214+
bun create better-t-stack@${{ steps.canary.outputs.version }} my-app
215+
216+
# Using npx
217+
npx create-better-t-stack@${{ steps.canary.outputs.version }} my-app
218+
219+
# Using the alias
220+
bun create bts@${{ steps.canary.outputs.version }} my-app
221+
npx create-bts@${{ steps.canary.outputs.version }} my-app
222+
```
223+
224+
### NPM Links
225+
- [create-better-t-stack@${{ steps.canary.outputs.version }}](https://www.npmjs.com/package/create-better-t-stack/v/${{ steps.canary.outputs.version }})
226+
- [create-bts@${{ steps.canary.outputs.version }}](https://www.npmjs.com/package/create-bts/v/${{ steps.canary.outputs.version }})
227+
- [@better-t-stack/types@${{ steps.canary.outputs.version }}](https://www.npmjs.com/package/@better-t-stack/types/v/${{ steps.canary.outputs.version }})
228+
229+
---
230+
*To publish a new canary after more commits, remove and re-add the `canary` label.*

apps/cli/package.json

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"license": "MIT",
77
"author": "Aman Varshney",
88
"bin": {
9-
"create-better-t-stack": "dist/cli.js"
9+
"create-better-t-stack": "dist/cli.mjs"
1010
},
1111
"files": [
1212
"templates",
@@ -57,38 +57,39 @@
5757
},
5858
"exports": {
5959
".": {
60-
"types": "./dist/index.d.ts",
61-
"import": "./dist/index.js"
60+
"types": "./dist/index.d.mts",
61+
"import": "./dist/index.mjs"
6262
},
6363
"./cli": {
64-
"import": "./dist/cli.js"
64+
"import": "./dist/cli.mjs"
6565
}
6666
},
6767
"dependencies": {
68-
"@biomejs/js-api": "^3.0.0",
69-
"@biomejs/wasm-nodejs": "^2.2.6",
70-
"@clack/prompts": "^1.0.0-alpha.6",
71-
"@orpc/server": "^1.10.0",
68+
"@better-t-stack/types": "workspace:*",
69+
"@biomejs/js-api": "^4.0.0",
70+
"@biomejs/wasm-nodejs": "^2.3.8",
71+
"@clack/prompts": "^1.0.0-alpha.8",
72+
"@orpc/server": "^1.12.2",
7273
"consola": "^3.4.2",
73-
"execa": "^9.6.0",
74+
"execa": "^9.6.1",
7475
"fs-extra": "^11.3.2",
7576
"gradient-string": "^3.0.0",
7677
"handlebars": "^4.7.8",
7778
"jsonc-parser": "^3.3.1",
7879
"picocolors": "^1.1.1",
7980
"tinyglobby": "^0.2.15",
80-
"trpc-cli": "^0.12.0",
81+
"trpc-cli": "^0.12.1",
8182
"ts-morph": "^27.0.2",
82-
"yaml": "^2.8.1",
83+
"yaml": "^2.8.2",
8384
"zod": "^4.1.13"
8485
},
8586
"devDependencies": {
8687
"@types/fs-extra": "^11.0.4",
87-
"@types/node": "^24.9.1",
88-
"@vitest/ui": "^3.2.4",
89-
"publint": "^0.3.15",
90-
"tsdown": "^0.15.9",
88+
"@types/node": "^24.10.2",
89+
"@vitest/ui": "^4.0.15",
90+
"publint": "^0.3.16",
91+
"tsdown": "^0.17.2",
9192
"typescript": "^5.9.3",
92-
"vitest": "^3.2.4"
93+
"vitest": "^4.0.15"
9394
}
94-
}
95+
}

apps/cli/src/constants.ts

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -40,20 +40,22 @@ export function getDefaultConfig() {
4040
export const DEFAULT_CONFIG = getDefaultConfig();
4141

4242
export const dependencyVersionMap = {
43-
"better-auth": "^1.4.5",
44-
"@better-auth/expo": "^1.4.5",
43+
typescript: "^5",
44+
45+
"better-auth": "1.4.5",
46+
"@better-auth/expo": "1.4.5",
4547

4648
"@clerk/nextjs": "^6.31.5",
4749
"@clerk/clerk-react": "^5.45.0",
4850
"@clerk/tanstack-react-start": "^0.26.3",
4951
"@clerk/clerk-expo": "^2.14.25",
5052

51-
"drizzle-orm": "^0.45.0",
53+
"drizzle-orm": "^0.45.1",
5254
"drizzle-kit": "^0.31.8",
5355
"@planetscale/database": "^1.19.0",
5456

55-
"@libsql/client": "^0.14.0",
56-
libsql: "^0.5.22",
57+
"@libsql/client": "0.15.15",
58+
libsql: "0.5.22",
5759

5860
"@neondatabase/serverless": "^1.0.2",
5961
pg: "^8.16.3",
@@ -63,15 +65,15 @@ export const dependencyVersionMap = {
6365

6466
mysql2: "^3.14.0",
6567

66-
"@prisma/client": "^7.0.1",
67-
prisma: "^7.0.1",
68-
"@prisma/adapter-d1": "^7.0.1",
69-
"@prisma/adapter-neon": "^7.0.1",
70-
"@prisma/adapter-mariadb": "^7.0.1",
71-
"@prisma/adapter-libsql": "^7.0.1",
72-
"@prisma/adapter-better-sqlite3": "^7.0.1",
73-
"@prisma/adapter-pg": "^7.0.1",
74-
"@prisma/adapter-planetscale": "^7.0.1",
68+
"@prisma/client": "^7.1.0",
69+
prisma: "^7.1.0",
70+
"@prisma/adapter-d1": "^7.1.0",
71+
"@prisma/adapter-neon": "^7.1.0",
72+
"@prisma/adapter-mariadb": "^7.1.0",
73+
"@prisma/adapter-libsql": "^7.1.0",
74+
"@prisma/adapter-better-sqlite3": "^7.1.0",
75+
"@prisma/adapter-pg": "^7.1.0",
76+
"@prisma/adapter-planetscale": "^7.1.0",
7577

7678
mongoose: "^8.14.0",
7779

@@ -81,15 +83,15 @@ export const dependencyVersionMap = {
8183
"@tauri-apps/cli": "^2.4.0",
8284

8385
"@biomejs/biome": "^2.2.0",
84-
oxlint: "^1.12.0",
86+
oxlint: "^1.32.0",
8587

8688
husky: "^9.1.7",
8789
"lint-staged": "^16.1.2",
8890

8991
tsx: "^4.19.2",
9092
"@types/node": "^22.13.11",
9193

92-
"@types/bun": "^1.2.6",
94+
"@types/bun": "^1.3.4",
9395

9496
"@elysiajs/node": "^1.3.1",
9597

@@ -158,7 +160,7 @@ export const dependencyVersionMap = {
158160
"@sveltejs/adapter-cloudflare": "^7.2.1",
159161
"@cloudflare/workers-types": "^4.20250822.0",
160162

161-
alchemy: "^0.77.0",
163+
alchemy: "^0.81.1",
162164

163165
dotenv: "^17.2.2",
164166
tsdown: "^0.16.5",

apps/cli/src/helpers/addons/examples-setup.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import type { ProjectConfig } from "../../types";
55
import { addPackageDependency } from "../../utils/add-package-deps";
66

77
export async function setupExamples(config: ProjectConfig) {
8-
const { examples, frontend, backend, projectDir, orm } = config;
8+
const { examples, frontend, backend, projectDir, orm, database } = config;
99

1010
if (backend === "convex" || !examples || examples.length === 0 || examples[0] === "none") {
1111
return;
@@ -16,8 +16,13 @@ export async function setupExamples(config: ProjectConfig) {
1616

1717
if (apiDirExists && backend !== "none") {
1818
if (orm === "drizzle") {
19+
const dependencies: AvailableDependencies[] = ["drizzle-orm"];
20+
if (database === "postgres") {
21+
// Workaround: not sure there is a weird types error if i add it in dev dep
22+
dependencies.push("@types/pg");
23+
}
1924
await addPackageDependency({
20-
dependencies: ["drizzle-orm", "@types/pg"],
25+
dependencies,
2126
projectDir: apiDir,
2227
});
2328
} else if (orm === "prisma") {

0 commit comments

Comments
 (0)