-
Notifications
You must be signed in to change notification settings - Fork 197
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(config): separate config from cli (#600)
* feat(config): separate config from cli * fix(std-client): fix config import
- Loading branch information
Showing
47 changed files
with
186 additions
and
150 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 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 {}; |
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.