Skip to content

Commit 86949fc

Browse files
committed
chore: wip
1 parent 2db31e6 commit 86949fc

File tree

11 files changed

+70
-37
lines changed

11 files changed

+70
-37
lines changed

eslint.config.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ export default stacks({
66
quotes: 'single', // or 'double'
77
},
88

9-
stacks: true,
10-
typescript: true,
11-
129
// Enable jsonc, yaml, toml support
1310
jsonc: true,
1411
yaml: false,

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@
113113
"storage/framework/core/*",
114114
"storage/framework/core/bun-create/*",
115115
"storage/framework/docs",
116+
"storage/framework/email",
116117
"storage/framework/libs/*",
117118
"storage/framework/views/*"
118119
]

storage/framework/core/email/src/email.ts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ export class Email {
1111
}
1212

1313
public async send() {
14-
try {
15-
log.info('Sending email...')
14+
log.info('Sending email...')
1615

16+
try {
1717
const template = await useCompiler(this.message.template)
1818
const params: SendEmailParams = {
1919
Source: this.message.from?.address || '',
@@ -39,7 +39,10 @@ export class Email {
3939

4040
await this.client.sendEmail(params)
4141

42-
const returnMsg = await this.message.handle()
42+
let returnMsg: { message: string } = { message: 'Email sent' }
43+
44+
if (this.message.handle)
45+
returnMsg = await this.message.handle()
4346

4447
await this.onSuccess()
4548

@@ -52,15 +55,22 @@ export class Email {
5255

5356
public async onError(error: Error) {
5457
log.error(error)
58+
59+
if (!this.message.onError)
60+
return
61+
5562
return await this.message.onError(error)
5663
}
5764

5865
public onSuccess() {
5966
try {
67+
if (!this.message.onSuccess)
68+
return
69+
6070
this.message.onSuccess()
6171
}
6272
catch (error) {
63-
return this.onError(error)
73+
return this.onError(error as Error)
6474
}
6575
}
6676
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import process from 'node:process'
2+
import { config } from '@vue-email/compiler'
3+
import { path } from '@stacksjs/path'
4+
import type { I18n } from 'vue-email'
5+
6+
interface RenderOptions {
7+
props?: Record<string, unknown>
8+
i18n?: I18n
9+
}
10+
11+
const email = config(path.resourcesPath('emails'), {
12+
verbose: !!process.env.DEBUG,
13+
// options: {
14+
// baseUrl: 'https://APP_URL/',
15+
// },
16+
})
17+
18+
export const template = async (path: string, options: RenderOptions) => await email.render(path, options)

storage/framework/core/path/src/index.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,7 @@ export function langPath(path?: string) {
259259

260260
export function layoutsPath(path?: string, options?: { relative?: boolean }) {
261261
const absolutePath = resourcesPath(`layouts/${path || ''}`)
262+
262263
if (options?.relative)
263264
return relative(process.cwd(), absolutePath)
264265

@@ -379,7 +380,12 @@ export function realtimePath(path?: string) {
379380
return corePath(`realtime/${path || ''}`)
380381
}
381382

382-
export function resourcesPath(path?: string) {
383+
export function resourcesPath(path?: string, options?: { relative?: boolean }) {
384+
const absolutePath = projectStoragePath(`resources/${path || ''}`)
385+
386+
if (options?.relative)
387+
return relative(process.cwd(), absolutePath)
388+
383389
return projectPath(`resources/${path || ''}`)
384390
}
385391

storage/framework/email/.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
.DS_Store
2+
.vite-ssg-dist
3+
.vite-ssg-temp
4+
*.local
5+
dist
6+
dist-ssr
7+
node_modules
8+
.idea/
9+
*.log
10+
cypress/downloads

storage/framework/email/.npmrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
shamefully-hoist=true
2+
strict-peer-dependencies=false

storage/framework/email/index.ts

Lines changed: 0 additions & 28 deletions
This file was deleted.

storage/framework/email/package.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"name": "stacks-email",
3+
"type": "module",
4+
"private": true,
5+
"scripts": {
6+
"build": "wip",
7+
"dev": "wip",
8+
"typecheck": "bunx --bun vue-tsc --noEmit",
9+
"sizecheck": "bunx vite-bundle-visualizer"
10+
},
11+
"dependencies": {
12+
"@stacksjs/path": "workspace:*",
13+
"@vue-email/compiler": "^0.8.13"
14+
}
15+
}

storage/framework/email/src/index.ts

Whitespace-only changes.

storage/framework/views/web/src/main.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { ViteSSG } from 'vite-ssg'
22
import { setupLayouts } from 'virtual:generated-layouts'
33
import { routes } from 'vue-router/auto/routes'
4+
import { resourcesPath } from '@stacksjs/path'
45
import App from './App.stx'
56
import type { UserModule } from './types'
67
import '@unocss/reset/tailwind.css'
@@ -19,8 +20,9 @@ export const createApp = ViteSSG(
1920
},
2021
(ctx) => {
2122
// install all modules under `modules/`
22-
Object.values(import.meta.glob<{ install: UserModule }>('../../../../../resources/modules/*.ts', { eager: true }))
23+
Object.values(import.meta.glob<{ install: UserModule }>(resourcesPath('modules/*.ts', { relative: true }), { eager: true }))
2324
.forEach(i => i.install?.(ctx))
25+
2426
// ctx.app.use(Previewer)
2527
},
2628
)

0 commit comments

Comments
 (0)