Skip to content

Commit 73e5331

Browse files
committed
chore: wip
1 parent 8485b3c commit 73e5331

File tree

16 files changed

+95
-104
lines changed

16 files changed

+95
-104
lines changed

.stacks/auto-imports.d.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -234,9 +234,7 @@ declare global {
234234
const ensurePrefix: typeof import('./core/strings/src/utils')['ensurePrefix']
235235
const ensureSuffix: typeof import('./core/strings/src/utils')['ensureSuffix']
236236
const env: typeof import('./core/validation/src/types/env')['env']
237-
const envPrefix: typeof import('./core/validation/src/types/env')['envPrefix']
238237
const envSchema: typeof import('./core/validation/src/types/env')['envSchema']
239-
const envv: typeof import('./core/validation/src/types/env')['envv']
240238
const equal: typeof import('./core/utils/src/currency')['equal']
241239
const err: typeof import('./core/error-handling/src/index')['err']
242240
const errAsync: typeof import('./core/error-handling/src/index')['errAsync']
@@ -1083,7 +1081,6 @@ declare module 'vue' {
10831081
readonly ensurePrefix: UnwrapRef<typeof import('./core/strings/src/utils')['ensurePrefix']>
10841082
readonly ensureSuffix: UnwrapRef<typeof import('./core/strings/src/utils')['ensureSuffix']>
10851083
readonly env: UnwrapRef<typeof import('./core/validation/src/types/env')['env']>
1086-
readonly envPrefix: UnwrapRef<typeof import('./core/validation/src/types/env')['envPrefix']>
10871084
readonly envSchema: UnwrapRef<typeof import('./core/validation/src/types/env')['envSchema']>
10881085
readonly equal: UnwrapRef<typeof import('./core/utils/src/currency')['equal']>
10891086
readonly err: UnwrapRef<typeof import('./core/error-handling/src/index')['err']>
@@ -1920,7 +1917,6 @@ declare module '@vue/runtime-core' {
19201917
readonly ensurePrefix: UnwrapRef<typeof import('./core/strings/src/utils')['ensurePrefix']>
19211918
readonly ensureSuffix: UnwrapRef<typeof import('./core/strings/src/utils')['ensureSuffix']>
19221919
readonly env: UnwrapRef<typeof import('./core/validation/src/types/env')['env']>
1923-
readonly envPrefix: UnwrapRef<typeof import('./core/validation/src/types/env')['envPrefix']>
19241920
readonly envSchema: UnwrapRef<typeof import('./core/validation/src/types/env')['envSchema']>
19251921
readonly equal: UnwrapRef<typeof import('./core/utils/src/currency')['equal']>
19261922
readonly err: UnwrapRef<typeof import('./core/error-handling/src/index')['err']>

.stacks/core/buddy/src/cli.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ async function main() {
2222

2323
// before running any commands, check if the project is already initialized
2424
if (!await isProjectCreated()) {
25-
if (env().APP_ENV !== 'production')
25+
if (env.APP_ENV !== 'production')
2626
log.info('Project not yet initialized, generating application key...')
2727
else
2828
handleError(new Error('Please run `buddy key:generate` to generate an application key'))

.stacks/core/build/src/desktop.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export default defineConfig({
2424
port: 3333,
2525
strictPort: true,
2626
},
27-
envPrefix: ['VITE_', 'TAURI_'],
27+
envPrefix: [''],
2828
plugins: [
2929

3030
Vue({

.stacks/core/build/src/functions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { alias } from '@stacksjs/alias'
1010
export const functionsConfig: ViteConfig = {
1111
root: functionsPath(),
1212
envDir: projectPath(),
13-
envPrefix: 'APP_',
13+
envPrefix: '',
1414

1515
resolve: {
1616
alias,

.stacks/core/build/src/vue-components.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,10 @@ import mkcert from 'vite-plugin-mkcert'
88
import c from 'picocolors'
99
import { autoImports, components, cssEngine, inspect, uiEngine } from './stacks'
1010

11-
export const envPrefix: string | string[] = ['FRONTEND_', 'APP_', 'DB_', 'REDIS_', 'AWS_', 'MAIL_', 'SEARCH_ENGINE_', 'MEILISEARCH_']
12-
1311
export const vueComponentsConfig: ViteConfig = {
1412
root: frameworkPath('libs/components/vue'),
1513
envDir: projectPath(),
16-
envPrefix,
14+
envPrefix: 'FRONTEND_',
1715

1816
server: {
1917
https: true,
@@ -128,7 +126,7 @@ export function vueComponentsBuildOptions(): ViteBuildOptions {
128126
}
129127

130128
export default defineConfig(({ command, mode }) => {
131-
process.env = { ...process.env, ...loadEnv(mode, projectPath(), envPrefix) }
129+
process.env = { ...process.env, ...loadEnv(mode, projectPath(), '') }
132130

133131
if (command === 'serve')
134132
return vueComponentsConfig

.stacks/core/database/src/migrations/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// function generatePrismaSchema(models: Model[], path: string, options: SchemaOptions): void {
99
// let schema = `datasource db {
1010
// provider = "${options.database}"
11-
// url = env().DATABASE_URL
11+
// url = env.DATABASE_URL
1212
// }
1313

1414
// generator client {

.stacks/core/email/src/drivers/ses.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
// const env = notification.email.ses
88

99
// const provider = new SESEmailProvider({
10-
// region: env().region,
11-
// accessKeyId: env().key,
12-
// secretAccessKey: env().secret,
13-
// from: env().from,
10+
// region: env.region,
11+
// accessKeyId: env.key,
12+
// secretAccessKey: env.secret,
13+
// from: env.from,
1414
// })
1515

1616
// async function send(options: EmailOptions, css?: string): Promise<ResultAsync<any, Error>> {

.stacks/core/notifications/tests/email/Sendgrid.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
// it('should send email', async () => {
77
// const notification = email.sendgrid
88
// const test = await notification.send({
9-
// from: env().email.sendgrid.from,
9+
// from: env.email.sendgrid.from,
1010
// to: 'chris@stacksjs.dev',
1111
// subject: 'Test Email',
1212
// html: '<p> Test Email using SG!</p>',
@@ -18,7 +18,7 @@
1818
// it('should send email using useEmail', async () => {
1919
// const notification = useEmail('sendgrid')
2020
// const test = await notification.send({
21-
// from: env().email.sendgrid.from,
21+
// from: env.email.sendgrid.from,
2222
// to: 'chris@stacksjs.dev',
2323
// subject: 'Test Email',
2424
// html: '<p> Test Email using SG!</p>',
@@ -30,7 +30,7 @@
3030
// it('should not send email when receiver is empty', async () => {
3131
// const notification = email.sendgrid
3232
// const test = await notification.send({
33-
// from: env().email.sendgrid.from,
33+
// from: env.email.sendgrid.from,
3434
// to: '',
3535
// subject: 'Test Email',
3636
// html: '<p> Test Email using SG!</p>',

.stacks/core/security/src/crypt.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import utf8 from 'crypto-js/enc-utf8'
33
import { env } from '@stacksjs/validation'
44

55
function encrypt(message: string): string {
6-
const passphrase = env().APP_KEY
6+
const passphrase = env.APP_KEY
77

88
if (!passphrase)
99
throw new Error('APP_KEY is not defined')
@@ -12,7 +12,7 @@ function encrypt(message: string): string {
1212
}
1313

1414
function decrypt(encrypted: string): string {
15-
const passphrase = env().APP_KEY
15+
const passphrase = env.APP_KEY
1616

1717
if (!passphrase)
1818
throw new Error('APP_KEY is not defined')

.stacks/core/validation/src/types/env.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ import type { Infer } from '@vinejs/vine/build/src/types'
44
import { loadEnv } from 'vite'
55
import { projectPath } from '@stacksjs/path'
66

7-
export const envPrefix: string | string[] = ['FRONTEND_', 'APP_', 'DB_', 'REDIS_', 'AWS_', 'MAIL_', 'SEARCH_ENGINE_', 'MEILISEARCH_']
8-
97
// TODO: envSchema needs to be auto generated from the .env file
108
// envSchema could also be named "backendEnvSchema"
119
export const envSchema = validator.object({
@@ -134,23 +132,22 @@ export type FrontendEnvKeys = keyof FrontendEnv
134132
export type Env = Infer<typeof envSchema>
135133
export type EnvKeys = keyof Env
136134

137-
export const env = async () => await getEnv()
135+
export const env = process.env as Env
138136
export async function getEnv() {
139137
try {
140138
const mode = process.env.NODE_ENV ?? 'development'
141-
const data = loadEnv(mode, projectPath(), envPrefix)
139+
const data = loadEnv(mode, projectPath(), '')
142140
const v = validator.compile(envSchema)
143141

144142
return v.validate(data)
145143
}
146144
catch (error: any) {
147145
handleError(error)
148-
throw new Error(error)
149146
}
150147
}
151148

152149
// export async function getEnvIssues(env?: any): void {
153-
// const result = await getEnv()
150+
// const result = await getenv
154151
//
155152
// if (!result.success) {
156153
// const message = result.error.message

0 commit comments

Comments
 (0)