Skip to content

Commit fbafee6

Browse files
committed
chore: wip
1 parent eaab705 commit fbafee6

File tree

4 files changed

+9
-45
lines changed

4 files changed

+9
-45
lines changed
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { runCommand } from '@stacksjs/cli'
22
import { projectPath } from '@stacksjs/path'
33
import { generateAppKey } from '@stacksjs/security'
4-
import { isFile } from '@stacksjs/storage'
4+
import { fs } from '@stacksjs/storage'
55
import { setEnvValue } from '@stacksjs/utils'
66

7-
if (!isFile('.env'))
7+
if (!(await fs.exists('.env')))
88
await runCommand('cp .env.example .env', { cwd: projectPath() })
99

1010
await setEnvValue('APP_KEY', generateAppKey())

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

Lines changed: 5 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1423,7 +1423,7 @@ export async function generateModelString(
14231423
static async remove(id: number): Promise<void> {
14241424
const instance = new ${modelName}Model(null)
14251425
${mittDeleteFindStatement}
1426-
1426+
14271427
if (instance.softDeletes) {
14281428
await db.updateTable('${tableName}')
14291429
.set({
@@ -1825,48 +1825,15 @@ export async function generateModelFiles(modelStringFile?: string): Promise<void
18251825

18261826
log.info('Ensuring Code Style...')
18271827
try {
1828-
// we run this in background in background, because we simply need to lint:fix the auto-generated code
1829-
// the reason we run it in background is because we don't care whether it fails or not, given there
1830-
// is a chance that the codebase has lint issues unrelating to our auto-generated code
1831-
const process = Bun.spawn(['bunx', '--bun', 'eslint', '.', '--fix'], {
1832-
stdio: ['ignore', 'pipe', 'pipe'],
1828+
Bun.spawn(['bunx', '--bun', 'eslint', '.', '--fix'], {
1829+
stdio: ['ignore', 'ignore', 'ignore'],
18331830
cwd: path.projectPath(),
18341831
detached: true,
18351832
})
1836-
1837-
const reader = process.stdout.getReader()
1838-
// let output = ''
1839-
1840-
while (true) {
1841-
const { done } = await reader.read()
1842-
if (done)
1843-
break
1844-
// output += new TextDecoder().decode(value)
1845-
}
1846-
1847-
const stderrReader = process.stderr.getReader()
1848-
while (true) {
1849-
const { done } = await stderrReader.read()
1850-
if (done)
1851-
break
1852-
// Collect stderr output but do not log it
1853-
// output += new TextDecoder().decode(value)
1854-
}
1855-
1856-
const exitCode = await process.exited
1857-
1858-
if (exitCode !== 0) {
1859-
log.debug(
1860-
'There was an error fixing your code style but we are ignoring it because we fixed the auto-generated code already.',
1861-
)
1862-
}
1863-
else {
1864-
log.success('Code style fixed successfully.')
1865-
}
1833+
log.success('Code style fixing started in background.')
18661834
}
18671835
catch (error) {
1868-
handleError('There was an error fixing your code style.', error)
1869-
process.exit(ExitCode.FatalError)
1836+
handleError('There was an error starting the code style fixing process.', error)
18701837
}
18711838

18721839
log.success('Linted')

storage/framework/core/storage/src/delete.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import type { Result } from '@stacksjs/error-handling'
22
import { italic, log } from '@stacksjs/cli'
33
import { err, handleError, ok } from '@stacksjs/error-handling'
44
import { join } from '@stacksjs/path'
5-
import { isFile } from './files'
65
import { isFolder } from './folders'
76
import { fs } from './fs'
87
import { glob } from './glob'
@@ -85,7 +84,7 @@ export async function deleteEmptyFolders(dir: string): Promise<Result<string, Er
8584
export function deleteFile(path: string): Promise<Result<string, Error>> {
8685
return new Promise((resolve, reject) => {
8786
try {
88-
if (isFile(path)) {
87+
if (fs.statSync(path).isFile()) {
8988
fs.rmSync(path, { recursive: true, force: true })
9089
return resolve(ok(`Deleted ${path}`))
9190
}
@@ -118,7 +117,7 @@ export async function deleteGlob(path: string): Promise<Result<string, Error>> {
118117
}
119118

120119
export async function del(path: string): Promise<Result<string, Error>> {
121-
if (isFile(path))
120+
if (fs.existsSync(path) && fs.statSync(path).isFile())
122121
return await deleteFile(path)
123122

124123
if (isFolder(path))

storage/framework/core/storage/src/files.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,6 @@ export interface Files {
174174
readTextFile: typeof readTextFile
175175
writeJsonFile: typeof writeJsonFile
176176
writeTextFile: typeof writeTextFile
177-
isFile: typeof isFile
178177
hasFiles: typeof hasFiles
179178
hasComponents: typeof hasComponents
180179
hasFunctions: typeof hasFunctions
@@ -190,7 +189,6 @@ export const files: Files = {
190189
readTextFile,
191190
writeJsonFile,
192191
writeTextFile,
193-
isFile,
194192
hasFiles,
195193
hasComponents,
196194
hasFunctions,

0 commit comments

Comments
 (0)