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 user-specified PostDeploy forge options #2703

Merged
merged 3 commits into from
Apr 25, 2024
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
5 changes: 5 additions & 0 deletions .changeset/three-zoos-laugh.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@latticexyz/cli": patch
---

Added a `--forgeScriptOptions` flag to deploy and dev commands to allow passing in additional CLI flags to `forge script` command.
1 change: 1 addition & 0 deletions packages/cli/src/commands/dev-contracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const devOptions = {
rpc: deployOptions.rpc,
configPath: deployOptions.configPath,
alwaysRunPostDeploy: deployOptions.alwaysRunPostDeploy,
forgeScriptOptions: deployOptions.forgeScriptOptions,
worldAddress: deployOptions.worldAddress,
};

Expand Down
3 changes: 2 additions & 1 deletion packages/cli/src/runDeploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export const deployOptions = {
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.",
},
forgeScriptOptions: { type: "string", description: "Options to pass to forge script PostDeploy.s.sol" },
salt: {
type: "string",
desc: "The deployment salt to use. Defaults to a random salt.",
Expand Down Expand Up @@ -113,7 +114,7 @@ in your contracts directory to use the default anvil private key.`,
withWorldProxy: configV2.deploy.useProxy,
});
if (opts.worldAddress == null || opts.alwaysRunPostDeploy) {
await postDeploy(config.postDeployScript, worldDeploy.address, rpc, profile);
await postDeploy(config.postDeployScript, worldDeploy.address, rpc, profile, opts.forgeScriptOptions);
}
console.log(chalk.green("Deployment completed in", (Date.now() - startTime) / 1000, "seconds"));

Expand Down
4 changes: 4 additions & 0 deletions packages/cli/src/utils/postDeploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ export async function postDeploy(
worldAddress: string,
rpc: string,
profile: string | undefined,
forgeOptions: string | undefined,
): Promise<void> {
// TODO: make this more robust as it is likely to fail for any args that have a space in them
const userOptions = forgeOptions?.replaceAll("\\", "").split(" ") ?? [];
const postDeployPath = path.join(await getScriptDirectory(), postDeployScript + ".s.sol");
if (!existsSync(postDeployPath)) {
console.log(`No script at ${postDeployPath}, skipping post deploy hook`);
Expand All @@ -37,6 +40,7 @@ export async function postDeploy(
"--rpc-url",
rpc,
"-vvv",
...userOptions,
],
{
profile: profile,
Expand Down
Loading