From 78f48c0ae2102979fb6faaaef67848c10dc68dd6 Mon Sep 17 00:00:00 2001 From: Kevin Ingersoll Date: Thu, 4 Jul 2024 11:28:08 +0100 Subject: [PATCH] configPath -> rootDir --- packages/cli/src/build.ts | 2 +- packages/world/ts/node/findSolidityFiles.ts | 4 ++-- packages/world/ts/node/generateSystemManifest.ts | 8 ++++---- packages/world/ts/node/getSystemContracts.ts | 6 +++--- packages/world/ts/scripts/build.ts | 5 +++-- 5 files changed, 13 insertions(+), 12 deletions(-) diff --git a/packages/cli/src/build.ts b/packages/cli/src/build.ts index 50a4fb2a84..a3ee144fc4 100644 --- a/packages/cli/src/build.ts +++ b/packages/cli/src/build.ts @@ -30,7 +30,7 @@ export async function build({ await Promise.all([ tablegen({ configPath, config, remappings }), worldgen(config, getExistingContracts(srcDir), outPath), - generateSystemManifest({ configPath, config }), + generateSystemManifest({ rootDir: path.dirname(configPath), config }), ]); await forge(["build"], { profile: foundryProfile }); diff --git a/packages/world/ts/node/findSolidityFiles.ts b/packages/world/ts/node/findSolidityFiles.ts index 591d1fcb2b..6e61125fbd 100644 --- a/packages/world/ts/node/findSolidityFiles.ts +++ b/packages/world/ts/node/findSolidityFiles.ts @@ -2,9 +2,9 @@ import path from "node:path"; import { glob } from "glob"; import { World } from "../config/v2/output"; -export async function findSolidityFiles({ configPath, config }: { configPath: string; config: World }) { +export async function findSolidityFiles({ rootDir, config }: { rootDir: string; config: World }) { const files = await glob(path.join(config.sourceDirectory, "**", "*.sol"), { - cwd: path.dirname(configPath), + cwd: rootDir, }); return files.sort().map((filename) => ({ diff --git a/packages/world/ts/node/generateSystemManifest.ts b/packages/world/ts/node/generateSystemManifest.ts index eb6d6bee1b..9222439367 100644 --- a/packages/world/ts/node/generateSystemManifest.ts +++ b/packages/world/ts/node/generateSystemManifest.ts @@ -5,16 +5,16 @@ import { getSystemContracts } from "./getSystemContracts"; import { getSystemManifest } from "./getSystemManifest"; export type GenerateSystemManifestOptions = { - readonly configPath: string; + readonly rootDir: string; readonly config: World; }; -export async function generateSystemManifest({ configPath, config }: GenerateSystemManifestOptions): Promise { - const systemContracts = await getSystemContracts({ configPath, config }); +export async function generateSystemManifest({ rootDir, config }: GenerateSystemManifestOptions): Promise { + const systemContracts = await getSystemContracts({ rootDir, config }); const systemManifest = getSystemManifest({ config, systemContracts }); // TODO: generate corresponding .json.d.ts? - const outputPath = path.join(path.dirname(configPath), config.metadataDirectory, "systems.json"); + const outputPath = path.join(rootDir, config.metadataDirectory, "systems.json"); // TODO: transform system source paths to be relative to manifest output path? diff --git a/packages/world/ts/node/getSystemContracts.ts b/packages/world/ts/node/getSystemContracts.ts index 21e5f7adc9..93c0aaa81f 100644 --- a/packages/world/ts/node/getSystemContracts.ts +++ b/packages/world/ts/node/getSystemContracts.ts @@ -7,15 +7,15 @@ export type SolidityContract = { }; export type GetSystemContractsOptions = { - readonly configPath: string; + readonly rootDir: string; readonly config: World; }; export async function getSystemContracts({ - configPath, + rootDir, config, }: GetSystemContractsOptions): Promise { - const solidityFiles = await findSolidityFiles({ configPath, config }); + const solidityFiles = await findSolidityFiles({ rootDir, config }); return solidityFiles .map((file) => ({ diff --git a/packages/world/ts/scripts/build.ts b/packages/world/ts/scripts/build.ts index be6f833a52..9ec3f54541 100644 --- a/packages/world/ts/scripts/build.ts +++ b/packages/world/ts/scripts/build.ts @@ -14,11 +14,12 @@ import { generateSystemManifest, worldgen } from "../node"; // TODO: do the same for store build too const configPath = await resolveConfigPath(); +const rootDir = path.dirname(configPath); const config = (await loadConfig(configPath)) as World; const remappings = await getRemappings(); // TODO: move this into worldgen -const existingContracts = (await findSolidityFiles({ configPath, config })).map((file) => ({ +const existingContracts = (await findSolidityFiles({ rootDir, config })).map((file) => ({ path: file.filename, basename: file.basename, })); @@ -37,5 +38,5 @@ await Promise.all([ existingContracts, codegenDirectory, ), - generateSystemManifest({ configPath, config }), + generateSystemManifest({ rootDir, config }), ]);