Skip to content

Commit f3c035b

Browse files
committed
chore: wip
1 parent 578995e commit f3c035b

File tree

16 files changed

+35
-20
lines changed

16 files changed

+35
-20
lines changed

storage/framework/core/database/src/drivers/mysql.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ async function createTableMigration(modelPath: string): Promise<void> {
205205
const migrationFileName = `${timestamp}-create-${tableName}-table.ts`
206206
const migrationFilePath = path.userMigrationsPath(migrationFileName)
207207

208+
// eslint-disable-next-line no-console
208209
console.log(migrationFilePath)
209210

210211
Bun.write(migrationFilePath, migrationContent)
@@ -280,8 +281,6 @@ async function createPivotTableMigration(model: Model, modelPath: string): Promi
280281
}
281282

282283
export async function createAlterTableMigration(modelPath: string): Promise<void> {
283-
console.log('createAlterTableMigration')
284-
285284
const model = (await import(modelPath)).default as Model
286285
const modelName = getModelName(model, modelPath)
287286
const tableName = getTableName(model, modelPath)

storage/framework/core/database/src/drivers/postgres.ts

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export async function resetPostgresDatabase() {
6161
return ok('All tables dropped successfully!')
6262
}
6363

64-
export async function generatePostgresMigration(modelPath: string) {
64+
export async function generatePostgresMigration(modelPath: string): Promise<void> {
6565
// check if any files are in the database folder
6666
const files = await fs.readdir(path.userMigrationsPath())
6767

@@ -228,22 +228,17 @@ async function createPivotTableMigration(model: Model, modelPath: string) {
228228
}
229229

230230
async function createAlterTableMigration(modelPath: string) {
231-
console.log('createAlterTableMigration')
232-
233231
const model = (await import(modelPath)).default as Model
234232
const modelName = path.basename(modelPath)
235-
const tableName = await getTableName(model, modelPath)
233+
const tableName = getTableName(model, modelPath)
236234

237235
// Assuming you have a function to get the fields from the last migration
238236
// For simplicity, this is not implemented here
239237
const lastMigrationFields = await getLastMigrationFields(modelName)
240238
const lastFields = lastMigrationFields ?? {}
241239
const currentFields = model.attributes as Attributes
242-
243240
const changes = pluckChanges(Object.keys(lastFields), Object.keys(currentFields))
244-
245241
const fieldsToAdd = changes?.added || []
246-
247242
const fieldsToRemove = changes?.removed || []
248243

249244
let migrationContent = `import type { Database } from '@stacksjs/database'\n`
@@ -280,8 +275,7 @@ export async function fetchPostgresTables(): Promise<string[]> {
280275

281276
for (const modelPath of modelFiles) {
282277
const model = (await import(modelPath)).default
283-
284-
const tableName = await getTableName(model, modelPath)
278+
const tableName = getTableName(model, modelPath)
285279

286280
tables.push(tableName)
287281
}

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,13 @@ export const frameworkDefaults: VitePressConfig = {
4040
// const base = server.config.base || '/'
4141
// const _print = server.printUrls
4242
server.printUrls = () => {
43+
// eslint-disable-next-line no-console
4344
console.log(` ${c.blue(c.bold('STACKS'))} ${c.blue(version)}`)
4445

4546
// console.log(` ${c.green('➜')} ${c.bold('Docs')}: ${c.green('http://stacks.localhost:3000/docs')}`)
47+
// eslint-disable-next-line no-console
4648
console.log(` ${c.green('➜')} ${c.bold('Docs')}: ${c.green('https://stacks.localhost/docs')}`)
49+
// eslint-disable-next-line no-console
4750
console.log(` ${c.green('➜')} ${c.bold('Temp URL')}: ${c.green('http://stacksjs.test:3000')}`)
4851
}
4952
},

storage/framework/core/ecommerce/src/receipts/printer.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,19 @@ interface Receipt {
1616

1717
class TSPIVPrinter implements PrinterDriver {
1818
async print(receipt: Receipt): Promise<void> {
19+
// eslint-disable-next-line no-console
1920
console.log('TSP IV Printer: Printing receipt', receipt)
2021
// Implement actual printing logic here
2122
}
2223

2324
async cleanUp(): Promise<void> {
25+
// eslint-disable-next-line no-console
2426
console.log('TSP IV Printer: Cleaning up print job...')
2527
// Implement actual cleanup logic here
2628
}
2729

2830
async checkStatus(): Promise<boolean> {
31+
// eslint-disable-next-line no-console
2932
console.log('TSP IV Printer: Checking online status...')
3033
// Implement actual status check logic here
3134
return true // Return actual status

storage/framework/core/error-handling/src/handler.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { ErrorOptions } from '@stacksjs/logging'
22
import { access, appendFile, mkdir } from 'node:fs/promises'
33
import { dirname } from 'node:path'
4+
import process from 'node:process'
45
import { italic, stripAnsi } from '@stacksjs/cli'
56
import { config } from '@stacksjs/config'
67
import * as path from '@stacksjs/path'
@@ -18,7 +19,6 @@ export class ErrorHandler {
1819
if (options?.silent !== true)
1920
this.writeErrorToConsole(err)
2021

21-
let error: Error
2222
let errorMessage: string
2323

2424
if (options?.message) {
@@ -36,7 +36,7 @@ export class ErrorHandler {
3636
}
3737

3838
// Create a new Error with the determined message
39-
error = new Error(errorMessage)
39+
const error = new Error(errorMessage)
4040

4141
// If the original err was an Error instance, copy its properties
4242
if (err instanceof Error) {
@@ -82,9 +82,11 @@ export class ErrorHandler {
8282
|| errorString === `Failed to execute command: ${italic('bun storage/framework/core/actions/src/lint/fix.ts')}`
8383
) {
8484
if (!this.isTestEnvironment) {
85+
// eslint-disable-next-line no-console
8586
console.log(
8687
'No need to worry. The edge function is currently being destroyed. Please run `buddy undeploy` shortly again, and continue doing so until it succeeds running.',
8788
)
89+
// eslint-disable-next-line no-console
8890
console.log('Hoping to see you back soon!')
8991
}
9092
}
@@ -132,6 +134,7 @@ export async function writeToLogFile(message: string, options?: WriteOptions): P
132134
}
133135
catch {
134136
// File doesn't exist, create the directory
137+
// eslint-disable-next-line no-console
135138
console.log('Creating log file directory...', logFile)
136139
await mkdir(dirname(logFile), { recursive: true })
137140
}

storage/framework/core/error-handling/tests/error-handling.test.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { afterAll, beforeAll, describe, expect, it, mock, spyOn } from 'bun:test'
21
import { italic } from '@stacksjs/cli'
2+
import { afterAll, beforeAll, describe, expect, it, mock, spyOn } from 'bun:test'
33
import fs from 'fs-extra'
44
import { ErrorHandler, handleError } from '../src/handler'
55
import { rescue } from '../src/utils'
@@ -13,7 +13,9 @@ describe('@stacksjs/error-handling', () => {
1313
originalConsoleError = console.error
1414
console.error = () => {} // No-op function
1515

16+
// eslint-disable-next-line no-console
1617
originalConsoleLog = console.log
18+
// eslint-disable-next-line no-console
1719
console.log = () => {} // No-op function
1820

1921
originalProcessExit = process.exit
@@ -27,6 +29,7 @@ describe('@stacksjs/error-handling', () => {
2729

2830
afterAll(() => {
2931
console.error = originalConsoleError
32+
// eslint-disable-next-line no-console
3033
console.log = originalConsoleLog
3134
process.exit = originalProcessExit
3235
ErrorHandler.isTestEnvironment = false

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export function logLevel(): number {
1616
*
1717
* .trim() is used on options to ensure any trailing spaces in the entire options string do not affect the regex match.
1818
*/
19-
const verboseRegex = /--verbose(?!(\s*=\s*false|\s+false))(\s+|=true)?($|\s)/
19+
const verboseRegex = /--verbose(?!\s*=\s*false|\s+false)(?:\s+|=true)?(?:$|\s)/
2020
const opts = buddyOptions()
2121

2222
if (verboseRegex.test(opts))

storage/framework/core/orm/src/utils.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import type {
66
ModelElement,
77
RelationConfig,
88
} from '@stacksjs/types'
9+
import process from 'node:process'
910
import { generator, parser, traverse } from '@stacksjs/build'
1011
import { italic, log } from '@stacksjs/cli'
1112
import { path } from '@stacksjs/path'

storage/framework/core/router/src/server.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type { Model, Route, RouteParam, StatusCode } from '@stacksjs/types'
22
import process from 'node:process'
3+
import { handleError } from '@stacksjs/error-handling'
34
import { log } from '@stacksjs/logging'
45
import { getModelName } from '@stacksjs/orm'
56
import { extname, path } from '@stacksjs/path'
@@ -191,6 +192,7 @@ async function execute(foundRoute: Route, req: Request, { statusCode }: Options)
191192
})
192193
}
193194
catch (error) {
195+
handleError('Error reading the HTML file', error)
194196
return new Response('Error reading the HTML file', {
195197
status: 500,
196198
headers: {
@@ -420,6 +422,7 @@ function isObjectNotEmpty(obj: object): boolean {
420422
return Object.keys(obj).length > 0
421423
}
422424

425+
// eslint-disable-next-line ts/no-unsafe-function-type
423426
function isFunction(val: unknown): val is Function {
424427
return typeof val === 'function'
425428
}

storage/framework/core/router/src/utils.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { route } from './router'
77
export async function listRoutes(): Promise<Ok<string, any>> {
88
const routeLists = await route.getRoutes()
99

10+
// eslint-disable-next-line no-console
1011
console.table(routeLists)
1112

1213
return ok('Successfully listed routes!')
@@ -60,7 +61,7 @@ export function extractDynamicAction(action: string): string | undefined {
6061
return match ? match[1] : ''
6162
}
6263

63-
export async function extractModelRequest(action: string) {
64+
export async function extractModelRequest(action: string): Promise<Request | null> {
6465
const extractedModel = extractModelFromAction(action)
6566
const lowerCaseModel = camelCase(extractedModel)
6667
const requestPath = path.frameworkPath(`requests/${extractedModel}Request.ts`)
@@ -94,7 +95,7 @@ export async function findRequestInstance(requestInstance: string): Promise<Requ
9495
return null
9596
}
9697

97-
export async function extractDefaultRequest(action: string) {
98+
export async function extractDefaultRequest(action: string): Promise<Request> {
9899
const requestPath = path.frameworkPath(`core/router/src/request.ts`)
99100
const requestInstance = await import(requestPath)
100101

0 commit comments

Comments
 (0)