Skip to content

Commit 4825786

Browse files
committed
feat!: migrated codebase to monorepo
1 parent a40c525 commit 4825786

158 files changed

Lines changed: 1215 additions & 581 deletions

File tree

Some content is hidden

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

.changeset/config.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"$schema": "https://unpkg.com/@changesets/config@3.1.2/schema.json",
3+
"changelog": "@changesets/cli/changelog",
4+
"commit": false,
5+
"fixed": [],
6+
"linked": [],
7+
"access": "restricted",
8+
"baseBranch": "main",
9+
"updateInternalDependencies": "patch",
10+
"ignore": []
11+
}

.changeset/twenty-cats-exist.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
---
2+
'better-svelte-email': major
3+
'@better-svelte-email/components': major
4+
'@better-svelte-email/preview': major
5+
'@better-svelte-email/server': major
6+
---
7+
8+
# New in v2
9+
10+
In v2, we have migrated to a monorepo with new isolated packages (ex: @better-svelte-email/preview, @better-svelte-email/server, @better-svelte-email/components) instead of a single package. This allows for better isolation and modularity, making it easier to maintain and update the different parts of the library. It also reduces the bundle size of the library, when you only need to install the packages you need.
11+
12+
## Migration Guide
13+
14+
### Update your dependencies
15+
16+
First, uninstall the old package:
17+
18+
```bash
19+
npm uninstall better-svelte-email
20+
```
21+
22+
Then, install the new packages:
23+
24+
```bash
25+
npm install @better-svelte-email/components @better-svelte-email/server
26+
```
27+
28+
If you are using the preview system, you will need to install the preview package:
29+
30+
```bash
31+
npm install @better-svelte-email/preview
32+
```
33+
34+
### Update your imports
35+
36+
You will need to update all your imports across your project to use the new packages.
37+
38+
For the renderer, import it from the server package:
39+
40+
```typescript
41+
import { Renderer } from '@better-svelte-email/server';
42+
```
43+
44+
For the components, import them from the components package:
45+
46+
```typescript
47+
import { Button, Text, Heading, Container, Section } from '@better-svelte-email/components';
48+
```
49+
50+
For the preview, import it from the preview package:
51+
52+
```typescript
53+
import { EmailPreview } from '@better-svelte-email/preview';
54+
```
55+
56+
And that's it!

.github/workflows/ci.yml

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,11 @@ jobs:
2626
- name: Install dependencies
2727
run: bun install
2828

29-
- name: Build project
29+
- name: Build workspace
3030
run: bun run build
3131

3232
- name: Run linter
33-
run: bun run lint || echo "Linter not configured, skipping..."
33+
run: bun run lint
3434

3535
- name: Run tests
3636
run: bun run test
37-
38-
- name: Test summary
39-
if: always()
40-
run: |
41-
if [ $? -eq 0 ]; then
42-
echo "✅ All tests passed!"
43-
else
44-
echo "❌ Tests failed!"
45-
exit 1
46-
fi

.github/workflows/release.yml

Lines changed: 18 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,12 @@ on:
44
push:
55
branches:
66
- main
7-
pull_request:
8-
branches:
9-
- main
7+
8+
concurrency: ${{ github.workflow }}-${{ github.ref }}
109

1110
permissions:
1211
contents: write
13-
pull-requests: read
12+
pull-requests: write
1413
id-token: write
1514

1615
jobs:
@@ -32,14 +31,14 @@ jobs:
3231
- name: Install dependencies
3332
run: bun install
3433

35-
- name: Build project
34+
- name: Build workspace
3635
run: bun run build
3736

3837
- name: Run tests
3938
run: bun run test
4039

