-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(devbox): Refactor schema and improve logging (#33978)
Co-authored-by: Will Brennan <will.brennan@cultureamp.com> Co-authored-by: Will Brennan <will@moondev.co.uk> Co-authored-by: Michael Kriese <michael.kriese@gmx.de> Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
- Loading branch information
1 parent
0300c4e
commit 19ae54f
Showing
4 changed files
with
117 additions
and
221 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,17 @@ | ||
import { logger } from '../../../logger'; | ||
import { logger, withMeta } from '../../../logger'; | ||
import type { PackageFileContent } from '../types'; | ||
import { DevboxFileSchema } from './schema'; | ||
import { DevboxSchema } from './schema'; | ||
|
||
export function extractPackageFile( | ||
content: string, | ||
packageFile: string, | ||
): PackageFileContent | null { | ||
logger.trace('devbox.extractPackageFile()'); | ||
|
||
const parsedFile = DevboxFileSchema.safeParse(content); | ||
if (parsedFile.error) { | ||
logger.debug( | ||
{ packageFile, error: parsedFile.error }, | ||
'Error parsing devbox.json', | ||
); | ||
const deps = withMeta({ packageFile }, () => DevboxSchema.parse(content)); | ||
if (!deps.length) { | ||
return null; | ||
} | ||
|
||
const deps = parsedFile.data.packages; | ||
|
||
if (deps.length) { | ||
return { deps }; | ||
} | ||
|
||
return null; | ||
return { deps }; | ||
} |
Oops, something went wrong.