-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(app-builder): improve error handling
- Loading branch information
1 parent
340f12a
commit c5bd584
Showing
20 changed files
with
214 additions
and
125 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
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
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
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
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
35 changes: 35 additions & 0 deletions
35
apps/app-builder/src/utils/command/createCommandContext.ts
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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import type Liftoff from 'liftoff'; | ||
import {resolveConfig} from '../resolveConfig'; | ||
import {mergeDefaultConfig} from '../mergeDefaultConfig'; | ||
import { | ||
type AnyCommandArgs, | ||
type AnyCommandDefinition, | ||
type DefaultCommandArgs, | ||
type InputCommandArguments, | ||
type PdkBuilderCommand, | ||
type PdkBuilderContext, | ||
} from '../../types/command.types'; | ||
import {parseCommandInput} from './parseCommandInput'; | ||
|
||
type CommandContext<Args extends AnyCommandArgs = DefaultCommandArgs> = { | ||
command: PdkBuilderCommand<Args>; | ||
context: PdkBuilderContext<Args>; | ||
}; | ||
|
||
export const createCommandContext = async <Args extends AnyCommandArgs = DefaultCommandArgs>( | ||
definition: AnyCommandDefinition<Args>, | ||
args: InputCommandArguments<Args>, | ||
env: Liftoff.LiftoffEnv, | ||
): Promise<CommandContext<Args>> => { | ||
const {command, context} = await parseCommandInput(definition, args, env); | ||
|
||
const config = await resolveConfig(env, context.args); | ||
|
||
return { | ||
command, | ||
context: { | ||
...context, | ||
config: mergeDefaultConfig(config), | ||
}, | ||
}; | ||
}; |
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
Oops, something went wrong.