Skip to content

Commit

Permalink
configPath -> rootDir
Browse files Browse the repository at this point in the history
  • Loading branch information
holic committed Jul 4, 2024
1 parent 1ca67c3 commit 78f48c0
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 12 deletions.
2 changes: 1 addition & 1 deletion packages/cli/src/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
Expand Down
4 changes: 2 additions & 2 deletions packages/world/ts/node/findSolidityFiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => ({
Expand Down
8 changes: 4 additions & 4 deletions packages/world/ts/node/generateSystemManifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string> {
const systemContracts = await getSystemContracts({ configPath, config });
export async function generateSystemManifest({ rootDir, config }: GenerateSystemManifestOptions): Promise<string> {
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?

Expand Down
6 changes: 3 additions & 3 deletions packages/world/ts/node/getSystemContracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<readonly SolidityContract[]> {
const solidityFiles = await findSolidityFiles({ configPath, config });
const solidityFiles = await findSolidityFiles({ rootDir, config });

return solidityFiles
.map((file) => ({
Expand Down
5 changes: 3 additions & 2 deletions packages/world/ts/scripts/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}));
Expand All @@ -37,5 +38,5 @@ await Promise.all([
existingContracts,
codegenDirectory,
),
generateSystemManifest({ configPath, config }),
generateSystemManifest({ rootDir, config }),
]);

0 comments on commit 78f48c0

Please sign in to comment.