Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(cli): add --alwaysPostDeploy flag to deploys #1765

Merged
merged 6 commits into from
Oct 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/metal-pots-notice.md
Original file line number Diff line number Diff line change
@@ -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.
2 changes: 2 additions & 0 deletions packages/cli/src/commands/dev-contracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { Address } from "viem";
const devOptions = {
rpc: deployOptions.rpc,
configPath: deployOptions.configPath,
alwaysRunPostDeploy: deployOptions.alwaysRunPostDeploy,
};

const commandModule: CommandModule<typeof devOptions, InferredOptionTypes<typeof devOptions>> = {
Expand Down Expand Up @@ -74,6 +75,7 @@ const commandModule: CommandModule<typeof devOptions, InferredOptionTypes<typeof
}
// TODO: handle errors
const deploy = await runDeploy({
...opts,
configPath,
rpc,
skipBuild: false,
Expand Down
6 changes: 5 additions & 1 deletion packages/cli/src/runDeploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ export const deployOptions = {
worldAddress: { type: "string", desc: "Deploy to an existing World at the given address" },
srcDir: { type: "string", desc: "Source directory. Defaults to foundry src directory." },
skipBuild: { type: "boolean", desc: "Skip rebuilding the contracts before deploying" },
alwaysRunPostDeploy: {
type: "boolean",
desc: "Always run PostDeploy.s.sol after each deploy (including during upgrades). By default, PostDeploy.s.sol is only run once after a new world is deployed.",
},
} as const satisfies Record<string, Options>;

export type DeployOptions = InferredOptionTypes<typeof deployOptions>;
Expand Down Expand Up @@ -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"));
Expand Down