diff --git a/.changeset/metal-pots-notice.md b/.changeset/metal-pots-notice.md new file mode 100644 index 0000000000..37e977d7bc --- /dev/null +++ b/.changeset/metal-pots-notice.md @@ -0,0 +1,7 @@ +--- +"@latticexyz/cli": minor +--- + +Added a `--alwaysRunPostDeploy` flag to deploys (`deploy`, `test`, `dev-contracts` commands) to always run `PostDeploy.s.sol` script after each deploy. By default, `PostDeploy.s.sol` is only run once after a new world is deployed. + +This is helpful if you want to continue a deploy that may not have finished (due to an error or otherwise) or to run deploys with an idempotent `PostDeploy.s.sol` script. diff --git a/packages/cli/src/commands/dev-contracts.ts b/packages/cli/src/commands/dev-contracts.ts index 6ef7fd6da7..bcd13ddbe3 100644 --- a/packages/cli/src/commands/dev-contracts.ts +++ b/packages/cli/src/commands/dev-contracts.ts @@ -15,6 +15,7 @@ import { Address } from "viem"; const devOptions = { rpc: deployOptions.rpc, configPath: deployOptions.configPath, + alwaysRunPostDeploy: deployOptions.alwaysRunPostDeploy, }; const commandModule: CommandModule> = { @@ -74,6 +75,7 @@ const commandModule: CommandModule; export type DeployOptions = InferredOptionTypes; @@ -84,7 +88,7 @@ in your contracts directory to use the default anvil private key.` client, config: resolvedConfig, }); - if (opts.worldAddress == null) { + if (opts.worldAddress == null || opts.alwaysRunPostDeploy) { await postDeploy(config.postDeployScript, worldDeploy.address, rpc, profile); } console.log(chalk.green("Deployment completed in", (Date.now() - startTime) / 1000, "seconds"));