41-
publish:
42-
name: Publish to NPM
40+
release:
41+
name: Changesets Release
4342
runs-on: ubuntu-latest
4443
needs: test
4544
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
@@ -60,97 +59,23 @@ jobs:
6059
uses: actions/setup-node@v4
6160
with:
6261
node-version: lts/*
63-
registry-url: 'https://registry.npmjs.org'
64-
65-
- name: Get current version
66-
id: current_version
67-
run: |
68-
VERSION=$(node -p "require('./package.json').version")
69-
echo "version=$VERSION" >> $GITHUB_OUTPUT
70-
echo "Current version: $VERSION"
71-
72-
- name: Detect prerelease tag
73-
id: prerelease_tag
74-
run: |
75-
VERSION="${{ steps.current_version.outputs.version }}"
76-
77-
# Check if version contains a prerelease identifier (e.g., -alpha, -beta, -rc)
78-
if [[ "$VERSION" =~ -([a-zA-Z]+)\. ]]; then
79-
TAG="${BASH_REMATCH[1]}"
80-
echo "tag=$TAG" >> $GITHUB_OUTPUT
81-
echo "is_prerelease=true" >> $GITHUB_OUTPUT
82-
echo "📦 Detected prerelease version: $VERSION → dist-tag: $TAG"
83-
else
84-
echo "tag=latest" >> $GITHUB_OUTPUT
85-
echo "is_prerelease=false" >> $GITHUB_OUTPUT
86-
echo "📦 Stable version: $VERSION → dist-tag: latest"
87-
fi
88-
89-
- name: Check if version is published
90-
id: check_published
91-
run: |
92-
PACKAGE_NAME=$(node -p "require('./package.json').name")
93-
VERSION="${{ steps.current_version.outputs.version }}"
94-
95-
if npm view "$PACKAGE_NAME@$VERSION" version 2>/dev/null; then
96-
echo "published=true" >> $GITHUB_OUTPUT
97-
echo "📦 Version $VERSION is already published to npm"
98-
else
99-
echo "published=false" >> $GITHUB_OUTPUT
100-
echo "✨ Version $VERSION is not published yet"
101-
fi
62+
registry-url: "https://registry.npmjs.org"
10263

10364
- name: Install dependencies
104-
if: steps.check_published.outputs.published == 'false'
10565
run: bun install
10666

107-
- name: Build package
108-
if: steps.check_published.outputs.published == 'false'
109-
run: bun run prepack
110-
111-
- name: Publish to NPM
112-
if: steps.check_published.outputs.published == 'false'
113-
run: npm publish --provenance --access public --tag ${{ steps.prerelease_tag.outputs.tag }}
114-
env:
115-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
116-
117-
- name: Skip publishing
118-
if: steps.check_published.outputs.published == 'true'
119-
run: |
120-
echo "⏭️ Skipping npm publish - version ${{ steps.current_version.outputs.version }} already published"
121-
122-
outputs:
123-
version: ${{ steps.current_version.outputs.version }}
124-
should_release: ${{ steps.check_published.outputs.published == 'false' }}
67+
- name: Build publishable packages
68+
run: bunx turbo run build --filter={./packages/*}
12569

126-
release:
127-
name: Create GitHub Release
128-
runs-on: ubuntu-latest
129-
needs: publish
130-
if: needs.publish.outputs.should_release == 'true'
131-
132-
steps:
133-
- name: Checkout code
134-
uses: actions/checkout@v4
135-
with:
136-
fetch-depth: 0
137-
fetch-tags: true
138-
139-
- name: Setup Node.js
140-
uses: actions/setup-node@v4
70+
- name: Create Release Pull Request or Publish
71+
uses: changesets/action@v1
14172
with:
142-
node-version: lts/*
143-
144-
- name: Create and push tag
145-
run: |
146-
git config user.name "github-actions[bot]"
147-
git config user.email "github-actions[bot]@users.noreply.github.com"
148-
git tag -a "v${{ needs.publish.outputs.version }}" -m "Release v${{ needs.publish.outputs.version }}"
149-
git push origin "v${{ needs.publish.outputs.version }}"
150-
env:
151-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
152-
153-
- name: Generate changelog and create release
154-
run: npx changelogithub
73+
version: bun run version
74+
publish: bunx changeset publish --access public
75+
commit: "chore: version packages"
76+
title: "chore: version packages"
77+
createGithubReleases: true
15578
env:
15679
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
80+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
81+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,8 @@ node_modules
1010
vite.config.js.timestamp-*
1111
vite.config.ts.timestamp-*
1212
.vercel
13+
.turbo
14+
apps/*/.svelte-kit
15+
apps/*/build
16+
packages/*/.svelte-kit
17+
packages/*/dist

.prettierignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,9 @@ bun.lockb
77

88
# Miscellaneous
99
/static/
10+
**/.svelte-kit/
11+
**/dist/
12+
**/build/
13+
.turbo/
14+
**/.turbo/
15+
**/.vercel/

.prettierrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@
1212
}
1313
}
1414
],
15-
"tailwindStylesheet": "./src/app.css"
15+
"tailwindStylesheet": "./apps/docs/src/app.css"
1616
}
File renamed without changes.

apps/docs/package.json

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"name": "docs",
3+
"private": true,
4+
"type": "module",
5+
"scripts": {
6+
"dev": "vite dev",
7+
"build": "vite build",
8+
"preview": "vite preview",
9+
"prepare": "svelte-kit sync || echo ''",
10+
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
11+
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
12+
"lint": "prettier --check . --ignore-path ../../.prettierignore && eslint src",
13+
"test": "vitest run --passWithNoTests",
14+
"test:watch": "vitest"
15+
},
16+
"dependencies": {
17+
"@better-svelte-email/components": "workspace:*",
18+
"@better-svelte-email/preview": "workspace:*",
19+
"@better-svelte-email/server": "workspace:*",
20+
"mdsvex": "^0.12.6",
21+
"mode-watcher": "^1.1.0",
22+
"rehype-autolink-headings": "^7.1.0",
23+
"rehype-slug": "^6.0.0",
24+
"resend": "^6.8.0",
25+
"shiki": "^3.22.0",
26+
"tailwindcss-motion": "^1.1.1"
27+
},
28+
"devDependencies": {
29+
"@sveltejs/adapter-vercel": "^6.3.1",
30+
"@sveltejs/kit": "^2.50.2",
31+
"@tailwindcss/vite": "^4.1.18",
32+
"@types/node": "24.10.9",
33+
"prettier": "^3.8.1",
34+
"svelte": "5.49.2",
35+
"vite": "^7.3.1",
36+
"vitest": "^4.0.18"
37+
}
38+
}

src/app.css renamed to apps/docs/src/app.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
@import 'tailwindcss';
22
@plugin 'tailwindcss-motion';
33
@custom-variant dark (&:where(.dark, .dark *));
4-
@import './lib/preview/theme.css';
4+
@import './theme.css';
55

66
@theme {
77
--color-background: var(--background);

0 commit comments

Comments
 (0)