From 6d712ab1d4bbff27eb505f7212fb372d4ee8f26b Mon Sep 17 00:00:00 2001 From: Kevin Ingersoll Date: Wed, 3 Jul 2024 13:48:42 +0100 Subject: [PATCH] sort glob output --- packages/abi-ts/src/index.ts | 2 +- packages/cli/src/commands/set-version.ts | 5 ++++- packages/cli/src/deploy/findLibraries.ts | 6 +++--- packages/cli/src/utils/getExistingContracts.ts | 10 ++++++---- packages/cli/tsup.config.ts | 1 + packages/world-modules/ts/scripts/worldgen.ts | 10 ++++++---- packages/world/src/codegen/interfaces/IBaseWorld.sol | 6 +++--- packages/world/ts/scripts/worldgen.ts | 10 ++++++---- scripts/changelog.ts | 2 +- .../phaser/packages/art/scripts/export-tiled-types.ts | 2 +- 10 files changed, 32 insertions(+), 22 deletions(-) diff --git a/packages/abi-ts/src/index.ts b/packages/abi-ts/src/index.ts index a2e72d7aeb..7c859443d0 100644 --- a/packages/abi-ts/src/index.ts +++ b/packages/abi-ts/src/index.ts @@ -24,7 +24,7 @@ const commandModule: CommandModule = { }, handler({ input }) { - const files = globSync(input); + const files = globSync(input).sort(); if (!files.length) { console.error(`No files found for glob: ${input}`); diff --git a/packages/cli/src/commands/set-version.ts b/packages/cli/src/commands/set-version.ts index d270ebd694..c231139ab5 100644 --- a/packages/cli/src/commands/set-version.ts +++ b/packages/cli/src/commands/set-version.ts @@ -63,7 +63,10 @@ const commandModule: CommandModule = { } // Update all package.json below the current working directory (except in node_modules) - const packageJsons = globSync("**/package.json").filter((p) => !p.includes("node_modules")); + const packageJsons = globSync("**/package.json") + .filter((p) => !p.includes("node_modules")) + .sort(); + for (const packageJson of packageJsons) { updatePackageJson(packageJson, options); } diff --git a/packages/cli/src/deploy/findLibraries.ts b/packages/cli/src/deploy/findLibraries.ts index b2f4b1005e..40609a0f98 100644 --- a/packages/cli/src/deploy/findLibraries.ts +++ b/packages/cli/src/deploy/findLibraries.ts @@ -7,9 +7,9 @@ export function findLibraries(forgeOutDir: string): readonly { readonly path: string; readonly name: string; }[] { - const artifacts = globSync(`${forgeOutDir}/**/*.json`, { ignore: "**/*.abi.json" }).map((path) => - JSON.parse(readFileSync(path, "utf8")), - ); + const artifacts = globSync(`${forgeOutDir}/**/*.json`, { ignore: "**/*.abi.json" }) + .sort() + .map((path) => JSON.parse(readFileSync(path, "utf8"))); const libraries = artifacts.flatMap((artifact) => { if (!artifact.metadata) return []; diff --git a/packages/cli/src/utils/getExistingContracts.ts b/packages/cli/src/utils/getExistingContracts.ts index 9ee6373f43..c23a474da4 100644 --- a/packages/cli/src/utils/getExistingContracts.ts +++ b/packages/cli/src/utils/getExistingContracts.ts @@ -5,8 +5,10 @@ import { basename } from "path"; * Get a list of all contract paths/names within the provided src directory */ export function getExistingContracts(srcDir: string) { - return globSync(`${srcDir}/**/*.sol`).map((path) => ({ - path, - basename: basename(path, ".sol"), - })); + return globSync(`${srcDir}/**/*.sol`) + .sort() + .map((path) => ({ + path, + basename: basename(path, ".sol"), + })); } diff --git a/packages/cli/tsup.config.ts b/packages/cli/tsup.config.ts index 6479c4f403..3c4776d5a3 100644 --- a/packages/cli/tsup.config.ts +++ b/packages/cli/tsup.config.ts @@ -8,6 +8,7 @@ const mudWorkspace = path.normalize(`${__dirname}/../..`); const mudPackages: MudPackages = Object.fromEntries( globSync(path.join(mudWorkspace, `packages/*/package.json`)) + .sort() .map((filename) => [ path.relative(mudWorkspace, path.dirname(filename)), JSON.parse(readFileSync(filename, "utf8")), diff --git a/packages/world-modules/ts/scripts/worldgen.ts b/packages/world-modules/ts/scripts/worldgen.ts index eecb6ca59b..16852d9730 100644 --- a/packages/world-modules/ts/scripts/worldgen.ts +++ b/packages/world-modules/ts/scripts/worldgen.ts @@ -12,10 +12,12 @@ const clean = false; const srcDir = await getSrcDirectory(); // Get a list of all contract names -const existingContracts = globSync(`${srcDir}/**/*.sol`).map((path) => ({ - path, - basename: basename(path, ".sol"), -})); +const existingContracts = globSync(`${srcDir}/**/*.sol`) + .sort() + .map((path) => ({ + path, + basename: basename(path, ".sol"), + })); // Load and resolve the config const mudConfig = (await loadConfig(configPath)) as WorldConfig; diff --git a/packages/world/src/codegen/interfaces/IBaseWorld.sol b/packages/world/src/codegen/interfaces/IBaseWorld.sol index a30241297a..9d2ba9e356 100644 --- a/packages/world/src/codegen/interfaces/IBaseWorld.sol +++ b/packages/world/src/codegen/interfaces/IBaseWorld.sol @@ -6,12 +6,12 @@ pragma solidity >=0.8.24; import { IStore } from "@latticexyz/store/src/IStore.sol"; import { IWorldKernel } from "../../IWorldKernel.sol"; +import { IRegistrationSystem } from "./IRegistrationSystem.sol"; import { IAccessManagementSystem } from "./IAccessManagementSystem.sol"; import { IBalanceTransferSystem } from "./IBalanceTransferSystem.sol"; import { IBatchCallSystem } from "./IBatchCallSystem.sol"; import { IModuleInstallationSystem } from "./IModuleInstallationSystem.sol"; import { IWorldRegistrationSystem } from "./IWorldRegistrationSystem.sol"; -import { IRegistrationSystem } from "./IRegistrationSystem.sol"; /** * @title IBaseWorld @@ -23,10 +23,10 @@ import { IRegistrationSystem } from "./IRegistrationSystem.sol"; interface IBaseWorld is IStore, IWorldKernel, + IRegistrationSystem, IAccessManagementSystem, IBalanceTransferSystem, IBatchCallSystem, IModuleInstallationSystem, - IWorldRegistrationSystem, - IRegistrationSystem + IWorldRegistrationSystem {} diff --git a/packages/world/ts/scripts/worldgen.ts b/packages/world/ts/scripts/worldgen.ts index 109315dae3..366db3fae8 100644 --- a/packages/world/ts/scripts/worldgen.ts +++ b/packages/world/ts/scripts/worldgen.ts @@ -12,10 +12,12 @@ const clean = false; const srcDir = await getSrcDirectory(); // Get a list of all contract names -const existingContracts = globSync(`${srcDir}/**/*.sol`).map((path) => ({ - path, - basename: basename(path, ".sol"), -})); +const existingContracts = globSync(`${srcDir}/**/*.sol`) + .sort() + .map((path) => ({ + path, + basename: basename(path, ".sol"), + })); // Load and resolve the config const mudConfig = (await loadConfig(configPath)) as WorldConfig; diff --git a/scripts/changelog.ts b/scripts/changelog.ts index 4a4a97bc63..3dbc23f14f 100644 --- a/scripts/changelog.ts +++ b/scripts/changelog.ts @@ -120,7 +120,7 @@ async function getChanges(include: "diff" | "all") { ); } else if (include === "all") { // Load all current changesets from the .changeset dir - const changesetsToInclude = globSync(".changeset/*.md"); + const changesetsToInclude = globSync(".changeset/*.md").sort(); // Load the contents of each changeset from file and metadata from git changesetContents = await Promise.all( diff --git a/templates/phaser/packages/art/scripts/export-tiled-types.ts b/templates/phaser/packages/art/scripts/export-tiled-types.ts index 0c7fff5758..d54d207798 100644 --- a/templates/phaser/packages/art/scripts/export-tiled-types.ts +++ b/templates/phaser/packages/art/scripts/export-tiled-types.ts @@ -4,7 +4,7 @@ import { globSync } from "glob"; import ejs from "ejs"; import path from "path"; -const tilemaps = globSync("./tilesets/*.tsx"); +const tilemaps = globSync("./tilesets/*.tsx").sort(); enum PropertyName { Name = "name",