-
Notifications
You must be signed in to change notification settings - Fork 187
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(config): separate config from cli #600
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 was deleted.
Oops, something went wrong.
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,15 +1 @@ | ||
export { loadStoreConfig } from "./config/loadStoreConfig.js"; | ||
export { parseStoreConfig } from "./config/parseStoreConfig.js"; | ||
export { loadWorldConfig, resolveWorldConfig, parseWorldConfig } from "./config/world/index.js"; | ||
export { resolveTableId } from "./config/dynamicResolution.js"; | ||
|
||
export type { | ||
StoreUserConfig, | ||
StoreConfig, | ||
WorldUserConfig, | ||
ResolvedWorldConfig, | ||
MUDUserConfig, | ||
MUDConfig, | ||
} from "./config/index.js"; | ||
|
||
export { storeConfig, mudConfig } from "./config/index.js"; | ||
export {}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎉 |
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
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
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
packages/cli/src/config/dynamicResolution.ts → packages/config/src/dynamicResolution.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
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,25 @@ | ||
import chalk from "chalk"; | ||
import { z, ZodError, ZodIssueCode } from "zod"; | ||
import { fromZodError } from "zod-validation-error"; | ||
|
||
export class MUDError extends Error { | ||
name = "MUDError"; | ||
} | ||
|
||
// Wrapper with preset styles, only requires a `prefix` | ||
export function fromZodErrorCustom(error: ZodError, prefix: string) { | ||
return fromZodError(error, { | ||
prefix: chalk.red(prefix), | ||
prefixSeparator: "\n- ", | ||
issueSeparator: "\n- ", | ||
}); | ||
} | ||
|
||
export class NotInsideProjectError extends Error { | ||
name = "NotInsideProjectError"; | ||
message = "You are not inside a MUD project"; | ||
} | ||
|
||
export function UnrecognizedSystemErrorFactory(path: string[], systemName: string) { | ||
return new z.ZodError([{ code: ZodIssueCode.custom, path: path, message: `Unrecognized system: "${systemName}"` }]); | ||
} |
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,2 +1,25 @@ | ||
// TODO stub | ||
export {}; | ||
import { ExtractUserTypes, StringForUnion } from "./typeUtils.js"; | ||
import { StoreUserConfig, StoreConfig } from "./store/parseStoreConfig.js"; | ||
import { WorldUserConfig, ResolvedWorldConfig } from "./world/index.js"; | ||
|
||
export type MUDUserConfig< | ||
EnumNames extends StringForUnion = StringForUnion, | ||
StaticUserTypes extends ExtractUserTypes<EnumNames> = ExtractUserTypes<EnumNames> | ||
> = StoreUserConfig<EnumNames, StaticUserTypes> & WorldUserConfig; | ||
export type MUDConfig = StoreConfig & ResolvedWorldConfig; | ||
|
||
export function mudConfig< | ||
EnumNames extends StringForUnion = never, | ||
StaticUserTypes extends ExtractUserTypes<EnumNames> = ExtractUserTypes<EnumNames> | ||
>(config: MUDUserConfig<EnumNames, StaticUserTypes>) { | ||
return config; | ||
} | ||
|
||
export * from "./commonSchemas.js"; | ||
export * from "./loadConfig.js"; | ||
export * from "./store/loadStoreConfig.js"; | ||
export * from "./store/parseStoreConfig.js"; | ||
export * from "./world/index.js"; | ||
export * from "./validation.js"; | ||
export * from "./dynamicResolution.js"; | ||
export * from "./errors.js"; |
2 changes: 1 addition & 1 deletion
2
packages/cli/src/config/loadConfig.ts → packages/config/src/loadConfig.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
4 changes: 2 additions & 2 deletions
4
packages/cli/src/config/loadStoreConfig.ts → packages/config/src/store/loadStoreConfig.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
File renamed without changes.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
initially wanted to put
MUDError
intoutils
package, but importing it doesn't work yet so left this for another PR