Skip to content

Commit

Permalink
refactor: move old config imports to new path (#2448)
Browse files Browse the repository at this point in the history
  • Loading branch information
holic authored Mar 15, 2024
1 parent 694568b commit 93a654b
Show file tree
Hide file tree
Showing 18 changed files with 20 additions and 24 deletions.
2 changes: 1 addition & 1 deletion examples/minimal/packages/contracts/mud.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { mudConfig } from "@latticexyz/world/register";

import { resolveTableId } from "@latticexyz/config";
import { resolveTableId } from "@latticexyz/config/library";

export default mudConfig({
systems: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { extendMUDCoreConfig, fromZodErrorCustom } from "@latticexyz/config";
import { extendMUDCoreConfig, fromZodErrorCustom } from "@latticexyz/config/library";
import { ZodError } from "zod";
import { zMyPluginConfig } from "../library";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { OrDefaults } from "@latticexyz/common/type-utils";
import { MUDCoreUserConfig } from "@latticexyz/config";
import { MUDCoreUserConfig } from "@latticexyz/config/library";
import { DEFAULTS, MyPluginUserConfig, MyPluginConfig } from "../library";

import "@latticexyz/world/register";

// Inject the plugin options into the core config.
// Re-exporting an interface of an existing module merges them, adding new options to the interface.
// (typescript has no way to override types)
declare module "@latticexyz/config" {
declare module "@latticexyz/config/library" {
// Extend the user config type, which represents the config as written by the users.
// Most things are optional here.
// eslint-disable-next-line @typescript-eslint/no-empty-interface
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/deploy/resolveConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import path from "path";
import { resolveWorldConfig } from "@latticexyz/world";
import { Config, ConfigInput, Library, Module, System, WorldFunction } from "./common";
import { resourceToHex } from "@latticexyz/common";
import { resolveWithContext } from "@latticexyz/config";
import { resolveWithContext } from "@latticexyz/config/library";
import { encodeField } from "@latticexyz/protocol-parser";
import { SchemaAbiType, SchemaAbiTypeToPrimitiveType } from "@latticexyz/schema-type";
import { Hex, hexToBytes, bytesToHex, toFunctionSelector, toFunctionSignature } from "viem";
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/utils/errors.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import chalk from "chalk";
import { ZodError } from "zod";
import { fromZodError, ValidationError } from "zod-validation-error";
import { NotInsideProjectError } from "@latticexyz/config";
import { NotInsideProjectError } from "@latticexyz/config/library";
import { MUDError } from "@latticexyz/common/errors";

export function logError(error: unknown) {
Expand Down
4 changes: 0 additions & 4 deletions packages/config/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
export * from "./common";

// exported for backwards compatibility
// TODO: migrate these imports to `@latticexyz/config/library` or remove usages
export * from "./deprecated/library";
2 changes: 1 addition & 1 deletion packages/store/ts/codegen/userType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
SchemaType,
SchemaTypeToAbiType,
} from "@latticexyz/schema-type/deprecated";
import { parseStaticArray } from "@latticexyz/config";
import { parseStaticArray } from "@latticexyz/config/library";
import { ImportDatum, RenderType, SolidityUserDefinedType } from "@latticexyz/common/codegen";
import { StoreConfig } from "../config";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { describe, expect, it } from "vitest";
import { mudConfig } from "../../register/mudConfig";
import { resolveConfig } from "./resolveConfig";
import { MUDCoreContext } from "@latticexyz/config";
import { MUDCoreContext } from "@latticexyz/config/library";
import { resourceToHex } from "@latticexyz/common";
MUDCoreContext.createContext();

Expand Down
2 changes: 1 addition & 1 deletion packages/store/ts/config/storeConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
zValueName,
zNamespace,
zName,
} from "@latticexyz/config";
} from "@latticexyz/config/library";
import { DEFAULTS, PATH_DEFAULTS, TABLE_DEFAULTS } from "./defaults";
import { UserType } from "@latticexyz/common/codegen";
import { SchemaAbiType, isSchemaAbiType, schemaAbiTypes } from "@latticexyz/schema-type";
Expand Down
2 changes: 1 addition & 1 deletion packages/store/ts/register/configExtensions.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { extendMUDCoreConfig, fromZodErrorCustom } from "@latticexyz/config";
import { extendMUDCoreConfig, fromZodErrorCustom } from "@latticexyz/config/library";
import { ZodError } from "zod";
import { zPluginStoreConfig } from "../config";

Expand Down
2 changes: 1 addition & 1 deletion packages/store/ts/register/mudConfig.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { mudCoreConfig, MUDCoreUserConfig } from "@latticexyz/config";
import { mudCoreConfig, MUDCoreUserConfig } from "@latticexyz/config/library";
import { ExtractUserTypes, StringForUnion } from "@latticexyz/common/type-utils";
import { MUDUserConfig } from "..";
import { ExpandMUDUserConfig } from "./typeExtensions";
Expand Down
4 changes: 2 additions & 2 deletions packages/store/ts/register/typeExtensions.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { OrDefaults } from "@latticexyz/common/type-utils";
import { MUDCoreUserConfig } from "@latticexyz/config";
import { MUDCoreUserConfig } from "@latticexyz/config/library";
import { ExpandTablesConfig, StoreConfig, StoreUserConfig } from "../config";
import { DEFAULTS, PATH_DEFAULTS } from "../config/defaults";

// Inject non-generic options into the core config.
// Re-exporting an interface of an existing module merges them, adding new options to the interface.
// (typescript has no way to override types)
declare module "@latticexyz/config" {
declare module "@latticexyz/config/library" {
// Extend the user config type, which represents the config as written by the users.
// Most things are optional here.
// eslint-disable-next-line @typescript-eslint/no-empty-interface
Expand Down
2 changes: 1 addition & 1 deletion packages/world/ts/config/resolveWorldConfig.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { UnrecognizedSystemErrorFactory } from "@latticexyz/config";
import { UnrecognizedSystemErrorFactory } from "@latticexyz/config/library";
import { StoreConfig } from "@latticexyz/store";
import { SystemConfig, WorldConfig } from "./types";

Expand Down
2 changes: 1 addition & 1 deletion packages/world/ts/config/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { z } from "zod";
import { DynamicResolution, ValueWithType } from "@latticexyz/config";
import { DynamicResolution, ValueWithType } from "@latticexyz/config/library";
import { OrDefaults } from "@latticexyz/common/type-utils";
import { zWorldConfig } from "./worldConfig";
import { SYSTEM_DEFAULTS } from "./defaults";
Expand Down
2 changes: 1 addition & 1 deletion packages/world/ts/config/worldConfig.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { z } from "zod";
import { DynamicResolutionType, zEthereumAddress, zName, zObjectName } from "@latticexyz/config";
import { DynamicResolutionType, zEthereumAddress, zName, zObjectName } from "@latticexyz/config/library";
import { SYSTEM_DEFAULTS, WORLD_DEFAULTS } from "./defaults";

const zSystemName = zObjectName;
Expand Down
2 changes: 1 addition & 1 deletion packages/world/ts/register/configExtensions.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { extendMUDCoreConfig, fromZodErrorCustom } from "@latticexyz/config";
import { extendMUDCoreConfig, fromZodErrorCustom } from "@latticexyz/config/library";
import { ZodError } from "zod";
import { zPluginWorldConfig } from "../config/worldConfig";

Expand Down
4 changes: 2 additions & 2 deletions packages/world/ts/register/typeExtensions.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { OrDefaults } from "@latticexyz/common/type-utils";
import { MUDCoreUserConfig } from "@latticexyz/config";
import { MUDCoreUserConfig } from "@latticexyz/config/library";

import "@latticexyz/store/register";
import { WORLD_DEFAULTS } from "../config/defaults";
Expand All @@ -8,7 +8,7 @@ import { WorldUserConfig, WorldConfig, ExpandSystemsConfig } from "../config/typ
// Inject the plugin options into the core config.
// Re-exporting an interface of an existing module merges them, adding new options to the interface.
// (typescript has no way to override types)
declare module "@latticexyz/config" {
declare module "@latticexyz/config/library" {
// Extend the user config type, which represents the config as written by the users.
// Most things are optional here.
// eslint-disable-next-line @typescript-eslint/no-empty-interface
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { type Hex } from "viem";

import { type ExpandMUDUserConfig } from "@latticexyz/store/register";
import { type MUDCoreUserConfig } from "@latticexyz/config";
import { type MUDCoreUserConfig } from "@latticexyz/config/library";

import { resourceToHex } from "@latticexyz/common";

Expand Down

0 comments on commit 93a654b

Please sign in to comment.